@vef-framework/hooks 1.0.98 → 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
@@ -1,3 +1,71 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-data-query.cjs"),a=require("./use-fallback-options.cjs"),i=require("./use-normalized-options.cjs"),s=require("./use-remote-filter.cjs");exports.useComputedOptions=function useComputedOptions({labelKey:o,valueKey:t,descriptionKey:l,childrenKey:r,disabledKey:n,defaultToFirst:p,filterable:u=!1,filterFromRemote:d=!1,keywordKey:c="keyword",valuesKey:y="ids",fallbackOptionsApi:b,fallbackOptionsApiParams:O,resolveFallbackOptions:f,isGrouped:m=!1,selectedOptionValues:K,apiParams:k,...F}){const[g,v]=s.useRemoteFilter(u&&d,k,c),{data:P,isLoading:j}=e.useDataQuery({apiParams:g,...F}),[q,A,L]=i.useNormalizedDataOptions(P??[],{labelKey:o,valueKey:t,descriptionKey:l,childrenKey:r,disabledKey:n,defaultToFirst:p},{isGrouped:m,parsePinyin:u&&!d,selectedOptionValues:K}),{data:h,isLoading:w}=a.useFallbackOptions(A,{fallbackOptionsApi:b??F.api,fallbackOptionsApiParams:O,valuesKey:y,resolveFallbackOptions:f});return{onFilterKeywordChange:v,isLoading:j,normalizedOptions:q,defaultOption:L,fallbackOptions:h,isFallbackOptionsLoading:w}};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const useDataQuery = require('./use-data-query.cjs');
7
+ const useFallbackOptions = require('./use-fallback-options.cjs');
8
+ const useNormalizedOptions = require('./use-normalized-options.cjs');
9
+ const useRemoteFilter = require('./use-remote-filter.cjs');
10
+
11
+ function useComputedOptions({
12
+ labelKey,
13
+ valueKey,
14
+ descriptionKey,
15
+ childrenKey,
16
+ disabledKey,
17
+ defaultToFirst,
18
+ filterable = false,
19
+ filterFromRemote = false,
20
+ keywordKey = "keyword",
21
+ valuesKey = "ids",
22
+ fallbackOptionsApi,
23
+ fallbackOptionsApiParams,
24
+ resolveFallbackOptions,
25
+ isGrouped = false,
26
+ selectedOptionValues,
27
+ apiParams,
28
+ ...queryConfig
29
+ }) {
30
+ const [mergedApiParams, onFilterKeywordChange] = useRemoteFilter.useRemoteFilter(filterable && filterFromRemote, apiParams, keywordKey);
31
+ const { data: options, isLoading } = useDataQuery.useDataQuery({
32
+ apiParams: mergedApiParams,
33
+ ...queryConfig
34
+ });
35
+ const [normalizedOptions, missingOptionValues, defaultOption] = useNormalizedOptions.useNormalizedDataOptions(
36
+ options ?? [],
37
+ {
38
+ labelKey,
39
+ valueKey,
40
+ descriptionKey,
41
+ childrenKey,
42
+ disabledKey,
43
+ defaultToFirst
44
+ },
45
+ {
46
+ isGrouped,
47
+ parsePinyin: filterable && !filterFromRemote,
48
+ selectedOptionValues
49
+ }
50
+ );
51
+ const { data: fallbackOptions, isLoading: isFallbackOptionsLoading } = useFallbackOptions.useFallbackOptions(
52
+ missingOptionValues,
53
+ {
54
+ fallbackOptionsApi: fallbackOptionsApi ?? queryConfig.api,
55
+ fallbackOptionsApiParams,
56
+ valuesKey,
57
+ resolveFallbackOptions
58
+ }
59
+ );
60
+ return {
61
+ onFilterKeywordChange,
62
+ isLoading,
63
+ normalizedOptions,
64
+ defaultOption,
65
+ fallbackOptions,
66
+ isFallbackOptionsLoading
67
+ };
68
+ }
69
+
70
+ exports.useComputedOptions = useComputedOptions;
3
71
  /*! 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,16 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext(!1);const o=t.Provider;exports.DisabledContextProvider=o,exports.useContextDisabled=function useContextDisabled(){return e.useContext(t)};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const react = require('react');
7
+
8
+ const DisabledContext = react.createContext(false);
9
+ function useContextDisabled() {
10
+ return react.useContext(DisabledContext);
11
+ }
12
+ const DisabledContextProvider = DisabledContext.Provider;
13
+
14
+ exports.DisabledContextProvider = DisabledContextProvider;
15
+ exports.useContextDisabled = useContextDisabled;
3
16
  /*! 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,112 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/core"),a=require("@vef-framework/shared"),i=require("ahooks"),t=require("react");exports.useDataQuery=function useDataQuery({onFetched:r,...s}){const{useApiQuery:u,stubQueryApi:o,dataDictionaryApi:n}=e.useApiContext(),[l,c,p]=function useApi({data:e,dataDictionaryKey:i,api:r,apiParams:s,apiEnabled:u,staleTime:o,keepPreviousData:n,placeholderData:l},c,p){return t.useMemo((()=>a.isNullish(e)?a.isNullish(i)?a.isNullish(r)?[c,[],{keepPreviousData:!0,initialData:[]}]:[r,s,{enabled:u??!0,staleTime:o,keepPreviousData:n,placeholderData:l}]:[p,{...s,key:i},{enabled:u??!0,staleTime:o,keepPreviousData:n,placeholderData:l}]:[c,e,{keepPreviousData:!0,initialData:e}]),[e,i,r,c,p,s,u,o,n,l])}(s,o,n),d=u(l,c,p);i.useUnmount((()=>{Object.is(l,o)&&o.removeQueries(c)}));const{isSuccess:D,data:m,...y}=d,h=t.useMemo((()=>D&&a.isFunction(r)?r(m):m),[D,m,r]);return{...y,isSuccess:D,data:h}};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const core = require('@vef-framework/core');
7
+ const shared = require('@vef-framework/shared');
8
+ const ahooks = require('ahooks');
9
+ const react = require('react');
10
+
11
+ function useApi({
12
+ data,
13
+ dataDictionaryKey,
14
+ api,
15
+ apiParams,
16
+ apiEnabled,
17
+ staleTime,
18
+ keepPreviousData,
19
+ placeholderData
20
+ }, stubQueryApi, dataDictionaryApi) {
21
+ return react.useMemo(() => {
22
+ if (!shared.isNullish(data)) {
23
+ return [
24
+ stubQueryApi,
25
+ data,
26
+ {
27
+ keepPreviousData: true,
28
+ initialData: data
29
+ }
30
+ ];
31
+ }
32
+ if (!shared.isNullish(dataDictionaryKey)) {
33
+ return [
34
+ dataDictionaryApi,
35
+ {
36
+ ...apiParams,
37
+ key: dataDictionaryKey
38
+ },
39
+ {
40
+ enabled: apiEnabled ?? true,
41
+ staleTime,
42
+ keepPreviousData,
43
+ placeholderData
44
+ }
45
+ ];
46
+ }
47
+ if (!shared.isNullish(api)) {
48
+ return [
49
+ api,
50
+ apiParams,
51
+ {
52
+ enabled: apiEnabled ?? true,
53
+ staleTime,
54
+ keepPreviousData,
55
+ placeholderData
56
+ }
57
+ ];
58
+ }
59
+ return [
60
+ stubQueryApi,
61
+ [],
62
+ {
63
+ keepPreviousData: true,
64
+ initialData: []
65
+ }
66
+ ];
67
+ }, [
68
+ data,
69
+ dataDictionaryKey,
70
+ api,
71
+ stubQueryApi,
72
+ dataDictionaryApi,
73
+ apiParams,
74
+ apiEnabled,
75
+ staleTime,
76
+ keepPreviousData,
77
+ placeholderData
78
+ ]);
79
+ }
80
+ function useDataQuery({ onFetched, ...config }) {
81
+ const {
82
+ useApiQuery,
83
+ stubQueryApi,
84
+ dataDictionaryApi: dataDictionaryQueryApi
85
+ } = core.useApiContext();
86
+ const [api, args, options] = useApi(config, stubQueryApi, dataDictionaryQueryApi);
87
+ const result = useApiQuery(api, args, options);
88
+ ahooks.useUnmount(() => {
89
+ if (Object.is(api, stubQueryApi)) {
90
+ stubQueryApi.removeQueries(args);
91
+ }
92
+ });
93
+ const {
94
+ isSuccess,
95
+ data: rawData,
96
+ ...rest
97
+ } = result;
98
+ const data = react.useMemo(() => {
99
+ if (isSuccess && shared.isFunction(onFetched)) {
100
+ return onFetched(rawData);
101
+ }
102
+ return rawData;
103
+ }, [isSuccess, rawData, onFetched]);
104
+ return {
105
+ ...rest,
106
+ isSuccess,
107
+ data
108
+ };
109
+ }
110
+
111
+ exports.useDataQuery = useDataQuery;
3
112
  /*! 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,15 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./use-deep-memo.cjs");exports.useDeepCallback=function useDeepCallback(t,s){const u=r.useDeepMemo((()=>s),s);return e.useCallback(t,u)};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const react = require('react');
7
+ const useDeepMemo = require('./use-deep-memo.cjs');
8
+
9
+ function useDeepCallback(callback, dependencies) {
10
+ const memoizedDependencies = useDeepMemo.useDeepMemo(() => dependencies, dependencies);
11
+ return react.useCallback(callback, memoizedDependencies);
12
+ }
13
+
14
+ exports.useDeepCallback = useDeepCallback;
3
15
  /*! 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,23 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/shared"),r=require("react");exports.useDeepMemo=function useDeepMemo(t,u){const n=r.useRef(),o=r.useRef(0);return void 0!==n.current&&function isEqual(r,t){return r.length===t.length&&r.every(((r,u)=>e.isDeepEqual(r,t[u])))}(u,n.current)||(o.current+=1),n.current=u,r.useMemo(t,[o.current])};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const shared = require('@vef-framework/shared');
7
+ const react = require('react');
8
+
9
+ function useDeepMemo(factory, dependencies) {
10
+ const lastDependencies = react.useRef();
11
+ const signal = react.useRef(0);
12
+ if (lastDependencies.current === void 0 || !isEqual(dependencies, lastDependencies.current)) {
13
+ signal.current += 1;
14
+ }
15
+ lastDependencies.current = dependencies;
16
+ return react.useMemo(factory, [signal.current]);
17
+ }
18
+ function isEqual(one, another) {
19
+ return one.length === another.length && one.every((value, index) => shared.isDeepEqual(value, another[index]));
20
+ }
21
+
22
+ exports.useDeepMemo = useDeepMemo;
3
23
  /*! 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,18 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/shared"),r=require("react");exports.useDeepSelector=function useDeepSelector(t){const u=r.useRef();return r=>{const o=t(r);return e.isDeepEqual(u.current,o)?u.current:u.current=o}};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const shared = require('@vef-framework/shared');
7
+ const react = require('react');
8
+
9
+ function useDeepSelector(selector) {
10
+ const prevSelectedState = react.useRef();
11
+ return (state) => {
12
+ const nextSelectedState = selector(state);
13
+ return shared.isDeepEqual(prevSelectedState.current, nextSelectedState) ? prevSelectedState.current : prevSelectedState.current = nextSelectedState;
14
+ };
15
+ }
16
+
17
+ exports.useDeepSelector = useDeepSelector;
3
18
  /*! 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,107 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/core"),s=require("@vef-framework/shared"),a=require("ahooks"),r=require("react"),i=require("./use-shallow-memo.cjs");exports.useFallbackOptions=function useFallbackOptions(t,{fallbackOptionsApi:o,fallbackOptionsApiParams:u,valuesKey:l,resolveFallbackOptions:n}){const{useApiQuery:p,stubQueryApi:c,asyncFnQueryApi:k}=e.useApiContext(),[f,b,v]=function useApi(e,{fallbackOptionsApi:a,fallbackOptionsApiParams:t,valuesKey:o,resolveFallbackOptions:u},l,n){const p=r.useId();return i.useShallowMemo((()=>{if(e.length>0){if(s.isFunction(u))return[n,{key:p,args:[e],fn:u},{keepPreviousData:!0}];if(a){const s={...t,[o??"ids"]:e};return[a,s,{keepPreviousData:!0}]}}return[l,[],{keepPreviousData:!0,initialData:[]}]}),[u,a,l,p,e,n,t,o])}(t,{fallbackOptionsApi:o,fallbackOptionsApiParams:u,valuesKey:l,resolveFallbackOptions:n},c,k),O=p(f,b,v);return a.useUnmount((()=>{Object.is(f,c)&&c.removeQueries(b),Object.is(f,k)&&k.removeQueries(b)})),O};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const core = require('@vef-framework/core');
7
+ const shared = require('@vef-framework/shared');
8
+ const ahooks = require('ahooks');
9
+ const react = require('react');
10
+ const useShallowMemo = require('./use-shallow-memo.cjs');
11
+
12
+ function useApi(missingOptionValues, {
13
+ fallbackOptionsApi,
14
+ fallbackOptionsApiParams,
15
+ valuesKey,
16
+ resolveFallbackOptions
17
+ }, stubQueryApi, asyncFnQueryApi) {
18
+ const uniqueId = react.useId();
19
+ return useShallowMemo.useShallowMemo(() => {
20
+ if (missingOptionValues.length > 0) {
21
+ if (shared.isFunction(resolveFallbackOptions)) {
22
+ const params = {
23
+ key: uniqueId,
24
+ args: [missingOptionValues],
25
+ fn: resolveFallbackOptions
26
+ };
27
+ return [
28
+ asyncFnQueryApi,
29
+ params,
30
+ {
31
+ keepPreviousData: true
32
+ }
33
+ ];
34
+ }
35
+ if (fallbackOptionsApi) {
36
+ const params = {
37
+ ...fallbackOptionsApiParams,
38
+ [valuesKey ?? "ids"]: missingOptionValues
39
+ };
40
+ return [
41
+ fallbackOptionsApi,
42
+ params,
43
+ {
44
+ keepPreviousData: true
45
+ }
46
+ ];
47
+ }
48
+ }
49
+ return [
50
+ stubQueryApi,
51
+ [],
52
+ {
53
+ keepPreviousData: true,
54
+ initialData: []
55
+ }
56
+ ];
57
+ }, [
58
+ resolveFallbackOptions,
59
+ fallbackOptionsApi,
60
+ stubQueryApi,
61
+ uniqueId,
62
+ missingOptionValues,
63
+ asyncFnQueryApi,
64
+ fallbackOptionsApiParams,
65
+ valuesKey
66
+ ]);
67
+ }
68
+ function useFallbackOptions(missingOptionValues, {
69
+ fallbackOptionsApi,
70
+ fallbackOptionsApiParams,
71
+ valuesKey,
72
+ resolveFallbackOptions
73
+ }) {
74
+ const {
75
+ useApiQuery,
76
+ stubQueryApi,
77
+ asyncFnQueryApi
78
+ } = core.useApiContext();
79
+ const [
80
+ api,
81
+ params,
82
+ options
83
+ ] = useApi(
84
+ missingOptionValues,
85
+ {
86
+ fallbackOptionsApi,
87
+ fallbackOptionsApiParams,
88
+ valuesKey,
89
+ resolveFallbackOptions
90
+ },
91
+ stubQueryApi,
92
+ asyncFnQueryApi
93
+ );
94
+ const result = useApiQuery(api, params, options);
95
+ ahooks.useUnmount(() => {
96
+ if (Object.is(api, stubQueryApi)) {
97
+ stubQueryApi.removeQueries(params);
98
+ }
99
+ if (Object.is(api, asyncFnQueryApi)) {
100
+ asyncFnQueryApi.removeQueries(params);
101
+ }
102
+ });
103
+ return result;
104
+ }
105
+
106
+ exports.useFallbackOptions = useFallbackOptions;
3
107
  /*! 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,40 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),r=require("./use-theme-tokens.cjs");exports.useGapSizeNormalizer=function useGapSizeNormalizer(){const{paddingXS:i,paddingSM:a,padding:t,paddingMD:n,paddingLG:s}=r.useThemeTokens();return e.useCallback((e=>"tiny"===e?i:"small"===e?a:"medium"===e?t:"large"===e?n:"huge"===e?s:e),[i,a,t,n,s])};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const react = require('react');
7
+ const useThemeTokens = require('./use-theme-tokens.cjs');
8
+
9
+ function useGapSizeNormalizer() {
10
+ const {
11
+ paddingXS,
12
+ paddingSM,
13
+ padding,
14
+ paddingMD,
15
+ paddingLG
16
+ } = useThemeTokens.useThemeTokens();
17
+ return react.useCallback((gap) => {
18
+ if (gap === "tiny") {
19
+ return paddingXS;
20
+ } else if (gap === "small") {
21
+ return paddingSM;
22
+ } else if (gap === "medium") {
23
+ return padding;
24
+ } else if (gap === "large") {
25
+ return paddingMD;
26
+ } else if (gap === "huge") {
27
+ return paddingLG;
28
+ }
29
+ return gap;
30
+ }, [
31
+ paddingXS,
32
+ paddingSM,
33
+ padding,
34
+ paddingMD,
35
+ paddingLG
36
+ ]);
37
+ }
38
+
39
+ exports.useGapSizeNormalizer = useGapSizeNormalizer;
3
40
  /*! 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.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-gap-size-normalizer.cjs");exports.useNormalizedGapSize=function useNormalizedGapSize(r){return e.useGapSizeNormalizer()(r)};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const useGapSizeNormalizer = require('./use-gap-size-normalizer.cjs');
7
+
8
+ function useNormalizedGapSize(gap) {
9
+ const normalize = useGapSizeNormalizer.useGapSizeNormalizer();
10
+ return normalize(gap);
11
+ }
12
+
13
+ exports.useNormalizedGapSize = useNormalizedGapSize;
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,50 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("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}}exports.normalizeMenuItem=normalizeMenuItem,exports.useNormalizedMenuItems=function useNormalizedMenuItems(t){return e.useMemo((()=>t.map(normalizeMenuItem)),[t])};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const react = require('react');
7
+
8
+ function normalizeMenuItem(item) {
9
+ if (item.type === "item") {
10
+ return {
11
+ type: "item",
12
+ key: item.key,
13
+ label: item.label,
14
+ disabled: item.disabled,
15
+ icon: item.icon,
16
+ extra: item.extra
17
+ };
18
+ } else if (item.type === "submenu") {
19
+ return {
20
+ type: "submenu",
21
+ key: item.key,
22
+ label: item.label,
23
+ disabled: item.disabled,
24
+ icon: item.icon,
25
+ children: item.children.map(normalizeMenuItem)
26
+ };
27
+ } else if (item.type === "group") {
28
+ return {
29
+ type: "group",
30
+ key: item.key,
31
+ label: item.label,
32
+ children: item.children.map(normalizeMenuItem)
33
+ };
34
+ } else {
35
+ return {
36
+ type: "divider",
37
+ key: item.key
38
+ };
39
+ }
40
+ }
41
+ function useNormalizedMenuItems(items) {
42
+ return react.useMemo(
43
+ () => items.map(normalizeMenuItem),
44
+ [items]
45
+ );
46
+ }
47
+
48
+ exports.normalizeMenuItem = normalizeMenuItem;
49
+ exports.useNormalizedMenuItems = useNormalizedMenuItems;
3
50
  /*! 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,106 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/shared"),i=require("react");exports.useNormalizedDataOptions=function useNormalizedDataOptions(r,{labelKey:t="label",valueKey:n="value",childrenKey:o="children",descriptionKey:s="description",disabledKey:l="disabled",defaultToFirst:a=!1},{isTree:d=!1,isGrouped:u=!1,parsePinyin:c=!1,selectedOptionValues:h=[]}={}){return i.useMemo((()=>{const i=new Set(h),p=!d&&u,normalizeOption=(r,a=!1)=>{const d=r[t];if(e.isNullish(d)){if("label"===t)throw new e.VefError(-10001,"The label value of the option is required.");throw new e.VefError(-10001,`The label value pointed by '${t}' of the option is required.`)}const u=r[n];if(e.isNullish(u)){if("value"===n)throw new e.VefError(-10002,"The value of the option is required.");throw new e.VefError(-10002,`The value pointed by '${n}' of the option is required.`)}const h=r[o],f=r[s],y=r[l]??!1,b={...r,label:d,value:u,children:h,description:f,disabled:y};if(c){const{labelText:i,descriptionText:r}=b;(e.isString(d)||e.isString(i))&&(b.labelPinyin=e.parsePinyinFirstLetter(e.isString(d)?d:i).join("")),(e.isString(f)||e.isString(r))&&(b.descriptionPinyin=e.parsePinyinFirstLetter(e.isString(f)?f:r).join(""))}return a&&p||!i.has(u)||i.delete(u),e.isArray(b.children)&&(b.children=b.children.map((e=>normalizeOption(e)))),b},f=r.map((e=>normalizeOption(e,!0))),y=Array.from(i);if(!a)return[f,y];if(p){const i=f.find((i=>e.isArray(i.children)&&i.children.length>0));return[f,y,i?.children?.[0]]}return[f,y,f[0]]}),[o,a,s,l,u,d,t,r,c,n])};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const shared = require('@vef-framework/shared');
7
+ const react = require('react');
8
+
9
+ function useNormalizedDataOptions(options, {
10
+ labelKey = "label",
11
+ valueKey = "value",
12
+ childrenKey = "children",
13
+ descriptionKey = "description",
14
+ disabledKey = "disabled",
15
+ defaultToFirst = false
16
+ }, {
17
+ isTree = false,
18
+ isGrouped = false,
19
+ parsePinyin = false,
20
+ selectedOptionValues = []
21
+ } = {}) {
22
+ return react.useMemo(() => {
23
+ const selectedOptionValuesSet = new Set(selectedOptionValues);
24
+ const isGroupedOptions = !isTree && isGrouped;
25
+ const normalizeOption = (option, isTopLevel = false) => {
26
+ const label = option[labelKey];
27
+ if (shared.isNullish(label)) {
28
+ if (labelKey === "label") {
29
+ throw new shared.VefError(-10001, `The label value of the option is required.`);
30
+ }
31
+ throw new shared.VefError(-10001, `The label value pointed by '${labelKey}' of the option is required.`);
32
+ }
33
+ const value = option[valueKey];
34
+ if (shared.isNullish(value)) {
35
+ if (valueKey === "value") {
36
+ throw new shared.VefError(-10002, `The value of the option is required.`);
37
+ }
38
+ throw new shared.VefError(-10002, `The value pointed by '${valueKey}' of the option is required.`);
39
+ }
40
+ const children = option[childrenKey];
41
+ const description = option[descriptionKey];
42
+ const disabled = option[disabledKey] ?? false;
43
+ const normalizedOption = {
44
+ ...option,
45
+ label,
46
+ value,
47
+ children,
48
+ description,
49
+ disabled
50
+ };
51
+ if (parsePinyin) {
52
+ const { labelText, descriptionText } = normalizedOption;
53
+ if (shared.isString(label) || shared.isString(labelText)) {
54
+ normalizedOption.labelPinyin = shared.parsePinyinFirstLetter(
55
+ shared.isString(label) ? label : labelText
56
+ ).join("");
57
+ }
58
+ if (shared.isString(description) || shared.isString(descriptionText)) {
59
+ normalizedOption.descriptionPinyin = shared.parsePinyinFirstLetter(
60
+ shared.isString(description) ? description : descriptionText
61
+ ).join("");
62
+ }
63
+ }
64
+ if ((!isTopLevel || !isGroupedOptions) && selectedOptionValuesSet.has(value)) {
65
+ selectedOptionValuesSet.delete(value);
66
+ }
67
+ if (shared.isArray(normalizedOption.children)) {
68
+ normalizedOption.children = normalizedOption.children.map((option2) => normalizeOption(option2));
69
+ }
70
+ return normalizedOption;
71
+ };
72
+ const normalizedOptions = options.map((option) => normalizeOption(option, true));
73
+ const missingOptionValues = Array.from(selectedOptionValuesSet);
74
+ if (!defaultToFirst) {
75
+ return [normalizedOptions, missingOptionValues];
76
+ }
77
+ if (isGroupedOptions) {
78
+ const firstNonEmptyGroupOption = normalizedOptions.find((item) => shared.isArray(item.children) && item.children.length > 0);
79
+ return [
80
+ normalizedOptions,
81
+ missingOptionValues,
82
+ firstNonEmptyGroupOption?.children?.[0]
83
+ ];
84
+ }
85
+ return [
86
+ normalizedOptions,
87
+ missingOptionValues,
88
+ normalizedOptions[0]
89
+ ];
90
+ }, [
91
+ childrenKey,
92
+ defaultToFirst,
93
+ descriptionKey,
94
+ disabledKey,
95
+ isGrouped,
96
+ isTree,
97
+ labelKey,
98
+ options,
99
+ parsePinyin,
100
+ // selectedOptionValues,
101
+ valueKey
102
+ ]);
103
+ }
104
+
105
+ exports.useNormalizedDataOptions = useNormalizedDataOptions;
3
106
  /*! 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,22 @@
1
- /*! VefFramework version: 1.0.98, build time: 2025-03-07T07:45:28.296Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/shared"),i=require("react");exports.useOptionFilter=function useOptionFilter(t,n){return i.useMemo((()=>{if(t)return!n&&((i,t)=>(e.isString(t.label)&&t.label.includes(i)||e.isString(t.labelText)&&t.labelText.includes(i)||t.labelPinyin?.includes(i)||t.value.includes(i)||e.isString(t.description)&&t.description.includes(i)||e.isString(t.descriptionText)&&t.descriptionText.includes(i)||t.descriptionPinyin?.includes(i))??!1)}),[t,n])};
1
+ /*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
+
6
+ const shared = require('@vef-framework/shared');
7
+ const react = require('react');
8
+
9
+ function useOptionFilter(filterable, filterFromRemote) {
10
+ return react.useMemo(() => {
11
+ if (!filterable) {
12
+ return;
13
+ }
14
+ if (filterFromRemote) {
15
+ return false;
16
+ }
17
+ return (filterValue, option) => (shared.isString(option.label) && option.label.includes(filterValue) || shared.isString(option.labelText) && option.labelText.includes(filterValue) || option.labelPinyin?.includes(filterValue) || option.value.includes(filterValue) || shared.isString(option.description) && option.description.includes(filterValue) || shared.isString(option.descriptionText) && option.descriptionText.includes(filterValue) || option.descriptionPinyin?.includes(filterValue)) ?? false;
18
+ }, [filterable, filterFromRemote]);
19
+ }
20
+
21
+ exports.useOptionFilter = useOptionFilter;
3
22
  /*! 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 */