vue3-extended-multiselect 1.10.2 → 2.0.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.
Files changed (50) hide show
  1. package/.browserslistrc +2 -2
  2. package/.eslintrc.js +35 -34
  3. package/.github/workflows/publish.yml +41 -41
  4. package/CHANGELOG.md +411 -389
  5. package/LICENSE +21 -21
  6. package/README.md +270 -270
  7. package/babel.config.js +9 -9
  8. package/index.js +2 -2
  9. package/jest.config.js +62 -62
  10. package/package.json +56 -46
  11. package/rollup.config.mjs +74 -0
  12. package/src/assets/{base-arrow.svg → images/base-arrow.svg} +70 -70
  13. package/src/assets/{cancel.svg → images/cancel.svg} +34 -34
  14. package/src/assets/{circle-arrow.svg → images/circle-arrow.svg} +7 -7
  15. package/src/assets/{double-arrow.svg → images/double-arrow.svg} +39 -39
  16. package/src/assets/{inner-arrow.svg → images/inner-arrow.svg} +8 -8
  17. package/src/assets/{loader.svg → images/loader.svg} +5 -5
  18. package/src/assets/{triangle-arrow.svg → images/triangle-arrow.svg} +72 -72
  19. package/src/assets/{triangle-circle-arrow.svg → images/triangle-circle-arrow.svg} +38 -38
  20. package/src/assets/{wide-arrow.svg → images/wide-arrow.svg} +72 -72
  21. package/src/components/ExtendedMultiselectCancel.vue +165 -165
  22. package/src/components/ExtendedMultiselectInput.vue +741 -741
  23. package/src/components/ExtendedMultiselectLoader.vue +182 -182
  24. package/src/components/ExtendedMultiselectMultiple.vue +399 -399
  25. package/src/components/ExtendedMultiselectOptions.vue +1190 -1190
  26. package/src/components/ExtendedMultiselectToggle.vue +271 -271
  27. package/src/components/Vue3ExtendedMultiselect.vue +2475 -1949
  28. package/src/composition/cancel.js +39 -39
  29. package/src/composition/click-outside.js +8 -8
  30. package/src/composition/debounce.js +8 -8
  31. package/src/composition/emitter.js +8 -8
  32. package/src/composition/image-path.js +16 -16
  33. package/src/composition/labels.js +41 -41
  34. package/src/composition/preselected-options.js +67 -67
  35. package/src/composition/search-value.js +33 -33
  36. package/src/composition/sizes.js +44 -44
  37. package/src/composition/toggle.js +31 -31
  38. package/src/sets/sets.js +99 -99
  39. package/src/styles/animations.css +18 -18
  40. package/src/styles/main.css +460 -460
  41. package/src/styles/variables.css +51 -51
  42. package/src/tools/Debounce.js +25 -25
  43. package/src/tools/LocalEmitter.js +31 -31
  44. package/src/tools/instance.js +2 -2
  45. package/tests/unit/events.spec.js +149 -149
  46. package/tests/unit/props.spec.js +1154 -1155
  47. package/tests/unit/tools.spec.js +55 -53
  48. package/tests/utils/mount.js +37 -37
  49. package/tests/utils/utils.js +24 -24
  50. package/typings/vue3-extended-multiselect.d.ts +43 -43
@@ -1,1950 +1,2476 @@
1
- <template>
2
- <section
3
- aria-owns="extended-search-field"
4
- ref="extendedMultiselectWrapper"
5
- role="combobox"
6
- :aria-roledescription="roledescription"
7
- :class="wrapperClasses"
8
- :tabindex="tabindexIfSearch"
9
- @click.stop.left="fieldFocus"
10
- @click.stop.middle="fieldFocus"
11
- @keyup.stop.esc="rollUp"
12
- @keyup.stop.enter="selectByEnter"
13
- @mousedown.stop.left="toggleRestrictor"
14
- @mousedown.stop.middle="toggleRestrictor"
15
- @mouseleave.stop="resetEnterIndex"
16
- >
17
- <div
18
- ref="extendedMultiselect"
19
- :class="classes"
20
- :style="[displayWrongValue, expanded]"
21
- >
22
- <div>
23
- <extended-multiselect-input
24
- :accesskey="attrs.accesskey"
25
- :autocomplete="attrs.autocomplete"
26
- :name="attrs.name"
27
- :spellcheck="attrs.spellcheck"
28
- :tabindex="attrs.tabindex"
29
- :translate="attrs.translate"
30
- :auto-select-search-value="autoSelectSearchValue"
31
- :create-on-the-go="createOnTheGo"
32
- :disabled="disabled"
33
- :loading="internalLoading"
34
- :icon-filter="iconFilter"
35
- :multiple="multiple"
36
- :search-filter-active="searchFilterActive"
37
- :show-deselect-icon-loader="showDeselectIconLoader"
38
- :toggling-saves-search-value="togglingSavesSearchValue"
39
- :toggle-options-by-select="toggleOptionsBySelect"
40
- :placeholder="placeholder"
41
- :show-search-field="showSearchField"
42
- :empty-objects-placeholder="emptyObjectsPlaceholder"
43
- :label="label"
44
- :multiple-blocks-limit-message="multipleBlocksLimitMessage"
45
- :theme-type="themeType"
46
- :increase-display-by="increaseDisplayBy"
47
- :multipleBlocksLimit="multipleBlocksLimit"
48
- :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
49
- :selected-options="selectedOptions"
50
- :emitter="emitter"
51
- :create-custom-option-label="createCustomOptionLabel"
52
- :create-option-placeholder="createOptionPlaceholder"
53
- :external-options-loader="externalOptionsLoader"
54
- :input-id="inputId"
55
- >
56
- <template
57
- v-if="slots.labelBlock"
58
- #labelBlock="{ labelBlockValue }"
59
- >
60
- <slot
61
- name="labelBlock"
62
- :label-block-value="labelBlockValue"
63
- >
64
- </slot>
65
- </template>
66
- <template
67
- v-if="slots.multipleBlocks"
68
- #multipleBlocks="{ selectedOptions, deselectBlock }"
69
- >
70
- <slot
71
- name="multipleBlocks"
72
- :selected-options="selectedOptions"
73
- :deselect-block="deselectBlock"
74
- >
75
- </slot>
76
- </template>
77
- <template
78
- v-if="slots.optionBlock"
79
- #optionBlock="{ label, deselectBlock, index }"
80
- >
81
- <slot
82
- name="optionBlock"
83
- :label="label"
84
- :index="index"
85
- :deselect-block="deselectBlock"
86
- >
87
- </slot>
88
- </template>
89
- <template
90
- v-if="slots.maxElements"
91
- #maxElements
92
- >
93
- <slot name="maxElements"></slot>
94
- </template>
95
- <template
96
- v-if="toggleMultipleBlocksLimit"
97
- #showMore="{ showMoreOptions }"
98
- >
99
- <slot
100
- name="showMore"
101
- :show-more-options="showMoreOptions"
102
- >
103
- </slot>
104
- </template>
105
- </extended-multiselect-input>
106
- </div>
107
- <div class="extended__multiselect-toggle_wrapper">
108
- <slot
109
- name="toggle"
110
- :toggle-options-list="toggleOptionsList"
111
- >
112
- <extended-multiselect-toggle
113
- ref="extendedMultiselectToggle"
114
- :tabindex="attrs.tabindex"
115
- :disabled="disabled"
116
- :dropdown-active="dropdownActive"
117
- :loading="internalLoading"
118
- :icon-filter="iconFilter"
119
- :icon-size="iconSize"
120
- :toggle-icon="toggleIcon"
121
- :emitter="emitter"
122
- />
123
- </slot>
124
- </div>
125
- <div class="extended__multiselect-cancel_wrapper">
126
- <slot
127
- name="cancel"
128
- :cancel="cancel"
129
- >
130
- <extended-multiselect-cancel
131
- v-if="showClearIcon"
132
- :tabindex="attrs.tabindex"
133
- :disabled="disabled"
134
- :show-search-field="showSearchField"
135
- :loading="internalLoading"
136
- :icon-filter="iconFilter"
137
- :icon-size="iconSize"
138
- :selected-options="selectedOptions"
139
- :emitter="emitter"
140
- />
141
- </slot>
142
- </div>
143
- </div>
144
- <transition
145
- name="extended-toggle"
146
- type="transition"
147
- >
148
- <extended-multiselect-options
149
- v-if="dropdownActive"
150
- :auto-select-created-option="autoSelectCreatedOption"
151
- :clear-by-select-when-multiple="clearBySelectWhenMultiple"
152
- :create-on-the-go="createOnTheGo"
153
- :disabled-primitive-options-converted="disabledPrimitiveOptionsConverted"
154
- :highlight-options="highlightOptions"
155
- :loading="internalLoading"
156
- :multiple="multiple"
157
- :selected-options-shown="selectedOptionsShown"
158
- :show-insert-warnings="showInsertWarnings"
159
- :show-marker="showMarker"
160
- :chosen-toggle-appearance-side="chosenToggleAppearanceSide"
161
- :create-option-type="createOptionType"
162
- :disable-by-field="disableByField"
163
- :empty-objects-placeholder="emptyObjectsPlaceholder"
164
- :label="label"
165
- :search-by-field="searchByField"
166
- :theme-type="themeType"
167
- :any-option-wrapper-block-height="anyOptionWrapperBlockHeight"
168
- :max-options-count="maxOptionsCount"
169
- :min-options-count="minOptionsCount"
170
- :options-padding="optionsPadding"
171
- :toggle-max-height="toggleMaxHeight"
172
- :toggle-min-height="toggleMinHeight"
173
- :create-option-fields="createOptionFields"
174
- :options="restrictedOptions"
175
- :restricted-options="restrictedOptions"
176
- :selected-options="selectedOptions"
177
- :special-keys-block="specialKeysBlock"
178
- :preselected-option="preselectedOption"
179
- :preselected-options="preselectedOptions"
180
- :emitter="emitter"
181
- :create-custom-option-label="createCustomOptionLabel"
182
- :external-options-loader="externalOptionsLoader"
183
- >
184
- <template
185
- v-if="slots.listHeader"
186
- #listHeader
187
- >
188
- <slot name="listHeader"></slot>
189
- </template>
190
- <template
191
- v-if="maxOptionsCount"
192
- #moreThanLimit
193
- >
194
- <slot name="moreThanLimit"></slot>
195
- </template>
196
- <template
197
- v-if="minOptionsCount"
198
- #lessThanLimit
199
- >
200
- <slot name="lessThanLimit"></slot>
201
- </template>
202
- <template
203
- v-if="slots.option"
204
- #option="{ option, createCustomOptionLabel }"
205
- >
206
- <slot
207
- name="option"
208
- :option="option"
209
- :create-custom-option-label="createCustomOptionLabel"
210
- >
211
- </slot>
212
- </template>
213
- <template
214
- v-if="slots.marker"
215
- #marker="{ selected }"
216
- >
217
- <slot
218
- name="marker"
219
- :selected="selected"
220
- >
221
- </slot>
222
- </template>
223
- <template
224
- v-if="noResultsBlockShown"
225
- #noResults
226
- >
227
- <slot name="noResults"></slot>
228
- </template>
229
- <template
230
- v-if="slots.noOptions"
231
- #noOptions
232
- >
233
- <slot name="noOptions"></slot>
234
- </template>
235
- <template
236
- v-if="slots.listFooter"
237
- #listFooter
238
- >
239
- <slot name="listFooter"></slot>
240
- </template>
241
- </extended-multiselect-options>
242
- </transition>
243
- </section>
244
- </template>
245
-
246
- <script setup>
247
- import {
248
- computed,
249
- defineEmits,
250
- defineExpose,
251
- defineProps,
252
- onBeforeMount,
253
- onMounted,
254
- provide,
255
- ref,
256
- toRaw,
257
- toRefs,
258
- useAttrs,
259
- useSlots,
260
- watch,
261
- } from "vue";
262
-
263
- import {
264
- themeTypes,
265
- loaderThemeTypes,
266
- toggleIcons,
267
- iconFilters,
268
- iconSizes,
269
- createOptionTypes,
270
- specialKeysToBlock,
271
- toggleAppearenceSides,
272
- UnionPropType,
273
- } from "../sets/sets";
274
-
275
- import localEmitter from "../tools/instance.js";
276
-
277
- import useToggle from "../composition/toggle";
278
- import useCancel from "../composition/cancel";
279
- import useLabels from "../composition/labels";
280
- import useEmitter from "../composition/emitter";
281
- import useClickOutside from "../composition/click-outside";
282
- import usePreselectedOptions from "../composition/preselected-options";
283
- import useSearchValue from "../composition/search-value";
284
-
285
- import ExtendedMultiselectCancel from "./ExtendedMultiselectCancel.vue";
286
- import ExtendedMultiselectInput from "./ExtendedMultiselectInput.vue";
287
- import ExtendedMultiselectOptions from "./ExtendedMultiselectOptions.vue";
288
- import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
289
-
290
- /**
291
- * @todo Mark optional arguments of functions
292
- */
293
-
294
- /**
295
- * @author Ridiger Daniil Dmitrievich, 2022
296
- * @version 1.10.2
297
- */
298
- const props = defineProps({
299
- /**
300
- * Determines whether to select just now created option
301
- * automatically
302
- * @default false
303
- * @property {boolean} autoSelectCreatedOption
304
- */
305
- autoSelectCreatedOption: {
306
- type: Boolean,
307
- default: false,
308
- },
309
-
310
- /**
311
- * Determines whether to take search value from current
312
- * selected option if "multiple" prop equals false
313
- * @default false
314
- * @property {boolean} autoSelectSearchValue
315
- */
316
- autoSelectSearchValue: {
317
- type: Boolean,
318
- default: false,
319
- },
320
-
321
- /**
322
- * Determines whether to clear search field by option selection
323
- * @default false
324
- * @property {boolean} clearBySelectWhenMultiple
325
- */
326
- clearBySelectWhenMultiple: {
327
- type: Boolean,
328
- default: false,
329
- },
330
-
331
- /**
332
- * Allows user to create new options from search field
333
- * @default false
334
- * @property {boolean} createOnTheGo
335
- */
336
- createOnTheGo: {
337
- type: Boolean,
338
- default: false,
339
- },
340
-
341
- /**
342
- * Determines whether options list should be expanded by default
343
- * @default false
344
- * @property {boolean} defaultExpanded
345
- */
346
- defaultExpanded: {
347
- type: Boolean,
348
- default: false,
349
- },
350
-
351
- /**
352
- * Disables extended multiselect
353
- * @default false
354
- * @property {boolean} disabled
355
- */
356
- disabled: {
357
- type: Boolean,
358
- default: false,
359
- },
360
-
361
- /**
362
- * Disables dropdown toggle
363
- * @default false
364
- * @property {boolean} dropdownDisabled
365
- */
366
- dropdownDisabled: {
367
- type: Boolean,
368
- default: false,
369
- },
370
-
371
- /**
372
- * Switches options highlighting while hovering
373
- * @default true
374
- * @property {boolean} highlightOptions
375
- */
376
- highlightOptions: {
377
- type: Boolean,
378
- default: true,
379
- },
380
-
381
- /**
382
- * Switches loading state of extended multiselect
383
- * @default false
384
- * @property {boolean} loading
385
- */
386
- loading: {
387
- type: Boolean,
388
- default: false,
389
- },
390
-
391
- /**
392
- * Allows user to select multiple options
393
- * @default false
394
- * @property {boolean} multiple
395
- */
396
- multiple: {
397
- type: Boolean,
398
- default: false,
399
- },
400
-
401
- /**
402
- * Determines whether to show special hint if no options were found
403
- * @default true
404
- * @property {boolean} noResultsBlockShown
405
- */
406
- noResultsBlockShown: {
407
- type: Boolean,
408
- default: true,
409
- },
410
-
411
- /**
412
- * Determines whether to clear search field by selection/deselection of options
413
- * @default true
414
- * @property {boolean} resetSearchByValue
415
- */
416
- resetSearchByValue: {
417
- type: Boolean,
418
- default: true,
419
- },
420
-
421
- /**
422
- * Allows user to use internal search for options
423
- * @default true
424
- * @property {boolean} searchFilterActive
425
- */
426
- searchFilterActive: {
427
- type: Boolean,
428
- default: true,
429
- },
430
-
431
- /**
432
- * Switches full payload of extended multiselect events
433
- * @default true
434
- * @property {boolean} simpleEvents
435
- */
436
- simpleEvents: {
437
- type: Boolean,
438
- default: true,
439
- },
440
-
441
- /**
442
- * Determines whether to show selected options in options list
443
- * @default false
444
- * @property {boolean} selectedOptionsShown
445
- */
446
- selectedOptionsShown: {
447
- type: Boolean,
448
- default: false,
449
- },
450
-
451
- /**
452
- * Allows user to deselect all options by special icon
453
- * @default false
454
- * @property {boolean} showClearIcon
455
- */
456
- showClearIcon: {
457
- type: Boolean,
458
- default: false,
459
- },
460
-
461
- /**
462
- * Determines whether to show loader icon in multiple
463
- * options block if "loading" prop equals true
464
- * @default true
465
- * @property {boolean} showDeselectIconLoader
466
- */
467
- showDeselectIconLoader: {
468
- type: Boolean,
469
- default: true,
470
- },
471
-
472
- /**
473
- * Determines whether to show useful internal warnings in console
474
- * @default false
475
- * @property {boolean} showInsertWarnings
476
- */
477
- showInsertWarnings: {
478
- type: Boolean,
479
- default: false,
480
- },
481
-
482
- /**
483
- * Determines whether to show slot with special marker beside option in options list
484
- * @default false
485
- * @property {boolean} showMarker
486
- */
487
- showMarker: {
488
- type: Boolean,
489
- default: false,
490
- },
491
-
492
- /**
493
- * Determines whether to show search field which allows user
494
- * to search for options with internal search
495
- * @default true
496
- * @property {boolean} showSearchField
497
- */
498
- showSearchField: {
499
- type: Boolean,
500
- default: true,
501
- },
502
-
503
- /**
504
- * Allows user to increase limit of shown elements with selected options
505
- * by special icon
506
- * @default false
507
- * @property {boolean} toggleMultipleBlocksLimit
508
- */
509
- toggleMultipleBlocksLimit: {
510
- type: Boolean,
511
- default: false,
512
- },
513
-
514
- /**
515
- * Determines whether to roll up options list by selection of option
516
- * @default true
517
- * @property {boolean} toggleOptionsBySelect
518
- */
519
- toggleOptionsBySelect: {
520
- type: Boolean,
521
- default: true,
522
- },
523
-
524
- /**
525
- * Determines whether to save current search value if
526
- * display of options list was toggled
527
- * @default true
528
- * @property {boolean} togglingSavesSearchValue
529
- */
530
- togglingSavesSearchValue: {
531
- type: Boolean,
532
- default: true,
533
- },
534
-
535
- /**
536
- * Determines whether to define special class for extended multiselect
537
- * if value is wrong
538
- * Irregularity of value is defined by user
539
- * @default false
540
- * @property {boolean} wrongCurrentValue
541
- */
542
- wrongCurrentValue: {
543
- type: Boolean,
544
- default: false,
545
- },
546
-
547
- /**
548
- * Placeholder for the search field to be used if
549
- * user is allowed to create new options
550
- * @default "Select or create features"
551
- * @property {string} createOptionPlaceholder
552
- */
553
- createOptionPlaceholder: {
554
- type: String,
555
- default: "Select or create features",
556
- },
557
-
558
- /**
559
- * Defines kind for all options which will be created by user
560
- * @default "primitive"
561
- * @property {string} createOptionType
562
- */
563
- createOptionType: {
564
- type: String,
565
- default: "primitive",
566
- validator(value) {
567
- return createOptionTypes.includes(value);
568
- },
569
- },
570
-
571
- /**
572
- * Determines a field in options of type "object"
573
- * which value will be used to disable such options.
574
- * @default "disabled"
575
- * @property {string} disableByField
576
- */
577
- disableByField: {
578
- type: String,
579
- default: "disabled",
580
- },
581
-
582
- /**
583
- * Placeholder for options of type "object"
584
- * or Array instances which length/keys length equals 0
585
- * @default "Empty Object/Array"
586
- * @property {string} emptyObjectsPlaceholder
587
- */
588
- emptyObjectsPlaceholder: {
589
- type: String,
590
- default: "Empty Object/Array",
591
- },
592
-
593
- /**
594
- * Defines "border-color" css-property for extended multiselect with wrong value
595
- * @default "#FF0000"
596
- * @property {string} errorBorderColor
597
- */
598
- errorBorderColor: {
599
- type: String,
600
- default: "#FF0000",
601
- },
602
-
603
- /**
604
- * Defines svg-filter with color settings for all icons except loader
605
- * @default "basic"
606
- * @property {string} iconFilter
607
- */
608
- iconFilter: {
609
- type: String,
610
- default: "basic",
611
- validator(value) {
612
- return iconFilters.includes(value);
613
- },
614
- },
615
-
616
- /**
617
- * Defines sizes for all icons in pixels except loader
618
- * @default "large"
619
- * @property {string} iconSize
620
- */
621
- iconSize: {
622
- type: String,
623
- default: "large",
624
- validator(value) {
625
- return iconSizes.includes(value);
626
- },
627
- },
628
-
629
- /**
630
- * Defines field in options of type "object" that will be the label of option
631
- * @default "label"
632
- * @property {string} label
633
- */
634
- label: {
635
- type: String,
636
- default: "label",
637
- },
638
-
639
- /**
640
- * Defines svg-filter with color settings for loader icon
641
- * @default "loader-default"
642
- * @property {string} loaderIconFilter
643
- */
644
- loaderIconFilter: {
645
- type: String,
646
- default: "loader-default",
647
- validator(value) {
648
- return loaderThemeTypes.includes(value);
649
- },
650
- },
651
-
652
- /**
653
- * Placeholder for search field to be used if
654
- * user is not allowed to create new options
655
- * @default "Select features"
656
- * @property {string} placeholder
657
- */
658
- placeholder: {
659
- type: String,
660
- default: "Select features",
661
- },
662
-
663
- /**
664
- * Determines field in options of type "object"
665
- * to use in internal search.
666
- * @default ""
667
- * @property {string} searchByField
668
- */
669
- searchByField: {
670
- type: String,
671
- default: "",
672
- },
673
-
674
- /**
675
- * Defines overall color theme for extended multiselect
676
- * @default "basic"
677
- * @property {string} themeType
678
- */
679
- themeType: {
680
- type: String,
681
- default: "basic",
682
- validator(value) {
683
- return themeTypes.includes(value);
684
- },
685
- },
686
-
687
- /**
688
- * Defines which side options list will be displayed on
689
- * @default "auto"
690
- * @property {string} toggleAppearanceSide
691
- */
692
- toggleAppearanceSide: {
693
- type: String,
694
- default: "auto",
695
- validator(value) {
696
- return toggleAppearenceSides.includes(value);
697
- },
698
- },
699
-
700
- /**
701
- * Defines kind of toggle icon from icons collection
702
- * @default "base-arrow"
703
- * @property {string} toggleIcon
704
- */
705
- toggleIcon: {
706
- type: String,
707
- default: "base-arrow",
708
- validator(value) {
709
- return toggleIcons.includes(value);
710
- },
711
- },
712
-
713
- /**
714
- * Defines gap which increases limit of displayed elements with selected options
715
- * @default 5
716
- * @property {number} increaseDisplayBy
717
- */
718
- increaseDisplayBy: {
719
- type: Number,
720
- default: 5,
721
- },
722
-
723
- /**
724
- * Maximal limit of selected options
725
- * @default null
726
- * @property {number|null} maxOptionsCount
727
- */
728
- maxOptionsCount: {
729
- type: Number,
730
- default: null,
731
- },
732
-
733
- /**
734
- * Minimal limit of selected options
735
- * @default null
736
- * @property {number|null} minOptionsCount
737
- */
738
- minOptionsCount: {
739
- type: Number,
740
- default: null,
741
- },
742
-
743
- /**
744
- * Defines limit of displayed elements with selected options
745
- * @default null
746
- * @property {number|null} multipleBlocksLimit
747
- */
748
- multipleBlocksLimit: {
749
- type: Number,
750
- default: null,
751
- },
752
-
753
- /**
754
- * Defines maximal limit of options list length
755
- * @default null
756
- * @property {number|null} optionsCountRestriction
757
- */
758
- optionsCountRestriction: {
759
- type: Number,
760
- default: null,
761
- },
762
-
763
- /**
764
- * Defines maximal value in pixels of "max-height" css-property for options list
765
- * @default 400
766
- * @property {number} toggleMaxHeight
767
- */
768
- toggleMaxHeight: {
769
- type: Number,
770
- default: 400,
771
- },
772
-
773
- /**
774
- * Defines minimal value in pixels of "max-height" css-property for options list
775
- * @default null
776
- * @property {number} toggleMaxHeight
777
- */
778
- toggleMinHeight: {
779
- type: Number,
780
- default: null,
781
- },
782
-
783
- /**
784
- * Defines a list of fields for options of type "object" created by user
785
- * @default ["label"]
786
- * @property {Array} createOptionFields
787
- */
788
- createOptionFields: {
789
- type: Array,
790
- default: () => ["label"],
791
- validator(value) {
792
- return !value.some((field) => {
793
- return typeof field !== "string";
794
- });
795
- },
796
- },
797
-
798
- /**
799
- * Defines a list of primitive types for options.
800
- * Options of given types will be disabled for selection.
801
- * @default []
802
- * @property {Array} disabledPrimitiveOptions
803
- */
804
- disabledPrimitiveOptions: {
805
- type: Array,
806
- default: () => [],
807
- validator(value) {
808
- return value.every((option) => {
809
- return typeof option === "string" || Array.isArray(option)
810
- || typeof option === "number" || typeof option === "boolean"
811
- || typeof option === "function";
812
- });
813
- },
814
- },
815
-
816
- /**
817
- * Raw options list
818
- * @default []
819
- * @property {Array|Function} options
820
- */
821
- options: {
822
- type: [Array, Function],
823
- default: () => [],
824
- },
825
-
826
- /**
827
- * Defines a list with "padding-top", "padding-left", "padding-bottom"
828
- * and "padding-right" css-properties for options in options list.
829
- * Property "padding-top" matches index zero.
830
- * Property "padding-right" matches index three.
831
- * @default []
832
- * @property {Array} optionsPadding
833
- */
834
- optionsPadding: {
835
- type: Array,
836
- default: () => [],
837
- validator(value) {
838
- return value.length < 5
839
- && !value.some((padding) => {
840
- return typeof padding !== "number";
841
- });
842
- },
843
- },
844
-
845
- /**
846
- * Defines a list of options that will be select by default
847
- * @default []
848
- * @property {Array} preselectedOptions
849
- */
850
- preselectedOptions: {
851
- type: Array,
852
- default: () => [],
853
- },
854
-
855
- /**
856
- * Defines a list of keys which in combination with mouse buttons or "enter" key
857
- * will prevent selection of option
858
- * @default []
859
- * @property {Array} specialKeysBlock
860
- */
861
- specialKeysBlock: {
862
- type: Array,
863
- default: () => [],
864
- validator(value) {
865
- return value.every((keyBlock) => {
866
- return specialKeysToBlock.includes(keyBlock);
867
- });
868
- },
869
- },
870
-
871
- /**
872
- * Defines value of extended multiselect that can be used in "v-model" attribute
873
- * @default []
874
- * @property {Array|null} modelValue
875
- */
876
- modelValue: {
877
- type: UnionPropType,
878
- default: null,
879
- },
880
-
881
- /**
882
- * Defines function that creates custom label for each option
883
- * @default (option)=>null
884
- * @property {Function} createCustomOptionLabel
885
- */
886
- createCustomOptionLabel: {
887
- type: Function,
888
- default: (option) => null,
889
- },
890
-
891
- /**
892
- * Defines function that creates notification when maximal limit
893
- * of selected options has been reached
894
- * @default (number)=>string
895
- * @property {Function} multipleBlocksLimitMessage
896
- */
897
- multipleBlocksLimitMessage: {
898
- type: Function,
899
- default: (number) => `and ${number} more items`,
900
- },
901
-
902
-
903
- /**
904
- * Defines "height" css-property for each option in options list
905
- * @default 30
906
- * @property {number} anyOptionWrapperBlockHeight
907
- */
908
- anyOptionWrapperBlockHeight: {
909
- type: [Number, String],
910
- default: "auto",
911
- },
912
-
913
- /**
914
- * "id" attribute of search field
915
- * @default null
916
- * @property {string|number|null} inputId
917
- */
918
- inputId: {
919
- type: [String, Number],
920
- default: null,
921
- },
922
-
923
- /**
924
- * Defines options that will be select by default
925
- * @default null
926
- * @property {UnionPropType|null} preselectedOption
927
- */
928
- preselectedOption: {
929
- type: UnionPropType,
930
- default: null,
931
- },
932
- });
933
-
934
- const emit = defineEmits([
935
- "active",
936
- "clean",
937
- "close",
938
- "increase",
939
- "option-created",
940
- "pattern-changed",
941
- "select",
942
- "update:modelValue",
943
- ]);
944
-
945
- const dropdownActive = ref(false);
946
- const skipNextRemoval = ref(false);
947
- const externalOptionsLoader = ref(null);
948
- const chosenToggleAppearanceSide = ref(null);
949
- const selectedOptionsWatcher = ref(null);
950
- const rawOptions = ref([]);
951
- const selectedOptions = ref([]);
952
- const togglePattern = /^extended__multiselect-toggle_wrapper/i;
953
-
954
- /**
955
- * Element references
956
- */
957
- const extendedMultiselect = ref(null);
958
- const extendedMultiselectToggle = ref(null);
959
- const extendedMultiselectWrapper = ref(null);
960
-
961
- const {
962
- defaultExpanded,
963
- disabled,
964
- dropdownDisabled,
965
- disabledPrimitiveOptions,
966
- emptyObjectsPlaceholder,
967
- errorBorderColor,
968
- inputId,
969
- label,
970
- loading,
971
- loaderIconFilter,
972
- modelValue,
973
- multiple,
974
- options,
975
- optionsCountRestriction,
976
- preselectedOption,
977
- preselectedOptions,
978
- resetSearchByValue,
979
- simpleEvents,
980
- showClearIcon,
981
- showInsertWarnings,
982
- showSearchField,
983
- themeType,
984
- toggleAppearanceSide,
985
- toggleMaxHeight,
986
- toggleOptionsBySelect,
987
- wrongCurrentValue,
988
- createCustomOptionLabel,
989
- } = toRefs(props);
990
-
991
- const {
992
- searchState,
993
- setSearchValue,
994
- setSearchPattern,
995
- } = useSearchValue();
996
-
997
- provide("loaderIconFilter", loaderIconFilter.value);
998
- provide("searchState", searchState);
999
- provide("setSearchValue", setSearchValue);
1000
- provide("setSearchPattern", setSearchPattern);
1001
-
1002
- const { emitter } = useEmitter();
1003
- const { clickOutside } = useClickOutside();
1004
- const { toggleOptionsList } = useToggle(
1005
- loading,
1006
- disabled,
1007
- emitter,
1008
- );
1009
- const { cancel } = useCancel(
1010
- disabled,
1011
- showSearchField,
1012
- selectedOptions,
1013
- emitter,
1014
- setSearchValue,
1015
- setSearchPattern,
1016
- );
1017
- const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
1018
- label,
1019
- emptyObjectsPlaceholder,
1020
- showInsertWarnings,
1021
- );
1022
- const { optionCreateLabel } = useLabels(
1023
- label,
1024
- createCustomOptionLabel,
1025
- emptyObjectsPlaceholder,
1026
- );
1027
- const attrs = useAttrs();
1028
- const slots = useSlots();
1029
-
1030
- /**
1031
- * Defines a list of extended multiselect wrapper classes
1032
- * @function
1033
- * @returns {Array} classes
1034
- */
1035
- const classes = computed(() => {
1036
- let theme;
1037
- const localClassList = [];
1038
-
1039
- switch(themeType.value) {
1040
- case "basic":
1041
- theme = "extended__multiselect";
1042
- break;
1043
- case "slate-grey":
1044
- theme = "extended__multiselect-slate-grey";
1045
- break;
1046
- case "slate-blue":
1047
- theme = "extended__multiselect-slate-blue";
1048
- break;
1049
- case "teal":
1050
- theme = "extended__multiselect-teal";
1051
- break;
1052
- case "strict":
1053
- theme = "extended__multiselect-strict";
1054
- break;
1055
- default: theme = "extended__multiselect";
1056
- }
1057
-
1058
- localClassList.push(theme);
1059
-
1060
- const clear = showClearIcon.value
1061
- ? "extended__multiselect-clear--active"
1062
- : "extended__multiselect-clear--locked";
1063
-
1064
- localClassList.push(clear);
1065
- localClassList.push("extended__multiselect-container");
1066
-
1067
- return localClassList;
1068
- });
1069
-
1070
- /**
1071
- * Defines a list of disabled options by types given in "disabledPrimitiveOptions" prop
1072
- * @function
1073
- * @returns {Array} options
1074
- */
1075
- const disabledPrimitiveOptionsConverted = computed(() => {
1076
- if (!disabledPrimitiveOptions.value) return null;
1077
-
1078
- return disabledPrimitiveOptions.value.map((disabledOption) => {
1079
- if (Array.isArray(disabledOption)) {
1080
- if (!disabledOption.length) return emptyObjectsPlaceholder.value;
1081
-
1082
- return disabledOption.join(", ");
1083
- }
1084
-
1085
- return disabledOption;
1086
- });
1087
- });
1088
-
1089
- /**
1090
- * Determines whether to display irregularity of value by "border-color" css-property
1091
- * @function
1092
- * @returns {Object|null} styles
1093
- */
1094
- const displayWrongValue = computed(() => {
1095
- return wrongCurrentValue.value ? { borderColor: errorBorderColor.value } : null;
1096
- });
1097
-
1098
- /**
1099
- * Defines styles depending on current options list dropdown state
1100
- * @function
1101
- * @returns {Object|null} styles
1102
- */
1103
- const expanded = computed(() => {
1104
- let borderStyles;
1105
-
1106
- if (chosenToggleAppearanceSide.value === "atop") {
1107
- borderStyles = {
1108
- borderTopLeftRadius: 0,
1109
- borderTopRightRadius: 0,
1110
- };
1111
- } else {
1112
- borderStyles = {
1113
- borderBottomLeftRadius: 0,
1114
- borderBottomRightRadius: 0,
1115
- };
1116
- }
1117
-
1118
- return dropdownActive.value ? borderStyles : null;
1119
- });
1120
-
1121
- /**
1122
- * Determines whether to activate loading state by "loading" prop
1123
- * or by internal loading sign
1124
- * @function
1125
- * @returns {boolean} loading
1126
- */
1127
- const internalLoading = computed(() => {
1128
- return loading.value;
1129
- });
1130
-
1131
- /**
1132
- * Defines mapped list of previously restricted options
1133
- * @function
1134
- * @returns {Array} options
1135
- */
1136
- const mappedOptions = computed(() => {
1137
- return restrictedOptions.value.map((restrictedOption) => {
1138
- return JSON.stringify(restrictedOption);
1139
- });
1140
- });
1141
-
1142
- /**
1143
- * Defines a list of options filtered by maximal admissible options amount
1144
- * @function
1145
- * @returns {Array} options
1146
- */
1147
- const restrictedOptions = computed(() => {
1148
- if (!rawOptions.value) return [];
1149
-
1150
- return optionsCountRestriction.value
1151
- ? rawOptions.value.filter((_, index) => index + 1 <= optionsCountRestriction.value)
1152
- : rawOptions.value;
1153
- });
1154
-
1155
- /**
1156
- * Defines "aria-roledescription" attribute of extended multiselect wrapper
1157
- * @function
1158
- * @returns {string} aria-roledescription
1159
- */
1160
- const roledescription = computed(() => {
1161
- return multiple.value ? "Multiselect" : "Select";
1162
- });
1163
-
1164
- /**
1165
- * Defines "tabindex" attribute of extended multiselect wrapper if needed
1166
- * @function
1167
- * @returns {number} tabindex
1168
- */
1169
- const tabindexIfSearch = computed(() => {
1170
- return showSearchField.value ? attrs.tabindex : -1;
1171
- });
1172
-
1173
- /**
1174
- * Defines special class which indicates disabled or loading state
1175
- * of extended multiselect wrapper
1176
- * @function
1177
- * @returns {string} class
1178
- */
1179
- const wrapperClasses = computed(() => {
1180
- return disabled.value && !internalLoading.value
1181
- ? "extended__multiselect-wrapper--disabled"
1182
- : "extended__multiselect-wrapper";
1183
- });
1184
-
1185
- /**
1186
- * Forcibly rolls up dropdown options list by changing "dropdownActive" flag
1187
- * @function
1188
- * @emits extended:rollup-options
1189
- * @param {boolean} value - "dropdownActive" flag
1190
- */
1191
- watch(dropdownActive, (value) => {
1192
- if (!value) {
1193
- emitter.value.emit("extended:rollup-options");
1194
- }
1195
- });
1196
-
1197
- /**
1198
- * Changes selected options based on external modelValue changes
1199
- * @function
1200
- */
1201
- watch(modelValue, (value, prevValue) => {
1202
- if (
1203
- JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))
1204
- || skipNextRemoval.value
1205
- ) {
1206
- skipNextRemoval.value = false;
1207
-
1208
- return;
1209
- }
1210
-
1211
- setPreselectedOptionsByModelValue(true);
1212
- }, { deep: true });
1213
-
1214
- /**
1215
- * Emits "active" when dropdown options list is active
1216
- * @function
1217
- * @emits active
1218
- */
1219
- const activeEmitter = () => {
1220
- const eventData = simpleEvents.value ? null : {
1221
- inputId: inputId.value,
1222
- };
1223
-
1224
- /**
1225
- * @event active
1226
- * @type {object|null}
1227
- * @property {string} inputId - id of search field set by "id" prop
1228
- */
1229
- emit("active", eventData);
1230
- };
1231
-
1232
- /**
1233
- * Emits "close" when dropdown options list is rolled up
1234
- * @function
1235
- * @emits close
1236
- */
1237
- const closeEmitter = () => {
1238
- const eventData = simpleEvents.value
1239
- ? selectedOptions.value
1240
- : createEventFields(selectedOptions.value, "options");
1241
-
1242
- /**
1243
- * @event close
1244
- * @type {object|Array}
1245
- * @property {string} inputId - id of search field set by "id" prop
1246
- * @property {Array} options - array of selected options
1247
- */
1248
- emit("close", eventData);
1249
- }
1250
-
1251
- /**
1252
- * Creates payload for events that can be listened by outer listeners
1253
- * @function
1254
- * @param {UnionPropType} field - main payload of event
1255
- * @param {string} fieldName - name of field with main payload of event
1256
- * @returns {object} payload
1257
- */
1258
- const createEventFields = (field, fieldName) => {
1259
- const eventFields = {
1260
- inputId: inputId.value,
1261
- };
1262
-
1263
- Object.defineProperty(eventFields, fieldName, {
1264
- value: field,
1265
- enumerable: true,
1266
- });
1267
-
1268
- return eventFields;
1269
- };
1270
-
1271
- /**
1272
- * Focuses search field if "click" native event was triggered on available element
1273
- * @function
1274
- * @emits extended:field-focus
1275
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1276
- */
1277
- const fieldFocus = (mouseEvent) => {
1278
- if (disabled.value) return;
1279
-
1280
- if (!toggleOptionsBySelect.value) {
1281
- const customFilteredOptions = toggleOptionsRestrictor(mouseEvent);
1282
-
1283
- if (customFilteredOptions) return;
1284
- }
1285
-
1286
- const customFilteredCancel = toggleCustomRestrictor(mouseEvent, 2);
1287
- const customFilteredSelf = toggleCustomRestrictor(mouseEvent, 1);
1288
- const filteredHasCancel = toggleDetector(mouseEvent, /^extended__multiselect-cancel_wrapper/i);
1289
- const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
1290
-
1291
- if (customFilteredCancel) return;
1292
- if (customFilteredSelf && dropdownActive.value === false) return;
1293
- if (filteredHasCancel.length) return;
1294
- if (filteredHasToggle.length && dropdownActive.value === false) return;
1295
-
1296
- emitter.value.emit("extended:field-focus");
1297
- };
1298
-
1299
- /**
1300
- * Initialises options list loading by external async method
1301
- * @function
1302
- * @param {string} pattern - value of search field
1303
- * @param {boolean} initialValue - preselected options flag
1304
- */
1305
- const loadOptionsByExternalLoader = (pattern, initialValue) => {
1306
- externalOptionsLoader.value = options.value;
1307
- options.value(pattern).then(options => {
1308
- rawOptions.value = options;
1309
- if (initialValue) setPreselectedOptionsByConditions();
1310
- });
1311
- };
1312
-
1313
- /**
1314
- * Makes removal of selected options based on external modelValue changes
1315
- * @function
1316
- * @param {boolean} single - "multiple" prop flag
1317
- */
1318
- const removeSelectedOptions = (single = false) => {
1319
- if (!single) {
1320
- const modelValueMapped = modelValue.value.map((option) => {
1321
- return JSON.stringify(option);
1322
- });
1323
-
1324
- selectedOptions.value = selectedOptions.value.filter((option) => {
1325
- return modelValueMapped.includes(JSON.stringify(option));
1326
- });
1327
- } else {
1328
- if (!modelValue.value) cancel();
1329
- }
1330
- }
1331
-
1332
- /**
1333
- * Emits event whose listener resets index of "enter" key pressing
1334
- * @function
1335
- * @emits extended:reset-index
1336
- */
1337
- const resetEnterIndex = () => {
1338
- emitter.value.emit("extended:reset-index");
1339
- };
1340
-
1341
- /**
1342
- * Rolls up dropdown options list
1343
- * @function
1344
- * @emits extended:rollup-options
1345
- */
1346
- const rollUp = () => {
1347
- dropdownActive.value = false;
1348
- emitter.value.emit("extended:rollup-options");
1349
- };
1350
-
1351
- /**
1352
- * Rolls up dropdown options lists of other instances
1353
- * @function
1354
- * @emits extended:rollup-instances
1355
- */
1356
- const rollupInstanses = () => {
1357
- localEmitter.emit("extended:rollup-instances", extendedMultiselectWrapper.value);
1358
- };
1359
-
1360
- /**
1361
- * Triggers selection of option by "enter" key pressing
1362
- * @function
1363
- * @emits extended:select-enter
1364
- * @param {KeyboardEvent} keyboardEvent - KeyboardEvent instance
1365
- */
1366
- const selectByEnter = (keyboardEvent) => {
1367
- emitter.value.emit("extended:select-enter", keyboardEvent);
1368
- };
1369
-
1370
- /**
1371
- * Sets preselected option provided by "preselectedOption" prop
1372
- * @function
1373
- * @emits extended:select-option
1374
- * @param {UnionPropType} preselectedOption - option to be selected
1375
- * @param {boolean} restriction - restriction of preselected option
1376
- */
1377
- const setPreselectedOption = (preselectedOption, restriction = true) => {
1378
- const availableOptionType = optionTypeRestrictor(preselectedOption);
1379
- const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1380
- return JSON.stringify(selectedOption);
1381
- });
1382
-
1383
- if (!availableOptionType) return;
1384
- if (
1385
- (!mappedOptions.value.includes(JSON.stringify(preselectedOption)) && restriction)
1386
- && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1387
- ) {
1388
- if (showInsertWarnings.value) {
1389
- console.warn("vue-extended-multiselect: option in «preselectedOption» property should be the same as analogue in «options» property");
1390
- }
1391
-
1392
- return;
1393
- }
1394
-
1395
- const isObjectOrArray = typeof preselectedOption === "object";
1396
- const label = createLabel(isObjectOrArray, preselectedOption);
1397
-
1398
- emitter.value.emit("extended:select-option", {
1399
- label,
1400
- option: preselectedOption,
1401
- });
1402
- };
1403
-
1404
- /**
1405
- * Sets preselected options provided by "preselectedOptions" prop
1406
- * if "multiple" prop equals true
1407
- * @function
1408
- * @emits extended:select-option
1409
- * @param {Array} preselectedOptions - options to be selected
1410
- * @param {boolean} restriction - restriction of preselected options
1411
- */
1412
- const setPreselectedOptions = async (preselectedOptions, restriction = true) => {
1413
- let allOptionsWereSelected = 0;
1414
- const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1415
- return JSON.stringify(selectedOption);
1416
- });
1417
-
1418
- preselectedOptions.forEach((preselectedOption) => {
1419
- const availableOptionType = optionTypeRestrictor(preselectedOption);
1420
-
1421
- if (!preselectedOption || !availableOptionType) return;
1422
- if (selectedOptions.value.includes(preselectedOption)) return;
1423
-
1424
- if (
1425
- (mappedOptions.value.includes(JSON.stringify(preselectedOption)) || !restriction)
1426
- && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1427
- ) {
1428
- const isObjectOrArray = typeof option === "object";
1429
- const label = createLabel(isObjectOrArray, preselectedOption);
1430
-
1431
- allOptionsWereSelected++;
1432
-
1433
- emitter.value.emit("extended:select-option", {
1434
- label,
1435
- option: preselectedOption,
1436
- });
1437
- }
1438
- });
1439
-
1440
- if (allOptionsWereSelected !== preselectedOptions.length && showInsertWarnings.value) {
1441
- console.warn("vue-extended-multiselect: options in «preselectedOptions» property should be the same as analogues in «options» property");
1442
- }
1443
- };
1444
-
1445
- /**
1446
- * Determines conditions that control preselected options installattion
1447
- * if "modelValue" prop is defined
1448
- * @function
1449
- * @emits update:wrapper
1450
- * @param {boolean} withRemoval - removal of selected options flag
1451
- */
1452
- const setPreselectedOptionsByModelValue = (withRemoval = false) => {
1453
- if (!modelValue.value && !withRemoval) return;
1454
-
1455
- if (withRemoval) selectedOptionsWatcher.value();
1456
-
1457
- if (multiple.value) {
1458
- if (withRemoval) removeSelectedOptions();
1459
-
1460
- setPreselectedOptions(modelValue.value, false);
1461
- } else {
1462
- if (withRemoval) removeSelectedOptions(true);
1463
-
1464
- setPreselectedOption(modelValue.value, false);
1465
- }
1466
-
1467
- if (withRemoval) {
1468
- updateModelValue();
1469
-
1470
- selectedOptionsWatcher.value = watch(selectedOptions, () => {
1471
- updateModelValue();
1472
-
1473
- if (resetSearchByValue.value) {
1474
- emitter.value.emit("extended:clear-field");
1475
- }
1476
- }, { deep: true });
1477
- }
1478
- }
1479
-
1480
- /**
1481
- * Determines conditions that control preselected options installattion
1482
- * by "preselectedOption" and "preselectedOptions" props
1483
- * @function
1484
- */
1485
- const setPreselectedOptionsByConditions = () => {
1486
- if (preselectedOption.value && !multiple.value) {
1487
- setPreselectedOption(preselectedOption.value);
1488
-
1489
- if (selectedOptions.value.length) {
1490
- updateModelValue();
1491
- }
1492
- }
1493
-
1494
- if (preselectedOptions.value && multiple.value) {
1495
- const initialLength = selectedOptions.value.length;
1496
-
1497
- setPreselectedOptions(preselectedOptions.value);
1498
-
1499
- if (initialLength !== selectedOptions.value.length) {
1500
- updateModelValue();
1501
- }
1502
- }
1503
- };
1504
-
1505
- /**
1506
- * Defines a position of dropdown appearance
1507
- * @function
1508
- * @returns {string} position
1509
- */
1510
- const toggleAppearanceRestrictor = () => {
1511
- if (!window) return "under";
1512
-
1513
- const innerHeight = window.innerHeight;
1514
- const offsetTop = extendedMultiselect.value
1515
- ? extendedMultiselect.value.getBoundingClientRect().y
1516
- : 0;
1517
- const difference = innerHeight - offsetTop;
1518
-
1519
- if (difference > toggleMaxHeight.value) {
1520
- return "under";
1521
- } else {
1522
- return "atop";
1523
- }
1524
- };
1525
-
1526
- /**
1527
- * Sets a position of dropdown appearance
1528
- * @function
1529
- */
1530
- const toggleAppearanceRestrictorActivate = () => {
1531
- if (!dropdownActive.value) {
1532
- chosenToggleAppearanceSide.value = toggleAppearanceSide.value !== "auto"
1533
- ? toggleAppearanceSide.value
1534
- : toggleAppearanceRestrictor();
1535
- }
1536
- };
1537
-
1538
- /**
1539
- * Restricts toggling of dropdown options list
1540
- * @function
1541
- * @emits extended:skip-block-blur
1542
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1543
- * @returns {boolean} toggling
1544
- */
1545
- const toggleBlockRestrictor = (mouseEvent) => {
1546
- let generalRestriction;
1547
- let filteredCustomSelf;
1548
- const filteredHasBlock = toggleDetector(mouseEvent, /^extended__multiselect-block/i, true);
1549
- const filteredHasSlot = toggleDetector(mouseEvent, /^extended__multiselect-options(?!_option)/i, true)
1550
- const filteredSelf = toggleDetector(mouseEvent, /^extended__multiselect-clear/i, true);
1551
-
1552
- if (filteredSelf.length || filteredHasBlock.length || filteredHasSlot.length) {
1553
- filteredCustomSelf = true;
1554
- } else {
1555
- filteredCustomSelf = toggleCustomRestrictor(mouseEvent);
1556
- }
1557
-
1558
- if (extendedMultiselectToggle.value) {
1559
- generalRestriction = (filteredHasBlock.length && dropdownActive.value && filteredCustomSelf)
1560
- || (filteredSelf.length && dropdownActive.value && filteredCustomSelf)
1561
- || (filteredHasSlot.length && dropdownActive.value && filteredCustomSelf);
1562
- } else {
1563
- generalRestriction = (filteredHasBlock.length && dropdownActive.value)
1564
- || (filteredSelf.length && dropdownActive.value)
1565
- || (filteredHasSlot.length && dropdownActive.value);
1566
- }
1567
-
1568
- if (generalRestriction) {
1569
- emitter.value.emit("extended:skip-block-blur");
1570
- return true;
1571
- }
1572
-
1573
- return false;
1574
- }
1575
-
1576
- /**
1577
- * Restricts toggling of dropdown options list by clicking
1578
- * on particular descendants of toggle wrapper element
1579
- * @function
1580
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1581
- * @param {number} blockType - type of block which needs restriction
1582
- * @returns {boolean} restriction
1583
- */
1584
- const toggleCustomRestrictor = (mouseEvent, blockType) => {
1585
- let eventTarget = mouseEvent.target;
1586
- const toggleWrapper = extendedMultiselect.value;
1587
- const customToggle = toggleWrapper.children[blockType];
1588
-
1589
- while(eventTarget) {
1590
- if (eventTarget === customToggle) return true;
1591
-
1592
- eventTarget = eventTarget.parentNode;
1593
- }
1594
-
1595
- return false;
1596
- };
1597
-
1598
- /**
1599
- * Restricts toggling of dropdown options list by clicking
1600
- * on particular elements defined by given pattern
1601
- * @function
1602
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1603
- * @param {string} pattern - pattern with block class partial name
1604
- * @param {boolean} mode - marks whether restrict by parent element or by current target
1605
- * @returns {Array} classes
1606
- */
1607
- const toggleDetector = (mouseEvent, pattern, mode) => {
1608
- let target = mouseEvent.target;
1609
-
1610
- let filteredHasToggle = Array.prototype.filter.call(target.classList, (className) => {
1611
- return pattern.test(className) === true;
1612
- });
1613
-
1614
- while(
1615
- target
1616
- && (target.classList
1617
- && !target.classList.contains("extended__multiselect-wrapper")
1618
- || target.classList
1619
- && !target.classList.length)
1620
- && mode
1621
- && !filteredHasToggle.length
1622
- ) {
1623
- filteredHasToggle = Array.prototype.filter.call(target.classList, (className) => {
1624
- return pattern.test(className) === true;
1625
- });
1626
-
1627
- if (target.classList.contains("extended__multiselect-options_container")) {
1628
- filteredHasToggle.push("extended__multiselect-options_container");
1629
- return filteredHasToggle;
1630
- }
1631
-
1632
- if (target.classList.contains("extended__multiselect-toggle_wrapper")) {
1633
- filteredHasToggle.push("extended__multiselect-toggle_wrapper");
1634
- return filteredHasToggle;
1635
- }
1636
-
1637
- target = target.parentNode;
1638
- }
1639
-
1640
- return filteredHasToggle;
1641
- };
1642
-
1643
- /**
1644
- * Toggles dropdown options list and activates
1645
- * necessary methods with relevant events
1646
- * @function
1647
- */
1648
- const toggleOptions = () => {
1649
- if (internalLoading.value || disabled.value || dropdownDisabled.value) return;
1650
-
1651
- toggleAppearanceRestrictorActivate();
1652
-
1653
- if (!dropdownActive.value) {
1654
- activeEmitter();
1655
- } else {
1656
- closeEmitter();
1657
- }
1658
-
1659
- dropdownActive.value = !dropdownActive.value;
1660
- };
1661
-
1662
- /**
1663
- * Prevents toggling dropdown options list
1664
- * by selecting/deselecting option
1665
- * @function
1666
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1667
- * @returns {boolean} restriction
1668
- */
1669
- const toggleOptionsRestrictor = (mouseEvent) => {
1670
- try {
1671
- let eventTarget = mouseEvent.target;
1672
- const optionsWrapper = optionsWrapper.value;
1673
-
1674
- while(eventTarget) {
1675
- if (eventTarget === optionsWrapper) return true;
1676
-
1677
- eventTarget = eventTarget.parentNode;
1678
- }
1679
-
1680
- return false;
1681
- } catch(e) {
1682
- return false;
1683
- }
1684
- };
1685
-
1686
- /**
1687
- * Collects restrictions from other methods and defines
1688
- * general restriction of toggling dropdown options list
1689
- * @function
1690
- * @emits extended:skip-blur
1691
- * @param {MouseEvent} mouseEvent - MouseEvent instance
1692
- */
1693
- const toggleRestrictor = (mouseEvent) => {
1694
- rollupInstanses();
1695
-
1696
- const targetContentBlock = toggleBlockRestrictor(mouseEvent);
1697
-
1698
- if (targetContentBlock) return;
1699
-
1700
- const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
1701
-
1702
- if (filteredHasToggle.length && dropdownActive.value) {
1703
-
1704
- emitter.value.emit("extended:skip-blur");
1705
- }
1706
- };
1707
-
1708
- /**
1709
- * Triggers modelValue updating when v-model has
1710
- * been changed programmatically
1711
- * @function
1712
- * @emits update:modelValue
1713
- */
1714
- const updateModelValue = () => {
1715
- if (multiple.value) {
1716
- emit("update:modelValue", selectedOptions.value);
1717
- } else {
1718
- emit("update:modelValue", selectedOptions.value[0]);
1719
- }
1720
- }
1721
-
1722
- /**
1723
- * "onBeforeMount" hook of the Vue3ExtendedMultiselect component
1724
- * @emits select
1725
- * @emits clean
1726
- * @emits option-created
1727
- * @emits increase
1728
- * @emits pattern-changed
1729
- * @emits extended:rollup-options
1730
- * @listens extended:rollup-options
1731
- * @listens extended:toggle-options
1732
- * @listens extended:select-option
1733
- * @listens extended:deselect-option
1734
- * @listens extended:create-option
1735
- * @listens extended:increase-display
1736
- * @listens extended:loader-pattern-changed
1737
- * @listens extended:search-pattern-changed
1738
- */
1739
- onBeforeMount(() => {
1740
- selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
1741
- updateModelValue();
1742
-
1743
- if (resetSearchByValue.value) {
1744
- emitter.value.emit("extended:clear-field");
1745
- }
1746
- }, { deep: true });
1747
-
1748
- chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
1749
-
1750
- emitter.value.on("extended:rollup-options", () => {
1751
- if (!dropdownActive.value) return;
1752
-
1753
- closeEmitter();
1754
- dropdownActive.value = false;
1755
- });
1756
-
1757
- emitter.value.on("extended:toggle-options", () => {
1758
- toggleOptions();
1759
- });
1760
-
1761
- emitter.value.on("extended:select-option", (option) => {
1762
- const eventData = simpleEvents.value
1763
- ? option.option
1764
- : createEventFields(option.option, "option");
1765
-
1766
- if (multiple.value) {
1767
- selectedOptions.value.push(option.option);
1768
- /**
1769
- * @event select
1770
- * @type {Object}
1771
- * @property {string} inputId - id of search field set by "id" prop
1772
- * @property {UnionPropType} option - just now selected option
1773
- */
1774
- emit("select", eventData);
1775
- } else {
1776
- selectedOptions.value = [option.option];
1777
- /**
1778
- * @see select
1779
- */
1780
- emit("select", eventData);
1781
- }
1782
-
1783
- updateModelValue();
1784
- });
1785
-
1786
- emitter.value.on("extended:deselect-option", (payload) => {
1787
- if (multiple.value && (payload && !payload.clearAll)) {
1788
- const deselectedOption = selectedOptions.value[payload.index];
1789
-
1790
- const eventData = simpleEvents.value
1791
- ? deselectedOption
1792
- : createEventFields(deselectedOption, "option");
1793
-
1794
- /**
1795
- * @event clean
1796
- * @type {Object}
1797
- * @property {string} inputId - id of search field set by "id" prop
1798
- * @property {UnionPropType} option - just now deselected option
1799
- */
1800
- emit("clean", eventData);
1801
-
1802
- if (payload.skipNextRemoval) {
1803
- skipNextRemoval.value = true;
1804
- }
1805
-
1806
- selectedOptions.value.splice(payload.index, 1);
1807
- updateModelValue();
1808
-
1809
- return;
1810
- } else {
1811
- if (!selectedOptions.value.length) return;
1812
-
1813
- const deselectedOption = payload.deselectedOptions
1814
- ? payload.deselectedOptions
1815
- : selectedOptions.value;
1816
-
1817
- const eventData = simpleEvents.value
1818
- ? deselectedOption
1819
- : createEventFields(deselectedOption, "option");
1820
-
1821
- /**
1822
- * @event clean
1823
- * @type {Object}
1824
- * @property {string} inputId - id of search field set by "id" prop
1825
- * @property {UnionPropType} options - just now deselected options
1826
- */
1827
- emit("clean", eventData);
1828
-
1829
- selectedOptions.value = [];
1830
- updateModelValue();
1831
- }
1832
-
1833
- if (toggleOptionsBySelect.value) {
1834
- emitter.value.emit("extended:rollup-options");
1835
- }
1836
- });
1837
-
1838
- emitter.value.on("extended:create-option", (createdOption) => {
1839
- const eventData = simpleEvents.value
1840
- ? createdOption
1841
- : createEventFields(createdOption, "option");
1842
-
1843
- /**
1844
- * @event option-created
1845
- * @type {PluginObject}
1846
- * @property {string} inputId - id of search field set by "id" prop
1847
- * @property {UnionPropType} option - option created by user
1848
- */
1849
- emit("option-created", eventData);
1850
- });
1851
-
1852
- emitter.value.on("extended:increase-display", (limit) => {
1853
- const eventData = simpleEvents.value ? limit : createEventFields(limit, "limit");
1854
-
1855
- /**
1856
- * @event increase
1857
- * @type {Object}
1858
- * @property {string} inputId - id of search field set by "id" prop
1859
- * @property {limit} - current limit of options to be shown next
1860
- */
1861
- emit("increase", eventData);
1862
- });
1863
-
1864
- emitter.value.on("extended:loader-pattern-changed", (pattern) => {
1865
- const eventData = simpleEvents.value
1866
- ? pattern
1867
- : createEventFields(pattern, "pattern");
1868
-
1869
- /**
1870
- * @event pattern-changed
1871
- * @type {Object}
1872
- * @property {string} inputId - id of search field set by "id" prop
1873
- * @property {pattern} - pattern of internal search for available options
1874
- */
1875
- emit("pattern-changed", eventData);
1876
- });
1877
-
1878
- emitter.value.on("extended:search-pattern-changed", (pattern) => {
1879
- const eventData = simpleEvents.value
1880
- ? pattern
1881
- : createEventFields(pattern, "pattern");
1882
-
1883
- /**
1884
- * @event pattern-changed
1885
- * @type {Object}
1886
- * @property {string} inputId - id of search field set by "id" prop
1887
- * @property {pattern} - pattern of internal search for available options
1888
- */
1889
- emit("pattern-changed", eventData);
1890
- });
1891
- });
1892
-
1893
- /**
1894
- * "onMounted" hook of the Vue3ExtendedMultiselect component
1895
- * @listens extended:expand-options
1896
- * @listens extended:rollup-instances
1897
- * @listens extended:loader-pattern-changed
1898
- */
1899
- onMounted(() => {
1900
- if (typeof options.value === "function") {
1901
- loadOptionsByExternalLoader(null, true);
1902
- } else {
1903
- rawOptions.value = options.value;
1904
- setPreselectedOptionsByConditions();
1905
- }
1906
-
1907
- setPreselectedOptionsByModelValue();
1908
-
1909
- if (
1910
- defaultExpanded.value
1911
- && !disabled.value
1912
- && typeof options.value !== "function"
1913
- ) {
1914
- dropdownActive.value = true;
1915
- }
1916
-
1917
- emitter.value.on("extended:expand-options", () => {
1918
- if (dropdownActive.value || dropdownDisabled.value) return;
1919
-
1920
- toggleAppearanceRestrictorActivate();
1921
- activeEmitter();
1922
-
1923
- dropdownActive.value = true;
1924
- });
1925
-
1926
- emitter.value.on("extended:loader-pattern-changed", async (pattern) => {
1927
- await loadOptionsByExternalLoader(pattern, false);
1928
- });
1929
-
1930
- clickOutside.value.init(extendedMultiselectWrapper.value, () => {
1931
- emitter.value.emit("extended:rollup-options");
1932
- });
1933
-
1934
- localEmitter.on("extended:rollup-instances", (instanceRef) => {
1935
- if (instanceRef !== extendedMultiselectWrapper.value) {
1936
- emitter.value.emit("extended:rollup-options");
1937
- }
1938
- });
1939
- });
1940
-
1941
- defineExpose({
1942
- optionCreateLabel,
1943
- });
1944
- </script>
1945
-
1946
- <style>
1947
-
1948
- @import "../styles/main.css";
1949
-
1
+ <template>
2
+ <section
3
+ aria-owns="extended-search-field"
4
+ ref="extendedMultiselectWrapper"
5
+ role="combobox"
6
+ :aria-roledescription="roledescription"
7
+ :class="wrapperClasses"
8
+ :tabindex="tabindexIfSearch"
9
+ @click.stop.left="fieldFocus"
10
+ @click.stop.middle="fieldFocus"
11
+ @keyup.stop.esc="rollUp"
12
+ @keyup.stop.enter="selectByEnter"
13
+ @mousedown.stop.left="toggleRestrictor"
14
+ @mousedown.stop.middle="toggleRestrictor"
15
+ @mouseleave.stop="resetEnterIndex"
16
+ >
17
+ <div
18
+ ref="extendedMultiselect"
19
+ :class="classes"
20
+ :style="[displayWrongValue, expanded]"
21
+ >
22
+ <div>
23
+ <extended-multiselect-input
24
+ :accesskey="attrs.accesskey"
25
+ :autocomplete="attrs.autocomplete"
26
+ :name="attrs.name"
27
+ :spellcheck="attrs.spellcheck"
28
+ :tabindex="attrs.tabindex"
29
+ :translate="attrs.translate"
30
+ :auto-select-search-value="autoSelectSearchValue"
31
+ :create-on-the-go="createOnTheGo"
32
+ :disabled="disabled"
33
+ :loading="internalLoading"
34
+ :icon-filter="iconFilter"
35
+ :multiple="multiple"
36
+ :search-filter-active="searchFilterActive"
37
+ :show-deselect-icon-loader="showDeselectIconLoader"
38
+ :toggling-saves-search-value="togglingSavesSearchValue"
39
+ :toggle-options-by-select="toggleOptionsBySelect"
40
+ :placeholder="placeholder"
41
+ :show-search-field="showSearchField"
42
+ :empty-objects-placeholder="emptyObjectsPlaceholder"
43
+ :label="label"
44
+ :multiple-blocks-limit-message="multipleBlocksLimitMessage"
45
+ :theme-type="themeType"
46
+ :increase-display-by="increaseDisplayBy"
47
+ :multipleBlocksLimit="multipleBlocksLimit"
48
+ :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
49
+ :selected-options="selectedOptions"
50
+ :emitter="emitter"
51
+ :create-custom-option-label="createCustomOptionLabel"
52
+ :create-option-placeholder="createOptionPlaceholder"
53
+ :external-options-loader="externalOptionsLoader"
54
+ :input-id="inputId"
55
+ >
56
+ <template
57
+ v-if="slots.labelBlock"
58
+ #labelBlock="{ labelBlockValue }"
59
+ >
60
+ <slot
61
+ name="labelBlock"
62
+ :label-block-value="labelBlockValue"
63
+ >
64
+ </slot>
65
+ </template>
66
+ <template
67
+ v-if="slots.multipleBlocks"
68
+ #multipleBlocks="{ selectedOptions, deselectBlock }"
69
+ >
70
+ <slot
71
+ name="multipleBlocks"
72
+ :selected-options="selectedOptions"
73
+ :deselect-block="deselectBlock"
74
+ >
75
+ </slot>
76
+ </template>
77
+ <template
78
+ v-if="slots.optionBlock"
79
+ #optionBlock="{ label, deselectBlock, index }"
80
+ >
81
+ <slot
82
+ name="optionBlock"
83
+ :label="label"
84
+ :index="index"
85
+ :deselect-block="deselectBlock"
86
+ >
87
+ </slot>
88
+ </template>
89
+ <template
90
+ v-if="slots.maxElements"
91
+ #maxElements
92
+ >
93
+ <slot name="maxElements"></slot>
94
+ </template>
95
+ <template
96
+ v-if="toggleMultipleBlocksLimit"
97
+ #showMore="{ showMoreOptions }"
98
+ >
99
+ <slot
100
+ name="showMore"
101
+ :show-more-options="showMoreOptions"
102
+ >
103
+ </slot>
104
+ </template>
105
+ </extended-multiselect-input>
106
+ </div>
107
+ <div class="extended__multiselect-toggle_wrapper">
108
+ <slot
109
+ name="toggle"
110
+ :toggle-options-list="toggleOptionsList"
111
+ >
112
+ <extended-multiselect-toggle
113
+ ref="extendedMultiselectToggle"
114
+ :tabindex="attrs.tabindex"
115
+ :disabled="disabled"
116
+ :dropdown-active="dropdownActive"
117
+ :loading="internalLoading"
118
+ :icon-filter="iconFilter"
119
+ :icon-size="iconSize"
120
+ :toggle-icon="toggleIcon"
121
+ :emitter="emitter"
122
+ />
123
+ </slot>
124
+ </div>
125
+ <div class="extended__multiselect-cancel_wrapper">
126
+ <slot
127
+ name="cancel"
128
+ :cancel="cancel"
129
+ >
130
+ <extended-multiselect-cancel
131
+ v-if="showClearIcon"
132
+ :tabindex="attrs.tabindex"
133
+ :disabled="disabled"
134
+ :show-search-field="showSearchField"
135
+ :loading="internalLoading"
136
+ :icon-filter="iconFilter"
137
+ :icon-size="iconSize"
138
+ :selected-options="selectedOptions"
139
+ :emitter="emitter"
140
+ />
141
+ </slot>
142
+ </div>
143
+ </div>
144
+ <transition
145
+ name="extended-toggle"
146
+ type="transition"
147
+ >
148
+ <extended-multiselect-options
149
+ v-if="dropdownActive"
150
+ :auto-select-created-option="autoSelectCreatedOption"
151
+ :clear-by-select-when-multiple="clearBySelectWhenMultiple"
152
+ :create-on-the-go="createOnTheGo"
153
+ :disabled-primitive-options-converted="disabledPrimitiveOptionsConverted"
154
+ :highlight-options="highlightOptions"
155
+ :loading="internalLoading"
156
+ :multiple="multiple"
157
+ :selected-options-shown="selectedOptionsShown"
158
+ :show-insert-warnings="showInsertWarnings"
159
+ :show-marker="showMarker"
160
+ :chosen-toggle-appearance-side="chosenToggleAppearanceSide"
161
+ :create-option-type="createOptionType"
162
+ :disable-by-field="disableByField"
163
+ :empty-objects-placeholder="emptyObjectsPlaceholder"
164
+ :label="label"
165
+ :search-by-field="searchByField"
166
+ :theme-type="themeType"
167
+ :any-option-wrapper-block-height="anyOptionWrapperBlockHeight"
168
+ :max-options-count="maxOptionsCount"
169
+ :min-options-count="minOptionsCount"
170
+ :options-padding="optionsPadding"
171
+ :toggle-max-height="toggleMaxHeight"
172
+ :toggle-min-height="toggleMinHeight"
173
+ :create-option-fields="createOptionFields"
174
+ :options="restrictedOptions"
175
+ :restricted-options="restrictedOptions"
176
+ :selected-options="selectedOptions"
177
+ :special-keys-block="specialKeysBlock"
178
+ :preselected-option="preselectedOption"
179
+ :preselected-options="preselectedOptions"
180
+ :emitter="emitter"
181
+ :create-custom-option-label="createCustomOptionLabel"
182
+ :external-options-loader="externalOptionsLoader"
183
+ >
184
+ <template
185
+ v-if="slots.listHeader"
186
+ #listHeader
187
+ >
188
+ <slot name="listHeader"></slot>
189
+ </template>
190
+ <template
191
+ v-if="maxOptionsCount"
192
+ #moreThanLimit
193
+ >
194
+ <slot name="moreThanLimit"></slot>
195
+ </template>
196
+ <template
197
+ v-if="minOptionsCount"
198
+ #lessThanLimit
199
+ >
200
+ <slot name="lessThanLimit"></slot>
201
+ </template>
202
+ <template
203
+ v-if="slots.option"
204
+ #option="{ option, createCustomOptionLabel }"
205
+ >
206
+ <slot
207
+ name="option"
208
+ :option="option"
209
+ :create-custom-option-label="createCustomOptionLabel"
210
+ >
211
+ </slot>
212
+ </template>
213
+ <template
214
+ v-if="slots.marker"
215
+ #marker="{ selected }"
216
+ >
217
+ <slot
218
+ name="marker"
219
+ :selected="selected"
220
+ >
221
+ </slot>
222
+ </template>
223
+ <template
224
+ v-if="noResultsBlockShown"
225
+ #noResults
226
+ >
227
+ <slot name="noResults"></slot>
228
+ </template>
229
+ <template
230
+ v-if="slots.noOptions"
231
+ #noOptions
232
+ >
233
+ <slot name="noOptions"></slot>
234
+ </template>
235
+ <template
236
+ v-if="slots.listFooter"
237
+ #listFooter
238
+ >
239
+ <slot name="listFooter"></slot>
240
+ </template>
241
+ </extended-multiselect-options>
242
+ </transition>
243
+ </section>
244
+ </template>
245
+
246
+ <script setup>
247
+ import {
248
+ computed,
249
+ defineEmits,
250
+ defineExpose,
251
+ defineProps,
252
+ onBeforeMount,
253
+ onMounted,
254
+ provide,
255
+ ref,
256
+ toRaw,
257
+ toRefs,
258
+ useAttrs,
259
+ useSlots,
260
+ watch,
261
+ } from "vue";
262
+
263
+ import {
264
+ themeTypes,
265
+ loaderThemeTypes,
266
+ toggleIcons,
267
+ iconFilters,
268
+ iconSizes,
269
+ createOptionTypes,
270
+ specialKeysToBlock,
271
+ toggleAppearenceSides,
272
+ UnionPropType,
273
+ } from "../sets/sets";
274
+
275
+ import localEmitter from "../tools/instance.js";
276
+
277
+ import useToggle from "../composition/toggle";
278
+ import useCancel from "../composition/cancel";
279
+ import useLabels from "../composition/labels";
280
+ import useEmitter from "../composition/emitter";
281
+ import useClickOutside from "../composition/click-outside";
282
+ import usePreselectedOptions from "../composition/preselected-options";
283
+ import useSearchValue from "../composition/search-value";
284
+
285
+ import ExtendedMultiselectCancel from "./ExtendedMultiselectCancel.vue";
286
+ import ExtendedMultiselectInput from "./ExtendedMultiselectInput.vue";
287
+ import ExtendedMultiselectOptions from "./ExtendedMultiselectOptions.vue";
288
+ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
289
+
290
+ /**
291
+ * @todo Mark optional arguments of functions
292
+ */
293
+
294
+ /**
295
+ * @author Ridiger Daniil Dmitrievich, 2022
296
+ * @version 2.0.0
297
+ */
298
+ const props = defineProps({
299
+ /**
300
+ * Determines whether to select just now created option
301
+ * automatically
302
+ * @default false
303
+ * @property {boolean} autoSelectCreatedOption
304
+ */
305
+ autoSelectCreatedOption: {
306
+ type: Boolean,
307
+ default: false,
308
+ },
309
+
310
+ /**
311
+ * Determines whether to take search value from current
312
+ * selected option if "multiple" prop equals false
313
+ * @default false
314
+ * @property {boolean} autoSelectSearchValue
315
+ */
316
+ autoSelectSearchValue: {
317
+ type: Boolean,
318
+ default: false,
319
+ },
320
+
321
+ /**
322
+ * Determines whether to clear search field by option selection
323
+ * @default false
324
+ * @property {boolean} clearBySelectWhenMultiple
325
+ */
326
+ clearBySelectWhenMultiple: {
327
+ type: Boolean,
328
+ default: false,
329
+ },
330
+
331
+ /**
332
+ * Allows user to create new options from search field
333
+ * @default false
334
+ * @property {boolean} createOnTheGo
335
+ */
336
+ createOnTheGo: {
337
+ type: Boolean,
338
+ default: false,
339
+ },
340
+
341
+ /**
342
+ * Determines whether options list should be expanded by default
343
+ * @default false
344
+ * @property {boolean} defaultExpanded
345
+ */
346
+ defaultExpanded: {
347
+ type: Boolean,
348
+ default: false,
349
+ },
350
+
351
+ /**
352
+ * Disables extended multiselect
353
+ * @default false
354
+ * @property {boolean} disabled
355
+ */
356
+ disabled: {
357
+ type: Boolean,
358
+ default: false,
359
+ },
360
+
361
+ /**
362
+ * Disables dropdown toggle
363
+ * @default false
364
+ * @property {boolean} dropdownDisabled
365
+ */
366
+ dropdownDisabled: {
367
+ type: Boolean,
368
+ default: false,
369
+ },
370
+
371
+ /**
372
+ * Switches options highlighting while hovering
373
+ * @default true
374
+ * @property {boolean} highlightOptions
375
+ */
376
+ highlightOptions: {
377
+ type: Boolean,
378
+ default: true,
379
+ },
380
+
381
+ /**
382
+ * Switches loading state of extended multiselect
383
+ * @default false
384
+ * @property {boolean} loading
385
+ */
386
+ loading: {
387
+ type: Boolean,
388
+ default: false,
389
+ },
390
+
391
+ /**
392
+ * Allows user to select multiple options
393
+ * @default false
394
+ * @property {boolean} multiple
395
+ */
396
+ multiple: {
397
+ type: Boolean,
398
+ default: false,
399
+ },
400
+
401
+ /**
402
+ * Determines whether to show special hint if no options were found
403
+ * @default true
404
+ * @property {boolean} noResultsBlockShown
405
+ */
406
+ noResultsBlockShown: {
407
+ type: Boolean,
408
+ default: true,
409
+ },
410
+
411
+ /**
412
+ * Determines whether to clear search field by selection/deselection of options
413
+ * @default true
414
+ * @property {boolean} resetSearchByValue
415
+ */
416
+ resetSearchByValue: {
417
+ type: Boolean,
418
+ default: true,
419
+ },
420
+
421
+ /**
422
+ * Allows user to use internal search for options
423
+ * @default true
424
+ * @property {boolean} searchFilterActive
425
+ */
426
+ searchFilterActive: {
427
+ type: Boolean,
428
+ default: true,
429
+ },
430
+
431
+ /**
432
+ * Switches full payload of extended multiselect events
433
+ * @default true
434
+ * @property {boolean} simpleEvents
435
+ */
436
+ simpleEvents: {
437
+ type: Boolean,
438
+ default: true,
439
+ },
440
+
441
+ /**
442
+ * Determines whether to show selected options in options list
443
+ * @default false
444
+ * @property {boolean} selectedOptionsShown
445
+ */
446
+ selectedOptionsShown: {
447
+ type: Boolean,
448
+ default: false,
449
+ },
450
+
451
+ /**
452
+ * Allows user to deselect all options by special icon
453
+ * @default false
454
+ * @property {boolean} showClearIcon
455
+ */
456
+ showClearIcon: {
457
+ type: Boolean,
458
+ default: false,
459
+ },
460
+
461
+ /**
462
+ * Determines whether to show loader icon in multiple
463
+ * options block if "loading" prop equals true
464
+ * @default true
465
+ * @property {boolean} showDeselectIconLoader
466
+ */
467
+ showDeselectIconLoader: {
468
+ type: Boolean,
469
+ default: true,
470
+ },
471
+
472
+ /**
473
+ * Determines whether to show useful internal warnings in console
474
+ * @default false
475
+ * @property {boolean} showInsertWarnings
476
+ */
477
+ showInsertWarnings: {
478
+ type: Boolean,
479
+ default: false,
480
+ },
481
+
482
+ /**
483
+ * Determines whether to show slot with special marker beside option in options list
484
+ * @default false
485
+ * @property {boolean} showMarker
486
+ */
487
+ showMarker: {
488
+ type: Boolean,
489
+ default: false,
490
+ },
491
+
492
+ /**
493
+ * Determines whether to show search field which allows user
494
+ * to search for options with internal search
495
+ * @default true
496
+ * @property {boolean} showSearchField
497
+ */
498
+ showSearchField: {
499
+ type: Boolean,
500
+ default: true,
501
+ },
502
+
503
+ /**
504
+ * Allows user to increase limit of shown elements with selected options
505
+ * by special icon
506
+ * @default false
507
+ * @property {boolean} toggleMultipleBlocksLimit
508
+ */
509
+ toggleMultipleBlocksLimit: {
510
+ type: Boolean,
511
+ default: false,
512
+ },
513
+
514
+ /**
515
+ * Determines whether to roll up options list by selection of option
516
+ * @default true
517
+ * @property {boolean} toggleOptionsBySelect
518
+ */
519
+ toggleOptionsBySelect: {
520
+ type: Boolean,
521
+ default: true,
522
+ },
523
+
524
+ /**
525
+ * Determines whether to save current search value if
526
+ * display of options list was toggled
527
+ * @default true
528
+ * @property {boolean} togglingSavesSearchValue
529
+ */
530
+ togglingSavesSearchValue: {
531
+ type: Boolean,
532
+ default: true,
533
+ },
534
+
535
+ /**
536
+ * Determines whether to define special class for extended multiselect
537
+ * if value is wrong
538
+ * Irregularity of value is defined by user
539
+ * @default false
540
+ * @property {boolean} wrongCurrentValue
541
+ */
542
+ wrongCurrentValue: {
543
+ type: Boolean,
544
+ default: false,
545
+ },
546
+
547
+ /**
548
+ * Placeholder for the search field to be used if
549
+ * user is allowed to create new options
550
+ * @default "Select or create features"
551
+ * @property {string} createOptionPlaceholder
552
+ */
553
+ createOptionPlaceholder: {
554
+ type: String,
555
+ default: "Select or create features",
556
+ },
557
+
558
+ /**
559
+ * Defines kind for all options which will be created by user
560
+ * @default "primitive"
561
+ * @property {string} createOptionType
562
+ */
563
+ createOptionType: {
564
+ type: String,
565
+ default: "primitive",
566
+ validator(value) {
567
+ return createOptionTypes.includes(value);
568
+ },
569
+ },
570
+
571
+ /**
572
+ * Determines a field in options of type "object"
573
+ * which value will be used to disable such options.
574
+ * @default "disabled"
575
+ * @property {string} disableByField
576
+ */
577
+ disableByField: {
578
+ type: String,
579
+ default: "disabled",
580
+ },
581
+
582
+ /**
583
+ * Placeholder for options of type "object"
584
+ * or Array instances which length/keys length equals 0
585
+ * @default "Empty Object/Array"
586
+ * @property {string} emptyObjectsPlaceholder
587
+ */
588
+ emptyObjectsPlaceholder: {
589
+ type: String,
590
+ default: "Empty Object/Array",
591
+ },
592
+
593
+ /**
594
+ * Defines "border-color" css-property for extended multiselect with wrong value
595
+ * @default "#FF0000"
596
+ * @property {string} errorBorderColor
597
+ */
598
+ errorBorderColor: {
599
+ type: String,
600
+ default: "#FF0000",
601
+ },
602
+
603
+ /**
604
+ * Defines svg-filter with color settings for all icons except loader
605
+ * @default "basic"
606
+ * @property {string} iconFilter
607
+ */
608
+ iconFilter: {
609
+ type: String,
610
+ default: "basic",
611
+ validator(value) {
612
+ return iconFilters.includes(value);
613
+ },
614
+ },
615
+
616
+ /**
617
+ * Defines sizes for all icons in pixels except loader
618
+ * @default "large"
619
+ * @property {string} iconSize
620
+ */
621
+ iconSize: {
622
+ type: String,
623
+ default: "large",
624
+ validator(value) {
625
+ return iconSizes.includes(value);
626
+ },
627
+ },
628
+
629
+ /**
630
+ * Defines field in options of type "object" that will be the label of option
631
+ * @default "label"
632
+ * @property {string} label
633
+ */
634
+ label: {
635
+ type: String,
636
+ default: "label",
637
+ },
638
+
639
+ /**
640
+ * Defines svg-filter with color settings for loader icon
641
+ * @default "loader-default"
642
+ * @property {string} loaderIconFilter
643
+ */
644
+ loaderIconFilter: {
645
+ type: String,
646
+ default: "loader-default",
647
+ validator(value) {
648
+ return loaderThemeTypes.includes(value);
649
+ },
650
+ },
651
+
652
+ /**
653
+ * Placeholder for search field to be used if
654
+ * user is not allowed to create new options
655
+ * @default "Select features"
656
+ * @property {string} placeholder
657
+ */
658
+ placeholder: {
659
+ type: String,
660
+ default: "Select features",
661
+ },
662
+
663
+ /**
664
+ * Determines field in options of type "object"
665
+ * to use in internal search.
666
+ * @default ""
667
+ * @property {string} searchByField
668
+ */
669
+ searchByField: {
670
+ type: String,
671
+ default: "",
672
+ },
673
+
674
+ /**
675
+ * Defines overall color theme for extended multiselect
676
+ * @default "basic"
677
+ * @property {string} themeType
678
+ */
679
+ themeType: {
680
+ type: String,
681
+ default: "basic",
682
+ validator(value) {
683
+ return themeTypes.includes(value);
684
+ },
685
+ },
686
+
687
+ /**
688
+ * Defines which side options list will be displayed on
689
+ * @default "auto"
690
+ * @property {string} toggleAppearanceSide
691
+ */
692
+ toggleAppearanceSide: {
693
+ type: String,
694
+ default: "auto",
695
+ validator(value) {
696
+ return toggleAppearenceSides.includes(value);
697
+ },
698
+ },
699
+
700
+ /**
701
+ * Defines kind of toggle icon from icons collection
702
+ * @default "base-arrow"
703
+ * @property {string} toggleIcon
704
+ */
705
+ toggleIcon: {
706
+ type: String,
707
+ default: "base-arrow",
708
+ validator(value) {
709
+ return toggleIcons.includes(value);
710
+ },
711
+ },
712
+
713
+ /**
714
+ * Defines gap which increases limit of displayed elements with selected options
715
+ * @default 5
716
+ * @property {number} increaseDisplayBy
717
+ */
718
+ increaseDisplayBy: {
719
+ type: Number,
720
+ default: 5,
721
+ },
722
+
723
+ /**
724
+ * Maximal limit of selected options
725
+ * @default null
726
+ * @property {number|null} maxOptionsCount
727
+ */
728
+ maxOptionsCount: {
729
+ type: Number,
730
+ default: null,
731
+ },
732
+
733
+ /**
734
+ * Minimal limit of selected options
735
+ * @default null
736
+ * @property {number|null} minOptionsCount
737
+ */
738
+ minOptionsCount: {
739
+ type: Number,
740
+ default: null,
741
+ },
742
+
743
+ /**
744
+ * Defines limit of displayed elements with selected options
745
+ * @default null
746
+ * @property {number|null} multipleBlocksLimit
747
+ */
748
+ multipleBlocksLimit: {
749
+ type: Number,
750
+ default: null,
751
+ },
752
+
753
+ /**
754
+ * Defines maximal limit of options list length
755
+ * @default null
756
+ * @property {number|null} optionsCountRestriction
757
+ */
758
+ optionsCountRestriction: {
759
+ type: Number,
760
+ default: null,
761
+ },
762
+
763
+ /**
764
+ * Defines maximal value in pixels of "max-height" css-property for options list
765
+ * @default 400
766
+ * @property {number} toggleMaxHeight
767
+ */
768
+ toggleMaxHeight: {
769
+ type: Number,
770
+ default: 400,
771
+ },
772
+
773
+ /**
774
+ * Defines minimal value in pixels of "max-height" css-property for options list
775
+ * @default null
776
+ * @property {number} toggleMaxHeight
777
+ */
778
+ toggleMinHeight: {
779
+ type: Number,
780
+ default: null,
781
+ },
782
+
783
+ /**
784
+ * Defines a list of fields for options of type "object" created by user
785
+ * @default ["label"]
786
+ * @property {Array} createOptionFields
787
+ */
788
+ createOptionFields: {
789
+ type: Array,
790
+ default: () => ["label"],
791
+ validator(value) {
792
+ return !value.some((field) => {
793
+ return typeof field !== "string";
794
+ });
795
+ },
796
+ },
797
+
798
+ /**
799
+ * Defines a list of primitive types for options.
800
+ * Options of given types will be disabled for selection.
801
+ * @default []
802
+ * @property {Array} disabledPrimitiveOptions
803
+ */
804
+ disabledPrimitiveOptions: {
805
+ type: Array,
806
+ default: () => [],
807
+ validator(value) {
808
+ return value.every((option) => {
809
+ return typeof option === "string" || Array.isArray(option)
810
+ || typeof option === "number" || typeof option === "boolean"
811
+ || typeof option === "function";
812
+ });
813
+ },
814
+ },
815
+
816
+ /**
817
+ * Raw options list
818
+ * @default []
819
+ * @property {Array|Function} options
820
+ */
821
+ options: {
822
+ type: [Array, Function],
823
+ default: () => [],
824
+ },
825
+
826
+ /**
827
+ * Defines a list with "padding-top", "padding-left", "padding-bottom"
828
+ * and "padding-right" css-properties for options in options list.
829
+ * Property "padding-top" matches index zero.
830
+ * Property "padding-right" matches index three.
831
+ * @default []
832
+ * @property {Array} optionsPadding
833
+ */
834
+ optionsPadding: {
835
+ type: Array,
836
+ default: () => [],
837
+ validator(value) {
838
+ return value.length < 5
839
+ && !value.some((padding) => {
840
+ return typeof padding !== "number";
841
+ });
842
+ },
843
+ },
844
+
845
+ /**
846
+ * Defines a list of options that will be select by default
847
+ * @default []
848
+ * @property {Array} preselectedOptions
849
+ */
850
+ preselectedOptions: {
851
+ type: Array,
852
+ default: () => [],
853
+ },
854
+
855
+ /**
856
+ * Defines a list of keys which in combination with mouse buttons or "enter" key
857
+ * will prevent selection of option
858
+ * @default []
859
+ * @property {Array} specialKeysBlock
860
+ */
861
+ specialKeysBlock: {
862
+ type: Array,
863
+ default: () => [],
864
+ validator(value) {
865
+ return value.every((keyBlock) => {
866
+ return specialKeysToBlock.includes(keyBlock);
867
+ });
868
+ },
869
+ },
870
+
871
+ /**
872
+ * Defines value of extended multiselect that can be used in "v-model" attribute
873
+ * @default []
874
+ * @property {Array|null} modelValue
875
+ */
876
+ modelValue: {
877
+ type: UnionPropType,
878
+ default: null,
879
+ },
880
+
881
+ /**
882
+ * Defines function that creates custom label for each option
883
+ * @default (option)=>null
884
+ * @property {Function} createCustomOptionLabel
885
+ */
886
+ createCustomOptionLabel: {
887
+ type: Function,
888
+ default: (option) => null,
889
+ },
890
+
891
+ /**
892
+ * Defines function that creates notification when maximal limit
893
+ * of selected options has been reached
894
+ * @default (number)=>string
895
+ * @property {Function} multipleBlocksLimitMessage
896
+ */
897
+ multipleBlocksLimitMessage: {
898
+ type: Function,
899
+ default: (number) => `and ${number} more items`,
900
+ },
901
+
902
+
903
+ /**
904
+ * Defines "height" css-property for each option in options list
905
+ * @default 30
906
+ * @property {number} anyOptionWrapperBlockHeight
907
+ */
908
+ anyOptionWrapperBlockHeight: {
909
+ type: [Number, String],
910
+ default: "auto",
911
+ },
912
+
913
+ /**
914
+ * "id" attribute of search field
915
+ * @default null
916
+ * @property {string|number|null} inputId
917
+ */
918
+ inputId: {
919
+ type: [String, Number],
920
+ default: null,
921
+ },
922
+
923
+ /**
924
+ * Defines options that will be select by default
925
+ * @default null
926
+ * @property {UnionPropType|null} preselectedOption
927
+ */
928
+ preselectedOption: {
929
+ type: UnionPropType,
930
+ default: null,
931
+ },
932
+ });
933
+
934
+ const emit = defineEmits([
935
+ "active",
936
+ "clean",
937
+ "close",
938
+ "increase",
939
+ "option-created",
940
+ "pattern-changed",
941
+ "select",
942
+ "update:modelValue",
943
+ ]);
944
+
945
+ const dropdownActive = ref(false);
946
+ const skipNextRemoval = ref(false);
947
+ const externalOptionsLoader = ref(null);
948
+ const chosenToggleAppearanceSide = ref(null);
949
+ const selectedOptionsWatcher = ref(null);
950
+ const rawOptions = ref([]);
951
+ const selectedOptions = ref([]);
952
+ const togglePattern = /^extended__multiselect-toggle_wrapper/i;
953
+
954
+ /**
955
+ * Element references
956
+ */
957
+ const extendedMultiselect = ref(null);
958
+ const extendedMultiselectToggle = ref(null);
959
+ const extendedMultiselectWrapper = ref(null);
960
+
961
+ const {
962
+ defaultExpanded,
963
+ disabled,
964
+ dropdownDisabled,
965
+ disabledPrimitiveOptions,
966
+ emptyObjectsPlaceholder,
967
+ errorBorderColor,
968
+ inputId,
969
+ label,
970
+ loading,
971
+ loaderIconFilter,
972
+ modelValue,
973
+ multiple,
974
+ options,
975
+ optionsCountRestriction,
976
+ preselectedOption,
977
+ preselectedOptions,
978
+ resetSearchByValue,
979
+ simpleEvents,
980
+ showClearIcon,
981
+ showInsertWarnings,
982
+ showSearchField,
983
+ themeType,
984
+ toggleAppearanceSide,
985
+ toggleMaxHeight,
986
+ toggleOptionsBySelect,
987
+ wrongCurrentValue,
988
+ createCustomOptionLabel,
989
+ } = toRefs(props);
990
+
991
+ const {
992
+ searchState,
993
+ setSearchValue,
994
+ setSearchPattern,
995
+ } = useSearchValue();
996
+
997
+ provide("loaderIconFilter", loaderIconFilter.value);
998
+ provide("searchState", searchState);
999
+ provide("setSearchValue", setSearchValue);
1000
+ provide("setSearchPattern", setSearchPattern);
1001
+
1002
+ const { emitter } = useEmitter();
1003
+ const { clickOutside } = useClickOutside();
1004
+ const { toggleOptionsList } = useToggle(
1005
+ loading,
1006
+ disabled,
1007
+ emitter,
1008
+ );
1009
+ const { cancel } = useCancel(
1010
+ disabled,
1011
+ showSearchField,
1012
+ selectedOptions,
1013
+ emitter,
1014
+ setSearchValue,
1015
+ setSearchPattern,
1016
+ );
1017
+ const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
1018
+ label,
1019
+ emptyObjectsPlaceholder,
1020
+ showInsertWarnings,
1021
+ );
1022
+ const { optionCreateLabel } = useLabels(
1023
+ label,
1024
+ createCustomOptionLabel,
1025
+ emptyObjectsPlaceholder,
1026
+ );
1027
+ const attrs = useAttrs();
1028
+ const slots = useSlots();
1029
+
1030
+ /**
1031
+ * Defines a list of extended multiselect wrapper classes
1032
+ * @function
1033
+ * @returns {Array} classes
1034
+ */
1035
+ const classes = computed(() => {
1036
+ let theme;
1037
+ const localClassList = [];
1038
+
1039
+ switch(themeType.value) {
1040
+ case "basic":
1041
+ theme = "extended__multiselect";
1042
+ break;
1043
+ case "slate-grey":
1044
+ theme = "extended__multiselect-slate-grey";
1045
+ break;
1046
+ case "slate-blue":
1047
+ theme = "extended__multiselect-slate-blue";
1048
+ break;
1049
+ case "teal":
1050
+ theme = "extended__multiselect-teal";
1051
+ break;
1052
+ case "strict":
1053
+ theme = "extended__multiselect-strict";
1054
+ break;
1055
+ default: theme = "extended__multiselect";
1056
+ }
1057
+
1058
+ localClassList.push(theme);
1059
+
1060
+ const clear = showClearIcon.value
1061
+ ? "extended__multiselect-clear--active"
1062
+ : "extended__multiselect-clear--locked";
1063
+
1064
+ localClassList.push(clear);
1065
+ localClassList.push("extended__multiselect-container");
1066
+
1067
+ return localClassList;
1068
+ });
1069
+
1070
+ /**
1071
+ * Defines a list of disabled options by types given in "disabledPrimitiveOptions" prop
1072
+ * @function
1073
+ * @returns {Array} options
1074
+ */
1075
+ const disabledPrimitiveOptionsConverted = computed(() => {
1076
+ if (!disabledPrimitiveOptions.value) return null;
1077
+
1078
+ return disabledPrimitiveOptions.value.map((disabledOption) => {
1079
+ if (Array.isArray(disabledOption)) {
1080
+ if (!disabledOption.length) return emptyObjectsPlaceholder.value;
1081
+
1082
+ return disabledOption.join(", ");
1083
+ }
1084
+
1085
+ return disabledOption;
1086
+ });
1087
+ });
1088
+
1089
+ /**
1090
+ * Determines whether to display irregularity of value by "border-color" css-property
1091
+ * @function
1092
+ * @returns {Object|null} styles
1093
+ */
1094
+ const displayWrongValue = computed(() => {
1095
+ return wrongCurrentValue.value ? { borderColor: errorBorderColor.value } : null;
1096
+ });
1097
+
1098
+ /**
1099
+ * Defines styles depending on current options list dropdown state
1100
+ * @function
1101
+ * @returns {Object|null} styles
1102
+ */
1103
+ const expanded = computed(() => {
1104
+ let borderStyles;
1105
+
1106
+ if (chosenToggleAppearanceSide.value === "atop") {
1107
+ borderStyles = {
1108
+ borderTopLeftRadius: 0,
1109
+ borderTopRightRadius: 0,
1110
+ };
1111
+ } else {
1112
+ borderStyles = {
1113
+ borderBottomLeftRadius: 0,
1114
+ borderBottomRightRadius: 0,
1115
+ };
1116
+ }
1117
+
1118
+ return dropdownActive.value ? borderStyles : null;
1119
+ });
1120
+
1121
+ /**
1122
+ * Determines whether to activate loading state by "loading" prop
1123
+ * or by internal loading sign
1124
+ * @function
1125
+ * @returns {boolean} loading
1126
+ */
1127
+ const internalLoading = computed(() => {
1128
+ return loading.value;
1129
+ });
1130
+
1131
+ /**
1132
+ * Defines mapped list of previously restricted options
1133
+ * @function
1134
+ * @returns {Array} options
1135
+ */
1136
+ const mappedOptions = computed(() => {
1137
+ return restrictedOptions.value.map((restrictedOption) => {
1138
+ return JSON.stringify(restrictedOption);
1139
+ });
1140
+ });
1141
+
1142
+ /**
1143
+ * Defines a list of options filtered by maximal admissible options amount
1144
+ * @function
1145
+ * @returns {Array} options
1146
+ */
1147
+ const restrictedOptions = computed(() => {
1148
+ if (!rawOptions.value) return [];
1149
+
1150
+ return optionsCountRestriction.value
1151
+ ? rawOptions.value.filter((_, index) => index + 1 <= optionsCountRestriction.value)
1152
+ : rawOptions.value;
1153
+ });
1154
+
1155
+ /**
1156
+ * Defines "aria-roledescription" attribute of extended multiselect wrapper
1157
+ * @function
1158
+ * @returns {string} aria-roledescription
1159
+ */
1160
+ const roledescription = computed(() => {
1161
+ return multiple.value ? "Multiselect" : "Select";
1162
+ });
1163
+
1164
+ /**
1165
+ * Defines "tabindex" attribute of extended multiselect wrapper if needed
1166
+ * @function
1167
+ * @returns {number} tabindex
1168
+ */
1169
+ const tabindexIfSearch = computed(() => {
1170
+ return showSearchField.value ? attrs.tabindex : -1;
1171
+ });
1172
+
1173
+ /**
1174
+ * Defines special class which indicates disabled or loading state
1175
+ * of extended multiselect wrapper
1176
+ * @function
1177
+ * @returns {string} class
1178
+ */
1179
+ const wrapperClasses = computed(() => {
1180
+ return disabled.value && !internalLoading.value
1181
+ ? "extended__multiselect-wrapper--disabled"
1182
+ : "extended__multiselect-wrapper";
1183
+ });
1184
+
1185
+ /**
1186
+ * Forcibly rolls up dropdown options list by changing "dropdownActive" flag
1187
+ * @function
1188
+ * @emits extended:rollup-options
1189
+ * @param {boolean} value - "dropdownActive" flag
1190
+ */
1191
+ watch(dropdownActive, (value) => {
1192
+ if (!value) {
1193
+ emitter.value.emit("extended:rollup-options");
1194
+ }
1195
+ });
1196
+
1197
+ /**
1198
+ * Changes selected options based on external modelValue changes
1199
+ * @function
1200
+ */
1201
+ watch(modelValue, (value, prevValue) => {
1202
+ if (
1203
+ JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))
1204
+ || skipNextRemoval.value
1205
+ ) {
1206
+ skipNextRemoval.value = false;
1207
+
1208
+ return;
1209
+ }
1210
+
1211
+ setPreselectedOptionsByModelValue(true);
1212
+ }, { deep: true });
1213
+
1214
+ /**
1215
+ * Emits "active" when dropdown options list is active
1216
+ * @function
1217
+ * @emits active
1218
+ */
1219
+ const activeEmitter = () => {
1220
+ const eventData = simpleEvents.value ? null : {
1221
+ inputId: inputId.value,
1222
+ };
1223
+
1224
+ /**
1225
+ * @event active
1226
+ * @type {object|null}
1227
+ * @property {string} inputId - id of search field set by "id" prop
1228
+ */
1229
+ emit("active", eventData);
1230
+ };
1231
+
1232
+ /**
1233
+ * Emits "close" when dropdown options list is rolled up
1234
+ * @function
1235
+ * @emits close
1236
+ */
1237
+ const closeEmitter = () => {
1238
+ const eventData = simpleEvents.value
1239
+ ? selectedOptions.value
1240
+ : createEventFields(selectedOptions.value, "options");
1241
+
1242
+ /**
1243
+ * @event close
1244
+ * @type {object|Array}
1245
+ * @property {string} inputId - id of search field set by "id" prop
1246
+ * @property {Array} options - array of selected options
1247
+ */
1248
+ emit("close", eventData);
1249
+ }
1250
+
1251
+ /**
1252
+ * Creates payload for events that can be listened by outer listeners
1253
+ * @function
1254
+ * @param {UnionPropType} field - main payload of event
1255
+ * @param {string} fieldName - name of field with main payload of event
1256
+ * @returns {object} payload
1257
+ */
1258
+ const createEventFields = (field, fieldName) => {
1259
+ const eventFields = {
1260
+ inputId: inputId.value,
1261
+ };
1262
+
1263
+ Object.defineProperty(eventFields, fieldName, {
1264
+ value: field,
1265
+ enumerable: true,
1266
+ });
1267
+
1268
+ return eventFields;
1269
+ };
1270
+
1271
+ /**
1272
+ * Focuses search field if "click" native event was triggered on available element
1273
+ * @function
1274
+ * @emits extended:field-focus
1275
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1276
+ */
1277
+ const fieldFocus = (mouseEvent) => {
1278
+ if (disabled.value) return;
1279
+
1280
+ if (!toggleOptionsBySelect.value) {
1281
+ const customFilteredOptions = toggleOptionsRestrictor(mouseEvent);
1282
+
1283
+ if (customFilteredOptions) return;
1284
+ }
1285
+
1286
+ const customFilteredCancel = toggleCustomRestrictor(mouseEvent, 2);
1287
+ const customFilteredSelf = toggleCustomRestrictor(mouseEvent, 1);
1288
+ const filteredHasCancel = toggleDetector(mouseEvent, /^extended__multiselect-cancel_wrapper/i);
1289
+ const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
1290
+
1291
+ if (customFilteredCancel) return;
1292
+ if (customFilteredSelf && dropdownActive.value === false) return;
1293
+ if (filteredHasCancel.length) return;
1294
+ if (filteredHasToggle.length && dropdownActive.value === false) return;
1295
+
1296
+ emitter.value.emit("extended:field-focus");
1297
+ };
1298
+
1299
+ /**
1300
+ * Initialises options list loading by external async method
1301
+ * @function
1302
+ * @param {string} pattern - value of search field
1303
+ * @param {boolean} initialValue - preselected options flag
1304
+ */
1305
+ const loadOptionsByExternalLoader = (pattern, initialValue) => {
1306
+ externalOptionsLoader.value = options.value;
1307
+ options.value(pattern).then(options => {
1308
+ rawOptions.value = options;
1309
+ if (initialValue) setPreselectedOptionsByConditions();
1310
+ });
1311
+ };
1312
+
1313
+ /**
1314
+ * Makes removal of selected options based on external modelValue changes
1315
+ * @function
1316
+ * @param {boolean} single - "multiple" prop flag
1317
+ */
1318
+ const removeSelectedOptions = (single = false) => {
1319
+ if (!single) {
1320
+ const modelValueMapped = modelValue.value.map((option) => {
1321
+ return JSON.stringify(option);
1322
+ });
1323
+
1324
+ selectedOptions.value = selectedOptions.value.filter((option) => {
1325
+ return modelValueMapped.includes(JSON.stringify(option));
1326
+ });
1327
+ } else {
1328
+ if (!modelValue.value) cancel();
1329
+ }
1330
+ }
1331
+
1332
+ /**
1333
+ * Emits event whose listener resets index of "enter" key pressing
1334
+ * @function
1335
+ * @emits extended:reset-index
1336
+ */
1337
+ const resetEnterIndex = () => {
1338
+ emitter.value.emit("extended:reset-index");
1339
+ };
1340
+
1341
+ /**
1342
+ * Rolls up dropdown options list
1343
+ * @function
1344
+ * @emits extended:rollup-options
1345
+ */
1346
+ const rollUp = () => {
1347
+ dropdownActive.value = false;
1348
+ emitter.value.emit("extended:rollup-options");
1349
+ };
1350
+
1351
+ /**
1352
+ * Rolls up dropdown options lists of other instances
1353
+ * @function
1354
+ * @emits extended:rollup-instances
1355
+ */
1356
+ const rollupInstanses = () => {
1357
+ localEmitter.emit("extended:rollup-instances", extendedMultiselectWrapper.value);
1358
+ };
1359
+
1360
+ /**
1361
+ * Triggers selection of option by "enter" key pressing
1362
+ * @function
1363
+ * @emits extended:select-enter
1364
+ * @param {KeyboardEvent} keyboardEvent - KeyboardEvent instance
1365
+ */
1366
+ const selectByEnter = (keyboardEvent) => {
1367
+ emitter.value.emit("extended:select-enter", keyboardEvent);
1368
+ };
1369
+
1370
+ /**
1371
+ * Sets preselected option provided by "preselectedOption" prop
1372
+ * @function
1373
+ * @emits extended:select-option
1374
+ * @param {UnionPropType} preselectedOption - option to be selected
1375
+ * @param {boolean} restriction - restriction of preselected option
1376
+ */
1377
+ const setPreselectedOption = (preselectedOption, restriction = true) => {
1378
+ const availableOptionType = optionTypeRestrictor(preselectedOption);
1379
+ const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1380
+ return JSON.stringify(selectedOption);
1381
+ });
1382
+
1383
+ if (!availableOptionType) return;
1384
+ if (
1385
+ (!mappedOptions.value.includes(JSON.stringify(preselectedOption)) && restriction)
1386
+ && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1387
+ ) {
1388
+ if (showInsertWarnings.value) {
1389
+ console.warn("vue-extended-multiselect: option in «preselectedOption» property should be the same as analogue in «options» property");
1390
+ }
1391
+
1392
+ return;
1393
+ }
1394
+
1395
+ const isObjectOrArray = typeof preselectedOption === "object";
1396
+ const label = createLabel(isObjectOrArray, preselectedOption);
1397
+
1398
+ emitter.value.emit("extended:select-option", {
1399
+ label,
1400
+ option: preselectedOption,
1401
+ });
1402
+ };
1403
+
1404
+ /**
1405
+ * Sets preselected options provided by "preselectedOptions" prop
1406
+ * if "multiple" prop equals true
1407
+ * @function
1408
+ * @emits extended:select-option
1409
+ * @param {Array} preselectedOptions - options to be selected
1410
+ * @param {boolean} restriction - restriction of preselected options
1411
+ */
1412
+ const setPreselectedOptions = async (preselectedOptions, restriction = true) => {
1413
+ let allOptionsWereSelected = 0;
1414
+ const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1415
+ return JSON.stringify(selectedOption);
1416
+ });
1417
+
1418
+ preselectedOptions.forEach((preselectedOption) => {
1419
+ const availableOptionType = optionTypeRestrictor(preselectedOption);
1420
+
1421
+ if (!preselectedOption || !availableOptionType) return;
1422
+ if (selectedOptions.value.includes(preselectedOption)) return;
1423
+
1424
+ if (
1425
+ (mappedOptions.value.includes(JSON.stringify(preselectedOption)) || !restriction)
1426
+ && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1427
+ ) {
1428
+ const isObjectOrArray = typeof option === "object";
1429
+ const label = createLabel(isObjectOrArray, preselectedOption);
1430
+
1431
+ allOptionsWereSelected++;
1432
+
1433
+ emitter.value.emit("extended:select-option", {
1434
+ label,
1435
+ option: preselectedOption,
1436
+ });
1437
+ }
1438
+ });
1439
+
1440
+ if (allOptionsWereSelected !== preselectedOptions.length && showInsertWarnings.value) {
1441
+ console.warn("vue-extended-multiselect: options in «preselectedOptions» property should be the same as analogues in «options» property");
1442
+ }
1443
+ };
1444
+
1445
+ /**
1446
+ * Determines conditions that control preselected options installattion
1447
+ * if "modelValue" prop is defined
1448
+ * @function
1449
+ * @emits update:wrapper
1450
+ * @param {boolean} withRemoval - removal of selected options flag
1451
+ */
1452
+ const setPreselectedOptionsByModelValue = (withRemoval = false) => {
1453
+ if (!modelValue.value && !withRemoval) return;
1454
+
1455
+ if (withRemoval) selectedOptionsWatcher.value();
1456
+
1457
+ if (multiple.value) {
1458
+ if (withRemoval) removeSelectedOptions();
1459
+
1460
+ setPreselectedOptions(modelValue.value, false);
1461
+ } else {
1462
+ if (withRemoval) removeSelectedOptions(true);
1463
+
1464
+ setPreselectedOption(modelValue.value, false);
1465
+ }
1466
+
1467
+ if (withRemoval) {
1468
+ updateModelValue();
1469
+
1470
+ selectedOptionsWatcher.value = watch(selectedOptions, () => {
1471
+ updateModelValue();
1472
+
1473
+ if (resetSearchByValue.value) {
1474
+ emitter.value.emit("extended:clear-field");
1475
+ }
1476
+ }, { deep: true });
1477
+ }
1478
+ }
1479
+
1480
+ /**
1481
+ * Determines conditions that control preselected options installattion
1482
+ * by "preselectedOption" and "preselectedOptions" props
1483
+ * @function
1484
+ */
1485
+ const setPreselectedOptionsByConditions = () => {
1486
+ if (preselectedOption.value && !multiple.value) {
1487
+ setPreselectedOption(preselectedOption.value);
1488
+
1489
+ if (selectedOptions.value.length) {
1490
+ updateModelValue();
1491
+ }
1492
+ }
1493
+
1494
+ if (preselectedOptions.value && multiple.value) {
1495
+ const initialLength = selectedOptions.value.length;
1496
+
1497
+ setPreselectedOptions(preselectedOptions.value);
1498
+
1499
+ if (initialLength !== selectedOptions.value.length) {
1500
+ updateModelValue();
1501
+ }
1502
+ }
1503
+ };
1504
+
1505
+ /**
1506
+ * Defines a position of dropdown appearance
1507
+ * @function
1508
+ * @returns {string} position
1509
+ */
1510
+ const toggleAppearanceRestrictor = () => {
1511
+ if (!window) return "under";
1512
+
1513
+ const innerHeight = window.innerHeight;
1514
+ const offsetTop = extendedMultiselect.value
1515
+ ? extendedMultiselect.value.getBoundingClientRect().y
1516
+ : 0;
1517
+ const difference = innerHeight - offsetTop;
1518
+
1519
+ if (difference > toggleMaxHeight.value) {
1520
+ return "under";
1521
+ } else {
1522
+ return "atop";
1523
+ }
1524
+ };
1525
+
1526
+ /**
1527
+ * Sets a position of dropdown appearance
1528
+ * @function
1529
+ */
1530
+ const toggleAppearanceRestrictorActivate = () => {
1531
+ if (!dropdownActive.value) {
1532
+ chosenToggleAppearanceSide.value = toggleAppearanceSide.value !== "auto"
1533
+ ? toggleAppearanceSide.value
1534
+ : toggleAppearanceRestrictor();
1535
+ }
1536
+ };
1537
+
1538
+ /**
1539
+ * Restricts toggling of dropdown options list
1540
+ * @function
1541
+ * @emits extended:skip-block-blur
1542
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1543
+ * @returns {boolean} toggling
1544
+ */
1545
+ const toggleBlockRestrictor = (mouseEvent) => {
1546
+ let generalRestriction;
1547
+ let filteredCustomSelf;
1548
+ const filteredHasBlock = toggleDetector(mouseEvent, /^extended__multiselect-block/i, true);
1549
+ const filteredHasSlot = toggleDetector(mouseEvent, /^extended__multiselect-options(?!_option)/i, true)
1550
+ const filteredSelf = toggleDetector(mouseEvent, /^extended__multiselect-clear/i, true);
1551
+
1552
+ if (filteredSelf.length || filteredHasBlock.length || filteredHasSlot.length) {
1553
+ filteredCustomSelf = true;
1554
+ } else {
1555
+ filteredCustomSelf = toggleCustomRestrictor(mouseEvent);
1556
+ }
1557
+
1558
+ if (extendedMultiselectToggle.value) {
1559
+ generalRestriction = (filteredHasBlock.length && dropdownActive.value && filteredCustomSelf)
1560
+ || (filteredSelf.length && dropdownActive.value && filteredCustomSelf)
1561
+ || (filteredHasSlot.length && dropdownActive.value && filteredCustomSelf);
1562
+ } else {
1563
+ generalRestriction = (filteredHasBlock.length && dropdownActive.value)
1564
+ || (filteredSelf.length && dropdownActive.value)
1565
+ || (filteredHasSlot.length && dropdownActive.value);
1566
+ }
1567
+
1568
+ if (generalRestriction) {
1569
+ emitter.value.emit("extended:skip-block-blur");
1570
+ return true;
1571
+ }
1572
+
1573
+ return false;
1574
+ }
1575
+
1576
+ /**
1577
+ * Restricts toggling of dropdown options list by clicking
1578
+ * on particular descendants of toggle wrapper element
1579
+ * @function
1580
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1581
+ * @param {number} blockType - type of block which needs restriction
1582
+ * @returns {boolean} restriction
1583
+ */
1584
+ const toggleCustomRestrictor = (mouseEvent, blockType) => {
1585
+ let eventTarget = mouseEvent.target;
1586
+ const toggleWrapper = extendedMultiselect.value;
1587
+ const customToggle = toggleWrapper.children[blockType];
1588
+
1589
+ while(eventTarget) {
1590
+ if (eventTarget === customToggle) return true;
1591
+
1592
+ eventTarget = eventTarget.parentNode;
1593
+ }
1594
+
1595
+ return false;
1596
+ };
1597
+
1598
+ /**
1599
+ * Restricts toggling of dropdown options list by clicking
1600
+ * on particular elements defined by given pattern
1601
+ * @function
1602
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1603
+ * @param {string} pattern - pattern with block class partial name
1604
+ * @param {boolean} mode - marks whether restrict by parent element or by current target
1605
+ * @returns {Array} classes
1606
+ */
1607
+ const toggleDetector = (mouseEvent, pattern, mode) => {
1608
+ let target = mouseEvent.target;
1609
+
1610
+ let filteredHasToggle = Array.prototype.filter.call(target.classList, (className) => {
1611
+ return pattern.test(className) === true;
1612
+ });
1613
+
1614
+ while(
1615
+ target
1616
+ && (target.classList
1617
+ && !target.classList.contains("extended__multiselect-wrapper")
1618
+ || target.classList
1619
+ && !target.classList.length)
1620
+ && mode
1621
+ && !filteredHasToggle.length
1622
+ ) {
1623
+ filteredHasToggle = Array.prototype.filter.call(target.classList, (className) => {
1624
+ return pattern.test(className) === true;
1625
+ });
1626
+
1627
+ if (target.classList.contains("extended__multiselect-options_container")) {
1628
+ filteredHasToggle.push("extended__multiselect-options_container");
1629
+ return filteredHasToggle;
1630
+ }
1631
+
1632
+ if (target.classList.contains("extended__multiselect-toggle_wrapper")) {
1633
+ filteredHasToggle.push("extended__multiselect-toggle_wrapper");
1634
+ return filteredHasToggle;
1635
+ }
1636
+
1637
+ target = target.parentNode;
1638
+ }
1639
+
1640
+ return filteredHasToggle;
1641
+ };
1642
+
1643
+ /**
1644
+ * Toggles dropdown options list and activates
1645
+ * necessary methods with relevant events
1646
+ * @function
1647
+ */
1648
+ const toggleOptions = () => {
1649
+ if (internalLoading.value || disabled.value || dropdownDisabled.value) return;
1650
+
1651
+ toggleAppearanceRestrictorActivate();
1652
+
1653
+ if (!dropdownActive.value) {
1654
+ activeEmitter();
1655
+ } else {
1656
+ closeEmitter();
1657
+ }
1658
+
1659
+ dropdownActive.value = !dropdownActive.value;
1660
+ };
1661
+
1662
+ /**
1663
+ * Prevents toggling dropdown options list
1664
+ * by selecting/deselecting option
1665
+ * @function
1666
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1667
+ * @returns {boolean} restriction
1668
+ */
1669
+ const toggleOptionsRestrictor = (mouseEvent) => {
1670
+ try {
1671
+ let eventTarget = mouseEvent.target;
1672
+ const optionsWrapper = optionsWrapper.value;
1673
+
1674
+ while(eventTarget) {
1675
+ if (eventTarget === optionsWrapper) return true;
1676
+
1677
+ eventTarget = eventTarget.parentNode;
1678
+ }
1679
+
1680
+ return false;
1681
+ } catch(e) {
1682
+ return false;
1683
+ }
1684
+ };
1685
+
1686
+ /**
1687
+ * Collects restrictions from other methods and defines
1688
+ * general restriction of toggling dropdown options list
1689
+ * @function
1690
+ * @emits extended:skip-blur
1691
+ * @param {MouseEvent} mouseEvent - MouseEvent instance
1692
+ */
1693
+ const toggleRestrictor = (mouseEvent) => {
1694
+ rollupInstanses();
1695
+
1696
+ const targetContentBlock = toggleBlockRestrictor(mouseEvent);
1697
+
1698
+ if (targetContentBlock) return;
1699
+
1700
+ const filteredHasToggle = toggleDetector(mouseEvent, togglePattern);
1701
+
1702
+ if (filteredHasToggle.length && dropdownActive.value) {
1703
+
1704
+ emitter.value.emit("extended:skip-blur");
1705
+ }
1706
+ };
1707
+
1708
+ /**
1709
+ * Triggers modelValue updating when v-model has
1710
+ * been changed programmatically
1711
+ * @function
1712
+ * @emits update:modelValue
1713
+ */
1714
+ const updateModelValue = () => {
1715
+ if (multiple.value) {
1716
+ emit("update:modelValue", selectedOptions.value);
1717
+ } else {
1718
+ emit("update:modelValue", selectedOptions.value[0]);
1719
+ }
1720
+ }
1721
+
1722
+ /**
1723
+ * "onBeforeMount" hook of the Vue3ExtendedMultiselect component
1724
+ * @emits select
1725
+ * @emits clean
1726
+ * @emits option-created
1727
+ * @emits increase
1728
+ * @emits pattern-changed
1729
+ * @emits extended:rollup-options
1730
+ * @listens extended:rollup-options
1731
+ * @listens extended:toggle-options
1732
+ * @listens extended:select-option
1733
+ * @listens extended:deselect-option
1734
+ * @listens extended:create-option
1735
+ * @listens extended:increase-display
1736
+ * @listens extended:loader-pattern-changed
1737
+ * @listens extended:search-pattern-changed
1738
+ */
1739
+ onBeforeMount(() => {
1740
+ selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
1741
+ updateModelValue();
1742
+
1743
+ if (resetSearchByValue.value) {
1744
+ emitter.value.emit("extended:clear-field");
1745
+ }
1746
+ }, { deep: true });
1747
+
1748
+ chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
1749
+
1750
+ emitter.value.on("extended:rollup-options", () => {
1751
+ if (!dropdownActive.value) return;
1752
+
1753
+ closeEmitter();
1754
+ dropdownActive.value = false;
1755
+ });
1756
+
1757
+ emitter.value.on("extended:toggle-options", () => {
1758
+ toggleOptions();
1759
+ });
1760
+
1761
+ emitter.value.on("extended:select-option", (option) => {
1762
+ const eventData = simpleEvents.value
1763
+ ? option.option
1764
+ : createEventFields(option.option, "option");
1765
+
1766
+ if (multiple.value) {
1767
+ selectedOptions.value.push(option.option);
1768
+ /**
1769
+ * @event select
1770
+ * @type {Object}
1771
+ * @property {string} inputId - id of search field set by "id" prop
1772
+ * @property {UnionPropType} option - just now selected option
1773
+ */
1774
+ emit("select", eventData);
1775
+ } else {
1776
+ selectedOptions.value = [option.option];
1777
+ /**
1778
+ * @see select
1779
+ */
1780
+ emit("select", eventData);
1781
+ }
1782
+
1783
+ updateModelValue();
1784
+ });
1785
+
1786
+ emitter.value.on("extended:deselect-option", (payload) => {
1787
+ if (multiple.value && (payload && !payload.clearAll)) {
1788
+ const deselectedOption = selectedOptions.value[payload.index];
1789
+
1790
+ const eventData = simpleEvents.value
1791
+ ? deselectedOption
1792
+ : createEventFields(deselectedOption, "option");
1793
+
1794
+ /**
1795
+ * @event clean
1796
+ * @type {Object}
1797
+ * @property {string} inputId - id of search field set by "id" prop
1798
+ * @property {UnionPropType} option - just now deselected option
1799
+ */
1800
+ emit("clean", eventData);
1801
+
1802
+ if (payload.skipNextRemoval) {
1803
+ skipNextRemoval.value = true;
1804
+ }
1805
+
1806
+ selectedOptions.value.splice(payload.index, 1);
1807
+ updateModelValue();
1808
+
1809
+ return;
1810
+ } else {
1811
+ if (!selectedOptions.value.length) return;
1812
+
1813
+ const deselectedOption = payload.deselectedOptions
1814
+ ? payload.deselectedOptions
1815
+ : selectedOptions.value;
1816
+
1817
+ const eventData = simpleEvents.value
1818
+ ? deselectedOption
1819
+ : createEventFields(deselectedOption, "option");
1820
+
1821
+ /**
1822
+ * @event clean
1823
+ * @type {Object}
1824
+ * @property {string} inputId - id of search field set by "id" prop
1825
+ * @property {UnionPropType} options - just now deselected options
1826
+ */
1827
+ emit("clean", eventData);
1828
+
1829
+ selectedOptions.value = [];
1830
+ updateModelValue();
1831
+ }
1832
+
1833
+ if (toggleOptionsBySelect.value) {
1834
+ emitter.value.emit("extended:rollup-options");
1835
+ }
1836
+ });
1837
+
1838
+ emitter.value.on("extended:create-option", (createdOption) => {
1839
+ const eventData = simpleEvents.value
1840
+ ? createdOption
1841
+ : createEventFields(createdOption, "option");
1842
+
1843
+ /**
1844
+ * @event option-created
1845
+ * @type {PluginObject}
1846
+ * @property {string} inputId - id of search field set by "id" prop
1847
+ * @property {UnionPropType} option - option created by user
1848
+ */
1849
+ emit("option-created", eventData);
1850
+ });
1851
+
1852
+ emitter.value.on("extended:increase-display", (limit) => {
1853
+ const eventData = simpleEvents.value ? limit : createEventFields(limit, "limit");
1854
+
1855
+ /**
1856
+ * @event increase
1857
+ * @type {Object}
1858
+ * @property {string} inputId - id of search field set by "id" prop
1859
+ * @property {limit} - current limit of options to be shown next
1860
+ */
1861
+ emit("increase", eventData);
1862
+ });
1863
+
1864
+ emitter.value.on("extended:loader-pattern-changed", (pattern) => {
1865
+ const eventData = simpleEvents.value
1866
+ ? pattern
1867
+ : createEventFields(pattern, "pattern");
1868
+
1869
+ /**
1870
+ * @event pattern-changed
1871
+ * @type {Object}
1872
+ * @property {string} inputId - id of search field set by "id" prop
1873
+ * @property {pattern} - pattern of internal search for available options
1874
+ */
1875
+ emit("pattern-changed", eventData);
1876
+ });
1877
+
1878
+ emitter.value.on("extended:search-pattern-changed", (pattern) => {
1879
+ const eventData = simpleEvents.value
1880
+ ? pattern
1881
+ : createEventFields(pattern, "pattern");
1882
+
1883
+ /**
1884
+ * @event pattern-changed
1885
+ * @type {Object}
1886
+ * @property {string} inputId - id of search field set by "id" prop
1887
+ * @property {pattern} - pattern of internal search for available options
1888
+ */
1889
+ emit("pattern-changed", eventData);
1890
+ });
1891
+ });
1892
+
1893
+ /**
1894
+ * "onMounted" hook of the Vue3ExtendedMultiselect component
1895
+ * @listens extended:expand-options
1896
+ * @listens extended:rollup-instances
1897
+ * @listens extended:loader-pattern-changed
1898
+ */
1899
+ onMounted(() => {
1900
+ if (typeof options.value === "function") {
1901
+ loadOptionsByExternalLoader(null, true);
1902
+ } else {
1903
+ rawOptions.value = options.value;
1904
+ setPreselectedOptionsByConditions();
1905
+ }
1906
+
1907
+ setPreselectedOptionsByModelValue();
1908
+
1909
+ if (
1910
+ defaultExpanded.value
1911
+ && !disabled.value
1912
+ && typeof options.value !== "function"
1913
+ ) {
1914
+ dropdownActive.value = true;
1915
+ }
1916
+
1917
+ emitter.value.on("extended:expand-options", () => {
1918
+ if (dropdownActive.value || dropdownDisabled.value) return;
1919
+
1920
+ toggleAppearanceRestrictorActivate();
1921
+ activeEmitter();
1922
+
1923
+ dropdownActive.value = true;
1924
+ });
1925
+
1926
+ emitter.value.on("extended:loader-pattern-changed", async (pattern) => {
1927
+ await loadOptionsByExternalLoader(pattern, false);
1928
+ });
1929
+
1930
+ clickOutside.value.init(extendedMultiselectWrapper.value, () => {
1931
+ emitter.value.emit("extended:rollup-options");
1932
+ });
1933
+
1934
+ localEmitter.on("extended:rollup-instances", (instanceRef) => {
1935
+ if (instanceRef !== extendedMultiselectWrapper.value) {
1936
+ emitter.value.emit("extended:rollup-options");
1937
+ }
1938
+ });
1939
+ });
1940
+
1941
+ defineExpose({
1942
+ optionCreateLabel,
1943
+ });
1944
+ </script>
1945
+
1946
+ <style>
1947
+ .extended__multiselect-wrapper,
1948
+ .extended__multiselect-wrapper--disabled {
1949
+ --basic-color: #708090;
1950
+ --basic-transparent: rgba(112, 128, 144, 0.6);
1951
+ --cancel: #B22222;
1952
+ --cancel-backgound-color: rgba(179, 33, 33, 0.1);
1953
+ --dark-slate-blue: #483D8B;
1954
+ --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
1955
+ --dark-slate-grey: #2F4F4F;
1956
+ --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
1957
+ --disabled: rgba(176, 176, 176, 0.6);
1958
+ --hover-color: #FFFFFF;
1959
+ --loader-color: #00BFFF;
1960
+ --placeholder: #808080;
1961
+ --strict: #000000;
1962
+ --strict-transparent: rgba(0, 0, 0, 0.6);
1963
+ --teal: #008080;
1964
+ --teal-transparent: rgba(0, 128, 128, 0.6);
1965
+
1966
+ --block-border-radius: 4px;
1967
+ --block-cancel-padding: 4px;
1968
+ --block-gap: 6px;
1969
+ --block-padding: 1px 3px 1px 7px;
1970
+ --border-radius: 6px;
1971
+ --border-radius-small: 3px;
1972
+ --cancel-padding: 3px 8px;
1973
+ --grid-columns: 1fr 36px 36px;
1974
+ --grid-rows: 1fr 36px;
1975
+ --half-size: 50%;
1976
+ --icon-size-block: 14px;
1977
+ --icon-size-large: 18px;
1978
+ --icon-size-medium: 15px;
1979
+ --icon-size-small: 12px;
1980
+ --increaser-padding: 3px 7px;
1981
+ --max-size: 100%;
1982
+ --min-block-height: 26px;
1983
+ --options-padding: 6px 0;
1984
+ --outer-gap: 10px;
1985
+ --root-padding: 6px 10px;
1986
+ --toggle-icon-gap: 1px;
1987
+ --wide-text: 700;
1988
+ --wrapper-padding: 5px 10px;
1989
+ --z-index-options: 10;
1990
+
1991
+ --border: 1px solid;
1992
+ --default-cursor: default;
1993
+ --icons-align-self: start;
1994
+ --icons-justify-self: center;
1995
+ --pointer-cursor: pointer;
1996
+ --wrapper-transition: border-top-left-radius 250ms ease 0s, border-top-right-radius 250ms ease 0s,
1997
+ border-bottom-left-radius 250ms ease-out, border-bottom-right-radius 250ms ease-out;
1998
+ }
1999
+
2000
+ .extended-toggle-enter-active,
2001
+ .extended-toggle-leave-active {
2002
+ transition: opacity 250ms;
2003
+ }
2004
+
2005
+ .extended-toggle-enter,
2006
+ .extended-toggle-leave-to {
2007
+ opacity: 0;
2008
+ }
2009
+
2010
+ @keyframes loading {
2011
+ 0% {
2012
+ transform: rotate(0deg);
2013
+ }
2014
+ 100% {
2015
+ transform: rotate(2turn);
2016
+ }
2017
+ }
2018
+
2019
+ .extended__multiselect-wrapper,
2020
+ .extended__multiselect-wrapper--disabled {
2021
+ position: relative;
2022
+ width: var(--max-size);
2023
+ height: var(--max-size);
2024
+ cursor: var(--pointer-cursor);
2025
+ }
2026
+
2027
+ .extended__multiselect-wrapper *,
2028
+ .extended__multiselect-wrapper--disabled * {
2029
+ box-sizing: border-box;
2030
+ font-family: inherit;
2031
+ font-size: inherit;
2032
+ font-style: inherit;
2033
+ }
2034
+
2035
+ .extended__multiselect-wrapper--disabled .extended__multiselect-container {
2036
+ background-color: var(--disabled);
2037
+ user-select: none;
2038
+ cursor: var(--default-cursor);
2039
+ }
2040
+
2041
+ .extended__multiselect-wrapper--disabled .extended__multiselect-input,
2042
+ .extended__multiselect-wrapper--disabled .extended__multiselect-input--hidden {
2043
+ cursor: --default-cursor;
2044
+ }
2045
+
2046
+ .extended__multiselect-container {
2047
+ align-items: center;
2048
+ transition: var(--wrapper-transition);
2049
+ }
2050
+
2051
+ .extended__multiselect,
2052
+ .extended__multiselect-slate-grey,
2053
+ .extended__multiselect-slate-blue,
2054
+ .extended__multiselect-teal,
2055
+ .extended__multiselect-strict {
2056
+ border: var(--border);
2057
+ border-radius: var(--border-radius);
2058
+ display: grid;
2059
+ padding: var(--wrapper-padding);
2060
+ width: var(--max-size);
2061
+ }
2062
+
2063
+ .extended__multiselect,
2064
+ .extended__multiselect .extended__multiselect-increaser:active {
2065
+ border-color: var(--basic-color);
2066
+ }
2067
+
2068
+ .extended__multiselect .extended__multiselect-increaser:active {
2069
+ border-color: var(--basic-color);
2070
+ }
2071
+
2072
+ .extended__multiselect-slate-grey,
2073
+ .extended__multiselect-slate-grey .extended__multiselect-increaser:active {
2074
+ border-color: var(--dark-slate-grey);
2075
+ }
2076
+
2077
+ .extended__multiselect-slate-blue,
2078
+ .extended__multiselect-slate-blue .extended__multiselect-increaser:active {
2079
+ border-color: var(--dark-slate-blue);
2080
+ }
2081
+
2082
+ .extended__multiselect-teal,
2083
+ .extended__multiselect-teal .extended__multiselect-increaser:active {
2084
+ border-color: var(--teal);
2085
+ }
2086
+
2087
+ .extended__multiselect-strict,
2088
+ .extended__multiselect-strict .extended__multiselect-increaser:active {
2089
+ border-color: var(--strict);
2090
+ }
2091
+
2092
+ .extended__multiselect-options,
2093
+ .extended__multiselect-options-slate-grey,
2094
+ .extended__multiselect-options-slate-blue,
2095
+ .extended__multiselect-options-teal,
2096
+ .extended__multiselect-options-strict {
2097
+ display: flex;
2098
+ flex-flow: column nowrap;
2099
+ position: absolute;
2100
+ cursor: var(--pointer-cursor);
2101
+ border: var(--border);
2102
+ color: inherit;
2103
+ user-select: none;
2104
+ border-top-right-radius: 0;
2105
+ border-top-left-radius: 0;
2106
+ z-index: var(--z-index-options);
2107
+ border-bottom-right-radius: var(--border-radius);
2108
+ border-bottom-left-radius: var(--border-radius);
2109
+ width: var(--max-size);
2110
+ overflow: auto;
2111
+ border-top: none;
2112
+ top: var(--max-size);
2113
+ -webkit-overflow-scrolling: touch;
2114
+ }
2115
+
2116
+ .extended__multiselect-options > *:not([class^=extended__multiselect-options_option]):not([class=extended__multiselect-options_container]),
2117
+ .extended__multiselect-options-slate-grey > *:not([class^=extended__multiselect-options_option]):not([class=extended__multiselect-options_container]),
2118
+ .extended__multiselect-options-slate-blue > *:not([class^=extended__multiselect-options_option]):not([class=extended__multiselect-options_container]),
2119
+ .extended__multiselect-options-teal > *:not([class^=extended__multiselect-options_option]):not([class=extended__multiselect-options_container]),
2120
+ .extended__multiselect-options-strict > *:not([class^=extended__multiselect-options_option]):not([class=extended__multiselect-options_container]) {
2121
+ padding: var(--root-padding);
2122
+ }
2123
+
2124
+ .extended__multiselect-options--atop {
2125
+ border-top-right-radius: var(--border-radius);
2126
+ border-top-left-radius: var(--border-radius);
2127
+ border-bottom-right-radius: 0;
2128
+ border-bottom-left-radius: 0;
2129
+ border-top: var(--border);
2130
+ }
2131
+
2132
+ .extended__multiselect-clear--active {
2133
+ grid-template-columns: var(--grid-columns);
2134
+ }
2135
+
2136
+ .extended__multiselect-clear--locked {
2137
+ grid-template-columns: var(--grid-rows);
2138
+ }
2139
+
2140
+ .extended__multiselect,
2141
+ .extended__multiselect-options {
2142
+ border-color: var(--basic-color);
2143
+ }
2144
+
2145
+ .extended__multiselect-slate-grey,
2146
+ .extended__multiselect-options-slate-grey {
2147
+ border-color: var(--dark-slate-grey);
2148
+ }
2149
+
2150
+ .extended__multiselect-slate-blue,
2151
+ .extended__multiselect-options-slate-blue {
2152
+ border-color: var(--dark-slate-blue);
2153
+ }
2154
+
2155
+ .extended__multiselect-teal,
2156
+ .extended__multiselect-options-teal {
2157
+ border-color: var(--teal);
2158
+ }
2159
+
2160
+ .extended__multiselect-strict,
2161
+ .extended__multiselect-options-strict {
2162
+ border-color: var(--strict);
2163
+ }
2164
+
2165
+ .extended__multiselect-input,
2166
+ .extended__multiselect-block {
2167
+ min-height: var(--min-block-height);
2168
+ width: var(--max-size);
2169
+ border: none;
2170
+ outline: none;
2171
+ }
2172
+
2173
+ .extended__multiselect-block > span {
2174
+ word-break: break-all;
2175
+ white-space: pre-line;
2176
+ }
2177
+
2178
+ .extended__multiselect-input {
2179
+ cursor: text;
2180
+ color: inherit;
2181
+ }
2182
+
2183
+ .extended__multiselect-input:focus::placeholder {
2184
+ color: var(--strict);
2185
+ font-weight: var(--wide-text);
2186
+ }
2187
+
2188
+ .extended__multiselect-input--trigger-option::placeholder {
2189
+ color: var(--strict);
2190
+ font-weight: var(--wide-text);
2191
+ }
2192
+
2193
+ .extended__multiselect-block {
2194
+ display: flex;
2195
+ flex-flow: row nowrap;
2196
+ align-items: center;
2197
+ user-select: none;
2198
+ color: inherit;
2199
+ }
2200
+
2201
+ .extended__multiselect-input--hidden {
2202
+ position: absolute;
2203
+ cursor: var(--pointer-cursor);
2204
+ border: none;
2205
+ width: 0;
2206
+ height: 0;
2207
+ opacity: 0;
2208
+ padding: 0;
2209
+ }
2210
+
2211
+ .extended__multiselect-toggle,
2212
+ .extended__multiselect-toggle--disabled,
2213
+ .extended__multiselect-cancel,
2214
+ .extended__multiselect-cancel--disabled,
2215
+ .extended__multiselect-loader {
2216
+ display: flex;
2217
+ flex-flow: row nowrap;
2218
+ align-items: center;
2219
+ justify-content: center;
2220
+ user-select: none;
2221
+ }
2222
+
2223
+ .extended__multiselect-toggle--active {
2224
+ transform-origin: 50% 50%;
2225
+ transition: transform 0.2s ease-out;
2226
+ transform: rotate(180deg);
2227
+ }
2228
+
2229
+ .extended__multiselect-toggle--locked {
2230
+ transform-origin: 50% 50%;
2231
+ transition: transform 0.2s ease-out;
2232
+ transform: rotate(0deg);
2233
+ }
2234
+
2235
+ .extended__multiselect-toggle_wrapper,
2236
+ .extended__multiselect-cancel_wrapper {
2237
+ align-self: var(--icons-align-self);
2238
+ justify-self: var(--icons-justify-self);
2239
+ cursor: var(--pointer-cursor);
2240
+ }
2241
+
2242
+ .extended__multiselect-toggle {
2243
+ margin-top: var(--toggle-icon-gap);
2244
+ }
2245
+
2246
+ .extended__multiselect-toggle,
2247
+ .extended__multiselect-toggle--disabled {
2248
+ padding: var(--cancel-padding);
2249
+ }
2250
+
2251
+ .extended__multiselect-toggle_icon-large,
2252
+ .extended__multiselect-toggle--disabled_icon-large,
2253
+ .extended__multiselect-cancel_icon-large,
2254
+ .extended__multiselect-cancel--disabled_icon-large,
2255
+ .extended__multiselect-loader_icon-large {
2256
+ width: var(--icon-size-large);
2257
+ height: var(--icon-size-large);
2258
+ }
2259
+
2260
+ .extended__multiselect-toggle_icon-medium,
2261
+ .extended__multiselect-toggle--disabled_icon-medium,
2262
+ .extended__multiselect-cancel_icon-medium,
2263
+ .extended__multiselect-cancel--disabled_icon-medium,
2264
+ .extended__multiselect-loader_icon-medium {
2265
+ width: var(--icon-size-medium);
2266
+ height: var(--icon-size-medium);
2267
+ }
2268
+
2269
+ .extended__multiselect-toggle_icon-small,
2270
+ .extended__multiselect-toggle--disabled_icon-small,
2271
+ .extended__multiselect-cancel_icon-small,
2272
+ .extended__multiselect-cancel--disabled_icon-small,
2273
+ .extended__multiselect-loader_icon-small {
2274
+ width: var(--icon-size-small);
2275
+ height: var(--icon-size-small);
2276
+ }
2277
+
2278
+ .extended__multiselect-toggle_icon-deselect,
2279
+ .extended__multiselect-toggle--disabled_icon-deselect,
2280
+ .extended__multiselect-cancel_icon-deselect,
2281
+ .extended__multiselect-cancel--disabled_icon-deselect,
2282
+ .extended__multiselect-loader_icon-deselect {
2283
+ width: var(--icon-size-block);
2284
+ height: var(--icon-size-block);
2285
+ }
2286
+
2287
+ .extended__multiselect-cancel,
2288
+ .extended__multiselect-cancel--disabled {
2289
+ border: var(--border);
2290
+ border-color: transparent;
2291
+ display: flex;
2292
+ flex-flow: row nowrap;
2293
+ align-items: center;
2294
+ padding: var(--cancel-padding);
2295
+ }
2296
+
2297
+ .extended__multiselect-cancel:active {
2298
+ border-color: var(--cancel);
2299
+ border-radius: var(--border-radius-small);
2300
+ background-color: var(--cancel-backgound-color);
2301
+ }
2302
+
2303
+ .extended__multiselect-filter_basic {
2304
+ filter: url(#basicFilter);
2305
+ }
2306
+
2307
+ .extended__multiselect-filter_black {
2308
+ filter: url(#blackFilter);
2309
+ }
2310
+
2311
+ .extended__multiselect-filter_green {
2312
+ filter: url(#greenFilter);
2313
+ }
2314
+
2315
+ .extended__multiselect-loader_default-loader {
2316
+ filter: url(#filterLoaderDefault);
2317
+ }
2318
+
2319
+ .extended__multiselect-loader_basic {
2320
+ filter: url(#filterLoaderBasic);
2321
+ }
2322
+
2323
+ .extended__multiselect-loader_slate-grey {
2324
+ filter: url(#filterLoaderSlateGrey);
2325
+ }
2326
+
2327
+ .extended__multiselect-loader_slate-blue {
2328
+ filter: url(#filterLoaderSlateBlue);
2329
+ }
2330
+
2331
+ .extended__multiselect-loader_teal {
2332
+ filter: url(#filterLoaderTeal);
2333
+ }
2334
+
2335
+ .extended__multiselect-loader_strict {
2336
+ filter: url(#filterLoaderStrict);
2337
+ }
2338
+
2339
+ .extended__multiselect-loader-animate {
2340
+ animation-name: loading;
2341
+ animation-duration: 3s;
2342
+ animation-timing-function: linear;
2343
+ animation-iteration-count: infinite;
2344
+ }
2345
+
2346
+ .extended__multiselect-options_container {
2347
+ display: flex;
2348
+ flex-flow: column nowrap;
2349
+ }
2350
+
2351
+ .extended__multiselect-options_option,
2352
+ .extended__multiselect-options_option-slate-grey,
2353
+ .extended__multiselect-options_option-slate-blue,
2354
+ .extended__multiselect-options_option-teal,
2355
+ .extended__multiselect-options_option-strict {
2356
+ display: flex;
2357
+ flex-flow: row nowrap;
2358
+ align-items: center;
2359
+ padding: var(--root-padding);
2360
+ color: inherit;
2361
+ }
2362
+
2363
+ .extended__multiselect--multiple-basic,
2364
+ .extended__multiselect--multiple-slate-grey,
2365
+ .extended__multiselect--multiple-slate-blue,
2366
+ .extended__multiselect--multiple-teal,
2367
+ .extended__multiselect--multiple-strict {
2368
+ display: flex;
2369
+ flex-flow: row nowrap;
2370
+ align-items: center;
2371
+ border-radius: var(--block-border-radius);
2372
+ padding: var(--block-padding);
2373
+ gap: var(--block-gap);
2374
+ min-height: var(--min-block-height);
2375
+ }
2376
+
2377
+ .extended__multiselect-options_option:hover,
2378
+ .extended__multiselect--multiple-basic {
2379
+ background-color: var(--basic-transparent);
2380
+ color: var(--hover-color);
2381
+ }
2382
+
2383
+ .extended__multiselect-options_option-slate-grey:hover,
2384
+ .extended__multiselect--multiple-slate-grey {
2385
+ background-color: var(--dark-slate-grey-transparent);
2386
+ color: var(--hover-color);
2387
+ }
2388
+
2389
+ .extended__multiselect-options_option-slate-blue:hover,
2390
+ .extended__multiselect--multiple-slate-blue {
2391
+ background-color: var(--dark-slate-blue-transparent);
2392
+ color: var(--hover-color);
2393
+ }
2394
+
2395
+ .extended__multiselect-options_option-teal:hover,
2396
+ .extended__multiselect--multiple-teal {
2397
+ background-color: var(--teal-transparent);
2398
+ color: var(--hover-color);
2399
+ }
2400
+
2401
+ .extended__multiselect-options_option-strict:hover,
2402
+ .extended__multiselect--multiple-strict {
2403
+ background-color: var(--strict-transparent);
2404
+ color: var(--hover-color);
2405
+ }
2406
+
2407
+ .extended__multiselect-marker-shape {
2408
+ width: var(--icon-size-block);
2409
+ height: var(--icon-size-block);
2410
+ margin-right: var(--block-gap);
2411
+ border-radius: var(--half-size);
2412
+ border: var(--border);
2413
+ border-color: var(--basic-color);
2414
+ }
2415
+
2416
+ .extended__multiselect-marker-shape--selected {
2417
+ border-color: var(--cancel);
2418
+ }
2419
+
2420
+ .extended__multiselect-marker-shape-only {
2421
+ width: var(--icon-size-block);
2422
+ height: var(--icon-size-block);
2423
+ margin-left: var(--block-gap);
2424
+ border: var(--border);
2425
+ border-color: transparent;
2426
+ }
2427
+
2428
+ .extended__multiselect-container + .extended__multiselect-options--marker > span:not([id^=option-label]),
2429
+ .extended__multiselect-container + .extended__multiselect-options--marker > .extended__multiselect-option-create {
2430
+ padding-left: 30px;
2431
+ }
2432
+
2433
+ .extended__multiselect-options_option--disabled {
2434
+ background-color: var(--disabled);
2435
+ user-select: none;
2436
+ cursor: --default-cursor;
2437
+ }
2438
+
2439
+ .extended__multiselect_deselect-block-icon {
2440
+ width: var(--icon-size-block);
2441
+ height: var(--icon-size-block);
2442
+ }
2443
+
2444
+ .extended__multiselect-block--multiple > div {
2445
+ display: flex;
2446
+ flex-flow: row wrap;
2447
+ gap: var(--outer-gap);
2448
+ }
2449
+
2450
+ .extended__multiselect-block_cancel-wrapper,
2451
+ .extended__multiselect-block_cancel-wrapper--loading {
2452
+ border: var(--border);
2453
+ border-color: transparent;
2454
+ display: flex;
2455
+ flex-flow: row nowrap;
2456
+ align-items: center;
2457
+ padding: var(--block-cancel-padding);
2458
+ }
2459
+
2460
+ .extended__multiselect-block_cancel-wrapper:active {
2461
+ border-color: var(--cancel);
2462
+ border-radius: var(--border-radius-small);
2463
+ background-color: var(--cancel-backgound-color);
2464
+ }
2465
+
2466
+ .extended__multiselect-increaser {
2467
+ border: var(--border);
2468
+ border-color: transparent;
2469
+ padding: var(--increaser-padding);
2470
+ }
2471
+
2472
+ .extended__multiselect-placeholder {
2473
+ color: var(--placeholder);
2474
+ margin-left: 2px;
2475
+ }
1950
2476
  </style>