vue3-extended-multiselect 0.0.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/.browserslistrc +3 -0
- package/.eslintrc.js +29 -0
- package/CHANGELOG.md +9 -0
- package/README.md +696 -0
- package/babel.config.js +5 -0
- package/index.js +3 -0
- package/jest.config.js +57 -0
- package/package.json +44 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +17 -0
- package/src/assets/base-arrow.svg +70 -0
- package/src/assets/cancel.svg +35 -0
- package/src/assets/circle-arrow.svg +7 -0
- package/src/assets/double-arrow.svg +39 -0
- package/src/assets/inner-arrow.svg +8 -0
- package/src/assets/loader.svg +6 -0
- package/src/assets/triangle-arrow.svg +72 -0
- package/src/assets/triangle-circle-arrow.svg +38 -0
- package/src/assets/wide-arrow.svg +72 -0
- package/src/components/ExtendedMultiselectCancel.vue +142 -0
- package/src/components/ExtendedMultiselectInput.vue +619 -0
- package/src/components/ExtendedMultiselectLoader.vue +176 -0
- package/src/components/ExtendedMultiselectMultiple.vue +292 -0
- package/src/components/ExtendedMultiselectOptions.vue +1088 -0
- package/src/components/ExtendedMultiselectToggle.vue +255 -0
- package/src/components/Vue3ExtendedMultiselect.vue +1651 -0
- package/src/composition/cancel.js +31 -0
- package/src/composition/labels.js +40 -0
- package/src/composition/preselected-options.js +67 -0
- package/src/composition/search-value.js +34 -0
- package/src/composition/sizes.js +43 -0
- package/src/composition/toggle.js +34 -0
- package/src/sass/animations.sass +13 -0
- package/src/sass/main.sass +340 -0
- package/src/sass/mixins.sass +40 -0
- package/src/sass/variables.sass +37 -0
- package/src/sets/sets.js +100 -0
- package/tests/unit/events.spec.js +136 -0
- package/tests/unit/props.spec.js +1041 -0
- package/tests/utils/mount.js +38 -0
- package/tests/utils/stubs.js +1 -0
- package/tests/utils/utils.js +21 -0
- package/typings/vue3-extended-multiselect.d.ts +34 -0
package/src/sets/sets.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Set of background- and border- style variants
|
|
3
|
+
* @constant {Array} themeTypes
|
|
4
|
+
*/
|
|
5
|
+
export const themeTypes = [
|
|
6
|
+
"basic",
|
|
7
|
+
"slate-grey",
|
|
8
|
+
"slate-blue",
|
|
9
|
+
"teal",
|
|
10
|
+
"strict"
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Set of color-style variants for loader
|
|
15
|
+
* @constant {Array} loaderThemeTypes
|
|
16
|
+
*/
|
|
17
|
+
export const loaderThemeTypes = [
|
|
18
|
+
"loader-default",
|
|
19
|
+
...themeTypes
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Set of icon filenames
|
|
24
|
+
* @constant {Array} toggleIcons
|
|
25
|
+
*/
|
|
26
|
+
export const toggleIcons = [
|
|
27
|
+
"base-arrow",
|
|
28
|
+
"double-arrow",
|
|
29
|
+
"wide-arrow",
|
|
30
|
+
"circle-arrow",
|
|
31
|
+
"inner-arrow",
|
|
32
|
+
"triangle-arrow",
|
|
33
|
+
"triangle-circle-arrow"
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Set of icon colors filtered by svg
|
|
38
|
+
* @constant {Array} iconFilters
|
|
39
|
+
*/
|
|
40
|
+
export const iconFilters = [
|
|
41
|
+
"basic",
|
|
42
|
+
"black",
|
|
43
|
+
"green"
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Set of icons sizes filtered by css
|
|
48
|
+
* @constant {Array} iconSizes
|
|
49
|
+
*/
|
|
50
|
+
export const iconSizes = [
|
|
51
|
+
"large",
|
|
52
|
+
"medium",
|
|
53
|
+
"small"
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Set of types for options created by user
|
|
58
|
+
* @constant {Array} createOptionTypes
|
|
59
|
+
*/
|
|
60
|
+
export const createOptionTypes = [
|
|
61
|
+
"primitive",
|
|
62
|
+
"array",
|
|
63
|
+
"object"
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Set of keys to combine with cliks on options list and blocking choice
|
|
68
|
+
* @constant {Array} specialKeysToBlock
|
|
69
|
+
*/
|
|
70
|
+
export const specialKeysToBlock = [
|
|
71
|
+
"alt",
|
|
72
|
+
"ctrl",
|
|
73
|
+
"shift"
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Set of appearance variants of options list
|
|
78
|
+
* @constant {Array} toggleAppearenceSides
|
|
79
|
+
*/
|
|
80
|
+
export const toggleAppearenceSides = [
|
|
81
|
+
"auto",
|
|
82
|
+
"atop",
|
|
83
|
+
"under"
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Set of available types for options
|
|
88
|
+
* @constant {Array} UnionPropType
|
|
89
|
+
* @typedef {(string|number|boolean|Array|Object|Function|null|undefined)} UnionPropType
|
|
90
|
+
*/
|
|
91
|
+
export const UnionPropType = [
|
|
92
|
+
String,
|
|
93
|
+
Number,
|
|
94
|
+
Boolean,
|
|
95
|
+
Array,
|
|
96
|
+
Object,
|
|
97
|
+
Function,
|
|
98
|
+
null,
|
|
99
|
+
undefined
|
|
100
|
+
];
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { fireEvent } from "@testing-library/dom";
|
|
2
|
+
import {
|
|
3
|
+
mountComponent,
|
|
4
|
+
wrapperProvides,
|
|
5
|
+
SEARCH_PATTERN,
|
|
6
|
+
} from "../utils/mount";
|
|
7
|
+
import {
|
|
8
|
+
mockOptionSelection,
|
|
9
|
+
createNewOptionsWrapper,
|
|
10
|
+
} from "../utils/utils";
|
|
11
|
+
|
|
12
|
+
import emitter from "tiny-emitter/instance";
|
|
13
|
+
|
|
14
|
+
import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
|
|
15
|
+
import ExtendedMultiselectInput from "../../src/components/ExtendedMultiselectInput.vue";
|
|
16
|
+
import ExtendedMultiselectMultiple from "../../src/components/ExtendedMultiselectMultiple.vue";
|
|
17
|
+
|
|
18
|
+
let wrapper;
|
|
19
|
+
|
|
20
|
+
describe("events", () => {
|
|
21
|
+
it("correctly emits 'pattern-changed' event", async () => {
|
|
22
|
+
const propsData = {
|
|
23
|
+
options: globalThis.OPTIONS,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
|
|
27
|
+
|
|
28
|
+
emitter.emit("extended:search-pattern-changed", globalThis.SEARCH_VALUE);
|
|
29
|
+
|
|
30
|
+
expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
it("correctly emits 'select' event", async () => {
|
|
35
|
+
const propsData = {
|
|
36
|
+
defaultExpanded: true,
|
|
37
|
+
simpleEvents: false,
|
|
38
|
+
inputId: globalThis.INPUT_ID,
|
|
39
|
+
options: globalThis.OPTIONS,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
43
|
+
|
|
44
|
+
await mockOptionSelection(wrapper);
|
|
45
|
+
|
|
46
|
+
expect(wrapper.emitted().select[0][0].option.label).toEqual("First Option");
|
|
47
|
+
expect(wrapper.emitted().select[0][0].inputId).toEqual(globalThis.INPUT_ID);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
it("correctly emits 'clean' event", async () => {
|
|
52
|
+
const propsData = {
|
|
53
|
+
showClearIcon: true,
|
|
54
|
+
defaultExpanded: true,
|
|
55
|
+
options: globalThis.OPTIONS,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
59
|
+
|
|
60
|
+
const cleanButton = wrapper.find("#extended__multiselect-cancel");
|
|
61
|
+
|
|
62
|
+
await fireEvent.click(cleanButton.element);
|
|
63
|
+
|
|
64
|
+
expect(wrapper.emitted().clean).toBeDefined();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
it("correctly emits 'option-created' event", async () => {
|
|
69
|
+
const propsData = {
|
|
70
|
+
defaultExpanded: true,
|
|
71
|
+
createOnTheGo: true,
|
|
72
|
+
inputId: globalThis.INPUT_ID,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
wrapper = await mountComponent(
|
|
76
|
+
Vue3ExtendedMultiselect,
|
|
77
|
+
false,
|
|
78
|
+
propsData,
|
|
79
|
+
wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
|
|
83
|
+
|
|
84
|
+
expect(wrapper.emitted()["option-created"][0][0]).toEqual(globalThis.SEARCH_VALUE);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
it("correctly emits 'active' event", async () => {
|
|
89
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false);
|
|
90
|
+
|
|
91
|
+
const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
|
|
92
|
+
const field = inputWrapper.find("input");
|
|
93
|
+
|
|
94
|
+
await fireEvent.focus(field.element);
|
|
95
|
+
|
|
96
|
+
expect(wrapper.emitted().active[0][0]).toBeNull();
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
it("correctly emits 'close' event", async () => {
|
|
101
|
+
const propsData = {
|
|
102
|
+
defaultExpanded: true,
|
|
103
|
+
simpleEvents: false,
|
|
104
|
+
inputId: globalThis.INPUT_ID,
|
|
105
|
+
options: globalThis.OPTIONS,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
109
|
+
|
|
110
|
+
await mockOptionSelection(wrapper);
|
|
111
|
+
|
|
112
|
+
expect(wrapper.emitted().close[0][0].inputId).toEqual(globalThis.INPUT_ID);
|
|
113
|
+
expect(wrapper.emitted().close[0][0].options).toHaveLength(0);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
it("correctly emits 'increase' event", async () => {
|
|
118
|
+
expect.assertions(1);
|
|
119
|
+
|
|
120
|
+
const propsData = {
|
|
121
|
+
multiple: true,
|
|
122
|
+
toggleMultipleBlocksLimit: true,
|
|
123
|
+
multipleBlocksLimit: 1,
|
|
124
|
+
increaseDisplayBy: 1,
|
|
125
|
+
preselectedOptions: globalThis.OPTIONS,
|
|
126
|
+
options: globalThis.OPTIONS,
|
|
127
|
+
};
|
|
128
|
+
const wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
129
|
+
const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
|
|
130
|
+
const increaserWrapper = multipleWrapper.find(".extended__multiselect-increaser");
|
|
131
|
+
|
|
132
|
+
await fireEvent.click(increaserWrapper.element);
|
|
133
|
+
|
|
134
|
+
expect(wrapper.emitted().increase[0][0]).toEqual(2);
|
|
135
|
+
});
|
|
136
|
+
});
|