@blocklet/ui-react 2.4.55 → 2.4.57

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.
@@ -41,9 +41,9 @@ const layouts = [{
41
41
  name: 'plain',
42
42
  // navigation 数据为空时, 使用简单布局
43
43
  support: (_, data) => {
44
- var _data$navigation;
44
+ var _data$navigation, _data$socialMedia;
45
45
 
46
- return !((_data$navigation = data.navigation) !== null && _data$navigation !== void 0 && _data$navigation.length);
46
+ return !((_data$navigation = data.navigation) !== null && _data$navigation !== void 0 && _data$navigation.length) && !((_data$socialMedia = data.socialMedia) !== null && _data$socialMedia !== void 0 && _data$socialMedia.length);
47
47
  },
48
48
  component: _plain.default
49
49
  }, {
@@ -52,14 +52,22 @@ function StandardLayout(_ref) {
52
52
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
53
53
  sx: {
54
54
  display: 'flex',
55
+ flexDirection: {
56
+ xs: 'column',
57
+ md: 'row'
58
+ },
55
59
  justifyContent: 'space-between',
60
+ alignItems: {
61
+ xs: 'center',
62
+ md: 'space-between'
63
+ },
64
+ gap: 2,
56
65
  pb: 3
57
66
  },
58
67
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
59
68
  children: elements.brand
60
69
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
61
70
  lineHeight: 1,
62
- alignSelf: "end",
63
71
  children: elements.socialMedia
64
72
  })]
65
73
  }), !!((_data$navigation = data.navigation) !== null && _data$navigation !== void 0 && _data$navigation.length) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
@@ -93,6 +101,6 @@ StandardLayout.propTypes = {
93
101
  }).isRequired,
94
102
  data: _propTypes.default.object.isRequired
95
103
  };
96
- const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 0 24px 0;\n .footer-brand-name,\n .footer-brand-desc {\n display: none;\n }\n"])));
104
+ const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 32px 0 24px 0;\n .footer-brand-name,\n .footer-brand-desc {\n display: none;\n }\n && .footer-brand-logo {\n margin-right: 0;\n }\n"])));
97
105
  var _default = StandardLayout;
98
106
  exports.default = _default;
@@ -53,7 +53,7 @@ function SocialMedia(_ref) {
53
53
  target: "_blank",
54
54
  rel: "noreferrer",
55
55
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icon.default, {
56
- icon: item.icon,
56
+ icon: item.icon || item.title,
57
57
  sx: {
58
58
  bgcolor: theme.palette.grey[600],
59
59
  color: '#fff'
@@ -77,4 +77,4 @@ SocialMedia.propTypes = {
77
77
  SocialMedia.defaultProps = {
78
78
  items: null
79
79
  };
80
- const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n align-items: center;\n a {\n color: ", ";\n &:hover {\n color: ", ";\n }\n }\n a + a {\n margin-left: 20px;\n }\n"])), props => props.theme.palette.grey[400], props => props.theme.palette.primary.light);
80
+ const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n flex-wrap: wrap;\n align-items: center;\n justify-content: center;\n gap: 20px;\n a {\n color: ", ";\n text-decoration: none;\n &:hover {\n color: ", ";\n }\n }\n ", " {\n gap: 12px;\n }\n"])), props => props.theme.palette.grey[400], props => props.theme.palette.primary.light, props => props.theme.breakpoints.down('md'));
package/lib/Icon/index.js CHANGED
@@ -54,6 +54,7 @@ function Icon(_ref) {
54
54
  _sx.push({
55
55
  '&.MuiAvatar-root': {
56
56
  color: 'inherit',
57
+ fontWeight: 'bold',
57
58
  backgroundColor: 'transparent',
58
59
  borderRadius: 0
59
60
  },
@@ -74,7 +75,7 @@ function Icon(_ref) {
74
75
  }));
75
76
  }
76
77
 
77
- if (icon) {
78
+ if ((0, _utils.isIconifyString)(icon)) {
78
79
  // y = 0.6 * x + 4
79
80
  const iconHeight = size ? 0.6 * size + 4 : 0;
80
81
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, _objectSpread(_objectSpread({
@@ -88,6 +89,24 @@ function Icon(_ref) {
88
89
  'data-height': iconHeight
89
90
  }))
90
91
  }));
92
+ } // letter avatar
93
+
94
+
95
+ if (icon && typeof icon === 'string') {
96
+ _sx.push({
97
+ '&.MuiAvatar-root': _objectSpread({
98
+ display: 'inline-flex'
99
+ }, size && {
100
+ fontSize: size - 2
101
+ })
102
+ });
103
+
104
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Avatar.default, _objectSpread(_objectSpread({
105
+ as: "span"
106
+ }, rest), {}, {
107
+ sx: _sx,
108
+ children: Array.from(icon)[0]
109
+ }));
91
110
  }
92
111
 
93
112
  return null;
package/lib/utils.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.matchPaths = exports.matchPath = exports.mapRecursive = exports.isUrl = exports.flatRecursive = exports.filterRecursive = exports.countRecursive = void 0;
6
+ exports.matchPaths = exports.matchPath = exports.mapRecursive = exports.isUrl = exports.isIconifyString = exports.flatRecursive = exports.filterRecursive = exports.countRecursive = void 0;
7
7
 
8
8
  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; }
9
9
 
@@ -72,12 +72,18 @@ exports.filterRecursive = filterRecursive;
72
72
  const isUrl = str => {
73
73
  return /^https?:\/\//.test(str);
74
74
  };
75
+
76
+ exports.isUrl = isUrl;
77
+
78
+ const isIconifyString = str => {
79
+ return /^[\w-]+:[\w-]+$/.test(str);
80
+ };
75
81
  /**
76
82
  * 检测 path 是否匹配当前 location, path 只考虑 "/" 开头的相对路径
77
83
  */
78
84
 
79
85
 
80
- exports.isUrl = isUrl;
86
+ exports.isIconifyString = isIconifyString;
81
87
 
82
88
  const matchPath = path => {
83
89
  if (!path || !(path !== null && path !== void 0 && path.startsWith('/'))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.4.55",
3
+ "version": "2.4.57",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -30,8 +30,8 @@
30
30
  "url": "https://github.com/ArcBlock/ux/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@arcblock/did-connect": "^2.4.55",
34
- "@arcblock/ux": "^2.4.55",
33
+ "@arcblock/did-connect": "^2.4.57",
34
+ "@arcblock/ux": "^2.4.57",
35
35
  "@emotion/react": "^11.10.4",
36
36
  "@emotion/styled": "^11.10.4",
37
37
  "@iconify/iconify": "^2.2.1",
@@ -53,5 +53,5 @@
53
53
  "eslint-plugin-react-hooks": "^4.6.0",
54
54
  "jest": "^28.1.3"
55
55
  },
56
- "gitHead": "bbf02bb4e9c9fb40e33052f9bb3724ee8e2b1f00"
56
+ "gitHead": "79c25e5a5c10baa35fae9440333792476ec8f3ef"
57
57
  }
@@ -11,7 +11,7 @@ const layouts = [
11
11
  {
12
12
  name: 'plain',
13
13
  // navigation 数据为空时, 使用简单布局
14
- support: (_, data) => !data.navigation?.length,
14
+ support: (_, data) => !data.navigation?.length && !data.socialMedia?.length,
15
15
  component: PlainLayout,
16
16
  },
17
17
  {
@@ -15,13 +15,14 @@ function StandardLayout({ elements, data, ...rest }) {
15
15
  <Box
16
16
  sx={{
17
17
  display: 'flex',
18
+ flexDirection: { xs: 'column', md: 'row' },
18
19
  justifyContent: 'space-between',
20
+ alignItems: { xs: 'center', md: 'space-between' },
21
+ gap: 2,
19
22
  pb: 3,
20
23
  }}>
21
24
  <Box>{elements.brand}</Box>
22
- <Box lineHeight={1} alignSelf="end">
23
- {elements.socialMedia}
24
- </Box>
25
+ <Box lineHeight={1}>{elements.socialMedia}</Box>
25
26
  </Box>
26
27
  {!!data.navigation?.length && (
27
28
  <Box sx={{ mb: 6, pt: 3, borderTop: 1, borderColor: 'grey.200' }}>{elements.navigation}</Box>
@@ -52,6 +53,9 @@ const Root = styled('div')`
52
53
  .footer-brand-desc {
53
54
  display: none;
54
55
  }
56
+ && .footer-brand-logo {
57
+ margin-right: 0;
58
+ }
55
59
  `;
56
60
 
57
61
  export default StandardLayout;
@@ -14,7 +14,7 @@ export default function SocialMedia({ items, ...rest }) {
14
14
  // eslint-disable-next-line react/no-array-index-key
15
15
  <a key={i} href={item.link} target="_blank" rel="noreferrer">
16
16
  <Icon
17
- icon={item.icon}
17
+ icon={item.icon || item.title}
18
18
  sx={{ bgcolor: theme.palette.grey[600], color: '#fff' }}
19
19
  size={24}
20
20
  component="span"
@@ -42,14 +42,18 @@ SocialMedia.defaultProps = {
42
42
 
43
43
  const Root = styled('div')`
44
44
  display: inline-flex;
45
+ flex-wrap: wrap;
45
46
  align-items: center;
47
+ justify-content: center;
48
+ gap: 20px;
46
49
  a {
47
50
  color: ${(props) => props.theme.palette.grey[400]};
51
+ text-decoration: none;
48
52
  &:hover {
49
53
  color: ${(props) => props.theme.palette.primary.light};
50
54
  }
51
55
  }
52
- a + a {
53
- margin-left: 20px;
56
+ ${(props) => props.theme.breakpoints.down('md')} {
57
+ gap: 12px;
54
58
  }
55
59
  `;
package/src/Icon/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import Avatar from '@mui/material/Avatar';
3
3
  import '@iconify/iconify';
4
- import { isUrl } from '../utils';
4
+ import { isUrl, isIconifyString } from '../utils';
5
5
 
6
6
  /**
7
7
  * Icon 组件, 基于 mui Avatar 组件扩展对 iconify 的支持
@@ -16,6 +16,7 @@ export default function Icon({ icon, size, sx, ...rest }) {
16
16
  _sx.push({
17
17
  '&.MuiAvatar-root': {
18
18
  color: 'inherit',
19
+ fontWeight: 'bold',
19
20
  backgroundColor: 'transparent',
20
21
  borderRadius: 0,
21
22
  },
@@ -29,7 +30,7 @@ export default function Icon({ icon, size, sx, ...rest }) {
29
30
  if (isUrl(icon)) {
30
31
  return <Avatar as="span" {...rest} src={icon} sx={_sx} />;
31
32
  }
32
- if (icon) {
33
+ if (isIconifyString(icon)) {
33
34
  // y = 0.6 * x + 4
34
35
  const iconHeight = size ? 0.6 * size + 4 : 0;
35
36
  return (
@@ -38,6 +39,20 @@ export default function Icon({ icon, size, sx, ...rest }) {
38
39
  </Avatar>
39
40
  );
40
41
  }
42
+ // letter avatar
43
+ if (icon && typeof icon === 'string') {
44
+ _sx.push({
45
+ '&.MuiAvatar-root': {
46
+ display: 'inline-flex',
47
+ ...(size && { fontSize: size - 2 }),
48
+ },
49
+ });
50
+ return (
51
+ <Avatar as="span" {...rest} sx={_sx}>
52
+ {Array.from(icon)[0]}
53
+ </Avatar>
54
+ );
55
+ }
41
56
  return null;
42
57
  }
43
58
 
package/src/utils.js CHANGED
@@ -45,6 +45,10 @@ export const isUrl = (str) => {
45
45
  return /^https?:\/\//.test(str);
46
46
  };
47
47
 
48
+ export const isIconifyString = (str) => {
49
+ return /^[\w-]+:[\w-]+$/.test(str);
50
+ };
51
+
48
52
  /**
49
53
  * 检测 path 是否匹配当前 location, path 只考虑 "/" 开头的相对路径
50
54
  */