@blocklet/ui-react 3.2.17 → 3.2.19
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/Dashboard/app-shell/app-badge.d.ts +24 -0
- package/lib/Dashboard/app-shell/app-badge.js +48 -0
- package/lib/Dashboard/app-shell/app-header.d.ts +5 -0
- package/lib/Dashboard/app-shell/app-header.js +72 -0
- package/lib/Dashboard/app-shell/app-info-context.d.ts +42 -0
- package/lib/Dashboard/app-shell/app-info-context.js +83 -0
- package/lib/Dashboard/app-shell/badges/app-badge-default.d.ts +20 -0
- package/lib/Dashboard/app-shell/badges/app-badge-default.js +84 -0
- package/lib/Dashboard/app-shell/badges/app-badge-did.d.ts +5 -0
- package/lib/Dashboard/app-shell/badges/app-badge-did.js +16 -0
- package/lib/Dashboard/app-shell/badges/app-badge-state.d.ts +6 -0
- package/lib/Dashboard/app-shell/badges/app-badge-state.js +34 -0
- package/lib/Dashboard/app-shell/badges/app-badge-switch.d.ts +8 -0
- package/lib/Dashboard/app-shell/badges/app-badge-switch.js +66 -0
- package/lib/Dashboard/app-shell/badges/app-badge-version.d.ts +14 -0
- package/lib/Dashboard/app-shell/badges/app-badge-version.js +50 -0
- package/lib/Dashboard/app-shell/index.d.ts +4 -0
- package/lib/Dashboard/app-shell/index.js +9 -0
- package/lib/Dashboard/index.d.ts +12 -2
- package/lib/Dashboard/index.js +83 -63
- package/lib/Footer/internal-footer.js +11 -11
- package/lib/Footer/links.d.ts +5 -3
- package/lib/Footer/links.js +63 -61
- package/lib/utils.js +28 -28
- package/package.json +12 -6
- package/src/Dashboard/app-shell/app-badge.stories.tsx +64 -0
- package/src/Dashboard/app-shell/app-badge.tsx +94 -0
- package/src/Dashboard/app-shell/app-header.tsx +104 -0
- package/src/Dashboard/app-shell/app-info-context.tsx +182 -0
- package/src/Dashboard/app-shell/badges/app-badge-default.tsx +131 -0
- package/src/Dashboard/app-shell/badges/app-badge-did.tsx +28 -0
- package/src/Dashboard/app-shell/badges/app-badge-state.tsx +40 -0
- package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +72 -0
- package/src/Dashboard/app-shell/badges/app-badge-version.tsx +60 -0
- package/src/Dashboard/app-shell/index.ts +5 -0
- package/src/Dashboard/index.jsx +17 -3
- package/src/Footer/internal-footer.jsx +1 -1
- package/src/Footer/links.jsx +11 -7
- package/src/utils.js +6 -3
package/lib/Dashboard/index.js
CHANGED
|
@@ -1,52 +1,60 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as z } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import { use as
|
|
4
|
-
import
|
|
5
|
-
import { SessionContext as
|
|
6
|
-
import { useLocaleContext as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { SessionManagerProps as
|
|
11
|
-
import { mapRecursive as
|
|
12
|
-
import { formatBlockletInfo as
|
|
13
|
-
import
|
|
14
|
-
import { useWalletHiddenTopbar as
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
import { use as D, useMemo as w, useLayoutEffect as A } from "react";
|
|
4
|
+
import e from "prop-types";
|
|
5
|
+
import { SessionContext as M } from "@arcblock/did-connect-react/lib/Session";
|
|
6
|
+
import { useLocaleContext as j } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import H from "@arcblock/ux/lib/Img";
|
|
8
|
+
import O from "@arcblock/ux/lib/Layout/dashboard";
|
|
9
|
+
import S from "@arcblock/ux/lib/hooks/use-blocklet-logo";
|
|
10
|
+
import { SessionManagerProps as _, BlockletMetaProps as E } from "../types.js";
|
|
11
|
+
import { mapRecursive as U, flatRecursive as q, matchPaths as F } from "../utils.js";
|
|
12
|
+
import { formatBlockletInfo as G, getLocalizedNavigation as J, filterNavByRole as K, publicPath as m } from "../blocklets.js";
|
|
13
|
+
import Q from "../common/header-addons.js";
|
|
14
|
+
import { useWalletHiddenTopbar as V } from "../common/wallet-hidden-topbar.js";
|
|
15
|
+
import X from "./app-shell/app-header.js";
|
|
16
|
+
import { default as yo } from "./app-shell/app-badge.js";
|
|
17
|
+
import { AppInfoProvider as Y } from "./app-shell/app-info-context.js";
|
|
18
|
+
import { useAppInfo as Ao } from "./app-shell/app-info-context.js";
|
|
19
|
+
function Z({
|
|
20
|
+
meta: a = void 0,
|
|
17
21
|
fallbackUrl: s = m,
|
|
18
22
|
invalidPathFallback: l = null,
|
|
19
|
-
headerAddons:
|
|
20
|
-
sessionManagerProps:
|
|
23
|
+
headerAddons: L = void 0,
|
|
24
|
+
sessionManagerProps: P = {
|
|
21
25
|
showRole: !0,
|
|
22
26
|
// dashboard 默认退出登录行为: 跳转到 (root) blocklet 首页
|
|
23
27
|
onLogout: () => {
|
|
24
28
|
window.location.href = m;
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
|
-
links:
|
|
28
|
-
showDomainWarningDialog:
|
|
31
|
+
links: d = [],
|
|
32
|
+
showDomainWarningDialog: T = !0,
|
|
33
|
+
appPath: k = void 0,
|
|
34
|
+
appTab: I = void 0,
|
|
35
|
+
onAppTabChange: N = void 0,
|
|
36
|
+
children: B = void 0,
|
|
29
37
|
...h
|
|
30
38
|
}) {
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
const
|
|
39
|
+
V();
|
|
40
|
+
const c = D(M)?.session?.user, g = c?.role, { locale: v, defaultLocale: x } = j() || {}, n = w(() => {
|
|
41
|
+
const t = Object.assign({}, window.blocklet, a);
|
|
34
42
|
try {
|
|
35
|
-
return
|
|
36
|
-
} catch (
|
|
37
|
-
return console.error("Failed to format blocklet info",
|
|
43
|
+
return G(t);
|
|
44
|
+
} catch (i) {
|
|
45
|
+
return console.error("Failed to format blocklet info", i, t), t;
|
|
38
46
|
}
|
|
39
|
-
}, [a]), { localizedNav:
|
|
40
|
-
let
|
|
41
|
-
navigation:
|
|
42
|
-
locale:
|
|
43
|
-
defaultLocale:
|
|
47
|
+
}, [a]), { localizedNav: b, flattened: p, matchedIndex: y } = w(() => {
|
|
48
|
+
let t = J({
|
|
49
|
+
navigation: n?.navigation?.dashboard,
|
|
50
|
+
locale: v,
|
|
51
|
+
defaultLocale: x
|
|
44
52
|
}) || [];
|
|
45
|
-
|
|
46
|
-
|
|
53
|
+
t = K(t, g), t = U(
|
|
54
|
+
t,
|
|
47
55
|
(o) => {
|
|
48
56
|
let u = null;
|
|
49
|
-
return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? u = /* @__PURE__ */
|
|
57
|
+
return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? u = /* @__PURE__ */ r(H, { src: o.icon }) : u = /* @__PURE__ */ r("iconify-icon", { height: "100%", width: "100%", icon: o.icon })), {
|
|
50
58
|
id: o.id,
|
|
51
59
|
title: o.title,
|
|
52
60
|
url: o.link,
|
|
@@ -58,55 +66,67 @@ function G({
|
|
|
58
66
|
},
|
|
59
67
|
"items"
|
|
60
68
|
);
|
|
61
|
-
const
|
|
62
|
-
return
|
|
63
|
-
}, [
|
|
69
|
+
const i = q(t).filter((o) => !!o.url), f = F(i.map((o) => o.url));
|
|
70
|
+
return f !== -1 && (i[f].active = !0), { localizedNav: t, flattened: i, matchedIndex: f };
|
|
71
|
+
}, [n, v, x, g]), C = typeof d == "function" ? d(b) : [...b, ...d], W = S({
|
|
64
72
|
meta: a
|
|
65
73
|
});
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
}, [s]),
|
|
69
|
-
|
|
70
|
-
}, [l,
|
|
74
|
+
if (A(() => {
|
|
75
|
+
c && !p?.length && s && (window.location.href = s);
|
|
76
|
+
}, [s]), A(() => {
|
|
77
|
+
c && p?.length && y === -1 && l && l();
|
|
78
|
+
}, [l, p, y]), !n.appName)
|
|
71
79
|
return null;
|
|
72
|
-
const { appName:
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
-
|
|
80
|
+
const { appName: R } = n;
|
|
81
|
+
return /* @__PURE__ */ r(
|
|
82
|
+
O,
|
|
75
83
|
{
|
|
76
|
-
title:
|
|
84
|
+
title: R,
|
|
77
85
|
fullWidth: !0,
|
|
78
86
|
sidebarWidth: 128,
|
|
79
87
|
legacy: !1,
|
|
80
|
-
links:
|
|
88
|
+
links: C,
|
|
81
89
|
...h,
|
|
82
90
|
headerProps: {
|
|
83
91
|
homeLink: m,
|
|
84
|
-
logo: /* @__PURE__ */
|
|
85
|
-
addons: /* @__PURE__ */
|
|
86
|
-
|
|
92
|
+
logo: /* @__PURE__ */ r("img", { src: W, alt: "logo" }),
|
|
93
|
+
addons: /* @__PURE__ */ r(
|
|
94
|
+
Q,
|
|
87
95
|
{
|
|
88
|
-
formattedBlocklet:
|
|
89
|
-
addons:
|
|
90
|
-
sessionManagerProps:
|
|
91
|
-
showDomainWarningDialog:
|
|
96
|
+
formattedBlocklet: n,
|
|
97
|
+
addons: L,
|
|
98
|
+
sessionManagerProps: P,
|
|
99
|
+
showDomainWarningDialog: T
|
|
92
100
|
}
|
|
93
101
|
),
|
|
94
102
|
...h.headerProps
|
|
95
|
-
}
|
|
103
|
+
},
|
|
104
|
+
children: /* @__PURE__ */ z(Y, { path: k, currentTab: I, meta: a, children: [
|
|
105
|
+
/* @__PURE__ */ r(X, { onTabChange: N }),
|
|
106
|
+
B
|
|
107
|
+
] })
|
|
96
108
|
}
|
|
97
109
|
);
|
|
98
110
|
}
|
|
99
|
-
|
|
100
|
-
meta:
|
|
111
|
+
Z.propTypes = {
|
|
112
|
+
meta: E,
|
|
101
113
|
// 如果当前用户没有权限访问任何导航菜单, 则自动跳转到 fallbackUrl, 默认值为 publicPath, 设置为 null 表示禁用自动跳转
|
|
102
|
-
fallbackUrl:
|
|
114
|
+
fallbackUrl: e.string,
|
|
103
115
|
// 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
|
|
104
|
-
invalidPathFallback:
|
|
105
|
-
headerAddons:
|
|
106
|
-
sessionManagerProps:
|
|
107
|
-
links:
|
|
108
|
-
showDomainWarningDialog:
|
|
116
|
+
invalidPathFallback: e.func,
|
|
117
|
+
headerAddons: e.oneOfType([e.func, e.node]),
|
|
118
|
+
sessionManagerProps: _,
|
|
119
|
+
links: e.oneOfType([e.array, e.func]),
|
|
120
|
+
showDomainWarningDialog: e.bool,
|
|
121
|
+
appPath: e.string,
|
|
122
|
+
appTab: e.string,
|
|
123
|
+
onAppTabChange: e.func,
|
|
124
|
+
children: e.node
|
|
109
125
|
};
|
|
110
126
|
export {
|
|
111
|
-
|
|
127
|
+
yo as AppBadge,
|
|
128
|
+
X as AppHeader,
|
|
129
|
+
Y as AppInfoProvider,
|
|
130
|
+
Z as default,
|
|
131
|
+
Ao as useAppInfo
|
|
112
132
|
};
|
|
@@ -7,13 +7,13 @@ import y from "./links.js";
|
|
|
7
7
|
import M from "./social-media.js";
|
|
8
8
|
import O from "./copyright.js";
|
|
9
9
|
import B from "./layout/standard.js";
|
|
10
|
-
import
|
|
10
|
+
import C from "./layout/plain.js";
|
|
11
11
|
const f = [
|
|
12
12
|
{
|
|
13
13
|
name: "plain",
|
|
14
14
|
// 没有 navigation 和 socialMedia, 使用一个简单的两端对齐布局
|
|
15
15
|
support: (t, o) => !o.navigation?.length && !o.socialMedia?.length,
|
|
16
|
-
component:
|
|
16
|
+
component: C
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
name: "standard",
|
|
@@ -21,20 +21,20 @@ const f = [
|
|
|
21
21
|
support: () => !0,
|
|
22
22
|
component: B
|
|
23
23
|
}
|
|
24
|
-
],
|
|
25
|
-
function
|
|
24
|
+
], N = f.reduce((t, o) => ({ ...t, [o.name]: o }), {});
|
|
25
|
+
function S({ ...t }) {
|
|
26
26
|
const {
|
|
27
27
|
brand: o = null,
|
|
28
28
|
navigation: s = null,
|
|
29
29
|
socialMedia: p = null,
|
|
30
30
|
copyright: u = null,
|
|
31
|
-
links:
|
|
31
|
+
links: m = null,
|
|
32
32
|
layout: l = "auto",
|
|
33
33
|
...e
|
|
34
|
-
} = t, g = () => o ? /* @__PURE__ */ r(L, { ...o }) : null, h = () => s?.length ? /* @__PURE__ */ r(y, { links: s,
|
|
34
|
+
} = t, g = () => o ? /* @__PURE__ */ r(L, { ...o }) : null, h = () => s?.length ? /* @__PURE__ */ r(y, { links: s, minColumns: 3 }) : null, k = () => p?.length ? /* @__PURE__ */ r(M, { items: p }) : null, b = () => {
|
|
35
35
|
const i = u?.owner || o?.name;
|
|
36
36
|
return i ? /* @__PURE__ */ r(O, { owner: i, year: u?.year || void 0 }) : null;
|
|
37
|
-
}, x = () =>
|
|
37
|
+
}, x = () => m?.length ? /* @__PURE__ */ r(y, { flowLayout: !0, links: m }) : null, c = {
|
|
38
38
|
brand: g(),
|
|
39
39
|
navigation: h(),
|
|
40
40
|
socialMedia: k(),
|
|
@@ -42,7 +42,7 @@ function C({ ...t }) {
|
|
|
42
42
|
links: x()
|
|
43
43
|
};
|
|
44
44
|
let a = null;
|
|
45
|
-
if (l === "auto" ? a = f.find((i) => i.support(
|
|
45
|
+
if (l === "auto" ? a = f.find((i) => i.support(c, t)).component : a = N[l]?.component, !a)
|
|
46
46
|
throw new Error(`layout ${l} is not supported.`);
|
|
47
47
|
return /* @__PURE__ */ w(
|
|
48
48
|
d,
|
|
@@ -56,7 +56,7 @@ function C({ ...t }) {
|
|
|
56
56
|
...Array.isArray(e.sx) ? e.sx : [e.sx]
|
|
57
57
|
],
|
|
58
58
|
children: [
|
|
59
|
-
/* @__PURE__ */ r(a, { elements:
|
|
59
|
+
/* @__PURE__ */ r(a, { elements: c, data: t }),
|
|
60
60
|
/* @__PURE__ */ r(
|
|
61
61
|
d,
|
|
62
62
|
{
|
|
@@ -75,7 +75,7 @@ function C({ ...t }) {
|
|
|
75
75
|
}
|
|
76
76
|
);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
S.propTypes = {
|
|
79
79
|
brand: n.shape({
|
|
80
80
|
name: n.node,
|
|
81
81
|
description: n.string,
|
|
@@ -108,5 +108,5 @@ C.propTypes = {
|
|
|
108
108
|
layout: n.oneOf(["auto", "standard", "plain"])
|
|
109
109
|
};
|
|
110
110
|
export {
|
|
111
|
-
|
|
111
|
+
S as default
|
|
112
112
|
};
|
package/lib/Footer/links.d.ts
CHANGED
|
@@ -2,11 +2,12 @@ import { default as PropTypes } from 'prop-types';
|
|
|
2
2
|
/**
|
|
3
3
|
* footer 中的 links (支持分组, 最多支持 2 级)
|
|
4
4
|
*/
|
|
5
|
-
declare function Links({ links, flowLayout,
|
|
5
|
+
declare function Links({ links, flowLayout, minColumns, maxColumns, ...rest }: {
|
|
6
6
|
[x: string]: any;
|
|
7
7
|
links?: never[] | undefined;
|
|
8
8
|
flowLayout?: boolean | undefined;
|
|
9
|
-
|
|
9
|
+
minColumns?: number | undefined;
|
|
10
|
+
maxColumns?: number | undefined;
|
|
10
11
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
11
12
|
declare namespace Links {
|
|
12
13
|
namespace propTypes {
|
|
@@ -17,7 +18,8 @@ declare namespace Links {
|
|
|
17
18
|
props: PropTypes.Requireable<object>;
|
|
18
19
|
}> | null | undefined)[]>;
|
|
19
20
|
let flowLayout: PropTypes.Requireable<boolean>;
|
|
20
|
-
let
|
|
21
|
+
let minColumns: PropTypes.Requireable<number>;
|
|
22
|
+
let maxColumns: PropTypes.Requireable<number>;
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
export default Links;
|
package/lib/Footer/links.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import { useCreation as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { styled as
|
|
8
|
-
import
|
|
9
|
-
import { ExpandMore as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { splitNavColumns as
|
|
13
|
-
function
|
|
14
|
-
const [
|
|
15
|
-
let
|
|
1
|
+
import { jsx as r, jsxs as d, Fragment as M } from "react/jsx-runtime";
|
|
2
|
+
import { useState as j } from "react";
|
|
3
|
+
import i from "prop-types";
|
|
4
|
+
import { useCreation as I } from "ahooks";
|
|
5
|
+
import z from "lodash/isInteger";
|
|
6
|
+
import P from "lodash/isString";
|
|
7
|
+
import { styled as F } from "@arcblock/ux/lib/Theme";
|
|
8
|
+
import u from "clsx";
|
|
9
|
+
import { ExpandMore as A } from "@mui/icons-material";
|
|
10
|
+
import E from "../Icon/index.js";
|
|
11
|
+
import S from "../hooks/use-mobile.js";
|
|
12
|
+
import { splitNavColumns as T, isMailProtocol as W } from "../utils.js";
|
|
13
|
+
function _({ links: e = [], flowLayout: g = !1, minColumns: f = 1, maxColumns: k = 4, ...h }) {
|
|
14
|
+
const [x, y] = j(-1), v = S({ key: "md" }), b = e.some((t) => t.items?.length), m = !v && b && z(f) && f > 1 && k >= f, w = m ? Math.min(Math.max(e.length, f), k) : 1, p = ({ label: t, link: o, icon: n, render: a, props: s }) => {
|
|
15
|
+
let l = t;
|
|
16
16
|
if (a)
|
|
17
|
-
|
|
18
|
-
else if (o &&
|
|
19
|
-
const
|
|
20
|
-
target:
|
|
21
|
-
rel:
|
|
17
|
+
l = a({ label: t, link: o, props: s });
|
|
18
|
+
else if (o && P(o)) {
|
|
19
|
+
const c = o.startsWith("http") || o.startsWith("//"), $ = W(o) ? {} : {
|
|
20
|
+
target: c ? "_blank" : "_self",
|
|
21
|
+
rel: c ? "noreferrer noopener" : void 0
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
l = /* @__PURE__ */ r("a", { href: o, "aria-label": `Footer link for ${t}`, ...$, ...s, children: t });
|
|
24
24
|
}
|
|
25
|
-
return /* @__PURE__ */
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
return /* @__PURE__ */ d(M, { children: [
|
|
26
|
+
n && /* @__PURE__ */ r(E, { icon: n, size: 20, sx: { mr: 0.5 } }),
|
|
27
|
+
l
|
|
28
28
|
] });
|
|
29
|
-
},
|
|
30
|
-
const { items:
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */ r("span", { className: "footer-links-item", children: p(
|
|
33
|
-
!!
|
|
29
|
+
}, N = I(() => e?.length ? g ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : m ? T(e, { columns: w }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((n) => n.group).map((n, a) => {
|
|
30
|
+
const { items: s } = n;
|
|
31
|
+
return /* @__PURE__ */ d("div", { className: "footer-links-group", children: [
|
|
32
|
+
/* @__PURE__ */ r("span", { className: "footer-links-item", children: p(n) }),
|
|
33
|
+
!!s?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: s.map((l, c) => /* @__PURE__ */ r(
|
|
34
34
|
"span",
|
|
35
35
|
{
|
|
36
|
-
className:
|
|
37
|
-
children: p(
|
|
36
|
+
className: u("footer-links-item", { "footer-links-item--new": l.isNew }),
|
|
37
|
+
children: p(l)
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
c
|
|
40
40
|
)) })
|
|
41
41
|
] }, a);
|
|
42
42
|
}) }, o)) : e.map((t, o) => {
|
|
43
|
-
const { items:
|
|
44
|
-
return /* @__PURE__ */
|
|
43
|
+
const { items: n } = t, a = o === x;
|
|
44
|
+
return /* @__PURE__ */ d(
|
|
45
45
|
"div",
|
|
46
46
|
{
|
|
47
|
-
className:
|
|
47
|
+
className: u("footer-links-group", {
|
|
48
48
|
"footer-links-group--active": a
|
|
49
49
|
}),
|
|
50
|
-
onClick: () =>
|
|
50
|
+
onClick: () => y(x === o ? -1 : o),
|
|
51
51
|
children: [
|
|
52
|
-
/* @__PURE__ */
|
|
52
|
+
/* @__PURE__ */ d("span", { className: "footer-links-item", children: [
|
|
53
53
|
p(t),
|
|
54
|
-
!!
|
|
55
|
-
|
|
54
|
+
!!n?.length && /* @__PURE__ */ r("span", { className: "footer-links-group-expand-icon", children: /* @__PURE__ */ r(
|
|
55
|
+
A,
|
|
56
56
|
{
|
|
57
57
|
style: {
|
|
58
58
|
transform: `rotate(${a ? 180 : 0}deg)`
|
|
@@ -60,40 +60,42 @@ function R({ links: e = [], flowLayout: d = !1, columns: u, ...k }) {
|
|
|
60
60
|
}
|
|
61
61
|
) })
|
|
62
62
|
] }),
|
|
63
|
-
!!
|
|
63
|
+
!!n?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: n.map((s, l) => /* @__PURE__ */ r("span", { className: u("footer-links-item", { "footer-links-item--new": s.isNew }), children: p(s) }, l)) })
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
o
|
|
67
67
|
);
|
|
68
|
-
}) : null, [e,
|
|
68
|
+
}) : null, [e, g, m, x]);
|
|
69
69
|
return e?.length ? /* @__PURE__ */ r(
|
|
70
|
-
|
|
70
|
+
C,
|
|
71
71
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"footer-links--
|
|
76
|
-
"footer-links--
|
|
72
|
+
columns: w,
|
|
73
|
+
...h,
|
|
74
|
+
className: u(h.className, {
|
|
75
|
+
"footer-links--grouped": b,
|
|
76
|
+
"footer-links--flow": g,
|
|
77
|
+
"footer-links--columns": m
|
|
77
78
|
}),
|
|
78
|
-
children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children:
|
|
79
|
+
children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: N })
|
|
79
80
|
}
|
|
80
81
|
) : null;
|
|
81
82
|
}
|
|
82
|
-
|
|
83
|
-
links:
|
|
84
|
-
|
|
85
|
-
label:
|
|
86
|
-
link:
|
|
87
|
-
render:
|
|
88
|
-
props:
|
|
83
|
+
_.propTypes = {
|
|
84
|
+
links: i.arrayOf(
|
|
85
|
+
i.shape({
|
|
86
|
+
label: i.string,
|
|
87
|
+
link: i.string,
|
|
88
|
+
render: i.func,
|
|
89
|
+
props: i.object
|
|
89
90
|
})
|
|
90
91
|
),
|
|
91
92
|
// 流动布局, 简单的从左到右排列
|
|
92
|
-
flowLayout:
|
|
93
|
-
//
|
|
94
|
-
|
|
93
|
+
flowLayout: i.bool,
|
|
94
|
+
// 列布局,最小列数,最大列数
|
|
95
|
+
minColumns: i.number,
|
|
96
|
+
maxColumns: i.number
|
|
95
97
|
};
|
|
96
|
-
const
|
|
98
|
+
const C = F("div", { shouldForwardProp: (e) => e !== "columns" })`
|
|
97
99
|
overflow: hidden;
|
|
98
100
|
color: ${({ theme: e }) => e.palette.text.secondary};
|
|
99
101
|
.footer-links-inner {
|
|
@@ -158,7 +160,7 @@ const S = z("div")`
|
|
|
158
160
|
/* columns 布局 */
|
|
159
161
|
&.footer-links--columns {
|
|
160
162
|
.footer-links-inner {
|
|
161
|
-
gap:
|
|
163
|
+
gap: ${({ columns: e }) => `${288 / e}px`};
|
|
162
164
|
}
|
|
163
165
|
.footer-links-column {
|
|
164
166
|
display: flex;
|
|
@@ -244,5 +246,5 @@ const S = z("div")`
|
|
|
244
246
|
}
|
|
245
247
|
`;
|
|
246
248
|
export {
|
|
247
|
-
|
|
249
|
+
_ as default
|
|
248
250
|
};
|
package/lib/utils.js
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
const p = (n, r, e = "children") => n.map((t) => Array.isArray(t[e]) ? r({
|
|
2
2
|
...t,
|
|
3
3
|
[e]: p(t[e], r, e)
|
|
4
|
-
}) : r(t)),
|
|
4
|
+
}) : r(t)), A = (n, r = "children") => {
|
|
5
5
|
const e = [];
|
|
6
6
|
return p(n, (t) => e.push(t), r), e;
|
|
7
|
-
},
|
|
7
|
+
}, C = (n, r = "children") => {
|
|
8
8
|
let e = 0;
|
|
9
9
|
return p(n, () => e++, r), e;
|
|
10
|
-
},
|
|
10
|
+
}, R = (n, r, e = "children") => n.map((t) => ({ ...t })).filter((t) => {
|
|
11
11
|
const s = t[e];
|
|
12
12
|
if (Array.isArray(s)) {
|
|
13
|
-
const a =
|
|
13
|
+
const a = R(s, r, e);
|
|
14
14
|
t[e] = a?.length ? a : void 0;
|
|
15
15
|
}
|
|
16
16
|
const l = { filteredChildren: t[e], isLeaf: !s?.length };
|
|
17
17
|
return r(t, l);
|
|
18
|
-
}),
|
|
18
|
+
}), P = (n) => /^https?:\/\//.test(n), S = (n) => /^mailto:/i.test(n.trim()), x = (n) => /^[\w-]+:[\w-]+$/.test(n), v = (n) => {
|
|
19
19
|
if (!n || !n?.startsWith("/"))
|
|
20
20
|
return !1;
|
|
21
21
|
const r = (s) => s.endsWith("/") ? s : `${s}/`, e = r(window.location.pathname), t = r(new URL(n, window.location.origin).pathname);
|
|
22
22
|
return e.startsWith(t);
|
|
23
|
-
},
|
|
24
|
-
const r = n.map((t, s) => ({ path: t, index: s })).filter((t) =>
|
|
23
|
+
}, W = (n = []) => {
|
|
24
|
+
const r = n.map((t, s) => ({ path: t, index: s })).filter((t) => v(t.path));
|
|
25
25
|
return r?.length ? r.slice(1).reduce((t, s) => t.path.length >= s.path.length ? t : s, r[0]).index : -1;
|
|
26
|
-
},
|
|
27
|
-
const { columns: e = 1, breakInside: t = !1, groupHeight: s = 48, itemHeight: l = 24, childrenKey: a = "items" } = r, m = n.reduce((
|
|
28
|
-
let o = 0,
|
|
29
|
-
const d = h * 0.2, f = (
|
|
30
|
-
return n.forEach((
|
|
31
|
-
const g = s + (
|
|
32
|
-
t && f(s) && (o++,
|
|
33
|
-
...
|
|
26
|
+
}, k = (n, r = {}) => {
|
|
27
|
+
const { columns: e = 1, breakInside: t = !1, groupHeight: s = 48, itemHeight: l = 24, childrenKey: a = "items" } = r, m = n.length, w = n.reduce((i, g) => i + s + (g[a]?.length || 0) * l, 0), h = Math.ceil(w / e), u = [[]];
|
|
28
|
+
let o = 0, c = 0;
|
|
29
|
+
const d = h * 0.2, f = (i) => c > h - d && o < e - 1 && c + i > h + d;
|
|
30
|
+
return n.forEach((i) => {
|
|
31
|
+
const g = s + (i[a]?.length || 0) * l;
|
|
32
|
+
t && f(s) && (o++, c = 0, u[o] = []), !t && c > 0 && (m <= e || f(g)) && (o++, c = 0, u[o] = []), u[o].push({
|
|
33
|
+
...i,
|
|
34
34
|
group: !0
|
|
35
|
-
}),
|
|
36
|
-
t && f(l) && (o++,
|
|
37
|
-
...
|
|
35
|
+
}), c += s, i[a] && i[a].forEach((H) => {
|
|
36
|
+
t && f(l) && (o++, c = 0, u[o] = []), u[o].push({
|
|
37
|
+
...H,
|
|
38
38
|
group: !1
|
|
39
|
-
}),
|
|
39
|
+
}), c += l;
|
|
40
40
|
});
|
|
41
41
|
}), u;
|
|
42
42
|
};
|
|
43
43
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
C as countRecursive,
|
|
45
|
+
R as filterRecursive,
|
|
46
|
+
A as flatRecursive,
|
|
47
|
+
x as isIconifyString,
|
|
48
|
+
S as isMailProtocol,
|
|
49
|
+
P as isUrl,
|
|
50
50
|
p as mapRecursive,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
v as matchPath,
|
|
52
|
+
W as matchPaths,
|
|
53
|
+
k as splitNavColumns
|
|
54
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.19",
|
|
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.17.5",
|
|
37
37
|
"@abtnode/util": "^1.17.5",
|
|
38
|
-
"@arcblock/bridge": "3.2.
|
|
39
|
-
"@arcblock/icons": "3.2.
|
|
40
|
-
"@arcblock/react-hooks": "3.2.
|
|
38
|
+
"@arcblock/bridge": "3.2.19",
|
|
39
|
+
"@arcblock/icons": "3.2.19",
|
|
40
|
+
"@arcblock/react-hooks": "3.2.19",
|
|
41
41
|
"@arcblock/ws": "^1.27.15",
|
|
42
42
|
"@blocklet/did-space-react": "^1.2.10",
|
|
43
43
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -82,13 +82,19 @@
|
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@arcblock/did-connect-react": "3.2.
|
|
85
|
+
"@arcblock/did-connect-react": "3.2.19",
|
|
86
|
+
"@babel/preset-env": "^7.28.0",
|
|
87
|
+
"@babel/preset-react": "^7.27.1",
|
|
88
|
+
"@babel/preset-typescript": "^7.27.1",
|
|
86
89
|
"@types/dompurify": "^3.2.0",
|
|
90
|
+
"@types/jest": "^29.5.14",
|
|
87
91
|
"@types/ua-parser-js": "^0.7.39",
|
|
88
92
|
"@types/validator": "^13.15.2",
|
|
93
|
+
"babel-jest": "29",
|
|
89
94
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
90
95
|
"jest": "^29.7.0",
|
|
96
|
+
"typescript": "~5.5.4",
|
|
91
97
|
"unbuild": "^2.0.0"
|
|
92
98
|
},
|
|
93
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "8439c6a0c022c3fab219191ff035d737c422f3ff"
|
|
94
100
|
}
|