@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
@@ -1,3 +1,71 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-data-query.cjs"),i=require("./use-fallback-options.cjs"),a=require("./use-normalized-options.cjs"),l=require("./use-remote-filter.cjs");exports.useComputedOptions=function({labelField:s,valueField:o,descriptionField:t,childrenField:r,disabledField:d,defaultToFirst:n,filterable:p=!1,filterFromRemote:u=!1,keywordKey:c="keyword",valuesKey:F="ids",fallbackOptionsApi:b,fallbackOptionsApiParams:O,resolveFallbackOptions:f,isGrouped:m=!1,selectedOptionValues:k,apiParams:y,...g}){const[v,P]=l.useRemoteFilter(p&&u,y,c),{data:j,isLoading:q}=e.useDataQuery({apiParams:v,...g}),[A,K,L]=a.useNormalizedDataOptions(j??[],{labelField:s,valueField:o,descriptionField:t,childrenField:r,disabledField:d,defaultToFirst:n},{isGrouped:m,parsePinyin:p&&!u,selectedOptionValues:k}),{data:h,isLoading:w}=i.useFallbackOptions(K,{fallbackOptionsApi:b??g.api,fallbackOptionsApiParams:O,valuesKey:F,resolveFallbackOptions:f});return{onFilterKeywordChange:P,isLoading:q,normalizedOptions:A,defaultOption:L,fallbackOptions:h,isFallbackOptionsLoading:w}};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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
+ labelField,
13
+ valueField,
14
+ descriptionField,
15
+ childrenField,
16
+ disabledField,
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
+ labelField,
39
+ valueField,
40
+ descriptionField,
41
+ childrenField,
42
+ disabledField,
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.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext(!1);const r=t.Provider;exports.DisabledContextProvider=r,exports.useContextDisabled=function(){return e.useContext(t)};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, 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({onFetched:r,...s}){const{useApiQuery:u,stubQueryApi:o,dataDictionaryApi:n}=e.useApiContext(),[l,c,p]=function({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,...h}=d,k=t.useMemo((()=>D&&a.isFunction(r)?r(m):m),[D,m,r]);return{...h,isSuccess:D,data:k}};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, 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(t,o){const s=r.useDeepMemo((()=>o),o);return e.useCallback(t,s)};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, 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(t,u){const n=r.useRef(),o=r.useRef(0);var s,c;return void 0!==n.current&&(s=u,c=n.current,s.length===c.length&&s.every(((r,t)=>e.isDeepEqual(r,c[t]))))||(o.current+=1),n.current=u,r.useMemo(t,[o.current])};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, 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(t){const u=r.useRef();return r=>{const n=t(r);return e.isDeepEqual(u.current,n)?u.current:u.current=n}};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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,104 @@
1
- /*! VefFramework version: 1.0.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@vef-framework/core"),r=require("@vef-framework/shared"),a=require("ahooks"),s=require("react");exports.useFallbackOptions=function(i,{fallbackOptionsApi:t,fallbackOptionsApiParams:o,valuesKey:n,resolveFallbackOptions:u}){const{useApiQuery:l,stubQueryApi:p,asyncFnQueryApi:c}=e.useApiContext(),[k,f,b]=function(e,{fallbackOptionsApi:a,fallbackOptionsApiParams:i,valuesKey:t,resolveFallbackOptions:o},n,u){const l=s.useId();return s.useMemo((()=>{if(r.isFunction(o))return[u,{key:l,args:[e],fn:o},{keepPreviousData:!0}];if(a){const r={...i,[t??"ids"]:e};return[a,r,{keepPreviousData:!0}]}return[n,[],{keepPreviousData:!0,initialData:[]}]}),[o,a,n,l,e,u,i,t])}(i,{fallbackOptionsApi:t,fallbackOptionsApiParams:o,valuesKey:n,resolveFallbackOptions:u},p,c),v=l(k,f,b);return a.useUnmount((()=>{Object.is(k,p)&&p.removeQueries(f),Object.is(k,c)&&c.removeQueries(f)})),v};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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(missingOptionValues, {
12
+ fallbackOptionsApi,
13
+ fallbackOptionsApiParams,
14
+ valuesKey,
15
+ resolveFallbackOptions
16
+ }, stubQueryApi, asyncFnQueryApi) {
17
+ const uniqueId = react.useId();
18
+ return react.useMemo(() => {
19
+ if (shared.isFunction(resolveFallbackOptions)) {
20
+ const params = {
21
+ key: uniqueId,
22
+ args: [missingOptionValues],
23
+ fn: resolveFallbackOptions
24
+ };
25
+ return [
26
+ asyncFnQueryApi,
27
+ params,
28
+ {
29
+ keepPreviousData: true
30
+ }
31
+ ];
32
+ }
33
+ if (fallbackOptionsApi) {
34
+ const params = {
35
+ ...fallbackOptionsApiParams,
36
+ [valuesKey ?? "ids"]: missingOptionValues
37
+ };
38
+ return [
39
+ fallbackOptionsApi,
40
+ params,
41
+ {
42
+ keepPreviousData: true
43
+ }
44
+ ];
45
+ }
46
+ return [
47
+ stubQueryApi,
48
+ [],
49
+ {
50
+ keepPreviousData: true,
51
+ initialData: []
52
+ }
53
+ ];
54
+ }, [
55
+ resolveFallbackOptions,
56
+ fallbackOptionsApi,
57
+ stubQueryApi,
58
+ uniqueId,
59
+ missingOptionValues,
60
+ asyncFnQueryApi,
61
+ fallbackOptionsApiParams,
62
+ valuesKey
63
+ ]);
64
+ }
65
+ function useFallbackOptions(missingOptionValues, {
66
+ fallbackOptionsApi,
67
+ fallbackOptionsApiParams,
68
+ valuesKey,
69
+ resolveFallbackOptions
70
+ }) {
71
+ const {
72
+ useApiQuery,
73
+ stubQueryApi,
74
+ asyncFnQueryApi
75
+ } = core.useApiContext();
76
+ const [
77
+ api,
78
+ params,
79
+ options
80
+ ] = useApi(
81
+ missingOptionValues,
82
+ {
83
+ fallbackOptionsApi,
84
+ fallbackOptionsApiParams,
85
+ valuesKey,
86
+ resolveFallbackOptions
87
+ },
88
+ stubQueryApi,
89
+ asyncFnQueryApi
90
+ );
91
+ const result = useApiQuery(api, params, options);
92
+ ahooks.useUnmount(() => {
93
+ if (Object.is(api, stubQueryApi)) {
94
+ stubQueryApi.removeQueries(params);
95
+ }
96
+ if (Object.is(api, asyncFnQueryApi)) {
97
+ asyncFnQueryApi.removeQueries(params);
98
+ }
99
+ });
100
+ return result;
101
+ }
102
+
103
+ exports.useFallbackOptions = useFallbackOptions;
3
104
  /*! 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.62, build time: 2025-01-09T07:31:10.207Z, 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(){const{paddingXS:t,paddingSM:i,padding:n,paddingMD:a,paddingLG:s}=r.useThemeTokens();return e.useCallback((e=>"tiny"===e?t:"small"===e?i:"medium"===e?n:"large"===e?a:"huge"===e?s:e),[t,i,n,a,s])};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./use-gap-size-normalizer.cjs");exports.useNormalizedGapSize=function(r){return e.useGapSizeNormalizer()(r)};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, made by Venus. */
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");function t(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(t)}:"group"===e.type?{type:"group",key:e.key,label:e.label,children:e.children.map(t)}:{type:"divider",key:e.key}}exports.normalizeMenuItem=t,exports.useNormalizedMenuItems=function(l){return e.useMemo((()=>l.map(t)),[l])};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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.62, build time: 2025-01-09T07:31:10.207Z, 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(r,{labelField:t="label",valueField:n="value",childrenField:l="children",descriptionField:o="description",disabledField:s="disabled",defaultToFirst:a=!1},{isTree:d=!1,isGrouped:u=!1,parsePinyin:c=!1,selectedOptionValues:h=[]}={}){return i.useMemo((()=>{const i=new Set(h),f=!d&&u,p=(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 value of the option is required.");throw new e.VefError(-10002,`The value value pointed by '${n}' of the option is required.`)}const h=r[l],b=r[o],v=r[s]??!1,y={...r,label:d,value:u,children:h,description:b,disabled:v};if(c){const{labelText:i,descriptionText:r}=y;(e.isString(d)||e.isString(i))&&(y.labelPinyin=e.parsePinyinFirstLetter(e.isString(d)?d:i).join("")),(e.isString(b)||e.isString(r))&&(y.descriptionPinyin=e.parsePinyinFirstLetter(e.isString(b)?b:r).join(""))}return a&&f||!i.has(u)||i.delete(u),e.isArray(y.children)&&(y.children=y.children.map((e=>p(e)))),y},b=Array.from(i),v=r.map((e=>p(e,!0)));if(!a)return[v,b];if(f){const i=v.find((i=>e.isArray(i.children)&&i.children.length>0));return[v,b,i?.children?.[0]]}return[v,b,v[0]]}),[l,a,o,s,u,d,t,r,c,h,n])};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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
+ labelField = "label",
11
+ valueField = "value",
12
+ childrenField = "children",
13
+ descriptionField = "description",
14
+ disabledField = "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[labelField];
27
+ if (shared.isNullish(label)) {
28
+ if (labelField === "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 '${labelField}' of the option is required.`);
32
+ }
33
+ const value = option[valueField];
34
+ if (shared.isNullish(value)) {
35
+ if (valueField === "value") {
36
+ throw new shared.VefError(-10002, `The value value of the option is required.`);
37
+ }
38
+ throw new shared.VefError(-10002, `The value value pointed by '${valueField}' of the option is required.`);
39
+ }
40
+ const children = option[childrenField];
41
+ const description = option[descriptionField];
42
+ const disabled = option[disabledField] ?? 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 missingOptionValues = Array.from(selectedOptionValuesSet);
73
+ const normalizedOptions = options.map((option) => normalizeOption(option, true));
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
+ childrenField,
92
+ defaultToFirst,
93
+ descriptionField,
94
+ disabledField,
95
+ isGrouped,
96
+ isTree,
97
+ labelField,
98
+ options,
99
+ parsePinyin,
100
+ selectedOptionValues,
101
+ valueField
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.62, build time: 2025-01-09T07:31:10.207Z, 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(n,r){return i.useMemo((()=>{if(n)return!r&&((i,n)=>(e.isString(n.label)&&n.label.includes(i)||e.isString(n.labelText)&&n.labelText.includes(i)||n.labelPinyin?.includes(i)||n.value.includes(i)||e.isString(n.description)&&n.description.includes(i)||e.isString(n.descriptionText)&&n.descriptionText.includes(i)||n.descriptionPinyin?.includes(i))??!1)}),[n,r])};
1
+ /*! VefFramework version: 1.0.64, build time: 2025-01-10T01:26:01.309Z, 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 */