vueless 1.2.8-beta.6 → 1.2.8-beta.7
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { watch, computed, useId, ref, useTemplateRef, nextTick
|
|
2
|
+
import { watch, computed, useId, ref, useTemplateRef, nextTick } from "vue";
|
|
3
3
|
import { isEqual } from "lodash-es";
|
|
4
4
|
|
|
5
5
|
import useUI from "../composables/useUI";
|
|
@@ -65,8 +65,6 @@ const emit = defineEmits([
|
|
|
65
65
|
"update:search",
|
|
66
66
|
]);
|
|
67
67
|
|
|
68
|
-
const attrs = useAttrs();
|
|
69
|
-
|
|
70
68
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
71
69
|
const listboxInputRef = useTemplateRef<{ input: HTMLInputElement }>("listbox-input");
|
|
72
70
|
const optionsRef = useTemplateRef<HTMLLIElement[]>("option");
|
|
@@ -75,7 +73,7 @@ const addOptionRef = useTemplateRef<HTMLLIElement>("add-option");
|
|
|
75
73
|
|
|
76
74
|
const wrapperMaxHeight = ref("");
|
|
77
75
|
|
|
78
|
-
const
|
|
76
|
+
const localSearch = ref(props.search ?? "");
|
|
79
77
|
|
|
80
78
|
const { pointer, pointerDirty, pointerSet, pointerBackward, pointerForward, pointerReset } =
|
|
81
79
|
usePointer(props.options, optionsRef, wrapperRef);
|
|
@@ -88,13 +86,12 @@ const { localeMessages } = useComponentLocaleMessages<typeof defaultConfig.i18n>
|
|
|
88
86
|
props?.config?.i18n,
|
|
89
87
|
);
|
|
90
88
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const search = computed({
|
|
94
|
-
get: () => (isControlledSearch.value ? (props.search ?? "") : internalSearch.value),
|
|
89
|
+
const searchModel = computed({
|
|
90
|
+
get: () => localSearch.value,
|
|
95
91
|
set: (value: string) => {
|
|
96
92
|
emit("update:search", value);
|
|
97
|
-
|
|
93
|
+
|
|
94
|
+
localSearch.value = value ?? "";
|
|
98
95
|
},
|
|
99
96
|
});
|
|
100
97
|
|
|
@@ -107,7 +104,7 @@ const selectedValue = computed({
|
|
|
107
104
|
return props.modelValue;
|
|
108
105
|
},
|
|
109
106
|
set: (value) => {
|
|
110
|
-
if (
|
|
107
|
+
if (searchModel.value) searchModel.value = "";
|
|
111
108
|
|
|
112
109
|
emit("update:modelValue", value);
|
|
113
110
|
},
|
|
@@ -118,7 +115,7 @@ const addOptionKeyCombination = computed(() => {
|
|
|
118
115
|
});
|
|
119
116
|
|
|
120
117
|
const filteredOptions = computed(() => {
|
|
121
|
-
const normalizedSearch =
|
|
118
|
+
const normalizedSearch = searchModel.value.toLowerCase().trim();
|
|
122
119
|
|
|
123
120
|
let options = [...props.options];
|
|
124
121
|
|
|
@@ -136,14 +133,7 @@ const filteredOptions = computed(() => {
|
|
|
136
133
|
});
|
|
137
134
|
|
|
138
135
|
watch(
|
|
139
|
-
() => props.
|
|
140
|
-
(value) => {
|
|
141
|
-
if (isControlledSearch.value) internalSearch.value = value ?? "";
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
watch(
|
|
146
|
-
() => [props.options, props.size, props.visibleOptions, props.searchable, search.value],
|
|
136
|
+
() => [props.options, props.size, props.visibleOptions, props.searchable, searchModel.value],
|
|
147
137
|
() => {
|
|
148
138
|
nextTick(() => {
|
|
149
139
|
const options = [
|
|
@@ -444,7 +434,7 @@ const {
|
|
|
444
434
|
v-if="searchable"
|
|
445
435
|
:id="elementId"
|
|
446
436
|
ref="listbox-input"
|
|
447
|
-
v-model="
|
|
437
|
+
v-model="searchModel"
|
|
448
438
|
:placeholder="localeMessages.search"
|
|
449
439
|
:size="size"
|
|
450
440
|
:debounce="debounce"
|