vue3-extended-multiselect 1.7.2 → 1.7.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 +10 -2
- package/README.md +2 -1
- package/jest.config.js +1 -1
- package/package.json +1 -1
- package/src/components/Vue3ExtendedMultiselect.vue +68 -18
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.4**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -281,4 +281,12 @@ 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.
|
|
289
|
+
|
|
290
|
+
### 1.7.4 (2023-02-07)
|
|
291
|
+
|
|
292
|
+
* Adding "update:wrapper" event.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# vue3-extended-multiselect v1.7.
|
|
1
|
+
# vue3-extended-multiselect v1.7.4
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -122,6 +122,7 @@ Event name | Event appointment | Listener method | Simplified event payload | Fi
|
|
|
122
122
|
**active**|Dropdown options list expanding.|@active|—|``inputId`` — id of search field set by "id" prop|
|
|
123
123
|
**close**|Rolling up dropdown options list.|@close|``options`` — array of selected options|``options`` — array of selected options,<br/>``inputId`` — id of search field set by "id" prop|
|
|
124
124
|
**increase**|Increasing current limit of displayed elements with selected options.|@increase|``limit`` — current limit of options to be shown next|``limit`` — current limit of options to be shown next,<br/>``inputId`` — id of search field set by "id" prop|
|
|
125
|
+
**update:wrapper**|Notifies wrapper component that inner modelValue has been updated by external modelValue update|@update:wrapper|``options`` — array of selected options|``options`` — array of selected options,<br/>``inputId`` — id of search field set by "id" prop|
|
|
125
126
|
|
|
126
127
|
## Styling with css
|
|
127
128
|
|
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.4
|
|
266
266
|
*/
|
|
267
267
|
|
|
268
268
|
const props = defineProps({
|
|
@@ -898,12 +898,14 @@ const emit = defineEmits([
|
|
|
898
898
|
"option-created",
|
|
899
899
|
"pattern-changed",
|
|
900
900
|
"select",
|
|
901
|
-
"update:modelValue"
|
|
901
|
+
"update:modelValue",
|
|
902
|
+
"update:wrapper"
|
|
902
903
|
]);
|
|
903
904
|
|
|
904
905
|
const dropdownActive = ref(false);
|
|
905
906
|
const externalOptionsLoader = ref(null);
|
|
906
907
|
const chosenToggleAppearanceSide = ref(null);
|
|
908
|
+
const selectedOptionsWatcher = ref(null);
|
|
907
909
|
const rawOptions = ref([]);
|
|
908
910
|
const selectedOptions = ref([]);
|
|
909
911
|
const togglePattern = /^extended__multiselect-toggle_wrapper/i;
|
|
@@ -1150,21 +1152,11 @@ watch(dropdownActive, (value) => {
|
|
|
1150
1152
|
});
|
|
1151
1153
|
|
|
1152
1154
|
/**
|
|
1153
|
-
*
|
|
1154
|
-
* if "resetSearchByValue" prop equals true
|
|
1155
|
+
* Changes selected options based on external modelValue changes
|
|
1155
1156
|
* @function
|
|
1156
|
-
* @emits extended:clear-field
|
|
1157
1157
|
*/
|
|
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
|
-
}
|
|
1158
|
+
watch(modelValue, () => {
|
|
1159
|
+
setPreselectedOptionsByModelValue(true);
|
|
1168
1160
|
}, { deep: true });
|
|
1169
1161
|
|
|
1170
1162
|
/**
|
|
@@ -1266,6 +1258,25 @@ const loadOptionsByExternalLoader = (pattern, initialValue) => {
|
|
|
1266
1258
|
});
|
|
1267
1259
|
};
|
|
1268
1260
|
|
|
1261
|
+
/**
|
|
1262
|
+
* Makes removal of selected options based on external modelValue changes
|
|
1263
|
+
* @function
|
|
1264
|
+
* @param {boolean} single - "multiple" prop flag
|
|
1265
|
+
*/
|
|
1266
|
+
const removeSelectedOptions = (single = false) => {
|
|
1267
|
+
if (!single) {
|
|
1268
|
+
const modelValueMapped = modelValue.value.map((option) => {
|
|
1269
|
+
return JSON.stringify(option);
|
|
1270
|
+
});
|
|
1271
|
+
|
|
1272
|
+
selectedOptions.value = selectedOptions.value.filter((option) => {
|
|
1273
|
+
return modelValueMapped.includes(JSON.stringify(option));
|
|
1274
|
+
});
|
|
1275
|
+
} else {
|
|
1276
|
+
if (!modelValue.value) cancel();
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1269
1280
|
/**
|
|
1270
1281
|
* Emits event whose listener resets index of "enter" key pressing
|
|
1271
1282
|
* @function
|
|
@@ -1377,15 +1388,42 @@ const setPreselectedOptions = async (preselectedOptions, restriction = true) =>
|
|
|
1377
1388
|
* Determines conditions that control preselected options installattion
|
|
1378
1389
|
* if "modelValue" prop is defined
|
|
1379
1390
|
* @function
|
|
1391
|
+
* @emits update:wrapper
|
|
1392
|
+
* @param {boolean} withRemoval - removal of selected options flag
|
|
1380
1393
|
*/
|
|
1381
|
-
const setPreselectedOptionsByModelValue = () => {
|
|
1382
|
-
if (!modelValue.value) return;
|
|
1394
|
+
const setPreselectedOptionsByModelValue = (withRemoval = false) => {
|
|
1395
|
+
if (!modelValue.value && !withRemoval) return;
|
|
1396
|
+
|
|
1397
|
+
if (withRemoval) selectedOptionsWatcher.value();
|
|
1398
|
+
|
|
1399
|
+
if (multiple.value) {
|
|
1400
|
+
if (withRemoval) removeSelectedOptions();
|
|
1383
1401
|
|
|
1384
|
-
if (Array.isArray(modelValue.value) && multiple.value) {
|
|
1385
1402
|
setPreselectedOptions(modelValue.value, false);
|
|
1386
1403
|
} else {
|
|
1404
|
+
if (withRemoval) removeSelectedOptions(true);
|
|
1405
|
+
|
|
1387
1406
|
setPreselectedOption(modelValue.value, false);
|
|
1388
1407
|
}
|
|
1408
|
+
|
|
1409
|
+
if (withRemoval) {
|
|
1410
|
+
const eventData = simpleEvents.value
|
|
1411
|
+
? selectedOptions.value
|
|
1412
|
+
: createEventFields(selectedOptions.value, "options");
|
|
1413
|
+
|
|
1414
|
+
emit("update:wrapper", eventData);
|
|
1415
|
+
selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
|
|
1416
|
+
if (multiple.value) {
|
|
1417
|
+
emit("update:modelValue", value);
|
|
1418
|
+
} else {
|
|
1419
|
+
emit("update:modelValue", value[0]);
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
if (resetSearchByValue.value) {
|
|
1423
|
+
emitter.value.emit("extended:clear-field");
|
|
1424
|
+
}
|
|
1425
|
+
}, { deep: true });
|
|
1426
|
+
}
|
|
1389
1427
|
}
|
|
1390
1428
|
|
|
1391
1429
|
/**
|
|
@@ -1628,6 +1666,18 @@ const toggleRestrictor = (mouseEvent) => {
|
|
|
1628
1666
|
* @listens extended:search-pattern-changed
|
|
1629
1667
|
*/
|
|
1630
1668
|
onBeforeMount(() => {
|
|
1669
|
+
selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
|
|
1670
|
+
if (multiple.value) {
|
|
1671
|
+
emit("update:modelValue", value);
|
|
1672
|
+
} else {
|
|
1673
|
+
emit("update:modelValue", value[0]);
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
if (resetSearchByValue.value) {
|
|
1677
|
+
emitter.value.emit("extended:clear-field");
|
|
1678
|
+
}
|
|
1679
|
+
}, { deep: true });
|
|
1680
|
+
|
|
1631
1681
|
chosenToggleAppearanceSide.value = toggleAppearanceSide.value;
|
|
1632
1682
|
|
|
1633
1683
|
emitter.value.on("extended:rollup-options", () => {
|