@arcblock/ux 2.1.68 → 2.1.71

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.
@@ -17,7 +17,7 @@ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
17
17
 
18
18
  var _useMountedState = _interopRequireDefault(require("react-use/lib/useMountedState"));
19
19
 
20
- var _highlight = _interopRequireDefault(require("highlight.js/lib/highlight"));
20
+ var _core = _interopRequireDefault(require("highlight.js/lib/core"));
21
21
 
22
22
  var _javascript = _interopRequireDefault(require("highlight.js/lib/languages/javascript"));
23
23
 
@@ -71,57 +71,57 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
71
71
 
72
72
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
73
73
 
74
- _highlight.default.registerLanguage('javascript', _javascript.default);
74
+ _core.default.registerLanguage('javascript', _javascript.default);
75
75
 
76
- _highlight.default.registerLanguage('js', _javascript.default);
76
+ _core.default.registerLanguage('js', _javascript.default);
77
77
 
78
- _highlight.default.registerLanguage('jsx', _javascript.default);
78
+ _core.default.registerLanguage('jsx', _javascript.default);
79
79
 
80
- _highlight.default.registerLanguage('typescript', _typescript.default);
80
+ _core.default.registerLanguage('typescript', _typescript.default);
81
81
 
82
- _highlight.default.registerLanguage('ts', _typescript.default);
82
+ _core.default.registerLanguage('ts', _typescript.default);
83
83
 
84
- _highlight.default.registerLanguage('tsx', _typescript.default);
84
+ _core.default.registerLanguage('tsx', _typescript.default);
85
85
 
86
- _highlight.default.registerLanguage('json', _json.default);
86
+ _core.default.registerLanguage('json', _json.default);
87
87
 
88
- _highlight.default.registerLanguage('elixir', _elixir.default);
88
+ _core.default.registerLanguage('elixir', _elixir.default);
89
89
 
90
- _highlight.default.registerLanguage('java', _java.default);
90
+ _core.default.registerLanguage('java', _java.default);
91
91
 
92
- _highlight.default.registerLanguage('kotlin', _kotlin.default);
92
+ _core.default.registerLanguage('kotlin', _kotlin.default);
93
93
 
94
- _highlight.default.registerLanguage('kt', _kotlin.default);
94
+ _core.default.registerLanguage('kt', _kotlin.default);
95
95
 
96
- _highlight.default.registerLanguage('protobuf', _protobuf.default);
96
+ _core.default.registerLanguage('protobuf', _protobuf.default);
97
97
 
98
- _highlight.default.registerLanguage('protobuffer', _protobuf.default);
98
+ _core.default.registerLanguage('protobuffer', _protobuf.default);
99
99
 
100
- _highlight.default.registerLanguage('python', _python.default);
100
+ _core.default.registerLanguage('python', _python.default);
101
101
 
102
- _highlight.default.registerLanguage('py', _python.default);
102
+ _core.default.registerLanguage('py', _python.default);
103
103
 
104
- _highlight.default.registerLanguage('yaml', _yaml.default);
104
+ _core.default.registerLanguage('yaml', _yaml.default);
105
105
 
106
- _highlight.default.registerLanguage('yml', _yaml.default);
106
+ _core.default.registerLanguage('yml', _yaml.default);
107
107
 
108
- _highlight.default.registerLanguage('shell', _shell.default);
108
+ _core.default.registerLanguage('shell', _shell.default);
109
109
 
110
- _highlight.default.registerLanguage('sh', _shell.default);
110
+ _core.default.registerLanguage('sh', _shell.default);
111
111
 
112
- _highlight.default.registerLanguage('plaintext', _plaintext.default);
112
+ _core.default.registerLanguage('plaintext', _plaintext.default);
113
113
 
114
- _highlight.default.registerLanguage('text', _plaintext.default);
114
+ _core.default.registerLanguage('text', _plaintext.default);
115
115
 
116
- _highlight.default.registerLanguage('patch', _diff.default);
116
+ _core.default.registerLanguage('patch', _diff.default);
117
117
 
118
- _highlight.default.registerLanguage('diff', _diff.default);
118
+ _core.default.registerLanguage('diff', _diff.default);
119
119
 
120
- _highlight.default.registerLanguage('swift', _swift.default);
120
+ _core.default.registerLanguage('swift', _swift.default);
121
121
 
122
- _highlight.default.registerLanguage('objectivec', _objectivec.default);
122
+ _core.default.registerLanguage('objectivec', _objectivec.default);
123
123
 
124
- _highlight.default.registerLanguage('oc', _objectivec.default);
124
+ _core.default.registerLanguage('oc', _objectivec.default);
125
125
 
126
126
  function CodeBlock(_ref) {
127
127
  let {
@@ -152,7 +152,7 @@ function CodeBlock(_ref) {
152
152
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("code", {
153
153
  className: "hljs ".concat(language),
154
154
  dangerouslySetInnerHTML: {
155
- __html: _highlight.default.highlightAuto(source, [language]).value
155
+ __html: _core.default.highlightAuto(source, [language]).value
156
156
  }
157
157
  })
158
158
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_IconButton.default, {
@@ -31,17 +31,15 @@ var _Box = _interopRequireDefault(require("@mui/material/Box"));
31
31
 
32
32
  var _Check = _interopRequireDefault(require("@mui/icons-material/Check"));
33
33
 
34
+ var _Globe = _interopRequireDefault(require("@arcblock/icons/lib/Globe"));
35
+
34
36
  var _Util = require("../Util");
35
37
 
36
38
  var _context = require("./context");
37
39
 
38
- var _globeDark = _interopRequireDefault(require("./images/globe-dark.png"));
39
-
40
- var _globeLight = _interopRequireDefault(require("./images/globe-light.png"));
41
-
42
40
  var _jsxRuntime = require("react/jsx-runtime");
43
41
 
44
- const _excluded = ["dark", "showText", "popperProps", "popperType", "icon"];
42
+ const _excluded = ["showText", "popperProps", "popperType", "icon"];
45
43
 
46
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
47
45
 
@@ -56,8 +54,9 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
56
54
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
57
55
 
58
56
  function LocaleSelector(props) {
57
+ var _theme$palette, _theme$palette2, _theme$palette2$text;
58
+
59
59
  const {
60
- dark,
61
60
  showText,
62
61
  popperProps,
63
62
  popperType,
@@ -72,6 +71,7 @@ function LocaleSelector(props) {
72
71
  const anchorEl = (0, _react.useRef)(null);
73
72
  const [open, setOpen] = (0, _react.useState)(false);
74
73
  const theme = (0, _styles.useTheme)();
74
+ const dark = (theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.mode) === 'dark';
75
75
 
76
76
  const onSelect = newLocale => {
77
77
  changeLocale(newLocale);
@@ -107,12 +107,14 @@ function LocaleSelector(props) {
107
107
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {});
108
108
  }
109
109
 
110
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
111
- src: dark ? _globeDark.default : _globeLight.default,
112
- className: "trigger-image",
113
- alt: "globe"
110
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Globe.default, {
111
+ style: {
112
+ width: 26,
113
+ height: 24.76,
114
+ color: theme.palette.text.secondary
115
+ }
114
116
  });
115
- }, [Icon, dark]);
117
+ }, [Icon, theme === null || theme === void 0 ? void 0 : (_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : (_theme$palette2$text = _theme$palette2.text) === null || _theme$palette2$text === void 0 ? void 0 : _theme$palette2$text.secondary]);
116
118
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Div, _objectSpread(_objectSpread(_objectSpread({
117
119
  component: "div",
118
120
  dark: dark,
@@ -162,7 +164,6 @@ function LocaleSelector(props) {
162
164
  }
163
165
 
164
166
  LocaleSelector.propTypes = {
165
- dark: _propTypes.default.bool,
166
167
  size: _propTypes.default.number,
167
168
  showText: _propTypes.default.bool,
168
169
  popperProps: _propTypes.default.object,
@@ -171,7 +172,6 @@ LocaleSelector.propTypes = {
171
172
  icon: _propTypes.default.any
172
173
  };
173
174
  LocaleSelector.defaultProps = {
174
- dark: false,
175
175
  showText: true,
176
176
  size: 24,
177
177
  popperProps: {},
@@ -3,155 +3,30 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.create = void 0;
7
-
8
- var _styles = require("@mui/material/styles");
9
-
10
- require("@fontsource/lato/400.css");
11
-
12
- require("@fontsource/lato/700.css");
13
-
14
- var _Colors = _interopRequireDefault(require("../Colors"));
15
-
16
- const _excluded = ["mode", "pageWidth", "palette", "typography", "overrides"];
17
-
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
-
22
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
-
24
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
-
26
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
-
28
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
-
30
- const muiDarkTheme = (0, _styles.createTheme)({
31
- palette: {
32
- mode: 'dark'
6
+ var _exportNames = {
7
+ ThemeProvider: true
8
+ };
9
+ Object.defineProperty(exports, "ThemeProvider", {
10
+ enumerable: true,
11
+ get: function get() {
12
+ return _themeProvider.default;
33
13
  }
34
- }); // https://material-ui.com/customization/default-theme/
35
- // eslint-disable-next-line import/prefer-default-export
36
-
37
- const create = function create() {
38
- let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
- {
40
- mode = 'light',
41
- pageWidth = 'md',
42
- palette,
43
- typography,
44
- overrides
45
- } = _ref,
46
- rest = _objectWithoutProperties(_ref, _excluded);
47
-
48
- // palette 考虑 light & dark mode, dark mode 需要持续完善
49
- // - 能配合 ColorModeContext 使用
50
- // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
51
- const _palette = mode === 'light' ? Object.assign(_objectSpread(_objectSpread({}, _Colors.default), {}, {
52
- background: {
53
- paper: _Colors.default.common.white,
54
- default: _Colors.default.background.default
55
- },
56
- mode
57
- }), palette || {}) : Object.assign(_objectSpread(_objectSpread({}, muiDarkTheme.palette), {}, {
58
- background: {
59
- paper: _Colors.default.grey[900],
60
- default: _Colors.default.grey[900]
61
- },
62
- mode
63
- }), palette || {});
14
+ });
64
15
 
65
- const theme = (0, _styles.createTheme)(_objectSpread({
66
- themeName: 'ArcBlock',
67
- palette: _palette,
68
- typography: Object.assign({
69
- useNextVariants: true,
70
- color: {
71
- // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
72
- // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
73
- // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
74
- // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
75
- main: mode === 'light' ? '#222222' : _Colors.default.common.white,
76
- gray: mode === 'light' ? _Colors.default.grey[500] : _Colors.default.grey[300]
77
- },
78
- fontFamily: ['Lato', 'Avenir', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
79
- // 按最新设计规范, 只使用 400/700
80
- fontWeightLight: 400,
81
- fontWeightRegular: 400,
82
- fontWeightMedium: 700,
83
- fontWeightBold: 700,
84
- // button 默认使用粗体
85
- button: {
86
- fontWeight: 700
87
- }
88
- }, typography || {}),
89
- components: _objectSpread({
90
- MuiButton: {
91
- styleOverrides: {
92
- root: {
93
- boxShadow: 'none'
94
- }
95
- }
96
- },
97
- MuiButtonGroup: {
98
- styleOverrides: {
99
- root: {
100
- boxShadow: 'none'
101
- }
102
- }
103
- },
104
- MuiTableCell: {
105
- styleOverrides: {
106
- root: {
107
- borderBottomWidth: '0',
108
- paddingTop: '14px',
109
- paddingBottom: '14px',
110
- paddingLeft: 0,
111
- paddingRight: '30px'
112
- },
113
- head: {
114
- textTransform: 'uppercase',
115
- color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
116
- },
117
- body: {
118
- color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
119
- }
120
- }
121
- }
122
- }, overrides),
123
- pageWidth,
124
- // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
125
- // 可以从 Colors 模块/theme.palette/mui colors 中取值
126
- colors: {
127
- white: '#FFFFFF',
128
- dark: '#4A707C',
129
- gray: '#222222',
130
- minor: '#9B9B9B',
131
- darkText: '#DCDCDC',
132
- background: '#F7F8F8',
133
- yellow: '#FFCF71',
134
- green: '#44cdc6',
135
- red: '#D0021B',
136
- blue: '#4E6AF6',
137
- primary: '#222222',
138
- black: '#222222',
139
- secondary: '#44cdc6',
140
- mint: '#44cdc6',
141
- textSecondary: '#4A4A4A',
142
- active: '#5b9025',
143
- danger: '#D0021B',
144
- lightGrey: '#BCBCBC'
145
- },
146
- mode
147
- }, rest));
148
- const enhanced = (0, _styles.responsiveFontSizes)(theme, {
149
- breakpoints: ['xs', 'sm', 'md', 'lg'],
150
- disableAlign: false,
151
- factor: 3,
152
- variants: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline']
16
+ var _theme = require("./theme");
17
+
18
+ Object.keys(_theme).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
21
+ if (key in exports && exports[key] === _theme[key]) return;
22
+ Object.defineProperty(exports, key, {
23
+ enumerable: true,
24
+ get: function get() {
25
+ return _theme[key];
26
+ }
153
27
  });
154
- return enhanced;
155
- };
28
+ });
29
+
30
+ var _themeProvider = _interopRequireDefault(require("./theme-provider"));
156
31
 
157
- exports.create = create;
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = ThemeProvider;
7
+
8
+ var _propTypes = _interopRequireDefault(require("prop-types"));
9
+
10
+ var _styledComponents = require("styled-components");
11
+
12
+ var _styles = require("@mui/material/styles");
13
+
14
+ var _StyledEngineProvider = _interopRequireDefault(require("@mui/material/StyledEngineProvider"));
15
+
16
+ var _CssBaseline = _interopRequireDefault(require("@mui/material/CssBaseline"));
17
+
18
+ var _theme = require("./theme");
19
+
20
+ var _jsxRuntime = require("react/jsx-runtime");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
+
24
+ const defaultTheme = (0, _theme.create)();
25
+ /**
26
+ * 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
27
+ * 注: 目前 UX 依赖 styled-components, 所以该组件也内置了一个 StyledThemeProvider
28
+ */
29
+
30
+ function ThemeProvider(_ref) {
31
+ let {
32
+ children,
33
+ theme
34
+ } = _ref;
35
+ return (
36
+ /*#__PURE__*/
37
+ // injectFirst 会影响 makeStyles 自定义样式和 mui styles 覆盖问题
38
+ (0, _jsxRuntime.jsx)(_StyledEngineProvider.default, {
39
+ injectFirst: true,
40
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.ThemeProvider, {
41
+ theme: theme,
42
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_styledComponents.ThemeProvider, {
43
+ theme: theme,
44
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CssBaseline.default, {}), children]
45
+ })
46
+ })
47
+ })
48
+ );
49
+ }
50
+
51
+ ThemeProvider.propTypes = {
52
+ children: _propTypes.default.any,
53
+ theme: _propTypes.default.any
54
+ };
55
+ ThemeProvider.defaultProps = {
56
+ children: null,
57
+ theme: defaultTheme
58
+ };
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.create = void 0;
7
+
8
+ var _styles = require("@mui/material/styles");
9
+
10
+ require("@fontsource/lato/400.css");
11
+
12
+ require("@fontsource/lato/700.css");
13
+
14
+ var _Colors = _interopRequireDefault(require("../Colors"));
15
+
16
+ const _excluded = ["mode", "pageWidth", "palette", "typography", "overrides"];
17
+
18
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
25
+
26
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
27
+
28
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
29
+
30
+ const muiDarkTheme = (0, _styles.createTheme)({
31
+ palette: {
32
+ mode: 'dark'
33
+ }
34
+ }); // https://material-ui.com/customization/default-theme/
35
+ // eslint-disable-next-line import/prefer-default-export
36
+
37
+ const create = function create() {
38
+ let _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
39
+ {
40
+ mode = 'light',
41
+ pageWidth = 'md',
42
+ palette,
43
+ typography,
44
+ overrides
45
+ } = _ref,
46
+ rest = _objectWithoutProperties(_ref, _excluded);
47
+
48
+ // palette 考虑 light & dark mode, dark mode 需要持续完善
49
+ // - 能配合 ColorModeContext 使用
50
+ // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
51
+ const _palette = mode === 'light' ? Object.assign(_objectSpread(_objectSpread({}, _Colors.default), {}, {
52
+ background: {
53
+ paper: _Colors.default.common.white,
54
+ default: _Colors.default.background.default
55
+ },
56
+ mode
57
+ }), palette || {}) : Object.assign(_objectSpread(_objectSpread({}, muiDarkTheme.palette), {}, {
58
+ background: {
59
+ paper: _Colors.default.grey[900],
60
+ default: _Colors.default.grey[900]
61
+ },
62
+ mode
63
+ }), palette || {});
64
+
65
+ const theme = (0, _styles.createTheme)(_objectSpread({
66
+ themeName: 'ArcBlock',
67
+ palette: _palette,
68
+ typography: Object.assign({
69
+ useNextVariants: true,
70
+ color: {
71
+ // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
72
+ // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
73
+ // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
74
+ // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
75
+ main: mode === 'light' ? '#222222' : _Colors.default.common.white,
76
+ gray: mode === 'light' ? _Colors.default.grey[500] : _Colors.default.grey[300]
77
+ },
78
+ fontFamily: ['Lato', 'Avenir', '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
79
+ // 按最新设计规范, 只使用 400/700
80
+ fontWeightLight: 400,
81
+ fontWeightRegular: 400,
82
+ fontWeightMedium: 700,
83
+ fontWeightBold: 700,
84
+ // button 默认使用粗体
85
+ button: {
86
+ fontWeight: 700
87
+ }
88
+ }, typography || {}),
89
+ components: _objectSpread({
90
+ MuiButton: {
91
+ styleOverrides: {
92
+ root: {
93
+ boxShadow: 'none'
94
+ }
95
+ }
96
+ },
97
+ MuiButtonGroup: {
98
+ styleOverrides: {
99
+ root: {
100
+ boxShadow: 'none'
101
+ }
102
+ }
103
+ },
104
+ MuiTableCell: {
105
+ styleOverrides: {
106
+ root: {
107
+ borderBottomWidth: '0',
108
+ paddingTop: '14px',
109
+ paddingBottom: '14px',
110
+ paddingLeft: 0,
111
+ paddingRight: '30px'
112
+ },
113
+ head: {
114
+ textTransform: 'uppercase',
115
+ color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
116
+ },
117
+ body: {
118
+ color: mode === 'light' ? _Colors.default.grey[900] : _Colors.default.grey[300]
119
+ }
120
+ }
121
+ }
122
+ }, overrides),
123
+ pageWidth,
124
+ // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
125
+ // 可以从 Colors 模块/theme.palette/mui colors 中取值
126
+ colors: {
127
+ white: '#FFFFFF',
128
+ dark: '#4A707C',
129
+ gray: '#222222',
130
+ minor: '#9B9B9B',
131
+ darkText: '#DCDCDC',
132
+ background: '#F7F8F8',
133
+ yellow: '#FFCF71',
134
+ green: '#44cdc6',
135
+ red: '#D0021B',
136
+ blue: '#4E6AF6',
137
+ primary: '#222222',
138
+ black: '#222222',
139
+ secondary: '#44cdc6',
140
+ mint: '#44cdc6',
141
+ textSecondary: '#4A4A4A',
142
+ active: '#5b9025',
143
+ danger: '#D0021B',
144
+ lightGrey: '#BCBCBC'
145
+ },
146
+ mode
147
+ }, rest));
148
+ const enhanced = (0, _styles.responsiveFontSizes)(theme, {
149
+ breakpoints: ['xs', 'sm', 'md', 'lg'],
150
+ disableAlign: false,
151
+ factor: 3,
152
+ variants: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'subtitle1', 'subtitle2', 'body1', 'body2', 'caption', 'button', 'overline']
153
+ });
154
+ return enhanced;
155
+ };
156
+
157
+ exports.create = create;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.1.68",
3
+ "version": "2.1.71",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -48,10 +48,10 @@
48
48
  "react": ">=18.1.0",
49
49
  "react-ga": "^2.7.0"
50
50
  },
51
- "gitHead": "eb2261cc2a82cf9db7cec0dc66d1e32bc3bf7398",
51
+ "gitHead": "1f224c97d5d033351fde521ef22898492e8f40aa",
52
52
  "dependencies": {
53
- "@arcblock/icons": "^2.1.68",
54
- "@arcblock/react-hooks": "^2.1.68",
53
+ "@arcblock/icons": "^2.1.71",
54
+ "@arcblock/react-hooks": "^2.1.71",
55
55
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
56
  "@emotion/react": "^11.9.0",
57
57
  "@emotion/styled": "^11.8.1",
@@ -66,7 +66,7 @@
66
66
  "d3-geo": "^1.11.6",
67
67
  "dayjs": "^1.11.2",
68
68
  "devices.css": "^0.1.15",
69
- "highlight.js": "^9.15.8",
69
+ "highlight.js": "^11.6.0",
70
70
  "is-svg": "^4.3.1",
71
71
  "js-cookie": "^2.2.0",
72
72
  "lodash": "^4.17.21",
@@ -6,7 +6,7 @@ import Copy from 'copy-to-clipboard';
6
6
  import Button from '@mui/material/IconButton';
7
7
  import useMountedState from 'react-use/lib/useMountedState';
8
8
 
9
- import hljs from 'highlight.js/lib/highlight';
9
+ import hljs from 'highlight.js/lib/core';
10
10
  import javascript from 'highlight.js/lib/languages/javascript';
11
11
  import typescript from 'highlight.js/lib/languages/typescript';
12
12
  import json from 'highlight.js/lib/languages/json';
@@ -13,20 +13,19 @@ import MenuItem from '@mui/material/MenuItem';
13
13
  import MenuList from '@mui/material/MenuList';
14
14
  import Box from '@mui/material/Box';
15
15
  import CheckIcon from '@mui/icons-material/Check';
16
+ import GlobeIcon from '@arcblock/icons/lib/Globe';
16
17
 
17
18
  import { getColor, getBackground } from '../Util';
18
19
 
19
20
  import { LocaleContext, languages } from './context';
20
21
 
21
- import globeDark from './images/globe-dark.png';
22
- import globeLight from './images/globe-light.png';
23
-
24
22
  function LocaleSelector(props) {
25
- const { dark, showText, popperProps, popperType, icon: Icon, ...rest } = props;
23
+ const { showText, popperProps, popperType, icon: Icon, ...rest } = props;
26
24
  const { locale, changeLocale } = useContext(LocaleContext);
27
25
  const anchorEl = useRef(null);
28
26
  const [open, setOpen] = useState(false);
29
27
  const theme = useTheme();
28
+ const dark = theme?.palette?.mode === 'dark';
30
29
 
31
30
  const onSelect = (newLocale) => {
32
31
  changeLocale(newLocale);
@@ -64,8 +63,8 @@ function LocaleSelector(props) {
64
63
  return <Icon />;
65
64
  }
66
65
 
67
- return <img src={dark ? globeDark : globeLight} className="trigger-image" alt="globe" />;
68
- }, [Icon, dark]);
66
+ return <GlobeIcon style={{ width: 26, height: 24.76, color: theme.palette.text.secondary }} />;
67
+ }, [Icon, theme?.palette?.text?.secondary]);
69
68
 
70
69
  return (
71
70
  <Div component="div" dark={dark} theme={theme} {...rest} {...handleEventProps}>
@@ -105,7 +104,6 @@ function LocaleSelector(props) {
105
104
  }
106
105
 
107
106
  LocaleSelector.propTypes = {
108
- dark: PropTypes.bool,
109
107
  size: PropTypes.number,
110
108
  showText: PropTypes.bool,
111
109
  popperProps: PropTypes.object,
@@ -115,7 +113,6 @@ LocaleSelector.propTypes = {
115
113
  };
116
114
 
117
115
  LocaleSelector.defaultProps = {
118
- dark: false,
119
116
  showText: true,
120
117
  size: 24,
121
118
  popperProps: {},
@@ -1,164 +1,2 @@
1
- // https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
2
- import { createTheme, responsiveFontSizes } from '@mui/material/styles';
3
- import '@fontsource/lato/400.css';
4
- import '@fontsource/lato/700.css';
5
- import colors from '../Colors';
6
-
7
- const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
8
-
9
- // https://material-ui.com/customization/default-theme/
10
- // eslint-disable-next-line import/prefer-default-export
11
- export const create = ({ mode = 'light', pageWidth = 'md', palette, typography, overrides, ...rest } = {}) => {
12
- // palette 考虑 light & dark mode, dark mode 需要持续完善
13
- // - 能配合 ColorModeContext 使用
14
- // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
15
- const _palette =
16
- mode === 'light'
17
- ? Object.assign(
18
- {
19
- ...colors,
20
- background: {
21
- paper: colors.common.white,
22
- default: colors.background.default,
23
- },
24
- mode,
25
- },
26
- palette || {}
27
- )
28
- : Object.assign(
29
- {
30
- ...muiDarkTheme.palette,
31
- background: {
32
- paper: colors.grey[900],
33
- default: colors.grey[900],
34
- },
35
- mode,
36
- },
37
- palette || {}
38
- );
39
-
40
- const theme = createTheme({
41
- themeName: 'ArcBlock',
42
- palette: _palette,
43
- typography: Object.assign(
44
- {
45
- useNextVariants: true,
46
- color: {
47
- // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
48
- // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
49
- // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
50
- // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
51
- main: mode === 'light' ? '#222222' : colors.common.white,
52
- gray: mode === 'light' ? colors.grey[500] : colors.grey[300],
53
- },
54
- fontFamily: [
55
- 'Lato',
56
- 'Avenir',
57
- '-apple-system',
58
- 'BlinkMacSystemFont',
59
- '"Segoe UI"',
60
- 'Roboto',
61
- '"Helvetica Neue"',
62
- 'Arial',
63
- 'sans-serif',
64
- '"Apple Color Emoji"',
65
- '"Segoe UI Emoji"',
66
- '"Segoe UI Symbol"',
67
- ].join(','),
68
- // 按最新设计规范, 只使用 400/700
69
- fontWeightLight: 400,
70
- fontWeightRegular: 400,
71
- fontWeightMedium: 700,
72
- fontWeightBold: 700,
73
- // button 默认使用粗体
74
- button: {
75
- fontWeight: 700,
76
- },
77
- },
78
- typography || {}
79
- ),
80
- components: {
81
- MuiButton: {
82
- styleOverrides: {
83
- root: {
84
- boxShadow: 'none',
85
- },
86
- },
87
- },
88
- MuiButtonGroup: {
89
- styleOverrides: {
90
- root: {
91
- boxShadow: 'none',
92
- },
93
- },
94
- },
95
- MuiTableCell: {
96
- styleOverrides: {
97
- root: {
98
- borderBottomWidth: '0',
99
- paddingTop: '14px',
100
- paddingBottom: '14px',
101
- paddingLeft: 0,
102
- paddingRight: '30px',
103
- },
104
- head: {
105
- textTransform: 'uppercase',
106
- color: mode === 'light' ? colors.grey[900] : colors.grey[300],
107
- },
108
- body: {
109
- color: mode === 'light' ? colors.grey[900] : colors.grey[300],
110
- },
111
- },
112
- },
113
- ...overrides,
114
- },
115
- pageWidth,
116
- // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
117
- // 可以从 Colors 模块/theme.palette/mui colors 中取值
118
- colors: {
119
- white: '#FFFFFF',
120
- dark: '#4A707C',
121
- gray: '#222222',
122
- minor: '#9B9B9B',
123
- darkText: '#DCDCDC',
124
- background: '#F7F8F8',
125
- yellow: '#FFCF71',
126
- green: '#44cdc6',
127
- red: '#D0021B',
128
- blue: '#4E6AF6',
129
- primary: '#222222',
130
- black: '#222222',
131
- secondary: '#44cdc6',
132
- mint: '#44cdc6',
133
- textSecondary: '#4A4A4A',
134
- active: '#5b9025',
135
- danger: '#D0021B',
136
- lightGrey: '#BCBCBC',
137
- },
138
- mode,
139
- ...rest,
140
- });
141
-
142
- const enhanced = responsiveFontSizes(theme, {
143
- breakpoints: ['xs', 'sm', 'md', 'lg'],
144
- disableAlign: false,
145
- factor: 3,
146
- variants: [
147
- 'h1',
148
- 'h2',
149
- 'h3',
150
- 'h4',
151
- 'h5',
152
- 'h6',
153
- 'subtitle1',
154
- 'subtitle2',
155
- 'body1',
156
- 'body2',
157
- 'caption',
158
- 'button',
159
- 'overline',
160
- ],
161
- });
162
-
163
- return enhanced;
164
- };
1
+ export * from './theme';
2
+ export { default as ThemeProvider } from './theme-provider';
@@ -0,0 +1,36 @@
1
+ import PropTypes from 'prop-types';
2
+ import { ThemeProvider as StyledThemeProvider } from 'styled-components';
3
+ import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
4
+ import StyledEngineProvider from '@mui/material/StyledEngineProvider';
5
+ import CssBaseline from '@mui/material/CssBaseline';
6
+ import { create } from './theme';
7
+
8
+ const defaultTheme = create();
9
+
10
+ /**
11
+ * 默认的 theme provider, 可以为 webapp/blocklet 快捷的配置好 mui theme provider
12
+ * 注: 目前 UX 依赖 styled-components, 所以该组件也内置了一个 StyledThemeProvider
13
+ */
14
+ export default function ThemeProvider({ children, theme }) {
15
+ return (
16
+ // injectFirst 会影响 makeStyles 自定义样式和 mui styles 覆盖问题
17
+ <StyledEngineProvider injectFirst>
18
+ <MuiThemeProvider theme={theme}>
19
+ <StyledThemeProvider theme={theme}>
20
+ <CssBaseline />
21
+ {children}
22
+ </StyledThemeProvider>
23
+ </MuiThemeProvider>
24
+ </StyledEngineProvider>
25
+ );
26
+ }
27
+
28
+ ThemeProvider.propTypes = {
29
+ children: PropTypes.any,
30
+ theme: PropTypes.any,
31
+ };
32
+
33
+ ThemeProvider.defaultProps = {
34
+ children: null,
35
+ theme: defaultTheme,
36
+ };
@@ -0,0 +1,164 @@
1
+ // https://app.zeplin.io/styleguide/5d1436f1e97c2156f49c0725/colors
2
+ import { createTheme, responsiveFontSizes } from '@mui/material/styles';
3
+ import '@fontsource/lato/400.css';
4
+ import '@fontsource/lato/700.css';
5
+ import colors from '../Colors';
6
+
7
+ const muiDarkTheme = createTheme({ palette: { mode: 'dark' } });
8
+
9
+ // https://material-ui.com/customization/default-theme/
10
+ // eslint-disable-next-line import/prefer-default-export
11
+ export const create = ({ mode = 'light', pageWidth = 'md', palette, typography, overrides, ...rest } = {}) => {
12
+ // palette 考虑 light & dark mode, dark mode 需要持续完善
13
+ // - 能配合 ColorModeContext 使用
14
+ // - 为 dark mode 系统的设计整个 palette, 不要单个 color 设置
15
+ const _palette =
16
+ mode === 'light'
17
+ ? Object.assign(
18
+ {
19
+ ...colors,
20
+ background: {
21
+ paper: colors.common.white,
22
+ default: colors.background.default,
23
+ },
24
+ mode,
25
+ },
26
+ palette || {}
27
+ )
28
+ : Object.assign(
29
+ {
30
+ ...muiDarkTheme.palette,
31
+ background: {
32
+ paper: colors.grey[900],
33
+ default: colors.grey[900],
34
+ },
35
+ mode,
36
+ },
37
+ palette || {}
38
+ );
39
+
40
+ const theme = createTheme({
41
+ themeName: 'ArcBlock',
42
+ palette: _palette,
43
+ typography: Object.assign(
44
+ {
45
+ useNextVariants: true,
46
+ color: {
47
+ // 此处 #222222 必须硬编码, layout/sidebar.js -> Icon/image 加载图片时 color 会影响加载路径
48
+ // TODO: 此处硬编码的色值后面需要改为 colors.grey[900],
49
+ // 或者如果可以的话直接删掉 typography#color, 文本颜色建议使用 theme.palette.text 中的色值?
50
+ // layout 组件建议重构, sidebar 中建议使用 icon 替换 img (#366)
51
+ main: mode === 'light' ? '#222222' : colors.common.white,
52
+ gray: mode === 'light' ? colors.grey[500] : colors.grey[300],
53
+ },
54
+ fontFamily: [
55
+ 'Lato',
56
+ 'Avenir',
57
+ '-apple-system',
58
+ 'BlinkMacSystemFont',
59
+ '"Segoe UI"',
60
+ 'Roboto',
61
+ '"Helvetica Neue"',
62
+ 'Arial',
63
+ 'sans-serif',
64
+ '"Apple Color Emoji"',
65
+ '"Segoe UI Emoji"',
66
+ '"Segoe UI Symbol"',
67
+ ].join(','),
68
+ // 按最新设计规范, 只使用 400/700
69
+ fontWeightLight: 400,
70
+ fontWeightRegular: 400,
71
+ fontWeightMedium: 700,
72
+ fontWeightBold: 700,
73
+ // button 默认使用粗体
74
+ button: {
75
+ fontWeight: 700,
76
+ },
77
+ },
78
+ typography || {}
79
+ ),
80
+ components: {
81
+ MuiButton: {
82
+ styleOverrides: {
83
+ root: {
84
+ boxShadow: 'none',
85
+ },
86
+ },
87
+ },
88
+ MuiButtonGroup: {
89
+ styleOverrides: {
90
+ root: {
91
+ boxShadow: 'none',
92
+ },
93
+ },
94
+ },
95
+ MuiTableCell: {
96
+ styleOverrides: {
97
+ root: {
98
+ borderBottomWidth: '0',
99
+ paddingTop: '14px',
100
+ paddingBottom: '14px',
101
+ paddingLeft: 0,
102
+ paddingRight: '30px',
103
+ },
104
+ head: {
105
+ textTransform: 'uppercase',
106
+ color: mode === 'light' ? colors.grey[900] : colors.grey[300],
107
+ },
108
+ body: {
109
+ color: mode === 'light' ? colors.grey[900] : colors.grey[300],
110
+ },
111
+ },
112
+ },
113
+ ...overrides,
114
+ },
115
+ pageWidth,
116
+ // TODO: 过时的 colors, 需要各项目负责人检查项目中是否使用 "theme.colors", 如果有需要清除,
117
+ // 可以从 Colors 模块/theme.palette/mui colors 中取值
118
+ colors: {
119
+ white: '#FFFFFF',
120
+ dark: '#4A707C',
121
+ gray: '#222222',
122
+ minor: '#9B9B9B',
123
+ darkText: '#DCDCDC',
124
+ background: '#F7F8F8',
125
+ yellow: '#FFCF71',
126
+ green: '#44cdc6',
127
+ red: '#D0021B',
128
+ blue: '#4E6AF6',
129
+ primary: '#222222',
130
+ black: '#222222',
131
+ secondary: '#44cdc6',
132
+ mint: '#44cdc6',
133
+ textSecondary: '#4A4A4A',
134
+ active: '#5b9025',
135
+ danger: '#D0021B',
136
+ lightGrey: '#BCBCBC',
137
+ },
138
+ mode,
139
+ ...rest,
140
+ });
141
+
142
+ const enhanced = responsiveFontSizes(theme, {
143
+ breakpoints: ['xs', 'sm', 'md', 'lg'],
144
+ disableAlign: false,
145
+ factor: 3,
146
+ variants: [
147
+ 'h1',
148
+ 'h2',
149
+ 'h3',
150
+ 'h4',
151
+ 'h5',
152
+ 'h6',
153
+ 'subtitle1',
154
+ 'subtitle2',
155
+ 'body1',
156
+ 'body2',
157
+ 'caption',
158
+ 'button',
159
+ 'overline',
160
+ ],
161
+ });
162
+
163
+ return enhanced;
164
+ };
Binary file
Binary file
Binary file
Binary file