@blocklet/ui-react 3.0.25 → 3.0.27

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,25 +1,25 @@
1
- import { jsx as e, jsxs as f, Fragment as D } from "react/jsx-runtime";
2
- import { use as pe } from "react";
3
- import { Box as a, Typography as me, CircularProgress as he, Divider as xe } from "@mui/material";
4
- import { useMemoizedFn as y, useCreation as d, useRequest as Y } from "ahooks";
5
- import ge from "p-wait-for";
6
- import { SessionContext as ve } from "@arcblock/did-connect/lib/Session";
7
- import be from "@arcblock/ux/lib/Tabs";
8
- import M from "@arcblock/ux/lib/Empty";
9
- import we from "@arcblock/ux/lib/Button";
10
- import ye from "@arcblock/ux/lib/Result";
11
- import { useConfirm as Ce } from "@arcblock/ux/lib/Dialog";
12
- import { translate as ke } from "@arcblock/ux/lib/Locale/util";
13
- import { useLocaleContext as Pe } from "@arcblock/ux/lib/Locale/context";
14
- import { ErrorFallback as Se } from "@arcblock/ux/lib/ErrorBoundary";
15
- import { styled as oe } from "@arcblock/ux/lib/Theme";
16
- import De from "lodash/cloneDeep";
17
- import { joinURL as C, getQuery as Me, withoutTrailingSlash as Z, withQuery as $ } from "ufo";
1
+ import { jsx as r, jsxs as f, Fragment as S } from "react/jsx-runtime";
2
+ import { use as xe, isValidElement as X, cloneElement as Y, Children as ge } from "react";
3
+ import { Box as l, Typography as be, CircularProgress as ve, Divider as we } from "@mui/material";
4
+ import { useMemoizedFn as y, useCreation as u, useRequest as Z } from "ahooks";
5
+ import ye from "p-wait-for";
6
+ import { SessionContext as Ce } from "@arcblock/did-connect/lib/Session";
7
+ import ke from "@arcblock/ux/lib/Tabs";
8
+ import D from "@arcblock/ux/lib/Empty";
9
+ import Pe from "@arcblock/ux/lib/Button";
10
+ import Me from "@arcblock/ux/lib/Result";
11
+ import { useConfirm as Se } from "@arcblock/ux/lib/Dialog";
12
+ import { translate as De } from "@arcblock/ux/lib/Locale/util";
13
+ import { useLocaleContext as ze } from "@arcblock/ux/lib/Locale/context";
14
+ import { ErrorFallback as Te } from "@arcblock/ux/lib/ErrorBoundary";
15
+ import { styled as se } from "@arcblock/ux/lib/Theme";
16
+ import We from "lodash/cloneDeep";
17
+ import { joinURL as C, getQuery as Ae, withoutTrailingSlash as ee, withQuery as re } from "ufo";
18
18
  import { PROFILE_URL as k } from "@arcblock/ux/lib/Util/constant";
19
- import Te from "../../Footer/index.js";
20
- import ee from "../../Header/index.js";
21
- import { translations as We } from "../libs/locales.js";
22
- import re from "./user-info/user-basic-info.js";
19
+ import Ue from "../../Footer/index.js";
20
+ import te from "../../Header/index.js";
21
+ import { translations as Le } from "../libs/locales.js";
22
+ import ie from "./user-info/user-basic-info.js";
23
23
  import "@mui/icons-material";
24
24
  import "@iconify/react";
25
25
  import "@arcblock/ux/lib/DID";
@@ -30,15 +30,15 @@ import "@iconify-icons/material-symbols/settings-input-antenna-rounded";
30
30
  import "@arcblock/ux/lib/RelativeTime";
31
31
  import "@arcblock/ux/lib/UserCard/Content/shorten-label";
32
32
  import "./user-info/switch-role.js";
33
- import { formatBlockletInfo as ze, getLink as T, getLocalizedNavigation as Ae } from "../../blocklets.js";
34
- import Ue from "./passport.js";
35
- import Le from "./settings.js";
36
- import { client as te } from "../../libs/client.js";
37
- import Be from "../../hooks/use-mobile.js";
38
- import { ConfigUserSpaceProvider as Fe } from "../../contexts/config-user-space.js";
39
- import Re from "./storage/index.js";
40
- import Ie from "./nft.js";
41
- const W = C(k, "/nfts"), z = C(k, "/settings"), A = C(k, "/did-spaces"), ie = oe(a)(({ theme: v }) => ({
33
+ import { formatBlockletInfo as Be, getLink as z, getLocalizedNavigation as Fe } from "../../blocklets.js";
34
+ import Ie from "./passport.js";
35
+ import je from "./settings.js";
36
+ import { client as ne } from "../../libs/client.js";
37
+ import Ee from "../../hooks/use-mobile.js";
38
+ import { ConfigUserSpaceProvider as He } from "../../contexts/config-user-space.js";
39
+ import Ne from "./storage/index.js";
40
+ import _e from "./nft.js";
41
+ const T = C(k, "/nfts"), W = C(k, "/settings"), A = C(k, "/did-spaces"), oe = se(l)(({ theme: b }) => ({
42
42
  flex: 1,
43
43
  boxSizing: "border-box",
44
44
  padding: "0 16px",
@@ -49,13 +49,13 @@ const W = C(k, "/nfts"), z = C(k, "/settings"), A = C(k, "/did-spaces"), ie = oe
49
49
  alignItems: "stretch",
50
50
  gap: 2.5,
51
51
  flexDirection: "column",
52
- [v.breakpoints.up("md")]: {
52
+ [b.breakpoints.up("md")]: {
53
53
  flexDirection: "row"
54
54
  }
55
- })), U = oe(a)(({ theme: v }) => ({
55
+ })), U = se(l)(({ theme: b }) => ({
56
56
  overflow: "hidden",
57
57
  flex: "revert",
58
- [v.breakpoints.up("md")]: {
58
+ [b.breakpoints.up("md")]: {
59
59
  flex: 1
60
60
  },
61
61
  "@media (min-width: 850px) and (max-width: 1050px)": {
@@ -64,46 +64,46 @@ const W = C(k, "/nfts"), z = C(k, "/settings"), A = C(k, "/did-spaces"), ie = oe
64
64
  }
65
65
  }
66
66
  }));
67
- function Dr({
68
- children: v,
67
+ function Wr({
68
+ children: b,
69
69
  notLoginContent: L = null,
70
70
  currentTab: h,
71
71
  contentProps: B = {},
72
72
  disableAutoRedirect: F = !1,
73
- hideFooter: ne = !1,
74
- headerProps: se = {},
75
- footerProps: ae = {},
73
+ hideFooter: ae = !1,
74
+ headerProps: le = {},
75
+ footerProps: de = {},
76
76
  userDid: P = void 0,
77
- stickySidebar: R = !1,
78
- embed: I = !1,
77
+ stickySidebar: I = !1,
78
+ embed: j = !1,
79
79
  onlyProfile: w = !1,
80
80
  // 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
81
- onDestroySelf: le = void 0
81
+ onDestroySelf: ue = void 0
82
82
  }) {
83
- const { locale: x } = Pe(), l = Be({ key: "md" }), g = y((r, o = {}) => ke(We, r, x, "en", o)), t = pe(ve)?.session, p = d(() => {
83
+ const { locale: x } = ze(), d = Ee({ key: "md" }), g = y((e, t = {}) => De(Le, e, x, "en", t)), i = xe(Ce)?.session, p = u(() => {
84
84
  if (P)
85
85
  return P;
86
- const r = window.location.href, o = Me(r);
87
- return o?.did ? Array.isArray(o.did) ? o.did[0] : o.did : t?.user?.did;
88
- }, [t?.user?.did, P]), i = d(() => t?.user ? p === t?.user?.did : !1, [p, t?.user?.did]), n = Y(
86
+ const e = window.location.href, t = Ae(e);
87
+ return t?.did ? Array.isArray(t.did) ? t.did[0] : t.did : i?.user?.did;
88
+ }, [i?.user?.did, P]), n = u(() => i?.user ? p === i?.user?.did : !1, [p, i?.user?.did]), o = Z(
89
89
  // eslint-disable-next-line consistent-return
90
90
  async () => {
91
- if (await ge(() => t?.initialized), i)
92
- return t.user;
91
+ if (await ye(() => i?.initialized), n)
92
+ return i.user;
93
93
  if (p)
94
- return te.user.getUserPublicInfo({ did: p });
94
+ return ne.user.getUserPublicInfo({ did: p });
95
95
  },
96
96
  {
97
- refreshDeps: [p, i, t?.initialized, t?.user]
97
+ refreshDeps: [p, n, i?.initialized, i?.user]
98
98
  }
99
- ), j = y(() => i ? t.refresh() : n.refresh()), m = Y(
100
- async () => n.data && h ? await te.user.getUserPrivacyConfig({ did: p }) : null,
99
+ ), E = y(() => n ? i.refresh() : o.refresh()), m = Z(
100
+ async () => o.data && h ? await ne.user.getUserPrivacyConfig({ did: p }) : null,
101
101
  {
102
- refreshDeps: [p, n.data, h],
102
+ refreshDeps: [p, o.data, h],
103
103
  loadingDelay: 300
104
104
  }
105
- ), { confirmHolder: H } = Ce({
106
- fullScreen: l,
105
+ ), { confirmHolder: H } = Se({
106
+ fullScreen: d,
107
107
  sx: {
108
108
  ".MuiDialog-paper": {
109
109
  borderRadius: 1,
@@ -122,72 +122,78 @@ function Dr({
122
122
  }
123
123
  }
124
124
  }
125
- }), N = d(() => {
126
- const r = De(window.blocklet);
125
+ }), N = u(() => {
126
+ const e = We(window.blocklet);
127
127
  try {
128
- return ze(r);
129
- } catch (o) {
130
- return console.error("Failed to format blocklet info", o, r), r;
128
+ return Be(e);
129
+ } catch (t) {
130
+ return console.error("Failed to format blocklet info", t, e), e;
131
131
  }
132
- }, []), _ = d(() => {
133
- const r = {
132
+ }, []), _ = u(() => {
133
+ const e = {
134
134
  label: g("common.nft"),
135
135
  protected: !1,
136
136
  isPrivate: !1,
137
137
  // true: 隐私数据,仅自己可见
138
- value: W,
139
- url: T(W, x)
138
+ value: T,
139
+ url: z(T, x)
140
140
  };
141
- let o = [r];
142
- return i && (o = [
143
- r,
141
+ let t = [e];
142
+ return n && (t = [
143
+ e,
144
144
  {
145
145
  label: g("common.setting"),
146
146
  protected: !0,
147
147
  isPrivate: !0,
148
- value: z,
149
- url: T(z, x)
148
+ value: W,
149
+ url: z(W, x)
150
150
  },
151
151
  {
152
152
  label: g("storageManagement"),
153
153
  protected: !0,
154
154
  isPrivate: !0,
155
155
  value: A,
156
- url: T(A, x)
156
+ url: z(A, x)
157
157
  }
158
- ]), o;
159
- }, [i, x]), c = d(() => {
160
- const r = N?.navigation?.userCenter || [];
161
- return (Ae(r, x) || []).concat(_).map((u) => {
162
- const X = u.value ?? u._rawLink ?? u.link ?? u.url;
158
+ ]), t;
159
+ }, [n, x]), a = u(() => {
160
+ const e = N?.navigation?.userCenter || [];
161
+ return (Fe(e, x) || []).concat(_).map((c) => {
162
+ const K = c.value ?? c._rawLink ?? c.link ?? c.url;
163
163
  return {
164
- value: X,
165
- label: u.title || u.label,
166
- url: u.link || u.url,
167
- protected: m?.data?.[X] ?? !1,
168
- isPrivate: u.isPrivate || u.private || (u?._rawLink?.includes("/customer") ?? !1)
164
+ value: K,
165
+ label: c.title || c.label,
166
+ url: c.link || c.url,
167
+ protected: m?.data?.[K] ?? !1,
168
+ isPrivate: c.isPrivate || c.private || (c?._rawLink?.includes("/customer") ?? !1)
169
169
  // FIXME: HACK: 隐藏 /customer 菜单, 需要一个通用的解决方案,在嵌入的时候就决定是否是私有的
170
170
  // icon: x.icon,
171
171
  };
172
- }).filter((u) => i || !u.isPrivate);
173
- }, [N, n.data, m?.data, x, _, i]), s = d(() => c.find((r) => Z(r.value) === Z(h)), [c]), de = y((r) => {
174
- const o = c.find((b) => b.value === r);
175
- o && (window.location.href = $(o.url, {
176
- did: i ? void 0 : p
172
+ }).filter((c) => n || !c.isPrivate);
173
+ }, [N, o.data, m?.data, x, _, n]), s = u(() => a.find((e) => ee(e.value) === ee(h)), [a]), ce = y((e) => e && (X(e) ? Y(e, {
174
+ ...e.props || {},
175
+ userCenterTabs: a
176
+ }) : ge.map(e, (t) => X(t) ? Y(t, {
177
+ ...t.props || {},
178
+ userCenterTabs: a
179
+ }) : t))), fe = y((e) => {
180
+ const t = a.find((v) => v.value === e);
181
+ t && (window.location.href = re(t.url, {
182
+ did: n ? void 0 : p
177
183
  }));
178
- }), E = d(() => /* @__PURE__ */ e(
179
- Le,
184
+ }), R = u(() => /* @__PURE__ */ r(
185
+ je,
180
186
  {
181
- user: n.data,
182
- settings: { userCenterTabs: c },
183
- onSave: async (r) => r === "privacy" ? (await m.runAsync(), m.data) : (r === "profile" && await t.refresh(), null),
184
- isMobile: l,
185
- onDestroySelf: le
187
+ user: o.data,
188
+ settings: { userCenterTabs: a },
189
+ onSave: async (e) => e === "privacy" ? (await m.runAsync(), m.data) : (e === "profile" && await i.refresh(), null),
190
+ isMobile: d,
191
+ onDestroySelf: ue
186
192
  }
187
- ), [n.data, c, m.data, m.runAsync]), O = d(() => s && s?.value === z, [s]), q = d(() => s && s?.value === C(k, "/profile") || s?.value === W, [s]), ce = d(() => s && s?.value === A, [s]), ue = t.useOAuth(), fe = t.usePasskey(), Q = y(() => {
188
- t?.user?.sourceProvider === "passkey" ? fe.switchPassport(t.user) : ["google", "apple", "email", "github"].includes(t?.user?.sourceProvider ?? "") ? ue.switchOAuthPassport(t.user) : t && t.switchPassport();
189
- }), S = d(() => q ? /* @__PURE__ */ f(
190
- a,
193
+ ), [o.data, a, m.data, m.runAsync]), O = u(() => s && s?.value === W, [s]), q = u(() => s && s?.value === C(k, "/profile") || s?.value === T, [s]), pe = u(() => s && s?.value === A, [s]), me = i.useOAuth(), he = i.usePasskey(), Q = y(() => {
194
+ i?.user?.sourceProvider === "passkey" ? he.switchPassport(i.user) : ["google", "apple", "email", "github"].includes(i?.user?.sourceProvider ?? "") ? me.switchOAuthPassport(i.user) : i && i.switchPassport();
195
+ }), M = u(() => q ? /* @__PURE__ */ f(
196
+ l,
191
197
  {
192
198
  sx: {
193
199
  display: "flex",
@@ -195,9 +201,9 @@ function Dr({
195
201
  gap: 2.5
196
202
  },
197
203
  children: [
198
- i ? /* @__PURE__ */ f(a, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
199
- /* @__PURE__ */ e(
200
- me,
204
+ n ? /* @__PURE__ */ f(l, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1.5, p: 2 }, children: [
205
+ /* @__PURE__ */ r(
206
+ be,
201
207
  {
202
208
  sx: {
203
209
  color: "text.primary",
@@ -207,25 +213,25 @@ function Dr({
207
213
  children: g("passport")
208
214
  }
209
215
  ),
210
- /* @__PURE__ */ e(Ue, { user: n.data })
216
+ /* @__PURE__ */ r(Ie, { user: o.data })
211
217
  ] }) : null,
212
- /* @__PURE__ */ e(Ie, { user: n.data })
218
+ /* @__PURE__ */ r(_e, { user: o.data })
213
219
  ]
214
220
  }
215
- ) : O && i ? E : ce && i ? /* @__PURE__ */ e(Fe, { children: /* @__PURE__ */ e(Re, {}) }) : null, [O, q, n, i, R, E]), G = d(() => /* @__PURE__ */ e(
216
- a,
221
+ ) : O && n ? R : pe && n ? /* @__PURE__ */ r(He, { children: /* @__PURE__ */ r(Ne, {}) }) : null, [O, q, o, n, I, R]), V = u(() => /* @__PURE__ */ r(
222
+ l,
217
223
  {
218
224
  sx: {
219
225
  display: {
220
- xs: i ? "none" : "block",
226
+ xs: n ? "none" : "block",
221
227
  md: "block"
222
228
  },
223
229
  py: 3
224
230
  },
225
- children: /* @__PURE__ */ e(M, { children: g("emptyContent") })
231
+ children: /* @__PURE__ */ r(D, { children: g("emptyContent") })
226
232
  }
227
- ), [i, x]), J = d(() => !m.data || m.loading ? /* @__PURE__ */ e(
228
- a,
233
+ ), [n, x]), $ = u(() => !m.data || m.loading ? /* @__PURE__ */ r(
234
+ l,
229
235
  {
230
236
  sx: {
231
237
  height: "100%",
@@ -236,27 +242,27 @@ function Dr({
236
242
  alignItems: "center",
237
243
  flex: 1
238
244
  },
239
- children: /* @__PURE__ */ e(he, {})
245
+ children: /* @__PURE__ */ r(ve, {})
240
246
  }
241
247
  ) : (
242
248
  // eslint-disable-next-line react/jsx-no-useless-fragment
243
- /* @__PURE__ */ e(a, { sx: { flex: 1 }, children: s?.protected && !i ? /* @__PURE__ */ e(a, { children: /* @__PURE__ */ e(M, { children: g("underProtected") }) }) : (
249
+ /* @__PURE__ */ r(l, { sx: { flex: 1 }, children: s?.protected && !n ? /* @__PURE__ */ r(l, { children: /* @__PURE__ */ r(D, { children: g("underProtected") }) }) : (
244
250
  // eslint-disable-next-line react/jsx-no-useless-fragment
245
- /* @__PURE__ */ e(D, { children: v ? /* @__PURE__ */ e(a, { ...B, children: v }) : /* @__PURE__ */ e(D, { children: S }) })
251
+ /* @__PURE__ */ r(S, { children: b ? /* @__PURE__ */ r(l, { ...B, children: ce(b) }) : /* @__PURE__ */ r(S, { children: M }) })
246
252
  ) })
247
- ), [m, s, i, v, B, S, x]), K = d(() => {
248
- if (n.loading || t.loading)
253
+ ), [m, s, n, b, B, M, x]), G = u(() => {
254
+ if (o.loading || i.loading)
249
255
  return null;
250
- if (n.error) {
251
- if (n.error?.response?.status === 404)
252
- return /* @__PURE__ */ e(a, { sx: { width: "100%" }, children: /* @__PURE__ */ e(ye, { status: 404, description: g("noUserFound") }) });
253
- const b = {
254
- message: n.error.response?.data?.error || n.error.message || "error occurred"
256
+ if (o.error) {
257
+ if (o.error?.response?.status === 404)
258
+ return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Me, { status: 404, description: g("noUserFound") }) });
259
+ const v = {
260
+ message: o.error.response?.data?.error || o.error.message || "error occurred"
255
261
  };
256
- return /* @__PURE__ */ e(a, { sx: { width: "100%" }, children: /* @__PURE__ */ e(Se, { error: b }) });
262
+ return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Te, { error: v }) });
257
263
  }
258
- return !p && !n.data ? L || /* @__PURE__ */ e(a, { sx: { width: "100%" }, children: /* @__PURE__ */ f(
259
- a,
264
+ return !p && !o.data ? L || /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ f(
265
+ l,
260
266
  {
261
267
  sx: {
262
268
  display: "flex",
@@ -266,54 +272,54 @@ function Dr({
266
272
  gap: 1
267
273
  },
268
274
  children: [
269
- /* @__PURE__ */ e(M, { children: g("viewAfterLogin") }),
270
- /* @__PURE__ */ e(we, { size: "small", variant: "contained", onClick: () => t.login(), children: g("loginNow") })
275
+ /* @__PURE__ */ r(D, { children: g("viewAfterLogin") }),
276
+ /* @__PURE__ */ r(Pe, { size: "small", variant: "contained", onClick: () => i.login(), children: g("loginNow") })
271
277
  ]
272
278
  }
273
- ) }) : I ? /* @__PURE__ */ f(U, { children: [
274
- c.length > 0 && h ? /* @__PURE__ */ e(
275
- a,
279
+ ) }) : j ? /* @__PURE__ */ f(U, { children: [
280
+ a.length > 0 && h ? /* @__PURE__ */ r(
281
+ l,
276
282
  {
277
283
  sx: {
278
- display: l ? "block" : "flex",
284
+ display: d ? "block" : "flex",
279
285
  height: "100%",
280
286
  overflow: "auto",
281
287
  padding: "1px"
282
288
  },
283
- children: J
289
+ children: $
284
290
  }
285
291
  ) : null,
286
- c.length === 0 && G
287
- ] }) : w ? /* @__PURE__ */ e(U, { display: "flex", flexDirection: l ? "column" : "row", children: /* @__PURE__ */ e(
288
- re,
292
+ a.length === 0 && V
293
+ ] }) : w ? /* @__PURE__ */ r(U, { display: "flex", flexDirection: d ? "column" : "row", children: /* @__PURE__ */ r(
294
+ ie,
289
295
  {
290
- isMobile: l,
291
- order: l ? 1 : "unset",
292
- isMyself: i,
296
+ isMobile: d,
297
+ order: d ? 1 : "unset",
298
+ isMyself: n,
293
299
  switchPassport: Q,
294
- switchProfile: t.switchProfile,
295
- user: n.data,
300
+ switchProfile: i.switchProfile,
301
+ user: o.data,
296
302
  showFullDid: !1,
297
303
  onlyProfile: w,
298
- refreshProfile: j,
304
+ refreshProfile: E,
299
305
  sx: {
300
- padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
301
- ...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
306
+ padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
307
+ ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
302
308
  boxSizing: "content-box"
303
309
  }
304
310
  }
305
- ) }) : /* @__PURE__ */ f(U, { display: "flex", flexDirection: l ? "column" : "row", children: [
311
+ ) }) : /* @__PURE__ */ f(U, { display: "flex", flexDirection: d ? "column" : "row", children: [
306
312
  /* @__PURE__ */ f(
307
- a,
313
+ l,
308
314
  {
309
315
  className: "user-center-tabs",
310
316
  sx: {
311
317
  flex: "1",
312
- order: l ? 2 : "unset"
318
+ order: d ? 2 : "unset"
313
319
  },
314
320
  children: [
315
- c.length > 0 && h ? /* @__PURE__ */ f(
316
- a,
321
+ a.length > 0 && h ? /* @__PURE__ */ f(
322
+ l,
317
323
  {
318
324
  sx: {
319
325
  display: "flex",
@@ -323,21 +329,21 @@ function Dr({
323
329
  padding: "1px"
324
330
  },
325
331
  children: [
326
- /* @__PURE__ */ e(
327
- be,
332
+ /* @__PURE__ */ r(
333
+ ke,
328
334
  {
329
335
  orientation: "horizontal",
330
336
  variant: "line",
331
- tabs: c,
337
+ tabs: a,
332
338
  current: s?.value ?? h,
333
- onChange: de,
339
+ onChange: fe,
334
340
  enableTabClick: !0,
335
341
  sx: {
336
- mb: 2,
342
+ mb: (e) => `${e.spacing(3)} !important`,
337
343
  ".MuiTabs-flexContainer": {
338
344
  gap: 3,
339
345
  ".MuiButtonBase-root": {
340
- padding: l ? "16px 4px" : "32px 4px 16px 4px",
346
+ padding: d ? "16px 4px" : "32px 4px 16px 4px",
341
347
  fontSize: 16
342
348
  },
343
349
  ".MuiTab-root": {
@@ -345,13 +351,20 @@ function Dr({
345
351
  textAlign: "left",
346
352
  alignItems: "flex-start",
347
353
  justifyContent: "flex-start",
348
- fontWeight: 400
354
+ fontWeight: 400,
355
+ mr: 0
349
356
  }
350
357
  },
351
- ".MuiTabs-root": {
358
+ ".MuiTabs-indicator": {
359
+ zIndex: 2
360
+ },
361
+ ".MuiTabs-scroller": {
352
362
  "&:after": {
353
363
  content: '""',
354
364
  display: "block",
365
+ position: "sticky",
366
+ left: 0,
367
+ zIndex: 1,
355
368
  width: "100%",
356
369
  height: "1px",
357
370
  backgroundColor: "divider"
@@ -360,60 +373,60 @@ function Dr({
360
373
  }
361
374
  }
362
375
  ),
363
- J
376
+ $
364
377
  ]
365
378
  }
366
379
  ) : null,
367
- c.length === 0 && G
380
+ a.length === 0 && V
368
381
  ]
369
382
  }
370
383
  ),
371
- !l && /* @__PURE__ */ e(xe, { orientation: "vertical", sx: { ml: 5 } }),
372
- /* @__PURE__ */ e(
373
- re,
384
+ !d && /* @__PURE__ */ r(we, { orientation: "vertical", sx: { ml: 5 } }),
385
+ /* @__PURE__ */ r(
386
+ ie,
374
387
  {
375
- isMobile: l,
376
- order: l ? 1 : "unset",
377
- isMyself: i,
388
+ isMobile: d,
389
+ order: d ? 1 : "unset",
390
+ isMyself: n,
378
391
  switchPassport: Q,
379
- switchProfile: t.switchProfile,
380
- user: n.data,
381
- refreshProfile: j,
392
+ switchProfile: i.switchProfile,
393
+ user: o.data,
394
+ refreshProfile: E,
382
395
  showFullDid: !1,
383
396
  sx: {
384
- padding: l ? "16px 0 0 0" : "40px 24px 24px 40px",
385
- ...l ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
397
+ padding: d ? "16px 0 0 0" : "40px 24px 24px 40px",
398
+ ...d ? {} : { width: 320, maxWidth: 320, flexShrink: 0 },
386
399
  boxSizing: "content-box"
387
400
  }
388
401
  }
389
402
  )
390
403
  ] });
391
404
  }, [
405
+ o,
406
+ a,
392
407
  n,
393
- c,
394
- i,
395
408
  s,
396
409
  m,
397
410
  h,
398
- R,
399
- S
400
- ]), V = d(() => i ? !1 : s?.isPrivate, [i, s]);
401
- if (d(() => w ? !1 : !F && !h && c?.length > 0 || !s || V, [F, h, c, s, V, w])) {
402
- const r = c[0]?.url, o = c.find((b) => b.value === r);
403
- return r && !o?.isPrivate && window.location.replace(
404
- $(r, {
405
- did: i ? void 0 : p
411
+ I,
412
+ M
413
+ ]), J = u(() => n ? !1 : s?.isPrivate, [n, s]);
414
+ if (u(() => w ? !1 : !F && !h && a?.length > 0 || !s || J, [F, h, a, s, J, w])) {
415
+ const e = a[0]?.url, t = a.find((v) => v.value === e);
416
+ return e && !t?.isPrivate && window.location.replace(
417
+ re(e, {
418
+ did: n ? void 0 : p
406
419
  })
407
420
  ), null;
408
421
  }
409
- return I || w ? /* @__PURE__ */ f(D, { children: [
410
- /* @__PURE__ */ e(ee, { style: { display: "none" } }),
411
- /* @__PURE__ */ f(ie, { children: [
412
- K,
422
+ return j || w ? /* @__PURE__ */ f(S, { children: [
423
+ /* @__PURE__ */ r(te, { style: { display: "none" } }),
424
+ /* @__PURE__ */ f(oe, { children: [
425
+ G,
413
426
  H
414
427
  ] })
415
428
  ] }) : /* @__PURE__ */ f(
416
- a,
429
+ l,
417
430
  {
418
431
  sx: {
419
432
  minHeight: "100vh",
@@ -421,16 +434,16 @@ function Dr({
421
434
  flexDirection: "column"
422
435
  },
423
436
  children: [
424
- /* @__PURE__ */ e(ee, { bordered: !0, ...se, maxWidth: "100%" }),
425
- /* @__PURE__ */ f(ie, { children: [
426
- K,
437
+ /* @__PURE__ */ r(te, { bordered: !0, ...le, maxWidth: "100%" }),
438
+ /* @__PURE__ */ f(oe, { children: [
439
+ G,
427
440
  H
428
441
  ] }),
429
- ne ? null : /* @__PURE__ */ e(
430
- Te,
442
+ ae ? null : /* @__PURE__ */ r(
443
+ Ue,
431
444
  {
432
445
  bordered: !0,
433
- ...ae,
446
+ ...de,
434
447
  sx: {
435
448
  ".MuiContainer-root": {
436
449
  maxWidth: 1600
@@ -443,5 +456,5 @@ function Dr({
443
456
  );
444
457
  }
445
458
  export {
446
- Dr as default
459
+ Wr as default
447
460
  };
@@ -1,12 +1,12 @@
1
- import { jsxs as a, jsx as i } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
2
  import { useState as S, useMemo as d, useCallback as u } from "react";
3
3
  import p from "prop-types";
4
- import { Dialog as T, DialogContent as A, Typography as c, Box as C, DialogActions as W, Button as f } from "@mui/material";
5
- import { useMemoizedFn as v } from "ahooks";
6
- import { translate as M } from "@arcblock/ux/lib/Locale/util";
7
- import { joinURL as O } from "ufo";
4
+ import { Dialog as T, DialogContent as C, Typography as c, Box as W, DialogActions as v, Button as f } from "@mui/material";
5
+ import { useMemoizedFn as M } from "ahooks";
6
+ import { translate as O } from "@arcblock/ux/lib/Locale/util";
7
+ import { joinURL as A } from "ufo";
8
8
  import j from "../hooks/use-mobile.js";
9
- const z = ["admin", "owner"], I = (t) => t.endsWith(".ip.abtnet.io"), E = (t) => t.endsWith(".did.abtnet.io"), H = {
9
+ const z = ["admin", "owner"], I = (i) => i.endsWith(".ip.abtnet.io"), E = (i) => i.endsWith(".did.abtnet.io"), H = {
10
10
  en: {
11
11
  guest: {
12
12
  title: "Notice: You are using a temporary domain",
@@ -42,13 +42,13 @@ const z = ["admin", "owner"], I = (t) => t.endsWith(".ip.abtnet.io"), E = (t) =>
42
42
  bindDomain: "配置域名"
43
43
  }
44
44
  }, N = 1e3 * 60 * 60 * 24 * 30, w = ".well-known/service/admin/domains";
45
- function P({ locale: t = "en", session: h = {} }) {
45
+ function P({ locale: i = "en", session: h = {} }) {
46
46
  const l = h?.user, b = j(), [g, s] = S(() => {
47
47
  const e = window.localStorage.getItem("domain-warning-skip");
48
48
  if (!e) return !0;
49
- const r = +/* @__PURE__ */ new Date(), y = +new Date(e);
50
- return r - y > N;
51
- }), n = v((e, r = {}) => M(H, e, t, "en", r)), m = d(() => {
49
+ const r = +/* @__PURE__ */ new Date(), k = +new Date(e);
50
+ return r - k > N;
51
+ }), n = M((e, r = {}) => O(H, e, i, "en", r)), m = d(() => {
52
52
  try {
53
53
  const { hostname: e } = new URL(window.location.href);
54
54
  return e;
@@ -66,13 +66,13 @@ function P({ locale: t = "en", session: h = {} }) {
66
66
  [n]
67
67
  ), D = u(() => {
68
68
  window.localStorage.setItem("domain-warning-skip", (/* @__PURE__ */ new Date()).toISOString()), s(!1);
69
- }, []), k = u(() => {
70
- const e = O(window.location.origin, w);
69
+ }, []), y = u(() => {
70
+ const e = A(window.location.origin, w);
71
71
  e.startsWith("http") && window.open(e, "_blank"), s(!1);
72
72
  }, []), o = l?.role && z.includes(l.role);
73
73
  return window.location.href.includes(w) || b || !I(m) && !E(m) ? null : /* @__PURE__ */ a(T, { open: g, disableEscapeKeyDown: !0, fullWidth: !0, maxWidth: "sm", onClose: () => s(!1), children: [
74
- /* @__PURE__ */ a(A, { sx: { padding: "20px !important" }, children: [
75
- /* @__PURE__ */ i(
74
+ /* @__PURE__ */ a(C, { sx: { padding: "20px !important" }, children: [
75
+ /* @__PURE__ */ t(
76
76
  c,
77
77
  {
78
78
  sx: {
@@ -82,33 +82,33 @@ function P({ locale: t = "en", session: h = {} }) {
82
82
  children: n(o ? "owner.title" : "guest.title")
83
83
  }
84
84
  ),
85
- /* @__PURE__ */ i(
85
+ /* @__PURE__ */ t(
86
86
  c,
87
87
  {
88
88
  sx: {
89
89
  marginTop: "20px",
90
90
  fontSize: "14px",
91
- color: "#9397A1"
91
+ color: "text.secondary"
92
92
  },
93
93
  children: n(o ? "owner.description" : "guest.description")
94
94
  }
95
95
  ),
96
- o && /* @__PURE__ */ i(C, { component: "ul", children: x.map((e) => /* @__PURE__ */ i(
96
+ o && /* @__PURE__ */ t(W, { component: "ul", children: x.map((e) => /* @__PURE__ */ t(
97
97
  c,
98
98
  {
99
99
  component: "li",
100
100
  sx: {
101
101
  fontSize: "14px",
102
- color: "#9397A1"
102
+ color: "text.secondary"
103
103
  },
104
104
  children: e
105
105
  },
106
106
  e
107
107
  )) })
108
108
  ] }),
109
- /* @__PURE__ */ a(W, { sx: { px: "12px !important" }, children: [
110
- /* @__PURE__ */ i(f, { onClick: D, children: n("skip") }),
111
- o && /* @__PURE__ */ i(f, { variant: "contained", onClick: k, children: n("bindDomain") })
109
+ /* @__PURE__ */ a(v, { sx: { px: "12px !important" }, children: [
110
+ /* @__PURE__ */ t(f, { onClick: D, children: n("skip") }),
111
+ o && /* @__PURE__ */ t(f, { variant: "contained", onClick: y, children: n("bindDomain") })
112
112
  ] })
113
113
  ] });
114
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.0.25",
3
+ "version": "3.0.27",
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.25",
39
- "@arcblock/icons": "3.0.25",
40
- "@arcblock/react-hooks": "3.0.25",
38
+ "@arcblock/bridge": "3.0.27",
39
+ "@arcblock/icons": "3.0.27",
40
+ "@arcblock/react-hooks": "3.0.27",
41
41
  "@arcblock/ws": "^1.20.15",
42
42
  "@blocklet/constant": "^1.16.46",
43
43
  "@blocklet/did-space-react": "^1.1.6",
@@ -90,5 +90,5 @@
90
90
  "jest": "^29.7.0",
91
91
  "unbuild": "^2.0.0"
92
92
  },
93
- "gitHead": "4f1f8b69bdd71bd8dee091312a9923e6fb9b8f41"
93
+ "gitHead": "b1e137e0c74f4b58af16b1d75a65166b163cf65d"
94
94
  }
@@ -1,6 +1,6 @@
1
- import { use } from 'react';
1
+ import { Children, cloneElement, isValidElement, use } from 'react';
2
2
  import { Box, CircularProgress, Divider, Typography } from '@mui/material';
3
- import type { BoxProps } from '@mui/material';
3
+ import type { BoxProps, Theme } from '@mui/material';
4
4
  import { useCreation, useMemoizedFn, useRequest } from 'ahooks';
5
5
  import pWaitFor from 'p-wait-for';
6
6
 
@@ -263,6 +263,30 @@ export default function UserCenter({
263
263
  return userCenterTabs.find((x) => withoutTrailingSlash(x.value) === withoutTrailingSlash(currentTab));
264
264
  }, [userCenterTabs]);
265
265
 
266
+ // 辅助函数:给 children 注入 userCenterTabs 属性
267
+ const renderChildrenWithProps = useMemoizedFn((childrenToRender: any) => {
268
+ if (!childrenToRender) return childrenToRender;
269
+
270
+ // 如果 children 是单个 React 元素,克隆并注入 props
271
+ if (isValidElement(childrenToRender)) {
272
+ return cloneElement(childrenToRender as any, {
273
+ ...(childrenToRender.props || {}),
274
+ userCenterTabs,
275
+ });
276
+ }
277
+
278
+ // 如果 children 是数组,遍历每个元素并注入 props
279
+ return Children.map(childrenToRender, (child) => {
280
+ if (isValidElement(child)) {
281
+ return cloneElement(child as any, {
282
+ ...(child.props || {}),
283
+ userCenterTabs,
284
+ });
285
+ }
286
+ return child;
287
+ });
288
+ });
289
+
266
290
  const handleChangeTab = useMemoizedFn((value) => {
267
291
  const findTab = userCenterTabs.find((x) => x.value === value);
268
292
  if (findTab) {
@@ -402,7 +426,7 @@ export default function UserCenter({
402
426
  </Box>
403
427
  ) : (
404
428
  // eslint-disable-next-line react/jsx-no-useless-fragment
405
- <>{children ? <Box {...contentProps}>{children}</Box> : <>{renderDefaultTab}</>}</>
429
+ <>{children ? <Box {...contentProps}>{renderChildrenWithProps(children)}</Box> : <>{renderDefaultTab}</>}</>
406
430
  )}
407
431
  </Box>
408
432
  );
@@ -528,7 +552,7 @@ export default function UserCenter({
528
552
  onChange={handleChangeTab}
529
553
  enableTabClick
530
554
  sx={{
531
- mb: 2,
555
+ mb: (theme: Theme) => `${theme.spacing(3)} !important`,
532
556
  '.MuiTabs-flexContainer': {
533
557
  gap: 3,
534
558
  '.MuiButtonBase-root': {
@@ -541,12 +565,19 @@ export default function UserCenter({
541
565
  alignItems: 'flex-start',
542
566
  justifyContent: 'flex-start',
543
567
  fontWeight: 400,
568
+ mr: 0,
544
569
  },
545
570
  },
546
- '.MuiTabs-root': {
571
+ '.MuiTabs-indicator': {
572
+ zIndex: 2,
573
+ },
574
+ '.MuiTabs-scroller': {
547
575
  '&:after': {
548
576
  content: '""',
549
577
  display: 'block',
578
+ position: 'sticky',
579
+ left: 0,
580
+ zIndex: 1,
550
581
  width: '100%',
551
582
  height: '1px',
552
583
  backgroundColor: 'divider',
@@ -138,7 +138,7 @@ export default function DomainWarning({ locale = 'en', session = {} }) {
138
138
  sx={{
139
139
  marginTop: '20px',
140
140
  fontSize: '14px',
141
- color: '#9397A1',
141
+ color: 'text.secondary',
142
142
  }}>
143
143
  {isOwner ? t('owner.description') : t('guest.description')}
144
144
  </Typography>
@@ -151,7 +151,7 @@ export default function DomainWarning({ locale = 'en', session = {} }) {
151
151
  key={benefit}
152
152
  sx={{
153
153
  fontSize: '14px',
154
- color: '#9397A1',
154
+ color: 'text.secondary',
155
155
  }}>
156
156
  {benefit}
157
157
  </Typography>