@v-c/select 1.0.20 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { createVNode, defineComponent, isVNode } from "vue";
2
- var Polite_default = /* @__PURE__ */ defineComponent((props) => {
2
+ //#region src/BaseSelect/Polite.tsx
3
+ var Polite = /* @__PURE__ */ defineComponent((props) => {
3
4
  return () => {
4
5
  const { visible, values } = props;
5
6
  if (!visible) return null;
@@ -19,16 +20,15 @@ var Polite_default = /* @__PURE__ */ defineComponent((props) => {
19
20
  props: {
20
21
  visible: {
21
22
  type: Boolean,
22
- required: true,
23
- default: void 0
23
+ required: true
24
24
  },
25
25
  values: {
26
26
  type: Array,
27
- required: true,
28
- default: void 0
27
+ required: true
29
28
  }
30
29
  },
31
30
  name: "Polite",
32
31
  inheritAttrs: false
33
32
  });
34
- export { Polite_default as default };
33
+ //#endregion
34
+ export { Polite as default };
@@ -1,23 +1,31 @@
1
- import { useBaseSelectProvider } from "../hooks/useBaseProps.js";
2
- import { getSeparatedContent, isValidCount } from "../utils/valueUtil.js";
3
1
  import { useAllowClear } from "../hooks/useAllowClear.js";
2
+ import { useBaseSelectProvider } from "../hooks/useBaseProps.js";
4
3
  import useComponents from "../hooks/useComponents.js";
5
4
  import useLock from "../hooks/useLock.js";
6
5
  import useOpen, { macroTask } from "../hooks/useOpen.js";
7
6
  import useSelectTriggerControl, { isInside } from "../hooks/useSelectTriggerControl.js";
8
7
  import "../hooks/index.js";
9
- import SelectInput_default from "../SelectInput/index.js";
10
- import SelectTrigger_default from "../SelectTrigger.js";
11
- import Polite_default from "./Polite.js";
8
+ import SelectInput from "../SelectInput/index.js";
9
+ import SelectTrigger from "../SelectTrigger.js";
10
+ import { getSeparatedContent, isValidCount } from "../utils/valueUtil.js";
11
+ import Polite from "./Polite.js";
12
12
  import { Fragment, computed, createVNode, defineComponent, isVNode, mergeDefaults, mergeProps, shallowRef, watch } from "vue";
13
13
  import { clsx } from "@v-c/util";
14
+ import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
14
15
  import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
15
16
  import omit from "@v-c/util/dist/omit";
16
- import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
17
+ //#region src/BaseSelect/index.tsx
18
+ /**
19
+ * ZombieJ:
20
+ * We are currently refactoring the semantic structure of the component. Changelog:
21
+ * - Remove `suffixIcon` and change to `suffix`.
22
+ * - Add `components.root` for replacing response element.
23
+ * - Remove `getInputElement` and `getRawInputElement` since we can use `components.input` instead.
24
+ */
17
25
  function _isSlot(s) {
18
26
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
19
27
  }
20
- const isMultiple = (mode) => mode === "tags" || mode === "multiple";
28
+ var isMultiple = (mode) => mode === "tags" || mode === "multiple";
21
29
  var omitKeys = [
22
30
  "id",
23
31
  "prefixCls",
@@ -76,7 +84,7 @@ var omitKeys = [
76
84
  "onMouseDown",
77
85
  "components"
78
86
  ];
79
- const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
87
+ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
80
88
  const mode = computed(() => props.mode);
81
89
  const getInputElement = computed(() => props.getInputElement);
82
90
  const getRawInputElement = computed(() => props.getRawInputElement);
@@ -90,6 +98,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
90
98
  const containerRef = shallowRef();
91
99
  const triggerRef = shallowRef();
92
100
  const listRef = shallowRef();
101
+ /** Used for component focused management */
93
102
  const focused = shallowRef(false);
94
103
  expose({
95
104
  focus: (...args) => containerRef.value?.focus?.(...args),
@@ -134,6 +143,8 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
134
143
  return ret;
135
144
  };
136
145
  const onInternalSearchSubmit = (searchText) => {
146
+ const { maxCount } = props;
147
+ if (multiple.value && isValidCount(maxCount) && displayValues.value.length >= maxCount) return;
137
148
  if (!searchText || !searchText.trim()) return;
138
149
  props?.onSearch?.(searchText, { source: "submit" });
139
150
  };
@@ -146,6 +157,12 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
146
157
  focused.value = false;
147
158
  }
148
159
  }, { immediate: true });
160
+ /**
161
+ * We record input value here to check if can press to clean up by backspace
162
+ * - null: Key is not down, this is reset by key up
163
+ * - true: Search text is empty when first time backspace down
164
+ * - false: Search text is not empty when first time backspace down
165
+ */
149
166
  const [getClearLock, setClearLock] = useLock();
150
167
  const keyLockRef = shallowRef(false);
151
168
  const onInternalKeyDown = (event) => {
@@ -288,7 +305,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
288
305
  [`${prefixCls}-customize-input`]: customizeInputElement,
289
306
  [`${prefixCls}-show-search`]: showSearch
290
307
  });
291
- let renderNode = createVNode(SelectInput_default, mergeProps(attrs, omit(props, omitKeys), {
308
+ let renderNode = createVNode(SelectInput, mergeProps(attrs, omit(props, omitKeys), {
292
309
  "ref": containerRef,
293
310
  "prefixCls": prefixCls,
294
311
  "className": mergedClassName,
@@ -318,7 +335,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
318
335
  const _renderNode = function() {
319
336
  return renderNode;
320
337
  }();
321
- renderNode = createVNode(SelectTrigger_default, {
338
+ renderNode = createVNode(SelectTrigger, {
322
339
  "ref": triggerRef,
323
340
  "disabled": disabled.value ?? false,
324
341
  "prefixCls": prefixCls,
@@ -341,7 +358,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
341
358
  "onPopupMouseDown": onInternalMouseDown,
342
359
  "onPopupBlur": onRootBlur
343
360
  }, _isSlot(renderNode) ? renderNode : { default: () => [_renderNode] });
344
- return createVNode(Fragment, null, [createVNode(Polite_default, {
361
+ return createVNode(Fragment, null, [createVNode(Polite, {
345
362
  "visible": focused.value && !mergedOpen.value,
346
363
  "values": displayValues.value
347
364
  }, null), renderNode]);
@@ -699,13 +716,11 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
699
716
  },
700
717
  id: {
701
718
  type: String,
702
- required: true,
703
- default: void 0
719
+ required: true
704
720
  },
705
721
  prefixCls: {
706
722
  type: String,
707
- required: true,
708
- default: void 0
723
+ required: true
709
724
  },
710
725
  omitDomProps: {
711
726
  type: Array,
@@ -714,13 +729,11 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
714
729
  },
715
730
  displayValues: {
716
731
  type: Array,
717
- required: true,
718
- default: void 0
732
+ required: true
719
733
  },
720
734
  onDisplayValuesChange: {
721
735
  type: Function,
722
- required: true,
723
- default: void 0
736
+ required: true
724
737
  },
725
738
  activeValue: {
726
739
  type: String,
@@ -739,8 +752,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
739
752
  },
740
753
  searchValue: {
741
754
  type: String,
742
- required: true,
743
- default: void 0
755
+ required: true
744
756
  },
745
757
  autoClearSearchValue: {
746
758
  type: Boolean,
@@ -749,22 +761,17 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
749
761
  },
750
762
  onSearch: {
751
763
  type: Function,
752
- required: true,
753
- default: void 0
764
+ required: true
754
765
  },
755
766
  onSearchSplit: {
756
767
  type: Function,
757
768
  required: false,
758
769
  default: void 0
759
770
  },
760
- OptionList: {
761
- required: true,
762
- default: void 0
763
- },
771
+ OptionList: { required: true },
764
772
  emptyOptions: {
765
773
  type: Boolean,
766
- required: true,
767
- default: void 0
774
+ required: true
768
775
  }
769
776
  }, {
770
777
  showScrollBar: "optional",
@@ -774,4 +781,5 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
774
781
  name: "BaseSelect",
775
782
  inheritAttrs: false
776
783
  });
784
+ //#endregion
777
785
  export { BaseSelect, isMultiple };
package/dist/OptGroup.js CHANGED
@@ -1,4 +1,5 @@
1
+ //#region src/OptGroup.tsx
1
2
  var OptGroup = () => null;
2
3
  OptGroup.isSelectOptGroup = true;
3
- var OptGroup_default = OptGroup;
4
- export { OptGroup_default as default };
4
+ //#endregion
5
+ export { OptGroup as default };
package/dist/Option.js CHANGED
@@ -1,4 +1,5 @@
1
+ //#region src/Option.tsx
1
2
  var Option = () => null;
2
3
  Option.isSelectOption = true;
3
- var Option_default = Option;
4
- export { Option_default as default };
4
+ //#endregion
5
+ export { Option as default };
@@ -1,17 +1,22 @@
1
1
  import useBaseProps from "./hooks/useBaseProps.js";
2
+ import TransBtn from "./TransBtn.js";
2
3
  import { useSelectContext } from "./SelectContext.js";
3
- import TransBtn_default from "./TransBtn.js";
4
- import { isPlatformMac } from "./utils/platformUtil.js";
5
4
  import { isValidCount } from "./utils/valueUtil.js";
5
+ import { isPlatformMac } from "./utils/platformUtil.js";
6
6
  import { Fragment, computed, createVNode, defineComponent, mergeProps, shallowRef, watch } from "vue";
7
7
  import { clsx } from "@v-c/util";
8
8
  import KeyCode from "@v-c/util/dist/KeyCode";
9
9
  import pickAttrs from "@v-c/util/dist/pickAttrs";
10
10
  import List from "@v-c/virtual-list";
11
+ //#region src/OptionList.tsx
11
12
  function isTitleType(content) {
12
13
  return typeof content === "string" || typeof content === "number";
13
14
  }
14
- var OptionList_default = /* @__PURE__ */ defineComponent({
15
+ /**
16
+ * Using virtual list of option display.
17
+ * Will fallback to dom if use customize render.
18
+ */
19
+ var OptionList = /* @__PURE__ */ defineComponent({
15
20
  name: "OptionList",
16
21
  inheritAttrs: false,
17
22
  setup(_, { expose }) {
@@ -77,7 +82,7 @@ var OptionList_default = /* @__PURE__ */ defineComponent({
77
82
  () => baseProps.value?.open,
78
83
  () => baseProps.value?.searchValue,
79
84
  () => memoFlattenOptions.value.length
80
- ], (_$1, __, onCleanup) => {
85
+ ], (_, __, onCleanup) => {
81
86
  let timeoutId;
82
87
  const rawValues = context.value?.rawValues;
83
88
  if (!baseProps.value?.multiple && baseProps.value?.open && rawValues?.size === 1) {
@@ -251,7 +256,7 @@ var OptionList_default = /* @__PURE__ */ defineComponent({
251
256
  ...contextStyles?.popup?.listItem,
252
257
  ...style
253
258
  }
254
- }), [createVNode("div", { "class": `${optionPrefixCls}-content` }, [typeof optionRender === "function" ? optionRender(item, { index: itemIndex }) : content]), iconVisible && createVNode(TransBtn_default, {
259
+ }), [createVNode("div", { "class": `${optionPrefixCls}-content` }, [typeof optionRender === "function" ? optionRender(item, { index: itemIndex }) : content]), iconVisible && createVNode(TransBtn, {
255
260
  "className": `${itemPrefixCls.value}-option-state`,
256
261
  "customizeIcon": menuItemSelectedIcon,
257
262
  "customizeIconProps": {
@@ -264,4 +269,5 @@ var OptionList_default = /* @__PURE__ */ defineComponent({
264
269
  };
265
270
  }
266
271
  });
267
- export { OptionList_default as default };
272
+ //#endregion
273
+ export { OptionList as default };
package/dist/Select.js CHANGED
@@ -1,18 +1,19 @@
1
- import { useSelectProvider } from "./SelectContext.js";
2
- import { fillFieldNames, flattenOptions, injectPropsWithOption } from "./utils/valueUtil.js";
3
- import OptionList_default from "./OptionList.js";
4
1
  import useCache from "./hooks/useCache.js";
5
2
  import { hasValue, isComboNoValue, toArray } from "./utils/commonUtil.js";
6
3
  import useFilterOptions from "./hooks/useFilterOptions.js";
7
4
  import useOptions from "./hooks/useOptions.js";
8
5
  import useRefFunc from "./hooks/useRefFunc.js";
9
6
  import useSearchConfig from "./hooks/useSearchConfig.js";
7
+ import { useSelectProvider } from "./SelectContext.js";
8
+ import { fillFieldNames, flattenOptions, injectPropsWithOption } from "./utils/valueUtil.js";
10
9
  import { BaseSelect, isMultiple } from "./BaseSelect/index.js";
10
+ import OptionList from "./OptionList.js";
11
11
  import { convertChildrenToData } from "./utils/legacyUtil.js";
12
12
  import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef, toRef, watch } from "vue";
13
- import useId from "@v-c/util/dist/hooks/useId";
14
13
  import omit from "@v-c/util/dist/omit";
15
14
  import { filterEmpty } from "@v-c/util/dist/props-util";
15
+ import useId from "@v-c/util/dist/hooks/useId";
16
+ //#region src/Select.tsx
16
17
  var OMIT_DOM_PROPS = ["inputValue"];
17
18
  var omitKeyList = [
18
19
  "id",
@@ -53,7 +54,7 @@ var omitKeyList = [
53
54
  function isRawValue(value) {
54
55
  return !value || typeof value !== "object";
55
56
  }
56
- var Select_default = /* @__PURE__ */ defineComponent({
57
+ var Select = /* @__PURE__ */ defineComponent({
57
58
  props: /* @__PURE__ */ mergeDefaults({
58
59
  prefixCls: {
59
60
  type: String,
@@ -634,6 +635,7 @@ var Select_default = /* @__PURE__ */ defineComponent({
634
635
  label: (typeof props.labelRender === "function" ? props.labelRender(item) : item.label) ?? item.value
635
636
  }));
636
637
  });
638
+ /** Convert `displayValues` to raw value type set */
637
639
  const rawValues = computed(() => new Set(mergedValues.value.map((val) => val.value)));
638
640
  watch(mergedValues, () => {
639
641
  if (props.mode === "combobox") {
@@ -822,7 +824,7 @@ var Select_default = /* @__PURE__ */ defineComponent({
822
824
  "autoClearSearchValue": searchConfig.value.autoClearSearchValue,
823
825
  "onSearchSplit": onInternalSearchSplit,
824
826
  "popupMatchSelectWidth": popupMatchSelectWidth,
825
- "OptionList": OptionList_default,
827
+ "OptionList": OptionList,
826
828
  "emptyOptions": !displayOptions.value.length,
827
829
  "activeValue": activeValue.value || void 0,
828
830
  "activeDescendantId": `${mergedId}_list_${accessibilityIndex.value}`
@@ -830,4 +832,5 @@ var Select_default = /* @__PURE__ */ defineComponent({
830
832
  };
831
833
  }
832
834
  });
833
- export { Select_default as default };
835
+ //#endregion
836
+ export { Select as default };
@@ -1,4 +1,5 @@
1
1
  import { inject, provide, ref } from "vue";
2
+ //#region src/SelectContext.ts
2
3
  var SelectContextKey = Symbol("SelectContext");
3
4
  function useSelectProvider(value) {
4
5
  provide(SelectContextKey, value);
@@ -6,4 +7,5 @@ function useSelectProvider(value) {
6
7
  function useSelectContext() {
7
8
  return inject(SelectContextKey, ref(null));
8
9
  }
10
+ //#endregion
9
11
  export { useSelectContext, useSelectProvider };
@@ -1,6 +1,7 @@
1
1
  import { createVNode, defineComponent } from "vue";
2
2
  import { filterEmpty } from "@v-c/util/dist/props-util";
3
- var Affix_default = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
3
+ //#region src/SelectInput/Affix.tsx
4
+ var Affix = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
4
5
  return () => {
5
6
  const children = filterEmpty(slots?.default?.() ?? []);
6
7
  if (children.length < 1) return null;
@@ -10,4 +11,5 @@ var Affix_default = /* @__PURE__ */ defineComponent((_, { attrs, slots }) => {
10
11
  name: "Affix",
11
12
  inheritAttrs: false
12
13
  });
13
- export { Affix_default as default };
14
+ //#endregion
15
+ export { Affix as default };
@@ -1,12 +1,13 @@
1
1
  import useBaseProps from "../../hooks/useBaseProps.js";
2
- import TransBtn_default from "../../TransBtn.js";
3
2
  import { getTitle } from "../../utils/commonUtil.js";
4
3
  import { useSelectInputContext } from "../context.js";
5
- import Input_default from "../Input.js";
6
- import Placeholder_default from "./Placeholder.js";
4
+ import TransBtn from "../../TransBtn.js";
5
+ import Input from "../Input.js";
6
+ import Placeholder from "./Placeholder.js";
7
7
  import { computed, createTextVNode, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
8
8
  import { clsx } from "@v-c/util";
9
9
  import Overflow from "@v-c/overflow";
10
+ //#region src/SelectInput/Content/MultipleContent.tsx
10
11
  function itemKey(value) {
11
12
  return value.key ?? value.value ?? "";
12
13
  }
@@ -14,7 +15,7 @@ function onPreventMouseDown(event) {
14
15
  event.preventDefault();
15
16
  event.stopPropagation();
16
17
  }
17
- var MultipleContent_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
18
+ var MultipleContent = /* @__PURE__ */ defineComponent((props, { expose }) => {
18
19
  const selectInputContext = useSelectInputContext();
19
20
  const baseProps = useBaseProps();
20
21
  const inputRef = shallowRef();
@@ -59,7 +60,7 @@ var MultipleContent_default = /* @__PURE__ */ defineComponent((props, { expose }
59
60
  }, [createVNode("span", {
60
61
  "class": clsx(`${selectionItemPrefixCls.value}-content`, classNamesConfig.value?.itemContent),
61
62
  "style": stylesConfig.value?.itemContent
62
- }, [content]), closable && createVNode(TransBtn_default, {
63
+ }, [content]), closable && createVNode(TransBtn, {
63
64
  "className": clsx(`${selectionItemPrefixCls.value}-remove`, classNamesConfig.value?.itemRemove),
64
65
  "style": stylesConfig.value?.itemRemove,
65
66
  "onMouseDown": onPreventMouseDown,
@@ -104,8 +105,8 @@ var MultipleContent_default = /* @__PURE__ */ defineComponent((props, { expose }
104
105
  };
105
106
  return () => {
106
107
  const { inputProps } = props;
107
- const prefixNode = !displayValues.value.length && !inputValue.value ? () => createVNode(Placeholder_default, null, null) : null;
108
- const suffixNode = () => createVNode(Input_default, mergeProps({
108
+ const prefixNode = !displayValues.value.length && !inputValue.value ? () => createVNode(Placeholder, null, null) : null;
109
+ const suffixNode = () => createVNode(Input, mergeProps({
109
110
  "ref": inputRef,
110
111
  "disabled": disabled.value,
111
112
  "readOnly": !inputEditable.value
@@ -129,10 +130,10 @@ var MultipleContent_default = /* @__PURE__ */ defineComponent((props, { expose }
129
130
  }, {
130
131
  props: { inputProps: {
131
132
  type: Object,
132
- required: true,
133
- default: void 0
133
+ required: true
134
134
  } },
135
135
  name: "MultipleContent",
136
136
  inheritAttrs: false
137
137
  });
138
- export { MultipleContent_default as default };
138
+ //#endregion
139
+ export { MultipleContent as default };
@@ -2,7 +2,8 @@ import useBaseProps from "../../hooks/useBaseProps.js";
2
2
  import { useSelectInputContext } from "../context.js";
3
3
  import { createVNode, defineComponent } from "vue";
4
4
  import { clsx } from "@v-c/util";
5
- var Placeholder_default = /* @__PURE__ */ defineComponent((props) => {
5
+ //#region src/SelectInput/Content/Placeholder.tsx
6
+ var Placeholder = /* @__PURE__ */ defineComponent((props) => {
6
7
  const selectInputContext = useSelectInputContext();
7
8
  const baseProps = useBaseProps();
8
9
  return () => {
@@ -27,4 +28,5 @@ var Placeholder_default = /* @__PURE__ */ defineComponent((props) => {
27
28
  name: "Placeholder",
28
29
  inheritAttrs: false
29
30
  });
30
- export { Placeholder_default as default };
31
+ //#endregion
32
+ export { Placeholder as default };
@@ -1,12 +1,13 @@
1
1
  import useBaseProps from "../../hooks/useBaseProps.js";
2
- import { useSelectContext } from "../../SelectContext.js";
3
2
  import { getTitle } from "../../utils/commonUtil.js";
4
3
  import { useSelectInputContext } from "../context.js";
5
- import Input_default from "../Input.js";
6
- import Placeholder_default from "./Placeholder.js";
4
+ import Input from "../Input.js";
5
+ import Placeholder from "./Placeholder.js";
6
+ import { useSelectContext } from "../../SelectContext.js";
7
7
  import { computed, createVNode, defineComponent, mergeProps, shallowRef, watch } from "vue";
8
8
  import { clsx } from "@v-c/util";
9
- var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose }) => {
9
+ //#region src/SelectInput/Content/SingleContent.tsx
10
+ var SingleContent = /* @__PURE__ */ defineComponent((props, { expose }) => {
10
11
  const selectInputContext = useSelectInputContext();
11
12
  const baseProps = useBaseProps();
12
13
  const selectContext = useSelectContext();
@@ -57,12 +58,12 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
57
58
  ...optionStyle.value
58
59
  },
59
60
  "title": optionTitle.value
60
- }, [displayValue.value?.label]) : displayValue.value?.label : createVNode(Placeholder_default, { "show": !mergedSearchValue.value }, null) : null;
61
+ }, [displayValue.value?.label]) : displayValue.value?.label : createVNode(Placeholder, { "show": !mergedSearchValue.value }, null) : null;
61
62
  return createVNode("div", {
62
63
  "class": clsx(`${prefixCls}-content`, showHasValueCls && `${prefixCls}-content-has-value`, mergedSearchValue.value && `${prefixCls}-content-has-search-value`, hasOptionStyle.value && `${prefixCls}-content-has-option-style`, classNames?.content),
63
64
  "style": styles?.content,
64
65
  "title": hasOptionStyle.value ? void 0 : optionTitle.value
65
- }, [renderValue, createVNode(Input_default, mergeProps(inputProps, {
66
+ }, [renderValue, createVNode(Input, mergeProps(inputProps, {
66
67
  "value": mergedSearchValue.value,
67
68
  "maxLength": mode === "combobox" ? maxLength : void 0,
68
69
  "onChange": (e) => {
@@ -75,10 +76,10 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
75
76
  }, {
76
77
  props: { inputProps: {
77
78
  type: Object,
78
- required: true,
79
- default: void 0
79
+ required: true
80
80
  } },
81
81
  name: "SingleContent",
82
82
  inheritAttrs: false
83
83
  });
84
- export { SingleContent_default as default };
84
+ //#endregion
85
+ export { SingleContent as default };
@@ -1,10 +1,11 @@
1
1
  import useBaseProps from "../../hooks/useBaseProps.js";
2
2
  import { useSelectInputContext } from "../context.js";
3
- import MultipleContent_default from "./MultipleContent.js";
4
- import SingleContent_default from "./SingleContent.js";
3
+ import MultipleContent from "./MultipleContent.js";
4
+ import SingleContent from "./SingleContent.js";
5
5
  import { computed, createVNode, defineComponent, shallowRef } from "vue";
6
6
  import pickAttrs from "@v-c/util/dist/pickAttrs";
7
- var Content_default = /* @__PURE__ */ defineComponent((_, { expose }) => {
7
+ //#region src/SelectInput/Content/index.tsx
8
+ var SelectContent = /* @__PURE__ */ defineComponent((_, { expose }) => {
8
9
  const selectInputContext = useSelectInputContext();
9
10
  const baseProps = useBaseProps();
10
11
  const inputRef = shallowRef();
@@ -20,11 +21,11 @@ var Content_default = /* @__PURE__ */ defineComponent((_, { expose }) => {
20
21
  tabindex: baseProps.value?.tabIndex
21
22
  }));
22
23
  return () => {
23
- if (multiple.value) return createVNode(MultipleContent_default, {
24
+ if (multiple.value) return createVNode(MultipleContent, {
24
25
  "ref": inputRef,
25
26
  "inputProps": sharedInputProps.value
26
27
  }, null);
27
- return createVNode(SingleContent_default, {
28
+ return createVNode(SingleContent, {
28
29
  "ref": inputRef,
29
30
  "inputProps": sharedInputProps.value
30
31
  }, null);
@@ -33,4 +34,5 @@ var Content_default = /* @__PURE__ */ defineComponent((_, { expose }) => {
33
34
  name: "SelectContent",
34
35
  inheritAttrs: false
35
36
  });
36
- export { Content_default as default };
37
+ //#endregion
38
+ export { SelectContent as default };
@@ -3,7 +3,8 @@ import { useSelectInputContext } from "./context.js";
3
3
  import { createVNode, defineComponent, isVNode, nextTick, shallowRef, watch } from "vue";
4
4
  import { clsx } from "@v-c/util";
5
5
  import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
6
- var Input_default = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
6
+ //#region src/SelectInput/Input.tsx
7
+ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
7
8
  const selectInputContext = useSelectInputContext();
8
9
  const baseProps = useBaseProps();
9
10
  const compositionStatusRef = shallowRef(false);
@@ -171,4 +172,5 @@ var Input_default = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =
171
172
  name: "Input",
172
173
  inheritAttrs: false
173
174
  });
174
- export { Input_default as default };
175
+ //#endregion
176
+ export { Input as default };
@@ -1,4 +1,5 @@
1
1
  import { inject, provide, ref } from "vue";
2
+ //#region src/SelectInput/context.ts
2
3
  var SelectInputKey = Symbol("SelectInputContext");
3
4
  function useSelectInputContext() {
4
5
  return inject(SelectInputKey, ref(null));
@@ -6,4 +7,5 @@ function useSelectInputContext() {
6
7
  function useSelectInputProvider(context) {
7
8
  provide(SelectInputKey, context);
8
9
  }
10
+ //#endregion
9
11
  export { useSelectInputContext, useSelectInputProvider };
@@ -1,13 +1,14 @@
1
1
  import useBaseProps from "../hooks/useBaseProps.js";
2
2
  import { isValidateOpenKey } from "../utils/keyUtil.js";
3
- import Affix_default from "./Affix.js";
3
+ import Affix from "./Affix.js";
4
4
  import { useSelectInputProvider } from "./context.js";
5
- import Content_default from "./Content/index.js";
5
+ import SelectContent from "./Content/index.js";
6
6
  import { cloneVNode, computed, createVNode, defineComponent, isVNode, mergeProps, shallowRef } from "vue";
7
7
  import { clsx } from "@v-c/util";
8
+ import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
8
9
  import KeyCode from "@v-c/util/dist/KeyCode";
9
10
  import omit from "@v-c/util/dist/omit";
10
- import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
11
+ //#region src/SelectInput/index.tsx
11
12
  var DEFAULT_OMIT_PROPS = [
12
13
  "value",
13
14
  "onChange",
@@ -39,7 +40,7 @@ function mergeVNodeProps(originProps, nextProps) {
39
40
  });
40
41
  return mergedProps;
41
42
  }
42
- var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots }) => {
43
+ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots }) => {
43
44
  const baseProps = useBaseProps();
44
45
  const rootRef = shallowRef();
45
46
  const inputRef = shallowRef();
@@ -133,16 +134,16 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
133
134
  "onFocusin": props.onFocus,
134
135
  "onFocusout": props.onBlur
135
136
  }), [
136
- createVNode(Affix_default, {
137
+ createVNode(Affix, {
137
138
  "class": clsx(`${prefixCls.value}-prefix`, classNamesConfig.value?.prefix),
138
139
  "style": stylesConfig.value?.prefix
139
140
  }, { default: () => [prefix.value] }),
140
- createVNode(Content_default, { "ref": inputRef }, null),
141
- createVNode(Affix_default, {
141
+ createVNode(SelectContent, { "ref": inputRef }, null),
142
+ createVNode(Affix, {
142
143
  "class": clsx(`${prefixCls.value}-suffix`, { [`${prefixCls.value}-suffix-loading`]: loading.value }, classNamesConfig.value?.suffix),
143
144
  "style": stylesConfig.value?.suffix
144
145
  }, { default: () => [suffix.value] }),
145
- clearIcon.value && createVNode(Affix_default, {
146
+ clearIcon.value && createVNode(Affix, {
146
147
  "class": clsx(`${prefixCls.value}-clear`, classNamesConfig.value?.clear),
147
148
  "style": stylesConfig.value?.clear,
148
149
  "onMousedown": (e) => {
@@ -157,8 +158,7 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
157
158
  props: {
158
159
  prefixCls: {
159
160
  type: String,
160
- required: true,
161
- default: void 0
161
+ required: true
162
162
  },
163
163
  prefix: {
164
164
  type: [
@@ -219,8 +219,7 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
219
219
  },
220
220
  displayValues: {
221
221
  type: Array,
222
- required: true,
223
- default: void 0
222
+ required: true
224
223
  },
225
224
  placeholder: {
226
225
  type: [
@@ -317,8 +316,7 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
317
316
  },
318
317
  components: {
319
318
  type: Object,
320
- required: true,
321
- default: void 0
319
+ required: true
322
320
  },
323
321
  onFocus: {
324
322
  type: Function,
@@ -349,4 +347,5 @@ var SelectInput_default = /* @__PURE__ */ defineComponent((props, { attrs, expos
349
347
  name: "SelectInput",
350
348
  inheritAttrs: false
351
349
  });
352
- export { SelectInput_default as default };
350
+ //#endregion
351
+ export { SelectInput as default };
@@ -1,6 +1,7 @@
1
1
  import { computed, createVNode, defineComponent, mergeDefaults, mergeProps, shallowRef } from "vue";
2
2
  import { clsx } from "@v-c/util";
3
3
  import Trigger from "@v-c/trigger";
4
+ //#region src/SelectTrigger.tsx
4
5
  function getBuiltInPlacements(popupMatchSelectWidth) {
5
6
  const adjustX = popupMatchSelectWidth === true ? 0 : 1;
6
7
  return {
@@ -42,7 +43,7 @@ function getBuiltInPlacements(popupMatchSelectWidth) {
42
43
  }
43
44
  };
44
45
  }
45
- var SelectTrigger_default = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) => {
46
+ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expose }) => {
46
47
  const mergedBuiltinPlacements = computed(() => {
47
48
  return props?.builtinPlacements || getBuiltInPlacements(props.popupMatchSelectWidth);
48
49
  });
@@ -87,23 +88,17 @@ var SelectTrigger_default = /* @__PURE__ */ defineComponent((props, { slots, att
87
88
  props: /* @__PURE__ */ mergeDefaults({
88
89
  prefixCls: {
89
90
  type: String,
90
- required: true,
91
- default: void 0
91
+ required: true
92
92
  },
93
93
  disabled: {
94
94
  type: Boolean,
95
- required: true,
96
- default: void 0
95
+ required: true
97
96
  },
98
97
  visible: {
99
98
  type: Boolean,
100
- required: true,
101
- default: void 0
102
- },
103
- popupElement: {
104
- required: true,
105
- default: void 0
99
+ required: true
106
100
  },
101
+ popupElement: { required: true },
107
102
  animation: {
108
103
  type: String,
109
104
  required: false,
@@ -161,8 +156,7 @@ var SelectTrigger_default = /* @__PURE__ */ defineComponent((props, { slots, att
161
156
  },
162
157
  empty: {
163
158
  type: Boolean,
164
- required: true,
165
- default: void 0
159
+ required: true
166
160
  },
167
161
  onPopupVisibleChange: {
168
162
  type: [Function, null],
@@ -171,13 +165,11 @@ var SelectTrigger_default = /* @__PURE__ */ defineComponent((props, { slots, att
171
165
  },
172
166
  onPopupMouseEnter: {
173
167
  type: Function,
174
- required: true,
175
- default: void 0
168
+ required: true
176
169
  },
177
170
  onPopupMouseDown: {
178
171
  type: Function,
179
- required: true,
180
- default: void 0
172
+ required: true
181
173
  },
182
174
  onPopupBlur: {
183
175
  type: Function,
@@ -188,4 +180,5 @@ var SelectTrigger_default = /* @__PURE__ */ defineComponent((props, { slots, att
188
180
  name: "SelectTrigger",
189
181
  inheritAttrs: false
190
182
  });
191
- export { SelectTrigger_default as default };
183
+ //#endregion
184
+ export { SelectTrigger as default };
package/dist/TransBtn.js CHANGED
@@ -1,6 +1,17 @@
1
1
  import { createVNode, defineComponent } from "vue";
2
2
  import { clsx } from "@v-c/util";
3
- var TransBtn_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
3
+ //#region src/TransBtn.tsx
4
+ /**
5
+ * Small wrapper for Select icons (clear/arrow/etc.).
6
+ * Prevents default mousedown to avoid blurring or caret moves, and
7
+ * renders a custom icon or a fallback icon span.
8
+ *
9
+ * DOM structure:
10
+ * <span className={className} ...>
11
+ * { icon || <span className={`${className}-icon`}>{children}</span> }
12
+ * </span>
13
+ */
14
+ var TransBtn = /* @__PURE__ */ defineComponent((props, { slots }) => {
4
15
  return () => {
5
16
  const { className, style, customizeIcon, customizeIconProps, onMouseDown, onClick } = props;
6
17
  const icon = typeof customizeIcon === "function" ? customizeIcon(customizeIconProps) : customizeIcon;
@@ -24,8 +35,7 @@ var TransBtn_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
24
35
  props: {
25
36
  className: {
26
37
  type: String,
27
- required: true,
28
- default: void 0
38
+ required: true
29
39
  },
30
40
  style: {
31
41
  type: Object,
@@ -63,4 +73,5 @@ var TransBtn_default = /* @__PURE__ */ defineComponent((props, { slots }) => {
63
73
  name: "TransBtn",
64
74
  inheritAttrs: false
65
75
  });
66
- export { TransBtn_default as default };
76
+ //#endregion
77
+ export { TransBtn as default };
@@ -1,5 +1,5 @@
1
- import useBaseProps, { useBaseSelectProvider } from "./useBaseProps.js";
2
1
  import { useAllowClear } from "./useAllowClear.js";
2
+ import useBaseProps, { useBaseSelectProvider } from "./useBaseProps.js";
3
3
  import useCache from "./useCache.js";
4
4
  import useComponents from "./useComponents.js";
5
5
  import useFilterOptions from "./useFilterOptions.js";
@@ -1,4 +1,5 @@
1
1
  import { computed } from "vue";
2
+ //#region src/hooks/useAllowClear.tsx
2
3
  function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disabled, mergedSearchValue, mode) {
3
4
  const allowClearConfig = computed(() => {
4
5
  if (typeof allowClear?.value === "boolean") return { allowClear: allowClear.value };
@@ -13,4 +14,5 @@ function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disable
13
14
  };
14
15
  });
15
16
  }
17
+ //#endregion
16
18
  export { useAllowClear };
@@ -1,4 +1,5 @@
1
1
  import { inject, provide, ref } from "vue";
2
+ //#region src/hooks/useBaseProps.ts
2
3
  var BaseSelectContext = Symbol("BaseSelectContext");
3
4
  function useBaseSelectProvider(context) {
4
5
  provide(BaseSelectContext, context);
@@ -6,4 +7,5 @@ function useBaseSelectProvider(context) {
6
7
  function useBaseProps() {
7
8
  return inject(BaseSelectContext, ref(null));
8
9
  }
10
+ //#endregion
9
11
  export { useBaseProps as default, useBaseSelectProvider };
@@ -1,4 +1,8 @@
1
1
  import { computed } from "vue";
2
+ //#region src/hooks/useCache.ts
3
+ /**
4
+ * Cache `value` related LabeledValue & options.
5
+ */
2
6
  function useCache(labeledValues, valueOptions) {
3
7
  const cache = {
4
8
  values: /* @__PURE__ */ new Map(),
@@ -29,4 +33,5 @@ function useCache(labeledValues, valueOptions) {
29
33
  };
30
34
  return [filledLabeledValues, getOption];
31
35
  }
36
+ //#endregion
32
37
  export { useCache as default };
@@ -1,4 +1,5 @@
1
1
  import { computed } from "vue";
2
+ //#region src/hooks/useComponents.ts
2
3
  function useComponents(components, getInputElement, getRawInputElement) {
3
4
  return computed(() => {
4
5
  let { root, input } = components.value || {};
@@ -10,4 +11,5 @@ function useComponents(components, getInputElement, getRawInputElement) {
10
11
  };
11
12
  });
12
13
  }
14
+ //#endregion
13
15
  export { useComponents as default };
@@ -1,5 +1,6 @@
1
1
  import { injectPropsWithOption, toArray } from "../utils/commonUtil.js";
2
2
  import { computed } from "vue";
3
+ //#region src/hooks/useFilterOptions.ts
3
4
  function includes(test, search) {
4
5
  return toArray(test).join("").toUpperCase().includes(search);
5
6
  }
@@ -34,4 +35,5 @@ function useFilterOptions(options, fieldNames, searchValue, filterOption, option
34
35
  return filteredOptions;
35
36
  });
36
37
  }
38
+ //#endregion
37
39
  export { useFilterOptions as default };
@@ -1,4 +1,5 @@
1
1
  import { onUnmounted, shallowRef } from "vue";
2
+ //#region src/hooks/useLock.ts
2
3
  function useLock(duration = 250) {
3
4
  const lockRef = shallowRef(null);
4
5
  const timeoutRef = shallowRef(null);
@@ -21,4 +22,5 @@ function useLock(duration = 250) {
21
22
  }
22
23
  return [() => !!lockRef.value, doLock];
23
24
  }
25
+ //#endregion
24
26
  export { useLock as default };
@@ -1,4 +1,5 @@
1
1
  import { computed, onMounted, shallowRef, watch } from "vue";
2
+ //#region src/hooks/useOpen.ts
2
3
  function internalMacroTask(fn) {
3
4
  const channel = new MessageChannel();
4
5
  channel.port1.onmessage = fn;
@@ -13,6 +14,15 @@ function macroTask(fn, times = 1) {
13
14
  macroTask(fn, times - 1);
14
15
  });
15
16
  }
17
+ /**
18
+ * When `open` is controlled, follow the controlled value;
19
+ * Otherwise use uncontrolled logic.
20
+ * Setting `open` takes effect immediately,
21
+ * but setting it to `false` is delayed via MessageChannel.
22
+ *
23
+ * SSR handling: During SSR, `open` is always false to avoid Portal issues.
24
+ * On client-side hydration, it syncs with the actual open state.
25
+ */
16
26
  function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
17
27
  const rendered = shallowRef(propOpen.value ?? false);
18
28
  onMounted(() => {
@@ -55,4 +65,5 @@ function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
55
65
  lock
56
66
  ];
57
67
  }
68
+ //#endregion
58
69
  export { useOpen as default, macroTask };
@@ -1,4 +1,8 @@
1
1
  import { computed } from "vue";
2
+ //#region src/hooks/useOptions.ts
3
+ /**
4
+ * Parse `options` and flatten them.
5
+ */
2
6
  function useOptions(options, childrenOptions, fieldNames, optionFilterProp, optionLabelProp) {
3
7
  return computed(() => {
4
8
  let mergedOptions = [];
@@ -33,4 +37,5 @@ function useOptions(options, childrenOptions, fieldNames, optionFilterProp, opti
33
37
  };
34
38
  });
35
39
  }
40
+ //#endregion
36
41
  export { useOptions as default };
@@ -1,4 +1,10 @@
1
1
  import { shallowRef } from "vue";
2
+ //#region src/hooks/useRefFunc.ts
3
+ /**
4
+ * Same as `React.useCallback` but always return a memoized function
5
+ * but redirect to real function.
6
+ * In Vue, we use shallowRef to store the callback reference.
7
+ */
2
8
  function useRefFunc(callback) {
3
9
  const funcRef = shallowRef(callback);
4
10
  funcRef.value = callback;
@@ -7,4 +13,5 @@ function useRefFunc(callback) {
7
13
  };
8
14
  return cacheFn;
9
15
  }
16
+ //#endregion
10
17
  export { useRefFunc as default };
@@ -1,4 +1,5 @@
1
1
  import { computed } from "vue";
2
+ //#region src/hooks/useSearchConfig.ts
2
3
  function useSearchConfig(showSearch, props, mode) {
3
4
  const { filterOption, searchValue, optionFilterProp, filterSort, onSearch, autoClearSearchValue } = props;
4
5
  return [computed(() => {
@@ -18,4 +19,5 @@ function useSearchConfig(showSearch, props, mode) {
18
19
  return config;
19
20
  })];
20
21
  }
22
+ //#endregion
21
23
  export { useSearchConfig as default };
@@ -1,4 +1,5 @@
1
1
  import { onMounted, onUnmounted } from "vue";
2
+ //#region src/hooks/useSelectTriggerControl.ts
2
3
  function isInside(elements, target) {
3
4
  return elements.filter((element) => element).some((element) => element.contains(target) || element === target);
4
5
  }
@@ -17,4 +18,5 @@ function useSelectTriggerControl(elements, open, triggerOpen, customizedTrigger)
17
18
  });
18
19
  });
19
20
  }
21
+ //#endregion
20
22
  export { useSelectTriggerControl as default, isInside };
package/dist/index.js CHANGED
@@ -1,10 +1,12 @@
1
- import OptGroup_default from "./OptGroup.js";
2
- import Option_default from "./Option.js";
3
1
  import useBaseProps from "./hooks/useBaseProps.js";
4
- import { useSelectContext, useSelectProvider } from "./SelectContext.js";
5
- import OptionList_default from "./OptionList.js";
6
2
  import "./hooks/index.js";
3
+ import { useSelectContext, useSelectProvider } from "./SelectContext.js";
7
4
  import { BaseSelect } from "./BaseSelect/index.js";
8
- import Select_default from "./Select.js";
9
- var src_default = Select_default;
10
- export { BaseSelect, OptGroup_default as OptGroup, Option_default as Option, OptionList_default as OptionList, Select_default as Select, src_default as default, useBaseProps, useSelectContext, useSelectProvider };
5
+ import OptGroup from "./OptGroup.js";
6
+ import Option from "./Option.js";
7
+ import OptionList from "./OptionList.js";
8
+ import Select from "./Select.js";
9
+ //#region src/index.ts
10
+ var src_default = Select;
11
+ //#endregion
12
+ export { BaseSelect, OptGroup, Option, OptionList, Select, src_default as default, useBaseProps, useSelectContext, useSelectProvider };
@@ -1,3 +1,4 @@
1
+ //#region src/utils/commonUtil.ts
1
2
  function toArray(value) {
2
3
  if (value === null || value === void 0) return [];
3
4
  return Array.isArray(value) ? value : [value];
@@ -19,12 +20,15 @@ function getTitle(item) {
19
20
  }
20
21
  return title;
21
22
  }
22
- const isClient = typeof window !== "undefined" && window.document && window.document.documentElement;
23
- const isBrowserClient = typeof process !== "undefined" && process.env.NODE_ENV !== "test" && isClient;
23
+ var isClient = typeof window !== "undefined" && window.document && window.document.documentElement;
24
+ /** Is client side and not jsdom */
25
+ var isBrowserClient = typeof process !== "undefined" && process.env.NODE_ENV !== "test" && isClient;
24
26
  function hasValue(value) {
25
27
  return value !== void 0 && value !== null;
26
28
  }
29
+ /** combo mode no value judgment function */
27
30
  function isComboNoValue(value) {
28
31
  return !value && value !== 0;
29
32
  }
33
+ //#endregion
30
34
  export { getTitle, hasValue, injectPropsWithOption, isBrowserClient, isClient, isComboNoValue, toArray, toVueNode };
@@ -1,4 +1,6 @@
1
1
  import KeyCode from "@v-c/util/dist/KeyCode";
2
+ //#region src/utils/keyUtil.ts
3
+ /** keyCode Judgment function */
2
4
  function isValidateOpenKey(currentKeyCode) {
3
5
  return !!currentKeyCode && ![
4
6
  KeyCode.ESC,
@@ -31,4 +33,5 @@ function isValidateOpenKey(currentKeyCode) {
31
33
  KeyCode.F12
32
34
  ].includes(currentKeyCode);
33
35
  }
36
+ //#endregion
34
37
  export { isValidateOpenKey };
@@ -1,4 +1,5 @@
1
1
  import { isVNode, toRaw } from "vue";
2
+ //#region src/utils/legacyUtil.ts
2
3
  function convertNodeToOption(node) {
3
4
  const { key, props, children } = node;
4
5
  const { value, label, ...restProps } = props || {};
@@ -28,4 +29,5 @@ function convertChildrenToData(nodes, optionOnly = false) {
28
29
  };
29
30
  }).filter((data) => data !== null);
30
31
  }
32
+ //#endregion
31
33
  export { convertChildrenToData };
@@ -1,5 +1,7 @@
1
+ //#region src/utils/platformUtil.ts
1
2
  /* istanbul ignore file */
2
3
  function isPlatformMac() {
3
4
  return /(mac\sos|macintosh)/i.test(navigator.appVersion);
4
5
  }
6
+ //#endregion
5
7
  export { isPlatformMac };
@@ -1,3 +1,4 @@
1
+ //#region src/utils/valueUtil.ts
1
2
  function getKey(data, index) {
2
3
  const { key } = data;
3
4
  let value;
@@ -19,6 +20,11 @@ function fillFieldNames(fieldNames, childrenAsData) {
19
20
  groupLabel: groupLabel || mergedLabel
20
21
  };
21
22
  }
23
+ /**
24
+ * Flat options into flatten list.
25
+ * We use `optionOnly` here is aim to avoid user use nested option group.
26
+ * Here is simply set `key` to the index if not provided.
27
+ */
22
28
  function flattenOptions(options, { fieldNames, childrenAsData } = {}) {
23
29
  const flattenList = [];
24
30
  const { label: fieldLabel, value: fieldValue, options: fieldOptions, groupLabel } = fillFieldNames(fieldNames, false);
@@ -50,6 +56,9 @@ function flattenOptions(options, { fieldNames, childrenAsData } = {}) {
50
56
  dig(options, false);
51
57
  return flattenList;
52
58
  }
59
+ /**
60
+ * Inject `props` into `option` for legacy usage
61
+ */
53
62
  function injectPropsWithOption(option) {
54
63
  if (!option) return option;
55
64
  const newOption = { ...option };
@@ -64,12 +73,13 @@ function getSeparatedContent(text, tokens, end) {
64
73
  let match = false;
65
74
  const separate = (str, [token, ...restTokens]) => {
66
75
  if (!token) return [str];
67
- const list$1 = str.split(token);
68
- match = match || list$1.length > 1;
69
- return list$1.reduce((prevList, unitStr) => [...prevList, ...separate(unitStr, restTokens)], []).filter(Boolean);
76
+ const list = str.split(token);
77
+ match = match || list.length > 1;
78
+ return list.reduce((prevList, unitStr) => [...prevList, ...separate(unitStr, restTokens)], []).filter(Boolean);
70
79
  };
71
80
  const list = separate(text, tokens);
72
81
  if (match) return typeof end !== "undefined" ? list.slice(0, end) : list;
73
82
  else return null;
74
83
  }
84
+ //#endregion
75
85
  export { fillFieldNames, flattenOptions, getSeparatedContent, injectPropsWithOption, isValidCount };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.0.20",
4
+ "version": "1.0.21",
5
5
  "description": "",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -29,10 +29,10 @@
29
29
  "vue": "^3.0.0"
30
30
  },
31
31
  "dependencies": {
32
- "@v-c/overflow": "^1.0.4",
33
- "@v-c/trigger": "^1.0.13",
34
- "@v-c/util": "^1.0.18",
35
- "@v-c/virtual-list": "^1.0.6"
32
+ "@v-c/overflow": "^1.0.5",
33
+ "@v-c/util": "^1.0.19",
34
+ "@v-c/trigger": "^1.0.14",
35
+ "@v-c/virtual-list": "^1.0.7"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "vite build",