@blocklet/pages-kit 0.6.98 → 0.6.100
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/builtin/color-picker.js +7 -2
- package/lib/cjs/contexts/color.js +22 -3
- package/lib/cjs/tsconfig.tsbuildinfo +1 -1
- package/lib/cjs/utils/common.js +1 -1
- package/lib/cjs/utils/style.js +16 -2
- package/lib/esm/builtin/color-picker.js +8 -3
- package/lib/esm/contexts/color.js +22 -4
- package/lib/esm/tsconfig.tsbuildinfo +1 -1
- package/lib/esm/utils/common.js +1 -1
- package/lib/esm/utils/style.js +14 -1
- package/lib/types/contexts/color.d.ts +13 -0
- package/lib/types/tsconfig.tsbuildinfo +1 -1
- package/lib/types/utils/style.d.ts +5 -0
- package/package.json +2 -2
|
@@ -157,6 +157,7 @@ function ColorItem({ color, sx = {}, ...props }) {
|
|
|
157
157
|
const MuiThemeTab = ({ value, onChange, }) => {
|
|
158
158
|
const { t } = (0, context_1.useLocaleContext)();
|
|
159
159
|
const muiPalette = (0, color_1.useMuiColorPalette)();
|
|
160
|
+
const { getBackgroundColorStyle } = (0, color_1.useBackgroundColorStyle)();
|
|
160
161
|
const mode = muiPalette?.theme?.palette?.mode;
|
|
161
162
|
const isDark = mode === 'dark';
|
|
162
163
|
const { groupedMuiColors } = muiPalette;
|
|
@@ -173,6 +174,9 @@ const MuiThemeTab = ({ value, onChange, }) => {
|
|
|
173
174
|
selectedColor = 'rgba(0,0,0,0.7)';
|
|
174
175
|
}
|
|
175
176
|
}
|
|
177
|
+
else if (item.colorKey === 'auto') {
|
|
178
|
+
selectedColor = 'rgba(0,0,0,0.7)';
|
|
179
|
+
}
|
|
176
180
|
// 是否有另一种模式的颜色值
|
|
177
181
|
const hasAlternateColor = !!item.alternateColorValue;
|
|
178
182
|
return ((0, jsx_runtime_1.jsx)(material_1.Tooltip, { title: `${item.colorKey}${hasAlternateColor ? t('maker.configColorMuiThemeWithAlternateColor') : ''}`, sx: {
|
|
@@ -204,7 +208,7 @@ const MuiThemeTab = ({ value, onChange, }) => {
|
|
|
204
208
|
left: 0,
|
|
205
209
|
...(item.colorValue === 'transparent'
|
|
206
210
|
? { background: (0, style_1.getTransparentBackground)() }
|
|
207
|
-
:
|
|
211
|
+
: getBackgroundColorStyle(item.colorValue)),
|
|
208
212
|
} }), hasAlternateColor && (0, jsx_runtime_1.jsx)(AlternateColorIndicator, { value: item.alternateColorValue }), value?.originalMuiKey === item.colorKey && ((0, jsx_runtime_1.jsx)("i", { className: "i-mdi:check", style: {
|
|
209
213
|
color: selectedColor,
|
|
210
214
|
fontSize: '1.2rem',
|
|
@@ -238,6 +242,7 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
238
242
|
defaultValue: 0,
|
|
239
243
|
});
|
|
240
244
|
const muiPalette = (0, color_1.useMuiColorPalette)();
|
|
245
|
+
const { getBackgroundColorStyle } = (0, color_1.useBackgroundColorStyle)();
|
|
241
246
|
const mode = muiPalette?.theme?.palette?.mode;
|
|
242
247
|
const isDark = mode === 'dark';
|
|
243
248
|
// Create default tabs
|
|
@@ -275,7 +280,7 @@ const ConfigColorDialog = function ConfigColorDialog({ ref, onSave, enableMuiPal
|
|
|
275
280
|
previewStyle.backgroundImage = state.value;
|
|
276
281
|
}
|
|
277
282
|
else {
|
|
278
|
-
previewStyle
|
|
283
|
+
Object.assign(previewStyle, getBackgroundColorStyle(state.value));
|
|
279
284
|
}
|
|
280
285
|
}
|
|
281
286
|
else {
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useMuiColorPalette = useMuiColorPalette;
|
|
7
7
|
exports.useColorConvert = useColorConvert;
|
|
8
|
+
exports.useBackgroundColorStyle = useBackgroundColorStyle;
|
|
8
9
|
const Theme_1 = require("@arcblock/ux/lib/Theme");
|
|
9
10
|
const styles_1 = require("@mui/material/styles");
|
|
10
11
|
const get_1 = __importDefault(require("lodash/get"));
|
|
@@ -30,10 +31,10 @@ function useMuiColorPalette() {
|
|
|
30
31
|
// 特殊颜色组
|
|
31
32
|
{
|
|
32
33
|
type: 'special',
|
|
33
|
-
keys: ['transparent'],
|
|
34
|
+
keys: ['transparent', 'auto'],
|
|
34
35
|
variants: null,
|
|
35
|
-
format: () =>
|
|
36
|
-
accessor: () => ({
|
|
36
|
+
format: (key) => key,
|
|
37
|
+
accessor: (key) => ({ [key]: key }),
|
|
37
38
|
},
|
|
38
39
|
// common 颜色
|
|
39
40
|
{
|
|
@@ -191,3 +192,21 @@ function useColorConvert() {
|
|
|
191
192
|
return (0, style_1.colorConvert)(color, theme);
|
|
192
193
|
}, [theme, style_1.colorConvert]);
|
|
193
194
|
}
|
|
195
|
+
function useBackgroundColorStyle() {
|
|
196
|
+
const getBackgroundColor = (0, react_1.useCallback)((color = '') => {
|
|
197
|
+
if (color === 'auto') {
|
|
198
|
+
return (0, style_1.gradientFromPrimary)();
|
|
199
|
+
}
|
|
200
|
+
return color;
|
|
201
|
+
}, []);
|
|
202
|
+
const getBackgroundColorStyle = (0, react_1.useCallback)((color = '') => {
|
|
203
|
+
if (color === 'auto') {
|
|
204
|
+
return { backgroundImage: (0, style_1.gradientFromPrimary)() };
|
|
205
|
+
}
|
|
206
|
+
if ((0, style_1.isGradient)(color)) {
|
|
207
|
+
return { backgroundImage: color };
|
|
208
|
+
}
|
|
209
|
+
return { bgcolor: color };
|
|
210
|
+
}, []);
|
|
211
|
+
return { getBackgroundColorStyle, getBackgroundColor };
|
|
212
|
+
}
|