@vef-framework/hooks 2.0.4 → 2.0.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.
Files changed (55) hide show
  1. package/dist/cjs/index.cjs +1 -172
  2. package/dist/cjs/lib.cjs +1 -148
  3. package/dist/cjs/use-authorized-items/index.cjs +1 -20
  4. package/dist/cjs/use-breakpoints/index.cjs +1 -74
  5. package/dist/cjs/use-check-permission/index.cjs +1 -18
  6. package/dist/cjs/use-data-dict-query/index.cjs +1 -34
  7. package/dist/cjs/use-data-options/index.cjs +1 -119
  8. package/dist/cjs/use-deep-callback/index.cjs +1 -13
  9. package/dist/cjs/use-deep-compare/index.cjs +1 -36
  10. package/dist/cjs/use-deep-effect/index.cjs +1 -13
  11. package/dist/cjs/use-deep-isomorphic-effect/index.cjs +1 -14
  12. package/dist/cjs/use-deep-layout-effect/index.cjs +1 -13
  13. package/dist/cjs/use-deep-memo/index.cjs +1 -13
  14. package/dist/cjs/use-document-event/index.cjs +1 -22
  15. package/dist/cjs/use-emitter-event/index.cjs +1 -22
  16. package/dist/cjs/use-has-fetching/index.cjs +1 -17
  17. package/dist/cjs/use-has-mutating/index.cjs +1 -16
  18. package/dist/cjs/use-is-authorized/index.cjs +1 -18
  19. package/dist/cjs/use-latest/index.cjs +1 -14
  20. package/dist/cjs/use-raf-state/index.cjs +1 -23
  21. package/dist/cjs/use-shallow-callback/index.cjs +1 -13
  22. package/dist/cjs/use-shallow-compare/index.cjs +1 -36
  23. package/dist/cjs/use-shallow-effect/index.cjs +1 -13
  24. package/dist/cjs/use-shallow-isomorphic-effect/index.cjs +1 -14
  25. package/dist/cjs/use-shallow-layout-effect/index.cjs +1 -13
  26. package/dist/cjs/use-shallow-memo/index.cjs +1 -13
  27. package/dist/cjs/use-singleton/index.cjs +1 -16
  28. package/dist/es/index.js +85 -29
  29. package/dist/es/lib.js +51 -23
  30. package/dist/es/use-authorized-items/index.js +12 -13
  31. package/dist/es/use-breakpoints/index.js +43 -58
  32. package/dist/es/use-check-permission/index.js +10 -12
  33. package/dist/es/use-data-dict-query/index.js +22 -26
  34. package/dist/es/use-data-options/index.js +72 -105
  35. package/dist/es/use-deep-callback/index.js +7 -8
  36. package/dist/es/use-deep-compare/index.js +19 -30
  37. package/dist/es/use-deep-effect/index.js +7 -8
  38. package/dist/es/use-deep-isomorphic-effect/index.js +8 -9
  39. package/dist/es/use-deep-layout-effect/index.js +7 -8
  40. package/dist/es/use-deep-memo/index.js +7 -8
  41. package/dist/es/use-document-event/index.js +13 -15
  42. package/dist/es/use-emitter-event/index.js +12 -13
  43. package/dist/es/use-has-fetching/index.js +9 -11
  44. package/dist/es/use-has-mutating/index.js +9 -11
  45. package/dist/es/use-is-authorized/index.js +10 -12
  46. package/dist/es/use-latest/index.js +7 -9
  47. package/dist/es/use-raf-state/index.js +11 -16
  48. package/dist/es/use-shallow-callback/index.js +7 -8
  49. package/dist/es/use-shallow-compare/index.js +19 -30
  50. package/dist/es/use-shallow-effect/index.js +7 -8
  51. package/dist/es/use-shallow-isomorphic-effect/index.js +8 -9
  52. package/dist/es/use-shallow-layout-effect/index.js +7 -8
  53. package/dist/es/use-shallow-memo/index.js +7 -8
  54. package/dist/es/use-singleton/index.js +7 -11
  55. package/package.json +3 -3
@@ -1,14 +1,12 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useAppContext, checkPermission } from '@vef-framework/core';
3
- import { useMemo } from 'react';
4
-
5
- function useIsAuthorized(permTokens, checkMode) {
6
- const { hasPermission = () => true } = useAppContext();
7
- const isAuthorized = useMemo(
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
- export { useIsAuthorized };
10
+ export {
11
+ h as useIsAuthorized
12
+ };
@@ -1,10 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useRef } from 'react';
3
-
4
- function useLatest(value) {
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
- export { useLatest };
6
+ export {
7
+ o as useLatest
8
+ };
@@ -1,19 +1,14 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useRef, useState, useCallback, useEffect } from 'react';
3
-
4
- function useRafState(initialState) {
5
- const frameId = useRef(0);
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
- useEffect(() => () => {
14
- cancelAnimationFrame(frameId.current);
15
- }, []);
16
- return [state, setRafState];
8
+ return m(() => () => {
9
+ cancelAnimationFrame(e.current);
10
+ }, []), [a, r];
17
11
  }
18
-
19
- export { useRafState };
12
+ export {
13
+ i as useRafState
14
+ };
@@ -1,9 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useCallback } from 'react';
3
- import { useShallowCompare } from '../use-shallow-compare/index.js';
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
- export { useShallowCallback };
6
+ export {
7
+ t as useShallowCallback
8
+ };
@@ -1,32 +1,21 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { isShallowEqual } from '@vef-framework/shared';
3
- import { useRef } from 'react';
4
-
5
- function useShallowCompare(dependencies) {
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 shallowCompare(previous, current) {
15
- if (!previous || !current) {
16
- return false;
17
- }
18
- if (Object.is(previous, current)) {
19
- return true;
20
- }
21
- if (previous.length !== current.length) {
22
- return false;
23
- }
24
- for (const [index, element] of previous.entries()) {
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
- export { useShallowCompare };
19
+ export {
20
+ a as useShallowCompare
21
+ };
@@ -1,9 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useEffect } from 'react';
3
- import { useShallowCompare } from '../use-shallow-compare/index.js';
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
- export { useShallowEffect };
6
+ export {
7
+ u as useShallowEffect
8
+ };
@@ -1,10 +1,9 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import '../lib.js';
3
- import { useShallowCompare } from '../use-shallow-compare/index.js';
4
- import { useIsomorphicEffect } from '@mantine/hooks';
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
- export { useShallowIsomorphicEffect };
7
+ export {
8
+ i as useShallowIsomorphicEffect
9
+ };
@@ -1,9 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useLayoutEffect } from 'react';
3
- import { useShallowCompare } from '../use-shallow-compare/index.js';
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
- export { useShallowLayoutEffect };
6
+ export {
7
+ a as useShallowLayoutEffect
8
+ };
@@ -1,9 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useMemo } from 'react';
3
- import { useShallowCompare } from '../use-shallow-compare/index.js';
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
- export { useShallowMemo };
6
+ export {
7
+ l as useShallowMemo
8
+ };
@@ -1,12 +1,8 @@
1
- /*! @vef-framework/hooks v2.0.2 made with ❤️ by Venus | 2025-11-25T15:03:15.845Z */
2
- import { useRef } from 'react';
3
-
4
- function useSingleton(initializer) {
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
- export { useSingleton };
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",
4
+ "version": "2.0.6",
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/shared": "2.0.4",
54
- "@vef-framework/core": "2.0.4"
53
+ "@vef-framework/core": "2.0.6",
54
+ "@vef-framework/shared": "2.0.6"
55
55
  },
56
56
  "devDependencies": {
57
57
  "react": "^19.2.0"