vue3-extended-multiselect 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Vue3ExtendedMultiselect.cjs.js +5295 -0
- package/dist/Vue3ExtendedMultiselect.cjs.js.map +1 -0
- package/dist/Vue3ExtendedMultiselect.esm.js +5290 -0
- package/dist/Vue3ExtendedMultiselect.esm.js.map +1 -0
- package/dist/types/index.d.ts +46 -0
- package/package.json +5 -1
- package/.browserslistrc +0 -3
- package/.eslintrc.js +0 -36
- package/.github/workflows/publish.yml +0 -41
- package/.nvmrc +0 -0
- package/CHANGELOG.md +0 -411
- package/CONTRIBUTING.md +0 -57
- package/babel.config.js +0 -10
- package/index.js +0 -3
- package/jest.config.js +0 -62
- package/rollup.config.mjs +0 -74
- package/src/components/ExtendedMultiselectCancel.vue +0 -165
- package/src/components/ExtendedMultiselectInput.vue +0 -742
- package/src/components/ExtendedMultiselectLoader.vue +0 -182
- package/src/components/ExtendedMultiselectMultiple.vue +0 -400
- package/src/components/ExtendedMultiselectOptions.vue +0 -1191
- package/src/components/ExtendedMultiselectToggle.vue +0 -272
- package/src/components/Vue3ExtendedMultiselect.vue +0 -2476
- package/src/composition/cancel.js +0 -40
- package/src/composition/click-outside.js +0 -9
- package/src/composition/debounce.js +0 -9
- package/src/composition/emitter.js +0 -9
- package/src/composition/image-path.js +0 -17
- package/src/composition/labels.js +0 -42
- package/src/composition/preselected-options.js +0 -68
- package/src/composition/search-value.js +0 -34
- package/src/composition/sizes.js +0 -45
- package/src/composition/toggle.js +0 -32
- package/src/sets/sets.js +0 -100
- package/src/styles/animations.css +0 -19
- package/src/styles/main.css +0 -460
- package/src/styles/variables.css +0 -52
- package/src/tools/Debounce.js +0 -26
- package/src/tools/LocalEmitter.js +0 -32
- package/src/tools/instance.js +0 -3
- package/tests/unit/events.spec.js +0 -150
- package/tests/unit/props.spec.js +0 -1155
- package/tests/unit/tools.spec.js +0 -56
- package/tests/utils/mocks.js +0 -1
- package/tests/utils/mount.js +0 -38
- package/tests/utils/stubs.js +0 -1
- package/tests/utils/utils.js +0 -25
- package/typings/vue3-extended-multiselect.d.ts +0 -44
- /package/{src → dist}/assets/images/base-arrow.svg +0 -0
- /package/{src → dist}/assets/images/cancel.svg +0 -0
- /package/{src → dist}/assets/images/circle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/double-arrow.svg +0 -0
- /package/{src → dist}/assets/images/inner-arrow.svg +0 -0
- /package/{src → dist}/assets/images/loader.svg +0 -0
- /package/{src → dist}/assets/images/triangle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/triangle-circle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/wide-arrow.svg +0 -0
|
@@ -1,742 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div v-if="showSearchField">
|
|
3
|
-
<input
|
|
4
|
-
aria-controls="extended-search-field"
|
|
5
|
-
ref="extendedInput"
|
|
6
|
-
type="text"
|
|
7
|
-
:accesskey="attrs.accesskey"
|
|
8
|
-
:autocomplete="attrs.autocomplete"
|
|
9
|
-
:class="searchFieldClass"
|
|
10
|
-
:disabled="disabled"
|
|
11
|
-
:id="inputId"
|
|
12
|
-
:name="attrs.name"
|
|
13
|
-
:placeholder="appropriatePlaceholder"
|
|
14
|
-
:spellcheck="attrs.spellcheck"
|
|
15
|
-
:tabindex="attrs.tabindex"
|
|
16
|
-
:translate="attrs.translate"
|
|
17
|
-
v-model="searchValue"
|
|
18
|
-
@blur.prevent="rollUp"
|
|
19
|
-
@focus.prevent="expand"
|
|
20
|
-
@input="search"
|
|
21
|
-
/>
|
|
22
|
-
<div
|
|
23
|
-
class="extended__multiselect-block"
|
|
24
|
-
v-show="!searchFieldForwarding && !multiple && !placeholderBlockShown"
|
|
25
|
-
@click="expand"
|
|
26
|
-
>
|
|
27
|
-
<slot
|
|
28
|
-
name="labelBlock"
|
|
29
|
-
:label-block-value="singleLabel"
|
|
30
|
-
>
|
|
31
|
-
<span>{{ singleLabel }}</span>
|
|
32
|
-
</slot>
|
|
33
|
-
</div>
|
|
34
|
-
<span
|
|
35
|
-
v-if="placeholderBlockShown"
|
|
36
|
-
class="extended__multiselect-placeholder"
|
|
37
|
-
>
|
|
38
|
-
{{ appropriatePlaceholder }}
|
|
39
|
-
</span>
|
|
40
|
-
<extended-multiselect-multiple
|
|
41
|
-
v-show="multiple && !!selectedOptions.length"
|
|
42
|
-
:style="multipleBlocksMargin"
|
|
43
|
-
:disabled="disabled"
|
|
44
|
-
:loading="loading"
|
|
45
|
-
:icon-filter="iconFilter"
|
|
46
|
-
:show-deselect-icon-loader="showDeselectIconLoader"
|
|
47
|
-
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
48
|
-
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
49
|
-
:label="label"
|
|
50
|
-
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
51
|
-
:theme-type="themeType"
|
|
52
|
-
:increase-display-by="increaseDisplayBy"
|
|
53
|
-
:multipleBlocksLimit="multipleBlocksLimit"
|
|
54
|
-
:selected-options="selectedOptions"
|
|
55
|
-
:emitter="emitter"
|
|
56
|
-
:create-custom-option-label="createCustomOptionLabel"
|
|
57
|
-
>
|
|
58
|
-
<template #multipleBlocks="{ selectedOptions, deselectBlock }">
|
|
59
|
-
<slot
|
|
60
|
-
name="multipleBlocks"
|
|
61
|
-
:selected-options="selectedOptions"
|
|
62
|
-
:deselect-block="deselectBlock"
|
|
63
|
-
>
|
|
64
|
-
</slot>
|
|
65
|
-
</template>
|
|
66
|
-
<template #optionBlock="{ label, deselectBlock, index }">
|
|
67
|
-
<slot
|
|
68
|
-
name="optionBlock"
|
|
69
|
-
:label="label"
|
|
70
|
-
:index="index"
|
|
71
|
-
:deselect-block="deselectBlock"
|
|
72
|
-
>
|
|
73
|
-
</slot>
|
|
74
|
-
</template>
|
|
75
|
-
<template #maxElements>
|
|
76
|
-
<slot name="maxElements"></slot>
|
|
77
|
-
</template>
|
|
78
|
-
<template
|
|
79
|
-
v-if="toggleMultipleBlocksLimit"
|
|
80
|
-
#showMore="{ showMoreOptions }"
|
|
81
|
-
>
|
|
82
|
-
<slot
|
|
83
|
-
name="showMore"
|
|
84
|
-
:show-more-options="showMoreOptions"
|
|
85
|
-
>
|
|
86
|
-
</slot>
|
|
87
|
-
</template>
|
|
88
|
-
</extended-multiselect-multiple>
|
|
89
|
-
</div>
|
|
90
|
-
<div v-else-if="!showSearchField && multiple">
|
|
91
|
-
<extended-multiselect-multiple
|
|
92
|
-
:disabled="disabled"
|
|
93
|
-
:loading="loading"
|
|
94
|
-
:icon-filter="iconFilter"
|
|
95
|
-
:placeholder-block-shown="!selectedOptions.length"
|
|
96
|
-
:show-deselect-icon-loader="showDeselectIconLoader"
|
|
97
|
-
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
98
|
-
:appropriate-placeholder="appropriatePlaceholder"
|
|
99
|
-
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
100
|
-
:label="label"
|
|
101
|
-
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
102
|
-
:theme-type="themeType"
|
|
103
|
-
:increase-display-by="increaseDisplayBy"
|
|
104
|
-
:multipleBlocksLimit="multipleBlocksLimit"
|
|
105
|
-
:selected-options="selectedOptions"
|
|
106
|
-
:emitter="emitter"
|
|
107
|
-
:create-custom-option-label="createCustomOptionLabel"
|
|
108
|
-
>
|
|
109
|
-
<template #multipleBlocks="{ selectedOptions, deselectBlock }">
|
|
110
|
-
<slot
|
|
111
|
-
name="multipleBlocks"
|
|
112
|
-
:selected-options="selectedOptions"
|
|
113
|
-
:deselect-block="deselectBlock"
|
|
114
|
-
>
|
|
115
|
-
</slot>
|
|
116
|
-
</template>
|
|
117
|
-
<template #optionBlock="{ label, deselectBlock, index }">
|
|
118
|
-
<slot
|
|
119
|
-
name="optionBlock"
|
|
120
|
-
:label="label"
|
|
121
|
-
:index="index"
|
|
122
|
-
:deselect-block="deselectBlock"
|
|
123
|
-
>
|
|
124
|
-
</slot>
|
|
125
|
-
</template>
|
|
126
|
-
<template
|
|
127
|
-
v-if="toggleMultipleBlocksLimit"
|
|
128
|
-
#showMore="{ showMoreOptions }"
|
|
129
|
-
>
|
|
130
|
-
<slot
|
|
131
|
-
name="showMore"
|
|
132
|
-
:show-more-options="showMoreOptions"
|
|
133
|
-
></slot>
|
|
134
|
-
</template>
|
|
135
|
-
</extended-multiselect-multiple>
|
|
136
|
-
<input
|
|
137
|
-
class="extended__multiselect-input--hidden"
|
|
138
|
-
ref="extendedInput"
|
|
139
|
-
type="text"
|
|
140
|
-
@blur.prevent="rollUp"
|
|
141
|
-
@focus.prevent="expand"
|
|
142
|
-
/>
|
|
143
|
-
</div>
|
|
144
|
-
<div
|
|
145
|
-
class="extended__multiselect-block"
|
|
146
|
-
v-else
|
|
147
|
-
>
|
|
148
|
-
<span
|
|
149
|
-
v-if="placeholderBlockShown"
|
|
150
|
-
class="extended__multiselect-placeholder"
|
|
151
|
-
>
|
|
152
|
-
{{ appropriatePlaceholder }}
|
|
153
|
-
</span>
|
|
154
|
-
<slot
|
|
155
|
-
name="labelBlock"
|
|
156
|
-
:label-block-value="singleLabel"
|
|
157
|
-
>
|
|
158
|
-
<span>{{ singleLabel }}</span>
|
|
159
|
-
</slot>
|
|
160
|
-
<input
|
|
161
|
-
class="extended__multiselect-input--hidden"
|
|
162
|
-
ref="extendedInput"
|
|
163
|
-
type="text"
|
|
164
|
-
@blur.prevent="rollUp"
|
|
165
|
-
@focus.prevent="expand"
|
|
166
|
-
/>
|
|
167
|
-
</div>
|
|
168
|
-
</template>
|
|
169
|
-
|
|
170
|
-
<script setup>
|
|
171
|
-
import {
|
|
172
|
-
computed,
|
|
173
|
-
defineProps,
|
|
174
|
-
inject,
|
|
175
|
-
nextTick,
|
|
176
|
-
onBeforeMount,
|
|
177
|
-
onMounted,
|
|
178
|
-
ref,
|
|
179
|
-
toRef,
|
|
180
|
-
toRefs,
|
|
181
|
-
useAttrs,
|
|
182
|
-
watch,
|
|
183
|
-
} from "vue";
|
|
184
|
-
|
|
185
|
-
import useDebounce from "../composition/debounce";
|
|
186
|
-
|
|
187
|
-
import ExtendedMultiselectMultiple from "./ExtendedMultiselectMultiple.vue";
|
|
188
|
-
|
|
189
|
-
const props = defineProps({
|
|
190
|
-
/**
|
|
191
|
-
* Determines whether to take search value from current
|
|
192
|
-
* selected option if "multiple" prop equals false
|
|
193
|
-
* @property {boolean} autoSelectSearchValue
|
|
194
|
-
*/
|
|
195
|
-
autoSelectSearchValue: {
|
|
196
|
-
type: Boolean,
|
|
197
|
-
required: true,
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Determines which placeholder to use
|
|
202
|
-
* depending on the options creation mode
|
|
203
|
-
* @property {boolean} createOnTheGo
|
|
204
|
-
*/
|
|
205
|
-
createOnTheGo: {
|
|
206
|
-
type: Boolean,
|
|
207
|
-
required: true,
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Blocks search field
|
|
212
|
-
* @property {boolean} disabled
|
|
213
|
-
*/
|
|
214
|
-
disabled: {
|
|
215
|
-
type: Boolean,
|
|
216
|
-
required: true,
|
|
217
|
-
},
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* Provides "loading" state of component
|
|
221
|
-
* to ExtendedMultiselectMultiple child component
|
|
222
|
-
* @property {boolean} loading
|
|
223
|
-
*/
|
|
224
|
-
loading: {
|
|
225
|
-
type: Boolean,
|
|
226
|
-
required: true,
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Determines whether to use ExtendedMultiselectMultiple
|
|
231
|
-
* child component and some other related functionality
|
|
232
|
-
* @property {boolean} multiple
|
|
233
|
-
*/
|
|
234
|
-
multiple: {
|
|
235
|
-
type: Boolean,
|
|
236
|
-
required: true,
|
|
237
|
-
},
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Renews the pattern of internal search for available options
|
|
241
|
-
* @property {boolean} searchFilterActive
|
|
242
|
-
*/
|
|
243
|
-
searchFilterActive: {
|
|
244
|
-
type: Boolean,
|
|
245
|
-
required: true,
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Determines whether to show search field
|
|
250
|
-
* @property {boolean} showSearchField
|
|
251
|
-
*/
|
|
252
|
-
showSearchField: {
|
|
253
|
-
type: Boolean,
|
|
254
|
-
required: true,
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* Determines whether to show loader icon in multiple
|
|
259
|
-
* options block if "loading" prop equals true
|
|
260
|
-
* @default true
|
|
261
|
-
* @property {boolean} showDeselectIconLoader
|
|
262
|
-
*/
|
|
263
|
-
showDeselectIconLoader: {
|
|
264
|
-
type: Boolean,
|
|
265
|
-
default: true,
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Determines whether to allow user to increase limit of shown
|
|
270
|
-
* elements with selected options by special icon
|
|
271
|
-
* @property {boolean} toggleMultipleBlocksLimit
|
|
272
|
-
*/
|
|
273
|
-
toggleMultipleBlocksLimit: {
|
|
274
|
-
type: Boolean,
|
|
275
|
-
required: true,
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Determines whether to roll up options list
|
|
280
|
-
* by option selection
|
|
281
|
-
* @property {boolean} toggleOptionsBySelect
|
|
282
|
-
*/
|
|
283
|
-
toggleOptionsBySelect: {
|
|
284
|
-
type: Boolean,
|
|
285
|
-
required: true,
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Determines whether to clear value of search field
|
|
290
|
-
* after next switch of search field display
|
|
291
|
-
* @property {boolean} togglingSavesSearchValue
|
|
292
|
-
*/
|
|
293
|
-
togglingSavesSearchValue: {
|
|
294
|
-
type: Boolean,
|
|
295
|
-
required: true,
|
|
296
|
-
},
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Placeholder which will be shown
|
|
300
|
-
* if "createOnTheGo" prop equals true
|
|
301
|
-
* @property {string} createOptionPlaceholder
|
|
302
|
-
*/
|
|
303
|
-
createOptionPlaceholder: {
|
|
304
|
-
type: String,
|
|
305
|
-
required: true,
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Placeholder used in internal options filters
|
|
310
|
-
* and provided to ExtendedMultiselectMultiple child component
|
|
311
|
-
* @property {string} emptyObjectsPlaceholder
|
|
312
|
-
*/
|
|
313
|
-
emptyObjectsPlaceholder: {
|
|
314
|
-
type: String,
|
|
315
|
-
required: true,
|
|
316
|
-
},
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* Defines a svg-filter for icons
|
|
320
|
-
* @property {string} iconFilter
|
|
321
|
-
*/
|
|
322
|
-
iconFilter: {
|
|
323
|
-
type: String,
|
|
324
|
-
required: true,
|
|
325
|
-
},
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Determines field of option which will be displayed as label
|
|
329
|
-
* @property {string} label
|
|
330
|
-
*/
|
|
331
|
-
label: {
|
|
332
|
-
type: String,
|
|
333
|
-
required: true,
|
|
334
|
-
},
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* "placeholder" attribute for search field
|
|
338
|
-
* @property {string} placeholder
|
|
339
|
-
*/
|
|
340
|
-
placeholder: {
|
|
341
|
-
type: String,
|
|
342
|
-
required: true,
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Provides current theme of extended multiselect
|
|
347
|
-
* to ExtendedMultiselectMultiple child component
|
|
348
|
-
* @property {string} themeType
|
|
349
|
-
*/
|
|
350
|
-
themeType: {
|
|
351
|
-
type: String,
|
|
352
|
-
required: true,
|
|
353
|
-
},
|
|
354
|
-
|
|
355
|
-
/**
|
|
356
|
-
* Provides limit of hidden options amount to be shown next
|
|
357
|
-
* @property {number} increaseDisplayBy
|
|
358
|
-
*/
|
|
359
|
-
increaseDisplayBy: {
|
|
360
|
-
type: Number,
|
|
361
|
-
required: true,
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
/**
|
|
365
|
-
* Provides limit of multiple option blocks amount
|
|
366
|
-
* to ExtendedMultiselectMultiple child component
|
|
367
|
-
* @default null
|
|
368
|
-
* @property {number} multipleBlocksLimit
|
|
369
|
-
*/
|
|
370
|
-
multipleBlocksLimit: {
|
|
371
|
-
type: Number,
|
|
372
|
-
default: null,
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* Provides list of selected options
|
|
377
|
-
* to ExtendedMultiselectMultiple child component
|
|
378
|
-
* @property {Array} selectedOptions
|
|
379
|
-
*/
|
|
380
|
-
selectedOptions: {
|
|
381
|
-
type: Array,
|
|
382
|
-
required: true,
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* Reactive instance of LocalEmitter class
|
|
387
|
-
* @property {object} emitter
|
|
388
|
-
*/
|
|
389
|
-
emitter: {
|
|
390
|
-
type: Object,
|
|
391
|
-
required: true,
|
|
392
|
-
},
|
|
393
|
-
|
|
394
|
-
/**
|
|
395
|
-
* Provides function that creates custom label for
|
|
396
|
-
* block with selected option to ExtendedMultiselectMultiple
|
|
397
|
-
* child component
|
|
398
|
-
* @property {Function} createCustomOptionLabel
|
|
399
|
-
*/
|
|
400
|
-
createCustomOptionLabel: {
|
|
401
|
-
type: Function,
|
|
402
|
-
required: true,
|
|
403
|
-
},
|
|
404
|
-
|
|
405
|
-
/**
|
|
406
|
-
* Loader function provided by user.
|
|
407
|
-
* @property {Function} externalOptionsLoader
|
|
408
|
-
* @default null
|
|
409
|
-
* @param {string} value - value of search field
|
|
410
|
-
*/
|
|
411
|
-
externalOptionsLoader: {
|
|
412
|
-
type: Function,
|
|
413
|
-
default: null,
|
|
414
|
-
},
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Provides function that creates limit message for maximal of selected
|
|
418
|
-
* options to ExtendedMultiselectMultiple child component
|
|
419
|
-
* @property {Function} multipleBlocksLimitMessage
|
|
420
|
-
*/
|
|
421
|
-
multipleBlocksLimitMessage: {
|
|
422
|
-
type: Function,
|
|
423
|
-
required: true,
|
|
424
|
-
},
|
|
425
|
-
|
|
426
|
-
/**
|
|
427
|
-
* "id" attribute of search field
|
|
428
|
-
* @default null
|
|
429
|
-
* @property {string|number} inputId
|
|
430
|
-
*/
|
|
431
|
-
inputId: {
|
|
432
|
-
type: [String, Number],
|
|
433
|
-
default: null,
|
|
434
|
-
},
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
const searchState = inject("searchState");
|
|
438
|
-
const setSearchValue = inject("setSearchValue");
|
|
439
|
-
const setSearchPattern = inject("setSearchPattern");
|
|
440
|
-
|
|
441
|
-
const emitter = toRef(props, "emitter");
|
|
442
|
-
|
|
443
|
-
const { DebounceConstructor } = useDebounce();
|
|
444
|
-
|
|
445
|
-
const blurSkip = ref(false);
|
|
446
|
-
const reversePrevented = ref(false);
|
|
447
|
-
const searchFieldFocused = ref(false);
|
|
448
|
-
const optionWillBeTriggered = ref(false);
|
|
449
|
-
const searchValue = ref("");
|
|
450
|
-
const singleLabel = ref("");
|
|
451
|
-
const blurSkipByToggleIcon = ref(0);
|
|
452
|
-
const blurSkipByBlock = ref(0);
|
|
453
|
-
const labelBlocks = ref([]);
|
|
454
|
-
const searchDebounce = ref(new DebounceConstructor.value(() => {
|
|
455
|
-
const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
|
|
456
|
-
if (externalOptionsLoader.value) {
|
|
457
|
-
emitter.value.emit("extended:loader-pattern-changed", searchValue.value);
|
|
458
|
-
} else {
|
|
459
|
-
emitter.value.emit("extended:search-pattern-changed", searchValue.value);
|
|
460
|
-
setSearchPattern(searchPattern);
|
|
461
|
-
}
|
|
462
|
-
}, 250));
|
|
463
|
-
|
|
464
|
-
/**
|
|
465
|
-
* Element references
|
|
466
|
-
*/
|
|
467
|
-
const extendedInput = ref(null);
|
|
468
|
-
|
|
469
|
-
const {
|
|
470
|
-
autoSelectSearchValue,
|
|
471
|
-
createOnTheGo,
|
|
472
|
-
createOptionPlaceholder,
|
|
473
|
-
disabled,
|
|
474
|
-
externalOptionsLoader,
|
|
475
|
-
increaseDisplayBy,
|
|
476
|
-
multiple,
|
|
477
|
-
placeholder,
|
|
478
|
-
searchFilterActive,
|
|
479
|
-
showSearchField,
|
|
480
|
-
selectedOptions,
|
|
481
|
-
toggleOptionsBySelect,
|
|
482
|
-
togglingSavesSearchValue,
|
|
483
|
-
} = toRefs(props);
|
|
484
|
-
|
|
485
|
-
const attrs = useAttrs();
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Defines "placeholder" attribute of search field
|
|
489
|
-
* @function
|
|
490
|
-
* @returns {string} placeholder
|
|
491
|
-
*/
|
|
492
|
-
const appropriatePlaceholder = computed(() => {
|
|
493
|
-
return createOnTheGo.value ? createOptionPlaceholder.value : placeholder.value;
|
|
494
|
-
});
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Sets "margin-top" css property to multiple option blocks
|
|
498
|
-
* if search field is shown
|
|
499
|
-
* @function
|
|
500
|
-
* @returns {Object|null} margin-top
|
|
501
|
-
*/
|
|
502
|
-
const multipleBlocksMargin = computed(() => {
|
|
503
|
-
return searchFieldForwarding.value ? { marginTop: "4px" } : null;
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
/**
|
|
507
|
-
* Determines whether to show placeholder block
|
|
508
|
-
* @function
|
|
509
|
-
* @returns {boolean} display
|
|
510
|
-
*/
|
|
511
|
-
const placeholderBlockShown = computed(() => {
|
|
512
|
-
if (selectedOptions.value.length || searchFieldForwarding.value) {
|
|
513
|
-
return false;
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
return true;
|
|
517
|
-
});
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Defines classes of search field
|
|
521
|
-
* @function
|
|
522
|
-
* @returns {Array} classes
|
|
523
|
-
*/
|
|
524
|
-
const searchFieldClass = computed(() => {
|
|
525
|
-
const mainClass = searchFieldForwarding.value
|
|
526
|
-
? "extended__multiselect-input"
|
|
527
|
-
: "extended__multiselect-input--hidden";
|
|
528
|
-
const searchFieldClasses = [];
|
|
529
|
-
|
|
530
|
-
if (optionWillBeTriggered.value) {
|
|
531
|
-
searchFieldClasses.push("extended__multiselect-input--trigger-option");
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
searchFieldClasses.push(mainClass);
|
|
535
|
-
|
|
536
|
-
return searchFieldClasses;
|
|
537
|
-
});
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* Determines whether to show search field
|
|
541
|
-
* over element with selected option
|
|
542
|
-
* @function
|
|
543
|
-
* @returns {boolean} display
|
|
544
|
-
*/
|
|
545
|
-
const searchFieldForwarding = computed(() => {
|
|
546
|
-
return searchFieldFocused.value || optionWillBeTriggered.value;
|
|
547
|
-
});
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* Determines whether option shall be triggered before selection
|
|
551
|
-
* @function
|
|
552
|
-
* @emits extended:renew-field-forwarding
|
|
553
|
-
* @param {boolean} searchFieldForwarding - restrictor of triggered option
|
|
554
|
-
*/
|
|
555
|
-
watch(searchFieldForwarding, (value) => {
|
|
556
|
-
if (value && autoSelectSearchValue.value && !multiple.value && singleLabel.value) {
|
|
557
|
-
searchValue.value = singleLabel.value;
|
|
558
|
-
}
|
|
559
|
-
emitter.value.emit("extended:renew-field-forwarding", value);
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Sets pattern of internal search for available options from search field to store
|
|
564
|
-
* @function
|
|
565
|
-
* @param {string} pattern - pattern of internal search for available options
|
|
566
|
-
*/
|
|
567
|
-
watch(searchState, (prevState, state) => {
|
|
568
|
-
if (state.searchPattern === prevState.searchPattern) return;
|
|
569
|
-
|
|
570
|
-
if (searchFilterActive.value) {
|
|
571
|
-
setSearchPattern(state.pattern);
|
|
572
|
-
}
|
|
573
|
-
}, { deep: true });
|
|
574
|
-
|
|
575
|
-
/**
|
|
576
|
-
* Sets value of search field from search field to store
|
|
577
|
-
* @function
|
|
578
|
-
* @param {string} value - value of search field
|
|
579
|
-
*/
|
|
580
|
-
watch(searchValue, (value) => {
|
|
581
|
-
if (searchFilterActive.value) {
|
|
582
|
-
setSearchValue(value);
|
|
583
|
-
}
|
|
584
|
-
});
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Expands options list
|
|
588
|
-
* @function
|
|
589
|
-
* @emits extended:expand-options
|
|
590
|
-
*/
|
|
591
|
-
const expand = () => {
|
|
592
|
-
if (disabled.value) return;
|
|
593
|
-
|
|
594
|
-
searchFieldFocused.value = true;
|
|
595
|
-
emitter.value.emit("extended:expand-options");
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
/**
|
|
599
|
-
* Describes behavour of input blur event
|
|
600
|
-
* when "multiple" prop equals true
|
|
601
|
-
* @function
|
|
602
|
-
*/
|
|
603
|
-
const multipleBlur = () => {
|
|
604
|
-
if (!multiple.value) {
|
|
605
|
-
searchFieldFocused.value = false;
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
|
|
610
|
-
/**
|
|
611
|
-
* Rolls up options list if it needed
|
|
612
|
-
* @function
|
|
613
|
-
* @emits extended:rollup-options
|
|
614
|
-
*/
|
|
615
|
-
const rollUp = () => {
|
|
616
|
-
if (disabled.value) return;
|
|
617
|
-
|
|
618
|
-
multipleBlur();
|
|
619
|
-
|
|
620
|
-
if (!togglingSavesSearchValue.value) {
|
|
621
|
-
searchValue.value = "";
|
|
622
|
-
setSearchValue(null);
|
|
623
|
-
setSearchPattern(null);
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
if (blurSkipByToggleIcon.value > 0) {
|
|
627
|
-
blurSkipByToggleIcon.value = 0;
|
|
628
|
-
return;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
if (blurSkipByBlock.value > 0) {
|
|
632
|
-
blurSkipByBlock.value = 0;
|
|
633
|
-
return;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
blurSkip.value = true;
|
|
637
|
-
blurSkipByBlock.value = 0;
|
|
638
|
-
blurSkipByToggleIcon.value = 0;
|
|
639
|
-
|
|
640
|
-
emitter.value.emit("extended:rollup-options", true);
|
|
641
|
-
};
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Activates debounced version of options list filter
|
|
645
|
-
* @function
|
|
646
|
-
*/
|
|
647
|
-
const search = () => {
|
|
648
|
-
searchDebounce.value.start();
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* "onBeforeMount" hook of the ExtendedMultiselectInput component
|
|
653
|
-
* @listens extended:field-focus
|
|
654
|
-
* @listens extended:rollup-options
|
|
655
|
-
* @listens extended:select-option
|
|
656
|
-
* @listens extended:deselect-option
|
|
657
|
-
* @listens extended:clean-options
|
|
658
|
-
* @listens extended:clear-field
|
|
659
|
-
* @listens extended:skip-blur
|
|
660
|
-
* @listens extended:skip-block-blur
|
|
661
|
-
* @listens extended:skip-block-blur-zeroing
|
|
662
|
-
* @listens extended:trigger-selection
|
|
663
|
-
*/
|
|
664
|
-
onBeforeMount(() => {
|
|
665
|
-
emitter.value.on("extended:rollup-options", (internalRollup) => {
|
|
666
|
-
if (blurSkip.value === true) {
|
|
667
|
-
blurSkip.value = false;
|
|
668
|
-
return;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (internalRollup) {
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
rollUp();
|
|
676
|
-
});
|
|
677
|
-
|
|
678
|
-
emitter.value.on("extended:select-option", (option) => {
|
|
679
|
-
|
|
680
|
-
if (toggleOptionsBySelect.value) {
|
|
681
|
-
rollUp();
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
if (multiple.value) {
|
|
685
|
-
return;
|
|
686
|
-
} else {
|
|
687
|
-
singleLabel.value = option.label;
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
emitter.value.on("extended:deselect-option", () => {
|
|
692
|
-
if (multiple.value) {
|
|
693
|
-
return;
|
|
694
|
-
} else {
|
|
695
|
-
singleLabel.value = "";
|
|
696
|
-
}
|
|
697
|
-
});
|
|
698
|
-
|
|
699
|
-
emitter.value.on("extended:clean-options", () => {
|
|
700
|
-
searchValue.value = null;
|
|
701
|
-
});
|
|
702
|
-
|
|
703
|
-
emitter.value.on("extended:clear-field", () => {
|
|
704
|
-
searchValue.value = null;
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
emitter.value.on("extended:skip-blur", () => {
|
|
708
|
-
blurSkipByToggleIcon.value++;
|
|
709
|
-
});
|
|
710
|
-
|
|
711
|
-
emitter.value.on("extended:skip-block-blur", () => {
|
|
712
|
-
blurSkipByBlock.value++;
|
|
713
|
-
});
|
|
714
|
-
|
|
715
|
-
emitter.value.on("extended:skip-block-blur-zeroing", () => {
|
|
716
|
-
blurSkipByBlock.value = 0;
|
|
717
|
-
});
|
|
718
|
-
|
|
719
|
-
emitter.value.on("extended:trigger-selection", (triggerState) => {
|
|
720
|
-
if (!toggleOptionsBySelect.value) {
|
|
721
|
-
searchFieldFocused.value = false;
|
|
722
|
-
}
|
|
723
|
-
optionWillBeTriggered.value = triggerState;
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* "onMounted" hook of the ExtendedMultiselectInput component
|
|
729
|
-
* @listens extended:field-focus
|
|
730
|
-
*/
|
|
731
|
-
onMounted(() => {
|
|
732
|
-
emitter.value.on("extended:field-focus", () => {
|
|
733
|
-
if (showSearchField.value) {
|
|
734
|
-
nextTick(() => {
|
|
735
|
-
extendedInput.value.focus();
|
|
736
|
-
});
|
|
737
|
-
} else {
|
|
738
|
-
extendedInput.value.focus();
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
});
|
|
742
|
-
</script>
|