vue3-extended-multiselect 1.1.8 → 1.2.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 CHANGED
@@ -128,4 +128,11 @@ Adding descriptive comments for some types in typings.
128
128
  * Adding "disableByField" prop for determination of field in options of type "object" which value will be used to disable such options.
129
129
 
130
130
  ### 1.1.8 (2022-12-18)
131
- * Changing default value of "toggleIcon" prop to "base-arrow".
131
+ * Changing default value of "toggleIcon" prop to "base-arrow".
132
+
133
+ ### 1.2.0 (2022-12-20)
134
+ * Adding "uuid" dependency
135
+ * Removal of "id" attribute of extended multiselect wrapper.
136
+ * Removal of "querySelector" usage in ExtendedMultiselect component. Switching to using event emitter.
137
+ * Fix bug with bound event emitters between two extended multiselects.
138
+ * Fix bug with undefined class in extended multiselect wrapper class list.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.1.8
1
+ # vue3-extended-multiselect v1.2.0
2
2
 
3
3
  ***
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -25,6 +25,7 @@
25
25
  "core-js": "^3.6.5",
26
26
  "lodash-es": "^4.17.21",
27
27
  "mitt": "^3.0.0",
28
+ "uuid": "^9.0.0",
28
29
  "vue": "^3.0.0",
29
30
  "vue3-click-away": "^1.2.4"
30
31
  },
@@ -46,6 +46,16 @@ const props = defineProps({
46
46
  required: true,
47
47
  },
48
48
 
49
+ /**
50
+ * Assigns unique identifier of extended multiselect
51
+ * for each event
52
+ * @property {string} emitterUniqueId
53
+ */
54
+ emitterUniqueId: {
55
+ type: String,
56
+ required: true,
57
+ },
58
+
49
59
  /**
50
60
  * Defines a svg-filter for icons
51
61
  * @property {string} iconFilter
@@ -105,6 +115,7 @@ const props = defineProps({
105
115
 
106
116
  const {
107
117
  disabled,
118
+ emitterUniqueId,
108
119
  iconFilter,
109
120
  iconSize,
110
121
  loading,
@@ -121,6 +132,7 @@ const { cancel } = useCancel(
121
132
  disabled,
122
133
  showSearchField,
123
134
  selectedOptions,
135
+ emitterUniqueId,
124
136
  );
125
137
  const { iconSizeClass } = useSizes(iconSize);
126
138
 
@@ -37,6 +37,7 @@
37
37
  :disabled="disabled"
38
38
  :loading="loading"
39
39
  :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
40
+ :emitter-unique-id="emitterUniqueId"
40
41
  :empty-objects-placeholder="emptyObjectsPlaceholder"
41
42
  :label="label"
42
43
  :multiple-blocks-limit-message="multipleBlocksLimitMessage"
@@ -75,6 +76,7 @@
75
76
  :disabled="disabled"
76
77
  :loading="loading"
77
78
  :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
79
+ :emitter-unique-id="emitterUniqueId"
78
80
  :empty-objects-placeholder="emptyObjectsPlaceholder"
79
81
  :label="label"
80
82
  :multiple-blocks-limit-message="multipleBlocksLimitMessage"
@@ -140,6 +142,7 @@ import {
140
142
  onBeforeMount,
141
143
  onMounted,
142
144
  ref,
145
+ toRef,
143
146
  toRefs,
144
147
  useAttrs,
145
148
  watch,
@@ -257,6 +260,16 @@ const props = defineProps({
257
260
  required: true,
258
261
  },
259
262
 
263
+ /**
264
+ * Assigns unique identifier of extended multiselect
265
+ * for each event
266
+ * @property {string} emitterUniqueId
267
+ */
268
+ emitterUniqueId: {
269
+ type: String,
270
+ required: true,
271
+ },
272
+
260
273
  /**
261
274
  * Placeholder used in internal options filters
262
275
  * and provided to ExtendedMultiselectMultiple child component
@@ -372,6 +385,8 @@ const searchState = inject("searchState");
372
385
  const setSearchValue = inject("setSearchValue");
373
386
  const setSearchPattern = inject("setSearchPattern");
374
387
 
388
+ const emitterUniqueId = toRef(props, "emitterUniqueId");
389
+
375
390
  const blurSkip = ref(false);
376
391
  const reversePrevented = ref(false);
377
392
  const searchFieldFocused = ref(false);
@@ -385,9 +400,9 @@ const searchDebounce = ref(debounce(() => {
385
400
  const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
386
401
 
387
402
  if (externalOptionsLoader.value) {
388
- emitter.emit("extended:loader-pattern-changed", searchValue.value);
403
+ emitter.emit(`extended:loader-pattern-changed-${emitterUniqueId.value}`, searchValue.value);
389
404
  } else {
390
- emitter.emit("extended:search-pattern-changed", searchValue.value);
405
+ emitter.emit(`extended:search-pattern-changed-${emitterUniqueId.value}`, searchValue.value);
391
406
  setSearchPattern(searchPattern);
392
407
  }
393
408
  }, 250));
@@ -462,6 +477,16 @@ const searchFieldForwarding = computed(() => {
462
477
  return searchFieldFocused.value || optionWillBeTriggered.value;
463
478
  });
464
479
 
480
+ /**
481
+ * Determines whether option shall be triggered before selection
482
+ * @function
483
+ * @emits extended:renew-field-forwarding
484
+ * @param {boolean} searchFieldForwarding - restrictor of triggered option
485
+ */
486
+ watch(searchFieldForwarding, (value) => {
487
+ emitter.emit(`extended:renew-field-forwarding-${emitterUniqueId.value}`, value);
488
+ });
489
+
465
490
  /**
466
491
  * Sets pattern of internal search for available options from search field to store
467
492
  * @function
@@ -495,7 +520,7 @@ const expand = () => {
495
520
  if (disabled.value) return;
496
521
 
497
522
  searchFieldFocused.value = true;
498
- emitter.emit("extended:expand-options");
523
+ emitter.emit(`extended:expand-options-${emitterUniqueId.value}`);
499
524
  };
500
525
 
501
526
  /**
@@ -544,7 +569,7 @@ const rollUp = () => {
544
569
  blurSkipByBlock.value = 0;
545
570
  blurSkipByToggleIcon.value = 0;
546
571
 
547
- emitter.emit("extended:rollup-options", true);
572
+ emitter.emit(`extended:rollup-options-${emitterUniqueId.value}`, true);
548
573
  };
549
574
 
550
575
  /**
@@ -569,7 +594,7 @@ const search = () => {
569
594
  * @listens extended:trigger-selection
570
595
  */
571
596
  onBeforeMount(() => {
572
- emitter.on("extended:rollup-options", (internalRollup) => {
597
+ emitter.on(`extended:rollup-options-${emitterUniqueId.value}`, (internalRollup) => {
573
598
  if (blurSkip.value === true) {
574
599
  blurSkip.value = false;
575
600
  return;
@@ -582,7 +607,7 @@ onBeforeMount(() => {
582
607
  rollUp();
583
608
  });
584
609
 
585
- emitter.on("extended:select-option", (option) => {
610
+ emitter.on(`extended:select-option-${emitterUniqueId.value}`, (option) => {
586
611
  if (toggleOptionsBySelect.value) {
587
612
  rollUp();
588
613
  }
@@ -594,7 +619,7 @@ onBeforeMount(() => {
594
619
  }
595
620
  });
596
621
 
597
- emitter.on("extended:deselect-option", () => {
622
+ emitter.on(`extended:deselect-option-${emitterUniqueId.value}`, () => {
598
623
  if (multiple.value) {
599
624
  return;
600
625
  } else {
@@ -602,27 +627,27 @@ onBeforeMount(() => {
602
627
  }
603
628
  });
604
629
 
605
- emitter.on("extended:clean-options", () => {
630
+ emitter.on(`extended:clean-options-${emitterUniqueId.value}`, () => {
606
631
  searchValue.value = null;
607
632
  });
608
633
 
609
- emitter.on("extended:clear-field", () => {
634
+ emitter.on(`extended:clear-field-${emitterUniqueId.value}`, () => {
610
635
  searchValue.value = null;
611
636
  });
612
637
 
613
- emitter.on("extended:skip-blur", () => {
638
+ emitter.on(`extended:skip-blur-${emitterUniqueId.value}`, () => {
614
639
  blurSkipByToggleIcon.value++;
615
640
  });
616
641
 
617
- emitter.on("extended:skip-block-blur", () => {
642
+ emitter.on(`extended:skip-block-blur-${emitterUniqueId.value}`, () => {
618
643
  blurSkipByBlock.value++;
619
644
  });
620
645
 
621
- emitter.on("extended:skip-block-blur-zeroing", () => {
646
+ emitter.on(`extended:skip-block-blur-zeroing-${emitterUniqueId.value}`, () => {
622
647
  blurSkipByBlock.value = 0;
623
648
  });
624
649
 
625
- emitter.on("extended:trigger-selection", (triggerState) => {
650
+ emitter.on(`extended:trigger-selection-${emitterUniqueId.value}`, (triggerState) => {
626
651
  optionWillBeTriggered.value = triggerState;
627
652
  });
628
653
  });
@@ -632,7 +657,7 @@ onBeforeMount(() => {
632
657
  * @listens extended:field-focus
633
658
  */
634
659
  onMounted(() => {
635
- emitter.on("extended:field-focus", () => {
660
+ emitter.on(`extended:field-focus-${emitterUniqueId.value}`, () => {
636
661
  if (showSearchField.value) {
637
662
  nextTick(() => {
638
663
  extendedInput.value.focus();
@@ -82,6 +82,16 @@ const props = defineProps({
82
82
  required: true,
83
83
  },
84
84
 
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
+
85
95
  /**
86
96
  * Defines label for blocks with options of type "object"
87
97
  * or Array instances which length/keys length equals 0
@@ -169,6 +179,7 @@ const props = defineProps({
169
179
  const {
170
180
  createCustomOptionLabel,
171
181
  disabled,
182
+ emitterUniqueId,
172
183
  emptyObjectsPlaceholder,
173
184
  label,
174
185
  increaseDisplayBy,
@@ -286,7 +297,7 @@ const overLimitOptionsCount = computed(() => {
286
297
  const deselectBlock = (index) => {
287
298
  if (loading.value || disabled.value) return;
288
299
 
289
- emitter.emit("extended:deselect-option", { index });
300
+ emitter.emit(`extended:deselect-option-${emitterUniqueId.value}`, { index });
290
301
  };
291
302
 
292
303
  /**
@@ -298,7 +309,7 @@ const deselectBlock = (index) => {
298
309
  */
299
310
  const showMoreOptions = () => {
300
311
  optionsLimitIncreaser.value += increaseDisplayBy.value;
301
- emitter.emit("extended:increase-display", optionsLimitIncreaser.value);
312
+ emitter.emit(`extended:increase-display-${emitterUniqueId.value}`, optionsLimitIncreaser.value);
302
313
  };
303
314
 
304
315
  /**
@@ -217,6 +217,16 @@ const props = defineProps({
217
217
  required: true,
218
218
  },
219
219
 
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
+
220
230
  /**
221
231
  * Sets labels for options of type "object"
222
232
  * or Array instances which length/keys length equals 0
@@ -403,6 +413,7 @@ const searchState = inject("searchState");
403
413
  const setSearchValue = inject("setSearchValue");
404
414
  const setSearchPattern = inject("setSearchPattern");
405
415
 
416
+ const fieldWasShown = ref(false);
406
417
  const atopWithScroll = ref(null);
407
418
  const enterIndex = ref(null);
408
419
  const heightFromMounted = ref(null);
@@ -424,6 +435,7 @@ const {
424
435
  createOptionType,
425
436
  disableByField,
426
437
  disabledPrimitiveOptionsConverted,
438
+ emitterUniqueId,
427
439
  emptyObjectsPlaceholder,
428
440
  highlightOptions,
429
441
  label,
@@ -708,7 +720,7 @@ const createNewOption = () => {
708
720
  }
709
721
 
710
722
  options.value.unshift(newOption);
711
- emitter.emit("extended:create-option", newOption);
723
+ emitter.emit(`extended:create-option-${emitterUniqueId.value}`, newOption);
712
724
 
713
725
  if (autoSelectCreatedOption.value) {
714
726
  selectOption(newOption, { target: { id: "extended__multiselect" } });
@@ -974,7 +986,7 @@ const optionHighlightClasses = (option) => {
974
986
  * @param {MouseEvent|KeyboardEvent} clickEvent - MouseEvent or KeyboardEvent instance
975
987
  */
976
988
  const selectOption = (option, clickEvent) => {
977
- emitter.emit("extended:trigger-selection", false);
989
+ emitter.emit(`extended:trigger-selection-${emitterUniqueId.value}`, false);
978
990
 
979
991
  if (!clickEvent) return;
980
992
  if (keyBlocker(clickEvent)) return;
@@ -989,7 +1001,7 @@ const selectOption = (option, clickEvent) => {
989
1001
  const optionDeselected = lookForObjectOptions(option);
990
1002
 
991
1003
  if (!optionDeselected) {
992
- emitter.emit("extended:deselect-option");
1004
+ emitter.emit(`extended:deselect-option-${emitterUniqueId.value}`);
993
1005
  return;
994
1006
  }
995
1007
  }
@@ -1019,15 +1031,15 @@ const selectOptionEmitter = (option) => {
1019
1031
 
1020
1032
  if (multiple.value) {
1021
1033
  if (clearBySelectWhenMultiple.value) {
1022
- emitter.emit("extended:clear-field");
1034
+ emitter.emit(`extended:clear-field-${emitterUniqueId.value}`);
1023
1035
  }
1024
1036
 
1025
- emitter.emit("extended:select-option", {
1037
+ emitter.emit(`extended:select-option-${emitterUniqueId.value}`, {
1026
1038
  label,
1027
1039
  option,
1028
1040
  });
1029
1041
  } else {
1030
- emitter.emit("extended:select-option", {
1042
+ emitter.emit(`extended:select-option-${emitterUniqueId.value}`, {
1031
1043
  label,
1032
1044
  option,
1033
1045
  });
@@ -1065,16 +1077,15 @@ const showCurrentMarker = (option) => {
1065
1077
  * @emits extended:trigger-selection
1066
1078
  */
1067
1079
  const triggerOptionBeforeSelection = () => {
1068
- const fieldWasShown = document.querySelector(".extended__multiselect-input");
1069
-
1070
- if (fieldWasShown) {
1071
- emitter.emit("extended:trigger-selection", true);
1080
+ if (fieldWasShown.value) {
1081
+ emitter.emit(`extended:trigger-selection-${emitterUniqueId.value}`, true);
1072
1082
  }
1073
1083
  };
1074
1084
 
1075
1085
  /**
1076
1086
  * "onBeforeMount" hook of ExtendedMultiselectOptions component
1077
1087
  * @listens extended:select-enter
1088
+ * @listens extended:renew-field-forwarding
1078
1089
  * @listens extended:reset-index
1079
1090
  */
1080
1091
  onBeforeMount(() => {
@@ -1088,14 +1099,18 @@ onBeforeMount(() => {
1088
1099
  console.warn("vue-extended-multiselect: «label» property can not be of type «object»");
1089
1100
  }
1090
1101
 
1091
- emitter.on("extended:select-enter", (keyboardEvent) => {
1102
+ emitter.on(`extended:select-enter-${emitterUniqueId.value}`, (keyboardEvent) => {
1092
1103
  if (!enterIndex.value) return;
1093
1104
 
1094
1105
  const option = availableOptions.value[enterIndex.value];
1095
1106
  selectOption(option, keyboardEvent);
1096
1107
  });
1097
1108
 
1098
- emitter.on("extended:reset-index", () => {
1109
+ emitter.on(`extended:renew-field-forwarding-${emitterUniqueId.value}`, (value) => {
1110
+ fieldWasShown.value = value;
1111
+ });
1112
+
1113
+ emitter.on(`extended:reset-index-${emitterUniqueId.value}`, () => {
1099
1114
  enterIndex.value = null;
1100
1115
  });
1101
1116
  });
@@ -137,6 +137,16 @@ 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
+
140
150
  /**
141
151
  * Determines toggle icon to be used in default toggle slot
142
152
  * @property {string} toggleIcon
@@ -160,6 +170,7 @@ const props = defineProps({
160
170
  const {
161
171
  disabled,
162
172
  dropdownActive,
173
+ emitterUniqueId,
163
174
  iconFilter,
164
175
  iconSize,
165
176
  loading,
@@ -173,6 +184,7 @@ const { toggleSlotClass, toggleOptionsList } = useToggle(
173
184
  loading,
174
185
  disabled,
175
186
  null,
187
+ emitterUniqueId,
176
188
  );
177
189
  const { iconSizeClass } = useSizes(iconSize);
178
190
 
@@ -15,7 +15,6 @@
15
15
  @mouseleave.stop="resetEnterIndex"
16
16
  >
17
17
  <div
18
- id="extended__multiselect"
19
18
  ref="extendedMultiselect"
20
19
  :class="classes"
21
20
  :style="[displayWrongValue, expanded]"
@@ -31,12 +30,12 @@
31
30
  :create-on-the-go="createOnTheGo"
32
31
  :disabled="inputDisabled"
33
32
  :dropdown-active="dropdownActive"
34
- :external-options-loader="externalOptionsLoader"
35
33
  :loading="internalLoading"
36
34
  :multiple="multiple"
37
35
  :search-filter-active="searchFilterActive"
38
36
  :toggling-saves-search-value="togglingSavesSearchValue"
39
37
  :toggle-options-by-select="toggleOptionsBySelect"
38
+ :emitter-unique-id="emitterUniqueId"
40
39
  :placeholder="placeholder"
41
40
  :show-search-field="showSearchField"
42
41
  :empty-objects-placeholder="emptyObjectsPlaceholder"
@@ -50,6 +49,7 @@
50
49
  :selected-options="selectedOptions"
51
50
  :create-custom-option-label="createCustomOptionLabel"
52
51
  :create-option-placeholder="createOptionPlaceholder"
52
+ :external-options-loader="externalOptionsLoader"
53
53
  :input-id="inputId"
54
54
  >
55
55
  <template
@@ -98,6 +98,7 @@
98
98
  :disabled="inputDisabled"
99
99
  :dropdown-active="dropdownActive"
100
100
  :loading="internalLoading"
101
+ :emitter-unique-id="emitterUniqueId"
101
102
  :icon-filter="iconFilter"
102
103
  :icon-size="iconSize"
103
104
  :toggle-icon="toggleIcon"
@@ -113,6 +114,7 @@
113
114
  :disabled="inputDisabled"
114
115
  :show-search-field="showSearchField"
115
116
  :loading="internalLoading"
117
+ :emitter-unique-id="emitterUniqueId"
116
118
  :icon-filter="iconFilter"
117
119
  :icon-size="iconSize"
118
120
  :selected-options="selectedOptions"
@@ -137,6 +139,7 @@
137
139
  :chosen-toggle-appearance-side="chosenToggleAppearanceSide"
138
140
  :create-option-type="createOptionType"
139
141
  :disable-by-field="disableByField"
142
+ :emitter-unique-id="emitterUniqueId"
140
143
  :empty-objects-placeholder="emptyObjectsPlaceholder"
141
144
  :label="label"
142
145
  :search-by-field="searchByField"
@@ -223,6 +226,7 @@ import {
223
226
 
224
227
  import { directive as vClickOutside } from "vue3-click-away";
225
228
  import emitter from "../events/emitter";
229
+ import { v4 } from "uuid";
226
230
 
227
231
  import {
228
232
  themeTypes,
@@ -249,7 +253,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
249
253
 
250
254
  /**
251
255
  * @author Ridiger Daniil Dmitrievich
252
- * @version 1.0.0
256
+ * @version 1.2.0
253
257
  */
254
258
 
255
259
  const props = defineProps({
@@ -874,6 +878,7 @@ const inputDisabled = ref(false);
874
878
  const internalLoader = ref(false);
875
879
  const externalOptionsLoader = ref(null);
876
880
  const chosenToggleAppearanceSide = ref(null);
881
+ const emitterUniqueId = ref(v4());
877
882
  const rawOptions = ref([]);
878
883
  const selectedOptions = ref([]);
879
884
  const togglePattern = /^extended__multiselect-toggle/i;
@@ -924,14 +929,16 @@ provide("setSearchValue", setSearchValue);
924
929
  provide("setSearchPattern", setSearchPattern);
925
930
 
926
931
  const { toggleOptionsList } = useToggle(
927
- loading,
928
- disabled,
929
- internalLoader,
932
+ loading,
933
+ disabled,
934
+ internalLoader,
935
+ emitterUniqueId,
930
936
  );
931
937
  const { cancel } = useCancel(
932
- disabled,
933
- showSearchField,
938
+ disabled,
939
+ showSearchField,
934
940
  selectedOptions,
941
+ emitterUniqueId,
935
942
  );
936
943
  const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
937
944
  label,
@@ -971,7 +978,7 @@ const classes = computed(() => {
971
978
  case "strict":
972
979
  theme = "extended__multiselect-strict";
973
980
  break;
974
- default: return ["extended__multiselect"];
981
+ default: theme = "extended__multiselect";
975
982
  }
976
983
 
977
984
  localClassList.push(theme);
@@ -981,6 +988,7 @@ const classes = computed(() => {
981
988
  : "extended__multiselect-clear--locked";
982
989
 
983
990
  localClassList.push(clear);
991
+ localClassList.push("extended__multiselect-container");
984
992
 
985
993
  return localClassList;
986
994
  });
@@ -1118,7 +1126,7 @@ watch(disabled, (value) => {
1118
1126
  */
1119
1127
  watch(dropdownActive, (value) => {
1120
1128
  if (!value) {
1121
- emitter.emit("extended:rollup-options");
1129
+ emitter.emit(`extended:rollup-options-${emitterUniqueId.value}`);
1122
1130
  }
1123
1131
  });
1124
1132
 
@@ -1147,7 +1155,7 @@ watch(selectedOptions, (value) => {
1147
1155
  }
1148
1156
 
1149
1157
  if (resetSearchByValue.value) {
1150
- emitter.emit("extended:clear-field");
1158
+ emitter.emit(`extended:clear-field-${emitterUniqueId.value}`);
1151
1159
  }
1152
1160
  }, { deep: true });
1153
1161
 
@@ -1175,7 +1183,7 @@ const activeEmitter = () => {
1175
1183
  * @emits "extended:rollup-options"
1176
1184
  */
1177
1185
  const clickOutside = () => {
1178
- emitter.emit("extended:rollup-options");
1186
+ emitter.emit(`extended:rollup-options-${emitterUniqueId.value}`);
1179
1187
  };
1180
1188
 
1181
1189
  /**
@@ -1242,7 +1250,7 @@ const fieldFocus = (mouseEvent) => {
1242
1250
  if (filteredHasCancel.length) return;
1243
1251
  if (filteredHasToggle.length && dropdownActive.value === false) return;
1244
1252
 
1245
- emitter.emit("extended:field-focus");
1253
+ emitter.emit(`extended:field-focus-${emitterUniqueId.value}`);
1246
1254
  };
1247
1255
 
1248
1256
  /**
@@ -1266,7 +1274,7 @@ const loadOptionsByExternalLoader = (pattern) => {
1266
1274
  * @emits extended:reset-index
1267
1275
  */
1268
1276
  const resetEnterIndex = () => {
1269
- emitter.emit("extended:reset-index");
1277
+ emitter.emit(`extended:reset-index-${emitterUniqueId.value}`);
1270
1278
  };
1271
1279
 
1272
1280
  /**
@@ -1276,7 +1284,7 @@ const resetEnterIndex = () => {
1276
1284
  */
1277
1285
  const rollUp = () => {
1278
1286
  dropdownActive.value = false;
1279
- emitter.emit("extended:rollup-options");
1287
+ emitter.emit(`extended:rollup-options-${emitterUniqueId.value}`);
1280
1288
  };
1281
1289
 
1282
1290
  /**
@@ -1286,7 +1294,7 @@ const rollUp = () => {
1286
1294
  * @param {KeyboardEvent} keyboardEvent - KeyboardEvent instance
1287
1295
  */
1288
1296
  const selectByEnter = (keyboardEvent) => {
1289
- emitter.emit("extended:select-enter", keyboardEvent);
1297
+ emitter.emit(`extended:select-enter-${emitterUniqueId.value}`, keyboardEvent);
1290
1298
  };
1291
1299
 
1292
1300
  /**
@@ -1309,7 +1317,7 @@ const setPreselectedOption = () => {
1309
1317
  const isObjectOrArray = typeof preselectedOption.value === "object";
1310
1318
  const label = createLabel(isObjectOrArray, preselectedOption.value);
1311
1319
 
1312
- emitter.emit("extended:select-option", {
1320
+ emitter.emit(`extended:select-option-${emitterUniqueId.value}`, {
1313
1321
  label,
1314
1322
  option: preselectedOption.value,
1315
1323
  });
@@ -1339,7 +1347,7 @@ const setPreselectedOptions = async () => {
1339
1347
 
1340
1348
  allOptionsWereSelected++;
1341
1349
 
1342
- emitter.emit("extended:select-option", {
1350
+ emitter.emit(`extended:select-option-${emitterUniqueId.value}`, {
1343
1351
  label,
1344
1352
  option: preselectedOption,
1345
1353
  });
@@ -1374,7 +1382,9 @@ const toggleAppearanceRestrictor = () => {
1374
1382
  if (!window) return "under";
1375
1383
 
1376
1384
  const innerHeight = window.innerHeight;
1377
- const offsetTop = extendedMultiselect.value.getBoundingClientRect().y;
1385
+ const offsetTop = extendedMultiselect.value
1386
+ ? extendedMultiselect.value.getBoundingClientRect().y
1387
+ : 0;
1378
1388
  const difference = innerHeight - offsetTop;
1379
1389
 
1380
1390
  if (difference > toggleMaxHeight.value) {
@@ -1424,7 +1434,7 @@ const toggleBlockRestrictor = (mouseEvent) => {
1424
1434
  }
1425
1435
 
1426
1436
  if (generalRestriction) {
1427
- emitter.emit("extended:skip-block-blur");
1437
+ emitter.emit(`extended:skip-block-blur`);
1428
1438
  return true;
1429
1439
  }
1430
1440
 
@@ -1536,7 +1546,7 @@ const toggleRestrictor = (mouseEvent) => {
1536
1546
  const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
1537
1547
 
1538
1548
  if (filteredHasToggle.length && dropdownActive.value) {
1539
- emitter.emit("extended:skip-blur");
1549
+ emitter.emit(`extended:skip-blur-${emitterUniqueId.value}`);
1540
1550
  }
1541
1551
  };
1542
1552
 
@@ -1560,18 +1570,18 @@ const toggleRestrictor = (mouseEvent) => {
1560
1570
  onBeforeMount(() => {
1561
1571
  chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
1562
1572
 
1563
- emitter.on("extended:rollup-options", () => {
1573
+ emitter.on(`extended:rollup-options-${emitterUniqueId.value}`, () => {
1564
1574
  if (!dropdownActive.value) return;
1565
1575
 
1566
1576
  closeEmitter();
1567
1577
  dropdownActive.value = false;
1568
1578
  });
1569
1579
 
1570
- emitter.on("extended:toggle-options", () => {
1580
+ emitter.on(`extended:toggle-options-${emitterUniqueId.value}`, () => {
1571
1581
  toggleOptions();
1572
1582
  });
1573
1583
 
1574
- emitter.on("extended:select-option", (option) => {
1584
+ emitter.on(`extended:select-option-${emitterUniqueId.value}`, (option) => {
1575
1585
  const eventData = simpleEvents.value
1576
1586
  ? option.option
1577
1587
  : createEventFields(option.option, "option");
@@ -1594,7 +1604,7 @@ onBeforeMount(() => {
1594
1604
  }
1595
1605
  });
1596
1606
 
1597
- emitter.on("extended:deselect-option", (payload) => {
1607
+ emitter.on(`extended:deselect-option-${emitterUniqueId.value}`, (payload) => {
1598
1608
  if (multiple.value && (payload && !payload.clearAll)) {
1599
1609
  const deselectedOption = selectedOptions.value[payload.index];
1600
1610
 
@@ -1617,11 +1627,11 @@ onBeforeMount(() => {
1617
1627
  }
1618
1628
 
1619
1629
  if (toggleOptionsBySelect.value) {
1620
- emitter.emit("extended:rollup-options");
1630
+ emitter.emit(`extended:rollup-options-${emitterUniqueId.value}`);
1621
1631
  }
1622
1632
  });
1623
1633
 
1624
- emitter.on("extended:clean-options", (selectedOptions) => {
1634
+ emitter.on(`extended:clean-options-${emitterUniqueId.value}`, (selectedOptions) => {
1625
1635
  const eventData = simpleEvents.value
1626
1636
  ? selectedOptions.value
1627
1637
  : createEventFields(selectedOptions, "options");
@@ -1633,7 +1643,7 @@ onBeforeMount(() => {
1633
1643
  emit("clean", eventData);
1634
1644
  });
1635
1645
 
1636
- emitter.on("extended:create-option", (createdOption) => {
1646
+ emitter.on(`extended:create-option-${emitterUniqueId.value}`, (createdOption) => {
1637
1647
  const eventData = simpleEvents.value
1638
1648
  ? createdOption
1639
1649
  : createEventFields(createdOption, "option");
@@ -1647,7 +1657,7 @@ onBeforeMount(() => {
1647
1657
  emit("option-created", eventData);
1648
1658
  });
1649
1659
 
1650
- emitter.on("extended:increase-display", (limit) => {
1660
+ emitter.on(`extended:increase-display-${emitterUniqueId.value}`, (limit) => {
1651
1661
  const eventData = simpleEvents.value ? limit : createEventFields(limit, "limit");
1652
1662
 
1653
1663
  /**
@@ -1659,7 +1669,7 @@ onBeforeMount(() => {
1659
1669
  emit("increase", eventData);
1660
1670
  });
1661
1671
 
1662
- emitter.on("extended:search-pattern-changed", (pattern) => {
1672
+ emitter.on(`extended:search-pattern-changed-${emitterUniqueId.value}`, (pattern) => {
1663
1673
  const eventData = simpleEvents.value
1664
1674
  ? pattern
1665
1675
  : createEventFields(pattern, "pattern");
@@ -1696,7 +1706,7 @@ onMounted(() => {
1696
1706
  dropdownActive.value = true;
1697
1707
  }
1698
1708
 
1699
- emitter.on("extended:expand-options", () => {
1709
+ emitter.on(`extended:expand-options-${emitterUniqueId.value}`, () => {
1700
1710
  if (dropdownActive.value === true) return;
1701
1711
 
1702
1712
  toggleAppearanceRestrictorActivate();
@@ -1705,7 +1715,7 @@ onMounted(() => {
1705
1715
  dropdownActive.value = true;
1706
1716
  });
1707
1717
 
1708
- emitter.on("extended:loader-pattern-changed", (pattern) => {
1718
+ emitter.on(`extended:loader-pattern-changed-${emitterUniqueId.value}`, (pattern) => {
1709
1719
  loadOptionsByExternalLoader(pattern);
1710
1720
  });
1711
1721
  });
@@ -2,7 +2,7 @@ import emitter from "../events/emitter";
2
2
 
3
3
  import useSearchValue from './search-value';
4
4
 
5
- export default function useCancel(disabled, showSearchField, selectedOptions) {
5
+ export default function useCancel(disabled, showSearchField, selectedOptions, emitterUniqueId) {
6
6
  /**
7
7
  * Removes all selected options or single selected option
8
8
  * when "multiple" prop equals false
@@ -16,15 +16,15 @@ export default function useCancel(disabled, showSearchField, selectedOptions) {
16
16
 
17
17
  if (disabled.value) return;
18
18
 
19
- emitter.emit("extended:skip-block-blur-zeroing");
20
- emitter.emit("extended:deselect-option", {
19
+ emitter.emit(`extended:skip-block-blur-zeroing-${emitterUniqueId.value}`);
20
+ emitter.emit(`extended:deselect-option-${emitterUniqueId.value}`, {
21
21
  index: null,
22
22
  clearAll: true,
23
23
  });
24
24
 
25
25
  if (!showSearchField.value) return;
26
26
 
27
- emitter.emit("extended:clean-options", selectedOptions.value);
27
+ emitter.emit(`extended:clean-options-${emitterUniqueId.value}`, selectedOptions.value);
28
28
 
29
29
  setSearchValue(null);
30
30
  setSearchPattern(null);
@@ -2,7 +2,7 @@ import { computed, readonly } from "vue";
2
2
 
3
3
  import emitter from "../events/emitter"
4
4
 
5
- export default function useToggle(loading, disabled, internalLoader) {
5
+ export default function useToggle(loading, disabled, internalLoader, emitterUniqueId) {
6
6
  /**
7
7
  * Toggles classes of slots if "loading"
8
8
  * or "disabled" props equals true
@@ -24,7 +24,7 @@ export default function useToggle(loading, disabled, internalLoader) {
24
24
  const toggleOptionsList = (event) => {
25
25
  if (event && event.code === "Tab") return;
26
26
 
27
- emitter.emit("extended:toggle-options");
27
+ emitter.emit(`extended:toggle-options-${emitterUniqueId.value}`);
28
28
  };
29
29
 
30
30
  return {
@@ -16,7 +16,7 @@
16
16
  font-style: inherit;
17
17
  }
18
18
 
19
- .extended__multiselect-wrapper--disabled #extended__multiselect {
19
+ .extended__multiselect-wrapper--disabled .extended__multiselect-container {
20
20
  background-color: var(--disabled);
21
21
  user-select: none;
22
22
  cursor: var(--default-cursor);
@@ -390,8 +390,8 @@
390
390
  border-color: transparent;
391
391
  }
392
392
 
393
- #extended__multiselect + .extended__multiselect-options--marker > span:not([id^=option-label]),
394
- #extended__multiselect + .extended__multiselect-options--marker > .extended__multiselect-option-create {
393
+ .extended__multiselect-container + .extended__multiselect-options--marker > span:not([id^=option-label]),
394
+ .extended__multiselect-container + .extended__multiselect-options--marker > .extended__multiselect-option-create {
395
395
  padding-left: 30px;
396
396
  }
397
397
 
@@ -25,7 +25,10 @@ describe("events", () => {
25
25
 
26
26
  wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
27
27
 
28
- emitter.emit("extended:search-pattern-changed", globalThis.SEARCH_VALUE);
28
+ emitter.emit(
29
+ `extended:search-pattern-changed-${wrapper.vm.emitterUniqueId}`,
30
+ globalThis.SEARCH_VALUE,
31
+ );
29
32
 
30
33
  expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE);
31
34
  });
@@ -110,7 +113,7 @@ describe("events", () => {
110
113
  await mockOptionSelection(wrapper);
111
114
 
112
115
  expect(wrapper.emitted().close[0][0].inputId).toEqual(globalThis.INPUT_ID);
113
- expect(wrapper.emitted().close[0][0].options).toHaveLength(0);
116
+ expect(wrapper.emitted().close[0][0].options).toHaveLength(1);
114
117
  });
115
118
 
116
119
 
@@ -423,7 +423,7 @@ describe("props", () => {
423
423
  wrongCurrentValue: true,
424
424
  };
425
425
 
426
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find("#extended__multiselect");
426
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find(".extended__multiselect-container");
427
427
 
428
428
  expect(wrapper.attributes("style")).toMatch("border-color: #ff0000");
429
429
  });
@@ -526,7 +526,7 @@ describe("props", () => {
526
526
  errorBorderColor: "#DC143C",
527
527
  };
528
528
 
529
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find("#extended__multiselect");
529
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData).find(".extended__multiselect-container");
530
530
 
531
531
  expect(wrapper.attributes("style")).toMatch("border-color: #dc143c");
532
532
  });
@@ -636,9 +636,7 @@ describe("props", () => {
636
636
 
637
637
  wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
638
638
 
639
- await expandOptionsList(wrapper);
640
-
641
- const multiselectWrapper = wrapper.find("#extended__multiselect");
639
+ const multiselectWrapper = wrapper.find(".extended__multiselect-container");
642
640
  const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
643
641
  const optionWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
644
642