@blocklet/ui-react 2.9.13 → 2.9.14

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.
Files changed (161) hide show
  1. package/build.config.ts +29 -0
  2. package/es/@types/index.d.ts +63 -0
  3. package/es/@types/index.js +0 -0
  4. package/es/@types/shims.d.ts +12 -0
  5. package/es/Dashboard/index.d.ts +41 -0
  6. package/es/Dashboard/index.js +63 -97
  7. package/es/Footer/brand.d.ts +22 -0
  8. package/es/Footer/brand.js +20 -37
  9. package/es/Footer/copyright.d.ts +18 -0
  10. package/es/Footer/copyright.js +14 -16
  11. package/es/Footer/index.d.ts +6 -0
  12. package/es/Footer/index.js +30 -56
  13. package/es/Footer/internal-footer.d.ts +29 -0
  14. package/es/Footer/internal-footer.js +67 -94
  15. package/es/Footer/layout/plain.d.ts +15 -0
  16. package/es/Footer/layout/plain.js +19 -37
  17. package/es/Footer/layout/row.d.ts +18 -0
  18. package/es/Footer/layout/row.js +9 -19
  19. package/es/Footer/layout/standard.d.ts +15 -0
  20. package/es/Footer/layout/standard.js +29 -57
  21. package/es/Footer/links.d.ts +22 -0
  22. package/es/Footer/links.js +72 -104
  23. package/es/Footer/social-media.d.ts +14 -0
  24. package/es/Footer/social-media.js +35 -35
  25. package/es/Header/index.d.ts +9 -0
  26. package/es/Header/index.js +55 -100
  27. package/es/Icon/index.d.ts +23 -0
  28. package/es/Icon/index.js +23 -58
  29. package/es/UserCenter/assets/banner.png +0 -0
  30. package/es/UserCenter/components/notification.d.ts +5 -0
  31. package/es/UserCenter/components/notification.js +276 -0
  32. package/es/UserCenter/components/passport.d.ts +6 -0
  33. package/es/UserCenter/components/passport.js +69 -0
  34. package/es/UserCenter/components/privacy.d.ts +11 -0
  35. package/es/UserCenter/components/privacy.js +99 -0
  36. package/es/UserCenter/components/settings.d.ts +10 -0
  37. package/es/UserCenter/components/settings.js +68 -0
  38. package/es/UserCenter/components/user-basic-info.d.ts +8 -0
  39. package/es/UserCenter/components/user-basic-info.js +66 -0
  40. package/es/UserCenter/components/user-center.d.ts +9 -0
  41. package/es/UserCenter/components/user-center.js +397 -0
  42. package/es/UserCenter/components/user-info-item.d.ts +10 -0
  43. package/es/UserCenter/components/user-info-item.js +54 -0
  44. package/es/UserCenter/components/user-info.d.ts +6 -0
  45. package/es/UserCenter/components/user-info.js +68 -0
  46. package/es/UserCenter/components/webhook-item.d.ts +3 -0
  47. package/es/UserCenter/components/webhook-item.js +243 -0
  48. package/es/UserCenter/index.d.ts +1 -0
  49. package/es/UserCenter/index.js +1 -0
  50. package/es/UserCenter/libs/client.d.ts +2 -0
  51. package/es/UserCenter/libs/client.js +2 -0
  52. package/es/UserCenter/libs/locales.d.ts +72 -0
  53. package/es/UserCenter/libs/locales.js +72 -0
  54. package/es/UserCenter/libs/utils.d.ts +4 -0
  55. package/es/UserCenter/libs/utils.js +14 -0
  56. package/es/blocklets.d.ts +16 -0
  57. package/es/blocklets.js +56 -45
  58. package/es/common/header-addons.d.ts +22 -0
  59. package/es/common/header-addons.js +41 -59
  60. package/es/common/link-blocker.d.ts +7 -0
  61. package/es/common/link-blocker.js +10 -17
  62. package/es/common/overridable-theme-provider.d.ts +18 -0
  63. package/es/common/overridable-theme-provider.js +6 -16
  64. package/es/common/wallet-hidden-topbar.d.ts +1 -0
  65. package/es/common/wallet-hidden-topbar.js +12 -10
  66. package/es/index.d.ts +5 -0
  67. package/es/index.js +5 -0
  68. package/es/types.d.ts +2 -0
  69. package/es/types.js +17 -11
  70. package/es/utils.d.ts +8 -0
  71. package/es/utils.js +21 -26
  72. package/lib/@types/index.d.ts +63 -0
  73. package/lib/@types/index.js +1 -0
  74. package/lib/@types/shims.d.ts +12 -0
  75. package/lib/Dashboard/index.d.ts +41 -0
  76. package/lib/Dashboard/index.js +44 -71
  77. package/lib/Footer/brand.d.ts +22 -0
  78. package/lib/Footer/brand.js +65 -30
  79. package/lib/Footer/copyright.d.ts +18 -0
  80. package/lib/Footer/copyright.js +18 -23
  81. package/lib/Footer/index.d.ts +6 -0
  82. package/lib/Footer/index.js +33 -42
  83. package/lib/Footer/internal-footer.d.ts +29 -0
  84. package/lib/Footer/internal-footer.js +43 -59
  85. package/lib/Footer/layout/plain.d.ts +15 -0
  86. package/lib/Footer/layout/plain.js +25 -30
  87. package/lib/Footer/layout/row.d.ts +18 -0
  88. package/lib/Footer/layout/row.js +34 -23
  89. package/lib/Footer/layout/standard.d.ts +15 -0
  90. package/lib/Footer/layout/standard.js +35 -41
  91. package/lib/Footer/links.d.ts +22 -0
  92. package/lib/Footer/links.js +163 -60
  93. package/lib/Footer/social-media.d.ts +14 -0
  94. package/lib/Footer/social-media.js +31 -25
  95. package/lib/Header/index.d.ts +9 -0
  96. package/lib/Header/index.js +83 -76
  97. package/lib/Icon/index.d.ts +23 -0
  98. package/lib/Icon/index.js +37 -51
  99. package/lib/UserCenter/assets/banner.png +0 -0
  100. package/lib/UserCenter/components/notification.d.ts +5 -0
  101. package/lib/UserCenter/components/notification.js +261 -0
  102. package/lib/UserCenter/components/passport.d.ts +6 -0
  103. package/lib/UserCenter/components/passport.js +86 -0
  104. package/lib/UserCenter/components/privacy.d.ts +11 -0
  105. package/lib/UserCenter/components/privacy.js +101 -0
  106. package/lib/UserCenter/components/settings.d.ts +10 -0
  107. package/lib/UserCenter/components/settings.js +81 -0
  108. package/lib/UserCenter/components/user-basic-info.d.ts +8 -0
  109. package/lib/UserCenter/components/user-basic-info.js +67 -0
  110. package/lib/UserCenter/components/user-center.d.ts +9 -0
  111. package/lib/UserCenter/components/user-center.js +376 -0
  112. package/lib/UserCenter/components/user-info-item.d.ts +10 -0
  113. package/lib/UserCenter/components/user-info-item.js +46 -0
  114. package/lib/UserCenter/components/user-info.d.ts +6 -0
  115. package/lib/UserCenter/components/user-info.js +94 -0
  116. package/lib/UserCenter/components/webhook-item.d.ts +3 -0
  117. package/lib/UserCenter/components/webhook-item.js +236 -0
  118. package/lib/UserCenter/index.d.ts +1 -0
  119. package/lib/UserCenter/index.js +13 -0
  120. package/lib/UserCenter/libs/client.d.ts +2 -0
  121. package/lib/UserCenter/libs/client.js +8 -0
  122. package/lib/UserCenter/libs/locales.d.ts +72 -0
  123. package/lib/UserCenter/libs/locales.js +78 -0
  124. package/lib/UserCenter/libs/utils.d.ts +4 -0
  125. package/lib/UserCenter/libs/utils.js +25 -0
  126. package/lib/blocklets.d.ts +16 -0
  127. package/lib/blocklets.js +28 -36
  128. package/lib/common/header-addons.d.ts +22 -0
  129. package/lib/common/header-addons.js +24 -36
  130. package/lib/common/link-blocker.d.ts +7 -0
  131. package/lib/common/link-blocker.js +10 -18
  132. package/lib/common/overridable-theme-provider.d.ts +18 -0
  133. package/lib/common/overridable-theme-provider.js +9 -14
  134. package/lib/common/wallet-hidden-topbar.d.ts +1 -0
  135. package/lib/common/wallet-hidden-topbar.js +1 -3
  136. package/lib/index.d.ts +5 -0
  137. package/lib/index.js +52 -0
  138. package/lib/types.d.ts +2 -0
  139. package/lib/types.js +3 -5
  140. package/lib/utils.d.ts +8 -0
  141. package/lib/utils.js +16 -23
  142. package/package.json +17 -11
  143. package/src/@types/index.ts +70 -0
  144. package/src/@types/shims.d.ts +12 -0
  145. package/src/UserCenter/assets/banner.png +0 -0
  146. package/src/UserCenter/components/notification.tsx +275 -0
  147. package/src/UserCenter/components/passport.tsx +83 -0
  148. package/src/UserCenter/components/privacy.tsx +107 -0
  149. package/src/UserCenter/components/settings.tsx +78 -0
  150. package/src/UserCenter/components/user-basic-info.tsx +70 -0
  151. package/src/UserCenter/components/user-center.tsx +410 -0
  152. package/src/UserCenter/components/user-info-item.tsx +50 -0
  153. package/src/UserCenter/components/user-info.tsx +85 -0
  154. package/src/UserCenter/components/webhook-item.tsx +243 -0
  155. package/src/UserCenter/index.tsx +1 -0
  156. package/src/UserCenter/libs/client.ts +3 -0
  157. package/src/UserCenter/libs/locales.ts +72 -0
  158. package/src/UserCenter/libs/utils.ts +21 -0
  159. package/src/blocklets.js +2 -0
  160. package/src/index.ts +9 -0
  161. /package/src/common/{link-blocker.js → link-blocker.jsx} +0 -0
@@ -0,0 +1,66 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Box, Chip, Typography } from "@mui/material";
3
+ import { Icon } from "@iconify/react";
4
+ import SwapHorizRoundedIcon from "@iconify-icons/material-symbols/swap-horiz-rounded";
5
+ import { temp as colors } from "@arcblock/ux/lib/Colors";
6
+ import DID from "@arcblock/ux/lib/DID";
7
+ import { useCreation } from "ahooks";
8
+ export default function UserBasicInfo({
9
+ user,
10
+ isMyself = true,
11
+ switchPassport,
12
+ ...rest
13
+ }) {
14
+ const currentRole = useCreation(
15
+ () => (user?.passports || [])?.find((item) => item.name === user.role),
16
+ [user?.passports, user?.role]
17
+ );
18
+ return /* @__PURE__ */ jsxs(Box, { ...rest, children: [
19
+ /* @__PURE__ */ jsxs(
20
+ Typography,
21
+ {
22
+ variant: "h4",
23
+ sx: {
24
+ fontWeight: "bold",
25
+ display: "flex",
26
+ alignItems: "center",
27
+ gap: 1,
28
+ mb: 1
29
+ },
30
+ children: [
31
+ user?.fullName,
32
+ isMyself ? /* @__PURE__ */ jsx(
33
+ Chip,
34
+ {
35
+ label: currentRole?.title || user?.role || "Guest",
36
+ size: "small",
37
+ variant: "outlined",
38
+ sx: {
39
+ flexShrink: 0,
40
+ fontWeight: "bold",
41
+ fontSize: "12px",
42
+ color: colors.textBase,
43
+ borderColor: colors.strokeBorderStrong,
44
+ backgroundColor: "white",
45
+ textTransform: "capitalize",
46
+ pr: 1,
47
+ pl: 0.5,
48
+ "&:hover": {
49
+ backgroundColor: "rgba(0, 0, 0, 0.04)"
50
+ },
51
+ "&:active": {
52
+ boxShadow: "none"
53
+ }
54
+ },
55
+ clickable: true,
56
+ deleteIcon: /* @__PURE__ */ jsx(Icon, { icon: SwapHorizRoundedIcon, color: colors.textBase }),
57
+ onDelete: switchPassport,
58
+ onClick: switchPassport
59
+ }
60
+ ) : null
61
+ ]
62
+ }
63
+ ),
64
+ /* @__PURE__ */ jsx(DID, { did: user.did, copyable: false })
65
+ ] });
66
+ }
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import type { PaperProps } from '@mui/material';
3
+ export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, }: {
4
+ children: any;
5
+ currentTab: string;
6
+ contentProps?: PaperProps;
7
+ disableAutoRedirect?: boolean;
8
+ autoPopupSetting?: boolean;
9
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,397 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { Box, CircularProgress, IconButton, Paper, Typography } from "@mui/material";
4
+ import { useCreation, useMemoizedFn, useMount, useRequest } from "ahooks";
5
+ import { Icon } from "@iconify/react";
6
+ import SettingsOutlineRoundedIcon from "@iconify-icons/material-symbols/settings-outline-rounded";
7
+ import { SessionContext } from "@arcblock/did-connect/lib/Session";
8
+ import Avatar from "@arcblock/ux/lib/Avatar";
9
+ import Tabs from "@arcblock/ux/lib/Tabs";
10
+ import Empty from "@arcblock/ux/lib/Empty";
11
+ import { temp as colors } from "@arcblock/ux/lib/Colors";
12
+ import { useConfirm } from "@arcblock/ux/lib/Dialog";
13
+ import { translate } from "@arcblock/ux/lib/Locale/util";
14
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
15
+ import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
16
+ import cloneDeep from "lodash/cloneDeep";
17
+ import { getQuery, withQuery } from "ufo";
18
+ import Header from "../../Header/index.js";
19
+ import { translations } from "../libs/locales.js";
20
+ import banner from "../assets/banner.png";
21
+ import UserInfo from "./user-info.js";
22
+ import UserBasicInfo from "./user-basic-info.js";
23
+ import { formatBlockletInfo, getLocalizedNavigation } from "../../blocklets.js";
24
+ import Passport from "./passport.js";
25
+ import Settings from "./settings.js";
26
+ import { client } from "../libs/client.js";
27
+ export default function UserCenter({
28
+ children,
29
+ currentTab,
30
+ contentProps = {},
31
+ disableAutoRedirect = false,
32
+ autoPopupSetting = false
33
+ }) {
34
+ const { locale } = useLocaleContext();
35
+ const t = useMemoizedFn((key, data = {}) => {
36
+ return translate(translations, key, locale, "en", data);
37
+ });
38
+ const sessionCtx = useContext(SessionContext);
39
+ const session = sessionCtx?.session;
40
+ const currentDid = useCreation(() => {
41
+ const currentUrl = window.location.href;
42
+ const query = getQuery(currentUrl);
43
+ if (query?.did) {
44
+ if (Array.isArray(query.did)) {
45
+ return query.did[0];
46
+ }
47
+ return query.did;
48
+ }
49
+ return session?.user?.did;
50
+ }, [session?.user?.did]);
51
+ const isMyself = useCreation(() => {
52
+ if (session?.user) {
53
+ return currentDid === session?.user?.did;
54
+ }
55
+ return false;
56
+ }, [currentDid, session?.user?.did]);
57
+ const userState = useRequest(
58
+ async () => {
59
+ if (isMyself) {
60
+ return session.user;
61
+ }
62
+ if (currentDid) {
63
+ return await client.user.getUserPublicInfo({ did: currentDid });
64
+ }
65
+ throw new Error(t("noUserFound"));
66
+ },
67
+ {
68
+ refreshDeps: [currentDid, isMyself]
69
+ }
70
+ );
71
+ const privacyState = useRequest(
72
+ async () => {
73
+ if (userState.data && currentTab) {
74
+ const config = await client.user.getUserPrivacyConfig({ did: currentDid });
75
+ return config;
76
+ }
77
+ return null;
78
+ },
79
+ {
80
+ refreshDeps: [currentDid, userState.data, currentTab],
81
+ loadingDelay: 300
82
+ }
83
+ );
84
+ const { confirmHolder, confirmApi } = useConfirm({
85
+ sx: {
86
+ ".MuiDialog-paper": {
87
+ borderRadius: 2
88
+ },
89
+ ".ux-dialog_title": {
90
+ fontWeight: 600
91
+ },
92
+ ".ux-dialog_closeButton": {
93
+ p: 1
94
+ },
95
+ ".MuiDialogActions-root": {
96
+ display: {
97
+ xs: "none",
98
+ md: "flex"
99
+ }
100
+ }
101
+ }
102
+ });
103
+ const formattedBlocklet = useCreation(() => {
104
+ const blocklet = cloneDeep(window.blocklet);
105
+ try {
106
+ return formatBlockletInfo(blocklet);
107
+ } catch (e) {
108
+ console.error("Failed to format blocklet info", e, blocklet);
109
+ return blocklet;
110
+ }
111
+ }, []);
112
+ const userCenterTabs = useCreation(() => {
113
+ const menus = formattedBlocklet?.navigation?.userCenter || [];
114
+ const localizedMenus = getLocalizedNavigation(menus, locale) || [];
115
+ return localizedMenus.map((x) => {
116
+ const value = x._rawLink ?? x.link;
117
+ return {
118
+ value,
119
+ label: x.title,
120
+ url: x.link,
121
+ protected: privacyState?.data?.[value] ?? false
122
+ // icon: x.icon,
123
+ };
124
+ });
125
+ }, [formattedBlocklet, userState.data, privacyState?.data]);
126
+ const currentActiveTab = useCreation(() => {
127
+ return userCenterTabs.find((x) => x.value === currentTab);
128
+ }, [userCenterTabs]);
129
+ const handleChangeTab = useMemoizedFn((value) => {
130
+ const findTab = userCenterTabs.find((x) => x.value === value);
131
+ if (findTab) {
132
+ window.location.href = withQuery(findTab.url, {
133
+ did: isMyself ? void 0 : currentDid
134
+ });
135
+ }
136
+ });
137
+ const xsGridTemplateAreas = useCreation(() => {
138
+ return [
139
+ '"avatar settings"',
140
+ '"basicInfo basicInfo"',
141
+ userCenterTabs.length > 0 || !isMyself ? '"tabs tabs"' : null,
142
+ isMyself ? '"passport passport"' : null,
143
+ isMyself ? '"extraInfo extraInfo"' : null
144
+ ];
145
+ }, [userCenterTabs, isMyself]);
146
+ const mdGridTemplateAreas = useCreation(() => {
147
+ if (!isMyself) {
148
+ return ['"avatar"', '"basicInfo"', '"tabs"'];
149
+ }
150
+ return [
151
+ '"avatar settings"',
152
+ '"basicInfo extraInfo"',
153
+ userCenterTabs.length > 0 ? '"tabs extraInfo"' : null,
154
+ '"passport extraInfo"'
155
+ ];
156
+ }, [userCenterTabs, isMyself]);
157
+ const openSettings = useMemoizedFn(() => {
158
+ confirmApi.open({
159
+ title: t("settings"),
160
+ content: /* @__PURE__ */ jsx(
161
+ Settings,
162
+ {
163
+ user: userState.data,
164
+ settings: {
165
+ userCenterTabs
166
+ },
167
+ sx: { mt: -2 },
168
+ onSave: async () => {
169
+ await privacyState.runAsync();
170
+ return privacyState.data;
171
+ }
172
+ }
173
+ ),
174
+ showCancelButton: false,
175
+ confirmButtonText: t("done"),
176
+ onConfirm: confirmApi.close
177
+ });
178
+ });
179
+ useMount(() => {
180
+ if (autoPopupSetting) {
181
+ openSettings();
182
+ }
183
+ });
184
+ const content = useCreation(() => {
185
+ if (userState.loading || session.loading) {
186
+ return null;
187
+ }
188
+ if (userState.error) {
189
+ const errorMessage = userState.error.response?.data?.error || userState.error.message || "error occurred";
190
+ const formatError = {
191
+ message: errorMessage
192
+ };
193
+ return /* @__PURE__ */ jsx(ErrorFallback, { error: formatError });
194
+ }
195
+ return /* @__PURE__ */ jsxs(
196
+ Box,
197
+ {
198
+ sx: {
199
+ maxWidth: 1200,
200
+ margin: "0 auto",
201
+ px: 3,
202
+ pb: 3,
203
+ display: "grid",
204
+ gap: 2.5,
205
+ gridTemplateAreas: {
206
+ xs: xsGridTemplateAreas.filter(Boolean).join(" "),
207
+ md: mdGridTemplateAreas.filter(Boolean).join(" ")
208
+ },
209
+ gridTemplateRows: {
210
+ xs: "64px auto auto auto",
211
+ md: "64px auto 1fr"
212
+ },
213
+ gridTemplateColumns: {
214
+ xs: "1fr",
215
+ md: isMyself ? "1fr 300px" : "1fr"
216
+ }
217
+ },
218
+ children: [
219
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
220
+ Avatar,
221
+ {
222
+ src: userState.data?.avatar,
223
+ did: userState.data?.did,
224
+ size: 120,
225
+ variant: "circle",
226
+ shape: "circle",
227
+ style: {
228
+ border: "4px solid #fff",
229
+ transform: "translateY(-50%)",
230
+ borderRadius: "100%",
231
+ gridArea: "avatar",
232
+ backgroundColor: "#fff"
233
+ }
234
+ }
235
+ ) }),
236
+ isMyself ? /* @__PURE__ */ jsx(
237
+ Box,
238
+ {
239
+ sx: {
240
+ gridArea: "settings",
241
+ display: "flex",
242
+ justifyContent: "flex-end",
243
+ alignItems: "center"
244
+ },
245
+ children: /* @__PURE__ */ jsx(
246
+ IconButton,
247
+ {
248
+ sx: {
249
+ borderRadius: 2,
250
+ color: colors.textBase,
251
+ backgroundColor: "white",
252
+ border: `1px solid ${colors.strokeBorderBase}`
253
+ },
254
+ disableFocusRipple: true,
255
+ onClick: openSettings,
256
+ children: /* @__PURE__ */ jsx(Icon, { icon: SettingsOutlineRoundedIcon })
257
+ }
258
+ )
259
+ }
260
+ ) : null,
261
+ /* @__PURE__ */ jsx(
262
+ UserBasicInfo,
263
+ {
264
+ isMyself,
265
+ switchPassport: session.switchPassport,
266
+ user: userState.data,
267
+ sx: {
268
+ gridArea: "basicInfo"
269
+ }
270
+ }
271
+ ),
272
+ userCenterTabs.length > 0 && currentTab ? /* @__PURE__ */ jsxs(
273
+ Box,
274
+ {
275
+ sx: {
276
+ gridArea: "tabs",
277
+ overflow: "auto",
278
+ padding: "1px"
279
+ },
280
+ children: [
281
+ /* @__PURE__ */ jsx(Tabs, { variant: "card", tabs: userCenterTabs, current: currentTab, onChange: handleChangeTab }),
282
+ !privacyState.data || privacyState.loading ? /* @__PURE__ */ jsx(
283
+ Box,
284
+ {
285
+ sx: {
286
+ height: "100%",
287
+ minWidth: "160px",
288
+ minHeight: "160px",
289
+ display: "flex",
290
+ justifyContent: "center",
291
+ alignItems: "center"
292
+ },
293
+ children: /* @__PURE__ */ jsx(CircularProgress, { sx: { color: colors.primary100 } })
294
+ }
295
+ ) : /* @__PURE__ */ jsx(Fragment, { children: currentActiveTab?.protected && !isMyself ? /* @__PURE__ */ jsx(Paper, { variant: "outlined", sx: { mt: 2, borderRadius: 2, p: 2 }, children: /* @__PURE__ */ jsx(Empty, { children: t("underProtected") }) }) : /* @__PURE__ */ jsx(Fragment, { children: children && /* @__PURE__ */ jsx(
296
+ Paper,
297
+ {
298
+ ...contentProps,
299
+ variant: "outlined",
300
+ sx: { mt: 2, borderRadius: 2, p: 2, ...contentProps?.sx },
301
+ children
302
+ }
303
+ ) }) })
304
+ ]
305
+ }
306
+ ) : null,
307
+ !isMyself && userCenterTabs.length === 0 ? /* @__PURE__ */ jsx(
308
+ Box,
309
+ {
310
+ sx: {
311
+ gridArea: "tabs",
312
+ overflow: "auto",
313
+ padding: "1px"
314
+ },
315
+ children: /* @__PURE__ */ jsx(
316
+ Paper,
317
+ {
318
+ variant: "outlined",
319
+ sx: {
320
+ borderRadius: 2,
321
+ p: 2
322
+ },
323
+ children: /* @__PURE__ */ jsx(Empty, { children: t("emptyContent") })
324
+ }
325
+ )
326
+ }
327
+ ) : null,
328
+ isMyself ? /* @__PURE__ */ jsxs(Fragment, { children: [
329
+ /* @__PURE__ */ jsxs(
330
+ Box,
331
+ {
332
+ sx: {
333
+ gridArea: "passport"
334
+ },
335
+ children: [
336
+ /* @__PURE__ */ jsx(Typography, { variant: "h5", sx: { fontWeight: "bold", mb: 1.5 }, children: "Passport" }),
337
+ /* @__PURE__ */ jsx(Passport, { user: userState.data })
338
+ ]
339
+ }
340
+ ),
341
+ /* @__PURE__ */ jsx(
342
+ Box,
343
+ {
344
+ sx: {
345
+ gridArea: "extraInfo"
346
+ },
347
+ children: /* @__PURE__ */ jsx(
348
+ UserInfo,
349
+ {
350
+ user: userState.data,
351
+ sx: {
352
+ padding: 3,
353
+ borderRadius: 3
354
+ }
355
+ }
356
+ )
357
+ }
358
+ )
359
+ ] }) : null
360
+ ]
361
+ }
362
+ );
363
+ }, [userState, userCenterTabs, mdGridTemplateAreas, xsGridTemplateAreas]);
364
+ if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
365
+ window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
366
+ return null;
367
+ }
368
+ return /* @__PURE__ */ jsxs(
369
+ Box,
370
+ {
371
+ sx: {
372
+ backgroundColor: colors.backgroundsBgSubtitle,
373
+ minHeight: "100vh"
374
+ },
375
+ children: [
376
+ /* @__PURE__ */ jsx(Header, {}),
377
+ /* @__PURE__ */ jsx(
378
+ Box,
379
+ {
380
+ sx: {
381
+ pt: {
382
+ xs: `${400 / 1280 * 100}%`,
383
+ sm: `${300 / 1280 * 100}%`,
384
+ md: `${200 / 1280 * 100}%`
385
+ },
386
+ backgroundImage: `url(${banner})`,
387
+ backgroundSize: "cover",
388
+ minHeight: "60px"
389
+ }
390
+ }
391
+ ),
392
+ content,
393
+ confirmHolder
394
+ ]
395
+ }
396
+ );
397
+ }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ type TUserInfoItemProps = {
3
+ data: {
4
+ icon: any;
5
+ title: string;
6
+ content: any;
7
+ };
8
+ };
9
+ export default function UserInfoItem({ data }: TUserInfoItemProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,54 @@
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 }) {
5
+ return /* @__PURE__ */ jsxs(
6
+ Box,
7
+ {
8
+ sx: {
9
+ display: "grid",
10
+ gridTemplateColumns: "auto 1fr",
11
+ gridTemplateAreas: `"icon title" ". content"`,
12
+ alignItems: "center",
13
+ rowGap: 0.75,
14
+ columnGap: 1
15
+ },
16
+ children: [
17
+ /* @__PURE__ */ jsx(
18
+ Box,
19
+ {
20
+ sx: {
21
+ gridArea: "icon",
22
+ display: "flex",
23
+ alignItems: "center"
24
+ },
25
+ children: data.icon
26
+ }
27
+ ),
28
+ /* @__PURE__ */ jsx(
29
+ Typography,
30
+ {
31
+ sx: {
32
+ color: colors.textBase,
33
+ gridArea: "title",
34
+ fontSize: "14px"
35
+ },
36
+ children: data.title
37
+ }
38
+ ),
39
+ /* @__PURE__ */ jsx(
40
+ Typography,
41
+ {
42
+ sx: {
43
+ color: colors.textSubtitle,
44
+ whiteSpace: "pre-wrap",
45
+ gridArea: "content",
46
+ fontSize: "14px"
47
+ },
48
+ children: data.content
49
+ }
50
+ )
51
+ ]
52
+ }
53
+ );
54
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ import type { PaperProps } from '@mui/material';
3
+ import type { User } from '../../@types';
4
+ export default function UserInfo({ user, ...rest }: {
5
+ user: User;
6
+ } & PaperProps): import("react").JSX.Element;
@@ -0,0 +1,68 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Paper } from "@mui/material";
3
+ import { Icon } from "@iconify/react";
4
+ import { useMemoizedFn, useCreation } from "ahooks";
5
+ import MailOutlineRoundedIcon from "@iconify-icons/material-symbols/mail-outline-rounded";
6
+ import ScheduleOutlineRoundedIcon from "@iconify-icons/material-symbols/schedule-outline-rounded";
7
+ import MoreTimeRoundedIcon from "@iconify-icons/material-symbols/more-time-rounded";
8
+ import CaptivePortalRoundedIcon from "@iconify-icons/material-symbols/captive-portal-rounded";
9
+ import { translate } from "@arcblock/ux/lib/Locale/util";
10
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
11
+ import RelativeTime from "@arcblock/ux/lib/RelativeTime";
12
+ import UserInfoItem from "./user-info-item.js";
13
+ import { translations } from "../libs/locales.js";
14
+ export default function UserInfo({
15
+ user,
16
+ ...rest
17
+ }) {
18
+ const { locale } = useLocaleContext();
19
+ const t = useMemoizedFn((key, data = {}) => {
20
+ return translate(translations, key, locale, "en", data);
21
+ });
22
+ const readableProvider = useCreation(() => {
23
+ const nameMap = {
24
+ wallet: "DID Wallet",
25
+ auth0: "Auth0"
26
+ };
27
+ return nameMap[user.sourceProvider] || t("unknown");
28
+ }, [user?.sourceProvider]);
29
+ const userInfoListData = [];
30
+ userInfoListData.push({
31
+ icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: MailOutlineRoundedIcon }),
32
+ title: t("email"),
33
+ content: user?.email || t("emptyField")
34
+ });
35
+ userInfoListData.push({
36
+ icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: ScheduleOutlineRoundedIcon }),
37
+ title: t("lastLogin"),
38
+ content: /* @__PURE__ */ jsx(Fragment, { children: user?.lastLoginAt || user?.lastLoginIp ? /* @__PURE__ */ jsxs(Fragment, { children: [
39
+ user?.lastLoginAt ? /* @__PURE__ */ jsx(RelativeTime, { locale, value: user?.lastLoginAt }) : null,
40
+ user?.lastLoginAt && user?.lastLoginIp ? /* @__PURE__ */ jsx("br", {}) : null,
41
+ user?.lastLoginIp
42
+ ] }) : t("unknown") })
43
+ });
44
+ userInfoListData.push({
45
+ icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: MoreTimeRoundedIcon }),
46
+ title: t("createdAt"),
47
+ content: user?.createdAt ? /* @__PURE__ */ jsx(RelativeTime, { locale, value: user?.createdAt }) : t("unknown")
48
+ });
49
+ userInfoListData.push({
50
+ icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: CaptivePortalRoundedIcon }),
51
+ title: t("registerFrom"),
52
+ content: readableProvider
53
+ });
54
+ return /* @__PURE__ */ jsx(
55
+ Paper,
56
+ {
57
+ variant: "outlined",
58
+ ...rest,
59
+ sx: {
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ gap: 3,
63
+ ...rest?.sx
64
+ },
65
+ children: userInfoListData.map((item) => /* @__PURE__ */ jsx(UserInfoItem, { data: item }, item.title))
66
+ }
67
+ );
68
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import { WebhookItemProps } from '../../@types';
3
+ export default function WebhookItem({ onTest, onDelete, onSave, onCancel, type, url, edit, }: WebhookItemProps): import("react").JSX.Element;