@mptw/skylens-ui 1.2.10 → 1.2.11
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.
|
@@ -111,36 +111,53 @@ export default defineComponent({
|
|
|
111
111
|
>,
|
|
112
112
|
default: () => [],
|
|
113
113
|
},
|
|
114
|
+
query: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: '',
|
|
117
|
+
}
|
|
114
118
|
},
|
|
115
|
-
emits: ["update:modelValue", "update:selecting"],
|
|
119
|
+
emits: ["update:modelValue", "update:selecting", 'update:query'],
|
|
116
120
|
setup(props, { emit }) {
|
|
117
|
-
const { size, modelValue, options, placement } = toRefs(props);
|
|
121
|
+
const { size, modelValue, options, placement, query } = toRefs(props);
|
|
118
122
|
|
|
119
123
|
const selectEl = shallowRef<HTMLElement | null>(null);
|
|
120
124
|
const toggleEl = shallowRef<HTMLElement | null>(null);
|
|
121
125
|
const popupEl = shallowRef<HTMLElement | null>(null);
|
|
122
|
-
const
|
|
126
|
+
const selfQuery = ref("");
|
|
123
127
|
const selectedFirstOption = ref<string | null>(null);
|
|
124
128
|
const isSelecting = ref(false);
|
|
125
129
|
|
|
126
130
|
let popperInstance: any = null;
|
|
127
131
|
let clickSubscriber: any = null;
|
|
128
132
|
|
|
133
|
+
const queryProxy = computed({
|
|
134
|
+
get() { query.value || selfQuery },
|
|
135
|
+
set(newValue: string) {
|
|
136
|
+
emit('update:query', newValue);
|
|
137
|
+
selfQuery.value = newValue;
|
|
138
|
+
},
|
|
139
|
+
});
|
|
129
140
|
const sizeClass = computed(() => {
|
|
130
141
|
if (size.value === "") return "";
|
|
131
142
|
return `two-layer-multi-select-${size.value}`;
|
|
132
143
|
});
|
|
133
144
|
const filteredOptions = computed(() => {
|
|
134
|
-
if (
|
|
145
|
+
if (queryProxy.value === "") {
|
|
135
146
|
return options.value;
|
|
136
147
|
}
|
|
137
148
|
|
|
138
149
|
const regexp = new RegExp(`.*${query.value}.*`, "i");
|
|
139
150
|
return options.value
|
|
140
|
-
.map((option) =>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
.map((option) => {
|
|
152
|
+
if (regexp.test(option.name)) {
|
|
153
|
+
return option;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
...option,
|
|
158
|
+
subOptions: option.subOptions.filter((o) => regexp.test(o.name)),
|
|
159
|
+
};
|
|
160
|
+
})
|
|
144
161
|
.filter((option) => option.subOptions.length > 0);
|
|
145
162
|
});
|
|
146
163
|
const firstOptions = computed(() => {
|
|
@@ -309,7 +326,7 @@ export default defineComponent({
|
|
|
309
326
|
selectEl,
|
|
310
327
|
toggleEl,
|
|
311
328
|
popupEl,
|
|
312
|
-
|
|
329
|
+
queryProxy,
|
|
313
330
|
sizeClass,
|
|
314
331
|
selectedFirstOption,
|
|
315
332
|
firstOptions,
|