vue3-extended-multiselect 1.7.5 → 1.8.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.
- package/CHANGELOG.md +11 -2
- package/README.md +1 -1
- package/jest.config.js +1 -1
- package/package.json +1 -2
- package/src/components/ExtendedMultiselectInput.vue +5 -4
- package/src/components/Vue3ExtendedMultiselect.vue +2 -2
- package/src/composition/debounce.js +9 -0
- package/src/composition/emitter.js +3 -3
- package/src/tools/Debounce.js +26 -0
- package/src/{events → tools}/LocalEmitter.js +0 -0
- package/src/tools/instance.js +3 -0
- package/tests/unit/tools.spec.js +54 -0
- package/typings/vue3-extended-multiselect.d.ts +2 -1
- package/src/events/instance.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Patch notes
|
|
2
2
|
|
|
3
|
-
Current `vue3-extended-multiselect` version: **1.
|
|
3
|
+
Current `vue3-extended-multiselect` version: **1.8.0**
|
|
4
4
|
|
|
5
5
|
***
|
|
6
6
|
|
|
@@ -293,4 +293,13 @@ Adding descriptive comments for some types in typings.
|
|
|
293
293
|
|
|
294
294
|
### 1.7.5 (2023-02-08)
|
|
295
295
|
|
|
296
|
-
* Removal of excess condition in toggle restriction.
|
|
296
|
+
* Removal of excess condition in toggle restriction.
|
|
297
|
+
|
|
298
|
+
### 1.8.0 (2023-02-15)
|
|
299
|
+
|
|
300
|
+
* Adding tools directory.
|
|
301
|
+
* Adding Debounce.js file with debounce tool.
|
|
302
|
+
* Adding type for "update-wrapper" event.
|
|
303
|
+
* Adding tools.spec.js file with unit-tests for tools.
|
|
304
|
+
* Moving local emitter files to tools directory.
|
|
305
|
+
* Removal of "lodash-es" dependency.
|
package/README.md
CHANGED
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue3-extended-multiselect",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "Extended multiselect component for applications based on Vue 3 framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"multiselect",
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"core-js": "^3.6.5",
|
|
26
26
|
"extended-click-outside": "^1.1.0",
|
|
27
|
-
"lodash-es": "^4.17.21",
|
|
28
27
|
"vue": "^3.0.0"
|
|
29
28
|
},
|
|
30
29
|
"devDependencies": {
|
|
@@ -152,7 +152,7 @@ import {
|
|
|
152
152
|
watch,
|
|
153
153
|
} from "vue";
|
|
154
154
|
|
|
155
|
-
import
|
|
155
|
+
import useDebounce from "../composition/debounce";
|
|
156
156
|
|
|
157
157
|
import ExtendedMultiselectMultiple from "./ExtendedMultiselectMultiple.vue";
|
|
158
158
|
|
|
@@ -419,6 +419,8 @@ const setSearchPattern = inject("setSearchPattern");
|
|
|
419
419
|
|
|
420
420
|
const emitter = toRef(props, "emitter");
|
|
421
421
|
|
|
422
|
+
const { DebounceConstructor } = useDebounce();
|
|
423
|
+
|
|
422
424
|
const blurSkip = ref(false);
|
|
423
425
|
const reversePrevented = ref(false);
|
|
424
426
|
const searchFieldFocused = ref(false);
|
|
@@ -428,9 +430,8 @@ const singleLabel = ref("");
|
|
|
428
430
|
const blurSkipByToggleIcon = ref(0);
|
|
429
431
|
const blurSkipByBlock = ref(0);
|
|
430
432
|
const labelBlocks = ref([]);
|
|
431
|
-
const searchDebounce = ref(
|
|
433
|
+
const searchDebounce = ref(new DebounceConstructor.value(() => {
|
|
432
434
|
const searchPattern = searchValue.value ? new RegExp(`${searchValue.value}`, "i") : null;
|
|
433
|
-
|
|
434
435
|
if (externalOptionsLoader.value) {
|
|
435
436
|
emitter.value.emit("extended:loader-pattern-changed", searchValue.value);
|
|
436
437
|
} else {
|
|
@@ -609,7 +610,7 @@ const rollUp = () => {
|
|
|
609
610
|
* @function
|
|
610
611
|
*/
|
|
611
612
|
const search = () => {
|
|
612
|
-
searchDebounce.value();
|
|
613
|
+
searchDebounce.value.start();
|
|
613
614
|
};
|
|
614
615
|
|
|
615
616
|
/**
|
|
@@ -245,7 +245,7 @@ import {
|
|
|
245
245
|
UnionPropType,
|
|
246
246
|
} from "../sets/sets";
|
|
247
247
|
|
|
248
|
-
import localEmitter from "../
|
|
248
|
+
import localEmitter from "../tools/instance.js";
|
|
249
249
|
|
|
250
250
|
import useToggle from "../composition/toggle";
|
|
251
251
|
import useCancel from "../composition/cancel";
|
|
@@ -262,7 +262,7 @@ import ExtendedMultiselectToggle from "./ExtendedMultiselectToggle.vue";
|
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* @author Ridiger Daniil Dmitrievich, 2022
|
|
265
|
-
* @version 1.
|
|
265
|
+
* @version 1.8.0
|
|
266
266
|
*/
|
|
267
267
|
|
|
268
268
|
const props = defineProps({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ref } from "vue";
|
|
2
2
|
|
|
3
|
-
import LocalEmitter from "../
|
|
3
|
+
import LocalEmitter from "../tools/LocalEmitter";
|
|
4
4
|
|
|
5
5
|
export default function useEmitter() {
|
|
6
|
-
|
|
6
|
+
const emitter = ref(new LocalEmitter());
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
return { emitter };
|
|
9
9
|
}
|
|
@@ -0,0 +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
|
+
|
|
26
|
+
export default Debounce;
|
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { fireEvent } from "@testing-library/dom";
|
|
2
|
+
|
|
3
|
+
import { mountComponent } from "../utils/mount";
|
|
4
|
+
|
|
5
|
+
import Vue3ExtendedMultiselect from "../../src/components/Vue3ExtendedMultiselect.vue";
|
|
6
|
+
import ExtendedMultiselectOptions from "../../src/components/ExtendedMultiselectOptions.vue";
|
|
7
|
+
|
|
8
|
+
let wrapper;
|
|
9
|
+
|
|
10
|
+
describe("tools", () => {
|
|
11
|
+
it("correctly debounces search value changing", async (done) => {
|
|
12
|
+
const propsData = {
|
|
13
|
+
defaultExpanded: true,
|
|
14
|
+
options: globalThis.OPTIONS,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
18
|
+
|
|
19
|
+
const input = wrapper.find("input");
|
|
20
|
+
const optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
21
|
+
const optionsListWrapper = optionsWrapper.find(".extended__multiselect-options_container");
|
|
22
|
+
|
|
23
|
+
await fireEvent.input(input.element, { target: { value: globalThis.SEARCH_VALUE_WITH_RESULTS } });
|
|
24
|
+
|
|
25
|
+
expect(optionsListWrapper.element.children).toHaveLength(4);
|
|
26
|
+
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
expect(optionsListWrapper.element.children).toHaveLength(1);
|
|
29
|
+
|
|
30
|
+
done();
|
|
31
|
+
}, 1000);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it("correctly handles outside clicks", async () => {
|
|
36
|
+
const propsData = {
|
|
37
|
+
defaultExpanded: true,
|
|
38
|
+
options: globalThis.OPTIONS,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
wrapper = await mountComponent(Vue3ExtendedMultiselect, false, propsData);
|
|
42
|
+
|
|
43
|
+
let optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
44
|
+
|
|
45
|
+
expect(optionsWrapper.exists()).toBeTruthy();
|
|
46
|
+
expect(optionsWrapper.isVisible()).toBeTruthy();
|
|
47
|
+
|
|
48
|
+
await fireEvent.click(document.documentElement);
|
|
49
|
+
|
|
50
|
+
optionsWrapper = wrapper.findComponent(ExtendedMultiselectOptions);
|
|
51
|
+
|
|
52
|
+
expect(optionsWrapper.exists()).toBeFalsy();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -41,4 +41,5 @@ export type CloseEvent = CleanEvent;
|
|
|
41
41
|
export type IncreaseEvent = number | Limit;
|
|
42
42
|
export type OptionCreatedEvent = UnionOptionType | SingleOption;
|
|
43
43
|
export type PatternChangedEvent = string | PatternChanged;
|
|
44
|
-
export type SelectEvent = OptionCreatedEvent;
|
|
44
|
+
export type SelectEvent = OptionCreatedEvent;
|
|
45
|
+
export type UpdateWrapperEvent = OptionsList;
|
package/src/events/instance.js
DELETED