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,40 +1,40 @@
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
- const deselectedOptions = selectedOptions.value;
23
-
24
- emitter.value.emit("extended:skip-block-blur-zeroing");
25
- emitter.value.emit("extended:deselect-option", {
26
- index: null,
27
- clearAll: true,
28
- deselectedOptions,
29
- });
30
-
31
- if (!showSearchField.value) return;
32
-
33
- emitter.value.emit("extended:clean-options");
34
-
35
- setSearchValue(null);
36
- setSearchPattern(null);
37
- };
38
-
39
- 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
+ const deselectedOptions = selectedOptions.value;
23
+
24
+ emitter.value.emit("extended:skip-block-blur-zeroing");
25
+ emitter.value.emit("extended:deselect-option", {
26
+ index: null,
27
+ clearAll: true,
28
+ deselectedOptions,
29
+ });
30
+
31
+ if (!showSearchField.value) return;
32
+
33
+ emitter.value.emit("extended:clean-options");
34
+
35
+ setSearchValue(null);
36
+ setSearchPattern(null);
37
+ };
38
+
39
+ return { cancel };
40
40
  }
@@ -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 Debounce from "../tools/Debounce";
4
-
5
- export default function useDebounce() {
6
- const DebounceConstructor = ref(Debounce);
7
-
8
- return { DebounceConstructor };
1
+ import { ref } from "vue";
2
+
3
+ import Debounce from "../tools/Debounce";
4
+
5
+ export default function useDebounce() {
6
+ const DebounceConstructor = ref(Debounce);
7
+
8
+ return { DebounceConstructor };
9
9
  }
@@ -1,9 +1,9 @@
1
- import { ref } from "vue";
2
-
3
- import LocalEmitter from "../tools/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 "../tools/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/images/${image}`);
7
+ } else {
8
+ try {
9
+ return new URL(`../assets/images/${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
  }