@blocklet/ui-react 3.0.39 → 3.0.41
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/Footer/links.js +4 -3
- package/lib/Header/index.js +98 -86
- package/package.json +5 -5
- package/src/Footer/Footer.stories.jsx +2 -1
- package/src/Footer/links.jsx +1 -0
- package/src/Header/index.tsx +32 -6
package/lib/Footer/links.js
CHANGED
|
@@ -11,7 +11,7 @@ import C from "../Icon/index.js";
|
|
|
11
11
|
import A from "../hooks/use-mobile.js";
|
|
12
12
|
import { splitNavColumns as E } from "../utils.js";
|
|
13
13
|
function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
|
|
14
|
-
const [g, b] = N(-1),
|
|
14
|
+
const [g, b] = N(-1), w = A({ key: "md" }), h = e.some((t) => t.items?.length), k = !w && h && j(u) && u > 1, p = ({ label: t, link: o, icon: i, render: a, props: n }) => {
|
|
15
15
|
let s = t;
|
|
16
16
|
if (a)
|
|
17
17
|
s = a({ label: t, link: o, props: n });
|
|
@@ -33,7 +33,7 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
|
|
|
33
33
|
i && /* @__PURE__ */ r(C, { icon: i, size: 20, sx: { mr: 0.5 } }),
|
|
34
34
|
s
|
|
35
35
|
] });
|
|
36
|
-
},
|
|
36
|
+
}, y = $(() => e?.length ? d ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : k ? E(e, { columns: u }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((i) => i.group).map((i, a) => {
|
|
37
37
|
const { items: n } = i;
|
|
38
38
|
return /* @__PURE__ */ m("div", { className: "footer-links-group", children: [
|
|
39
39
|
/* @__PURE__ */ r("span", { className: "footer-links-item", children: p(i) }),
|
|
@@ -82,7 +82,7 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
|
|
|
82
82
|
"footer-links--flow": d,
|
|
83
83
|
"footer-links--columns": k
|
|
84
84
|
}),
|
|
85
|
-
children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children:
|
|
85
|
+
children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: y })
|
|
86
86
|
}
|
|
87
87
|
) : null;
|
|
88
88
|
}
|
|
@@ -131,6 +131,7 @@ const R = z("div")`
|
|
|
131
131
|
position: relative;
|
|
132
132
|
padding: 6px 8px;
|
|
133
133
|
font-size: 14px;
|
|
134
|
+
white-space: nowrap;
|
|
134
135
|
&--new::after {
|
|
135
136
|
content: 'New';
|
|
136
137
|
color: ${({ theme: e }) => e.palette.info.main};
|
package/lib/Header/index.js
CHANGED
|
@@ -1,141 +1,153 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useMemoizedFn as
|
|
4
|
-
import { withErrorBoundary as
|
|
5
|
-
import { ErrorFallback as
|
|
6
|
-
import { styled as
|
|
7
|
-
import { ResponsiveHeader as
|
|
8
|
-
import
|
|
9
|
-
import { useLocaleContext as
|
|
10
|
-
import { translate as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as f } from "react";
|
|
3
|
+
import { useMemoizedFn as N } from "ahooks";
|
|
4
|
+
import { withErrorBoundary as $ } from "react-error-boundary";
|
|
5
|
+
import { ErrorFallback as C } from "@arcblock/ux/lib/ErrorBoundary";
|
|
6
|
+
import { styled as H, useTheme as _, deepmerge as w, ThemeProvider as A } from "@arcblock/ux/lib/Theme";
|
|
7
|
+
import { ResponsiveHeader as B } from "@arcblock/ux/lib/Header";
|
|
8
|
+
import L, { Products as R } from "@arcblock/ux/lib/NavMenu";
|
|
9
|
+
import { useLocaleContext as F } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import { translate as M } from "@arcblock/ux/lib/Locale/util";
|
|
11
|
+
import O from "@arcblock/ux/lib/hooks/use-blocklet-logo";
|
|
12
|
+
import P from "lodash/omit";
|
|
13
|
+
import I from "lodash/isFinite";
|
|
14
|
+
import z from "clsx";
|
|
15
15
|
import W from "../Icon/index.js";
|
|
16
|
-
import { mapRecursive as
|
|
17
|
-
import { formatBlockletInfo as
|
|
16
|
+
import { mapRecursive as S, flatRecursive as U, matchPaths as j } from "../utils.js";
|
|
17
|
+
import { formatBlockletInfo as G, getLocalizedNavigation as K, publicPath as q } from "../blocklets.js";
|
|
18
18
|
import D from "../common/header-addons.js";
|
|
19
|
-
import { useWalletHiddenTopbar as
|
|
20
|
-
import
|
|
21
|
-
const
|
|
19
|
+
import { useWalletHiddenTopbar as J } from "../common/wallet-hidden-topbar.js";
|
|
20
|
+
import Q from "../libs/with-hide-when-embed.js";
|
|
21
|
+
const V = {
|
|
22
22
|
en: {
|
|
23
23
|
products: "Products"
|
|
24
24
|
},
|
|
25
25
|
zh: {
|
|
26
26
|
products: "产品"
|
|
27
27
|
}
|
|
28
|
-
},
|
|
29
|
-
if (!
|
|
28
|
+
}, X = (r) => {
|
|
29
|
+
if (!r?.length)
|
|
30
30
|
return { navItems: [], activeId: null };
|
|
31
|
-
let
|
|
32
|
-
const
|
|
33
|
-
const i =
|
|
34
|
-
if (
|
|
31
|
+
let t = 1;
|
|
32
|
+
const c = S(r, (e) => {
|
|
33
|
+
const i = e.icon ? /* @__PURE__ */ a(W, { icon: e.icon }) : null;
|
|
34
|
+
if (e.items)
|
|
35
35
|
return {
|
|
36
|
-
id: `${
|
|
37
|
-
label:
|
|
36
|
+
id: `${t++}`,
|
|
37
|
+
label: e.title,
|
|
38
38
|
icon: i,
|
|
39
|
-
children:
|
|
39
|
+
children: e.items
|
|
40
40
|
};
|
|
41
|
-
let
|
|
42
|
-
return (
|
|
41
|
+
let s = {};
|
|
42
|
+
return (e.link?.startsWith("http") || e.link?.startsWith("//")) && (s = {
|
|
43
43
|
target: "_blank",
|
|
44
44
|
rel: "noreferrer"
|
|
45
45
|
}), {
|
|
46
|
-
id: `${
|
|
47
|
-
label: /* @__PURE__ */
|
|
46
|
+
id: `${t++}`,
|
|
47
|
+
label: /* @__PURE__ */ a("a", { href: e.link, ...s, children: e.title }),
|
|
48
48
|
icon: i,
|
|
49
|
-
description:
|
|
50
|
-
link:
|
|
49
|
+
description: e.description,
|
|
50
|
+
link: e.link
|
|
51
51
|
};
|
|
52
|
-
}, "items"),
|
|
53
|
-
return { navItems:
|
|
52
|
+
}, "items"), l = U(c), p = j(l.map((e) => e.link));
|
|
53
|
+
return { navItems: c, activeId: p >= 0 ? l[p].id : null };
|
|
54
54
|
};
|
|
55
|
-
function
|
|
56
|
-
meta:
|
|
57
|
-
addons:
|
|
58
|
-
sessionManagerProps:
|
|
55
|
+
function Y({
|
|
56
|
+
meta: r = {},
|
|
57
|
+
addons: t = void 0,
|
|
58
|
+
sessionManagerProps: h = {
|
|
59
59
|
showRole: !0
|
|
60
60
|
},
|
|
61
|
-
homeLink:
|
|
62
|
-
theme:
|
|
63
|
-
hideNavMenu:
|
|
64
|
-
showDomainWarningDialog:
|
|
61
|
+
homeLink: c = q,
|
|
62
|
+
theme: l = void 0,
|
|
63
|
+
hideNavMenu: p = !1,
|
|
64
|
+
showDomainWarningDialog: e = !0,
|
|
65
65
|
...i
|
|
66
66
|
}) {
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const
|
|
67
|
+
J();
|
|
68
|
+
const s = _(), { locale: b } = F() || {}, x = N((o, n = {}) => M(V, o, b, "en", n)), d = f(() => {
|
|
69
|
+
const o = Object.assign({}, window.blocklet, r);
|
|
70
70
|
try {
|
|
71
|
-
return
|
|
72
|
-
} catch (
|
|
73
|
-
return console.error("Failed to format blocklet info",
|
|
71
|
+
return G(o);
|
|
72
|
+
} catch (n) {
|
|
73
|
+
return console.error("Failed to format blocklet info", n, o), o;
|
|
74
74
|
}
|
|
75
|
-
}, [
|
|
76
|
-
meta:
|
|
77
|
-
theme:
|
|
78
|
-
})
|
|
79
|
-
|
|
75
|
+
}, [r]), m = f(() => w(s, l), [s, l]), y = O({
|
|
76
|
+
meta: r,
|
|
77
|
+
theme: l
|
|
78
|
+
}), { productsOrder: g, productsType: k } = f(() => {
|
|
79
|
+
let { USE_ARCBLOCK_THEME: o, USE_AIGNE_THEME: n } = d;
|
|
80
|
+
return o = parseInt(o, 10), n = parseInt(n, 10), I(n) ? {
|
|
81
|
+
productsOrder: n,
|
|
82
|
+
productsType: "AIGNE"
|
|
83
|
+
} : I(o) ? {
|
|
84
|
+
productsOrder: o,
|
|
85
|
+
productsType: "ARCBLOCK"
|
|
86
|
+
} : {
|
|
87
|
+
productsOrder: null,
|
|
88
|
+
productsType: null
|
|
89
|
+
};
|
|
90
|
+
}, [d]);
|
|
91
|
+
if (!d.appName)
|
|
80
92
|
return null;
|
|
81
|
-
const
|
|
82
|
-
return
|
|
83
|
-
label:
|
|
93
|
+
const T = K(d?.navigation?.header, b), v = X(T), { navItems: u, activeId: E } = v;
|
|
94
|
+
return k && Number.isInteger(g) && u.splice(g, 0, {
|
|
95
|
+
label: x("products"),
|
|
84
96
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
85
|
-
children: (
|
|
86
|
-
}), /* @__PURE__ */
|
|
87
|
-
|
|
97
|
+
children: () => /* @__PURE__ */ a(R, { type: k })
|
|
98
|
+
}), /* @__PURE__ */ a(A, { theme: m, children: /* @__PURE__ */ a(
|
|
99
|
+
Z,
|
|
88
100
|
{
|
|
89
|
-
homeLink:
|
|
90
|
-
logo: /* @__PURE__ */
|
|
101
|
+
homeLink: c,
|
|
102
|
+
logo: /* @__PURE__ */ a("img", { src: y, alt: "logo" }),
|
|
91
103
|
addons: (
|
|
92
104
|
// @ts-ignore
|
|
93
|
-
/* @__PURE__ */
|
|
105
|
+
/* @__PURE__ */ a(
|
|
94
106
|
D,
|
|
95
107
|
{
|
|
96
|
-
formattedBlocklet:
|
|
97
|
-
addons: typeof
|
|
98
|
-
sessionManagerProps:
|
|
99
|
-
showDomainWarningDialog:
|
|
108
|
+
formattedBlocklet: d,
|
|
109
|
+
addons: typeof t == "function" ? (o) => t(o, { navigation: v }) : t,
|
|
110
|
+
sessionManagerProps: h,
|
|
111
|
+
showDomainWarningDialog: e
|
|
100
112
|
}
|
|
101
113
|
)
|
|
102
114
|
),
|
|
103
|
-
...
|
|
115
|
+
...P(i, ["bordered"]),
|
|
104
116
|
$bordered: i?.bordered,
|
|
105
|
-
$bgcolor:
|
|
106
|
-
className:
|
|
107
|
-
children:
|
|
117
|
+
$bgcolor: m.palette.background.default,
|
|
118
|
+
className: z("blocklet__header", i.className),
|
|
119
|
+
children: p || !u?.length ? null : ({ isMobile: o }) => (
|
|
108
120
|
// @ts-ignore
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
|
|
121
|
+
/* @__PURE__ */ a(
|
|
122
|
+
L,
|
|
111
123
|
{
|
|
112
|
-
mode:
|
|
113
|
-
activeId:
|
|
114
|
-
items:
|
|
124
|
+
mode: o ? "inline" : "horizontal",
|
|
125
|
+
activeId: E,
|
|
126
|
+
items: u,
|
|
115
127
|
className: "header-nav",
|
|
116
128
|
bgColor: "transparent",
|
|
117
|
-
textColor:
|
|
118
|
-
activeTextColor:
|
|
129
|
+
textColor: m.palette.grey[500],
|
|
130
|
+
activeTextColor: m.palette.text.primary
|
|
119
131
|
}
|
|
120
132
|
)
|
|
121
133
|
)
|
|
122
134
|
}
|
|
123
135
|
) });
|
|
124
136
|
}
|
|
125
|
-
const
|
|
126
|
-
${({ $bgcolor:
|
|
137
|
+
const Z = H(B)`
|
|
138
|
+
${({ $bgcolor: r }) => `background-color: ${r || "#fff"};`}
|
|
127
139
|
.header-logo {
|
|
128
140
|
min-width: 44px;
|
|
129
141
|
}
|
|
130
|
-
${({ $bordered:
|
|
131
|
-
${(
|
|
142
|
+
${({ $bordered: r, theme: t }) => r ? `border-bottom: 1px solid ${t.palette.divider};` : ""}
|
|
143
|
+
${(r) => r.theme.breakpoints.down("md")} {
|
|
132
144
|
.header-logo {
|
|
133
145
|
min-width: 32px;
|
|
134
146
|
}
|
|
135
147
|
}
|
|
136
|
-
`,
|
|
137
|
-
FallbackComponent:
|
|
148
|
+
`, ye = $(Q(Y), {
|
|
149
|
+
FallbackComponent: C
|
|
138
150
|
});
|
|
139
151
|
export {
|
|
140
|
-
|
|
152
|
+
ye as default
|
|
141
153
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.41",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@abtnode/constant": "^1.16.46",
|
|
37
37
|
"@abtnode/util": "^1.16.46",
|
|
38
|
-
"@arcblock/bridge": "3.0.
|
|
39
|
-
"@arcblock/icons": "3.0.
|
|
40
|
-
"@arcblock/react-hooks": "3.0.
|
|
38
|
+
"@arcblock/bridge": "3.0.41",
|
|
39
|
+
"@arcblock/icons": "3.0.41",
|
|
40
|
+
"@arcblock/react-hooks": "3.0.41",
|
|
41
41
|
"@arcblock/ws": "^1.21.0",
|
|
42
42
|
"@blocklet/constant": "^1.16.46",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.11",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"jest": "^29.7.0",
|
|
92
92
|
"unbuild": "^2.0.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "e4bf7c421b39bfc7b969653e580047629e5338b5"
|
|
95
95
|
}
|
|
@@ -4,6 +4,7 @@ import SocialMediaIcons from './demo/social-media-icons';
|
|
|
4
4
|
import Copyright from './demo/copyright';
|
|
5
5
|
import Footer from './demo/footer';
|
|
6
6
|
import ArcblockSite from './demo/arcblock-site';
|
|
7
|
+
import AigneSite from './demo/aigne-site';
|
|
7
8
|
|
|
8
9
|
export default {
|
|
9
10
|
title: 'Blocklet-UI-React/Footer',
|
|
@@ -29,4 +30,4 @@ ArcblockSite.argTypes = {
|
|
|
29
30
|
locale: { control: 'select', options: ['en', 'zh'] },
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite };
|
|
33
|
+
export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite, AigneSite };
|
package/src/Footer/links.jsx
CHANGED
package/src/Header/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { withErrorBoundary } from 'react-error-boundary';
|
|
|
4
4
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
5
5
|
import { styled, useTheme, deepmerge, ThemeProvider } from '@arcblock/ux/lib/Theme';
|
|
6
6
|
import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
|
|
7
|
-
import NavMenu, { Products } from '@arcblock/ux/lib/NavMenu';
|
|
7
|
+
import NavMenu, { Products, ProductsType } from '@arcblock/ux/lib/NavMenu';
|
|
8
8
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
9
9
|
import { translate } from '@arcblock/ux/lib/Locale/util';
|
|
10
10
|
import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
|
|
@@ -133,6 +133,34 @@ function Header({
|
|
|
133
133
|
theme: themeOverrides,
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
+
// 显示 Products 导航
|
|
137
|
+
const { productsOrder, productsType } = useMemo<{
|
|
138
|
+
productsOrder: number | null;
|
|
139
|
+
productsType: ProductsType | null;
|
|
140
|
+
}>(() => {
|
|
141
|
+
let { USE_ARCBLOCK_THEME, USE_AIGNE_THEME } = formattedBlocklet;
|
|
142
|
+
USE_ARCBLOCK_THEME = parseInt(USE_ARCBLOCK_THEME, 10);
|
|
143
|
+
USE_AIGNE_THEME = parseInt(USE_AIGNE_THEME, 10);
|
|
144
|
+
|
|
145
|
+
if (isFinite(USE_AIGNE_THEME)) {
|
|
146
|
+
return {
|
|
147
|
+
productsOrder: USE_AIGNE_THEME,
|
|
148
|
+
productsType: 'AIGNE',
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
if (isFinite(USE_ARCBLOCK_THEME)) {
|
|
152
|
+
return {
|
|
153
|
+
productsOrder: USE_ARCBLOCK_THEME,
|
|
154
|
+
productsType: 'ARCBLOCK',
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
productsOrder: null,
|
|
160
|
+
productsType: null,
|
|
161
|
+
};
|
|
162
|
+
}, [formattedBlocklet]);
|
|
163
|
+
|
|
136
164
|
if (!formattedBlocklet.appName) {
|
|
137
165
|
return null;
|
|
138
166
|
}
|
|
@@ -140,13 +168,11 @@ function Header({
|
|
|
140
168
|
const parsedNavigation = parseNavigation(navigation);
|
|
141
169
|
const { navItems, activeId } = parsedNavigation;
|
|
142
170
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (isFinite(productsNavOrder)) {
|
|
146
|
-
navItems.splice(productsNavOrder, 0, {
|
|
171
|
+
if (productsType && Number.isInteger(productsOrder)) {
|
|
172
|
+
navItems.splice(productsOrder, 0, {
|
|
147
173
|
label: t('products'),
|
|
148
174
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
149
|
-
children: (
|
|
175
|
+
children: () => <Products type={productsType} />,
|
|
150
176
|
});
|
|
151
177
|
}
|
|
152
178
|
|