vue3-extended-multiselect 2.0.0 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +1 -1
  2. package/dist/Vue3ExtendedMultiselect.cjs.js +5295 -0
  3. package/dist/Vue3ExtendedMultiselect.cjs.js.map +1 -0
  4. package/dist/Vue3ExtendedMultiselect.esm.js +5290 -0
  5. package/dist/Vue3ExtendedMultiselect.esm.js.map +1 -0
  6. package/dist/types/index.d.ts +46 -0
  7. package/package.json +5 -1
  8. package/.browserslistrc +0 -3
  9. package/.eslintrc.js +0 -36
  10. package/.github/workflows/publish.yml +0 -41
  11. package/.nvmrc +0 -0
  12. package/CHANGELOG.md +0 -411
  13. package/CONTRIBUTING.md +0 -57
  14. package/babel.config.js +0 -10
  15. package/index.js +0 -3
  16. package/jest.config.js +0 -62
  17. package/rollup.config.mjs +0 -74
  18. package/src/components/ExtendedMultiselectCancel.vue +0 -165
  19. package/src/components/ExtendedMultiselectInput.vue +0 -742
  20. package/src/components/ExtendedMultiselectLoader.vue +0 -182
  21. package/src/components/ExtendedMultiselectMultiple.vue +0 -400
  22. package/src/components/ExtendedMultiselectOptions.vue +0 -1191
  23. package/src/components/ExtendedMultiselectToggle.vue +0 -272
  24. package/src/components/Vue3ExtendedMultiselect.vue +0 -2476
  25. package/src/composition/cancel.js +0 -40
  26. package/src/composition/click-outside.js +0 -9
  27. package/src/composition/debounce.js +0 -9
  28. package/src/composition/emitter.js +0 -9
  29. package/src/composition/image-path.js +0 -17
  30. package/src/composition/labels.js +0 -42
  31. package/src/composition/preselected-options.js +0 -68
  32. package/src/composition/search-value.js +0 -34
  33. package/src/composition/sizes.js +0 -45
  34. package/src/composition/toggle.js +0 -32
  35. package/src/sets/sets.js +0 -100
  36. package/src/styles/animations.css +0 -19
  37. package/src/styles/main.css +0 -460
  38. package/src/styles/variables.css +0 -52
  39. package/src/tools/Debounce.js +0 -26
  40. package/src/tools/LocalEmitter.js +0 -32
  41. package/src/tools/instance.js +0 -3
  42. package/tests/unit/events.spec.js +0 -150
  43. package/tests/unit/props.spec.js +0 -1155
  44. package/tests/unit/tools.spec.js +0 -56
  45. package/tests/utils/mocks.js +0 -1
  46. package/tests/utils/mount.js +0 -38
  47. package/tests/utils/stubs.js +0 -1
  48. package/tests/utils/utils.js +0 -25
  49. package/typings/vue3-extended-multiselect.d.ts +0 -44
  50. /package/{src → dist}/assets/images/base-arrow.svg +0 -0
  51. /package/{src → dist}/assets/images/cancel.svg +0 -0
  52. /package/{src → dist}/assets/images/circle-arrow.svg +0 -0
  53. /package/{src → dist}/assets/images/double-arrow.svg +0 -0
  54. /package/{src → dist}/assets/images/inner-arrow.svg +0 -0
  55. /package/{src → dist}/assets/images/loader.svg +0 -0
  56. /package/{src → dist}/assets/images/triangle-arrow.svg +0 -0
  57. /package/{src → dist}/assets/images/triangle-circle-arrow.svg +0 -0
  58. /package/{src → dist}/assets/images/wide-arrow.svg +0 -0
@@ -1,182 +0,0 @@
1
- <template>
2
- <div class="extended__multiselect-loader">
3
- <img
4
- alt=""
5
- :class="[iconFilterClass, iconSizeClass, 'extended__multiselect-loader-animate']"
6
- :src="loaderIcon"
7
- />
8
- <svg
9
- version="1.1"
10
- xmlns="http://www.w3.org/2000/svg"
11
- xmlns:xlink="http://www.w3.org/1999/xlink"
12
- width="0"
13
- height="0"
14
- >
15
- <defs>
16
- <filter
17
- x="0"
18
- y="0"
19
- width="1"
20
- height="1"
21
- id="filterLoaderDefault"
22
- >
23
- <feFlood flood-color="#00BFFF"/>
24
- <feComposite
25
- out="SourceGraphic"
26
- in2="SourceGraphic"
27
- operator="in"
28
- />
29
- </filter>
30
- <filter
31
- x="0"
32
- y="0"
33
- width="1"
34
- height="1"
35
- id="filterLoaderBasic"
36
- >
37
- <feFlood flood-color="#708090"/>
38
- <feComposite
39
- out="SourceGraphic"
40
- in2="SourceGraphic"
41
- operator="in"
42
- />
43
- </filter>
44
- <filter
45
- x="0"
46
- y="0"
47
- width="1"
48
- height="1"
49
- id="filterLoaderSlateGrey"
50
- >
51
- <feFlood flood-color="#2F4F4F"/>
52
- <feComposite
53
- out="SourceGraphic"
54
- in2="SourceGraphic"
55
- operator="in"
56
- />
57
- </filter>
58
- <filter
59
- x="0"
60
- y="0"
61
- width="1"
62
- height="1"
63
- id="filterLoaderSlateBlue"
64
- >
65
- <feFlood flood-color="#483D8B"/>
66
- <feComposite
67
- out="SourceGraphic"
68
- in2="SourceGraphic"
69
- operator="in"
70
- />
71
- </filter>
72
- <filter
73
- x="0"
74
- y="0"
75
- width="1"
76
- height="1"
77
- id="filterLoaderTeal"
78
- >
79
- <feFlood flood-color="#008080"/>
80
- <feComposite
81
- out="SourceGraphic"
82
- in2="SourceGraphic"
83
- operator="in"
84
- />
85
- </filter>
86
- <filter
87
- x="0"
88
- y="0"
89
- width="1"
90
- height="1"
91
- id="filterLoaderStrict"
92
- >
93
- <feFlood flood-color="#00BFFF"/>
94
- <feComposite
95
- out="SourceGraphic"
96
- in2="SourceGraphic"
97
- operator="in"
98
- />
99
- </filter>
100
- </defs>
101
- </svg>
102
- </div>
103
- </template>
104
-
105
- <script setup>
106
- import {
107
- computed,
108
- defineProps,
109
- inject,
110
- ref,
111
- toRefs,
112
- } from "vue";
113
-
114
- import useImagePath from "../composition/image-path";
115
- import useSizes from "../composition/sizes";
116
-
117
- const props = defineProps({
118
- /**
119
- * Defines svg-filter for loader icon
120
- * @property {string} iconFilter
121
- */
122
- iconFilter: {
123
- type: String,
124
- required: true,
125
- },
126
-
127
- /**
128
- * Provides size to create special size-class
129
- * for each kind of icon
130
- * @property {string} iconSize
131
- */
132
- iconSize: {
133
- type: String,
134
- required: true,
135
- },
136
- });
137
-
138
- const loaderIconFilter = inject("loaderIconFilter");
139
-
140
- const { iconSize } = toRefs(props);
141
-
142
- const { createImagePath } = useImagePath();
143
-
144
- const loaderIcon = ref(createImagePath("loader.svg"));
145
-
146
- const { iconSizeClass } = useSizes(iconSize);
147
-
148
- /**
149
- * Defines class for loader icon
150
- * depends on injected filter name
151
- * @function
152
- * @returns {string} class
153
- */
154
- const iconFilterClass = computed(() => {
155
- let basicFilter = "extended__multiselect-loader";
156
-
157
- switch(loaderIconFilter) {
158
- case "default-loader":
159
- basicFilter = `${basicFilter}_default-loader`;
160
- break;
161
- case "basic":
162
- basicFilter = `${basicFilter}_basic`;
163
- break;
164
- case "slate-grey":
165
- basicFilter = `${basicFilter}_slate-grey`;
166
- break;
167
- case "slate-blue":
168
- basicFilter = `${basicFilter}_slate-blue`;
169
- break;
170
- case "teal":
171
- basicFilter = `${basicFilter}_teal`;
172
- break;
173
- case "strict":
174
- basicFilter = `${basicFilter}_strict`;
175
- break;
176
- default:
177
- basicFilter = `${basicFilter}_default-loader`;
178
- }
179
-
180
- return basicFilter;
181
- });
182
- </script>
@@ -1,400 +0,0 @@
1
- <template>
2
- <div class="extended__multiselect-block extended__multiselect-block--multiple">
3
- <span
4
- v-if="placeholderBlockShown"
5
- class="extended__multiselect-placeholder"
6
- >
7
- {{ appropriatePlaceholder }}
8
- </span>
9
- <div>
10
- <slot
11
- name="multipleBlocks"
12
- :selected-options="limitRestriction"
13
- :deselect-block="deselectBlock"
14
- >
15
- <div
16
- v-for="(option, index) in limitRestriction"
17
- :key="index"
18
- >
19
- <slot
20
- name="optionBlock"
21
- :label="optionCreateLabel(option)"
22
- :index="index"
23
- :deselect-block="deselectBlock"
24
- >
25
- <div :class="classes">
26
- <span>{{ optionCreateLabel(option) }}</span>
27
- <div :class="deselectClasses">
28
- <img
29
- alt=""
30
- class="extended__multiselect_deselect-block-icon"
31
- v-if="!showLoaderIcon"
32
- :src="deselectImage"
33
- @click.stop="deselectBlock(index)"
34
- />
35
- <extended-multiselect-loader
36
- v-else
37
- :icon-filter="iconFilter"
38
- icon-size="deselect"
39
- />
40
- </div>
41
- </div>
42
- </slot>
43
- </div>
44
- <slot
45
- name="maxElements"
46
- v-if="optionsLimitAchieved && !toggleMultipleBlocksLimit"
47
- >
48
- {{ multipleBlocksLimitMessage(overLimitOptionsCount) }}
49
- </slot>
50
- <slot
51
- name="showMore"
52
- v-if="optionIncreaserAvailable"
53
- :show-more-options="showMoreOptions"
54
- >
55
- <div
56
- :class="[classes, increaserClass]"
57
- @click.stop="showMoreOptions"
58
- >
59
- Show more options
60
- </div>
61
- </slot>
62
- </slot>
63
- </div>
64
- </div>
65
- </template>
66
-
67
- <script setup>
68
- import {
69
- computed,
70
- defineProps,
71
- onBeforeMount,
72
- ref,
73
- toRefs,
74
- watch,
75
- } from "vue";
76
-
77
- import useImagePath from "../composition/image-path";
78
- import useLabels from "../composition/labels";
79
-
80
- import ExtendedMultiselectLoader from "./ExtendedMultiselectLoader.vue";
81
-
82
- const props = defineProps({
83
- /**
84
- * Blocks deselect block button
85
- * @property {boolean} disabled
86
- */
87
- disabled: {
88
- type: Boolean,
89
- required: true,
90
- },
91
-
92
- /**
93
- * Hides all deselect buttons if equals true
94
- * @property {boolean} loading
95
- */
96
- loading: {
97
- type: Boolean,
98
- required: true,
99
- },
100
-
101
- /**
102
- * Determines whether to show extended multiselect
103
- * placeholder element
104
- * @property {boolean} placeholderBlockShown
105
- */
106
- placeholderBlockShown: {
107
- type: Boolean,
108
- default: false,
109
- },
110
-
111
- /**
112
- * Determines whether to show loader icon in multiple
113
- * options block if "loading" prop equals true
114
- * @default true
115
- * @property {boolean} showDeselectIconLoader
116
- */
117
- showDeselectIconLoader: {
118
- type: Boolean,
119
- default: true,
120
- },
121
-
122
- /**
123
- * Allows to increase limit of displayed selected option blocks
124
- * @property {boolean} toggleMultipleBlocksLimit
125
- */
126
- toggleMultipleBlocksLimit: {
127
- type: Boolean,
128
- required: true,
129
- },
130
-
131
- /**
132
- * Defines placeholder for extended multiselect
133
- * placeholder element
134
- * @property {string} appropriatePlaceholder
135
- */
136
- appropriatePlaceholder: {
137
- type: String,
138
- default: "",
139
- },
140
-
141
- /**
142
- * Defines label for blocks with options of type "object"
143
- * or Array instances which length/keys length equals 0
144
- * @property {string} emptyObjectsPlaceholder
145
- */
146
- emptyObjectsPlaceholder: {
147
- type: String,
148
- required: true,
149
- },
150
-
151
- /**
152
- * Defines a svg-filter for icons
153
- * @property {string} iconFilter
154
- */
155
- iconFilter: {
156
- type: String,
157
- required: true,
158
- },
159
-
160
- /**
161
- * Determines field of option which will be displayed as label
162
- * @property {string} label
163
- */
164
- label: {
165
- type: String,
166
- required: true,
167
- },
168
-
169
- /**
170
- * Current theme of extended-multiselect
171
- * used in class definition
172
- * @property {string} themeType
173
- */
174
- themeType: {
175
- type: String,
176
- required: true,
177
- },
178
-
179
- /**
180
- * Limit of hidden options amount to be shown next
181
- * @property {number} increaseDisplayBy
182
- */
183
- increaseDisplayBy: {
184
- type: Number,
185
- required: true,
186
- },
187
-
188
- /**
189
- * Limit of option blocks amount
190
- * @property {number} multipleBlocksLimit
191
- */
192
- multipleBlocksLimit: {
193
- type: Number,
194
- default: null,
195
- },
196
-
197
- /**
198
- * List of selected options that will be shown as option blocks
199
- * @property {Array} selectedOptions
200
- */
201
- selectedOptions: {
202
- type: Array,
203
- required: true,
204
- },
205
-
206
- /**
207
- * Reactive instance of LocalEmitter class
208
- * @property {object} emitter
209
- */
210
- emitter: {
211
- type: Object,
212
- required: true,
213
- },
214
-
215
- /**
216
- * Function that creates custom label for
217
- * block with selected option
218
- * @property {Function} createCustomOptionLabel
219
- */
220
- createCustomOptionLabel: {
221
- type: Function,
222
- required: true,
223
- },
224
-
225
- /**
226
- * Function that creates limit message for maximal of selected options
227
- * @property {Function} multipleBlocksLimitMessage
228
- */
229
- multipleBlocksLimitMessage: {
230
- type: Function,
231
- required: true,
232
- },
233
- });
234
-
235
- const {
236
- createCustomOptionLabel,
237
- disabled,
238
- emitter,
239
- emptyObjectsPlaceholder,
240
- label,
241
- increaseDisplayBy,
242
- loading,
243
- showDeselectIconLoader,
244
- multipleBlocksLimit,
245
- selectedOptions,
246
- themeType,
247
- toggleMultipleBlocksLimit,
248
- } = toRefs(props);
249
-
250
- const { createImagePath } = useImagePath();
251
-
252
- const optionsLimitIncreaser = ref(null);
253
- const increaserClass = ref("extended__multiselect-increaser");
254
- const deselectImage = ref(createImagePath("cancel.svg"));
255
-
256
- const { optionCreateLabel } = useLabels(
257
- label,
258
- createCustomOptionLabel,
259
- emptyObjectsPlaceholder,
260
- );
261
-
262
- /**
263
- * Defines class for every selected option block
264
- * depends on current theme of extended multiselect
265
- * @function
266
- * @returns {string} class
267
- */
268
- const classes = computed(() => {
269
- const basicClassName = "extended__multiselect--multiple";
270
-
271
- switch(themeType.value) {
272
- case "basic":
273
- return `${basicClassName}-basic`;
274
- case "slate-grey":
275
- return `${basicClassName}-slate-grey`;
276
- case "slate-blue":
277
- return `${basicClassName}-slate-blue`;
278
- case "teal":
279
- return `${basicClassName}-teal`;
280
- case "strict":
281
- return `${basicClassName}-strict`;
282
- default:
283
- return `${basicClassName}-basic`;
284
- }
285
- });
286
-
287
- /**
288
- * Defines class for every deselect/loader icon in multiple
289
- * option blocks depends on "loading" prop
290
- * @function
291
- * @returns {string} class
292
- */
293
- const deselectClasses = computed(() => {
294
- return loading.value
295
- ? "extended__multiselect-block_cancel-wrapper--loading"
296
- : "extended__multiselect-block_cancel-wrapper";
297
- });
298
-
299
- /**
300
- * Defines current limited amount of displayed option blocks
301
- * @function
302
- * @returns {Array} UnionPropType
303
- */
304
- const limitRestriction = computed(() => {
305
- if (!optionsLimitIncreaser.value) return selectedOptions.value;
306
-
307
- return selectedOptions.value.filter((_, index) => {
308
- const limit = typeof optionsLimitIncreaser.value === "number"
309
- ? optionsLimitIncreaser.value
310
- : optionsLimitIncreaser.value.value;
311
-
312
- return ++index <= limit;
313
- });
314
- });
315
-
316
- /**
317
- * Determines whether user can increase limited amount of displayed option blocks
318
- * @function
319
- * @returns {boolean} possibility
320
- */
321
- const optionIncreaserAvailable = computed(() => {
322
- return toggleMultipleBlocksLimit.value && optionsLimitAchieved.value;
323
- });
324
-
325
- /**
326
- * Determines whether current limit of displayed option blocks amount
327
- * was reached
328
- * @function
329
- * @returns {boolean} reaching
330
- */
331
- const optionsLimitAchieved = computed(() => {
332
- return optionsLimitIncreaser.value && selectedOptions.value.length > optionsLimitIncreaser.value;
333
- });
334
-
335
- /**
336
- * Amount of selected options exceeding the limit
337
- * determined by "multipleBlocksLimit" prop
338
- * @function
339
- * @returns {number|null} amount
340
- */
341
- const overLimitOptionsCount = computed(() => {
342
- if (selectedOptions.value.length <= multipleBlocksLimit.value) return null;
343
-
344
- return selectedOptions.value.length - multipleBlocksLimit.value;
345
- });
346
-
347
- /**
348
- * Determines whether to show loader icon if "loading" prop equals true
349
- * or show multiple option blocks as usual
350
- * @function
351
- * @returns {boolean} restriction
352
- */
353
- const showLoaderIcon = computed(() => {
354
- return showDeselectIconLoader.value ? loading.value : false;
355
- });
356
-
357
- /**
358
- * If limit of selected options was achieved restricts further
359
- * extension of options container if "multiple" prop equals true
360
- * @function
361
- * @param {Array} - array of selected options
362
- */
363
- watch(selectedOptions, (value) => {
364
- if (!value.length || value.length <= multipleBlocksLimit.value) {
365
- optionsLimitIncreaser.value = multipleBlocksLimit.value;
366
- }
367
- }, { deep: true });
368
-
369
- /**
370
- * Deselects option by users click on its element cancel icon
371
- * if "multiple" prop equals true
372
- * @function
373
- * @emits extended:deselect-option
374
- * @param {number} index - index of deselected option
375
- */
376
- const deselectBlock = (index) => {
377
- if (loading.value || disabled.value) return;
378
-
379
- emitter.value.emit("extended:deselect-option", { index });
380
- };
381
-
382
- /**
383
- * Shows next hidden options
384
- * This behavior restricts by "toggleMultipleBlocksLimit" prop
385
- * if "multiple" prop equals true
386
- * @function
387
- * @emits extended:increase-display
388
- */
389
- const showMoreOptions = () => {
390
- optionsLimitIncreaser.value += increaseDisplayBy.value;
391
- emitter.value.emit("extended:increase-display", optionsLimitIncreaser.value);
392
- };
393
-
394
- /**
395
- * "onBeforeMount" hook of ExtendedMultiselectMultiple component
396
- */
397
- onBeforeMount(() => {
398
- optionsLimitIncreaser.value = multipleBlocksLimit.value;
399
- });
400
- </script>