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

1 month ago
  1. {"ast":null,"code":"import { reactive, ref, computed, watch, watchEffect, nextTick, onMounted } from 'vue';\nimport { castArray, isEqual, get, debounce, findLastIndex } from 'lodash-unified';\nimport { isIOS, isClient, useResizeObserver } from '@vueuse/core';\nimport { useLocale } from '../../../hooks/use-locale/index.mjs';\nimport { useId } from '../../../hooks/use-id/index.mjs';\nimport { useNamespace } from '../../../hooks/use-namespace/index.mjs';\nimport { useComposition } from '../../../hooks/use-composition/index.mjs';\nimport { useFocusController } from '../../../hooks/use-focus-controller/index.mjs';\nimport { useFormItem, useFormItemInputId } from '../../form/src/hooks/use-form-item.mjs';\nimport { useEmptyValues } from '../../../hooks/use-empty-values/index.mjs';\nimport { isArray, isFunction, isPlainObject, isObject } from '@vue/shared';\nimport { ValidateComponentsMap } from '../../../utils/vue/icon.mjs';\nimport { useFormSize } from '../../form/src/hooks/use-form-common-props.mjs';\nimport { isUndefined, isNumber } from '../../../utils/types.mjs';\nimport { debugWarn } from '../../../utils/error.mjs';\nimport { EVENT_CODE } from '../../../constants/aria.mjs';\nimport { UPDATE_MODEL_EVENT, CHANGE_EVENT } from '../../../constants/event.mjs';\nimport { scrollIntoView } from '../../../utils/dom/scroll.mjs';\nconst useSelect = (props, emit) => {\n const {\n t\n } = useLocale();\n const contentId = useId();\n const nsSelect = useNamespace(\"select\");\n const nsInput = useNamespace(\"input\");\n const states = reactive({\n inputValue: \"\",\n options: /* @__PURE__ */new Map(),\n cachedOptions: /* @__PURE__ */new Map(),\n optionValues: [],\n selected: [],\n selectionWidth: 0,\n collapseItemWidth: 0,\n selectedLabel: \"\",\n hoveringIndex: -1,\n previousQuery: null,\n inputHovering: false,\n menuVisibleOnFocus: false,\n isBeforeHide: false\n });\n const selectRef = ref(null);\n const selectionRef = ref(null);\n const tooltipRef = ref(null);\n const tagTooltipRef = ref(null);\n const inputRef = ref(null);\n const prefixRef = ref(null);\n const suffixRef = ref(null);\n const menuRef = ref(null);\n const tagMenuRef = ref(null);\n const collapseItemRef = ref(null);\n const scrollbarRef = ref(null);\n const {\n isComposing,\n handleCompositionStart,\n handleCompositionUpdate,\n handleCompositionEnd\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 expanded = ref(false);\n const hoverOption = ref();\n const {\n form,\n formItem\n } = useFormItem();\n const {\n inputId\n } = useFormItemInputId(props, {\n formItemContext: formItem\n });\n const {\n valueOnClear,\n isEmptyValue\n } = useEmptyValues(props);\n const selectDisabled = computed(() => props.disabled || (form == null ? void 0 : form.disabled));\n const hasModelValue = computed(() => {\n return isArray(props.modelValue) ? props.modelValue.length > 0 : !isEmptyValue(props.modelValue);\n });\n const needStatusIcon = computed(() => {\n var _a;\n return (_a = form == null ? void 0 : form.statusIcon) != null ? _a : false;\n });\n const showClose = computed(() => {\n return props.clearable && !selectDisabled.value && states.inputHovering && hasModelValue.value;\n });\n const iconComponent = computed(() => props.remote && props.filterable && !props.remoteShowSuffix ? \"\" : p