@blocklet/ui-react 2.9.91 → 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.
Files changed (209) hide show
  1. package/build.config.ts +1 -6
  2. package/lib/@types/index.d.ts +1 -0
  3. package/lib/@types/index.js +0 -1
  4. package/lib/BlockletStudio/index.js +50 -50
  5. package/lib/ComponentInstaller/index.js +122 -202
  6. package/lib/ComponentInstaller/installer-item.js +116 -138
  7. package/lib/ComponentInstaller/locales.js +5 -10
  8. package/lib/ComponentInstaller/use-component-installed.js +37 -41
  9. package/lib/ComponentManager/components/add-component.js +58 -67
  10. package/lib/ComponentManager/components/check-component.js +2 -9
  11. package/lib/ComponentManager/components/publish-component.js +50 -59
  12. package/lib/ComponentManager/components/resource-dialog.js +42 -39
  13. package/lib/ComponentManager/index.js +3 -27
  14. package/lib/ComponentManager/libs/locales.js +2 -8
  15. package/lib/Dashboard/index.js +74 -99
  16. package/lib/Footer/brand.js +21 -43
  17. package/lib/Footer/copyright.js +15 -24
  18. package/lib/Footer/index.js +47 -71
  19. package/lib/Footer/internal-footer.js +72 -100
  20. package/lib/Footer/layout/plain.js +26 -45
  21. package/lib/Footer/layout/row.js +12 -29
  22. package/lib/Footer/layout/standard.js +34 -64
  23. package/lib/Footer/links.js +74 -104
  24. package/lib/Footer/social-media.js +35 -42
  25. package/lib/Header/index.js +69 -117
  26. package/lib/Icon/index.js +18 -53
  27. package/{es/UserCenter/components/notification.d.ts → lib/UserCenter/components/config-profile.d.ts} +1 -1
  28. package/lib/UserCenter/components/config-profile.js +67 -0
  29. package/lib/UserCenter/components/notification.js +203 -186
  30. package/lib/UserCenter/components/passport.js +70 -79
  31. package/lib/UserCenter/components/privacy.js +86 -88
  32. package/lib/UserCenter/components/settings.js +74 -84
  33. package/lib/UserCenter/components/storage/connect-to.js +56 -75
  34. package/lib/UserCenter/components/storage/connected.js +16 -37
  35. package/lib/UserCenter/components/storage/delete.js +42 -51
  36. package/lib/UserCenter/components/storage/disconnect.js +15 -29
  37. package/lib/UserCenter/components/storage/index.js +20 -54
  38. package/lib/UserCenter/components/storage/item.js +94 -122
  39. package/lib/UserCenter/components/storage/preview-nft.js +77 -85
  40. package/lib/UserCenter/components/third-party-login/index.js +49 -61
  41. package/lib/UserCenter/components/third-party-login/third-party-item.js +159 -176
  42. package/lib/UserCenter/components/user-center.js +276 -287
  43. package/lib/UserCenter/components/user-info/index.js +3 -27
  44. package/lib/UserCenter/components/user-info/user-basic-info.js +134 -129
  45. package/lib/UserCenter/components/user-info/user-info-item.js +43 -37
  46. package/lib/UserCenter/components/user-info/user-info.js +41 -74
  47. package/lib/UserCenter/components/webhook-item.js +184 -177
  48. package/lib/UserCenter/index.js +1 -13
  49. package/lib/UserCenter/libs/api.js +4 -16
  50. package/lib/UserCenter/libs/locales.d.ts +10 -0
  51. package/lib/UserCenter/libs/locales.js +12 -8
  52. package/lib/UserCenter/libs/utils.js +7 -17
  53. package/lib/UserSessions/components/user-session-info.js +88 -85
  54. package/lib/UserSessions/components/user-sessions.js +177 -213
  55. package/lib/UserSessions/index.js +1 -13
  56. package/lib/UserSessions/libs/locales.js +2 -8
  57. package/lib/UserSessions/libs/utils.js +4 -11
  58. package/lib/blocklets.js +59 -63
  59. package/lib/common/header-addons.js +44 -60
  60. package/lib/common/link-blocker.js +9 -18
  61. package/lib/common/overridable-theme-provider.js +10 -23
  62. package/lib/common/wallet-hidden-topbar.js +7 -14
  63. package/lib/contexts/config-user-space.js +38 -46
  64. package/lib/hooks/use-mobile.js +5 -13
  65. package/lib/index.js +10 -100
  66. package/lib/libs/client.js +2 -8
  67. package/lib/libs/spaces.js +6 -13
  68. package/lib/types.js +39 -41
  69. package/lib/utils.js +25 -44
  70. package/package.json +8 -38
  71. package/src/@types/index.ts +1 -0
  72. package/src/Footer/brand.jsx +6 -1
  73. package/src/UserCenter/components/config-profile.tsx +70 -0
  74. package/src/UserCenter/components/notification.tsx +63 -47
  75. package/src/UserCenter/components/settings.tsx +6 -0
  76. package/src/UserCenter/libs/locales.ts +10 -0
  77. package/es/@types/index.d.ts +0 -101
  78. package/es/@types/index.js +0 -0
  79. package/es/@types/shims.d.ts +0 -16
  80. package/es/BlockletStudio/index.d.ts +0 -28
  81. package/es/BlockletStudio/index.js +0 -114
  82. package/es/ComponentInstaller/index.d.ts +0 -37
  83. package/es/ComponentInstaller/index.js +0 -200
  84. package/es/ComponentInstaller/installer-item.d.ts +0 -21
  85. package/es/ComponentInstaller/installer-item.js +0 -139
  86. package/es/ComponentInstaller/locales.d.ts +0 -28
  87. package/es/ComponentInstaller/locales.js +0 -22
  88. package/es/ComponentInstaller/use-component-installed.d.ts +0 -12
  89. package/es/ComponentInstaller/use-component-installed.js +0 -88
  90. package/es/ComponentManager/components/add-component.d.ts +0 -16
  91. package/es/ComponentManager/components/add-component.js +0 -114
  92. package/es/ComponentManager/components/check-component.d.ts +0 -2
  93. package/es/ComponentManager/components/check-component.js +0 -2
  94. package/es/ComponentManager/components/publish-component.d.ts +0 -10
  95. package/es/ComponentManager/components/publish-component.js +0 -76
  96. package/es/ComponentManager/components/resource-dialog.d.ts +0 -14
  97. package/es/ComponentManager/components/resource-dialog.js +0 -74
  98. package/es/ComponentManager/index.d.ts +0 -3
  99. package/es/ComponentManager/index.js +0 -3
  100. package/es/ComponentManager/libs/locales.d.ts +0 -14
  101. package/es/ComponentManager/libs/locales.js +0 -14
  102. package/es/Dashboard/index.d.ts +0 -40
  103. package/es/Dashboard/index.js +0 -118
  104. package/es/Footer/brand.d.ts +0 -22
  105. package/es/Footer/brand.js +0 -73
  106. package/es/Footer/copyright.d.ts +0 -18
  107. package/es/Footer/copyright.js +0 -25
  108. package/es/Footer/index.d.ts +0 -6
  109. package/es/Footer/index.js +0 -82
  110. package/es/Footer/internal-footer.d.ts +0 -29
  111. package/es/Footer/internal-footer.js +0 -117
  112. package/es/Footer/layout/plain.d.ts +0 -15
  113. package/es/Footer/layout/plain.js +0 -39
  114. package/es/Footer/layout/row.d.ts +0 -18
  115. package/es/Footer/layout/row.js +0 -41
  116. package/es/Footer/layout/standard.d.ts +0 -15
  117. package/es/Footer/layout/standard.js +0 -53
  118. package/es/Footer/links.d.ts +0 -22
  119. package/es/Footer/links.js +0 -207
  120. package/es/Footer/social-media.d.ts +0 -14
  121. package/es/Footer/social-media.js +0 -60
  122. package/es/Header/index.d.ts +0 -10
  123. package/es/Header/index.js +0 -155
  124. package/es/Icon/index.d.ts +0 -23
  125. package/es/Icon/index.js +0 -55
  126. package/es/UserCenter/assets/banner.png +0 -0
  127. package/es/UserCenter/components/notification.js +0 -248
  128. package/es/UserCenter/components/passport.d.ts +0 -6
  129. package/es/UserCenter/components/passport.js +0 -88
  130. package/es/UserCenter/components/privacy.d.ts +0 -11
  131. package/es/UserCenter/components/privacy.js +0 -99
  132. package/es/UserCenter/components/settings.d.ts +0 -9
  133. package/es/UserCenter/components/settings.js +0 -89
  134. package/es/UserCenter/components/storage/connect-to.d.ts +0 -7
  135. package/es/UserCenter/components/storage/connect-to.js +0 -108
  136. package/es/UserCenter/components/storage/connected.d.ts +0 -7
  137. package/es/UserCenter/components/storage/connected.js +0 -24
  138. package/es/UserCenter/components/storage/delete.d.ts +0 -7
  139. package/es/UserCenter/components/storage/delete.js +0 -62
  140. package/es/UserCenter/components/storage/disconnect.d.ts +0 -3
  141. package/es/UserCenter/components/storage/disconnect.js +0 -23
  142. package/es/UserCenter/components/storage/icons/empty-spaces-nft.svg +0 -58
  143. package/es/UserCenter/components/storage/icons/long-arrow.svg +0 -5
  144. package/es/UserCenter/components/storage/icons/space-connected.svg +0 -3
  145. package/es/UserCenter/components/storage/icons/space-disconnect.svg +0 -3
  146. package/es/UserCenter/components/storage/index.d.ts +0 -3
  147. package/es/UserCenter/components/storage/index.js +0 -27
  148. package/es/UserCenter/components/storage/item.d.ts +0 -9
  149. package/es/UserCenter/components/storage/item.js +0 -158
  150. package/es/UserCenter/components/storage/preview-nft.d.ts +0 -6
  151. package/es/UserCenter/components/storage/preview-nft.js +0 -80
  152. package/es/UserCenter/components/third-party-login/index.d.ts +0 -5
  153. package/es/UserCenter/components/third-party-login/index.js +0 -110
  154. package/es/UserCenter/components/third-party-login/third-party-item.d.ts +0 -13
  155. package/es/UserCenter/components/third-party-login/third-party-item.js +0 -224
  156. package/es/UserCenter/components/user-center.d.ts +0 -15
  157. package/es/UserCenter/components/user-center.js +0 -414
  158. package/es/UserCenter/components/user-info/index.d.ts +0 -3
  159. package/es/UserCenter/components/user-info/index.js +0 -3
  160. package/es/UserCenter/components/user-info/user-basic-info.d.ts +0 -11
  161. package/es/UserCenter/components/user-info/user-basic-info.js +0 -151
  162. package/es/UserCenter/components/user-info/user-info-item.d.ts +0 -11
  163. package/es/UserCenter/components/user-info/user-info-item.js +0 -47
  164. package/es/UserCenter/components/user-info/user-info.d.ts +0 -6
  165. package/es/UserCenter/components/user-info/user-info.js +0 -66
  166. package/es/UserCenter/components/webhook-item.d.ts +0 -3
  167. package/es/UserCenter/components/webhook-item.js +0 -243
  168. package/es/UserCenter/index.d.ts +0 -1
  169. package/es/UserCenter/index.js +0 -1
  170. package/es/UserCenter/libs/api.d.ts +0 -3
  171. package/es/UserCenter/libs/api.js +0 -4
  172. package/es/UserCenter/libs/locales.d.ts +0 -162
  173. package/es/UserCenter/libs/locales.js +0 -162
  174. package/es/UserCenter/libs/utils.d.ts +0 -4
  175. package/es/UserCenter/libs/utils.js +0 -14
  176. package/es/UserSessions/components/user-session-info.d.ts +0 -6
  177. package/es/UserSessions/components/user-session-info.js +0 -92
  178. package/es/UserSessions/components/user-sessions.d.ts +0 -9
  179. package/es/UserSessions/components/user-sessions.js +0 -265
  180. package/es/UserSessions/index.d.ts +0 -1
  181. package/es/UserSessions/index.js +0 -1
  182. package/es/UserSessions/libs/locales.d.ts +0 -58
  183. package/es/UserSessions/libs/locales.js +0 -58
  184. package/es/UserSessions/libs/utils.d.ts +0 -2
  185. package/es/UserSessions/libs/utils.js +0 -73
  186. package/es/blocklets.d.ts +0 -16
  187. package/es/blocklets.js +0 -178
  188. package/es/common/header-addons.d.ts +0 -21
  189. package/es/common/header-addons.js +0 -83
  190. package/es/common/link-blocker.d.ts +0 -7
  191. package/es/common/link-blocker.js +0 -18
  192. package/es/common/overridable-theme-provider.d.ts +0 -18
  193. package/es/common/overridable-theme-provider.js +0 -15
  194. package/es/common/wallet-hidden-topbar.d.ts +0 -1
  195. package/es/common/wallet-hidden-topbar.js +0 -14
  196. package/es/contexts/config-user-space.d.ts +0 -26
  197. package/es/contexts/config-user-space.js +0 -53
  198. package/es/hooks/use-mobile.d.ts +0 -4
  199. package/es/hooks/use-mobile.js +0 -5
  200. package/es/index.d.ts +0 -10
  201. package/es/index.js +0 -10
  202. package/es/libs/client.d.ts +0 -2
  203. package/es/libs/client.js +0 -2
  204. package/es/libs/spaces.d.ts +0 -2
  205. package/es/libs/spaces.js +0 -13
  206. package/es/types.d.ts +0 -2
  207. package/es/types.js +0 -43
  208. package/es/utils.d.ts +0 -8
  209. package/es/utils.js +0 -78
@@ -1,248 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Alert, Box, CircularProgress, Divider, Stack, Typography } from "@mui/material";
3
- import { useCreation, useMemoizedFn, useReactive, useRequest } from "ahooks";
4
- import { Icon } from "@iconify/react";
5
- import AddRoundedIcon from "@iconify-icons/material-symbols/add-rounded";
6
- import Switch from "@arcblock/ux/lib/Switch";
7
- import Button from "@arcblock/ux/lib/Button";
8
- import { temp as colors } from "@arcblock/ux/lib/Colors";
9
- import Toast from "@arcblock/ux/lib/Toast";
10
- import { getWalletDid } from "@arcblock/ux/lib/SessionUser/libs/utils";
11
- import { translate } from "@arcblock/ux/lib/Locale/util";
12
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
13
- import { translations } from "../libs/locales.js";
14
- import WebhookItem from "./webhook-item.js";
15
- import { formatAxiosError } from "../libs/utils.js";
16
- import { client } from "../../libs/client.js";
17
- export default function Notification({ user }) {
18
- const { locale } = useLocaleContext();
19
- const t = useMemoizedFn((key, data = {}) => {
20
- return translate(translations, key, locale, "en", data);
21
- });
22
- const currentState = useReactive({
23
- showAdd: false
24
- });
25
- const notificationConfigState = useRequest(
26
- async () => {
27
- const data = await client.user.getUserNotificationConfig();
28
- return data;
29
- },
30
- {
31
- refreshDeps: [user],
32
- loadingDelay: 300
33
- }
34
- );
35
- const notifications = useCreation(() => {
36
- return {
37
- wallet: true,
38
- email: true,
39
- phone: false,
40
- ...notificationConfigState?.data?.notifications || {}
41
- };
42
- }, [notificationConfigState?.data?.notifications]);
43
- const webhooks = useCreation(() => {
44
- return notificationConfigState?.data?.webhooks || [];
45
- }, [notificationConfigState?.data?.webhooks]);
46
- const onSaveChanges = useMemoizedFn(async (values) => {
47
- try {
48
- await client.user.saveUserNotificationConfig(values);
49
- Toast.success(t("saveSuccess"));
50
- notificationConfigState.run();
51
- } catch (err) {
52
- Toast.error(formatAxiosError(err));
53
- }
54
- });
55
- const handleChangeSwitch = useMemoizedFn(async (channel, value) => {
56
- await onSaveChanges({
57
- notifications: {
58
- [channel]: value
59
- }
60
- });
61
- });
62
- const handleTestWebhook = async (data) => {
63
- try {
64
- await client.user.testNotificationWebhook(data);
65
- Toast.success(t("webhookTested"));
66
- } catch (err) {
67
- Toast.error(formatAxiosError(err));
68
- }
69
- };
70
- const handleDeleteWebhook = useMemoizedFn(async (index) => {
71
- await onSaveChanges({
72
- webhooks: webhooks.filter((_, i) => i !== index)
73
- });
74
- });
75
- const handleEditWebhook = useMemoizedFn(async (index, webhook) => {
76
- await onSaveChanges({
77
- webhooks: webhooks.map((item, i) => i === index ? webhook : item)
78
- });
79
- });
80
- const handleAddWebhook = useMemoizedFn(async (webhook) => {
81
- await onSaveChanges({
82
- webhooks: [...webhooks, webhook]
83
- });
84
- currentState.showAdd = false;
85
- });
86
- if (notificationConfigState.error) {
87
- return /* @__PURE__ */ jsx(Alert, { severity: "error", children: notificationConfigState.error.message });
88
- }
89
- if (notificationConfigState.loading || !notificationConfigState.data) {
90
- return /* @__PURE__ */ jsx(
91
- Box,
92
- {
93
- sx: {
94
- display: "flex",
95
- justifyContent: "center",
96
- alignItems: "center",
97
- height: "100px"
98
- },
99
- children: /* @__PURE__ */ jsx(CircularProgress, {})
100
- }
101
- );
102
- }
103
- return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
104
- /* @__PURE__ */ jsxs(
105
- Box,
106
- {
107
- sx: {
108
- display: "flex",
109
- flexDirection: "column",
110
- gap: 1,
111
- alignItems: "start",
112
- ".MuiFormControlLabel-root": {
113
- gap: 1,
114
- m: 0,
115
- flexDirection: {
116
- xs: "row-reverse",
117
- md: "row"
118
- },
119
- width: {
120
- xs: "100%",
121
- md: "unset"
122
- }
123
- },
124
- ".MuiSwitch-track": {
125
- borderRadius: "100vw"
126
- },
127
- ".MuiSwitch-thumb": {
128
- borderRadius: "100%"
129
- },
130
- ".MuiSwitch-root.MuiSwitch-sizeSmall": {
131
- height: "20px",
132
- width: "36px",
133
- ".MuiSwitch-thumb": {
134
- width: "16px",
135
- height: "16px"
136
- }
137
- }
138
- },
139
- children: [
140
- /* @__PURE__ */ jsx(
141
- Switch,
142
- {
143
- checked: notifications.wallet,
144
- labelProps: {
145
- label: /* @__PURE__ */ jsxs(
146
- Typography,
147
- {
148
- color: "text.primary",
149
- sx: {
150
- fontSize: 14,
151
- display: "flex",
152
- flexFlow: "wrap",
153
- columnGap: 1,
154
- flex: 1
155
- },
156
- children: [
157
- t("walletNotification"),
158
- getWalletDid(user) && /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.secondary", fontSize: 13, children: getWalletDid(user) })
159
- ]
160
- }
161
- )
162
- },
163
- size: "small",
164
- onChange: (event) => handleChangeSwitch("wallet", event.target.checked)
165
- }
166
- ),
167
- /* @__PURE__ */ jsx(
168
- Switch,
169
- {
170
- checked: notifications.email,
171
- labelProps: {
172
- label: /* @__PURE__ */ jsxs(
173
- Typography,
174
- {
175
- color: "text.primary",
176
- sx: {
177
- fontSize: 14,
178
- display: "flex",
179
- flexFlow: "wrap",
180
- columnGap: 1,
181
- flex: 1
182
- },
183
- children: [
184
- t("emailNotification"),
185
- user?.email && /* @__PURE__ */ jsx(Typography, { component: "span", color: "text.secondary", fontSize: 13, children: user?.email })
186
- ]
187
- }
188
- )
189
- },
190
- size: "small",
191
- onChange: (event) => handleChangeSwitch("email", event.target.checked)
192
- }
193
- )
194
- ]
195
- }
196
- ),
197
- /* @__PURE__ */ jsx(Divider, {}),
198
- /* @__PURE__ */ jsxs(Stack, { spacing: 1.5, useFlexGap: true, direction: "column", alignItems: "start", children: [
199
- webhooks.map((item, index) => /* @__PURE__ */ jsx(
200
- WebhookItem,
201
- {
202
- onTest: handleTestWebhook,
203
- onDelete: () => handleDeleteWebhook(index),
204
- onSave: (...args) => handleEditWebhook(index, ...args),
205
- type: item.type,
206
- url: item.url,
207
- edit: false
208
- },
209
- `${index}_${item.url}`
210
- )),
211
- currentState.showAdd && /* @__PURE__ */ jsx(
212
- WebhookItem,
213
- {
214
- onTest: handleTestWebhook,
215
- onCancel: () => {
216
- currentState.showAdd = false;
217
- },
218
- onSave: (...args) => handleAddWebhook(...args),
219
- edit: true
220
- },
221
- "add"
222
- ),
223
- /* @__PURE__ */ jsx(
224
- Button,
225
- {
226
- variant: "outlined",
227
- size: "small",
228
- sx: {
229
- color: colors.foregroundsFgBase,
230
- borderColor: colors.strokeBorderBase,
231
- backgroundColor: colors.buttonsButtonNeutral,
232
- "&:hover": {
233
- borderColor: colors.strokeBorderBase,
234
- backgroundColor: colors.buttonsButtonNeutralHover
235
- },
236
- py: 0.5,
237
- borderRadius: 2
238
- },
239
- startIcon: /* @__PURE__ */ jsx(Icon, { icon: AddRoundedIcon }),
240
- onClick: () => {
241
- currentState.showAdd = true;
242
- },
243
- children: t("addWebhook")
244
- }
245
- )
246
- ] })
247
- ] });
248
- }
@@ -1,6 +0,0 @@
1
- /// <reference types="react" />
2
- import type { BoxProps } from '@mui/material';
3
- import type { User } from '../../@types';
4
- export default function Passport({ user, ...rest }: {
5
- user: User;
6
- } & BoxProps): import("react").JSX.Element;
@@ -1,88 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Box } from "@mui/material";
3
- import Empty from "@arcblock/ux/lib/Empty";
4
- import { useTheme } from "@arcblock/ux/lib/Theme";
5
- import { temp as colors } from "@arcblock/ux/lib/Colors";
6
- import PassportItem from "@arcblock/ux/lib/Passport";
7
- import { PASSPORT_STATUS } from "@arcblock/ux/lib/Util/constant";
8
- import { useCreation, useMemoizedFn } from "ahooks";
9
- import uniqBy from "lodash/uniqBy";
10
- import { translate } from "@arcblock/ux/lib/Locale/util";
11
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
12
- import { translations } from "../libs/locales.js";
13
- import { createPassportSvg } from "../libs/utils.js";
14
- export default function Passport({ user, ...rest }) {
15
- const { locale } = useLocaleContext();
16
- const t = useMemoizedFn((key, data = {}) => {
17
- return translate(translations, key, locale, "en", data);
18
- });
19
- const theme = useTheme();
20
- const passports = useCreation(() => {
21
- const passportList = (user?.passports || []).map((x) => ({
22
- ...x,
23
- revoked: x.status === PASSPORT_STATUS.REVOKED
24
- }));
25
- passportList.sort((a, b) => {
26
- if (a.revoked === b.revoked) {
27
- return 0;
28
- }
29
- if (a.revoked) {
30
- return 1;
31
- }
32
- return -1;
33
- });
34
- return uniqBy(passportList, "role");
35
- }, [user?.passports]);
36
- const currentRole = useCreation(() => passports?.find((item) => item.name === user.role), [passports, user?.role]);
37
- const activeColor = useCreation(() => {
38
- return theme?.palette?.primary?.main || colors.textBase;
39
- }, [theme?.palette?.primary?.main]);
40
- if (passports.length === 0) {
41
- return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Empty, { children: t("noPassport") }) });
42
- }
43
- return /* @__PURE__ */ jsx(
44
- Box,
45
- {
46
- ...rest,
47
- sx: {
48
- display: "grid",
49
- gridTemplateColumns: {
50
- xs: "repeat(2, 1fr)",
51
- sm: "repeat(3, 1fr)",
52
- md: "repeat(2, 1fr)"
53
- },
54
- gap: 2.5,
55
- ...rest.sx
56
- },
57
- children: passports.map((x) => /* @__PURE__ */ jsx(
58
- PassportItem,
59
- {
60
- passport: x,
61
- user,
62
- color: window.blocklet.passportColor,
63
- createPassportSvg,
64
- title: currentRole && currentRole.role === x.role ? t("currentPassport") : "",
65
- sx: {
66
- flexDirection: "column",
67
- alignItems: "center",
68
- gap: 1,
69
- ".passport-item__display": {
70
- width: 166,
71
- height: 166,
72
- borderRadius: 2,
73
- px: 2,
74
- display: "flex",
75
- justifyContent: "center",
76
- backgroundColor: colors.backgroundsBgComponent,
77
- boxShadow: currentRole && currentRole.role === x.role ? `0px 2px 4px 0px ${activeColor}, 0px 1px 2px -1px ${activeColor}, 0px 0px 0px 1px ${activeColor} !important` : "unset"
78
- },
79
- ".passport-item__body": {
80
- marginLeft: "0 !important"
81
- }
82
- }
83
- },
84
- x.id
85
- ))
86
- }
87
- );
88
- }
@@ -1,11 +0,0 @@
1
- /// <reference types="react" />
2
- type PrivacyConfig = {
3
- key: string;
4
- name: string;
5
- value: boolean;
6
- };
7
- export default function Privacy({ configList, onSave }: {
8
- configList: PrivacyConfig[];
9
- onSave: () => void;
10
- }): import("react").JSX.Element;
11
- export {};
@@ -1,99 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { Box, Typography } from "@mui/material";
3
- import Switch from "@arcblock/ux/lib/Switch";
4
- import { useState } from "react";
5
- import { useMemoizedFn } from "ahooks";
6
- import { translate } from "@arcblock/ux/lib/Locale/util";
7
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
8
- import Toast from "@arcblock/ux/lib/Toast";
9
- import { translations } from "../libs/locales.js";
10
- import { client } from "../../libs/client.js";
11
- import { formatAxiosError } from "../libs/utils.js";
12
- export default function Privacy({ configList, onSave }) {
13
- const [dataList, setDataList] = useState(configList);
14
- const { locale } = useLocaleContext();
15
- const t = useMemoizedFn((key, data = {}) => {
16
- return translate(translations, key, locale, "en", data);
17
- });
18
- const handleChangeSwitch = useMemoizedFn(async (type, value) => {
19
- try {
20
- const result = await client.user.saveUserPrivacyConfig({
21
- [type]: !value
22
- });
23
- setDataList(
24
- dataList.map((item) => {
25
- return {
26
- ...item,
27
- value: result?.[item.key] ?? item.value
28
- };
29
- })
30
- );
31
- Toast.success(t("saveSuccess"));
32
- onSave();
33
- } catch (err) {
34
- Toast.error(formatAxiosError(err));
35
- }
36
- });
37
- return /* @__PURE__ */ jsx(
38
- Box,
39
- {
40
- sx: {
41
- display: "flex",
42
- flexDirection: "column",
43
- gap: 1,
44
- alignItems: "start",
45
- ".MuiFormControlLabel-root": {
46
- gap: 1,
47
- m: 0,
48
- flexDirection: {
49
- xs: "row-reverse",
50
- md: "row"
51
- },
52
- width: {
53
- xs: "100%",
54
- md: "unset"
55
- }
56
- },
57
- ".MuiSwitch-track": {
58
- borderRadius: "100vw"
59
- },
60
- ".MuiSwitch-thumb": {
61
- borderRadius: "100%"
62
- },
63
- ".MuiSwitch-root.MuiSwitch-sizeSmall": {
64
- height: "20px",
65
- width: "36px",
66
- ".MuiSwitch-thumb": {
67
- width: "16px",
68
- height: "16px"
69
- }
70
- }
71
- },
72
- children: dataList.map((item) => /* @__PURE__ */ jsx(
73
- Switch,
74
- {
75
- checked: !item.value,
76
- labelProps: {
77
- label: /* @__PURE__ */ jsx(
78
- Typography,
79
- {
80
- color: "text.primary",
81
- sx: {
82
- fontSize: 14,
83
- display: "flex",
84
- flexFlow: "wrap",
85
- columnGap: 1,
86
- flex: 1
87
- },
88
- children: t("toPublic", { name: item.name })
89
- }
90
- )
91
- },
92
- size: "small",
93
- onChange: (event) => handleChangeSwitch(item.key, event.target.checked)
94
- },
95
- item.key
96
- ))
97
- }
98
- );
99
- }
@@ -1,9 +0,0 @@
1
- import type { BoxProps } from '@mui/material';
2
- import { User, UserCenterTab } from '../../@types';
3
- export default function Settings({ user, settings, onSave, ...rest }: {
4
- user: User;
5
- onSave: () => void;
6
- settings: {
7
- userCenterTabs: UserCenterTab[];
8
- };
9
- } & BoxProps): any;
@@ -1,89 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import Tabs from "@arcblock/ux/lib/Tabs";
3
- import { Box } from "@mui/material";
4
- import { useCreation, useMemoizedFn, useReactive } from "ahooks";
5
- import { translate } from "@arcblock/ux/lib/Locale/util";
6
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
7
- import { ConfigUserSpaceProvider } from "../../contexts/config-user-space.js";
8
- import { translations } from "../libs/locales.js";
9
- import Notification from "./notification.js";
10
- import Privacy from "./privacy.js";
11
- import DidSpace from "./storage/index.js";
12
- import { UserSessions } from "../../UserSessions/index.js";
13
- import ThirdPartyLogin from "./third-party-login/index.js";
14
- export default function Settings({
15
- user,
16
- settings,
17
- onSave,
18
- ...rest
19
- }) {
20
- const { locale } = useLocaleContext();
21
- const t = useMemoizedFn((key, data = {}) => {
22
- return translate(translations, key, locale, "en", data);
23
- });
24
- const privacyConfigList = useCreation(() => {
25
- const userCenterTabs = settings?.userCenterTabs || [];
26
- return userCenterTabs.map((item) => {
27
- return {
28
- key: item.value,
29
- name: item.label,
30
- value: item.protected
31
- };
32
- });
33
- }, [settings?.userCenterTabs]);
34
- const tabs = useCreation(() => {
35
- return [
36
- {
37
- label: t("notificationManagement"),
38
- value: "notification",
39
- content: /* @__PURE__ */ jsx(Notification, { user })
40
- },
41
- {
42
- label: t("thirdPartyLogin.title"),
43
- value: "thirdPartyLogin",
44
- content: /* @__PURE__ */ jsx(ThirdPartyLogin, { user })
45
- },
46
- {
47
- label: t("privacyManagement"),
48
- value: "privacy",
49
- content: /* @__PURE__ */ jsx(Privacy, { configList: privacyConfigList, onSave })
50
- },
51
- user?.didSpace?.endpoint && {
52
- label: t("storageManagement"),
53
- value: "storage",
54
- content: /* @__PURE__ */ jsx(ConfigUserSpaceProvider, { children: /* @__PURE__ */ jsx(DidSpace, {}) })
55
- },
56
- {
57
- label: t("sessionManagement"),
58
- value: "session",
59
- content: /* @__PURE__ */ jsx(UserSessions, { user })
60
- }
61
- ].filter(Boolean);
62
- }, [user, privacyConfigList]);
63
- const currentState = useReactive({
64
- tab: tabs[0].value
65
- });
66
- const currentTab = useCreation(() => {
67
- return tabs.find((x) => x.value === currentState.tab);
68
- }, [currentState.tab, tabs]);
69
- const handleChangeTab = useMemoizedFn((value) => {
70
- currentState.tab = value;
71
- });
72
- return currentTab && /* @__PURE__ */ jsxs(
73
- Box,
74
- {
75
- ...rest,
76
- sx: {
77
- ...rest?.sx,
78
- minWidth: {
79
- md: 500
80
- },
81
- maxWidth: "100%"
82
- },
83
- children: [
84
- /* @__PURE__ */ jsx(Tabs, { variant: "card", tabs, current: currentTab.value, onChange: handleChangeTab }),
85
- /* @__PURE__ */ jsx(Box, { mt: 2.5, children: currentTab.content })
86
- ]
87
- }
88
- );
89
- }
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { SpaceGateway } from '../../../contexts/config-user-space';
3
- declare function ConnectTo({ onConnect, storageEndpoint, }: {
4
- onConnect: (spaceGateway: SpaceGateway) => Promise<void>;
5
- storageEndpoint: string;
6
- }): import("react").JSX.Element;
7
- export default ConnectTo;
@@ -1,108 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Box, Button, Typography } from "@mui/material";
3
- import { useState } from "react";
4
- import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
- import DidConnect from "@arcblock/did-connect/lib/Connect";
6
- import { joinURL } from "ufo";
7
- import toast from "@arcblock/ux/lib/Toast";
8
- import isEmpty from "lodash/isEmpty";
9
- import { RELAY_SOCKET_PREFIX } from "@arcblock/ux/lib/Util/constant";
10
- import { axios } from "../../libs/api.js";
11
- function ConnectTo({
12
- onConnect,
13
- storageEndpoint
14
- }) {
15
- const { t, locale } = useLocaleContext();
16
- const [authorizeFromNftConnect, setAuthorizeFromNftConnect] = useState({
17
- open: false,
18
- action: "connect-to-did-spaces-for-user",
19
- checkTimeout: 1e3 * 300,
20
- prefix: "/api/did",
21
- checkFn: axios.create({
22
- baseURL: joinURL(window.location.origin, RELAY_SOCKET_PREFIX)
23
- }).get,
24
- extraParams: {},
25
- messages: {
26
- title: t("storage.spaces.provideNFT.title", { appName: window.blocklet.appName }, locale),
27
- scan: t("storage.spaces.provideNFT.scan", { appName: window.blocklet.appName }, locale),
28
- confirm: "",
29
- success: /* @__PURE__ */ jsx(Typography, { gutterBottom: true, children: t("storage.spaces.provideNFT.success") })
30
- },
31
- onClose: () => {
32
- setAuthorizeFromNftConnect((preValue) => ({
33
- ...preValue,
34
- open: false
35
- }));
36
- }
37
- });
38
- const updateSpaceGateway = async (spaceGateway) => {
39
- await onConnect(spaceGateway);
40
- toast.success(t("storage.spaces.connectedWithName", { name: spaceGateway.name }));
41
- };
42
- const onAuthorizeConnectSuccess = (response, decrypt) => {
43
- setTimeout(async () => {
44
- setAuthorizeFromNftConnect((preValue) => ({
45
- ...preValue,
46
- open: false
47
- }));
48
- if (!isEmpty(response.spaceGateway)) {
49
- await updateSpaceGateway(decrypt(response.spaceGateway));
50
- return;
51
- }
52
- const endpoint = decrypt(response.endpoint);
53
- const space = response.space ? decrypt(response.space) : {};
54
- await updateSpaceGateway({
55
- endpoint,
56
- // name 默认为 DID Space,兼容旧版本的 DID Spaces
57
- ...{ name: "DID Space" },
58
- ...space
59
- });
60
- }, 0);
61
- };
62
- const handleUseWalletConnect = () => {
63
- setAuthorizeFromNftConnect((preValue) => ({
64
- ...preValue,
65
- open: true,
66
- extraParams: {
67
- appDid: window.blocklet.appId,
68
- appName: window.blocklet.appName,
69
- appDescription: window.blocklet.appDescription,
70
- scopes: "list:object read:object write:object",
71
- appUrl: window.blocklet.appUrl,
72
- referrer: window.location.href
73
- }
74
- }));
75
- };
76
- return /* @__PURE__ */ jsxs(Box, { children: [
77
- /* @__PURE__ */ jsx(
78
- Button,
79
- {
80
- color: "primary",
81
- sx: { textTransform: "none !important", fontSize: "13px", paddingLeft: 0.75, paddingRight: 0.75 },
82
- size: "small",
83
- onClick: handleUseWalletConnect,
84
- variant: "outlined",
85
- children: storageEndpoint ? t("storage.spaces.connect.useWalletReconnect") : t("storage.spaces.connect.useWallet")
86
- }
87
- ),
88
- /* @__PURE__ */ jsx(
89
- DidConnect,
90
- {
91
- forceConnected: false,
92
- saveConnect: false,
93
- prefix: authorizeFromNftConnect.prefix,
94
- open: authorizeFromNftConnect.open,
95
- popup: true,
96
- action: authorizeFromNftConnect.action,
97
- checkFn: authorizeFromNftConnect.checkFn,
98
- onSuccess: onAuthorizeConnectSuccess,
99
- onClose: authorizeFromNftConnect.onClose,
100
- checkTimeout: authorizeFromNftConnect.checkTimeout,
101
- extraParams: authorizeFromNftConnect.extraParams,
102
- messages: authorizeFromNftConnect.messages,
103
- locale
104
- }
105
- )
106
- ] });
107
- }
108
- export default ConnectTo;
@@ -1,7 +0,0 @@
1
- /// <reference types="react" />
2
- import { SettingStorageEndpoint, SpaceGateway } from '../../../contexts/config-user-space';
3
- declare function Connected({ spaceGateway, settingStorageEndpoint, }: {
4
- spaceGateway: SpaceGateway | undefined;
5
- settingStorageEndpoint: SettingStorageEndpoint;
6
- }): import("react").JSX.Element;
7
- export default Connected;