@v-c/select 1.0.23 → 1.1.0

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.
@@ -91,7 +91,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps {
91
91
  maxTagTextLength?: number;
92
92
  maxTagCount?: number | 'responsive';
93
93
  maxTagPlaceholder?: VueNode | ((omittedValues: DisplayValueType[]) => any);
94
- tokenSeparators?: string[];
94
+ tokenSeparators?: string[] | ((input: string) => string[]);
95
95
  allowClear?: boolean | {
96
96
  clearIcon?: VueNode;
97
97
  };
@@ -1,19 +1,19 @@
1
- import { useAllowClear } from "../hooks/useAllowClear.js";
2
1
  import { useBaseSelectProvider } from "../hooks/useBaseProps.js";
2
+ import { getSeparatedContent, isValidCount } from "../utils/valueUtil.js";
3
+ import { useAllowClear } from "../hooks/useAllowClear.js";
3
4
  import useComponents from "../hooks/useComponents.js";
4
5
  import useLock from "../hooks/useLock.js";
5
6
  import useOpen, { macroTask } from "../hooks/useOpen.js";
6
7
  import useSelectTriggerControl, { isInside } from "../hooks/useSelectTriggerControl.js";
7
8
  import "../hooks/index.js";
8
- import { getSeparatedContent, isValidCount } from "../utils/valueUtil.js";
9
9
  import SelectInput from "../SelectInput/index.js";
10
10
  import SelectTrigger from "../SelectTrigger.js";
11
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";
15
14
  import { KeyCodeStr } from "@v-c/util/dist/KeyCode";
16
15
  import omit from "@v-c/util/dist/omit";
16
+ import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
17
17
  //#region src/BaseSelect/index.tsx
18
18
  /**
19
19
  * ZombieJ:
@@ -122,16 +122,32 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
122
122
  return props.disabled || emptyListContent.value ? false : nextOpen;
123
123
  });
124
124
  const tokenWithEnter = computed(() => {
125
- return (tokenSeparators.value || []).some((tokenSeparator) => ["\n", "\r\n"].includes(tokenSeparator));
125
+ const value = tokenSeparators.value;
126
+ return typeof value === "function" || (value || []).some((tokenSeparator) => ["\n", "\r\n"].includes(tokenSeparator));
126
127
  });
128
+ /**
129
+ * ant-design#57391 / rc-select#1220: when `tokenSeparators` is a
130
+ * function, defer the split decision to the user callback. Otherwise
131
+ * fall back to the static-string-array behaviour via getSeparatedContent.
132
+ */
133
+ const splitByTokenSeparators = (input, end) => {
134
+ const value = tokenSeparators.value;
135
+ if (typeof value === "function") {
136
+ const tokens = value(input);
137
+ const isUnchanged = Array.isArray(tokens) && tokens.length === 1 && tokens[0] === input;
138
+ if (!Array.isArray(tokens) || !tokens.length || isUnchanged) return null;
139
+ return typeof end !== "undefined" ? tokens.slice(0, end) : tokens;
140
+ }
141
+ return getSeparatedContent(input, value, end);
142
+ };
127
143
  const onInternalSearch = (searchText, fromTyping, isCompositing) => {
128
144
  const { maxCount } = props;
129
145
  if (multiple.value && isValidCount(maxCount) && displayValues.value.length >= maxCount) return;
130
146
  let ret = true;
131
147
  let newSearchText = searchText;
132
148
  props?.onActiveValueChange?.(null);
133
- const separatedList = getSeparatedContent(searchText, tokenSeparators.value, isValidCount(maxCount) ? maxCount - displayValues.value.length : void 0);
134
- const patchLabels = isCompositing ? null : separatedList;
149
+ const cap = isValidCount(maxCount) ? maxCount - displayValues.value.length : void 0;
150
+ const patchLabels = isCompositing ? null : splitByTokenSeparators(searchText, cap);
135
151
  if (mode.value !== "combobox" && patchLabels) {
136
152
  newSearchText = "";
137
153
  props?.onSearchSplit?.(patchLabels);
@@ -530,7 +546,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
530
546
  default: void 0
531
547
  },
532
548
  tokenSeparators: {
533
- type: Array,
549
+ type: [Array, Function],
534
550
  required: false,
535
551
  default: void 0
536
552
  },
@@ -1,8 +1,8 @@
1
1
  import useBaseProps from "./hooks/useBaseProps.js";
2
- import TransBtn from "./TransBtn.js";
3
- import { isValidCount } from "./utils/valueUtil.js";
4
2
  import { useSelectContext } from "./SelectContext.js";
3
+ import TransBtn from "./TransBtn.js";
5
4
  import { isPlatformMac } from "./utils/platformUtil.js";
5
+ import { isValidCount } from "./utils/valueUtil.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";
package/dist/Select.js CHANGED
@@ -1,18 +1,18 @@
1
+ import { useSelectProvider } from "./SelectContext.js";
2
+ import { fillFieldNames, flattenOptions, injectPropsWithOption } from "./utils/valueUtil.js";
3
+ import OptionList from "./OptionList.js";
1
4
  import useCache from "./hooks/useCache.js";
2
5
  import { hasValue, isComboNoValue, toArray } from "./utils/commonUtil.js";
3
6
  import useFilterOptions from "./hooks/useFilterOptions.js";
4
7
  import useOptions from "./hooks/useOptions.js";
5
8
  import useRefFunc from "./hooks/useRefFunc.js";
6
9
  import useSearchConfig from "./hooks/useSearchConfig.js";
7
- import { fillFieldNames, flattenOptions, injectPropsWithOption } from "./utils/valueUtil.js";
8
- import { useSelectProvider } from "./SelectContext.js";
9
10
  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";
13
14
  import omit from "@v-c/util/dist/omit";
14
15
  import { filterEmpty } from "@v-c/util/dist/props-util";
15
- import useId from "@v-c/util/dist/hooks/useId";
16
16
  //#region src/Select.tsx
17
17
  var OMIT_DOM_PROPS = ["inputValue"];
18
18
  var omitKeyList = [
@@ -357,7 +357,7 @@ var Select = /* @__PURE__ */ defineComponent({
357
357
  default: void 0
358
358
  },
359
359
  tokenSeparators: {
360
- type: Array,
360
+ type: [Array, Function],
361
361
  required: false,
362
362
  default: void 0
363
363
  },
@@ -1,8 +1,8 @@
1
1
  import useBaseProps from "../../hooks/useBaseProps.js";
2
- import { getTitle } from "../../utils/commonUtil.js";
3
- import { useSelectInputContext } from "../context.js";
4
2
  import TransBtn from "../../TransBtn.js";
5
3
  import { isValidCount } from "../../utils/valueUtil.js";
4
+ import { getTitle } from "../../utils/commonUtil.js";
5
+ import { useSelectInputContext } from "../context.js";
6
6
  import Input from "../Input.js";
7
7
  import Placeholder from "./Placeholder.js";
8
8
  import { computed, createTextVNode, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
@@ -1,9 +1,9 @@
1
1
  import useBaseProps from "../../hooks/useBaseProps.js";
2
+ import { useSelectContext } from "../../SelectContext.js";
2
3
  import { getTitle } from "../../utils/commonUtil.js";
3
4
  import { useSelectInputContext } from "../context.js";
4
5
  import Input from "../Input.js";
5
6
  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
9
  //#region src/SelectInput/Content/SingleContent.tsx
@@ -5,9 +5,9 @@ import { useSelectInputProvider } from "./context.js";
5
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";
9
8
  import KeyCode from "@v-c/util/dist/KeyCode";
10
9
  import omit from "@v-c/util/dist/omit";
10
+ import { getDOM } from "@v-c/util/dist/Dom/findDOMNode";
11
11
  //#region src/SelectInput/index.tsx
12
12
  var DEFAULT_OMIT_PROPS = [
13
13
  "value",
@@ -1,5 +1,5 @@
1
- import { useAllowClear } from "./useAllowClear.js";
2
1
  import useBaseProps, { useBaseSelectProvider } from "./useBaseProps.js";
2
+ import { useAllowClear } from "./useAllowClear.js";
3
3
  import useCache from "./useCache.js";
4
4
  import useComponents from "./useComponents.js";
5
5
  import useFilterOptions from "./useFilterOptions.js";
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import useBaseProps from "./hooks/useBaseProps.js";
2
- import "./hooks/index.js";
3
- import { useSelectContext, useSelectProvider } from "./SelectContext.js";
4
- import { BaseSelect } from "./BaseSelect/index.js";
5
1
  import OptGroup from "./OptGroup.js";
6
2
  import Option from "./Option.js";
3
+ import useBaseProps from "./hooks/useBaseProps.js";
4
+ import { useSelectContext, useSelectProvider } from "./SelectContext.js";
7
5
  import OptionList from "./OptionList.js";
6
+ import "./hooks/index.js";
7
+ import { BaseSelect } from "./BaseSelect/index.js";
8
8
  import Select from "./Select.js";
9
9
  //#region src/index.ts
10
10
  var src_default = Select;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@v-c/select",
3
3
  "type": "module",
4
- "version": "1.0.23",
4
+ "version": "1.1.0",
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.5",
33
- "@v-c/virtual-list": "^1.0.7",
34
32
  "@v-c/trigger": "^1.0.14",
35
- "@v-c/util": "^1.0.19"
33
+ "@v-c/util": "^1.0.19",
34
+ "@v-c/overflow": "^1.1.0",
35
+ "@v-c/virtual-list": "^1.0.7"
36
36
  },
37
37
  "scripts": {
38
38
  "build": "vite build",