@vef-framework-react/hooks 2.1.6 → 2.1.7
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 -1
- package/dist/cjs/use-data-options/index.cjs +1 -1
- package/dist/cjs/use-dictionary-query/index.cjs +1 -0
- package/dist/es/index.js +25 -25
- package/dist/es/lib.js +1 -1
- package/dist/es/use-authorized-items/index.js +1 -1
- package/dist/es/use-breakpoints/index.js +1 -1
- package/dist/es/use-check-permission/index.js +1 -1
- package/dist/es/use-data-options/index.js +31 -35
- package/dist/es/use-deep-callback/index.js +1 -1
- package/dist/es/use-deep-compare/index.js +1 -1
- package/dist/es/use-deep-effect/index.js +1 -1
- package/dist/es/use-deep-isomorphic-effect/index.js +1 -1
- package/dist/es/use-deep-layout-effect/index.js +1 -1
- package/dist/es/use-deep-memo/index.js +1 -1
- package/dist/es/use-dictionary-query/index.js +24 -0
- package/dist/es/use-document-event/index.js +1 -1
- package/dist/es/use-emitter-event/index.js +1 -1
- package/dist/es/use-has-fetching/index.js +1 -1
- package/dist/es/use-has-mutating/index.js +1 -1
- package/dist/es/use-is-authorized/index.js +1 -1
- package/dist/es/use-latest/index.js +1 -1
- package/dist/es/use-raf-state/index.js +1 -1
- package/dist/es/use-shallow-callback/index.js +1 -1
- package/dist/es/use-shallow-compare/index.js +1 -1
- package/dist/es/use-shallow-effect/index.js +1 -1
- package/dist/es/use-shallow-isomorphic-effect/index.js +1 -1
- package/dist/es/use-shallow-layout-effect/index.js +1 -1
- package/dist/es/use-shallow-memo/index.js +1 -1
- package/dist/es/use-singleton/index.js +1 -1
- package/dist/es/use-viewport-size/index.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/use-data-options/index.d.ts +2 -23
- package/dist/types/use-dictionary-query/index.d.ts +36 -0
- package/package.json +6 -6
- package/dist/cjs/use-data-dict-query/index.cjs +0 -1
- package/dist/es/use-data-dict-query/index.js +0 -22
- package/dist/types/use-data-dict-query/index.d.ts +0 -15
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lib.cjs`),t=require(`./use-authorized-items/index.cjs`),n=require(`./use-breakpoints/index.cjs`),r=require(`./use-check-permission/index.cjs`),i=require(`./use-data-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./lib.cjs`),t=require(`./use-authorized-items/index.cjs`),n=require(`./use-breakpoints/index.cjs`),r=require(`./use-check-permission/index.cjs`),i=require(`./use-data-options/index.cjs`),a=require(`./use-deep-compare/index.cjs`),o=require(`./use-deep-callback/index.cjs`),s=require(`./use-deep-effect/index.cjs`),c=require(`./use-deep-isomorphic-effect/index.cjs`),l=require(`./use-deep-layout-effect/index.cjs`),u=require(`./use-deep-memo/index.cjs`),d=require(`./use-dictionary-query/index.cjs`),f=require(`./use-latest/index.cjs`),p=require(`./use-document-event/index.cjs`),m=require(`./use-emitter-event/index.cjs`),h=require(`./use-has-fetching/index.cjs`),g=require(`./use-has-mutating/index.cjs`),_=require(`./use-is-authorized/index.cjs`),v=require(`./use-raf-state/index.cjs`),y=require(`./use-shallow-compare/index.cjs`),b=require(`./use-shallow-callback/index.cjs`),x=require(`./use-shallow-effect/index.cjs`),S=require(`./use-shallow-isomorphic-effect/index.cjs`),C=require(`./use-shallow-layout-effect/index.cjs`),w=require(`./use-shallow-memo/index.cjs`),T=require(`./use-singleton/index.cjs`),E=require(`./use-viewport-size/index.cjs`);let D=require(`react-hotkeys-hook`),O=require(`@mantine/hooks`),k=require(`@ai-sdk/react`);Object.defineProperty(exports,`HotkeysProvider`,{enumerable:!0,get:function(){return D.HotkeysProvider}}),Object.defineProperty(exports,`assignRef`,{enumerable:!0,get:function(){return O.assignRef}}),Object.defineProperty(exports,`getHotkeyHandler`,{enumerable:!0,get:function(){return O.getHotkeyHandler}}),Object.defineProperty(exports,`mergeRefs`,{enumerable:!0,get:function(){return O.mergeRefs}}),exports.resolveDictKey=d.resolveDictKey,exports.useAuthorizedItems=t.useAuthorizedItems,exports.useBreakpoints=n.useBreakpoints,Object.defineProperty(exports,`useChat`,{enumerable:!0,get:function(){return k.useChat}}),exports.useCheckPermission=r.useCheckPermission,exports.useColorScheme=e.useColorScheme,Object.defineProperty(exports,`useCompletion`,{enumerable:!0,get:function(){return k.useCompletion}}),exports.useDataOptionsQuery=i.useDataOptionsQuery,Object.defineProperty(exports,`useDebouncedCallback`,{enumerable:!0,get:function(){return O.useDebouncedCallback}}),Object.defineProperty(exports,`useDebouncedState`,{enumerable:!0,get:function(){return O.useDebouncedState}}),Object.defineProperty(exports,`useDebouncedValue`,{enumerable:!0,get:function(){return O.useDebouncedValue}}),exports.useDeepCallback=o.useDeepCallback,exports.useDeepCompare=a.useDeepCompare,exports.useDeepEffect=s.useDeepEffect,exports.useDeepIsomorphicEffect=c.useDeepIsomorphicEffect,exports.useDeepLayoutEffect=l.useDeepLayoutEffect,exports.useDeepMemo=u.useDeepMemo,exports.useDictionaryQuery=d.useDictionaryQuery,Object.defineProperty(exports,`useDidUpdate`,{enumerable:!0,get:function(){return O.useDidUpdate}}),exports.useDocumentEvent=p.useDocumentEvent,Object.defineProperty(exports,`useDocumentTitle`,{enumerable:!0,get:function(){return O.useDocumentTitle}}),Object.defineProperty(exports,`useElementSize`,{enumerable:!0,get:function(){return O.useElementSize}}),exports.useEmitterEvent=m.useEmitterEvent,Object.defineProperty(exports,`useEventListener`,{enumerable:!0,get:function(){return O.useEventListener}}),Object.defineProperty(exports,`useFocusTrap`,{enumerable:!0,get:function(){return O.useFocusTrap}}),Object.defineProperty(exports,`useFullscreenDocument`,{enumerable:!0,get:function(){return O.useFullscreenDocument}}),exports.useHasFetching=h.useHasFetching,exports.useHasMutating=g.useHasMutating,Object.defineProperty(exports,`useHotkeys`,{enumerable:!0,get:function(){return D.useHotkeys}}),Object.defineProperty(exports,`useHotkeysContext`,{enumerable:!0,get:function(){return D.useHotkeysContext}}),Object.defineProperty(exports,`useIntersection`,{enumerable:!0,get:function(){return O.useIntersection}}),Object.defineProperty(exports,`useInterval`,{enumerable:!0,get:function(){return O.useInterval}}),exports.useIsAuthorized=_.useIsAuthorized,Object.defineProperty(exports,`useIsFirstRender`,{enumerable:!0,get:function(){return O.useIsFirstRender}}),Object.defineProperty(exports,`useIsomorphicEffect`,{enumerable:!0,get:function(){return O.useIsomorphicEffect}}),exports.useLatest=f.useLatest,exports.useMediaQuery=e.useMediaQuery,Object.defineProperty(exports,`useMergedRef`,{enumerable:!0,get:function(){return O.useMergedRef}}),Object.defineProperty(exports,`useMounted`,{enumerable:!0,get:function(){return O.useMounted}}),Object.defineProperty(exports,`useMutationObserverTarget`,{enumerable:!0,get:function(){return O.useMutationObserverTarget}}),Object.defineProperty(exports,`useObject`,{enumerable:!0,get:function(){return k.experimental_useObject}}),Object.defineProperty(exports,`usePrevious`,{enumerable:!0,get:function(){return O.usePrevious}}),exports.useRafState=v.useRafState,Object.defineProperty(exports,`useRecordHotkeys`,{enumerable:!0,get:function(){return D.useRecordHotkeys}}),exports.useReducedMotion=e.useReducedMotion,Object.defineProperty(exports,`useResizeObserver`,{enumerable:!0,get:function(){return O.useResizeObserver}}),exports.useShallowCallback=b.useShallowCallback,exports.useShallowCompare=y.useShallowCompare,exports.useShallowEffect=x.useShallowEffect,exports.useShallowIsomorphicEffect=S.useShallowIsomorphicEffect,exports.useShallowLayoutEffect=C.useShallowLayoutEffect,exports.useShallowMemo=w.useShallowMemo,exports.useSingleton=T.useSingleton,Object.defineProperty(exports,`useTimeout`,{enumerable:!0,get:function(){return O.useTimeout}}),exports.useViewportSize=E.useViewportSize,Object.defineProperty(exports,`useWindowEvent`,{enumerable:!0,get:function(){return O.useWindowEvent}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
let e=require(`@vef-framework-react/core`),t=require(`@vef-framework-react/shared`),n=require(`react`);function r(e,n,r){return n?(0,t.isFunction)(n)?n(e):(0,t.get)(e,n):e[r]}function i(e,n,a){let{labelKey:o,valueKey:s,disabledKey:c,descriptionKey:l,childrenKey:u}=n,d=r(e,o,`label`),f=r(e,s,`value`),p=r(e,c,`disabled`),m=r(e,l,`description`),h=r(e,u,`children`),g={...e,label:d,value:f,...!(0,t.isNullish)(p)&&{disabled:p},...!(0,t.isNullish)(m)&&{description:m}},_=a?(0,t.withPinyin)(g,`label`,`description`):g;return Array.isArray(h)&&h.length>0&&(_.children=h.map(e=>i(e,n,a))),_}function a(e,n,r){return!e||(0,t.isEmpty)(e)?[]:e.map(e=>i(e,n,r))}function o({queryOptions:t,labelKey:r,valueKey:i,disabledKey:o,descriptionKey:s,childrenKey:c,withPinyin:l=!1}){let{data:u,...d}=(0,e.useQuery)(t),f=(0,n.useMemo)(()=>({labelKey:r,valueKey:i,disabledKey:o,descriptionKey:s,childrenKey:c}),[r,i,o,s,c]);return{options:(0,n.useMemo)(()=>a(u,f,l),[u,f,l]),...d}}exports.useDataOptionsQuery=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let e=require(`@vef-framework-react/core`),t=require(`@vef-framework-react/shared`),n=require(`react`);function r(e){return(0,t.isString)(e)?e:e.key}function i(i){let{dictionaryQueryFn:a}=(0,e.useAppContext)();if(!(0,t.isFunction)(a))throw Error(`Dictionary query function is not provided in the app context.`);let o=(0,n.useMemo)(()=>[...new Set(Object.values(i).map(e=>r(e)))].toSorted(),[i]),s=(0,e.useQuery)({queryFn:o.length===0?e.skipQueryToken:a,queryKey:[a.key,o],staleTime:1/0}),c=(0,n.useMemo)(()=>Object.fromEntries(Object.entries(i).map(([e,t])=>[e,s.data?.[r(t)]??[]])),[i,s.data]),{data:l,isFetching:u,isSuccess:d}=s;return{data:c,isFetching:u,isSuccess:d}}exports.resolveDictKey=r,exports.useDictionaryQuery=i;
|
package/dist/es/index.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { HotkeysProvider as e, assignRef as t, getHotkeyHandler as n, mergeRefs as r, useChat as i, useColorScheme as a, useCompletion as o, useDebouncedCallback as s, useDebouncedState as c, useDebouncedValue as l, useDidUpdate as u, useDocumentTitle as d, useElementSize as f, useEventListener as p, useFocusTrap as m, useFullscreenDocument as h, useHotkeys as g, useHotkeysContext as _, useIntersection as v, useInterval as y, useIsFirstRender as b, useIsomorphicEffect as x, useMediaQuery as S, useMergedRef as C, useMounted as w, useMutationObserverTarget as T, useObject as E, usePrevious as D, useRecordHotkeys as O, useReducedMotion as k, useResizeObserver as A, useTimeout as j, useWindowEvent as M } from "./lib.js";
|
|
3
3
|
import { useAuthorizedItems as N } from "./use-authorized-items/index.js";
|
|
4
4
|
import { useBreakpoints as P } from "./use-breakpoints/index.js";
|
|
5
5
|
import { useCheckPermission as F } from "./use-check-permission/index.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { useLatest as
|
|
15
|
-
import { useDocumentEvent as
|
|
16
|
-
import { useEmitterEvent as
|
|
17
|
-
import { useHasFetching as
|
|
18
|
-
import { useHasMutating as
|
|
19
|
-
import { useIsAuthorized as
|
|
20
|
-
import { useRafState as
|
|
21
|
-
import { useShallowCompare as
|
|
22
|
-
import { useShallowCallback as
|
|
23
|
-
import { useShallowEffect as
|
|
24
|
-
import { useShallowIsomorphicEffect as
|
|
25
|
-
import { useShallowLayoutEffect as
|
|
26
|
-
import { useShallowMemo as
|
|
27
|
-
import { useSingleton as
|
|
28
|
-
import { useViewportSize as
|
|
29
|
-
export { e as HotkeysProvider, t as assignRef, n as getHotkeyHandler, r as mergeRefs, N as useAuthorizedItems, P as useBreakpoints, i as useChat, F as useCheckPermission, a as useColorScheme, o as useCompletion, I as
|
|
6
|
+
import { useDataOptionsQuery as I } from "./use-data-options/index.js";
|
|
7
|
+
import { useDeepCompare as L } from "./use-deep-compare/index.js";
|
|
8
|
+
import { useDeepCallback as R } from "./use-deep-callback/index.js";
|
|
9
|
+
import { useDeepEffect as z } from "./use-deep-effect/index.js";
|
|
10
|
+
import { useDeepIsomorphicEffect as B } from "./use-deep-isomorphic-effect/index.js";
|
|
11
|
+
import { useDeepLayoutEffect as V } from "./use-deep-layout-effect/index.js";
|
|
12
|
+
import { useDeepMemo as H } from "./use-deep-memo/index.js";
|
|
13
|
+
import { resolveDictKey as U, useDictionaryQuery as W } from "./use-dictionary-query/index.js";
|
|
14
|
+
import { useLatest as G } from "./use-latest/index.js";
|
|
15
|
+
import { useDocumentEvent as K } from "./use-document-event/index.js";
|
|
16
|
+
import { useEmitterEvent as q } from "./use-emitter-event/index.js";
|
|
17
|
+
import { useHasFetching as J } from "./use-has-fetching/index.js";
|
|
18
|
+
import { useHasMutating as Y } from "./use-has-mutating/index.js";
|
|
19
|
+
import { useIsAuthorized as X } from "./use-is-authorized/index.js";
|
|
20
|
+
import { useRafState as Z } from "./use-raf-state/index.js";
|
|
21
|
+
import { useShallowCompare as Q } from "./use-shallow-compare/index.js";
|
|
22
|
+
import { useShallowCallback as $ } from "./use-shallow-callback/index.js";
|
|
23
|
+
import { useShallowEffect as ee } from "./use-shallow-effect/index.js";
|
|
24
|
+
import { useShallowIsomorphicEffect as te } from "./use-shallow-isomorphic-effect/index.js";
|
|
25
|
+
import { useShallowLayoutEffect as ne } from "./use-shallow-layout-effect/index.js";
|
|
26
|
+
import { useShallowMemo as re } from "./use-shallow-memo/index.js";
|
|
27
|
+
import { useSingleton as ie } from "./use-singleton/index.js";
|
|
28
|
+
import { useViewportSize as ae } from "./use-viewport-size/index.js";
|
|
29
|
+
export { e as HotkeysProvider, t as assignRef, n as getHotkeyHandler, r as mergeRefs, U as resolveDictKey, N as useAuthorizedItems, P as useBreakpoints, i as useChat, F as useCheckPermission, a as useColorScheme, o as useCompletion, I as useDataOptionsQuery, s as useDebouncedCallback, c as useDebouncedState, l as useDebouncedValue, R as useDeepCallback, L as useDeepCompare, z as useDeepEffect, B as useDeepIsomorphicEffect, V as useDeepLayoutEffect, H as useDeepMemo, W as useDictionaryQuery, u as useDidUpdate, K as useDocumentEvent, d as useDocumentTitle, f as useElementSize, q as useEmitterEvent, p as useEventListener, m as useFocusTrap, h as useFullscreenDocument, J as useHasFetching, Y as useHasMutating, g as useHotkeys, _ as useHotkeysContext, v as useIntersection, y as useInterval, X as useIsAuthorized, b as useIsFirstRender, x as useIsomorphicEffect, G as useLatest, S as useMediaQuery, C as useMergedRef, w as useMounted, T as useMutationObserverTarget, E as useObject, D as usePrevious, Z as useRafState, O as useRecordHotkeys, k as useReducedMotion, A as useResizeObserver, $ as useShallowCallback, Q as useShallowCompare, ee as useShallowEffect, te as useShallowIsomorphicEffect, ne as useShallowLayoutEffect, re as useShallowMemo, ie as useSingleton, j as useTimeout, ae as useViewportSize, M as useWindowEvent };
|
package/dist/es/lib.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { assignRef as e, getHotkeyHandler as t, mergeRefs as n, useColorScheme as r, useDebouncedCallback as i, useDebouncedState as a, useDebouncedValue as o, useDidUpdate as s, useDocumentTitle as c, useElementSize as l, useEventListener as u, useFocusTrap as d, useFullscreenDocument as f, useIntersection as p, useInterval as m, useIsFirstRender as h, useIsomorphicEffect as g, useMediaQuery as _, useMergedRef as v, useMounted as y, useMutationObserverTarget as b, usePrevious as x, useReducedMotion as S, useResizeObserver as C, useTimeout as w, useWindowEvent as T } from "@mantine/hooks";
|
|
3
3
|
import { experimental_useObject as E, useChat as D, useCompletion as O } from "@ai-sdk/react";
|
|
4
4
|
import { HotkeysProvider as k, useHotkeys as A, useHotkeysContext as j, useRecordHotkeys as M } from "react-hotkeys-hook";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { checkPermission as e, useAppContext as t } from "@vef-framework-react/core";
|
|
3
3
|
//#region src/use-authorized-items/index.ts
|
|
4
4
|
function n(n) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { isNumber as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { useEffect as t, useMemo as n, useState as r } from "react";
|
|
4
4
|
//#region src/use-breakpoints/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { checkPermission as e, useAppContext as t } from "@vef-framework-react/core";
|
|
3
3
|
//#region src/use-check-permission/index.ts
|
|
4
4
|
function n() {
|
|
@@ -1,50 +1,46 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { useMemo as l } from "react";
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
|
+
import { useQuery as e } from "@vef-framework-react/core";
|
|
3
|
+
import { get as t, isEmpty as n, isFunction as r, isNullish as i, withPinyin as a } from "@vef-framework-react/shared";
|
|
4
|
+
import { useMemo as o } from "react";
|
|
6
5
|
//#region src/use-data-options/index.ts
|
|
7
|
-
function
|
|
8
|
-
return
|
|
6
|
+
function s(e, n, i) {
|
|
7
|
+
return n ? r(n) ? n(e) : t(e, n) : e[i];
|
|
9
8
|
}
|
|
10
|
-
function
|
|
11
|
-
let { labelKey: r, valueKey:
|
|
9
|
+
function c(e, t, n) {
|
|
10
|
+
let { labelKey: r, valueKey: o, disabledKey: l, descriptionKey: u, childrenKey: d } = t, f = s(e, r, "label"), p = s(e, o, "value"), m = s(e, l, "disabled"), h = s(e, u, "description"), g = s(e, d, "children"), _ = {
|
|
12
11
|
...e,
|
|
13
12
|
label: f,
|
|
14
13
|
value: p,
|
|
15
|
-
...!
|
|
16
|
-
...!
|
|
17
|
-
}, v = n ?
|
|
18
|
-
return Array.isArray(g) && g.length > 0 && (v.children = g.map((e) =>
|
|
14
|
+
...!i(m) && { disabled: m },
|
|
15
|
+
...!i(h) && { description: h }
|
|
16
|
+
}, v = n ? a(_, "label", "description") : _;
|
|
17
|
+
return Array.isArray(g) && g.length > 0 && (v.children = g.map((e) => c(e, t, n))), v;
|
|
19
18
|
}
|
|
20
|
-
function
|
|
21
|
-
return !e ||
|
|
19
|
+
function l(e, t, r) {
|
|
20
|
+
return !e || n(e) ? [] : e.map((e) => c(e, t, r));
|
|
22
21
|
}
|
|
23
|
-
function
|
|
24
|
-
let
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
disabledKey: c,
|
|
31
|
-
descriptionKey: u,
|
|
32
|
-
childrenKey: d
|
|
22
|
+
function u({ queryOptions: t, labelKey: n, valueKey: r, disabledKey: i, descriptionKey: a, childrenKey: s, withPinyin: c = !1 }) {
|
|
23
|
+
let { data: u, ...d } = e(t), f = o(() => ({
|
|
24
|
+
labelKey: n,
|
|
25
|
+
valueKey: r,
|
|
26
|
+
disabledKey: i,
|
|
27
|
+
descriptionKey: a,
|
|
28
|
+
childrenKey: s
|
|
33
29
|
}), [
|
|
30
|
+
n,
|
|
31
|
+
r,
|
|
32
|
+
i,
|
|
34
33
|
a,
|
|
35
|
-
|
|
36
|
-
c,
|
|
37
|
-
u,
|
|
38
|
-
d
|
|
34
|
+
s
|
|
39
35
|
]);
|
|
40
36
|
return {
|
|
41
|
-
options:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
options: o(() => l(u, f, c), [
|
|
38
|
+
u,
|
|
39
|
+
f,
|
|
40
|
+
c
|
|
45
41
|
]),
|
|
46
|
-
...
|
|
42
|
+
...d
|
|
47
43
|
};
|
|
48
44
|
}
|
|
49
45
|
//#endregion
|
|
50
|
-
export {
|
|
46
|
+
export { u as useDataOptionsQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useDeepCompare as e } from "../use-deep-compare/index.js";
|
|
3
3
|
import { useCallback as t } from "react";
|
|
4
4
|
//#region src/use-deep-callback/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { isDeepEqual as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { useRef as t } from "react";
|
|
4
4
|
//#region src/use-deep-compare/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useDeepCompare as e } from "../use-deep-compare/index.js";
|
|
3
3
|
import { useEffect as t } from "react";
|
|
4
4
|
//#region src/use-deep-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useIsomorphicEffect as e } from "../lib.js";
|
|
3
3
|
import { useDeepCompare as t } from "../use-deep-compare/index.js";
|
|
4
4
|
//#region src/use-deep-isomorphic-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useDeepCompare as e } from "../use-deep-compare/index.js";
|
|
3
3
|
import { useLayoutEffect as t } from "react";
|
|
4
4
|
//#region src/use-deep-layout-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useDeepCompare as e } from "../use-deep-compare/index.js";
|
|
3
3
|
import { useMemo as t } from "react";
|
|
4
4
|
//#region src/use-deep-memo/index.ts
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
|
+
import { skipQueryToken as e, useAppContext as t, useQuery as n } from "@vef-framework-react/core";
|
|
3
|
+
import { isFunction as r, isString as i } from "@vef-framework-react/shared";
|
|
4
|
+
import { useMemo as a } from "react";
|
|
5
|
+
//#region src/use-dictionary-query/index.ts
|
|
6
|
+
function o(e) {
|
|
7
|
+
return i(e) ? e : e.key;
|
|
8
|
+
}
|
|
9
|
+
function s(i) {
|
|
10
|
+
let { dictionaryQueryFn: s } = t();
|
|
11
|
+
if (!r(s)) throw Error("Dictionary query function is not provided in the app context.");
|
|
12
|
+
let c = a(() => [...new Set(Object.values(i).map((e) => o(e)))].toSorted(), [i]), l = n({
|
|
13
|
+
queryFn: c.length === 0 ? e : s,
|
|
14
|
+
queryKey: [s.key, c],
|
|
15
|
+
staleTime: Infinity
|
|
16
|
+
}), u = a(() => Object.fromEntries(Object.entries(i).map(([e, t]) => [e, l.data?.[o(t)] ?? []])), [i, l.data]), { data: d, isFetching: f, isSuccess: p } = l;
|
|
17
|
+
return {
|
|
18
|
+
data: u,
|
|
19
|
+
isFetching: f,
|
|
20
|
+
isSuccess: p
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { o as resolveDictKey, s as useDictionaryQuery };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useLatest as e } from "../use-latest/index.js";
|
|
3
3
|
import { useEffect as t } from "react";
|
|
4
4
|
//#region src/use-document-event/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import "@vef-framework-react/shared";
|
|
3
3
|
import { useEffect as e } from "react";
|
|
4
4
|
//#region src/use-emitter-event/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useIsFetching as e } from "@vef-framework-react/core";
|
|
3
3
|
//#region src/use-has-fetching/index.ts
|
|
4
4
|
function t(t, n) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useIsMutating as e } from "@vef-framework-react/core";
|
|
3
3
|
//#region src/use-has-mutating/index.ts
|
|
4
4
|
function t(t) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { checkPermission as e, useAppContext as t } from "@vef-framework-react/core";
|
|
3
3
|
//#region src/use-is-authorized/index.ts
|
|
4
4
|
function n(n, r) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
|
|
3
3
|
//#region src/use-raf-state/index.ts
|
|
4
4
|
function i(i) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useShallowCompare as e } from "../use-shallow-compare/index.js";
|
|
3
3
|
import { useCallback as t } from "react";
|
|
4
4
|
//#region src/use-shallow-callback/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { isShallowEqual as e } from "@vef-framework-react/shared";
|
|
3
3
|
import { useRef as t } from "react";
|
|
4
4
|
//#region src/use-shallow-compare/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useShallowCompare as e } from "../use-shallow-compare/index.js";
|
|
3
3
|
import { useEffect as t } from "react";
|
|
4
4
|
//#region src/use-shallow-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useIsomorphicEffect as e } from "../lib.js";
|
|
3
3
|
import { useShallowCompare as t } from "../use-shallow-compare/index.js";
|
|
4
4
|
//#region src/use-shallow-isomorphic-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useShallowCompare as e } from "../use-shallow-compare/index.js";
|
|
3
3
|
import { useLayoutEffect as t } from "react";
|
|
4
4
|
//#region src/use-shallow-layout-effect/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useShallowCompare as e } from "../use-shallow-compare/index.js";
|
|
3
3
|
import { useMemo as t } from "react";
|
|
4
4
|
//#region src/use-shallow-memo/index.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.
|
|
1
|
+
/*! @vef-framework-react/hooks v2.1.7 made by Venus | 2026-04-24T14:03:18.240Z */
|
|
2
2
|
import { useWindowEvent as e } from "../lib.js";
|
|
3
3
|
import { useRafState as t } from "../use-raf-state/index.js";
|
|
4
4
|
import { isUndefined as n } from "@vef-framework-react/shared";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ export * from './lib';
|
|
|
2
2
|
export { useAuthorizedItems, type PermissionAware } from './use-authorized-items';
|
|
3
3
|
export { useBreakpoints, type Breakpoints, type UseBreakpointsOptions, type UseBreakpointsResult } from './use-breakpoints';
|
|
4
4
|
export { useCheckPermission } from './use-check-permission';
|
|
5
|
-
export { useDataDictQuery, type UseDataDictQueryOptions } from './use-data-dict-query';
|
|
6
5
|
export { useDataOptionsQuery, type FieldExtractor, type UseDataOptionsQueryOptions, type UseDataOptionsQueryResult } from './use-data-options';
|
|
7
6
|
export { useDeepCallback } from './use-deep-callback';
|
|
8
7
|
export { useDeepCompare } from './use-deep-compare';
|
|
@@ -10,6 +9,7 @@ export { useDeepEffect } from './use-deep-effect';
|
|
|
10
9
|
export { useDeepIsomorphicEffect } from './use-deep-isomorphic-effect';
|
|
11
10
|
export { useDeepLayoutEffect } from './use-deep-layout-effect';
|
|
12
11
|
export { useDeepMemo } from './use-deep-memo';
|
|
12
|
+
export { resolveDictKey, useDictionaryQuery, type DictionaryAliasMap, type DictionaryKeyConfig, type DictionaryKeyValue, type UseDictionaryQueryResult } from './use-dictionary-query';
|
|
13
13
|
export { useDocumentEvent } from './use-document-event';
|
|
14
14
|
export { useEmitterEvent } from './use-emitter-event';
|
|
15
15
|
export { useHasFetching } from './use-has-fetching';
|
|
@@ -40,35 +40,14 @@ export interface DataOptionsFieldMapping<TData = unknown> {
|
|
|
40
40
|
childrenKey?: FieldExtractor<TData, MaybeUndefined<TData[]>>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Options for useDataOptionsQuery
|
|
43
|
+
* Options for useDataOptionsQuery
|
|
44
44
|
*/
|
|
45
|
-
export type
|
|
45
|
+
export type UseDataOptionsQueryOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = DataOptionsFieldMapping<TData> & {
|
|
46
46
|
/**
|
|
47
47
|
* Options for fetching data using regular query
|
|
48
48
|
*/
|
|
49
49
|
queryOptions: UseQueryOptions<TQueryFnData[], TData[], TParams>;
|
|
50
|
-
/**
|
|
51
|
-
* Data dictionary key - should not be provided when using queryOptions
|
|
52
|
-
*/
|
|
53
|
-
dataDictKey?: never;
|
|
54
50
|
};
|
|
55
|
-
/**
|
|
56
|
-
* Options for useDataOptionsQuery with data dictionary query
|
|
57
|
-
*/
|
|
58
|
-
export type UseDataOptionsQueryOptionsWithDataDict<TData = DataOption> = DataOptionsFieldMapping<TData> & {
|
|
59
|
-
/**
|
|
60
|
-
* Data dictionary key
|
|
61
|
-
*/
|
|
62
|
-
dataDictKey: string;
|
|
63
|
-
/**
|
|
64
|
-
* Regular query options - should not be provided when using dataDictKey
|
|
65
|
-
*/
|
|
66
|
-
queryOptions?: never;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Options for useDataOptionsQuery hook - supports both regular query and data dictionary query
|
|
70
|
-
*/
|
|
71
|
-
export type UseDataOptionsQueryOptions<TQueryFnData = unknown, TData = TQueryFnData, TParams = never> = UseDataOptionsQueryOptionsWithQuery<TQueryFnData, TData, TParams> | UseDataOptionsQueryOptionsWithDataDict<TData>;
|
|
72
51
|
/**
|
|
73
52
|
* Return type for useDataOptionsQuery hook
|
|
74
53
|
*/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DataOption } from '@vef-framework-react/core';
|
|
2
|
+
import { Simplify } from '@vef-framework-react/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Per-key configuration with dict key and optional overrides.
|
|
5
|
+
*/
|
|
6
|
+
export interface DictionaryKeyConfig {
|
|
7
|
+
key: string;
|
|
8
|
+
filterable?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Value can be a plain dict key string or a config object.
|
|
12
|
+
*/
|
|
13
|
+
export type DictionaryKeyValue = string | DictionaryKeyConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Alias map that rejects array inputs.
|
|
16
|
+
*/
|
|
17
|
+
export interface DictionaryAliasMap {
|
|
18
|
+
readonly [alias: string]: DictionaryKeyValue;
|
|
19
|
+
readonly [index: number]: never;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Extract the actual dict key from a string or config value.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveDictKey(value: DictionaryKeyValue): string;
|
|
25
|
+
type DictionaryQueryData<T extends DictionaryAliasMap> = Record<Extract<keyof T, string>, DataOption[]>;
|
|
26
|
+
export type UseDictionaryQueryResult<T extends DictionaryAliasMap> = Simplify<{
|
|
27
|
+
data: DictionaryQueryData<T>;
|
|
28
|
+
isFetching: boolean;
|
|
29
|
+
isSuccess: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Query data dictionaries and map them back to alias keys.
|
|
33
|
+
* Uses the `dictionaryQueryFn` from app context.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useDictionaryQuery<const T extends DictionaryAliasMap>(dictionaryKeys: T): UseDictionaryQueryResult<T>;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vef-framework-react/hooks",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"description": "Hooks for VEF framework",
|
|
7
7
|
"author": {
|
|
@@ -48,14 +48,14 @@
|
|
|
48
48
|
"react": ">=19"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ai-sdk/react": "3.0.
|
|
52
|
-
"@mantine/hooks": "^9.
|
|
51
|
+
"@ai-sdk/react": "3.0.170",
|
|
52
|
+
"@mantine/hooks": "^9.1.0",
|
|
53
53
|
"react-hotkeys-hook": "^5.2.4",
|
|
54
|
-
"@vef-framework-react/core": "2.1.
|
|
55
|
-
"@vef-framework-react/shared": "2.1.
|
|
54
|
+
"@vef-framework-react/core": "2.1.7",
|
|
55
|
+
"@vef-framework-react/shared": "2.1.7"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"react": "^19.2.
|
|
58
|
+
"react": "^19.2.5"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"clean": "rimraf dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
let e=require(`@vef-framework-react/core`),t=require(`@vef-framework-react/shared`),n=require(`react`);function r({dataDictKey:r,onFetch:i,...a}){let{dataDictQueryFn:o}=(0,e.useAppContext)();if(!(0,t.isFunction)(o))throw Error(`Data dictionary query function is not provided in the app context.`);let s=(0,n.useRef)(i);s.current=i;let c=(0,e.useQuery)({...a,queryFn:(0,t.isEmpty)(r)?e.skipQueryToken:o,queryKey:[o.key,r],staleTime:a?.staleTime??1/0});return(0,n.useEffect)(()=>{s.current&&c.promise.then(s.current)},[c.promise]),c}exports.useDataDictQuery=r;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*! @vef-framework-react/hooks v2.1.6 made by Venus | 2026-04-01T03:01:32.302Z */
|
|
2
|
-
import { skipQueryToken as e, useAppContext as t, useQuery as n } from "@vef-framework-react/core";
|
|
3
|
-
import { isEmpty as r, isFunction as i } from "@vef-framework-react/shared";
|
|
4
|
-
import { useEffect as a, useRef as o } from "react";
|
|
5
|
-
//#region src/use-data-dict-query/index.ts
|
|
6
|
-
function s({ dataDictKey: s, onFetch: c, ...l }) {
|
|
7
|
-
let { dataDictQueryFn: u } = t();
|
|
8
|
-
if (!i(u)) throw Error("Data dictionary query function is not provided in the app context.");
|
|
9
|
-
let d = o(c);
|
|
10
|
-
d.current = c;
|
|
11
|
-
let f = n({
|
|
12
|
-
...l,
|
|
13
|
-
queryFn: r(s) ? e : u,
|
|
14
|
-
queryKey: [u.key, s],
|
|
15
|
-
staleTime: l?.staleTime ?? Infinity
|
|
16
|
-
});
|
|
17
|
-
return a(() => {
|
|
18
|
-
d.current && f.promise.then(d.current);
|
|
19
|
-
}, [f.promise]), f;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
export { s as useDataDictQuery };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DataOption, UseQueryOptions, UseQueryResult } from '@vef-framework-react/core';
|
|
2
|
-
import { Except } from '@vef-framework-react/shared';
|
|
3
|
-
export type UseDataDictQueryOptions<TData = DataOption> = Except<UseQueryOptions<DataOption[], TData[], string>, "queryFn" | "queryKey" | "queryHash" | "queryKeyHashFn"> & {
|
|
4
|
-
dataDictKey?: string;
|
|
5
|
-
onFetch?: (data: TData[]) => void;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* A hook for querying data dictionary.
|
|
9
|
-
* Uses the dataDictQueryFn from app context to fetch data dictionary options.
|
|
10
|
-
*
|
|
11
|
-
* @param dataDictKey - The key of the data dictionary to query.
|
|
12
|
-
* @param options - Additional query options (excluding queryFn and queryKey).
|
|
13
|
-
* @returns The query result containing data dictionary options.
|
|
14
|
-
*/
|
|
15
|
-
export declare function useDataDictQuery<TData = DataOption>({ dataDictKey, onFetch, ...options }: UseDataDictQueryOptions<TData>): UseQueryResult<TData[]>;
|