@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.
- 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,70 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function createMediaQuery(value) {
|
|
6
|
-
return `(min-width: ${isNumber(value) ? `${value}px` : value})`;
|
|
1
|
+
import { isNumber as c } from "@vef-framework/shared";
|
|
2
|
+
import { useMemo as d, useState as h, useEffect as p } from "react";
|
|
3
|
+
function g(n) {
|
|
4
|
+
return `(min-width: ${c(n) ? `${n}px` : n})`;
|
|
7
5
|
}
|
|
8
|
-
function
|
|
9
|
-
const { initialBreakpoint, getInitialValueInEffect =
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
function q(n, u = {}) {
|
|
7
|
+
const { initialBreakpoint: a, getInitialValueInEffect: s = !1 } = u, i = d(
|
|
8
|
+
() => Object.entries(n).map(([r, t]) => ({
|
|
9
|
+
name: r,
|
|
10
|
+
value: t,
|
|
11
|
+
query: g(t),
|
|
12
|
+
order: c(t) ? t : Number.parseInt(t)
|
|
13
|
+
})).toSorted((r, t) => r.order - t.order),
|
|
14
|
+
[n]
|
|
15
|
+
), [l, f] = h(() => {
|
|
16
|
+
if (globalThis.window === void 0 || s) {
|
|
17
|
+
const e = i.find((o) => o.name === a);
|
|
12
18
|
return {
|
|
13
|
-
|
|
14
|
-
value,
|
|
15
|
-
|
|
16
|
-
order: isNumber(value) ? value : Number.parseInt(value)
|
|
17
|
-
};
|
|
18
|
-
}).toSorted((a, b) => a.order - b.order),
|
|
19
|
-
[breakpoints]
|
|
20
|
-
);
|
|
21
|
-
const [state, setState] = useState(() => {
|
|
22
|
-
if (globalThis.window === void 0 || getInitialValueInEffect) {
|
|
23
|
-
const initialEntry = sortedBreakpoints.find((bp) => bp.name === initialBreakpoint);
|
|
24
|
-
return {
|
|
25
|
-
current: initialBreakpoint,
|
|
26
|
-
value: initialEntry?.value,
|
|
27
|
-
matches: initialBreakpoint ? [initialBreakpoint] : []
|
|
19
|
+
current: a,
|
|
20
|
+
value: e?.value,
|
|
21
|
+
matches: a ? [a] : []
|
|
28
22
|
};
|
|
29
23
|
}
|
|
30
|
-
const
|
|
31
|
-
const currentBreakpoint = matchingBreakpoints.at(-1);
|
|
24
|
+
const r = i.filter((e) => globalThis.matchMedia(e.query).matches), t = r.at(-1);
|
|
32
25
|
return {
|
|
33
|
-
current:
|
|
34
|
-
value:
|
|
35
|
-
matches:
|
|
26
|
+
current: t?.name,
|
|
27
|
+
value: t?.value,
|
|
28
|
+
matches: r.map((e) => e.name)
|
|
36
29
|
};
|
|
37
30
|
});
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
setState({
|
|
50
|
-
current: currentBreakpoint?.name,
|
|
51
|
-
value: currentBreakpoint?.value,
|
|
52
|
-
matches: matchingBreakpoints.map((mbp) => mbp.name)
|
|
31
|
+
return p(() => {
|
|
32
|
+
const r = i.map((e) => ({
|
|
33
|
+
name: e.name,
|
|
34
|
+
value: e.value,
|
|
35
|
+
mql: globalThis.matchMedia(e.query)
|
|
36
|
+
})), t = () => {
|
|
37
|
+
const e = r.filter((m) => m.mql.matches), o = e.at(-1);
|
|
38
|
+
f({
|
|
39
|
+
current: o?.name,
|
|
40
|
+
value: o?.value,
|
|
41
|
+
matches: e.map((m) => m.name)
|
|
53
42
|
});
|
|
54
43
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
for (const item of mediaQueryLists) {
|
|
59
|
-
item.mql.addEventListener("change", updateBreakpoint);
|
|
60
|
-
}
|
|
44
|
+
s && t();
|
|
45
|
+
for (const e of r)
|
|
46
|
+
e.mql.addEventListener("change", t);
|
|
61
47
|
return () => {
|
|
62
|
-
for (const
|
|
63
|
-
|
|
64
|
-
}
|
|
48
|
+
for (const e of r)
|
|
49
|
+
e.mql.removeEventListener("change", t);
|
|
65
50
|
};
|
|
66
|
-
}, [
|
|
67
|
-
return state;
|
|
51
|
+
}, [s, i]), l;
|
|
68
52
|
}
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
export {
|
|
54
|
+
q as useBreakpoints
|
|
55
|
+
};
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
(permTokens, checkMode) => checkPermission(hasPermission, permTokens, checkMode),
|
|
9
|
-
[hasPermission]
|
|
1
|
+
import { useAppContext as i, checkPermission as r } from "@vef-framework/core";
|
|
2
|
+
import { useCallback as c } from "react";
|
|
3
|
+
function u() {
|
|
4
|
+
const { hasPermission: e = () => !0 } = i();
|
|
5
|
+
return c(
|
|
6
|
+
(s, o) => r(e, s, o),
|
|
7
|
+
[e]
|
|
10
8
|
);
|
|
11
|
-
return checkPermission$1;
|
|
12
9
|
}
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export {
|
|
11
|
+
u as useCheckPermission
|
|
12
|
+
};
|
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
onFetch,
|
|
9
|
-
...options
|
|
1
|
+
import { useAppContext as s, useQuery as c, skipQueryToken as p } from "@vef-framework/core";
|
|
2
|
+
import { isFunction as f, isEmpty as m } from "@vef-framework/shared";
|
|
3
|
+
import { useEffectEvent as y, useEffect as a } from "react";
|
|
4
|
+
function Q({
|
|
5
|
+
dataDictKey: r,
|
|
6
|
+
onFetch: o,
|
|
7
|
+
...n
|
|
10
8
|
}) {
|
|
11
|
-
const { dataDictQueryFn } =
|
|
12
|
-
if (!
|
|
9
|
+
const { dataDictQueryFn: e } = s();
|
|
10
|
+
if (!f(e))
|
|
13
11
|
throw new Error("Data dictionary query function is not provided in the app context.");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const t = c({
|
|
13
|
+
...n,
|
|
14
|
+
queryFn: m(r) ? p : e,
|
|
15
|
+
queryKey: [e.key, r],
|
|
16
|
+
staleTime: n?.staleTime ?? 1 / 0
|
|
17
|
+
}), i = y((u) => {
|
|
18
|
+
o?.(u);
|
|
20
19
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
result.promise.then(onFetchFn);
|
|
26
|
-
}, [result.promise]);
|
|
27
|
-
return result;
|
|
20
|
+
return a(() => {
|
|
21
|
+
t.promise.then(i);
|
|
22
|
+
}, [t.promise]), t;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
export {
|
|
25
|
+
Q as useDataDictQuery
|
|
26
|
+
};
|
|
@@ -1,115 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function extractField(item, extractor, defaultKey) {
|
|
8
|
-
if (!extractor) {
|
|
9
|
-
return item[defaultKey];
|
|
10
|
-
}
|
|
11
|
-
if (isFunction(extractor)) {
|
|
12
|
-
return extractor(item);
|
|
13
|
-
}
|
|
14
|
-
return get(item, extractor);
|
|
1
|
+
import { useQuery as F, skipQueryToken as b } from "@vef-framework/core";
|
|
2
|
+
import { isFunction as R, get as k, isNullish as h, withPinyin as q, isEmpty as A, isString as v } from "@vef-framework/shared";
|
|
3
|
+
import { useMemo as E } from "react";
|
|
4
|
+
import { useDataDictQuery as I } from "../use-data-dict-query/index.js";
|
|
5
|
+
function c(r, n, t) {
|
|
6
|
+
return n ? R(n) ? n(r) : k(r, n) : r[t];
|
|
15
7
|
}
|
|
16
|
-
function
|
|
8
|
+
function g(r, n, t) {
|
|
17
9
|
const {
|
|
18
|
-
labelKey,
|
|
19
|
-
valueKey,
|
|
20
|
-
disabledKey,
|
|
21
|
-
descriptionKey,
|
|
22
|
-
childrenKey
|
|
23
|
-
} =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
label,
|
|
32
|
-
value,
|
|
33
|
-
...!isNullish(disabled) && { disabled },
|
|
34
|
-
...!isNullish(description) && { description }
|
|
35
|
-
};
|
|
36
|
-
const optionWithPinyin = withPinyin$1 ? withPinyin(
|
|
37
|
-
option,
|
|
10
|
+
labelKey: s,
|
|
11
|
+
valueKey: u,
|
|
12
|
+
disabledKey: e,
|
|
13
|
+
descriptionKey: i,
|
|
14
|
+
childrenKey: l
|
|
15
|
+
} = n, f = c(r, s, "label"), Q = c(r, u, "value"), a = c(r, e, "disabled"), p = c(r, i, "description"), o = c(r, l, "children"), m = {
|
|
16
|
+
...r,
|
|
17
|
+
label: f,
|
|
18
|
+
value: Q,
|
|
19
|
+
...!h(a) && { disabled: a },
|
|
20
|
+
...!h(p) && { description: p }
|
|
21
|
+
}, d = t ? q(
|
|
22
|
+
m,
|
|
38
23
|
"label",
|
|
39
24
|
"description"
|
|
40
|
-
) :
|
|
41
|
-
|
|
42
|
-
optionWithPinyin.children = children.map((child) => transformDataItem(child, options, withPinyin$1));
|
|
43
|
-
}
|
|
44
|
-
return optionWithPinyin;
|
|
25
|
+
) : m;
|
|
26
|
+
return Array.isArray(o) && o.length > 0 && (d.children = o.map((y) => g(y, n, t))), d;
|
|
45
27
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
return [];
|
|
49
|
-
}
|
|
50
|
-
if (withPinyin) {
|
|
51
|
-
return data.map((item) => transformDataItem(item, options, true));
|
|
52
|
-
}
|
|
53
|
-
return data.map((item) => transformDataItem(item, options, false));
|
|
28
|
+
function D(r, n, t) {
|
|
29
|
+
return !r || A(r) ? [] : t ? r.map((s) => g(s, n, !0)) : r.map((s) => g(s, n, !1));
|
|
54
30
|
}
|
|
55
|
-
function
|
|
56
|
-
queryOptions,
|
|
57
|
-
dataDictKey,
|
|
58
|
-
labelKey,
|
|
59
|
-
valueKey,
|
|
60
|
-
disabledKey,
|
|
61
|
-
descriptionKey,
|
|
62
|
-
childrenKey,
|
|
63
|
-
withPinyin =
|
|
31
|
+
function W({
|
|
32
|
+
queryOptions: r,
|
|
33
|
+
dataDictKey: n,
|
|
34
|
+
labelKey: t,
|
|
35
|
+
valueKey: s,
|
|
36
|
+
disabledKey: u,
|
|
37
|
+
descriptionKey: e,
|
|
38
|
+
childrenKey: i,
|
|
39
|
+
withPinyin: l = !1
|
|
64
40
|
}) {
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
labelKey,
|
|
94
|
-
valueKey,
|
|
95
|
-
disabledKey,
|
|
96
|
-
descriptionKey,
|
|
97
|
-
childrenKey
|
|
98
|
-
},
|
|
99
|
-
false
|
|
100
|
-
);
|
|
101
|
-
},
|
|
41
|
+
const f = v(n) && n.length > 0, Q = F({
|
|
42
|
+
...r,
|
|
43
|
+
queryFn: f ? b : r?.queryFn
|
|
44
|
+
}), a = I({
|
|
45
|
+
dataDictKey: n
|
|
46
|
+
}), p = f ? a : Q, { data: o, ...m } = p;
|
|
47
|
+
return { options: E(
|
|
48
|
+
() => l ? D(
|
|
49
|
+
o,
|
|
50
|
+
{
|
|
51
|
+
labelKey: t,
|
|
52
|
+
valueKey: s,
|
|
53
|
+
disabledKey: u,
|
|
54
|
+
descriptionKey: e,
|
|
55
|
+
childrenKey: i
|
|
56
|
+
},
|
|
57
|
+
!0
|
|
58
|
+
) : D(
|
|
59
|
+
o,
|
|
60
|
+
{
|
|
61
|
+
labelKey: t,
|
|
62
|
+
valueKey: s,
|
|
63
|
+
disabledKey: u,
|
|
64
|
+
descriptionKey: e,
|
|
65
|
+
childrenKey: i
|
|
66
|
+
},
|
|
67
|
+
!1
|
|
68
|
+
),
|
|
102
69
|
[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
70
|
+
o,
|
|
71
|
+
t,
|
|
72
|
+
s,
|
|
73
|
+
u,
|
|
74
|
+
e,
|
|
75
|
+
i,
|
|
76
|
+
l
|
|
110
77
|
]
|
|
111
|
-
);
|
|
112
|
-
return { options, ...result };
|
|
78
|
+
), ...m };
|
|
113
79
|
}
|
|
114
|
-
|
|
115
|
-
|
|
80
|
+
export {
|
|
81
|
+
W as useDataOptionsQuery
|
|
82
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useDeepCallback(callback, dependencies) {
|
|
6
|
-
return useCallback(callback, useDeepCompare(dependencies));
|
|
1
|
+
import { useCallback as o } from "react";
|
|
2
|
+
import { useDeepCompare as p } from "../use-deep-compare/index.js";
|
|
3
|
+
function t(e, r) {
|
|
4
|
+
return o(e, p(r));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
t as useDeepCallback
|
|
8
|
+
};
|
|
@@ -1,32 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const ref = useRef(void 0);
|
|
7
|
-
const signalRef = useRef(0);
|
|
8
|
-
if (!deepCompare(ref.current, dependencies)) {
|
|
9
|
-
ref.current = dependencies;
|
|
10
|
-
signalRef.current += 1;
|
|
11
|
-
}
|
|
12
|
-
return [signalRef.current];
|
|
1
|
+
import { isDeepEqual as o } from "@vef-framework/shared";
|
|
2
|
+
import { useRef as n } from "react";
|
|
3
|
+
function s(e) {
|
|
4
|
+
const r = n(void 0), t = n(0);
|
|
5
|
+
return i(r.current, e) || (r.current = e, t.current += 1), [t.current];
|
|
13
6
|
}
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (!isDeepEqual(element, current[index])) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return true;
|
|
7
|
+
function i(e, r) {
|
|
8
|
+
if (!e || !r)
|
|
9
|
+
return !1;
|
|
10
|
+
if (Object.is(e, r))
|
|
11
|
+
return !0;
|
|
12
|
+
if (e.length !== r.length)
|
|
13
|
+
return !1;
|
|
14
|
+
for (const [t, f] of e.entries())
|
|
15
|
+
if (!o(f, r[t]))
|
|
16
|
+
return !1;
|
|
17
|
+
return !0;
|
|
30
18
|
}
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
export {
|
|
20
|
+
s as useDeepCompare
|
|
21
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useDeepEffect(effect, dependencies) {
|
|
6
|
-
return useEffect(effect, useDeepCompare(dependencies));
|
|
1
|
+
import { useEffect as f } from "react";
|
|
2
|
+
import { useDeepCompare as o } from "../use-deep-compare/index.js";
|
|
3
|
+
function m(e, r) {
|
|
4
|
+
return f(e, o(r));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
m as useDeepEffect
|
|
8
|
+
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function useDeepIsomorphicEffect(effect, dependencies) {
|
|
7
|
-
return useIsomorphicEffect(effect, useDeepCompare(dependencies));
|
|
1
|
+
import "../lib.js";
|
|
2
|
+
import { useDeepCompare as r } from "../use-deep-compare/index.js";
|
|
3
|
+
import { useIsomorphicEffect as p } from "@mantine/hooks";
|
|
4
|
+
function i(e, o) {
|
|
5
|
+
return p(e, r(o));
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
export {
|
|
8
|
+
i as useDeepIsomorphicEffect
|
|
9
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useDeepLayoutEffect(effect, dependencies) {
|
|
6
|
-
return useLayoutEffect(effect, useDeepCompare(dependencies));
|
|
1
|
+
import { useLayoutEffect as t } from "react";
|
|
2
|
+
import { useDeepCompare as r } from "../use-deep-compare/index.js";
|
|
3
|
+
function p(e, o) {
|
|
4
|
+
return t(e, r(o));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
p as useDeepLayoutEffect
|
|
8
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
function useDeepMemo(factory, dependencies) {
|
|
6
|
-
return useMemo(factory, useDeepCompare(dependencies));
|
|
1
|
+
import { useMemo as r } from "react";
|
|
2
|
+
import { useDeepCompare as m } from "../use-deep-compare/index.js";
|
|
3
|
+
function u(e, o) {
|
|
4
|
+
return r(e, m(o));
|
|
7
5
|
}
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
export {
|
|
7
|
+
u as useDeepMemo
|
|
8
|
+
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
function handleEvent(event) {
|
|
9
|
-
listenerFn.current.call(this, event);
|
|
1
|
+
import { useLatest as o } from "../use-latest/index.js";
|
|
2
|
+
import { useShallowEffect as m } from "../use-shallow-effect/index.js";
|
|
3
|
+
function i(e, u, t) {
|
|
4
|
+
const n = o(u);
|
|
5
|
+
m(() => {
|
|
6
|
+
function r(c) {
|
|
7
|
+
n.current.call(this, c);
|
|
10
8
|
}
|
|
11
|
-
document.addEventListener(
|
|
12
|
-
|
|
13
|
-
document.removeEventListener(type, handleEvent, options);
|
|
9
|
+
return document.addEventListener(e, r, t), () => {
|
|
10
|
+
document.removeEventListener(e, r, t);
|
|
14
11
|
};
|
|
15
|
-
}, [
|
|
12
|
+
}, [e, t, n]);
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
export {
|
|
15
|
+
i as useDocumentEvent
|
|
16
|
+
};
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const listenerFn = useEffectEvent(eventListener);
|
|
7
|
-
useEffect(
|
|
1
|
+
import "@vef-framework/shared";
|
|
2
|
+
import { useEffectEvent as s, useEffect as c } from "react";
|
|
3
|
+
function i(t, n, e) {
|
|
4
|
+
const o = s(e);
|
|
5
|
+
c(
|
|
8
6
|
() => {
|
|
9
|
-
const
|
|
10
|
-
|
|
7
|
+
const r = (...f) => {
|
|
8
|
+
o(...f);
|
|
11
9
|
};
|
|
12
|
-
return
|
|
10
|
+
return t.on(n, r);
|
|
13
11
|
},
|
|
14
|
-
[
|
|
12
|
+
[t, n]
|
|
15
13
|
);
|
|
16
14
|
}
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export {
|
|
16
|
+
i as useEmitterEvent
|
|
17
|
+
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
queryKey: params ? [key, params] : [key],
|
|
7
|
-
exact: false,
|
|
1
|
+
import { useIsFetching as c } from "@vef-framework/core";
|
|
2
|
+
function u(t, e) {
|
|
3
|
+
return c({
|
|
4
|
+
queryKey: e ? [t, e] : [t],
|
|
5
|
+
exact: !1,
|
|
8
6
|
type: "active"
|
|
9
|
-
});
|
|
10
|
-
return count > 0;
|
|
7
|
+
}) > 0;
|
|
11
8
|
}
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export {
|
|
10
|
+
u as useHasFetching
|
|
11
|
+
};
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exact: false
|
|
8
|
-
});
|
|
9
|
-
return count > 0;
|
|
1
|
+
import { useIsMutating as n } from "@vef-framework/core";
|
|
2
|
+
function e(t) {
|
|
3
|
+
return n({
|
|
4
|
+
mutationKey: [t],
|
|
5
|
+
exact: !1
|
|
6
|
+
}) > 0;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export {
|
|
9
|
+
e as useHasMutating
|
|
10
|
+
};
|