@blocklet/ui-react 3.1.32 → 3.1.34
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/index.js +3 -3
- package/lib/Header/index.js +29 -28
- package/lib/blocklets.d.ts +1 -1
- package/lib/blocklets.js +35 -34
- package/package.json +6 -6
- package/src/Footer/index.jsx +3 -3
- package/src/Header/index.tsx +2 -1
- package/src/blocklets.js +7 -2
package/lib/Footer/index.js
CHANGED
|
@@ -29,9 +29,9 @@ function d({ meta: o = {}, theme: t = {}, ...n }) {
|
|
|
29
29
|
if (!r.appName)
|
|
30
30
|
return null;
|
|
31
31
|
const { appName: b, appDescription: k, description: g, copyright: u } = r, h = m.palette.background.default, a = {
|
|
32
|
-
footerNav: l(r?.navigation?.footer, i) || [],
|
|
33
|
-
socialMedia: l(r?.navigation?.social, i) || [],
|
|
34
|
-
links: l(r?.navigation?.bottom, i) || []
|
|
32
|
+
footerNav: l(r?.navigation?.footer, i, "footer") || [],
|
|
33
|
+
socialMedia: l(r?.navigation?.social, i, "footer") || [],
|
|
34
|
+
links: l(r?.navigation?.bottom, i, "footer") || []
|
|
35
35
|
}, y = {
|
|
36
36
|
brand: {
|
|
37
37
|
name: b,
|
package/lib/Header/index.js
CHANGED
|
@@ -5,20 +5,21 @@ import { withErrorBoundary as $ } from "react-error-boundary";
|
|
|
5
5
|
import { ErrorFallback as C } from "@arcblock/ux/lib/ErrorBoundary";
|
|
6
6
|
import { styled as H, useTheme as _, deepmerge as w, ThemeProvider as A } from "@arcblock/ux/lib/Theme";
|
|
7
7
|
import { ResponsiveHeader as B } from "@arcblock/ux/lib/Header";
|
|
8
|
-
import L, { Products as
|
|
9
|
-
import { useLocaleContext as
|
|
10
|
-
import { translate as
|
|
11
|
-
import
|
|
8
|
+
import L, { Products as M } from "@arcblock/ux/lib/NavMenu";
|
|
9
|
+
import { useLocaleContext as R } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import { translate as z } from "@arcblock/ux/lib/Locale/util";
|
|
11
|
+
import F from "@arcblock/ux/lib/hooks/use-blocklet-logo";
|
|
12
12
|
import O from "lodash/omit";
|
|
13
13
|
import I from "lodash/isFinite";
|
|
14
14
|
import P from "clsx";
|
|
15
|
+
import { getUTMUrl as U } from "@arcblock/ux/lib/withTracker/libs/utm";
|
|
15
16
|
import W from "../Icon/index.js";
|
|
16
|
-
import { mapRecursive as j, flatRecursive as S, matchPaths as
|
|
17
|
-
import { formatBlockletInfo as
|
|
18
|
-
import
|
|
19
|
-
import { useWalletHiddenTopbar as
|
|
20
|
-
import
|
|
21
|
-
const
|
|
17
|
+
import { mapRecursive as j, flatRecursive as S, matchPaths as G } from "../utils.js";
|
|
18
|
+
import { formatBlockletInfo as K, getLocalizedNavigation as q, publicPath as D } from "../blocklets.js";
|
|
19
|
+
import J from "../common/header-addons.js";
|
|
20
|
+
import { useWalletHiddenTopbar as Q } from "../common/wallet-hidden-topbar.js";
|
|
21
|
+
import V from "../libs/with-hide-when-embed.js";
|
|
22
|
+
const X = {
|
|
22
23
|
en: {
|
|
23
24
|
products: "Products"
|
|
24
25
|
},
|
|
@@ -31,7 +32,7 @@ const V = {
|
|
|
31
32
|
ja: {
|
|
32
33
|
products: "製品"
|
|
33
34
|
}
|
|
34
|
-
},
|
|
35
|
+
}, Y = (r) => {
|
|
35
36
|
if (!r?.length)
|
|
36
37
|
return { navItems: [], activeId: null };
|
|
37
38
|
let t = 1;
|
|
@@ -50,38 +51,38 @@ const V = {
|
|
|
50
51
|
rel: "noreferrer"
|
|
51
52
|
}), {
|
|
52
53
|
id: `${t++}`,
|
|
53
|
-
label: /* @__PURE__ */ a("a", { href: e.link, ...s, children: e.title }),
|
|
54
|
+
label: /* @__PURE__ */ a("a", { href: U(e.link, "header"), ...s, children: e.title }),
|
|
54
55
|
icon: i,
|
|
55
56
|
description: e.description,
|
|
56
57
|
link: e.link
|
|
57
58
|
};
|
|
58
|
-
}, "items"), l = S(c), p =
|
|
59
|
+
}, "items"), l = S(c), p = G(l.map((e) => e.link));
|
|
59
60
|
return { navItems: c, activeId: p >= 0 ? l[p].id : null };
|
|
60
61
|
};
|
|
61
|
-
function
|
|
62
|
+
function Z({
|
|
62
63
|
meta: r = {},
|
|
63
64
|
addons: t = void 0,
|
|
64
65
|
sessionManagerProps: h = {
|
|
65
66
|
showRole: !0
|
|
66
67
|
},
|
|
67
|
-
homeLink: c =
|
|
68
|
+
homeLink: c = D,
|
|
68
69
|
theme: l = {},
|
|
69
70
|
hideNavMenu: p = !1,
|
|
70
71
|
showDomainWarningDialog: e = !0,
|
|
71
72
|
...i
|
|
72
73
|
}) {
|
|
73
|
-
|
|
74
|
-
const s = _(), { locale:
|
|
74
|
+
Q();
|
|
75
|
+
const s = _(), { locale: g } = R() || {}, T = N((o, n = {}) => z(X, o, g, "en", n)), d = f(() => {
|
|
75
76
|
const o = Object.assign({}, window.blocklet, r);
|
|
76
77
|
try {
|
|
77
|
-
return
|
|
78
|
+
return K(o);
|
|
78
79
|
} catch (n) {
|
|
79
80
|
return console.error("Failed to format blocklet info", n, o), o;
|
|
80
81
|
}
|
|
81
|
-
}, [r]), m = f(() => w(s, l), [s, l]), x =
|
|
82
|
+
}, [r]), m = f(() => w(s, l), [s, l]), x = F({
|
|
82
83
|
meta: r,
|
|
83
84
|
theme: l
|
|
84
|
-
}), { productsOrder:
|
|
85
|
+
}), { productsOrder: b, productsType: k } = f(() => {
|
|
85
86
|
let { USE_ARCBLOCK_THEME: o, USE_AIGNE_THEME: n } = d;
|
|
86
87
|
return o = parseInt(o, 10), n = parseInt(n, 10), I(n) ? {
|
|
87
88
|
productsOrder: n,
|
|
@@ -96,20 +97,20 @@ function Y({
|
|
|
96
97
|
}, [d]);
|
|
97
98
|
if (!d.appName)
|
|
98
99
|
return null;
|
|
99
|
-
const y =
|
|
100
|
-
return k && Number.isInteger(
|
|
100
|
+
const y = q(d?.navigation?.header, g), v = Y(y), { navItems: u, activeId: E } = v;
|
|
101
|
+
return k && Number.isInteger(b) && u.splice(b, 0, {
|
|
101
102
|
label: T("products"),
|
|
102
103
|
// eslint-disable-next-line react/no-unstable-nested-components
|
|
103
|
-
children: () => /* @__PURE__ */ a(
|
|
104
|
+
children: () => /* @__PURE__ */ a(M, { type: k })
|
|
104
105
|
}), /* @__PURE__ */ a(A, { theme: m, children: /* @__PURE__ */ a(
|
|
105
|
-
|
|
106
|
+
ee,
|
|
106
107
|
{
|
|
107
108
|
homeLink: c,
|
|
108
109
|
logo: /* @__PURE__ */ a("img", { src: x, alt: "logo" }),
|
|
109
110
|
addons: (
|
|
110
111
|
// @ts-ignore
|
|
111
112
|
/* @__PURE__ */ a(
|
|
112
|
-
|
|
113
|
+
J,
|
|
113
114
|
{
|
|
114
115
|
formattedBlocklet: d,
|
|
115
116
|
addons: typeof t == "function" ? (o) => t(o, { navigation: v }) : t,
|
|
@@ -140,7 +141,7 @@ function Y({
|
|
|
140
141
|
}
|
|
141
142
|
) });
|
|
142
143
|
}
|
|
143
|
-
const
|
|
144
|
+
const ee = H(B)`
|
|
144
145
|
${({ $bgcolor: r }) => `background-color: ${r || "#fff"};`}
|
|
145
146
|
.header-logo {
|
|
146
147
|
min-width: 44px;
|
|
@@ -151,9 +152,9 @@ const Z = H(B)`
|
|
|
151
152
|
min-width: 32px;
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
`,
|
|
155
|
+
`, Ee = $(V(Z), {
|
|
155
156
|
FallbackComponent: C
|
|
156
157
|
});
|
|
157
158
|
export {
|
|
158
|
-
|
|
159
|
+
Ee as default
|
|
159
160
|
};
|
package/lib/blocklets.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const publicPath: any;
|
|
2
2
|
export function formatTheme(theme: any): any;
|
|
3
3
|
export function getLink(link: any, locale?: string): any;
|
|
4
|
-
export function getLocalizedNavigation(navigation: any, locale?: string): any;
|
|
4
|
+
export function getLocalizedNavigation(navigation: any[], locale?: string, section?: "header" | "footer"): any;
|
|
5
5
|
export function formatNavigation(navigation: any): any;
|
|
6
6
|
export function parseNavigation(navigation: any): {
|
|
7
7
|
header: never[];
|
package/lib/blocklets.js
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getUTMUrl as i } from "@arcblock/ux/lib/withTracker/libs/utm";
|
|
2
|
+
import { mapRecursive as s, filterRecursive as a, isUrl as c, isMailProtocol as u } from "./utils.js";
|
|
3
|
+
const w = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || "/", l = (e) => {
|
|
3
4
|
const r = { ...e }, t = e?.background;
|
|
4
5
|
return typeof t == "string" ? r.background = { header: t, footer: t, default: t } : t && typeof t == "object" && (r.background = {
|
|
5
6
|
header: t.header || t.default,
|
|
6
7
|
footer: t.footer || t.default,
|
|
7
8
|
default: t.default
|
|
8
9
|
}), r;
|
|
9
|
-
},
|
|
10
|
+
}, d = (e, r = "en") => {
|
|
10
11
|
if (typeof e == "string") {
|
|
11
|
-
if (
|
|
12
|
-
const
|
|
13
|
-
return
|
|
12
|
+
if (c(e)) {
|
|
13
|
+
const n = new URL(e);
|
|
14
|
+
return n.searchParams.set("locale", r), n.href;
|
|
14
15
|
}
|
|
15
|
-
if (
|
|
16
|
+
if (u(e))
|
|
16
17
|
return e;
|
|
17
18
|
const t = new URL(e, window.location.origin);
|
|
18
19
|
return t.searchParams.set("locale", r), t.pathname + t.search;
|
|
19
20
|
}
|
|
20
21
|
return typeof e == "object" ? e[r] || e?.en || e?.zh : e;
|
|
21
|
-
},
|
|
22
|
+
}, v = (e, r = "en", t = "header") => {
|
|
22
23
|
if (!e?.length)
|
|
23
24
|
return e;
|
|
24
|
-
const
|
|
25
|
+
const n = (o, f) => o && typeof o == "object" ? o[f] || o?.en || o?.zh : o;
|
|
25
26
|
return s(
|
|
26
27
|
e,
|
|
27
28
|
(o) => ({
|
|
28
29
|
...o,
|
|
29
|
-
title:
|
|
30
|
-
description:
|
|
30
|
+
title: n(o.title, r),
|
|
31
|
+
description: n(o.description, r),
|
|
31
32
|
// 仅对叶结点进行处理
|
|
32
|
-
link: o.items?.length ? o.link :
|
|
33
|
+
link: i(o.items?.length ? o.link : d(o.link, r), t),
|
|
33
34
|
_rawLink: o.link
|
|
34
35
|
}),
|
|
35
36
|
"items"
|
|
36
37
|
);
|
|
37
|
-
},
|
|
38
|
+
}, h = (e) => s(
|
|
38
39
|
e,
|
|
39
40
|
(r) => r.role ? {
|
|
40
41
|
...r,
|
|
41
42
|
role: Array.isArray(r.role) ? r.role : [r.role]
|
|
42
43
|
} : r,
|
|
43
44
|
"items"
|
|
44
|
-
),
|
|
45
|
+
), g = (e) => {
|
|
45
46
|
if (!e?.length)
|
|
46
47
|
return null;
|
|
47
|
-
const r =
|
|
48
|
+
const r = h(e), t = {
|
|
48
49
|
header: [],
|
|
49
50
|
footer: [],
|
|
50
51
|
// 对应 footer social media
|
|
@@ -57,32 +58,32 @@ const p = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || "/", c =
|
|
|
57
58
|
sessionManager: [],
|
|
58
59
|
userCenter: []
|
|
59
60
|
};
|
|
60
|
-
return r.forEach((
|
|
61
|
-
|
|
62
|
-
t[
|
|
63
|
-
}) : typeof
|
|
61
|
+
return r.forEach((n) => {
|
|
62
|
+
n.section ? Array.isArray(n.section) ? n.section.forEach((o) => {
|
|
63
|
+
t[o]?.push(n);
|
|
64
|
+
}) : typeof n.section == "string" && t[n.section]?.push(n) : t.header.push(n);
|
|
64
65
|
}), t;
|
|
65
|
-
},
|
|
66
|
+
}, L = (e) => {
|
|
66
67
|
if (!e)
|
|
67
68
|
return null;
|
|
68
69
|
const r = { ...e };
|
|
69
|
-
return r.theme =
|
|
70
|
-
},
|
|
70
|
+
return r.theme = l(r.theme), r.navigation = g(p(r.navigation)), r;
|
|
71
|
+
}, p = (e = []) => a(e, (r, t) => !!r.link || t.filteredChildren?.length, "items"), N = (e, r) => a(
|
|
71
72
|
e,
|
|
72
|
-
(t,
|
|
73
|
-
const
|
|
74
|
-
return
|
|
73
|
+
(t, n) => {
|
|
74
|
+
const o = !t.role || r && (t.role.includes(r) || t.role.includes("guest"));
|
|
75
|
+
return n.isLeaf ? o : o && n.filteredChildren?.length;
|
|
75
76
|
},
|
|
76
77
|
"items"
|
|
77
78
|
);
|
|
78
79
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
80
|
+
N as filterNavByRole,
|
|
81
|
+
p as filterValidNavItems,
|
|
82
|
+
L as formatBlockletInfo,
|
|
83
|
+
h as formatNavigation,
|
|
84
|
+
l as formatTheme,
|
|
85
|
+
d as getLink,
|
|
86
|
+
v as getLocalizedNavigation,
|
|
87
|
+
g as parseNavigation,
|
|
88
|
+
w as publicPath
|
|
88
89
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.34",
|
|
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.49-beta-20250823-082650-626c1473",
|
|
37
37
|
"@abtnode/util": "^1.16.49-beta-20250823-082650-626c1473",
|
|
38
|
-
"@arcblock/bridge": "3.1.
|
|
39
|
-
"@arcblock/icons": "3.1.
|
|
40
|
-
"@arcblock/react-hooks": "3.1.
|
|
38
|
+
"@arcblock/bridge": "3.1.34",
|
|
39
|
+
"@arcblock/icons": "3.1.34",
|
|
40
|
+
"@arcblock/react-hooks": "3.1.34",
|
|
41
41
|
"@arcblock/ws": "^1.21.3",
|
|
42
42
|
"@blocklet/constant": "^1.16.49-beta-20250823-082650-626c1473",
|
|
43
43
|
"@blocklet/did-space-react": "^1.1.16",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"access": "public"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@arcblock/did-connect-react": "3.1.
|
|
86
|
+
"@arcblock/did-connect-react": "3.1.34",
|
|
87
87
|
"@types/dompurify": "^3.2.0",
|
|
88
88
|
"@types/ua-parser-js": "^0.7.39",
|
|
89
89
|
"@types/validator": "^13.15.2",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"jest": "^29.7.0",
|
|
92
92
|
"unbuild": "^2.0.0"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "c4810edc1f51b25c0e9bd55b2021f284d378ecb1"
|
|
95
95
|
}
|
package/src/Footer/index.jsx
CHANGED
|
@@ -44,9 +44,9 @@ function Footer({ meta = {}, theme: themeOverrides = {}, ...rest }) {
|
|
|
44
44
|
const $bgColor = mergeTheme.palette.background.default;
|
|
45
45
|
|
|
46
46
|
const localized = {
|
|
47
|
-
footerNav: getLocalizedNavigation(formattedBlocklet?.navigation?.footer, locale) || [],
|
|
48
|
-
socialMedia: getLocalizedNavigation(formattedBlocklet?.navigation?.social, locale) || [],
|
|
49
|
-
links: getLocalizedNavigation(formattedBlocklet?.navigation?.bottom, locale) || [],
|
|
47
|
+
footerNav: getLocalizedNavigation(formattedBlocklet?.navigation?.footer, locale, 'footer') || [],
|
|
48
|
+
socialMedia: getLocalizedNavigation(formattedBlocklet?.navigation?.social, locale, 'footer') || [],
|
|
49
|
+
links: getLocalizedNavigation(formattedBlocklet?.navigation?.bottom, locale, 'footer') || [],
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
const props = {
|
package/src/Header/index.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import omit from 'lodash/omit';
|
|
|
12
12
|
import isFinite from 'lodash/isFinite';
|
|
13
13
|
import type { BoxProps, Breakpoint, Theme } from '@mui/material';
|
|
14
14
|
import clsx from 'clsx';
|
|
15
|
+
import { getUTMUrl } from '@arcblock/ux/lib/withTracker/libs/utm';
|
|
15
16
|
|
|
16
17
|
import Icon from '../Icon';
|
|
17
18
|
import { mapRecursive, flatRecursive, matchPaths } from '../utils';
|
|
@@ -67,7 +68,7 @@ const parseNavigation = (navigation: any) => {
|
|
|
67
68
|
return {
|
|
68
69
|
id: `${counter++}`,
|
|
69
70
|
label: (
|
|
70
|
-
<a href={item.link} {...props}>
|
|
71
|
+
<a href={getUTMUrl(item.link, 'header')} {...props}>
|
|
71
72
|
{item.title}
|
|
72
73
|
</a>
|
|
73
74
|
),
|
package/src/blocklets.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getUTMUrl } from '@arcblock/ux/lib/withTracker/libs/utm';
|
|
1
2
|
import { mapRecursive, filterRecursive, isUrl, isMailProtocol } from './utils';
|
|
2
3
|
|
|
3
4
|
export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
@@ -43,9 +44,13 @@ export const getLink = (link, locale = 'en') => {
|
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
/**
|
|
47
|
+
*
|
|
48
|
+
* @param {any[]} navigation 导航菜单数据
|
|
49
|
+
* @param {string} locale 语言
|
|
50
|
+
* @param {'header' | 'footer'} section 导航区域
|
|
46
51
|
* 获取指定 locale 对应的 navigation 数据, 仅考虑 zh/en
|
|
47
52
|
*/
|
|
48
|
-
export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
53
|
+
export const getLocalizedNavigation = (navigation, locale = 'en', section = 'header') => {
|
|
49
54
|
if (!navigation?.length) {
|
|
50
55
|
return navigation;
|
|
51
56
|
}
|
|
@@ -65,7 +70,7 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
65
70
|
title: trans(item.title, locale),
|
|
66
71
|
description: trans(item.description, locale),
|
|
67
72
|
// 仅对叶结点进行处理
|
|
68
|
-
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
73
|
+
link: getUTMUrl(!item.items?.length ? getLink(item.link, locale) : item.link, section),
|
|
69
74
|
_rawLink: item.link,
|
|
70
75
|
};
|
|
71
76
|
},
|