@vef-framework/hooks 1.0.101 → 1.0.103
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.
- package/es/index.js +1 -28
- package/es/lib.js +1 -4
- package/es/use-authorized-items.js +1 -24
- package/es/use-color-tokens.js +1 -30
- package/es/use-computed-action-buttons.js +1 -43
- package/es/use-computed-options.js +1 -67
- package/es/use-context-disabled.js +1 -11
- package/es/use-data-query.js +1 -108
- package/es/use-deep-callback.js +1 -11
- package/es/use-deep-memo.js +1 -19
- package/es/use-deep-selector.js +1 -14
- package/es/use-fallback-options.js +1 -103
- package/es/use-gap-size-normalizer.js +1 -36
- package/es/use-normalized-gap-size.js +1 -10
- package/es/use-normalized-menu-items.js +1 -45
- package/es/use-normalized-options.js +1 -102
- package/es/use-option-filter.js +1 -18
- package/es/use-remote-filter.js +1 -37
- package/es/use-shallow-callback.js +1 -11
- package/es/use-shallow-memo.js +1 -19
- package/es/use-shallow-selector.js +1 -14
- package/es/use-singleton.js +1 -14
- package/es/use-theme-tokens.js +1 -11
- package/es/use-transient-store.js +1 -32
- package/es/use-window-size.js +1 -19
- package/lib/index.cjs +1 -110
- package/lib/lib.cjs +1 -59
- package/lib/use-authorized-items.cjs +1 -28
- package/lib/use-color-tokens.cjs +1 -36
- package/lib/use-computed-action-buttons.cjs +1 -47
- package/lib/use-computed-options.cjs +1 -71
- package/lib/use-context-disabled.cjs +1 -16
- package/lib/use-data-query.cjs +1 -112
- package/lib/use-deep-callback.cjs +1 -15
- package/lib/use-deep-memo.cjs +1 -23
- package/lib/use-deep-selector.cjs +1 -18
- package/lib/use-fallback-options.cjs +1 -107
- package/lib/use-gap-size-normalizer.cjs +1 -40
- package/lib/use-normalized-gap-size.cjs +1 -14
- package/lib/use-normalized-menu-items.cjs +1 -50
- package/lib/use-normalized-options.cjs +1 -106
- package/lib/use-option-filter.cjs +1 -22
- package/lib/use-remote-filter.cjs +1 -41
- package/lib/use-shallow-callback.cjs +1 -15
- package/lib/use-shallow-memo.cjs +1 -23
- package/lib/use-shallow-selector.cjs +1 -18
- package/lib/use-singleton.cjs +1 -18
- package/lib/use-theme-tokens.cjs +1 -15
- package/lib/use-transient-store.cjs +1 -36
- package/lib/use-window-size.cjs +1 -23
- package/package.json +3 -3
|
@@ -1,102 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isNullish, VefError, isString, parsePinyinFirstLetter, isArray } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useNormalizedDataOptions(options, {
|
|
6
|
-
labelKey = "label",
|
|
7
|
-
valueKey = "value",
|
|
8
|
-
childrenKey = "children",
|
|
9
|
-
descriptionKey = "description",
|
|
10
|
-
disabledKey = "disabled",
|
|
11
|
-
defaultToFirst = false
|
|
12
|
-
}, {
|
|
13
|
-
isTree = false,
|
|
14
|
-
isGrouped = false,
|
|
15
|
-
parsePinyin = false,
|
|
16
|
-
selectedOptionValues = []
|
|
17
|
-
} = {}) {
|
|
18
|
-
return useMemo(() => {
|
|
19
|
-
const selectedOptionValuesSet = new Set(selectedOptionValues);
|
|
20
|
-
const isGroupedOptions = !isTree && isGrouped;
|
|
21
|
-
const normalizeOption = (option, isTopLevel = false) => {
|
|
22
|
-
const label = option[labelKey];
|
|
23
|
-
if (isNullish(label)) {
|
|
24
|
-
if (labelKey === "label") {
|
|
25
|
-
throw new VefError(-10001, `The label value of the option is required.`);
|
|
26
|
-
}
|
|
27
|
-
throw new VefError(-10001, `The label value pointed by '${labelKey}' of the option is required.`);
|
|
28
|
-
}
|
|
29
|
-
const value = option[valueKey];
|
|
30
|
-
if (isNullish(value)) {
|
|
31
|
-
if (valueKey === "value") {
|
|
32
|
-
throw new VefError(-10002, `The value of the option is required.`);
|
|
33
|
-
}
|
|
34
|
-
throw new VefError(-10002, `The value pointed by '${valueKey}' of the option is required.`);
|
|
35
|
-
}
|
|
36
|
-
const children = option[childrenKey];
|
|
37
|
-
const description = option[descriptionKey];
|
|
38
|
-
const disabled = option[disabledKey] ?? false;
|
|
39
|
-
const normalizedOption = {
|
|
40
|
-
...option,
|
|
41
|
-
label,
|
|
42
|
-
value,
|
|
43
|
-
children,
|
|
44
|
-
description,
|
|
45
|
-
disabled
|
|
46
|
-
};
|
|
47
|
-
if (parsePinyin) {
|
|
48
|
-
const { labelText, descriptionText } = normalizedOption;
|
|
49
|
-
if (isString(label) || isString(labelText)) {
|
|
50
|
-
normalizedOption.labelPinyin = parsePinyinFirstLetter(
|
|
51
|
-
isString(label) ? label : labelText
|
|
52
|
-
).join("");
|
|
53
|
-
}
|
|
54
|
-
if (isString(description) || isString(descriptionText)) {
|
|
55
|
-
normalizedOption.descriptionPinyin = parsePinyinFirstLetter(
|
|
56
|
-
isString(description) ? description : descriptionText
|
|
57
|
-
).join("");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
if ((!isTopLevel || !isGroupedOptions) && selectedOptionValuesSet.has(value)) {
|
|
61
|
-
selectedOptionValuesSet.delete(value);
|
|
62
|
-
}
|
|
63
|
-
if (isArray(normalizedOption.children)) {
|
|
64
|
-
normalizedOption.children = normalizedOption.children.map((option2) => normalizeOption(option2));
|
|
65
|
-
}
|
|
66
|
-
return normalizedOption;
|
|
67
|
-
};
|
|
68
|
-
const normalizedOptions = options.map((option) => normalizeOption(option, true));
|
|
69
|
-
const missingOptionValues = Array.from(selectedOptionValuesSet);
|
|
70
|
-
if (!defaultToFirst) {
|
|
71
|
-
return [normalizedOptions, missingOptionValues];
|
|
72
|
-
}
|
|
73
|
-
if (isGroupedOptions) {
|
|
74
|
-
const firstNonEmptyGroupOption = normalizedOptions.find((item) => isArray(item.children) && item.children.length > 0);
|
|
75
|
-
return [
|
|
76
|
-
normalizedOptions,
|
|
77
|
-
missingOptionValues,
|
|
78
|
-
firstNonEmptyGroupOption?.children?.[0]
|
|
79
|
-
];
|
|
80
|
-
}
|
|
81
|
-
return [
|
|
82
|
-
normalizedOptions,
|
|
83
|
-
missingOptionValues,
|
|
84
|
-
normalizedOptions[0]
|
|
85
|
-
];
|
|
86
|
-
}, [
|
|
87
|
-
childrenKey,
|
|
88
|
-
defaultToFirst,
|
|
89
|
-
descriptionKey,
|
|
90
|
-
disabledKey,
|
|
91
|
-
isGrouped,
|
|
92
|
-
isTree,
|
|
93
|
-
labelKey,
|
|
94
|
-
options,
|
|
95
|
-
parsePinyin,
|
|
96
|
-
// selectedOptionValues,
|
|
97
|
-
valueKey
|
|
98
|
-
]);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { useNormalizedDataOptions };
|
|
102
|
-
/*! 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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isNullish,VefError,isString,parsePinyinFirstLetter,isArray}from"@vef-framework/shared";import{useMemo}from"react";function useNormalizedDataOptions(options,{labelKey="label",valueKey="value",childrenKey="children",descriptionKey="description",disabledKey="disabled",defaultToFirst=!1},{isTree=!1,isGrouped=!1,parsePinyin=!1,selectedOptionValues=[]}={}){return useMemo(()=>{const selectedOptionValuesSet=new Set(selectedOptionValues),isGroupedOptions=!isTree&&isGrouped,normalizeOption=(option,isTopLevel=!1)=>{const label=option[labelKey];if(isNullish(label))throw labelKey==="label"?new VefError(-10001,"The label value of the option is required."):new VefError(-10001,`The label value pointed by '${labelKey}' of the option is required.`);const value=option[valueKey];if(isNullish(value))throw valueKey==="value"?new VefError(-10002,"The value of the option is required."):new 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;(isString(label)||isString(labelText))&&(normalizedOption.labelPinyin=parsePinyinFirstLetter(isString(label)?label:labelText).join("")),(isString(description)||isString(descriptionText))&&(normalizedOption.descriptionPinyin=parsePinyinFirstLetter(isString(description)?description:descriptionText).join(""))}return(!isTopLevel||!isGroupedOptions)&&selectedOptionValuesSet.has(value)&&selectedOptionValuesSet.delete(value),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=>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])}/*! 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 */export{useNormalizedDataOptions};
|
package/es/use-option-filter.js
CHANGED
|
@@ -1,18 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isString } from '@vef-framework/shared';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useOptionFilter(filterable, filterFromRemote) {
|
|
6
|
-
return useMemo(() => {
|
|
7
|
-
if (!filterable) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
if (filterFromRemote) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
return (filterValue, option) => (isString(option.label) && option.label.includes(filterValue) || isString(option.labelText) && option.labelText.includes(filterValue) || option.labelPinyin?.includes(filterValue) || option.value.includes(filterValue) || isString(option.description) && option.description.includes(filterValue) || isString(option.descriptionText) && option.descriptionText.includes(filterValue) || option.descriptionPinyin?.includes(filterValue)) ?? false;
|
|
14
|
-
}, [filterable, filterFromRemote]);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { useOptionFilter };
|
|
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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isString}from"@vef-framework/shared";import{useMemo}from"react";function useOptionFilter(filterable,filterFromRemote){return useMemo(()=>{if(filterable)return filterFromRemote?!1:(filterValue,option)=>(isString(option.label)&&option.label.includes(filterValue)||isString(option.labelText)&&option.labelText.includes(filterValue)||option.labelPinyin?.includes(filterValue)||option.value.includes(filterValue)||isString(option.description)&&option.description.includes(filterValue)||isString(option.descriptionText)&&option.descriptionText.includes(filterValue)||option.descriptionPinyin?.includes(filterValue))??!1},[filterable,filterFromRemote])}/*! 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 */export{useOptionFilter};
|
package/es/use-remote-filter.js
CHANGED
|
@@ -1,37 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { trim, debounce } from '@vef-framework/shared';
|
|
3
|
-
import { useState, useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useRemoteFilter(enabled, apiParams, keywordKey = "keyword") {
|
|
6
|
-
const [filterKeyword, setFilterKeyword] = useState();
|
|
7
|
-
const mergedApiParams = useMemo(() => {
|
|
8
|
-
if (!enabled) {
|
|
9
|
-
return apiParams;
|
|
10
|
-
}
|
|
11
|
-
const params = {
|
|
12
|
-
...apiParams
|
|
13
|
-
};
|
|
14
|
-
const keywordToUse = trim(filterKeyword);
|
|
15
|
-
if (keywordToUse) {
|
|
16
|
-
params[keywordKey] = keywordToUse;
|
|
17
|
-
}
|
|
18
|
-
return params;
|
|
19
|
-
}, [
|
|
20
|
-
enabled,
|
|
21
|
-
apiParams,
|
|
22
|
-
filterKeyword,
|
|
23
|
-
keywordKey
|
|
24
|
-
]);
|
|
25
|
-
const handleInputKeyword = useMemo(() => {
|
|
26
|
-
if (!enabled) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
return debounce({ delay: 500 }, (keyword) => {
|
|
30
|
-
setFilterKeyword(keyword);
|
|
31
|
-
});
|
|
32
|
-
}, [enabled]);
|
|
33
|
-
return [mergedApiParams, handleInputKeyword];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export { useRemoteFilter };
|
|
37
|
-
/*! 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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{trim,debounce}from"@vef-framework/shared";import{useState,useMemo}from"react";function useRemoteFilter(enabled,apiParams,keywordKey="keyword"){const[filterKeyword,setFilterKeyword]=useState(),mergedApiParams=useMemo(()=>{if(!enabled)return apiParams;const params={...apiParams},keywordToUse=trim(filterKeyword);return keywordToUse&&(params[keywordKey]=keywordToUse),params},[enabled,apiParams,filterKeyword,keywordKey]),handleInputKeyword=useMemo(()=>{if(enabled)return debounce({delay:500},keyword=>{setFilterKeyword(keyword)})},[enabled]);return[mergedApiParams,handleInputKeyword]}/*! 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 */export{useRemoteFilter};
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { useCallback } from 'react';
|
|
3
|
-
import { useShallowMemo } from './use-shallow-memo.js';
|
|
4
|
-
|
|
5
|
-
function useShallowCallback(callback, dependencies) {
|
|
6
|
-
const memoizedDependencies = useShallowMemo(() => dependencies, dependencies);
|
|
7
|
-
return useCallback(callback, memoizedDependencies);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useShallowCallback };
|
|
11
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{useCallback}from"react";import{useShallowMemo}from"./use-shallow-memo.js";function useShallowCallback(callback,dependencies){const memoizedDependencies=useShallowMemo(()=>dependencies,dependencies);return useCallback(callback,memoizedDependencies)}/*! 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 */export{useShallowCallback};
|
package/es/use-shallow-memo.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isShallowEqual } from '@vef-framework/shared';
|
|
3
|
-
import { useRef, useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function useShallowMemo(factory, dependencies) {
|
|
6
|
-
const lastDependencies = useRef();
|
|
7
|
-
const signal = useRef(0);
|
|
8
|
-
if (lastDependencies.current === void 0 || !isEqual(dependencies, lastDependencies.current)) {
|
|
9
|
-
signal.current += 1;
|
|
10
|
-
}
|
|
11
|
-
lastDependencies.current = dependencies;
|
|
12
|
-
return useMemo(factory, [signal.current]);
|
|
13
|
-
}
|
|
14
|
-
function isEqual(one, another) {
|
|
15
|
-
return one.length === another.length && one.every((value, index) => isShallowEqual(value, another[index]));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { useShallowMemo };
|
|
19
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isShallowEqual}from"@vef-framework/shared";import{useRef,useMemo}from"react";function useShallowMemo(factory,dependencies){const lastDependencies=useRef(),signal=useRef(0);return(lastDependencies.current===void 0||!isEqual(dependencies,lastDependencies.current))&&(signal.current+=1),lastDependencies.current=dependencies,useMemo(factory,[signal.current])}function isEqual(one,another){return one.length===another.length&&one.every((value,index)=>isShallowEqual(value,another[index]))}/*! 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 */export{useShallowMemo};
|
|
@@ -1,14 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isShallowEqual } from '@vef-framework/shared';
|
|
3
|
-
import { useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
function useShallowSelector(selector) {
|
|
6
|
-
const prevSelectedState = useRef();
|
|
7
|
-
return (state) => {
|
|
8
|
-
const nextSelectedState = selector(state);
|
|
9
|
-
return isShallowEqual(prevSelectedState.current, nextSelectedState) ? prevSelectedState.current : prevSelectedState.current = nextSelectedState;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { useShallowSelector };
|
|
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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isShallowEqual}from"@vef-framework/shared";import{useRef}from"react";function useShallowSelector(selector){const prevSelectedState=useRef();return state=>{const nextSelectedState=selector(state);return isShallowEqual(prevSelectedState.current,nextSelectedState)?prevSelectedState.current:prevSelectedState.current=nextSelectedState}}/*! 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 */export{useShallowSelector};
|
package/es/use-singleton.js
CHANGED
|
@@ -1,14 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isNullish } from '@vef-framework/shared';
|
|
3
|
-
import { useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
function useSingleton(factory) {
|
|
6
|
-
const singleton = useRef();
|
|
7
|
-
if (isNullish(singleton.current)) {
|
|
8
|
-
singleton.current = factory();
|
|
9
|
-
}
|
|
10
|
-
return singleton.current;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { useSingleton };
|
|
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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isNullish}from"@vef-framework/shared";import{useRef}from"react";function useSingleton(factory){const singleton=useRef();return isNullish(singleton.current)&&(singleton.current=factory()),singleton.current}/*! 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 */export{useSingleton};
|
package/es/use-theme-tokens.js
CHANGED
|
@@ -1,11 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { theme } from 'antd';
|
|
3
|
-
|
|
4
|
-
const { useToken } = theme;
|
|
5
|
-
function useThemeTokens() {
|
|
6
|
-
const { token } = useToken();
|
|
7
|
-
return token;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { useThemeTokens };
|
|
11
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{theme}from"antd";const{useToken}=theme;function useThemeTokens(){const{token}=useToken();return token}/*! 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 */export{useThemeTokens};
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { isShallowEqual } from '@vef-framework/shared';
|
|
3
|
-
import { useRef, useEffect } from 'react';
|
|
4
|
-
|
|
5
|
-
function useTransientStore({ subscribe, getState }, {
|
|
6
|
-
selector = (state) => state,
|
|
7
|
-
equalityFn = isShallowEqual,
|
|
8
|
-
listener
|
|
9
|
-
} = {}) {
|
|
10
|
-
const stateRef = useRef();
|
|
11
|
-
if (!stateRef.current) {
|
|
12
|
-
stateRef.current = selector(getState());
|
|
13
|
-
}
|
|
14
|
-
useEffect(
|
|
15
|
-
() => subscribe(
|
|
16
|
-
selector,
|
|
17
|
-
(state, prevState) => {
|
|
18
|
-
stateRef.current = state;
|
|
19
|
-
listener?.(state, prevState);
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
fireImmediately: false,
|
|
23
|
-
equalityFn
|
|
24
|
-
}
|
|
25
|
-
),
|
|
26
|
-
[equalityFn, listener, selector, subscribe]
|
|
27
|
-
);
|
|
28
|
-
return stateRef;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { useTransientStore };
|
|
32
|
-
/*! 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
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{isShallowEqual}from"@vef-framework/shared";import{useRef,useEffect}from"react";function useTransientStore({subscribe,getState},{selector=state=>state,equalityFn=isShallowEqual,listener}={}){const stateRef=useRef();return stateRef.current||(stateRef.current=selector(getState())),useEffect(()=>subscribe(selector,(state,prevState)=>{stateRef.current=state,listener?.(state,prevState)},{fireImmediately:!1,equalityFn}),[equalityFn,listener,selector,subscribe]),stateRef}/*! 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 */export{useTransientStore};
|
package/es/use-window-size.js
CHANGED
|
@@ -1,19 +1 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import { useRafState, useEventListener } from 'ahooks';
|
|
3
|
-
|
|
4
|
-
function useWindowSize() {
|
|
5
|
-
const [size, setSize] = useRafState(() => ({
|
|
6
|
-
width: window.innerWidth,
|
|
7
|
-
height: window.innerHeight
|
|
8
|
-
}));
|
|
9
|
-
useEventListener("resize", () => {
|
|
10
|
-
setSize({
|
|
11
|
-
width: window.innerWidth,
|
|
12
|
-
height: window.innerHeight
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
return size;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { useWindowSize };
|
|
19
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */import{useRafState,useEventListener}from"ahooks";function useWindowSize(){const[size,setSize]=useRafState(()=>({width:window.innerWidth,height:window.innerHeight}));return useEventListener("resize",()=>{setSize({width:window.innerWidth,height:window.innerHeight})}),size}/*! 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 */export{useWindowSize};
|
package/lib/index.cjs
CHANGED
|
@@ -1,110 +1 @@
|
|
|
1
|
-
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
-
|
|
6
|
-
require('./lib.cjs');
|
|
7
|
-
const useAuthorizedItems = require('./use-authorized-items.cjs');
|
|
8
|
-
const useColorTokens = require('./use-color-tokens.cjs');
|
|
9
|
-
const useComputedActionButtons = require('./use-computed-action-buttons.cjs');
|
|
10
|
-
const useComputedOptions = require('./use-computed-options.cjs');
|
|
11
|
-
const useContextDisabled = require('./use-context-disabled.cjs');
|
|
12
|
-
const useDataQuery = require('./use-data-query.cjs');
|
|
13
|
-
const useDeepCallback = require('./use-deep-callback.cjs');
|
|
14
|
-
const useDeepMemo = require('./use-deep-memo.cjs');
|
|
15
|
-
const useDeepSelector = require('./use-deep-selector.cjs');
|
|
16
|
-
const useFallbackOptions = require('./use-fallback-options.cjs');
|
|
17
|
-
const useGapSizeNormalizer = require('./use-gap-size-normalizer.cjs');
|
|
18
|
-
const useNormalizedGapSize = require('./use-normalized-gap-size.cjs');
|
|
19
|
-
const useNormalizedMenuItems = require('./use-normalized-menu-items.cjs');
|
|
20
|
-
const useNormalizedOptions = require('./use-normalized-options.cjs');
|
|
21
|
-
const useOptionFilter = require('./use-option-filter.cjs');
|
|
22
|
-
const useRemoteFilter = require('./use-remote-filter.cjs');
|
|
23
|
-
const useShallowCallback = require('./use-shallow-callback.cjs');
|
|
24
|
-
const useShallowMemo = require('./use-shallow-memo.cjs');
|
|
25
|
-
const useShallowSelector = require('./use-shallow-selector.cjs');
|
|
26
|
-
const useSingleton = require('./use-singleton.cjs');
|
|
27
|
-
const useThemeTokens = require('./use-theme-tokens.cjs');
|
|
28
|
-
const useTransientStore = require('./use-transient-store.cjs');
|
|
29
|
-
const useWindowSize = require('./use-window-size.cjs');
|
|
30
|
-
const usehooks = require('@uidotdev/usehooks');
|
|
31
|
-
const ahooks = require('ahooks');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.useAuthorizedItems = useAuthorizedItems.useAuthorizedItems;
|
|
36
|
-
exports.useColorTokens = useColorTokens.useColorTokens;
|
|
37
|
-
exports.useDefaultColorTokens = useColorTokens.useDefaultColorTokens;
|
|
38
|
-
exports.useSemanticColorTokens = useColorTokens.useSemanticColorTokens;
|
|
39
|
-
exports.useComputedActionButtons = useComputedActionButtons.useComputedActionButtons;
|
|
40
|
-
exports.useComputedOptions = useComputedOptions.useComputedOptions;
|
|
41
|
-
exports.DisabledContextProvider = useContextDisabled.DisabledContextProvider;
|
|
42
|
-
exports.useContextDisabled = useContextDisabled.useContextDisabled;
|
|
43
|
-
exports.useDataQuery = useDataQuery.useDataQuery;
|
|
44
|
-
exports.useDeepCallback = useDeepCallback.useDeepCallback;
|
|
45
|
-
exports.useDeepMemo = useDeepMemo.useDeepMemo;
|
|
46
|
-
exports.useDeepSelector = useDeepSelector.useDeepSelector;
|
|
47
|
-
exports.useFallbackOptions = useFallbackOptions.useFallbackOptions;
|
|
48
|
-
exports.useGapSizeNormalizer = useGapSizeNormalizer.useGapSizeNormalizer;
|
|
49
|
-
exports.useNormalizedGapSize = useNormalizedGapSize.useNormalizedGapSize;
|
|
50
|
-
exports.normalizeMenuItem = useNormalizedMenuItems.normalizeMenuItem;
|
|
51
|
-
exports.useNormalizedMenuItems = useNormalizedMenuItems.useNormalizedMenuItems;
|
|
52
|
-
exports.useNormalizedDataOptions = useNormalizedOptions.useNormalizedDataOptions;
|
|
53
|
-
exports.useOptionFilter = useOptionFilter.useOptionFilter;
|
|
54
|
-
exports.useRemoteFilter = useRemoteFilter.useRemoteFilter;
|
|
55
|
-
exports.useShallowCallback = useShallowCallback.useShallowCallback;
|
|
56
|
-
exports.useShallowMemo = useShallowMemo.useShallowMemo;
|
|
57
|
-
exports.useShallowSelector = useShallowSelector.useShallowSelector;
|
|
58
|
-
exports.useSingleton = useSingleton.useSingleton;
|
|
59
|
-
exports.useThemeTokens = useThemeTokens.useThemeTokens;
|
|
60
|
-
exports.useTransientStore = useTransientStore.useTransientStore;
|
|
61
|
-
exports.useWindowSize = useWindowSize.useWindowSize;
|
|
62
|
-
Object.defineProperty(exports, "useClickAway", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
get: () => usehooks.useClickAway
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(exports, "useMeasure", {
|
|
67
|
-
enumerable: true,
|
|
68
|
-
get: () => usehooks.useMeasure
|
|
69
|
-
});
|
|
70
|
-
Object.defineProperty(exports, "useDeepEffect", {
|
|
71
|
-
enumerable: true,
|
|
72
|
-
get: () => ahooks.useDeepCompareEffect
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(exports, "useDeepLayoutEffect", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
get: () => ahooks.useDeepCompareLayoutEffect
|
|
77
|
-
});
|
|
78
|
-
Object.defineProperty(exports, "useElementSize", {
|
|
79
|
-
enumerable: true,
|
|
80
|
-
get: () => ahooks.useSize
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(exports, "useEventListener", {
|
|
83
|
-
enumerable: true,
|
|
84
|
-
get: () => ahooks.useEventListener
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(exports, "useKeyPress", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
get: () => ahooks.useKeyPress
|
|
89
|
-
});
|
|
90
|
-
Object.defineProperty(exports, "useMount", {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: () => ahooks.useMount
|
|
93
|
-
});
|
|
94
|
-
Object.defineProperty(exports, "useUnmount", {
|
|
95
|
-
enumerable: true,
|
|
96
|
-
get: () => ahooks.useUnmount
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(exports, "useUpdateEffect", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
get: () => ahooks.useUpdateEffect
|
|
101
|
-
});
|
|
102
|
-
Object.defineProperty(exports, "useUpdateLayoutEffect", {
|
|
103
|
-
enumerable: true,
|
|
104
|
-
get: () => ahooks.useUpdateLayoutEffect
|
|
105
|
-
});
|
|
106
|
-
Object.defineProperty(exports, "useUpdater", {
|
|
107
|
-
enumerable: true,
|
|
108
|
-
get: () => ahooks.useUpdate
|
|
109
|
-
});
|
|
110
|
-
/*! 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.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("./lib.cjs");const useAuthorizedItems=require("./use-authorized-items.cjs"),useColorTokens=require("./use-color-tokens.cjs"),useComputedActionButtons=require("./use-computed-action-buttons.cjs"),useComputedOptions=require("./use-computed-options.cjs"),useContextDisabled=require("./use-context-disabled.cjs"),useDataQuery=require("./use-data-query.cjs"),useDeepCallback=require("./use-deep-callback.cjs"),useDeepMemo=require("./use-deep-memo.cjs"),useDeepSelector=require("./use-deep-selector.cjs"),useFallbackOptions=require("./use-fallback-options.cjs"),useGapSizeNormalizer=require("./use-gap-size-normalizer.cjs"),useNormalizedGapSize=require("./use-normalized-gap-size.cjs"),useNormalizedMenuItems=require("./use-normalized-menu-items.cjs"),useNormalizedOptions=require("./use-normalized-options.cjs"),useOptionFilter=require("./use-option-filter.cjs"),useRemoteFilter=require("./use-remote-filter.cjs"),useShallowCallback=require("./use-shallow-callback.cjs"),useShallowMemo=require("./use-shallow-memo.cjs"),useShallowSelector=require("./use-shallow-selector.cjs"),useSingleton=require("./use-singleton.cjs"),useThemeTokens=require("./use-theme-tokens.cjs"),useTransientStore=require("./use-transient-store.cjs"),useWindowSize=require("./use-window-size.cjs"),usehooks=require("@uidotdev/usehooks"),ahooks=require("ahooks");exports.useAuthorizedItems=useAuthorizedItems.useAuthorizedItems,exports.useColorTokens=useColorTokens.useColorTokens,exports.useDefaultColorTokens=useColorTokens.useDefaultColorTokens,exports.useSemanticColorTokens=useColorTokens.useSemanticColorTokens,exports.useComputedActionButtons=useComputedActionButtons.useComputedActionButtons,exports.useComputedOptions=useComputedOptions.useComputedOptions,exports.DisabledContextProvider=useContextDisabled.DisabledContextProvider,exports.useContextDisabled=useContextDisabled.useContextDisabled,exports.useDataQuery=useDataQuery.useDataQuery,exports.useDeepCallback=useDeepCallback.useDeepCallback,exports.useDeepMemo=useDeepMemo.useDeepMemo,exports.useDeepSelector=useDeepSelector.useDeepSelector,exports.useFallbackOptions=useFallbackOptions.useFallbackOptions,exports.useGapSizeNormalizer=useGapSizeNormalizer.useGapSizeNormalizer,exports.useNormalizedGapSize=useNormalizedGapSize.useNormalizedGapSize,exports.normalizeMenuItem=useNormalizedMenuItems.normalizeMenuItem,exports.useNormalizedMenuItems=useNormalizedMenuItems.useNormalizedMenuItems,exports.useNormalizedDataOptions=useNormalizedOptions.useNormalizedDataOptions,exports.useOptionFilter=useOptionFilter.useOptionFilter,exports.useRemoteFilter=useRemoteFilter.useRemoteFilter,exports.useShallowCallback=useShallowCallback.useShallowCallback,exports.useShallowMemo=useShallowMemo.useShallowMemo,exports.useShallowSelector=useShallowSelector.useShallowSelector,exports.useSingleton=useSingleton.useSingleton,exports.useThemeTokens=useThemeTokens.useThemeTokens,exports.useTransientStore=useTransientStore.useTransientStore,exports.useWindowSize=useWindowSize.useWindowSize,Object.defineProperty(exports,"useClickAway",{enumerable:!0,get:()=>usehooks.useClickAway}),Object.defineProperty(exports,"useMeasure",{enumerable:!0,get:()=>usehooks.useMeasure}),Object.defineProperty(exports,"useDeepEffect",{enumerable:!0,get:()=>ahooks.useDeepCompareEffect}),Object.defineProperty(exports,"useDeepLayoutEffect",{enumerable:!0,get:()=>ahooks.useDeepCompareLayoutEffect}),Object.defineProperty(exports,"useElementSize",{enumerable:!0,get:()=>ahooks.useSize}),Object.defineProperty(exports,"useEventListener",{enumerable:!0,get:()=>ahooks.useEventListener}),Object.defineProperty(exports,"useKeyPress",{enumerable:!0,get:()=>ahooks.useKeyPress}),Object.defineProperty(exports,"useMount",{enumerable:!0,get:()=>ahooks.useMount}),Object.defineProperty(exports,"useUnmount",{enumerable:!0,get:()=>ahooks.useUnmount}),Object.defineProperty(exports,"useUpdateEffect",{enumerable:!0,get:()=>ahooks.useUpdateEffect}),Object.defineProperty(exports,"useUpdateLayoutEffect",{enumerable:!0,get:()=>ahooks.useUpdateLayoutEffect}),Object.defineProperty(exports,"useUpdater",{enumerable:!0,get:()=>ahooks.useUpdate});/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
package/lib/lib.cjs
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
-
|
|
6
|
-
const usehooks = require('@uidotdev/usehooks');
|
|
7
|
-
const ahooks = require('ahooks');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "useClickAway", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: () => usehooks.useClickAway
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(exports, "useMeasure", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
get: () => usehooks.useMeasure
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "useDeepEffect", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: () => ahooks.useDeepCompareEffect
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports, "useDeepLayoutEffect", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: () => ahooks.useDeepCompareLayoutEffect
|
|
26
|
-
});
|
|
27
|
-
Object.defineProperty(exports, "useElementSize", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: () => ahooks.useSize
|
|
30
|
-
});
|
|
31
|
-
Object.defineProperty(exports, "useEventListener", {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: () => ahooks.useEventListener
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "useKeyPress", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: () => ahooks.useKeyPress
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(exports, "useMount", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: () => ahooks.useMount
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(exports, "useUnmount", {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: () => ahooks.useUnmount
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(exports, "useUpdateEffect", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
get: () => ahooks.useUpdateEffect
|
|
50
|
-
});
|
|
51
|
-
Object.defineProperty(exports, "useUpdateLayoutEffect", {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: () => ahooks.useUpdateLayoutEffect
|
|
54
|
-
});
|
|
55
|
-
Object.defineProperty(exports, "useUpdater", {
|
|
56
|
-
enumerable: true,
|
|
57
|
-
get: () => ahooks.useUpdate
|
|
58
|
-
});
|
|
59
|
-
/*! 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.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const usehooks=require("@uidotdev/usehooks"),ahooks=require("ahooks");Object.defineProperty(exports,"useClickAway",{enumerable:!0,get:()=>usehooks.useClickAway}),Object.defineProperty(exports,"useMeasure",{enumerable:!0,get:()=>usehooks.useMeasure}),Object.defineProperty(exports,"useDeepEffect",{enumerable:!0,get:()=>ahooks.useDeepCompareEffect}),Object.defineProperty(exports,"useDeepLayoutEffect",{enumerable:!0,get:()=>ahooks.useDeepCompareLayoutEffect}),Object.defineProperty(exports,"useElementSize",{enumerable:!0,get:()=>ahooks.useSize}),Object.defineProperty(exports,"useEventListener",{enumerable:!0,get:()=>ahooks.useEventListener}),Object.defineProperty(exports,"useKeyPress",{enumerable:!0,get:()=>ahooks.useKeyPress}),Object.defineProperty(exports,"useMount",{enumerable:!0,get:()=>ahooks.useMount}),Object.defineProperty(exports,"useUnmount",{enumerable:!0,get:()=>ahooks.useUnmount}),Object.defineProperty(exports,"useUpdateEffect",{enumerable:!0,get:()=>ahooks.useUpdateEffect}),Object.defineProperty(exports,"useUpdateLayoutEffect",{enumerable:!0,get:()=>ahooks.useUpdateLayoutEffect}),Object.defineProperty(exports,"useUpdater",{enumerable:!0,get:()=>ahooks.useUpdate});/*! 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,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
-
|
|
6
|
-
const core = require('@vef-framework/core');
|
|
7
|
-
const react = require('react');
|
|
8
|
-
|
|
9
|
-
function useAuthorizedItems(items) {
|
|
10
|
-
const { checkPermission } = core.useAuthContext();
|
|
11
|
-
return react.useMemo(
|
|
12
|
-
() => items?.filter((item) => {
|
|
13
|
-
const { permissions } = item;
|
|
14
|
-
if (!permissions) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
const checkMode = item.checkMode ?? "any";
|
|
18
|
-
if (checkMode === "any") {
|
|
19
|
-
return permissions.some((permission) => checkPermission(permission));
|
|
20
|
-
}
|
|
21
|
-
return permissions.every((permission) => checkPermission(permission));
|
|
22
|
-
}),
|
|
23
|
-
[items, checkPermission]
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
exports.useAuthorizedItems = useAuthorizedItems;
|
|
28
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
"use strict";/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const core=require("@vef-framework/core"),react=require("react");function useAuthorizedItems(items){const{checkPermission}=core.useAuthContext();return react.useMemo(()=>items?.filter(item=>{const{permissions}=item;return permissions?(item.checkMode??"any")==="any"?permissions.some(permission=>checkPermission(permission)):permissions.every(permission=>checkPermission(permission)):!0}),[items,checkPermission])}exports.useAuthorizedItems=useAuthorizedItems;/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
package/lib/use-color-tokens.cjs
CHANGED
|
@@ -1,36 +1 @@
|
|
|
1
|
-
|
|
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
|
-
const useThemeTokens = require('./use-theme-tokens.cjs');
|
|
9
|
-
|
|
10
|
-
function useDefaultColorTokens() {
|
|
11
|
-
const tokens = useThemeTokens.useThemeTokens();
|
|
12
|
-
return react.useMemo(() => shared.defaultColorTypes.reduce(
|
|
13
|
-
(map, color) => {
|
|
14
|
-
map.set(color, tokens[color]);
|
|
15
|
-
return map;
|
|
16
|
-
},
|
|
17
|
-
/* @__PURE__ */ new Map()
|
|
18
|
-
), [tokens]);
|
|
19
|
-
}
|
|
20
|
-
function useSemanticColorTokens() {
|
|
21
|
-
const tokens = useThemeTokens.useThemeTokens();
|
|
22
|
-
return react.useMemo(() => shared.semanticColorTypes.reduce((map, color) => {
|
|
23
|
-
map.set(color, tokens[`color${shared.capitalize(color)}`]);
|
|
24
|
-
return map;
|
|
25
|
-
}, /* @__PURE__ */ new Map()), [tokens]);
|
|
26
|
-
}
|
|
27
|
-
function useColorTokens() {
|
|
28
|
-
const defaultColorTokens = useDefaultColorTokens();
|
|
29
|
-
const semanticColorTokens = useSemanticColorTokens();
|
|
30
|
-
return react.useMemo(() => new Map([...defaultColorTokens, ...semanticColorTokens]), [defaultColorTokens, semanticColorTokens]);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
exports.useColorTokens = useColorTokens;
|
|
34
|
-
exports.useDefaultColorTokens = useDefaultColorTokens;
|
|
35
|
-
exports.useSemanticColorTokens = useSemanticColorTokens;
|
|
36
|
-
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
|
1
|
+
"use strict";/*! VefFramework version: 1.0.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react"),useThemeTokens=require("./use-theme-tokens.cjs");function useDefaultColorTokens(){const tokens=useThemeTokens.useThemeTokens();return react.useMemo(()=>shared.defaultColorTypes.reduce((map,color)=>(map.set(color,tokens[color]),map),new Map),[tokens])}function useSemanticColorTokens(){const tokens=useThemeTokens.useThemeTokens();return react.useMemo(()=>shared.semanticColorTypes.reduce((map,color)=>(map.set(color,tokens[`color${shared.capitalize(color)}`]),map),new Map),[tokens])}function useColorTokens(){const defaultColorTokens=useDefaultColorTokens(),semanticColorTokens=useSemanticColorTokens();return react.useMemo(()=>new Map([...defaultColorTokens,...semanticColorTokens]),[defaultColorTokens,semanticColorTokens])}exports.useColorTokens=useColorTokens,exports.useDefaultColorTokens=useDefaultColorTokens,exports.useSemanticColorTokens=useSemanticColorTokens;/*! 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,47 +1 @@
|
|
|
1
|
-
|
|
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 useComputedActionButtons(buttons, context) {
|
|
10
|
-
return react.useMemo(() => buttons.filter((button) => {
|
|
11
|
-
const { show } = button;
|
|
12
|
-
if (shared.isFunction(show)) {
|
|
13
|
-
return show(context);
|
|
14
|
-
}
|
|
15
|
-
return show ?? true;
|
|
16
|
-
}).map((button) => {
|
|
17
|
-
const {
|
|
18
|
-
disabled,
|
|
19
|
-
requireConfirmation,
|
|
20
|
-
confirmationMode,
|
|
21
|
-
confirmationTitle,
|
|
22
|
-
confirmationContent,
|
|
23
|
-
...rest
|
|
24
|
-
} = button;
|
|
25
|
-
const computedButton = {
|
|
26
|
-
...rest,
|
|
27
|
-
disabled: shared.isFunction(disabled) ? disabled(context) : disabled ?? false,
|
|
28
|
-
requireConfirmation: shared.isFunction(requireConfirmation) ? requireConfirmation(context) : requireConfirmation ?? false,
|
|
29
|
-
confirmationMode: shared.isFunction(confirmationMode) ? confirmationMode(context) : confirmationMode ?? "simple",
|
|
30
|
-
confirmationTitle: shared.isFunction(confirmationTitle) ? confirmationTitle(context) : confirmationTitle ?? shared.defaultMessageTitle,
|
|
31
|
-
confirmationContent: shared.isFunction(confirmationContent) ? confirmationContent(context) : confirmationContent ?? `确定要${rest.label}吗?`
|
|
32
|
-
};
|
|
33
|
-
if (computedButton.requireConfirmation && !computedButton.confirmationMode) {
|
|
34
|
-
computedButton.confirmationMode = "simple";
|
|
35
|
-
}
|
|
36
|
-
if (computedButton.requireConfirmation && !computedButton.confirmationTitle) {
|
|
37
|
-
computedButton.confirmationTitle = shared.defaultMessageTitle;
|
|
38
|
-
}
|
|
39
|
-
if (computedButton.requireConfirmation && !computedButton.confirmationContent) {
|
|
40
|
-
computedButton.confirmationContent = `确定要${computedButton.label}吗?`;
|
|
41
|
-
}
|
|
42
|
-
return computedButton;
|
|
43
|
-
}), [buttons, context]);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.useComputedActionButtons = useComputedActionButtons;
|
|
47
|
-
/*! 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.103, build time: 2025-03-07T17:03:51.335Z, made by Venus. */Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const shared=require("@vef-framework/shared"),react=require("react");function useComputedActionButtons(buttons,context){return react.useMemo(()=>buttons.filter(button=>{const{show}=button;return shared.isFunction(show)?show(context):show??!0}).map(button=>{const{disabled,requireConfirmation,confirmationMode,confirmationTitle,confirmationContent,...rest}=button,computedButton={...rest,disabled:shared.isFunction(disabled)?disabled(context):disabled??!1,requireConfirmation:shared.isFunction(requireConfirmation)?requireConfirmation(context):requireConfirmation??!1,confirmationMode:shared.isFunction(confirmationMode)?confirmationMode(context):confirmationMode??"simple",confirmationTitle:shared.isFunction(confirmationTitle)?confirmationTitle(context):confirmationTitle??shared.defaultMessageTitle,confirmationContent:shared.isFunction(confirmationContent)?confirmationContent(context):confirmationContent??`确定要${rest.label}吗?`};return computedButton.requireConfirmation&&!computedButton.confirmationMode&&(computedButton.confirmationMode="simple"),computedButton.requireConfirmation&&!computedButton.confirmationTitle&&(computedButton.confirmationTitle=shared.defaultMessageTitle),computedButton.requireConfirmation&&!computedButton.confirmationContent&&(computedButton.confirmationContent=`确定要${computedButton.label}吗?`),computedButton}),[buttons,context])}exports.useComputedActionButtons=useComputedActionButtons;/*! 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 */
|