@pequity/squirrel 6.0.1 → 6.0.2
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/cjs/p-dropdown.js +2 -6
- package/dist/cjs/useSelectList.js +12 -5
- package/dist/es/p-dropdown.js +2 -6
- package/dist/es/useSelectList.js +13 -6
- package/dist/squirrel/components/p-dropdown/p-dropdown.vue.d.ts +5 -403
- package/package.json +5 -5
- package/squirrel/components/p-dropdown/p-dropdown.vue +3 -9
- package/squirrel/components/p-dropdown-select/p-dropdown-select.spec.js +47 -1
- package/squirrel/components/p-select-list/p-select-list.spec.js +39 -0
- package/squirrel/components/p-select-list/useSelectList.ts +27 -7
- package/squirrel/utils/listKeyboardNavigation.spec.js +36 -0
package/dist/cjs/p-dropdown.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const listKeyboardNavigation = require("./listKeyboardNavigation.js");
|
|
3
|
-
const floatingVue = require("floating-vue");
|
|
4
3
|
const vue = require("vue");
|
|
5
4
|
const _pluginVue_exportHelper = require("./chunks/_plugin-vue_export-helper.js");
|
|
6
5
|
const ESCAPE_KEY = "Escape";
|
|
@@ -13,9 +12,6 @@ const nextFrame = () => {
|
|
|
13
12
|
};
|
|
14
13
|
const _sfc_main = vue.defineComponent({
|
|
15
14
|
name: "PDropdown",
|
|
16
|
-
components: {
|
|
17
|
-
Dropdown: floatingVue.Dropdown
|
|
18
|
-
},
|
|
19
15
|
inheritAttrs: false,
|
|
20
16
|
props: {
|
|
21
17
|
/**
|
|
@@ -110,8 +106,8 @@ const _sfc_main = vue.defineComponent({
|
|
|
110
106
|
}
|
|
111
107
|
});
|
|
112
108
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
113
|
-
const
|
|
114
|
-
return vue.openBlock(), vue.createBlock(
|
|
109
|
+
const _component_VDropdown = vue.resolveComponent("VDropdown");
|
|
110
|
+
return vue.openBlock(), vue.createBlock(_component_VDropdown, vue.mergeProps({ ref: "vPopper" }, { ..._ctx.defaultAttrs, ..._ctx.$attrs }, {
|
|
115
111
|
onShow: _ctx.onShow,
|
|
116
112
|
onHide: _ctx.destroy
|
|
117
113
|
}), vue.createSlots({ _: 2 }, [
|
|
@@ -39,6 +39,9 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
|
|
|
39
39
|
const selectedItems = vue.computed(() => {
|
|
40
40
|
return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]));
|
|
41
41
|
});
|
|
42
|
+
const deselectedItems = vue.computed(() => {
|
|
43
|
+
return internalItems.value.filter((item) => !internalValue.value.includes(item[props.itemValue]));
|
|
44
|
+
});
|
|
42
45
|
const computedItems = vue.computed(() => {
|
|
43
46
|
return lodashEs.cloneDeep(internalItems.value).filter((item) => {
|
|
44
47
|
return String(item[props.itemText]).toLocaleLowerCase().includes(String(search.value).toLocaleLowerCase());
|
|
@@ -205,17 +208,21 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
|
|
|
205
208
|
return internalItems.value.indexOf(selectedItems.value[0]);
|
|
206
209
|
};
|
|
207
210
|
const selectAll = () => {
|
|
208
|
-
if (!props.multiple)
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
+
if (!props.multiple) return;
|
|
211
212
|
const selectedItems2 = internalValue.value;
|
|
213
|
+
const deselectedDisabledItemsValues = deselectedItems.value.filter((item) => isDisabled(item)).map((item) => item[props.itemValue]);
|
|
212
214
|
const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
|
|
213
|
-
const
|
|
215
|
+
const uniqueItems = lodashEs.uniqBy([...selectedItems2, ...filteredItems], (item) => item);
|
|
216
|
+
const toEmit = lodashEs.difference(uniqueItems, deselectedDisabledItemsValues);
|
|
214
217
|
emit("update:modelValue", toArrOfObjIfNeeded(toEmit));
|
|
215
218
|
};
|
|
216
219
|
const clearAll = () => {
|
|
220
|
+
if (!props.multiple) return;
|
|
217
221
|
search.value = "";
|
|
218
|
-
|
|
222
|
+
const disabledItemsValues = internalItems.value.filter((item) => isDisabled(item)).map((item) => item[props.itemValue]);
|
|
223
|
+
const selectedItemsValues = internalValue.value;
|
|
224
|
+
const selectedDisabledItems = lodashEs.intersection(disabledItemsValues, selectedItemsValues);
|
|
225
|
+
emit("update:modelValue", toArrOfObjIfNeeded(selectedDisabledItems));
|
|
219
226
|
};
|
|
220
227
|
vue.watch(
|
|
221
228
|
() => props.items,
|
package/dist/es/p-dropdown.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { setupListKeyboardNavigation } from "./listKeyboardNavigation.js";
|
|
2
|
-
import { Dropdown } from "floating-vue";
|
|
3
2
|
import { defineComponent, resolveComponent, openBlock, createBlock, mergeProps, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps } from "vue";
|
|
4
3
|
import { _ as _export_sfc } from "./chunks/_plugin-vue_export-helper.js";
|
|
5
4
|
const ESCAPE_KEY = "Escape";
|
|
@@ -12,9 +11,6 @@ const nextFrame = () => {
|
|
|
12
11
|
};
|
|
13
12
|
const _sfc_main = defineComponent({
|
|
14
13
|
name: "PDropdown",
|
|
15
|
-
components: {
|
|
16
|
-
Dropdown
|
|
17
|
-
},
|
|
18
14
|
inheritAttrs: false,
|
|
19
15
|
props: {
|
|
20
16
|
/**
|
|
@@ -109,8 +105,8 @@ const _sfc_main = defineComponent({
|
|
|
109
105
|
}
|
|
110
106
|
});
|
|
111
107
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
112
|
-
const
|
|
113
|
-
return openBlock(), createBlock(
|
|
108
|
+
const _component_VDropdown = resolveComponent("VDropdown");
|
|
109
|
+
return openBlock(), createBlock(_component_VDropdown, mergeProps({ ref: "vPopper" }, { ..._ctx.defaultAttrs, ..._ctx.$attrs }, {
|
|
114
110
|
onShow: _ctx.onShow,
|
|
115
111
|
onHide: _ctx.destroy
|
|
116
112
|
}), createSlots({ _: 2 }, [
|
package/dist/es/useSelectList.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isObject } from "./object.js";
|
|
|
2
2
|
import { setupListKeyboardNavigation } from "./listKeyboardNavigation.js";
|
|
3
3
|
import { toString } from "./string.js";
|
|
4
4
|
import { useVirtualizer } from "@tanstack/vue-virtual";
|
|
5
|
-
import { cloneDeep, uniqBy } from "lodash-es";
|
|
5
|
+
import { cloneDeep, uniqBy, difference, intersection } from "lodash-es";
|
|
6
6
|
import { ref, computed, watch, onUnmounted, nextTick } from "vue";
|
|
7
7
|
const createInternalItems = (items) => {
|
|
8
8
|
let arr = Array.isArray(items) ? items.slice() : [];
|
|
@@ -37,6 +37,9 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
|
|
|
37
37
|
const selectedItems = computed(() => {
|
|
38
38
|
return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]));
|
|
39
39
|
});
|
|
40
|
+
const deselectedItems = computed(() => {
|
|
41
|
+
return internalItems.value.filter((item) => !internalValue.value.includes(item[props.itemValue]));
|
|
42
|
+
});
|
|
40
43
|
const computedItems = computed(() => {
|
|
41
44
|
return cloneDeep(internalItems.value).filter((item) => {
|
|
42
45
|
return String(item[props.itemText]).toLocaleLowerCase().includes(String(search.value).toLocaleLowerCase());
|
|
@@ -203,17 +206,21 @@ const useSelectList = (props, inputSearch, virtualizerRef, emit) => {
|
|
|
203
206
|
return internalItems.value.indexOf(selectedItems.value[0]);
|
|
204
207
|
};
|
|
205
208
|
const selectAll = () => {
|
|
206
|
-
if (!props.multiple)
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
+
if (!props.multiple) return;
|
|
209
210
|
const selectedItems2 = internalValue.value;
|
|
211
|
+
const deselectedDisabledItemsValues = deselectedItems.value.filter((item) => isDisabled(item)).map((item) => item[props.itemValue]);
|
|
210
212
|
const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
|
|
211
|
-
const
|
|
213
|
+
const uniqueItems = uniqBy([...selectedItems2, ...filteredItems], (item) => item);
|
|
214
|
+
const toEmit = difference(uniqueItems, deselectedDisabledItemsValues);
|
|
212
215
|
emit("update:modelValue", toArrOfObjIfNeeded(toEmit));
|
|
213
216
|
};
|
|
214
217
|
const clearAll = () => {
|
|
218
|
+
if (!props.multiple) return;
|
|
215
219
|
search.value = "";
|
|
216
|
-
|
|
220
|
+
const disabledItemsValues = internalItems.value.filter((item) => isDisabled(item)).map((item) => item[props.itemValue]);
|
|
221
|
+
const selectedItemsValues = internalValue.value;
|
|
222
|
+
const selectedDisabledItems = intersection(disabledItemsValues, selectedItemsValues);
|
|
223
|
+
emit("update:modelValue", toArrOfObjIfNeeded(selectedDisabledItems));
|
|
217
224
|
};
|
|
218
225
|
watch(
|
|
219
226
|
() => props.items,
|
|
@@ -27,14 +27,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
27
27
|
};
|
|
28
28
|
}>, {}, {
|
|
29
29
|
defaultAttrs: {
|
|
30
|
-
triggers:
|
|
31
|
-
autoHide:
|
|
30
|
+
triggers: string[];
|
|
31
|
+
autoHide: boolean;
|
|
32
32
|
theme: string;
|
|
33
33
|
popperClass: string;
|
|
34
|
-
placement:
|
|
34
|
+
placement: string;
|
|
35
35
|
distance: number;
|
|
36
36
|
delay: number;
|
|
37
|
-
handleResize:
|
|
37
|
+
handleResize: boolean;
|
|
38
38
|
};
|
|
39
39
|
navigationSvc: ListKeyboardNavigationInstance | null;
|
|
40
40
|
prevReference: HTMLElement | null;
|
|
@@ -73,403 +73,5 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
73
73
|
enableArrowNavigation: boolean;
|
|
74
74
|
enableCloseOnEsc: boolean;
|
|
75
75
|
triggerStyle: Record<string, any>;
|
|
76
|
-
}, {}, {
|
|
77
|
-
Dropdown: import("vue").DefineComponent<{
|
|
78
|
-
theme: {
|
|
79
|
-
type: StringConstructor;
|
|
80
|
-
default: any;
|
|
81
|
-
};
|
|
82
|
-
referenceNode: {
|
|
83
|
-
type: import("vue").PropType<() => Element>;
|
|
84
|
-
default: any;
|
|
85
|
-
};
|
|
86
|
-
shown: {
|
|
87
|
-
type: BooleanConstructor;
|
|
88
|
-
default: boolean;
|
|
89
|
-
};
|
|
90
|
-
showGroup: {
|
|
91
|
-
type: StringConstructor;
|
|
92
|
-
default: any;
|
|
93
|
-
};
|
|
94
|
-
ariaId: {
|
|
95
|
-
default: any;
|
|
96
|
-
};
|
|
97
|
-
disabled: {
|
|
98
|
-
type: BooleanConstructor;
|
|
99
|
-
default: any;
|
|
100
|
-
};
|
|
101
|
-
positioningDisabled: {
|
|
102
|
-
type: BooleanConstructor;
|
|
103
|
-
default: any;
|
|
104
|
-
};
|
|
105
|
-
placement: {
|
|
106
|
-
type: import("vue").PropType<import("floating-vue/dist/util/popper.js").Placement>;
|
|
107
|
-
default: any;
|
|
108
|
-
};
|
|
109
|
-
delay: {
|
|
110
|
-
type: import("vue").PropType<string | number | {
|
|
111
|
-
show: number;
|
|
112
|
-
hide: number;
|
|
113
|
-
}>;
|
|
114
|
-
default: any;
|
|
115
|
-
};
|
|
116
|
-
distance: {
|
|
117
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
118
|
-
default: any;
|
|
119
|
-
};
|
|
120
|
-
skidding: {
|
|
121
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
122
|
-
default: any;
|
|
123
|
-
};
|
|
124
|
-
triggers: {
|
|
125
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]>;
|
|
126
|
-
default: any;
|
|
127
|
-
};
|
|
128
|
-
showTriggers: {
|
|
129
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
130
|
-
default: any;
|
|
131
|
-
};
|
|
132
|
-
hideTriggers: {
|
|
133
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
134
|
-
default: any;
|
|
135
|
-
};
|
|
136
|
-
popperTriggers: {
|
|
137
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]>;
|
|
138
|
-
default: any;
|
|
139
|
-
};
|
|
140
|
-
popperShowTriggers: {
|
|
141
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
142
|
-
default: any;
|
|
143
|
-
};
|
|
144
|
-
popperHideTriggers: {
|
|
145
|
-
type: import("vue").PropType<import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
146
|
-
default: any;
|
|
147
|
-
};
|
|
148
|
-
container: {
|
|
149
|
-
type: any[];
|
|
150
|
-
default: any;
|
|
151
|
-
};
|
|
152
|
-
boundary: {
|
|
153
|
-
type: any[];
|
|
154
|
-
default: any;
|
|
155
|
-
};
|
|
156
|
-
strategy: {
|
|
157
|
-
type: import("vue").PropType<"absolute" | "fixed">;
|
|
158
|
-
default: any;
|
|
159
|
-
};
|
|
160
|
-
autoHide: {
|
|
161
|
-
type: import("vue").PropType<boolean | ((event: Event) => boolean)>;
|
|
162
|
-
default: any;
|
|
163
|
-
};
|
|
164
|
-
handleResize: {
|
|
165
|
-
type: BooleanConstructor;
|
|
166
|
-
default: any;
|
|
167
|
-
};
|
|
168
|
-
instantMove: {
|
|
169
|
-
type: BooleanConstructor;
|
|
170
|
-
default: any;
|
|
171
|
-
};
|
|
172
|
-
eagerMount: {
|
|
173
|
-
type: BooleanConstructor;
|
|
174
|
-
default: any;
|
|
175
|
-
};
|
|
176
|
-
popperClass: {
|
|
177
|
-
type: (ObjectConstructor | StringConstructor | ArrayConstructor)[];
|
|
178
|
-
default: any;
|
|
179
|
-
};
|
|
180
|
-
computeTransformOrigin: {
|
|
181
|
-
type: BooleanConstructor;
|
|
182
|
-
default: any;
|
|
183
|
-
};
|
|
184
|
-
autoMinSize: {
|
|
185
|
-
type: BooleanConstructor;
|
|
186
|
-
default: any;
|
|
187
|
-
};
|
|
188
|
-
autoSize: {
|
|
189
|
-
type: import("vue").PropType<boolean | "min" | "max">;
|
|
190
|
-
default: any;
|
|
191
|
-
};
|
|
192
|
-
autoMaxSize: {
|
|
193
|
-
type: BooleanConstructor;
|
|
194
|
-
default: any;
|
|
195
|
-
};
|
|
196
|
-
autoBoundaryMaxSize: {
|
|
197
|
-
type: BooleanConstructor;
|
|
198
|
-
default: any;
|
|
199
|
-
};
|
|
200
|
-
preventOverflow: {
|
|
201
|
-
type: BooleanConstructor;
|
|
202
|
-
default: any;
|
|
203
|
-
};
|
|
204
|
-
overflowPadding: {
|
|
205
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
206
|
-
default: any;
|
|
207
|
-
};
|
|
208
|
-
arrowPadding: {
|
|
209
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
210
|
-
default: any;
|
|
211
|
-
};
|
|
212
|
-
arrowOverflow: {
|
|
213
|
-
type: BooleanConstructor;
|
|
214
|
-
default: any;
|
|
215
|
-
};
|
|
216
|
-
flip: {
|
|
217
|
-
type: BooleanConstructor;
|
|
218
|
-
default: any;
|
|
219
|
-
};
|
|
220
|
-
shift: {
|
|
221
|
-
type: BooleanConstructor;
|
|
222
|
-
default: any;
|
|
223
|
-
};
|
|
224
|
-
shiftCrossAxis: {
|
|
225
|
-
type: BooleanConstructor;
|
|
226
|
-
default: any;
|
|
227
|
-
};
|
|
228
|
-
noAutoFocus: {
|
|
229
|
-
type: BooleanConstructor;
|
|
230
|
-
default: any;
|
|
231
|
-
};
|
|
232
|
-
disposeTimeout: {
|
|
233
|
-
type: NumberConstructor;
|
|
234
|
-
default: any;
|
|
235
|
-
};
|
|
236
|
-
}, unknown, unknown, {
|
|
237
|
-
finalTheme(): string;
|
|
238
|
-
}, {
|
|
239
|
-
getTargetNodes(): unknown[];
|
|
240
|
-
}, {
|
|
241
|
-
computed: {
|
|
242
|
-
themeClass(): string[];
|
|
243
|
-
};
|
|
244
|
-
} | {
|
|
245
|
-
methods: {
|
|
246
|
-
show(...args: any[]): any;
|
|
247
|
-
hide(...args: any[]): any;
|
|
248
|
-
dispose(...args: any[]): any;
|
|
249
|
-
onResize(...args: any[]): any;
|
|
250
|
-
};
|
|
251
|
-
}, import("vue").ComponentOptionsMixin, {
|
|
252
|
-
show: () => true;
|
|
253
|
-
hide: () => true;
|
|
254
|
-
'update:shown': (shown: boolean) => true;
|
|
255
|
-
'apply-show': () => true;
|
|
256
|
-
'apply-hide': () => true;
|
|
257
|
-
'close-group': () => true;
|
|
258
|
-
'close-directive': () => true;
|
|
259
|
-
'auto-hide': () => true;
|
|
260
|
-
resize: () => true;
|
|
261
|
-
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
262
|
-
theme: {
|
|
263
|
-
type: StringConstructor;
|
|
264
|
-
default: any;
|
|
265
|
-
};
|
|
266
|
-
referenceNode: {
|
|
267
|
-
type: import("vue").PropType<() => Element>;
|
|
268
|
-
default: any;
|
|
269
|
-
};
|
|
270
|
-
shown: {
|
|
271
|
-
type: BooleanConstructor;
|
|
272
|
-
default: boolean;
|
|
273
|
-
};
|
|
274
|
-
showGroup: {
|
|
275
|
-
type: StringConstructor;
|
|
276
|
-
default: any;
|
|
277
|
-
};
|
|
278
|
-
ariaId: {
|
|
279
|
-
default: any;
|
|
280
|
-
};
|
|
281
|
-
disabled: {
|
|
282
|
-
type: BooleanConstructor;
|
|
283
|
-
default: any;
|
|
284
|
-
};
|
|
285
|
-
positioningDisabled: {
|
|
286
|
-
type: BooleanConstructor;
|
|
287
|
-
default: any;
|
|
288
|
-
};
|
|
289
|
-
placement: {
|
|
290
|
-
type: import("vue").PropType<import("floating-vue").Placement>;
|
|
291
|
-
default: any;
|
|
292
|
-
};
|
|
293
|
-
delay: {
|
|
294
|
-
type: import("vue").PropType<string | number | {
|
|
295
|
-
show: number;
|
|
296
|
-
hide: number;
|
|
297
|
-
}>;
|
|
298
|
-
default: any;
|
|
299
|
-
};
|
|
300
|
-
distance: {
|
|
301
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
302
|
-
default: any;
|
|
303
|
-
};
|
|
304
|
-
skidding: {
|
|
305
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
306
|
-
default: any;
|
|
307
|
-
};
|
|
308
|
-
triggers: {
|
|
309
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[]>;
|
|
310
|
-
default: any;
|
|
311
|
-
};
|
|
312
|
-
showTriggers: {
|
|
313
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
314
|
-
default: any;
|
|
315
|
-
};
|
|
316
|
-
hideTriggers: {
|
|
317
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
318
|
-
default: any;
|
|
319
|
-
};
|
|
320
|
-
popperTriggers: {
|
|
321
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[]>;
|
|
322
|
-
default: any;
|
|
323
|
-
};
|
|
324
|
-
popperShowTriggers: {
|
|
325
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
326
|
-
default: any;
|
|
327
|
-
};
|
|
328
|
-
popperHideTriggers: {
|
|
329
|
-
type: import("vue").PropType<import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[])>;
|
|
330
|
-
default: any;
|
|
331
|
-
};
|
|
332
|
-
container: {
|
|
333
|
-
type: any[];
|
|
334
|
-
default: any;
|
|
335
|
-
};
|
|
336
|
-
boundary: {
|
|
337
|
-
type: any[];
|
|
338
|
-
default: any;
|
|
339
|
-
};
|
|
340
|
-
strategy: {
|
|
341
|
-
type: import("vue").PropType<"absolute" | "fixed">;
|
|
342
|
-
default: any;
|
|
343
|
-
};
|
|
344
|
-
autoHide: {
|
|
345
|
-
type: import("vue").PropType<boolean | ((event: Event) => boolean)>;
|
|
346
|
-
default: any;
|
|
347
|
-
};
|
|
348
|
-
handleResize: {
|
|
349
|
-
type: BooleanConstructor;
|
|
350
|
-
default: any;
|
|
351
|
-
};
|
|
352
|
-
instantMove: {
|
|
353
|
-
type: BooleanConstructor;
|
|
354
|
-
default: any;
|
|
355
|
-
};
|
|
356
|
-
eagerMount: {
|
|
357
|
-
type: BooleanConstructor;
|
|
358
|
-
default: any;
|
|
359
|
-
};
|
|
360
|
-
popperClass: {
|
|
361
|
-
type: (ObjectConstructor | StringConstructor | ArrayConstructor)[];
|
|
362
|
-
default: any;
|
|
363
|
-
};
|
|
364
|
-
computeTransformOrigin: {
|
|
365
|
-
type: BooleanConstructor;
|
|
366
|
-
default: any;
|
|
367
|
-
};
|
|
368
|
-
autoMinSize: {
|
|
369
|
-
type: BooleanConstructor;
|
|
370
|
-
default: any;
|
|
371
|
-
};
|
|
372
|
-
autoSize: {
|
|
373
|
-
type: import("vue").PropType<boolean | "min" | "max">;
|
|
374
|
-
default: any;
|
|
375
|
-
};
|
|
376
|
-
autoMaxSize: {
|
|
377
|
-
type: BooleanConstructor;
|
|
378
|
-
default: any;
|
|
379
|
-
};
|
|
380
|
-
autoBoundaryMaxSize: {
|
|
381
|
-
type: BooleanConstructor;
|
|
382
|
-
default: any;
|
|
383
|
-
};
|
|
384
|
-
preventOverflow: {
|
|
385
|
-
type: BooleanConstructor;
|
|
386
|
-
default: any;
|
|
387
|
-
};
|
|
388
|
-
overflowPadding: {
|
|
389
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
390
|
-
default: any;
|
|
391
|
-
};
|
|
392
|
-
arrowPadding: {
|
|
393
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
394
|
-
default: any;
|
|
395
|
-
};
|
|
396
|
-
arrowOverflow: {
|
|
397
|
-
type: BooleanConstructor;
|
|
398
|
-
default: any;
|
|
399
|
-
};
|
|
400
|
-
flip: {
|
|
401
|
-
type: BooleanConstructor;
|
|
402
|
-
default: any;
|
|
403
|
-
};
|
|
404
|
-
shift: {
|
|
405
|
-
type: BooleanConstructor;
|
|
406
|
-
default: any;
|
|
407
|
-
};
|
|
408
|
-
shiftCrossAxis: {
|
|
409
|
-
type: BooleanConstructor;
|
|
410
|
-
default: any;
|
|
411
|
-
};
|
|
412
|
-
noAutoFocus: {
|
|
413
|
-
type: BooleanConstructor;
|
|
414
|
-
default: any;
|
|
415
|
-
};
|
|
416
|
-
disposeTimeout: {
|
|
417
|
-
type: NumberConstructor;
|
|
418
|
-
default: any;
|
|
419
|
-
};
|
|
420
|
-
}>> & {
|
|
421
|
-
onResize?: () => any;
|
|
422
|
-
onShow?: () => any;
|
|
423
|
-
onHide?: () => any;
|
|
424
|
-
"onUpdate:shown"?: (shown: boolean) => any;
|
|
425
|
-
"onApply-show"?: () => any;
|
|
426
|
-
"onApply-hide"?: () => any;
|
|
427
|
-
"onClose-group"?: () => any;
|
|
428
|
-
"onClose-directive"?: () => any;
|
|
429
|
-
"onAuto-hide"?: () => any;
|
|
430
|
-
}, {
|
|
431
|
-
placement: import("floating-vue").Placement;
|
|
432
|
-
strategy: "absolute" | "fixed";
|
|
433
|
-
disabled: boolean;
|
|
434
|
-
positioningDisabled: boolean;
|
|
435
|
-
delay: string | number | {
|
|
436
|
-
show: number;
|
|
437
|
-
hide: number;
|
|
438
|
-
};
|
|
439
|
-
distance: string | number;
|
|
440
|
-
skidding: string | number;
|
|
441
|
-
triggers: import("floating-vue").TriggerEvent[];
|
|
442
|
-
showTriggers: import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]);
|
|
443
|
-
hideTriggers: import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]);
|
|
444
|
-
popperTriggers: import("floating-vue").TriggerEvent[];
|
|
445
|
-
popperShowTriggers: import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]);
|
|
446
|
-
popperHideTriggers: import("floating-vue").TriggerEvent[] | ((triggers: import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]) => import("floating-vue/dist/components/PopperWrapper.vue.js").TriggerEvent[]);
|
|
447
|
-
container: any;
|
|
448
|
-
boundary: any;
|
|
449
|
-
autoHide: boolean | ((event: Event) => boolean);
|
|
450
|
-
handleResize: boolean;
|
|
451
|
-
instantMove: boolean;
|
|
452
|
-
eagerMount: boolean;
|
|
453
|
-
popperClass: string | unknown[] | Record<string, any>;
|
|
454
|
-
computeTransformOrigin: boolean;
|
|
455
|
-
autoMinSize: boolean;
|
|
456
|
-
autoSize: boolean | "min" | "max";
|
|
457
|
-
autoMaxSize: boolean;
|
|
458
|
-
autoBoundaryMaxSize: boolean;
|
|
459
|
-
preventOverflow: boolean;
|
|
460
|
-
overflowPadding: string | number;
|
|
461
|
-
arrowPadding: string | number;
|
|
462
|
-
arrowOverflow: boolean;
|
|
463
|
-
flip: boolean;
|
|
464
|
-
shift: boolean;
|
|
465
|
-
shiftCrossAxis: boolean;
|
|
466
|
-
noAutoFocus: boolean;
|
|
467
|
-
disposeTimeout: number;
|
|
468
|
-
shown: boolean;
|
|
469
|
-
theme: string;
|
|
470
|
-
referenceNode: () => Element;
|
|
471
|
-
showGroup: string;
|
|
472
|
-
ariaId: any;
|
|
473
|
-
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
474
|
-
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
76
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
475
77
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pequity/squirrel",
|
|
3
3
|
"description": "Squirrel component library",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.2",
|
|
5
5
|
"packageManager": "pnpm@9.15.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"vue-toastification": "^2.0.0-rc.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@commitlint/cli": "^19.6.
|
|
50
|
+
"@commitlint/cli": "^19.6.1",
|
|
51
51
|
"@commitlint/config-conventional": "^19.6.0",
|
|
52
52
|
"@pequity/eslint-config": "^1.0.3",
|
|
53
53
|
"@playwright/test": "^1.49.1",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@storybook/theming": "^8.4.7",
|
|
66
66
|
"@storybook/vue3": "^8.4.7",
|
|
67
67
|
"@storybook/vue3-vite": "^8.4.7",
|
|
68
|
-
"@tanstack/vue-virtual": "3.11.
|
|
68
|
+
"@tanstack/vue-virtual": "3.11.2",
|
|
69
69
|
"@types/jsdom": "^21.1.7",
|
|
70
70
|
"@types/lodash-es": "^4.17.12",
|
|
71
71
|
"@types/node": "^22.10.2",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"@vuepic/vue-datepicker": "10.0.0",
|
|
77
77
|
"autoprefixer": "^10.4.20",
|
|
78
78
|
"dayjs": "1.11.13",
|
|
79
|
-
"eslint": "^9.
|
|
79
|
+
"eslint": "^9.17.0",
|
|
80
80
|
"eslint-plugin-storybook": "^0.11.1",
|
|
81
81
|
"floating-vue": "5.2.2",
|
|
82
82
|
"glob": "^11.0.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"prettier-plugin-tailwindcss": "^0.6.9",
|
|
92
92
|
"resolve-tspaths": "^0.8.23",
|
|
93
93
|
"rimraf": "^6.0.1",
|
|
94
|
-
"sass": "^1.
|
|
94
|
+
"sass": "^1.83.0",
|
|
95
95
|
"semantic-release": "^24.2.0",
|
|
96
96
|
"storybook": "^8.4.7",
|
|
97
97
|
"svgo": "^3.3.2",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<VDropdown ref="vPopper" v-bind="{ ...defaultAttrs, ...$attrs }" @show="onShow" @hide="destroy">
|
|
3
3
|
<template v-for="(_, slot) in $slots" #[slot]="scope">
|
|
4
4
|
<slot :name="slot" v-bind="scope || {}" />
|
|
5
5
|
</template>
|
|
6
|
-
</
|
|
6
|
+
</VDropdown>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script lang="ts">
|
|
@@ -88,11 +88,8 @@ import {
|
|
|
88
88
|
type ListKeyboardNavigationInstance,
|
|
89
89
|
setupListKeyboardNavigation,
|
|
90
90
|
} from '@squirrel/utils/listKeyboardNavigation';
|
|
91
|
-
import { Dropdown } from 'floating-vue';
|
|
92
91
|
import { defineComponent } from 'vue';
|
|
93
92
|
|
|
94
|
-
type DropdownProps = InstanceType<typeof Dropdown>['$props'];
|
|
95
|
-
|
|
96
93
|
type VPopper = {
|
|
97
94
|
$refs: {
|
|
98
95
|
popperContent: {
|
|
@@ -125,9 +122,6 @@ const nextFrame = () => {
|
|
|
125
122
|
|
|
126
123
|
export default defineComponent({
|
|
127
124
|
name: 'PDropdown',
|
|
128
|
-
components: {
|
|
129
|
-
Dropdown,
|
|
130
|
-
},
|
|
131
125
|
inheritAttrs: false,
|
|
132
126
|
props: {
|
|
133
127
|
/**
|
|
@@ -167,7 +161,7 @@ export default defineComponent({
|
|
|
167
161
|
distance: 4,
|
|
168
162
|
delay: 0,
|
|
169
163
|
handleResize: true,
|
|
170
|
-
}
|
|
164
|
+
},
|
|
171
165
|
navigationSvc: null as ListKeyboardNavigationInstance | null,
|
|
172
166
|
prevReference: null as HTMLElement | null,
|
|
173
167
|
};
|
|
@@ -197,6 +197,27 @@ describe('PDropdownSelect.vue', () => {
|
|
|
197
197
|
cleanup(wrapper);
|
|
198
198
|
});
|
|
199
199
|
|
|
200
|
+
it('does not select disabled items when "Select All" is clicked', async () => {
|
|
201
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
202
|
+
|
|
203
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
204
|
+
items[0].disabled = true;
|
|
205
|
+
items[1].disabled = true;
|
|
206
|
+
const wrapper = createWrapper({ selected: [], items }, { multiple: true });
|
|
207
|
+
|
|
208
|
+
await wrapper.find('button').trigger('click');
|
|
209
|
+
|
|
210
|
+
await wrapper.findByText('Select all').trigger('click');
|
|
211
|
+
|
|
212
|
+
const selectedItemsOptions = wrapper.findAll('[p-select-list-option-item]');
|
|
213
|
+
const selectedItems = wrapper.findAll('[p-select-list-option-item].selected');
|
|
214
|
+
|
|
215
|
+
expect(selectedItems.length).toBe(selectedItemsOptions.length - 2);
|
|
216
|
+
expect(wrapper.vm.$data.selected.length).toBe(items.length - 2);
|
|
217
|
+
|
|
218
|
+
cleanup(wrapper);
|
|
219
|
+
});
|
|
220
|
+
|
|
200
221
|
it('clears all values', async () => {
|
|
201
222
|
const wrapper = createWrapper({ selected: [] }, { multiple: true });
|
|
202
223
|
|
|
@@ -213,6 +234,26 @@ describe('PDropdownSelect.vue', () => {
|
|
|
213
234
|
cleanup(wrapper);
|
|
214
235
|
});
|
|
215
236
|
|
|
237
|
+
it('does not clear disabled items', async () => {
|
|
238
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
239
|
+
|
|
240
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
241
|
+
items[0].disabled = true;
|
|
242
|
+
items[1].disabled = true;
|
|
243
|
+
const wrapper = createWrapper({ selected: [1, 2], items }, { multiple: true });
|
|
244
|
+
|
|
245
|
+
await wrapper.find('button').trigger('click');
|
|
246
|
+
|
|
247
|
+
await wrapper.findByText('Clear all').trigger('click');
|
|
248
|
+
|
|
249
|
+
const selectedItems = wrapper.findAll('[p-select-list-option-item].selected');
|
|
250
|
+
|
|
251
|
+
expect(selectedItems.length).toBe(2);
|
|
252
|
+
expect(wrapper.vm.$data.selected).toEqual([1, 2]);
|
|
253
|
+
|
|
254
|
+
cleanup(wrapper);
|
|
255
|
+
});
|
|
256
|
+
|
|
216
257
|
it('displays the selected items on top', async () => {
|
|
217
258
|
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
218
259
|
|
|
@@ -532,6 +573,8 @@ describe('PDropdownSelect.vue', () => {
|
|
|
532
573
|
});
|
|
533
574
|
|
|
534
575
|
expect(wrapper.vm.$data.selected).toEqual([1, 3]);
|
|
576
|
+
|
|
577
|
+
cleanup(wrapper);
|
|
535
578
|
});
|
|
536
579
|
|
|
537
580
|
it('disables the item when the disabled item prop is set', async () => {
|
|
@@ -555,6 +598,7 @@ describe('PDropdownSelect.vue', () => {
|
|
|
555
598
|
expect(item.classes()).not.toContain('pointer-events-none');
|
|
556
599
|
}
|
|
557
600
|
});
|
|
601
|
+
|
|
558
602
|
cleanup(wrapper);
|
|
559
603
|
});
|
|
560
604
|
|
|
@@ -580,13 +624,14 @@ describe('PDropdownSelect.vue', () => {
|
|
|
580
624
|
expect(item.classes()).not.toContain('pointer-events-none');
|
|
581
625
|
}
|
|
582
626
|
});
|
|
627
|
+
|
|
583
628
|
cleanup(wrapper);
|
|
584
629
|
});
|
|
585
630
|
|
|
586
631
|
it('renders clear button when clearable is true and a value is selected', async () => {
|
|
587
632
|
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
588
633
|
|
|
589
|
-
const wrapper = createWrapper({ selected: 17 }, { clearable: true });
|
|
634
|
+
const wrapper = createWrapper({ selected: [17] }, { multiple: true, clearable: true });
|
|
590
635
|
|
|
591
636
|
const clearButton = wrapper.find('button[aria-label="Clear selection"]');
|
|
592
637
|
expect(clearButton.exists()).toBe(true);
|
|
@@ -618,6 +663,7 @@ describe('PDropdownSelect.vue', () => {
|
|
|
618
663
|
|
|
619
664
|
await clearButton.trigger('click');
|
|
620
665
|
expect(wrapper.vm.$data.selected).toEqual([]);
|
|
666
|
+
|
|
621
667
|
cleanup(wrapper);
|
|
622
668
|
});
|
|
623
669
|
});
|
|
@@ -183,6 +183,25 @@ describe('PSelectList.vue', () => {
|
|
|
183
183
|
cleanup(wrapper);
|
|
184
184
|
});
|
|
185
185
|
|
|
186
|
+
it('does not select disabled items when "Select All" is clicked', async () => {
|
|
187
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
188
|
+
|
|
189
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
190
|
+
items[0].disabled = true;
|
|
191
|
+
items[1].disabled = true;
|
|
192
|
+
const wrapper = createWrapper({ selected: [], items }, { multiple: true });
|
|
193
|
+
|
|
194
|
+
await wrapper.findByText('Select all').trigger('click');
|
|
195
|
+
|
|
196
|
+
const selectedItemsOptions = wrapper.findAll('[p-select-list-option-item]');
|
|
197
|
+
const selectedItems = wrapper.findAll('[p-select-list-option-item].selected');
|
|
198
|
+
|
|
199
|
+
expect(selectedItems.length).toBe(selectedItemsOptions.length - 2);
|
|
200
|
+
expect(wrapper.vm.$data.selected.length).toBe(items.length - 2);
|
|
201
|
+
|
|
202
|
+
cleanup(wrapper);
|
|
203
|
+
});
|
|
204
|
+
|
|
186
205
|
it('clears all values', async () => {
|
|
187
206
|
const wrapper = createWrapper({ selected: [] }, { multiple: true });
|
|
188
207
|
|
|
@@ -198,6 +217,24 @@ describe('PSelectList.vue', () => {
|
|
|
198
217
|
cleanup(wrapper);
|
|
199
218
|
});
|
|
200
219
|
|
|
220
|
+
it('does not clear disabled items', async () => {
|
|
221
|
+
useVirtualizer.mockImplementation(() => createMockedVirtualizer(10));
|
|
222
|
+
|
|
223
|
+
const items = cloneDeep(filterListItems).slice(0, 10);
|
|
224
|
+
items[0].disabled = true;
|
|
225
|
+
items[1].disabled = true;
|
|
226
|
+
const wrapper = createWrapper({ selected: [1, 2], items }, { multiple: true });
|
|
227
|
+
|
|
228
|
+
await wrapper.findByText('Clear all').trigger('click');
|
|
229
|
+
|
|
230
|
+
const selectedItems = wrapper.findAll('[p-select-list-option-item].selected');
|
|
231
|
+
|
|
232
|
+
expect(selectedItems.length).toBe(2);
|
|
233
|
+
expect(wrapper.vm.$data.selected).toEqual([1, 2]);
|
|
234
|
+
|
|
235
|
+
cleanup(wrapper);
|
|
236
|
+
});
|
|
237
|
+
|
|
201
238
|
it('displays the selected items on top', async () => {
|
|
202
239
|
useVirtualizer.mockImplementation(() => createMockedVirtualizer(20));
|
|
203
240
|
|
|
@@ -448,6 +485,8 @@ describe('PSelectList.vue', () => {
|
|
|
448
485
|
});
|
|
449
486
|
|
|
450
487
|
expect(wrapper.vm.$data.selected).toEqual([1, 3]);
|
|
488
|
+
|
|
489
|
+
cleanup(wrapper);
|
|
451
490
|
});
|
|
452
491
|
|
|
453
492
|
it('removes values from the internalValue (modelValue) that are not in the items list', async () => {
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from '@squirrel/utils/listKeyboardNavigation';
|
|
12
12
|
import { toString } from '@squirrel/utils/string';
|
|
13
13
|
import { useVirtualizer } from '@tanstack/vue-virtual';
|
|
14
|
-
import { cloneDeep, uniqBy } from 'lodash-es';
|
|
14
|
+
import { cloneDeep, difference, intersection, uniqBy } from 'lodash-es';
|
|
15
15
|
import { type ComponentPublicInstance, computed, nextTick, onUnmounted, type Ref, ref, watch } from 'vue';
|
|
16
16
|
|
|
17
17
|
type Emits = {
|
|
@@ -59,7 +59,11 @@ export const useSelectList = (props: Props, inputSearch: InputSearch, virtualize
|
|
|
59
59
|
|
|
60
60
|
// Computed
|
|
61
61
|
const selectedItems = computed(() => {
|
|
62
|
-
return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]
|
|
62
|
+
return internalItems.value.filter((item) => internalValue.value.includes(item[props.itemValue]));
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const deselectedItems = computed(() => {
|
|
66
|
+
return internalItems.value.filter((item) => !internalValue.value.includes(item[props.itemValue]));
|
|
63
67
|
});
|
|
64
68
|
|
|
65
69
|
const computedItems = computed(() => {
|
|
@@ -279,20 +283,36 @@ export const useSelectList = (props: Props, inputSearch: InputSearch, virtualize
|
|
|
279
283
|
};
|
|
280
284
|
|
|
281
285
|
const selectAll = () => {
|
|
282
|
-
if (!props.multiple)
|
|
283
|
-
return;
|
|
284
|
-
}
|
|
286
|
+
if (!props.multiple) return;
|
|
285
287
|
|
|
286
288
|
const selectedItems = internalValue.value;
|
|
289
|
+
const deselectedDisabledItemsValues = deselectedItems.value
|
|
290
|
+
.filter((item) => isDisabled(item))
|
|
291
|
+
.map((item) => item[props.itemValue]);
|
|
287
292
|
const filteredItems = computedItems.value.map((item) => item[props.itemValue]);
|
|
288
|
-
const
|
|
293
|
+
const uniqueItems = uniqBy([...selectedItems, ...filteredItems], (item) => item);
|
|
294
|
+
|
|
295
|
+
// We cannot select disabled items so we remove them from the list
|
|
296
|
+
const toEmit = difference(uniqueItems, deselectedDisabledItemsValues);
|
|
289
297
|
|
|
290
298
|
emit('update:modelValue', toArrOfObjIfNeeded(toEmit));
|
|
291
299
|
};
|
|
292
300
|
|
|
293
301
|
const clearAll = () => {
|
|
302
|
+
if (!props.multiple) return;
|
|
303
|
+
|
|
294
304
|
search.value = '';
|
|
295
|
-
|
|
305
|
+
|
|
306
|
+
// We cannot clear disabled items that are selected
|
|
307
|
+
const disabledItemsValues = internalItems.value
|
|
308
|
+
.filter((item) => isDisabled(item))
|
|
309
|
+
.map((item) => item[props.itemValue]);
|
|
310
|
+
|
|
311
|
+
const selectedItemsValues = internalValue.value;
|
|
312
|
+
|
|
313
|
+
const selectedDisabledItems = intersection(disabledItemsValues, selectedItemsValues);
|
|
314
|
+
|
|
315
|
+
emit('update:modelValue', toArrOfObjIfNeeded(selectedDisabledItems));
|
|
296
316
|
};
|
|
297
317
|
|
|
298
318
|
// Watch
|
|
@@ -168,4 +168,40 @@ describe('listKeyboardNavigation', () => {
|
|
|
168
168
|
|
|
169
169
|
navigationSvc.destroy();
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
it('triggers selection event on enter key', () => {
|
|
173
|
+
const navigationSvc = createTestSvc();
|
|
174
|
+
|
|
175
|
+
const event = new window.KeyboardEvent('keydown', {
|
|
176
|
+
key: 'Enter',
|
|
177
|
+
keyCode: 13,
|
|
178
|
+
bubbles: true,
|
|
179
|
+
target: document.querySelector('.dropdown-menu'),
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const items = navigationSvc.getItems();
|
|
183
|
+
navigationSvc.setFocusedItem(items[1]);
|
|
184
|
+
|
|
185
|
+
const clickEvent = vi.fn();
|
|
186
|
+
items[1].addEventListener('click', clickEvent);
|
|
187
|
+
|
|
188
|
+
navigationSvc.listKeydown(event);
|
|
189
|
+
|
|
190
|
+
expect(clickEvent).toHaveBeenCalled();
|
|
191
|
+
|
|
192
|
+
navigationSvc.destroy();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('warns when multiple instances are initialized', () => {
|
|
196
|
+
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
197
|
+
|
|
198
|
+
const navigationSvc1 = createTestSvc();
|
|
199
|
+
const navigationSvc2 = createTestSvc();
|
|
200
|
+
|
|
201
|
+
expect(consoleWarnSpy).toHaveBeenCalledWith('There can only be one instance of list navigation active at a time.');
|
|
202
|
+
|
|
203
|
+
navigationSvc1.destroy();
|
|
204
|
+
navigationSvc2.destroy();
|
|
205
|
+
consoleWarnSpy.mockRestore();
|
|
206
|
+
});
|
|
171
207
|
});
|