vue3-extended-multiselect 1.0.0 → 1.1.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 (41) hide show
  1. package/.eslintrc.js +34 -34
  2. package/.github/workflows/publish.yml +41 -41
  3. package/CHANGELOG.md +109 -91
  4. package/LICENSE +21 -21
  5. package/README.md +261 -261
  6. package/index.js +2 -2
  7. package/jest.config.js +60 -57
  8. package/package.json +47 -47
  9. package/src/assets/base-arrow.svg +70 -70
  10. package/src/assets/cancel.svg +34 -34
  11. package/src/assets/circle-arrow.svg +7 -7
  12. package/src/assets/double-arrow.svg +39 -39
  13. package/src/assets/inner-arrow.svg +8 -8
  14. package/src/assets/loader.svg +5 -5
  15. package/src/assets/triangle-arrow.svg +72 -72
  16. package/src/assets/triangle-circle-arrow.svg +38 -38
  17. package/src/assets/wide-arrow.svg +72 -72
  18. package/src/components/ExtendedMultiselectCancel.vue +148 -148
  19. package/src/components/ExtendedMultiselectInput.vue +617 -617
  20. package/src/components/ExtendedMultiselectLoader.vue +182 -182
  21. package/src/components/ExtendedMultiselectMultiple.vue +295 -295
  22. package/src/components/ExtendedMultiselectOptions.vue +1092 -1091
  23. package/src/components/ExtendedMultiselectToggle.vue +261 -261
  24. package/src/components/Vue3ExtendedMultiselect.vue +1665 -1660
  25. package/src/composition/cancel.js +33 -33
  26. package/src/composition/image-path.js +16 -16
  27. package/src/composition/labels.js +39 -39
  28. package/src/composition/preselected-options.js +66 -66
  29. package/src/composition/search-value.js +33 -33
  30. package/src/composition/sizes.js +42 -42
  31. package/src/composition/toggle.js +33 -33
  32. package/src/events/emitter.js +2 -2
  33. package/src/sets/sets.js +99 -99
  34. package/src/styles/animations.css +18 -18
  35. package/src/styles/main.css +433 -432
  36. package/src/styles/variables.css +47 -47
  37. package/tests/unit/events.spec.js +135 -135
  38. package/tests/unit/props.spec.js +1040 -1040
  39. package/tests/utils/mount.js +37 -37
  40. package/tests/utils/utils.js +20 -20
  41. package/typings/vue3-extended-multiselect.d.ts +42 -42
@@ -1,262 +1,262 @@
1
- <template>
2
- <div
3
- aria-label="Toggle options list"
4
- id="extended__multiselect-toggle"
5
- role="switch"
6
- :aria-checked="dropdownActive"
7
- :class="toggleSlotClass"
8
- :tabindex="increasedTabindex"
9
- @click.stop.left="toggleOptionsList"
10
- @click.stop.middle="toggleOptionsList"
11
- @keypress.stop="toggleOptionsList($event)"
12
- >
13
- <img
14
- alt=""
15
- v-if="!loading"
16
- :class="classesSummary"
17
- :src="icon"
18
- />
19
- <extended-multiselect-loader
20
- v-else
21
- :icon-filter="iconFilter"
22
- :icon-size="iconSize"
23
- />
24
- <svg
25
- version="1.1"
26
- xmlns="http://www.w3.org/2000/svg"
27
- xmlns:xlink="http://www.w3.org/1999/xlink"
28
- width="0"
29
- height="0"
30
- >
31
- <defs>
32
- <filter
33
- x="0"
34
- y="0"
35
- width="1"
36
- height="1"
37
- id="basicFilter"
38
- >
39
- <feFlood flood-color="#BDBDBD"/>
40
- <feComposite
41
- out="SourceGraphic"
42
- in2="SourceGraphic"
43
- operator="in"
44
- />
45
- </filter>
46
- <filter
47
- x="0"
48
- y="0"
49
- width="1"
50
- height="1"
51
- id="blackFilter"
52
- >
53
- <feFlood flood-color="#000000"/>
54
- <feComposite
55
- out="SourceGraphic"
56
- in2="SourceGraphic"
57
- operator="in"
58
- />
59
- </filter>
60
- <filter
61
- x="0"
62
- y="0"
63
- width="1"
64
- height="1"
65
- id="greenFilter"
66
- >
67
- <feFlood flood-color="#068504"/>
68
- <feComposite
69
- out="SourceGraphic"
70
- in2="SourceGraphic"
71
- operator="in"
72
- />
73
- </filter>
74
- </defs>
75
- </svg>
76
- </div>
77
- </template>
78
-
79
- <script setup>
80
- import {
81
- computed,
82
- defineProps,
83
- toRefs,
84
- } from "vue";
85
-
86
- import useImagePath from "../composition/image-path";
87
- import useToggle from "../composition/toggle";
88
- import useSizes from "../composition/sizes";
89
-
90
- import ExtendedMultiselectLoader from "./ExtendedMultiselectLoader.vue";
91
-
92
- const props = defineProps({
93
- /**
94
- * Determines what class to use on toggle slot
95
- * @default false
96
- * @property {boolean} disabled
97
- */
98
- disabled: {
99
- type: Boolean,
100
- default: false,
101
- },
102
-
103
- /**
104
- * Determines whether option list expanded or not
105
- * @property {boolean} dropdownActive
106
- */
107
- dropdownActive: {
108
- type: Boolean,
109
- required: true,
110
- },
111
-
112
- /**
113
- * Defines a svg-filter for icons
114
- * @property {string} iconFilter
115
- */
116
- iconFilter: {
117
- type: String,
118
- required: true,
119
- },
120
-
121
- /**
122
- * Provides size to create special size-class
123
- * for each kind of icon
124
- * @property {string} iconSize
125
- */
126
- iconSize: {
127
- type: String,
128
- required: true,
129
- },
130
-
131
- /**
132
- * Replaces toggle button with loader
133
- * @property {boolean} loading
134
- */
135
- loading: {
136
- type: Boolean,
137
- required: true,
138
- },
139
-
140
- /**
141
- * Determines toggle icon to be used in default toggle slot
142
- * @property {string} toggleIcon
143
- */
144
- toggleIcon: {
145
- type: String,
146
- required: true,
147
- },
148
-
149
- /**
150
- * Defines "tabindex" attribute of toggle button
151
- * @default null
152
- * @property {number|null} tabindex
153
- */
154
- tabindex: {
155
- type: Number,
156
- default: null,
157
- },
158
- });
159
-
160
- const {
161
- disabled,
162
- dropdownActive,
163
- iconFilter,
164
- iconSize,
165
- loading,
166
- tabindex,
167
- toggleIcon,
168
- } = toRefs(props);
169
-
170
- const { createImagePath } = useImagePath();
171
-
172
- const { toggleSlotClass, toggleOptionsList } = useToggle(
173
- loading,
174
- disabled,
175
- null,
176
- );
177
- const { iconSizeClass } = useSizes(iconSize);
178
-
179
- /**
180
- * Defines a list of toggle button classes
181
- * @function
182
- * @returns {Array} classes
183
- */
184
- const classesSummary = computed(() => {
185
- return [
186
- iconFilterClass.value,
187
- iconSizeClass.value,
188
- iconFilterRotationClass.value
189
- ];
190
- });
191
-
192
- /**
193
- * Determines kind of toggle icon based on
194
- * "toggleIcon" prop
195
- * @function
196
- * @returns {string} icon
197
- */
198
- const icon = computed(() => {
199
- const baseArrow = createImagePath("base-arrow.svg");
200
-
201
- switch(toggleIcon.value) {
202
- case "base-arrow":
203
- return baseArrow;
204
- case "double-arrow":
205
- return createImagePath("double-arrow.svg");
206
- case "wide-arrow":
207
- return createImagePath("wide-arrow.svg");
208
- case "circle-arrow":
209
- return createImagePath("circle-arrow.svg");
210
- case "inner-arrow":
211
- return createImagePath("inner-arrow.svg");
212
- case "triangle-arrow":
213
- return createImagePath("triangle-arrow.svg");
214
- case "triangle-circle-arrow":
215
- return createImagePath("triangle-circle-arrow.svg");
216
- default:
217
- return baseArrow;
218
- }
219
- });
220
-
221
- /**
222
- * Defines svg-filter for toggle icon
223
- * @function
224
- * @returns {string} svg-filter
225
- */
226
- const iconFilterClass = computed(() => {
227
- const basicFilter = "extended__multiselect-filter";
228
-
229
- switch(iconFilter) {
230
- case "basic":
231
- return `${basicFilter}_basic`;
232
- case "black":
233
- return `${basicFilter}_black`;
234
- case "green":
235
- return `${basicFilter}_green`;
236
- default:
237
- return `${basicFilter}_basic`;
238
- }
239
- });
240
-
241
- /**
242
- * Defines rotation class of toggle icon based on
243
- * "dropdownActive" prop
244
- * @function
245
- * @returns {string} class
246
- */
247
- const iconFilterRotationClass = computed(() => {
248
- return dropdownActive.value
249
- ? "extended__multiselect-toggle--active"
250
- : "extended__multiselect-toggle--locked";
251
- });
252
-
253
- /**
254
- * Sets "tabindex" attibute of toggle button based on
255
- * given tabindex
256
- * @function
257
- * @returns {number} tabindex
258
- */
259
- const increasedTabindex = computed(() => {
260
- return tabindex.value ? tabindex.value + 1 : 0;
261
- });
1
+ <template>
2
+ <div
3
+ aria-label="Toggle options list"
4
+ id="extended__multiselect-toggle"
5
+ role="switch"
6
+ :aria-checked="dropdownActive"
7
+ :class="toggleSlotClass"
8
+ :tabindex="increasedTabindex"
9
+ @click.stop.left="toggleOptionsList"
10
+ @click.stop.middle="toggleOptionsList"
11
+ @keypress.stop="toggleOptionsList($event)"
12
+ >
13
+ <img
14
+ alt=""
15
+ v-if="!loading"
16
+ :class="classesSummary"
17
+ :src="icon"
18
+ />
19
+ <extended-multiselect-loader
20
+ v-else
21
+ :icon-filter="iconFilter"
22
+ :icon-size="iconSize"
23
+ />
24
+ <svg
25
+ version="1.1"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ xmlns:xlink="http://www.w3.org/1999/xlink"
28
+ width="0"
29
+ height="0"
30
+ >
31
+ <defs>
32
+ <filter
33
+ x="0"
34
+ y="0"
35
+ width="1"
36
+ height="1"
37
+ id="basicFilter"
38
+ >
39
+ <feFlood flood-color="#BDBDBD"/>
40
+ <feComposite
41
+ out="SourceGraphic"
42
+ in2="SourceGraphic"
43
+ operator="in"
44
+ />
45
+ </filter>
46
+ <filter
47
+ x="0"
48
+ y="0"
49
+ width="1"
50
+ height="1"
51
+ id="blackFilter"
52
+ >
53
+ <feFlood flood-color="#000000"/>
54
+ <feComposite
55
+ out="SourceGraphic"
56
+ in2="SourceGraphic"
57
+ operator="in"
58
+ />
59
+ </filter>
60
+ <filter
61
+ x="0"
62
+ y="0"
63
+ width="1"
64
+ height="1"
65
+ id="greenFilter"
66
+ >
67
+ <feFlood flood-color="#068504"/>
68
+ <feComposite
69
+ out="SourceGraphic"
70
+ in2="SourceGraphic"
71
+ operator="in"
72
+ />
73
+ </filter>
74
+ </defs>
75
+ </svg>
76
+ </div>
77
+ </template>
78
+
79
+ <script setup>
80
+ import {
81
+ computed,
82
+ defineProps,
83
+ toRefs,
84
+ } from "vue";
85
+
86
+ import useImagePath from "../composition/image-path";
87
+ import useToggle from "../composition/toggle";
88
+ import useSizes from "../composition/sizes";
89
+
90
+ import ExtendedMultiselectLoader from "./ExtendedMultiselectLoader.vue";
91
+
92
+ const props = defineProps({
93
+ /**
94
+ * Determines what class to use on toggle slot
95
+ * @default false
96
+ * @property {boolean} disabled
97
+ */
98
+ disabled: {
99
+ type: Boolean,
100
+ default: false,
101
+ },
102
+
103
+ /**
104
+ * Determines whether option list expanded or not
105
+ * @property {boolean} dropdownActive
106
+ */
107
+ dropdownActive: {
108
+ type: Boolean,
109
+ required: true,
110
+ },
111
+
112
+ /**
113
+ * Defines a svg-filter for icons
114
+ * @property {string} iconFilter
115
+ */
116
+ iconFilter: {
117
+ type: String,
118
+ required: true,
119
+ },
120
+
121
+ /**
122
+ * Provides size to create special size-class
123
+ * for each kind of icon
124
+ * @property {string} iconSize
125
+ */
126
+ iconSize: {
127
+ type: String,
128
+ required: true,
129
+ },
130
+
131
+ /**
132
+ * Replaces toggle button with loader
133
+ * @property {boolean} loading
134
+ */
135
+ loading: {
136
+ type: Boolean,
137
+ required: true,
138
+ },
139
+
140
+ /**
141
+ * Determines toggle icon to be used in default toggle slot
142
+ * @property {string} toggleIcon
143
+ */
144
+ toggleIcon: {
145
+ type: String,
146
+ required: true,
147
+ },
148
+
149
+ /**
150
+ * Defines "tabindex" attribute of toggle button
151
+ * @default null
152
+ * @property {number|null} tabindex
153
+ */
154
+ tabindex: {
155
+ type: Number,
156
+ default: null,
157
+ },
158
+ });
159
+
160
+ const {
161
+ disabled,
162
+ dropdownActive,
163
+ iconFilter,
164
+ iconSize,
165
+ loading,
166
+ tabindex,
167
+ toggleIcon,
168
+ } = toRefs(props);
169
+
170
+ const { createImagePath } = useImagePath();
171
+
172
+ const { toggleSlotClass, toggleOptionsList } = useToggle(
173
+ loading,
174
+ disabled,
175
+ null,
176
+ );
177
+ const { iconSizeClass } = useSizes(iconSize);
178
+
179
+ /**
180
+ * Defines a list of toggle button classes
181
+ * @function
182
+ * @returns {Array} classes
183
+ */
184
+ const classesSummary = computed(() => {
185
+ return [
186
+ iconFilterClass.value,
187
+ iconSizeClass.value,
188
+ iconFilterRotationClass.value
189
+ ];
190
+ });
191
+
192
+ /**
193
+ * Determines kind of toggle icon based on
194
+ * "toggleIcon" prop
195
+ * @function
196
+ * @returns {string} icon
197
+ */
198
+ const icon = computed(() => {
199
+ const baseArrow = createImagePath("base-arrow.svg");
200
+
201
+ switch(toggleIcon.value) {
202
+ case "base-arrow":
203
+ return baseArrow;
204
+ case "double-arrow":
205
+ return createImagePath("double-arrow.svg");
206
+ case "wide-arrow":
207
+ return createImagePath("wide-arrow.svg");
208
+ case "circle-arrow":
209
+ return createImagePath("circle-arrow.svg");
210
+ case "inner-arrow":
211
+ return createImagePath("inner-arrow.svg");
212
+ case "triangle-arrow":
213
+ return createImagePath("triangle-arrow.svg");
214
+ case "triangle-circle-arrow":
215
+ return createImagePath("triangle-circle-arrow.svg");
216
+ default:
217
+ return baseArrow;
218
+ }
219
+ });
220
+
221
+ /**
222
+ * Defines svg-filter for toggle icon
223
+ * @function
224
+ * @returns {string} svg-filter
225
+ */
226
+ const iconFilterClass = computed(() => {
227
+ const basicFilter = "extended__multiselect-filter";
228
+
229
+ switch(iconFilter) {
230
+ case "basic":
231
+ return `${basicFilter}_basic`;
232
+ case "black":
233
+ return `${basicFilter}_black`;
234
+ case "green":
235
+ return `${basicFilter}_green`;
236
+ default:
237
+ return `${basicFilter}_basic`;
238
+ }
239
+ });
240
+
241
+ /**
242
+ * Defines rotation class of toggle icon based on
243
+ * "dropdownActive" prop
244
+ * @function
245
+ * @returns {string} class
246
+ */
247
+ const iconFilterRotationClass = computed(() => {
248
+ return dropdownActive.value
249
+ ? "extended__multiselect-toggle--active"
250
+ : "extended__multiselect-toggle--locked";
251
+ });
252
+
253
+ /**
254
+ * Sets "tabindex" attibute of toggle button based on
255
+ * given tabindex
256
+ * @function
257
+ * @returns {number} tabindex
258
+ */
259
+ const increasedTabindex = computed(() => {
260
+ return tabindex.value ? tabindex.value + 1 : 0;
261
+ });
262
262
  </script>