vue3-extended-multiselect 1.1.2 → 1.1.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/.eslintrc.js
CHANGED
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.3**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -84,7 +84,7 @@ Adding descriptive comments for some types in typings.
|
|
|
84
84
|
* Adding image-path.js file with "useImagePath" custom hook.
|
|
85
85
|
* Adding emitter import in composition api from "mitt" dependency.
|
|
86
86
|
* Adding some new css-variabled.
|
|
87
|
-
* Removal of
|
|
87
|
+
* Removal of some old css-variables.
|
|
88
88
|
* Changing styles of "marker" and "option" slots.
|
|
89
89
|
* Adding new fields in "parserOptions" section of .eslintrc.
|
|
90
90
|
* Disabling "no-undef" rule in .eslintrc.
|
|
@@ -106,4 +106,8 @@ Adding descriptive comments for some types in typings.
|
|
|
106
106
|
* Replacing package-lock.json file with new one.
|
|
107
107
|
|
|
108
108
|
### 1.1.2 (2022-12-10)
|
|
109
|
-
* Replacing dev-dependency "@vue/cli-plugin-eslint" with its latest version.
|
|
109
|
+
* Replacing dev-dependency "@vue/cli-plugin-eslint" with its latest version.
|
|
110
|
+
|
|
111
|
+
### 1.1.3 (2022-12-11)
|
|
112
|
+
* Adding "searchByField" optional prop.
|
|
113
|
+
* Adding unit-test for new optional prop.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# vue3-extended-multiselect v1.1.
|
|
1
|
+
# vue3-extended-multiselect v1.1.3
|
|
2
2
|
|
|
3
3
|
***
|
|
4
4
|
|
|
@@ -67,6 +67,7 @@ Prop name | Prop type | Prop appointment | Prop default value | Prop values
|
|
|
67
67
|
**label**|String|Defines field in options of type "object" that will be the label of option.|"label"|—|
|
|
68
68
|
**loaderIcon<br/>Filter**|String|Defines svg-filter with color settings for loader icon.|"loader-default"|"loader-default", "basic", "slate-grey", "slate-blue", "teal",<br/> "strict"|
|
|
69
69
|
**placeholder**|String|Placeholder for search field to be used if user is not allowed to create new options.|"Select features"|—|
|
|
70
|
+
**searchByField**|String|Determines field in options of type "object" to use in internal search.|""|—|
|
|
70
71
|
**themeType**|String|Defines overall color theme for extended multiselect.|"basic"|"basic", "slate-grey", "slate-blue", "teal",<br/> "strict"|
|
|
71
72
|
**toggle<br/>Appearance<br/>Side**|String|Defines which side options list will be displayed on.|"auto"|"auto", "atop", "under"|
|
|
72
73
|
**toggleIcon**|String|Defines kind of toggle icon from icons collection.|"double-arrow"|"base-arrow", "double-arrow", "wide-arrow", "circle-arrow", "inner-arrow", "triangle-arrow", "triangle-circle-arrow"|
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -226,6 +226,16 @@ const props = defineProps({
|
|
|
226
226
|
required: true,
|
|
227
227
|
},
|
|
228
228
|
|
|
229
|
+
/**
|
|
230
|
+
* Determines field in options of type "object"
|
|
231
|
+
* to use in internal search.
|
|
232
|
+
* @property {string} searchByField
|
|
233
|
+
*/
|
|
234
|
+
searchByField: {
|
|
235
|
+
type: String,
|
|
236
|
+
required: true,
|
|
237
|
+
},
|
|
238
|
+
|
|
229
239
|
/**
|
|
230
240
|
* Current theme of extended-multiselect
|
|
231
241
|
* used in class definition
|
|
@@ -406,6 +416,7 @@ const {
|
|
|
406
416
|
emptyObjectsPlaceholder,
|
|
407
417
|
highlightOptions,
|
|
408
418
|
label,
|
|
419
|
+
searchByField,
|
|
409
420
|
maxOptionsCount,
|
|
410
421
|
minOptionsCount,
|
|
411
422
|
multiple,
|
|
@@ -753,7 +764,18 @@ const filterBySearchPattern = (optionsList) => {
|
|
|
753
764
|
if (Array.isArray(option)) {
|
|
754
765
|
return searchState.searchPattern.test(option.length ? option.join(", ") : emptyObjectsPlaceholder.value);
|
|
755
766
|
}
|
|
756
|
-
|
|
767
|
+
|
|
768
|
+
let internalSearchResult;
|
|
769
|
+
|
|
770
|
+
if (searchByField.value.length) {
|
|
771
|
+
if (!option[searchByField.value]) return false;
|
|
772
|
+
|
|
773
|
+
internalSearchResult = option[searchByField.value].toString();
|
|
774
|
+
} else {
|
|
775
|
+
internalSearchResult = option[label.value].toString();
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
return searchState.searchPattern.test(internalSearchResult);
|
|
757
779
|
} else {
|
|
758
780
|
return searchState.searchPattern.test(option.toString());
|
|
759
781
|
}
|
|
@@ -1054,8 +1076,8 @@ onBeforeMount(() => {
|
|
|
1054
1076
|
emitter.on("extended:select-enter", (keyboardEvent) => {
|
|
1055
1077
|
if (!enterIndex.value) return;
|
|
1056
1078
|
|
|
1057
|
-
const option =
|
|
1058
|
-
|
|
1079
|
+
const option = availableOptions.value[enterIndex.value];
|
|
1080
|
+
selectOption(option, keyboardEvent);
|
|
1059
1081
|
});
|
|
1060
1082
|
|
|
1061
1083
|
emitter.on("extended:reset-index", () => {
|
|
@@ -136,6 +136,7 @@
|
|
|
136
136
|
:create-option-type="createOptionType"
|
|
137
137
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
138
138
|
:label="label"
|
|
139
|
+
:search-by-field="searchByField"
|
|
139
140
|
:theme-type="themeType"
|
|
140
141
|
:any-option-wrapper-block-height="anyOptionWrapperBlockHeight"
|
|
141
142
|
:max-options-count="maxOptionsCount"
|
|
@@ -571,6 +572,17 @@ const props = defineProps({
|
|
|
571
572
|
default: "Select features",
|
|
572
573
|
},
|
|
573
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Determines field in options of type "object"
|
|
577
|
+
* to use in internal search.
|
|
578
|
+
* @default ""
|
|
579
|
+
* @property {string} searchByField
|
|
580
|
+
*/
|
|
581
|
+
searchByField: {
|
|
582
|
+
type: String,
|
|
583
|
+
default: "",
|
|
584
|
+
},
|
|
585
|
+
|
|
574
586
|
/**
|
|
575
587
|
* Defines overall color theme for extended multiselect
|
|
576
588
|
* @default "basic"
|
package/tests/unit/props.spec.js
CHANGED
|
@@ -272,7 +272,7 @@ describe("props", () => {
|
|
|
272
272
|
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
273
273
|
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
274
274
|
|
|
275
|
-
expect(optionsListWrapper.element.children).toHaveLength(
|
|
275
|
+
expect(optionsListWrapper.element.children).toHaveLength(4);
|
|
276
276
|
});
|
|
277
277
|
|
|
278
278
|
|
|
@@ -582,6 +582,28 @@ describe("props", () => {
|
|
|
582
582
|
});
|
|
583
583
|
|
|
584
584
|
|
|
585
|
+
it("correctly handles 'searchByField' prop value", async () => {
|
|
586
|
+
const propsData = {
|
|
587
|
+
options: globalThis.OPTIONS,
|
|
588
|
+
searchByField: "searchByField",
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
wrapper = await mountComponent(
|
|
592
|
+
Vue3ExtendedMultiselect,
|
|
593
|
+
false,
|
|
594
|
+
propsData,
|
|
595
|
+
wrapperProvides(globalThis.SEARCH_VALUE_WITH_RESULTS, SEARCH_PATTERN),
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
await expandOptionsList(wrapper);
|
|
599
|
+
|
|
600
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
601
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
602
|
+
|
|
603
|
+
expect(optionsListWrapper.element.children).toHaveLength(1);
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
|
|
585
607
|
it("correctly handles 'themeType' prop value", async () => {
|
|
586
608
|
expect.assertions(3);
|
|
587
609
|
|
|
@@ -595,6 +617,8 @@ describe("props", () => {
|
|
|
595
617
|
|
|
596
618
|
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
597
619
|
|
|
620
|
+
await expandOptionsList(wrapper);
|
|
621
|
+
|
|
598
622
|
const multiselectWrapper = wrapper.find("#extended__multiselect");
|
|
599
623
|
const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
|
|
600
624
|
const optionWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
@@ -833,7 +857,7 @@ describe("props", () => {
|
|
|
833
857
|
|
|
834
858
|
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
835
859
|
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
836
|
-
const optionElement = optionsListWrapper.findAll(".extended__multiselect-options_option").at(
|
|
860
|
+
const optionElement = optionsListWrapper.findAll(".extended__multiselect-options_option").at(3);
|
|
837
861
|
|
|
838
862
|
expect(optionElement.classes()).toContain("extended__multiselect-options_option--disabled");
|
|
839
863
|
});
|
|
@@ -852,7 +876,7 @@ describe("props", () => {
|
|
|
852
876
|
let optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
853
877
|
let optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
854
878
|
|
|
855
|
-
expect(optionsListWrapper.element.children).toHaveLength(
|
|
879
|
+
expect(optionsListWrapper.element.children).toHaveLength(4);
|
|
856
880
|
|
|
857
881
|
const optionsLoader = async () => {
|
|
858
882
|
return await Promise.resolve(globalThis.OPTIONS);
|
|
@@ -863,7 +887,7 @@ describe("props", () => {
|
|
|
863
887
|
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
864
888
|
|
|
865
889
|
process.nextTick(async () => {
|
|
866
|
-
expect(wrapper.vm.rawOptions).toHaveLength(
|
|
890
|
+
expect(wrapper.vm.rawOptions).toHaveLength(4);
|
|
867
891
|
done();
|
|
868
892
|
});
|
|
869
893
|
});
|
|
@@ -1032,7 +1056,7 @@ describe("props", () => {
|
|
|
1032
1056
|
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
1033
1057
|
const selectedOption = inputWrapper.find(".extended__multiselect-block").find("span");
|
|
1034
1058
|
|
|
1035
|
-
expect(optionsListWrapper.element.children).toHaveLength(
|
|
1059
|
+
expect(optionsListWrapper.element.children).toHaveLength(3);
|
|
1036
1060
|
expect(selectedOption.text()).toEqual(globalThis.OPTIONS[0].label);
|
|
1037
1061
|
|
|
1038
1062
|
done();
|