@blocklet/ui-react 2.9.90 → 2.10.0
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/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
package/lib/Footer/links.js
CHANGED
|
@@ -1,119 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
11
|
-
var _clsx = _interopRequireDefault(require("clsx"));
|
|
12
|
-
var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
|
|
13
|
-
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function Links({
|
|
16
|
-
links,
|
|
17
|
-
flowLayout,
|
|
18
|
-
...rest
|
|
19
|
-
}) {
|
|
20
|
-
const [activeIndex, setActiveIndex] = (0, _react.useState)(-1);
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { styled } from "@arcblock/ux/lib/Theme";
|
|
5
|
+
import clsx from "clsx";
|
|
6
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
7
|
+
import Icon from "../Icon/index.js";
|
|
8
|
+
export default function Links({ links, flowLayout, ...rest }) {
|
|
9
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
21
10
|
if (!links?.length) {
|
|
22
11
|
return null;
|
|
23
12
|
}
|
|
24
|
-
const isGroupMode = links.some(item => item.items?.length);
|
|
25
|
-
const renderItem = ({
|
|
26
|
-
label,
|
|
27
|
-
link,
|
|
28
|
-
icon,
|
|
29
|
-
render,
|
|
30
|
-
props
|
|
31
|
-
}) => {
|
|
13
|
+
const isGroupMode = links.some((item) => item.items?.length);
|
|
14
|
+
const renderItem = ({ label, link, icon, render, props }) => {
|
|
32
15
|
let result = label;
|
|
33
16
|
if (render) {
|
|
34
|
-
result = render({
|
|
35
|
-
label,
|
|
36
|
-
link,
|
|
37
|
-
props
|
|
38
|
-
});
|
|
17
|
+
result = render({ label, link, props });
|
|
39
18
|
} else if (link) {
|
|
40
|
-
result = /* @__PURE__ */
|
|
41
|
-
href: link,
|
|
42
|
-
"aria-label": `Footer link for ${label}`,
|
|
43
|
-
...props,
|
|
44
|
-
children: label
|
|
45
|
-
});
|
|
19
|
+
result = /* @__PURE__ */ jsx("a", { href: link, "aria-label": `Footer link for ${label}`, ...props, children: label });
|
|
46
20
|
}
|
|
47
|
-
return /* @__PURE__ */
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
sx: {
|
|
52
|
-
mr: 0.5
|
|
53
|
-
}
|
|
54
|
-
}), result]
|
|
55
|
-
});
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
icon && /* @__PURE__ */ jsx(Icon, { icon, size: 20, sx: { mr: 0.5 } }),
|
|
23
|
+
result
|
|
24
|
+
] });
|
|
56
25
|
};
|
|
57
|
-
return /* @__PURE__ */
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
children:
|
|
66
|
-
className: "footer-links-item",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
});
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
Root,
|
|
28
|
+
{
|
|
29
|
+
...rest,
|
|
30
|
+
className: clsx(rest.className, {
|
|
31
|
+
"footer-links--grouped": isGroupMode,
|
|
32
|
+
"footer-links--flow": flowLayout
|
|
33
|
+
}),
|
|
34
|
+
children: /* @__PURE__ */ jsxs("div", { className: "footer-links-inner", children: [
|
|
35
|
+
flowLayout && links.map((item, i) => /* @__PURE__ */ jsx("span", { className: "footer-links-item", children: renderItem(item) }, i)),
|
|
36
|
+
!flowLayout && links.map((item, i) => {
|
|
37
|
+
const { items } = item;
|
|
38
|
+
const isActive = i === activeIndex;
|
|
39
|
+
return /* @__PURE__ */ jsxs(
|
|
40
|
+
"div",
|
|
41
|
+
{
|
|
42
|
+
className: clsx("footer-links-group", {
|
|
43
|
+
"footer-links-group--active": isActive
|
|
44
|
+
}),
|
|
45
|
+
onClick: () => setActiveIndex(activeIndex === i ? -1 : i),
|
|
46
|
+
children: [
|
|
47
|
+
/* @__PURE__ */ jsxs("span", { className: "footer-links-item", children: [
|
|
48
|
+
renderItem(item),
|
|
49
|
+
!!items?.length && /* @__PURE__ */ jsx("span", { className: "footer-links-group-expand-icon", children: /* @__PURE__ */ jsx(
|
|
50
|
+
ExpandMoreIcon,
|
|
51
|
+
{
|
|
52
|
+
style: {
|
|
53
|
+
transform: `rotate(${isActive ? 180 : 0}deg)`
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
) })
|
|
57
|
+
] }),
|
|
58
|
+
!!items?.length && /* @__PURE__ */ jsx("div", { className: "footer-links-sub", children: items.map((child, j) => /* @__PURE__ */ jsx("span", { className: "footer-links-item", children: renderItem(child) }, j)) })
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
i
|
|
62
|
+
);
|
|
63
|
+
})
|
|
64
|
+
] })
|
|
65
|
+
}
|
|
66
|
+
);
|
|
99
67
|
}
|
|
100
68
|
Links.propTypes = {
|
|
101
|
-
links:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
69
|
+
links: PropTypes.arrayOf(
|
|
70
|
+
PropTypes.shape({
|
|
71
|
+
label: PropTypes.string,
|
|
72
|
+
link: PropTypes.string,
|
|
73
|
+
render: PropTypes.func,
|
|
74
|
+
props: PropTypes.object
|
|
75
|
+
})
|
|
76
|
+
),
|
|
107
77
|
// 流动布局, 简单的从左到右排列
|
|
108
|
-
flowLayout:
|
|
78
|
+
flowLayout: PropTypes.bool
|
|
109
79
|
};
|
|
110
80
|
Links.defaultProps = {
|
|
111
81
|
links: [],
|
|
112
82
|
flowLayout: false
|
|
113
83
|
};
|
|
114
|
-
const Root =
|
|
84
|
+
const Root = styled("div")`
|
|
115
85
|
overflow: hidden;
|
|
116
|
-
color: ${props => props.theme.palette.grey[600]};
|
|
86
|
+
color: ${(props) => props.theme.palette.grey[600]};
|
|
117
87
|
.footer-links-inner {
|
|
118
88
|
display: flex;
|
|
119
89
|
justify-content: space-between;
|
|
@@ -125,7 +95,7 @@ const Root = (0, _Theme.styled)("div")`
|
|
|
125
95
|
flex-direction: column;
|
|
126
96
|
}
|
|
127
97
|
.footer-links-sub .footer-links-item {
|
|
128
|
-
color: ${props => props.theme.palette.grey[900]};
|
|
98
|
+
color: ${(props) => props.theme.palette.grey[900]};
|
|
129
99
|
}
|
|
130
100
|
.footer-links-group-expand-icon {
|
|
131
101
|
display: none;
|
|
@@ -182,12 +152,12 @@ const Root = (0, _Theme.styled)("div")`
|
|
|
182
152
|
top: 50%;
|
|
183
153
|
transform: translate(0, -50%);
|
|
184
154
|
height: 1em;
|
|
185
|
-
border-left: 1px solid ${props => props.theme.palette.grey[400]};
|
|
155
|
+
border-left: 1px solid ${(props) => props.theme.palette.grey[400]};
|
|
186
156
|
}
|
|
187
157
|
}
|
|
188
158
|
}
|
|
189
159
|
|
|
190
|
-
${props => props.theme.breakpoints.down("md")} {
|
|
160
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
191
161
|
.footer-links-inner {
|
|
192
162
|
flex-direction: column;
|
|
193
163
|
margin: 0;
|
|
@@ -203,7 +173,7 @@ const Root = (0, _Theme.styled)("div")`
|
|
|
203
173
|
}
|
|
204
174
|
}
|
|
205
175
|
.footer-links-group + .footer-links-group {
|
|
206
|
-
border-top: 1px solid ${props => props.theme.palette.grey[200]};
|
|
176
|
+
border-top: 1px solid ${(props) => props.theme.palette.grey[200]};
|
|
207
177
|
}
|
|
208
178
|
.footer-links-group--active {
|
|
209
179
|
.footer-links-sub {
|
|
@@ -234,4 +204,4 @@ const Root = (0, _Theme.styled)("div")`
|
|
|
234
204
|
}
|
|
235
205
|
}
|
|
236
206
|
}
|
|
237
|
-
`;
|
|
207
|
+
`;
|
|
@@ -1,67 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
-
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
10
|
-
var _Icon = _interopRequireDefault(require("../Icon"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function SocialMedia({
|
|
13
|
-
items,
|
|
14
|
-
...rest
|
|
15
|
-
}) {
|
|
16
|
-
const theme = (0, _Theme.useTheme)();
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import { useTheme, styled } from "@arcblock/ux/lib/Theme";
|
|
4
|
+
import Icon from "../Icon/index.js";
|
|
5
|
+
export default function SocialMedia({ items, ...rest }) {
|
|
6
|
+
const theme = useTheme();
|
|
17
7
|
if (!items?.length) {
|
|
18
8
|
return null;
|
|
19
9
|
}
|
|
20
|
-
return /* @__PURE__ */(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
return /* @__PURE__ */ jsx(Root, { ...rest, children: items.map((item, i) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"a",
|
|
13
|
+
{
|
|
24
14
|
href: item.link,
|
|
25
15
|
target: "_blank",
|
|
26
16
|
"aria-label": `Social media icon${item.title ? ` for ${item.title}` : ""}`,
|
|
27
17
|
rel: "noreferrer",
|
|
28
|
-
children: /* @__PURE__ */
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
color: "#fff"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
children: /* @__PURE__ */ jsx(
|
|
19
|
+
Icon,
|
|
20
|
+
{
|
|
21
|
+
icon: item.icon || item.title,
|
|
22
|
+
sx: { bgcolor: theme.palette.grey[600], color: "#fff" },
|
|
23
|
+
size: 24,
|
|
24
|
+
component: "span"
|
|
25
|
+
}
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
i
|
|
29
|
+
);
|
|
30
|
+
}) });
|
|
40
31
|
}
|
|
41
32
|
SocialMedia.propTypes = {
|
|
42
|
-
items:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
items: PropTypes.arrayOf(
|
|
34
|
+
PropTypes.shape({
|
|
35
|
+
// icon 对应 Icon#icon prop, 支持 iconify name 和 url 2 种形式:
|
|
36
|
+
icon: PropTypes.string,
|
|
37
|
+
link: PropTypes.string
|
|
38
|
+
})
|
|
39
|
+
)
|
|
47
40
|
};
|
|
48
41
|
SocialMedia.defaultProps = {
|
|
49
42
|
items: null
|
|
50
43
|
};
|
|
51
|
-
const Root =
|
|
44
|
+
const Root = styled("div")`
|
|
52
45
|
display: inline-flex;
|
|
53
46
|
flex-wrap: wrap;
|
|
54
47
|
align-items: center;
|
|
55
48
|
justify-content: center;
|
|
56
49
|
gap: 20px;
|
|
57
50
|
a {
|
|
58
|
-
color: ${props => props.theme.palette.grey[400]};
|
|
51
|
+
color: ${(props) => props.theme.palette.grey[400]};
|
|
59
52
|
text-decoration: none;
|
|
60
53
|
&:hover {
|
|
61
|
-
color: ${props => props.theme.palette.primary.light};
|
|
54
|
+
color: ${(props) => props.theme.palette.primary.light};
|
|
62
55
|
}
|
|
63
56
|
}
|
|
64
|
-
${props => props.theme.breakpoints.down("md")} {
|
|
57
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
65
58
|
gap: 12px;
|
|
66
59
|
}
|
|
67
|
-
`;
|
|
60
|
+
`;
|
package/lib/Header/index.js
CHANGED
|
@@ -1,40 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _types = require("../types");
|
|
21
|
-
var _utils = require("../utils");
|
|
22
|
-
var _blocklets = require("../blocklets");
|
|
23
|
-
var _headerAddons = _interopRequireDefault(require("../common/header-addons"));
|
|
24
|
-
var _walletHiddenTopbar = require("../common/wallet-hidden-topbar");
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
-
const parseNavigation = navigation => {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import PropTypes from "prop-types";
|
|
4
|
+
import { withErrorBoundary } from "react-error-boundary";
|
|
5
|
+
import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
|
|
6
|
+
import { styled } from "@arcblock/ux/lib/Theme";
|
|
7
|
+
import { ResponsiveHeader } from "@arcblock/ux/lib/Header";
|
|
8
|
+
import NavMenu from "@arcblock/ux/lib/NavMenu";
|
|
9
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
11
|
+
import omit from "lodash/omit";
|
|
12
|
+
import Icon from "../Icon/index.js";
|
|
13
|
+
import OverridableThemeProvider from "../common/overridable-theme-provider.js";
|
|
14
|
+
import { BlockletMetaProps, SessionManagerProps } from "../types.js";
|
|
15
|
+
import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
16
|
+
import { publicPath, formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
17
|
+
import HeaderAddons from "../common/header-addons.js";
|
|
18
|
+
import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
|
|
19
|
+
const parseNavigation = (navigation) => {
|
|
27
20
|
if (!navigation?.length) {
|
|
28
|
-
return {
|
|
29
|
-
navItems: [],
|
|
30
|
-
activeId: null
|
|
31
|
-
};
|
|
21
|
+
return { navItems: [], activeId: null };
|
|
32
22
|
}
|
|
33
23
|
let counter = 1;
|
|
34
|
-
const parseItem = item => {
|
|
35
|
-
const icon = item.icon ? /* @__PURE__ */(
|
|
36
|
-
icon: item.icon
|
|
37
|
-
}) : null;
|
|
24
|
+
const parseItem = (item) => {
|
|
25
|
+
const icon = item.icon ? /* @__PURE__ */ jsx(Icon, { icon: item.icon }) : null;
|
|
38
26
|
if (item.items) {
|
|
39
27
|
return {
|
|
40
28
|
id: `${counter++}`,
|
|
@@ -52,40 +40,23 @@ const parseNavigation = navigation => {
|
|
|
52
40
|
}
|
|
53
41
|
return {
|
|
54
42
|
id: `${counter++}`,
|
|
55
|
-
label: /* @__PURE__ */
|
|
56
|
-
href: item.link,
|
|
57
|
-
...props,
|
|
58
|
-
children: item.title
|
|
59
|
-
}),
|
|
43
|
+
label: /* @__PURE__ */ jsx("a", { href: item.link, ...props, children: item.title }),
|
|
60
44
|
icon,
|
|
61
45
|
link: item.link
|
|
62
46
|
};
|
|
63
47
|
};
|
|
64
|
-
const navItems =
|
|
65
|
-
const flattened =
|
|
66
|
-
const matchedIndex =
|
|
67
|
-
return {
|
|
68
|
-
navItems,
|
|
69
|
-
activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null
|
|
70
|
-
};
|
|
48
|
+
const navItems = mapRecursive(navigation, parseItem, "items");
|
|
49
|
+
const flattened = flatRecursive(navItems);
|
|
50
|
+
const matchedIndex = matchPaths(flattened.map((item) => item.link));
|
|
51
|
+
return { navItems, activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null };
|
|
71
52
|
};
|
|
72
|
-
function Header({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
homeLink,
|
|
77
|
-
theme: themeOverrides,
|
|
78
|
-
hideNavMenu,
|
|
79
|
-
...rest
|
|
80
|
-
}) {
|
|
81
|
-
(0, _walletHiddenTopbar.useWalletHiddenTopbar)();
|
|
82
|
-
const {
|
|
83
|
-
locale
|
|
84
|
-
} = (0, _context.useLocaleContext)() || {};
|
|
85
|
-
const formattedBlocklet = (0, _react.useMemo)(() => {
|
|
53
|
+
function Header({ meta, addons, sessionManagerProps, homeLink, theme: themeOverrides, hideNavMenu, ...rest }) {
|
|
54
|
+
useWalletHiddenTopbar();
|
|
55
|
+
const { locale } = useLocaleContext() || {};
|
|
56
|
+
const formattedBlocklet = useMemo(() => {
|
|
86
57
|
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
87
58
|
try {
|
|
88
|
-
return
|
|
59
|
+
return formatBlockletInfo(blocklet);
|
|
89
60
|
} catch (e) {
|
|
90
61
|
console.error("Failed to format blocklet info", e, blocklet);
|
|
91
62
|
return blocklet;
|
|
@@ -94,61 +65,46 @@ function Header({
|
|
|
94
65
|
if (!formattedBlocklet.appName) {
|
|
95
66
|
return null;
|
|
96
67
|
}
|
|
97
|
-
const {
|
|
98
|
-
|
|
99
|
-
appLogoRect,
|
|
100
|
-
theme
|
|
101
|
-
} = formattedBlocklet;
|
|
102
|
-
const navigation = (0, _blocklets.getLocalizedNavigation)(formattedBlocklet?.navigation?.header, locale);
|
|
68
|
+
const { appLogo, appLogoRect, theme } = formattedBlocklet;
|
|
69
|
+
const navigation = getLocalizedNavigation(formattedBlocklet?.navigation?.header, locale);
|
|
103
70
|
const parsedNavigation = parseNavigation(navigation);
|
|
104
|
-
const {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}) : addons;
|
|
111
|
-
const headerAddons = /* @__PURE__ */(0, _jsxRuntime.jsx)(_headerAddons.default, {
|
|
112
|
-
formattedBlocklet,
|
|
113
|
-
addons: _addons,
|
|
114
|
-
sessionManagerProps
|
|
115
|
-
});
|
|
116
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_overridableThemeProvider.default, {
|
|
117
|
-
theme: themeOverrides,
|
|
118
|
-
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(StyledUxHeader, {
|
|
71
|
+
const { navItems, activeId } = parsedNavigation;
|
|
72
|
+
const _addons = typeof addons === "function" ? (builtInAddons) => addons(builtInAddons, { navigation: parsedNavigation }) : addons;
|
|
73
|
+
const headerAddons = /* @__PURE__ */ jsx(HeaderAddons, { formattedBlocklet, addons: _addons, sessionManagerProps });
|
|
74
|
+
return /* @__PURE__ */ jsx(OverridableThemeProvider, { theme: themeOverrides, children: /* @__PURE__ */ jsx(
|
|
75
|
+
StyledUxHeader,
|
|
76
|
+
{
|
|
119
77
|
homeLink,
|
|
120
|
-
logo: /* @__PURE__ */
|
|
121
|
-
src: appLogoRect || appLogo,
|
|
122
|
-
alt: "logo"
|
|
123
|
-
}),
|
|
78
|
+
logo: /* @__PURE__ */ jsx("img", { src: appLogoRect || appLogo, alt: "logo" }),
|
|
124
79
|
addons: headerAddons,
|
|
125
|
-
...(
|
|
80
|
+
...omit(rest, ["bordered"]),
|
|
126
81
|
$bordered: rest?.bordered,
|
|
127
82
|
$bgcolor: theme?.background?.header,
|
|
128
|
-
children: hideNavMenu || !navItems?.length ? null : ({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
83
|
+
children: hideNavMenu || !navItems?.length ? null : ({ isMobile }) => /* @__PURE__ */ jsx(
|
|
84
|
+
NavMenu,
|
|
85
|
+
{
|
|
86
|
+
mode: isMobile ? "inline" : "horizontal",
|
|
87
|
+
activeId,
|
|
88
|
+
items: navItems,
|
|
89
|
+
className: "header-nav",
|
|
90
|
+
bgColor: "transparent",
|
|
91
|
+
textColor: "#777"
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
) });
|
|
140
96
|
}
|
|
141
97
|
Header.propTypes = {
|
|
142
|
-
meta:
|
|
98
|
+
meta: BlockletMetaProps,
|
|
143
99
|
// 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
|
|
144
100
|
// - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
|
|
145
101
|
// - PropTypes.node: 将 addons 原样传给 UX Header 组件
|
|
146
|
-
addons:
|
|
147
|
-
sessionManagerProps:
|
|
148
|
-
homeLink:
|
|
102
|
+
addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
|
|
103
|
+
sessionManagerProps: SessionManagerProps,
|
|
104
|
+
homeLink: PropTypes.string,
|
|
149
105
|
// 允许覆盖 header 内置的 theme
|
|
150
|
-
theme:
|
|
151
|
-
hideNavMenu:
|
|
106
|
+
theme: PropTypes.object,
|
|
107
|
+
hideNavMenu: PropTypes.bool
|
|
152
108
|
};
|
|
153
109
|
Header.defaultProps = {
|
|
154
110
|
meta: {},
|
|
@@ -156,23 +112,19 @@ Header.defaultProps = {
|
|
|
156
112
|
sessionManagerProps: {
|
|
157
113
|
showRole: true
|
|
158
114
|
},
|
|
159
|
-
homeLink:
|
|
115
|
+
homeLink: publicPath,
|
|
160
116
|
theme: null,
|
|
161
117
|
hideNavMenu: false
|
|
162
118
|
};
|
|
163
|
-
const StyledUxHeader =
|
|
164
|
-
${({
|
|
165
|
-
$bgcolor
|
|
166
|
-
}) => `background-color: ${$bgcolor || "#fff"};`}
|
|
119
|
+
const StyledUxHeader = styled(ResponsiveHeader)`
|
|
120
|
+
${({ $bgcolor }) => `background-color: ${$bgcolor || "#fff"};`}
|
|
167
121
|
font-family: Inter, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
168
122
|
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
169
123
|
.header-logo {
|
|
170
124
|
min-width: 44px;
|
|
171
125
|
}
|
|
172
|
-
${({
|
|
173
|
-
$
|
|
174
|
-
}) => $bordered ? `border-bottom: 1px solid ${_Colors.temp.strokeSep};` : ""}
|
|
175
|
-
${props => props.theme.breakpoints.down("md")} {
|
|
126
|
+
${({ $bordered }) => $bordered ? `border-bottom: 1px solid ${colors.strokeSep};` : ""}
|
|
127
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
176
128
|
.header-logo {
|
|
177
129
|
min-width: 32px;
|
|
178
130
|
}
|
|
@@ -198,6 +150,6 @@ const StyledUxHeader = (0, _Theme.styled)(_Header.ResponsiveHeader)`
|
|
|
198
150
|
}
|
|
199
151
|
}
|
|
200
152
|
`;
|
|
201
|
-
|
|
202
|
-
FallbackComponent:
|
|
203
|
-
});
|
|
153
|
+
export default withErrorBoundary(Header, {
|
|
154
|
+
FallbackComponent: ErrorFallback
|
|
155
|
+
});
|