@blocklet/pages-kit 0.6.37 → 0.6.39
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/index.js +6 -1
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/property.js +1 -6
- package/lib/cjs/utils/style.js +2 -6
- package/lib/esm/components/CustomComponentRenderer/index.js +6 -1
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/property.js +2 -7
- package/lib/esm/utils/style.js +3 -7
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/style.d.ts +1 -1
- package/package.json +5 -5
|
@@ -119,12 +119,7 @@ const initDynamicParsePropertyValueHandlers = () => {
|
|
|
119
119
|
initDynamicPropertyHandlersPromise = (async () => {
|
|
120
120
|
dynamicPropertyHandlers = {};
|
|
121
121
|
if ((0, common_1.isBrowserEnv)()) {
|
|
122
|
-
//
|
|
123
|
-
// @ts-ignore
|
|
124
|
-
const colorConvertFn = globalThis[common_1.COLOR_CONVERT_FUNCTION_NAME];
|
|
125
|
-
if (typeof colorConvertFn === 'function') {
|
|
126
|
-
dynamicPropertyHandlers.color = (value) => colorConvertFn(value);
|
|
127
|
-
}
|
|
122
|
+
// do nothing
|
|
128
123
|
}
|
|
129
124
|
return dynamicPropertyHandlers;
|
|
130
125
|
})();
|
package/lib/cjs/utils/style.js
CHANGED
|
@@ -147,12 +147,12 @@ function parseColor(color = '') {
|
|
|
147
147
|
* @param _theme - 主题对象,默认为全局主题
|
|
148
148
|
* @returns 转换后的颜色字符串
|
|
149
149
|
*/
|
|
150
|
-
function colorConvert(color,
|
|
150
|
+
function colorConvert(color, theme = blockletTheme) {
|
|
151
151
|
if ((0, common_1.isMuiColorKey)(color)) {
|
|
152
152
|
if (color === 'transparent') {
|
|
153
153
|
return 'transparent';
|
|
154
154
|
}
|
|
155
|
-
return (0, get_1.default)(
|
|
155
|
+
return (0, get_1.default)(theme.palette, color, color);
|
|
156
156
|
}
|
|
157
157
|
// 处理渐变和普通颜色
|
|
158
158
|
if (isGradient(color)) {
|
|
@@ -163,10 +163,6 @@ function colorConvert(color, _theme = blockletTheme) {
|
|
|
163
163
|
}
|
|
164
164
|
return color || '';
|
|
165
165
|
}
|
|
166
|
-
if ((0, common_1.isBrowserEnv)()) {
|
|
167
|
-
// @ts-ignore inject colorConvert to globalThis
|
|
168
|
-
globalThis[common_1.COLOR_CONVERT_FUNCTION_NAME] = colorConvert;
|
|
169
|
-
}
|
|
170
166
|
function getTransparentBackground() {
|
|
171
167
|
return 'repeating-conic-gradient(#CCCCCC 0% 25%, #FFFFFF 0% 50%) 50% / 10px 10px';
|
|
172
168
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
|
+
import { useColorConvert } from '../../contexts/color';
|
|
4
5
|
import { RenderNestedComponent, parsePropertyValue } from '../../utils/property';
|
|
5
6
|
import BlockletReactComponentRenderer from './BlockletReactComponentRenderer';
|
|
6
7
|
import { DevProvider, useDev } from './DevProvider';
|
|
@@ -25,6 +26,7 @@ function ComponentRenderer({ renderCount = 0, blockletId, blockletTitle, compone
|
|
|
25
26
|
}
|
|
26
27
|
const component = useComponent({ ...props, dev });
|
|
27
28
|
const ctx = useCustomComponentRenderer();
|
|
29
|
+
const colorConvert = useColorConvert();
|
|
28
30
|
// 传递过来的参数,需要确保经过前端 parsePropertyValue 处理,并且补全不存在的参数
|
|
29
31
|
const parsedProps = useMemo(() => {
|
|
30
32
|
const result = {
|
|
@@ -41,10 +43,13 @@ function ComponentRenderer({ renderCount = 0, blockletId, blockletTitle, compone
|
|
|
41
43
|
result[key] = parsePropertyValue(property, result[key] ?? defaultValue, {
|
|
42
44
|
locale: props?.locale,
|
|
43
45
|
defaultLocale,
|
|
46
|
+
propertyHandlers: {
|
|
47
|
+
color: (value) => colorConvert(value),
|
|
48
|
+
},
|
|
44
49
|
});
|
|
45
50
|
});
|
|
46
51
|
return result;
|
|
47
|
-
}, [props?.props, component?.properties, component?.props]);
|
|
52
|
+
}, [props?.props, component?.properties, component?.props, colorConvert]);
|
|
48
53
|
const renderComponentChildren = (Component) => {
|
|
49
54
|
const children = _jsx(Renderer, { renderCount: renderCount + 1, ...props, Component: Component, props: parsedProps });
|
|
50
55
|
return ctx?.customRendererComponent ? (_jsx(ctx.customRendererComponent, { Component: Component, children: children })) : (children);
|