vue3-extended-multiselect 1.7.0 → 1.7.2

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 (46) hide show
  1. package/.browserslistrc +2 -2
  2. package/.eslintrc.js +34 -34
  3. package/.github/workflows/publish.yml +41 -41
  4. package/CHANGELOG.md +284 -275
  5. package/LICENSE +21 -21
  6. package/README.md +267 -267
  7. package/babel.config.js +9 -9
  8. package/index.js +2 -2
  9. package/jest.config.js +61 -61
  10. package/package.json +46 -46
  11. package/src/assets/base-arrow.svg +70 -70
  12. package/src/assets/cancel.svg +34 -34
  13. package/src/assets/circle-arrow.svg +7 -7
  14. package/src/assets/double-arrow.svg +39 -39
  15. package/src/assets/inner-arrow.svg +8 -8
  16. package/src/assets/loader.svg +5 -5
  17. package/src/assets/triangle-arrow.svg +72 -72
  18. package/src/assets/triangle-circle-arrow.svg +38 -38
  19. package/src/assets/wide-arrow.svg +72 -72
  20. package/src/components/ExtendedMultiselectCancel.vue +165 -165
  21. package/src/components/ExtendedMultiselectInput.vue +705 -705
  22. package/src/components/ExtendedMultiselectLoader.vue +182 -182
  23. package/src/components/ExtendedMultiselectMultiple.vue +365 -365
  24. package/src/components/ExtendedMultiselectOptions.vue +1168 -1168
  25. package/src/components/ExtendedMultiselectToggle.vue +271 -271
  26. package/src/components/Vue3ExtendedMultiselect.vue +1803 -1783
  27. package/src/composition/cancel.js +36 -36
  28. package/src/composition/click-outside.js +8 -8
  29. package/src/composition/emitter.js +8 -8
  30. package/src/composition/image-path.js +16 -16
  31. package/src/composition/labels.js +41 -41
  32. package/src/composition/preselected-options.js +67 -67
  33. package/src/composition/search-value.js +33 -33
  34. package/src/composition/sizes.js +44 -44
  35. package/src/composition/toggle.js +31 -31
  36. package/src/events/LocalEmitter.js +31 -31
  37. package/src/events/instance.js +3 -0
  38. package/src/sets/sets.js +99 -99
  39. package/src/styles/animations.css +18 -18
  40. package/src/styles/main.css +454 -454
  41. package/src/styles/variables.css +49 -49
  42. package/tests/unit/events.spec.js +136 -136
  43. package/tests/unit/props.spec.js +1128 -1128
  44. package/tests/utils/mount.js +37 -37
  45. package/tests/utils/utils.js +20 -20
  46. package/typings/vue3-extended-multiselect.d.ts +43 -43
@@ -1,37 +1,37 @@
1
- import useSearchValue from './search-value';
2
-
3
- export default function useCancel(
4
- disabled,
5
- showSearchField,
6
- selectedOptions,
7
- emitter,
8
- setSearchValue,
9
- setSearchPattern,
10
- ) {
11
- /**
12
- * Removes all selected options or single selected option
13
- * when "multiple" prop equals false
14
- * @function
15
- * @emits extended:skip-block-blur-zeroing
16
- * @emits extended:deselect-option
17
- * @emits extended:clean-options
18
- */
19
- const cancel = () => {
20
- if (disabled.value) return;
21
-
22
- emitter.value.emit("extended:skip-block-blur-zeroing");
23
- emitter.value.emit("extended:deselect-option", {
24
- index: null,
25
- clearAll: true,
26
- });
27
-
28
- if (!showSearchField.value) return;
29
-
30
- emitter.value.emit("extended:clean-options", selectedOptions.value);
31
-
32
- setSearchValue(null);
33
- setSearchPattern(null);
34
- };
35
-
36
- return { cancel };
1
+ import useSearchValue from './search-value';
2
+
3
+ export default function useCancel(
4
+ disabled,
5
+ showSearchField,
6
+ selectedOptions,
7
+ emitter,
8
+ setSearchValue,
9
+ setSearchPattern,
10
+ ) {
11
+ /**
12
+ * Removes all selected options or single selected option
13
+ * when "multiple" prop equals false
14
+ * @function
15
+ * @emits extended:skip-block-blur-zeroing
16
+ * @emits extended:deselect-option
17
+ * @emits extended:clean-options
18
+ */
19
+ const cancel = () => {
20
+ if (disabled.value) return;
21
+
22
+ emitter.value.emit("extended:skip-block-blur-zeroing");
23
+ emitter.value.emit("extended:deselect-option", {
24
+ index: null,
25
+ clearAll: true,
26
+ });
27
+
28
+ if (!showSearchField.value) return;
29
+
30
+ emitter.value.emit("extended:clean-options", selectedOptions.value);
31
+
32
+ setSearchValue(null);
33
+ setSearchPattern(null);
34
+ };
35
+
36
+ return { cancel };
37
37
  }
@@ -1,9 +1,9 @@
1
- import { ref } from "vue";
2
-
3
- import ExtendedClickOutside from "extended-click-outside";
4
-
5
- export default function useClickOutside() {
6
- const clickOutside = ref(new ExtendedClickOutside());
7
-
8
- return { clickOutside };
1
+ import { ref } from "vue";
2
+
3
+ import ExtendedClickOutside from "extended-click-outside";
4
+
5
+ export default function useClickOutside() {
6
+ const clickOutside = ref(new ExtendedClickOutside());
7
+
8
+ return { clickOutside };
9
9
  }
@@ -1,9 +1,9 @@
1
- import { ref } from "vue";
2
-
3
- import LocalEmitter from "../events/LocalEmitter";
4
-
5
- export default function useEmitter() {
6
- const emitter = ref(new LocalEmitter());
7
-
8
- return { emitter };
1
+ import { ref } from "vue";
2
+
3
+ import LocalEmitter from "../events/LocalEmitter";
4
+
5
+ export default function useEmitter() {
6
+ const emitter = ref(new LocalEmitter());
7
+
8
+ return { emitter };
9
9
  }
@@ -1,17 +1,17 @@
1
- export default function useImagePath() {
2
-
3
- const createImagePath = (image) => {
4
- const hasRequire = typeof require !== "undefined";
5
- if (hasRequire) {
6
- return require(`../assets/${image}`);
7
- } else {
8
- try {
9
- return new URL(`../assets/${image}`, import.meta.url).href;
10
- } catch(error) {
11
- throw new ReferenceError("import.meta.url is available in «esnext» libtype only");
12
- }
13
- }
14
- };
15
-
16
- return { createImagePath };
1
+ export default function useImagePath() {
2
+
3
+ const createImagePath = (image) => {
4
+ const hasRequire = typeof require !== "undefined";
5
+ if (hasRequire) {
6
+ return require(`../assets/${image}`);
7
+ } else {
8
+ try {
9
+ return new URL(`../assets/${image}`, import.meta.url).href;
10
+ } catch(error) {
11
+ throw new ReferenceError("import.meta.url is available in «esnext» libtype only");
12
+ }
13
+ }
14
+ };
15
+
16
+ return { createImagePath };
17
17
  }
@@ -1,42 +1,42 @@
1
- export default function useLabels(
2
- label,
3
- createCustomOptionLabel,
4
- emptyObjectsPlaceholder,
5
- ) {
6
- /**
7
- * Creates label of any kind of option
8
- * @function
9
- * @param {string} label - label field in options of type "object"
10
- * @param {option} UnionPropType
11
- * @returns {string} label
12
- */
13
- const optionCreateLabel = (option) => {
14
- const isFunction = typeof option === "function";
15
-
16
- if (!option && isFunction) return "";
17
-
18
- const customOptionLabel = createCustomOptionLabel.value(option);
19
-
20
- if (customOptionLabel) return customOptionLabel;
21
-
22
- if (Array.isArray(option) && option.length > 0) {
23
- return option.join(", ");
24
- }
25
-
26
- if (typeof option !== "object") return option.toString();
27
-
28
- if (Object.keys(option).length === 0) {
29
- return emptyObjectsPlaceholder.value;
30
- }
31
-
32
- const hasLabel = Object.getOwnPropertyNames(option).includes(label.value);
33
-
34
- if (hasLabel) {
35
- return typeof option[label.value] === "object" ? JSON.stringify(option[label.value]) : option[label.value];
36
- }
37
-
38
- return "";
39
- };
40
-
41
- return { optionCreateLabel };
1
+ export default function useLabels(
2
+ label,
3
+ createCustomOptionLabel,
4
+ emptyObjectsPlaceholder,
5
+ ) {
6
+ /**
7
+ * Creates label of any kind of option
8
+ * @function
9
+ * @param {string} label - label field in options of type "object"
10
+ * @param {option} UnionPropType
11
+ * @returns {string} label
12
+ */
13
+ const optionCreateLabel = (option) => {
14
+ const isFunction = typeof option === "function";
15
+
16
+ if (!option && isFunction) return "";
17
+
18
+ const customOptionLabel = createCustomOptionLabel.value(option);
19
+
20
+ if (customOptionLabel) return customOptionLabel;
21
+
22
+ if (Array.isArray(option) && option.length > 0) {
23
+ return option.join(", ");
24
+ }
25
+
26
+ if (typeof option !== "object") return option.toString();
27
+
28
+ if (Object.keys(option).length === 0) {
29
+ return emptyObjectsPlaceholder.value;
30
+ }
31
+
32
+ const hasLabel = Object.getOwnPropertyNames(option).includes(label.value);
33
+
34
+ if (hasLabel) {
35
+ return typeof option[label.value] === "object" ? JSON.stringify(option[label.value]) : option[label.value];
36
+ }
37
+
38
+ return "";
39
+ };
40
+
41
+ return { optionCreateLabel };
42
42
  }
@@ -1,68 +1,68 @@
1
- export default function usePreselectedOptions(
2
- label,
3
- emptyObjectsPlaceholder,
4
- showInsertWarnings,
5
- ) {
6
- /**
7
- * Creates string label for any kind of option
8
- * @function
9
- * @param {string} label - label field in options of type "object"
10
- * @param {boolean} isObjectOrArray - determines whether option is of type "object" or instance of Array
11
- * @param {UnionPropType} option - option which needs label
12
- * @returns {string} label
13
- */
14
- const createLabel = (isObjectOrArray, option) => {
15
- let createdLabel;
16
-
17
- if (isObjectOrArray) {
18
- if (Array.isArray(option) && option.length > 0) {
19
- createdLabel = option.join(", ");
20
- } else {
21
- createdLabel = typeof option[label.value] === "object"
22
- ? JSON.stringify(option[label.value])
23
- : option[label.value];
24
- }
25
-
26
- if (Object.keys(option).length === 0) {
27
- createdLabel = emptyObjectsPlaceholder.value;
28
- }
29
- } else {
30
- createdLabel = option.toString();
31
- }
32
-
33
- return createdLabel;
34
- };
35
-
36
- /**
37
- * Restricts wrong types of options in options list
38
- * @method
39
- * @param {UnionPropType} option - option to restrict
40
- * @returns {boolean} restriction
41
- */
42
- const optionTypeRestrictor = (option) => {
43
- if (!option) return false;
44
-
45
- const isObjectArrayInstance = Object.getPrototypeOf(option).constructor.name
46
- !== "Object"
47
- && Object.getPrototypeOf(option).constructor.name !== "Array";
48
- const isAnyInstance = typeof option === "object" && isObjectArrayInstance;
49
- const isSymbol = typeof option === "symbol";
50
-
51
- if (isSymbol && showInsertWarnings.value) {
52
- console.warn("vue-extended-multiselect: option can not be of type «symbol»");
53
- }
54
-
55
- if (isAnyInstance && showInsertWarnings.value) {
56
- console.warn("vue-extended-multiselect: option can not be an instance of any constructor function");
57
- }
58
-
59
- if (isSymbol || isAnyInstance) return false;
60
-
61
- return true;
62
- };
63
-
64
- return {
65
- createLabel,
66
- optionTypeRestrictor,
67
- };
1
+ export default function usePreselectedOptions(
2
+ label,
3
+ emptyObjectsPlaceholder,
4
+ showInsertWarnings,
5
+ ) {
6
+ /**
7
+ * Creates string label for any kind of option
8
+ * @function
9
+ * @param {string} label - label field in options of type "object"
10
+ * @param {boolean} isObjectOrArray - determines whether option is of type "object" or instance of Array
11
+ * @param {UnionPropType} option - option which needs label
12
+ * @returns {string} label
13
+ */
14
+ const createLabel = (isObjectOrArray, option) => {
15
+ let createdLabel;
16
+
17
+ if (isObjectOrArray) {
18
+ if (Array.isArray(option) && option.length > 0) {
19
+ createdLabel = option.join(", ");
20
+ } else {
21
+ createdLabel = typeof option[label.value] === "object"
22
+ ? JSON.stringify(option[label.value])
23
+ : option[label.value];
24
+ }
25
+
26
+ if (Object.keys(option).length === 0) {
27
+ createdLabel = emptyObjectsPlaceholder.value;
28
+ }
29
+ } else {
30
+ createdLabel = option.toString();
31
+ }
32
+
33
+ return createdLabel;
34
+ };
35
+
36
+ /**
37
+ * Restricts wrong types of options in options list
38
+ * @method
39
+ * @param {UnionPropType} option - option to restrict
40
+ * @returns {boolean} restriction
41
+ */
42
+ const optionTypeRestrictor = (option) => {
43
+ if (!option) return false;
44
+
45
+ const isObjectArrayInstance = Object.getPrototypeOf(option).constructor.name
46
+ !== "Object"
47
+ && Object.getPrototypeOf(option).constructor.name !== "Array";
48
+ const isAnyInstance = typeof option === "object" && isObjectArrayInstance;
49
+ const isSymbol = typeof option === "symbol";
50
+
51
+ if (isSymbol && showInsertWarnings.value) {
52
+ console.warn("vue-extended-multiselect: option can not be of type «symbol»");
53
+ }
54
+
55
+ if (isAnyInstance && showInsertWarnings.value) {
56
+ console.warn("vue-extended-multiselect: option can not be an instance of any constructor function");
57
+ }
58
+
59
+ if (isSymbol || isAnyInstance) return false;
60
+
61
+ return true;
62
+ };
63
+
64
+ return {
65
+ createLabel,
66
+ optionTypeRestrictor,
67
+ };
68
68
  }
@@ -1,34 +1,34 @@
1
- import { reactive, readonly } from "vue";
2
-
3
- export default function useSearchValue() {
4
- /**
5
- * @property {string|null} searchValue - value of search field
6
- * @property {string|null} searchPattern - pattern of inner search for available options
7
- */
8
- const searchState = reactive({
9
- searchValue: null,
10
- searchPattern: null,
11
- });
12
-
13
- /**
14
- * @function setSearchValue
15
- * @param {string|null} value - new value of search field
16
- */
17
- const setSearchValue = (value) => {
18
- searchState.searchValue = value;
19
- };
20
-
21
- /**
22
- * @function setSearchPattern
23
- * @param {string|null} pattern - new pattern of inner search for available options
24
- */
25
- const setSearchPattern = (pattern) => {
26
- searchState.searchPattern = pattern;
27
- };
28
-
29
- return {
30
- searchState: readonly(searchState),
31
- setSearchValue,
32
- setSearchPattern,
33
- };
1
+ import { reactive, readonly } from "vue";
2
+
3
+ export default function useSearchValue() {
4
+ /**
5
+ * @property {string|null} searchValue - value of search field
6
+ * @property {string|null} searchPattern - pattern of inner search for available options
7
+ */
8
+ const searchState = reactive({
9
+ searchValue: null,
10
+ searchPattern: null,
11
+ });
12
+
13
+ /**
14
+ * @function setSearchValue
15
+ * @param {string|null} value - new value of search field
16
+ */
17
+ const setSearchValue = (value) => {
18
+ searchState.searchValue = value;
19
+ };
20
+
21
+ /**
22
+ * @function setSearchPattern
23
+ * @param {string|null} pattern - new pattern of inner search for available options
24
+ */
25
+ const setSearchPattern = (pattern) => {
26
+ searchState.searchPattern = pattern;
27
+ };
28
+
29
+ return {
30
+ searchState: readonly(searchState),
31
+ setSearchValue,
32
+ setSearchPattern,
33
+ };
34
34
  }
@@ -1,45 +1,45 @@
1
- import {
2
- computed,
3
- getCurrentInstance,
4
- readonly,
5
- } from "vue";
6
-
7
- export default function useSizes(iconSize) {
8
- /**
9
- * Defines classes for each kind of icon
10
- * @function
11
- * @returns {string} class
12
- */
13
- const iconSizeClass = computed(() => {
14
- let basicIconSize = "extended__multiselect";
15
-
16
- switch(getCurrentInstance().type.__name) {
17
- case "ExtendedMultiselectLoader":
18
- basicIconSize += "-loader_icon";
19
- break;
20
- case "ExtendedMultiselectToggle":
21
- basicIconSize += "-toggle_icon";
22
- break;
23
- case "ExtendedMultiselectCancel":
24
- basicIconSize += "-cancel_icon";
25
- break;
26
- default:
27
- basicIconSize += "-toggle_icon";
28
- }
29
-
30
- switch(iconSize.value) {
31
- case "large":
32
- return `${basicIconSize}-large`;
33
- case "medium":
34
- return `${basicIconSize}-medium`;
35
- case "small":
36
- return `${basicIconSize}-small`;
37
- case "deselect":
38
- return `${basicIconSize}-deselect`;
39
- default:
40
- return `${basicIconSize}-large`;
41
- }
42
- });
43
-
44
- return { iconSizeClass: readonly(iconSizeClass) };
1
+ import {
2
+ computed,
3
+ getCurrentInstance,
4
+ readonly,
5
+ } from "vue";
6
+
7
+ export default function useSizes(iconSize) {
8
+ /**
9
+ * Defines classes for each kind of icon
10
+ * @function
11
+ * @returns {string} class
12
+ */
13
+ const iconSizeClass = computed(() => {
14
+ let basicIconSize = "extended__multiselect";
15
+
16
+ switch(getCurrentInstance().type.__name) {
17
+ case "ExtendedMultiselectLoader":
18
+ basicIconSize += "-loader_icon";
19
+ break;
20
+ case "ExtendedMultiselectToggle":
21
+ basicIconSize += "-toggle_icon";
22
+ break;
23
+ case "ExtendedMultiselectCancel":
24
+ basicIconSize += "-cancel_icon";
25
+ break;
26
+ default:
27
+ basicIconSize += "-toggle_icon";
28
+ }
29
+
30
+ switch(iconSize.value) {
31
+ case "large":
32
+ return `${basicIconSize}-large`;
33
+ case "medium":
34
+ return `${basicIconSize}-medium`;
35
+ case "small":
36
+ return `${basicIconSize}-small`;
37
+ case "deselect":
38
+ return `${basicIconSize}-deselect`;
39
+ default:
40
+ return `${basicIconSize}-large`;
41
+ }
42
+ });
43
+
44
+ return { iconSizeClass: readonly(iconSizeClass) };
45
45
  }
@@ -1,32 +1,32 @@
1
- import { computed, readonly } from "vue";
2
-
3
- export default function useToggle(loading, disabled, emitter) {
4
- /**
5
- * Toggles classes of slots if "loading"
6
- * or "disabled" props equals true
7
- * @function
8
- * @returns {string} class
9
- */
10
- const toggleSlotClass = computed(() => {
11
- return loading.value || disabled.value
12
- ? "extended__multiselect-toggle--disabled"
13
- : "extended__multiselect-toggle";
14
- });
15
-
16
- /**
17
- * Emits an event which listeners will toggle options list
18
- * @function
19
- * @emits extended:toggle-options
20
- * @param {MouseEvent|KeyboardEvent} event - MouseEvent or KeyboardEvent instance
21
- */
22
- const toggleOptionsList = (event) => {
23
- if (event && event.code === "Tab") return;
24
-
25
- emitter.value.emit("extended:toggle-options");
26
- };
27
-
28
- return {
29
- toggleSlotClass: readonly(toggleSlotClass),
30
- toggleOptionsList,
31
- };
1
+ import { computed, readonly } from "vue";
2
+
3
+ export default function useToggle(loading, disabled, emitter) {
4
+ /**
5
+ * Toggles classes of slots if "loading"
6
+ * or "disabled" props equals true
7
+ * @function
8
+ * @returns {string} class
9
+ */
10
+ const toggleSlotClass = computed(() => {
11
+ return loading.value || disabled.value
12
+ ? "extended__multiselect-toggle--disabled"
13
+ : "extended__multiselect-toggle";
14
+ });
15
+
16
+ /**
17
+ * Emits an event which listeners will toggle options list
18
+ * @function
19
+ * @emits extended:toggle-options
20
+ * @param {MouseEvent|KeyboardEvent} event - MouseEvent or KeyboardEvent instance
21
+ */
22
+ const toggleOptionsList = (event) => {
23
+ if (event && event.code === "Tab") return;
24
+
25
+ emitter.value.emit("extended:toggle-options");
26
+ };
27
+
28
+ return {
29
+ toggleSlotClass: readonly(toggleSlotClass),
30
+ toggleOptionsList,
31
+ };
32
32
  }
@@ -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;
@@ -0,0 +1,3 @@
1
+ import LocalEmitter from "../events/LocalEmitter";
2
+
3
+ export default new LocalEmitter();