@blocklet/ui-react 3.0.9 → 3.0.10

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