@blocklet/ui-react 2.9.12 → 2.9.14
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 +29 -0
- package/es/@types/index.d.ts +63 -0
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +12 -0
- package/es/Dashboard/index.d.ts +41 -0
- package/es/Dashboard/index.js +63 -97
- package/es/Footer/brand.d.ts +22 -0
- package/es/Footer/brand.js +20 -37
- package/es/Footer/copyright.d.ts +18 -0
- package/es/Footer/copyright.js +14 -16
- package/es/Footer/index.d.ts +6 -0
- package/es/Footer/index.js +30 -56
- package/es/Footer/internal-footer.d.ts +29 -0
- package/es/Footer/internal-footer.js +67 -94
- package/es/Footer/layout/plain.d.ts +15 -0
- package/es/Footer/layout/plain.js +19 -37
- package/es/Footer/layout/row.d.ts +18 -0
- package/es/Footer/layout/row.js +9 -19
- package/es/Footer/layout/standard.d.ts +15 -0
- package/es/Footer/layout/standard.js +29 -57
- package/es/Footer/links.d.ts +22 -0
- package/es/Footer/links.js +72 -104
- package/es/Footer/social-media.d.ts +14 -0
- package/es/Footer/social-media.js +35 -35
- package/es/Header/index.d.ts +9 -0
- package/es/Header/index.js +55 -100
- package/es/Icon/index.d.ts +23 -0
- package/es/Icon/index.js +23 -58
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.d.ts +5 -0
- package/es/UserCenter/components/notification.js +276 -0
- package/es/UserCenter/components/passport.d.ts +6 -0
- package/es/UserCenter/components/passport.js +69 -0
- package/es/UserCenter/components/privacy.d.ts +11 -0
- package/es/UserCenter/components/privacy.js +99 -0
- package/es/UserCenter/components/settings.d.ts +10 -0
- package/es/UserCenter/components/settings.js +68 -0
- package/es/UserCenter/components/user-basic-info.d.ts +8 -0
- package/es/UserCenter/components/user-basic-info.js +66 -0
- package/es/UserCenter/components/user-center.d.ts +9 -0
- package/es/UserCenter/components/user-center.js +397 -0
- package/es/UserCenter/components/user-info-item.d.ts +10 -0
- package/es/UserCenter/components/user-info-item.js +54 -0
- package/es/UserCenter/components/user-info.d.ts +6 -0
- package/es/UserCenter/components/user-info.js +68 -0
- package/es/UserCenter/components/webhook-item.d.ts +3 -0
- package/es/UserCenter/components/webhook-item.js +243 -0
- package/es/UserCenter/index.d.ts +1 -0
- package/es/UserCenter/index.js +1 -0
- package/es/UserCenter/libs/client.d.ts +2 -0
- package/es/UserCenter/libs/client.js +2 -0
- package/es/UserCenter/libs/locales.d.ts +72 -0
- package/es/UserCenter/libs/locales.js +72 -0
- package/es/UserCenter/libs/utils.d.ts +4 -0
- package/es/UserCenter/libs/utils.js +14 -0
- package/es/blocklets.d.ts +16 -0
- package/es/blocklets.js +56 -45
- package/es/common/header-addons.d.ts +22 -0
- package/es/common/header-addons.js +41 -59
- package/es/common/link-blocker.d.ts +7 -0
- package/es/common/link-blocker.js +10 -17
- package/es/common/overridable-theme-provider.d.ts +18 -0
- package/es/common/overridable-theme-provider.js +6 -16
- package/es/common/wallet-hidden-topbar.d.ts +1 -0
- package/es/common/wallet-hidden-topbar.js +12 -10
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -0
- package/es/types.d.ts +2 -0
- package/es/types.js +17 -11
- package/es/utils.d.ts +8 -0
- package/es/utils.js +21 -26
- package/lib/@types/index.d.ts +63 -0
- package/lib/@types/index.js +1 -0
- package/lib/@types/shims.d.ts +12 -0
- package/lib/Dashboard/index.d.ts +41 -0
- package/lib/Dashboard/index.js +44 -71
- package/lib/Footer/brand.d.ts +22 -0
- package/lib/Footer/brand.js +65 -30
- package/lib/Footer/copyright.d.ts +18 -0
- package/lib/Footer/copyright.js +18 -23
- package/lib/Footer/index.d.ts +6 -0
- package/lib/Footer/index.js +33 -42
- package/lib/Footer/internal-footer.d.ts +29 -0
- package/lib/Footer/internal-footer.js +43 -59
- package/lib/Footer/layout/plain.d.ts +15 -0
- package/lib/Footer/layout/plain.js +25 -30
- package/lib/Footer/layout/row.d.ts +18 -0
- package/lib/Footer/layout/row.js +34 -23
- package/lib/Footer/layout/standard.d.ts +15 -0
- package/lib/Footer/layout/standard.js +35 -41
- package/lib/Footer/links.d.ts +22 -0
- package/lib/Footer/links.js +163 -60
- package/lib/Footer/social-media.d.ts +14 -0
- package/lib/Footer/social-media.js +31 -25
- package/lib/Header/index.d.ts +9 -0
- package/lib/Header/index.js +83 -76
- package/lib/Icon/index.d.ts +23 -0
- package/lib/Icon/index.js +37 -51
- package/lib/UserCenter/assets/banner.png +0 -0
- package/lib/UserCenter/components/notification.d.ts +5 -0
- package/lib/UserCenter/components/notification.js +261 -0
- package/lib/UserCenter/components/passport.d.ts +6 -0
- package/lib/UserCenter/components/passport.js +86 -0
- package/lib/UserCenter/components/privacy.d.ts +11 -0
- package/lib/UserCenter/components/privacy.js +101 -0
- package/lib/UserCenter/components/settings.d.ts +10 -0
- package/lib/UserCenter/components/settings.js +81 -0
- package/lib/UserCenter/components/user-basic-info.d.ts +8 -0
- package/lib/UserCenter/components/user-basic-info.js +67 -0
- package/lib/UserCenter/components/user-center.d.ts +9 -0
- package/lib/UserCenter/components/user-center.js +376 -0
- package/lib/UserCenter/components/user-info-item.d.ts +10 -0
- package/lib/UserCenter/components/user-info-item.js +46 -0
- package/lib/UserCenter/components/user-info.d.ts +6 -0
- package/lib/UserCenter/components/user-info.js +94 -0
- package/lib/UserCenter/components/webhook-item.d.ts +3 -0
- package/lib/UserCenter/components/webhook-item.js +236 -0
- package/lib/UserCenter/index.d.ts +1 -0
- package/lib/UserCenter/index.js +13 -0
- package/lib/UserCenter/libs/client.d.ts +2 -0
- package/lib/UserCenter/libs/client.js +8 -0
- package/lib/UserCenter/libs/locales.d.ts +72 -0
- package/lib/UserCenter/libs/locales.js +78 -0
- package/lib/UserCenter/libs/utils.d.ts +4 -0
- package/lib/UserCenter/libs/utils.js +25 -0
- package/lib/blocklets.d.ts +16 -0
- package/lib/blocklets.js +28 -36
- package/lib/common/header-addons.d.ts +22 -0
- package/lib/common/header-addons.js +24 -36
- package/lib/common/link-blocker.d.ts +7 -0
- package/lib/common/link-blocker.js +10 -18
- package/lib/common/overridable-theme-provider.d.ts +18 -0
- package/lib/common/overridable-theme-provider.js +9 -14
- package/lib/common/wallet-hidden-topbar.d.ts +1 -0
- package/lib/common/wallet-hidden-topbar.js +1 -3
- package/lib/index.d.ts +5 -0
- package/lib/index.js +52 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +3 -5
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +16 -23
- package/package.json +17 -11
- package/src/@types/index.ts +70 -0
- package/src/@types/shims.d.ts +12 -0
- package/src/UserCenter/assets/banner.png +0 -0
- package/src/UserCenter/components/notification.tsx +275 -0
- package/src/UserCenter/components/passport.tsx +83 -0
- package/src/UserCenter/components/privacy.tsx +107 -0
- package/src/UserCenter/components/settings.tsx +78 -0
- package/src/UserCenter/components/user-basic-info.tsx +70 -0
- package/src/UserCenter/components/user-center.tsx +410 -0
- package/src/UserCenter/components/user-info-item.tsx +50 -0
- package/src/UserCenter/components/user-info.tsx +85 -0
- package/src/UserCenter/components/webhook-item.tsx +243 -0
- package/src/UserCenter/index.tsx +1 -0
- package/src/UserCenter/libs/client.ts +3 -0
- package/src/UserCenter/libs/locales.ts +72 -0
- package/src/UserCenter/libs/utils.ts +21 -0
- package/src/blocklets.js +2 -0
- package/src/index.ts +9 -0
- /package/src/common/{link-blocker.js → link-blocker.jsx} +0 -0
package/es/Footer/links.js
CHANGED
|
@@ -1,111 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
import { useState } from
|
|
3
|
-
import PropTypes from
|
|
4
|
-
import { styled } from
|
|
5
|
-
import clsx from
|
|
6
|
-
import ExpandMoreIcon from
|
|
7
|
-
import Icon from
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* footer 中的 links (支持分组, 最多支持 2 级)
|
|
11
|
-
* TODO: dark/light theme
|
|
12
|
-
*/
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
export default function Links({
|
|
17
|
-
links,
|
|
18
|
-
flowLayout,
|
|
19
|
-
...rest
|
|
20
|
-
}) {
|
|
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 }) {
|
|
21
9
|
const [activeIndex, setActiveIndex] = useState(-1);
|
|
22
10
|
if (!links?.length) {
|
|
23
11
|
return null;
|
|
24
12
|
}
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const renderItem = ({
|
|
28
|
-
label,
|
|
29
|
-
link,
|
|
30
|
-
icon,
|
|
31
|
-
render,
|
|
32
|
-
props
|
|
33
|
-
}) => {
|
|
13
|
+
const isGroupMode = links.some((item) => item.items?.length);
|
|
14
|
+
const renderItem = ({ label, link, icon, render, props }) => {
|
|
34
15
|
let result = label;
|
|
35
16
|
if (render) {
|
|
36
|
-
result = render({
|
|
37
|
-
label,
|
|
38
|
-
link,
|
|
39
|
-
props
|
|
40
|
-
});
|
|
17
|
+
result = render({ label, link, props });
|
|
41
18
|
} else if (link) {
|
|
42
|
-
result =
|
|
43
|
-
href: link,
|
|
44
|
-
"aria-label": `Footer link for ${label}`,
|
|
45
|
-
...props,
|
|
46
|
-
children: label
|
|
47
|
-
});
|
|
19
|
+
result = /* @__PURE__ */ jsx("a", { href: link, "aria-label": `Footer link for ${label}`, ...props, children: label });
|
|
48
20
|
}
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
sx: {
|
|
54
|
-
mr: 0.5
|
|
55
|
-
}
|
|
56
|
-
}), result]
|
|
57
|
-
});
|
|
21
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
22
|
+
icon && /* @__PURE__ */ jsx(Icon, { icon, size: 20, sx: { mr: 0.5 } }),
|
|
23
|
+
result
|
|
24
|
+
] });
|
|
58
25
|
};
|
|
59
|
-
return
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
children:
|
|
68
|
-
className: "footer-links-item",
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
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
|
+
);
|
|
101
67
|
}
|
|
102
68
|
Links.propTypes = {
|
|
103
|
-
links: PropTypes.arrayOf(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
+
),
|
|
109
77
|
// 流动布局, 简单的从左到右排列
|
|
110
78
|
flowLayout: PropTypes.bool
|
|
111
79
|
};
|
|
@@ -113,9 +81,9 @@ Links.defaultProps = {
|
|
|
113
81
|
links: [],
|
|
114
82
|
flowLayout: false
|
|
115
83
|
};
|
|
116
|
-
const Root = styled(
|
|
84
|
+
const Root = styled("div")`
|
|
117
85
|
overflow: hidden;
|
|
118
|
-
color: ${props => props.theme.palette.grey[600]};
|
|
86
|
+
color: ${(props) => props.theme.palette.grey[600]};
|
|
119
87
|
.footer-links-inner {
|
|
120
88
|
display: flex;
|
|
121
89
|
justify-content: space-between;
|
|
@@ -127,7 +95,7 @@ const Root = styled('div')`
|
|
|
127
95
|
flex-direction: column;
|
|
128
96
|
}
|
|
129
97
|
.footer-links-sub .footer-links-item {
|
|
130
|
-
color: ${props => props.theme.palette.grey[900]};
|
|
98
|
+
color: ${(props) => props.theme.palette.grey[900]};
|
|
131
99
|
}
|
|
132
100
|
.footer-links-group-expand-icon {
|
|
133
101
|
display: none;
|
|
@@ -184,12 +152,12 @@ const Root = styled('div')`
|
|
|
184
152
|
top: 50%;
|
|
185
153
|
transform: translate(0, -50%);
|
|
186
154
|
height: 1em;
|
|
187
|
-
border-left: 1px solid ${props => props.theme.palette.grey[400]};
|
|
155
|
+
border-left: 1px solid ${(props) => props.theme.palette.grey[400]};
|
|
188
156
|
}
|
|
189
157
|
}
|
|
190
158
|
}
|
|
191
159
|
|
|
192
|
-
${props => props.theme.breakpoints.down(
|
|
160
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
193
161
|
.footer-links-inner {
|
|
194
162
|
flex-direction: column;
|
|
195
163
|
margin: 0;
|
|
@@ -205,7 +173,7 @@ const Root = styled('div')`
|
|
|
205
173
|
}
|
|
206
174
|
}
|
|
207
175
|
.footer-links-group + .footer-links-group {
|
|
208
|
-
border-top: 1px solid ${props => props.theme.palette.grey[200]};
|
|
176
|
+
border-top: 1px solid ${(props) => props.theme.palette.grey[200]};
|
|
209
177
|
}
|
|
210
178
|
.footer-links-group--active {
|
|
211
179
|
.footer-links-sub {
|
|
@@ -236,4 +204,4 @@ const Root = styled('div')`
|
|
|
236
204
|
}
|
|
237
205
|
}
|
|
238
206
|
}
|
|
239
|
-
`;
|
|
207
|
+
`;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare function SocialMedia({ items, ...rest }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
items: any;
|
|
4
|
+
}): import("react").JSX.Element | null;
|
|
5
|
+
declare namespace SocialMedia {
|
|
6
|
+
namespace propTypes {
|
|
7
|
+
let items: any;
|
|
8
|
+
}
|
|
9
|
+
namespace defaultProps {
|
|
10
|
+
let items_1: null;
|
|
11
|
+
export { items_1 as items };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export default SocialMedia;
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export default function SocialMedia({
|
|
6
|
-
items,
|
|
7
|
-
...rest
|
|
8
|
-
}) {
|
|
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 }) {
|
|
9
6
|
const theme = useTheme();
|
|
10
7
|
if (!items?.length) {
|
|
11
8
|
return null;
|
|
12
9
|
}
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
return /* @__PURE__ */ jsx(Root, { ...rest, children: items.map((item, i) => {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"a",
|
|
13
|
+
{
|
|
17
14
|
href: item.link,
|
|
18
15
|
target: "_blank",
|
|
19
|
-
"aria-label": `Social media icon${item.title ? ` for ${item.title}` :
|
|
16
|
+
"aria-label": `Social media icon${item.title ? ` for ${item.title}` : ""}`,
|
|
20
17
|
rel: "noreferrer",
|
|
21
|
-
children:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
color:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
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
|
+
}) });
|
|
33
31
|
}
|
|
34
32
|
SocialMedia.propTypes = {
|
|
35
|
-
items: PropTypes.arrayOf(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
+
)
|
|
40
40
|
};
|
|
41
41
|
SocialMedia.defaultProps = {
|
|
42
42
|
items: null
|
|
43
43
|
};
|
|
44
|
-
const Root = styled(
|
|
44
|
+
const Root = styled("div")`
|
|
45
45
|
display: inline-flex;
|
|
46
46
|
flex-wrap: wrap;
|
|
47
47
|
align-items: center;
|
|
48
48
|
justify-content: center;
|
|
49
49
|
gap: 20px;
|
|
50
50
|
a {
|
|
51
|
-
color: ${props => props.theme.palette.grey[400]};
|
|
51
|
+
color: ${(props) => props.theme.palette.grey[400]};
|
|
52
52
|
text-decoration: none;
|
|
53
53
|
&:hover {
|
|
54
|
-
color: ${props => props.theme.palette.primary.light};
|
|
54
|
+
color: ${(props) => props.theme.palette.primary.light};
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
${props => props.theme.breakpoints.down(
|
|
57
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
58
58
|
gap: 12px;
|
|
59
59
|
}
|
|
60
|
-
`;
|
|
60
|
+
`;
|
package/es/Header/index.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
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 Icon from "../Icon/index.js";
|
|
11
|
+
import OverridableThemeProvider from "../common/overridable-theme-provider.js";
|
|
12
|
+
import { blockletMetaProps, sessionManagerProps } from "../types.js";
|
|
13
|
+
import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
14
|
+
import { publicPath, formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
15
|
+
import HeaderAddons from "../common/header-addons.js";
|
|
16
|
+
import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
|
|
17
|
+
const parseNavigation = (navigation) => {
|
|
20
18
|
if (!navigation?.length) {
|
|
21
|
-
return {
|
|
22
|
-
navItems: [],
|
|
23
|
-
activeId: null
|
|
24
|
-
};
|
|
19
|
+
return { navItems: [], activeId: null };
|
|
25
20
|
}
|
|
26
21
|
let counter = 1;
|
|
27
|
-
const parseItem = item => {
|
|
28
|
-
const icon = item.icon ?
|
|
29
|
-
icon: item.icon
|
|
30
|
-
}) : null;
|
|
22
|
+
const parseItem = (item) => {
|
|
23
|
+
const icon = item.icon ? /* @__PURE__ */ jsx(Icon, { icon: item.icon }) : null;
|
|
31
24
|
if (item.items) {
|
|
32
25
|
return {
|
|
33
26
|
id: `${counter++}`,
|
|
@@ -37,102 +30,66 @@ const parseNavigation = navigation => {
|
|
|
37
30
|
};
|
|
38
31
|
}
|
|
39
32
|
let props = {};
|
|
40
|
-
if (item.link?.startsWith(
|
|
33
|
+
if (item.link?.startsWith("http://") || item.link?.startsWith("https://")) {
|
|
41
34
|
props = {
|
|
42
|
-
target:
|
|
43
|
-
rel:
|
|
35
|
+
target: "_blank",
|
|
36
|
+
rel: "noreferrer"
|
|
44
37
|
};
|
|
45
38
|
}
|
|
46
39
|
return {
|
|
47
40
|
id: `${counter++}`,
|
|
48
|
-
label:
|
|
49
|
-
href: item.link,
|
|
50
|
-
...props,
|
|
51
|
-
children: item.title
|
|
52
|
-
}),
|
|
41
|
+
label: /* @__PURE__ */ jsx("a", { href: item.link, ...props, children: item.title }),
|
|
53
42
|
icon,
|
|
54
43
|
link: item.link
|
|
55
44
|
};
|
|
56
45
|
};
|
|
57
|
-
const navItems = mapRecursive(navigation, parseItem,
|
|
46
|
+
const navItems = mapRecursive(navigation, parseItem, "items");
|
|
58
47
|
const flattened = flatRecursive(navItems);
|
|
59
|
-
const matchedIndex = matchPaths(flattened.map(item => item.link));
|
|
60
|
-
return {
|
|
61
|
-
navItems,
|
|
62
|
-
activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null
|
|
63
|
-
};
|
|
48
|
+
const matchedIndex = matchPaths(flattened.map((item) => item.link));
|
|
49
|
+
return { navItems, activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null };
|
|
64
50
|
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 专门用于 (composable) blocklet 的 Header 组件, 解析 blocklet meta 中的数据, 通过组合 UX 中的 Header & NavMenu 组件来渲染
|
|
68
|
-
*/
|
|
69
|
-
// eslint-disable-next-line no-shadow
|
|
70
|
-
function Header({
|
|
71
|
-
meta,
|
|
72
|
-
addons,
|
|
73
|
-
sessionManagerProps,
|
|
74
|
-
homeLink,
|
|
75
|
-
theme: themeOverrides,
|
|
76
|
-
...rest
|
|
77
|
-
}) {
|
|
51
|
+
function Header({ meta, addons, sessionManagerProps: sessionManagerProps2, homeLink, theme: themeOverrides, ...rest }) {
|
|
78
52
|
useWalletHiddenTopbar();
|
|
79
|
-
const {
|
|
80
|
-
locale
|
|
81
|
-
} = useLocaleContext() || {};
|
|
53
|
+
const { locale } = useLocaleContext() || {};
|
|
82
54
|
const formattedBlocklet = useMemo(() => {
|
|
83
55
|
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
84
56
|
try {
|
|
85
57
|
return formatBlockletInfo(blocklet);
|
|
86
58
|
} catch (e) {
|
|
87
|
-
console.error(
|
|
59
|
+
console.error("Failed to format blocklet info", e, blocklet);
|
|
88
60
|
return blocklet;
|
|
89
61
|
}
|
|
90
62
|
}, [meta]);
|
|
91
63
|
if (!formattedBlocklet.appName) {
|
|
92
64
|
return null;
|
|
93
65
|
}
|
|
94
|
-
const {
|
|
95
|
-
appLogo,
|
|
96
|
-
appLogoRect,
|
|
97
|
-
theme
|
|
98
|
-
} = formattedBlocklet;
|
|
66
|
+
const { appLogo, appLogoRect, theme } = formattedBlocklet;
|
|
99
67
|
const navigation = getLocalizedNavigation(formattedBlocklet?.navigation?.header, locale);
|
|
100
68
|
const parsedNavigation = parseNavigation(navigation);
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
formattedBlocklet: formattedBlocklet,
|
|
110
|
-
addons: _addons,
|
|
111
|
-
sessionManagerProps: sessionManagerProps
|
|
112
|
-
});
|
|
113
|
-
return /*#__PURE__*/_jsx(OverridableThemeProvider, {
|
|
114
|
-
theme: themeOverrides,
|
|
115
|
-
children: /*#__PURE__*/_jsx(StyledUxHeader, {
|
|
116
|
-
homeLink: homeLink,
|
|
117
|
-
logo: /*#__PURE__*/_jsx("img", {
|
|
118
|
-
src: appLogoRect || appLogo,
|
|
119
|
-
alt: "logo"
|
|
120
|
-
}),
|
|
69
|
+
const { navItems, activeId } = parsedNavigation;
|
|
70
|
+
const _addons = typeof addons === "function" ? (builtInAddons) => addons(builtInAddons, { navigation: parsedNavigation }) : addons;
|
|
71
|
+
const headerAddons = /* @__PURE__ */ jsx(HeaderAddons, { formattedBlocklet, addons: _addons, sessionManagerProps: sessionManagerProps2 });
|
|
72
|
+
return /* @__PURE__ */ jsx(OverridableThemeProvider, { theme: themeOverrides, children: /* @__PURE__ */ jsx(
|
|
73
|
+
StyledUxHeader,
|
|
74
|
+
{
|
|
75
|
+
homeLink,
|
|
76
|
+
logo: /* @__PURE__ */ jsx("img", { src: appLogoRect || appLogo, alt: "logo" }),
|
|
121
77
|
addons: headerAddons,
|
|
122
78
|
...rest,
|
|
123
79
|
$bgcolor: theme?.background?.header,
|
|
124
|
-
children: !navItems?.length ? null : ({
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
80
|
+
children: !navItems?.length ? null : ({ isMobile }) => /* @__PURE__ */ jsx(
|
|
81
|
+
NavMenu,
|
|
82
|
+
{
|
|
83
|
+
mode: isMobile ? "inline" : "horizontal",
|
|
84
|
+
activeId,
|
|
85
|
+
items: navItems,
|
|
86
|
+
className: "header-nav",
|
|
87
|
+
bgColor: "transparent",
|
|
88
|
+
textColor: "#777"
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
) });
|
|
136
93
|
}
|
|
137
94
|
Header.propTypes = {
|
|
138
95
|
meta: blockletMetaProps,
|
|
@@ -155,15 +112,13 @@ Header.defaultProps = {
|
|
|
155
112
|
theme: null
|
|
156
113
|
};
|
|
157
114
|
const StyledUxHeader = styled(ResponsiveHeader)`
|
|
158
|
-
${({
|
|
159
|
-
$bgcolor
|
|
160
|
-
}) => `background-color: ${$bgcolor || '#fff'};`}
|
|
115
|
+
${({ $bgcolor }) => `background-color: ${$bgcolor || "#fff"};`}
|
|
161
116
|
font-family: Lato, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
162
117
|
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
163
118
|
.header-logo {
|
|
164
119
|
min-width: 44px;
|
|
165
120
|
}
|
|
166
|
-
${props => props.theme.breakpoints.down(
|
|
121
|
+
${(props) => props.theme.breakpoints.down("md")} {
|
|
167
122
|
.header-logo {
|
|
168
123
|
min-width: 32px;
|
|
169
124
|
}
|
|
@@ -191,4 +146,4 @@ const StyledUxHeader = styled(ResponsiveHeader)`
|
|
|
191
146
|
`;
|
|
192
147
|
export default withErrorBoundary(Header, {
|
|
193
148
|
FallbackComponent: ErrorFallback
|
|
194
|
-
});
|
|
149
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon 组件, 基于 mui Avatar 组件扩展对 iconify 的支持
|
|
3
|
+
*/
|
|
4
|
+
declare function Icon({ icon, size, sx, ...rest }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
icon: any;
|
|
7
|
+
size: any;
|
|
8
|
+
sx: any;
|
|
9
|
+
}): import("react").JSX.Element | null;
|
|
10
|
+
declare namespace Icon {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
let icon: any;
|
|
13
|
+
let size: any;
|
|
14
|
+
let sx: any;
|
|
15
|
+
}
|
|
16
|
+
namespace defaultProps {
|
|
17
|
+
let size_1: null;
|
|
18
|
+
export { size_1 as size };
|
|
19
|
+
let sx_1: null;
|
|
20
|
+
export { sx_1 as sx };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default Icon;
|