@blocklet/pages-kit 0.4.120 → 0.4.122

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.
@@ -10,6 +10,7 @@ exports.isMuiColorKey = isMuiColorKey;
10
10
  exports.getSafeGradient = getSafeGradient;
11
11
  exports.parseColor = parseColor;
12
12
  exports.colorConvert = colorConvert;
13
+ exports.getTransparentBackground = getTransparentBackground;
13
14
  const Theme_1 = require("@arcblock/ux/lib/Theme");
14
15
  const gradient_parser_1 = __importDefault(require("gradient-parser"));
15
16
  const get_1 = __importDefault(require("lodash/get"));
@@ -173,3 +174,6 @@ if ((0, common_1.isBrowserEnv)()) {
173
174
  // @ts-ignore inject colorConvert to globalThis
174
175
  globalThis[common_1.COLOR_CONVERT_FUNCTION_NAME] = colorConvert;
175
176
  }
177
+ function getTransparentBackground() {
178
+ return 'repeating-conic-gradient(#CCCCCC 0% 25%, #FFFFFF 0% 50%) 50% / 10px 10px';
179
+ }
@@ -1,48 +1,47 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import Empty from '@arcblock/ux/lib/Empty';
3
3
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
4
- import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, ButtonGroup, Typography, Tooltip, Skeleton, } from '@mui/material';
4
+ import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, ButtonGroup, Typography, Tooltip, Skeleton, ThemeProvider, } from '@mui/material';
5
5
  import { useBoolean, useLocalStorageState, useReactive } from 'ahooks';
6
6
  import { Suspense, forwardRef, lazy, useCallback, useImperativeHandle, useRef } from 'react';
7
7
  import tinycolor from 'tinycolor2';
8
8
  import { useMuiColorPalette } from '../contexts/color';
9
- import { isColorString, isGradient, getSafeGradient } from '../utils/style';
9
+ import { getBlockletTheme, isColorString, isGradient, getSafeGradient, getTransparentBackground } from '../utils/style';
10
10
  const ColorPickerLib = lazy(() => import('react-best-gradient-color-picker'));
11
11
  const HEIGHT = 400;
12
12
  const WIDTH = 270;
13
+ const blockletTheme = getBlockletTheme();
14
+ export function BlockletThemeProvider({ children }) {
15
+ return _jsx(ThemeProvider, { theme: blockletTheme, children: children });
16
+ }
13
17
  export function ColorItem({ color, sx = {}, ...props }) {
14
18
  isColorString(color);
15
19
  const styleMap = {};
16
20
  if (isGradient(color)) {
17
21
  styleMap.backgroundImage = color;
18
22
  }
23
+ else if (color === 'transparent') {
24
+ styleMap.background = getTransparentBackground();
25
+ }
19
26
  else {
20
27
  styleMap.backgroundColor = color;
21
28
  }
22
- return (_jsx(Box, { sx: {
23
- ...sx,
24
- width: '100%',
25
- paddingBottom: '100%',
26
- cursor: 'pointer',
27
- transition: 'opacity 0.2s',
28
- border: '1px solid #ccc',
29
- borderRadius: 0.5,
30
- '&:hover': {
31
- opacity: 0.75,
32
- },
33
- ...styleMap,
34
- }, ...props }));
35
- }
36
- export function ColorPicker({ value, onChange, style = {}, sx = {} }) {
37
- const refDialog = useRef(null);
38
- return (_jsxs(_Fragment, { children: [_jsx(ColorItem, { color: value, style: { width: '1rem', height: '1rem', padding: 0, marginRight: '0.25rem', ...style }, sx: { ...sx }, onClick: () => {
39
- refDialog.current?.open({ value });
40
- } }), _jsx(ConfigColorDialog, { ref: refDialog, onSave: ({ value }, close) => {
41
- onChange(value);
42
- close();
43
- } })] }));
29
+ return (
30
+ // @FIXME:临时方案,等 theme 功能定下来之后去掉
31
+ _jsx(BlockletThemeProvider, { children: _jsx(Box, { sx: {
32
+ width: '100%',
33
+ height: '100%',
34
+ cursor: 'pointer',
35
+ transition: 'opacity 0.2s',
36
+ border: '1px solid #ccc',
37
+ borderRadius: 0.5,
38
+ '&:hover': {
39
+ opacity: 0.75,
40
+ },
41
+ ...sx,
42
+ ...styleMap,
43
+ }, ...props }) }));
44
44
  }
45
- export default ColorPicker;
46
45
  export const ConfigColorDialog = forwardRef(function ConfigColorDialog({ onSave, enableMuiPalette = true }, ref) {
47
46
  const state = useReactive({
48
47
  value: '',
@@ -156,7 +155,7 @@ export const ConfigColorDialog = forwardRef(function ConfigColorDialog({ onSave,
156
155
  selectedColor = 'rgba(0,0,0,0.7)';
157
156
  }
158
157
  }
159
- return (_jsx(Tooltip, { title: item.colorKey, children: _jsx(Box, { onClick: () => {
158
+ return (_jsx(Tooltip, { title: item.colorKey, children: _jsx(ColorItem, { color: item.colorValue, onClick: () => {
160
159
  state.value = item.colorValue;
161
160
  state.originalMuiKey = item.colorKey;
162
161
  }, sx: {
@@ -175,7 +174,7 @@ export const ConfigColorDialog = forwardRef(function ConfigColorDialog({ onSave,
175
174
  // 透明色时显示棋盘背景
176
175
  ...(item.colorValue === 'transparent'
177
176
  ? {
178
- background: 'repeating-conic-gradient(#CCCCCC 0% 25%, #FFFFFF 0% 50%) 50% / 10px 10px',
177
+ background: getTransparentBackground(),
179
178
  }
180
179
  : {}),
181
180
  }, children: state.originalMuiKey === item.colorKey && (_jsx("i", { className: "i-mdi:check", style: {
@@ -191,3 +190,13 @@ export const ConfigColorDialog = forwardRef(function ConfigColorDialog({ onSave,
191
190
  state.originalMuiKey = null;
192
191
  }, hidePresets: true, hideAdvancedSliders: true, hideColorGuide: true, hideInputType: true }) }) })) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { variant: "outlined", size: "small", onClick: handleClose, children: t('common.cancel') }), _jsx(Button, { variant: "contained", size: "small", onClick: handleSave, children: t('maker.save') })] })] }));
193
192
  });
193
+ export function ColorPicker({ value, onChange, style = {}, sx = {} }) {
194
+ const refDialog = useRef(null);
195
+ return (_jsxs(_Fragment, { children: [_jsx(ColorItem, { color: value || '', style: { width: '1rem', height: '1rem', padding: 0, marginRight: '0.25rem', ...style }, sx: { ...sx }, onClick: () => {
196
+ refDialog.current?.open({ value });
197
+ } }), _jsx(ConfigColorDialog, { ref: refDialog, onSave: ({ value }, close) => {
198
+ onChange(value);
199
+ close();
200
+ } })] }));
201
+ }
202
+ export default ColorPicker;
@@ -46,7 +46,16 @@ function MarkdownRenderer(props) {
46
46
  const options = {
47
47
  codeOptions,
48
48
  };
49
- return (_jsx(StyledBox, { children: _jsx(MarkdownProvider, { options: options, children: _jsx(MarkdownHooks, { ...rest, remarkPlugins: [remarkGfm], rehypePlugins: [rehypeMermaid], components: {
49
+ return (_jsx(StyledBox, { sx: {
50
+ '& h1': (theme) => ({ ...theme.typography.h1, marginBottom: '0.35em' }),
51
+ '& h2': (theme) => ({ ...theme.typography.h2, marginBottom: '0.35em' }),
52
+ '& h3': (theme) => ({ ...theme.typography.h3, marginBottom: '0.35em' }),
53
+ '& h4': (theme) => ({ ...theme.typography.h4, marginBottom: '0.35em' }),
54
+ '& h5': (theme) => ({ ...theme.typography.h5, marginBottom: '0.35em' }),
55
+ '& h6': (theme) => ({ ...theme.typography.h6, marginBottom: '0.35em' }),
56
+ '& p': (theme) => ({ ...theme.typography.body1, marginBottom: '0.35em' }),
57
+ '& li': (theme) => ({ ...theme.typography.body1, marginBottom: '0.35em' }),
58
+ }, children: _jsx(MarkdownProvider, { options: options, children: _jsx(MarkdownHooks, { ...rest, remarkPlugins: [remarkGfm], rehypePlugins: [rehypeMermaid], components: {
50
59
  pre: MarkdownPre,
51
60
  code: MarkdownCode,
52
61
  table: MarkdownTable,
@@ -71,14 +80,14 @@ const StyledBox = styled(Box) `
71
80
  }
72
81
 
73
82
  li {
74
- margin: 0;
83
+ margin: 0 0 0.35em 0;
75
84
  padding: 0;
76
85
  }
77
86
 
78
87
  li p {
79
88
  display: inline-block;
80
89
  vertical-align: top;
81
- margin: 0;
90
+ margin: 0 0 0.35em 0;
82
91
  padding: 0;
83
92
  }
84
93
 
@@ -1,11 +1,13 @@
1
- import { useTheme } from '@mui/material/styles';
1
+ // import { useTheme } from '@mui/material/styles';
2
2
  import { useCallback, useMemo } from 'react';
3
- import { isMuiColorKey, colorConvert } from '../utils/style';
3
+ import { isMuiColorKey, colorConvert, getBlockletTheme } from '../utils/style';
4
4
  /**
5
5
  * Hook 用于获取和操作 MUI 主题色
6
6
  */
7
7
  export function useMuiColorPalette() {
8
- const theme = useTheme();
8
+ // @FIXME:临时方案,等 theme 功能定下来之后去掉
9
+ const theme = getBlockletTheme();
10
+ // const theme = useTheme();
9
11
  // 创建 MUI 色板预设及映射关系
10
12
  const muiPaletteColors = useMemo(() => {
11
13
  const colors = [];