@blocklet/pages-kit 0.4.100 → 0.4.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.
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/common.js +8 -0
- package/lib/cjs/utils/property.js +8 -8
- package/lib/cjs/utils/style.js +5 -0
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/common.js +4 -0
- package/lib/esm/utils/property.js +6 -5
- package/lib/esm/utils/style.js +5 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/common.d.ts +2 -0
- package/lib/types/utils/property.d.ts +0 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import isNil from 'lodash/isNil';
|
|
2
2
|
import * as yaml from 'yaml';
|
|
3
|
+
import { isBrowserEnv, COLOR_CONVERT_FUNCTION_NAME } from './common';
|
|
3
4
|
export function componentUMDName({ componentId }) {
|
|
4
5
|
return `PagesCustomComponent${componentId}`;
|
|
5
6
|
}
|
|
@@ -66,9 +67,6 @@ export function safeYamlParse(value) {
|
|
|
66
67
|
}
|
|
67
68
|
return yaml.parse(value);
|
|
68
69
|
}
|
|
69
|
-
export const isBrowserEnv = () => {
|
|
70
|
-
return typeof globalThis.window !== 'undefined' && typeof globalThis.document !== 'undefined';
|
|
71
|
-
};
|
|
72
70
|
let dynamicPropertyHandlers = null;
|
|
73
71
|
let initDynamicPropertyHandlersPromise = null;
|
|
74
72
|
// 根据前后端环境初始化动态的属性处理函数
|
|
@@ -80,8 +78,11 @@ export const initDynamicParsePropertyValueHandlers = () => {
|
|
|
80
78
|
dynamicPropertyHandlers = {};
|
|
81
79
|
if (isBrowserEnv()) {
|
|
82
80
|
// colorConvert 需要前端环境才能处理,依赖 mui theme
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
const colorConvertFn = globalThis[COLOR_CONVERT_FUNCTION_NAME];
|
|
83
|
+
if (typeof colorConvertFn === 'function') {
|
|
84
|
+
dynamicPropertyHandlers.color = (value) => colorConvertFn(value);
|
|
85
|
+
}
|
|
85
86
|
}
|
|
86
87
|
return dynamicPropertyHandlers;
|
|
87
88
|
})();
|
package/lib/esm/utils/style.js
CHANGED
|
@@ -2,6 +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
6
|
const GRADIENT_START = 0;
|
|
6
7
|
const GRADIENT_END = 100;
|
|
7
8
|
const baseTheme = createTheme({});
|
|
@@ -153,3 +154,7 @@ export function colorConvert(color, _theme = blockletTheme) {
|
|
|
153
154
|
}
|
|
154
155
|
return color || '';
|
|
155
156
|
}
|
|
157
|
+
if (isBrowserEnv()) {
|
|
158
|
+
// @ts-ignore inject colorConvert to globalThis
|
|
159
|
+
globalThis[COLOR_CONVERT_FUNCTION_NAME] = colorConvert;
|
|
160
|
+
}
|