@vef-framework/hooks 2.0.4 → 2.0.5
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/dist/cjs/index.cjs +1 -172
- package/dist/cjs/lib.cjs +1 -148
- package/dist/cjs/use-authorized-items/index.cjs +1 -20
- package/dist/cjs/use-breakpoints/index.cjs +1 -74
- package/dist/cjs/use-check-permission/index.cjs +1 -18
- package/dist/cjs/use-data-dict-query/index.cjs +1 -34
- package/dist/cjs/use-data-options/index.cjs +1 -119
- package/dist/cjs/use-deep-callback/index.cjs +1 -13
- package/dist/cjs/use-deep-compare/index.cjs +1 -36
- package/dist/cjs/use-deep-effect/index.cjs +1 -13
- package/dist/cjs/use-deep-isomorphic-effect/index.cjs +1 -14
- package/dist/cjs/use-deep-layout-effect/index.cjs +1 -13
- package/dist/cjs/use-deep-memo/index.cjs +1 -13
- package/dist/cjs/use-document-event/index.cjs +1 -22
- package/dist/cjs/use-emitter-event/index.cjs +1 -22
- package/dist/cjs/use-has-fetching/index.cjs +1 -17
- package/dist/cjs/use-has-mutating/index.cjs +1 -16
- package/dist/cjs/use-is-authorized/index.cjs +1 -18
- package/dist/cjs/use-latest/index.cjs +1 -14
- package/dist/cjs/use-raf-state/index.cjs +1 -23
- package/dist/cjs/use-shallow-callback/index.cjs +1 -13
- package/dist/cjs/use-shallow-compare/index.cjs +1 -36
- package/dist/cjs/use-shallow-effect/index.cjs +1 -13
- package/dist/cjs/use-shallow-isomorphic-effect/index.cjs +1 -14
- package/dist/cjs/use-shallow-layout-effect/index.cjs +1 -13
- package/dist/cjs/use-shallow-memo/index.cjs +1 -13
- package/dist/cjs/use-singleton/index.cjs +1 -16
- package/dist/es/index.js +85 -29
- package/dist/es/lib.js +51 -23
- package/dist/es/use-authorized-items/index.js +12 -13
- package/dist/es/use-breakpoints/index.js +43 -58
- package/dist/es/use-check-permission/index.js +10 -12
- package/dist/es/use-data-dict-query/index.js +22 -26
- package/dist/es/use-data-options/index.js +72 -105
- package/dist/es/use-deep-callback/index.js +7 -8
- package/dist/es/use-deep-compare/index.js +19 -30
- package/dist/es/use-deep-effect/index.js +7 -8
- package/dist/es/use-deep-isomorphic-effect/index.js +8 -9
- package/dist/es/use-deep-layout-effect/index.js +7 -8
- package/dist/es/use-deep-memo/index.js +7 -8
- package/dist/es/use-document-event/index.js +13 -15
- package/dist/es/use-emitter-event/index.js +12 -13
- package/dist/es/use-has-fetching/index.js +9 -11
- package/dist/es/use-has-mutating/index.js +9 -11
- package/dist/es/use-is-authorized/index.js +10 -12
- package/dist/es/use-latest/index.js +7 -9
- package/dist/es/use-raf-state/index.js +11 -16
- package/dist/es/use-shallow-callback/index.js +7 -8
- package/dist/es/use-shallow-compare/index.js +19 -30
- package/dist/es/use-shallow-effect/index.js +7 -8
- package/dist/es/use-shallow-isomorphic-effect/index.js +8 -9
- package/dist/es/use-shallow-layout-effect/index.js +7 -8
- package/dist/es/use-shallow-memo/index.js +7 -8
- package/dist/es/use-singleton/index.js +7 -11
- package/package.json +3 -3
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
() => checkPermission(hasPermission, permTokens, checkMode),
|
|
9
|
-
[permTokens, checkMode, hasPermission]
|
|
1
|
+
import { useAppContext as r, checkPermission as s } from "@vef-framework/core";
|
|
2
|
+
import { useMemo as e } from "react";
|
|
3
|
+
function h(o, t) {
|
|
4
|
+
const { hasPermission: i = () => !0 } = r();
|
|
5
|
+
return e(
|
|
6
|
+
() => s(i, o, t),
|
|
7
|
+
[o, t, i]
|
|
10
8
|
);
|
|
11
|
-
return isAuthorized;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export {
|
|
11
|
+
h as useIsAuthorized
|
|
12
|
+
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ref = useRef(value);
|
|
6
|
-
ref.current = value;
|
|
7
|
-
return ref;
|
|
1
|
+
import { useRef as e } from "react";
|
|
2
|
+
function o(r) {
|
|
3
|
+
const t = e(r);
|
|
4
|
+
return t.current = r, t;
|
|
8
5
|
}
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export {
|
|
7
|
+
o as useLatest
|
|
8
|
+
};
|
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const [state, setState] = useState(initialState);
|
|
7
|
-
const setRafState = useCallback((state2) => {
|
|
8
|
-
cancelAnimationFrame(frameId.current);
|
|
9
|
-
frameId.current = requestAnimationFrame(() => {
|
|
10
|
-
setState(state2);
|
|
1
|
+
import { useRef as s, useState as u, useCallback as o, useEffect as m } from "react";
|
|
2
|
+
function i(t) {
|
|
3
|
+
const e = s(0), [a, n] = u(t), r = o((c) => {
|
|
4
|
+
cancelAnimationFrame(e.current), e.current = requestAnimationFrame(() => {
|
|
5
|
+
n(c);
|
|
11
6
|
});
|
|
12
7
|
}, []);
|
|
13
|
-
|
|
14
|
-
cancelAnimationFrame(
|
|
15
|
-
}, []);
|
|
16
|
-
return [state, setRafState];
|
|
8
|
+
return m(() => () => {
|
|
9
|
+
cancelAnimationFrame(e.current);
|
|
10
|
+
}, []), [a, r];
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
export {
|
|
13
|
+
i as useRafState
|
|
14
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useShallowCallback(callback, dependencies) {
|
|
6
|
-
return useCallback(callback, useShallowCompare(dependencies));
|
|
1
|
+
import { useCallback as r } from "react";
|
|
2
|
+
import { useShallowCompare as a } from "../use-shallow-compare/index.js";
|
|
3
|
+
function t(o, l) {
|
|
4
|
+
return r(o, a(l));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
t as useShallowCallback
|
|
8
|
+
};
|
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ref = useRef(void 0);
|
|
7
|
-
const signalRef = useRef(0);
|
|
8
|
-
if (!shallowCompare(ref.current, dependencies)) {
|
|
9
|
-
ref.current = dependencies;
|
|
10
|
-
signalRef.current += 1;
|
|
11
|
-
}
|
|
12
|
-
return [signalRef.current];
|
|
1
|
+
import { isShallowEqual as o } from "@vef-framework/shared";
|
|
2
|
+
import { useRef as n } from "react";
|
|
3
|
+
function a(r) {
|
|
4
|
+
const e = n(void 0), t = n(0);
|
|
5
|
+
return l(e.current, r) || (e.current = r, t.current += 1), [t.current];
|
|
13
6
|
}
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!isShallowEqual(element, current[index])) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
7
|
+
function l(r, e) {
|
|
8
|
+
if (!r || !e)
|
|
9
|
+
return !1;
|
|
10
|
+
if (Object.is(r, e))
|
|
11
|
+
return !0;
|
|
12
|
+
if (r.length !== e.length)
|
|
13
|
+
return !1;
|
|
14
|
+
for (const [t, f] of r.entries())
|
|
15
|
+
if (!o(f, e[t]))
|
|
16
|
+
return !1;
|
|
17
|
+
return !0;
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
export {
|
|
20
|
+
a as useShallowCompare
|
|
21
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useShallowEffect(effect, dependencies) {
|
|
6
|
-
return useEffect(effect, useShallowCompare(dependencies));
|
|
1
|
+
import { useEffect as r } from "react";
|
|
2
|
+
import { useShallowCompare as f } from "../use-shallow-compare/index.js";
|
|
3
|
+
function u(o, e) {
|
|
4
|
+
return r(o, f(e));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
u as useShallowEffect
|
|
8
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function useShallowIsomorphicEffect(effect, dependencies) {
|
|
7
|
-
return useIsomorphicEffect(effect, useShallowCompare(dependencies));
|
|
1
|
+
import "../lib.js";
|
|
2
|
+
import { useShallowCompare as e } from "../use-shallow-compare/index.js";
|
|
3
|
+
import { useIsomorphicEffect as m } from "@mantine/hooks";
|
|
4
|
+
function i(o, r) {
|
|
5
|
+
return m(o, e(r));
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export {
|
|
8
|
+
i as useShallowIsomorphicEffect
|
|
9
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useShallowLayoutEffect(effect, dependencies) {
|
|
6
|
-
return useLayoutEffect(effect, useShallowCompare(dependencies));
|
|
1
|
+
import { useLayoutEffect as e } from "react";
|
|
2
|
+
import { useShallowCompare as r } from "../use-shallow-compare/index.js";
|
|
3
|
+
function a(o, t) {
|
|
4
|
+
return e(o, r(t));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
a as useShallowLayoutEffect
|
|
8
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useShallowMemo(factory, dependencies) {
|
|
6
|
-
return useMemo(factory, useShallowCompare(dependencies));
|
|
1
|
+
import { useMemo as r } from "react";
|
|
2
|
+
import { useShallowCompare as m } from "../use-shallow-compare/index.js";
|
|
3
|
+
function l(o, e) {
|
|
4
|
+
return r(o, m(e));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
l as useShallowMemo
|
|
8
|
+
};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const ref = useRef(null);
|
|
6
|
-
if (ref.current === null) {
|
|
7
|
-
ref.current = initializer();
|
|
8
|
-
}
|
|
9
|
-
return ref;
|
|
1
|
+
import { useRef as e } from "react";
|
|
2
|
+
function u(r) {
|
|
3
|
+
const n = e(null);
|
|
4
|
+
return n.current === null && (n.current = r()), n;
|
|
10
5
|
}
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
export {
|
|
7
|
+
u as useSingleton
|
|
8
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework/hooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Hooks for VEF framework",
|
|
7
7
|
"author": {
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@mantine/hooks": "^8.3.9",
|
|
52
52
|
"react-hotkeys-hook": "^5.2.1",
|
|
53
|
-
"@vef-framework/
|
|
54
|
-
"@vef-framework/
|
|
53
|
+
"@vef-framework/core": "2.0.5",
|
|
54
|
+
"@vef-framework/shared": "2.0.5"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"react": "^19.2.0"
|