@varlet/use 2.11.5 → 2.11.6
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/index.d.ts +7 -5
- package/lib/index.js +7 -5
- package/lib/onMounted.d.ts +1 -0
- package/lib/onMounted.js +16 -0
- package/lib/onSmartMounted copy.d.ts +1 -0
- package/lib/onSmartMounted copy.js +16 -0
- package/lib/onSmartMounted.d.ts +1 -0
- package/lib/onSmartMounted.js +16 -0
- package/lib/onSmartUnmounted.d.ts +1 -0
- package/lib/onSmartUnmounted.js +9 -0
- package/lib/onWindowResize.d.ts +1 -0
- package/lib/onWindowResize.js +5 -0
- package/lib/useClickOutside.js +1 -1
- package/lib/useEventListener.js +2 -2
- package/lib/useParent.d.ts +1 -1
- package/lib/useWindowResize.d.ts +1 -0
- package/lib/useWindowResize.js +5 -0
- package/package.json +2 -2
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * from './useEventListener
|
|
2
|
-
export * from './useClickOutside
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './useEventListener';
|
|
2
|
+
export * from './useClickOutside';
|
|
3
|
+
export * from './onSmartMounted';
|
|
4
|
+
export * from './onSmartUnmounted';
|
|
5
|
+
export * from './useParent';
|
|
6
|
+
export * from './useChildren';
|
|
7
|
+
export * from './onWindowResize';
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export * from './useEventListener
|
|
2
|
-
export * from './useClickOutside
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
1
|
+
export * from './useEventListener';
|
|
2
|
+
export * from './useClickOutside';
|
|
3
|
+
export * from './onSmartMounted';
|
|
4
|
+
export * from './onSmartUnmounted';
|
|
5
|
+
export * from './useParent';
|
|
6
|
+
export * from './useChildren';
|
|
7
|
+
export * from './onWindowResize';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onSmartMounted(hook: () => void): void;
|
package/lib/onMounted.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { onMounted, nextTick, onActivated } from 'vue';
|
|
2
|
+
export function onSmartMounted(hook) {
|
|
3
|
+
let isMounted = false;
|
|
4
|
+
onMounted(() => {
|
|
5
|
+
hook();
|
|
6
|
+
nextTick(() => {
|
|
7
|
+
isMounted = true;
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
onActivated(() => {
|
|
11
|
+
if (!isMounted) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
hook();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onSmartMounted(hook: () => void): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { onMounted, nextTick, onActivated } from 'vue';
|
|
2
|
+
export function onSmartMounted(hook) {
|
|
3
|
+
let isMounted = false;
|
|
4
|
+
onMounted(() => {
|
|
5
|
+
hook();
|
|
6
|
+
nextTick(() => {
|
|
7
|
+
isMounted = true;
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
onActivated(() => {
|
|
11
|
+
if (!isMounted) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
hook();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onSmartMounted(hook: () => void): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { onMounted, nextTick, onActivated } from 'vue';
|
|
2
|
+
export function onSmartMounted(hook) {
|
|
3
|
+
let isMounted = false;
|
|
4
|
+
onMounted(() => {
|
|
5
|
+
hook();
|
|
6
|
+
nextTick(() => {
|
|
7
|
+
isMounted = true;
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
onActivated(() => {
|
|
11
|
+
if (!isMounted) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
hook();
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onSmartUnmounted(hook: () => void): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function onWindowResize(listener: EventListener): void;
|
package/lib/useClickOutside.js
CHANGED
package/lib/useEventListener.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inBrowser, isFunction } from '@varlet/shared';
|
|
2
2
|
import { isRef, onDeactivated, onBeforeUnmount, unref, watch } from 'vue';
|
|
3
|
-
import {
|
|
3
|
+
import { onSmartMounted } from './onSmartMounted';
|
|
4
4
|
export function useEventListener(target, type, listener, options = {}) {
|
|
5
5
|
if (!inBrowser()) {
|
|
6
6
|
return;
|
|
@@ -48,7 +48,7 @@ export function useEventListener(target, type, listener, options = {}) {
|
|
|
48
48
|
remove(target);
|
|
49
49
|
cleaned = true;
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
onSmartMounted(() => {
|
|
52
52
|
add(target);
|
|
53
53
|
});
|
|
54
54
|
onBeforeUnmount(() => {
|
package/lib/useParent.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComputedRef } from 'vue';
|
|
2
|
-
import { type UseChildrenBaseProvider } from './useChildren
|
|
2
|
+
import { type UseChildrenBaseProvider } from './useChildren';
|
|
3
3
|
export declare function keyInProvides(key: symbol | string): boolean;
|
|
4
4
|
export declare function useParent<P, C>(key: symbol | string): {
|
|
5
5
|
index: null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useWindowResize(listener: EventListener): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlet/use",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/varletjs/varlet/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@varlet/shared": "2.11.
|
|
27
|
+
"@varlet/shared": "2.11.6"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"typescript": "^4.4.4",
|