You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
6.1 KiB

1 month ago
  1. {"ast":null,"code":"import { useAttrs, useSlots, computed } from 'vue';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nfunction useInputTagDom({\n props,\n isFocused,\n hovering,\n disabled,\n inputValue,\n size,\n validateState,\n validateIcon,\n needStatusIcon\n}) {\n const attrs = useAttrs();\n const slots = useSlots();\n const ns = useNamespace(\"input-tag\");\n const nsInput = useNamespace(\"input\");\n const containerKls = computed(() => [ns.b(), ns.is(\"focused\", isFocused.value), ns.is(\"hovering\", hovering.value), ns.is(\"disabled\", disabled.value), ns.m(size.value), ns.e(\"wrapper\"), attrs.class]);\n const containerStyle = computed(() => [attrs.style]);\n const innerKls = computed(() => {\n var _a, _b;\n return [ns.e(\"inner\"), ns.is(\"draggable\", props.draggable), ns.is(\"left-space\", !((_a = props.modelValue) == null ? void 0 : _a.length) && !slots.prefix), ns.is(\"right-space\", !((_b = props.modelValue) == null ? void 0 : _b.length) && !showSuffix.value)];\n });\n const showClear = computed(() => {\n var _a;\n return props.clearable && !disabled.value && !props.readonly && (((_a = props.modelValue) == null ? void 0 : _a.length) || inputValue.value) && (isFocused.value || hovering.value);\n });\n const showSuffix = computed(() => {\n return slots.suffix || showClear.value || validateState.value && validateIcon.value && needStatusIcon.value;\n });\n return {\n ns,\n nsInput,\n containerKls,\n containerStyle,\n innerKls,\n showClear,\n showSuffix\n };\n}\nexport { useInputTagDom };","map":{"version":3,"names":["useInputTagDom","props","isFocused","hovering","disabled","inputValue","size","validateState","validateIcon","needStatusIcon","attrs","useAttrs","slots","useSlots","ns","useNamespace","nsInput","containerKls","computed","b","is","value","m","e","class","containerStyle","style","innerKls","_a","_b","draggable","modelValue","length","prefix","showSuffix","showClear","clearable","readonly","suffix"],"sources":["../../../../../../../packages/components/input-tag/src/composables/use-input-tag-dom.ts"],"sourcesContent":["import { computed, useAttrs, useSlots } from 'vue'\nimport { useNamespace } from '@element-plus/hooks'\nimport type { ComputedRef, Ref, StyleValue } from 'vue'\nimport type { ComponentSize } from '@element-plus/constants'\nimport type { InputTagProps } from '../input-tag'\n\ninterface UseInputTagDomOptions {\n props: InputTagProps\n isFocused: Ref<boolean>\n hovering: Ref<boolean>\n disabled: ComputedRef<boolean>\n inputValue: Ref<string | undefined>\n size: ComputedRef<ComponentSize>\n validateState: ComputedRef<string>\n validateIcon: ComputedRef<boolean>\n needStatusIcon: ComputedRef<boolean>\n}\n\nexport function useInputTagDom({\n props,\n isFocused,\n hovering,\n disabled,\n inputValue,\n size,\n validateState,\n validateIcon,\n needStatusIcon,\n}: UseInputTagDomOptions) {\n const attrs = useAttrs()\n const slots = useSlots()\n const ns = useNamespace('input-tag')\n const nsInput = useNamespace('input')\n\n const containerKls = computed(() => [\n ns.b(),\n ns.is('focused', isFocused.value),\n ns.is('hovering', hovering.value),\n ns.is('disabled', disabled.value),\n ns.m(size.value),\n ns.e('wrapper'),\n attrs.class,\n ])\n const containerStyle = computed<StyleValue>(() => [attrs.style as StyleValue])\n const innerKls = computed(() => [\n ns.e('inner'),\n ns.is('draggable', props.draggable),\n ns.is('left-space', !props.modelValue?.length && !slots.prefix),\n ns.is('right-space', !props.modelValue?.length && !showSuffix.value),\n ])\n const showClear = computed(() => {\n return (\n props.clearable &&\n !disabled.value &&\n !props.readonly &&\n (props.modelValue?.length || inputValue.value) &&\n (isFocused.value || hovering.value)\n )\n })\n const showSuffix = computed(() => {\n return (\n slots.suffix ||\n showClear.value ||\n (validateState.value && validateIcon.value && needStatusI