@v-c/select 1.0.9 → 1.0.10
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.js +9 -4
- package/dist/SelectInput/Content/SingleContent.js +32 -26
- package/dist/hooks/useBaseProps.d.ts +1 -0
- package/dist/hooks/useOpen.d.ts +1 -1
- package/dist/hooks/useOpen.js +3 -2
- package/package.json +4 -4
- package/dist/BaseSelect/Polite.cjs +0 -40
- package/dist/BaseSelect/index.cjs +0 -778
- package/dist/OptGroup.cjs +0 -8
- package/dist/Option.cjs +0 -8
- package/dist/OptionList.cjs +0 -258
- package/dist/Select.cjs +0 -838
- package/dist/SelectContext.cjs +0 -12
- package/dist/SelectInput/Affix.cjs +0 -19
- package/dist/SelectInput/Content/MultipleContent.cjs +0 -145
- package/dist/SelectInput/Content/Placeholder.cjs +0 -36
- package/dist/SelectInput/Content/SingleContent.cjs +0 -83
- package/dist/SelectInput/Content/index.cjs +0 -43
- package/dist/SelectInput/Input.cjs +0 -179
- package/dist/SelectInput/context.cjs +0 -12
- package/dist/SelectInput/index.cjs +0 -341
- package/dist/SelectTrigger.cjs +0 -198
- package/dist/TransBtn.cjs +0 -72
- package/dist/_virtual/rolldown_runtime.cjs +0 -21
- package/dist/hooks/index.cjs +0 -24
- package/dist/hooks/useAllowClear.cjs +0 -18
- package/dist/hooks/useBaseProps.cjs +0 -15
- package/dist/hooks/useCache.cjs +0 -39
- package/dist/hooks/useComponents.cjs +0 -18
- package/dist/hooks/useFilterOptions.cjs +0 -42
- package/dist/hooks/useLock.cjs +0 -29
- package/dist/hooks/useOpen.cjs +0 -63
- package/dist/hooks/useOptions.cjs +0 -41
- package/dist/hooks/useRefFunc.cjs +0 -15
- package/dist/hooks/useSearchConfig.cjs +0 -26
- package/dist/hooks/useSelectTriggerControl.cjs +0 -26
- package/dist/index.cjs +0 -22
- package/dist/interface.cjs +0 -1
- package/dist/utils/commonUtil.cjs +0 -38
- package/dist/utils/keyUtil.cjs +0 -37
- package/dist/utils/legacyUtil.cjs +0 -33
- package/dist/utils/platformUtil.cjs +0 -6
- package/dist/utils/valueUtil.cjs +0 -80
package/dist/BaseSelect/index.js
CHANGED
|
@@ -107,7 +107,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
107
107
|
return props.notFoundContent ?? "Not Found";
|
|
108
108
|
});
|
|
109
109
|
const emptyListContent = computed(() => !props?.notFoundContent && props.emptyOptions);
|
|
110
|
-
const [mergedOpen, triggerOpen, lockOptions] = useOpen(open, (openVal) => {
|
|
110
|
+
const [rawOpen, mergedOpen, triggerOpen, lockOptions] = useOpen(props?.defaultOpen || false, open, (openVal) => {
|
|
111
111
|
props.onPopupVisibleChange?.(openVal);
|
|
112
112
|
}, (nextOpen) => {
|
|
113
113
|
return props.disabled || emptyListContent.value ? false : nextOpen;
|
|
@@ -140,6 +140,9 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
140
140
|
watch(mergedOpen, () => {
|
|
141
141
|
if (!mergedOpen.value && !multiple.value && mode.value !== "combobox") onInternalSearch("", false, false);
|
|
142
142
|
}, { immediate: true });
|
|
143
|
+
watch(rawOpen, () => {
|
|
144
|
+
if (!rawOpen.value && !multiple.value && mode.value === "combobox") onInternalSearch("", false, false);
|
|
145
|
+
}, { immediate: true });
|
|
143
146
|
watch([disabled, mergedOpen], () => {
|
|
144
147
|
if (disabled.value) {
|
|
145
148
|
triggerOpen(false);
|
|
@@ -152,7 +155,8 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
152
155
|
const clearLock = getClearLock();
|
|
153
156
|
const { key } = event;
|
|
154
157
|
const isEnterKey = key === KeyCodeStr.Enter;
|
|
155
|
-
|
|
158
|
+
const isSpaceKey = key === KeyCodeStr.Space;
|
|
159
|
+
if (isEnterKey || isSpaceKey) {
|
|
156
160
|
if (mode.value !== "combobox") event.preventDefault();
|
|
157
161
|
if (!mergedOpen.value) triggerOpen(true);
|
|
158
162
|
}
|
|
@@ -173,7 +177,7 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
173
177
|
values: [removedDisplayValue]
|
|
174
178
|
});
|
|
175
179
|
}
|
|
176
|
-
if (mergedOpen.value && (!isEnterKey || !keyLockRef.value)) {
|
|
180
|
+
if (mergedOpen.value && (!isEnterKey || !keyLockRef.value) && !isSpaceKey) {
|
|
177
181
|
if (isEnterKey) keyLockRef.value = true;
|
|
178
182
|
listRef.value?.onKeyDown?.(event);
|
|
179
183
|
}
|
|
@@ -237,7 +241,8 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
237
241
|
triggerOpen: mergedOpen.value,
|
|
238
242
|
toggleOpen: triggerOpen,
|
|
239
243
|
multiple: multiple.value,
|
|
240
|
-
lockOptions: lockOptions.value
|
|
244
|
+
lockOptions: lockOptions.value,
|
|
245
|
+
rawOpen: rawOpen.value
|
|
241
246
|
};
|
|
242
247
|
}));
|
|
243
248
|
const onClearMouseDown = () => {
|
|
@@ -17,32 +17,30 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
|
|
|
17
17
|
if (combobox.value && selectInputContext.value?.activeValue && !inputChanged.value && baseProps.value?.triggerOpen) return selectInputContext.value.activeValue;
|
|
18
18
|
return baseProps.value?.showSearch ? selectInputContext.value?.searchValue : "";
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
let restProps = {
|
|
22
|
-
class: `${selectInputContext.value?.prefixCls}-content-value`,
|
|
23
|
-
style: mergedSearchValue.value ? { visibility: "hidden" } : {}
|
|
24
|
-
};
|
|
20
|
+
const optionClassName = computed(() => {
|
|
25
21
|
if (displayValue.value && selectContext.value?.flattenOptions) {
|
|
26
22
|
const option = selectContext.value.flattenOptions.find((opt) => opt.value === displayValue.value?.value);
|
|
27
|
-
if (option?.data)
|
|
28
|
-
const { label, value, className, style, key, children, ...rest } = option.data;
|
|
29
|
-
restProps = {
|
|
30
|
-
...restProps,
|
|
31
|
-
...rest,
|
|
32
|
-
title: getTitle(option.data),
|
|
33
|
-
class: clsx(restProps.class, className),
|
|
34
|
-
style: {
|
|
35
|
-
...restProps.style,
|
|
36
|
-
...style
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
}
|
|
23
|
+
if (option?.data) return option.data.className || option.data.class;
|
|
40
24
|
}
|
|
41
|
-
if (displayValue.value && !restProps.title) restProps.title = getTitle(displayValue.value);
|
|
42
|
-
if (baseProps.value?.title !== void 0) restProps.title = baseProps.value.title;
|
|
43
|
-
return restProps;
|
|
44
25
|
});
|
|
45
|
-
|
|
26
|
+
const optionStyle = computed(() => {
|
|
27
|
+
if (displayValue.value && selectContext.value?.flattenOptions) {
|
|
28
|
+
const option = selectContext.value.flattenOptions.find((opt) => opt.value === displayValue.value?.value);
|
|
29
|
+
if (option?.data) return option.data.style;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const optionTitle = computed(() => {
|
|
33
|
+
let titleValue;
|
|
34
|
+
if (displayValue.value && selectContext.value?.flattenOptions) {
|
|
35
|
+
const option = selectContext.value.flattenOptions.find((opt) => opt.value === displayValue.value?.value);
|
|
36
|
+
if (option?.data) titleValue = getTitle(option.data);
|
|
37
|
+
}
|
|
38
|
+
if (displayValue.value && !titleValue) titleValue = getTitle(displayValue.value);
|
|
39
|
+
if (baseProps.value?.title !== void 0) titleValue = baseProps.value.title;
|
|
40
|
+
return titleValue;
|
|
41
|
+
});
|
|
42
|
+
const hasOptionStyle = computed(() => !!optionClassName.value || !!optionStyle.value);
|
|
43
|
+
watch([combobox, () => selectInputContext.value?.activeValue], () => {
|
|
46
44
|
if (combobox.value) inputChanged.value = false;
|
|
47
45
|
}, { immediate: true });
|
|
48
46
|
const inputRef = shallowRef();
|
|
@@ -51,16 +49,24 @@ var SingleContent_default = /* @__PURE__ */ defineComponent((props, { expose })
|
|
|
51
49
|
const { prefixCls, mode, maxLength } = selectInputContext.value ?? {};
|
|
52
50
|
const { classNames, styles } = baseProps.value ?? {};
|
|
53
51
|
const { inputProps } = props;
|
|
52
|
+
const renderValue = displayValue.value ? hasOptionStyle.value ? createVNode("div", {
|
|
53
|
+
"class": clsx(`${prefixCls}-content-value`, optionClassName.value),
|
|
54
|
+
"style": {
|
|
55
|
+
...mergedSearchValue.value ? { visibility: "hidden" } : {},
|
|
56
|
+
...optionStyle.value
|
|
57
|
+
},
|
|
58
|
+
"title": optionTitle.value
|
|
59
|
+
}, [displayValue.value.label]) : displayValue.value.label : createVNode(Placeholder_default, { "show": !mergedSearchValue.value }, null);
|
|
54
60
|
return createVNode("div", {
|
|
55
|
-
"class": clsx(`${prefixCls}-content`, classNames?.content),
|
|
56
|
-
"style": styles?.content
|
|
57
|
-
|
|
61
|
+
"class": clsx(`${prefixCls}-content`, displayValue.value && `${prefixCls}-content-has-value`, mergedSearchValue.value && `${prefixCls}-content-has-search-value`, hasOptionStyle.value && `${prefixCls}-content-has-option-style`, classNames?.content),
|
|
62
|
+
"style": styles?.content,
|
|
63
|
+
"title": hasOptionStyle.value ? void 0 : optionTitle.value
|
|
64
|
+
}, [renderValue, createVNode(Input_default, mergeProps(inputProps, {
|
|
58
65
|
"value": mergedSearchValue.value,
|
|
59
66
|
"maxLength": mode === "combobox" ? maxLength : void 0,
|
|
60
67
|
"onChange": (e) => {
|
|
61
68
|
inputChanged.value = true;
|
|
62
69
|
inputProps.onChange?.(e);
|
|
63
|
-
inputProps.onInput?.(e);
|
|
64
70
|
},
|
|
65
71
|
"ref": inputRef
|
|
66
72
|
}), null)]);
|
|
@@ -6,6 +6,7 @@ export interface BaseSelectContextProps extends BaseSelectProps {
|
|
|
6
6
|
toggleOpen: (open?: boolean) => void;
|
|
7
7
|
role?: string;
|
|
8
8
|
lockOptions: boolean;
|
|
9
|
+
rawOpen: boolean;
|
|
9
10
|
}
|
|
10
11
|
export declare function useBaseSelectProvider(context: Ref<BaseSelectContextProps>): void;
|
|
11
12
|
export default function useBaseProps(): Ref<BaseSelectContextProps | null>;
|
package/dist/hooks/useOpen.d.ts
CHANGED
|
@@ -16,4 +16,4 @@ export type TriggerOpenType = (nextOpen?: boolean, config?: {
|
|
|
16
16
|
* SSR handling: During SSR, `open` is always false to avoid Portal issues.
|
|
17
17
|
* On client-side hydration, it syncs with the actual open state.
|
|
18
18
|
*/
|
|
19
|
-
export default function useOpen(propOpen: Ref<boolean>, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): readonly [import('vue').ComputedRef<boolean>, TriggerOpenType, import('vue').ShallowRef<boolean, boolean>];
|
|
19
|
+
export default function useOpen(defaultOpen: boolean, propOpen: Ref<boolean>, onOpen: (nextOpen: boolean) => void, postOpen: (nextOpen: boolean) => boolean): readonly [import('vue').ComputedRef<boolean>, import('vue').ComputedRef<boolean>, TriggerOpenType, import('vue').ShallowRef<boolean, boolean>];
|
package/dist/hooks/useOpen.js
CHANGED
|
@@ -13,12 +13,12 @@ function macroTask(fn, times = 1) {
|
|
|
13
13
|
macroTask(fn, times - 1);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
function useOpen(propOpen, onOpen, postOpen) {
|
|
16
|
+
function useOpen(defaultOpen, propOpen, onOpen, postOpen) {
|
|
17
17
|
const rendered = shallowRef(propOpen.value ?? false);
|
|
18
18
|
onMounted(() => {
|
|
19
19
|
rendered.value = true;
|
|
20
20
|
});
|
|
21
|
-
const stateOpen = shallowRef(propOpen.value ?? false);
|
|
21
|
+
const stateOpen = shallowRef(propOpen.value ?? defaultOpen ?? false);
|
|
22
22
|
watch(propOpen, () => {
|
|
23
23
|
stateOpen.value = propOpen.value;
|
|
24
24
|
});
|
|
@@ -49,6 +49,7 @@ function useOpen(propOpen, onOpen, postOpen) {
|
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
return [
|
|
52
|
+
ssrSafeOpen,
|
|
52
53
|
mergedOpen,
|
|
53
54
|
toggleOpen,
|
|
54
55
|
lock
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@v-c/select",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.10",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
".": {
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
|
-
"
|
|
18
|
+
"default": "./dist/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./dist/*": "./dist/*",
|
|
21
21
|
"./package.json": "./package.json"
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@v-c/overflow": "^1.0.3",
|
|
33
|
-
"@v-c/trigger": "^1.0.
|
|
34
|
-
"@v-c/util": "^1.0.
|
|
33
|
+
"@v-c/trigger": "^1.0.11",
|
|
34
|
+
"@v-c/util": "^1.0.14",
|
|
35
35
|
"@v-c/virtual-list": "^1.0.5"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
Object.defineProperties(exports, {
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_rolldown_runtime = require("../_virtual/rolldown_runtime.cjs");
|
|
6
|
-
let vue = require("vue");
|
|
7
|
-
var Polite = /* @__PURE__ */ (0, vue.defineComponent)((props) => {
|
|
8
|
-
return () => {
|
|
9
|
-
const { visible, values } = props;
|
|
10
|
-
if (!visible) return null;
|
|
11
|
-
const MAX_COUNT = 50;
|
|
12
|
-
return (0, vue.createVNode)("span", {
|
|
13
|
-
"aria-live": "polite",
|
|
14
|
-
"style": {
|
|
15
|
-
width: 0,
|
|
16
|
-
height: 0,
|
|
17
|
-
position: "absolute",
|
|
18
|
-
overflow: "hidden",
|
|
19
|
-
opacity: 0
|
|
20
|
-
}
|
|
21
|
-
}, [`${values.slice(0, MAX_COUNT).map(({ label, value }) => ["number", "string"].includes(typeof label) ? label : (0, vue.isVNode)(label) || Array.isArray(label) ? label : value).join(", ")}`, values.length > MAX_COUNT ? ", ..." : null]);
|
|
22
|
-
};
|
|
23
|
-
}, {
|
|
24
|
-
props: {
|
|
25
|
-
visible: {
|
|
26
|
-
type: Boolean,
|
|
27
|
-
required: true,
|
|
28
|
-
default: void 0
|
|
29
|
-
},
|
|
30
|
-
values: {
|
|
31
|
-
type: Array,
|
|
32
|
-
required: true,
|
|
33
|
-
default: void 0
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
name: "Polite",
|
|
37
|
-
inheritAttrs: false
|
|
38
|
-
});
|
|
39
|
-
var Polite_default = Polite;
|
|
40
|
-
exports.default = Polite_default;
|