vue3-extended-multiselect 1.4.2 → 1.5.0
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/CHANGELOG.md +12 -3
- package/README.md +1 -1
- package/package.json +1 -2
- package/src/components/ExtendedMultiselectCancel.vue +11 -12
- package/src/components/ExtendedMultiselectInput.vue +27 -29
- package/src/components/ExtendedMultiselectMultiple.vue +12 -15
- package/src/components/ExtendedMultiselectOptions.vue +20 -23
- package/src/components/ExtendedMultiselectToggle.vue +11 -12
- package/src/components/Vue3ExtendedMultiselect.vue +31 -32
- package/src/composition/cancel.js +4 -6
- package/src/composition/emitter.js +9 -0
- package/src/composition/toggle.js +2 -4
- package/tests/unit/events.spec.js +2 -4
- package/src/events/emitter.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Patch notes
|
|
2
2
|
|
|
3
|
-
Current `vue3-extended-multiselect` version: **1.
|
|
3
|
+
Current `vue3-extended-multiselect` version: **1.5.0**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -178,8 +178,17 @@ Adding descriptive comments for some types in typings.
|
|
|
178
178
|
|
|
179
179
|
### 1.4.1 (2023-01-14)
|
|
180
180
|
|
|
181
|
-
Small fixes in documentation.
|
|
181
|
+
* Small fixes in documentation.
|
|
182
182
|
|
|
183
183
|
### 1.4.2 (2023-01-15)
|
|
184
184
|
|
|
185
|
-
Regenerating of .nvmrc file.
|
|
185
|
+
* Regenerating of .nvmrc file.
|
|
186
|
+
|
|
187
|
+
### 1.5.0 (2023-01-21)
|
|
188
|
+
|
|
189
|
+
* Removal of dependency "uuid".
|
|
190
|
+
* Adding "events" prop to child components using LocalEmitter.
|
|
191
|
+
* Adding emitter.js file to composition directory with reactive LocalEmitter instace.
|
|
192
|
+
* Removal of "emitterUniqueId" prop from child components.
|
|
193
|
+
* Removal of emitter.js file from events directory.
|
|
194
|
+
* Changing event emitter invocations in some of unit tests.
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-extended-multiselect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Extended multiselect component for applications based on Vue 3 framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multiselect",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"core-js": "^3.6.5",
|
|
26
26
|
"lodash-es": "^4.17.21",
|
|
27
|
-
"uuid": "^9.0.0",
|
|
28
27
|
"vue": "^3.0.0",
|
|
29
28
|
"vue3-click-away": "^1.2.4"
|
|
30
29
|
},
|
|
@@ -47,16 +47,6 @@ const props = defineProps({
|
|
|
47
47
|
required: true,
|
|
48
48
|
},
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* Assigns unique identifier of extended multiselect
|
|
52
|
-
* for each event
|
|
53
|
-
* @property {string} emitterUniqueId
|
|
54
|
-
*/
|
|
55
|
-
emitterUniqueId: {
|
|
56
|
-
type: String,
|
|
57
|
-
required: true,
|
|
58
|
-
},
|
|
59
|
-
|
|
60
50
|
/**
|
|
61
51
|
* Defines a svg-filter for icons
|
|
62
52
|
* @property {string} iconFilter
|
|
@@ -112,6 +102,15 @@ const props = defineProps({
|
|
|
112
102
|
type: Array,
|
|
113
103
|
required: true,
|
|
114
104
|
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Reactive instance of LocalEmitter class
|
|
108
|
+
* @property {object} emitter
|
|
109
|
+
*/
|
|
110
|
+
emitter: {
|
|
111
|
+
type: Object,
|
|
112
|
+
required: true,
|
|
113
|
+
},
|
|
115
114
|
});
|
|
116
115
|
|
|
117
116
|
const setSearchValue = inject("setSearchValue");
|
|
@@ -119,7 +118,7 @@ const setSearchPattern = inject("setSearchPattern");
|
|
|
119
118
|
|
|
120
119
|
const {
|
|
121
120
|
disabled,
|
|
122
|
-
|
|
121
|
+
emitter,
|
|
123
122
|
iconFilter,
|
|
124
123
|
iconSize,
|
|
125
124
|
loading,
|
|
@@ -136,7 +135,7 @@ const { cancel } = useCancel(
|
|
|
136
135
|
disabled,
|
|
137
136
|
showSearchField,
|
|
138
137
|
selectedOptions,
|
|
139
|
-
|
|
138
|
+
emitter,
|
|
140
139
|
setSearchValue,
|
|
141
140
|
setSearchPattern,
|
|
142
141
|
);
|
|
@@ -37,7 +37,6 @@
|
|
|
37
37
|
:disabled="disabled"
|
|
38
38
|
:loading="loading"
|
|
39
39
|
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
40
|
-
:emitter-unique-id="emitterUniqueId"
|
|
41
40
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
42
41
|
:label="label"
|
|
43
42
|
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
@@ -45,6 +44,7 @@
|
|
|
45
44
|
:increase-display-by="increaseDisplayBy"
|
|
46
45
|
:multipleBlocksLimit="multipleBlocksLimit"
|
|
47
46
|
:selected-options="selectedOptions"
|
|
47
|
+
:emitter="emitter"
|
|
48
48
|
:create-custom-option-label="createCustomOptionLabel"
|
|
49
49
|
>
|
|
50
50
|
<template #optionBlock="{ label, deselectBlock, index }">
|
|
@@ -76,7 +76,6 @@
|
|
|
76
76
|
:disabled="disabled"
|
|
77
77
|
:loading="loading"
|
|
78
78
|
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
79
|
-
:emitter-unique-id="emitterUniqueId"
|
|
80
79
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
81
80
|
:label="label"
|
|
82
81
|
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
@@ -84,6 +83,7 @@
|
|
|
84
83
|
:increase-display-by="increaseDisplayBy"
|
|
85
84
|
:multipleBlocksLimit="multipleBlocksLimit"
|
|
86
85
|
:selected-options="selectedOptions"
|
|
86
|
+
:emitter="emitter"
|
|
87
87
|
:create-custom-option-label="createCustomOptionLabel"
|
|
88
88
|
>
|
|
89
89
|
<template #optionBlock="{ label, deselectBlock, index }">
|
|
@@ -149,7 +149,6 @@ import {
|
|
|
149
149
|
} from "vue";
|
|
150
150
|
|
|
151
151
|
import { debounce } from "lodash-es";
|
|
152
|
-
import emitter from "../events/emitter";
|
|
153
152
|
|
|
154
153
|
import ExtendedMultiselectMultiple from "./ExtendedMultiselectMultiple.vue";
|
|
155
154
|
|
|
@@ -270,16 +269,6 @@ const props = defineProps({
|
|
|
270
269
|
required: true,
|
|
271
270
|
},
|
|
272
271
|
|
|
273
|
-
/**
|
|
274
|
-
* Assigns unique identifier of extended multiselect
|
|
275
|
-
* for each event
|
|
276
|
-
* @property {string} emitterUniqueId
|
|
277
|
-
*/
|
|
278
|
-
emitterUniqueId: {
|
|
279
|
-
type: String,
|
|
280
|
-
required: true,
|
|
281
|
-
},
|
|
282
|
-
|
|
283
272
|
/**
|
|
284
273
|
* Placeholder used in internal options filters
|
|
285
274
|
* and provided to ExtendedMultiselectMultiple child component
|
|
@@ -348,6 +337,15 @@ const props = defineProps({
|
|
|
348
337
|
required: true,
|
|
349
338
|
},
|
|
350
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Reactive instance of LocalEmitter class
|
|
342
|
+
* @property {object} emitter
|
|
343
|
+
*/
|
|
344
|
+
emitter: {
|
|
345
|
+
type: Object,
|
|
346
|
+
required: true,
|
|
347
|
+
},
|
|
348
|
+
|
|
351
349
|
/**
|
|
352
350
|
* Provides function that creates custom label for
|
|
353
351
|
* block with selected option to ExtendedMultiselectMultiple
|
|
@@ -395,7 +393,7 @@ const searchState = inject("searchState");
|
|
|
395
393
|
const setSearchValue = inject("setSearchValue");
|
|
396
394
|
const setSearchPattern = inject("setSearchPattern");
|
|
397
395
|
|
|
398
|
-
const
|
|
396
|
+
const emitter = toRef(props, "emitter");
|
|
399
397
|
|
|
400
398
|
const blurSkip = ref(false);
|
|
401
399
|
const reversePrevented = ref(false);
|
|
@@ -410,9 +408,9 @@ const searchDebounce = ref(debounce(() => {
|
|
|
410
408
|
const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
|
|
411
409
|
|
|
412
410
|
if (externalOptionsLoader.value) {
|
|
413
|
-
emitter.emit(
|
|
411
|
+
emitter.value.emit("extended:loader-pattern-changed", searchValue.value);
|
|
414
412
|
} else {
|
|
415
|
-
emitter.emit(
|
|
413
|
+
emitter.value.emit("extended:search-pattern-changed", searchValue.value);
|
|
416
414
|
setSearchPattern(searchPattern);
|
|
417
415
|
}
|
|
418
416
|
}, 250));
|
|
@@ -498,7 +496,7 @@ watch(searchFieldForwarding, (value) => {
|
|
|
498
496
|
if (value && autoSelectSearchValue.value && !multiple.value && singleLabel.value) {
|
|
499
497
|
searchValue.value = singleLabel.value;
|
|
500
498
|
}
|
|
501
|
-
emitter.emit(
|
|
499
|
+
emitter.value.emit("extended:renew-field-forwarding", value);
|
|
502
500
|
});
|
|
503
501
|
|
|
504
502
|
/**
|
|
@@ -534,7 +532,7 @@ const expand = () => {
|
|
|
534
532
|
if (disabled.value) return;
|
|
535
533
|
|
|
536
534
|
searchFieldFocused.value = true;
|
|
537
|
-
emitter.emit(
|
|
535
|
+
emitter.value.emit("extended:expand-options");
|
|
538
536
|
};
|
|
539
537
|
|
|
540
538
|
/**
|
|
@@ -583,7 +581,7 @@ const rollUp = () => {
|
|
|
583
581
|
blurSkipByBlock.value = 0;
|
|
584
582
|
blurSkipByToggleIcon.value = 0;
|
|
585
583
|
|
|
586
|
-
emitter.emit(
|
|
584
|
+
emitter.value.emit("extended:rollup-options", true);
|
|
587
585
|
};
|
|
588
586
|
|
|
589
587
|
/**
|
|
@@ -608,7 +606,7 @@ const search = () => {
|
|
|
608
606
|
* @listens extended:trigger-selection
|
|
609
607
|
*/
|
|
610
608
|
onBeforeMount(() => {
|
|
611
|
-
emitter.on(
|
|
609
|
+
emitter.value.on("extended:rollup-options", (internalRollup) => {
|
|
612
610
|
if (blurSkip.value === true) {
|
|
613
611
|
blurSkip.value = false;
|
|
614
612
|
return;
|
|
@@ -621,7 +619,7 @@ onBeforeMount(() => {
|
|
|
621
619
|
rollUp();
|
|
622
620
|
});
|
|
623
621
|
|
|
624
|
-
emitter.on(
|
|
622
|
+
emitter.value.on("extended:select-option", (option) => {
|
|
625
623
|
|
|
626
624
|
if (toggleOptionsBySelect.value) {
|
|
627
625
|
rollUp();
|
|
@@ -634,7 +632,7 @@ onBeforeMount(() => {
|
|
|
634
632
|
}
|
|
635
633
|
});
|
|
636
634
|
|
|
637
|
-
emitter.on(
|
|
635
|
+
emitter.value.on("extended:deselect-option", () => {
|
|
638
636
|
if (multiple.value) {
|
|
639
637
|
return;
|
|
640
638
|
} else {
|
|
@@ -642,27 +640,27 @@ onBeforeMount(() => {
|
|
|
642
640
|
}
|
|
643
641
|
});
|
|
644
642
|
|
|
645
|
-
emitter.on(
|
|
643
|
+
emitter.value.on("extended:clean-options", () => {
|
|
646
644
|
searchValue.value = null;
|
|
647
645
|
});
|
|
648
646
|
|
|
649
|
-
emitter.on(
|
|
647
|
+
emitter.value.on("extended:clear-field", () => {
|
|
650
648
|
searchValue.value = null;
|
|
651
649
|
});
|
|
652
650
|
|
|
653
|
-
emitter.on(
|
|
651
|
+
emitter.value.on("extended:skip-blur", () => {
|
|
654
652
|
blurSkipByToggleIcon.value++;
|
|
655
653
|
});
|
|
656
654
|
|
|
657
|
-
emitter.on(
|
|
655
|
+
emitter.value.on("extended:skip-block-blur", () => {
|
|
658
656
|
blurSkipByBlock.value++;
|
|
659
657
|
});
|
|
660
658
|
|
|
661
|
-
emitter.on(
|
|
659
|
+
emitter.value.on("extended:skip-block-blur-zeroing", () => {
|
|
662
660
|
blurSkipByBlock.value = 0;
|
|
663
661
|
});
|
|
664
662
|
|
|
665
|
-
emitter.on(
|
|
663
|
+
emitter.value.on("extended:trigger-selection", (triggerState) => {
|
|
666
664
|
if (!toggleOptionsBySelect.value) {
|
|
667
665
|
searchFieldFocused.value = false;
|
|
668
666
|
}
|
|
@@ -675,7 +673,7 @@ onBeforeMount(() => {
|
|
|
675
673
|
* @listens extended:field-focus
|
|
676
674
|
*/
|
|
677
675
|
onMounted(() => {
|
|
678
|
-
emitter.on(
|
|
676
|
+
emitter.value.on("extended:field-focus", () => {
|
|
679
677
|
if (showSearchField.value) {
|
|
680
678
|
nextTick(() => {
|
|
681
679
|
extendedInput.value.focus();
|
|
@@ -57,8 +57,6 @@ import {
|
|
|
57
57
|
watch,
|
|
58
58
|
} from "vue";
|
|
59
59
|
|
|
60
|
-
import emitter from "../events/emitter";
|
|
61
|
-
|
|
62
60
|
import useImagePath from "../composition/image-path";
|
|
63
61
|
import useLabels from "../composition/labels";
|
|
64
62
|
|
|
@@ -82,16 +80,6 @@ const props = defineProps({
|
|
|
82
80
|
required: true,
|
|
83
81
|
},
|
|
84
82
|
|
|
85
|
-
/**
|
|
86
|
-
* Assigns unique identifier of extended multiselect
|
|
87
|
-
* for each event
|
|
88
|
-
* @property {string} emitterUniqueId
|
|
89
|
-
*/
|
|
90
|
-
emitterUniqueId: {
|
|
91
|
-
type: String,
|
|
92
|
-
required: true,
|
|
93
|
-
},
|
|
94
|
-
|
|
95
83
|
/**
|
|
96
84
|
* Defines label for blocks with options of type "object"
|
|
97
85
|
* or Array instances which length/keys length equals 0
|
|
@@ -165,6 +153,15 @@ const props = defineProps({
|
|
|
165
153
|
required: true,
|
|
166
154
|
},
|
|
167
155
|
|
|
156
|
+
/**
|
|
157
|
+
* Reactive instance of LocalEmitter class
|
|
158
|
+
* @property {object} emitter
|
|
159
|
+
*/
|
|
160
|
+
emitter: {
|
|
161
|
+
type: Object,
|
|
162
|
+
required: true,
|
|
163
|
+
},
|
|
164
|
+
|
|
168
165
|
/**
|
|
169
166
|
* Current theme of extended-multiselect
|
|
170
167
|
* used in class definition
|
|
@@ -179,7 +176,7 @@ const props = defineProps({
|
|
|
179
176
|
const {
|
|
180
177
|
createCustomOptionLabel,
|
|
181
178
|
disabled,
|
|
182
|
-
|
|
179
|
+
emitter,
|
|
183
180
|
emptyObjectsPlaceholder,
|
|
184
181
|
label,
|
|
185
182
|
increaseDisplayBy,
|
|
@@ -297,7 +294,7 @@ const overLimitOptionsCount = computed(() => {
|
|
|
297
294
|
const deselectBlock = (index) => {
|
|
298
295
|
if (loading.value || disabled.value) return;
|
|
299
296
|
|
|
300
|
-
emitter.emit(
|
|
297
|
+
emitter.value.emit("extended:deselect-option", { index });
|
|
301
298
|
};
|
|
302
299
|
|
|
303
300
|
/**
|
|
@@ -309,7 +306,7 @@ const deselectBlock = (index) => {
|
|
|
309
306
|
*/
|
|
310
307
|
const showMoreOptions = () => {
|
|
311
308
|
optionsLimitIncreaser.value += increaseDisplayBy.value;
|
|
312
|
-
emitter.emit(`extended:increase-display
|
|
309
|
+
emitter.value.emit(`extended:increase-display`, optionsLimitIncreaser.value);
|
|
313
310
|
};
|
|
314
311
|
|
|
315
312
|
/**
|
|
@@ -104,8 +104,6 @@ import {
|
|
|
104
104
|
toRefs,
|
|
105
105
|
} from "vue";
|
|
106
106
|
|
|
107
|
-
import emitter from '../events/emitter';
|
|
108
|
-
|
|
109
107
|
import usePreselectedOptions from "../composition/preselected-options";
|
|
110
108
|
import useLabels from "../composition/labels";
|
|
111
109
|
|
|
@@ -217,16 +215,6 @@ const props = defineProps({
|
|
|
217
215
|
required: true,
|
|
218
216
|
},
|
|
219
217
|
|
|
220
|
-
/**
|
|
221
|
-
* Assigns unique identifier of extended multiselect
|
|
222
|
-
* for each event
|
|
223
|
-
* @property {string} emitterUniqueId
|
|
224
|
-
*/
|
|
225
|
-
emitterUniqueId: {
|
|
226
|
-
type: String,
|
|
227
|
-
required: true,
|
|
228
|
-
},
|
|
229
|
-
|
|
230
218
|
/**
|
|
231
219
|
* Sets labels for options of type "object"
|
|
232
220
|
* or Array instances which length/keys length equals 0
|
|
@@ -389,6 +377,15 @@ const props = defineProps({
|
|
|
389
377
|
required: true,
|
|
390
378
|
},
|
|
391
379
|
|
|
380
|
+
/**
|
|
381
|
+
* Reactive instance of LocalEmitter class
|
|
382
|
+
* @property {object} emitter
|
|
383
|
+
*/
|
|
384
|
+
emitter: {
|
|
385
|
+
type: Object,
|
|
386
|
+
required: true,
|
|
387
|
+
},
|
|
388
|
+
|
|
392
389
|
/**
|
|
393
390
|
* Creates custom label for every option in options list
|
|
394
391
|
* @property {Function} createCustomOptionLabel
|
|
@@ -435,7 +432,7 @@ const {
|
|
|
435
432
|
createOptionType,
|
|
436
433
|
disableByField,
|
|
437
434
|
disabledPrimitiveOptionsConverted,
|
|
438
|
-
|
|
435
|
+
emitter,
|
|
439
436
|
emptyObjectsPlaceholder,
|
|
440
437
|
highlightOptions,
|
|
441
438
|
label,
|
|
@@ -720,7 +717,7 @@ const createNewOption = () => {
|
|
|
720
717
|
}
|
|
721
718
|
|
|
722
719
|
options.value.unshift(newOption);
|
|
723
|
-
emitter.emit(
|
|
720
|
+
emitter.value.emit("extended:create-option", newOption);
|
|
724
721
|
|
|
725
722
|
if (autoSelectCreatedOption.value) {
|
|
726
723
|
selectOption(newOption, { target: { id: "extended__multiselect" } });
|
|
@@ -986,7 +983,7 @@ const optionHighlightClasses = (option) => {
|
|
|
986
983
|
* @param {MouseEvent|KeyboardEvent} clickEvent - MouseEvent or KeyboardEvent instance
|
|
987
984
|
*/
|
|
988
985
|
const selectOption = (option, clickEvent) => {
|
|
989
|
-
emitter.emit(
|
|
986
|
+
emitter.value.emit("extended:trigger-selection", false);
|
|
990
987
|
|
|
991
988
|
if (!clickEvent) return;
|
|
992
989
|
if (keyBlocker(clickEvent)) return;
|
|
@@ -1001,7 +998,7 @@ const selectOption = (option, clickEvent) => {
|
|
|
1001
998
|
const optionDeselected = lookForObjectOptions(option);
|
|
1002
999
|
|
|
1003
1000
|
if (!optionDeselected) {
|
|
1004
|
-
emitter.emit(
|
|
1001
|
+
emitter.value.emit("extended:deselect-option");
|
|
1005
1002
|
return;
|
|
1006
1003
|
}
|
|
1007
1004
|
}
|
|
@@ -1031,15 +1028,15 @@ const selectOptionEmitter = (option) => {
|
|
|
1031
1028
|
|
|
1032
1029
|
if (multiple.value) {
|
|
1033
1030
|
if (clearBySelectWhenMultiple.value) {
|
|
1034
|
-
emitter.emit(
|
|
1031
|
+
emitter.value.emit("extended:clear-field");
|
|
1035
1032
|
}
|
|
1036
1033
|
|
|
1037
|
-
emitter.emit(
|
|
1034
|
+
emitter.value.emit("extended:select-option", {
|
|
1038
1035
|
label,
|
|
1039
1036
|
option,
|
|
1040
1037
|
});
|
|
1041
1038
|
} else {
|
|
1042
|
-
emitter.emit(
|
|
1039
|
+
emitter.value.emit("extended:select-option", {
|
|
1043
1040
|
label,
|
|
1044
1041
|
option,
|
|
1045
1042
|
});
|
|
@@ -1078,7 +1075,7 @@ const showCurrentMarker = (option) => {
|
|
|
1078
1075
|
*/
|
|
1079
1076
|
const triggerOptionBeforeSelection = () => {
|
|
1080
1077
|
if (fieldWasShown.value) {
|
|
1081
|
-
emitter.emit(
|
|
1078
|
+
emitter.value.emit("extended:trigger-selection", true);
|
|
1082
1079
|
}
|
|
1083
1080
|
};
|
|
1084
1081
|
|
|
@@ -1099,18 +1096,18 @@ onBeforeMount(() => {
|
|
|
1099
1096
|
console.warn("vue-extended-multiselect: «label» property can not be of type «object»");
|
|
1100
1097
|
}
|
|
1101
1098
|
|
|
1102
|
-
emitter.on(
|
|
1099
|
+
emitter.value.on("extended:select-enter", (keyboardEvent) => {
|
|
1103
1100
|
if (!enterIndex.value) return;
|
|
1104
1101
|
|
|
1105
1102
|
const option = availableOptions.value[enterIndex.value];
|
|
1106
1103
|
selectOption(option, keyboardEvent);
|
|
1107
1104
|
});
|
|
1108
1105
|
|
|
1109
|
-
emitter.on(
|
|
1106
|
+
emitter.value.on("extended:renew-field-forwarding", (value) => {
|
|
1110
1107
|
fieldWasShown.value = value;
|
|
1111
1108
|
});
|
|
1112
1109
|
|
|
1113
|
-
emitter.on(
|
|
1110
|
+
emitter.value.on("extended:reset-index", () => {
|
|
1114
1111
|
enterIndex.value = null;
|
|
1115
1112
|
});
|
|
1116
1113
|
});
|
|
@@ -137,16 +137,6 @@ const props = defineProps({
|
|
|
137
137
|
required: true,
|
|
138
138
|
},
|
|
139
139
|
|
|
140
|
-
/**
|
|
141
|
-
* Assigns unique identifier of extended multiselect
|
|
142
|
-
* for each event
|
|
143
|
-
* @property {string} emitterUniqueId
|
|
144
|
-
*/
|
|
145
|
-
emitterUniqueId: {
|
|
146
|
-
type: String,
|
|
147
|
-
required: true,
|
|
148
|
-
},
|
|
149
|
-
|
|
150
140
|
/**
|
|
151
141
|
* Determines toggle icon to be used in default toggle slot
|
|
152
142
|
* @property {string} toggleIcon
|
|
@@ -165,12 +155,21 @@ const props = defineProps({
|
|
|
165
155
|
type: Number,
|
|
166
156
|
default: null,
|
|
167
157
|
},
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Reactive instance of LocalEmitter class
|
|
161
|
+
* @property {object} emitter
|
|
162
|
+
*/
|
|
163
|
+
emitter: {
|
|
164
|
+
type: Object,
|
|
165
|
+
required: true,
|
|
166
|
+
},
|
|
168
167
|
});
|
|
169
168
|
|
|
170
169
|
const {
|
|
171
170
|
disabled,
|
|
172
171
|
dropdownActive,
|
|
173
|
-
|
|
172
|
+
emitter,
|
|
174
173
|
iconFilter,
|
|
175
174
|
iconSize,
|
|
176
175
|
loading,
|
|
@@ -184,7 +183,7 @@ const { toggleSlotClass, toggleOptionsList } = useToggle(
|
|
|
184
183
|
loading,
|
|
185
184
|
disabled,
|
|
186
185
|
null,
|
|
187
|
-
|
|
186
|
+
emitter,
|
|
188
187
|
);
|
|
189
188
|
const { iconSizeClass } = useSizes(iconSize);
|
|
190
189
|
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
:search-filter-active="searchFilterActive"
|
|
37
37
|
:toggling-saves-search-value="togglingSavesSearchValue"
|
|
38
38
|
:toggle-options-by-select="toggleOptionsBySelect"
|
|
39
|
-
:emitter-unique-id="emitterUniqueId"
|
|
40
39
|
:placeholder="placeholder"
|
|
41
40
|
:show-search-field="showSearchField"
|
|
42
41
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
@@ -48,6 +47,7 @@
|
|
|
48
47
|
:restricted-options-length="restrictedOptionsLength"
|
|
49
48
|
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
50
49
|
:selected-options="selectedOptions"
|
|
50
|
+
:emitter="emitter"
|
|
51
51
|
:create-custom-option-label="createCustomOptionLabel"
|
|
52
52
|
:create-option-placeholder="createOptionPlaceholder"
|
|
53
53
|
:external-options-loader="externalOptionsLoader"
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
:disabled="inputDisabled"
|
|
100
100
|
:dropdown-active="dropdownActive"
|
|
101
101
|
:loading="internalLoading"
|
|
102
|
-
:emitter-unique-id="emitterUniqueId"
|
|
103
102
|
:icon-filter="iconFilter"
|
|
104
103
|
:icon-size="iconSize"
|
|
105
104
|
:toggle-icon="toggleIcon"
|
|
105
|
+
:emitter="emitter"
|
|
106
106
|
/>
|
|
107
107
|
</slot>
|
|
108
108
|
<slot
|
|
@@ -115,10 +115,10 @@
|
|
|
115
115
|
:disabled="inputDisabled"
|
|
116
116
|
:show-search-field="showSearchField"
|
|
117
117
|
:loading="internalLoading"
|
|
118
|
-
:emitter-unique-id="emitterUniqueId"
|
|
119
118
|
:icon-filter="iconFilter"
|
|
120
119
|
:icon-size="iconSize"
|
|
121
120
|
:selected-options="selectedOptions"
|
|
121
|
+
:emitter="emitter"
|
|
122
122
|
/>
|
|
123
123
|
</slot>
|
|
124
124
|
</div>
|
|
@@ -140,7 +140,6 @@
|
|
|
140
140
|
:chosen-toggle-appearance-side="chosenToggleAppearanceSide"
|
|
141
141
|
:create-option-type="createOptionType"
|
|
142
142
|
:disable-by-field="disableByField"
|
|
143
|
-
:emitter-unique-id="emitterUniqueId"
|
|
144
143
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
145
144
|
:label="label"
|
|
146
145
|
:search-by-field="searchByField"
|
|
@@ -158,6 +157,7 @@
|
|
|
158
157
|
:special-keys-block="specialKeysBlock"
|
|
159
158
|
:preselected-option="preselectedOption"
|
|
160
159
|
:preselected-options="preselectedOptions"
|
|
160
|
+
:emitter="emitter"
|
|
161
161
|
:create-custom-option-label="createCustomOptionLabel"
|
|
162
162
|
>
|
|
163
163
|
<template
|
|
@@ -226,8 +226,6 @@ import {
|
|
|
226
226
|
} from "vue";
|
|
227
227
|
|
|
228
228
|
import { directive as vClickOutside } from "vue3-click-away";
|
|
229
|
-
import emitter from "../events/emitter";
|
|
230
|
-
import { v4 } from "uuid";
|
|
231
229
|
|
|
232
230
|
import {
|
|
233
231
|
themeTypes,
|
|
@@ -244,6 +242,7 @@ import {
|
|
|
244
242
|
import useToggle from "../composition/toggle";
|
|
245
243
|
import useCancel from "../composition/cancel";
|
|
246
244
|
import useLabels from "../composition/labels";
|
|
245
|
+
import useEmitter from "../composition/emitter";
|
|
247
246
|
import usePreselectedOptions from "../composition/preselected-options";
|
|
248
247
|
import useSearchValue from "../composition/search-value";
|
|
249
248
|
|
|
@@ -254,7 +253,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
|
|
|
254
253
|
|
|
255
254
|
/**
|
|
256
255
|
* @author Ridiger Daniil Dmitrievich
|
|
257
|
-
* @version 1.
|
|
256
|
+
* @version 1.5.0
|
|
258
257
|
*/
|
|
259
258
|
|
|
260
259
|
const props = defineProps({
|
|
@@ -890,7 +889,6 @@ const inputDisabled = ref(false);
|
|
|
890
889
|
const internalLoader = ref(false);
|
|
891
890
|
const externalOptionsLoader = ref(null);
|
|
892
891
|
const chosenToggleAppearanceSide = ref(null);
|
|
893
|
-
const emitterUniqueId = ref(v4());
|
|
894
892
|
const rawOptions = ref([]);
|
|
895
893
|
const selectedOptions = ref([]);
|
|
896
894
|
const togglePattern = /^extended__multiselect-toggle/i;
|
|
@@ -940,17 +938,18 @@ provide("searchState", searchState);
|
|
|
940
938
|
provide("setSearchValue", setSearchValue);
|
|
941
939
|
provide("setSearchPattern", setSearchPattern);
|
|
942
940
|
|
|
941
|
+
const { emitter } = useEmitter();
|
|
943
942
|
const { toggleOptionsList } = useToggle(
|
|
944
943
|
loading,
|
|
945
944
|
disabled,
|
|
946
945
|
internalLoader,
|
|
947
|
-
|
|
946
|
+
emitter,
|
|
948
947
|
);
|
|
949
948
|
const { cancel } = useCancel(
|
|
950
949
|
disabled,
|
|
951
950
|
showSearchField,
|
|
952
951
|
selectedOptions,
|
|
953
|
-
|
|
952
|
+
emitter,
|
|
954
953
|
setSearchValue,
|
|
955
954
|
setSearchPattern,
|
|
956
955
|
);
|
|
@@ -1138,7 +1137,7 @@ watch(disabled, (value) => {
|
|
|
1138
1137
|
*/
|
|
1139
1138
|
watch(dropdownActive, (value) => {
|
|
1140
1139
|
if (!value) {
|
|
1141
|
-
emitter.emit(
|
|
1140
|
+
emitter.value.emit("extended:rollup-options");
|
|
1142
1141
|
}
|
|
1143
1142
|
});
|
|
1144
1143
|
|
|
@@ -1167,7 +1166,7 @@ watch(selectedOptions, (value) => {
|
|
|
1167
1166
|
}
|
|
1168
1167
|
|
|
1169
1168
|
if (resetSearchByValue.value) {
|
|
1170
|
-
emitter.emit(
|
|
1169
|
+
emitter.value.emit("extended:clear-field");
|
|
1171
1170
|
}
|
|
1172
1171
|
}, { deep: true });
|
|
1173
1172
|
|
|
@@ -1195,7 +1194,7 @@ const activeEmitter = () => {
|
|
|
1195
1194
|
* @emits "extended:rollup-options"
|
|
1196
1195
|
*/
|
|
1197
1196
|
const clickOutside = () => {
|
|
1198
|
-
emitter.emit(
|
|
1197
|
+
emitter.value.emit("extended:rollup-options");
|
|
1199
1198
|
};
|
|
1200
1199
|
|
|
1201
1200
|
/**
|
|
@@ -1262,7 +1261,7 @@ const fieldFocus = (mouseEvent) => {
|
|
|
1262
1261
|
if (filteredHasCancel.length) return;
|
|
1263
1262
|
if (filteredHasToggle.length && dropdownActive.value === false) return;
|
|
1264
1263
|
|
|
1265
|
-
emitter.emit(
|
|
1264
|
+
emitter.value.emit("extended:field-focus");
|
|
1266
1265
|
};
|
|
1267
1266
|
|
|
1268
1267
|
/**
|
|
@@ -1286,7 +1285,7 @@ const loadOptionsByExternalLoader = (pattern) => {
|
|
|
1286
1285
|
* @emits extended:reset-index
|
|
1287
1286
|
*/
|
|
1288
1287
|
const resetEnterIndex = () => {
|
|
1289
|
-
emitter.emit(
|
|
1288
|
+
emitter.value.emit("extended:reset-index");
|
|
1290
1289
|
};
|
|
1291
1290
|
|
|
1292
1291
|
/**
|
|
@@ -1296,7 +1295,7 @@ const resetEnterIndex = () => {
|
|
|
1296
1295
|
*/
|
|
1297
1296
|
const rollUp = () => {
|
|
1298
1297
|
dropdownActive.value = false;
|
|
1299
|
-
emitter.emit(
|
|
1298
|
+
emitter.value.emit("extended:rollup-options");
|
|
1300
1299
|
};
|
|
1301
1300
|
|
|
1302
1301
|
/**
|
|
@@ -1306,7 +1305,7 @@ const rollUp = () => {
|
|
|
1306
1305
|
* @param {KeyboardEvent} keyboardEvent - KeyboardEvent instance
|
|
1307
1306
|
*/
|
|
1308
1307
|
const selectByEnter = (keyboardEvent) => {
|
|
1309
|
-
emitter.emit(
|
|
1308
|
+
emitter.value.emit("extended:select-enter", keyboardEvent);
|
|
1310
1309
|
};
|
|
1311
1310
|
|
|
1312
1311
|
/**
|
|
@@ -1329,7 +1328,7 @@ const setPreselectedOption = () => {
|
|
|
1329
1328
|
const isObjectOrArray = typeof preselectedOption.value === "object";
|
|
1330
1329
|
const label = createLabel(isObjectOrArray, preselectedOption.value);
|
|
1331
1330
|
|
|
1332
|
-
emitter.emit(
|
|
1331
|
+
emitter.value.emit("extended:select-option", {
|
|
1333
1332
|
label,
|
|
1334
1333
|
option: preselectedOption.value,
|
|
1335
1334
|
});
|
|
@@ -1359,7 +1358,7 @@ const setPreselectedOptions = async () => {
|
|
|
1359
1358
|
|
|
1360
1359
|
allOptionsWereSelected++;
|
|
1361
1360
|
|
|
1362
|
-
emitter.emit(
|
|
1361
|
+
emitter.value.emit("extended:select-option", {
|
|
1363
1362
|
label,
|
|
1364
1363
|
option: preselectedOption,
|
|
1365
1364
|
});
|
|
@@ -1446,7 +1445,7 @@ const toggleBlockRestrictor = (mouseEvent) => {
|
|
|
1446
1445
|
}
|
|
1447
1446
|
|
|
1448
1447
|
if (generalRestriction) {
|
|
1449
|
-
emitter.emit(
|
|
1448
|
+
emitter.value.emit("extended:skip-block-blur");
|
|
1450
1449
|
return true;
|
|
1451
1450
|
}
|
|
1452
1451
|
|
|
@@ -1567,7 +1566,7 @@ const toggleRestrictor = (mouseEvent) => {
|
|
|
1567
1566
|
const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
|
|
1568
1567
|
|
|
1569
1568
|
if (filteredHasToggle.length && dropdownActive.value) {
|
|
1570
|
-
emitter.emit(
|
|
1569
|
+
emitter.value.emit("extended:skip-blur");
|
|
1571
1570
|
}
|
|
1572
1571
|
};
|
|
1573
1572
|
|
|
@@ -1591,18 +1590,18 @@ const toggleRestrictor = (mouseEvent) => {
|
|
|
1591
1590
|
onBeforeMount(() => {
|
|
1592
1591
|
chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
|
|
1593
1592
|
|
|
1594
|
-
emitter.on(
|
|
1593
|
+
emitter.value.on("extended:rollup-options", () => {
|
|
1595
1594
|
if (!dropdownActive.value) return;
|
|
1596
1595
|
|
|
1597
1596
|
closeEmitter();
|
|
1598
1597
|
dropdownActive.value = false;
|
|
1599
1598
|
});
|
|
1600
1599
|
|
|
1601
|
-
emitter.on(
|
|
1600
|
+
emitter.value.on("extended:toggle-options", () => {
|
|
1602
1601
|
toggleOptions();
|
|
1603
1602
|
});
|
|
1604
1603
|
|
|
1605
|
-
emitter.on(
|
|
1604
|
+
emitter.value.on("extended:select-option", (option) => {
|
|
1606
1605
|
const eventData = simpleEvents.value
|
|
1607
1606
|
? option.option
|
|
1608
1607
|
: createEventFields(option.option, "option");
|
|
@@ -1625,7 +1624,7 @@ onBeforeMount(() => {
|
|
|
1625
1624
|
}
|
|
1626
1625
|
});
|
|
1627
1626
|
|
|
1628
|
-
emitter.on(
|
|
1627
|
+
emitter.value.on("extended:deselect-option", (payload) => {
|
|
1629
1628
|
if (multiple.value && (payload && !payload.clearAll)) {
|
|
1630
1629
|
const deselectedOption = selectedOptions.value[payload.index];
|
|
1631
1630
|
|
|
@@ -1648,11 +1647,11 @@ onBeforeMount(() => {
|
|
|
1648
1647
|
}
|
|
1649
1648
|
|
|
1650
1649
|
if (toggleOptionsBySelect.value) {
|
|
1651
|
-
emitter.emit(
|
|
1650
|
+
emitter.value.emit("extended:rollup-options");
|
|
1652
1651
|
}
|
|
1653
1652
|
});
|
|
1654
1653
|
|
|
1655
|
-
emitter.on(
|
|
1654
|
+
emitter.value.on("extended:clean-options", (selectedOptions) => {
|
|
1656
1655
|
const eventData = simpleEvents.value
|
|
1657
1656
|
? selectedOptions.value
|
|
1658
1657
|
: createEventFields(selectedOptions, "options");
|
|
@@ -1664,7 +1663,7 @@ onBeforeMount(() => {
|
|
|
1664
1663
|
emit("clean", eventData);
|
|
1665
1664
|
});
|
|
1666
1665
|
|
|
1667
|
-
emitter.on(
|
|
1666
|
+
emitter.value.on("extended:create-option", (createdOption) => {
|
|
1668
1667
|
const eventData = simpleEvents.value
|
|
1669
1668
|
? createdOption
|
|
1670
1669
|
: createEventFields(createdOption, "option");
|
|
@@ -1678,7 +1677,7 @@ onBeforeMount(() => {
|
|
|
1678
1677
|
emit("option-created", eventData);
|
|
1679
1678
|
});
|
|
1680
1679
|
|
|
1681
|
-
emitter.on(
|
|
1680
|
+
emitter.value.on("extended:increase-display", (limit) => {
|
|
1682
1681
|
const eventData = simpleEvents.value ? limit : createEventFields(limit, "limit");
|
|
1683
1682
|
|
|
1684
1683
|
/**
|
|
@@ -1690,7 +1689,7 @@ onBeforeMount(() => {
|
|
|
1690
1689
|
emit("increase", eventData);
|
|
1691
1690
|
});
|
|
1692
1691
|
|
|
1693
|
-
emitter.on(
|
|
1692
|
+
emitter.value.on("extended:search-pattern-changed", (pattern) => {
|
|
1694
1693
|
const eventData = simpleEvents.value
|
|
1695
1694
|
? pattern
|
|
1696
1695
|
: createEventFields(pattern, "pattern");
|
|
@@ -1727,7 +1726,7 @@ onMounted(() => {
|
|
|
1727
1726
|
dropdownActive.value = true;
|
|
1728
1727
|
}
|
|
1729
1728
|
|
|
1730
|
-
emitter.on(
|
|
1729
|
+
emitter.value.on("extended:expand-options", () => {
|
|
1731
1730
|
if (dropdownActive.value === true) return;
|
|
1732
1731
|
|
|
1733
1732
|
toggleAppearanceRestrictorActivate();
|
|
@@ -1736,7 +1735,7 @@ onMounted(() => {
|
|
|
1736
1735
|
dropdownActive.value = true;
|
|
1737
1736
|
});
|
|
1738
1737
|
|
|
1739
|
-
emitter.on(
|
|
1738
|
+
emitter.value.on("extended:loader-pattern-changed", (pattern) => {
|
|
1740
1739
|
loadOptionsByExternalLoader(pattern);
|
|
1741
1740
|
});
|
|
1742
1741
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import emitter from "../events/emitter";
|
|
2
|
-
|
|
3
1
|
import useSearchValue from './search-value';
|
|
4
2
|
|
|
5
3
|
export default function useCancel(
|
|
6
4
|
disabled,
|
|
7
5
|
showSearchField,
|
|
8
6
|
selectedOptions,
|
|
9
|
-
|
|
7
|
+
emitter,
|
|
10
8
|
setSearchValue,
|
|
11
9
|
setSearchPattern,
|
|
12
10
|
) {
|
|
@@ -21,15 +19,15 @@ export default function useCancel(
|
|
|
21
19
|
const cancel = () => {
|
|
22
20
|
if (disabled.value) return;
|
|
23
21
|
|
|
24
|
-
emitter.emit(
|
|
25
|
-
emitter.emit(
|
|
22
|
+
emitter.value.emit("extended:skip-block-blur-zeroing");
|
|
23
|
+
emitter.value.emit("extended:deselect-option", {
|
|
26
24
|
index: null,
|
|
27
25
|
clearAll: true,
|
|
28
26
|
});
|
|
29
27
|
|
|
30
28
|
if (!showSearchField.value) return;
|
|
31
29
|
|
|
32
|
-
emitter.emit(
|
|
30
|
+
emitter.value.emit("extended:clean-options", selectedOptions.value);
|
|
33
31
|
|
|
34
32
|
setSearchValue(null);
|
|
35
33
|
setSearchPattern(null);
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { computed, readonly } from "vue";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default function useToggle(loading, disabled, internalLoader, emitterUniqueId) {
|
|
3
|
+
export default function useToggle(loading, disabled, internalLoader, emitter) {
|
|
6
4
|
/**
|
|
7
5
|
* Toggles classes of slots if "loading"
|
|
8
6
|
* or "disabled" props equals true
|
|
@@ -24,7 +22,7 @@ export default function useToggle(loading, disabled, internalLoader, emitterUniq
|
|
|
24
22
|
const toggleOptionsList = (event) => {
|
|
25
23
|
if (event && event.code === "Tab") return;
|
|
26
24
|
|
|
27
|
-
emitter.emit(
|
|
25
|
+
emitter.value.emit("extended:toggle-options");
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
return {
|
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
createNewOptionsWrapper,
|
|
10
10
|
} from "../utils/utils";
|
|
11
11
|
|
|
12
|
-
import emitter from "../../src/events/emitter";
|
|
13
|
-
|
|
14
12
|
import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
|
|
15
13
|
import ExtendedMultiselectInput from "../../src/components/ExtendedMultiselectInput.vue";
|
|
16
14
|
import ExtendedMultiselectMultiple from "../../src/components/ExtendedMultiselectMultiple.vue";
|
|
@@ -25,8 +23,8 @@ describe("events", () => {
|
|
|
25
23
|
|
|
26
24
|
wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
|
|
27
25
|
|
|
28
|
-
emitter.emit(
|
|
29
|
-
|
|
26
|
+
wrapper.vm.emitter.emit(
|
|
27
|
+
"extended:search-pattern-changed",
|
|
30
28
|
globalThis.SEARCH_VALUE,
|
|
31
29
|
);
|
|
32
30
|
|
package/src/events/emitter.js
DELETED