@vef-framework/hooks 1.0.101 → 1.0.102

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 +1 -28
  2. package/es/lib.js +1 -4
  3. package/es/use-authorized-items.js +1 -24
  4. package/es/use-color-tokens.js +1 -30
  5. package/es/use-computed-action-buttons.js +1 -43
  6. package/es/use-computed-options.js +1 -67
  7. package/es/use-context-disabled.js +1 -11
  8. package/es/use-data-query.js +1 -108
  9. package/es/use-deep-callback.js +1 -11
  10. package/es/use-deep-memo.js +1 -19
  11. package/es/use-deep-selector.js +1 -14
  12. package/es/use-fallback-options.js +1 -103
  13. package/es/use-gap-size-normalizer.js +1 -36
  14. package/es/use-normalized-gap-size.js +1 -10
  15. package/es/use-normalized-menu-items.js +1 -45
  16. package/es/use-normalized-options.js +1 -102
  17. package/es/use-option-filter.js +1 -18
  18. package/es/use-remote-filter.js +1 -37
  19. package/es/use-shallow-callback.js +1 -11
  20. package/es/use-shallow-memo.js +1 -19
  21. package/es/use-shallow-selector.js +1 -14
  22. package/es/use-singleton.js +1 -14
  23. package/es/use-theme-tokens.js +1 -11
  24. package/es/use-transient-store.js +1 -32
  25. package/es/use-window-size.js +1 -19
  26. package/lib/index.cjs +1 -110
  27. package/lib/lib.cjs +1 -59
  28. package/lib/use-authorized-items.cjs +1 -28
  29. package/lib/use-color-tokens.cjs +1 -36
  30. package/lib/use-computed-action-buttons.cjs +1 -47
  31. package/lib/use-computed-options.cjs +1 -71
  32. package/lib/use-context-disabled.cjs +1 -16
  33. package/lib/use-data-query.cjs +1 -112
  34. package/lib/use-deep-callback.cjs +1 -15
  35. package/lib/use-deep-memo.cjs +1 -23
  36. package/lib/use-deep-selector.cjs +1 -18
  37. package/lib/use-fallback-options.cjs +1 -107
  38. package/lib/use-gap-size-normalizer.cjs +1 -40
  39. package/lib/use-normalized-gap-size.cjs +1 -14
  40. package/lib/use-normalized-menu-items.cjs +1 -50
  41. package/lib/use-normalized-options.cjs +1 -106
  42. package/lib/use-option-filter.cjs +1 -22
  43. package/lib/use-remote-filter.cjs +1 -41
  44. package/lib/use-shallow-callback.cjs +1 -15
  45. package/lib/use-shallow-memo.cjs +1 -23
  46. package/lib/use-shallow-selector.cjs +1 -18
  47. package/lib/use-singleton.cjs +1 -18
  48. package/lib/use-theme-tokens.cjs +1 -15
  49. package/lib/use-transient-store.cjs +1 -36
  50. package/lib/use-window-size.cjs +1 -23
  51. package/package.json +3 -3
@@ -1,71 +1 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const useDataQuery=require("./use-data-query.cjs"),useFallbackOptions=require("./use-fallback-options.cjs"),useNormalizedOptions=require("./use-normalized-options.cjs"),useRemoteFilter=require("./use-remote-filter.cjs");function useComputedOptions({labelKey,valueKey,descriptionKey,childrenKey,disabledKey,defaultToFirst,filterable=!1,filterFromRemote=!1,keywordKey="keyword",valuesKey="ids",fallbackOptionsApi,fallbackOptionsApiParams,resolveFallbackOptions,isGrouped=!1,selectedOptionValues,apiParams,...queryConfig}){const[mergedApiParams,onFilterKeywordChange]=useRemoteFilter.useRemoteFilter(filterable&&filterFromRemote,apiParams,keywordKey),{data:options,isLoading}=useDataQuery.useDataQuery({apiParams:mergedApiParams,...queryConfig}),[normalizedOptions,missingOptionValues,defaultOption]=useNormalizedOptions.useNormalizedDataOptions(options??[],{labelKey,valueKey,descriptionKey,childrenKey,disabledKey,defaultToFirst},{isGrouped,parsePinyin:filterable&&!filterFromRemote,selectedOptionValues}),{data:fallbackOptions,isLoading:isFallbackOptionsLoading}=useFallbackOptions.useFallbackOptions(missingOptionValues,{fallbackOptionsApi:fallbackOptionsApi??queryConfig.api,fallbackOptionsApiParams,valuesKey,resolveFallbackOptions});return{onFilterKeywordChange,isLoading,normalizedOptions,defaultOption,fallbackOptions,isFallbackOptionsLoading}}exports.useComputedOptions=useComputedOptions;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const react=require("react"),DisabledContext=react.createContext(!1);function useContextDisabled(){return react.useContext(DisabledContext)}const DisabledContextProvider=DisabledContext.Provider;exports.DisabledContextProvider=DisabledContextProvider,exports.useContextDisabled=useContextDisabled;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@vef-framework/core"),shared=require("@vef-framework/shared"),ahooks=require("ahooks"),react=require("react");function useApi({data,dataDictionaryKey,api,apiParams,apiEnabled,staleTime,keepPreviousData,placeholderData},stubQueryApi,dataDictionaryApi){return react.useMemo(()=>shared.isNullish(data)?shared.isNullish(dataDictionaryKey)?shared.isNullish(api)?[stubQueryApi,[],{keepPreviousData:!0,initialData:[]}]:[api,apiParams,{enabled:apiEnabled??!0,staleTime,keepPreviousData,placeholderData}]:[dataDictionaryApi,{...apiParams,key:dataDictionaryKey},{enabled:apiEnabled??!0,staleTime,keepPreviousData,placeholderData}]:[stubQueryApi,data,{keepPreviousData:!0,initialData:data}],[data,dataDictionaryKey,api,stubQueryApi,dataDictionaryApi,apiParams,apiEnabled,staleTime,keepPreviousData,placeholderData])}function useDataQuery({onFetched,...config}){const{useApiQuery,stubQueryApi,dataDictionaryApi:dataDictionaryQueryApi}=core.useApiContext(),[api,args,options]=useApi(config,stubQueryApi,dataDictionaryQueryApi),result=useApiQuery(api,args,options);ahooks.useUnmount(()=>{Object.is(api,stubQueryApi)&&stubQueryApi.removeQueries(args)});const{isSuccess,data:rawData,...rest}=result,data=react.useMemo(()=>isSuccess&&shared.isFunction(onFetched)?onFetched(rawData):rawData,[isSuccess,rawData,onFetched]);return{...rest,isSuccess,data}}exports.useDataQuery=useDataQuery;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const react=require("react"),useDeepMemo=require("./use-deep-memo.cjs");function useDeepCallback(callback,dependencies){const memoizedDependencies=useDeepMemo.useDeepMemo(()=>dependencies,dependencies);return react.useCallback(callback,memoizedDependencies)}exports.useDeepCallback=useDeepCallback;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react");function useDeepMemo(factory,dependencies){const lastDependencies=react.useRef(),signal=react.useRef(0);return(lastDependencies.current===void 0||!isEqual(dependencies,lastDependencies.current))&&(signal.current+=1),lastDependencies.current=dependencies,react.useMemo(factory,[signal.current])}function isEqual(one,another){return one.length===another.length&&one.every((value,index)=>shared.isDeepEqual(value,another[index]))}exports.useDeepMemo=useDeepMemo;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react");function useDeepSelector(selector){const prevSelectedState=react.useRef();return state=>{const nextSelectedState=selector(state);return shared.isDeepEqual(prevSelectedState.current,nextSelectedState)?prevSelectedState.current:prevSelectedState.current=nextSelectedState}}exports.useDeepSelector=useDeepSelector;/*! 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,107 +1 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@vef-framework/core"),shared=require("@vef-framework/shared"),ahooks=require("ahooks"),react=require("react"),useShallowMemo=require("./use-shallow-memo.cjs");function useApi(missingOptionValues,{fallbackOptionsApi,fallbackOptionsApiParams,valuesKey,resolveFallbackOptions},stubQueryApi,asyncFnQueryApi){const uniqueId=react.useId();return useShallowMemo.useShallowMemo(()=>{if(missingOptionValues.length>0){if(shared.isFunction(resolveFallbackOptions))return[asyncFnQueryApi,{key:uniqueId,args:[missingOptionValues],fn:resolveFallbackOptions},{keepPreviousData:!0}];if(fallbackOptionsApi){const params={...fallbackOptionsApiParams,[valuesKey??"ids"]:missingOptionValues};return[fallbackOptionsApi,params,{keepPreviousData:!0}]}}return[stubQueryApi,[],{keepPreviousData:!0,initialData:[]}]},[resolveFallbackOptions,fallbackOptionsApi,stubQueryApi,uniqueId,missingOptionValues,asyncFnQueryApi,fallbackOptionsApiParams,valuesKey])}function useFallbackOptions(missingOptionValues,{fallbackOptionsApi,fallbackOptionsApiParams,valuesKey,resolveFallbackOptions}){const{useApiQuery,stubQueryApi,asyncFnQueryApi}=core.useApiContext(),[api,params,options]=useApi(missingOptionValues,{fallbackOptionsApi,fallbackOptionsApiParams,valuesKey,resolveFallbackOptions},stubQueryApi,asyncFnQueryApi),result=useApiQuery(api,params,options);return ahooks.useUnmount(()=>{Object.is(api,stubQueryApi)&&stubQueryApi.removeQueries(params),Object.is(api,asyncFnQueryApi)&&asyncFnQueryApi.removeQueries(params)}),result}exports.useFallbackOptions=useFallbackOptions;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const react=require("react"),useThemeTokens=require("./use-theme-tokens.cjs");function useGapSizeNormalizer(){const{paddingXS,paddingSM,padding,paddingMD,paddingLG}=useThemeTokens.useThemeTokens();return react.useCallback(gap=>gap==="tiny"?paddingXS:gap==="small"?paddingSM:gap==="medium"?padding:gap==="large"?paddingMD:gap==="huge"?paddingLG:gap,[paddingXS,paddingSM,padding,paddingMD,paddingLG])}exports.useGapSizeNormalizer=useGapSizeNormalizer;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const useGapSizeNormalizer=require("./use-gap-size-normalizer.cjs");function useNormalizedGapSize(gap){return useGapSizeNormalizer.useGapSizeNormalizer()(gap)}exports.useNormalizedGapSize=useNormalizedGapSize;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const react=require("react");function normalizeMenuItem(item){return item.type==="item"?{type:"item",key:item.key,label:item.label,disabled:item.disabled,icon:item.icon,extra:item.extra}:item.type==="submenu"?{type:"submenu",key:item.key,label:item.label,disabled:item.disabled,icon:item.icon,children:item.children.map(normalizeMenuItem)}:item.type==="group"?{type:"group",key:item.key,label:item.label,children:item.children.map(normalizeMenuItem)}:{type:"divider",key:item.key}}function useNormalizedMenuItems(items){return react.useMemo(()=>items.map(normalizeMenuItem),[items])}exports.normalizeMenuItem=normalizeMenuItem,exports.useNormalizedMenuItems=useNormalizedMenuItems;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react");function useNormalizedDataOptions(options,{labelKey="label",valueKey="value",childrenKey="children",descriptionKey="description",disabledKey="disabled",defaultToFirst=!1},{isTree=!1,isGrouped=!1,parsePinyin=!1,selectedOptionValues=[]}={}){return react.useMemo(()=>{const selectedOptionValuesSet=new Set(selectedOptionValues),isGroupedOptions=!isTree&&isGrouped,normalizeOption=(option,isTopLevel=!1)=>{const label=option[labelKey];if(shared.isNullish(label))throw labelKey==="label"?new shared.VefError(-10001,"The label value of the option is required."):new shared.VefError(-10001,`The label value pointed by '${labelKey}' of the option is required.`);const value=option[valueKey];if(shared.isNullish(value))throw valueKey==="value"?new shared.VefError(-10002,"The value of the option is required."):new shared.VefError(-10002,`The value pointed by '${valueKey}' of the option is required.`);const children=option[childrenKey],description=option[descriptionKey],disabled=option[disabledKey]??!1,normalizedOption={...option,label,value,children,description,disabled};if(parsePinyin){const{labelText,descriptionText}=normalizedOption;(shared.isString(label)||shared.isString(labelText))&&(normalizedOption.labelPinyin=shared.parsePinyinFirstLetter(shared.isString(label)?label:labelText).join("")),(shared.isString(description)||shared.isString(descriptionText))&&(normalizedOption.descriptionPinyin=shared.parsePinyinFirstLetter(shared.isString(description)?description:descriptionText).join(""))}return(!isTopLevel||!isGroupedOptions)&&selectedOptionValuesSet.has(value)&&selectedOptionValuesSet.delete(value),shared.isArray(normalizedOption.children)&&(normalizedOption.children=normalizedOption.children.map(option2=>normalizeOption(option2))),normalizedOption},normalizedOptions=options.map(option=>normalizeOption(option,!0)),missingOptionValues=Array.from(selectedOptionValuesSet);if(!defaultToFirst)return[normalizedOptions,missingOptionValues];if(isGroupedOptions){const firstNonEmptyGroupOption=normalizedOptions.find(item=>shared.isArray(item.children)&&item.children.length>0);return[normalizedOptions,missingOptionValues,firstNonEmptyGroupOption?.children?.[0]]}return[normalizedOptions,missingOptionValues,normalizedOptions[0]]},[childrenKey,defaultToFirst,descriptionKey,disabledKey,isGrouped,isTree,labelKey,options,parsePinyin,valueKey])}exports.useNormalizedDataOptions=useNormalizedDataOptions;/*! 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 @@
1
- /*! VefFramework version: 1.0.101, build time: 2025-03-07T14:07:14.523Z, 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;
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 */
1
+ "use strict";/*! VefFramework version: 1.0.102, build time: 2025-03-07T16:32:57.404Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react");function useOptionFilter(filterable,filterFromRemote){return react.useMemo(()=>{if(filterable)return filterFromRemote?!1:(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))??!1},[filterable,filterFromRemote])}exports.useOptionFilter=useOptionFilter;/*! 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 */