@v-c/select 1.1.3 → 1.2.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.
- package/dist/BaseSelect/index.d.ts +1 -0
- package/dist/BaseSelect/index.js +3 -1
- package/dist/OptionList.js +1 -0
- package/dist/Select.js +6 -4
- package/dist/SelectInput/Content/Placeholder.js +1 -1
- package/dist/SelectInput/Input.js +7 -5
- package/dist/SelectInput/index.d.ts +1 -0
- package/dist/SelectInput/index.js +14 -5
- package/dist/SelectTrigger.js +1 -1
- package/dist/hooks/useAllowClear.d.ts +2 -0
- package/dist/hooks/useAllowClear.js +2 -1
- package/package.json +5 -5
|
@@ -94,6 +94,7 @@ export interface BaseSelectProps extends BaseSelectPrivateProps {
|
|
|
94
94
|
tokenSeparators?: string[] | ((input: string) => string[]);
|
|
95
95
|
allowClear?: boolean | {
|
|
96
96
|
clearIcon?: VueNode;
|
|
97
|
+
label?: string;
|
|
97
98
|
};
|
|
98
99
|
prefix?: VueNode;
|
|
99
100
|
/** @deprecated Please use `suffix` instead. */
|
package/dist/BaseSelect/index.js
CHANGED
|
@@ -292,6 +292,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
292
292
|
const { OptionList, prefixCls, className, loading, showSearch, prefix, placeholder, activeValue, animation, transitionName, popupStyle, popupClassName, direction, popupMatchSelectWidth, popupRender, popupAlign, placement, builtinPlacements, getPopupContainer, emptyOptions } = props;
|
|
293
293
|
const mergedAllowClear = allowClearConfig.value.allowClear;
|
|
294
294
|
const clearNode = allowClearConfig.value.clearIcon;
|
|
295
|
+
const clearLabel = allowClearConfig.value.label;
|
|
295
296
|
const customizeInputElement = mode.value === "combobox" && typeof getInputElement.value === "function" && getInputElement.value() || null;
|
|
296
297
|
let onTriggerVisibleChange = null;
|
|
297
298
|
if (mergedComponents.value?.root) onTriggerVisibleChange = (newOpen) => {
|
|
@@ -330,6 +331,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
330
331
|
"prefix": prefix,
|
|
331
332
|
"suffix": mergedSuffixIcon,
|
|
332
333
|
"clearIcon": clearNode,
|
|
334
|
+
"clearLabel": clearLabel,
|
|
333
335
|
"multiple": multiple.value,
|
|
334
336
|
"mode": mode.value,
|
|
335
337
|
"displayValues": displayValues.value,
|
|
@@ -381,7 +383,7 @@ var BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
381
383
|
}, null), renderNode]);
|
|
382
384
|
};
|
|
383
385
|
}, {
|
|
384
|
-
props:
|
|
386
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
385
387
|
className: {
|
|
386
388
|
type: String,
|
|
387
389
|
required: false,
|
package/dist/OptionList.js
CHANGED
|
@@ -196,6 +196,7 @@ var OptionList = /* @__PURE__ */ defineComponent({
|
|
|
196
196
|
renderItem(activeIndex.value),
|
|
197
197
|
renderItem(activeIndex.value + 1)
|
|
198
198
|
]), createVNode(List, mergeProps({
|
|
199
|
+
"prefixCls": `${baseProps.value?.prefixCls}-dropdown-list`,
|
|
199
200
|
"itemKey": "key",
|
|
200
201
|
"ref": (el) => {
|
|
201
202
|
listRef.value = el;
|
package/dist/Select.js
CHANGED
|
@@ -55,7 +55,7 @@ function isRawValue(value) {
|
|
|
55
55
|
return !value || typeof value !== "object";
|
|
56
56
|
}
|
|
57
57
|
var Select = /* @__PURE__ */ defineComponent({
|
|
58
|
-
props:
|
|
58
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
59
59
|
prefixCls: {
|
|
60
60
|
type: String,
|
|
61
61
|
required: false,
|
|
@@ -621,7 +621,8 @@ var Select = /* @__PURE__ */ defineComponent({
|
|
|
621
621
|
internalValue.value = val;
|
|
622
622
|
};
|
|
623
623
|
const [mergedValues, getMixedOption] = useCache(computed(() => {
|
|
624
|
-
const
|
|
624
|
+
const newInternalValue = multiple.value && internalValue.value === null ? [] : internalValue.value;
|
|
625
|
+
const values = convert2LabelValues(newInternalValue);
|
|
625
626
|
if (props.mode === "combobox" && isComboNoValue(values[0]?.value)) return [];
|
|
626
627
|
return values;
|
|
627
628
|
}), valueOptions);
|
|
@@ -751,7 +752,8 @@ var Select = /* @__PURE__ */ defineComponent({
|
|
|
751
752
|
setSearchValue("");
|
|
752
753
|
return;
|
|
753
754
|
}
|
|
754
|
-
|
|
755
|
+
const newRawValues = Array.from(/* @__PURE__ */ new Set([...rawValues.value, formatted]));
|
|
756
|
+
triggerChange(newRawValues);
|
|
755
757
|
triggerSelect(formatted, true);
|
|
756
758
|
setSearchValue("");
|
|
757
759
|
}
|
|
@@ -768,7 +770,7 @@ var Select = /* @__PURE__ */ defineComponent({
|
|
|
768
770
|
return labelOptions.value.get(word)?.[mergedFieldNames.value.value];
|
|
769
771
|
}).filter((val) => val !== void 0);
|
|
770
772
|
if (props.mode === "tags") patchValues = patchValues.filter((val) => !valueOptions.value.get(val)?.disabled);
|
|
771
|
-
const newRawValues = Array.from(new Set([...rawValues.value, ...patchValues]));
|
|
773
|
+
const newRawValues = Array.from(/* @__PURE__ */ new Set([...rawValues.value, ...patchValues]));
|
|
772
774
|
triggerChange(newRawValues);
|
|
773
775
|
newRawValues.forEach((newRawValue) => {
|
|
774
776
|
triggerSelect(newRawValue, true);
|
|
@@ -14,7 +14,7 @@ var Placeholder = /* @__PURE__ */ defineComponent((props) => {
|
|
|
14
14
|
return createVNode("div", {
|
|
15
15
|
"class": clsx(`${prefixCls}-placeholder`, classNames?.placeholder),
|
|
16
16
|
"style": {
|
|
17
|
-
|
|
17
|
+
...show ? {} : { visibility: "hidden" },
|
|
18
18
|
...styles?.placeholder
|
|
19
19
|
}
|
|
20
20
|
}, [placeholder]);
|
|
@@ -48,7 +48,8 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
48
48
|
};
|
|
49
49
|
const handlePaste = (event) => {
|
|
50
50
|
const { clipboardData } = event;
|
|
51
|
-
|
|
51
|
+
const pastedValue = clipboardData?.getData?.("text");
|
|
52
|
+
pastedTextRef.value = pastedValue || "";
|
|
52
53
|
};
|
|
53
54
|
const widthCssVar = shallowRef();
|
|
54
55
|
watch([() => props.syncWidth, () => props.value], async () => {
|
|
@@ -56,19 +57,20 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
56
57
|
const input = inputRef.value;
|
|
57
58
|
if (props.syncWidth && input) {
|
|
58
59
|
input.style.width = "0px";
|
|
59
|
-
|
|
60
|
+
const scrollWidth = input.scrollWidth;
|
|
61
|
+
widthCssVar.value = scrollWidth;
|
|
60
62
|
input.style.width = "";
|
|
61
63
|
}
|
|
62
64
|
}, { immediate: true });
|
|
63
65
|
return () => {
|
|
64
66
|
const { style, autoComplete, className, value, readOnly } = props;
|
|
65
|
-
const { prefixCls,
|
|
67
|
+
const { prefixCls, autoFocus, placeholder } = selectInputContext.value ?? {};
|
|
66
68
|
const { input: InputComponent = "input" } = selectInputContext.value?.components ?? {};
|
|
67
69
|
const { styles, id, classNames, open, activeDescendantId, role, disabled } = baseProps.value ?? {};
|
|
68
70
|
const inputCls = clsx(`${prefixCls}-input`, classNames?.input, className);
|
|
69
71
|
const sharedInputProps = {
|
|
70
72
|
id,
|
|
71
|
-
"type":
|
|
73
|
+
"type": "text",
|
|
72
74
|
readOnly,
|
|
73
75
|
...attrs,
|
|
74
76
|
"ref": inputRef,
|
|
@@ -78,7 +80,7 @@ var Input = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
|
78
80
|
"--select-input-width": widthCssVar.value
|
|
79
81
|
},
|
|
80
82
|
autoFocus,
|
|
81
|
-
"autocomplete": autoComplete || "
|
|
83
|
+
"autocomplete": autoComplete || "new-password",
|
|
82
84
|
"class": inputCls,
|
|
83
85
|
disabled,
|
|
84
86
|
"value": value || "",
|
|
@@ -50,6 +50,7 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
50
50
|
const prefix = computed(() => props.prefix);
|
|
51
51
|
const suffix = computed(() => props.suffix);
|
|
52
52
|
const clearIcon = computed(() => props.clearIcon);
|
|
53
|
+
const clearLabel = computed(() => props.clearLabel);
|
|
53
54
|
const multiple = computed(() => props.multiple);
|
|
54
55
|
const mode = computed(() => props.mode);
|
|
55
56
|
const onClearMouseDown = computed(() => props.onClearMouseDown);
|
|
@@ -97,7 +98,7 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
97
98
|
if (!event._select_lazy) {
|
|
98
99
|
inputRef.value?.input?.focus();
|
|
99
100
|
if (!shouldPreventClose) toggleOpen.value?.();
|
|
100
|
-
} else if (triggerOpen.value) toggleOpen.value?.(false);
|
|
101
|
+
} else if (triggerOpen.value && !multiple.value) toggleOpen.value?.(false);
|
|
101
102
|
}
|
|
102
103
|
props?.onMouseDown?.(event);
|
|
103
104
|
};
|
|
@@ -152,14 +153,17 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
152
153
|
"class": clsx(`${prefixCls.value}-suffix`, { [`${prefixCls.value}-suffix-loading`]: loading.value }, classNamesConfig.value?.suffix),
|
|
153
154
|
"style": stylesConfig.value?.suffix
|
|
154
155
|
}, { default: () => [suffix.value] }),
|
|
155
|
-
clearIcon.value && createVNode(
|
|
156
|
+
clearIcon.value && createVNode("button", {
|
|
157
|
+
"type": "button",
|
|
158
|
+
"aria-label": clearLabel.value,
|
|
156
159
|
"class": clsx(`${prefixCls.value}-clear`, classNamesConfig.value?.clear),
|
|
157
160
|
"style": stylesConfig.value?.clear,
|
|
158
161
|
"onMousedown": (e) => {
|
|
162
|
+
e.preventDefault();
|
|
159
163
|
e._select_lazy = true;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
164
|
+
},
|
|
165
|
+
"onClick": (e) => onClearMouseDown.value?.(e)
|
|
166
|
+
}, [clearIcon.value]),
|
|
163
167
|
slots.default?.()
|
|
164
168
|
]);
|
|
165
169
|
};
|
|
@@ -208,6 +212,11 @@ var SelectInput = /* @__PURE__ */ defineComponent((props, { attrs, expose, slots
|
|
|
208
212
|
required: false,
|
|
209
213
|
default: void 0
|
|
210
214
|
},
|
|
215
|
+
clearLabel: {
|
|
216
|
+
type: String,
|
|
217
|
+
required: false,
|
|
218
|
+
default: void 0
|
|
219
|
+
},
|
|
211
220
|
removeIcon: {
|
|
212
221
|
type: [
|
|
213
222
|
Object,
|
package/dist/SelectTrigger.js
CHANGED
|
@@ -84,7 +84,7 @@ var SelectTrigger = /* @__PURE__ */ defineComponent((props, { slots, attrs, expo
|
|
|
84
84
|
}), { default: () => [slots?.default?.()] });
|
|
85
85
|
};
|
|
86
86
|
}, {
|
|
87
|
-
props:
|
|
87
|
+
props: /*@__PURE__*/ mergeDefaults({
|
|
88
88
|
prefixCls: {
|
|
89
89
|
type: String,
|
|
90
90
|
required: true
|
|
@@ -3,7 +3,9 @@ import { DisplayValueType, Mode } from '../interface.ts';
|
|
|
3
3
|
export interface AllowClearConfig {
|
|
4
4
|
allowClear: boolean;
|
|
5
5
|
clearIcon: any;
|
|
6
|
+
label: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function useAllowClear(_prefixCls: Ref<string>, displayValues: Ref<DisplayValueType[]>, allowClear?: Ref<boolean | {
|
|
8
9
|
clearIcon?: any;
|
|
10
|
+
label?: string;
|
|
9
11
|
}>, clearIcon?: Ref<any>, disabled?: Ref<boolean>, mergedSearchValue?: Ref<string | undefined>, mode?: Ref<Mode | undefined>): import('vue').ComputedRef<AllowClearConfig>;
|
|
@@ -10,7 +10,8 @@ function useAllowClear(_prefixCls, displayValues, allowClear, clearIcon, disable
|
|
|
10
10
|
const mergedAllowClear = !disabled?.value && allowClearConfig.value?.allowClear !== false && (displayValues.value.length || mergedSearchValue?.value) && !(mode?.value === "combobox" && mergedSearchValue?.value === "");
|
|
11
11
|
return {
|
|
12
12
|
allowClear: !!mergedAllowClear,
|
|
13
|
-
clearIcon: mergedAllowClear ? allowClearConfig.value.clearIcon || clearIcon?.value || "×" : null
|
|
13
|
+
clearIcon: mergedAllowClear ? allowClearConfig.value.clearIcon || clearIcon?.value || "×" : null,
|
|
14
|
+
label: mergedAllowClear ? allowClearConfig.value.label ?? "Clear" : ""
|
|
14
15
|
};
|
|
15
16
|
});
|
|
16
17
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/select",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"vue": "^3.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@v-c/
|
|
38
|
-
"@v-c/
|
|
39
|
-
"@v-c/util": "^1.0
|
|
40
|
-
"@v-c/
|
|
37
|
+
"@v-c/trigger": "^1.1.0",
|
|
38
|
+
"@v-c/virtual-list": "^1.1.0",
|
|
39
|
+
"@v-c/util": "^1.1.0",
|
|
40
|
+
"@v-c/overflow": "^1.1.1"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "vite build",
|