vue3-extended-multiselect 1.9.3 → 1.9.4

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.4**
4
4
 
5
5
  ***
6
6
 
@@ -349,4 +349,9 @@ 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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.9.3
1
+ # vue3-extended-multiselect v1.9.4
2
2
 
3
3
  ***
4
4
 
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.4",
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
@@ -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
  }
@@ -262,7 +262,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
262
262
 
263
263
  /**
264
264
  * @author Ridiger Daniil Dmitrievich, 2022
265
- * @version 1.9.3
265
+ * @version 1.9.4
266
266
  */
267
267
  const props = defineProps({
268
268
  /**
@@ -913,6 +913,7 @@ const emit = defineEmits([
913
913
  ]);
914
914
 
915
915
  const dropdownActive = ref(false);
916
+ const skipNextRemoval = ref(false);
916
917
  const externalOptionsLoader = ref(null);
917
918
  const chosenToggleAppearanceSide = ref(null);
918
919
  const selectedOptionsWatcher = ref(null);
@@ -1168,7 +1169,14 @@ watch(dropdownActive, (value) => {
1168
1169
  * @function
1169
1170
  */
1170
1171
  watch(modelValue, (value, prevValue) => {
1171
- if (JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))) return;
1172
+ if (
1173
+ JSON.stringify(toRaw(value)) === JSON.stringify(toRaw(prevValue))
1174
+ || skipNextRemoval.value
1175
+ ) {
1176
+ skipNextRemoval.value = false;
1177
+
1178
+ return;
1179
+ }
1172
1180
 
1173
1181
  setPreselectedOptionsByModelValue(true);
1174
1182
  }, { deep: true });
@@ -1761,7 +1769,12 @@ onBeforeMount(() => {
1761
1769
  */
1762
1770
  emit("clean", eventData);
1763
1771
 
1772
+ if (payload.skipNextRemoval) {
1773
+ skipNextRemoval.value = true;
1774
+ }
1775
+
1764
1776
  selectedOptions.value.splice(payload.index, 1);
1777
+
1765
1778
  return;
1766
1779
  } else {
1767
1780
  selectedOptions.value = [];