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
86 KiB

1 month ago
  1. {"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.le