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.

1 lines
86 KiB

{"ast":null,"code":"import { reactive, ref, computed, nextTick, watch, watchEffect, onMounted } from 'vue';\nimport { debounce, get, findLastIndex, isEqual } from 'lodash-unified';\nimport { useResizeObserver } from '@vueuse/core';\nimport { ArrowDown } from '@element-plus/icons-vue';\nimport { useAllowCreate } from './useAllowCreate.mjs';\nimport { useProps } from './useProps.mjs';\nimport { useLocale } from '../../../hooks/use-locale/index.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { useFormItem, useFormItemInputId } from '../../form/src/hooks/use-form-item.mjs';\nimport { useEmptyValues } from '../../../hooks/use-empty-values/index.mjs';\nimport { useComposition } from '../../../hooks/use-composition/index.mjs';\nimport { useFocusController } from '../../../hooks/use-focus-controller/index.mjs';\nimport { isArray, isObject, isFunction } from '@vue/shared';\nimport { ValidateComponentsMap } from '../../../utils/vue/icon.mjs';\nimport { useFormSize } from '../../form/src/hooks/use-form-common-props.mjs';\nimport { EVENT_CODE } from '../../../constants/aria.mjs';\nimport { debugWarn } from '../../../utils/error.mjs';\nimport { isNumber } from '../../../utils/types.mjs';\nimport { UPDATE_MODEL_EVENT, CHANGE_EVENT } from '../../../constants/event.mjs';\nimport { escapeStringRegexp } from '../../../utils/strings.mjs';\nconst useSelect = (props, emit) => {\n const {\n t\n } = useLocale();\n const nsSelect = useNamespace(\"select\");\n const nsInput = useNamespace(\"input\");\n const {\n form: elForm,\n formItem: elFormItem\n } = useFormItem();\n const {\n inputId\n } = useFormItemInputId(props, {\n formItemContext: elFormItem\n });\n const {\n aliasProps,\n getLabel,\n getValue,\n getDisabled,\n getOptions\n } = useProps(props);\n const {\n valueOnClear,\n isEmptyValue\n } = useEmptyValues(props);\n const states = reactive({\n inputValue: \"\",\n cachedOptions: [],\n createdOptions: [],\n hoveringIndex: -1,\n inputHovering: false,\n selectionWidth: 0,\n collapseItemWidth: 0,\n previousQuery: null,\n previousValue: void 0,\n selectedLabel: \"\",\n menuVisibleOnFocus: false,\n isBeforeHide: false\n });\n const popperSize = ref(-1);\n const selectRef = ref();\n const selectionRef = ref();\n const tooltipRef = ref();\n const tagTooltipRef = ref();\n const inputRef = ref();\n const prefixRef = ref();\n const suffixRef = ref();\n const menuRef = ref();\n const tagMenuRef = ref();\n const collapseItemRef = ref();\n const {\n isComposing,\n handleCompositionStart,\n handleCompositionEnd,\n handleCompositionUpdate\n } = useComposition({\n afterComposition: e => onInput(e)\n });\n const {\n wrapperRef,\n isFocused,\n handleBlur\n } = useFocusController(inputRef, {\n beforeFocus() {\n return selectDisabled.value;\n },\n afterFocus() {\n if (props.automaticDropdown && !expanded.value) {\n expanded.value = true;\n states.menuVisibleOnFocus = true;\n }\n },\n beforeBlur(event) {\n var _a, _b;\n return ((_a = tooltipRef.value) == null ? void 0 : _a.isFocusInsideContent(event)) || ((_b = tagTooltipRef.value) == null ? void 0 : _b.isFocusInsideContent(event));\n },\n afterBlur() {\n expanded.value = false;\n states.menuVisibleOnFocus = false;\n }\n });\n const allOptions = ref([]);\n const filteredOptions = ref([]);\n const expanded = ref(false);\n const selectDisabled = computed(() => props.disabled || (elForm == null ? void 0 : elForm.disabled));\n const needStatusIcon = computed(() => {\n var _a;\n return (_a = elForm == null ? void 0 : elForm.statusIcon) != null ? _a : false;\n });\n const popupHeight = computed(() => {\n const totalHeight = filteredOptions.value.length * props.itemHeight;\n return totalHeight > props.height ? props.height : totalHeight;\n });\n const hasModelValue = computed(() => {\n return props.multiple ? isArray(props.modelValue) && props.modelValue.length > 0 : !isEmptyValue(props.modelValue);\n });\n const showClearBtn = computed(() => {\n return props.clearable && !selectDisabled.value && states.inputHovering && hasModelValue.value;\n });\n const iconComponent = computed(() => props.remote && props.filterable ? \"\" : ArrowDown);\n const iconReverse = computed(() => iconComponent.value && nsSelect.is(\"reverse\", expanded.value));\n const validateState = computed(() => (elFormItem == null ? void 0 : elFormItem.validateState) || \"\");\n const validateIcon = computed(() => {\n if (!validateState.value) return;\n return ValidateComponentsMap[validateState.value];\n });\n const debounce$1 = computed(() => props.remote ? 300 : 0);\n const emptyText = computed(() => {\n if (props.loading) {\n return props.loadingText || t(\"el.select.loading\");\n } else {\n if (props.remote && !states.inputValue && allOptions.value.length === 0) return false;\n if (props.filterable && states.inputValue && allOptions.value.length > 0 && filteredOptions.value.length === 0) {\n return props.noMatchText || t(\"el.select.noMatch\");\n }\n if (allOptions.value.length === 0) {\n return props.noDataText || t(\"el.select.noData\");\n }\n }\n return null;\n });\n const filterOptions = query => {\n const isValidOption = o => {\n if (props.filterable && isFunction(props.filterMethod)) return true;\n if (props.filterable && props.remote && isFunction(props.remoteMethod)) return true;\n const regexp = new RegExp(escapeStringRegexp(query), \"i\");\n return query ? regexp.test(getLabel(o) || \"\") : true;\n };\n if (props.loading) {\n return [];\n }\n return [...states.createdOptions, ...props.options].reduce((all, item) => {\n const options = getOptions(item);\n if (isArray(options)) {\n const filtered = options.filter(isValidOption);\n if (filtered.length > 0) {\n all.push({\n label: getLabel(item),\n type: \"Group\"\n }, ...filtered);\n }\n } else if (props.remote || isValidOption(item)) {\n all.push(item);\n }\n return all;\n }, []);\n };\n const updateOptions = () => {\n allOptions.value = filterOptions(\"\");\n filteredOptions.value = filterOptions(states.inputValue);\n };\n const allOptionsValueMap = computed(() => {\n const valueMap = /* @__PURE__ */new Map();\n allOptions.value.forEach((option, index) => {\n valueMap.set(getValueKey(getValue(option)), {\n option,\n index\n });\n });\n return valueMap;\n });\n const filteredOptionsValueMap = computed(() => {\n const valueMap = /* @__PURE__ */new Map();\n filteredOptions.value.forEach((option, index) => {\n valueMap.set(getValueKey(getValue(option)), {\n option,\n index\n });\n });\n return valueMap;\n });\n const optionsAllDisabled = computed(() => filteredOptions.value.every(option => getDisabled(option)));\n const selectSize = useFormSize();\n const collapseTagSize = computed(() => selectSize.value === \"small\" ? \"small\" : \"default\");\n const calculatePopperSize = () => {\n var _a;\n if (isNumber(props.fitInputWidth)) {\n popperSize.value = props.fitInputWidth;\n return;\n }\n const width = ((_a = selectRef.value) == null ? void 0 : _a.offsetWidth) || 200;\n if (!props.fitInputWidth && allOptions.value.length > 0) {\n nextTick(() => {\n popperSize.value = Math.max(width, calculateLabelMaxWidth());\n });\n } else {\n popperSize.value = width;\n }\n };\n const calculateLabelMaxWidth = () => {\n var _a, _b;\n const canvas = document.createElement(\"canvas\");\n const ctx = canvas.getContext(\"2d\");\n const selector = nsSelect.be(\"dropdown\", \"item\");\n const dom = ((_b = (_a = menuRef.value) == null ? void 0 : _a.listRef) == null ? void 0 : _b.innerRef) || document;\n const dropdownItemEl = dom.querySelector(`.${selector}`);\n if (dropdownItemEl === null || ctx === null) return 0;\n const style = getComputedStyle(dropdownItemEl);\n const padding = Number.parseFloat(style.paddingLeft) + Number.parseFloat(style.paddingRight);\n ctx.font = style.font;\n const maxWidth = filteredOptions.value.reduce((max, option) => {\n const metrics = ctx.measureText(getLabel(option));\n return Math.max(metrics.width, max);\n }, 0);\n return maxWidth + padding;\n };\n const getGapWidth = () => {\n if (!selectionRef.value) return 0;\n const style = window.getComputedStyle(selectionRef.value);\n return Number.parseFloat(style.gap || \"6px\");\n };\n const tagStyle = computed(() => {\n const gapWidth = getGapWidth();\n const maxWidth = collapseItemRef.value && props.maxCollapseTags === 1 ? states.selectionWidth - states.collapseItemWidth - gapWidth : states.selectionWidth;\n return {\n maxWidth: `${maxWidth}px`\n };\n });\n const collapseTagStyle = computed(() => {\n return {\n maxWidth: `${states.selectionWidth}px`\n };\n });\n const shouldShowPlaceholder = computed(() => {\n if (isArray(props.modelValue)) {\n return props.modelValue.length === 0 && !states.inputValue;\n }\n return props.filterable ? !states.inputValue : true;\n });\n const currentPlaceholder = computed(() => {\n var _a;\n const _placeholder = (_a = props.placeholder) != null ? _a : t(\"el.select.placeholder\");\n return props.multiple || !hasModelValue.value ? _placeholder : states.selectedLabel;\n });\n const popperRef = computed(() => {\n var _a, _b;\n return (_b = (_a = tooltipRef.value) == null ? void 0 : _a.popperRef) == null ? void 0 : _b.contentRef;\n });\n const indexRef = computed(() => {\n if (props.multiple) {\n const len = props.modelValue.length;\n if (props.modelValue.length > 0 && filteredOptionsValueMap.value.has(props.modelValue[len - 1])) {\n const {\n index\n } = filteredOptionsValueMap.value.get(props.modelValue[len - 1]);\n return index;\n }\n } else {\n if (!isEmptyValue(props.modelValue) && filteredOptionsValueMap.value.has(props.modelValue)) {\n const {\n index\n } = filteredOptionsValueMap.value.get(props.modelValue);\n return index;\n }\n }\n return -1;\n });\n const dropdownMenuVisible = computed({\n get() {\n return expanded.value && emptyText.value !== false;\n },\n set(val) {\n expanded.value = val;\n }\n });\n const showTagList = computed(() => {\n if (!props.multiple) {\n return [];\n }\n return props.collapseTags ? states.cachedOptions.slice(0, props.maxCollapseTags) : states.cachedOptions;\n });\n const collapseTagList = computed(() => {\n if (!props.multiple) {\n return [];\n }\n return props.collapseTags ? states.cachedOptions.slice(props.maxCollapseTags) : [];\n });\n const {\n createNewOption,\n removeNewOption,\n selectNewOption,\n clearAllNewOption\n } = useAllowCreate(props, states);\n const toggleMenu = () => {\n if (selectDisabled.value) return;\n if (states.menuVisibleOnFocus) {\n states.menuVisibleOnFocus = false;\n } else {\n expanded.value = !expanded.value;\n }\n };\n const onInputChange = () => {\n if (states.inputValue.length > 0 && !expanded.value) {\n expanded.value = true;\n }\n createNewOption(states.inputValue);\n handleQueryChange(states.inputValue);\n };\n const debouncedOnInputChange = debounce(onInputChange, debounce$1.value);\n const handleQueryChange = val => {\n if (states.previousQuery === val || isComposing.value) {\n return;\n }\n states.previousQuery = val;\n if (props.filterable && isFunction(props.filterMethod)) {\n props.filterMethod(val);\n } else if (props.filterable && props.remote && isFunction(props.remoteMethod)) {\n props.remoteMethod(val);\n }\n if (props.defaultFirstOption && (props.filterable || props.remote) && filteredOptions.value.length) {\n nextTick(checkDefaultFirstOption);\n } else {\n nextTick(updateHoveringIndex);\n }\n };\n const checkDefaultFirstOption = () => {\n const optionsInDropdown = filteredOptions.value.filter(n => !n.disabled && n.type !== \"Group\");\n const userCreatedOption = optionsInDropdown.find(n => n.created);\n const firstOriginOption = optionsInDropdown[0];\n states.hoveringIndex = getValueIndex(filteredOptions.value, userCreatedOption || firstOriginOption);\n };\n const emitChange = val => {\n if (!isEqual(props.modelValue, val)) {\n emit(CHANGE_EVENT, val);\n }\n };\n const update = val => {\n emit(UPDATE_MODEL_EVENT, val);\n emitChange(val);\n states.previousValue = props.multiple ? String(val) : val;\n };\n const getValueIndex = (arr = [], value) => {\n if (!isObject(value)) {\n return arr.indexOf(value);\n }\n const valueKey = props.valueKey;\n let index = -1;\n arr.some((item, i) => {\n if (get(item, valueKey) === get(value, valueKey)) {\n index = i;\n return true;\n }\n return false;\n });\n return index;\n };\n const getValueKey = item => {\n return isObject(item) ? get(item, props.valueKey) : item;\n };\n const handleResize = () => {\n calculatePopperSize();\n };\n const resetSelectionWidth = () => {\n states.selectionWidth = selectionRef.value.getBoundingClientRect().width;\n };\n const resetCollapseItemWidth = () => {\n states.collapseItemWidth = collapseItemRef.value.getBoundingClientRect().width;\n };\n const updateTooltip = () => {\n var _a, _b;\n (_b = (_a = tooltipRef.value) == null ? void 0 : _a.updatePopper) == null ? void 0 : _b.call(_a);\n };\n const updateTagTooltip = () => {\n var _a, _b;\n (_b = (_a = tagTooltipRef.value) == null ? void 0 : _a.updatePopper) == null ? void 0 : _b.call(_a);\n };\n const onSelect = option => {\n if (props.multiple) {\n let selectedOptions = props.modelValue.slice();\n const index = getValueIndex(selectedOptions, getValue(option));\n if (index > -1) {\n selectedOptions = [...selectedOptions.slice(0, index), ...selectedOptions.slice(index + 1)];\n states.cachedOptions.splice(index, 1);\n removeNewOption(option);\n } else if (props.multipleLimit <= 0 || selectedOptions.length < props.multipleLimit) {\n selectedOptions = [...selectedOptions, getValue(option)];\n states.cachedOptions.push(option);\n selectNewOption(option);\n }\n update(selectedOptions);\n if (option.created) {\n handleQueryChange(\"\");\n }\n if (props.filterable && !props.reserveKeyword) {\n states.inputValue = \"\";\n }\n } else {\n states.selectedLabel = getLabel(option);\n update(getValue(option));\n expanded.value = false;\n selectNewOption(option);\n if (!option.created) {\n clearAllNewOption();\n }\n }\n focus();\n };\n const deleteTag = (event, option) => {\n let selectedOptions = props.modelValue.slice();\n const index = getValueIndex(selectedOptions, getValue(option));\n if (index > -1 && !selectDisabled.value) {\n selectedOptions = [...props.modelValue.slice(0, index), ...props.modelValue.slice(index + 1)];\n states.cachedOptions.splice(index, 1);\n update(selectedOptions);\n emit(\"remove-tag\", getValue(option));\n removeNewOption(option);\n }\n event.stopPropagation();\n focus();\n };\n const focus = () => {\n var _a;\n (_a = inputRef.value) == null ? void 0 : _a.focus();\n };\n const blur = () => {\n var _a;\n if (expanded.value) {\n expanded.value = false;\n nextTick(() => {\n var _a2;\n return (_a2 = inputRef.value) == null ? void 0 : _a2.blur();\n });\n return;\n }\n (_a = inputRef.value) == null ? void 0 : _a.blur();\n };\n const handleEsc = () => {\n if (states.inputValue.length > 0) {\n states.inputValue = \"\";\n } else {\n expanded.value = false;\n }\n };\n const getLastNotDisabledIndex = value => findLastIndex(value, it => !states.cachedOptions.some(option => getValue(option) === it && getDisabled(option)));\n const handleDel = e => {\n if (!props.multiple) return;\n if (e.code === EVENT_CODE.delete) return;\n if (states.inputValue.length === 0) {\n e.preventDefault();\n const selected = props.modelValue.slice();\n const lastNotDisabledIndex = getLastNotDisabledIndex(selected);\n if (lastNotDisabledIndex < 0) return;\n const removeTagValue = selected[lastNotDisabledIndex];\n selected.splice(lastNotDisabledIndex, 1);\n const option = states.cachedOptions[lastNotDisabledIndex];\n states.cachedOptions.splice(lastNotDisabledIndex, 1);\n removeNewOption(option);\n update(selected);\n emit(\"remove-tag\", removeTagValue);\n }\n };\n const handleClear = () => {\n let emptyValue;\n if (isArray(props.modelValue)) {\n emptyValue = [];\n } else {\n emptyValue = valueOnClear.value;\n }\n if (props.multiple) {\n states.cachedOptions = [];\n } else {\n states.selectedLabel = \"\";\n }\n expanded.value = false;\n update(emptyValue);\n emit(\"clear\");\n clearAllNewOption();\n focus();\n };\n const onKeyboardNavigate = (direction, hoveringIndex = void 0) => {\n const options = filteredOptions.value;\n if (![\"forward\", \"backward\"].includes(direction) || selectDisabled.value || options.length <= 0 || optionsAllDisabled.value || isComposing.value) {\n return;\n }\n if (!expanded.value) {\n return toggleMenu();\n }\n if (hoveringIndex === void 0) {\n hoveringIndex = states.hoveringIndex;\n }\n let newIndex = -1;\n if (direction === \"forward\") {\n newIndex = hoveringIndex + 1;\n if (newIndex >= options.length) {\n newIndex = 0;\n }\n } else if (direction === \"backward\") {\n newIndex = hoveringIndex - 1;\n if (newIndex < 0 || newIndex >= options.length) {\n newIndex = options.length - 1;\n }\n }\n const option = options[newIndex];\n if (getDisabled(option) || option.type === \"Group\") {\n return onKeyboardNavigate(direction, newIndex);\n } else {\n states.hoveringIndex = newIndex;\n scrollToItem(newIndex);\n }\n };\n const onKeyboardSelect = () => {\n if (!expanded.value) {\n return toggleMenu();\n } else if (~states.hoveringIndex && filteredOptions.value[states.hoveringIndex]) {\n onSelect(filteredOptions.value[states.hoveringIndex]);\n }\n };\n const onHoverOption = idx => {\n states.hoveringIndex = idx != null ? idx : -1;\n };\n const updateHoveringIndex = () => {\n if (!props.multiple) {\n states.hoveringIndex = filteredOptions.value.findIndex(item => {\n return getValueKey(item) === getValueKey(props.modelValue);\n });\n } else {\n states.hoveringIndex = filteredOptions.value.findIndex(item => props.modelValue.some(modelValue => getValueKey(modelValue) === getValueKey(item)));\n }\n };\n const onInput = event => {\n states.inputValue = event.target.value;\n if (props.remote) {\n debouncedOnInputChange();\n } else {\n return onInputChange();\n }\n };\n const handleClickOutside = event => {\n expanded.value = false;\n if (isFocused.value) {\n const _event = new FocusEvent(\"focus\", event);\n handleBlur(_event);\n }\n };\n const handleMenuEnter = () => {\n states.isBeforeHide = false;\n return nextTick(() => {\n if (~indexRef.value) {\n scrollToItem(states.hoveringIndex);\n }\n });\n };\n const scrollToItem = index => {\n menuRef.value.scrollToItem(index);\n };\n const getOption = (value, cachedOptions) => {\n const selectValue = getValueKey(value);\n if (allOptionsValueMap.value.has(selectValue)) {\n const {\n option\n } = allOptionsValueMap.value.get(selectValue);\n return option;\n }\n if (cachedOptions && cachedOptions.length) {\n const option = cachedOptions.find(option2 => getValueKey(getValue(option2)) === selectValue);\n if (option) {\n return option;\n }\n }\n return {\n [aliasProps.value.value]: value,\n [aliasProps.value.label]: value\n };\n };\n const initStates = (needUpdateSelectedLabel = false) => {\n if (props.multiple) {\n if (props.modelValue.length > 0) {\n const cachedOptions = states.cachedOptions.slice();\n states.cachedOptions.length = 0;\n states.previousValue = props.modelValue.toString();\n for (const value of props.modelValue) {\n const option = getOption(value, cachedOptions);\n states.cachedOptions.push(option);\n }\n } else {\n states.cachedOptions = [];\n states.previousValue = void 0;\n }\n } else {\n if (hasModelValue.value) {\n states.previousValue = props.modelValue;\n const options = filteredOptions.value;\n const selectedItemIndex = options.findIndex(option => getValueKey(getValue(option)) === getValueKey(props.modelValue));\n if (~selectedItemIndex) {\n states.selectedLabel = getLabel(options[selectedItemIndex]);\n } else {\n if (!states.selectedLabel || needUpdateSelectedLabel) {\n states.selectedLabel = getValueKey(props.modelValue);\n }\n }\n } else {\n states.selectedLabel = \"\";\n states.previousValue = void 0;\n }\n }\n clearAllNewOption();\n calculatePopperSize();\n };\n watch(() => props.fitInputWidth, () => {\n calculatePopperSize();\n });\n watch(expanded, val => {\n if (val) {\n if (!props.persistent) {\n calculatePopperSize();\n }\n handleQueryChange(\"\");\n } else {\n states.inputValue = \"\";\n states.previousQuery = null;\n states.isBeforeHide = true;\n createNewOption(\"\");\n }\n emit(\"visible-change\", val);\n });\n watch(() => props.modelValue, (val, oldVal) => {\n var _a;\n const isValEmpty = !val || isArray(val) && val.length === 0;\n if (isValEmpty || props.multiple && !isEqual(val.toString(), states.previousValue) || !props.multiple && getValueKey(val) !== getValueKey(states.previousValue)) {\n initStates(true);\n }\n if (!isEqual(val, oldVal) && props.validateEvent) {\n (_a = elFormItem == null ? void 0 : elFormItem.validate) == null ? void 0 : _a.call(elFormItem, \"change\").catch(err => debugWarn(err));\n }\n }, {\n deep: true\n });\n watch(() => props.options, () => {\n const input = inputRef.value;\n if (!input || input && document.activeElement !== input) {\n initStates();\n }\n }, {\n deep: true,\n flush: \"post\"\n });\n watch(() => filteredOptions.value, () => {\n calculatePopperSize();\n return menuRef.value && nextTick(menuRef.value.resetScrollTop);\n });\n watchEffect(() => {\n if (states.isBeforeHide) return;\n updateOptions();\n });\n watchEffect(() => {\n const {\n valueKey,\n options\n } = props;\n const duplicateValue = /* @__PURE__ */new Map();\n for (const item of options) {\n const optionValue = getValue(item);\n let v = optionValue;\n if (isObject(v)) {\n v = get(optionValue, valueKey);\n }\n if (duplicateValue.get(v)) {\n debugWarn(\"ElSelectV2\", `The option values you provided seem to be duplicated, which may cause some problems, please check.`);\n break;\n } else {\n duplicateValue.set(v, true);\n }\n }\n });\n onMounted(() => {\n initStates();\n });\n useResizeObserver(selectRef, handleResize);\n useResizeObserver(selectionRef, resetSelectionWidth);\n useResizeObserver(menuRef, updateTooltip);\n useResizeObserver(wrapperRef, updateTooltip);\n useResizeObserver(tagMenuRef, updateTagTooltip);\n useResizeObserver(collapseItemRef, resetCollapseItemWidth);\n return {\n inputId,\n collapseTagSize,\n currentPlaceholder,\n expanded,\n emptyText,\n popupHeight,\n debounce: debounce$1,\n allOptions,\n filteredOptions,\n iconComponent,\n iconReverse,\n tagStyle,\n collapseTagStyle,\n popperSize,\n dropdownMenuVisible,\n hasModelValue,\n shouldShowPlaceholder,\n selectDisabled,\n selectSize,\n needStatusIcon,\n showClearBtn,\n states,\n isFocused,\n nsSelect,\n nsInput,\n inputRef,\n menuRef,\n tagMenuRef,\n tooltipRef,\n tagTooltipRef,\n selectRef,\n wrapperRef,\n selectionRef,\n prefixRef,\n suffixRef,\n collapseItemRef,\n popperRef,\n validateState,\n validateIcon,\n showTagList,\n collapseTagList,\n debouncedOnInputChange,\n deleteTag,\n getLabel,\n getValue,\n getDisabled,\n getValueKey,\n handleClear,\n handleClickOutside,\n handleDel,\n handleEsc,\n focus,\n blur,\n handleMenuEnter,\n handleResize,\n resetSelectionWidth,\n updateTooltip,\n updateTagTooltip,\n updateOptions,\n toggleMenu,\n scrollTo: scrollToItem,\n onInput,\n onKeyboardNavigate,\n onKeyboardSelect,\n onSelect,\n onHover: onHoverOption,\n handleCompositionStart,\n handleCompositionEnd,\n handleCompositionUpdate\n };\n};\nexport { useSelect as default };","map":{"version":3,"names":["useSelect","props","emit","t","useLocale","nsSelect","useNamespace","nsInput","form","elForm","formItem","elFormItem","useFormItem","inputId","useFormItemInputId","formItemContext","aliasProps","getLabel","getValue","getDisabled","getOptions","useProps","valueOnClear","isEmptyValue","useEmptyValues","states","reactive","inputValue","cachedOptions","createdOptions","hoveringIndex","inputHovering","selectionWidth","collapseItemWidth","previousQuery","previousValue","selectedLabel","menuVisibleOnFocus","isBeforeHide","popperSize","ref","selectRef","selectionRef","tooltipRef","tagTooltipRef","inputRef","prefixRef","suffixRef","menuRef","tagMenuRef","collapseItemRef","isComposing","handleCompositionStart","handleCompositionEnd","handleCompositionUpdate","useComposition","afterComposition","e","onInput","wrapperRef","isFocused","handleBlur","useFocusController","beforeFocus","selectDisabled","value","afterFocus","automaticDropdown","expanded","beforeBlur","event","_a","_b","isFocusInsideContent","afterBlur","allOptions","filteredOptions","computed","disabled","needStatusIcon","statusIcon","popupHeight","totalHeight","length","itemHeight","height","hasModelValue","multiple","isArray","modelValue","showClearBtn","clearable","iconComponent","remote","filterable","ArrowDown","iconReverse","is","validateState","validateIcon","ValidateComponentsMap","debounce$1","emptyText","loading","loadingText","noMatchText","noDataText","filterOptions","query","isValidOption","o","isFunction","filterMethod","remoteMethod","regexp","RegExp","escapeStringRegexp","test","options","reduce","all","item","filtered","filter","push","label","type","updateOptions","allOptionsValueMap","valueMap","Map","forEach","option","index","set","getValueKey","filteredOptionsValueMap","optionsAllDisabled","every","selectSize","useFormSize","collapseTagSize","calculatePopperSize","isNumber","fitInputWidth","width","offsetWidth","nextTick","Math","max","calculateLabelMaxWidth","canvas","document","createElement","ctx","getContext","selector","be","dom","listRef","innerRef","dropdownItemEl","querySelector","style","getComputedStyle","padding","Number","parseFloat","paddingLeft","paddingRight","font","maxWidth","metrics","measureText","getGapWidth","window","gap","tagStyle","gapWidth","maxCollapseTags","collapseTagStyle","shouldShowPlaceholder","currentPlaceholder","_placeholder","placeholder","popperRef","contentRef","indexRef","len","has","get","dropdownMenuVisible","val","showTagList","collapseTags","slice","collapseTagList","createNewOption","removeNewOption","selectNewOption","clearAllNewOption","useAllowCreate","toggleMenu","onInputChange","handleQueryChange","debouncedOnInputChange","debounce","defaultFirstOption","checkDefaultFirstOption","updateHoveringIndex","optionsInDropdown","n","userCreatedOption","find","created","firstOriginOption","getValueIndex","emitChange","isEqual","CHANGE_EVENT","update","UPDATE_MODEL_EVENT","String","arr","isObject","indexOf","valueKey","some","i","handleResize","resetSelectionWidth","getBoundingClientRect","resetCollapseItemWidth","updateTooltip","updatePopper","call","updateTagTooltip","onSelect","selectedOptions","splice","multipleLimit","reserveKeyword","focus","deleteTag","stopPropagation","blur","_a2","handleEsc","getLastNotDisabledIndex","findLastIndex","it","handleDel","code","EVENT_CODE","delete","preventDefault","selected","lastNotDisabledIndex","removeTagValue","handleClear","emptyValue","onKeyboardNavigate","direction","includes","newIndex","scrollToItem","onKeyboardSelect","onHoverOption","idx","findIndex","target","handleClickOutside","_event","FocusEvent","handleMenuEnter","getOption","selectValue","option2","initStates","needUpdateSelectedLabel","toString","selectedItemIndex","watch","persistent","oldVal","isValEmpty","validateEvent","validate","catch","err","debugWarn","deep","input","activeElement","flush","resetScrollTop","watchEffect","duplicateValue","optionValue","v","onMounted","useResizeObserver","scrollTo","onHover"],"sources":["../../../../../../packages/components/select-v2/src/useSelect.ts"],"sourcesContent":["import {\n computed,\n nextTick,\n onMounted,\n reactive,\n ref,\n watch,\n watchEffect,\n} from 'vue'\nimport {\n findLastIndex,\n get,\n isEqual,\n debounce as lodashDebounce,\n} from 'lodash-unified'\nimport { useResizeObserver } from '@vueuse/core'\nimport {\n ValidateComponentsMap,\n debugWarn,\n escapeStringRegexp,\n isArray,\n isFunction,\n isNumber,\n isObject,\n} from '@element-plus/utils'\nimport {\n useComposition,\n useEmptyValues,\n useFocusController,\n useLocale,\n useNamespace,\n} from '@element-plus/hooks'\nimport {\n CHANGE_EVENT,\n EVENT_CODE,\n UPDATE_MODEL_EVENT,\n} from '@element-plus/constants'\nimport {\n useFormItem,\n useFormItemInputId,\n useFormSize,\n} from '@element-plus/components/form'\n\nimport { ArrowDown } from '@element-plus/icons-vue'\nimport { useAllowCreate } from './useAllowCreate'\nimport { useProps } from './useProps'\n\nimport type { Option, OptionType, SelectStates } from './select.types'\nimport type { ISelectV2Props } from './token'\nimport type { SelectEmitFn } from './defaults'\nimport type { TooltipInstance } from '@element-plus/components/tooltip'\nimport type { SelectDropdownInstance } from './select-dropdown'\nimport type { Component, ComputedRef, Ref, WritableComputedRef } from 'vue'\n\ntype useSelectReturnType = (\n props: ISelectV2Props,\n emit: SelectEmitFn\n) => {\n inputId: Ref<string | undefined>\n collapseTagSize: ComputedRef<'default' | 'small'>\n currentPlaceholder: ComputedRef<string>\n expanded: Ref<boolean>\n emptyText: ComputedRef<string | false | null>\n popupHeight: ComputedRef<number>\n debounce: ComputedRef<0 | 300>\n allOptions: Ref<OptionType[]>\n filteredOptions: Ref<OptionType[]>\n iconComponent: ComputedRef<any>\n iconReverse: ComputedRef<any>\n tagStyle: ComputedRef<{ maxWidth: string }>\n collapseTagStyle: ComputedRef<{ maxWidth: string }>\n popperSize: Ref<number>\n dropdownMenuVisible: WritableComputedRef<boolean>\n hasModelValue: ComputedRef<boolean>\n shouldShowPlaceholder: ComputedRef<boolean>\n selectDisabled: ComputedRef<boolean | undefined>\n selectSize: ComputedRef<string>\n needStatusIcon: ComputedRef<boolean>\n showClearBtn: ComputedRef<boolean>\n states: SelectStates\n isFocused: Ref<boolean>\n nsSelect: ReturnType<typeof useNamespace>\n nsInput: ReturnType<typeof useNamespace>\n inputRef: Ref<HTMLElement | undefined>\n menuRef: Ref<SelectDropdownInstance | undefined>\n tagMenuRef: Ref<HTMLElement | undefined>\n tooltipRef: Ref<TooltipInstance | undefined>\n tagTooltipRef: Ref<TooltipInstance | undefined>\n selectRef: Ref<HTMLElement | undefined>\n wrapperRef: Ref<HTMLElement | undefined>\n selectionRef: Ref<HTMLElement | undefined>\n prefixRef: Ref<HTMLElement | undefined>\n suffixRef: Ref<HTMLElement | undefined>\n collapseItemRef: Ref<HTMLElement | undefined>\n popperRef: ComputedRef<HTMLElement | undefined>\n validateState: ComputedRef<string>\n validateIcon: ComputedRef<Component | undefined>\n showTagList: ComputedRef<Option[]>\n collapseTagList: ComputedRef<Option[]>\n debouncedOnInputChange: () => void\n deleteTag: (event: MouseEvent, option: Option) => void\n getLabel: (option: Option) => string\n getValue: (option: Option) => unknown\n getDisabled: (option: Option) => boolean\n getValueKey: (item: unknown) => any\n handleClear: () => void\n handleClickOutside: (event: Event) => void\n handleDel: (e: KeyboardEvent) => void\n handleEsc: () => void\n focus: () => void\n blur: () => void\n handleMenuEnter: () => void\n handleResize: () => void\n resetSelectionWidth: () => void\n updateTooltip: () => void\n updateTagTooltip: () => void\n updateOptions: () => void\n toggleMenu: () => void\n scrollTo: (index: number) => void\n onInput: (event: Event) => void\n onKeyboardNavigate: (\n direction: 'forward' | 'backward',\n hoveringIndex?: number\n ) => void\n onKeyboardSelect: () => void\n onSelect: (option: Option) => void\n onHover: (idx?: number) => void\n handleCompositionStart: (event: CompositionEvent) => void\n handleCompositionEnd: (event: CompositionEvent) => void\n handleCompositionUpdate: (event: CompositionEvent) => void\n}\n\nconst useSelect: useSelectReturnType = (\n props: ISelectV2Props,\n emit: SelectEmitFn\n) => {\n // inject\n const { t } = useLocale()\n const nsSelect = useNamespace('select')\n const nsInput = useNamespace('input')\n const { form: elForm, formItem: elFormItem } = useFormItem()\n const { inputId } = useFormItemInputId(props, {\n formItemContext: elFormItem,\n })\n const { aliasProps, getLabel, getValue, getDisabled, getOptions } =\n useProps(props)\n const { valueOnClear, isEmptyValue } = useEmptyValues(props)\n\n const states: SelectStates = reactive({\n inputValue: '',\n cachedOptions: [],\n createdOptions: [],\n hoveringIndex: -1,\n inputHovering: false,\n selectionWidth: 0,\n collapseItemWidth: 0,\n previousQuery: null,\n previousValue: undefined,\n selectedLabel: '',\n menuVisibleOnFocus: false,\n isBeforeHide: false,\n })\n\n // data refs\n const popperSize = ref(-1)\n\n // DOM & Component refs\n const selectRef = ref<HTMLElement>()\n const selectionRef = ref<HTMLElement>()\n const tooltipRef = ref<TooltipInstance>()\n const tagTooltipRef = ref<TooltipInstance>()\n const inputRef = ref<HTMLElement>()\n const prefixRef = ref<HTMLElement>()\n const suffixRef = ref<HTMLElement>()\n const menuRef = ref<SelectDropdownInstance>()\n const tagMenuRef = ref<HTMLElement>()\n const collapseItemRef = ref<HTMLElement>()\n\n const {\n isComposing,\n handleCompositionStart,\n handleCompositionEnd,\n handleCompositionUpdate,\n } = useComposition({\n afterComposition: (e) => onInput(e),\n })\n\n const { wrapperRef, isFocused, handleBlur } = useFocusController(inputRef, {\n beforeFocus() {\n return selectDisabled.value\n },\n afterFocus() {\n if (props.automaticDropdown && !expanded.value) {\n expanded.value = true\n states.menuVisibleOnFocus = true\n }\n },\n beforeBlur(event) {\n return (\n tooltipRef.value?.isFocusInsideContent(event) ||\n tagTooltipRef.value?.isFocusInsideContent(event)\n )\n },\n afterBlur() {\n expanded.value = false\n states.menuVisibleOnFocus = false\n },\n })\n\n const allOptions = ref<OptionType[]>([])\n const filteredOptions = ref<OptionType[]>([])\n // the controller of the expanded popup\n const expanded = ref(false)\n\n const selectDisabled = computed(() => props.disabled || elForm?.disabled)\n\n const needStatusIcon = computed(() => elForm?.statusIcon ?? false)\n\n const popupHeight = computed(() => {\n const totalHeight = filteredOptions.value.length * props.itemHeight\n return totalHeight > props.height ? props.height : totalHeight\n })\n\n const hasModelValue = computed(() => {\n return props.multiple\n ? isArray(props.modelValue) && props.modelValue.length > 0\n : !isEmptyValue(props.modelValue)\n })\n\n const showClearBtn = computed(() => {\n return (\n props.clearable &&\n !selectDisabled.value &&\n states.inputHovering &&\n hasModelValue.value\n )\n })\n\n const iconComponent = computed(() =>\n props.remote && props.filterable ? '' : ArrowDown\n )\n\n const iconReverse = computed(\n () => iconComponent.value && nsSelect.is('reverse', expanded.value)\n )\n\n const validateState = computed(() => elFormItem?.validateState || '')\n const validateIcon = computed(() => {\n // When we use indexed access to get the type of an undeclared property,\n // the unsafe type `any` will be inferred, which TypeScript throws an error to emphasize it.\n // To avoid TypeScript complaining about it, we use truthiness narrowing to narrow the type of validateState.\n if (!validateState.value) return\n return ValidateComponentsMap[validateState.value]\n })\n\n const debounce = computed(() => (props.remote ? 300 : 0))\n\n // filteredOptions includes flatten the data into one dimensional array.\n const emptyText = computed(() => {\n if (props.loading) {\n return props.loadingText || t('el.select.loading')\n } else {\n if (props.remote && !states.inputValue && allOptions.value.length === 0)\n return false\n if (\n props.filterable &&\n states.inputValue &&\n allOptions.value.length > 0 &&\n filteredOptions.value.length === 0\n ) {\n return props.noMatchText || t('el.select.noMatch')\n }\n if (allOptions.value.length === 0) {\n return props.noDataText || t('el.select.noData')\n }\n }\n return null\n })\n\n const filterOptions = (query: string) => {\n const isValidOption = (o: Option): boolean => {\n if (props.filterable && isFunction(props.filterMethod)) return true\n if (props.filterable && props.remote && isFunction(props.remoteMethod))\n return true\n // when query was given, we should test on the label see whether the label contains the given query\n const regexp = new RegExp(escapeStringRegexp(query), 'i')\n return query ? regexp.test(getLabel(o) || '') : true\n }\n if (props.loading) {\n return []\n }\n\n return [...states.createdOptions, ...props.options].reduce((all, item) => {\n const options = getOptions(item)\n\n if (isArray(options)) {\n const filtered = options.filter(isValidOption)\n\n if (filtered.length > 0) {\n all.push(\n {\n label: getLabel(item),\n type: 'Group',\n },\n ...filtered\n )\n }\n } else if (props.remote || isValidOption(item)) {\n all.push(item)\n }\n\n return all\n }, []) as OptionType[]\n }\n\n const updateOptions = () => {\n allOptions.value = filterOptions('')\n filteredOptions.value = filterOptions(states.inputValue)\n }\n\n const allOptionsValueMap = computed(() => {\n const valueMap = new Map()\n\n allOptions.value.forEach((option, index) => {\n valueMap.set(getValueKey(getValue(option)), { option, index })\n })\n return valueMap\n })\n\n const filteredOptionsValueMap = computed(() => {\n const valueMap = new Map()\n\n filteredOptions.value.forEach((option, index) => {\n valueMap.set(getValueKey(getValue(option)), { option, index })\n })\n return valueMap\n })\n\n const optionsAllDisabled = computed(() =>\n filteredOptions.value.every((option) => getDisabled(option))\n )\n\n const selectSize = useFormSize()\n\n const collapseTagSize = computed(() =>\n 'small' === selectSize.value ? 'small' : 'default'\n )\n\n const calculatePopperSize = () => {\n if (isNumber(props.fitInputWidth)) {\n popperSize.value = props.fitInputWidth\n return\n }\n const width = selectRef.value?.offsetWidth || 200\n if (!props.fitInputWidth && allOptions.value.length > 0) {\n nextTick(() => {\n popperSize.value = Math.max(width, calculateLabelMaxWidth())\n })\n } else {\n popperSize.value = width\n }\n }\n\n // TODO Caching implementation\n // 1. There is no need to calculate options that have already been calculated\n // 2. Repeatedly expand and close when persistent is set to false, no need for repeated calculations\n const calculateLabelMaxWidth = () => {\n const canvas = document.createElement('canvas')\n const ctx = canvas.getContext('2d')\n const selector = nsSelect.be('dropdown', 'item')\n const dom = menuRef.value?.listRef?.innerRef || document\n const dropdownItemEl = dom.querySelector(`.${selector}`)\n if (dropdownItemEl === null || ctx === null) return 0\n const style = getComputedStyle(dropdownItemEl)\n const padding =\n Number.parseFloat(style.paddingLeft) +\n Number.parseFloat(style.paddingRight)\n ctx.font = style.font\n const maxWidth = filteredOptions.value.reduce((max, option) => {\n const metrics = ctx.measureText(getLabel(option))\n return Math.max(metrics.width, max)\n }, 0)\n return maxWidth + padding\n }\n\n const getGapWidth = () => {\n if (!selectionRef.value) return 0\n const style = window.getComputedStyle(selectionRef.value)\n return Number.parseFloat(style.gap || '6px')\n }\n\n // computed style\n const tagStyle = computed(() => {\n const gapWidth = getGapWidth()\n const maxWidth =\n collapseItemRef.value && props.maxCollapseTags === 1\n ? states.selectionWidth - states.collapseItemWidth - gapWidth\n : states.selectionWidth\n return { maxWidth: `${maxWidth}px` }\n })\n\n const collapseTagStyle = computed(() => {\n return { maxWidth: `${states.selectionWidth}px` }\n })\n\n const shouldShowPlaceholder = computed(() => {\n if (isArray(props.modelValue)) {\n return props.modelValue.length === 0 && !states.inputValue\n }\n\n // when it's not multiple mode, we only determine this flag based on filterable and expanded\n // when filterable flag is true, which means we have input box on the screen\n return props.filterable ? !states.inputValue : true\n })\n\n const currentPlaceholder = computed(() => {\n const _placeholder = props.placeholder ?? t('el.select.placeholder')\n return props.multiple || !hasModelValue.value\n ? _placeholder\n : states.selectedLabel\n })\n\n // this obtains the actual popper DOM element.\n const popperRef = computed(() => tooltipRef.value?.popperRef?.contentRef)\n\n // the index with current value in options\n const indexRef = computed<number>(() => {\n if (props.multiple) {\n const len = (props.modelValue as []).length\n if (\n (props.modelValue as Array<any>).length > 0 &&\n filteredOptionsValueMap.value.has(props.modelValue[len - 1])\n ) {\n const { index } = filteredOptionsValueMap.value.get(\n props.modelValue[len - 1]\n )\n return index\n }\n } else {\n if (\n !isEmptyValue(props.modelValue) &&\n filteredOptionsValueMap.value.has(props.modelValue)\n ) {\n const { index } = filteredOptionsValueMap.value.get(props.modelValue)\n return index\n }\n }\n return -1\n })\n\n const dropdownMenuVisible = computed({\n get() {\n return expanded.value && emptyText.value !== false\n },\n set(val: boolean) {\n expanded.value = val\n },\n })\n\n const showTagList = computed(() => {\n if (!props.multiple) {\n return []\n }\n return props.collapseTags\n ? states.cachedOptions.slice(0, props.maxCollapseTags)\n : states.cachedOptions\n })\n\n const collapseTagList = computed(() => {\n if (!props.multiple) {\n return []\n }\n return props.collapseTags\n ? states.cachedOptions.slice(props.maxCollapseTags)\n : []\n })\n\n // hooks\n const {\n createNewOption,\n removeNewOption,\n selectNewOption,\n clearAllNewOption,\n } = useAllowCreate(props, states)\n\n // methods\n const toggleMenu = () => {\n if (selectDisabled.value) return\n\n if (states.menuVisibleOnFocus) {\n // controlled by automaticDropdown\n states.menuVisibleOnFocus = false\n } else {\n expanded.value = !expanded.value\n }\n }\n\n const onInputChange = () => {\n if (states.inputValue.length > 0 && !expanded.value) {\n expanded.value = true\n }\n createNewOption(states.inputValue)\n handleQueryChange(states.inputValue)\n }\n\n const debouncedOnInputChange = lodashDebounce(onInputChange, debounce.value)\n\n const handleQueryChange = (val: string) => {\n if (states.previousQuery === val || isComposing.value) {\n return\n }\n states.previousQuery = val\n if (props.filterable && isFunction(props.filterMethod)) {\n props.filterMethod(val)\n } else if (\n props.filterable &&\n props.remote &&\n isFunction(props.remoteMethod)\n ) {\n props.remoteMethod(val)\n }\n if (\n props.defaultFirstOption &&\n (props.filterable || props.remote) &&\n filteredOptions.value.length\n ) {\n nextTick(checkDefaultFirstOption)\n } else {\n nextTick(updateHoveringIndex)\n }\n }\n\n /**\n * find and highlight first option as default selected\n * @remark\n * - if the first option in dropdown list is user-created,\n * it would be at the end of the optionsArray\n * so find it and set hover.\n * (NOTE: there must be only one user-created option in dropdown list with query)\n * - if there's no user-created option in list, just find the first one as usual\n * (NOTE: exclude options that are disabled or in disabled-group)\n */\n const checkDefaultFirstOption = () => {\n const optionsInDropdown = filteredOptions.value.filter(\n (n) => !n.disabled && n.type !== 'Group'\n )\n const userCreatedOption = optionsInDropdown.find((n) => n.created)\n const firstOriginOption = optionsInDropdown[0]\n states.hoveringIndex = getValueIndex(\n filteredOptions.value,\n userCreatedOption || firstOriginOption\n )\n }\n\n const emitChange = (val: any | any[]) => {\n if (!isEqual(props.modelValue, val)) {\n emit(CHANGE_EVENT, val)\n }\n }\n\n const update = (val: any) => {\n emit(UPDATE_MODEL_EVENT, val)\n emitChange(val)\n states.previousValue = props.multiple ? String(val) : val\n }\n\n const getValueIndex = (arr: unknown[] = [], value: unknown) => {\n if (!isObject(value)) {\n return arr.indexOf(value)\n }\n const valueKey = props.valueKey\n let index = -1\n arr.some((item, i) => {\n if (get(item, valueKey) === get(value, valueKey)) {\n index = i\n return true\n }\n return false\n })\n return index\n }\n\n const getValueKey = (item: unknown) => {\n return isObject(item) ? get(item, props.valueKey) : item\n }\n\n const handleResize = () => {\n calculatePopperSize()\n }\n\n const resetSelectionWidth = () => {\n states.selectionWidth = selectionRef.value!.getBoundingClientRect().width\n }\n\n const resetCollapseItemWidth = () => {\n states.collapseItemWidth =\n collapseItemRef.value!.getBoundingClientRect().width\n }\n\n const updateTooltip = () => {\n tooltipRef.value?.updatePopper?.()\n }\n\n const updateTagTooltip = () => {\n tagTooltipRef.value?.updatePopper?.()\n }\n\n const onSelect = (option: Option) => {\n if (props.multiple) {\n let selectedOptions = (props.modelValue as any[]).slice()\n\n const index = getValueIndex(selectedOptions, getValue(option))\n if (index > -1) {\n selectedOptions = [\n ...selectedOptions.slice(0, index),\n ...selectedOptions.slice(index + 1),\n ]\n states.cachedOptions.splice(index, 1)\n removeNewOption(option)\n } else if (\n props.multipleLimit <= 0 ||\n selectedOptions.length < props.multipleLimit\n ) {\n selectedOptions = [...selectedOptions, getValue(option)]\n states.cachedOptions.push(option)\n selectNewOption(option)\n }\n update(selectedOptions)\n if (option.created) {\n handleQueryChange('')\n }\n if (props.filterable && !props.reserveKeyword) {\n states.inputValue = ''\n }\n } else {\n states.selectedLabel = getLabel(option)\n update(getValue(option))\n expanded.value = false\n selectNewOption(option)\n if (!option.created) {\n clearAllNewOption()\n }\n }\n focus()\n }\n\n const deleteTag = (event: MouseEvent, option: Option) => {\n let selectedOptions = (props.modelValue as any[]).slice()\n\n const index = getValueIndex(selectedOptions, getValue(option))\n\n if (index > -1 && !selectDisabled.value) {\n selectedOptions = [\n ...(props.modelValue as Array<unknown>).slice(0, index),\n ...(props.modelValue as Array<unknown>).slice(index + 1),\n ]\n states.cachedOptions.splice(index, 1)\n update(selectedOptions)\n emit('remove-tag', getValue(option))\n removeNewOption(option)\n }\n event.stopPropagation()\n focus()\n }\n\n const focus = () => {\n inputRef.value?.focus()\n }\n\n const blur = () => {\n if (expanded.value) {\n expanded.value = false\n nextTick(() => inputRef.value?.blur())\n return\n }\n inputRef.value?.blur()\n }\n\n // keyboard handlers\n const handleEsc = () => {\n if (states.inputValue.length > 0) {\n states.inputValue = ''\n } else {\n expanded.value = false\n }\n }\n\n const getLastNotDisabledIndex = (value: unknown[]) =>\n findLastIndex(\n value,\n (it) =>\n !states.cachedOptions.some(\n (option) => getValue(option) === it && getDisabled(option)\n )\n )\n\n const handleDel = (e: KeyboardEvent) => {\n if (!props.multiple) return\n if (e.code === EVENT_CODE.delete) return\n if (states.inputValue.length === 0) {\n e.preventDefault()\n const selected = (props.modelValue as Array<any>).slice()\n const lastNotDisabledIndex = getLastNotDisabledIndex(selected)\n if (lastNotDisabledIndex < 0) return\n const removeTagValue = selected[lastNotDisabledIndex]\n selected.splice(lastNotDisabledIndex, 1)\n const option = states.cachedOptions[lastNotDisabledIndex]\n states.cachedOptions.splice(lastNotDisabledIndex, 1)\n removeNewOption(option)\n update(selected)\n emit('remove-tag', removeTagValue)\n }\n }\n\n const handleClear = () => {\n let emptyValue: string | any[]\n if (isArray(props.modelValue)) {\n emptyValue = []\n } else {\n emptyValue = valueOnClear.value\n }\n\n if (props.multiple) {\n states.cachedOptions = []\n } else {\n states.selectedLabel = ''\n }\n expanded.value = false\n update(emptyValue)\n emit('clear')\n clearAllNewOption()\n focus()\n }\n\n const onKeyboardNavigate = (\n direction: 'forward' | 'backward',\n hoveringIndex: number | undefined = undefined\n ): void => {\n const options = filteredOptions.value\n if (\n !['forward', 'backward'].includes(direction) ||\n selectDisabled.value ||\n options.length <= 0 ||\n optionsAllDisabled.value ||\n isComposing.value\n ) {\n return\n }\n if (!expanded.value) {\n return toggleMenu()\n }\n if (hoveringIndex === undefined) {\n hoveringIndex = states.hoveringIndex\n }\n let newIndex = -1\n if (direction === 'forward') {\n newIndex = hoveringIndex + 1\n if (newIndex >= options.length) {\n // return to the first option\n newIndex = 0\n }\n } else if (direction === 'backward') {\n newIndex = hoveringIndex - 1\n if (newIndex < 0 || newIndex >= options.length) {\n // navigate to the last one\n newIndex = options.length - 1\n }\n }\n const option = options[newIndex]\n if (getDisabled(option) || option.type === 'Group') {\n // prevent dispatching multiple nextTick callbacks.\n return onKeyboardNavigate(direction, newIndex)\n } else {\n states.hoveringIndex = newIndex\n scrollToItem(newIndex)\n }\n }\n\n const onKeyboardSelect = () => {\n if (!expanded.value) {\n return toggleMenu()\n } else if (\n ~states.hoveringIndex &&\n filteredOptions.value[states.hoveringIndex]\n ) {\n onSelect(filteredOptions.value[states.hoveringIndex])\n }\n }\n\n const onHoverOption = (idx?: number) => {\n states.hoveringIndex = idx ?? -1\n }\n\n const updateHoveringIndex = () => {\n if (!props.multiple) {\n states.hoveringIndex = filteredOptions.value.findIndex((item) => {\n return getValueKey(item) === getValueKey(props.modelValue)\n })\n } else {\n states.hoveringIndex = filteredOptions.value.findIndex((item) =>\n props.modelValue.some(\n (modelValue: unknown) => getValueKey(modelValue) === getValueKey(item)\n )\n )\n }\n }\n\n const onInput = (event: Event) => {\n states.inputValue = (event.target as HTMLInputElement).value\n if (props.remote) {\n debouncedOnInputChange()\n } else {\n return onInputChange()\n }\n }\n\n const handleClickOutside = (event: Event) => {\n expanded.value = false\n\n if (isFocused.value) {\n const _event = new FocusEvent('focus', event)\n handleBlur(_event)\n }\n }\n\n const handleMenuEnter = () => {\n states.isBeforeHide = false\n return nextTick(() => {\n if (~indexRef.value) {\n scrollToItem(states.hoveringIndex)\n }\n })\n }\n\n const scrollToItem = (index: number) => {\n menuRef.value!.scrollToItem(index)\n }\n\n const getOption = (value: unknown, cachedOptions?: Option[]) => {\n // match the option with the given value, if not found, create a new option\n const selectValue = getValueKey(value)\n\n if (allOptionsValueMap.value.has(selectValue)) {\n const { option } = allOptionsValueMap.value.get(selectValue)\n\n return option\n }\n if (cachedOptions && cachedOptions.length) {\n const option = cachedOptions.find(\n (option) => getValueKey(getValue(option)) === selectValue\n )\n if (option) {\n return option\n }\n }\n\n return {\n [aliasProps.value.value]: value,\n [aliasProps.value.label]: value,\n }\n }\n\n const initStates = (needUpdateSelectedLabel = false) => {\n if (props.multiple) {\n if ((props.modelValue as Array<any>).length > 0) {\n const cachedOptions = states.cachedOptions.slice()\n states.cachedOptions.length = 0\n states.previousValue = props.modelValue.toString()\n\n for (const value of props.modelValue) {\n const option = getOption(value, cachedOptions)\n states.cachedOptions.push(option)\n }\n } else {\n states.cachedOptions = []\n states.previousValue = undefined\n }\n } else {\n if (hasModelValue.value) {\n states.previousValue = props.modelValue\n const options = filteredOptions.value\n const selectedItemIndex = options.findIndex(\n (option) =>\n getValueKey(getValue(option)) === getValueKey(props.modelValue)\n )\n if (~selectedItemIndex) {\n states.selectedLabel = getLabel(options[selectedItemIndex])\n } else {\n if (!states.selectedLabel || needUpdateSelectedLabel) {\n states.selectedLabel = getValueKey(props.modelValue)\n }\n }\n } else {\n states.selectedLabel = ''\n states.previousValue = undefined\n }\n }\n clearAllNewOption()\n calculatePopperSize()\n }\n\n watch(\n () => props.fitInputWidth,\n () => {\n calculatePopperSize()\n }\n )\n\n // in order to track these individually, we need to turn them into refs instead of watching the entire\n // reactive object which could cause perf penalty when unnecessary field gets changed the watch method will\n // be invoked.\n\n watch(expanded, (val) => {\n if (val) {\n if (!props.persistent) {\n calculatePopperSize()\n }\n handleQueryChange('')\n } else {\n states.inputValue = ''\n states.previousQuery = null\n states.isBeforeHide = true\n createNewOption('')\n }\n emit('visible-change', val)\n })\n\n watch(\n () => props.modelValue,\n (val, oldVal) => {\n const isValEmpty = !val || (isArray(val) && val.length === 0)\n\n if (\n isValEmpty ||\n (props.multiple && !isEqual(val.toString(), states.previousValue)) ||\n (!props.multiple &&\n getValueKey(val) !== getValueKey(states.previousValue))\n ) {\n initStates(true)\n }\n if (!isEqual(val, oldVal) && props.validateEvent) {\n elFormItem?.validate?.('change').catch((err) => debugWarn(err))\n }\n },\n {\n deep: true,\n }\n )\n\n watch(\n () => props.options,\n () => {\n const input = inputRef.value\n // filter or remote-search scenarios are not initialized\n if (!input || (input && document.activeElement !== input)) {\n initStates()\n }\n },\n {\n deep: true,\n flush: 'post',\n }\n )\n\n // fix the problem that scrollTop is not reset in filterable mode\n watch(\n () => filteredOptions.value,\n () => {\n calculatePopperSize()\n return menuRef.value && nextTick(menuRef.value.resetScrollTop)\n }\n )\n\n watchEffect(() => {\n // Anything could cause options changed, then update options\n // If you want to control it by condition, write here\n if (states.isBeforeHide) return\n updateOptions()\n })\n\n watchEffect(() => {\n const { valueKey, options } = props\n const duplicateValue = new Map()\n for (const item of options) {\n const optionValue = getValue(item)\n let v = optionValue\n if (isObject(v)) {\n v = get(optionValue, valueKey)\n }\n if (duplicateValue.get(v)) {\n debugWarn(\n 'ElSelectV2',\n `The option values you provided seem to be duplicated, which may cause some problems, please check.`\n )\n break\n } else {\n duplicateValue.set(v, true)\n }\n }\n })\n\n onMounted(() => {\n initStates()\n })\n useResizeObserver(selectRef, handleResize)\n useResizeObserver(selectionRef, resetSelectionWidth)\n useResizeObserver(menuRef, updateTooltip)\n useResizeObserver(wrapperRef, updateTooltip)\n useResizeObserver(tagMenuRef, updateTagTooltip)\n useResizeObserver(collapseItemRef, resetCollapseItemWidth)\n\n return {\n // data exports\n inputId,\n collapseTagSize,\n currentPlaceholder,\n expanded,\n emptyText,\n popupHeight,\n debounce,\n allOptions,\n filteredOptions,\n iconComponent,\n iconReverse,\n tagStyle,\n collapseTagStyle,\n popperSize,\n dropdownMenuVisible,\n hasModelValue,\n shouldShowPlaceholder,\n selectDisabled,\n selectSize,\n needStatusIcon,\n showClearBtn,\n states,\n isFocused,\n nsSelect,\n nsInput,\n\n // refs items exports\n inputRef,\n menuRef,\n tagMenuRef,\n tooltipRef,\n tagTooltipRef,\n selectRef,\n wrapperRef,\n selectionRef,\n prefixRef,\n suffixRef,\n collapseItemRef,\n\n popperRef,\n\n validateState,\n validateIcon,\n showTagList,\n collapseTagList,\n\n // methods exports\n debouncedOnInputChange,\n deleteTag,\n getLabel,\n getValue,\n getDisabled,\n getValueKey,\n handleClear,\n handleClickOutside,\n handleDel,\n handleEsc,\n focus,\n blur,\n handleMenuEnter,\n handleResize,\n resetSelectionWidth,\n updateTooltip,\n updateTagTooltip,\n updateOptions,\n toggleMenu,\n scrollTo: scrollToItem,\n onInput,\n onKeyboardNavigate,\n onKeyboardSelect,\n onSelect,\n onHover: onHoverOption,\n handleCompositionStart,\n handleCompositionEnd,\n handleCompositionUpdate,\n }\n}\n\nexport default useSelect\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CK,MAACA,SAAS,GAAGA,CAACC,KAAK,EAAEC,IAAI,KAAK;EACjC,MAAM;IAAEC;EAAC,CAAE,GAAGC,SAAS,EAAE;EACzB,MAAMC,QAAQ,GAAGC,YAAY,CAAC,QAAQ,CAAC;EACvC,MAAMC,OAAO,GAAGD,YAAY,CAAC,OAAO,CAAC;EACrC,MAAM;IAAEE,IAAI,EAAEC,MAAM;IAAEC,QAAQ,EAAEC;EAAU,CAAE,GAAGC,WAAW,EAAE;EAC5D,MAAM;IAAEC;EAAO,CAAE,GAAGC,kBAAkB,CAACb,KAAK,EAAE;IAC5Cc,eAAe,EAAEJ;EACrB,CAAG,CAAC;EACF,MAAM;IAAEK,UAAU;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,WAAW;IAAEC;EAAU,CAAE,GAAGC,QAAQ,CAACpB,KAAK,CAAC;EACnF,MAAM;IAAEqB,YAAY;IAAEC;EAAY,CAAE,GAAGC,cAAc,CAACvB,KAAK,CAAC;EAC5D,MAAMwB,MAAM,GAAGC,QAAQ,CAAC;IACtBC,UAAU,EAAE,EAAE;IACdC,aAAa,EAAE,EAAE;IACjBC,cAAc,EAAE,EAAE;IAClBC,aAAa,EAAE,CAAC,CAAC;IACjBC,aAAa,EAAE,KAAK;IACpBC,cAAc,EAAE,CAAC;IACjBC,iBAAiB,EAAE,CAAC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OAAO,EAAEpC,aAAa;IACtBvN,sBAAsB;IACtBC,oBAAoB;IACpBC;EACJ,CAAG;AACH","ignoreList":[]},"metadata":{},"sourceType":"module","externalDependencies":[]}