@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
|
|
2
|
-
import { use as
|
|
3
|
-
import { Box as
|
|
4
|
-
import { useMemoizedFn as y, useCreation as
|
|
5
|
-
import
|
|
6
|
-
import { SessionContext as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import { useConfirm as
|
|
12
|
-
import { translate as
|
|
13
|
-
import { useLocaleContext as
|
|
14
|
-
import { ErrorFallback as
|
|
15
|
-
import { styled as
|
|
16
|
-
import
|
|
17
|
-
import { joinURL as C, getQuery as
|
|
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
|
|
20
|
-
import
|
|
21
|
-
import { translations as
|
|
22
|
-
import
|
|
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
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import { client as
|
|
37
|
-
import
|
|
38
|
-
import { ConfigUserSpaceProvider as
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
const
|
|
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
|
-
[
|
|
52
|
+
[b.breakpoints.up("md")]: {
|
|
53
53
|
flexDirection: "row"
|
|
54
54
|
}
|
|
55
|
-
})), U =
|
|
55
|
+
})), U = se(l)(({ theme: b }) => ({
|
|
56
56
|
overflow: "hidden",
|
|
57
57
|
flex: "revert",
|
|
58
|
-
[
|
|
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
|
|
68
|
-
children:
|
|
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:
|
|
74
|
-
headerProps:
|
|
75
|
-
footerProps:
|
|
73
|
+
hideFooter: ae = !1,
|
|
74
|
+
headerProps: le = {},
|
|
75
|
+
footerProps: de = {},
|
|
76
76
|
userDid: P = void 0,
|
|
77
|
-
stickySidebar:
|
|
78
|
-
embed:
|
|
77
|
+
stickySidebar: I = !1,
|
|
78
|
+
embed: j = !1,
|
|
79
79
|
onlyProfile: w = !1,
|
|
80
80
|
// 只显示 profile 页面,用于 ArcSphere 只需要显示 Profile 的内容
|
|
81
|
-
onDestroySelf:
|
|
81
|
+
onDestroySelf: ue = void 0
|
|
82
82
|
}) {
|
|
83
|
-
const { locale: x } =
|
|
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
|
|
87
|
-
return
|
|
88
|
-
}, [
|
|
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
|
|
92
|
-
return
|
|
91
|
+
if (await ye(() => i?.initialized), n)
|
|
92
|
+
return i.user;
|
|
93
93
|
if (p)
|
|
94
|
-
return
|
|
94
|
+
return ne.user.getUserPublicInfo({ did: p });
|
|
95
95
|
},
|
|
96
96
|
{
|
|
97
|
-
refreshDeps: [p,
|
|
97
|
+
refreshDeps: [p, n, i?.initialized, i?.user]
|
|
98
98
|
}
|
|
99
|
-
),
|
|
100
|
-
async () =>
|
|
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,
|
|
102
|
+
refreshDeps: [p, o.data, h],
|
|
103
103
|
loadingDelay: 300
|
|
104
104
|
}
|
|
105
|
-
), { confirmHolder: H } =
|
|
106
|
-
fullScreen:
|
|
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 =
|
|
126
|
-
const
|
|
125
|
+
}), N = u(() => {
|
|
126
|
+
const e = We(window.blocklet);
|
|
127
127
|
try {
|
|
128
|
-
return
|
|
129
|
-
} catch (
|
|
130
|
-
return console.error("Failed to format blocklet info",
|
|
128
|
+
return Be(e);
|
|
129
|
+
} catch (t) {
|
|
130
|
+
return console.error("Failed to format blocklet info", t, e), e;
|
|
131
131
|
}
|
|
132
|
-
}, []), _ =
|
|
133
|
-
const
|
|
132
|
+
}, []), _ = u(() => {
|
|
133
|
+
const e = {
|
|
134
134
|
label: g("common.nft"),
|
|
135
135
|
protected: !1,
|
|
136
136
|
isPrivate: !1,
|
|
137
137
|
// true: 隐私数据,仅自己可见
|
|
138
|
-
value:
|
|
139
|
-
url: T
|
|
138
|
+
value: T,
|
|
139
|
+
url: z(T, x)
|
|
140
140
|
};
|
|
141
|
-
let
|
|
142
|
-
return
|
|
143
|
-
|
|
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:
|
|
149
|
-
url:
|
|
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:
|
|
156
|
+
url: z(A, x)
|
|
157
157
|
}
|
|
158
|
-
]),
|
|
159
|
-
}, [
|
|
160
|
-
const
|
|
161
|
-
return (
|
|
162
|
-
const
|
|
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:
|
|
165
|
-
label:
|
|
166
|
-
url:
|
|
167
|
-
protected: m?.data?.[
|
|
168
|
-
isPrivate:
|
|
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((
|
|
173
|
-
}, [N,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
}),
|
|
179
|
-
|
|
184
|
+
}), R = u(() => /* @__PURE__ */ r(
|
|
185
|
+
je,
|
|
180
186
|
{
|
|
181
|
-
user:
|
|
182
|
-
settings: { userCenterTabs:
|
|
183
|
-
onSave: async (
|
|
184
|
-
isMobile:
|
|
185
|
-
onDestroySelf:
|
|
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
|
-
), [
|
|
188
|
-
|
|
189
|
-
}),
|
|
190
|
-
|
|
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
|
-
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
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__ */
|
|
216
|
+
/* @__PURE__ */ r(Ie, { user: o.data })
|
|
211
217
|
] }) : null,
|
|
212
|
-
/* @__PURE__ */
|
|
218
|
+
/* @__PURE__ */ r(_e, { user: o.data })
|
|
213
219
|
]
|
|
214
220
|
}
|
|
215
|
-
) : O &&
|
|
216
|
-
|
|
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:
|
|
226
|
+
xs: n ? "none" : "block",
|
|
221
227
|
md: "block"
|
|
222
228
|
},
|
|
223
229
|
py: 3
|
|
224
230
|
},
|
|
225
|
-
children: /* @__PURE__ */
|
|
231
|
+
children: /* @__PURE__ */ r(D, { children: g("emptyContent") })
|
|
226
232
|
}
|
|
227
|
-
), [
|
|
228
|
-
|
|
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__ */
|
|
245
|
+
children: /* @__PURE__ */ r(ve, {})
|
|
240
246
|
}
|
|
241
247
|
) : (
|
|
242
248
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
243
|
-
/* @__PURE__ */
|
|
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__ */
|
|
251
|
+
/* @__PURE__ */ r(S, { children: b ? /* @__PURE__ */ r(l, { ...B, children: ce(b) }) : /* @__PURE__ */ r(S, { children: M }) })
|
|
246
252
|
) })
|
|
247
|
-
), [m, s,
|
|
248
|
-
if (
|
|
253
|
+
), [m, s, n, b, B, M, x]), G = u(() => {
|
|
254
|
+
if (o.loading || i.loading)
|
|
249
255
|
return null;
|
|
250
|
-
if (
|
|
251
|
-
if (
|
|
252
|
-
return /* @__PURE__ */
|
|
253
|
-
const
|
|
254
|
-
message:
|
|
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__ */
|
|
262
|
+
return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Te, { error: v }) });
|
|
257
263
|
}
|
|
258
|
-
return !p && !
|
|
259
|
-
|
|
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__ */
|
|
270
|
-
/* @__PURE__ */
|
|
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
|
-
) }) :
|
|
274
|
-
|
|
275
|
-
|
|
279
|
+
) }) : j ? /* @__PURE__ */ f(U, { children: [
|
|
280
|
+
a.length > 0 && h ? /* @__PURE__ */ r(
|
|
281
|
+
l,
|
|
276
282
|
{
|
|
277
283
|
sx: {
|
|
278
|
-
display:
|
|
284
|
+
display: d ? "block" : "flex",
|
|
279
285
|
height: "100%",
|
|
280
286
|
overflow: "auto",
|
|
281
287
|
padding: "1px"
|
|
282
288
|
},
|
|
283
|
-
children:
|
|
289
|
+
children: $
|
|
284
290
|
}
|
|
285
291
|
) : null,
|
|
286
|
-
|
|
287
|
-
] }) : w ? /* @__PURE__ */
|
|
288
|
-
|
|
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:
|
|
291
|
-
order:
|
|
292
|
-
isMyself:
|
|
296
|
+
isMobile: d,
|
|
297
|
+
order: d ? 1 : "unset",
|
|
298
|
+
isMyself: n,
|
|
293
299
|
switchPassport: Q,
|
|
294
|
-
switchProfile:
|
|
295
|
-
user:
|
|
300
|
+
switchProfile: i.switchProfile,
|
|
301
|
+
user: o.data,
|
|
296
302
|
showFullDid: !1,
|
|
297
303
|
onlyProfile: w,
|
|
298
|
-
refreshProfile:
|
|
304
|
+
refreshProfile: E,
|
|
299
305
|
sx: {
|
|
300
|
-
padding:
|
|
301
|
-
...
|
|
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:
|
|
311
|
+
) }) : /* @__PURE__ */ f(U, { display: "flex", flexDirection: d ? "column" : "row", children: [
|
|
306
312
|
/* @__PURE__ */ f(
|
|
307
|
-
|
|
313
|
+
l,
|
|
308
314
|
{
|
|
309
315
|
className: "user-center-tabs",
|
|
310
316
|
sx: {
|
|
311
317
|
flex: "1",
|
|
312
|
-
order:
|
|
318
|
+
order: d ? 2 : "unset"
|
|
313
319
|
},
|
|
314
320
|
children: [
|
|
315
|
-
|
|
316
|
-
|
|
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__ */
|
|
327
|
-
|
|
332
|
+
/* @__PURE__ */ r(
|
|
333
|
+
ke,
|
|
328
334
|
{
|
|
329
335
|
orientation: "horizontal",
|
|
330
336
|
variant: "line",
|
|
331
|
-
tabs:
|
|
337
|
+
tabs: a,
|
|
332
338
|
current: s?.value ?? h,
|
|
333
|
-
onChange:
|
|
339
|
+
onChange: fe,
|
|
334
340
|
enableTabClick: !0,
|
|
335
341
|
sx: {
|
|
336
|
-
mb:
|
|
342
|
+
mb: (e) => `${e.spacing(3)} !important`,
|
|
337
343
|
".MuiTabs-flexContainer": {
|
|
338
344
|
gap: 3,
|
|
339
345
|
".MuiButtonBase-root": {
|
|
340
|
-
padding:
|
|
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-
|
|
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
|
-
|
|
376
|
+
$
|
|
364
377
|
]
|
|
365
378
|
}
|
|
366
379
|
) : null,
|
|
367
|
-
|
|
380
|
+
a.length === 0 && V
|
|
368
381
|
]
|
|
369
382
|
}
|
|
370
383
|
),
|
|
371
|
-
!
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
|
|
384
|
+
!d && /* @__PURE__ */ r(we, { orientation: "vertical", sx: { ml: 5 } }),
|
|
385
|
+
/* @__PURE__ */ r(
|
|
386
|
+
ie,
|
|
374
387
|
{
|
|
375
|
-
isMobile:
|
|
376
|
-
order:
|
|
377
|
-
isMyself:
|
|
388
|
+
isMobile: d,
|
|
389
|
+
order: d ? 1 : "unset",
|
|
390
|
+
isMyself: n,
|
|
378
391
|
switchPassport: Q,
|
|
379
|
-
switchProfile:
|
|
380
|
-
user:
|
|
381
|
-
refreshProfile:
|
|
392
|
+
switchProfile: i.switchProfile,
|
|
393
|
+
user: o.data,
|
|
394
|
+
refreshProfile: E,
|
|
382
395
|
showFullDid: !1,
|
|
383
396
|
sx: {
|
|
384
|
-
padding:
|
|
385
|
-
...
|
|
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
|
-
|
|
399
|
-
|
|
400
|
-
]),
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
return
|
|
404
|
-
|
|
405
|
-
did:
|
|
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
|
|
410
|
-
/* @__PURE__ */
|
|
411
|
-
/* @__PURE__ */ f(
|
|
412
|
-
|
|
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
|
-
|
|
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__ */
|
|
425
|
-
/* @__PURE__ */ f(
|
|
426
|
-
|
|
437
|
+
/* @__PURE__ */ r(te, { bordered: !0, ...le, maxWidth: "100%" }),
|
|
438
|
+
/* @__PURE__ */ f(oe, { children: [
|
|
439
|
+
G,
|
|
427
440
|
H
|
|
428
441
|
] }),
|
|
429
|
-
|
|
430
|
-
|
|
442
|
+
ae ? null : /* @__PURE__ */ r(
|
|
443
|
+
Ue,
|
|
431
444
|
{
|
|
432
445
|
bordered: !0,
|
|
433
|
-
...
|
|
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
|
-
|
|
459
|
+
Wr as default
|
|
447
460
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as a, jsx as
|
|
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
|
|
5
|
-
import { useMemoizedFn as
|
|
6
|
-
import { translate as
|
|
7
|
-
import { joinURL as
|
|
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 = (
|
|
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:
|
|
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(),
|
|
50
|
-
return r -
|
|
51
|
-
}), n =
|
|
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
|
-
}, []),
|
|
70
|
-
const e =
|
|
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(
|
|
75
|
-
/* @__PURE__ */
|
|
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__ */
|
|
85
|
+
/* @__PURE__ */ t(
|
|
86
86
|
c,
|
|
87
87
|
{
|
|
88
88
|
sx: {
|
|
89
89
|
marginTop: "20px",
|
|
90
90
|
fontSize: "14px",
|
|
91
|
-
color: "
|
|
91
|
+
color: "text.secondary"
|
|
92
92
|
},
|
|
93
93
|
children: n(o ? "owner.description" : "guest.description")
|
|
94
94
|
}
|
|
95
95
|
),
|
|
96
|
-
o && /* @__PURE__ */
|
|
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: "
|
|
102
|
+
color: "text.secondary"
|
|
103
103
|
},
|
|
104
104
|
children: e
|
|
105
105
|
},
|
|
106
106
|
e
|
|
107
107
|
)) })
|
|
108
108
|
] }),
|
|
109
|
-
/* @__PURE__ */ a(
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
o && /* @__PURE__ */
|
|
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.
|
|
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.
|
|
39
|
-
"@arcblock/icons": "3.0.
|
|
40
|
-
"@arcblock/react-hooks": "3.0.
|
|
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": "
|
|
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:
|
|
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-
|
|
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: '
|
|
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: '
|
|
154
|
+
color: 'text.secondary',
|
|
155
155
|
}}>
|
|
156
156
|
{benefit}
|
|
157
157
|
</Typography>
|