@vef-framework/hooks 1.0.62 → 1.0.64

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 (51) hide show
  1. package/es/index.js +27 -2
  2. package/es/lib.js +3 -2
  3. package/es/use-authorized-items.js +23 -2
  4. package/es/use-color-tokens.js +29 -2
  5. package/es/use-computed-action-buttons.js +42 -2
  6. package/es/use-computed-options.js +66 -2
  7. package/es/use-context-disabled.js +10 -2
  8. package/es/use-data-query.js +107 -2
  9. package/es/use-deep-callback.js +10 -2
  10. package/es/use-deep-memo.js +18 -2
  11. package/es/use-deep-selector.js +13 -2
  12. package/es/use-fallback-options.js +99 -2
  13. package/es/use-gap-size-normalizer.js +35 -2
  14. package/es/use-normalized-gap-size.js +9 -2
  15. package/es/use-normalized-menu-items.js +44 -2
  16. package/es/use-normalized-options.js +101 -2
  17. package/es/use-option-filter.js +17 -2
  18. package/es/use-remote-filter.js +36 -2
  19. package/es/use-shallow-callback.js +10 -2
  20. package/es/use-shallow-memo.js +18 -2
  21. package/es/use-shallow-selector.js +13 -2
  22. package/es/use-singleton.js +13 -2
  23. package/es/use-theme-tokens.js +10 -2
  24. package/es/use-transient-store.js +31 -2
  25. package/es/use-window-size.js +18 -2
  26. package/lib/index.cjs +109 -2
  27. package/lib/lib.cjs +58 -2
  28. package/lib/use-authorized-items.cjs +27 -2
  29. package/lib/use-color-tokens.cjs +35 -2
  30. package/lib/use-computed-action-buttons.cjs +46 -2
  31. package/lib/use-computed-options.cjs +70 -2
  32. package/lib/use-context-disabled.cjs +15 -2
  33. package/lib/use-data-query.cjs +111 -2
  34. package/lib/use-deep-callback.cjs +14 -2
  35. package/lib/use-deep-memo.cjs +22 -2
  36. package/lib/use-deep-selector.cjs +17 -2
  37. package/lib/use-fallback-options.cjs +103 -2
  38. package/lib/use-gap-size-normalizer.cjs +39 -2
  39. package/lib/use-normalized-gap-size.cjs +13 -2
  40. package/lib/use-normalized-menu-items.cjs +49 -2
  41. package/lib/use-normalized-options.cjs +105 -2
  42. package/lib/use-option-filter.cjs +21 -2
  43. package/lib/use-remote-filter.cjs +40 -2
  44. package/lib/use-shallow-callback.cjs +14 -2
  45. package/lib/use-shallow-memo.cjs +22 -2
  46. package/lib/use-shallow-selector.cjs +17 -2
  47. package/lib/use-singleton.cjs +17 -2
  48. package/lib/use-theme-tokens.cjs +14 -2
  49. package/lib/use-transient-store.cjs +35 -2
  50. package/lib/use-window-size.cjs +22 -2
  51. package/package.json +3 -3
package/es/index.js CHANGED
@@ -1,3 +1,28 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import"./lib.js";export{useAuthorizedItems}from"./use-authorized-items.js";export{useColorTokens,useDefaultColorTokens,useSemanticColorTokens}from"./use-color-tokens.js";export{useComputedActionButtons}from"./use-computed-action-buttons.js";export{useComputedOptions}from"./use-computed-options.js";export{DisabledContextProvider,useContextDisabled}from"./use-context-disabled.js";export{useDataQuery}from"./use-data-query.js";export{useDeepCallback}from"./use-deep-callback.js";export{useDeepMemo}from"./use-deep-memo.js";export{useDeepSelector}from"./use-deep-selector.js";export{useFallbackOptions}from"./use-fallback-options.js";export{useGapSizeNormalizer}from"./use-gap-size-normalizer.js";export{useNormalizedGapSize}from"./use-normalized-gap-size.js";export{normalizeMenuItem,useNormalizedMenuItems}from"./use-normalized-menu-items.js";export{useNormalizedDataOptions}from"./use-normalized-options.js";export{useOptionFilter}from"./use-option-filter.js";export{useRemoteFilter}from"./use-remote-filter.js";export{useShallowCallback}from"./use-shallow-callback.js";export{useShallowMemo}from"./use-shallow-memo.js";export{useShallowSelector}from"./use-shallow-selector.js";export{useSingleton}from"./use-singleton.js";export{useThemeTokens}from"./use-theme-tokens.js";export{useTransientStore}from"./use-transient-store.js";export{useWindowSize}from"./use-window-size.js";export{useClickAway,useMeasure}from"@uidotdev/usehooks";export{useDeepCompareEffect as useDeepEffect,useDeepCompareLayoutEffect as useDeepLayoutEffect,useSize as useElementSize,useEventListener,useKeyPress,useMount,useUnmount,useUpdateEffect,useUpdateLayoutEffect,useUpdate as useUpdater}from"ahooks";
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import './lib.js';
3
+ export { useAuthorizedItems } from './use-authorized-items.js';
4
+ export { useColorTokens, useDefaultColorTokens, useSemanticColorTokens } from './use-color-tokens.js';
5
+ export { useComputedActionButtons } from './use-computed-action-buttons.js';
6
+ export { useComputedOptions } from './use-computed-options.js';
7
+ export { DisabledContextProvider, useContextDisabled } from './use-context-disabled.js';
8
+ export { useDataQuery } from './use-data-query.js';
9
+ export { useDeepCallback } from './use-deep-callback.js';
10
+ export { useDeepMemo } from './use-deep-memo.js';
11
+ export { useDeepSelector } from './use-deep-selector.js';
12
+ export { useFallbackOptions } from './use-fallback-options.js';
13
+ export { useGapSizeNormalizer } from './use-gap-size-normalizer.js';
14
+ export { useNormalizedGapSize } from './use-normalized-gap-size.js';
15
+ export { normalizeMenuItem, useNormalizedMenuItems } from './use-normalized-menu-items.js';
16
+ export { useNormalizedDataOptions } from './use-normalized-options.js';
17
+ export { useOptionFilter } from './use-option-filter.js';
18
+ export { useRemoteFilter } from './use-remote-filter.js';
19
+ export { useShallowCallback } from './use-shallow-callback.js';
20
+ export { useShallowMemo } from './use-shallow-memo.js';
21
+ export { useShallowSelector } from './use-shallow-selector.js';
22
+ export { useSingleton } from './use-singleton.js';
23
+ export { useThemeTokens } from './use-theme-tokens.js';
24
+ export { useTransientStore } from './use-transient-store.js';
25
+ export { useWindowSize } from './use-window-size.js';
26
+ export { useClickAway, useMeasure } from '@uidotdev/usehooks';
27
+ export { useDeepCompareEffect as useDeepEffect, useDeepCompareLayoutEffect as useDeepLayoutEffect, useSize as useElementSize, useEventListener, useKeyPress, useMount, useUnmount, useUpdateEffect, useUpdateLayoutEffect, useUpdate as useUpdater } from 'ahooks';
3
28
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
package/es/lib.js CHANGED
@@ -1,3 +1,4 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- export{useClickAway,useMeasure}from"@uidotdev/usehooks";export{useDeepCompareEffect as useDeepEffect,useDeepCompareLayoutEffect as useDeepLayoutEffect,useSize as useElementSize,useEventListener,useKeyPress,useMount,useUnmount,useUpdateEffect,useUpdateLayoutEffect,useUpdate as useUpdater}from"ahooks";
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ export { useClickAway, useMeasure } from '@uidotdev/usehooks';
3
+ export { useDeepCompareEffect as useDeepEffect, useDeepCompareLayoutEffect as useDeepLayoutEffect, useSize as useElementSize, useEventListener, useKeyPress, useMount, useUnmount, useUpdateEffect, useUpdateLayoutEffect, useUpdate as useUpdater } from 'ahooks';
3
4
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,24 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useAuthContext as r}from"@vef-framework/core";import{useMemo as e}from"react";function o(o){const{checkPermission:n}=r();return e((()=>o?.filter((r=>{const{permissions:e}=r;if(!e)return!0;return"any"===(r.checkMode??"any")?e.some((r=>n(r))):e.every((r=>n(r)))}))),[o,n])}export{o as useAuthorizedItems};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useAuthContext } from '@vef-framework/core';
3
+ import { useMemo } from 'react';
4
+
5
+ function useAuthorizedItems(items) {
6
+ const { checkPermission } = useAuthContext();
7
+ return useMemo(
8
+ () => items?.filter((item) => {
9
+ const { permissions } = item;
10
+ if (!permissions) {
11
+ return true;
12
+ }
13
+ const checkMode = item.checkMode ?? "any";
14
+ if (checkMode === "any") {
15
+ return permissions.some((permission) => checkPermission(permission));
16
+ }
17
+ return permissions.every((permission) => checkPermission(permission));
18
+ }),
19
+ [items, checkPermission]
20
+ );
21
+ }
22
+
23
+ export { useAuthorizedItems };
3
24
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,30 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{defaultColorTypes as e,semanticColorTypes as r,capitalize as t}from"@vef-framework/shared";import{useMemo as o}from"react";import{useThemeTokens as n}from"./use-theme-tokens.js";function c(){const r=n();return o((()=>e.reduce(((e,t)=>(e.set(t,r[t]),e)),new Map)),[r])}function s(){const e=n();return o((()=>r.reduce(((r,o)=>(r.set(o,e[`color${t(o)}`]),r)),new Map)),[e])}function u(){const e=c(),r=s();return o((()=>new Map([...e,...r])),[e,r])}export{u as useColorTokens,c as useDefaultColorTokens,s as useSemanticColorTokens};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { defaultColorTypes, semanticColorTypes, capitalize } from '@vef-framework/shared';
3
+ import { useMemo } from 'react';
4
+ import { useThemeTokens } from './use-theme-tokens.js';
5
+
6
+ function useDefaultColorTokens() {
7
+ const tokens = useThemeTokens();
8
+ return useMemo(() => defaultColorTypes.reduce(
9
+ (map, color) => {
10
+ map.set(color, tokens[color]);
11
+ return map;
12
+ },
13
+ /* @__PURE__ */ new Map()
14
+ ), [tokens]);
15
+ }
16
+ function useSemanticColorTokens() {
17
+ const tokens = useThemeTokens();
18
+ return useMemo(() => semanticColorTypes.reduce((map, color) => {
19
+ map.set(color, tokens[`color${capitalize(color)}`]);
20
+ return map;
21
+ }, /* @__PURE__ */ new Map()), [tokens]);
22
+ }
23
+ function useColorTokens() {
24
+ const defaultColorTokens = useDefaultColorTokens();
25
+ const semanticColorTokens = useSemanticColorTokens();
26
+ return useMemo(() => new Map([...defaultColorTokens, ...semanticColorTokens]), [defaultColorTokens, semanticColorTokens]);
27
+ }
28
+
29
+ export { useColorTokens, useDefaultColorTokens, useSemanticColorTokens };
3
30
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,43 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{isFunction as o,defaultMessageTitle as i}from"@vef-framework/shared";import{useMemo as n}from"react";function r(r,t){return n((()=>r.filter((i=>{const{show:n}=i;return o(n)?n(t):n??!0})).map((n=>{const{disabled:r,requireConfirmation:e,confirmationMode:a,confirmationTitle:m,confirmationContent:f,...c}=n,l={...c,disabled:o(r)?r(t):r??!1,requireConfirmation:o(e)?e(t):e??!1,confirmationMode:o(a)?a(t):a??"simple",confirmationTitle:o(m)?m(t):m??i,confirmationContent:o(f)?f(t):f??`确定要${c.label}吗?`};return l.requireConfirmation&&!l.confirmationMode&&(l.confirmationMode="simple"),l.requireConfirmation&&!l.confirmationTitle&&(l.confirmationTitle=i),l.requireConfirmation&&!l.confirmationContent&&(l.confirmationContent=`确定要${l.label}吗?`),l}))),[r,t])}export{r as useComputedActionButtons};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { isFunction, defaultMessageTitle } from '@vef-framework/shared';
3
+ import { useMemo } from 'react';
4
+
5
+ function useComputedActionButtons(buttons, context) {
6
+ return useMemo(() => buttons.filter((button) => {
7
+ const { show } = button;
8
+ if (isFunction(show)) {
9
+ return show(context);
10
+ }
11
+ return show ?? true;
12
+ }).map((button) => {
13
+ const {
14
+ disabled,
15
+ requireConfirmation,
16
+ confirmationMode,
17
+ confirmationTitle,
18
+ confirmationContent,
19
+ ...rest
20
+ } = button;
21
+ const computedButton = {
22
+ ...rest,
23
+ disabled: isFunction(disabled) ? disabled(context) : disabled ?? false,
24
+ requireConfirmation: isFunction(requireConfirmation) ? requireConfirmation(context) : requireConfirmation ?? false,
25
+ confirmationMode: isFunction(confirmationMode) ? confirmationMode(context) : confirmationMode ?? "simple",
26
+ confirmationTitle: isFunction(confirmationTitle) ? confirmationTitle(context) : confirmationTitle ?? defaultMessageTitle,
27
+ confirmationContent: isFunction(confirmationContent) ? confirmationContent(context) : confirmationContent ?? `\u786E\u5B9A\u8981${rest.label}\u5417\uFF1F`
28
+ };
29
+ if (computedButton.requireConfirmation && !computedButton.confirmationMode) {
30
+ computedButton.confirmationMode = "simple";
31
+ }
32
+ if (computedButton.requireConfirmation && !computedButton.confirmationTitle) {
33
+ computedButton.confirmationTitle = defaultMessageTitle;
34
+ }
35
+ if (computedButton.requireConfirmation && !computedButton.confirmationContent) {
36
+ computedButton.confirmationContent = `\u786E\u5B9A\u8981${computedButton.label}\u5417\uFF1F`;
37
+ }
38
+ return computedButton;
39
+ }), [buttons, context]);
40
+ }
41
+
42
+ export { useComputedActionButtons };
3
43
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,67 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useDataQuery as e}from"./use-data-query.js";import{useFallbackOptions as i}from"./use-fallback-options.js";import{useNormalizedDataOptions as a}from"./use-normalized-options.js";import{useRemoteFilter as l}from"./use-remote-filter.js";function o({labelField:o,valueField:s,descriptionField:t,childrenField:d,disabledField:r,defaultToFirst:n,filterable:p=!1,filterFromRemote:u=!1,keywordKey:c="keyword",valuesKey:f="ids",fallbackOptionsApi:m,fallbackOptionsApiParams:F,resolveFallbackOptions:b,isGrouped:O=!1,selectedOptionValues:k,apiParams:y,...v}){const[g,P]=l(p&&u,y,c),{data:j,isLoading:A}=e({apiParams:g,...v}),[K,L,h]=a(j??[],{labelField:o,valueField:s,descriptionField:t,childrenField:d,disabledField:r,defaultToFirst:n},{isGrouped:O,parsePinyin:p&&!u,selectedOptionValues:k}),{data:w,isLoading:z}=i(L,{fallbackOptionsApi:m??v.api,fallbackOptionsApiParams:F,valuesKey:f,resolveFallbackOptions:b});return{onFilterKeywordChange:P,isLoading:A,normalizedOptions:K,defaultOption:h,fallbackOptions:w,isFallbackOptionsLoading:z}}export{o as useComputedOptions};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useDataQuery } from './use-data-query.js';
3
+ import { useFallbackOptions } from './use-fallback-options.js';
4
+ import { useNormalizedDataOptions } from './use-normalized-options.js';
5
+ import { useRemoteFilter } from './use-remote-filter.js';
6
+
7
+ function useComputedOptions({
8
+ labelField,
9
+ valueField,
10
+ descriptionField,
11
+ childrenField,
12
+ disabledField,
13
+ defaultToFirst,
14
+ filterable = false,
15
+ filterFromRemote = false,
16
+ keywordKey = "keyword",
17
+ valuesKey = "ids",
18
+ fallbackOptionsApi,
19
+ fallbackOptionsApiParams,
20
+ resolveFallbackOptions,
21
+ isGrouped = false,
22
+ selectedOptionValues,
23
+ apiParams,
24
+ ...queryConfig
25
+ }) {
26
+ const [mergedApiParams, onFilterKeywordChange] = useRemoteFilter(filterable && filterFromRemote, apiParams, keywordKey);
27
+ const { data: options, isLoading } = useDataQuery({
28
+ apiParams: mergedApiParams,
29
+ ...queryConfig
30
+ });
31
+ const [normalizedOptions, missingOptionValues, defaultOption] = useNormalizedDataOptions(
32
+ options ?? [],
33
+ {
34
+ labelField,
35
+ valueField,
36
+ descriptionField,
37
+ childrenField,
38
+ disabledField,
39
+ defaultToFirst
40
+ },
41
+ {
42
+ isGrouped,
43
+ parsePinyin: filterable && !filterFromRemote,
44
+ selectedOptionValues
45
+ }
46
+ );
47
+ const { data: fallbackOptions, isLoading: isFallbackOptionsLoading } = useFallbackOptions(
48
+ missingOptionValues,
49
+ {
50
+ fallbackOptionsApi: fallbackOptionsApi ?? queryConfig.api,
51
+ fallbackOptionsApiParams,
52
+ valuesKey,
53
+ resolveFallbackOptions
54
+ }
55
+ );
56
+ return {
57
+ onFilterKeywordChange,
58
+ isLoading,
59
+ normalizedOptions,
60
+ defaultOption,
61
+ fallbackOptions,
62
+ isFallbackOptionsLoading
63
+ };
64
+ }
65
+
66
+ export { useComputedOptions };
3
67
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,11 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{createContext as r,useContext as o}from"react";const t=r(!1);function n(){return o(t)}const c=t.Provider;export{c as DisabledContextProvider,n as useContextDisabled};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { createContext, useContext } from 'react';
3
+
4
+ const DisabledContext = createContext(false);
5
+ function useContextDisabled() {
6
+ return useContext(DisabledContext);
7
+ }
8
+ const DisabledContextProvider = DisabledContext.Provider;
9
+
10
+ export { DisabledContextProvider, useContextDisabled };
3
11
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,108 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useApiContext as e}from"@vef-framework/core";import{isNullish as a,isFunction as t}from"@vef-framework/shared";import{useUnmount as r}from"ahooks";import{useMemo as i}from"react";function o({onFetched:o,...s}){const{useApiQuery:p,stubQueryApi:c,dataDictionaryApi:n}=e(),[u,m,l]=function({data:e,dataDictionaryKey:t,api:r,apiParams:o,apiEnabled:s,staleTime:p,keepPreviousData:c,placeholderData:n},u,m){return i((()=>a(e)?a(t)?a(r)?[u,[],{keepPreviousData:!0,initialData:[]}]:[r,o,{enabled:s??!0,staleTime:p,keepPreviousData:c,placeholderData:n}]:[m,{...o,key:t},{enabled:s??!0,staleTime:p,keepPreviousData:c,placeholderData:n}]:[u,e,{keepPreviousData:!0,initialData:e}]),[e,t,r,u,m,o,s,p,c,n])}(s,c,n),d=p(u,m,l);r((()=>{Object.is(u,c)&&c.removeQueries(m)}));const{isSuccess:D,data:f,...k}=d,v=i((()=>D&&t(o)?o(f):f),[D,f,o]);return{...k,isSuccess:D,data:v}}export{o as useDataQuery};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useApiContext } from '@vef-framework/core';
3
+ import { isNullish, isFunction } from '@vef-framework/shared';
4
+ import { useUnmount } from 'ahooks';
5
+ import { useMemo } from 'react';
6
+
7
+ function useApi({
8
+ data,
9
+ dataDictionaryKey,
10
+ api,
11
+ apiParams,
12
+ apiEnabled,
13
+ staleTime,
14
+ keepPreviousData,
15
+ placeholderData
16
+ }, stubQueryApi, dataDictionaryApi) {
17
+ return useMemo(() => {
18
+ if (!isNullish(data)) {
19
+ return [
20
+ stubQueryApi,
21
+ data,
22
+ {
23
+ keepPreviousData: true,
24
+ initialData: data
25
+ }
26
+ ];
27
+ }
28
+ if (!isNullish(dataDictionaryKey)) {
29
+ return [
30
+ dataDictionaryApi,
31
+ {
32
+ ...apiParams,
33
+ key: dataDictionaryKey
34
+ },
35
+ {
36
+ enabled: apiEnabled ?? true,
37
+ staleTime,
38
+ keepPreviousData,
39
+ placeholderData
40
+ }
41
+ ];
42
+ }
43
+ if (!isNullish(api)) {
44
+ return [
45
+ api,
46
+ apiParams,
47
+ {
48
+ enabled: apiEnabled ?? true,
49
+ staleTime,
50
+ keepPreviousData,
51
+ placeholderData
52
+ }
53
+ ];
54
+ }
55
+ return [
56
+ stubQueryApi,
57
+ [],
58
+ {
59
+ keepPreviousData: true,
60
+ initialData: []
61
+ }
62
+ ];
63
+ }, [
64
+ data,
65
+ dataDictionaryKey,
66
+ api,
67
+ stubQueryApi,
68
+ dataDictionaryApi,
69
+ apiParams,
70
+ apiEnabled,
71
+ staleTime,
72
+ keepPreviousData,
73
+ placeholderData
74
+ ]);
75
+ }
76
+ function useDataQuery({ onFetched, ...config }) {
77
+ const {
78
+ useApiQuery,
79
+ stubQueryApi,
80
+ dataDictionaryApi: dataDictionaryQueryApi
81
+ } = useApiContext();
82
+ const [api, args, options] = useApi(config, stubQueryApi, dataDictionaryQueryApi);
83
+ const result = useApiQuery(api, args, options);
84
+ useUnmount(() => {
85
+ if (Object.is(api, stubQueryApi)) {
86
+ stubQueryApi.removeQueries(args);
87
+ }
88
+ });
89
+ const {
90
+ isSuccess,
91
+ data: rawData,
92
+ ...rest
93
+ } = result;
94
+ const data = useMemo(() => {
95
+ if (isSuccess && isFunction(onFetched)) {
96
+ return onFetched(rawData);
97
+ }
98
+ return rawData;
99
+ }, [isSuccess, rawData, onFetched]);
100
+ return {
101
+ ...rest,
102
+ isSuccess,
103
+ data
104
+ };
105
+ }
106
+
107
+ export { useDataQuery };
3
108
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,11 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useCallback as o}from"react";import{useDeepMemo as r}from"./use-deep-memo.js";function e(e,t){const m=r((()=>t),t);return o(e,m)}export{e as useDeepCallback};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useCallback } from 'react';
3
+ import { useDeepMemo } from './use-deep-memo.js';
4
+
5
+ function useDeepCallback(callback, dependencies) {
6
+ const memoizedDependencies = useDeepMemo(() => dependencies, dependencies);
7
+ return useCallback(callback, memoizedDependencies);
8
+ }
9
+
10
+ export { useDeepCallback };
3
11
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,19 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{isDeepEqual as r}from"@vef-framework/shared";import{useRef as e,useMemo as t}from"react";function n(n,o){const c=e(),u=e(0);var f,m;return void 0!==c.current&&(f=o,m=c.current,f.length===m.length&&f.every(((e,t)=>r(e,m[t]))))||(u.current+=1),c.current=o,t(n,[u.current])}export{n as useDeepMemo};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { isDeepEqual } from '@vef-framework/shared';
3
+ import { useRef, useMemo } from 'react';
4
+
5
+ function useDeepMemo(factory, dependencies) {
6
+ const lastDependencies = useRef();
7
+ const signal = useRef(0);
8
+ if (lastDependencies.current === void 0 || !isEqual(dependencies, lastDependencies.current)) {
9
+ signal.current += 1;
10
+ }
11
+ lastDependencies.current = dependencies;
12
+ return useMemo(factory, [signal.current]);
13
+ }
14
+ function isEqual(one, another) {
15
+ return one.length === another.length && one.every((value, index) => isDeepEqual(value, another[index]));
16
+ }
17
+
18
+ export { useDeepMemo };
3
19
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,14 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{isDeepEqual as r}from"@vef-framework/shared";import{useRef as t}from"react";function e(e){const n=t();return t=>{const o=e(t);return r(n.current,o)?n.current:n.current=o}}export{e as useDeepSelector};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { isDeepEqual } from '@vef-framework/shared';
3
+ import { useRef } from 'react';
4
+
5
+ function useDeepSelector(selector) {
6
+ const prevSelectedState = useRef();
7
+ return (state) => {
8
+ const nextSelectedState = selector(state);
9
+ return isDeepEqual(prevSelectedState.current, nextSelectedState) ? prevSelectedState.current : prevSelectedState.current = nextSelectedState;
10
+ };
11
+ }
12
+
13
+ export { useDeepSelector };
3
14
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,100 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useApiContext as e}from"@vef-framework/core";import{isFunction as a}from"@vef-framework/shared";import{useUnmount as r}from"ahooks";import{useId as i,useMemo as o}from"react";function s(s,{fallbackOptionsApi:t,fallbackOptionsApiParams:p,valuesKey:l,resolveFallbackOptions:n}){const{useApiQuery:u,stubQueryApi:c,asyncFnQueryApi:f}=e(),[k,m,v]=function(e,{fallbackOptionsApi:r,fallbackOptionsApiParams:s,valuesKey:t,resolveFallbackOptions:p},l,n){const u=i();return o((()=>{if(a(p))return[n,{key:u,args:[e],fn:p},{keepPreviousData:!0}];if(r){const a={...s,[t??"ids"]:e};return[r,a,{keepPreviousData:!0}]}return[l,[],{keepPreviousData:!0,initialData:[]}]}),[p,r,l,u,e,n,s,t])}(s,{fallbackOptionsApi:t,fallbackOptionsApiParams:p,valuesKey:l,resolveFallbackOptions:n},c,f),b=u(k,m,v);return r((()=>{Object.is(k,c)&&c.removeQueries(m),Object.is(k,f)&&f.removeQueries(m)})),b}export{s as useFallbackOptions};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useApiContext } from '@vef-framework/core';
3
+ import { isFunction } from '@vef-framework/shared';
4
+ import { useUnmount } from 'ahooks';
5
+ import { useId, useMemo } from 'react';
6
+
7
+ function useApi(missingOptionValues, {
8
+ fallbackOptionsApi,
9
+ fallbackOptionsApiParams,
10
+ valuesKey,
11
+ resolveFallbackOptions
12
+ }, stubQueryApi, asyncFnQueryApi) {
13
+ const uniqueId = useId();
14
+ return useMemo(() => {
15
+ if (isFunction(resolveFallbackOptions)) {
16
+ const params = {
17
+ key: uniqueId,
18
+ args: [missingOptionValues],
19
+ fn: resolveFallbackOptions
20
+ };
21
+ return [
22
+ asyncFnQueryApi,
23
+ params,
24
+ {
25
+ keepPreviousData: true
26
+ }
27
+ ];
28
+ }
29
+ if (fallbackOptionsApi) {
30
+ const params = {
31
+ ...fallbackOptionsApiParams,
32
+ [valuesKey ?? "ids"]: missingOptionValues
33
+ };
34
+ return [
35
+ fallbackOptionsApi,
36
+ params,
37
+ {
38
+ keepPreviousData: true
39
+ }
40
+ ];
41
+ }
42
+ return [
43
+ stubQueryApi,
44
+ [],
45
+ {
46
+ keepPreviousData: true,
47
+ initialData: []
48
+ }
49
+ ];
50
+ }, [
51
+ resolveFallbackOptions,
52
+ fallbackOptionsApi,
53
+ stubQueryApi,
54
+ uniqueId,
55
+ missingOptionValues,
56
+ asyncFnQueryApi,
57
+ fallbackOptionsApiParams,
58
+ valuesKey
59
+ ]);
60
+ }
61
+ function useFallbackOptions(missingOptionValues, {
62
+ fallbackOptionsApi,
63
+ fallbackOptionsApiParams,
64
+ valuesKey,
65
+ resolveFallbackOptions
66
+ }) {
67
+ const {
68
+ useApiQuery,
69
+ stubQueryApi,
70
+ asyncFnQueryApi
71
+ } = useApiContext();
72
+ const [
73
+ api,
74
+ params,
75
+ options
76
+ ] = useApi(
77
+ missingOptionValues,
78
+ {
79
+ fallbackOptionsApi,
80
+ fallbackOptionsApiParams,
81
+ valuesKey,
82
+ resolveFallbackOptions
83
+ },
84
+ stubQueryApi,
85
+ asyncFnQueryApi
86
+ );
87
+ const result = useApiQuery(api, params, options);
88
+ useUnmount(() => {
89
+ if (Object.is(api, stubQueryApi)) {
90
+ stubQueryApi.removeQueries(params);
91
+ }
92
+ if (Object.is(api, asyncFnQueryApi)) {
93
+ asyncFnQueryApi.removeQueries(params);
94
+ }
95
+ });
96
+ return result;
97
+ }
98
+
99
+ export { useFallbackOptions };
3
100
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,36 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useCallback as d}from"react";import{useThemeTokens as n}from"./use-theme-tokens.js";function e(){const{paddingXS:e,paddingSM:i,padding:t,paddingMD:r,paddingLG:a}=n();return d((d=>"tiny"===d?e:"small"===d?i:"medium"===d?t:"large"===d?r:"huge"===d?a:d),[e,i,t,r,a])}export{e as useGapSizeNormalizer};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useCallback } from 'react';
3
+ import { useThemeTokens } from './use-theme-tokens.js';
4
+
5
+ function useGapSizeNormalizer() {
6
+ const {
7
+ paddingXS,
8
+ paddingSM,
9
+ padding,
10
+ paddingMD,
11
+ paddingLG
12
+ } = useThemeTokens();
13
+ return useCallback((gap) => {
14
+ if (gap === "tiny") {
15
+ return paddingXS;
16
+ } else if (gap === "small") {
17
+ return paddingSM;
18
+ } else if (gap === "medium") {
19
+ return padding;
20
+ } else if (gap === "large") {
21
+ return paddingMD;
22
+ } else if (gap === "huge") {
23
+ return paddingLG;
24
+ }
25
+ return gap;
26
+ }, [
27
+ paddingXS,
28
+ paddingSM,
29
+ padding,
30
+ paddingMD,
31
+ paddingLG
32
+ ]);
33
+ }
34
+
35
+ export { useGapSizeNormalizer };
3
36
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,10 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useGapSizeNormalizer as r}from"./use-gap-size-normalizer.js";function e(e){return r()(e)}export{e as useNormalizedGapSize};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useGapSizeNormalizer } from './use-gap-size-normalizer.js';
3
+
4
+ function useNormalizedGapSize(gap) {
5
+ const normalize = useGapSizeNormalizer();
6
+ return normalize(gap);
7
+ }
8
+
9
+ export { useNormalizedGapSize };
3
10
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
@@ -1,3 +1,45 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- import{useMemo as e}from"react";function l(e){return"item"===e.type?{type:"item",key:e.key,label:e.label,disabled:e.disabled,icon:e.icon,extra:e.extra}:"submenu"===e.type?{type:"submenu",key:e.key,label:e.label,disabled:e.disabled,icon:e.icon,children:e.children.map(l)}:"group"===e.type?{type:"group",key:e.key,label:e.label,children:e.children.map(l)}:{type:"divider",key:e.key}}function i(i){return e((()=>i.map(l)),[i])}export{l as normalizeMenuItem,i as useNormalizedMenuItems};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, made by Venus. */
2
+ import { useMemo } from 'react';
3
+
4
+ function normalizeMenuItem(item) {
5
+ if (item.type === "item") {
6
+ return {
7
+ type: "item",
8
+ key: item.key,
9
+ label: item.label,
10
+ disabled: item.disabled,
11
+ icon: item.icon,
12
+ extra: item.extra
13
+ };
14
+ } else if (item.type === "submenu") {
15
+ return {
16
+ type: "submenu",
17
+ key: item.key,
18
+ label: item.label,
19
+ disabled: item.disabled,
20
+ icon: item.icon,
21
+ children: item.children.map(normalizeMenuItem)
22
+ };
23
+ } else if (item.type === "group") {
24
+ return {
25
+ type: "group",
26
+ key: item.key,
27
+ label: item.label,
28
+ children: item.children.map(normalizeMenuItem)
29
+ };
30
+ } else {
31
+ return {
32
+ type: "divider",
33
+ key: item.key
34
+ };
35
+ }
36
+ }
37
+ function useNormalizedMenuItems(items) {
38
+ return useMemo(
39
+ () => items.map(normalizeMenuItem),
40
+ [items]
41
+ );
42
+ }
43
+
44
+ export { normalizeMenuItem, useNormalizedMenuItems };
3
45
  /*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */