vue3-extended-multiselect 1.1.3 → 1.1.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 +6 -2
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/components/ExtendedMultiselectInput.vue +11 -0
- package/src/components/ExtendedMultiselectMultiple.vue +15 -1
- package/src/components/ExtendedMultiselectOptions.vue +5 -1
- package/src/components/Vue3ExtendedMultiselect.vue +13 -0
- package/src/composition/labels.js +4 -2
- package/src/composition/preselected-options.js +1 -0
- package/typings/vue3-extended-multiselect.d.ts +1 -0
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.4**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -110,4 +110,8 @@ Adding descriptive comments for some types in typings.
|
|
|
110
110
|
|
|
111
111
|
### 1.1.3 (2022-12-11)
|
|
112
112
|
* Adding "searchByField" optional prop.
|
|
113
|
-
* Adding unit-test for new optional prop.
|
|
113
|
+
* Adding unit-test for new optional prop.
|
|
114
|
+
|
|
115
|
+
### 1.1.4 (2022-13-11)
|
|
116
|
+
* Adding "optionCreateLabel" to expose as utility.
|
|
117
|
+
* Fix bug with wrong name of label field
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
:loading="loading"
|
|
39
39
|
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
40
40
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
41
|
+
:label="label"
|
|
41
42
|
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
42
43
|
:theme-type="themeType"
|
|
43
44
|
:increase-display-by="increaseDisplayBy"
|
|
@@ -75,6 +76,7 @@
|
|
|
75
76
|
:loading="loading"
|
|
76
77
|
:toggle-multiple-blocks-limit="toggleMultipleBlocksLimit"
|
|
77
78
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
79
|
+
:label="label"
|
|
78
80
|
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
79
81
|
:theme-type="themeType"
|
|
80
82
|
:increase-display-by="increaseDisplayBy"
|
|
@@ -265,6 +267,15 @@ const props = defineProps({
|
|
|
265
267
|
required: true,
|
|
266
268
|
},
|
|
267
269
|
|
|
270
|
+
/**
|
|
271
|
+
* Determines field of option which will be displayed as label
|
|
272
|
+
* @property {string} label
|
|
273
|
+
*/
|
|
274
|
+
label: {
|
|
275
|
+
type: String,
|
|
276
|
+
required: true,
|
|
277
|
+
},
|
|
278
|
+
|
|
268
279
|
/**
|
|
269
280
|
* "placeholder" attribute for search field
|
|
270
281
|
* @property {string} placeholder
|
|
@@ -92,6 +92,15 @@ const props = defineProps({
|
|
|
92
92
|
required: true,
|
|
93
93
|
},
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Determines field of option which will be displayed as label
|
|
97
|
+
* @property {string} label
|
|
98
|
+
*/
|
|
99
|
+
label: {
|
|
100
|
+
type: String,
|
|
101
|
+
required: true,
|
|
102
|
+
},
|
|
103
|
+
|
|
95
104
|
/**
|
|
96
105
|
* Limit of hidden options amount to be shown next
|
|
97
106
|
* @property {number} increaseDisplayBy
|
|
@@ -161,6 +170,7 @@ const {
|
|
|
161
170
|
createCustomOptionLabel,
|
|
162
171
|
disabled,
|
|
163
172
|
emptyObjectsPlaceholder,
|
|
173
|
+
label,
|
|
164
174
|
increaseDisplayBy,
|
|
165
175
|
loading,
|
|
166
176
|
multipleBlocksLimit,
|
|
@@ -175,7 +185,11 @@ const optionsLimitIncreaser = ref(null);
|
|
|
175
185
|
const increaserClass = ref("extended__multiselect-increaser");
|
|
176
186
|
const deselectImage = ref(createImagePath("cancel.svg"));
|
|
177
187
|
|
|
178
|
-
const { optionCreateLabel } = useLabels(
|
|
188
|
+
const { optionCreateLabel } = useLabels(
|
|
189
|
+
label,
|
|
190
|
+
createCustomOptionLabel,
|
|
191
|
+
emptyObjectsPlaceholder,
|
|
192
|
+
);
|
|
179
193
|
|
|
180
194
|
/**
|
|
181
195
|
* Defines class for every selected option block
|
|
@@ -438,7 +438,11 @@ const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
|
|
|
438
438
|
emptyObjectsPlaceholder,
|
|
439
439
|
showInsertWarnings,
|
|
440
440
|
);
|
|
441
|
-
const { optionCreateLabel } = useLabels(
|
|
441
|
+
const { optionCreateLabel } = useLabels(
|
|
442
|
+
label,
|
|
443
|
+
createCustomOptionLabel,
|
|
444
|
+
emptyObjectsPlaceholder,
|
|
445
|
+
);
|
|
442
446
|
|
|
443
447
|
/**
|
|
444
448
|
* List of options filtered by "disabled" and "selected" signs
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
:placeholder="placeholder"
|
|
40
40
|
:show-search-field="showSearchField"
|
|
41
41
|
:empty-objects-placeholder="emptyObjectsPlaceholder"
|
|
42
|
+
:label="label"
|
|
42
43
|
:multiple-blocks-limit-message="multipleBlocksLimitMessage"
|
|
43
44
|
:theme-type="themeType"
|
|
44
45
|
:increase-display-by="increaseDisplayBy"
|
|
@@ -206,6 +207,7 @@
|
|
|
206
207
|
import {
|
|
207
208
|
computed,
|
|
208
209
|
defineEmits,
|
|
210
|
+
defineExpose,
|
|
209
211
|
defineProps,
|
|
210
212
|
onBeforeMount,
|
|
211
213
|
onMounted,
|
|
@@ -234,6 +236,7 @@ import {
|
|
|
234
236
|
|
|
235
237
|
import useToggle from "../composition/toggle";
|
|
236
238
|
import useCancel from "../composition/cancel";
|
|
239
|
+
import useLabels from "../composition/labels";
|
|
237
240
|
import usePreselectedOptions from "../composition/preselected-options";
|
|
238
241
|
import useSearchValue from "../composition/search-value";
|
|
239
242
|
|
|
@@ -892,6 +895,7 @@ const {
|
|
|
892
895
|
toggleMaxHeight,
|
|
893
896
|
toggleOptionsBySelect,
|
|
894
897
|
wrongCurrentValue,
|
|
898
|
+
createCustomOptionLabel,
|
|
895
899
|
} = toRefs(props);
|
|
896
900
|
|
|
897
901
|
const {
|
|
@@ -920,6 +924,11 @@ const { createLabel, optionTypeRestrictor } = usePreselectedOptions(
|
|
|
920
924
|
emptyObjectsPlaceholder,
|
|
921
925
|
showInsertWarnings,
|
|
922
926
|
);
|
|
927
|
+
const { optionCreateLabel } = useLabels(
|
|
928
|
+
label,
|
|
929
|
+
createCustomOptionLabel,
|
|
930
|
+
emptyObjectsPlaceholder,
|
|
931
|
+
);
|
|
923
932
|
const attrs = useAttrs();
|
|
924
933
|
const slots = useSlots();
|
|
925
934
|
|
|
@@ -1669,6 +1678,10 @@ onMounted(() => {
|
|
|
1669
1678
|
dropdownActive.value = true;
|
|
1670
1679
|
});
|
|
1671
1680
|
});
|
|
1681
|
+
|
|
1682
|
+
defineExpose({
|
|
1683
|
+
optionCreateLabel,
|
|
1684
|
+
});
|
|
1672
1685
|
</script>
|
|
1673
1686
|
|
|
1674
1687
|
<style>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export default function useLabels(
|
|
2
|
+
label,
|
|
2
3
|
createCustomOptionLabel,
|
|
3
4
|
emptyObjectsPlaceholder,
|
|
4
5
|
) {
|
|
5
6
|
/**
|
|
6
7
|
* Creates label of any kind of option
|
|
7
8
|
* @function
|
|
9
|
+
* @param {string} label - label field in options of type "object"
|
|
8
10
|
* @param {option} UnionPropType
|
|
9
11
|
* @returns {string} label
|
|
10
12
|
*/
|
|
@@ -27,10 +29,10 @@ export default function useLabels(
|
|
|
27
29
|
return emptyObjectsPlaceholder.value;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const hasLabel = Object.getOwnPropertyNames(option).includes(
|
|
32
|
+
const hasLabel = Object.getOwnPropertyNames(option).includes(label.value);
|
|
31
33
|
|
|
32
34
|
if (hasLabel) {
|
|
33
|
-
return typeof option.
|
|
35
|
+
return typeof option[label.value] === "object" ? JSON.stringify(option[label.value]) : option[label.value];
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
return "";
|
|
@@ -6,6 +6,7 @@ export default function usePreselectedOptions(
|
|
|
6
6
|
/**
|
|
7
7
|
* Creates string label for any kind of option
|
|
8
8
|
* @function
|
|
9
|
+
* @param {string} label - label field in options of type "object"
|
|
9
10
|
* @param {boolean} isObjectOrArray - determines whether option is of type "object" or instance of Array
|
|
10
11
|
* @param {UnionPropType} option - option which needs label
|
|
11
12
|
* @returns {string} label
|
|
@@ -10,6 +10,7 @@ export type Cancel = () => void;
|
|
|
10
10
|
export type CreateCustomOptionLabel = (option: UnionOptionType) => null | string;
|
|
11
11
|
export type Increase = Cancel;
|
|
12
12
|
export type DeselectBlock = (index: number) => void;
|
|
13
|
+
export type OptionCreateLabel = CreateCustomOptionLabel;
|
|
13
14
|
export type ToggleOptionsList = (keyboardEvent?: KeyboardEvent) => void;
|
|
14
15
|
|
|
15
16
|
interface InputIdInPayload {
|