vue3-extended-multiselect 1.8.0 → 1.8.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.8.0**
3
+ Current `vue3-extended-multiselect` version: **1.8.1**
4
4
 
5
5
  ***
6
6
 
@@ -302,4 +302,9 @@ Adding descriptive comments for some types in typings.
302
302
  * Adding type for "update-wrapper" event.
303
303
  * Adding tools.spec.js file with unit-tests for tools.
304
304
  * Moving local emitter files to tools directory.
305
- * Removal of "lodash-es" dependency.
305
+ * Removal of "lodash-es" dependency.
306
+
307
+ ### 1.8.1 (2023-02-21)
308
+
309
+ * Removal of "update:wrapper" event.
310
+ * Fixing bug with incorrect v-model updating in custom wrappers.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # vue3-extended-multiselect v1.8.0
1
+ # vue3-extended-multiselect v1.8.1
2
2
 
3
3
  ***
4
4
 
@@ -122,7 +122,6 @@ 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|
126
125
 
127
126
  ## Styling with css
128
127
 
package/jest.config.js CHANGED
@@ -5,7 +5,7 @@ module.exports = {
5
5
  },
6
6
  expand: true,
7
7
  displayName: {
8
- name: "vue3-extended-multiselect 1.8.0",
8
+ name: "vue3-extended-multiselect 1.8.1",
9
9
  color: "bgGreen",
10
10
  },
11
11
  extraGlobals: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-extended-multiselect",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Extended multiselect component for applications based on Vue 3 framework",
5
5
  "keywords": [
6
6
  "multiselect",
@@ -262,7 +262,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
262
262
 
263
263
  /**
264
264
  * @author Ridiger Daniil Dmitrievich, 2022
265
- * @version 1.8.0
265
+ * @version 1.8.1
266
266
  */
267
267
 
268
268
  const props = defineProps({
@@ -903,6 +903,7 @@ const emit = defineEmits([
903
903
  ]);
904
904
 
905
905
  const dropdownActive = ref(false);
906
+ const skipNextUpdate = ref(false);
906
907
  const externalOptionsLoader = ref(null);
907
908
  const chosenToggleAppearanceSide = ref(null);
908
909
  const selectedOptionsWatcher = ref(null);
@@ -1086,6 +1087,17 @@ const internalLoading = computed(() => {
1086
1087
  return loading.value;
1087
1088
  });
1088
1089
 
1090
+ /**
1091
+ * Defines mapped list of previously restricted options
1092
+ * @function
1093
+ * @returns {Array} options
1094
+ */
1095
+ const mappedOptions = computed(() => {
1096
+ return restrictedOptions.value.map((restrictedOption) => {
1097
+ return JSON.stringify(restrictedOption);
1098
+ });
1099
+ });
1100
+
1089
1101
  /**
1090
1102
  * Defines a list of options filtered by maximal admissible options amount
1091
1103
  * @function
@@ -1156,6 +1168,11 @@ watch(dropdownActive, (value) => {
1156
1168
  * @function
1157
1169
  */
1158
1170
  watch(modelValue, () => {
1171
+ if (skipNextUpdate.value) {
1172
+ skipNextUpdate.value = false;
1173
+ return;
1174
+ }
1175
+
1159
1176
  setPreselectedOptionsByModelValue(true);
1160
1177
  }, { deep: true });
1161
1178
 
@@ -1324,12 +1341,15 @@ const selectByEnter = (keyboardEvent) => {
1324
1341
  */
1325
1342
  const setPreselectedOption = (preselectedOption, restriction = true) => {
1326
1343
  const availableOptionType = optionTypeRestrictor(preselectedOption);
1327
- const mappedOptions = restrictedOptions.value.map((restrictedOption) => {
1328
- return JSON.stringify(restrictedOption);
1344
+ const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1345
+ return JSON.stringify(selectedOption);
1329
1346
  });
1330
1347
 
1331
1348
  if (!availableOptionType) return;
1332
- if (!mappedOptions.includes(JSON.stringify(preselectedOption)) && restriction) {
1349
+ if (
1350
+ (!mappedOptions.value.includes(JSON.stringify(preselectedOption)) && restriction)
1351
+ && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1352
+ ) {
1333
1353
  if (showInsertWarnings.value) {
1334
1354
  console.warn("vue-extended-multiselect: option in «preselectedOption» property should be the same as analogue in «options» property");
1335
1355
  }
@@ -1356,8 +1376,8 @@ const setPreselectedOption = (preselectedOption, restriction = true) => {
1356
1376
  */
1357
1377
  const setPreselectedOptions = async (preselectedOptions, restriction = true) => {
1358
1378
  let allOptionsWereSelected = 0;
1359
- const mappedOptions = restrictedOptions.value.map((restrictedOption) => {
1360
- return JSON.stringify(restrictedOption);
1379
+ const mappedSelectedOptions = selectedOptions.value.map((selectedOption) => {
1380
+ return JSON.stringify(selectedOption);
1361
1381
  });
1362
1382
 
1363
1383
  preselectedOptions.forEach((preselectedOption) => {
@@ -1366,7 +1386,10 @@ const setPreselectedOptions = async (preselectedOptions, restriction = true) =>
1366
1386
  if (!preselectedOption || !availableOptionType) return;
1367
1387
  if (selectedOptions.value.includes(preselectedOption)) return;
1368
1388
 
1369
- if (mappedOptions.includes(JSON.stringify(preselectedOption)) || !restriction) {
1389
+ if (
1390
+ (mappedOptions.value.includes(JSON.stringify(preselectedOption)) || !restriction)
1391
+ && !mappedSelectedOptions.includes(JSON.stringify(preselectedOption))
1392
+ ) {
1370
1393
  const isObjectOrArray = typeof option === "object";
1371
1394
  const label = createLabel(isObjectOrArray, preselectedOption);
1372
1395
 
@@ -1407,11 +1430,14 @@ const setPreselectedOptionsByModelValue = (withRemoval = false) => {
1407
1430
  }
1408
1431
 
1409
1432
  if (withRemoval) {
1410
- const eventData = simpleEvents.value
1411
- ? selectedOptions.value
1412
- : createEventFields(selectedOptions.value, "options");
1433
+ if (multiple.value) {
1434
+ emit("update:modelValue", selectedOptions.value);
1435
+ } else {
1436
+ emit("update:modelValue", selectedOptions.value[0]);
1437
+ }
1438
+
1439
+ skipNextUpdate.value = true;
1413
1440
 
1414
- emit("update:wrapper", eventData);
1415
1441
  selectedOptionsWatcher.value = watch(selectedOptions, (value) => {
1416
1442
  if (multiple.value) {
1417
1443
  emit("update:modelValue", value);