vue3-extended-multiselect 1.9.8 → 1.10.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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Patch notes
2
2
 
3
- Current `vue3-extended-multiselect` version: **1.9.8**
3
+ Current `vue3-extended-multiselect` version: **1.10.1**
4
4
 
5
5
  ***
6
6
 
@@ -370,4 +370,16 @@ Adding descriptive comments for some types in typings.
370
370
 
371
371
  ### 1.9.8 (2023-03-23)
372
372
 
373
- * Fixing bug with "clean" event payload when all options were deselected.
373
+ * Fixing bug with "clean" event payload when all options were deselected.
374
+
375
+ ### 1.10.0 (2023-03-26)
376
+
377
+ * Adding "multipleBlocks" slot for element with all selected options.
378
+ * Adding conditional rendering to all slots.
379
+ * Removal of some excess props inside the component.
380
+ * Ordering "Events" section in documentation in alphabetic order.
381
+ * Ordering props in alphabetic order inside the component.
382
+
383
+ ### 1.10.1 (2023-03-26)
384
+
385
+ * Fixing bug with incorrect display of multiple option blocks.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.9.8
1
+ # vue3-extended-multiselect v1.10.1
2
2
 
3
3
  ***
4
4
 
@@ -98,20 +98,21 @@ Prop name | Prop type | Prop appointment | Prop default value | Prop values
98
98
  ## Slots list
99
99
  Slot name | Slot appointment | Slot scope
100
100
  ----------|------------------|-----------
101
- **option**|Option in options list with its label.|``option`` — option from options list,<br/>``createCustomOptionLabel`` — function that creates custom label for each option|
102
- **optionBlock**|Element with selected option and its label.|``label`` — option label,<br/>``deselectBlock`` — function that deselects option and removes element that contained it,<br/>``index`` — option index|
101
+ **cancel**|Button that deselects all options.|``cancel`` — function that deselects all options|
102
+ **labelBlock**|Element with single selected option that is shown if search field display is disabled.|``labelBlockValue`` — option label|
103
+ **lessThanLimit**|Message displayed if minimal limit of selected options has not been reached.|&mdash;|
104
+ **listHeader**|Element at the top of options list for information content.|&mdash;|
105
+ **listFooter**|Element at the bottom of options list for information content.|&mdash;|
103
106
  **marker**|Marker that indicates state of option selection.|``selected`` — flag to determine markers for selected options|
104
107
  **maxElements**|Message displayed if maximal limit of elements with selected options has been shown.|&mdash;|
105
- **showMore**|Button that increases limit of displayed elements with selected options.|``showMoreOptions`` — function that increases limit of displayed elements with selected options|
108
+ **moreThanLimit**|Message displayed if maximal limit of selected options has been reached.|&mdash;|
109
+ **multipleBlocks**|Block with selected options and other multiple select slots|``selectedOptions`` — list of selected options,<br/>``deselectBlock`` — function that deselects option and removes element that contained it|
106
110
  **noResults**|Message displayed if no options have been found by internal search.|&mdash;|
107
111
  **noOptions**|Message displayed if given options list is empty.|&mdash;|
108
- **listHeader**|Element at the top of options list for information content.|&mdash;|
109
- **listFooter**|Element at the bottom of options list for information content.|&mdash;|
112
+ **option**|Option in options list with its label.|``option`` — option from options list,<br/>``createCustomOptionLabel`` — function that creates custom label for each option|
113
+ **optionBlock**|Element with selected option and its label.|``label`` — option label,<br/>``deselectBlock`` — function that deselects option and removes element that contained it,<br/>``index`` — option index|
114
+ **showMore**|Button that increases limit of displayed elements with selected options.|``showMoreOptions`` — function that increases limit of displayed elements with selected options|
110
115
  **toggle**|Button that toggles options list display.|``toggleOptionsList`` — function that toggles options list display|
111
- **labelBlock**|Element with single selected option that is shown if search field display is disabled.|``labelBlockValue`` — option label|
112
- **moreThanLimit**|Message displayed if maximal limit of selected options has been reached.|&mdash;|
113
- **lessThanLimit**|Message displayed if minimal limit of selected options has not been reached.|&mdash;|
114
- **cancel**|Button that deselects all options.|``cancel`` — function that deselects all options|
115
116
 
116
117
  ## Events list
117
118
  Event name | Event appointment | Listener method | Simplified event payload | Fields of object with full event payload |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.9.8",
3
+ "version": "1.10.1",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -55,6 +55,14 @@
55
55
  :emitter="emitter"
56
56
  :create-custom-option-label="createCustomOptionLabel"
57
57
  >
58
+ <template #multipleBlocks="{ selectedOptions, deselectBlock }">
59
+ <slot
60
+ name="multipleBlocks"
61
+ :selected-options="selectedOptions"
62
+ :deselect-block="deselectBlock"
63
+ >
64
+ </slot>
65
+ </template>
58
66
  <template #optionBlock="{ label, deselectBlock, index }">
59
67
  <slot
60
68
  name="optionBlock"
@@ -98,6 +106,14 @@
98
106
  :emitter="emitter"
99
107
  :create-custom-option-label="createCustomOptionLabel"
100
108
  >
109
+ <template #multipleBlocks="{ selectedOptions, deselectBlock }">
110
+ <slot
111
+ name="multipleBlocks"
112
+ :selected-options="selectedOptions"
113
+ :deselect-block="deselectBlock"
114
+ >
115
+ </slot>
116
+ </template>
101
117
  <template #optionBlock="{ label, deselectBlock, index }">
102
118
  <slot
103
119
  name="optionBlock"
@@ -199,15 +215,6 @@ const props = defineProps({
199
215
  type: Boolean,
200
216
  required: true,
201
217
  },
202
-
203
- /**
204
- * Determines whether option list expanded or not
205
- * @property {boolean} dropdownActive
206
- */
207
- dropdownActive: {
208
- type: Boolean,
209
- required: true,
210
- },
211
218
 
212
219
  /**
213
220
  * Provides "loading" state of component
@@ -6,53 +6,61 @@
6
6
  >
7
7
  {{ appropriatePlaceholder }}
8
8
  </span>
9
- <div
10
- v-for="(option, index) in limitRestriction"
11
- :key="index"
12
- >
9
+ <div>
13
10
  <slot
14
- name="optionBlock"
15
- :label="optionCreateLabel(option)"
16
- :index="index"
11
+ name="multipleBlocks"
12
+ :selected-options="limitRestriction"
17
13
  :deselect-block="deselectBlock"
18
14
  >
19
- <div :class="classes">
20
- <span>{{ optionCreateLabel(option) }}</span>
21
- <div :class="deselectClasses">
22
- <img
23
- alt=""
24
- class="extended__multiselect_deselect-block-icon"
25
- v-if="!showLoaderIcon"
26
- :src="deselectImage"
27
- @click.stop="deselectBlock(index)"
28
- />
29
- <extended-multiselect-loader
30
- v-else
31
- :icon-filter="iconFilter"
32
- icon-size="deselect"
33
- />
34
- </div>
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>
35
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>
36
62
  </slot>
37
63
  </div>
38
- <slot
39
- name="maxElements"
40
- v-if="optionsLimitAchieved && !toggleMultipleBlocksLimit"
41
- >
42
- {{ multipleBlocksLimitMessage(overLimitOptionsCount) }}
43
- </slot>
44
- <slot
45
- name="showMore"
46
- v-if="optionIncreaserAvailable"
47
- :show-more-options="showMoreOptions"
48
- >
49
- <div
50
- :class="[classes, increaserClass]"
51
- @click.stop="showMoreOptions"
52
- >
53
- Show more options
54
- </div>
55
- </slot>
56
64
  </div>
57
65
  </template>
58
66
 
@@ -72,26 +80,6 @@ import useLabels from "../composition/labels";
72
80
  import ExtendedMultiselectLoader from "./ExtendedMultiselectLoader.vue";
73
81
 
74
82
  const props = defineProps({
75
- /**
76
- * Defines placeholder for extended multiselect
77
- * placeholder element
78
- * @property {string} appropriatePlaceholder
79
- */
80
- appropriatePlaceholder: {
81
- type: String,
82
- default: "",
83
- },
84
-
85
- /**
86
- * Function that creates custom label for
87
- * block with selected option
88
- * @property {Function} createCustomOptionLabel
89
- */
90
- createCustomOptionLabel: {
91
- type: Function,
92
- required: true,
93
- },
94
-
95
83
  /**
96
84
  * Blocks deselect block button
97
85
  * @property {boolean} disabled
@@ -101,34 +89,6 @@ const props = defineProps({
101
89
  required: true,
102
90
  },
103
91
 
104
- /**
105
- * Defines label for blocks with options of type "object"
106
- * or Array instances which length/keys length equals 0
107
- * @property {string} emptyObjectsPlaceholder
108
- */
109
- emptyObjectsPlaceholder: {
110
- type: String,
111
- required: true,
112
- },
113
-
114
- /**
115
- * Determines field of option which will be displayed as label
116
- * @property {string} label
117
- */
118
- label: {
119
- type: String,
120
- required: true,
121
- },
122
-
123
- /**
124
- * Limit of hidden options amount to be shown next
125
- * @property {number} increaseDisplayBy
126
- */
127
- increaseDisplayBy: {
128
- type: Number,
129
- required: true,
130
- },
131
-
132
92
  /**
133
93
  * Hides all deselect buttons if equals true
134
94
  * @property {boolean} loading
@@ -139,12 +99,13 @@ const props = defineProps({
139
99
  },
140
100
 
141
101
  /**
142
- * Limit of option blocks amount
143
- * @property {number} multipleBlocksLimit
102
+ * Determines whether to show extended multiselect
103
+ * placeholder element
104
+ * @property {boolean} placeholderBlockShown
144
105
  */
145
- multipleBlocksLimit: {
146
- type: Number,
147
- default: null,
106
+ placeholderBlockShown: {
107
+ type: Boolean,
108
+ default: false,
148
109
  },
149
110
 
150
111
  /**
@@ -167,32 +128,70 @@ const props = defineProps({
167
128
  required: true,
168
129
  },
169
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
+
170
151
  /**
171
152
  * Defines a svg-filter for icons
172
153
  * @property {string} iconFilter
173
154
  */
174
- iconFilter: {
155
+ iconFilter: {
175
156
  type: String,
176
157
  required: true,
177
158
  },
178
159
 
179
160
  /**
180
- * Function that creates limit message for maximal of selected options
181
- * @property {Function} multipleBlocksLimitMessage
161
+ * Determines field of option which will be displayed as label
162
+ * @property {string} label
182
163
  */
183
- multipleBlocksLimitMessage: {
184
- type: Function,
164
+ label: {
165
+ type: String,
185
166
  required: true,
186
167
  },
187
168
 
188
169
  /**
189
- * Determines whether to show extended multiselect
190
- * placeholder element
191
- * @property {boolean} placeholderBlockShown
170
+ * Current theme of extended-multiselect
171
+ * used in class definition
172
+ * @property {string} themeType
192
173
  */
193
- placeholderBlockShown: {
194
- type: Boolean,
195
- default: false,
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,
196
195
  },
197
196
 
198
197
  /**
@@ -214,12 +213,21 @@ const props = defineProps({
214
213
  },
215
214
 
216
215
  /**
217
- * Current theme of extended-multiselect
218
- * used in class definition
219
- * @property {string} themeType
216
+ * Function that creates custom label for
217
+ * block with selected option
218
+ * @property {Function} createCustomOptionLabel
220
219
  */
221
- themeType: {
222
- type: String,
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,
223
231
  required: true,
224
232
  },
225
233
  });
@@ -296,7 +304,7 @@ const deselectClasses = computed(() => {
296
304
  const limitRestriction = computed(() => {
297
305
  if (!optionsLimitIncreaser.value) return selectedOptions.value;
298
306
 
299
- return selectedOptions.value.filter((selectedOption, index) => {
307
+ return selectedOptions.value.filter((_, index) => {
300
308
  const limit = typeof optionsLimitIncreaser.value === "number"
301
309
  ? optionsLimitIncreaser.value
302
310
  : optionsLimitIncreaser.value.value;
@@ -30,7 +30,6 @@
30
30
  :auto-select-search-value="autoSelectSearchValue"
31
31
  :create-on-the-go="createOnTheGo"
32
32
  :disabled="disabled"
33
- :dropdown-active="dropdownActive"
34
33
  :loading="internalLoading"
35
34
  :icon-filter="iconFilter"
36
35
  :multiple="multiple"
@@ -64,7 +63,21 @@
64
63
  >
65
64
  </slot>
66
65
  </template>
67
- <template #optionBlock="{ label, deselectBlock, index }">
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
+ >
68
81
  <slot
69
82
  name="optionBlock"
70
83
  :label="label"
@@ -74,6 +87,7 @@
74
87
  </slot>
75
88
  </template>
76
89
  <template
90
+ v-if="slots.maxElements"
77
91
  #maxElements
78
92
  >
79
93
  <slot name="maxElements"></slot>
@@ -125,7 +139,7 @@
125
139
  :emitter="emitter"
126
140
  />
127
141
  </slot>
128
- </div>
142
+ </div>
129
143
  </div>
130
144
  <transition
131
145
  name="extended-toggle"
@@ -185,7 +199,10 @@
185
199
  >
186
200
  <slot name="lessThanLimit"></slot>
187
201
  </template>
188
- <template #option="{ option, createCustomOptionLabel }">
202
+ <template
203
+ v-if="slots.option"
204
+ #option="{ option, createCustomOptionLabel }"
205
+ >
189
206
  <slot
190
207
  name="option"
191
208
  :option="option"
@@ -209,7 +226,10 @@
209
226
  >
210
227
  <slot name="noResults"></slot>
211
228
  </template>
212
- <template #noOptions>
229
+ <template
230
+ v-if="slots.noOptions"
231
+ #noOptions
232
+ >
213
233
  <slot name="noOptions"></slot>
214
234
  </template>
215
235
  <template
@@ -269,7 +289,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
269
289
 
270
290
  /**
271
291
  * @author Ridiger Daniil Dmitrievich, 2022
272
- * @version 1.9.8
292
+ * @version 1.10.1
273
293
  */
274
294
  const props = defineProps({
275
295
  /**
@@ -1124,7 +1144,7 @@ const restrictedOptions = computed(() => {
1124
1144
  if (!rawOptions.value) return [];
1125
1145
 
1126
1146
  return optionsCountRestriction.value
1127
- ? rawOptions.value.filter((option, index) => index + 1 <= optionsCountRestriction.value)
1147
+ ? rawOptions.value.filter((_, index) => index + 1 <= optionsCountRestriction.value)
1128
1148
  : rawOptions.value;
1129
1149
  });
1130
1150
 
@@ -1582,7 +1602,6 @@ const toggleCustomRestrictor = (mouseEvent, blockType) => {
1582
1602
  */
1583
1603
  const toggleDetector = (mouseEvent, pattern, mode) => {
1584
1604
  let target = mouseEvent.target;
1585
- const optionPattern = /^extended__multiselect-options_option/i;
1586
1605
 
1587
1606
  let filteredHasToggle = Array.prototype.filter.call(target.classList, (className) => {
1588
1607
  return pattern.test(className) === true;
@@ -426,7 +426,7 @@
426
426
  height: var(--icon-size-block);
427
427
  }
428
428
 
429
- .extended__multiselect-block--multiple {
429
+ .extended__multiselect-block--multiple > div {
430
430
  display: flex;
431
431
  flex-flow: row wrap;
432
432
  gap: var(--outer-gap);
@@ -785,7 +785,7 @@ describe("props", () => {
785
785
 
786
786
  await fireEvent.click(increaserWrapper.element);
787
787
 
788
- const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
788
+ const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple > div");
789
789
 
790
790
  expect(multipleWrapper.element.children).toHaveLength(2);
791
791
  expect(multipleWrapper.text()).toMatch(globalThis.OPTIONS[1].label);
@@ -999,8 +999,6 @@ describe("props", () => {
999
999
 
1000
1000
 
1001
1001
  it("correctly handles 'preselectedOptions' prop value", async () => {
1002
- expect.assertions(1);
1003
-
1004
1002
  const propsData = {
1005
1003
  defaultExpanded: true,
1006
1004
  multiple: true,
@@ -1010,9 +1008,14 @@ describe("props", () => {
1010
1008
 
1011
1009
  wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
1012
1010
 
1013
- const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple");
1011
+ const multipleWrapper = wrapper.find(".extended__multiselect-block--multiple > div");
1014
1012
 
1015
1013
  expect(multipleWrapper.element.children).toHaveLength(2);
1014
+
1015
+ const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
1016
+ const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
1017
+
1018
+ expect(optionsListWrapper.element.children).toHaveLength(2);
1016
1019
  });
1017
1020
 
1018
1021