vue3-extended-multiselect 1.10.2 → 2.0.0

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.
Files changed (50) hide show
  1. package/.browserslistrc +2 -2
  2. package/.eslintrc.js +35 -34
  3. package/.github/workflows/publish.yml +41 -41
  4. package/CHANGELOG.md +411 -389
  5. package/LICENSE +21 -21
  6. package/README.md +270 -270
  7. package/babel.config.js +9 -9
  8. package/index.js +2 -2
  9. package/jest.config.js +62 -62
  10. package/package.json +56 -46
  11. package/rollup.config.mjs +74 -0
  12. package/src/assets/{base-arrow.svg → images/base-arrow.svg} +70 -70
  13. package/src/assets/{cancel.svg → images/cancel.svg} +34 -34
  14. package/src/assets/{circle-arrow.svg → images/circle-arrow.svg} +7 -7
  15. package/src/assets/{double-arrow.svg → images/double-arrow.svg} +39 -39
  16. package/src/assets/{inner-arrow.svg → images/inner-arrow.svg} +8 -8
  17. package/src/assets/{loader.svg → images/loader.svg} +5 -5
  18. package/src/assets/{triangle-arrow.svg → images/triangle-arrow.svg} +72 -72
  19. package/src/assets/{triangle-circle-arrow.svg → images/triangle-circle-arrow.svg} +38 -38
  20. package/src/assets/{wide-arrow.svg → images/wide-arrow.svg} +72 -72
  21. package/src/components/ExtendedMultiselectCancel.vue +165 -165
  22. package/src/components/ExtendedMultiselectInput.vue +741 -741
  23. package/src/components/ExtendedMultiselectLoader.vue +182 -182
  24. package/src/components/ExtendedMultiselectMultiple.vue +399 -399
  25. package/src/components/ExtendedMultiselectOptions.vue +1190 -1190
  26. package/src/components/ExtendedMultiselectToggle.vue +271 -271
  27. package/src/components/Vue3ExtendedMultiselect.vue +2475 -1949
  28. package/src/composition/cancel.js +39 -39
  29. package/src/composition/click-outside.js +8 -8
  30. package/src/composition/debounce.js +8 -8
  31. package/src/composition/emitter.js +8 -8
  32. package/src/composition/image-path.js +16 -16
  33. package/src/composition/labels.js +41 -41
  34. package/src/composition/preselected-options.js +67 -67
  35. package/src/composition/search-value.js +33 -33
  36. package/src/composition/sizes.js +44 -44
  37. package/src/composition/toggle.js +31 -31
  38. package/src/sets/sets.js +99 -99
  39. package/src/styles/animations.css +18 -18
  40. package/src/styles/main.css +460 -460
  41. package/src/styles/variables.css +51 -51
  42. package/src/tools/Debounce.js +25 -25
  43. package/src/tools/LocalEmitter.js +31 -31
  44. package/src/tools/instance.js +2 -2
  45. package/tests/unit/events.spec.js +149 -149
  46. package/tests/unit/props.spec.js +1154 -1155
  47. package/tests/unit/tools.spec.js +55 -53
  48. package/tests/utils/mount.js +37 -37
  49. package/tests/utils/utils.js +24 -24
  50. package/typings/vue3-extended-multiselect.d.ts +43 -43
@@ -1,52 +1,52 @@
1
- .extended__multiselect-wrapper,
2
- .extended__multiselect-wrapper--disabled {
3
- --basic-color: #708090;
4
- --basic-transparent: rgba(112, 128, 144, 0.6);
5
- --cancel: #B22222;
6
- --cancel-backgound-color: rgba(179, 33, 33, 0.1);
7
- --dark-slate-blue: #483D8B;
8
- --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
9
- --dark-slate-grey: #2F4F4F;
10
- --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
11
- --disabled: rgba(176, 176, 176, 0.6);
12
- --hover-color: #FFFFFF;
13
- --loader-color: #00BFFF;
14
- --placeholder: #808080;
15
- --strict: #000000;
16
- --strict-transparent: rgba(0, 0, 0, 0.6);
17
- --teal: #008080;
18
- --teal-transparent: rgba(0, 128, 128, 0.6);
19
-
20
- --block-border-radius: 4px;
21
- --block-cancel-padding: 4px;
22
- --block-gap: 6px;
23
- --block-padding: 1px 3px 1px 7px;
24
- --border-radius: 6px;
25
- --border-radius-small: 3px;
26
- --cancel-padding: 3px 8px;
27
- --grid-columns: 1fr 36px 36px;
28
- --grid-rows: 1fr 36px;
29
- --half-size: 50%;
30
- --icon-size-block: 14px;
31
- --icon-size-large: 18px;
32
- --icon-size-medium: 15px;
33
- --icon-size-small: 12px;
34
- --increaser-padding: 3px 7px;
35
- --max-size: 100%;
36
- --min-block-height: 26px;
37
- --options-padding: 6px 0;
38
- --outer-gap: 10px;
39
- --root-padding: 6px 10px;
40
- --toggle-icon-gap: 1px;
41
- --wide-text: 700;
42
- --wrapper-padding: 5px 10px;
43
- --z-index-options: 10;
44
-
45
- --border: 1px solid;
46
- --default-cursor: default;
47
- --icons-align-self: start;
48
- --icons-justify-self: center;
49
- --pointer-cursor: pointer;
50
- --wrapper-transition: border-top-left-radius 250ms ease 0s, border-top-right-radius 250ms ease 0s,
51
- border-bottom-left-radius 250ms ease-out, border-bottom-right-radius 250ms ease-out;
1
+ .extended__multiselect-wrapper,
2
+ .extended__multiselect-wrapper--disabled {
3
+ --basic-color: #708090;
4
+ --basic-transparent: rgba(112, 128, 144, 0.6);
5
+ --cancel: #B22222;
6
+ --cancel-backgound-color: rgba(179, 33, 33, 0.1);
7
+ --dark-slate-blue: #483D8B;
8
+ --dark-slate-blue-transparent: rgba(72, 61, 139, 0.6);
9
+ --dark-slate-grey: #2F4F4F;
10
+ --dark-slate-grey-transparent: rgba(47, 79, 79, 0.6);
11
+ --disabled: rgba(176, 176, 176, 0.6);
12
+ --hover-color: #FFFFFF;
13
+ --loader-color: #00BFFF;
14
+ --placeholder: #808080;
15
+ --strict: #000000;
16
+ --strict-transparent: rgba(0, 0, 0, 0.6);
17
+ --teal: #008080;
18
+ --teal-transparent: rgba(0, 128, 128, 0.6);
19
+
20
+ --block-border-radius: 4px;
21
+ --block-cancel-padding: 4px;
22
+ --block-gap: 6px;
23
+ --block-padding: 1px 3px 1px 7px;
24
+ --border-radius: 6px;
25
+ --border-radius-small: 3px;
26
+ --cancel-padding: 3px 8px;
27
+ --grid-columns: 1fr 36px 36px;
28
+ --grid-rows: 1fr 36px;
29
+ --half-size: 50%;
30
+ --icon-size-block: 14px;
31
+ --icon-size-large: 18px;
32
+ --icon-size-medium: 15px;
33
+ --icon-size-small: 12px;
34
+ --increaser-padding: 3px 7px;
35
+ --max-size: 100%;
36
+ --min-block-height: 26px;
37
+ --options-padding: 6px 0;
38
+ --outer-gap: 10px;
39
+ --root-padding: 6px 10px;
40
+ --toggle-icon-gap: 1px;
41
+ --wide-text: 700;
42
+ --wrapper-padding: 5px 10px;
43
+ --z-index-options: 10;
44
+
45
+ --border: 1px solid;
46
+ --default-cursor: default;
47
+ --icons-align-self: start;
48
+ --icons-justify-self: center;
49
+ --pointer-cursor: pointer;
50
+ --wrapper-transition: border-top-left-radius 250ms ease 0s, border-top-right-radius 250ms ease 0s,
51
+ border-bottom-left-radius 250ms ease-out, border-bottom-right-radius 250ms ease-out;
52
52
  }
@@ -1,26 +1,26 @@
1
- class Debounce {
2
-
3
- _localTimer = null;
4
- _localTimeout = null;
5
- _callback = null;
6
- _timer = 0;
7
-
8
- constructor(callback, timer) {
9
- this._callback = callback;
10
- this._timer = timer;
11
- }
12
-
13
- start() {
14
- this._localTimer = performance.now();
15
-
16
- if (this._localTimeout) {
17
- clearTimeout(this._localTimeout);
18
- }
19
-
20
- this._localTimeout = setTimeout(() => {
21
- this._callback();
22
- }, this._timer);
23
- }
24
- }
25
-
1
+ class Debounce {
2
+
3
+ _localTimer = null;
4
+ _localTimeout = null;
5
+ _callback = null;
6
+ _timer = 0;
7
+
8
+ constructor(callback, timer) {
9
+ this._callback = callback;
10
+ this._timer = timer;
11
+ }
12
+
13
+ start() {
14
+ this._localTimer = performance.now();
15
+
16
+ if (this._localTimeout) {
17
+ clearTimeout(this._localTimeout);
18
+ }
19
+
20
+ this._localTimeout = setTimeout(() => {
21
+ this._callback();
22
+ }, this._timer);
23
+ }
24
+ }
25
+
26
26
  export default Debounce;
@@ -1,32 +1,32 @@
1
- class LocalEmitter {
2
-
3
- _eventsStack = {
4
- payload: null,
5
- };
6
- _eventsRegistered = [];
7
-
8
- emit(eventName, payload = null) {
9
- const proxies = this._eventsRegistered.filter(event => event.eventName === eventName);
10
-
11
- if (!proxies.length) return;
12
-
13
- proxies.forEach((proxy) => {
14
- this._eventsStack.payload = payload;
15
- proxy.proxy.payload = payload;
16
- });
17
- }
18
-
19
- on(eventName, callback) {
20
- this._eventsRegistered.push({
21
- eventName,
22
- proxy: new Proxy(this._eventsStack, {
23
- set(target) {
24
- callback(target.payload);
25
- return target;
26
- },
27
- }),
28
- });
29
- }
30
- }
31
-
1
+ class LocalEmitter {
2
+
3
+ _eventsStack = {
4
+ payload: null,
5
+ };
6
+ _eventsRegistered = [];
7
+
8
+ emit(eventName, payload = null) {
9
+ const proxies = this._eventsRegistered.filter(event => event.eventName === eventName);
10
+
11
+ if (!proxies.length) return;
12
+
13
+ proxies.forEach((proxy) => {
14
+ this._eventsStack.payload = payload;
15
+ proxy.proxy.payload = payload;
16
+ });
17
+ }
18
+
19
+ on(eventName, callback) {
20
+ this._eventsRegistered.push({
21
+ eventName,
22
+ proxy: new Proxy(this._eventsStack, {
23
+ set(target) {
24
+ callback(target.payload);
25
+ return target;
26
+ },
27
+ }),
28
+ });
29
+ }
30
+ }
31
+
32
32
  export default LocalEmitter;
@@ -1,3 +1,3 @@
1
- import LocalEmitter from "../tools/LocalEmitter";
2
-
1
+ import LocalEmitter from "../tools/LocalEmitter";
2
+
3
3
  export default new LocalEmitter();
@@ -1,150 +1,150 @@
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
- mockOptionsLoader,
10
- createNewOptionsWrapper,
11
- } from "../utils/utils";
12
-
13
- import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
14
- import ExtendedMultiselectInput from "../../src/components/ExtendedMultiselectInput.vue";
15
- import ExtendedMultiselectMultiple from "../../src/components/ExtendedMultiselectMultiple.vue";
16
-
17
- let wrapper;
18
-
19
- describe("events", () => {
20
- it("correctly emits 'pattern-changed' event", async () => {
21
- const propsData = {
22
- options: globalThis.OPTIONS,
23
- };
24
-
25
- wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
26
-
27
- wrapper.vm.emitter.emit(
28
- "extended:search-pattern-changed",
29
- globalThis.SEARCH_VALUE,
30
- );
31
-
32
- expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE);
33
-
34
- propsData.options = mockOptionsLoader;
35
- wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
36
-
37
- wrapper.vm.emitter.emit(
38
- "extended:loader-pattern-changed",
39
- globalThis.SEARCH_VALUE_WITH_RESULTS,
40
- );
41
-
42
- expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE_WITH_RESULTS);
43
- });
44
-
45
-
46
- it("correctly emits 'select' event", async () => {
47
- const propsData = {
48
- defaultExpanded: true,
49
- simpleEvents: false,
50
- inputId: globalThis.INPUT_ID,
51
- options: globalThis.OPTIONS,
52
- };
53
-
54
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
55
-
56
- await mockOptionSelection(wrapper);
57
-
58
- expect(wrapper.emitted().select[0][0].option.label).toEqual("First Option");
59
- expect(wrapper.emitted().select[0][0].inputId).toEqual(globalThis.INPUT_ID);
60
- });
61
-
62
-
63
- it("correctly emits 'clean' event", async () => {
64
- const propsData = {
65
- showClearIcon: true,
66
- defaultExpanded: true,
67
- options: globalThis.OPTIONS,
68
- };
69
-
70
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
71
-
72
- const cleanButton = wrapper.find("#extended__multiselect-cancel");
73
-
74
- await mockOptionSelection(wrapper);
75
-
76
- await fireEvent.click(cleanButton.element);
77
-
78
- expect(wrapper.emitted().clean).toBeDefined();
79
- });
80
-
81
-
82
- it("correctly emits 'option-created' event", async () => {
83
- const propsData = {
84
- defaultExpanded: true,
85
- createOnTheGo: true,
86
- inputId: globalThis.INPUT_ID,
87
- };
88
-
89
- wrapper = await mountComponent(
90
- Vue3ExtendedMultiselect,
91
- false,
92
- propsData,
93
- wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
94
- );
95
-
96
- await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
97
-
98
- expect(wrapper.emitted()["option-created"][0][0]).toEqual(globalThis.SEARCH_VALUE);
99
- });
100
-
101
-
102
- it("correctly emits 'active' event", async () => {
103
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false);
104
-
105
- const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
106
- const field = inputWrapper.find("input");
107
-
108
- await fireEvent.focus(field.element);
109
-
110
- expect(wrapper.emitted().active[0][0]).toBeNull();
111
- });
112
-
113
-
114
- it("correctly emits 'close' event", async () => {
115
- const propsData = {
116
- defaultExpanded: true,
117
- simpleEvents: false,
118
- inputId: globalThis.INPUT_ID,
119
- options: globalThis.OPTIONS,
120
- };
121
-
122
- wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
123
-
124
- await mockOptionSelection(wrapper);
125
-
126
- expect(wrapper.emitted().close[0][0].inputId).toEqual(globalThis.INPUT_ID);
127
- expect(wrapper.emitted().close[0][0].options).toHaveLength(1);
128
- });
129
-
130
-
131
- it("correctly emits 'increase' event", async () => {
132
- expect.assertions(1);
133
-
134
- const propsData = {
135
- multiple: true,
136
- toggleMultipleBlocksLimit: true,
137
- multipleBlocksLimit: 1,
138
- increaseDisplayBy: 1,
139
- preselectedOptions: globalThis.OPTIONS,
140
- options: globalThis.OPTIONS,
141
- };
142
- const wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
143
- const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
144
- const increaserWrapper = multipleWrapper.find(".extended__multiselect-increaser");
145
-
146
- await fireEvent.click(increaserWrapper.element);
147
-
148
- expect(wrapper.emitted().increase[0][0]).toEqual(2);
149
- });
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
+ mockOptionsLoader,
10
+ createNewOptionsWrapper,
11
+ } from "../utils/utils";
12
+
13
+ import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
14
+ import ExtendedMultiselectInput from "../../src/components/ExtendedMultiselectInput.vue";
15
+ import ExtendedMultiselectMultiple from "../../src/components/ExtendedMultiselectMultiple.vue";
16
+
17
+ let wrapper;
18
+
19
+ describe("events", () => {
20
+ it("correctly emits 'pattern-changed' event", async () => {
21
+ const propsData = {
22
+ options: globalThis.OPTIONS,
23
+ };
24
+
25
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
26
+
27
+ wrapper.vm.emitter.emit(
28
+ "extended:search-pattern-changed",
29
+ globalThis.SEARCH_VALUE,
30
+ );
31
+
32
+ expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE);
33
+
34
+ propsData.options = mockOptionsLoader;
35
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, true, propsData);
36
+
37
+ wrapper.vm.emitter.emit(
38
+ "extended:loader-pattern-changed",
39
+ globalThis.SEARCH_VALUE_WITH_RESULTS,
40
+ );
41
+
42
+ expect(wrapper.emitted()['pattern-changed'][0][0]).toEqual(globalThis.SEARCH_VALUE_WITH_RESULTS);
43
+ });
44
+
45
+
46
+ it("correctly emits 'select' event", async () => {
47
+ const propsData = {
48
+ defaultExpanded: true,
49
+ simpleEvents: false,
50
+ inputId: globalThis.INPUT_ID,
51
+ options: globalThis.OPTIONS,
52
+ };
53
+
54
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
55
+
56
+ await mockOptionSelection(wrapper);
57
+
58
+ expect(wrapper.emitted().select[0][0].option.label).toEqual("First Option");
59
+ expect(wrapper.emitted().select[0][0].inputId).toEqual(globalThis.INPUT_ID);
60
+ });
61
+
62
+
63
+ it("correctly emits 'clean' event", async () => {
64
+ const propsData = {
65
+ showClearIcon: true,
66
+ defaultExpanded: true,
67
+ options: globalThis.OPTIONS,
68
+ };
69
+
70
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
71
+
72
+ const cleanButton = wrapper.find("#extended__multiselect-cancel");
73
+
74
+ await mockOptionSelection(wrapper);
75
+
76
+ await fireEvent.click(cleanButton.element);
77
+
78
+ expect(wrapper.emitted().clean).toBeDefined();
79
+ });
80
+
81
+
82
+ it("correctly emits 'option-created' event", async () => {
83
+ const propsData = {
84
+ defaultExpanded: true,
85
+ createOnTheGo: true,
86
+ inputId: globalThis.INPUT_ID,
87
+ };
88
+
89
+ wrapper = await mountComponent(
90
+ Vue3ExtendedMultiselect,
91
+ false,
92
+ propsData,
93
+ wrapperProvides(globalThis.SEARCH_VALUE, SEARCH_PATTERN),
94
+ );
95
+
96
+ await fireEvent.mouseDown(createNewOptionsWrapper(wrapper).element);
97
+
98
+ expect(wrapper.emitted()["option-created"][0][0]).toEqual(globalThis.SEARCH_VALUE);
99
+ });
100
+
101
+
102
+ it("correctly emits 'active' event", async () => {
103
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false);
104
+
105
+ const inputWrapper = wrapper.findComponent(ExtendedMultiselectInput);
106
+ const field = inputWrapper.find("input");
107
+
108
+ await fireEvent.focus(field.element);
109
+
110
+ expect(wrapper.emitted().active[0][0]).toBeNull();
111
+ });
112
+
113
+
114
+ it("correctly emits 'close' event", async () => {
115
+ const propsData = {
116
+ defaultExpanded: true,
117
+ simpleEvents: false,
118
+ inputId: globalThis.INPUT_ID,
119
+ options: globalThis.OPTIONS,
120
+ };
121
+
122
+ wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
123
+
124
+ await mockOptionSelection(wrapper);
125
+
126
+ expect(wrapper.emitted().close[0][0].inputId).toEqual(globalThis.INPUT_ID);
127
+ expect(wrapper.emitted().close[0][0].options).toHaveLength(1);
128
+ });
129
+
130
+
131
+ it("correctly emits 'increase' event", async () => {
132
+ expect.assertions(1);
133
+
134
+ const propsData = {
135
+ multiple: true,
136
+ toggleMultipleBlocksLimit: true,
137
+ multipleBlocksLimit: 1,
138
+ increaseDisplayBy: 1,
139
+ preselectedOptions: globalThis.OPTIONS,
140
+ options: globalThis.OPTIONS,
141
+ };
142
+ const wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
143
+ const multipleWrapper = wrapper.findComponent(ExtendedMultiselectMultiple);
144
+ const increaserWrapper = multipleWrapper.find(".extended__multiselect-increaser");
145
+
146
+ await fireEvent.click(increaserWrapper.element);
147
+
148
+ expect(wrapper.emitted().increase[0][0]).toEqual(2);
149
+ });
150
150
  });