@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
|
|
3
|
-
import { Box as l, Typography as
|
|
4
|
-
import { useMemoizedFn as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { SessionContext as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { useConfirm as
|
|
13
|
-
import { translate as
|
|
14
|
-
import { useLocaleContext as
|
|
15
|
-
import { ErrorFallback as
|
|
16
|
-
import { styled as
|
|
17
|
-
import
|
|
18
|
-
import { joinURL as
|
|
19
|
-
import { isSupportFollow as
|
|
20
|
-
import { PROFILE_URL as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { translations as
|
|
24
|
-
import
|
|
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
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import { client as
|
|
39
|
-
import
|
|
40
|
-
import { ConfigUserSpaceProvider as
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import { UserFollowersProvider as
|
|
44
|
-
import
|
|
45
|
-
const
|
|
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
|
-
[
|
|
60
|
+
[b.breakpoints.up("md")]: {
|
|
57
61
|
flexDirection: "row"
|
|
58
62
|
}
|
|
59
|
-
})),
|
|
63
|
+
})), I = pe(l)(({ theme: b }) => ({
|
|
60
64
|
overflow: "hidden",
|
|
61
65
|
flex: "revert",
|
|
62
|
-
[
|
|
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
|
|
72
|
-
children:
|
|
73
|
-
notLoginContent:
|
|
74
|
-
currentTab:
|
|
75
|
-
contentProps:
|
|
76
|
-
disableAutoRedirect:
|
|
77
|
-
hideFooter:
|
|
78
|
-
headerProps:
|
|
79
|
-
footerProps:
|
|
80
|
-
userDid:
|
|
81
|
-
stickySidebar:
|
|
82
|
-
embed:
|
|
83
|
-
onlyProfile:
|
|
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:
|
|
89
|
+
onDestroySelf: ge = void 0
|
|
86
90
|
}) {
|
|
87
|
-
const { locale: x, defaultLocale: k } =
|
|
88
|
-
if (
|
|
89
|
-
return
|
|
90
|
-
const e = window.location.href, t =
|
|
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,
|
|
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
|
|
99
|
+
if (await Fe(() => o?.initialized), i)
|
|
96
100
|
return o.user;
|
|
97
101
|
if (h)
|
|
98
|
-
return
|
|
102
|
+
return ue.user.getUserPublicInfo({ did: h });
|
|
99
103
|
},
|
|
100
104
|
{
|
|
101
105
|
refreshDeps: [h, i, o?.initialized, o?.user]
|
|
102
106
|
}
|
|
103
|
-
),
|
|
104
|
-
async () => n.data &&
|
|
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,
|
|
110
|
+
refreshDeps: [h, n.data, v],
|
|
107
111
|
loadingDelay: 300
|
|
108
112
|
}
|
|
109
|
-
), { confirmHolder:
|
|
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
|
-
}),
|
|
130
|
-
const e =
|
|
133
|
+
}), $ = u(() => {
|
|
134
|
+
const e = Ne(window.blocklet);
|
|
131
135
|
try {
|
|
132
|
-
return
|
|
136
|
+
return Oe(e);
|
|
133
137
|
} catch (t) {
|
|
134
138
|
return console.error("Failed to format blocklet info", t, e), e;
|
|
135
139
|
}
|
|
136
|
-
}, []),
|
|
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:
|
|
143
|
-
url:
|
|
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:
|
|
149
|
-
url:
|
|
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
|
|
157
|
+
const L = [
|
|
154
158
|
e,
|
|
155
159
|
{
|
|
156
160
|
label: f("common.setting"),
|
|
157
161
|
protected: !0,
|
|
158
162
|
isPrivate: !0,
|
|
159
|
-
value:
|
|
160
|
-
url:
|
|
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:
|
|
167
|
-
url:
|
|
170
|
+
value: z,
|
|
171
|
+
url: D(z, x, k)
|
|
168
172
|
}
|
|
169
173
|
];
|
|
170
|
-
p = w ? [...
|
|
174
|
+
p = w ? [...L, t] : L;
|
|
171
175
|
}
|
|
172
176
|
return p;
|
|
173
177
|
}, [i, x, w]), d = u(() => {
|
|
174
|
-
const e =
|
|
175
|
-
return (
|
|
176
|
-
const
|
|
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:
|
|
182
|
+
value: re,
|
|
179
183
|
label: c.title || c.label,
|
|
180
184
|
url: c.link || c.url,
|
|
181
|
-
protected: g?.data?.[
|
|
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
|
-
}, [
|
|
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]),
|
|
196
|
+
}, [s, f]), be = P((e) => e && (te(e) ? ie(e, {
|
|
193
197
|
...e.props || {},
|
|
194
198
|
userCenterTabs: d
|
|
195
|
-
}) :
|
|
199
|
+
}) : Se.map(e, (t) => te(t) ? ie(t, {
|
|
196
200
|
...t.props || {},
|
|
197
201
|
userCenterTabs: d
|
|
198
|
-
}) : t))),
|
|
202
|
+
}) : t))), ve = P((e) => {
|
|
199
203
|
const t = d.find((p) => p.value === e);
|
|
200
|
-
t && (window.location.href =
|
|
204
|
+
t && (window.location.href = le(t.url, {
|
|
201
205
|
did: i ? void 0 : h
|
|
202
206
|
}));
|
|
203
|
-
}),
|
|
204
|
-
|
|
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:
|
|
214
|
+
onDestroySelf: ge
|
|
211
215
|
}
|
|
212
|
-
), [n.data, d, g.data, g.runAsync]),
|
|
213
|
-
o?.user?.sourceProvider === "passkey" ?
|
|
214
|
-
}),
|
|
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
|
-
|
|
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(
|
|
239
|
+
/* @__PURE__ */ r($e, { user: n.data })
|
|
236
240
|
] }) : null,
|
|
237
|
-
/* @__PURE__ */ r(
|
|
241
|
+
/* @__PURE__ */ r(Je, { user: n.data })
|
|
238
242
|
]
|
|
239
243
|
}
|
|
240
|
-
) :
|
|
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(
|
|
254
|
+
children: /* @__PURE__ */ r(B, { children: f("emptyContent") })
|
|
251
255
|
}
|
|
252
|
-
), [i, x]),
|
|
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(
|
|
268
|
+
children: /* @__PURE__ */ r(Me, {})
|
|
265
269
|
}
|
|
266
270
|
) : /* @__PURE__ */ r(l, { sx: { flex: 1 }, children: /* @__PURE__ */ r(
|
|
267
|
-
|
|
271
|
+
Ke,
|
|
268
272
|
{
|
|
269
273
|
isSupportFollow: w,
|
|
270
274
|
currentActiveTab: s,
|
|
271
275
|
isMyself: i,
|
|
272
|
-
children:
|
|
276
|
+
children: b ? /* @__PURE__ */ r(l, { ...j, children: be(b) }) : A
|
|
273
277
|
}
|
|
274
|
-
) }), [g, s, i,
|
|
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(
|
|
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(
|
|
287
|
+
return /* @__PURE__ */ r(l, { sx: { width: "100%" }, children: /* @__PURE__ */ r(Ie, { error: p }) });
|
|
284
288
|
}
|
|
285
|
-
return !h && !n.data ?
|
|
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(
|
|
297
|
-
/* @__PURE__ */ r(
|
|
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(
|
|
301
|
-
/* @__PURE__ */ r(
|
|
302
|
-
/* @__PURE__ */ r(
|
|
303
|
-
] }) }) :
|
|
304
|
-
d.length > 0 &&
|
|
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:
|
|
317
|
+
children: Y
|
|
314
318
|
}
|
|
315
319
|
) : null,
|
|
316
|
-
d.length === 0 &&
|
|
317
|
-
] }) :
|
|
318
|
-
|
|
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:
|
|
327
|
+
switchPassport: K,
|
|
324
328
|
switchProfile: o.switchProfile,
|
|
325
329
|
user: n.data,
|
|
326
330
|
showFullDid: !1,
|
|
327
|
-
onlyProfile:
|
|
328
|
-
refreshProfile:
|
|
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(
|
|
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 &&
|
|
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
|
-
|
|
363
|
+
ze,
|
|
360
364
|
{
|
|
361
365
|
orientation: "horizontal",
|
|
362
366
|
variant: "line",
|
|
363
367
|
tabs: d,
|
|
364
|
-
current: s?.value ??
|
|
365
|
-
onChange:
|
|
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
|
-
|
|
406
|
+
Y
|
|
403
407
|
]
|
|
404
408
|
}
|
|
405
409
|
) : null,
|
|
406
|
-
d.length === 0 &&
|
|
410
|
+
d.length === 0 && X
|
|
407
411
|
]
|
|
408
412
|
}
|
|
409
413
|
),
|
|
410
|
-
!a && /* @__PURE__ */ r(
|
|
414
|
+
!a && /* @__PURE__ */ r(De, { orientation: "vertical", sx: { ml: 5 } }),
|
|
411
415
|
/* @__PURE__ */ r(
|
|
412
|
-
|
|
416
|
+
de,
|
|
413
417
|
{
|
|
414
418
|
isMobile: a,
|
|
415
419
|
order: a ? 1 : "unset",
|
|
416
420
|
isMyself: i,
|
|
417
|
-
switchPassport:
|
|
421
|
+
switchPassport: K,
|
|
418
422
|
switchProfile: o.switchProfile,
|
|
419
423
|
user: n.data,
|
|
420
|
-
refreshProfile:
|
|
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
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
]),
|
|
441
|
-
if (u(() =>
|
|
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
|
-
|
|
448
|
+
le(e, {
|
|
445
449
|
did: i ? void 0 : h
|
|
446
450
|
})
|
|
447
451
|
), null;
|
|
448
452
|
}
|
|
449
|
-
return
|
|
450
|
-
/* @__PURE__ */ r(
|
|
451
|
-
/* @__PURE__ */ r(
|
|
452
|
-
/* @__PURE__ */ m(
|
|
453
|
-
/* @__PURE__ */ r(
|
|
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(
|
|
466
|
-
/* @__PURE__ */ r(
|
|
467
|
-
/* @__PURE__ */ m(
|
|
468
|
-
/* @__PURE__ */ r(
|
|
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
|
-
|
|
472
|
-
|
|
475
|
+
me ? null : /* @__PURE__ */ r(
|
|
476
|
+
Ee,
|
|
473
477
|
{
|
|
474
478
|
bordered: !0,
|
|
475
|
-
...
|
|
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
|
-
|
|
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
|
+
"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.
|
|
39
|
-
"@arcblock/icons": "3.2.
|
|
40
|
-
"@arcblock/react-hooks": "3.2.
|
|
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.
|
|
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": "
|
|
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;
|