@arcblock/ux 2.4.18 → 2.4.21

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.
@@ -28,10 +28,8 @@ function InternalErrorFallback(_ref) {
28
28
  desc,
29
29
  retryFunc
30
30
  } = _ref;
31
- const theme = (0, _Theme.useTheme)();
32
31
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, {
33
32
  role: "alert",
34
- $theme: theme,
35
33
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
36
34
  children: title
37
35
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
@@ -84,4 +82,4 @@ ErrorFallbackRetry.propTypes = {
84
82
  error: _propTypes.default.instanceOf(Error).isRequired,
85
83
  resetErrorBoundary: _propTypes.default.func.isRequired
86
84
  };
87
- const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 16px;\n border: 2px solid ", ";\n border-radius: 4px;\n color: ", ";\n background-color: ", ";\n font-size: 14px;\n h3 {\n margin: 0;\n font-size: 16px;\n }\n pre {\n white-space: normal;\n }\n"])), props => props.$theme.palette.error.main, props => props.$theme.palette.error.main, _colors.red[50]);
85
+ const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 16px;\n border: 2px solid ", ";\n border-radius: 4px;\n color: ", ";\n background-color: ", ";\n font-size: 14px;\n h3 {\n margin: 0;\n font-size: 16px;\n }\n pre {\n white-space: normal;\n }\n"])), props => props.theme.palette.error.main, props => props.theme.palette.error.main, _colors.red[50]);
@@ -53,9 +53,7 @@ function Header(_ref) {
53
53
  } = _ref,
54
54
  rest = _objectWithoutProperties(_ref, _excluded);
55
55
 
56
- const theme = (0, _Theme.useTheme)();
57
56
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, _objectSpread(_objectSpread({}, rest), {}, {
58
- $theme: theme,
59
57
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Container.default, {
60
58
  maxWidth: maxWidth,
61
59
  className: "header-container",
@@ -125,6 +123,6 @@ Header.defaultProps = {
125
123
  align: 'left',
126
124
  maxWidth: undefined
127
125
  };
128
- const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n z-index: ", ";\n font-size: 14px;\n background: ", ";\n .header-container {\n display: flex;\n align-items: center;\n height: 64px;\n }\n .header-logo {\n display: inline-flex;\n position: relative;\n height: 44px;\n margin-right: 16px;\n img,\n svg {\n width: auto;\n height: 100%;\n max-height: 100%;\n }\n > a {\n height: 100%;\n line-height: 1;\n }\n > a::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: transparent;\n content: '';\n }\n }\n .header-brand {\n display: flex;\n flex-direction: column;\n justify-content: center;\n height: 44px;\n margin-right: 16px;\n line-height: 1;\n a {\n color: inherit;\n text-decoration: none;\n }\n .header-brand-title {\n display: flex;\n align-items: center;\n h2 {\n margin: 0;\n font-size: 16px;\n }\n }\n .header-brand-desc {\n margin-top: 4px;\n color: #9397a1;\n }\n }\n .header-brand-addon {\n margin-right: 16px;\n }\n .header-addons {\n display: flex;\n align-items: center;\n }\n ", " {\n .header-brand {\n margin-right: 12px;\n .header-brand-title {\n h2 {\n font-size: 14px;\n }\n }\n }\n }\n ", " {\n .header-menu {\n display: inline-block;\n }\n .header-logo {\n height: 32px;\n }\n .header-brand {\n .header-brand-title {\n h2 {\n font-size: 13px;\n }\n }\n .header-brand-desc {\n font-size: 12px;\n }\n }\n .header-brand-addon {\n display: none;\n }\n }\n"])), props => props.$theme.zIndex.appBar, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('md'));
126
+ const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n z-index: ", ";\n font-size: 14px;\n background: ", ";\n .header-container {\n display: flex;\n align-items: center;\n height: 64px;\n }\n .header-logo {\n display: inline-flex;\n position: relative;\n height: 44px;\n margin-right: 16px;\n img,\n svg {\n width: auto;\n height: 100%;\n max-height: 100%;\n }\n > a {\n height: 100%;\n line-height: 1;\n }\n > a::before {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: transparent;\n content: '';\n }\n }\n .header-brand {\n display: flex;\n flex-direction: column;\n justify-content: center;\n height: 44px;\n margin-right: 16px;\n line-height: 1;\n a {\n color: inherit;\n text-decoration: none;\n }\n .header-brand-title {\n display: flex;\n align-items: center;\n h2 {\n margin: 0;\n font-size: 16px;\n }\n }\n .header-brand-desc {\n margin-top: 4px;\n color: #9397a1;\n }\n }\n .header-brand-addon {\n margin-right: 16px;\n }\n .header-addons {\n display: flex;\n align-items: center;\n }\n ", " {\n .header-brand {\n margin-right: 12px;\n .header-brand-title {\n h2 {\n font-size: 14px;\n }\n }\n }\n }\n ", " {\n .header-menu {\n display: inline-block;\n }\n .header-logo {\n height: 32px;\n }\n .header-brand {\n .header-brand-title {\n h2 {\n font-size: 13px;\n }\n }\n .header-brand-desc {\n font-size: 12px;\n }\n }\n .header-brand-addon {\n display: none;\n }\n }\n"])), props => props.theme.zIndex.appBar, props => props.theme.palette.common.white, props => props.theme.breakpoints.down('lg'), props => props.theme.breakpoints.down('md'));
129
127
  var _default = Header;
130
128
  exports.default = _default;
@@ -88,7 +88,6 @@ function ResponsiveHeader(_ref) {
88
88
  children: drawerOpen ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Close.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Menu.default, {})
89
89
  })
90
90
  }, rest), {}, {
91
- $theme: theme,
92
91
  children: [!isMobile && _children, isMobile && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Drawer.default, {
93
92
  open: drawerOpen,
94
93
  onClose: () => setDrawerOpen(false),
@@ -123,7 +122,7 @@ ResponsiveHeader.propTypes = _objectSpread(_objectSpread({}, _header.default.Pro
123
122
  children: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.func])
124
123
  });
125
124
  ResponsiveHeader.defaultProps = _objectSpread({}, _header.default.defaultProps);
126
- const Root = (0, _Theme.styled)(_header.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .header-menu {\n display: none;\n }\n ", " {\n .header-menu {\n display: flex;\n margin-right: 12px;\n }\n }\n"])), props => props.$theme.breakpoints.down('md'));
125
+ const Root = (0, _Theme.styled)(_header.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n .header-menu {\n display: none;\n }\n ", " {\n .header-menu {\n display: flex;\n margin-right: 12px;\n }\n }\n"])), props => props.theme.breakpoints.down('md'));
127
126
  const MenuPanel = (0, _Theme.styled)(_Container.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-top: 8px;\n padding-bottom: 16px;\n .navmenu {\n margin: 0 -16px;\n .navmenu-root > .navmenu-item,\n .navmenu-root > .navmenu-sub {\n border: 0;\n }\n }\n"])));
128
127
  var _default = ResponsiveHeader;
129
128
  exports.default = _default;
@@ -184,4 +184,4 @@ LocaleSelector.defaultProps = {
184
184
  };
185
185
  var _default = LocaleSelector;
186
186
  exports.default = _default;
187
- const Div = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-block;\n\n .trigger {\n display: flex;\n flex-direction: column;\n justify-content: center;\n font-size: 14px;\n\n .trigger-text {\n margin-left: 5px;\n font-size: 14px;\n color: ", ";\n }\n }\n\n .locales {\n background: ", ";\n }\n\n .locale-item {\n font-size: 16px;\n font-style: normal;\n font-stretch: normal;\n line-height: normal;\n letter-spacing: 2px;\n text-align: center;\n color: ", ";\n cursor: pointer;\n display: flex;\n padding: 16px;\n align-items: center;\n .check-icon {\n visibility: hidden;\n margin-right: 4px;\n }\n .check-icon-visible {\n visibility: visible;\n }\n }\n"])), props => (0, _Util.getColor)(props), props => (0, _Util.getBackground)(props), props => (0, _Util.getColor)(props));
187
+ const Div = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-block;\n\n .trigger {\n display: flex;\n flex-direction: column;\n justify-content: center;\n font-size: 14px;\n\n .trigger-text {\n margin-left: 5px;\n font-size: 14px;\n color: ", ";\n }\n }\n\n .locales {\n background: ", ";\n box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);\n }\n\n .locale-item {\n font-size: 16px;\n font-style: normal;\n font-stretch: normal;\n line-height: normal;\n letter-spacing: 2px;\n text-align: center;\n color: ", ";\n cursor: pointer;\n display: flex;\n padding: 16px;\n align-items: center;\n .check-icon {\n visibility: hidden;\n margin-right: 4px;\n }\n .check-icon-visible {\n visibility: visible;\n }\n }\n"])), props => (0, _Util.getColor)(props), props => (0, _Util.getBackground)(props), props => (0, _Util.getColor)(props));
@@ -14,12 +14,7 @@ Object.defineProperty(exports, "ThemeProvider", {
14
14
  return _themeProvider.default;
15
15
  }
16
16
  });
17
- Object.defineProperty(exports, "styled", {
18
- enumerable: true,
19
- get: function get() {
20
- return _styles.styled;
21
- }
22
- });
17
+ exports.styled = void 0;
23
18
  Object.defineProperty(exports, "useTheme", {
24
19
  enumerable: true,
25
20
  get: function get() {
@@ -27,6 +22,8 @@ Object.defineProperty(exports, "useTheme", {
27
22
  }
28
23
  });
29
24
 
25
+ var _styles = require("@mui/material/styles");
26
+
30
27
  var _theme = require("./theme");
31
28
 
32
29
  Object.keys(_theme).forEach(function (key) {
@@ -41,8 +38,29 @@ Object.keys(_theme).forEach(function (key) {
41
38
  });
42
39
  });
43
40
 
44
- var _styles = require("@mui/material/styles");
45
-
46
41
  var _themeProvider = _interopRequireDefault(require("./theme-provider"));
47
42
 
48
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
+
45
+ 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; }
46
+
47
+ 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; }
48
+
49
+ 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; }
50
+
51
+ const isTransientProp = prop => prop.startsWith('$');
52
+
53
+ const styled = function styled(component) {
54
+ let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
55
+ return (0, _styles.styled)(component, _objectSpread(_objectSpread({}, options), {}, {
56
+ shouldForwardProp: prop => {
57
+ if (options.shouldForwardProp) {
58
+ return options.shouldForwardProp(prop) && !isTransientProp(prop);
59
+ }
60
+
61
+ return !isTransientProp(prop);
62
+ }
63
+ }));
64
+ };
65
+
66
+ exports.styled = styled;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.4.18",
3
+ "version": "2.4.21",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -19,11 +19,11 @@
19
19
  "lint": "eslint src tests",
20
20
  "build": "babel src --out-dir lib --copy-files --no-copy-ignored",
21
21
  "watch": "babel src --out-dir lib -w --copy-files --no-copy-ignored",
22
- "precommit": "CI=1 yarn test",
23
- "prepush": "CI=1 yarn test",
22
+ "precommit": "CI=1 npm run lint",
23
+ "prepush": "CI=1 npm run lint",
24
24
  "prepublish": "npm run build",
25
- "test": "npm run lint && node tools/jest.js",
26
- "coverage": "npm run lint && yarn test -- --coverage"
25
+ "test": "node tools/jest.js",
26
+ "coverage": "npm run test -- --coverage"
27
27
  },
28
28
  "bugs": {
29
29
  "url": "https://github.com/ArcBlock/ux/issues"
@@ -39,7 +39,7 @@
39
39
  "@babel/preset-react": "^7.18.6",
40
40
  "babel-plugin-inline-react-svg": "^1.1.2",
41
41
  "eslint-plugin-react-hooks": "^4.6.0",
42
- "jest": "^24.9.0",
42
+ "jest": "^28.1.3",
43
43
  "moment-timezone": "^0.5.34"
44
44
  },
45
45
  "peerDependencies": {
@@ -47,10 +47,10 @@
47
47
  "react": ">=18.1.0",
48
48
  "react-ga": "^2.7.0"
49
49
  },
50
- "gitHead": "45fe2e3b1726e2172aad280f62b81dea7e353f1b",
50
+ "gitHead": "5989f403515c81eaaa1c1b459b1d79daf8cca317",
51
51
  "dependencies": {
52
- "@arcblock/icons": "^2.4.18",
53
- "@arcblock/react-hooks": "^2.4.18",
52
+ "@arcblock/icons": "^2.4.21",
53
+ "@arcblock/react-hooks": "^2.4.21",
54
54
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
55
55
  "@emotion/react": "^11.10.0",
56
56
  "@emotion/styled": "^11.10.0",
@@ -1,12 +1,11 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import { red } from '@mui/material/colors';
3
3
  import Button from '../Button';
4
- import { styled, useTheme } from '../Theme';
4
+ import { styled } from '../Theme';
5
5
 
6
6
  function InternalErrorFallback({ title, desc, retryFunc }) {
7
- const theme = useTheme();
8
7
  return (
9
- <Root role="alert" $theme={theme}>
8
+ <Root role="alert">
10
9
  <h3>{title}</h3>
11
10
  <pre>{desc}</pre>
12
11
  {retryFunc && (
@@ -47,9 +46,9 @@ ErrorFallbackRetry.propTypes = {
47
46
 
48
47
  const Root = styled('div')`
49
48
  padding: 16px;
50
- border: 2px solid ${(props) => props.$theme.palette.error.main};
49
+ border: 2px solid ${(props) => props.theme.palette.error.main};
51
50
  border-radius: 4px;
52
- color: ${(props) => props.$theme.palette.error.main};
51
+ color: ${(props) => props.theme.palette.error.main};
53
52
  background-color: ${red[50]};
54
53
  font-size: 14px;
55
54
  h3 {
@@ -2,16 +2,15 @@ import PropTypes from 'prop-types';
2
2
  import Box from '@mui/material/Box';
3
3
  import Container from '@mui/material/Container';
4
4
  import AutoHidden from './auto-hidden';
5
- import { styled, useTheme } from '../Theme';
5
+ import { styled } from '../Theme';
6
6
 
7
7
  /**
8
8
  * Header 组件
9
9
  * TODO: Layout/dashboard 可以复用此处的 header
10
10
  */
11
11
  function Header({ logo, brand, brandAddon, description, children, addons, prepend, align, maxWidth, ...rest }) {
12
- const theme = useTheme();
13
12
  return (
14
- <Root {...rest} $theme={theme}>
13
+ <Root {...rest}>
15
14
  <Container maxWidth={maxWidth} className="header-container">
16
15
  {prepend}
17
16
  {logo && <div className="header-logo">{logo}</div>}
@@ -65,9 +64,9 @@ Header.defaultProps = {
65
64
 
66
65
  const Root = styled('div')`
67
66
  position: relative;
68
- z-index: ${(props) => props.$theme.zIndex.appBar};
67
+ z-index: ${(props) => props.theme.zIndex.appBar};
69
68
  font-size: 14px;
70
- background: ${(props) => props.$theme.palette.common.white};
69
+ background: ${(props) => props.theme.palette.common.white};
71
70
  .header-container {
72
71
  display: flex;
73
72
  align-items: center;
@@ -129,7 +128,7 @@ const Root = styled('div')`
129
128
  display: flex;
130
129
  align-items: center;
131
130
  }
132
- ${(props) => props.$theme.breakpoints.down('lg')} {
131
+ ${(props) => props.theme.breakpoints.down('lg')} {
133
132
  .header-brand {
134
133
  margin-right: 12px;
135
134
  .header-brand-title {
@@ -139,7 +138,7 @@ const Root = styled('div')`
139
138
  }
140
139
  }
141
140
  }
142
- ${(props) => props.$theme.breakpoints.down('md')} {
141
+ ${(props) => props.theme.breakpoints.down('md')} {
143
142
  .header-menu {
144
143
  display: inline-block;
145
144
  }
@@ -40,8 +40,7 @@ function ResponsiveHeader({ menu, prepend, children, ...rest }) {
40
40
  </Button>
41
41
  )
42
42
  }
43
- {...rest}
44
- $theme={theme}>
43
+ {...rest}>
45
44
  {!isMobile && _children}
46
45
  {isMobile && (
47
46
  <Drawer
@@ -74,7 +73,7 @@ const Root = styled(Header)`
74
73
  .header-menu {
75
74
  display: none;
76
75
  }
77
- ${(props) => props.$theme.breakpoints.down('md')} {
76
+ ${(props) => props.theme.breakpoints.down('md')} {
78
77
  .header-menu {
79
78
  display: flex;
80
79
  margin-right: 12px;
@@ -139,6 +139,7 @@ const Div = styled('div')`
139
139
 
140
140
  .locales {
141
141
  background: ${(props) => getBackground(props)};
142
+ box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
142
143
  }
143
144
 
144
145
  .locale-item {
@@ -1,3 +1,19 @@
1
+ import { styled as muiStyled, useTheme } from '@mui/material/styles';
2
+
1
3
  export * from './theme';
2
- export { styled, useTheme } from '@mui/material/styles';
3
4
  export { default as ThemeProvider } from './theme-provider';
5
+ export { useTheme };
6
+
7
+ const isTransientProp = (prop) => prop.startsWith('$');
8
+
9
+ export const styled = (component, options = {}) => {
10
+ return muiStyled(component, {
11
+ ...options,
12
+ shouldForwardProp: (prop) => {
13
+ if (options.shouldForwardProp) {
14
+ return options.shouldForwardProp(prop) && !isTransientProp(prop);
15
+ }
16
+ return !isTransientProp(prop);
17
+ },
18
+ });
19
+ };