vue3-extended-multiselect 2.0.0 → 2.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/README.md +1 -1
- package/dist/Vue3ExtendedMultiselect.cjs.js +5295 -0
- package/dist/Vue3ExtendedMultiselect.cjs.js.map +1 -0
- package/dist/Vue3ExtendedMultiselect.esm.js +5290 -0
- package/dist/Vue3ExtendedMultiselect.esm.js.map +1 -0
- package/dist/types/index.d.ts +46 -0
- package/package.json +5 -1
- package/.browserslistrc +0 -3
- package/.eslintrc.js +0 -36
- package/.github/workflows/publish.yml +0 -41
- package/.nvmrc +0 -0
- package/CHANGELOG.md +0 -411
- package/CONTRIBUTING.md +0 -57
- package/babel.config.js +0 -10
- package/index.js +0 -3
- package/jest.config.js +0 -62
- package/rollup.config.mjs +0 -74
- package/src/components/ExtendedMultiselectCancel.vue +0 -165
- package/src/components/ExtendedMultiselectInput.vue +0 -742
- package/src/components/ExtendedMultiselectLoader.vue +0 -182
- package/src/components/ExtendedMultiselectMultiple.vue +0 -400
- package/src/components/ExtendedMultiselectOptions.vue +0 -1191
- package/src/components/ExtendedMultiselectToggle.vue +0 -272
- package/src/components/Vue3ExtendedMultiselect.vue +0 -2476
- package/src/composition/cancel.js +0 -40
- package/src/composition/click-outside.js +0 -9
- package/src/composition/debounce.js +0 -9
- package/src/composition/emitter.js +0 -9
- package/src/composition/image-path.js +0 -17
- package/src/composition/labels.js +0 -42
- package/src/composition/preselected-options.js +0 -68
- package/src/composition/search-value.js +0 -34
- package/src/composition/sizes.js +0 -45
- package/src/composition/toggle.js +0 -32
- package/src/sets/sets.js +0 -100
- package/src/styles/animations.css +0 -19
- package/src/styles/main.css +0 -460
- package/src/styles/variables.css +0 -52
- package/src/tools/Debounce.js +0 -26
- package/src/tools/LocalEmitter.js +0 -32
- package/src/tools/instance.js +0 -3
- package/tests/unit/events.spec.js +0 -150
- package/tests/unit/props.spec.js +0 -1155
- package/tests/unit/tools.spec.js +0 -56
- package/tests/utils/mocks.js +0 -1
- package/tests/utils/mount.js +0 -38
- package/tests/utils/stubs.js +0 -1
- package/tests/utils/utils.js +0 -25
- package/typings/vue3-extended-multiselect.d.ts +0 -44
- /package/{src → dist}/assets/images/base-arrow.svg +0 -0
- /package/{src → dist}/assets/images/cancel.svg +0 -0
- /package/{src → dist}/assets/images/circle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/double-arrow.svg +0 -0
- /package/{src → dist}/assets/images/inner-arrow.svg +0 -0
- /package/{src → dist}/assets/images/loader.svg +0 -0
- /package/{src → dist}/assets/images/triangle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/triangle-circle-arrow.svg +0 -0
- /package/{src → dist}/assets/images/wide-arrow.svg +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
}
|
package/src/composition/sizes.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
package/src/sets/sets.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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
|
-
];
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
.extended-toggle-enter-active,
|
|
2
|
-
.extended-toggle-leave-active {
|
|
3
|
-
transition: opacity 250ms;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.extended-toggle-enter,
|
|
7
|
-
.extended-toggle-leave-to {
|
|
8
|
-
opacity: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@keyframes loading {
|
|
13
|
-
0% {
|
|
14
|
-
transform: rotate(0deg);
|
|
15
|
-
}
|
|
16
|
-
100% {
|
|
17
|
-
transform: rotate(2turn);
|
|
18
|
-
}
|
|
19
|
-
}
|