vue3-extended-multiselect 1.7.2 → 1.7.3
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 +6 -2
- package/README.md +1 -1
- package/jest.config.js +1 -1
- package/package.json +1 -1
- package/src/components/Vue3ExtendedMultiselect.vue +60 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Patch notes
|
|
2
2
|
|
|
3
|
-
Current `vue3-extended-multiselect` version: **1.7.
|
|
3
|
+
Current `vue3-extended-multiselect` version: **1.7.3**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -281,4 +281,8 @@ Adding descriptive comments for some types in typings.
|
|
|
281
281
|
|
|
282
282
|
### 1.7.2 (2023-02-07)
|
|
283
283
|
|
|
284
|
-
* Changing event type to collapse the list of options when clicking on another instance.
|
|
284
|
+
* Changing event type to collapse the list of options when clicking on another instance.
|
|
285
|
+
|
|
286
|
+
### 1.7.3 (2023-02-07)
|
|
287
|
+
|
|
288
|
+
* Fixing bug with disabled removal of selected options based on external modelValue changes.
|
package/README.md
CHANGED
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -262,7 +262,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
|
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* @author Ridiger Daniil Dmitrievich, 2022
|
|
265
|
-
* @version 1.7.
|
|
265
|
+
* @version 1.7.3
|
|
266
266
|
*/
|
|
267
267
|
|
|
268
268
|
const props = defineProps({
|
|
@@ -904,6 +904,7 @@ const emit = defineEmits([
|
|
|
904
904
|
const dropdownActive = ref(false);
|
|
905
905
|
const externalOptionsLoader = ref(null);
|
|
906
906
|
const chosenToggleAppearanceSide = ref(null);
|
|
907
|
+
const selectedOptionsWatcher = ref(null);
|
|
907
908
|
const rawOptions = ref([]);
|
|
908
909
|
const selectedOptions = ref([]);
|
|
909
910
|
const togglePattern = /^extended__multiselect-toggle_wrapper/i;
|
|
@@ -1150,21 +1151,11 @@ watch(dropdownActive, (value) => {
|
|
|
1150
1151
|
});
|
|
1151
1152
|
|
|
1152
1153
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
* if "resetSearchByValue" prop equals true
|
|
1154
|
+
* Changes selected options based on external modelValue changes
|
|
1155
1155
|
* @function
|
|
1156
|
-
* @emits extended:clear-field
|
|
1157
1156
|
*/
|
|
1158
|
-
watch(
|
|
1159
|
-
|
|
1160
|
-
emit("update:modelValue", value);
|
|
1161
|
-
} else {
|
|
1162
|
-
emit("update:modelValue", value[0]);
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
if (resetSearchByValue.value) {
|
|
1166
|
-
emitter.value.emit("extended:clear-field");
|
|
1167
|
-
}
|
|
1157
|
+
watch(modelValue, () => {
|
|
1158
|
+
setPreselectedOptionsByModelValue(true);
|
|
1168
1159
|
}, { deep: true });
|
|
1169
1160
|
|
|
1170
1161
|
/**
|
|
@@ -1266,6 +1257,25 @@ const loadOptionsByExternalLoader = (pattern, initialValue) => {
|
|
|
1266
1257
|
});
|
|
1267
1258
|
};
|
|
1268
1259
|
|
|
1260
|
+
/**
|
|
1261
|
+
* Makes removal of selected options based on external modelValue changes
|
|
1262
|
+
* @function
|
|
1263
|
+
* @param {boolean} single - "multiple" prop flag
|
|
1264
|
+
*/
|
|
1265
|
+
const removeSelectedOptions = (single = false) => {
|
|
1266
|
+
if (!single) {
|
|
1267
|
+
const modelValueMapped = modelValue.value.map((option) => {
|
|
1268
|
+
return JSON.stringify(option);
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
selectedOptions.value = selectedOptions.value.filter((option) => {
|
|
1272
|
+
return modelValueMapped.includes(JSON.stringify(option));
|
|
1273
|
+
});
|
|
1274
|
+
} else {
|
|
1275
|
+
if (!modelValue.value) cancel();
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1269
1279
|
/**
|
|
1270
1280
|
* Emits event whose listener resets index of "enter" key pressing
|
|
1271
1281
|
* @function
|
|
@@ -1377,15 +1387,36 @@ const setPreselectedOptions = async (preselectedOptions, restriction = true) =>
|
|
|
1377
1387
|
* Determines conditions that control preselected options installattion
|
|
1378
1388
|
* if "modelValue" prop is defined
|
|
1379
1389
|
* @function
|
|
1390
|
+
* @param {boolean} withRemoval - removal of selected options flag
|
|
1380
1391
|
*/
|
|
1381
|
-
const setPreselectedOptionsByModelValue = () => {
|
|
1382
|
-
if (!modelValue.value) return;
|
|
1392
|
+
const setPreselectedOptionsByModelValue = (withRemoval = false) => {
|
|
1393
|
+
if (!modelValue.value && !withRemoval) return;
|
|
1394
|
+
|
|
1395
|
+
if (withRemoval) selectedOptionsWatcher.value();
|
|
1396
|
+
|
|
1397
|
+
if (multiple.value) {
|
|
1398
|
+
if (withRemoval) removeSelectedOptions();
|
|
1383
1399
|
|
|
1384
|
-
if (Array.isArray(modelValue.value) && multiple.value) {
|
|
1385
1400
|
setPreselectedOptions(modelValue.value, false);
|
|
1386
1401
|
} else {
|
|
1402
|
+
if (withRemoval) removeSelectedOptions(true);
|
|
1403
|
+
|
|
1387
1404
|
setPreselectedOption(modelValue.value, false);
|
|
1388
1405
|
}
|
|
1406
|
+
|
|
1407
|
+
if (withRemoval) {
|
|
1408
|
+
selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
|
|
1409
|
+
if (multiple.value) {
|
|
1410
|
+
emit("update:modelValue", value);
|
|
1411
|
+
} else {
|
|
1412
|
+
emit("update:modelValue", value[0]);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
if (resetSearchByValue.value) {
|
|
1416
|
+
emitter.value.emit("extended:clear-field");
|
|
1417
|
+
}
|
|
1418
|
+
}, { deep: true });
|
|
1419
|
+
}
|
|
1389
1420
|
}
|
|
1390
1421
|
|
|
1391
1422
|
/**
|
|
@@ -1628,6 +1659,18 @@ const toggleRestrictor = (mouseEvent) => {
|
|
|
1628
1659
|
* @listens extended:search-pattern-changed
|
|
1629
1660
|
*/
|
|
1630
1661
|
onBeforeMount(() => {
|
|
1662
|
+
selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
|
|
1663
|
+
if (multiple.value) {
|
|
1664
|
+
emit("update:modelValue", value);
|
|
1665
|
+
} else {
|
|
1666
|
+
emit("update:modelValue", value[0]);
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
if (resetSearchByValue.value) {
|
|
1670
|
+
emitter.value.emit("extended:clear-field");
|
|
1671
|
+
}
|
|
1672
|
+
}, { deep: true });
|
|
1673
|
+
|
|
1631
1674
|
chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
|
|
1632
1675
|
|
|
1633
1676
|
emitter.value.on("extended:rollup-options", () => {
|