@vef-framework/hooks 1.0.97 → 1.0.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +27 -2
- package/es/lib.js +3 -2
- package/es/use-authorized-items.js +23 -2
- package/es/use-color-tokens.js +29 -2
- package/es/use-computed-action-buttons.js +42 -2
- package/es/use-computed-options.js +66 -2
- package/es/use-context-disabled.js +10 -2
- package/es/use-data-query.js +107 -2
- package/es/use-deep-callback.js +10 -2
- package/es/use-deep-memo.js +18 -2
- package/es/use-deep-selector.js +13 -2
- package/es/use-fallback-options.js +102 -2
- package/es/use-gap-size-normalizer.js +35 -2
- package/es/use-normalized-gap-size.js +9 -2
- package/es/use-normalized-menu-items.js +44 -2
- package/es/use-normalized-options.js +101 -2
- package/es/use-option-filter.js +17 -2
- package/es/use-remote-filter.js +36 -2
- package/es/use-shallow-callback.js +10 -2
- package/es/use-shallow-memo.js +18 -2
- package/es/use-shallow-selector.js +13 -2
- package/es/use-singleton.js +13 -2
- package/es/use-theme-tokens.js +10 -2
- package/es/use-transient-store.js +31 -2
- package/es/use-window-size.js +18 -2
- package/lib/index.cjs +109 -2
- package/lib/lib.cjs +58 -2
- package/lib/use-authorized-items.cjs +27 -2
- package/lib/use-color-tokens.cjs +35 -2
- package/lib/use-computed-action-buttons.cjs +46 -2
- package/lib/use-computed-options.cjs +70 -2
- package/lib/use-context-disabled.cjs +15 -2
- package/lib/use-data-query.cjs +111 -2
- package/lib/use-deep-callback.cjs +14 -2
- package/lib/use-deep-memo.cjs +22 -2
- package/lib/use-deep-selector.cjs +17 -2
- package/lib/use-fallback-options.cjs +106 -2
- package/lib/use-gap-size-normalizer.cjs +39 -2
- package/lib/use-normalized-gap-size.cjs +13 -2
- package/lib/use-normalized-menu-items.cjs +49 -2
- package/lib/use-normalized-options.cjs +105 -2
- package/lib/use-option-filter.cjs +21 -2
- package/lib/use-remote-filter.cjs +40 -2
- package/lib/use-shallow-callback.cjs +14 -2
- package/lib/use-shallow-memo.cjs +22 -2
- package/lib/use-shallow-selector.cjs +17 -2
- package/lib/use-singleton.cjs +17 -2
- package/lib/use-theme-tokens.cjs +14 -2
- package/lib/use-transient-store.cjs +35 -2
- package/lib/use-window-size.cjs +22 -2
- package/package.json +3 -3
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isNullish
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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 */
|
package/es/use-option-filter.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isString
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
18
|
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
package/es/use-remote-filter.js
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{trim
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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,3 +1,11 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{useCallback
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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 */
|
package/es/use-shallow-memo.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isShallowEqual
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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,3 +1,14 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isShallowEqual
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
14
|
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
package/es/use-singleton.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isNullish
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
14
|
/*! VefFramework is a blazingly high-level, modern, flexible, easy-to-use UI framework made by Venus. Follow me on Github: https://github.com/ilxqx! @ilxqx */
|
package/es/use-theme-tokens.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{theme
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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,3 +1,32 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{isShallowEqual
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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 */
|
package/es/use-window-size.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
import{useRafState
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
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 };
|
|
3
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 */
|
package/lib/index.cjs
CHANGED
|
@@ -1,3 +1,110 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
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
|
+
});
|
|
3
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 */
|
package/lib/lib.cjs
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const 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
|
+
});
|
|
3
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,3 +1,28 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const core = require('@vef-framework/core');
|
|
7
|
+
const 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;
|
|
3
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 */
|
package/lib/use-color-tokens.cjs
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const shared = require('@vef-framework/shared');
|
|
7
|
+
const react = require('react');
|
|
8
|
+
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;
|
|
3
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,3 +1,47 @@
|
|
|
1
|
-
/*! VefFramework version: 1.0.
|
|
2
|
-
|
|
1
|
+
/*! VefFramework version: 1.0.99, build time: 2025-03-07T13:41:55.433Z, made by Venus. */
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const shared = require('@vef-framework/shared');
|
|
7
|
+
const react = require('react');
|
|
8
|
+
|
|
9
|
+
function 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 ?? `\u786E\u5B9A\u8981${rest.label}\u5417\uFF1F`
|
|
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 = `\u786E\u5B9A\u8981${computedButton.label}\u5417\uFF1F`;
|
|
41
|
+
}
|
|
42
|
+
return computedButton;
|
|
43
|
+
}), [buttons, context]);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.useComputedActionButtons = useComputedActionButtons;
|
|
3
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 */
|