@blocklet/ui-react 3.2.3 → 3.2.4

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.
@@ -14,7 +14,8 @@
14
14
  "src/blocklets.js",
15
15
  "src/utils.js"
16
16
  ],
17
- "parentId": ""
17
+ "parentId": "",
18
+ "icon": "lucide:book-open"
18
19
  },
19
20
  {
20
21
  "title": "Getting Started",
@@ -27,7 +28,8 @@
27
28
  "src/Footer/index.jsx",
28
29
  "src/common/overridable-theme-provider.jsx"
29
30
  ],
30
- "parentId": ""
31
+ "parentId": "",
32
+ "icon": "lucide:rocket"
31
33
  },
32
34
  {
33
35
  "title": "Core Concepts",
@@ -39,7 +41,8 @@
39
41
  "src/@types/index.ts",
40
42
  "src/utils.js"
41
43
  ],
42
- "parentId": ""
44
+ "parentId": "",
45
+ "icon": "lucide:lightbulb"
43
46
  },
44
47
  {
45
48
  "title": "Components",
@@ -58,7 +61,8 @@
58
61
  "src/ComponentManager/index.tsx",
59
62
  "src/common/notification-addon.jsx"
60
63
  ],
61
- "parentId": ""
64
+ "parentId": "",
65
+ "icon": "lucide:blocks"
62
66
  },
63
67
  {
64
68
  "title": "Layout",
@@ -232,7 +236,8 @@
232
236
  "src/hooks/use-follow.tsx",
233
237
  "src/hooks/use-mobile.tsx"
234
238
  ],
235
- "parentId": ""
239
+ "parentId": "",
240
+ "icon": "lucide:hook"
236
241
  },
237
242
  {
238
243
  "title": "How-to Guides",
@@ -244,6 +249,7 @@
244
249
  "src/common/notification-addon.jsx",
245
250
  "src/BlockletStudio/README.md"
246
251
  ],
247
- "parentId": ""
252
+ "parentId": "",
253
+ "icon": "lucide:compass"
248
254
  }
249
255
  ]
@@ -1,27 +1,27 @@
1
1
  import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
- import { use as ke, useMemo as Ce, isValidElement as ee, cloneElement as re, Children as Pe } from "react";
3
- import { Box as l, Typography as T, CircularProgress as Se, Divider as Me } from "@mui/material";
4
- import { useMemoizedFn as C, useCreation as u, useRequest as te } from "ahooks";
5
- import De from "p-wait-for";
6
- import ie from "react-helmet";
7
- import { SessionContext as Fe } from "@arcblock/did-connect-react/lib/Session";
8
- import Te from "@arcblock/ux/lib/Tabs";
9
- import z from "@arcblock/ux/lib/Empty";
10
- import ze from "@arcblock/ux/lib/Button";
11
- import We from "@arcblock/ux/lib/Result";
12
- import { useConfirm as Ae } from "@arcblock/ux/lib/Dialog";
13
- import { translate as Le } from "@arcblock/ux/lib/Locale/util";
14
- import { useLocaleContext as Ue } from "@arcblock/ux/lib/Locale/context";
15
- import { ErrorFallback as Be } from "@arcblock/ux/lib/ErrorBoundary";
16
- import { styled as fe } from "@arcblock/ux/lib/Theme";
17
- import Ie from "lodash/cloneDeep";
18
- import { joinURL as P, getQuery as Ne, withoutTrailingSlash as oe, withQuery as ne } from "ufo";
19
- import { isSupportFollow as je } from "@arcblock/ux/lib/Util";
20
- import { PROFILE_URL as S } from "@arcblock/ux/lib/Util/constant";
21
- import He from "../../Footer/index.js";
22
- import se from "../../Header/index.js";
23
- import { translations as Ee } from "../libs/locales.js";
24
- import le from "./user-info/user-basic-info.js";
2
+ import { use as ke, useMemo as Pe, isValidElement as te, cloneElement as ie, Children as Se } from "react";
3
+ import { Box as l, Typography as U, CircularProgress as Me, Divider as De } from "@mui/material";
4
+ import { useMemoizedFn as P, useCreation as u, useRequest as oe } from "ahooks";
5
+ import Fe from "p-wait-for";
6
+ import ne from "react-helmet";
7
+ import { SessionContext as Te } from "@arcblock/did-connect-react/lib/Session";
8
+ import ze from "@arcblock/ux/lib/Tabs";
9
+ import B from "@arcblock/ux/lib/Empty";
10
+ import We from "@arcblock/ux/lib/Button";
11
+ import Ae from "@arcblock/ux/lib/Result";
12
+ import { useConfirm as Le } from "@arcblock/ux/lib/Dialog";
13
+ import { translate as Ue } from "@arcblock/ux/lib/Locale/util";
14
+ import { useLocaleContext as Be } from "@arcblock/ux/lib/Locale/context";
15
+ import { ErrorFallback as Ie } from "@arcblock/ux/lib/ErrorBoundary";
16
+ import { styled as pe } from "@arcblock/ux/lib/Theme";
17
+ import Ne from "lodash/cloneDeep";
18
+ import { joinURL as S, getQuery as je, withoutTrailingSlash as se, withQuery as le } from "ufo";
19
+ import { isSupportFollow as He } from "@arcblock/ux/lib/Util";
20
+ import { PROFILE_URL as M } from "@arcblock/ux/lib/Util/constant";
21
+ import Ee from "../../Footer/index.js";
22
+ import ae from "../../Header/index.js";
23
+ import { translations as _e } from "../libs/locales.js";
24
+ import de from "./user-info/user-basic-info.js";
25
25
  import "@mui/icons-material";
26
26
  import "@iconify/react";
27
27
  import "@arcblock/ux/lib/DID";
@@ -32,17 +32,21 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
32
32
  import "@arcblock/ux/lib/RelativeTime";
33
33
  import "@arcblock/ux/lib/UserCard/Content/shorten-label";
34
34
  import "./user-info/switch-role.js";
35
- import { formatBlockletInfo as _e, getLink as M, getLocalizedNavigation as Oe } from "../../blocklets.js";
36
- import Re from "./passport.js";
37
- import $e from "./settings.js";
38
- import { client as ae } from "../../libs/client.js";
39
- import qe from "../../hooks/use-mobile.js";
40
- import { ConfigUserSpaceProvider as Ge } from "../../contexts/config-user-space.js";
41
- import Qe from "./storage/index.js";
42
- import Ve from "./nft.js";
43
- import { UserFollowersProvider as de } from "../../contexts/user-followers.js";
44
- import Je from "./fallback.js";
45
- const W = P(S, "/nfts"), A = P(S, "/settings"), L = P(S, "/did-spaces"), ce = P(S, "/user-followers"), ue = fe(l)(({ theme: v }) => ({
35
+ import { formatBlockletInfo as Oe, getLink as D, getLocalizedNavigation as Re } from "../../blocklets.js";
36
+ import $e from "./passport.js";
37
+ import qe from "./settings.js";
38
+ import { client as ue } from "../../libs/client.js";
39
+ import Ge from "../../hooks/use-mobile.js";
40
+ import { ConfigUserSpaceProvider as Qe } from "../../contexts/config-user-space.js";
41
+ import Ve from "./storage/index.js";
42
+ import Je from "./nft.js";
43
+ import { UserFollowersProvider as ce } from "../../contexts/user-followers.js";
44
+ import Ke from "./fallback.js";
45
+ const F = S(M, "/nfts"), T = S(M, "/settings"), z = S(M, "/did-spaces"), N = S(M, "/user-followers"), Xe = (b) => b.some(
46
+ (y) => ["/userCenter/nfts", "/userCenter/user-followers", "/userCenter/settings", "/userCenter/did-spaces"].includes(
47
+ y.id
48
+ ) || [F, T, z, N].includes(y.link)
49
+ ), fe = pe(l)(({ theme: b }) => ({
46
50
  flex: 1,
47
51
  boxSizing: "border-box",
48
52
  padding: "0 16px",
@@ -53,13 +57,13 @@ const W = P(S, "/nfts"), A = P(S, "/settings"), L = P(S, "/did-spaces"), ce = P(
53
57
  alignItems: "stretch",
54
58
  gap: 2.5,
55
59
  flexDirection: "column",
56
- [v.breakpoints.up("md")]: {
60
+ [b.breakpoints.up("md")]: {
57
61
  flexDirection: "row"
58
62
  }
59
- })), U = fe(l)(({ theme: v }) => ({
63
+ })), I = pe(l)(({ theme: b }) => ({
60
64
  overflow: "hidden",
61
65
  flex: "revert",
62
- [v.breakpoints.up("md")]: {
66
+ [b.breakpoints.up("md")]: {
63
67
  flex: 1
64
68
  },
65
69
  "@media (min-width: 960px) and (max-width: 1050px)": {
@@ -68,45 +72,45 @@ const W = P(S, "/nfts"), A = P(S, "/settings"), L = P(S, "/did-spaces"), ce = P(
68
72
  }
69
73
  }
70
74
  }));
71
- function Or({
72
- children: v,
73
- notLoginContent: B = null,
74
- currentTab: b,
75
- contentProps: I = {},
76
- disableAutoRedirect: N = !1,
77
- hideFooter: pe = !1,
78
- headerProps: me = {},
79
- footerProps: he = {},
80
- userDid: D = void 0,
81
- stickySidebar: j = !1,
82
- embed: H = !1,
83
- onlyProfile: y = !1,
75
+ function $r({
76
+ children: b,
77
+ notLoginContent: y = null,
78
+ currentTab: v,
79
+ contentProps: j = {},
80
+ disableAutoRedirect: H = !1,
81
+ hideFooter: me = !1,
82
+ headerProps: he = {},
83
+ footerProps: xe = {},
84
+ userDid: W = void 0,
85
+ stickySidebar: E = !1,
86
+ embed: _ = !1,
87
+ onlyProfile: C = !1,
84
88
  // 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
85
- onDestroySelf: xe = void 0
89
+ onDestroySelf: ge = void 0
86
90
  }) {
87
- const { locale: x, defaultLocale: k } = Ue(), a = qe({ key: "md" }), f = C((e, t = {}) => Le(Ee, e, x, "en", t)), o = ke(Fe)?.session, h = u(() => {
88
- if (D)
89
- return D;
90
- const e = window.location.href, t = Ne(e);
91
+ const { locale: x, defaultLocale: k } = Be(), a = Ge({ key: "md" }), f = P((e, t = {}) => Ue(_e, e, x, "en", t)), o = ke(Te)?.session, h = u(() => {
92
+ if (W)
93
+ return W;
94
+ const e = window.location.href, t = je(e);
91
95
  return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : o?.user?.did;
92
- }, [o?.user?.did, D]), i = u(() => o?.user ? h === o?.user?.did : !1, [h, o?.user?.did]), w = Ce(() => je(), []), n = te(
96
+ }, [o?.user?.did, W]), i = u(() => o?.user ? h === o?.user?.did : !1, [h, o?.user?.did]), w = Pe(() => He(), []), n = oe(
93
97
  // eslint-disable-next-line consistent-return
94
98
  async () => {
95
- if (await De(() => o?.initialized), i)
99
+ if (await Fe(() => o?.initialized), i)
96
100
  return o.user;
97
101
  if (h)
98
- return ae.user.getUserPublicInfo({ did: h });
102
+ return ue.user.getUserPublicInfo({ did: h });
99
103
  },
100
104
  {
101
105
  refreshDeps: [h, i, o?.initialized, o?.user]
102
106
  }
103
- ), E = C(() => i ? o.refresh() : n.refresh()), g = te(
104
- async () => n.data && b ? await ae.user.getUserPrivacyConfig({ did: h }) : null,
107
+ ), O = P(() => i ? o.refresh() : n.refresh()), g = oe(
108
+ async () => n.data && v ? await ue.user.getUserPrivacyConfig({ did: h }) : null,
105
109
  {
106
- refreshDeps: [h, n.data, b],
110
+ refreshDeps: [h, n.data, v],
107
111
  loadingDelay: 300
108
112
  }
109
- ), { confirmHolder: _ } = Ae({
113
+ ), { confirmHolder: R } = Le({
110
114
  fullScreen: a,
111
115
  sx: {
112
116
  ".MuiDialog-paper": {
@@ -126,59 +130,59 @@ function Or({
126
130
  }
127
131
  }
128
132
  }
129
- }), O = u(() => {
130
- const e = Ie(window.blocklet);
133
+ }), $ = u(() => {
134
+ const e = Ne(window.blocklet);
131
135
  try {
132
- return _e(e);
136
+ return Oe(e);
133
137
  } catch (t) {
134
138
  return console.error("Failed to format blocklet info", t, e), e;
135
139
  }
136
- }, []), R = u(() => {
140
+ }, []), q = u(() => {
137
141
  const e = {
138
142
  label: f("common.nft"),
139
143
  protected: !1,
140
144
  isPrivate: !1,
141
145
  // true: 隐私数据,仅自己可见
142
- value: W,
143
- url: M(W, x, k)
146
+ value: F,
147
+ url: D(F, x, k)
144
148
  }, t = {
145
149
  label: f("userFollowers"),
146
150
  protected: !1,
147
151
  isPrivate: !1,
148
- value: ce,
149
- url: M(ce, x, k)
152
+ value: N,
153
+ url: D(N, x, k)
150
154
  };
151
155
  let p = w ? [e, t] : [e];
152
156
  if (i) {
153
- const c = [
157
+ const L = [
154
158
  e,
155
159
  {
156
160
  label: f("common.setting"),
157
161
  protected: !0,
158
162
  isPrivate: !0,
159
- value: A,
160
- url: M(A, x, k)
163
+ value: T,
164
+ url: D(T, x, k)
161
165
  },
162
166
  {
163
167
  label: f("storageManagement"),
164
168
  protected: !0,
165
169
  isPrivate: !0,
166
- value: L,
167
- url: M(L, x, k)
170
+ value: z,
171
+ url: D(z, x, k)
168
172
  }
169
173
  ];
170
- p = w ? [...c, t] : c;
174
+ p = w ? [...L, t] : L;
171
175
  }
172
176
  return p;
173
177
  }, [i, x, w]), d = u(() => {
174
- const e = O?.navigation?.userCenter || [];
175
- return (Oe({ navigation: e, locale: x, defaultLocale: k }) || []).concat(R).map((c) => {
176
- const Z = c.value ?? c._rawLink ?? c.link ?? c.url;
178
+ const e = $?.navigation?.userCenter || [], t = Xe(e);
179
+ return (Re({ navigation: e, locale: x, defaultLocale: k }) || []).concat(t ? [] : q).map((c) => {
180
+ const re = c.value ?? c._rawLink ?? c.link ?? c.url;
177
181
  return {
178
- value: Z,
182
+ value: re,
179
183
  label: c.title || c.label,
180
184
  url: c.link || c.url,
181
- protected: g?.data?.[Z] ?? !1,
185
+ protected: g?.data?.[re] ?? !1,
182
186
  isPrivate: c.isPrivate || c.private || (c?._rawLink?.includes("/customer") ?? !1),
183
187
  // FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
184
188
  followersOnly: c.component === "did-comments"
@@ -186,32 +190,32 @@ function Or({
186
190
  // icon: x.icon,
187
191
  };
188
192
  }).filter((c) => i || !c.isPrivate);
189
- }, [O, n.data, g?.data, x, R, i]), s = u(() => d.find((e) => oe(e.value) === oe(b)), [d]), $ = u(() => {
193
+ }, [$, n.data, g?.data, x, q, i]), s = u(() => d.find((e) => se(e.value) === se(v)), [d]), G = u(() => {
190
194
  const e = window.blocklet?.appName, p = [s?.label, f("userCenter.title")].filter(Boolean).join("-");
191
195
  return e ? `${p} | ${e}` : p;
192
- }, [s, f]), ge = C((e) => e && (ee(e) ? re(e, {
196
+ }, [s, f]), be = P((e) => e && (te(e) ? ie(e, {
193
197
  ...e.props || {},
194
198
  userCenterTabs: d
195
- }) : Pe.map(e, (t) => ee(t) ? re(t, {
199
+ }) : Se.map(e, (t) => te(t) ? ie(t, {
196
200
  ...t.props || {},
197
201
  userCenterTabs: d
198
- }) : t))), be = C((e) => {
202
+ }) : t))), ve = P((e) => {
199
203
  const t = d.find((p) => p.value === e);
200
- t && (window.location.href = ne(t.url, {
204
+ t && (window.location.href = le(t.url, {
201
205
  did: i ? void 0 : h
202
206
  }));
203
- }), q = u(() => /* @__PURE__ */ r(
204
- $e,
207
+ }), Q = u(() => /* @__PURE__ */ r(
208
+ qe,
205
209
  {
206
210
  user: n.data,
207
211
  settings: { userCenterTabs: d },
208
212
  onSave: async (e) => e === "privacy" ? (await g.runAsync(), g.data) : (e === "profile" && await o.refresh(), null),
209
213
  isMobile: a,
210
- onDestroySelf: xe
214
+ onDestroySelf: ge
211
215
  }
212
- ), [n.data, d, g.data, g.runAsync]), G = u(() => s && s?.value === A, [s]), Q = u(() => s && s?.value === P(S, "/profile") || s?.value === W, [s]), ve = u(() => s && s?.value === L, [s]), we = o.useOAuth(), ye = o.usePasskey(), V = C(() => {
213
- o?.user?.sourceProvider === "passkey" ? ye.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? we.switchOAuthPassport(o.user) : o && o.switchPassport();
214
- }), F = u(() => Q ? /* @__PURE__ */ m(
216
+ ), [n.data, d, g.data, g.runAsync]), V = u(() => s && s?.value === T, [s]), J = u(() => s && s?.value === S(M, "/profile") || s?.value === F, [s]), we = u(() => s && s?.value === z, [s]), ye = o.useOAuth(), Ce = o.usePasskey(), K = P(() => {
217
+ o?.user?.sourceProvider === "passkey" ? Ce.switchPassport(o.user) : ["google", "apple", "email", "github"].includes(o?.user?.sourceProvider ?? "") ? ye.switchOAuthPassport(o.user) : o && o.switchPassport();
218
+ }), A = u(() => J ? /* @__PURE__ */ m(
215
219
  l,
216
220
  {
217
221
  sx: {
@@ -222,7 +226,7 @@ function Or({
222
226
  children: [
223
227
  i ? /* @__PURE__ */ m(l, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
224
228
  /* @__PURE__ */ r(
225
- T,
229
+ U,
226
230
  {
227
231
  sx: {
228
232
  color: "text.primary",
@@ -232,12 +236,12 @@ function Or({
232
236
  children: f("passport")
233
237
  }
234
238
  ),
235
- /* @__PURE__ */ r(Re, { user: n.data })
239
+ /* @__PURE__ */ r($e, { user: n.data })
236
240
  ] }) : null,
237
- /* @__PURE__ */ r(Ve, { user: n.data })
241
+ /* @__PURE__ */ r(Je, { user: n.data })
238
242
  ]
239
243
  }
240
- ) : G && i ? q : ve && i ? /* @__PURE__ */ r(Ge, { children: /* @__PURE__ */ r(Qe, {}) }) : null, [G, Q, n, i, j, q]), J = u(() => /* @__PURE__ */ r(
244
+ ) : V && i ? Q : we && i ? /* @__PURE__ */ r(Qe, { children: /* @__PURE__ */ r(Ve, {}) }) : null, [V, J, n, i, E, Q]), X = u(() => /* @__PURE__ */ r(
241
245
  l,
242
246
  {
243
247
  sx: {
@@ -247,9 +251,9 @@ function Or({
247
251
  },
248
252
  py: 3
249
253
  },
250
- children: /* @__PURE__ */ r(z, { children: f("emptyContent") })
254
+ children: /* @__PURE__ */ r(B, { children: f("emptyContent") })
251
255
  }
252
- ), [i, x]), K = u(() => !g.data || g.loading ? /* @__PURE__ */ r(
256
+ ), [i, x]), Y = u(() => !g.data || g.loading ? /* @__PURE__ */ r(
253
257
  l,
254
258
  {
255
259
  sx: {
@@ -261,28 +265,28 @@ function Or({
261
265
  alignItems: "center",
262
266
  flex: 1
263
267
  },
264
- children: /* @__PURE__ */ r(Se, {})
268
+ children: /* @__PURE__ */ r(Me, {})
265
269
  }
266
270
  ) : /* @__PURE__ */ r(l, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
267
- Je,
271
+ Ke,
268
272
  {
269
273
  isSupportFollow: w,
270
274
  currentActiveTab: s,
271
275
  isMyself: i,
272
- children: v ? /* @__PURE__ */ r(l, { ...I, children: ge(v) }) : F
276
+ children: b ? /* @__PURE__ */ r(l, { ...j, children: be(b) }) : A
273
277
  }
274
- ) }), [g, s, i, v, I, F, x]), X = u(() => {
278
+ ) }), [g, s, i, b, j, A, x]), Z = u(() => {
275
279
  if (n.loading || o.loading)
276
280
  return null;
277
281
  if (n.error) {
278
282
  if (n.error?.response?.status === 404)
279
- return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(We, { status: 404, description: f("noUserFound") }) });
283
+ return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ae, { status: 404, description: f("noUserFound") }) });
280
284
  const p = {
281
285
  message: n.error.response?.data?.error || n.error.message || "error occurred"
282
286
  };
283
- return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Be, { error: p }) });
287
+ return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ie, { error: p }) });
284
288
  }
285
- return !h && !n.data ? B || /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
289
+ return !h && !n.data ? y || /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ m(
286
290
  l,
287
291
  {
288
292
  sx: {
@@ -293,15 +297,15 @@ function Or({
293
297
  gap: 1
294
298
  },
295
299
  children: [
296
- /* @__PURE__ */ r(z, { children: f("viewAfterLogin") }),
297
- /* @__PURE__ */ r(ze, { size: "small", variant: "contained", onClick: () => o.login(), children: f("loginNow") })
300
+ /* @__PURE__ */ r(B, { children: f("viewAfterLogin") }),
301
+ /* @__PURE__ */ r(We, { size: "small", variant: "contained", onClick: () => o.login(), children: f("loginNow") })
298
302
  ]
299
303
  }
300
- ) }) : h && !n.data && !n.loading ? /* @__PURE__ */ r(z, { style: { width: "100%", paddingTop: 16 }, children: /* @__PURE__ */ m(l, { sx: { textAlign: "center", width: "100%" }, children: [
301
- /* @__PURE__ */ r(T, { variant: "body1", sx: { fontSize: 18, fontWeight: 500 }, children: f("userNotFound") }),
302
- /* @__PURE__ */ r(T, { variant: "body1", color: "text.secondary", children: f("userNotFoundDescription") })
303
- ] }) }) : H ? /* @__PURE__ */ m(U, { children: [
304
- d.length > 0 && b ? /* @__PURE__ */ r(
304
+ ) }) : h && !n.data && !n.loading ? /* @__PURE__ */ r(B, { style: { width: "100%", paddingTop: 16 }, children: /* @__PURE__ */ m(l, { sx: { textAlign: "center", width: "100%" }, children: [
305
+ /* @__PURE__ */ r(U, { variant: "body1", sx: { fontSize: 18, fontWeight: 500 }, children: f("userNotFound") }),
306
+ /* @__PURE__ */ r(U, { variant: "body1", color: "text.secondary", children: f("userNotFoundDescription") })
307
+ ] }) }) : _ ? /* @__PURE__ */ m(I, { children: [
308
+ d.length > 0 && v ? /* @__PURE__ */ r(
305
309
  l,
306
310
  {
307
311
  sx: {
@@ -310,22 +314,22 @@ function Or({
310
314
  overflow: "auto",
311
315
  padding: "1px"
312
316
  },
313
- children: K
317
+ children: Y
314
318
  }
315
319
  ) : null,
316
- d.length === 0 && J
317
- ] }) : y ? /* @__PURE__ */ r(U, { display: "flex", flexDirection: a ? "column" : "row", children: /* @__PURE__ */ r(
318
- le,
320
+ d.length === 0 && X
321
+ ] }) : C ? /* @__PURE__ */ r(I, { display: "flex", flexDirection: a ? "column" : "row", children: /* @__PURE__ */ r(
322
+ de,
319
323
  {
320
324
  isMobile: a,
321
325
  order: a ? 1 : "unset",
322
326
  isMyself: i,
323
- switchPassport: V,
327
+ switchPassport: K,
324
328
  switchProfile: o.switchProfile,
325
329
  user: n.data,
326
330
  showFullDid: !1,
327
- onlyProfile: y,
328
- refreshProfile: E,
331
+ onlyProfile: C,
332
+ refreshProfile: O,
329
333
  isShowSocialActions: w,
330
334
  sx: {
331
335
  padding: a ? "16px 0 0 0" : "40px 24px 24px 40px",
@@ -333,7 +337,7 @@ function Or({
333
337
  boxSizing: "content-box"
334
338
  }
335
339
  }
336
- ) }) : /* @__PURE__ */ m(U, { display: "flex", flexDirection: a ? "column" : "row", children: [
340
+ ) }) : /* @__PURE__ */ m(I, { display: "flex", flexDirection: a ? "column" : "row", children: [
337
341
  /* @__PURE__ */ m(
338
342
  l,
339
343
  {
@@ -344,7 +348,7 @@ function Or({
344
348
  width: a ? "unset" : "calc(100% - 424px)"
345
349
  },
346
350
  children: [
347
- d.length > 0 && b ? /* @__PURE__ */ m(
351
+ d.length > 0 && v ? /* @__PURE__ */ m(
348
352
  l,
349
353
  {
350
354
  sx: {
@@ -356,13 +360,13 @@ function Or({
356
360
  },
357
361
  children: [
358
362
  /* @__PURE__ */ r(
359
- Te,
363
+ ze,
360
364
  {
361
365
  orientation: "horizontal",
362
366
  variant: "line",
363
367
  tabs: d,
364
- current: s?.value ?? b,
365
- onChange: be,
368
+ current: s?.value ?? v,
369
+ onChange: ve,
366
370
  enableTabClick: !0,
367
371
  sx: {
368
372
  mb: (e) => `${e.spacing(3)} !important`,
@@ -399,25 +403,25 @@ function Or({
399
403
  }
400
404
  }
401
405
  ),
402
- K
406
+ Y
403
407
  ]
404
408
  }
405
409
  ) : null,
406
- d.length === 0 && J
410
+ d.length === 0 && X
407
411
  ]
408
412
  }
409
413
  ),
410
- !a && /* @__PURE__ */ r(Me, { orientation: "vertical", sx: { ml: 5 } }),
414
+ !a && /* @__PURE__ */ r(De, { orientation: "vertical", sx: { ml: 5 } }),
411
415
  /* @__PURE__ */ r(
412
- le,
416
+ de,
413
417
  {
414
418
  isMobile: a,
415
419
  order: a ? 1 : "unset",
416
420
  isMyself: i,
417
- switchPassport: V,
421
+ switchPassport: K,
418
422
  switchProfile: o.switchProfile,
419
423
  user: n.data,
420
- refreshProfile: E,
424
+ refreshProfile: O,
421
425
  showFullDid: !1,
422
426
  isShowSocialActions: w,
423
427
  sx: {
@@ -434,24 +438,24 @@ function Or({
434
438
  i,
435
439
  s,
436
440
  g,
437
- b,
438
- j,
439
- F
440
- ]), Y = u(() => i ? !1 : s?.isPrivate, [i, s]);
441
- if (u(() => y ? !1 : !N && !b && d?.length > 0 || !s || Y, [N, b, d, s, Y, y])) {
441
+ v,
442
+ E,
443
+ A
444
+ ]), ee = u(() => i ? !1 : s?.isPrivate, [i, s]);
445
+ if (u(() => C ? !1 : !H && !v && d?.length > 0 || !s || ee, [H, v, d, s, ee, C])) {
442
446
  const e = d[0]?.url, t = d.find((p) => p.value === e);
443
447
  return e && !t?.isPrivate && window.location.replace(
444
- ne(e, {
448
+ le(e, {
445
449
  did: i ? void 0 : h
446
450
  })
447
451
  ), null;
448
452
  }
449
- return H || y ? /* @__PURE__ */ m(l, { children: [
450
- /* @__PURE__ */ r(ie, { children: /* @__PURE__ */ r("title", { children: $ }) }),
451
- /* @__PURE__ */ r(se, { style: { display: "none" } }),
452
- /* @__PURE__ */ m(ue, { children: [
453
- /* @__PURE__ */ r(de, { isMySelf: i, userDid: n.data?.did ?? "", children: X }),
454
- _
453
+ return _ || C ? /* @__PURE__ */ m(l, { children: [
454
+ /* @__PURE__ */ r(ne, { children: /* @__PURE__ */ r("title", { children: G }) }),
455
+ /* @__PURE__ */ r(ae, { style: { display: "none" } }),
456
+ /* @__PURE__ */ m(fe, { children: [
457
+ /* @__PURE__ */ r(ce, { isMySelf: i, userDid: n.data?.did ?? "", children: Z }),
458
+ R
455
459
  ] })
456
460
  ] }) : /* @__PURE__ */ m(
457
461
  l,
@@ -462,17 +466,17 @@ function Or({
462
466
  flexDirection: "column"
463
467
  },
464
468
  children: [
465
- /* @__PURE__ */ r(ie, { children: /* @__PURE__ */ r("title", { children: $ }) }),
466
- /* @__PURE__ */ r(se, { bordered: !0, ...me, maxWidth: "100%" }),
467
- /* @__PURE__ */ m(ue, { children: [
468
- /* @__PURE__ */ r(de, { isMySelf: i, userDid: n.data?.did ?? "", children: X }),
469
- _
469
+ /* @__PURE__ */ r(ne, { children: /* @__PURE__ */ r("title", { children: G }) }),
470
+ /* @__PURE__ */ r(ae, { bordered: !0, ...he, maxWidth: "100%" }),
471
+ /* @__PURE__ */ m(fe, { children: [
472
+ /* @__PURE__ */ r(ce, { isMySelf: i, userDid: n.data?.did ?? "", children: Z }),
473
+ R
470
474
  ] }),
471
- pe ? null : /* @__PURE__ */ r(
472
- He,
475
+ me ? null : /* @__PURE__ */ r(
476
+ Ee,
473
477
  {
474
478
  bordered: !0,
475
- ...he,
479
+ ...xe,
476
480
  sx: {
477
481
  ".MuiContainer-root": {
478
482
  maxWidth: 1600
@@ -485,5 +489,5 @@ function Or({
485
489
  );
486
490
  }
487
491
  export {
488
- Or as default
492
+ $r as default
489
493
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.2.3",
3
+ "version": "3.2.4",
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.1",
37
37
  "@abtnode/util": "1.17.1",
38
- "@arcblock/bridge": "3.2.3",
39
- "@arcblock/icons": "3.2.3",
40
- "@arcblock/react-hooks": "3.2.3",
38
+ "@arcblock/bridge": "3.2.4",
39
+ "@arcblock/icons": "3.2.4",
40
+ "@arcblock/react-hooks": "3.2.4",
41
41
  "@arcblock/ws": "^1.27.3",
42
42
  "@blocklet/constant": "1.17.1",
43
43
  "@blocklet/did-space-react": "^1.2.1",
@@ -83,7 +83,7 @@
83
83
  "access": "public"
84
84
  },
85
85
  "devDependencies": {
86
- "@arcblock/did-connect-react": "3.2.3",
86
+ "@arcblock/did-connect-react": "3.2.4",
87
87
  "@types/dompurify": "^3.2.0",
88
88
  "@types/ua-parser-js": "^0.7.39",
89
89
  "@types/validator": "^13.15.2",
@@ -91,5 +91,5 @@
91
91
  "jest": "^29.7.0",
92
92
  "unbuild": "^2.0.0"
93
93
  },
94
- "gitHead": "bbd2b3c8caecf454ee738676f1ca5fe0e71fdb6a"
94
+ "gitHead": "75c7e540161356c3b4d7a35322b85cd5d09c872e"
95
95
  }
@@ -44,6 +44,15 @@ const settingsLink = joinURL(PROFILE_URL, '/settings');
44
44
  const didSpacesLink = joinURL(PROFILE_URL, '/did-spaces');
45
45
  const userFollowersLink = joinURL(PROFILE_URL, '/user-followers');
46
46
 
47
+ const hasSystemMenusInjected = (menus: Array<any>) => {
48
+ return menus.some(
49
+ (menu: any) =>
50
+ ['/userCenter/nfts', '/userCenter/user-followers', '/userCenter/settings', '/userCenter/did-spaces'].includes(
51
+ menu.id
52
+ ) || [nftsLink, settingsLink, didSpacesLink, userFollowersLink].includes(menu.link)
53
+ );
54
+ };
55
+
47
56
  interface NavigationTabProps {
48
57
  label: string;
49
58
  protected: boolean;
@@ -258,8 +267,9 @@ export default function UserCenter({
258
267
 
259
268
  const userCenterTabs = useCreation<UserCenterTab[]>(() => {
260
269
  const menus = formattedBlocklet?.navigation?.userCenter || [];
270
+ const hasSystemMenus = hasSystemMenusInjected(menus);
261
271
  const localizedMenus = getLocalizedNavigation({ navigation: menus, locale, defaultLocale }) || [];
262
- const allMenus = localizedMenus.concat(defaultTabs);
272
+ const allMenus = localizedMenus.concat(hasSystemMenus ? [] : defaultTabs);
263
273
  return allMenus
264
274
  .map((x: any) => {
265
275
  const value = x.value ?? x._rawLink ?? x.link ?? x.url;