@arcblock/ux 2.4.38 → 2.4.39
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.
- package/lib/Header/header.js +32 -12
- package/lib/Layout/dashboard/index.js +15 -1
- package/package.json +4 -4
- package/src/Header/header.js +48 -23
- package/src/Layout/dashboard/index.js +6 -1
package/lib/Header/header.js
CHANGED
@@ -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
|
-
|
57
|
-
|
58
|
-
|
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
62
|
}), /*#__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-
|
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({},
|
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.
|
3
|
+
"version": "2.4.39",
|
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": "
|
50
|
+
"gitHead": "73a00d536038df6b5c1eb282deb6c0b2c1dc9a42",
|
51
51
|
"dependencies": {
|
52
|
-
"@arcblock/icons": "^2.4.
|
53
|
-
"@arcblock/react-hooks": "^2.4.
|
52
|
+
"@arcblock/icons": "^2.4.39",
|
53
|
+
"@arcblock/react-hooks": "^2.4.39",
|
54
54
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
55
55
|
"@emotion/react": "^11.10.4",
|
56
56
|
"@emotion/styled": "^11.10.4",
|
package/src/Header/header.js
CHANGED
@@ -8,13 +8,24 @@ import { styled } from '../Theme';
|
|
8
8
|
* Header 组件
|
9
9
|
* TODO: Layout/dashboard 可以复用此处的 header
|
10
10
|
*/
|
11
|
-
function Header({
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
+
<>
|
16
27
|
{logo && <div className="header-logo">{logo}</div>}
|
17
|
-
<AutoHidden height={44} sx={{ flexShrink: { xs: 1
|
28
|
+
<AutoHidden height={44} sx={{ flexShrink: { xs: 1 } }}>
|
18
29
|
<div className="header-brand">
|
19
30
|
<div className="header-brand-title">
|
20
31
|
<h2>{brand}</h2>
|
@@ -22,6 +33,18 @@ function Header({ logo, brand, brandAddon, description, children, addons, prepen
|
|
22
33
|
<div className="header-brand-desc">{description}</div>
|
23
34
|
</div>
|
24
35
|
</AutoHidden>
|
36
|
+
</>
|
37
|
+
);
|
38
|
+
if (typeof homeLink === 'function') {
|
39
|
+
return homeLink(brandContent);
|
40
|
+
}
|
41
|
+
return <a href={homeLink}>{brandContent}</a>;
|
42
|
+
};
|
43
|
+
return (
|
44
|
+
<Root {...rest}>
|
45
|
+
<Container maxWidth={maxWidth} className="header-container">
|
46
|
+
{prepend}
|
47
|
+
<div className="header-brand-wrapper">{renderBrand()}</div>
|
25
48
|
<div className="header-brand-addon">{brandAddon}</div>
|
26
49
|
{align === 'right' && <Box flexGrow={1} />}
|
27
50
|
{children}
|
@@ -48,6 +71,7 @@ Header.propTypes = {
|
|
48
71
|
prepend: PropTypes.node,
|
49
72
|
align: PropTypes.oneOf(['left', 'right']),
|
50
73
|
maxWidth: PropTypes.oneOfType([PropTypes.string, PropTypes.oneOf(['xs', 'sm', 'md', 'lg', 'xl', false])]),
|
74
|
+
homeLink: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
|
51
75
|
};
|
52
76
|
|
53
77
|
Header.defaultProps = {
|
@@ -60,6 +84,7 @@ Header.defaultProps = {
|
|
60
84
|
prepend: null,
|
61
85
|
align: 'left',
|
62
86
|
maxWidth: undefined,
|
87
|
+
homeLink: '/',
|
63
88
|
};
|
64
89
|
|
65
90
|
const Root = styled('div')`
|
@@ -72,7 +97,20 @@ const Root = styled('div')`
|
|
72
97
|
align-items: center;
|
73
98
|
height: 64px;
|
74
99
|
}
|
75
|
-
|
100
|
+
|
101
|
+
.header-brand-wrapper {
|
102
|
+
flex-shrink: 1;
|
103
|
+
min-width: 0;
|
104
|
+
> a {
|
105
|
+
display: flex;
|
106
|
+
align-items: center;
|
107
|
+
height: 100%;
|
108
|
+
line-height: 1;
|
109
|
+
color: inherit;
|
110
|
+
text-decoration: none;
|
111
|
+
}
|
112
|
+
}
|
113
|
+
.header-brand-wrapper .header-logo {
|
76
114
|
display: inline-flex;
|
77
115
|
position: relative;
|
78
116
|
height: 44px;
|
@@ -83,19 +121,6 @@ const Root = styled('div')`
|
|
83
121
|
height: 100%;
|
84
122
|
max-height: 100%;
|
85
123
|
}
|
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
124
|
}
|
100
125
|
.header-brand {
|
101
126
|
display: flex;
|
@@ -137,6 +162,9 @@ const Root = styled('div')`
|
|
137
162
|
}
|
138
163
|
}
|
139
164
|
}
|
165
|
+
.header-brand-addon {
|
166
|
+
display: none;
|
167
|
+
}
|
140
168
|
}
|
141
169
|
${(props) => props.theme.breakpoints.down('md')} {
|
142
170
|
.header-menu {
|
@@ -155,9 +183,6 @@ const Root = styled('div')`
|
|
155
183
|
font-size: 12px;
|
156
184
|
}
|
157
185
|
}
|
158
|
-
.header-brand-addon {
|
159
|
-
display: none;
|
160
|
-
}
|
161
186
|
}
|
162
187
|
`;
|
163
188
|
|
@@ -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 {...
|
69
|
+
<StyledUxHeader {..._headerProps} className="dashboard-header">
|
65
70
|
{links?.length
|
66
71
|
? ({ isMobile, closeMenu }) => {
|
67
72
|
if (isMobile) {
|