@vef-framework/hooks 1.0.97 → 1.0.99

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 +102 -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 +106 -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.97, build time: 2025-03-06T12:24:36.309Z, 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.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, 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.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useAuthContext as e}from"@vef-framework/core";import{useMemo as r}from"react";function useAuthorizedItems(o){const{checkPermission:t}=e();return r((()=>o?.filter((e=>{const{permissions:r}=e;if(!r)return!0;return"any"===(e.checkMode??"any")?r.some((e=>t(e))):r.every((e=>t(e)))}))),[o,t])}export{useAuthorizedItems};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{defaultColorTypes as e,semanticColorTypes as o,capitalize as r}from"@vef-framework/shared";import{useMemo as n}from"react";import{useThemeTokens as s}from"./use-theme-tokens.js";function useDefaultColorTokens(){const o=s();return n((()=>e.reduce(((e,r)=>(e.set(r,o[r]),e)),new Map)),[o])}function useSemanticColorTokens(){const e=s();return n((()=>o.reduce(((o,n)=>(o.set(n,e[`color${r(n)}`]),o)),new Map)),[e])}function useColorTokens(){const e=useDefaultColorTokens(),o=useSemanticColorTokens();return n((()=>new Map([...e,...o])),[e,o])}export{useColorTokens,useDefaultColorTokens,useSemanticColorTokens};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{isFunction as o,defaultMessageTitle as i}from"@vef-framework/shared";import{useMemo as n}from"react";function useComputedActionButtons(t,r){return n((()=>t.filter((i=>{const{show:n}=i;return o(n)?n(r):n??!0})).map((n=>{const{disabled:t,requireConfirmation:e,confirmationMode:m,confirmationTitle:a,confirmationContent:f,...c}=n,u={...c,disabled:o(t)?t(r):t??!1,requireConfirmation:o(e)?e(r):e??!1,confirmationMode:o(m)?m(r):m??"simple",confirmationTitle:o(a)?a(r):a??i,confirmationContent:o(f)?f(r):f??`确定要${c.label}吗?`};return u.requireConfirmation&&!u.confirmationMode&&(u.confirmationMode="simple"),u.requireConfirmation&&!u.confirmationTitle&&(u.confirmationTitle=i),u.requireConfirmation&&!u.confirmationContent&&(u.confirmationContent=`确定要${u.label}吗?`),u}))),[t,r])}export{useComputedActionButtons};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useDataQuery as e}from"./use-data-query.js";import{useFallbackOptions as a}from"./use-fallback-options.js";import{useNormalizedDataOptions as i}from"./use-normalized-options.js";import{useRemoteFilter as o}from"./use-remote-filter.js";function useComputedOptions({labelKey:s,valueKey:l,descriptionKey:t,childrenKey:r,disabledKey:p,defaultToFirst:n,filterable:d=!1,filterFromRemote:u=!1,keywordKey:m="keyword",valuesKey:y="ids",fallbackOptionsApi:c,fallbackOptionsApiParams:f,resolveFallbackOptions:b,isGrouped:K=!1,selectedOptionValues:O,apiParams:k,...F}){const[v,g]=o(d&&u,k,m),{data:P,isLoading:j}=e({apiParams:v,...F}),[A,L,h]=i(P??[],{labelKey:s,valueKey:l,descriptionKey:t,childrenKey:r,disabledKey:p,defaultToFirst:n},{isGrouped:K,parsePinyin:d&&!u,selectedOptionValues:O}),{data:w,isLoading:C}=a(L,{fallbackOptionsApi:c??F.api,fallbackOptionsApiParams:f,valuesKey:y,resolveFallbackOptions:b});return{onFilterKeywordChange:g,isLoading:j,normalizedOptions:A,defaultOption:h,fallbackOptions:w,isFallbackOptionsLoading:C}}export{useComputedOptions};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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
+ labelKey,
9
+ valueKey,
10
+ descriptionKey,
11
+ childrenKey,
12
+ disabledKey,
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
+ labelKey,
35
+ valueKey,
36
+ descriptionKey,
37
+ childrenKey,
38
+ disabledKey,
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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{createContext as t,useContext as e}from"react";const o=t(!1);function useContextDisabled(){return e(o)}const r=o.Provider;export{r as DisabledContextProvider,useContextDisabled};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, 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 useDataQuery({onFetched:o,...s}){const{useApiQuery:u,stubQueryApi:p,dataDictionaryApi:c}=e(),[n,m,l]=function useApi({data:e,dataDictionaryKey:t,api:r,apiParams:o,apiEnabled:s,staleTime:u,keepPreviousData:p,placeholderData:c},n,m){return i((()=>a(e)?a(t)?a(r)?[n,[],{keepPreviousData:!0,initialData:[]}]:[r,o,{enabled:s??!0,staleTime:u,keepPreviousData:p,placeholderData:c}]:[m,{...o,key:t},{enabled:s??!0,staleTime:u,keepPreviousData:p,placeholderData:c}]:[n,e,{keepPreviousData:!0,initialData:e}]),[e,t,r,n,m,o,s,u,p,c])}(s,p,c),D=u(n,m,l);r((()=>{Object.is(n,p)&&p.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{useDataQuery};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useCallback as e}from"react";import{useDeepMemo as o}from"./use-deep-memo.js";function useDeepCallback(r,t){const m=o((()=>t),t);return e(r,m)}export{useDeepCallback};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{isDeepEqual as e}from"@vef-framework/shared";import{useRef as r,useMemo as t}from"react";function useDeepMemo(n,o){const u=r(),c=r(0);return void 0!==u.current&&function isEqual(r,t){return r.length===t.length&&r.every(((r,n)=>e(r,t[n])))}(o,u.current)||(c.current+=1),u.current=o,t(n,[c.current])}export{useDeepMemo};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{isDeepEqual as r}from"@vef-framework/shared";import{useRef as e}from"react";function useDeepSelector(t){const o=e();return e=>{const c=t(e);return r(o.current,c)?o.current:o.current=c}}export{useDeepSelector};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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,103 @@
1
- /*! VefFramework version: 1.0.97, build time: 2025-03-06T12:24:36.309Z, 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 s}from"react";import{useShallowMemo as i}from"./use-shallow-memo.js";function useFallbackOptions(o,{fallbackOptionsApi:t,fallbackOptionsApiParams:l,valuesKey:p,resolveFallbackOptions:n}){const{useApiQuery:u,stubQueryApi:c,asyncFnQueryApi:f}=e(),[m,k,b]=function useApi(e,{fallbackOptionsApi:r,fallbackOptionsApiParams:o,valuesKey:t,resolveFallbackOptions:l},p,n){const u=s();return i((()=>{if(e.length>0){if(a(l))return[n,{key:u,args:[e],fn:l},{keepPreviousData:!0}];if(r){const a={...o,[t??"ids"]:e};return[r,a,{keepPreviousData:!0}]}}return[p,[],{keepPreviousData:!0,initialData:[]}]}),[l,r,p,u,e,n,o,t])}(o,{fallbackOptionsApi:t,fallbackOptionsApiParams:l,valuesKey:p,resolveFallbackOptions:n},c,f),v=u(m,k,b);return r((()=>{Object.is(m,c)&&c.removeQueries(k),Object.is(m,f)&&f.removeQueries(k)})),v}export{useFallbackOptions};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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 } from 'react';
6
+ import { useShallowMemo } from './use-shallow-memo.js';
7
+
8
+ function useApi(missingOptionValues, {
9
+ fallbackOptionsApi,
10
+ fallbackOptionsApiParams,
11
+ valuesKey,
12
+ resolveFallbackOptions
13
+ }, stubQueryApi, asyncFnQueryApi) {
14
+ const uniqueId = useId();
15
+ return useShallowMemo(() => {
16
+ if (missingOptionValues.length > 0) {
17
+ if (isFunction(resolveFallbackOptions)) {
18
+ const params = {
19
+ key: uniqueId,
20
+ args: [missingOptionValues],
21
+ fn: resolveFallbackOptions
22
+ };
23
+ return [
24
+ asyncFnQueryApi,
25
+ params,
26
+ {
27
+ keepPreviousData: true
28
+ }
29
+ ];
30
+ }
31
+ if (fallbackOptionsApi) {
32
+ const params = {
33
+ ...fallbackOptionsApiParams,
34
+ [valuesKey ?? "ids"]: missingOptionValues
35
+ };
36
+ return [
37
+ fallbackOptionsApi,
38
+ params,
39
+ {
40
+ keepPreviousData: true
41
+ }
42
+ ];
43
+ }
44
+ }
45
+ return [
46
+ stubQueryApi,
47
+ [],
48
+ {
49
+ keepPreviousData: true,
50
+ initialData: []
51
+ }
52
+ ];
53
+ }, [
54
+ resolveFallbackOptions,
55
+ fallbackOptionsApi,
56
+ stubQueryApi,
57
+ uniqueId,
58
+ missingOptionValues,
59
+ asyncFnQueryApi,
60
+ fallbackOptionsApiParams,
61
+ valuesKey
62
+ ]);
63
+ }
64
+ function useFallbackOptions(missingOptionValues, {
65
+ fallbackOptionsApi,
66
+ fallbackOptionsApiParams,
67
+ valuesKey,
68
+ resolveFallbackOptions
69
+ }) {
70
+ const {
71
+ useApiQuery,
72
+ stubQueryApi,
73
+ asyncFnQueryApi
74
+ } = useApiContext();
75
+ const [
76
+ api,
77
+ params,
78
+ options
79
+ ] = useApi(
80
+ missingOptionValues,
81
+ {
82
+ fallbackOptionsApi,
83
+ fallbackOptionsApiParams,
84
+ valuesKey,
85
+ resolveFallbackOptions
86
+ },
87
+ stubQueryApi,
88
+ asyncFnQueryApi
89
+ );
90
+ const result = useApiQuery(api, params, options);
91
+ useUnmount(() => {
92
+ if (Object.is(api, stubQueryApi)) {
93
+ stubQueryApi.removeQueries(params);
94
+ }
95
+ if (Object.is(api, asyncFnQueryApi)) {
96
+ asyncFnQueryApi.removeQueries(params);
97
+ }
98
+ });
99
+ return result;
100
+ }
101
+
102
+ export { useFallbackOptions };
3
103
  /*! 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useCallback as e}from"react";import{useThemeTokens as i}from"./use-theme-tokens.js";function useGapSizeNormalizer(){const{paddingXS:r,paddingSM:a,padding:d,paddingMD:n,paddingLG:m}=i();return e((e=>"tiny"===e?r:"small"===e?a:"medium"===e?d:"large"===e?n:"huge"===e?m:e),[r,a,d,n,m])}export{useGapSizeNormalizer};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useGapSizeNormalizer as e}from"./use-gap-size-normalizer.js";function useNormalizedGapSize(r){return e()(r)}export{useNormalizedGapSize};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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.97, build time: 2025-03-06T12:24:36.309Z, made by Venus. */
2
- import{useMemo as e}from"react";function normalizeMenuItem(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(normalizeMenuItem)}:"group"===e.type?{type:"group",key:e.key,label:e.label,children:e.children.map(normalizeMenuItem)}:{type:"divider",key:e.key}}function useNormalizedMenuItems(n){return e((()=>n.map(normalizeMenuItem)),[n])}export{normalizeMenuItem,useNormalizedMenuItems};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, 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 */