@arcblock/ux 2.9.16 → 2.9.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,7 @@
1
1
  import { useRef, useLayoutEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { update } from '@arcblock/did-motif';
4
+ import { Box } from '@mui/material';
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  function DIDMotif({
6
7
  did,
@@ -25,13 +26,15 @@ function DIDMotif({
25
26
  ...rest.style,
26
27
  width: '100%'
27
28
  };
28
- return /*#__PURE__*/_jsx("svg", {
29
+ return /*#__PURE__*/_jsx(Box, {
30
+ component: "svg",
29
31
  ref: svgRef,
30
32
  ...rest,
31
33
  style: styles
32
34
  });
33
35
  }
34
- return /*#__PURE__*/_jsx("span", {
36
+ return /*#__PURE__*/_jsx(Box, {
37
+ component: "span",
35
38
  ...rest,
36
39
  style: {
37
40
  display: 'inline-block',
@@ -39,7 +42,8 @@ function DIDMotif({
39
42
  height: size,
40
43
  ...rest.style
41
44
  },
42
- children: /*#__PURE__*/_jsx("svg", {
45
+ children: /*#__PURE__*/_jsx(Box, {
46
+ component: "svg",
43
47
  ref: svgRef,
44
48
  style: {
45
49
  width: '100%'
@@ -6,7 +6,6 @@ import { Shape } from '@arcblock/did-motif';
6
6
  import Box from '@mui/material/Box';
7
7
  import Img from '../Img';
8
8
  import { mergeProps, isEthereumDid } from '../Util';
9
- import { styled } from '../Theme';
10
9
  import DIDMotif from './did-motif';
11
10
  import blockies from './etherscan-blockies';
12
11
 
@@ -59,13 +58,25 @@ function Avatar(props) {
59
58
 
60
59
  // 如果显式传入 src 则直接使用 src
61
60
  if (src && !imgError) {
62
- return /*#__PURE__*/_jsx(StyledImg, {
61
+ return /*#__PURE__*/_jsx(Img, {
63
62
  width: size,
64
63
  src: src,
65
64
  alt: did,
66
65
  onError: () => setImgError(true),
67
66
  ...rest,
68
- className: `avatar-img--${variant} ${rest.className}`
67
+ // HACK: 这个 className 是传递给子元素的,所以下面的 sx 需要通过子元素选择器来写样式
68
+ className: `avatar-img--${variant} ${rest?.className || ''}`,
69
+ sx: {
70
+ '& .avatar-img--rounded': {
71
+ borderRadius: '4px',
72
+ overflow: 'hidden'
73
+ },
74
+ '& .avatar-img--circle': {
75
+ borderRadius: '100%',
76
+ overflow: 'hidden'
77
+ },
78
+ ...rest.sx
79
+ }
69
80
  });
70
81
  }
71
82
  // 对于 eth address, 渲染成 blocky icon, 形状与 account role type 的 did motif 相似都为矩形, 高宽比为 0.7
@@ -73,9 +84,25 @@ function Avatar(props) {
73
84
  if (blockiesPadding) {
74
85
  // blocky icon 要与灰色卡片矩形留有空间
75
86
  const padding = size > 24 ? 4 : 2;
76
- return /*#__PURE__*/_jsx(BlockyIconContainer, {
77
- $size: size,
87
+ return /*#__PURE__*/_jsx(Box, {
78
88
  ...rest,
89
+ sx: {
90
+ display: 'flex',
91
+ alignItems: 'center',
92
+ width: size,
93
+ height: size,
94
+ '.blocky-icon-inner': {
95
+ boxSizing: 'border-box',
96
+ display: 'flex',
97
+ justifyContent: 'center',
98
+ alignItems: 'center',
99
+ width: size,
100
+ height: size * 0.7,
101
+ borderRadius: `${Math.min(10, Math.floor(0.1 * size + 2))}px`,
102
+ background: '#ddd'
103
+ },
104
+ ...rest.sx
105
+ },
79
106
  children: /*#__PURE__*/_jsx("div", {
80
107
  className: "blocky-icon-inner",
81
108
  children: /*#__PURE__*/_jsx(Img, {
@@ -87,6 +114,7 @@ function Avatar(props) {
87
114
  });
88
115
  }
89
116
  return /*#__PURE__*/_jsx(Img, {
117
+ ...rest,
90
118
  width: size,
91
119
  src: blockyIcon,
92
120
  alt: did,
@@ -127,32 +155,6 @@ Avatar.defaultProps = {
127
155
  shape: '',
128
156
  responsive: false
129
157
  };
130
- const BlockyIconContainer = styled(Box)`
131
- display: flex;
132
- align-items: center;
133
- width: ${props => props.$size}px;
134
- height: ${props => props.$size}px;
135
- .blocky-icon-inner {
136
- box-sizing: border-box;
137
- display: flex;
138
- justify-content: center;
139
- align-items: center;
140
- width: ${props => props.$size}px;
141
- height: ${props => props.$size * 0.7}px;
142
- border-radius: ${props => Math.min(10, Math.floor(0.1 * props.$size + 2))}px;
143
- background: #ddd;
144
- }
145
- `;
146
- const StyledImg = styled(Img)`
147
- &.avatar-img--rounded {
148
- border-radius: 4px;
149
- overflow: hidden;
150
- }
151
- &.avatar-img--circle {
152
- border-radius: 100%;
153
- overflow: hidden;
154
- }
155
- `;
156
158
  export default function AvatarWithErrorBoundary(props) {
157
159
  const size = props.size || 36;
158
160
  const borderRadius = {
package/es/Img/index.js CHANGED
@@ -4,8 +4,8 @@ import { useInView } from 'react-intersection-observer';
4
4
  import WarningRoundedIcon from '@iconify-icons/material-symbols/warning-rounded';
5
5
  import ImageRoundedIcon from '@iconify-icons/material-symbols/image-rounded';
6
6
  import { Icon } from '@iconify/react';
7
+ import { Box } from '@mui/material';
7
8
  import noop from 'lodash/noop';
8
- import { styled } from '../Theme';
9
9
 
10
10
  /**
11
11
  * @typedef {Object} ImgExProps
@@ -36,41 +36,6 @@ const classes = {
36
36
  root: `${PREFIX}-root`
37
37
  };
38
38
 
39
- /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
40
- const Root = styled('div')(() => ({
41
- [`& .${classes.root}`]: {
42
- position: 'relative',
43
- overflow: 'hidden',
44
- '& .image--state, & .image--img': {
45
- minWidth: '100%',
46
- minHeight: '100%',
47
- position: 'absolute',
48
- top: 0,
49
- left: '50%',
50
- transform: 'translateX(-50%)'
51
- },
52
- '& .image--state': {
53
- display: 'flex',
54
- flexDirection: 'column',
55
- justifyContent: 'center',
56
- alignItems: 'center',
57
- color: '#999',
58
- background: '#eee',
59
- width: '100%',
60
- height: '100%'
61
- },
62
- '& .image--img': {
63
- opacity: 0,
64
- visibility: 'hidden'
65
- },
66
- '& .image--icon': {
67
- fontSize: 30,
68
- maxWidth: '80%',
69
- maxHeight: '80%'
70
- }
71
- }
72
- }));
73
-
74
39
  /**
75
40
  *
76
41
  * @param {ImgProps} props
@@ -152,10 +117,45 @@ function Img({
152
117
  return (
153
118
  /*#__PURE__*/
154
119
  // paddingTop 要求元素本身的宽度为 100%,所以只能加一个外层元素去限制宽度
155
- _jsx(Root, {
120
+ _jsx(Box, {
121
+ "data-id": "2",
156
122
  ref: ref,
157
123
  style: outerStyle,
158
124
  ...rest,
125
+ sx: {
126
+ [`& .${classes.root}`]: {
127
+ position: 'relative',
128
+ overflow: 'hidden',
129
+ '& .image--state, & .image--img': {
130
+ minWidth: '100%',
131
+ minHeight: '100%',
132
+ position: 'absolute',
133
+ top: 0,
134
+ left: '50%',
135
+ transform: 'translateX(-50%)'
136
+ },
137
+ '& .image--state': {
138
+ display: 'flex',
139
+ flexDirection: 'column',
140
+ justifyContent: 'center',
141
+ alignItems: 'center',
142
+ color: '#999',
143
+ background: '#eee',
144
+ width: '100%',
145
+ height: '100%'
146
+ },
147
+ '& .image--img': {
148
+ opacity: 0,
149
+ visibility: 'hidden'
150
+ },
151
+ '& .image--icon': {
152
+ fontSize: 30,
153
+ maxWidth: '80%',
154
+ maxHeight: '80%'
155
+ }
156
+ },
157
+ ...rest.sx
158
+ },
159
159
  children: /*#__PURE__*/_jsxs("div", {
160
160
  className: `image ${className} ${classes.root}`,
161
161
  style: mergedStyle,
@@ -232,7 +232,7 @@ const Wrapper = styled('div', {
232
232
  display: flex;
233
233
  justify-content: center;
234
234
  /* logo 与 sidebar 中的 icon 垂直对齐, sidebarWidth - 24 * 2 */
235
- width: ${props => props.sidebarWidth - 24 * 2}px;
235
+ min-width: ${props => props.sidebarWidth - 24 * 2}px;
236
236
  }
237
237
  &.dashboard-dense {
238
238
  .header-logo {
@@ -65,7 +65,7 @@ export default function LocaleSelector(props) {
65
65
  fontSize: size,
66
66
  color: theme.palette.text.secondary,
67
67
  style: {
68
- transform: 'scale(1.15)'
68
+ transform: 'scale(1.10)'
69
69
  }
70
70
  });
71
71
  }, [Icon, theme?.palette?.text?.secondary, size]);
@@ -51,7 +51,7 @@ export default function SessionBlocklet({
51
51
  icon: DashboardOutlineRoundedIcon,
52
52
  fontSize: size,
53
53
  style: {
54
- transform: 'scale(1.10)'
54
+ transform: 'scale(1.08)'
55
55
  }
56
56
  })
57
57
  }), /*#__PURE__*/_jsx(Popper, {
@@ -7,6 +7,7 @@ exports.default = void 0;
7
7
  var _react = require("react");
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  var _didMotif = require("@arcblock/did-motif");
10
+ var _material = require("@mui/material");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
11
12
  const _excluded = ["did", "size", "animation", "shape", "responsive"];
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -40,19 +41,23 @@ function DIDMotif(_ref) {
40
41
  const styles = _objectSpread(_objectSpread({}, rest.style), {}, {
41
42
  width: '100%'
42
43
  });
43
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", _objectSpread(_objectSpread({
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, _objectSpread(_objectSpread({
45
+ component: "svg",
44
46
  ref: svgRef
45
47
  }, rest), {}, {
46
48
  style: styles
47
49
  }));
48
50
  }
49
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", _objectSpread(_objectSpread({}, rest), {}, {
51
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, _objectSpread(_objectSpread({
52
+ component: "span"
53
+ }, rest), {}, {
50
54
  style: _objectSpread({
51
55
  display: 'inline-block',
52
56
  width: size,
53
57
  height: size
54
58
  }, rest.style),
55
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
59
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Box, {
60
+ component: "svg",
56
61
  ref: svgRef,
57
62
  style: {
58
63
  width: '100%'
@@ -11,11 +11,9 @@ var _didMotif = require("@arcblock/did-motif");
11
11
  var _Box = _interopRequireDefault(require("@mui/material/Box"));
12
12
  var _Img = _interopRequireDefault(require("../Img"));
13
13
  var _Util = require("../Util");
14
- var _Theme = require("../Theme");
15
14
  var _didMotif2 = _interopRequireDefault(require("./did-motif"));
16
15
  var _etherscanBlockies = _interopRequireDefault(require("./etherscan-blockies"));
17
16
  var _jsxRuntime = require("react/jsx-runtime");
18
- var _templateObject, _templateObject2;
19
17
  const _excluded = ["did", "size", "src", "variant", "animation", "shape", "blockiesPadding", "responsive"];
20
18
  /* eslint-disable react/no-unused-prop-types */
21
19
  /**
@@ -37,7 +35,6 @@ const _excluded = ["did", "size", "src", "variant", "animation", "shape", "block
37
35
  * @returns {JSX.Element}
38
36
  */
39
37
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
- function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
41
38
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
42
39
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
43
40
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -74,13 +71,24 @@ function Avatar(props) {
74
71
 
75
72
  // 如果显式传入 src 则直接使用 src
76
73
  if (src && !imgError) {
77
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledImg, _objectSpread(_objectSpread({
74
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, _objectSpread(_objectSpread({
78
75
  width: size,
79
76
  src: src,
80
77
  alt: did,
81
78
  onError: () => setImgError(true)
82
79
  }, rest), {}, {
83
- className: "avatar-img--".concat(variant, " ").concat(rest.className)
80
+ // HACK: 这个 className 是传递给子元素的,所以下面的 sx 需要通过子元素选择器来写样式
81
+ className: "avatar-img--".concat(variant, " ").concat((rest === null || rest === void 0 ? void 0 : rest.className) || ''),
82
+ sx: _objectSpread({
83
+ '& .avatar-img--rounded': {
84
+ borderRadius: '4px',
85
+ overflow: 'hidden'
86
+ },
87
+ '& .avatar-img--circle': {
88
+ borderRadius: '100%',
89
+ overflow: 'hidden'
90
+ }
91
+ }, rest.sx)
84
92
  }));
85
93
  }
86
94
  // 对于 eth address, 渲染成 blocky icon, 形状与 account role type 的 did motif 相似都为矩形, 高宽比为 0.7
@@ -88,9 +96,23 @@ function Avatar(props) {
88
96
  if (blockiesPadding) {
89
97
  // blocky icon 要与灰色卡片矩形留有空间
90
98
  const padding = size > 24 ? 4 : 2;
91
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(BlockyIconContainer, _objectSpread(_objectSpread({
92
- $size: size
93
- }, rest), {}, {
99
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, _objectSpread(_objectSpread({}, rest), {}, {
100
+ sx: _objectSpread({
101
+ display: 'flex',
102
+ alignItems: 'center',
103
+ width: size,
104
+ height: size,
105
+ '.blocky-icon-inner': {
106
+ boxSizing: 'border-box',
107
+ display: 'flex',
108
+ justifyContent: 'center',
109
+ alignItems: 'center',
110
+ width: size,
111
+ height: size * 0.7,
112
+ borderRadius: "".concat(Math.min(10, Math.floor(0.1 * size + 2)), "px"),
113
+ background: '#ddd'
114
+ }
115
+ }, rest.sx),
94
116
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
95
117
  className: "blocky-icon-inner",
96
118
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, {
@@ -101,14 +123,14 @@ function Avatar(props) {
101
123
  })
102
124
  }));
103
125
  }
104
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, {
126
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Img.default, _objectSpread(_objectSpread({}, rest), {}, {
105
127
  width: size,
106
128
  src: blockyIcon,
107
129
  alt: did,
108
130
  style: {
109
131
  marginRight: 4
110
132
  }
111
- });
133
+ }));
112
134
  }
113
135
  if (did) {
114
136
  // 渲染 did motif
@@ -141,8 +163,6 @@ Avatar.defaultProps = {
141
163
  shape: '',
142
164
  responsive: false
143
165
  };
144
- const BlockyIconContainer = (0, _Theme.styled)(_Box.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n width: ", "px;\n height: ", "px;\n .blocky-icon-inner {\n box-sizing: border-box;\n display: flex;\n justify-content: center;\n align-items: center;\n width: ", "px;\n height: ", "px;\n border-radius: ", "px;\n background: #ddd;\n }\n"])), props => props.$size, props => props.$size, props => props.$size, props => props.$size * 0.7, props => Math.min(10, Math.floor(0.1 * props.$size + 2)));
145
- const StyledImg = (0, _Theme.styled)(_Img.default)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n &.avatar-img--rounded {\n border-radius: 4px;\n overflow: hidden;\n }\n &.avatar-img--circle {\n border-radius: 100%;\n overflow: hidden;\n }\n"])));
146
166
  function AvatarWithErrorBoundary(props) {
147
167
  const size = props.size || 36;
148
168
  const borderRadius = {
package/lib/Img/index.js CHANGED
@@ -10,8 +10,8 @@ var _reactIntersectionObserver = require("react-intersection-observer");
10
10
  var _warningRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/warning-rounded"));
11
11
  var _imageRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/image-rounded"));
12
12
  var _react2 = require("@iconify/react");
13
+ var _material = require("@mui/material");
13
14
  var _noop = _interopRequireDefault(require("lodash/noop"));
14
- var _Theme = require("../Theme");
15
15
  var _jsxRuntime = require("react/jsx-runtime");
16
16
  const _excluded = ["lazy", "width", "height", "repeat", "ratio", "alt", "size", "position", "src", "placeholder", "fallback", "style", "className", "onError", "onSuccess"];
17
17
  /**
@@ -48,41 +48,6 @@ const classes = {
48
48
  root: "".concat(PREFIX, "-root")
49
49
  };
50
50
 
51
- /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
52
- const Root = (0, _Theme.styled)('div')(() => ({
53
- ["& .".concat(classes.root)]: {
54
- position: 'relative',
55
- overflow: 'hidden',
56
- '& .image--state, & .image--img': {
57
- minWidth: '100%',
58
- minHeight: '100%',
59
- position: 'absolute',
60
- top: 0,
61
- left: '50%',
62
- transform: 'translateX(-50%)'
63
- },
64
- '& .image--state': {
65
- display: 'flex',
66
- flexDirection: 'column',
67
- justifyContent: 'center',
68
- alignItems: 'center',
69
- color: '#999',
70
- background: '#eee',
71
- width: '100%',
72
- height: '100%'
73
- },
74
- '& .image--img': {
75
- opacity: 0,
76
- visibility: 'hidden'
77
- },
78
- '& .image--icon': {
79
- fontSize: 30,
80
- maxWidth: '80%',
81
- maxHeight: '80%'
82
- }
83
- }
84
- }));
85
-
86
51
  /**
87
52
  *
88
53
  * @param {ImgProps} props
@@ -164,10 +129,44 @@ function Img(_ref) {
164
129
  return (
165
130
  /*#__PURE__*/
166
131
  // paddingTop 要求元素本身的宽度为 100%,所以只能加一个外层元素去限制宽度
167
- (0, _jsxRuntime.jsx)(Root, _objectSpread(_objectSpread({
132
+ (0, _jsxRuntime.jsx)(_material.Box, _objectSpread(_objectSpread({
133
+ "data-id": "2",
168
134
  ref: ref,
169
135
  style: outerStyle
170
136
  }, rest), {}, {
137
+ sx: _objectSpread({
138
+ ["& .".concat(classes.root)]: {
139
+ position: 'relative',
140
+ overflow: 'hidden',
141
+ '& .image--state, & .image--img': {
142
+ minWidth: '100%',
143
+ minHeight: '100%',
144
+ position: 'absolute',
145
+ top: 0,
146
+ left: '50%',
147
+ transform: 'translateX(-50%)'
148
+ },
149
+ '& .image--state': {
150
+ display: 'flex',
151
+ flexDirection: 'column',
152
+ justifyContent: 'center',
153
+ alignItems: 'center',
154
+ color: '#999',
155
+ background: '#eee',
156
+ width: '100%',
157
+ height: '100%'
158
+ },
159
+ '& .image--img': {
160
+ opacity: 0,
161
+ visibility: 'hidden'
162
+ },
163
+ '& .image--icon': {
164
+ fontSize: 30,
165
+ maxWidth: '80%',
166
+ maxHeight: '80%'
167
+ }
168
+ }
169
+ }, rest.sx),
171
170
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
172
171
  className: "image ".concat(className, " ").concat(classes.root),
173
172
  style: mergedStyle,
@@ -206,7 +206,7 @@ Dashboard.defaultProps = {
206
206
  };
207
207
  const Wrapper = (0, _Theme.styled)('div', {
208
208
  shouldForwardProp: prop => prop !== 'sidebarWidth'
209
- })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.dashboard {\n display: flex;\n flex-direction: column;\n height: 100vh;\n }\n .dashboard-body {\n overflow: hidden;\n flex: 1;\n }\n .dashboard-sidebar {\n box-sizing: border-box;\n flex: 0 0 auto;\n width: ", "px;\n overflow: hidden;\n &:hover {\n overflow-y: auto;\n }\n }\n .dashboard-main {\n display: flex;\n flex-direction: column;\n overflow: auto;\n flex: 1;\n position: relative;\n }\n .dashboard-content {\n flex: 1;\n }\n &.dashboard-dense {\n .dashboard-header {\n border-bottom: 1px solid #eee;\n }\n .dashboard-sidebar {\n width: 256px;\n border-right: 1px solid #eee;\n }\n }\n ", " {\n .header-logo {\n display: flex;\n justify-content: center;\n /* logo \u4E0E sidebar \u4E2D\u7684 icon \u5782\u76F4\u5BF9\u9F50, sidebarWidth - 24 * 2 */\n width: ", "px;\n }\n &.dashboard-dense {\n .header-logo {\n /* dense = true \u65F6 logo \u4E0E sidenav icons \u4E0D\u9700\u8981\u5BF9\u9F50 */\n width: auto;\n }\n }\n }\n"])), props => props.sidebarWidth, props => props.theme.breakpoints.up('md'), props => props.sidebarWidth - 24 * 2);
209
+ })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &.dashboard {\n display: flex;\n flex-direction: column;\n height: 100vh;\n }\n .dashboard-body {\n overflow: hidden;\n flex: 1;\n }\n .dashboard-sidebar {\n box-sizing: border-box;\n flex: 0 0 auto;\n width: ", "px;\n overflow: hidden;\n &:hover {\n overflow-y: auto;\n }\n }\n .dashboard-main {\n display: flex;\n flex-direction: column;\n overflow: auto;\n flex: 1;\n position: relative;\n }\n .dashboard-content {\n flex: 1;\n }\n &.dashboard-dense {\n .dashboard-header {\n border-bottom: 1px solid #eee;\n }\n .dashboard-sidebar {\n width: 256px;\n border-right: 1px solid #eee;\n }\n }\n ", " {\n .header-logo {\n display: flex;\n justify-content: center;\n /* logo \u4E0E sidebar \u4E2D\u7684 icon \u5782\u76F4\u5BF9\u9F50, sidebarWidth - 24 * 2 */\n min-width: ", "px;\n }\n &.dashboard-dense {\n .header-logo {\n /* dense = true \u65F6 logo \u4E0E sidenav icons \u4E0D\u9700\u8981\u5BF9\u9F50 */\n width: auto;\n }\n }\n }\n"])), props => props.sidebarWidth, props => props.theme.breakpoints.up('md'), props => props.sidebarWidth - 24 * 2);
210
210
  const StyledUxHeader = (0, _Theme.styled)(_Header.ResponsiveHeader)(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .header-container {\n max-width: 100%;\n }\n"])));
211
211
 
212
212
  // 兼容旧版 dashboard
@@ -83,7 +83,7 @@ function LocaleSelector(props) {
83
83
  fontSize: size,
84
84
  color: theme.palette.text.secondary,
85
85
  style: {
86
- transform: 'scale(1.15)'
86
+ transform: 'scale(1.10)'
87
87
  }
88
88
  });
89
89
  }, [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, size]);
@@ -64,7 +64,7 @@ function SessionBlocklet(_ref) {
64
64
  icon: _dashboardOutlineRounded.default,
65
65
  fontSize: size,
66
66
  style: {
67
- transform: 'scale(1.10)'
67
+ transform: 'scale(1.08)'
68
68
  }
69
69
  })
70
70
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Popper, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.9.16",
3
+ "version": "2.9.18",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -344,12 +344,12 @@
344
344
  "peerDependencies": {
345
345
  "react": ">=18.1.0"
346
346
  },
347
- "gitHead": "d970601a888adbd27f76ee9ce490bc8f93f11833",
347
+ "gitHead": "435fbdda42f68b81af5b09ce49fc874142d17e74",
348
348
  "dependencies": {
349
349
  "@arcblock/did-motif": "^1.1.13",
350
- "@arcblock/icons": "^2.9.16",
351
- "@arcblock/nft-display": "^2.9.16",
352
- "@arcblock/react-hooks": "^2.9.16",
350
+ "@arcblock/icons": "^2.9.18",
351
+ "@arcblock/nft-display": "^2.9.18",
352
+ "@arcblock/react-hooks": "^2.9.18",
353
353
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
354
354
  "@emotion/react": "^11.10.4",
355
355
  "@emotion/styled": "^11.10.4",
@@ -1,6 +1,7 @@
1
1
  import { useRef, useLayoutEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { update } from '@arcblock/did-motif';
4
+ import { Box } from '@mui/material';
4
5
 
5
6
  function DIDMotif({ did, size, animation, shape, responsive, ...rest }) {
6
7
  const svgRef = useRef(null);
@@ -12,12 +13,12 @@ function DIDMotif({ did, size, animation, shape, responsive, ...rest }) {
12
13
  if (responsive) {
13
14
  // fix avatar 显示问题 (safari 下父容器为 flex 时 inline svg 显示不出来, 需要明确指定 width)
14
15
  const styles = { ...rest.style, width: '100%' };
15
- return <svg ref={svgRef} {...rest} style={styles} />;
16
+ return <Box component="svg" ref={svgRef} {...rest} style={styles} />;
16
17
  }
17
18
  return (
18
- <span {...rest} style={{ display: 'inline-block', width: size, height: size, ...rest.style }}>
19
- <svg ref={svgRef} style={{ width: '100%' }} />
20
- </span>
19
+ <Box component="span" {...rest} style={{ display: 'inline-block', width: size, height: size, ...rest.style }}>
20
+ <Box component="svg" ref={svgRef} style={{ width: '100%' }} />
21
+ </Box>
21
22
  );
22
23
  }
23
24
 
@@ -6,7 +6,6 @@ import { Shape } from '@arcblock/did-motif';
6
6
  import Box from '@mui/material/Box';
7
7
  import Img from '../Img';
8
8
  import { mergeProps, isEthereumDid } from '../Util';
9
- import { styled } from '../Theme';
10
9
  import DIDMotif from './did-motif';
11
10
  import blockies from './etherscan-blockies';
12
11
 
@@ -51,13 +50,25 @@ function Avatar(props) {
51
50
  // 如果显式传入 src 则直接使用 src
52
51
  if (src && !imgError) {
53
52
  return (
54
- <StyledImg
53
+ <Img
55
54
  width={size}
56
55
  src={src}
57
56
  alt={did}
58
57
  onError={() => setImgError(true)}
59
58
  {...rest}
60
- className={`avatar-img--${variant} ${rest.className}`}
59
+ // HACK: 这个 className 是传递给子元素的,所以下面的 sx 需要通过子元素选择器来写样式
60
+ className={`avatar-img--${variant} ${rest?.className || ''}`}
61
+ sx={{
62
+ '& .avatar-img--rounded': {
63
+ borderRadius: '4px',
64
+ overflow: 'hidden',
65
+ },
66
+ '& .avatar-img--circle': {
67
+ borderRadius: '100%',
68
+ overflow: 'hidden',
69
+ },
70
+ ...rest.sx,
71
+ }}
61
72
  />
62
73
  );
63
74
  }
@@ -67,15 +78,33 @@ function Avatar(props) {
67
78
  // blocky icon 要与灰色卡片矩形留有空间
68
79
  const padding = size > 24 ? 4 : 2;
69
80
  return (
70
- <BlockyIconContainer $size={size} {...rest}>
81
+ <Box
82
+ {...rest}
83
+ sx={{
84
+ display: 'flex',
85
+ alignItems: 'center',
86
+ width: size,
87
+ height: size,
88
+ '.blocky-icon-inner': {
89
+ boxSizing: 'border-box',
90
+ display: 'flex',
91
+ justifyContent: 'center',
92
+ alignItems: 'center',
93
+ width: size,
94
+ height: size * 0.7,
95
+ borderRadius: `${Math.min(10, Math.floor(0.1 * size + 2))}px`,
96
+ background: '#ddd',
97
+ },
98
+ ...rest.sx,
99
+ }}>
71
100
  <div className="blocky-icon-inner">
72
101
  <Img width={size * 0.7 - padding * 2} src={blockyIcon} alt={did} />
73
102
  </div>
74
- </BlockyIconContainer>
103
+ </Box>
75
104
  );
76
105
  }
77
106
 
78
- return <Img width={size} src={blockyIcon} alt={did} style={{ marginRight: 4 }} />;
107
+ return <Img {...rest} width={size} src={blockyIcon} alt={did} style={{ marginRight: 4 }} />;
79
108
  }
80
109
 
81
110
  if (did) {
@@ -115,34 +144,6 @@ Avatar.defaultProps = {
115
144
  responsive: false,
116
145
  };
117
146
 
118
- const BlockyIconContainer = styled(Box)`
119
- display: flex;
120
- align-items: center;
121
- width: ${(props) => props.$size}px;
122
- height: ${(props) => props.$size}px;
123
- .blocky-icon-inner {
124
- box-sizing: border-box;
125
- display: flex;
126
- justify-content: center;
127
- align-items: center;
128
- width: ${(props) => props.$size}px;
129
- height: ${(props) => props.$size * 0.7}px;
130
- border-radius: ${(props) => Math.min(10, Math.floor(0.1 * props.$size + 2))}px;
131
- background: #ddd;
132
- }
133
- `;
134
-
135
- const StyledImg = styled(Img)`
136
- &.avatar-img--rounded {
137
- border-radius: 4px;
138
- overflow: hidden;
139
- }
140
- &.avatar-img--circle {
141
- border-radius: 100%;
142
- overflow: hidden;
143
- }
144
- `;
145
-
146
147
  export default function AvatarWithErrorBoundary(props) {
147
148
  const size = props.size || 36;
148
149
  const borderRadius = { rounded: '4px', circle: '100%' }[props.variant] || 0;
package/src/Img/index.jsx CHANGED
@@ -4,10 +4,9 @@ import { useInView } from 'react-intersection-observer';
4
4
  import WarningRoundedIcon from '@iconify-icons/material-symbols/warning-rounded';
5
5
  import ImageRoundedIcon from '@iconify-icons/material-symbols/image-rounded';
6
6
  import { Icon } from '@iconify/react';
7
+ import { Box } from '@mui/material';
7
8
  import noop from 'lodash/noop';
8
9
 
9
- import { styled } from '../Theme';
10
-
11
10
  /**
12
11
  * @typedef {Object} ImgExProps
13
12
  * @property {string} src - required
@@ -37,41 +36,6 @@ const classes = {
37
36
  root: `${PREFIX}-root`,
38
37
  };
39
38
 
40
- /** @type {import('@emotion/styled').StyledComponent<import('react').ComponentPropsWithoutRef<"div">, {}, { ref?: React.Ref<any> | undefined;}>} */
41
- const Root = styled('div')(() => ({
42
- [`& .${classes.root}`]: {
43
- position: 'relative',
44
- overflow: 'hidden',
45
- '& .image--state, & .image--img': {
46
- minWidth: '100%',
47
- minHeight: '100%',
48
- position: 'absolute',
49
- top: 0,
50
- left: '50%',
51
- transform: 'translateX(-50%)',
52
- },
53
- '& .image--state': {
54
- display: 'flex',
55
- flexDirection: 'column',
56
- justifyContent: 'center',
57
- alignItems: 'center',
58
- color: '#999',
59
- background: '#eee',
60
- width: '100%',
61
- height: '100%',
62
- },
63
- '& .image--img': {
64
- opacity: 0,
65
- visibility: 'hidden',
66
- },
67
- '& .image--icon': {
68
- fontSize: 30,
69
- maxWidth: '80%',
70
- maxHeight: '80%',
71
- },
72
- },
73
- }));
74
-
75
39
  /**
76
40
  *
77
41
  * @param {ImgProps} props
@@ -158,7 +122,45 @@ function Img({
158
122
 
159
123
  return (
160
124
  // paddingTop 要求元素本身的宽度为 100%,所以只能加一个外层元素去限制宽度
161
- <Root ref={ref} style={outerStyle} {...rest}>
125
+ <Box
126
+ data-id="2"
127
+ ref={ref}
128
+ style={outerStyle}
129
+ {...rest}
130
+ sx={{
131
+ [`& .${classes.root}`]: {
132
+ position: 'relative',
133
+ overflow: 'hidden',
134
+ '& .image--state, & .image--img': {
135
+ minWidth: '100%',
136
+ minHeight: '100%',
137
+ position: 'absolute',
138
+ top: 0,
139
+ left: '50%',
140
+ transform: 'translateX(-50%)',
141
+ },
142
+ '& .image--state': {
143
+ display: 'flex',
144
+ flexDirection: 'column',
145
+ justifyContent: 'center',
146
+ alignItems: 'center',
147
+ color: '#999',
148
+ background: '#eee',
149
+ width: '100%',
150
+ height: '100%',
151
+ },
152
+ '& .image--img': {
153
+ opacity: 0,
154
+ visibility: 'hidden',
155
+ },
156
+ '& .image--icon': {
157
+ fontSize: 30,
158
+ maxWidth: '80%',
159
+ maxHeight: '80%',
160
+ },
161
+ },
162
+ ...rest.sx,
163
+ }}>
162
164
  <div className={`image ${className} ${classes.root}`} style={mergedStyle}>
163
165
  {!fallback && imgState === 'error' && (
164
166
  <div className="image--state" title="loading image">
@@ -172,7 +174,7 @@ function Img({
172
174
  )}
173
175
  {imgState === 'loaded' && <img className="image--img" src={src} alt={alt} />}
174
176
  </div>
175
- </Root>
177
+ </Box>
176
178
  );
177
179
  }
178
180
 
@@ -199,7 +199,7 @@ const Wrapper = styled('div', {
199
199
  display: flex;
200
200
  justify-content: center;
201
201
  /* logo 与 sidebar 中的 icon 垂直对齐, sidebarWidth - 24 * 2 */
202
- width: ${(props) => props.sidebarWidth - 24 * 2}px;
202
+ min-width: ${(props) => props.sidebarWidth - 24 * 2}px;
203
203
  }
204
204
  &.dashboard-dense {
205
205
  .header-logo {
@@ -63,7 +63,7 @@ export default function LocaleSelector(props) {
63
63
  icon={LanguageIcon}
64
64
  fontSize={size}
65
65
  color={theme.palette.text.secondary}
66
- style={{ transform: 'scale(1.15)' }}
66
+ style={{ transform: 'scale(1.10)' }}
67
67
  />
68
68
  );
69
69
  }, [Icon, theme?.palette?.text?.secondary, size]);
@@ -55,7 +55,7 @@ export default function SessionBlocklet({ session, locale, size }) {
55
55
  return (
56
56
  <>
57
57
  <IconButton size="medium" ref={popperAnchorRef} onClick={() => onTogglePopper()}>
58
- <Icon icon={DashboardOutlineRoundedIcon} fontSize={size} style={{ transform: 'scale(1.10)' }} />
58
+ <Icon icon={DashboardOutlineRoundedIcon} fontSize={size} style={{ transform: 'scale(1.08)' }} />
59
59
  </IconButton>
60
60
  <Popper
61
61
  open={currentState.open}