@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,132 +1,71 @@
1
- import { jsx as e, Fragment as x } from "react/jsx-runtime";
1
+ import { jsx as s, Fragment as v } from "react/jsx-runtime";
2
2
  import "iconify-icon";
3
- import { useState as h, useEffect as L, use as N, createElement as W } from "react";
4
- import s from "prop-types";
5
- import { Tooltip as M, IconButton as R } from "@mui/material";
6
- import B from "@iconify-icons/tabler/wand";
7
- import { SessionContext as D } from "@arcblock/did-connect/lib/Session";
8
- import E from "@arcblock/ux/lib/SessionUser";
9
- import O from "@arcblock/ux/lib/SessionBlocklet";
10
- import P from "@arcblock/ux/lib/Locale/selector";
11
- import { useLocaleContext as g } from "@arcblock/ux/lib/Locale/context";
12
- import j from "@arcblock/ux/lib/Config/theme-mode-toggle";
13
- import { SessionManagerProps as F } from "../types.js";
14
- import { getLocalizedNavigation as I, filterNavByRole as q } from "../blocklets.js";
15
- import H from "./notification-addon.js";
16
- import U from "./domain-warning.js";
17
- import V from "./wizard-modal.js";
18
- const $ = () => !!(window?.blocklet?.navigation ?? []).find((i) => i.id === "/userCenter/notification");
19
- function G({
20
- formattedBlocklet: m,
21
- addons: i = null,
22
- showDomainWarningDialog: y = !0,
23
- sessionManagerProps: w = { showRole: !0 },
24
- showWizard: T = !1
3
+ import r from "prop-types";
4
+ import { use as b, createElement as k } from "react";
5
+ import { SessionContext as w } from "@arcblock/did-connect/lib/Session";
6
+ import L from "@arcblock/ux/lib/Config/theme-mode-toggle";
7
+ import { useLocaleContext as N } from "@arcblock/ux/lib/Locale/context";
8
+ import T from "@arcblock/ux/lib/Locale/selector";
9
+ import C from "@arcblock/ux/lib/SessionBlocklet";
10
+ import R from "@arcblock/ux/lib/SessionUser";
11
+ import { getLocalizedNavigation as S, filterNavByRole as M } from "../blocklets.js";
12
+ import { SessionManagerProps as B } from "../types.js";
13
+ import D from "./domain-warning.js";
14
+ import P from "./notification-addon.js";
15
+ const j = () => !!(window?.blocklet?.navigation ?? []).find((o) => o.id === "/userCenter/notification");
16
+ function x({
17
+ formattedBlocklet: l,
18
+ addons: o = null,
19
+ showDomainWarningDialog: m = !0,
20
+ sessionManagerProps: u = { showRole: !0 }
25
21
  }) {
26
- const [d, p] = h(!1), [t, c] = h(!1), { t: b } = g();
27
- L(() => {
28
- let o;
29
- return t && (o = setTimeout(() => {
30
- c(!1);
31
- }, 3e3)), () => {
32
- o && clearTimeout(o);
33
- };
34
- }, [t]);
35
- const n = N(D), { locale: r, languages: z } = g() || {}, { enableConnect: A = !0, enableLocale: k = !0 } = m, v = !!n?.session?.user;
36
- let f = I(m?.navigation?.sessionManager, r) || [];
37
- f = q(f, n?.session?.user?.role);
38
- const u = (() => {
39
- if (i && typeof i != "function")
40
- return Array.isArray(i) ? i : [i];
41
- let o = [];
42
- if ($() && o.push(/* @__PURE__ */ e(H, { session: n.session }, "notification-addon")), k && r && z.length > 1 && o.push(/* @__PURE__ */ e(P, { showText: !1 }, "locale-selector")), o.push(/* @__PURE__ */ e(j, {}, "theme-mode-toggle")), T && o.push(
43
- /* @__PURE__ */ e(
44
- M,
45
- {
46
- title: b("setup.wizardTooltip"),
47
- open: t,
48
- placement: "bottom",
49
- arrow: !0,
50
- children: /* @__PURE__ */ e(
51
- R,
52
- {
53
- size: "small",
54
- onClick: () => {
55
- p(!0), c(!1);
56
- },
57
- sx: {
58
- display: { xs: "none", md: "flex" },
59
- color: "text.secondary",
60
- ...t && {
61
- backgroundColor: "action.hover",
62
- "@keyframes pulse": {
63
- "0%": { opacity: 0.8 },
64
- "50%": { opacity: 0.5 },
65
- "100%": { opacity: 0.8 }
66
- },
67
- animation: "pulse 2s infinite"
68
- }
69
- },
70
- children: /* @__PURE__ */ e("iconify-icon", { icon: B, height: 20 })
71
- }
72
- )
73
- },
74
- `wizard-toggle-${t}`
75
- ),
76
- /* @__PURE__ */ e(
77
- V,
78
- {
79
- show: d,
80
- onChangeVisible: (a) => {
81
- p(a), !a && d && c(!0);
82
- },
83
- onFinished: () => {
84
- p(!1), c(!1);
85
- }
86
- },
87
- "wizard-modal"
88
- )
89
- ), A && n) {
90
- const a = [];
91
- v && (f ? f.slice(0, 5) : []).forEach((l) => {
92
- a.push({
93
- label: l.title,
94
- icon: l.icon ? /* @__PURE__ */ e("iconify-icon", { icon: l.icon, height: 24, style: { marginRight: 8 } }) : null,
22
+ const n = b(w), { locale: i, languages: p } = N() || {}, { enableConnect: g = !0, enableLocale: d = !0 } = l, h = !!n?.session?.user;
23
+ let a = S(l?.navigation?.sessionManager, i) || [];
24
+ a = M(a, n?.session?.user?.role);
25
+ const c = (() => {
26
+ if (o && typeof o != "function")
27
+ return Array.isArray(o) ? o : [o];
28
+ let e = [];
29
+ if (j() && e.push(/* @__PURE__ */ s(P, { session: n.session }, "notification-addon")), d && i && p.length > 1 && e.push(/* @__PURE__ */ s(T, { showText: !1 }, "locale-selector")), e.push(/* @__PURE__ */ s(L, {}, "theme-mode-toggle")), g && n) {
30
+ const f = [];
31
+ h && (a ? a.slice(0, 5) : []).forEach((t) => {
32
+ f.push({
33
+ label: t.title,
34
+ icon: t.icon ? /* @__PURE__ */ s("iconify-icon", { icon: t.icon, height: 24, style: { marginRight: 8 } }) : null,
95
35
  component: "a",
96
- href: l.link,
97
- key: l.link
36
+ href: t.link,
37
+ key: t.link
98
38
  });
99
- }), o.push(/* @__PURE__ */ e(O, { session: n.session, locale: r }, "session-blocklet")), o.push(
100
- /* @__PURE__ */ e(
101
- E,
39
+ }), e.push(/* @__PURE__ */ s(C, { session: n.session, locale: i }, "session-blocklet")), e.push(
40
+ /* @__PURE__ */ s(
41
+ R,
102
42
  {
103
43
  session: n.session,
104
- locale: r,
105
- menu: a,
44
+ locale: i,
45
+ menu: f,
106
46
  showRole: !0,
107
- ...w
47
+ ...u
108
48
  },
109
49
  "session-user"
110
50
  )
111
51
  );
112
52
  }
113
- return typeof i == "function" && (o = i(o) || []), o;
114
- })(), C = Array.isArray(u) ? u : [u], S = [
115
- y ? /* @__PURE__ */ e(U, { session: n?.session, locale: r }) : null,
116
- ...C
53
+ return typeof o == "function" && (e = o(e) || []), e;
54
+ })(), y = Array.isArray(c) ? c : [c], A = [
55
+ m ? /* @__PURE__ */ s(D, { session: n?.session, locale: i }) : null,
56
+ ...y
117
57
  ].filter(Boolean);
118
- return W(x, null, ...S);
58
+ return k(v, null, ...A);
119
59
  }
120
- G.propTypes = {
121
- formattedBlocklet: s.object.isRequired,
60
+ x.propTypes = {
61
+ formattedBlocklet: r.object.isRequired,
122
62
  // 需要考虑 定制的 addons 与内置的 连接钱包/选择语言 addons 共存的情况
123
63
  // - PropTypes.func: 可以把自定义 addons 插在 session-manager 或 locale-selector (如果存在的话) 前/中/后
124
64
  // - PropTypes.node: 将 addons 原样传给 UX Header 组件
125
- addons: s.oneOfType([s.func, s.node]),
126
- sessionManagerProps: F,
127
- showDomainWarningDialog: s.bool,
128
- showWizard: s.bool
65
+ addons: r.oneOfType([r.func, r.node]),
66
+ sessionManagerProps: B,
67
+ showDomainWarningDialog: r.bool
129
68
  };
130
69
  export {
131
- G as default
70
+ x as default
132
71
  };
@@ -1,14 +1,16 @@
1
1
  import { default as PropTypes } from 'prop-types';
2
- declare function WizardModal({ onFinished, show, onChangeVisible }: {
2
+ declare function WizardModal({ onFinished, show, onChangeVisible, loadingText, }: {
3
3
  onFinished?: (() => void) | undefined;
4
4
  show?: boolean | undefined;
5
5
  onChangeVisible?: (() => void) | undefined;
6
+ loadingText?: string | undefined;
6
7
  }): import("react/jsx-runtime").JSX.Element | null;
7
8
  declare namespace WizardModal {
8
9
  namespace propTypes {
9
10
  let onFinished: PropTypes.Requireable<(...args: any[]) => any>;
10
11
  let show: PropTypes.Requireable<boolean>;
11
12
  let onChangeVisible: PropTypes.Requireable<(...args: any[]) => any>;
13
+ let loadingText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
12
14
  }
13
15
  }
14
16
  export default WizardModal;
@@ -1,46 +1,51 @@
1
- import { jsxs as I, jsx as m } from "react/jsx-runtime";
2
- import { useLocaleContext as U } from "@arcblock/ux/lib/Locale/context";
3
- import { useTheme as W, useMediaQuery as P, Dialog as T, Box as j, CircularProgress as E } from "@mui/material";
4
- import p from "prop-types";
5
- import { useState as w, useRef as g, useEffect as a } from "react";
6
- import { withQuery as M, joinURL as A } from "ufo";
7
- const h = "/.well-known/service/wizard/bind-account";
8
- function D({ onFinished: b = () => {
9
- }, show: o = !1, onChangeVisible: x = () => {
10
- } }) {
11
- const [r, n] = w(o), [i, s] = w(!1), [y, l] = w(() => localStorage.getItem("wizard-current-url") || h), z = g(b), c = g(), d = g(null), { locale: R } = U(), C = W(), u = P(C.breakpoints.down("sm"));
12
- if (z.current = b, c.current = () => {
13
- if (d.current?.contentWindow)
1
+ import { jsxs as x, jsx as i } from "react/jsx-runtime";
2
+ import { useLocaleContext as P } from "@arcblock/ux/lib/Locale/context";
3
+ import { useTheme as T, useMediaQuery as j, Dialog as D, Box as R, CircularProgress as E, Typography as M } from "@mui/material";
4
+ import a from "prop-types";
5
+ import { useState as g, useRef as h, useEffect as s } from "react";
6
+ import { withQuery as A, joinURL as F } from "ufo";
7
+ const b = "/.well-known/service/wizard/bind-account";
8
+ function B({
9
+ onFinished: y = () => {
10
+ },
11
+ show: o = !1,
12
+ onChangeVisible: v = () => {
13
+ },
14
+ loadingText: l = ""
15
+ }) {
16
+ const [r, n] = g(o), [c, d] = g(!1), [C, u] = g(() => localStorage.getItem("wizard-current-url") || b), z = h(y), f = h(), m = h(null), { locale: I } = P(), L = T(), p = j(L.breakpoints.down("sm"));
17
+ if (z.current = y, f.current = () => {
18
+ if (m.current?.contentWindow)
14
19
  try {
15
- const t = new URL(d.current.contentWindow.location.href).pathname;
16
- localStorage.setItem("wizard-current-url", t), l(t);
20
+ const t = new URL(m.current.contentWindow.location.href).pathname;
21
+ localStorage.setItem("wizard-current-url", t), u(t);
17
22
  } catch (e) {
18
- l(h), console.warn("Failed to save wizard URL:", e);
23
+ u(b), console.warn("Failed to save wizard URL:", e);
19
24
  }
20
- localStorage.setItem("wizard-completed", "true"), n(!1), x(!1);
21
- }, a(() => {
25
+ localStorage.setItem("wizard-completed", "true"), n(!1), v(!1);
26
+ }, s(() => {
22
27
  o !== r && n(o);
23
- }, [o]), a(() => {
24
- !r && i && s(!1);
25
- }, [r]), a(() => {
28
+ }, [o]), s(() => {
29
+ !r && c && d(!1);
30
+ }, [r]), s(() => {
26
31
  const e = (t) => {
27
32
  if (t.origin !== window.location.origin)
28
33
  return;
29
- const { type: L, data: S } = t.data || {};
30
- switch (L) {
34
+ const { type: k, data: U } = t.data || {};
35
+ switch (k) {
31
36
  case "wizard.loaded":
32
- s(!0);
37
+ d(!0);
33
38
  break;
34
39
  case "wizard.finished": {
35
- n(!1), l(h), localStorage.removeItem("wizard-current-url"), localStorage.setItem("wizard-completed", "true");
36
- const f = z.current?.(S);
37
- f instanceof Promise ? f.then((k) => {
38
- k !== !1 && window.location.reload();
39
- }) : f !== !1 && window.location.reload();
40
+ n(!1), u(b), localStorage.removeItem("wizard-current-url"), localStorage.setItem("wizard-completed", "true");
41
+ const w = z.current?.(U);
42
+ w instanceof Promise ? w.then((W) => {
43
+ W !== !1 && window.location.reload();
44
+ }) : w !== !1 && window.location.reload();
40
45
  break;
41
46
  }
42
47
  case "wizard.close": {
43
- c.current();
48
+ f.current();
44
49
  break;
45
50
  }
46
51
  }
@@ -48,21 +53,21 @@ function D({ onFinished: b = () => {
48
53
  return window.addEventListener("message", e), () => {
49
54
  window.removeEventListener("message", e);
50
55
  };
51
- }, []), a(() => {
56
+ }, []), s(() => {
52
57
  localStorage.getItem("wizard-completed") || n(!0);
53
58
  }, []), !r)
54
59
  return null;
55
- const v = M(A(window.location.origin, y), {
56
- locale: R
60
+ const S = A(F(window.location.origin, C), {
61
+ locale: I
57
62
  });
58
- return /* @__PURE__ */ I(
59
- T,
63
+ return /* @__PURE__ */ x(
64
+ D,
60
65
  {
61
66
  open: r,
62
- onClose: () => c.current(),
67
+ onClose: () => f.current(),
63
68
  fullWidth: !0,
64
- maxWidth: u ? !1 : "md",
65
- fullScreen: u,
69
+ maxWidth: p ? !1 : "md",
70
+ fullScreen: p,
66
71
  slotProps: {
67
72
  paper: {
68
73
  sx: {
@@ -70,7 +75,7 @@ function D({ onFinished: b = () => {
70
75
  borderRadius: 0,
71
76
  position: "relative",
72
77
  overflow: "hidden",
73
- ...u ? { borderRadius: 0 } : {
78
+ ...p ? { borderRadius: 0 } : {
74
79
  borderRadius: 1,
75
80
  height: "max(800px, 80vh)"
76
81
  }
@@ -83,11 +88,11 @@ function D({ onFinished: b = () => {
83
88
  }
84
89
  },
85
90
  children: [
86
- /* @__PURE__ */ m(
91
+ /* @__PURE__ */ i(
87
92
  "iframe",
88
93
  {
89
- ref: d,
90
- src: v,
94
+ ref: m,
95
+ src: S,
91
96
  title: "Setup Wizard",
92
97
  style: {
93
98
  width: "100%",
@@ -95,14 +100,14 @@ function D({ onFinished: b = () => {
95
100
  border: 0,
96
101
  padding: 0,
97
102
  margin: 0,
98
- opacity: i ? 1 : 0,
103
+ opacity: c ? 1 : 0,
99
104
  transition: "opacity 0.3s ease-in-out"
100
105
  },
101
- onLoad: () => s(!0)
106
+ onLoad: () => d(!0)
102
107
  }
103
108
  ),
104
- i ? null : /* @__PURE__ */ m(
105
- j,
109
+ c ? null : /* @__PURE__ */ i(
110
+ R,
106
111
  {
107
112
  sx: {
108
113
  position: "absolute",
@@ -115,18 +120,22 @@ function D({ onFinished: b = () => {
115
120
  alignItems: "center",
116
121
  bgcolor: "background.paper"
117
122
  },
118
- children: /* @__PURE__ */ m(E, {})
123
+ children: /* @__PURE__ */ x(R, { sx: { display: "flex", alignItems: "center", flexDirection: "column", gap: 1 }, children: [
124
+ /* @__PURE__ */ i(E, {}),
125
+ typeof l == "string" ? /* @__PURE__ */ i(M, { variant: "body1", children: l }) : l
126
+ ] })
119
127
  }
120
128
  )
121
129
  ]
122
130
  }
123
131
  );
124
132
  }
125
- D.propTypes = {
126
- onFinished: p.func,
127
- show: p.bool,
128
- onChangeVisible: p.func
133
+ B.propTypes = {
134
+ onFinished: a.func,
135
+ show: a.bool,
136
+ onChangeVisible: a.func,
137
+ loadingText: a.node
129
138
  };
130
139
  export {
131
- D as default
140
+ B as default
132
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.0.38",
3
+ "version": "3.0.41",
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.46",
37
37
  "@abtnode/util": "^1.16.46",
38
- "@arcblock/bridge": "3.0.38",
39
- "@arcblock/icons": "3.0.38",
40
- "@arcblock/react-hooks": "3.0.38",
38
+ "@arcblock/bridge": "3.0.41",
39
+ "@arcblock/icons": "3.0.41",
40
+ "@arcblock/react-hooks": "3.0.41",
41
41
  "@arcblock/ws": "^1.21.0",
42
42
  "@blocklet/constant": "^1.16.46",
43
43
  "@blocklet/did-space-react": "^1.1.11",
@@ -91,5 +91,5 @@
91
91
  "jest": "^29.7.0",
92
92
  "unbuild": "^2.0.0"
93
93
  },
94
- "gitHead": "643c8e01d5f5cb421b3315d4625177d1ccfa1ea1"
94
+ "gitHead": "e4bf7c421b39bfc7b969653e580047629e5338b5"
95
95
  }
@@ -129,7 +129,6 @@ function Dashboard({
129
129
  addons={headerAddons}
130
130
  sessionManagerProps={sessionManagerProps}
131
131
  showDomainWarningDialog={showDomainWarningDialog}
132
- showWizard={rest.headerProps?.showWizard}
133
132
  />
134
133
  );
135
134
 
@@ -4,6 +4,7 @@ import SocialMediaIcons from './demo/social-media-icons';
4
4
  import Copyright from './demo/copyright';
5
5
  import Footer from './demo/footer';
6
6
  import ArcblockSite from './demo/arcblock-site';
7
+ import AigneSite from './demo/aigne-site';
7
8
 
8
9
  export default {
9
10
  title: 'Blocklet-UI-React/Footer',
@@ -29,4 +30,4 @@ ArcblockSite.argTypes = {
29
30
  locale: { control: 'select', options: ['en', 'zh'] },
30
31
  };
31
32
 
32
- export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite };
33
+ export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite, AigneSite };
@@ -193,6 +193,7 @@ const Root = styled('div')`
193
193
  position: relative;
194
194
  padding: 6px 8px;
195
195
  font-size: 14px;
196
+ white-space: nowrap;
196
197
  &--new::after {
197
198
  content: 'New';
198
199
  color: ${({ theme }) => theme.palette.info.main};
@@ -4,7 +4,7 @@ import { withErrorBoundary } from 'react-error-boundary';
4
4
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
5
5
  import { styled, useTheme, deepmerge, ThemeProvider } from '@arcblock/ux/lib/Theme';
6
6
  import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
7
- import NavMenu, { Products } from '@arcblock/ux/lib/NavMenu';
7
+ import NavMenu, { Products, ProductsType } from '@arcblock/ux/lib/NavMenu';
8
8
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
9
  import { translate } from '@arcblock/ux/lib/Locale/util';
10
10
  import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
@@ -93,7 +93,6 @@ type HeaderProps = {
93
93
  align?: 'left' | 'right';
94
94
  maxWidth?: false | Breakpoint;
95
95
  showDomainWarningDialog?: boolean;
96
- showWizard?: boolean;
97
96
  };
98
97
 
99
98
  /**
@@ -111,7 +110,6 @@ function Header({
111
110
  theme: themeOverrides = undefined,
112
111
  hideNavMenu = false,
113
112
  showDomainWarningDialog = true,
114
- showWizard = false,
115
113
  ...rest
116
114
  }: HeaderProps & Omit<BoxProps, keyof HeaderProps>) {
117
115
  useWalletHiddenTopbar();
@@ -135,6 +133,34 @@ function Header({
135
133
  theme: themeOverrides,
136
134
  });
137
135
 
136
+ // 显示 Products 导航
137
+ const { productsOrder, productsType } = useMemo<{
138
+ productsOrder: number | null;
139
+ productsType: ProductsType | null;
140
+ }>(() => {
141
+ let { USE_ARCBLOCK_THEME, USE_AIGNE_THEME } = formattedBlocklet;
142
+ USE_ARCBLOCK_THEME = parseInt(USE_ARCBLOCK_THEME, 10);
143
+ USE_AIGNE_THEME = parseInt(USE_AIGNE_THEME, 10);
144
+
145
+ if (isFinite(USE_AIGNE_THEME)) {
146
+ return {
147
+ productsOrder: USE_AIGNE_THEME,
148
+ productsType: 'AIGNE',
149
+ };
150
+ }
151
+ if (isFinite(USE_ARCBLOCK_THEME)) {
152
+ return {
153
+ productsOrder: USE_ARCBLOCK_THEME,
154
+ productsType: 'ARCBLOCK',
155
+ };
156
+ }
157
+
158
+ return {
159
+ productsOrder: null,
160
+ productsType: null,
161
+ };
162
+ }, [formattedBlocklet]);
163
+
138
164
  if (!formattedBlocklet.appName) {
139
165
  return null;
140
166
  }
@@ -142,13 +168,11 @@ function Header({
142
168
  const parsedNavigation = parseNavigation(navigation);
143
169
  const { navItems, activeId } = parsedNavigation;
144
170
 
145
- // 显示 Products 导航
146
- const productsNavOrder = parseInt(window.blocklet?.USE_ARCBLOCK_THEME, 10);
147
- if (isFinite(productsNavOrder)) {
148
- navItems.splice(productsNavOrder, 0, {
171
+ if (productsType && Number.isInteger(productsOrder)) {
172
+ navItems.splice(productsOrder, 0, {
149
173
  label: t('products'),
150
174
  // eslint-disable-next-line react/no-unstable-nested-components
151
- children: ({ isOpen }: { isOpen: boolean }) => <Products isOpen={isOpen} />,
175
+ children: () => <Products type={productsType} />,
152
176
  });
153
177
  }
154
178
 
@@ -166,7 +190,6 @@ function Header({
166
190
  // @ts-ignore
167
191
  sessionManagerProps={sessionManagerProps}
168
192
  showDomainWarningDialog={showDomainWarningDialog}
169
- showWizard={showWizard}
170
193
  />
171
194
  );
172
195
 
@@ -1,24 +1,21 @@
1
1
  import 'iconify-icon';
2
2
 
3
- import { use, createElement, useState, useEffect } from 'react';
4
3
  import PropTypes from 'prop-types';
5
- import { IconButton, Tooltip } from '@mui/material';
6
- import WandIcon from '@iconify-icons/tabler/wand';
4
+ import { createElement, use } from 'react';
7
5
 
8
6
  // FIXME: 直接从 react 中 import Fragment 可能会在 vite 下出错,先暂时从 react/jsx-runtime 导入 Fragment 来跳过这个问题
9
- import { Fragment } from 'react/jsx-runtime';
10
7
  import { SessionContext } from '@arcblock/did-connect/lib/Session';
11
- import SessionUser from '@arcblock/ux/lib/SessionUser';
12
- import SessionBlocklet from '@arcblock/ux/lib/SessionBlocklet';
13
- import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
14
- import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
15
8
  import ThemeModeToggle from '@arcblock/ux/lib/Config/theme-mode-toggle';
9
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
10
+ import LocaleSelector from '@arcblock/ux/lib/Locale/selector';
11
+ import SessionBlocklet from '@arcblock/ux/lib/SessionBlocklet';
12
+ import SessionUser from '@arcblock/ux/lib/SessionUser';
13
+ import { Fragment } from 'react/jsx-runtime';
16
14
 
15
+ import { filterNavByRole, getLocalizedNavigation } from '../blocklets';
17
16
  import { SessionManagerProps } from '../types';
18
- import { getLocalizedNavigation, filterNavByRole } from '../blocklets';
19
- import NotificationAddon from './notification-addon';
20
17
  import DomainWarning from './domain-warning';
21
- import WizardModal from './wizard-modal';
18
+ import NotificationAddon from './notification-addon';
22
19
 
23
20
  const hasNotification = () => {
24
21
  const navigations = window?.blocklet?.navigation ?? [];
@@ -31,25 +28,7 @@ export default function HeaderAddons({
31
28
  addons = null,
32
29
  showDomainWarningDialog = true,
33
30
  sessionManagerProps = { showRole: true },
34
- showWizard = false,
35
31
  }) {
36
- const [wizardOpen, setWizardOpen] = useState(false);
37
- const [showTooltip, setShowTooltip] = useState(false);
38
- const { t } = useLocaleContext();
39
-
40
- // 处理 tooltip 倒计时
41
- useEffect(() => {
42
- let timer;
43
- if (showTooltip) {
44
- timer = setTimeout(() => {
45
- setShowTooltip(false);
46
- }, 3000); // 3秒后自动隐藏
47
- }
48
- return () => {
49
- if (timer) clearTimeout(timer);
50
- };
51
- }, [showTooltip]);
52
-
53
32
  const sessionCtx = use(SessionContext);
54
33
  const { locale, languages } = useLocaleContext() || {};
55
34
  const { enableConnect = true, enableLocale = true } = formattedBlocklet;
@@ -77,54 +56,6 @@ export default function HeaderAddons({
77
56
  // 切换明暗主题
78
57
  addonsArray.push(<ThemeModeToggle key="theme-mode-toggle" />);
79
58
 
80
- // Wizard 开关
81
- if (showWizard) {
82
- addonsArray.push(
83
- <Tooltip
84
- key={`wizard-toggle-${showTooltip}`}
85
- title={t('setup.wizardTooltip')}
86
- open={showTooltip}
87
- placement="bottom"
88
- arrow>
89
- <IconButton
90
- size="small"
91
- onClick={() => {
92
- setWizardOpen(true);
93
- setShowTooltip(false); // 点击后隐藏 tooltip
94
- }}
95
- sx={{
96
- display: { xs: 'none', md: 'flex' },
97
- color: 'text.secondary',
98
- ...(showTooltip && {
99
- backgroundColor: 'action.hover',
100
- '@keyframes pulse': {
101
- '0%': { opacity: 0.8 },
102
- '50%': { opacity: 0.5 },
103
- '100%': { opacity: 0.8 },
104
- },
105
- animation: 'pulse 2s infinite',
106
- }),
107
- }}>
108
- <iconify-icon icon={WandIcon} height={20} />
109
- </IconButton>
110
- </Tooltip>,
111
- <WizardModal
112
- key="wizard-modal"
113
- show={wizardOpen}
114
- onChangeVisible={(visible) => {
115
- setWizardOpen(visible);
116
- if (!visible && wizardOpen) {
117
- setShowTooltip(true);
118
- }
119
- }}
120
- onFinished={() => {
121
- setWizardOpen(false);
122
- setShowTooltip(false);
123
- }}
124
- />
125
- );
126
- }
127
-
128
59
  // 启用了连接钱包并且检测到了 session context
129
60
  if (enableConnect && sessionCtx) {
130
61
  const menu = [];
@@ -180,5 +111,4 @@ HeaderAddons.propTypes = {
180
111
  addons: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
181
112
  sessionManagerProps: SessionManagerProps,
182
113
  showDomainWarningDialog: PropTypes.bool,
183
- showWizard: PropTypes.bool,
184
114
  };