@vef-framework/hooks 1.0.64 → 1.0.66

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 +2 -27
  2. package/es/lib.js +2 -3
  3. package/es/use-authorized-items.js +2 -23
  4. package/es/use-color-tokens.js +2 -29
  5. package/es/use-computed-action-buttons.js +2 -42
  6. package/es/use-computed-options.js +2 -66
  7. package/es/use-context-disabled.js +2 -10
  8. package/es/use-data-query.js +2 -107
  9. package/es/use-deep-callback.js +2 -10
  10. package/es/use-deep-memo.js +2 -18
  11. package/es/use-deep-selector.js +2 -13
  12. package/es/use-fallback-options.js +2 -99
  13. package/es/use-gap-size-normalizer.js +2 -35
  14. package/es/use-normalized-gap-size.js +2 -9
  15. package/es/use-normalized-menu-items.js +2 -44
  16. package/es/use-normalized-options.js +2 -101
  17. package/es/use-option-filter.js +2 -17
  18. package/es/use-remote-filter.js +2 -36
  19. package/es/use-shallow-callback.js +2 -10
  20. package/es/use-shallow-memo.js +2 -18
  21. package/es/use-shallow-selector.js +2 -13
  22. package/es/use-singleton.js +2 -13
  23. package/es/use-theme-tokens.js +2 -10
  24. package/es/use-transient-store.js +2 -31
  25. package/es/use-window-size.js +2 -18
  26. package/lib/index.cjs +2 -109
  27. package/lib/lib.cjs +2 -58
  28. package/lib/use-authorized-items.cjs +2 -27
  29. package/lib/use-color-tokens.cjs +2 -35
  30. package/lib/use-computed-action-buttons.cjs +2 -46
  31. package/lib/use-computed-options.cjs +2 -70
  32. package/lib/use-context-disabled.cjs +2 -15
  33. package/lib/use-data-query.cjs +2 -111
  34. package/lib/use-deep-callback.cjs +2 -14
  35. package/lib/use-deep-memo.cjs +2 -22
  36. package/lib/use-deep-selector.cjs +2 -17
  37. package/lib/use-fallback-options.cjs +2 -103
  38. package/lib/use-gap-size-normalizer.cjs +2 -39
  39. package/lib/use-normalized-gap-size.cjs +2 -13
  40. package/lib/use-normalized-menu-items.cjs +2 -49
  41. package/lib/use-normalized-options.cjs +2 -105
  42. package/lib/use-option-filter.cjs +2 -21
  43. package/lib/use-remote-filter.cjs +2 -40
  44. package/lib/use-shallow-callback.cjs +2 -14
  45. package/lib/use-shallow-memo.cjs +2 -22
  46. package/lib/use-shallow-selector.cjs +2 -17
  47. package/lib/use-singleton.cjs +2 -17
  48. package/lib/use-theme-tokens.cjs +2 -14
  49. package/lib/use-transient-store.cjs +2 -35
  50. package/lib/use-window-size.cjs +2 -22
  51. package/package.json +3 -3
@@ -1,71 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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 useComputedOptions({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}};
71
3
  /*! 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,16 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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)};
16
3
  /*! 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,112 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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}};
112
3
  /*! 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,15 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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)};
15
3
  /*! 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,23 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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])};
23
3
  /*! 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,18 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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}};
18
3
  /*! 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,104 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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");exports.useFallbackOptions=function useFallbackOptions(i,{fallbackOptionsApi:t,fallbackOptionsApiParams:o,valuesKey:u,resolveFallbackOptions:n}){const{useApiQuery:l,stubQueryApi:p,asyncFnQueryApi:c}=e.useApiContext(),[k,b,f]=function useApi(e,{fallbackOptionsApi:a,fallbackOptionsApiParams:i,valuesKey:t,resolveFallbackOptions:o},u,n){const l=r.useId();return r.useMemo((()=>{if(s.isFunction(o))return[n,{key:l,args:[e],fn:o},{keepPreviousData:!0}];if(a){const s={...i,[t??"ids"]:e};return[a,s,{keepPreviousData:!0}]}return[u,[],{keepPreviousData:!0,initialData:[]}]}),[o,a,u,l,e,n,i,t])}(i,{fallbackOptionsApi:t,fallbackOptionsApiParams:o,valuesKey:u,resolveFallbackOptions:n},p,c),v=l(k,b,f);return a.useUnmount((()=>{Object.is(k,p)&&p.removeQueries(b),Object.is(k,c)&&c.removeQueries(b)})),v};
104
3
  /*! 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,40 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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])};
40
3
  /*! 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,14 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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)};
14
3
  /*! 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,50 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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])};
50
3
  /*! 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,106 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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,{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),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 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],f=r[o],b=r[s]??!1,v={...r,label:d,value:u,children:h,description:f,disabled:b};if(c){const{labelText:i,descriptionText:r}=v;(e.isString(d)||e.isString(i))&&(v.labelPinyin=e.parsePinyinFirstLetter(e.isString(d)?d:i).join("")),(e.isString(f)||e.isString(r))&&(v.descriptionPinyin=e.parsePinyinFirstLetter(e.isString(f)?f:r).join(""))}return a&&p||!i.has(u)||i.delete(u),e.isArray(v.children)&&(v.children=v.children.map((e=>normalizeOption(e)))),v},f=Array.from(i),b=r.map((e=>normalizeOption(e,!0)));if(!a)return[b,f];if(p){const i=b.find((i=>e.isArray(i.children)&&i.children.length>0));return[b,f,i?.children?.[0]]}return[b,f,b[0]]}),[l,a,o,s,u,d,t,r,c,h,n])};
106
3
  /*! 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,22 +1,3 @@
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;
1
+ /*! VefFramework version: 1.0.66, build time: 2025-01-10T02:50:16.067Z, 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])};
22
3
  /*! 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 */