vue3-extended-multiselect 1.9.3 → 1.9.5

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.3**
3
+ Current `vue3-extended-multiselect` version: **1.9.5**
4
4
 
5
5
  ***
6
6
 
@@ -349,4 +349,13 @@ Adding descriptive comments for some types in typings.
349
349
 
350
350
  ### 1.9.3 (2023-03-22)
351
351
 
352
- * Fixing a bug with v-model not clearing by computed property.
352
+ * Fixing bug with v-model not clearing by computed property.
353
+
354
+ ### 1.9.4 (2023-03-23)
355
+
356
+ * Fixing bug with hidden placeholder when "showSearchField" prop is set to false.
357
+ * Fixing bug with deselection of all options when "showSelectedOptions" prop is set to true.
358
+
359
+ ### 1.9.5 (2023-03-23)
360
+
361
+ * Adding "selected" flag to "marker" slot.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.9.3
1
+ # vue3-extended-multiselect v1.9.5
2
2
 
3
3
  ***
4
4
 
@@ -100,7 +100,7 @@ Slot name | Slot appointment | Slot scope
100
100
  ----------|------------------|-----------
101
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
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|
103
- **marker**|Marker that indicates state of option selection.|&mdash;|
103
+ **marker**|Marker that indicates state of option selection.|``selected`` — flag to determine markers for selected options|
104
104
  **maxElements**|Message displayed if maximal limit of elements with selected options has been shown.|&mdash;|
105
105
  **showMore**|Button that increases limit of displayed elements with selected options.|``showMoreOptions`` — function that increases limit of displayed elements with selected options|
106
106
  **noResults**|Message displayed if no options have been found by internal search.|&mdash;|
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.9.3",
3
+ "version": "1.9.5",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -84,8 +84,10 @@
84
84
  :disabled="disabled"
85
85
  :loading="loading"
86
86
  :icon-filter="iconFilter"
87
+ :placeholder-block-shown="!selectedOptions.length"
87
88
  :show-deselect-icon-loader="showDeselectIconLoader"
88
89
  :toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
90
+ :appropriate-placeholder="appropriatePlaceholder"
89
91
  :empty-objects-placeholder="emptyObjectsPlaceholder"
90
92
  :label="label"
91
93
  :multiple-blocks-limit-message="multipleBlocksLimitMessage"
@@ -127,6 +129,12 @@
127
129
  class="extended__multiselect-block"
128
130
  v-else
129
131
  >
132
+ <span
133
+ v-if="placeholderBlockShown"
134
+ class="extended__multiselect-placeholder"
135
+ >
136
+ {{ appropriatePlaceholder }}
137
+ </span>
130
138
  <slot
131
139
  name="labelBlock"
132
140
  :label-block-value="singleLabel"
@@ -1,5 +1,11 @@
1
1
  <template>
2
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>
3
9
  <div
4
10
  v-for="(option, index) in limitRestriction"
5
11
  :key="index"
@@ -66,6 +72,16 @@ import useLabels from "../composition/labels";
66
72
  import ExtendedMultiselectLoader from "./ExtendedMultiselectLoader.vue";
67
73
 
68
74
  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
+
69
85
  /**
70
86
  * Function that creates custom label for
71
87
  * block with selected option
@@ -169,6 +185,16 @@ const props = defineProps({
169
185
  required: true,
170
186
  },
171
187
 
188
+ /**
189
+ * Determines whether to show extended multiselect
190
+ * placeholder element
191
+ * @property {boolean} placeholderBlockShown
192
+ */
193
+ placeholderBlockShown: {
194
+ type: Boolean,
195
+ default: false,
196
+ },
197
+
172
198
  /**
173
199
  * List of selected options that will be shown as option blocks
174
200
  * @property {Array} selectedOptions
@@ -55,7 +55,7 @@
55
55
  <div class="extended__multiselect-marker">
56
56
  <slot
57
57
  name="marker"
58
- :option="option"
58
+ :selected="showCurrentMarker(option)"
59
59
  >
60
60
  <div
61
61
  v-if="showMarker && showCurrentMarker(option)"
@@ -1061,7 +1061,12 @@ const selectOption = (option, clickEvent) => {
1061
1061
  const optionDeselected = lookForObjectOptions(option);
1062
1062
 
1063
1063
  if (!optionDeselected) {
1064
- emitter.value.emit("extended:deselect-option");
1064
+ const index = selectedOptions.value.findIndex((selectedOption) => {
1065
+ return JSON.stringify(selectedOption) === JSON.stringify(option);
1066
+ });
1067
+
1068
+ emitter.value.emit("extended:deselect-option", { skipNextRemoval: true, index });
1069
+
1065
1070
  return;
1066
1071
  }
1067
1072
  }
@@ -193,8 +193,15 @@
193
193
  >
194
194
  </slot>
195
195
  </template>
196
- <template #marker>
197
- <slot name="marker"></slot>
196
+ <template
197
+ v-if="slots.marker"
198
+ #marker="{ selected }"
199
+ >
200
+ <slot
201
+ name="marker"
202
+ :selected="selected"
203
+ >
204
+ </slot>
198
205
  </template>
199
206
  <template
200
207
  v-if="noResultsBlockShown"
@@ -262,7 +269,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
262
269
 
263
270
  /**
264
271
  * @author Ridiger Daniil Dmitrievich, 2022
265
- * @version 1.9.3
272
+ * @version 1.9.5
266
273
  */
267
274
  const props = defineProps({
268
275
  /**
@@ -913,6 +920,7 @@ const emit = defineEmits([
913
920
  ]);
914
921
 
915
922
  const dropdownActive = ref(false);
923
+ const skipNextRemoval = ref(false);
916
924
  const externalOptionsLoader = ref(null);
917
925
  const chosenToggleAppearanceSide = ref(null);
918
926
  const selectedOptionsWatcher = ref(null);
@@ -1168,7 +1176,14 @@ watch(dropdownActive, (value) => {
1168
1176
  * @function
1169
1177
  */
1170
1178
  watch(modelValue, (value, prevValue) => {
1171
- if (JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))) return;
1179
+ if (
1180
+ JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))
1181
+ || skipNextRemoval.value
1182
+ ) {
1183
+ skipNextRemoval.value = false;
1184
+
1185
+ return;
1186
+ }
1172
1187
 
1173
1188
  setPreselectedOptionsByModelValue(true);
1174
1189
  }, { deep: true });
@@ -1761,7 +1776,13 @@ onBeforeMount(() => {
1761
1776
  */
1762
1777
  emit("clean", eventData);
1763
1778
 
1779
+ if (payload.skipNextRemoval) {
1780
+ skipNextRemoval.value = true;
1781
+ }
1782
+
1764
1783
  selectedOptions.value.splice(payload.index, 1);
1784
+ updateModelValue();
1785
+
1765
1786
  return;
1766
1787
  } else {
1767
1788
  selectedOptions.value = [];