@blocklet/ui-react 3.0.8 → 3.0.10

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 (49) hide show
  1. package/lib/BlockletStudio/index.js +70 -71
  2. package/lib/ComponentInstaller/index.js +85 -88
  3. package/lib/ComponentInstaller/installer-item.js +47 -53
  4. package/lib/ComponentInstaller/use-component-installed.js +32 -38
  5. package/lib/ComponentManager/components/add-component.js +47 -50
  6. package/lib/ComponentManager/components/publish-component.js +30 -31
  7. package/lib/ComponentManager/components/resource-dialog.js +28 -30
  8. package/lib/Dashboard/index.js +59 -61
  9. package/lib/Footer/index.js +51 -52
  10. package/lib/Footer/internal-footer.js +43 -47
  11. package/lib/Footer/layout/standard.js +11 -12
  12. package/lib/Footer/links.js +25 -28
  13. package/lib/Footer/social-media.js +17 -17
  14. package/lib/Header/index.js +81 -83
  15. package/lib/Notifications/Snackbar.js +76 -77
  16. package/lib/Notifications/hooks/use-title.js +34 -34
  17. package/lib/Notifications/utils.js +56 -60
  18. package/lib/UserCenter/components/config-inviter.js +17 -18
  19. package/lib/UserCenter/components/danger-zone.js +49 -52
  20. package/lib/UserCenter/components/nft.js +44 -45
  21. package/lib/UserCenter/components/notification.js +92 -99
  22. package/lib/UserCenter/components/passport.js +22 -22
  23. package/lib/UserCenter/components/privacy.js +6 -6
  24. package/lib/UserCenter/components/settings.js +40 -43
  25. package/lib/UserCenter/components/status-dialog/date-picker.js +7 -8
  26. package/lib/UserCenter/components/status-dialog/index.js +112 -114
  27. package/lib/UserCenter/components/status-selector/duration-menu.js +35 -36
  28. package/lib/UserCenter/components/status-selector/index.js +13 -13
  29. package/lib/UserCenter/components/storage/action.js +21 -22
  30. package/lib/UserCenter/components/storage/delete.js +24 -24
  31. package/lib/UserCenter/components/third-party-login/index.js +53 -53
  32. package/lib/UserCenter/components/third-party-login/third-party-item.js +87 -89
  33. package/lib/UserCenter/components/user-center.js +198 -207
  34. package/lib/UserCenter/components/user-info/metadata.js +343 -353
  35. package/lib/UserCenter/components/user-info/switch-role.js +17 -20
  36. package/lib/UserCenter/components/user-info/user-basic-info.js +79 -82
  37. package/lib/UserCenter/components/user-info/user-info.js +40 -40
  38. package/lib/UserCenter/components/user-info/user-status.js +97 -99
  39. package/lib/UserCenter/components/user-info/utils.js +34 -35
  40. package/lib/UserSessions/components/user-session-info.js +25 -28
  41. package/lib/UserSessions/components/user-sessions.js +169 -181
  42. package/lib/blocklets.js +62 -72
  43. package/lib/common/domain-warning.js +31 -31
  44. package/lib/common/header-addons.js +49 -53
  45. package/lib/common/notification-addon.js +29 -32
  46. package/lib/common/ws.js +17 -18
  47. package/lib/contexts/config-user-space.js +16 -19
  48. package/lib/utils.js +44 -48
  49. package/package.json +9 -9
@@ -1,22 +1,19 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { memo as r } from "react";
3
- import { Chip as p } from "@mui/material";
4
- import { Icon as m } from "@iconify/react";
5
- import e from "@iconify-icons/material-symbols/swap-horiz-rounded";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { memo as n } from "react";
3
+ import { Chip as i } from "@mui/material";
4
+ import { Icon as a } from "@iconify/react";
5
+ import p from "@iconify-icons/material-symbols/swap-horiz-rounded";
6
6
  import { useCreation as c } from "ahooks";
7
- function f({ user: o, switchPassport: i }) {
8
- const t = c(
7
+ function m({ user: o, switchPassport: r }) {
8
+ const l = c(
9
9
  // FIXME: @zhanghan 感觉应该把 name 的判断去掉?
10
- () => {
11
- var l;
12
- return (l = (o == null ? void 0 : o.passports) || []) == null ? void 0 : l.find((n) => n.name === o.role || n.role === o.role);
13
- },
14
- [o == null ? void 0 : o.passports, o == null ? void 0 : o.role]
10
+ () => (o?.passports || [])?.find((e) => e.name === o.role || e.role === o.role),
11
+ [o?.passports, o?.role]
15
12
  );
16
- return /* @__PURE__ */ a(
17
- p,
13
+ return /* @__PURE__ */ t(
14
+ i,
18
15
  {
19
- label: (t == null ? void 0 : t.title) || (o == null ? void 0 : o.role) || "Guest",
16
+ label: l?.title || o?.role || "Guest",
20
17
  size: "small",
21
18
  variant: "outlined",
22
19
  sx: {
@@ -34,13 +31,13 @@ function f({ user: o, switchPassport: i }) {
34
31
  }
35
32
  },
36
33
  clickable: !0,
37
- deleteIcon: /* @__PURE__ */ a(m, { icon: e, color: "inherit" }),
38
- onDelete: i,
39
- onClick: i
34
+ deleteIcon: /* @__PURE__ */ t(a, { icon: p, color: "inherit" }),
35
+ onDelete: r,
36
+ onClick: r
40
37
  }
41
38
  );
42
39
  }
43
- const k = r(f);
40
+ const S = n(m);
44
41
  export {
45
- k as default
42
+ S as default
46
43
  };
@@ -1,81 +1,78 @@
1
- import { jsxs as c, jsx as r, Fragment as N } from "react/jsx-runtime";
2
- import { Box as l, Typography as z, Divider as T, IconButton as F, Collapse as K } from "@mui/material";
3
- import W from "@arcblock/ux/lib/Avatar";
4
- import O from "@arcblock/ux/lib/DID";
5
- import { useMemoizedFn as Q } from "ahooks";
6
- import { translate as V } from "@arcblock/ux/lib/Locale/util";
7
- import { useLocaleContext as Y } from "@arcblock/ux/lib/Locale/context";
8
- import $ from "lodash/noop";
9
- import { useState as S, useEffect as j } from "react";
10
- import I from "@arcblock/ux/lib/Toast";
11
- import { parseURL as q, joinURL as G } from "ufo";
12
- import { KeyboardArrowUp as H, KeyboardArrowDown as J } from "@mui/icons-material";
13
- import { translations as X } from "../../libs/locales.js";
14
- import { formatAxiosError as R } from "../../libs/utils.js";
15
- import { currentTimezone as Z, getStatusDuration as _, isValidUrl as P } from "./utils.js";
16
- import M from "./switch-role.js";
17
- import tt from "./metadata.js";
18
- import ot from "./user-status.js";
19
- import rt from "./user-info.js";
20
- import { client as u } from "../../../libs/client.js";
1
+ import { jsxs as c, jsx as r, Fragment as E } from "react/jsx-runtime";
2
+ import { Box as l, Typography as y, Divider as B, IconButton as N, Collapse as T } from "@mui/material";
3
+ import F from "@arcblock/ux/lib/Avatar";
4
+ import K from "@arcblock/ux/lib/DID";
5
+ import { useMemoizedFn as W } from "ahooks";
6
+ import { translate as O } from "@arcblock/ux/lib/Locale/util";
7
+ import { useLocaleContext as Q } from "@arcblock/ux/lib/Locale/context";
8
+ import V from "lodash/noop";
9
+ import { useState as S, useEffect as U } from "react";
10
+ import C from "@arcblock/ux/lib/Toast";
11
+ import { parseURL as Y, joinURL as $ } from "ufo";
12
+ import { KeyboardArrowUp as q, KeyboardArrowDown as G } from "@mui/icons-material";
13
+ import { translations as H } from "../../libs/locales.js";
14
+ import { formatAxiosError as z } from "../../libs/utils.js";
15
+ import { currentTimezone as J, getStatusDuration as X, isValidUrl as Z } from "./utils.js";
16
+ import _ from "./switch-role.js";
17
+ import P from "./metadata.js";
18
+ import M from "./user-status.js";
19
+ import tt from "./user-info.js";
20
+ import { client as j } from "../../../libs/client.js";
21
21
  function St({
22
22
  user: t,
23
23
  isMyself: a = !0,
24
- showFullDid: x = !0,
25
- switchPassport: A,
26
- switchProfile: b,
27
- isMobile: e = !1,
28
- onlyProfile: p = !1,
29
- refreshProfile: h,
24
+ showFullDid: f = !0,
25
+ switchPassport: I,
26
+ switchProfile: R,
27
+ isMobile: o = !1,
28
+ onlyProfile: s = !1,
29
+ refreshProfile: u,
30
30
  ...m
31
31
  }) {
32
- var U;
33
- const { locale: g } = Y(), [d, w] = S(void 0), v = Q((n, o = {}) => V(X, n, g, "en", o)), [s, y] = S(!e || p);
34
- j(() => {
35
- var n;
36
- w((n = t == null ? void 0 : t.metadata) == null ? void 0 : n.status);
37
- }, [t]), j(() => {
38
- y(!e || p);
39
- }, [e, p]);
40
- const D = async (n) => {
32
+ const { locale: x } = Q(), [h, g] = S(void 0), w = W((n, e = {}) => O(H, n, x, "en", e)), [d, v] = S(!o || s);
33
+ U(() => {
34
+ g(t?.metadata?.status);
35
+ }, [t]), U(() => {
36
+ v(!o || s);
37
+ }, [o, s]);
38
+ const A = async (n) => {
41
39
  if (a)
42
40
  try {
43
41
  if (n) {
44
- const o = _(n);
45
- n.dateRange = o.length > 0 ? o : (d == null ? void 0 : d.dateRange) ?? [];
42
+ const e = X(n);
43
+ n.dateRange = e.length > 0 ? e : h?.dateRange ?? [];
46
44
  }
47
- w(n), await u.user.saveProfile({
45
+ g(n), await j.user.saveProfile({
48
46
  // @ts-ignore
49
47
  metadata: {
50
- ...(t == null ? void 0 : t.metadata) ?? { joinedAt: t == null ? void 0 : t.createdAt, email: t == null ? void 0 : t.email, phone: t == null ? void 0 : t.phone },
48
+ ...t?.metadata ?? { joinedAt: t?.createdAt, email: t?.email, phone: t?.phone },
51
49
  status: n || {}
52
50
  }
53
- }), h();
54
- } catch (o) {
55
- console.error(o), I.error(R(o));
51
+ }), u();
52
+ } catch (e) {
53
+ console.error(e), C.error(z(e));
56
54
  }
57
- }, L = () => {
58
- y(!s);
55
+ }, b = () => {
56
+ v(!d);
59
57
  };
60
58
  if (!t)
61
59
  return null;
62
- const k = async (n) => {
63
- var C;
60
+ const D = async (n) => {
64
61
  if (!a)
65
62
  return;
66
- const { metadata: o, address: E } = n;
63
+ const { metadata: e, address: L } = n;
67
64
  try {
68
- const f = ((C = o == null ? void 0 : o.links) == null ? void 0 : C.map((i) => {
69
- if (!i.url || !P(i.url)) return null;
65
+ const p = e?.links?.map((i) => {
66
+ if (!i.url || !Z(i.url)) return null;
70
67
  try {
71
- return q(i.url).protocol || (i.url = G("https://", i.url)), i;
68
+ return Y(i.url).protocol || (i.url = $("https://", i.url)), i;
72
69
  } catch {
73
70
  return console.error("Invalid URL:", i.url), null;
74
71
  }
75
- }).filter((i) => !!i)) || [];
76
- o.links = f, await u.user.saveProfile({ metadata: o, address: E }), h();
77
- } catch (f) {
78
- console.error(f), I.error(R(f));
72
+ }).filter((i) => !!i) || [];
73
+ e.links = p, await j.user.saveProfile({ metadata: e, address: L }), u();
74
+ } catch (p) {
75
+ console.error(p), C.error(z(p));
79
76
  }
80
77
  };
81
78
  return /* @__PURE__ */ c(
@@ -93,7 +90,7 @@ function St({
93
90
  className: "user-info",
94
91
  sx: {
95
92
  display: "flex",
96
- flexDirection: e ? "row" : "column",
93
+ flexDirection: o ? "row" : "column",
97
94
  gap: 2
98
95
  },
99
96
  children: [
@@ -109,11 +106,11 @@ function St({
109
106
  },
110
107
  children: [
111
108
  /* @__PURE__ */ r(
112
- W,
109
+ F,
113
110
  {
114
- src: t == null ? void 0 : t.avatar,
115
- did: t == null ? void 0 : t.did,
116
- size: m.size || (e ? 64 : 100),
111
+ src: t?.avatar,
112
+ did: t?.did,
113
+ size: m.size || (o ? 64 : 100),
117
114
  variant: "circle",
118
115
  shape: "circle",
119
116
  sx: {
@@ -125,7 +122,7 @@ function St({
125
122
  ...a ? {
126
123
  cursor: "pointer",
127
124
  "&::after": {
128
- content: `"${v("switchProfile")}"`,
125
+ content: `"${w("switchProfile")}"`,
129
126
  color: "white",
130
127
  position: "absolute",
131
128
  fontSize: "12px",
@@ -140,18 +137,18 @@ function St({
140
137
  }
141
138
  } : {}
142
139
  },
143
- onClick: a ? b : $
140
+ onClick: a ? R : V
144
141
  }
145
142
  ),
146
143
  /* @__PURE__ */ r(
147
- ot,
144
+ M,
148
145
  {
149
- isMobile: e,
150
- size: m.size || (e ? 64 : 100),
146
+ isMobile: o,
147
+ size: m.size || (o ? 64 : 100),
151
148
  isMyself: a,
152
- timezone: ((U = t == null ? void 0 : t.metadata) == null ? void 0 : U.timezone) || Z,
153
- status: d,
154
- onChange: D
149
+ timezone: t?.metadata?.timezone || J,
150
+ status: h,
151
+ onChange: A
155
152
  }
156
153
  )
157
154
  ]
@@ -166,7 +163,7 @@ function St({
166
163
  },
167
164
  children: [
168
165
  /* @__PURE__ */ c(
169
- z,
166
+ y,
170
167
  {
171
168
  variant: "h6",
172
169
  component: "div",
@@ -188,24 +185,24 @@ function St({
188
185
  textOverflow: "ellipsis",
189
186
  whiteSpace: "nowrap"
190
187
  },
191
- children: t == null ? void 0 : t.fullName
188
+ children: t?.fullName
192
189
  }
193
190
  ),
194
- a ? /* @__PURE__ */ r(M, { user: t, switchPassport: A }) : null
191
+ a ? /* @__PURE__ */ r(_, { user: t, switchPassport: I }) : null
195
192
  ]
196
193
  }
197
194
  ),
198
- /* @__PURE__ */ r(O, { did: t.did, showQrcode: !0, copyable: !0, compact: !x, responsive: !x, locale: g })
195
+ /* @__PURE__ */ r(K, { did: t.did, showQrcode: !0, copyable: !0, compact: !f, responsive: !f, locale: x })
199
196
  ]
200
197
  }
201
198
  )
202
199
  ]
203
200
  }
204
201
  ),
205
- /* @__PURE__ */ r(tt, { isMobile: e, isMyself: a, user: t, onSave: k }),
206
- a ? /* @__PURE__ */ c(N, { children: [
207
- /* @__PURE__ */ r(T, { sx: { my: e ? 1 : 3 } }),
208
- e && !p ? /* @__PURE__ */ r(
202
+ /* @__PURE__ */ r(P, { isMobile: o, isMyself: a, user: t, onSave: D }),
203
+ a ? /* @__PURE__ */ c(E, { children: [
204
+ /* @__PURE__ */ r(B, { sx: { my: o ? 1 : 3 } }),
205
+ o && !s ? /* @__PURE__ */ r(
209
206
  l,
210
207
  {
211
208
  sx: {
@@ -214,10 +211,10 @@ function St({
214
211
  mb: 0
215
212
  },
216
213
  children: /* @__PURE__ */ r(
217
- F,
214
+ N,
218
215
  {
219
216
  size: "small",
220
- onClick: L,
217
+ onClick: b,
221
218
  sx: {
222
219
  backgroundColor: "grey.50",
223
220
  "&:hover": {
@@ -225,14 +222,14 @@ function St({
225
222
  opacity: 0.8
226
223
  }
227
224
  },
228
- children: s ? /* @__PURE__ */ r(H, {}) : /* @__PURE__ */ r(J, {})
225
+ children: d ? /* @__PURE__ */ r(q, {}) : /* @__PURE__ */ r(G, {})
229
226
  }
230
227
  )
231
228
  }
232
229
  ) : null,
233
- /* @__PURE__ */ c(K, { in: s, timeout: "auto", children: [
230
+ /* @__PURE__ */ c(T, { in: d, timeout: "auto", children: [
234
231
  /* @__PURE__ */ r(
235
- z,
232
+ y,
236
233
  {
237
234
  component: "p",
238
235
  sx: {
@@ -240,10 +237,10 @@ function St({
240
237
  fontSize: "14px",
241
238
  mb: 2
242
239
  },
243
- children: v("profile.justForYou")
240
+ children: w("profile.justForYou")
244
241
  }
245
242
  ),
246
- /* @__PURE__ */ r(rt, { user: t, isMySelf: a })
243
+ /* @__PURE__ */ r(tt, { user: t, isMySelf: a })
247
244
  ] })
248
245
  ] }) : null
249
246
  ]
@@ -1,63 +1,63 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { Box as I } from "@mui/material";
3
- import { Icon as e } from "@iconify/react";
4
- import { useMemoizedFn as v, useCreation as h } from "ahooks";
5
- import x from "@arcblock/ux/lib/DID";
6
- import g from "@iconify-icons/material-symbols/schedule-outline-rounded";
7
- import L from "@iconify-icons/material-symbols/more-time-rounded";
8
- import p from "@iconify-icons/material-symbols/captive-portal-rounded";
9
- import A from "@iconify-icons/material-symbols/settings-input-antenna-rounded";
10
- import f from "@arcblock/ux/lib/RelativeTime";
11
- import { translate as R } from "@arcblock/ux/lib/Locale/util";
12
- import { useLocaleContext as S } from "@arcblock/ux/lib/Locale/context";
13
- import { LOGIN_PROVIDER_NAME as z } from "@arcblock/ux/lib/Util/constant";
14
- import P from "@arcblock/ux/lib/UserCard/Content/shorten-label";
15
- import { translations as w } from "../../libs/locales.js";
16
- import D from "./user-info-item.js";
17
- function V({
2
+ import { Box as d } from "@mui/material";
3
+ import { Icon as i } from "@iconify/react";
4
+ import { useMemoizedFn as u, useCreation as I } from "ahooks";
5
+ import v from "@arcblock/ux/lib/DID";
6
+ import h from "@iconify-icons/material-symbols/schedule-outline-rounded";
7
+ import x from "@iconify-icons/material-symbols/more-time-rounded";
8
+ import l from "@iconify-icons/material-symbols/captive-portal-rounded";
9
+ import g from "@iconify-icons/material-symbols/settings-input-antenna-rounded";
10
+ import p from "@arcblock/ux/lib/RelativeTime";
11
+ import { translate as L } from "@arcblock/ux/lib/Locale/util";
12
+ import { useLocaleContext as A } from "@arcblock/ux/lib/Locale/context";
13
+ import { LOGIN_PROVIDER_NAME as R } from "@arcblock/ux/lib/Util/constant";
14
+ import S from "@arcblock/ux/lib/UserCard/Content/shorten-label";
15
+ import { translations as z } from "../../libs/locales.js";
16
+ import P from "./user-info-item.js";
17
+ function G({
18
18
  user: o,
19
- isMySelf: l = !1,
20
- ...c
19
+ isMySelf: a = !1,
20
+ ...m
21
21
  }) {
22
- const { locale: a } = S(), n = v((m, r = {}) => R(w, m, a, "en", r)), d = h(() => (o == null ? void 0 : o.sourceProvider) && z[o.sourceProvider] || n("unknown"), [o == null ? void 0 : o.sourceProvider]), i = [];
23
- return l && (i.push({
24
- icon: /* @__PURE__ */ t(e, { fontSize: 16, icon: g }),
22
+ const { locale: r } = A(), n = u((c, s = {}) => L(z, c, r, "en", s)), f = I(() => o?.sourceProvider && R[o.sourceProvider] || n("unknown"), [o?.sourceProvider]), e = [];
23
+ return a && (e.push({
24
+ icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: h }),
25
25
  title: n("lastLoginAt"),
26
- content: o != null && o.lastLoginAt ? (
26
+ content: o?.lastLoginAt ? (
27
27
  // @ts-ignore
28
- /* @__PURE__ */ t(f, { locale: a, value: o == null ? void 0 : o.lastLoginAt, relativeRange: 3 * 86400 * 1e3 })
28
+ /* @__PURE__ */ t(p, { locale: r, value: o?.lastLoginAt, relativeRange: 3 * 86400 * 1e3 })
29
29
  ) : n("unknown")
30
- }), i.push({
31
- icon: /* @__PURE__ */ t(e, { fontSize: 16, icon: A }),
30
+ }), e.push({
31
+ icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: g }),
32
32
  title: n("lastLoginIp"),
33
- content: o != null && o.lastLoginIp ? /* @__PURE__ */ t(P, { maxLength: 20, children: o == null ? void 0 : o.lastLoginIp }) : n("unknown")
34
- })), i.push({
35
- icon: /* @__PURE__ */ t(e, { fontSize: 16, icon: L }),
33
+ content: o?.lastLoginIp ? /* @__PURE__ */ t(S, { maxLength: 20, children: o?.lastLoginIp }) : n("unknown")
34
+ })), e.push({
35
+ icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: x }),
36
36
  title: n("createdAt"),
37
37
  // @ts-ignore
38
- content: o != null && o.createdAt ? /* @__PURE__ */ t(f, { locale: a, value: o == null ? void 0 : o.createdAt }) : n("unknown")
39
- }), l && (i.push({
40
- icon: /* @__PURE__ */ t(e, { fontSize: 16, icon: p }),
38
+ content: o?.createdAt ? /* @__PURE__ */ t(p, { locale: r, value: o?.createdAt }) : n("unknown")
39
+ }), a && (e.push({
40
+ icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: l }),
41
41
  title: n("registerFrom"),
42
- content: d
43
- }), o != null && o.inviter && i.push({
44
- icon: /* @__PURE__ */ t(e, { fontSize: 16, icon: p }),
42
+ content: f
43
+ }), o?.inviter && e.push({
44
+ icon: /* @__PURE__ */ t(i, { fontSize: 16, icon: l }),
45
45
  title: n("invitedBy"),
46
- content: /* @__PURE__ */ t(x, { style: { maxWidth: 260 }, did: o.inviter, showQrcode: !0, copyable: !0, compact: !0, responsive: !0, locale: a })
46
+ content: /* @__PURE__ */ t(v, { style: { maxWidth: 260 }, did: o.inviter, showQrcode: !0, copyable: !0, compact: !0, responsive: !0, locale: r })
47
47
  })), /* @__PURE__ */ t(
48
- I,
48
+ d,
49
49
  {
50
- ...c,
50
+ ...m,
51
51
  sx: {
52
52
  display: "flex",
53
53
  flexDirection: "column",
54
54
  gap: 1.5,
55
- ...c == null ? void 0 : c.sx
55
+ ...m?.sx
56
56
  },
57
- children: i.map((m) => /* @__PURE__ */ t(D, { data: m, sx: { flex: 1 } }, m.title))
57
+ children: e.map((c) => /* @__PURE__ */ t(P, { data: c, sx: { flex: 1 } }, c.title))
58
58
  }
59
59
  );
60
60
  }
61
61
  export {
62
- V as default
62
+ G as default
63
63
  };