vue3-extended-multiselect 1.5.2 → 1.5.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 +11 -2
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/components/Vue3ExtendedMultiselect.vue +40 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Patch notes
|
|
2
2
|
|
|
3
|
-
Current `vue3-extended-multiselect` version: **1.5.
|
|
3
|
+
Current `vue3-extended-multiselect` version: **1.5.4**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -199,4 +199,13 @@ Adding descriptive comments for some types in typings.
|
|
|
199
199
|
|
|
200
200
|
### 1.5.2 (2023-01-25)
|
|
201
201
|
|
|
202
|
-
* Fixing bug with empty class list in toggle restrictor when "disabled" prop equals true.
|
|
202
|
+
* Fixing bug with empty class list in toggle restrictor when "disabled" prop equals true.
|
|
203
|
+
|
|
204
|
+
### 1.5.3 (2023-01-25)
|
|
205
|
+
|
|
206
|
+
* Fixing bug with incorrect setting of preselected options from v-model.
|
|
207
|
+
* Fixing bug with incompatible single preselected option.
|
|
208
|
+
|
|
209
|
+
### 1.5.4 (2023-01-25)
|
|
210
|
+
|
|
211
|
+
* Removal of restrictions for preselected options from v-model.
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -253,7 +253,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
|
|
|
253
253
|
|
|
254
254
|
/**
|
|
255
255
|
* @author Ridiger Daniil Dmitrievich
|
|
256
|
-
* @version 1.5.
|
|
256
|
+
* @version 1.5.4
|
|
257
257
|
*/
|
|
258
258
|
|
|
259
259
|
const props = defineProps({
|
|
@@ -909,6 +909,7 @@ const {
|
|
|
909
909
|
label,
|
|
910
910
|
loading,
|
|
911
911
|
loaderIconFilter,
|
|
912
|
+
modelValue,
|
|
912
913
|
multiple,
|
|
913
914
|
options,
|
|
914
915
|
optionsCountRestriction,
|
|
@@ -1312,25 +1313,30 @@ const selectByEnter = (keyboardEvent) => {
|
|
|
1312
1313
|
* Sets preselected option provided by "preselectedOption" prop
|
|
1313
1314
|
* @function
|
|
1314
1315
|
* @emits extended:select-option
|
|
1316
|
+
* @param {UnionPropType} preselectedOption - option to be selected
|
|
1317
|
+
* @param {boolean} restriction - restriction of preselected option
|
|
1315
1318
|
*/
|
|
1316
|
-
const setPreselectedOption = () => {
|
|
1317
|
-
const availableOptionType = optionTypeRestrictor(preselectedOption
|
|
1319
|
+
const setPreselectedOption = (preselectedOption, restriction = true) => {
|
|
1320
|
+
const availableOptionType = optionTypeRestrictor(preselectedOption);
|
|
1318
1321
|
const mappedOptions = restrictedOptions.value.map((restrictedOption) => {
|
|
1319
1322
|
return JSON.stringify(restrictedOption);
|
|
1320
1323
|
});
|
|
1321
1324
|
|
|
1322
1325
|
if (!availableOptionType) return;
|
|
1323
|
-
if (!mappedOptions.includes(JSON.stringify(preselectedOption
|
|
1324
|
-
|
|
1326
|
+
if (!mappedOptions.includes(JSON.stringify(preselectedOption)) && restriction) {
|
|
1327
|
+
if (showInsertWarnings.value) {
|
|
1328
|
+
console.warn("vue-extended-multiselect: option in «preselectedOption» property should be the same as analogue in «options» property");
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1325
1331
|
return;
|
|
1326
1332
|
}
|
|
1327
1333
|
|
|
1328
|
-
const isObjectOrArray = typeof preselectedOption
|
|
1329
|
-
const label = createLabel(isObjectOrArray, preselectedOption
|
|
1334
|
+
const isObjectOrArray = typeof preselectedOption === "object";
|
|
1335
|
+
const label = createLabel(isObjectOrArray, preselectedOption);
|
|
1330
1336
|
|
|
1331
1337
|
emitter.value.emit("extended:select-option", {
|
|
1332
1338
|
label,
|
|
1333
|
-
option: preselectedOption
|
|
1339
|
+
option: preselectedOption,
|
|
1334
1340
|
});
|
|
1335
1341
|
};
|
|
1336
1342
|
|
|
@@ -1339,20 +1345,22 @@ const setPreselectedOption = () => {
|
|
|
1339
1345
|
* if "multiple" prop equals true
|
|
1340
1346
|
* @function
|
|
1341
1347
|
* @emits extended:select-option
|
|
1348
|
+
* @param {Array} preselectedOptions - options to be selected
|
|
1349
|
+
* @param {boolean} restriction - restriction of preselected options
|
|
1342
1350
|
*/
|
|
1343
|
-
const setPreselectedOptions = async () => {
|
|
1351
|
+
const setPreselectedOptions = async (preselectedOptions, restriction = true) => {
|
|
1344
1352
|
let allOptionsWereSelected = 0;
|
|
1345
1353
|
const mappedOptions = restrictedOptions.value.map((restrictedOption) => {
|
|
1346
1354
|
return JSON.stringify(restrictedOption);
|
|
1347
1355
|
});
|
|
1348
1356
|
|
|
1349
|
-
preselectedOptions.
|
|
1357
|
+
preselectedOptions.forEach((preselectedOption) => {
|
|
1350
1358
|
const availableOptionType = optionTypeRestrictor(preselectedOption);
|
|
1351
1359
|
|
|
1352
1360
|
if (!preselectedOption || !availableOptionType) return;
|
|
1353
1361
|
if (selectedOptions.value.includes(preselectedOption)) return;
|
|
1354
1362
|
|
|
1355
|
-
if (mappedOptions.includes(JSON.stringify(preselectedOption))) {
|
|
1363
|
+
if (mappedOptions.includes(JSON.stringify(preselectedOption)) || !restriction) {
|
|
1356
1364
|
const isObjectOrArray = typeof option === "object";
|
|
1357
1365
|
const label = createLabel(isObjectOrArray, preselectedOption);
|
|
1358
1366
|
|
|
@@ -1365,22 +1373,38 @@ const setPreselectedOptions = async () => {
|
|
|
1365
1373
|
}
|
|
1366
1374
|
});
|
|
1367
1375
|
|
|
1368
|
-
if (allOptionsWereSelected !== preselectedOptions.
|
|
1376
|
+
if (allOptionsWereSelected !== preselectedOptions.length && showInsertWarnings.value) {
|
|
1369
1377
|
console.warn("vue-extended-multiselect: options in «preselectedOptions» property should be the same as analogues in «options» property");
|
|
1370
1378
|
}
|
|
1371
1379
|
};
|
|
1372
1380
|
|
|
1373
1381
|
/**
|
|
1374
1382
|
* Determines conditions that control preselected options installattion
|
|
1383
|
+
* if "modelValue" prop is defined
|
|
1384
|
+
* @function
|
|
1385
|
+
*/
|
|
1386
|
+
const setPreselectedOptionsByModelValue = () => {
|
|
1387
|
+
if (!modelValue.value) return;
|
|
1388
|
+
|
|
1389
|
+
if (Array.isArray(modelValue.value) && multiple.value) {
|
|
1390
|
+
setPreselectedOptions(modelValue.value, false);
|
|
1391
|
+
} else {
|
|
1392
|
+
setPreselectedOption(modelValue.value, false);
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
/**
|
|
1397
|
+
* Determines conditions that control preselected options installattion
|
|
1398
|
+
* by "preselectedOption" and "preselectedOptions" props
|
|
1375
1399
|
* @function
|
|
1376
1400
|
*/
|
|
1377
1401
|
const setPreselectedOptionsByConditions = () => {
|
|
1378
1402
|
if (preselectedOption.value && !multiple.value) {
|
|
1379
|
-
setPreselectedOption();
|
|
1403
|
+
setPreselectedOption(preselectedOption.value);
|
|
1380
1404
|
}
|
|
1381
1405
|
|
|
1382
1406
|
if (preselectedOptions.value && multiple.value) {
|
|
1383
|
-
setPreselectedOptions();
|
|
1407
|
+
setPreselectedOptions(preselectedOptions.value);
|
|
1384
1408
|
}
|
|
1385
1409
|
};
|
|
1386
1410
|
|
|
@@ -1721,6 +1745,8 @@ onMounted(() => {
|
|
|
1721
1745
|
setPreselectedOptionsByConditions();
|
|
1722
1746
|
}
|
|
1723
1747
|
|
|
1748
|
+
setPreselectedOptionsByModelValue();
|
|
1749
|
+
|
|
1724
1750
|
if (
|
|
1725
1751
|
defaultExpanded.value
|
|
1726
1752
|
&& !inputDisabled.value
|