@blocklet/ui-react 2.9.90 → 2.10.0
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.
- package/build.config.ts +1 -6
- package/lib/@types/index.d.ts +1 -0
- package/lib/@types/index.js +0 -1
- package/lib/BlockletStudio/index.js +50 -50
- package/lib/ComponentInstaller/index.js +122 -202
- package/lib/ComponentInstaller/installer-item.js +116 -138
- package/lib/ComponentInstaller/locales.js +5 -10
- package/lib/ComponentInstaller/use-component-installed.js +37 -41
- package/lib/ComponentManager/components/add-component.js +58 -67
- package/lib/ComponentManager/components/check-component.js +2 -9
- package/lib/ComponentManager/components/publish-component.js +50 -59
- package/lib/ComponentManager/components/resource-dialog.js +42 -39
- package/lib/ComponentManager/index.js +3 -27
- package/lib/ComponentManager/libs/locales.js +2 -8
- package/lib/Dashboard/index.js +74 -99
- package/lib/Footer/brand.js +21 -43
- package/lib/Footer/copyright.js +15 -24
- package/lib/Footer/index.js +47 -71
- package/lib/Footer/internal-footer.js +72 -100
- package/lib/Footer/layout/plain.js +26 -45
- package/lib/Footer/layout/row.js +12 -29
- package/lib/Footer/layout/standard.js +34 -64
- package/lib/Footer/links.js +74 -104
- package/lib/Footer/social-media.js +35 -42
- package/lib/Header/index.js +69 -117
- package/lib/Icon/index.js +18 -53
- package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
- package/lib/UserCenter/components/config-profile.js +67 -0
- package/lib/UserCenter/components/notification.js +203 -186
- package/lib/UserCenter/components/passport.js +70 -79
- package/lib/UserCenter/components/privacy.js +86 -88
- package/lib/UserCenter/components/settings.js +74 -84
- package/lib/UserCenter/components/storage/connect-to.js +56 -75
- package/lib/UserCenter/components/storage/connected.js +16 -37
- package/lib/UserCenter/components/storage/delete.js +42 -51
- package/lib/UserCenter/components/storage/disconnect.js +15 -29
- package/lib/UserCenter/components/storage/index.js +20 -54
- package/lib/UserCenter/components/storage/item.js +94 -122
- package/lib/UserCenter/components/storage/preview-nft.js +77 -85
- package/lib/UserCenter/components/third-party-login/index.js +49 -61
- package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
- package/lib/UserCenter/components/user-center.js +276 -287
- package/lib/UserCenter/components/user-info/index.js +3 -27
- package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
- package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
- package/lib/UserCenter/components/user-info/user-info.js +41 -74
- package/lib/UserCenter/components/webhook-item.js +184 -177
- package/lib/UserCenter/index.js +1 -13
- package/lib/UserCenter/libs/api.js +4 -16
- package/lib/UserCenter/libs/locales.d.ts +10 -0
- package/lib/UserCenter/libs/locales.js +12 -8
- package/lib/UserCenter/libs/utils.js +7 -17
- package/lib/UserSessions/components/user-session-info.js +88 -85
- package/lib/UserSessions/components/user-sessions.js +177 -213
- package/lib/UserSessions/index.js +1 -13
- package/lib/UserSessions/libs/locales.js +2 -8
- package/lib/UserSessions/libs/utils.js +4 -11
- package/lib/blocklets.js +59 -63
- package/lib/common/header-addons.js +44 -60
- package/lib/common/link-blocker.js +9 -18
- package/lib/common/overridable-theme-provider.js +10 -23
- package/lib/common/wallet-hidden-topbar.js +7 -14
- package/lib/contexts/config-user-space.js +38 -46
- package/lib/hooks/use-mobile.js +5 -13
- package/lib/index.js +10 -100
- package/lib/libs/client.js +2 -8
- package/lib/libs/spaces.js +6 -13
- package/lib/types.js +39 -41
- package/lib/utils.js +25 -44
- package/package.json +8 -38
- package/src/@types/index.ts +1 -0
- package/src/Footer/brand.jsx +6 -1
- package/src/UserCenter/components/config-profile.tsx +70 -0
- package/src/UserCenter/components/notification.tsx +63 -47
- package/src/UserCenter/components/settings.tsx +6 -0
- package/src/UserCenter/libs/locales.ts +10 -0
- package/es/@types/index.d.ts +0 -101
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +0 -16
- package/es/BlockletStudio/index.d.ts +0 -28
- package/es/BlockletStudio/index.js +0 -114
- package/es/ComponentInstaller/index.d.ts +0 -37
- package/es/ComponentInstaller/index.js +0 -200
- package/es/ComponentInstaller/installer-item.d.ts +0 -21
- package/es/ComponentInstaller/installer-item.js +0 -139
- package/es/ComponentInstaller/locales.d.ts +0 -28
- package/es/ComponentInstaller/locales.js +0 -22
- package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
- package/es/ComponentInstaller/use-component-installed.js +0 -88
- package/es/ComponentManager/components/add-component.d.ts +0 -16
- package/es/ComponentManager/components/add-component.js +0 -114
- package/es/ComponentManager/components/check-component.d.ts +0 -2
- package/es/ComponentManager/components/check-component.js +0 -2
- package/es/ComponentManager/components/publish-component.d.ts +0 -10
- package/es/ComponentManager/components/publish-component.js +0 -76
- package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
- package/es/ComponentManager/components/resource-dialog.js +0 -74
- package/es/ComponentManager/index.d.ts +0 -3
- package/es/ComponentManager/index.js +0 -3
- package/es/ComponentManager/libs/locales.d.ts +0 -14
- package/es/ComponentManager/libs/locales.js +0 -14
- package/es/Dashboard/index.d.ts +0 -40
- package/es/Dashboard/index.js +0 -118
- package/es/Footer/brand.d.ts +0 -22
- package/es/Footer/brand.js +0 -73
- package/es/Footer/copyright.d.ts +0 -18
- package/es/Footer/copyright.js +0 -25
- package/es/Footer/index.d.ts +0 -6
- package/es/Footer/index.js +0 -82
- package/es/Footer/internal-footer.d.ts +0 -29
- package/es/Footer/internal-footer.js +0 -117
- package/es/Footer/layout/plain.d.ts +0 -15
- package/es/Footer/layout/plain.js +0 -39
- package/es/Footer/layout/row.d.ts +0 -18
- package/es/Footer/layout/row.js +0 -41
- package/es/Footer/layout/standard.d.ts +0 -15
- package/es/Footer/layout/standard.js +0 -53
- package/es/Footer/links.d.ts +0 -22
- package/es/Footer/links.js +0 -207
- package/es/Footer/social-media.d.ts +0 -14
- package/es/Footer/social-media.js +0 -60
- package/es/Header/index.d.ts +0 -10
- package/es/Header/index.js +0 -155
- package/es/Icon/index.d.ts +0 -23
- package/es/Icon/index.js +0 -55
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.js +0 -248
- package/es/UserCenter/components/passport.d.ts +0 -6
- package/es/UserCenter/components/passport.js +0 -88
- package/es/UserCenter/components/privacy.d.ts +0 -11
- package/es/UserCenter/components/privacy.js +0 -99
- package/es/UserCenter/components/settings.d.ts +0 -9
- package/es/UserCenter/components/settings.js +0 -89
- package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
- package/es/UserCenter/components/storage/connect-to.js +0 -108
- package/es/UserCenter/components/storage/connected.d.ts +0 -7
- package/es/UserCenter/components/storage/connected.js +0 -24
- package/es/UserCenter/components/storage/delete.d.ts +0 -7
- package/es/UserCenter/components/storage/delete.js +0 -62
- package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
- package/es/UserCenter/components/storage/disconnect.js +0 -23
- package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
- package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
- package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
- package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
- package/es/UserCenter/components/storage/index.d.ts +0 -3
- package/es/UserCenter/components/storage/index.js +0 -27
- package/es/UserCenter/components/storage/item.d.ts +0 -9
- package/es/UserCenter/components/storage/item.js +0 -158
- package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
- package/es/UserCenter/components/storage/preview-nft.js +0 -80
- package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
- package/es/UserCenter/components/third-party-login/index.js +0 -110
- package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
- package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
- package/es/UserCenter/components/user-center.d.ts +0 -15
- package/es/UserCenter/components/user-center.js +0 -414
- package/es/UserCenter/components/user-info/index.d.ts +0 -3
- package/es/UserCenter/components/user-info/index.js +0 -3
- package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
- package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
- package/es/UserCenter/components/user-info/user-info-item.js +0 -47
- package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
- package/es/UserCenter/components/user-info/user-info.js +0 -66
- package/es/UserCenter/components/webhook-item.d.ts +0 -3
- package/es/UserCenter/components/webhook-item.js +0 -243
- package/es/UserCenter/index.d.ts +0 -1
- package/es/UserCenter/index.js +0 -1
- package/es/UserCenter/libs/api.d.ts +0 -3
- package/es/UserCenter/libs/api.js +0 -4
- package/es/UserCenter/libs/locales.d.ts +0 -162
- package/es/UserCenter/libs/locales.js +0 -162
- package/es/UserCenter/libs/utils.d.ts +0 -4
- package/es/UserCenter/libs/utils.js +0 -14
- package/es/UserSessions/components/user-session-info.d.ts +0 -6
- package/es/UserSessions/components/user-session-info.js +0 -92
- package/es/UserSessions/components/user-sessions.d.ts +0 -9
- package/es/UserSessions/components/user-sessions.js +0 -265
- package/es/UserSessions/index.d.ts +0 -1
- package/es/UserSessions/index.js +0 -1
- package/es/UserSessions/libs/locales.d.ts +0 -58
- package/es/UserSessions/libs/locales.js +0 -58
- package/es/UserSessions/libs/utils.d.ts +0 -2
- package/es/UserSessions/libs/utils.js +0 -73
- package/es/blocklets.d.ts +0 -16
- package/es/blocklets.js +0 -178
- package/es/common/header-addons.d.ts +0 -21
- package/es/common/header-addons.js +0 -83
- package/es/common/link-blocker.d.ts +0 -7
- package/es/common/link-blocker.js +0 -18
- package/es/common/overridable-theme-provider.d.ts +0 -18
- package/es/common/overridable-theme-provider.js +0 -15
- package/es/common/wallet-hidden-topbar.d.ts +0 -1
- package/es/common/wallet-hidden-topbar.js +0 -14
- package/es/contexts/config-user-space.d.ts +0 -26
- package/es/contexts/config-user-space.js +0 -53
- package/es/hooks/use-mobile.d.ts +0 -4
- package/es/hooks/use-mobile.js +0 -5
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -10
- package/es/libs/client.d.ts +0 -2
- package/es/libs/client.js +0 -2
- package/es/libs/spaces.d.ts +0 -2
- package/es/libs/spaces.js +0 -13
- package/es/types.d.ts +0 -2
- package/es/types.js +0 -43
- package/es/utils.d.ts +0 -8
- package/es/utils.js +0 -78
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useContext } from "react";
|
|
3
|
-
import { Box, CircularProgress, Typography } from "@mui/material";
|
|
4
|
-
import { useCreation, useMemoizedFn, useMount, useRequest, useUpdateEffect } from "ahooks";
|
|
5
|
-
import pWaitFor from "p-wait-for";
|
|
6
|
-
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
7
|
-
import Tabs from "@arcblock/ux/lib/Tabs";
|
|
8
|
-
import Empty from "@arcblock/ux/lib/Empty";
|
|
9
|
-
import Button from "@arcblock/ux/lib/Button";
|
|
10
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
11
|
-
import { useConfirm } from "@arcblock/ux/lib/Dialog";
|
|
12
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
13
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
14
|
-
import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
|
|
15
|
-
import cloneDeep from "lodash/cloneDeep";
|
|
16
|
-
import { getQuery, withQuery } from "ufo";
|
|
17
|
-
import Footer from "../../Footer/index.js";
|
|
18
|
-
import Header from "../../Header/index.js";
|
|
19
|
-
import { translations } from "../libs/locales.js";
|
|
20
|
-
import { UserInfo, UserBasicInfo } from "./user-info/index.js";
|
|
21
|
-
import { formatBlockletInfo, getLocalizedNavigation } from "../../blocklets.js";
|
|
22
|
-
import Passport from "./passport.js";
|
|
23
|
-
import Settings from "./settings.js";
|
|
24
|
-
import { client } from "../../libs/client.js";
|
|
25
|
-
export default function UserCenter({
|
|
26
|
-
children,
|
|
27
|
-
notLoginContent = null,
|
|
28
|
-
currentTab,
|
|
29
|
-
contentProps = {},
|
|
30
|
-
disableAutoRedirect = false,
|
|
31
|
-
autoPopupSetting = false,
|
|
32
|
-
hideFooter = false,
|
|
33
|
-
headerProps = {},
|
|
34
|
-
footerProps = {},
|
|
35
|
-
userDid = void 0,
|
|
36
|
-
stickySidebar = false
|
|
37
|
-
}) {
|
|
38
|
-
const { locale } = useLocaleContext();
|
|
39
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
40
|
-
return translate(translations, key, locale, "en", data);
|
|
41
|
-
});
|
|
42
|
-
const sessionCtx = useContext(SessionContext);
|
|
43
|
-
const session = sessionCtx?.session;
|
|
44
|
-
const currentDid = useCreation(() => {
|
|
45
|
-
if (userDid) {
|
|
46
|
-
return userDid;
|
|
47
|
-
}
|
|
48
|
-
const currentUrl = window.location.href;
|
|
49
|
-
const query = getQuery(currentUrl);
|
|
50
|
-
if (query?.did) {
|
|
51
|
-
if (Array.isArray(query.did)) {
|
|
52
|
-
return query.did[0];
|
|
53
|
-
}
|
|
54
|
-
return query.did;
|
|
55
|
-
}
|
|
56
|
-
return session?.user?.did;
|
|
57
|
-
}, [session?.user?.did, userDid]);
|
|
58
|
-
const isMyself = useCreation(() => {
|
|
59
|
-
if (session?.user) {
|
|
60
|
-
return currentDid === session?.user?.did;
|
|
61
|
-
}
|
|
62
|
-
return false;
|
|
63
|
-
}, [currentDid, session?.user?.did]);
|
|
64
|
-
const userState = useRequest(
|
|
65
|
-
// eslint-disable-next-line consistent-return
|
|
66
|
-
async () => {
|
|
67
|
-
await pWaitFor(() => session?.initialized);
|
|
68
|
-
if (isMyself) {
|
|
69
|
-
return session.user;
|
|
70
|
-
}
|
|
71
|
-
if (currentDid) {
|
|
72
|
-
return client.user.getUserPublicInfo({ did: currentDid });
|
|
73
|
-
}
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
refreshDeps: [currentDid, isMyself, session?.initialized, session?.user]
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
const privacyState = useRequest(
|
|
80
|
-
async () => {
|
|
81
|
-
if (userState.data && currentTab) {
|
|
82
|
-
const config = await client.user.getUserPrivacyConfig({ did: currentDid });
|
|
83
|
-
return config;
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
refreshDeps: [currentDid, userState.data, currentTab],
|
|
89
|
-
loadingDelay: 300
|
|
90
|
-
}
|
|
91
|
-
);
|
|
92
|
-
const { confirmHolder, confirmApi } = useConfirm({
|
|
93
|
-
sx: {
|
|
94
|
-
".MuiDialog-paper": {
|
|
95
|
-
borderRadius: 2,
|
|
96
|
-
maxWidth: 1200
|
|
97
|
-
},
|
|
98
|
-
".ux-dialog_title": {
|
|
99
|
-
fontWeight: 600
|
|
100
|
-
},
|
|
101
|
-
".ux-dialog_closeButton": {
|
|
102
|
-
p: 1
|
|
103
|
-
},
|
|
104
|
-
".MuiDialogActions-root": {
|
|
105
|
-
display: {
|
|
106
|
-
xs: "none",
|
|
107
|
-
md: "flex"
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
const formattedBlocklet = useCreation(() => {
|
|
113
|
-
const blocklet = cloneDeep(window.blocklet);
|
|
114
|
-
try {
|
|
115
|
-
return formatBlockletInfo(blocklet);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
console.error("Failed to format blocklet info", e, blocklet);
|
|
118
|
-
return blocklet;
|
|
119
|
-
}
|
|
120
|
-
}, []);
|
|
121
|
-
const userCenterTabs = useCreation(() => {
|
|
122
|
-
const menus = formattedBlocklet?.navigation?.userCenter || [];
|
|
123
|
-
const localizedMenus = getLocalizedNavigation(menus, locale) || [];
|
|
124
|
-
return localizedMenus.map((x) => {
|
|
125
|
-
const value = x._rawLink ?? x.link;
|
|
126
|
-
return {
|
|
127
|
-
value,
|
|
128
|
-
label: x.title,
|
|
129
|
-
url: x.link,
|
|
130
|
-
protected: privacyState?.data?.[value] ?? false
|
|
131
|
-
// icon: x.icon,
|
|
132
|
-
};
|
|
133
|
-
});
|
|
134
|
-
}, [formattedBlocklet, userState.data, privacyState?.data, locale]);
|
|
135
|
-
const currentActiveTab = useCreation(() => {
|
|
136
|
-
return userCenterTabs.find((x) => x.value === currentTab);
|
|
137
|
-
}, [userCenterTabs]);
|
|
138
|
-
const handleChangeTab = useMemoizedFn((value) => {
|
|
139
|
-
const findTab = userCenterTabs.find((x) => x.value === value);
|
|
140
|
-
if (findTab) {
|
|
141
|
-
window.location.href = withQuery(findTab.url, {
|
|
142
|
-
did: isMyself ? void 0 : currentDid
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
const settingContent = useCreation(() => {
|
|
147
|
-
return /* @__PURE__ */ jsx(
|
|
148
|
-
Settings,
|
|
149
|
-
{
|
|
150
|
-
user: userState.data,
|
|
151
|
-
settings: { userCenterTabs },
|
|
152
|
-
onSave: async () => {
|
|
153
|
-
await privacyState.runAsync();
|
|
154
|
-
return privacyState.data;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
);
|
|
158
|
-
}, [userState.data]);
|
|
159
|
-
const openSettings = useMemoizedFn(() => {
|
|
160
|
-
confirmApi.open({
|
|
161
|
-
title: t("settings"),
|
|
162
|
-
content: settingContent,
|
|
163
|
-
showCancelButton: false,
|
|
164
|
-
confirmButtonText: t("done"),
|
|
165
|
-
onConfirm: confirmApi.close
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
useUpdateEffect(() => {
|
|
169
|
-
confirmApi.update({
|
|
170
|
-
content: settingContent
|
|
171
|
-
});
|
|
172
|
-
}, [settingContent]);
|
|
173
|
-
useMount(() => {
|
|
174
|
-
if (autoPopupSetting) {
|
|
175
|
-
openSettings();
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
const content = useCreation(() => {
|
|
179
|
-
if (userState.loading || session.loading) {
|
|
180
|
-
return null;
|
|
181
|
-
}
|
|
182
|
-
if (userState.error) {
|
|
183
|
-
const errorMessage = userState.error.response?.data?.error || userState.error.message || "error occurred";
|
|
184
|
-
const formatError = {
|
|
185
|
-
message: errorMessage
|
|
186
|
-
};
|
|
187
|
-
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(ErrorFallback, { error: formatError }) });
|
|
188
|
-
}
|
|
189
|
-
if (!currentDid && !userState.data) {
|
|
190
|
-
if (notLoginContent) {
|
|
191
|
-
return notLoginContent;
|
|
192
|
-
}
|
|
193
|
-
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(
|
|
194
|
-
Box,
|
|
195
|
-
{
|
|
196
|
-
sx: {
|
|
197
|
-
display: "flex",
|
|
198
|
-
flexDirection: "column",
|
|
199
|
-
justifyContent: "center",
|
|
200
|
-
alignItems: "center",
|
|
201
|
-
gap: 1
|
|
202
|
-
},
|
|
203
|
-
children: [
|
|
204
|
-
/* @__PURE__ */ jsx(Empty, { children: t("viewAfterLogin") }),
|
|
205
|
-
/* @__PURE__ */ jsx(Button, { size: "small", variant: "contained", onClick: () => session.login(), children: t("loginNow") })
|
|
206
|
-
]
|
|
207
|
-
}
|
|
208
|
-
) });
|
|
209
|
-
}
|
|
210
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
211
|
-
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
212
|
-
userState?.data?.fullName ? /* @__PURE__ */ jsx(
|
|
213
|
-
Typography,
|
|
214
|
-
{
|
|
215
|
-
variant: "h4",
|
|
216
|
-
sx: {
|
|
217
|
-
py: 1.5,
|
|
218
|
-
fontWeight: 700,
|
|
219
|
-
display: {
|
|
220
|
-
xs: "none",
|
|
221
|
-
md: "block"
|
|
222
|
-
}
|
|
223
|
-
},
|
|
224
|
-
children: userState.data.fullName
|
|
225
|
-
}
|
|
226
|
-
) : null,
|
|
227
|
-
/* @__PURE__ */ jsx(
|
|
228
|
-
UserBasicInfo,
|
|
229
|
-
{
|
|
230
|
-
isMyself,
|
|
231
|
-
switchPassport: session.switchPassport,
|
|
232
|
-
switchProfile: session.switchProfile,
|
|
233
|
-
openSettings,
|
|
234
|
-
user: userState.data,
|
|
235
|
-
showFullDid: false,
|
|
236
|
-
sx: {
|
|
237
|
-
display: {
|
|
238
|
-
md: "none",
|
|
239
|
-
xs: "block"
|
|
240
|
-
},
|
|
241
|
-
mb: 1.5
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsxs(
|
|
246
|
-
Box,
|
|
247
|
-
{
|
|
248
|
-
sx: {
|
|
249
|
-
overflow: "auto",
|
|
250
|
-
padding: "1px"
|
|
251
|
-
},
|
|
252
|
-
children: [
|
|
253
|
-
/* @__PURE__ */ jsx(
|
|
254
|
-
Tabs,
|
|
255
|
-
{
|
|
256
|
-
variant: "line",
|
|
257
|
-
tabs: userCenterTabs,
|
|
258
|
-
current: currentTab,
|
|
259
|
-
onChange: handleChangeTab,
|
|
260
|
-
sx: { mb: 1.5 }
|
|
261
|
-
}
|
|
262
|
-
),
|
|
263
|
-
!privacyState.data || privacyState.loading ? /* @__PURE__ */ jsx(
|
|
264
|
-
Box,
|
|
265
|
-
{
|
|
266
|
-
sx: {
|
|
267
|
-
height: "100%",
|
|
268
|
-
minWidth: "160px",
|
|
269
|
-
minHeight: "160px",
|
|
270
|
-
display: "flex",
|
|
271
|
-
justifyContent: "center",
|
|
272
|
-
alignItems: "center"
|
|
273
|
-
},
|
|
274
|
-
children: /* @__PURE__ */ jsx(CircularProgress, { sx: { color: colors.primary100 } })
|
|
275
|
-
}
|
|
276
|
-
) : (
|
|
277
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
278
|
-
/* @__PURE__ */ jsx(Fragment, { children: currentActiveTab?.protected && !isMyself ? /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Empty, { children: t("underProtected") }) }) : (
|
|
279
|
-
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
280
|
-
/* @__PURE__ */ jsx(Fragment, { children: children && /* @__PURE__ */ jsx(Box, { ...contentProps, children }) })
|
|
281
|
-
) })
|
|
282
|
-
)
|
|
283
|
-
]
|
|
284
|
-
}
|
|
285
|
-
) : null,
|
|
286
|
-
userCenterTabs.length === 0 ? /* @__PURE__ */ jsx(
|
|
287
|
-
Box,
|
|
288
|
-
{
|
|
289
|
-
sx: {
|
|
290
|
-
display: {
|
|
291
|
-
xs: isMyself ? "none" : "block",
|
|
292
|
-
md: "block"
|
|
293
|
-
},
|
|
294
|
-
py: 3
|
|
295
|
-
},
|
|
296
|
-
children: /* @__PURE__ */ jsx(Empty, { children: t("emptyContent") })
|
|
297
|
-
}
|
|
298
|
-
) : null
|
|
299
|
-
] }),
|
|
300
|
-
/* @__PURE__ */ jsx(
|
|
301
|
-
Box,
|
|
302
|
-
{
|
|
303
|
-
sx: {
|
|
304
|
-
display: {
|
|
305
|
-
xs: "none",
|
|
306
|
-
md: "block"
|
|
307
|
-
},
|
|
308
|
-
width: "1px",
|
|
309
|
-
my: -3,
|
|
310
|
-
backgroundColor: colors.strokeSep
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
),
|
|
314
|
-
/* @__PURE__ */ jsx(
|
|
315
|
-
Box,
|
|
316
|
-
{
|
|
317
|
-
sx: {
|
|
318
|
-
width: {
|
|
319
|
-
sx: "100%",
|
|
320
|
-
md: 420
|
|
321
|
-
},
|
|
322
|
-
maxWidth: "100%",
|
|
323
|
-
position: "relative"
|
|
324
|
-
},
|
|
325
|
-
children: /* @__PURE__ */ jsxs(
|
|
326
|
-
Box,
|
|
327
|
-
{
|
|
328
|
-
sx: {
|
|
329
|
-
display: "flex",
|
|
330
|
-
flexDirection: "column",
|
|
331
|
-
gap: 2.5,
|
|
332
|
-
position: {
|
|
333
|
-
xs: "static",
|
|
334
|
-
md: stickySidebar ? "sticky" : "static"
|
|
335
|
-
},
|
|
336
|
-
top: (theme) => stickySidebar ? theme.spacing(3) : "unset"
|
|
337
|
-
},
|
|
338
|
-
children: [
|
|
339
|
-
/* @__PURE__ */ jsx(
|
|
340
|
-
UserBasicInfo,
|
|
341
|
-
{
|
|
342
|
-
isMyself,
|
|
343
|
-
switchPassport: session.switchPassport,
|
|
344
|
-
switchProfile: session.switchProfile,
|
|
345
|
-
openSettings,
|
|
346
|
-
user: userState.data,
|
|
347
|
-
sx: {
|
|
348
|
-
display: {
|
|
349
|
-
xs: "none",
|
|
350
|
-
md: "block"
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
),
|
|
355
|
-
isMyself ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
356
|
-
/* @__PURE__ */ jsxs(Box, { children: [
|
|
357
|
-
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, mb: 1.5 }, children: t("myInfo") }),
|
|
358
|
-
/* @__PURE__ */ jsx(UserInfo, { user: userState.data })
|
|
359
|
-
] }),
|
|
360
|
-
/* @__PURE__ */ jsxs(Box, { children: [
|
|
361
|
-
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, mb: 1.5 }, children: t("passport") }),
|
|
362
|
-
/* @__PURE__ */ jsx(Passport, { user: userState.data })
|
|
363
|
-
] })
|
|
364
|
-
] }) : null
|
|
365
|
-
]
|
|
366
|
-
}
|
|
367
|
-
)
|
|
368
|
-
}
|
|
369
|
-
)
|
|
370
|
-
] });
|
|
371
|
-
}, [userState, userCenterTabs, isMyself, currentActiveTab, privacyState, currentTab, stickySidebar]);
|
|
372
|
-
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
373
|
-
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|
|
374
|
-
return null;
|
|
375
|
-
}
|
|
376
|
-
return /* @__PURE__ */ jsxs(
|
|
377
|
-
Box,
|
|
378
|
-
{
|
|
379
|
-
sx: {
|
|
380
|
-
backgroundColor: colors.backgroundsBgSubtitle,
|
|
381
|
-
minHeight: "100vh",
|
|
382
|
-
display: "flex",
|
|
383
|
-
flexDirection: "column"
|
|
384
|
-
},
|
|
385
|
-
children: [
|
|
386
|
-
/* @__PURE__ */ jsx(Header, { bordered: true, ...headerProps }),
|
|
387
|
-
/* @__PURE__ */ jsxs(
|
|
388
|
-
Box,
|
|
389
|
-
{
|
|
390
|
-
flex: 1,
|
|
391
|
-
sx: {
|
|
392
|
-
width: "100%",
|
|
393
|
-
maxWidth: 1200,
|
|
394
|
-
margin: "0 auto",
|
|
395
|
-
p: 3,
|
|
396
|
-
display: "flex",
|
|
397
|
-
alignItems: "stretch",
|
|
398
|
-
flexDirection: {
|
|
399
|
-
xs: "column",
|
|
400
|
-
md: "row"
|
|
401
|
-
},
|
|
402
|
-
gap: 2.5
|
|
403
|
-
},
|
|
404
|
-
children: [
|
|
405
|
-
content,
|
|
406
|
-
confirmHolder
|
|
407
|
-
]
|
|
408
|
-
}
|
|
409
|
-
),
|
|
410
|
-
hideFooter ? null : /* @__PURE__ */ jsx(Footer, { bordered: true, ...footerProps })
|
|
411
|
-
]
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import type { BoxProps } from '@mui/material';
|
|
3
|
-
import type { User } from '../../../@types';
|
|
4
|
-
export default function UserBasicInfo({ user, isMyself, showFullDid, switchPassport, switchProfile, openSettings, ...rest }: {
|
|
5
|
-
user: User;
|
|
6
|
-
isMyself?: boolean;
|
|
7
|
-
showFullDid?: boolean;
|
|
8
|
-
switchPassport: () => void;
|
|
9
|
-
switchProfile: () => void;
|
|
10
|
-
openSettings: () => void;
|
|
11
|
-
} & BoxProps): import("react").JSX.Element | null;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Chip, IconButton, Typography } from "@mui/material";
|
|
3
|
-
import { Icon } from "@iconify/react";
|
|
4
|
-
import SwapHorizRoundedIcon from "@iconify-icons/material-symbols/swap-horiz-rounded";
|
|
5
|
-
import SettingsOutlineRoundedIcon from "@iconify-icons/material-symbols/settings-outline-rounded";
|
|
6
|
-
import Avatar from "@arcblock/ux/lib/Avatar";
|
|
7
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
8
|
-
import { useTheme } from "@arcblock/ux/lib/Theme";
|
|
9
|
-
import DID from "@arcblock/ux/lib/DID";
|
|
10
|
-
import { useCreation, useMemoizedFn } from "ahooks";
|
|
11
|
-
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
12
|
-
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
13
|
-
import noop from "lodash/noop";
|
|
14
|
-
import { translations } from "../../libs/locales.js";
|
|
15
|
-
export default function UserBasicInfo({
|
|
16
|
-
user,
|
|
17
|
-
isMyself = true,
|
|
18
|
-
showFullDid = true,
|
|
19
|
-
switchPassport,
|
|
20
|
-
switchProfile,
|
|
21
|
-
openSettings,
|
|
22
|
-
...rest
|
|
23
|
-
}) {
|
|
24
|
-
const { locale } = useLocaleContext();
|
|
25
|
-
const t = useMemoizedFn((key, data = {}) => {
|
|
26
|
-
return translate(translations, key, locale, "en", data);
|
|
27
|
-
});
|
|
28
|
-
const currentRole = useCreation(
|
|
29
|
-
() => (user?.passports || [])?.find((item) => item.name === user.role),
|
|
30
|
-
[user?.passports, user?.role]
|
|
31
|
-
);
|
|
32
|
-
const theme = useTheme();
|
|
33
|
-
const isSmallView = theme.breakpoints.down("md");
|
|
34
|
-
if (!user) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return /* @__PURE__ */ jsxs(
|
|
38
|
-
Box,
|
|
39
|
-
{
|
|
40
|
-
...rest,
|
|
41
|
-
sx: {
|
|
42
|
-
position: "relative",
|
|
43
|
-
...rest.sx
|
|
44
|
-
},
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
Avatar,
|
|
48
|
-
{
|
|
49
|
-
src: user?.avatar,
|
|
50
|
-
did: user?.did,
|
|
51
|
-
size: isSmallView ? 64 : 80,
|
|
52
|
-
variant: "circle",
|
|
53
|
-
shape: "circle",
|
|
54
|
-
sx: {
|
|
55
|
-
borderRadius: "100%",
|
|
56
|
-
backgroundColor: "#fff",
|
|
57
|
-
position: "relative",
|
|
58
|
-
overflow: "hidden",
|
|
59
|
-
mb: 1.5,
|
|
60
|
-
...isMyself ? {
|
|
61
|
-
cursor: "pointer",
|
|
62
|
-
"&:hover": {
|
|
63
|
-
"&::after": {
|
|
64
|
-
content: `"${t("switchProfile")}"`
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
"&::after": {
|
|
68
|
-
color: "white",
|
|
69
|
-
position: "absolute",
|
|
70
|
-
fontSize: "12px",
|
|
71
|
-
bottom: 0,
|
|
72
|
-
left: 0,
|
|
73
|
-
right: 0,
|
|
74
|
-
height: "50%",
|
|
75
|
-
backgroundColor: "rgba(0, 0, 0, 0.3)",
|
|
76
|
-
display: "flex",
|
|
77
|
-
justifyContent: "center",
|
|
78
|
-
alignItems: "center"
|
|
79
|
-
}
|
|
80
|
-
} : {}
|
|
81
|
-
},
|
|
82
|
-
onClick: isMyself ? switchProfile : noop
|
|
83
|
-
}
|
|
84
|
-
),
|
|
85
|
-
/* @__PURE__ */ jsxs(
|
|
86
|
-
Typography,
|
|
87
|
-
{
|
|
88
|
-
variant: "h6",
|
|
89
|
-
sx: {
|
|
90
|
-
fontWeight: "bold",
|
|
91
|
-
display: "flex",
|
|
92
|
-
alignItems: "center",
|
|
93
|
-
gap: 1,
|
|
94
|
-
fontSize: "24px !important"
|
|
95
|
-
},
|
|
96
|
-
children: [
|
|
97
|
-
user?.fullName,
|
|
98
|
-
isMyself ? /* @__PURE__ */ jsx(
|
|
99
|
-
Chip,
|
|
100
|
-
{
|
|
101
|
-
label: currentRole?.title || user?.role || "Guest",
|
|
102
|
-
size: "small",
|
|
103
|
-
variant: "outlined",
|
|
104
|
-
sx: {
|
|
105
|
-
flexShrink: 0,
|
|
106
|
-
fontWeight: "bold",
|
|
107
|
-
fontSize: "12px",
|
|
108
|
-
color: colors.textBase,
|
|
109
|
-
borderColor: colors.strokeBorderStrong,
|
|
110
|
-
backgroundColor: "transparent",
|
|
111
|
-
textTransform: "capitalize",
|
|
112
|
-
pr: 1,
|
|
113
|
-
pl: 0.5,
|
|
114
|
-
"&:hover": {
|
|
115
|
-
backgroundColor: "rgba(0, 0, 0, 0.04)"
|
|
116
|
-
},
|
|
117
|
-
"&:active": {
|
|
118
|
-
boxShadow: "none"
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
clickable: true,
|
|
122
|
-
deleteIcon: /* @__PURE__ */ jsx(Icon, { icon: SwapHorizRoundedIcon, color: colors.textBase }),
|
|
123
|
-
onDelete: switchPassport,
|
|
124
|
-
onClick: switchPassport
|
|
125
|
-
}
|
|
126
|
-
) : null
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
),
|
|
130
|
-
/* @__PURE__ */ jsx(DID, { did: user.did, showQrcode: true, copyable: true, compact: !showFullDid, responsive: !showFullDid, locale }),
|
|
131
|
-
isMyself ? /* @__PURE__ */ jsx(
|
|
132
|
-
IconButton,
|
|
133
|
-
{
|
|
134
|
-
sx: {
|
|
135
|
-
borderRadius: 2,
|
|
136
|
-
color: colors.textBase,
|
|
137
|
-
backgroundColor: "white",
|
|
138
|
-
border: `1px solid ${colors.strokeBorderBase}`,
|
|
139
|
-
position: "absolute",
|
|
140
|
-
top: 0,
|
|
141
|
-
right: 0
|
|
142
|
-
},
|
|
143
|
-
disableFocusRipple: true,
|
|
144
|
-
onClick: openSettings,
|
|
145
|
-
children: /* @__PURE__ */ jsx(Icon, { icon: SettingsOutlineRoundedIcon })
|
|
146
|
-
}
|
|
147
|
-
) : null
|
|
148
|
-
]
|
|
149
|
-
}
|
|
150
|
-
);
|
|
151
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { BoxProps } from '@mui/material';
|
|
3
|
-
type TUserInfoItemProps = {
|
|
4
|
-
data: {
|
|
5
|
-
icon: any;
|
|
6
|
-
title: string;
|
|
7
|
-
content: any;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
export default function UserInfoItem({ data, ...rest }: TUserInfoItemProps & BoxProps): import("react").JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Typography } from "@mui/material";
|
|
3
|
-
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
4
|
-
export default function UserInfoItem({ data, ...rest }) {
|
|
5
|
-
return /* @__PURE__ */ jsxs(
|
|
6
|
-
Box,
|
|
7
|
-
{
|
|
8
|
-
...rest,
|
|
9
|
-
sx: {
|
|
10
|
-
display: "flex",
|
|
11
|
-
alignItems: "center",
|
|
12
|
-
justifyContent: "space-between",
|
|
13
|
-
...rest.sx
|
|
14
|
-
},
|
|
15
|
-
children: [
|
|
16
|
-
/* @__PURE__ */ jsxs(
|
|
17
|
-
Typography,
|
|
18
|
-
{
|
|
19
|
-
sx: {
|
|
20
|
-
display: "flex",
|
|
21
|
-
alignItems: "center",
|
|
22
|
-
color: colors.textBase,
|
|
23
|
-
fontSize: "14px",
|
|
24
|
-
gap: 1,
|
|
25
|
-
fontWeight: 500
|
|
26
|
-
},
|
|
27
|
-
children: [
|
|
28
|
-
data.icon,
|
|
29
|
-
data.title
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
),
|
|
33
|
-
/* @__PURE__ */ jsx(
|
|
34
|
-
Typography,
|
|
35
|
-
{
|
|
36
|
-
sx: {
|
|
37
|
-
color: colors.textSubtitle,
|
|
38
|
-
whiteSpace: "pre-wrap",
|
|
39
|
-
fontSize: "14px"
|
|
40
|
-
},
|
|
41
|
-
children: data.content
|
|
42
|
-
}
|
|
43
|
-
)
|
|
44
|
-
]
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
}
|