@blocklet/pages-kit 0.4.125 → 0.4.126
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/lib/cjs/components/CustomComponentRenderer/state.js +2 -14
- package/lib/cjs/contexts/color.js +14 -7
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/common.js +11 -0
- package/lib/cjs/utils/preload.js +1 -0
- package/lib/cjs/utils/property.js +1 -1
- package/lib/cjs/utils/style.js +3 -12
- package/lib/esm/components/CustomComponentRenderer/state.js +2 -14
- package/lib/esm/contexts/color.js +14 -7
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/common.js +10 -0
- package/lib/esm/utils/preload.js +1 -0
- package/lib/esm/utils/property.js +1 -1
- package/lib/esm/utils/style.js +2 -11
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/common.d.ts +4 -0
- package/lib/types/utils/style.d.ts +2 -4
- package/package.json +1 -1
package/lib/esm/utils/common.js
CHANGED
|
@@ -2,3 +2,13 @@ export const COLOR_CONVERT_FUNCTION_NAME = 'colorConvert';
|
|
|
2
2
|
export const isBrowserEnv = () => {
|
|
3
3
|
return typeof globalThis.window !== 'undefined' && typeof globalThis.document !== 'undefined';
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* 检查字符串是否为有效的MUI颜色键
|
|
7
|
+
*/
|
|
8
|
+
export function isMuiColorKey(value) {
|
|
9
|
+
// special case
|
|
10
|
+
if (value === 'transparent') {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
return /^(primary|secondary|error|warning|info|success|grey|background|text|action)\.[a-z0-9]+$/.test(value);
|
|
14
|
+
}
|
package/lib/esm/utils/preload.js
CHANGED
|
@@ -78,7 +78,7 @@ export const initDynamicParsePropertyValueHandlers = () => {
|
|
|
78
78
|
initDynamicPropertyHandlersPromise = (async () => {
|
|
79
79
|
dynamicPropertyHandlers = {};
|
|
80
80
|
if (isBrowserEnv()) {
|
|
81
|
-
// colorConvert
|
|
81
|
+
// colorConvert 目前需要前端环境才能处理,依赖 mui theme
|
|
82
82
|
// @ts-ignore
|
|
83
83
|
const colorConvertFn = globalThis[COLOR_CONVERT_FUNCTION_NAME];
|
|
84
84
|
if (typeof colorConvertFn === 'function') {
|
package/lib/esm/utils/style.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createTheme } from '@arcblock/ux/lib/Theme';
|
|
|
2
2
|
import gradient from 'gradient-parser';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
4
|
import tinycolor from 'tinycolor2';
|
|
5
|
-
import { isBrowserEnv, COLOR_CONVERT_FUNCTION_NAME } from './common';
|
|
5
|
+
import { isBrowserEnv, COLOR_CONVERT_FUNCTION_NAME, isMuiColorKey } from './common';
|
|
6
6
|
const GRADIENT_START = 0;
|
|
7
7
|
const GRADIENT_END = 100;
|
|
8
8
|
const baseTheme = createTheme({});
|
|
@@ -47,16 +47,6 @@ export function isColorString(color) {
|
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
51
|
-
* 检查字符串是否为有效的MUI颜色键
|
|
52
|
-
*/
|
|
53
|
-
export function isMuiColorKey(value) {
|
|
54
|
-
// special case
|
|
55
|
-
if (value === 'transparent') {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return /^(primary|secondary|error|warning|info|success|grey|background|text|action)\.[a-z0-9]+$/.test(value);
|
|
59
|
-
}
|
|
60
50
|
/**
|
|
61
51
|
* 处理渐变的解析,并转换为rgba格式
|
|
62
52
|
*/
|
|
@@ -164,3 +154,4 @@ if (isBrowserEnv()) {
|
|
|
164
154
|
export function getTransparentBackground() {
|
|
165
155
|
return 'repeating-conic-gradient(#CCCCCC 0% 25%, #FFFFFF 0% 50%) 50% / 10px 10px';
|
|
166
156
|
}
|
|
157
|
+
export { isMuiColorKey };
|