vue3-extended-multiselect 1.1.5 → 1.1.7
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.1.
|
|
3
|
+
Current `vue3-extended-multiselect` version: **1.1.7**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -112,9 +112,17 @@ Adding descriptive comments for some types in typings.
|
|
|
112
112
|
* Adding "searchByField" optional prop.
|
|
113
113
|
* Adding unit-test for new optional prop.
|
|
114
114
|
|
|
115
|
-
### 1.1.4 (2022-13
|
|
115
|
+
### 1.1.4 (2022-12-13)
|
|
116
116
|
* Adding "optionCreateLabel" to expose as utility.
|
|
117
117
|
* Fix bug with wrong name of label field
|
|
118
118
|
|
|
119
|
-
### 1.1.5 (2022-
|
|
120
|
-
* Fix bug with empty raw options list when using async loader.
|
|
119
|
+
### 1.1.5 (2022-12-14)
|
|
120
|
+
* Fix bug with empty raw options list when using async loader.
|
|
121
|
+
|
|
122
|
+
### 1.1.6 (2022-12-14)
|
|
123
|
+
* Fix bug with extra call of async loader by changing value of search field.
|
|
124
|
+
* Adding new internal prop "externalOptionsLoader" to ExtendedMultiselectInput.
|
|
125
|
+
* Searching for options by async loader is moved to in separate method.
|
|
126
|
+
|
|
127
|
+
### 1.1.7 (2022-12-15)
|
|
128
|
+
* Adding "disableByField" prop for determination of field in options of type "object" which value will be used to disable such options.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# vue3-extended-multiselect v1.1.
|
|
1
|
+
# vue3-extended-multiselect v1.1.7
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -60,6 +60,7 @@ Prop name | Prop type | Prop appointment | Prop default value | Prop values
|
|
|
60
60
|
**wrongCurrent<br/>Value**|Boolean|Determines whether to define special class for extended multiselect if value is wrong or if irregularity of value is defined by user.|false|—|
|
|
61
61
|
**createOption<br/>Placeholder**|String|Placeholder for the search field to be used if user is allowed to create new options.|"Select or create features"|—|
|
|
62
62
|
**createOption<br/>Type**|String|Defines kind for all options which will be created by user.|"primitive"| "primitive", "array", "object"|
|
|
63
|
+
**disableByField**|String|Determines a field in options of type "object" which value will be used to disable such options.|"disabled"|—|
|
|
63
64
|
**emptyObjects<br/>Placeholder**|String|Placeholder for options of type "object" or Array instances which length/keys length equals 0.|"Empty Object/<br/>Array"|—|
|
|
64
65
|
**errorBorder<br/>Color**|String|Defines "border-color" css-property for extended multiselect with wrong value.|"#FF0000"|—|
|
|
65
66
|
**iconFilter**|String|Defines svg-filter with color settings for all icons except loader.|"basic"|"basic", "black", "green"|
|
package/package.json
CHANGED
|
@@ -336,6 +336,17 @@ const props = defineProps({
|
|
|
336
336
|
required: true,
|
|
337
337
|
},
|
|
338
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Loader function provided by user.
|
|
341
|
+
* @property {Function} externalOptionsLoader
|
|
342
|
+
* @default null
|
|
343
|
+
* @param {string} value - value of search field
|
|
344
|
+
*/
|
|
345
|
+
externalOptionsLoader: {
|
|
346
|
+
type: Function,
|
|
347
|
+
default: null,
|
|
348
|
+
},
|
|
349
|
+
|
|
339
350
|
/**
|
|
340
351
|
* Provides function that creates limit message for maximal of selected
|
|
341
352
|
* options to ExtendedMultiselectMultiple child component
|
|
@@ -372,9 +383,13 @@ const blurSkipByBlock = ref(0);
|
|
|
372
383
|
const labelBlocks = ref([]);
|
|
373
384
|
const searchDebounce = ref(debounce(() => {
|
|
374
385
|
const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
|
|
375
|
-
emitter.emit("extended:search-pattern-changed", searchValue.value);
|
|
376
386
|
|
|
377
|
-
|
|
387
|
+
if (externalOptionsLoader.value) {
|
|
388
|
+
emitter.emit("extended:loader-pattern-changed", searchValue.value);
|
|
389
|
+
} else {
|
|
390
|
+
emitter.emit("extended:search-pattern-changed", searchValue.value);
|
|
391
|
+
setSearchPattern(searchPattern);
|
|
392
|
+
}
|
|
378
393
|
}, 250));
|
|
379
394
|
|
|
380
395
|
/**
|
|
@@ -386,6 +401,7 @@ const {
|
|
|
386
401
|
createOnTheGo,
|
|
387
402
|
createOptionPlaceholder,
|
|
388
403
|
disabled,
|
|
404
|
+
externalOptionsLoader,
|
|
389
405
|
increaseDisplayBy,
|
|
390
406
|
multiple,
|
|
391
407
|
placeholder,
|
|
@@ -207,6 +207,16 @@ const props = defineProps({
|
|
|
207
207
|
required: true,
|
|
208
208
|
},
|
|
209
209
|
|
|
210
|
+
/**
|
|
211
|
+
* Determines a field in options of type "object"
|
|
212
|
+
* which value will be used to disable such options.
|
|
213
|
+
* @property {string} disableByField
|
|
214
|
+
*/
|
|
215
|
+
disableByField: {
|
|
216
|
+
type: String,
|
|
217
|
+
required: true,
|
|
218
|
+
},
|
|
219
|
+
|
|
210
220
|
/**
|
|
211
221
|
* Sets labels for options of type "object"
|
|
212
222
|
* or Array instances which length/keys length equals 0
|
|
@@ -412,6 +422,7 @@ const {
|
|
|
412
422
|
createCustomOptionLabel,
|
|
413
423
|
createOptionFields,
|
|
414
424
|
createOptionType,
|
|
425
|
+
disableByField,
|
|
415
426
|
disabledPrimitiveOptionsConverted,
|
|
416
427
|
emptyObjectsPlaceholder,
|
|
417
428
|
highlightOptions,
|
|
@@ -904,7 +915,7 @@ const optionCreateRole = (option) => {
|
|
|
904
915
|
* @returns {boolean} blocking
|
|
905
916
|
*/
|
|
906
917
|
const optionIsDisabled = (option) => {
|
|
907
|
-
if (option.
|
|
918
|
+
if (option[disableByField.value] || defineDisabledOption(option)) return true;
|
|
908
919
|
|
|
909
920
|
return false;
|
|
910
921
|
}
|
|
@@ -944,7 +955,7 @@ const optionHighlightClasses = (option) => {
|
|
|
944
955
|
theme.push("extended__multiselect-options_option--marker");
|
|
945
956
|
}
|
|
946
957
|
|
|
947
|
-
if (option && option.
|
|
958
|
+
if (option && option[disableByField.value]) {
|
|
948
959
|
theme.push("extended__multiselect-options_option--disabled");
|
|
949
960
|
}
|
|
950
961
|
|
|
@@ -968,7 +979,7 @@ const selectOption = (option, clickEvent) => {
|
|
|
968
979
|
if (!clickEvent) return;
|
|
969
980
|
if (keyBlocker(clickEvent)) return;
|
|
970
981
|
if (maxOptionsWereSelected.value) return;
|
|
971
|
-
if (option.
|
|
982
|
+
if (option[disableByField.value] || defineDisabledOption(option)) return;
|
|
972
983
|
if (
|
|
973
984
|
clickEvent.target.id === "extended__multiselect-toggle"
|
|
974
985
|
|| clickEvent.target.id === "extended__multiselect-cancel"
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
:create-on-the-go="createOnTheGo"
|
|
32
32
|
:disabled="inputDisabled"
|
|
33
33
|
:dropdown-active="dropdownActive"
|
|
34
|
+
:external-options-loader="externalOptionsLoader"
|
|
34
35
|
:loading="internalLoading"
|
|
35
36
|
:multiple="multiple"
|
|
36
37
|
:search-filter-active="searchFilterActive"
|
|
@@ -135,6 +136,7 @@
|
|
|
135
136
|
:show-marker="showMarker"
|
|
136
137
|
:chosen-toggle-appearance-side="chosenToggleAppearanceSide"
|
|
137
138
|
:create-option-type="createOptionType"
|
|
139
|
+
:disable-by-field="disableByField"
|
|
138
140
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
139
141
|
:label="label"
|
|
140
142
|
:search-by-field="searchByField"
|
|
@@ -491,6 +493,17 @@ const props = defineProps({
|
|
|
491
493
|
},
|
|
492
494
|
},
|
|
493
495
|
|
|
496
|
+
/**
|
|
497
|
+
* Determines a field in options of type "object"
|
|
498
|
+
* which value will be used to disable such options.
|
|
499
|
+
* @default "disabled"
|
|
500
|
+
* @property {string} disableByField
|
|
501
|
+
*/
|
|
502
|
+
disableByField: {
|
|
503
|
+
type: String,
|
|
504
|
+
default: "disabled",
|
|
505
|
+
},
|
|
506
|
+
|
|
494
507
|
/**
|
|
495
508
|
* Placeholder for options of type "object"
|
|
496
509
|
* or Array instances which length/keys length equals 0
|
|
@@ -805,7 +818,7 @@ const props = defineProps({
|
|
|
805
818
|
|
|
806
819
|
/**
|
|
807
820
|
* Defines function that creates custom label for each option
|
|
808
|
-
* @default ()=>null
|
|
821
|
+
* @default (option)=>null
|
|
809
822
|
* @property {Function} createCustomOptionLabel
|
|
810
823
|
*/
|
|
811
824
|
createCustomOptionLabel: {
|
|
@@ -816,7 +829,7 @@ const props = defineProps({
|
|
|
816
829
|
/**
|
|
817
830
|
* Defines function that creates notification when maximal limit
|
|
818
831
|
* of selected options has been reached
|
|
819
|
-
* @default ()=>string
|
|
832
|
+
* @default (number)=>string
|
|
820
833
|
* @property {Function} multipleBlocksLimitMessage
|
|
821
834
|
*/
|
|
822
835
|
multipleBlocksLimitMessage: {
|
|
@@ -859,6 +872,7 @@ const emit = defineEmits([
|
|
|
859
872
|
const dropdownActive = ref(false);
|
|
860
873
|
const inputDisabled = ref(false);
|
|
861
874
|
const internalLoader = ref(false);
|
|
875
|
+
const externalOptionsLoader = ref(null);
|
|
862
876
|
const chosenToggleAppearanceSide = ref(null);
|
|
863
877
|
const rawOptions = ref([]);
|
|
864
878
|
const selectedOptions = ref([]);
|
|
@@ -1231,6 +1245,21 @@ const fieldFocus = (mouseEvent) => {
|
|
|
1231
1245
|
emitter.emit("extended:field-focus");
|
|
1232
1246
|
};
|
|
1233
1247
|
|
|
1248
|
+
/**
|
|
1249
|
+
* Initialises options list loading by external async method
|
|
1250
|
+
* @function
|
|
1251
|
+
* @param {string} pattern - value of search field
|
|
1252
|
+
*/
|
|
1253
|
+
const loadOptionsByExternalLoader = (pattern) => {
|
|
1254
|
+
internalLoader.value = true;
|
|
1255
|
+
externalOptionsLoader.value = options.value;
|
|
1256
|
+
options.value(pattern).then(options => {
|
|
1257
|
+
rawOptions.value = options;
|
|
1258
|
+
internalLoader.value = false;
|
|
1259
|
+
setPreselectedOptionsByConditions();
|
|
1260
|
+
});
|
|
1261
|
+
};
|
|
1262
|
+
|
|
1234
1263
|
/**
|
|
1235
1264
|
* Emits event whose listener resets index of "enter" key pressing
|
|
1236
1265
|
* @function
|
|
@@ -1648,15 +1677,11 @@ onBeforeMount(() => {
|
|
|
1648
1677
|
/**
|
|
1649
1678
|
* "onMounted" hook of the Vue3ExtendedMultiselect component
|
|
1650
1679
|
* @listens extended:expand-options
|
|
1680
|
+
* @listens extended:loader-pattern-changed
|
|
1651
1681
|
*/
|
|
1652
1682
|
onMounted(() => {
|
|
1653
1683
|
if (typeof options.value === "function") {
|
|
1654
|
-
|
|
1655
|
-
options.value().then(options => {
|
|
1656
|
-
rawOptions.value = options;
|
|
1657
|
-
internalLoader.value = false;
|
|
1658
|
-
setPreselectedOptionsByConditions();
|
|
1659
|
-
});
|
|
1684
|
+
loadOptionsByExternalLoader();
|
|
1660
1685
|
} else {
|
|
1661
1686
|
rawOptions.value = options.value;
|
|
1662
1687
|
setPreselectedOptionsByConditions();
|
|
@@ -1679,6 +1704,10 @@ onMounted(() => {
|
|
|
1679
1704
|
|
|
1680
1705
|
dropdownActive.value = true;
|
|
1681
1706
|
});
|
|
1707
|
+
|
|
1708
|
+
emitter.on("extended:loader-pattern-changed", (pattern) => {
|
|
1709
|
+
loadOptionsByExternalLoader(pattern);
|
|
1710
|
+
});
|
|
1682
1711
|
});
|
|
1683
1712
|
|
|
1684
1713
|
defineExpose({
|
package/tests/unit/props.spec.js
CHANGED
|
@@ -485,6 +485,25 @@ describe("props", () => {
|
|
|
485
485
|
});
|
|
486
486
|
|
|
487
487
|
|
|
488
|
+
it("correctly handles 'disableByField' prop value", async () => {
|
|
489
|
+
const propsData = {
|
|
490
|
+
defaultExpanded: true,
|
|
491
|
+
disableByField: "searchByField",
|
|
492
|
+
options: globalThis.OPTIONS,
|
|
493
|
+
};
|
|
494
|
+
|
|
495
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
496
|
+
|
|
497
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
498
|
+
const selectedOptionWrapper = wrapper.find(".extended__multiselect-block");
|
|
499
|
+
const optionElement = optionsWrapper.findAll(".extended__multiselect-options_option").at(2);
|
|
500
|
+
|
|
501
|
+
await fireEvent.click(optionElement.element);
|
|
502
|
+
|
|
503
|
+
expect(selectedOptionWrapper.text()).toHaveLength(0);
|
|
504
|
+
});
|
|
505
|
+
|
|
506
|
+
|
|
488
507
|
it("correctly handles 'emptyObjectsPlaceholder' prop value", async () => {
|
|
489
508
|
const propsData = {
|
|
490
509
|
defaultExpanded: true,
|