@blocklet/ui-react 3.0.38 → 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.
@@ -1,52 +1,52 @@
1
1
  import { jsx as i } from "react/jsx-runtime";
2
2
  import "iconify-icon";
3
- import { use as I, useMemo as b, useLayoutEffect as v } from "react";
3
+ import { use as I, useMemo as v, useLayoutEffect as w } from "react";
4
4
  import t from "prop-types";
5
5
  import { SessionContext as R } from "@arcblock/did-connect/lib/Session";
6
6
  import { useLocaleContext as T } from "@arcblock/ux/lib/Locale/context";
7
- import C from "@arcblock/ux/lib/Img";
8
- import D from "@arcblock/ux/lib/Layout/dashboard";
9
- import M from "@arcblock/ux/lib/hooks/use-blocklet-logo";
10
- import { SessionManagerProps as A, BlockletMetaProps as O } from "../types.js";
11
- import { mapRecursive as j, flatRecursive as H, matchPaths as S } from "../utils.js";
12
- import { formatBlockletInfo as E, getLocalizedNavigation as U, filterNavByRole as _, publicPath as h } from "../blocklets.js";
13
- import q from "../common/header-addons.js";
14
- import { useWalletHiddenTopbar as F } from "../common/wallet-hidden-topbar.js";
15
- function G({
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
16
  meta: s = {},
17
- fallbackUrl: a = h,
17
+ fallbackUrl: a = m,
18
18
  invalidPathFallback: l = null,
19
19
  headerAddons: k = void 0,
20
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
27
  links: c = [],
28
- showDomainWarningDialog: P = !0,
29
- ...d
28
+ showDomainWarningDialog: N = !0,
29
+ ...h
30
30
  }) {
31
- F();
32
- const f = I(R)?.session?.user, g = f?.role, { locale: x } = T() || {}, r = b(() => {
31
+ q();
32
+ const d = I(R)?.session?.user, g = d?.role, { locale: x } = T() || {}, r = v(() => {
33
33
  const e = Object.assign({}, window.blocklet, s);
34
34
  try {
35
- return E(e);
35
+ return S(e);
36
36
  } catch (n) {
37
37
  return console.error("Failed to format blocklet info", n, e), e;
38
38
  }
39
- }, [s]), { localizedNav: w, flattened: p, matchedIndex: y } = b(() => {
40
- let e = U(r?.navigation?.dashboard, x) || [];
41
- e = _(e, g), e = j(
39
+ }, [s]), { localizedNav: y, flattened: f, matchedIndex: b } = v(() => {
40
+ let e = _(r?.navigation?.dashboard, x) || [];
41
+ e = E(e, g), e = O(
42
42
  e,
43
43
  (o) => {
44
- let m = null;
45
- return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? m = /* @__PURE__ */ i(C, { src: o.icon }) : m = /* @__PURE__ */ i("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 })), {
46
46
  id: o.id,
47
47
  title: o.title,
48
48
  url: o.link,
49
- icon: m,
49
+ icon: u,
50
50
  // https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
51
51
  external: !0,
52
52
  children: o.items
@@ -54,56 +54,55 @@ function G({
54
54
  },
55
55
  "items"
56
56
  );
57
- const n = H(e).filter((o) => !!o.url), u = S(n.map((o) => o.url));
58
- return u !== -1 && (n[u].active = !0), { localizedNav: e, flattened: n, matchedIndex: u };
59
- }, [r, x, g]), W = typeof c == "function" ? c(w) : [...w, ...c], N = M({
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
60
  meta: s
61
61
  });
62
- if (v(() => {
63
- f && !p?.length && a && (window.location.href = a);
64
- }, [a]), v(() => {
65
- f && p?.length && y === -1 && l && l();
66
- }, [l, p, y]), !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)
67
67
  return null;
68
- const { appName: z } = r, B = /* @__PURE__ */ i(
69
- q,
70
- {
71
- formattedBlocklet: r,
72
- addons: k,
73
- sessionManagerProps: L,
74
- showDomainWarningDialog: P,
75
- showWizard: d.headerProps?.showWizard
76
- }
77
- );
68
+ const { appName: B } = r;
78
69
  return /* @__PURE__ */ i(
79
- D,
70
+ A,
80
71
  {
81
- title: z,
72
+ title: B,
82
73
  fullWidth: !0,
83
74
  sidebarWidth: 128,
84
75
  legacy: !1,
85
- links: W,
86
- ...d,
76
+ links: P,
77
+ ...h,
87
78
  headerProps: {
88
- homeLink: h,
89
- logo: /* @__PURE__ */ i("img", { src: N, alt: "logo" }),
90
- addons: B,
91
- ...d.headerProps
79
+ homeLink: m,
80
+ logo: /* @__PURE__ */ i("img", { src: W, alt: "logo" }),
81
+ addons: /* @__PURE__ */ i(
82
+ U,
83
+ {
84
+ formattedBlocklet: r,
85
+ addons: k,
86
+ sessionManagerProps: L,
87
+ showDomainWarningDialog: N
88
+ }
89
+ ),
90
+ ...h.headerProps
92
91
  }
93
92
  }
94
93
  );
95
94
  }
96
- G.propTypes = {
97
- meta: O,
95
+ F.propTypes = {
96
+ meta: M,
98
97
  // 如果当前用户没有权限访问任何导航菜单, 则自动跳转到 fallbackUrl, 默认值为 publicPath, 设置为 null 表示禁用自动跳转
99
98
  fallbackUrl: t.string,
100
99
  // 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
101
100
  invalidPathFallback: t.func,
102
101
  headerAddons: t.oneOfType([t.func, t.node]),
103
- sessionManagerProps: A,
102
+ sessionManagerProps: D,
104
103
  links: t.oneOfType([t.array, t.func]),
105
104
  showDomainWarningDialog: t.bool
106
105
  };
107
106
  export {
108
- G as default
107
+ F as default
109
108
  };
@@ -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), y = A({ key: "md" }), h = e.some((t) => t.items?.length), k = !y && h && j(u) && u > 1, p = ({ label: t, link: o, icon: i, render: a, props: n }) => {
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
- }, w = $(() => 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) => {
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: w })
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};
@@ -18,7 +18,6 @@ type HeaderProps = {
18
18
  align?: 'left' | 'right';
19
19
  maxWidth?: false | Breakpoint;
20
20
  showDomainWarningDialog?: boolean;
21
- showWizard?: boolean;
22
21
  };
23
22
  declare const _default: import('react').ComponentType<HeaderProps & Omit<BoxProps, keyof HeaderProps>>;
24
23
  export default _default;
@@ -1,21 +1,21 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { useMemo as v } from "react";
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useMemo as f } from "react";
3
3
  import { useMemoizedFn as N } from "ahooks";
4
- import { withErrorBoundary as H } from "react-error-boundary";
5
- import { ErrorFallback as y } from "@arcblock/ux/lib/ErrorBoundary";
6
- import { styled as C, useTheme as T, deepmerge as _, ThemeProvider as E } from "@arcblock/ux/lib/Theme";
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
7
  import { ResponsiveHeader as B } from "@arcblock/ux/lib/Header";
8
- import F, { Products as L } from "@arcblock/ux/lib/NavMenu";
9
- import { useLocaleContext as P } from "@arcblock/ux/lib/Locale/context";
10
- import { translate as R } from "@arcblock/ux/lib/Locale/util";
11
- import z from "@arcblock/ux/lib/hooks/use-blocklet-logo";
12
- import A from "lodash/omit";
13
- import M from "lodash/isFinite";
14
- import W from "clsx";
15
- import j from "../Icon/index.js";
16
- import { mapRecursive as S, flatRecursive as U, matchPaths as K } from "../utils.js";
17
- import { formatBlockletInfo as O, getLocalizedNavigation as q, publicPath as D } from "../blocklets.js";
18
- import G from "../common/header-addons.js";
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
+ import W from "../Icon/index.js";
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
+ import D from "../common/header-addons.js";
19
19
  import { useWalletHiddenTopbar as J } from "../common/wallet-hidden-topbar.js";
20
20
  import Q from "../libs/with-hide-when-embed.js";
21
21
  const V = {
@@ -25,119 +25,129 @@ const V = {
25
25
  zh: {
26
26
  products: "产品"
27
27
  }
28
- }, X = (e) => {
29
- if (!e?.length)
28
+ }, X = (r) => {
29
+ if (!r?.length)
30
30
  return { navItems: [], activeId: null };
31
- let r = 1;
32
- const i = S(e, (o) => {
33
- const d = o.icon ? /* @__PURE__ */ n(j, { icon: o.icon }) : null;
34
- if (o.items)
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: `${r++}`,
37
- label: o.title,
38
- icon: d,
39
- children: o.items
36
+ id: `${t++}`,
37
+ label: e.title,
38
+ icon: i,
39
+ children: e.items
40
40
  };
41
- let l = {};
42
- return (o.link?.startsWith("http") || o.link?.startsWith("//")) && (l = {
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: `${r++}`,
47
- label: /* @__PURE__ */ n("a", { href: o.link, ...l, children: o.title }),
48
- icon: d,
49
- description: o.description,
50
- link: o.link
46
+ id: `${t++}`,
47
+ label: /* @__PURE__ */ a("a", { href: e.link, ...s, children: e.title }),
48
+ icon: i,
49
+ description: e.description,
50
+ link: e.link
51
51
  };
52
- }, "items"), a = U(i), s = K(a.map((o) => o.link));
53
- return { navItems: i, activeId: s >= 0 ? a[s].id : null };
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
55
  function Y({
56
- meta: e = {},
57
- addons: r = void 0,
58
- sessionManagerProps: u = {
56
+ meta: r = {},
57
+ addons: t = void 0,
58
+ sessionManagerProps: h = {
59
59
  showRole: !0
60
60
  },
61
- homeLink: i = D,
62
- theme: a = void 0,
63
- hideNavMenu: s = !1,
64
- showDomainWarningDialog: o = !0,
65
- showWizard: d = !1,
66
- ...l
61
+ homeLink: c = q,
62
+ theme: l = void 0,
63
+ hideNavMenu: p = !1,
64
+ showDomainWarningDialog: e = !0,
65
+ ...i
67
66
  }) {
68
67
  J();
69
- const h = T(), { locale: b } = P() || {}, x = N((t, f = {}) => R(V, t, b, "en", f)), m = v(() => {
70
- const t = Object.assign({}, window.blocklet, e);
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);
71
70
  try {
72
- return O(t);
73
- } catch (f) {
74
- return console.error("Failed to format blocklet info", f, t), t;
71
+ return G(o);
72
+ } catch (n) {
73
+ return console.error("Failed to format blocklet info", n, o), o;
75
74
  }
76
- }, [e]), c = v(() => _(h, a), [h, a]), I = z({
77
- meta: e,
78
- theme: a
79
- });
80
- if (!m.appName)
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)
81
92
  return null;
82
- const w = q(m?.navigation?.header, b), g = X(w), { navItems: p, activeId: $ } = g, k = parseInt(window.blocklet?.USE_ARCBLOCK_THEME, 10);
83
- return M(k) && p.splice(k, 0, {
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, {
84
95
  label: x("products"),
85
96
  // eslint-disable-next-line react/no-unstable-nested-components
86
- children: ({ isOpen: t }) => /* @__PURE__ */ n(L, { isOpen: t })
87
- }), /* @__PURE__ */ n(E, { theme: c, children: /* @__PURE__ */ n(
97
+ children: () => /* @__PURE__ */ a(R, { type: k })
98
+ }), /* @__PURE__ */ a(A, { theme: m, children: /* @__PURE__ */ a(
88
99
  Z,
89
100
  {
90
- homeLink: i,
91
- logo: /* @__PURE__ */ n("img", { src: I, alt: "logo" }),
101
+ homeLink: c,
102
+ logo: /* @__PURE__ */ a("img", { src: y, alt: "logo" }),
92
103
  addons: (
93
104
  // @ts-ignore
94
- /* @__PURE__ */ n(
95
- G,
105
+ /* @__PURE__ */ a(
106
+ D,
96
107
  {
97
- formattedBlocklet: m,
98
- addons: typeof r == "function" ? (t) => r(t, { navigation: g }) : r,
99
- sessionManagerProps: u,
100
- showDomainWarningDialog: o,
101
- showWizard: d
108
+ formattedBlocklet: d,
109
+ addons: typeof t == "function" ? (o) => t(o, { navigation: v }) : t,
110
+ sessionManagerProps: h,
111
+ showDomainWarningDialog: e
102
112
  }
103
113
  )
104
114
  ),
105
- ...A(l, ["bordered"]),
106
- $bordered: l?.bordered,
107
- $bgcolor: c.palette.background.default,
108
- className: W("blocklet__header", l.className),
109
- children: s || !p?.length ? null : ({ isMobile: t }) => (
115
+ ...P(i, ["bordered"]),
116
+ $bordered: i?.bordered,
117
+ $bgcolor: m.palette.background.default,
118
+ className: z("blocklet__header", i.className),
119
+ children: p || !u?.length ? null : ({ isMobile: o }) => (
110
120
  // @ts-ignore
111
- /* @__PURE__ */ n(
112
- F,
121
+ /* @__PURE__ */ a(
122
+ L,
113
123
  {
114
- mode: t ? "inline" : "horizontal",
115
- activeId: $,
116
- items: p,
124
+ mode: o ? "inline" : "horizontal",
125
+ activeId: E,
126
+ items: u,
117
127
  className: "header-nav",
118
128
  bgColor: "transparent",
119
- textColor: c.palette.grey[500],
120
- activeTextColor: c.palette.text.primary
129
+ textColor: m.palette.grey[500],
130
+ activeTextColor: m.palette.text.primary
121
131
  }
122
132
  )
123
133
  )
124
134
  }
125
135
  ) });
126
136
  }
127
- const Z = C(B)`
128
- ${({ $bgcolor: e }) => `background-color: ${e || "#fff"};`}
137
+ const Z = H(B)`
138
+ ${({ $bgcolor: r }) => `background-color: ${r || "#fff"};`}
129
139
  .header-logo {
130
140
  min-width: 44px;
131
141
  }
132
- ${({ $bordered: e, theme: r }) => e ? `border-bottom: 1px solid ${r.palette.divider};` : ""}
133
- ${(e) => e.theme.breakpoints.down("md")} {
142
+ ${({ $bordered: r, theme: t }) => r ? `border-bottom: 1px solid ${t.palette.divider};` : ""}
143
+ ${(r) => r.theme.breakpoints.down("md")} {
134
144
  .header-logo {
135
145
  min-width: 32px;
136
146
  }
137
147
  }
138
- `, $o = H(Q(Y), {
139
- FallbackComponent: y
148
+ `, ye = $(Q(Y), {
149
+ FallbackComponent: C
140
150
  });
141
151
  export {
142
- $o as default
152
+ ye as default
143
153
  };
@@ -1,13 +1,12 @@
1
1
  import { default as PropTypes } from 'prop-types';
2
2
  import { SessionManagerProps } from '../types';
3
- declare function HeaderAddons({ formattedBlocklet, addons, showDomainWarningDialog, sessionManagerProps, showWizard, }: {
3
+ declare function HeaderAddons({ formattedBlocklet, addons, showDomainWarningDialog, sessionManagerProps, }: {
4
4
  formattedBlocklet: any;
5
5
  addons?: null | undefined;
6
6
  showDomainWarningDialog?: boolean | undefined;
7
7
  sessionManagerProps?: {
8
8
  showRole: boolean;
9
9
  } | undefined;
10
- showWizard?: boolean | undefined;
11
10
  }): import('react').FunctionComponentElement<import('react').FragmentProps>;
12
11
  declare namespace HeaderAddons {
13
12
  namespace propTypes {
@@ -15,7 +14,6 @@ declare namespace HeaderAddons {
15
14
  export let addons: PropTypes.Requireable<NonNullable<((...args: any[]) => any) | PropTypes.ReactNodeLike>>;
16
15
  export { SessionManagerProps as sessionManagerProps };
17
16
  export let showDomainWarningDialog: PropTypes.Requireable<boolean>;
18
- export let showWizard: PropTypes.Requireable<boolean>;
19
17
  }
20
18
  }
21
19
  export default HeaderAddons;