@v-c/select 1.0.11 → 1.0.13-beta.1
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 +1 -4
- package/dist/OptionList.js +21 -7
- package/package.json +2 -2
package/dist/BaseSelect/index.js
CHANGED
|
@@ -137,11 +137,8 @@ const BaseSelect = /* @__PURE__ */ defineComponent((props, { expose, attrs }) =>
|
|
|
137
137
|
if (!searchText || !searchText.trim()) return;
|
|
138
138
|
props?.onSearch?.(searchText, { source: "submit" });
|
|
139
139
|
};
|
|
140
|
-
watch(mergedOpen, () => {
|
|
141
|
-
if (!mergedOpen.value && !multiple.value && mode.value !== "combobox") onInternalSearch("", false, false);
|
|
142
|
-
}, { immediate: true });
|
|
143
140
|
watch(rawOpen, () => {
|
|
144
|
-
if (!rawOpen.value && !multiple.value && mode.value
|
|
141
|
+
if (!rawOpen.value && !multiple.value && mode.value !== "combobox") onInternalSearch("", false, false);
|
|
145
142
|
}, { immediate: true });
|
|
146
143
|
watch([disabled, mergedOpen], () => {
|
|
147
144
|
if (disabled.value) {
|
package/dist/OptionList.js
CHANGED
|
@@ -57,20 +57,31 @@ var OptionList_default = /* @__PURE__ */ defineComponent({
|
|
|
57
57
|
}
|
|
58
58
|
context.value?.onActiveValue?.(flattenItem.value, index, info);
|
|
59
59
|
};
|
|
60
|
+
const getActiveIndexByRawValue = () => {
|
|
61
|
+
const rawValues = context.value?.rawValues;
|
|
62
|
+
if (baseProps.value?.multiple || rawValues?.size !== 1) return -1;
|
|
63
|
+
const value = Array.from(rawValues)[0];
|
|
64
|
+
const searchValue = baseProps.value?.searchValue;
|
|
65
|
+
return memoFlattenOptions.value.findIndex(({ data }) => searchValue ? String(data?.value).startsWith(searchValue) : data?.value === value);
|
|
66
|
+
};
|
|
60
67
|
watch([() => memoFlattenOptions.value.length, () => baseProps.value?.searchValue], () => {
|
|
61
|
-
|
|
68
|
+
const defaultFirst = context.value?.defaultActiveFirstOption !== false;
|
|
69
|
+
const activeIndexByRawValue = getActiveIndexByRawValue();
|
|
70
|
+
setActive(activeIndexByRawValue !== -1 ? activeIndexByRawValue : defaultFirst ? getEnabledActiveIndex(0) : -1);
|
|
62
71
|
}, { immediate: true });
|
|
63
72
|
const isAriaSelected = (value) => {
|
|
64
73
|
if (baseProps.value?.mode === "combobox") return String(value).toLowerCase() === (baseProps.value?.searchValue || "").toLowerCase();
|
|
65
74
|
return context.value?.rawValues?.has(value) || false;
|
|
66
75
|
};
|
|
67
|
-
watch([
|
|
76
|
+
watch([
|
|
77
|
+
() => baseProps.value?.open,
|
|
78
|
+
() => baseProps.value?.searchValue,
|
|
79
|
+
() => memoFlattenOptions.value.length
|
|
80
|
+
], (_$1, __, onCleanup) => {
|
|
68
81
|
let timeoutId;
|
|
69
82
|
const rawValues = context.value?.rawValues;
|
|
70
83
|
if (!baseProps.value?.multiple && baseProps.value?.open && rawValues?.size === 1) {
|
|
71
|
-
const
|
|
72
|
-
const searchValue = baseProps.value?.searchValue;
|
|
73
|
-
const index = memoFlattenOptions.value.findIndex(({ data }) => searchValue ? String(data.value).startsWith(searchValue) : data.value === value);
|
|
84
|
+
const index = getActiveIndexByRawValue();
|
|
74
85
|
if (index !== -1) {
|
|
75
86
|
setActive(index);
|
|
76
87
|
timeoutId = setTimeout(() => {
|
|
@@ -79,9 +90,12 @@ var OptionList_default = /* @__PURE__ */ defineComponent({
|
|
|
79
90
|
}
|
|
80
91
|
}
|
|
81
92
|
if (baseProps.value?.open) listRef.value?.scrollTo(void 0);
|
|
82
|
-
|
|
93
|
+
onCleanup(() => {
|
|
83
94
|
if (timeoutId) clearTimeout(timeoutId);
|
|
84
|
-
};
|
|
95
|
+
});
|
|
96
|
+
}, {
|
|
97
|
+
immediate: true,
|
|
98
|
+
flush: "post"
|
|
85
99
|
});
|
|
86
100
|
const onSelectValue = (value) => {
|
|
87
101
|
if (value !== void 0) context.value?.onSelect?.(value, { selected: !context.value?.rawValues?.has(value) });
|
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.13-beta.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"vue": "^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@v-c/trigger": "^1.0.11",
|
|
33
32
|
"@v-c/overflow": "^1.0.3",
|
|
33
|
+
"@v-c/trigger": "^1.0.11",
|
|
34
34
|
"@v-c/util": "^1.0.14",
|
|
35
35
|
"@v-c/virtual-list": "^1.0.6"
|
|
36
36
|
},
|