@antify/ui 3.1.10 → 3.1.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.
|
@@ -78,6 +78,8 @@ const isOpen = ref(false);
|
|
|
78
78
|
const _modelValue = computed<string[]>(() => [
|
|
79
79
|
...props.modelValue || [],
|
|
80
80
|
]);
|
|
81
|
+
let actuallyValueLength = ref<number>(0);
|
|
82
|
+
|
|
81
83
|
const hasInputState = computed(() => props.skeleton || props.readonly || props.disabled);
|
|
82
84
|
const inputClasses = computed(() => {
|
|
83
85
|
const variants: Record<InputState, string> = {
|
|
@@ -148,15 +150,15 @@ const valueLabel = computed(() => {
|
|
|
148
150
|
return;
|
|
149
151
|
}
|
|
150
152
|
|
|
151
|
-
if (
|
|
153
|
+
if (actuallyValueLength.value === 0) {
|
|
152
154
|
return props.label || props.placeholder;
|
|
153
155
|
}
|
|
154
156
|
|
|
155
|
-
if (
|
|
156
|
-
return `${
|
|
157
|
+
if (actuallyValueLength.value === 1) {
|
|
158
|
+
return `${actuallyValueLength.value} ${props.singularValueLabel}`;
|
|
157
159
|
}
|
|
158
160
|
|
|
159
|
-
return `${
|
|
161
|
+
return `${actuallyValueLength.value} ${props.pluralValueLabel}`;
|
|
160
162
|
});
|
|
161
163
|
const iconSize = computed(() => {
|
|
162
164
|
if (props.size === Size.lg || props.size === Size.md || props.size === Size.sm) {
|
|
@@ -165,21 +167,11 @@ const iconSize = computed(() => {
|
|
|
165
167
|
|
|
166
168
|
return IconSize.xs;
|
|
167
169
|
});
|
|
168
|
-
const selectedCheckboxes = ref<string[]>(
|
|
170
|
+
const selectedCheckboxes = ref<string[]>([
|
|
169
171
|
..._modelValue.value,
|
|
170
172
|
]);
|
|
171
173
|
const inputRef = ref<HTMLElement | null>(null);
|
|
172
174
|
|
|
173
|
-
onMounted(() => {
|
|
174
|
-
handleEnumValidation(props.size, Size, 'size');
|
|
175
|
-
handleEnumValidation(props.state, InputState, 'state');
|
|
176
|
-
handleEnumValidation(props.grouped, Grouped, 'grouped');
|
|
177
|
-
|
|
178
|
-
if (!props.skeleton && props.modelValue !== null) {
|
|
179
|
-
emit('validate', props.modelValue);
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
|
|
183
175
|
watch(isOpen, (val) => {
|
|
184
176
|
if (!val) {
|
|
185
177
|
emit('update:modelValue', selectedCheckboxes.value);
|
|
@@ -199,6 +191,8 @@ watch(() => props.skeleton, (val) => {
|
|
|
199
191
|
}
|
|
200
192
|
});
|
|
201
193
|
watch(_modelValue, () => {
|
|
194
|
+
getActuallySelectedItems();
|
|
195
|
+
|
|
202
196
|
if (props.messages.length > 0) {
|
|
203
197
|
emit('validate', props.modelValue);
|
|
204
198
|
}
|
|
@@ -222,6 +216,36 @@ function onClickSelectInput(e: MouseEvent) {
|
|
|
222
216
|
|
|
223
217
|
isOpen.value = !isOpen.value;
|
|
224
218
|
}
|
|
219
|
+
|
|
220
|
+
function onClickClear() {
|
|
221
|
+
const optionValues = props.options.map(option => option.value);
|
|
222
|
+
const clearedValue = _modelValue.value.filter((value) => !optionValues.includes(value));
|
|
223
|
+
|
|
224
|
+
emit('update:modelValue', clearedValue);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function getActuallySelectedItems() {
|
|
228
|
+
actuallyValueLength.value = 0;
|
|
229
|
+
|
|
230
|
+
_modelValue.value.forEach((value) => {
|
|
231
|
+
props.options.forEach((option) => {
|
|
232
|
+
if (value === option.value) {
|
|
233
|
+
actuallyValueLength.value++;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
onMounted(() => {
|
|
240
|
+
getActuallySelectedItems();
|
|
241
|
+
handleEnumValidation(props.size, Size, 'size');
|
|
242
|
+
handleEnumValidation(props.state, InputState, 'state');
|
|
243
|
+
handleEnumValidation(props.grouped, Grouped, 'grouped');
|
|
244
|
+
|
|
245
|
+
if (!props.skeleton && props.modelValue !== null) {
|
|
246
|
+
emit('validate', props.modelValue);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
225
249
|
</script>
|
|
226
250
|
|
|
227
251
|
<template>
|
|
@@ -263,14 +287,14 @@ function onClickSelectInput(e: MouseEvent) {
|
|
|
263
287
|
<slot name="icon" />
|
|
264
288
|
|
|
265
289
|
<div
|
|
266
|
-
v-if="(_modelValue === null ||
|
|
290
|
+
v-if="(_modelValue === null || actuallyValueLength === 0) && placeholder !== undefined"
|
|
267
291
|
:class="placeholderClasses"
|
|
268
292
|
>
|
|
269
293
|
{{ placeholder }}
|
|
270
294
|
</div>
|
|
271
295
|
|
|
272
296
|
<div
|
|
273
|
-
v-else-if="(_modelValue === null ||
|
|
297
|
+
v-else-if="(_modelValue === null || actuallyValueLength === 0) && label !== undefined"
|
|
274
298
|
:class="placeholderClasses"
|
|
275
299
|
>
|
|
276
300
|
{{ label }}
|
|
@@ -311,7 +335,7 @@ function onClickSelectInput(e: MouseEvent) {
|
|
|
311
335
|
:icon-left="faMultiply"
|
|
312
336
|
:grouped="Grouped.right"
|
|
313
337
|
:size="size"
|
|
314
|
-
@click="
|
|
338
|
+
@click="onClickClear"
|
|
315
339
|
/>
|
|
316
340
|
</div>
|
|
317
341
|
</AntSkeleton>
|