@varlet/use 2.11.8 → 2.12.0-alpha.1687974059976
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/lib/useChildren.js
CHANGED
|
@@ -26,9 +26,7 @@ export function useChildren(key) {
|
|
|
26
26
|
const length = computed(() => childInstances.length);
|
|
27
27
|
const sortInstances = () => {
|
|
28
28
|
const vNodes = flatVNodes(parentInstance.subTree);
|
|
29
|
-
childInstances.sort((a, b) =>
|
|
30
|
-
return vNodes.indexOf(a.vnode) - vNodes.indexOf(b.vnode);
|
|
31
|
-
});
|
|
29
|
+
childInstances.sort((a, b) => vNodes.indexOf(a.vnode) - vNodes.indexOf(b.vnode));
|
|
32
30
|
};
|
|
33
31
|
const collect = (childInstance, childProvider) => {
|
|
34
32
|
childInstances.push(childInstance);
|
package/lib/useClickOutside.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
export
|
|
2
|
+
export type UseClickOutsideTarget = Element | Ref<Element | undefined | null> | (() => Element);
|
|
3
3
|
export declare function useClickOutside(target: UseClickOutsideTarget, type: string, listener: EventListener): void;
|
package/lib/useClickOutside.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useEventListener } from './useEventListener.js';
|
|
2
|
-
import { inBrowser } from '@varlet/shared';
|
|
2
|
+
import { inBrowser, isFunction } from '@varlet/shared';
|
|
3
3
|
import { unref } from 'vue';
|
|
4
4
|
export function useClickOutside(target, type, listener) {
|
|
5
5
|
if (!inBrowser()) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
const handler = (event) => {
|
|
9
|
-
const element = unref(target);
|
|
9
|
+
const element = isFunction(target) ? target() : unref(target);
|
|
10
10
|
if (element && !element.contains(event.target)) {
|
|
11
11
|
listener(event);
|
|
12
12
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
export
|
|
2
|
+
export type UseEventListenerTarget = EventTarget | Ref<EventTarget | undefined | null> | (() => EventTarget);
|
|
3
3
|
export interface UseEventListenerOptions {
|
|
4
4
|
capture?: boolean;
|
|
5
5
|
passive?: boolean;
|
package/lib/useEventListener.js
CHANGED
|
@@ -8,9 +8,7 @@ export function useEventListener(target, type, listener, options = {}) {
|
|
|
8
8
|
const { passive = false, capture = false } = options;
|
|
9
9
|
let listening = false;
|
|
10
10
|
let cleaned = false;
|
|
11
|
-
const getElement = (target) =>
|
|
12
|
-
return isFunction(target) ? target() : unref(target);
|
|
13
|
-
};
|
|
11
|
+
const getElement = (target) => isFunction(target) ? target() : unref(target);
|
|
14
12
|
const add = (target) => {
|
|
15
13
|
if (listening || cleaned) {
|
|
16
14
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/use",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0-alpha.1687974059976",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"url": "https://github.com/varletjs/varlet/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@varlet/shared": "2.
|
|
27
|
+
"@varlet/shared": "2.12.0-alpha.1687974059976"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"typescript": "^
|
|
31
|
-
"vue": "3.3.
|
|
30
|
+
"typescript": "^5.1.5",
|
|
31
|
+
"vue": "3.3.4"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"vue": "^3.2.0"
|