@blocklet/ui-react 3.0.9 → 3.0.11
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/BlockletStudio/index.js +70 -71
- package/lib/ComponentInstaller/index.js +85 -88
- package/lib/ComponentInstaller/installer-item.js +47 -53
- package/lib/ComponentInstaller/use-component-installed.js +32 -38
- package/lib/ComponentManager/components/add-component.js +47 -50
- package/lib/ComponentManager/components/publish-component.js +30 -31
- package/lib/ComponentManager/components/resource-dialog.js +28 -30
- package/lib/Dashboard/index.d.ts +1 -1
- package/lib/Dashboard/index.js +59 -61
- package/lib/Footer/index.js +51 -52
- package/lib/Footer/internal-footer.js +43 -47
- package/lib/Footer/layout/standard.js +11 -12
- package/lib/Footer/links.js +25 -28
- package/lib/Footer/social-media.js +17 -17
- package/lib/Header/index.js +81 -83
- package/lib/Notifications/Snackbar.js +76 -77
- package/lib/Notifications/hooks/use-title.js +34 -34
- package/lib/Notifications/utils.js +56 -60
- package/lib/UserCenter/components/config-inviter.js +17 -18
- package/lib/UserCenter/components/danger-zone.js +49 -52
- package/lib/UserCenter/components/nft.js +44 -45
- package/lib/UserCenter/components/notification.js +92 -99
- package/lib/UserCenter/components/passport.js +22 -22
- package/lib/UserCenter/components/privacy.js +6 -6
- package/lib/UserCenter/components/settings.js +40 -43
- package/lib/UserCenter/components/status-dialog/date-picker.js +7 -8
- package/lib/UserCenter/components/status-dialog/index.js +112 -114
- package/lib/UserCenter/components/status-selector/duration-menu.js +35 -36
- package/lib/UserCenter/components/status-selector/index.js +13 -13
- package/lib/UserCenter/components/storage/action.js +21 -22
- package/lib/UserCenter/components/storage/delete.js +24 -24
- package/lib/UserCenter/components/third-party-login/index.js +53 -53
- package/lib/UserCenter/components/third-party-login/third-party-item.js +87 -89
- package/lib/UserCenter/components/user-center.js +198 -207
- package/lib/UserCenter/components/user-info/metadata.js +343 -353
- package/lib/UserCenter/components/user-info/switch-role.js +17 -20
- package/lib/UserCenter/components/user-info/user-basic-info.js +79 -82
- package/lib/UserCenter/components/user-info/user-info.js +40 -40
- package/lib/UserCenter/components/user-info/user-status.js +97 -99
- package/lib/UserCenter/components/user-info/utils.js +34 -35
- package/lib/UserSessions/components/user-session-info.js +25 -28
- package/lib/UserSessions/components/user-sessions.js +169 -181
- package/lib/blocklets.js +62 -72
- package/lib/common/domain-warning.js +31 -31
- package/lib/common/header-addons.d.ts +1 -1
- package/lib/common/header-addons.js +49 -53
- package/lib/common/notification-addon.js +29 -32
- package/lib/common/ws.js +17 -18
- package/lib/contexts/config-user-space.js +16 -19
- package/lib/utils.js +44 -48
- package/package.json +11 -11
|
@@ -1,44 +1,38 @@
|
|
|
1
|
-
import { BLOCKLET_SERVICE_PATH_PREFIX as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { joinURL as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const o = Array.isArray(e) ? e.join(";;") : e, [
|
|
7
|
-
|
|
8
|
-
const { optionalComponents:
|
|
9
|
-
|
|
10
|
-
if (!l || !l.length)
|
|
1
|
+
import { BLOCKLET_SERVICE_PATH_PREFIX as k } from "@arcblock/did-connect/lib/constant";
|
|
2
|
+
import { useState as b, useRef as C, useMemo as h, useEffect as I } from "react";
|
|
3
|
+
import { joinURL as w } from "ufo";
|
|
4
|
+
const c = (e) => typeof e == "string" ? new Set(e.split(";;")) : new Set(e);
|
|
5
|
+
function y({ did: e, onInstalled: u, onError: f }) {
|
|
6
|
+
const o = Array.isArray(e) ? e.join(";;") : e, [S, a] = b({}), i = C({ onInstalled: u, onError: f });
|
|
7
|
+
i.current = { onInstalled: u, onError: f };
|
|
8
|
+
const { optionalComponents: s, componentMountPoints: p } = window.blocklet, r = h(() => {
|
|
9
|
+
if (!s || !s.length)
|
|
11
10
|
return [];
|
|
12
|
-
const t =
|
|
13
|
-
return (
|
|
14
|
-
}, [o,
|
|
11
|
+
const t = c(o), n = s.filter((l) => t.has(l.meta.did));
|
|
12
|
+
return (n ? i.current.onError : i.current.onInstalled)?.(n), n;
|
|
13
|
+
}, [o, s]), m = h(() => {
|
|
15
14
|
if (r.length)
|
|
16
15
|
return !0;
|
|
17
|
-
const t =
|
|
18
|
-
return (
|
|
19
|
-
}, [r,
|
|
16
|
+
const t = c(o);
|
|
17
|
+
return (p || []).find((n) => t.has(n.did));
|
|
18
|
+
}, [r, p, o]);
|
|
20
19
|
return r.forEach((t) => {
|
|
21
|
-
t.storeUrl =
|
|
20
|
+
t.storeUrl = w(t.meta.homepage, "blocklets", t.meta.did), t.installUrl = w(
|
|
22
21
|
window.blocklet.appUrl,
|
|
23
|
-
|
|
22
|
+
k,
|
|
24
23
|
`/admin/components?install-component=${t.meta.did}`
|
|
25
24
|
);
|
|
26
|
-
}),
|
|
25
|
+
}), I(() => {
|
|
27
26
|
const t = (n) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
...U,
|
|
38
|
-
[(b = c.meta) == null ? void 0 : b.did]: c.status || "waiting"
|
|
39
|
-
};
|
|
40
|
-
}));
|
|
41
|
-
}), E || i({});
|
|
27
|
+
if (n.origin === window.blocklet.appUrl && n.data?.kind === "component-installer" && n.data?.blocklet?.children) {
|
|
28
|
+
let l = !1;
|
|
29
|
+
const g = c(o);
|
|
30
|
+
n.data?.blocklet?.children.forEach((d) => {
|
|
31
|
+
g.has(d.meta?.did) && (l = !0, a((E) => ({
|
|
32
|
+
...E,
|
|
33
|
+
[d.meta?.did]: d.status || "waiting"
|
|
34
|
+
})));
|
|
35
|
+
}), l || a({});
|
|
42
36
|
}
|
|
43
37
|
};
|
|
44
38
|
return window.addEventListener("message", t), () => {
|
|
@@ -46,12 +40,12 @@ function B({ did: e, onInstalled: f, onError: p }) {
|
|
|
46
40
|
};
|
|
47
41
|
}, [o]), {
|
|
48
42
|
optComponents: r,
|
|
49
|
-
installed: !r.length &&
|
|
50
|
-
installStatus:
|
|
51
|
-
setInstallStatus:
|
|
52
|
-
definedInBlockletYML:
|
|
43
|
+
installed: !r.length && m,
|
|
44
|
+
installStatus: S,
|
|
45
|
+
setInstallStatus: a,
|
|
46
|
+
definedInBlockletYML: m
|
|
53
47
|
};
|
|
54
48
|
}
|
|
55
49
|
export {
|
|
56
|
-
|
|
50
|
+
y as default
|
|
57
51
|
};
|
|
@@ -1,89 +1,86 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { use as
|
|
1
|
+
import { jsxs as k, Fragment as y, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { use as B, useRef as F, useEffect as I } from "react";
|
|
3
3
|
import S from "@arcblock/ux/lib/Button";
|
|
4
4
|
import { useLocaleContext as j } from "@arcblock/ux/lib/Locale/context";
|
|
5
5
|
import { BLOCKLET_SERVICE_PATH_PREFIX as P } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
-
import { useMemoizedFn as
|
|
6
|
+
import { useMemoizedFn as e, useReactive as T } from "ahooks";
|
|
7
7
|
import { translate as U } from "@arcblock/ux/lib/Locale/util";
|
|
8
8
|
import { withQuery as _, joinURL as A } from "ufo";
|
|
9
9
|
import { SessionContext as M } from "@arcblock/did-connect/lib/Session";
|
|
10
|
-
import
|
|
10
|
+
import f from "@arcblock/ux/lib/Toast";
|
|
11
11
|
import O from "./resource-dialog.js";
|
|
12
12
|
import { translations as z } from "../libs/locales.js";
|
|
13
13
|
function $({
|
|
14
|
-
componentDid:
|
|
15
|
-
resourceType:
|
|
16
|
-
resourceDid:
|
|
17
|
-
grantedRoles:
|
|
18
|
-
autoClose:
|
|
19
|
-
selectedMeta:
|
|
20
|
-
storeUrl:
|
|
21
|
-
onComplete:
|
|
22
|
-
onClose:
|
|
23
|
-
render:
|
|
14
|
+
componentDid: s,
|
|
15
|
+
resourceType: u = void 0,
|
|
16
|
+
resourceDid: g = void 0,
|
|
17
|
+
grantedRoles: p = ["admin", "owner"],
|
|
18
|
+
autoClose: h = !0,
|
|
19
|
+
selectedMeta: w = void 0,
|
|
20
|
+
storeUrl: C = void 0,
|
|
21
|
+
onComplete: v,
|
|
22
|
+
onClose: L,
|
|
23
|
+
render: a = void 0
|
|
24
24
|
}) {
|
|
25
|
-
const { session:
|
|
25
|
+
const { session: i } = B(M), { locale: R } = j(), t = e((n, b = {}) => U(z, n, R, "en", b)), r = F(null), o = T({
|
|
26
26
|
loading: !1,
|
|
27
27
|
showDialog: !1
|
|
28
|
-
}),
|
|
29
|
-
resourceDid:
|
|
30
|
-
resourceType:
|
|
28
|
+
}), D = _(A(P, "embed/resources", s, "add"), {
|
|
29
|
+
resourceDid: g,
|
|
30
|
+
resourceType: u,
|
|
31
31
|
mode: "dialog",
|
|
32
32
|
showFromUrl: "false",
|
|
33
33
|
showResourcesSwitch: "false",
|
|
34
34
|
enableRunBackground: "false",
|
|
35
35
|
showCategory: "false"
|
|
36
|
-
}),
|
|
37
|
-
|
|
38
|
-
}),
|
|
39
|
-
|
|
40
|
-
}),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
h.warning(i("needLogin"));
|
|
36
|
+
}), E = e(() => {
|
|
37
|
+
o.showDialog = !1, L?.();
|
|
38
|
+
}), l = e(() => {
|
|
39
|
+
o.showDialog = !1, v?.();
|
|
40
|
+
}), m = e(() => {
|
|
41
|
+
if (!i.user) {
|
|
42
|
+
f.warning(t("needLogin"));
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
|
-
if (!
|
|
47
|
-
|
|
45
|
+
if (!p.includes(i.user?.role)) {
|
|
46
|
+
f.warning(t("noPermission"));
|
|
48
47
|
return;
|
|
49
48
|
}
|
|
50
|
-
|
|
51
|
-
}),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var s;
|
|
56
|
-
((s = o == null ? void 0 : o.data) == null ? void 0 : s.event) === "component.installed" && o.data.componentDid === a && (R || o.data.manual) && c();
|
|
49
|
+
o.loading = !0, o.showDialog = !0;
|
|
50
|
+
}), x = e(() => {
|
|
51
|
+
o.loading = !1, r.current && r.current?.selectBlocklet(w);
|
|
52
|
+
}), d = e((n) => {
|
|
53
|
+
n?.data?.event === "component.installed" && n.data.componentDid === s && (h || n.data.manual) && l();
|
|
57
54
|
});
|
|
58
55
|
return I(() => {
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
|
|
56
|
+
o.showDialog ? window.addEventListener("message", d) : window.removeEventListener("message", d);
|
|
57
|
+
}, [o.showDialog]), /* @__PURE__ */ k(y, { children: [
|
|
58
|
+
a ? a({ onClick: m, loading: o.loading }) : /* @__PURE__ */ c(
|
|
62
59
|
S,
|
|
63
60
|
{
|
|
64
61
|
variant: "outlined",
|
|
65
62
|
color: "secondary",
|
|
66
63
|
type: "button",
|
|
67
64
|
className: "submit",
|
|
68
|
-
onClick:
|
|
69
|
-
loading:
|
|
65
|
+
onClick: m,
|
|
66
|
+
loading: o.loading,
|
|
70
67
|
sx: { mr: 1, ml: 1 },
|
|
71
|
-
children:
|
|
68
|
+
children: t("importResource")
|
|
72
69
|
},
|
|
73
70
|
"button"
|
|
74
71
|
),
|
|
75
|
-
|
|
72
|
+
o.showDialog && /* @__PURE__ */ c(
|
|
76
73
|
O,
|
|
77
74
|
{
|
|
78
|
-
ref:
|
|
79
|
-
src:
|
|
80
|
-
storeUrl:
|
|
75
|
+
ref: r,
|
|
76
|
+
src: D,
|
|
77
|
+
storeUrl: C,
|
|
81
78
|
open: !0,
|
|
82
|
-
componentDid:
|
|
83
|
-
loading:
|
|
84
|
-
onClose:
|
|
85
|
-
onComplete:
|
|
86
|
-
onLoad:
|
|
79
|
+
componentDid: s,
|
|
80
|
+
loading: o.loading,
|
|
81
|
+
onClose: E,
|
|
82
|
+
onComplete: l,
|
|
83
|
+
onLoad: x
|
|
87
84
|
}
|
|
88
85
|
)
|
|
89
86
|
] });
|
|
@@ -1,67 +1,66 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { use as
|
|
3
|
-
import
|
|
4
|
-
import { useLocaleContext as
|
|
1
|
+
import { jsxs as C, Fragment as x, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { use as b } from "react";
|
|
3
|
+
import w from "@arcblock/ux/lib/Button";
|
|
4
|
+
import { useLocaleContext as L } from "@arcblock/ux/lib/Locale/context";
|
|
5
5
|
import { BLOCKLET_SERVICE_PATH_PREFIX as v } from "@arcblock/ux/lib/Util/constant";
|
|
6
|
-
import { useMemoizedFn as
|
|
6
|
+
import { useMemoizedFn as e, useReactive as D } from "ahooks";
|
|
7
7
|
import { translate as E } from "@arcblock/ux/lib/Locale/util";
|
|
8
8
|
import { SessionContext as P } from "@arcblock/did-connect/lib/Session";
|
|
9
|
-
import
|
|
9
|
+
import m from "@arcblock/ux/lib/Toast";
|
|
10
10
|
import F from "./resource-dialog.js";
|
|
11
|
-
import { translations as
|
|
12
|
-
function
|
|
13
|
-
componentDid:
|
|
14
|
-
grantedRoles:
|
|
15
|
-
onClose:
|
|
16
|
-
render:
|
|
11
|
+
import { translations as R } from "../libs/locales.js";
|
|
12
|
+
function A({
|
|
13
|
+
componentDid: t,
|
|
14
|
+
grantedRoles: n = void 0,
|
|
15
|
+
onClose: u,
|
|
16
|
+
render: i = void 0
|
|
17
17
|
}) {
|
|
18
|
-
const { session:
|
|
18
|
+
const { session: s } = b(P), { locale: c } = L(), r = e((p, h = {}) => E(R, p, c, "en", h)), o = D({
|
|
19
19
|
showDialog: !1,
|
|
20
20
|
loading: !1
|
|
21
|
-
}), d = `${v}/embed/resources/${
|
|
22
|
-
o.showDialog = !1,
|
|
23
|
-
}), g =
|
|
21
|
+
}), d = `${v}/embed/resources/${t}/publish?mode=dialog`, f = e(() => {
|
|
22
|
+
o.showDialog = !1, u?.();
|
|
23
|
+
}), g = e(() => {
|
|
24
24
|
o.loading = !1;
|
|
25
|
-
}),
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
c.warning(e("needLogin"));
|
|
25
|
+
}), l = e(() => {
|
|
26
|
+
if (!s.user) {
|
|
27
|
+
m.warning(r("needLogin"));
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
if (
|
|
32
|
-
|
|
30
|
+
if (n && n.length > 0 && !n?.includes(s.user?.role)) {
|
|
31
|
+
m.warning(r("noPermission"));
|
|
33
32
|
return;
|
|
34
33
|
}
|
|
35
34
|
o.loading = !0, o.showDialog = !0;
|
|
36
35
|
});
|
|
37
|
-
return /* @__PURE__ */ x
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
return /* @__PURE__ */ C(x, { children: [
|
|
37
|
+
i ? i({ onClick: l, loading: o.loading }) : /* @__PURE__ */ a(
|
|
38
|
+
w,
|
|
40
39
|
{
|
|
41
40
|
variant: "outlined",
|
|
42
41
|
color: "secondary",
|
|
43
42
|
type: "button",
|
|
44
43
|
className: "submit",
|
|
45
44
|
loading: o.loading,
|
|
46
|
-
onClick:
|
|
45
|
+
onClick: l,
|
|
47
46
|
sx: { mr: 1, ml: 1 },
|
|
48
|
-
children:
|
|
47
|
+
children: r("exportResource")
|
|
49
48
|
},
|
|
50
49
|
"button"
|
|
51
50
|
),
|
|
52
|
-
o.showDialog && /* @__PURE__ */
|
|
51
|
+
o.showDialog && /* @__PURE__ */ a(
|
|
53
52
|
F,
|
|
54
53
|
{
|
|
55
54
|
src: d,
|
|
56
55
|
open: !0,
|
|
57
|
-
onClose:
|
|
56
|
+
onClose: f,
|
|
58
57
|
onLoad: g,
|
|
59
|
-
componentDid:
|
|
58
|
+
componentDid: t,
|
|
60
59
|
loading: o.loading
|
|
61
60
|
}
|
|
62
61
|
)
|
|
63
62
|
] });
|
|
64
63
|
}
|
|
65
64
|
export {
|
|
66
|
-
|
|
65
|
+
A as default
|
|
67
66
|
};
|
|
@@ -1,50 +1,48 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemoizedFn as
|
|
3
|
-
import { forwardRef as
|
|
4
|
-
function
|
|
5
|
-
src:
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useMemoizedFn as m, useMount as g, useUnmount as w } from "ahooks";
|
|
3
|
+
import { forwardRef as p, useRef as v, useImperativeHandle as D } from "react";
|
|
4
|
+
function R({
|
|
5
|
+
src: n,
|
|
6
6
|
open: t = !1,
|
|
7
|
-
componentDid:
|
|
8
|
-
loading:
|
|
9
|
-
storeUrl:
|
|
10
|
-
onClose:
|
|
7
|
+
componentDid: i,
|
|
8
|
+
loading: s = !0,
|
|
9
|
+
storeUrl: a = "",
|
|
10
|
+
onClose: l = () => {
|
|
11
11
|
},
|
|
12
|
-
onComplete:
|
|
12
|
+
onComplete: u = () => {
|
|
13
13
|
},
|
|
14
|
-
onLoad:
|
|
14
|
+
onLoad: c = () => {
|
|
15
15
|
}
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
t && (((o = e == null ? void 0 : e.data) == null ? void 0 : o.event) === "resourceDialog.close" && d(), ((s = e == null ? void 0 : e.data) == null ? void 0 : s.event) === "resourceDialog.complete" && f(), ((a = e == null ? void 0 : e.data) == null ? void 0 : a.event) === "resourceDialog.loaded" && m());
|
|
16
|
+
}, d) {
|
|
17
|
+
const o = v(null), r = m((e) => {
|
|
18
|
+
t && (e?.data?.event === "resourceDialog.close" && l(), e?.data?.event === "resourceDialog.complete" && u(), e?.data?.event === "resourceDialog.loaded" && c());
|
|
20
19
|
});
|
|
21
|
-
return
|
|
22
|
-
window.addEventListener("message",
|
|
23
|
-
}),
|
|
24
|
-
window.removeEventListener("message",
|
|
25
|
-
}),
|
|
20
|
+
return g(() => {
|
|
21
|
+
window.addEventListener("message", r);
|
|
22
|
+
}), w(() => {
|
|
23
|
+
window.removeEventListener("message", r);
|
|
24
|
+
}), D(d, () => ({
|
|
26
25
|
selectBlocklet: (e) => {
|
|
27
|
-
|
|
28
|
-
(o = r.current) != null && o.contentWindow && r.current.contentWindow.postMessage(
|
|
26
|
+
o.current?.contentWindow && o.current.contentWindow.postMessage(
|
|
29
27
|
{
|
|
30
28
|
event: "resourceDialog.select",
|
|
31
29
|
data: e,
|
|
32
|
-
componentDid:
|
|
33
|
-
storeUrl:
|
|
30
|
+
componentDid: i,
|
|
31
|
+
storeUrl: a
|
|
34
32
|
},
|
|
35
33
|
"*"
|
|
36
34
|
);
|
|
37
35
|
}
|
|
38
|
-
})), t ? /* @__PURE__ */
|
|
36
|
+
})), t ? /* @__PURE__ */ f(
|
|
39
37
|
"iframe",
|
|
40
38
|
{
|
|
41
|
-
ref:
|
|
42
|
-
src:
|
|
39
|
+
ref: o,
|
|
40
|
+
src: n,
|
|
43
41
|
title: "Resource Dialog",
|
|
44
42
|
style: {
|
|
45
43
|
position: "fixed",
|
|
46
44
|
top: 0,
|
|
47
|
-
left:
|
|
45
|
+
left: s ? "-100vw" : 0,
|
|
48
46
|
width: "100vw",
|
|
49
47
|
height: "100vh",
|
|
50
48
|
zIndex: 9999,
|
|
@@ -54,7 +52,7 @@ function b({
|
|
|
54
52
|
}
|
|
55
53
|
) : null;
|
|
56
54
|
}
|
|
57
|
-
const
|
|
55
|
+
const b = p(R);
|
|
58
56
|
export {
|
|
59
|
-
|
|
57
|
+
b as default
|
|
60
58
|
};
|
package/lib/Dashboard/index.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ declare namespace Dashboard {
|
|
|
22
22
|
export { BlockletMetaProps as meta };
|
|
23
23
|
export let fallbackUrl: PropTypes.Requireable<string>;
|
|
24
24
|
export let invalidPathFallback: PropTypes.Requireable<(...args: any[]) => any>;
|
|
25
|
-
export let headerAddons: PropTypes.Requireable<NonNullable<
|
|
25
|
+
export let headerAddons: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
|
|
26
26
|
export { SessionManagerProps as sessionManagerProps };
|
|
27
27
|
export let links: PropTypes.Requireable<NonNullable<any[] | ((...args: any[]) => any) | null | undefined>>;
|
|
28
28
|
export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
|
package/lib/Dashboard/index.js
CHANGED
|
@@ -1,54 +1,52 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import "iconify-icon";
|
|
3
|
-
import { use as
|
|
3
|
+
import { use as I, useMemo as v, useLayoutEffect as w } from "react";
|
|
4
4
|
import t from "prop-types";
|
|
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
|
-
function
|
|
16
|
-
meta:
|
|
17
|
-
fallbackUrl:
|
|
18
|
-
invalidPathFallback:
|
|
5
|
+
import { SessionContext as R } from "@arcblock/did-connect/lib/Session";
|
|
6
|
+
import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import z from "@arcblock/ux/lib/Img";
|
|
8
|
+
import A from "@arcblock/ux/lib/Layout/dashboard";
|
|
9
|
+
import C from "@arcblock/ux/lib/hooks/use-blocklet-logo";
|
|
10
|
+
import { SessionManagerProps as D, BlockletMetaProps as M } from "../types.js";
|
|
11
|
+
import { mapRecursive as O, flatRecursive as j, matchPaths as H } from "../utils.js";
|
|
12
|
+
import { formatBlockletInfo as S, getLocalizedNavigation as _, filterNavByRole as E, publicPath as m } from "../blocklets.js";
|
|
13
|
+
import U from "../common/header-addons.js";
|
|
14
|
+
import { useWalletHiddenTopbar as q } from "../common/wallet-hidden-topbar.js";
|
|
15
|
+
function F({
|
|
16
|
+
meta: s = {},
|
|
17
|
+
fallbackUrl: a = m,
|
|
18
|
+
invalidPathFallback: l = null,
|
|
19
19
|
headerAddons: k = void 0,
|
|
20
|
-
sessionManagerProps:
|
|
20
|
+
sessionManagerProps: L = {
|
|
21
21
|
showRole: !0,
|
|
22
22
|
// dashboard 默认退出登录行为: 跳转到 (root) blocklet 首页
|
|
23
23
|
onLogout: () => {
|
|
24
|
-
window.location.href =
|
|
24
|
+
window.location.href = m;
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
links:
|
|
28
|
-
showDomainWarningDialog:
|
|
29
|
-
...
|
|
27
|
+
links: c = [],
|
|
28
|
+
showDomainWarningDialog: N = !0,
|
|
29
|
+
...h
|
|
30
30
|
}) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const e = Object.assign({}, window.blocklet, l);
|
|
31
|
+
q();
|
|
32
|
+
const d = I(R)?.session?.user, g = d?.role, { locale: x } = T() || {}, r = v(() => {
|
|
33
|
+
const e = Object.assign({}, window.blocklet, s);
|
|
35
34
|
try {
|
|
36
|
-
return
|
|
37
|
-
} catch (
|
|
38
|
-
return console.error("Failed to format blocklet info",
|
|
35
|
+
return S(e);
|
|
36
|
+
} catch (n) {
|
|
37
|
+
return console.error("Failed to format blocklet info", n, e), e;
|
|
39
38
|
}
|
|
40
|
-
}, [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
e = F(e, y), e = _(
|
|
39
|
+
}, [s]), { localizedNav: y, flattened: f, matchedIndex: b } = v(() => {
|
|
40
|
+
let e = _(r?.navigation?.dashboard, x) || [];
|
|
41
|
+
e = E(e, g), e = O(
|
|
44
42
|
e,
|
|
45
43
|
(o) => {
|
|
46
|
-
let
|
|
47
|
-
return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ?
|
|
44
|
+
let u = null;
|
|
45
|
+
return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? u = /* @__PURE__ */ i(z, { src: o.icon }) : u = /* @__PURE__ */ i("iconify-icon", { height: "100%", width: "100%", icon: o.icon })), {
|
|
48
46
|
id: o.id,
|
|
49
47
|
title: o.title,
|
|
50
48
|
url: o.link,
|
|
51
|
-
icon:
|
|
49
|
+
icon: u,
|
|
52
50
|
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
53
51
|
external: !0,
|
|
54
52
|
children: o.items
|
|
@@ -56,55 +54,55 @@ function K({
|
|
|
56
54
|
},
|
|
57
55
|
"items"
|
|
58
56
|
);
|
|
59
|
-
const
|
|
60
|
-
return
|
|
61
|
-
}, [r,
|
|
62
|
-
meta:
|
|
57
|
+
const n = j(e).filter((o) => !!o.url), p = H(n.map((o) => o.url));
|
|
58
|
+
return p !== -1 && (n[p].active = !0), { localizedNav: e, flattened: n, matchedIndex: p };
|
|
59
|
+
}, [r, x, g]), P = typeof c == "function" ? c(y) : [...y, ...c], W = C({
|
|
60
|
+
meta: s
|
|
63
61
|
});
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
|
|
68
|
-
}, [
|
|
62
|
+
if (w(() => {
|
|
63
|
+
d && !f?.length && a && (window.location.href = a);
|
|
64
|
+
}, [a]), w(() => {
|
|
65
|
+
d && f?.length && b === -1 && l && l();
|
|
66
|
+
}, [l, f, b]), !r.appName)
|
|
69
67
|
return null;
|
|
70
|
-
const { appName:
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
-
|
|
68
|
+
const { appName: B } = r;
|
|
69
|
+
return /* @__PURE__ */ i(
|
|
70
|
+
A,
|
|
73
71
|
{
|
|
74
|
-
title:
|
|
72
|
+
title: B,
|
|
75
73
|
fullWidth: !0,
|
|
76
74
|
sidebarWidth: 128,
|
|
77
75
|
legacy: !1,
|
|
78
|
-
links:
|
|
79
|
-
...
|
|
76
|
+
links: P,
|
|
77
|
+
...h,
|
|
80
78
|
headerProps: {
|
|
81
|
-
homeLink:
|
|
82
|
-
logo: /* @__PURE__ */
|
|
83
|
-
addons: /* @__PURE__ */
|
|
84
|
-
|
|
79
|
+
homeLink: m,
|
|
80
|
+
logo: /* @__PURE__ */ i("img", { src: W, alt: "logo" }),
|
|
81
|
+
addons: /* @__PURE__ */ i(
|
|
82
|
+
U,
|
|
85
83
|
{
|
|
86
84
|
formattedBlocklet: r,
|
|
87
85
|
addons: k,
|
|
88
|
-
sessionManagerProps:
|
|
89
|
-
showDomainWarningDialog:
|
|
86
|
+
sessionManagerProps: L,
|
|
87
|
+
showDomainWarningDialog: N
|
|
90
88
|
}
|
|
91
89
|
),
|
|
92
|
-
...
|
|
90
|
+
...h.headerProps
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
);
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
meta:
|
|
95
|
+
F.propTypes = {
|
|
96
|
+
meta: M,
|
|
99
97
|
// 如果当前用户没有权限访问任何导航菜单, 则自动跳转到 fallbackUrl, 默认值为 publicPath, 设置为 null 表示禁用自动跳转
|
|
100
98
|
fallbackUrl: t.string,
|
|
101
99
|
// 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
|
|
102
100
|
invalidPathFallback: t.func,
|
|
103
101
|
headerAddons: t.oneOfType([t.func, t.node]),
|
|
104
|
-
sessionManagerProps:
|
|
102
|
+
sessionManagerProps: D,
|
|
105
103
|
links: t.oneOfType([t.array, t.func]),
|
|
106
104
|
showDomainWarningDialog: t.bool
|
|
107
105
|
};
|
|
108
106
|
export {
|
|
109
|
-
|
|
107
|
+
F as default
|
|
110
108
|
};
|