@arcblock/ux 2.4.38 → 2.4.40

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.
@@ -19,7 +19,7 @@ var _jsxRuntime = require("react/jsx-runtime");
19
19
 
20
20
  var _templateObject;
21
21
 
22
- const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend", "align", "maxWidth"];
22
+ const _excluded = ["logo", "brand", "brandAddon", "description", "children", "addons", "prepend", "align", "maxWidth", "homeLink"];
23
23
 
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
25
 
@@ -49,23 +49,21 @@ function Header(_ref) {
49
49
  addons,
50
50
  prepend,
51
51
  align,
52
- maxWidth
52
+ maxWidth,
53
+ homeLink
53
54
  } = _ref,
54
55
  rest = _objectWithoutProperties(_ref, _excluded);
55
56
 
56
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, _objectSpread(_objectSpread({}, rest), {}, {
57
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Container.default, {
58
- maxWidth: maxWidth,
59
- className: "header-container",
60
- children: [prepend, logo && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
57
+ const renderBrand = () => {
58
+ const brandContent = /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
59
+ children: [logo && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
61
60
  className: "header-logo",
62
61
  children: logo
63
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_autoHidden.default, {
62
+ }), brand && /*#__PURE__*/(0, _jsxRuntime.jsx)(_autoHidden.default, {
64
63
  height: 44,
65
64
  sx: {
66
65
  flexShrink: {
67
- xs: 1,
68
- md: 0
66
+ xs: 1
69
67
  }
70
68
  },
71
69
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
@@ -80,6 +78,26 @@ function Header(_ref) {
80
78
  children: description
81
79
  })]
82
80
  })
81
+ })]
82
+ });
83
+
84
+ if (typeof homeLink === 'function') {
85
+ return homeLink(brandContent);
86
+ }
87
+
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
89
+ href: homeLink,
90
+ children: brandContent
91
+ });
92
+ };
93
+
94
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Root, _objectSpread(_objectSpread({}, rest), {}, {
95
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Container.default, {
96
+ maxWidth: maxWidth,
97
+ className: "header-container",
98
+ children: [prepend, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
99
+ className: "header-brand-wrapper",
100
+ children: renderBrand()
83
101
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
84
102
  className: "header-brand-addon",
85
103
  children: brandAddon
@@ -110,7 +128,8 @@ Header.propTypes = {
110
128
  // logo 左侧内容
111
129
  prepend: _propTypes.default.node,
112
130
  align: _propTypes.default.oneOf(['left', 'right']),
113
- maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])])
131
+ maxWidth: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])]),
132
+ homeLink: _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func])
114
133
  };
115
134
  Header.defaultProps = {
116
135
  logo: null,
@@ -121,8 +140,9 @@ Header.defaultProps = {
121
140
  addons: null,
122
141
  prepend: null,
123
142
  align: 'left',
124
- maxWidth: undefined
143
+ maxWidth: undefined,
144
+ homeLink: '/'
125
145
  };
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'));
146
+ 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\n .header-brand-wrapper {\n flex-shrink: 1;\n min-width: 0;\n > a {\n display: flex;\n align-items: center;\n height: 100%;\n line-height: 1;\n color: inherit;\n text-decoration: none;\n }\n }\n .header-brand-wrapper .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 }\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 .header-brand-addon {\n display: none;\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 }\n"])), props => props.theme.zIndex.appBar, props => props.theme.palette.common.white, props => props.theme.breakpoints.down('lg'), props => props.theme.breakpoints.down('md'));
127
147
  var _default = Header;
128
148
  exports.default = _default;
@@ -124,11 +124,25 @@ function Dashboard(_ref2) {
124
124
  const classes = (0, _clsx.default)('dashboard', {
125
125
  'dashboard-dense': _dense
126
126
  }, rest.className);
127
+
128
+ const defaultHomeLink = content => {
129
+ var _window$blocklet;
130
+
131
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_externalLink.Link, {
132
+ to: ((_window$blocklet = window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.prefix) || '/',
133
+ children: content
134
+ });
135
+ };
136
+
137
+ const _headerProps = _objectSpread({
138
+ homeLink: defaultHomeLink
139
+ }, headerProps);
140
+
127
141
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Wrapper, _objectSpread(_objectSpread({}, rest), {}, {
128
142
  className: classes,
129
143
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactHelmet.default, {
130
144
  title: title
131
- }, title), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledUxHeader, _objectSpread(_objectSpread({}, headerProps), {}, {
145
+ }, title), /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledUxHeader, _objectSpread(_objectSpread({}, _headerProps), {}, {
132
146
  className: "dashboard-header",
133
147
  children: links !== null && links !== void 0 && links.length ? _ref3 => {
134
148
  let {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.4.38",
3
+ "version": "2.4.40",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -47,10 +47,10 @@
47
47
  "react": ">=18.1.0",
48
48
  "react-ga": "^2.7.0"
49
49
  },
50
- "gitHead": "d5db89486d5c862c2f11c26991ac515e701ac7d3",
50
+ "gitHead": "c26da2c4ed0c311c2dceab75db245f0290344860",
51
51
  "dependencies": {
52
- "@arcblock/icons": "^2.4.38",
53
- "@arcblock/react-hooks": "^2.4.38",
52
+ "@arcblock/icons": "^2.4.40",
53
+ "@arcblock/react-hooks": "^2.4.40",
54
54
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
55
55
  "@emotion/react": "^11.10.4",
56
56
  "@emotion/styled": "^11.10.4",
@@ -8,20 +8,45 @@ import { styled } from '../Theme';
8
8
  * Header 组件
9
9
  * TODO: Layout/dashboard 可以复用此处的 header
10
10
  */
11
- function Header({ logo, brand, brandAddon, description, children, addons, prepend, align, maxWidth, ...rest }) {
11
+ function Header({
12
+ logo,
13
+ brand,
14
+ brandAddon,
15
+ description,
16
+ children,
17
+ addons,
18
+ prepend,
19
+ align,
20
+ maxWidth,
21
+ homeLink,
22
+ ...rest
23
+ }) {
24
+ const renderBrand = () => {
25
+ const brandContent = (
26
+ <>
27
+ {logo && <div className="header-logo">{logo}</div>}
28
+ {brand && (
29
+ <AutoHidden height={44} sx={{ flexShrink: { xs: 1 } }}>
30
+ <div className="header-brand">
31
+ <div className="header-brand-title">
32
+ <h2>{brand}</h2>
33
+ </div>
34
+ <div className="header-brand-desc">{description}</div>
35
+ </div>
36
+ </AutoHidden>
37
+ )}
38
+ </>
39
+ );
40
+ if (typeof homeLink === 'function') {
41
+ return homeLink(brandContent);
42
+ }
43
+ return <a href={homeLink}>{brandContent}</a>;
44
+ };
12
45
  return (
13
46
  <Root {...rest}>
14
47
  <Container maxWidth={maxWidth} className="header-container">
15
48
  {prepend}
16
- {logo && <div className="header-logo">{logo}</div>}
17
- <AutoHidden height={44} sx={{ flexShrink: { xs: 1, md: 0 } }}>
18
- <div className="header-brand">
19
- <div className="header-brand-title">
20
- <h2>{brand}</h2>
21
- </div>
22
- <div className="header-brand-desc">{description}</div>
23
- </div>
24
- </AutoHidden>
49
+ <div className="header-brand-wrapper">{renderBrand()}</div>
25
50
  <div className="header-brand-addon">{brandAddon}</div>
26
51
  {align === 'right' && <Box flexGrow={1} />}
27
52
  {children}
@@ -48,6 +73,7 @@ Header.propTypes = {
48
73
  prepend: PropTypes.node,
49
74
  align: PropTypes.oneOf(['left', 'right']),
50
75
  maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])]),
76
+ homeLink: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
51
77
  };
52
78
 
53
79
  Header.defaultProps = {
@@ -60,6 +86,7 @@ Header.defaultProps = {
60
86
  prepend: null,
61
87
  align: 'left',
62
88
  maxWidth: undefined,
89
+ homeLink: '/',
63
90
  };
64
91
 
65
92
  const Root = styled('div')`
@@ -72,7 +99,20 @@ const Root = styled('div')`
72
99
  align-items: center;
73
100
  height: 64px;
74
101
  }
75
- .header-logo {
102
+
103
+ .header-brand-wrapper {
104
+ flex-shrink: 1;
105
+ min-width: 0;
106
+ > a {
107
+ display: flex;
108
+ align-items: center;
109
+ height: 100%;
110
+ line-height: 1;
111
+ color: inherit;
112
+ text-decoration: none;
113
+ }
114
+ }
115
+ .header-brand-wrapper .header-logo {
76
116
  display: inline-flex;
77
117
  position: relative;
78
118
  height: 44px;
@@ -83,19 +123,6 @@ const Root = styled('div')`
83
123
  height: 100%;
84
124
  max-height: 100%;
85
125
  }
86
- > a {
87
- height: 100%;
88
- line-height: 1;
89
- }
90
- > a::before {
91
- position: absolute;
92
- top: 0;
93
- right: 0;
94
- bottom: 0;
95
- left: 0;
96
- background-color: transparent;
97
- content: '';
98
- }
99
126
  }
100
127
  .header-brand {
101
128
  display: flex;
@@ -137,6 +164,9 @@ const Root = styled('div')`
137
164
  }
138
165
  }
139
166
  }
167
+ .header-brand-addon {
168
+ display: none;
169
+ }
140
170
  }
141
171
  ${(props) => props.theme.breakpoints.down('md')} {
142
172
  .header-menu {
@@ -155,9 +185,6 @@ const Root = styled('div')`
155
185
  font-size: 12px;
156
186
  }
157
187
  }
158
- .header-brand-addon {
159
- display: none;
160
- }
161
188
  }
162
189
  `;
163
190
 
@@ -56,12 +56,17 @@ function Dashboard({ children, title, headerProps, links = [], fullWidth, dense,
56
56
  // 一级菜单数量 > 8 或都分组模式, 都启用 dense 布局
57
57
  const _dense = dense === 'auto' ? navItems.length >= 8 || isGroupedMode : dense;
58
58
  const classes = clsx('dashboard', { 'dashboard-dense': _dense }, rest.className);
59
+ const defaultHomeLink = (content) => <Link to={window.blocklet?.prefix || '/'}>{content}</Link>;
60
+ const _headerProps = {
61
+ homeLink: defaultHomeLink,
62
+ ...headerProps,
63
+ };
59
64
 
60
65
  return (
61
66
  <Wrapper {...rest} className={classes}>
62
67
  <Helmet title={title} key={title} />
63
68
 
64
- <StyledUxHeader {...headerProps} className="dashboard-header">
69
+ <StyledUxHeader {..._headerProps} className="dashboard-header">
65
70
  {links?.length
66
71
  ? ({ isMobile, closeMenu }) => {
67
72
  if (isMobile) {