@arcblock/ux 3.0.9 → 3.0.11

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 (66) hide show
  1. package/lib/Address/did-address.js +47 -49
  2. package/lib/Address/responsive-did-address.js +53 -57
  3. package/lib/Avatar/index.js +16 -16
  4. package/lib/BlockletV2/blocklet.js +64 -64
  5. package/lib/BlockletV2/components/tooltip-icon.js +26 -27
  6. package/lib/CardSelector/index.js +1 -2
  7. package/lib/ClickToCopy/hook.js +10 -11
  8. package/lib/ClickToCopy/index.js +16 -16
  9. package/lib/Config/theme-mode-toggle.js +7 -8
  10. package/lib/DID/index.js +131 -133
  11. package/lib/DIDConnect/app-info-item.js +18 -18
  12. package/lib/DIDConnect/auth-apps/index.js +83 -84
  13. package/lib/DIDConnect/did-connect-container.js +89 -90
  14. package/lib/DIDConnect/did-connect-footer.js +25 -25
  15. package/lib/DIDConnect/landing-page.js +17 -17
  16. package/lib/DIDConnect/powered-by.js +11 -11
  17. package/lib/DIDConnect/request-storage-access-api-dialog.js +36 -37
  18. package/lib/DIDConnect/with-container.js +66 -68
  19. package/lib/Dialog/use-confirm.js +40 -43
  20. package/lib/Earth/index.js +21 -22
  21. package/lib/Footer/index.js +15 -16
  22. package/lib/Header/responsive-header.js +23 -24
  23. package/lib/Layout/dashboard/index.js +63 -72
  24. package/lib/Layout/dashboard/sidebar.js +20 -21
  25. package/lib/Layout/dashboard-legacy/index.js +52 -52
  26. package/lib/Locale/context.js +36 -37
  27. package/lib/Locale/selector.js +40 -42
  28. package/lib/NFTDisplay/index.js +114 -118
  29. package/lib/NFTDisplay/render-svg.js +12 -12
  30. package/lib/NavMenu/nav-menu.js +159 -161
  31. package/lib/NavMenu/sub-container.js +25 -26
  32. package/lib/PageScroller/index.js +28 -32
  33. package/lib/Passport/passport.js +11 -11
  34. package/lib/PhoneInput/country-select.js +38 -38
  35. package/lib/PhoneInput/index.js +65 -66
  36. package/lib/Screenshot/index.js +26 -27
  37. package/lib/SessionBlocklet/index.js +87 -93
  38. package/lib/SessionPermission/index.js +5 -9
  39. package/lib/SessionUser/components/did-space.js +24 -25
  40. package/lib/SessionUser/components/logged-in.js +122 -127
  41. package/lib/SessionUser/components/quick-login-item.js +41 -42
  42. package/lib/SessionUser/components/session-user-item.js +35 -36
  43. package/lib/SessionUser/components/session-user-switch.js +81 -85
  44. package/lib/SessionUser/components/un-login.js +41 -41
  45. package/lib/SessionUser/components/user-info.js +43 -47
  46. package/lib/SessionUser/index.js +1 -1
  47. package/lib/SessionUser/libs/utils.js +24 -30
  48. package/lib/SharedBridge/index.js +35 -35
  49. package/lib/Theme/index.js +16 -16
  50. package/lib/Theme/theme.js +42 -43
  51. package/lib/Toast/index.js +24 -25
  52. package/lib/Typography/index.js +42 -42
  53. package/lib/UserCard/Content/basic.js +91 -93
  54. package/lib/UserCard/Content/shorten-label.js +9 -9
  55. package/lib/UserCard/components.js +15 -15
  56. package/lib/Util/deprecate.js +1 -1
  57. package/lib/Util/federated.js +28 -32
  58. package/lib/Util/iframe.js +9 -10
  59. package/lib/Util/index.js +134 -135
  60. package/lib/Util/security.js +9 -10
  61. package/lib/Util/wallet.js +6 -9
  62. package/lib/VerificationCode/index.js +26 -28
  63. package/lib/hooks/use-blocklet-logo.js +11 -14
  64. package/lib/ux.css +1 -1
  65. package/lib/withTracker/index.js +13 -14
  66. package/package.json +10 -11
@@ -1,50 +1,46 @@
1
- import { jsx as t, jsxs as c, Fragment as M } from "react/jsx-runtime";
2
- import { useTheme as T, Box as S, Popper as D, ClickAwayListener as N, Fade as $, Paper as z, MenuList as L, MenuItem as I, LinearProgress as F, Divider as U } from "@mui/material";
3
- import { useRef as j } from "react";
4
- import { useMemoizedFn as l, useReactive as E, useMount as H, useCreation as _, useSize as O } from "ahooks";
5
- import { Icon as f } from "@iconify/react";
6
- import V from "@iconify-icons/material-symbols/add-circle-outline-rounded";
7
- import q from "@iconify-icons/material-symbols/expand-more-rounded";
8
- import B from "@iconify-icons/material-symbols/swap-horiz-rounded";
9
- import G from "lodash/pick";
10
- import h from "./session-user-item.js";
11
- import { getVisitorId as J } from "../../Util/index.js";
12
- import { translate as K } from "../../Locale/util.js";
13
- import { translations as Q } from "../libs/translation.js";
14
- function sr({
15
- session: o,
16
- onSwitch: g,
17
- isBlocklet: x = !0,
18
- locale: P = "en"
1
+ import { jsx as r, jsxs as d, Fragment as w } from "react/jsx-runtime";
2
+ import { useTheme as I, Box as x, Popper as P, ClickAwayListener as A, Fade as R, Paper as M, MenuList as T, MenuItem as b, LinearProgress as z, Divider as D } from "@mui/material";
3
+ import { useRef as N } from "react";
4
+ import { useMemoizedFn as p, useReactive as $, useMount as L, useCreation as F, useSize as U } from "ahooks";
5
+ import { Icon as l } from "@iconify/react";
6
+ import j from "@iconify-icons/material-symbols/add-circle-outline-rounded";
7
+ import E from "@iconify-icons/material-symbols/expand-more-rounded";
8
+ import H from "@iconify-icons/material-symbols/swap-horiz-rounded";
9
+ import _ from "lodash/pick";
10
+ import u from "./session-user-item.js";
11
+ import { getVisitorId as O } from "../../Util/index.js";
12
+ import { translate as V } from "../../Locale/util.js";
13
+ import { translations as q } from "../libs/translation.js";
14
+ function ne({
15
+ session: s,
16
+ onSwitch: m,
17
+ isBlocklet: f = !0,
18
+ locale: v = "en"
19
19
  }) {
20
- const d = j(null), { palette: n } = T(), A = l((r, e = {}) => K(Q, r, P, "en", e)), i = E({
20
+ const t = N(null), { palette: n } = I(), y = p((e, o = {}) => V(q, e, v, "en", o)), i = $({
21
21
  open: !1,
22
22
  userSessions: [],
23
23
  loadingSessionId: null
24
24
  });
25
- H(async () => {
26
- if (x) {
27
- const r = await o.getUserSessions();
28
- i.userSessions = r;
25
+ L(async () => {
26
+ if (f) {
27
+ const e = await s.getUserSessions();
28
+ i.userSessions = e;
29
29
  }
30
30
  });
31
- const u = _(() => {
32
- var e, s, a, v, y;
33
- const r = (i.userSessions || []).find(
34
- (C) => {
35
- var k, w;
36
- return C.appPid === ((k = globalThis == null ? void 0 : globalThis.blocklet) == null ? void 0 : k.appPid) && C.userDid === ((w = o == null ? void 0 : o.user) == null ? void 0 : w.did);
37
- }
31
+ const c = F(() => {
32
+ const e = (i.userSessions || []).find(
33
+ (o) => o.appPid === globalThis?.blocklet?.appPid && o.userDid === s?.user?.did
38
34
  );
39
- return r || {
35
+ return e || {
40
36
  __isDefault: !0,
41
- appName: ((e = globalThis == null ? void 0 : globalThis.blocklet) == null ? void 0 : e.appName) || ((s = globalThis == null ? void 0 : globalThis.env) == null ? void 0 : s.appName),
42
- appPid: ((a = globalThis == null ? void 0 : globalThis.blocklet) == null ? void 0 : a.appPid) || ((v = globalThis == null ? void 0 : globalThis.env) == null ? void 0 : v.appPid),
43
- userDid: (y = o == null ? void 0 : o.user) == null ? void 0 : y.did,
44
- visitorId: J(),
37
+ appName: globalThis?.blocklet?.appName || globalThis?.env?.appName,
38
+ appPid: globalThis?.blocklet?.appPid || globalThis?.env?.appPid,
39
+ userDid: s?.user?.did,
40
+ visitorId: O(),
45
41
  // passportId: '', // 无法从当前 session 获取 passportId 的值
46
42
  // updatedAt: '', // 当前 session 拼凑的信息无法得到 userSession 的更新时间
47
- user: G(o == null ? void 0 : o.user, [
43
+ user: _(s?.user, [
48
44
  "did",
49
45
  "sourceProvider",
50
46
  "fullName",
@@ -55,27 +51,27 @@ function sr({
55
51
  "role"
56
52
  ])
57
53
  };
58
- }, [i.userSessions, o == null ? void 0 : o.user]), p = l((r = !i.open) => {
59
- i.open = r;
60
- }), m = O(d.current), b = l(() => {
61
- p(!1), g();
62
- }), R = l(async (r) => {
54
+ }, [i.userSessions, s?.user]), a = p((e = !i.open) => {
55
+ i.open = e;
56
+ }), S = U(t.current), h = p(() => {
57
+ a(!1), m();
58
+ }), C = p(async (e) => {
63
59
  try {
64
- i.loadingSessionId = r == null ? void 0 : r.id, await g({ userSession: r }), p(!1);
60
+ i.loadingSessionId = e?.id, await m({ userSession: e }), a(!1);
65
61
  } finally {
66
62
  i.loadingSessionId = null;
67
63
  }
68
64
  });
69
- return x ? /* @__PURE__ */ c(M, { children: [
70
- /* @__PURE__ */ t(
71
- h,
65
+ return f ? /* @__PURE__ */ d(w, { children: [
66
+ /* @__PURE__ */ r(
67
+ u,
72
68
  {
73
- sessionItem: u,
74
- statusContent: /* @__PURE__ */ t(
75
- S,
69
+ sessionItem: c,
70
+ statusContent: /* @__PURE__ */ r(
71
+ x,
76
72
  {
77
- component: f,
78
- icon: q,
73
+ component: l,
74
+ icon: E,
79
75
  className: "session-user-switch-icon",
80
76
  sx: {
81
77
  transform: "scale(1.5) rotate(-90deg)",
@@ -95,33 +91,33 @@ function sr({
95
91
  }
96
92
  }
97
93
  },
98
- onClick: () => p(),
99
- ref: d
94
+ onClick: () => a(),
95
+ ref: t
100
96
  }
101
97
  ),
102
- /* @__PURE__ */ t(D, { open: i.open, anchorEl: d.current, transition: !0, sx: { zIndex: 1600 }, children: ({ TransitionProps: r }) => /* @__PURE__ */ t(
103
- N,
98
+ /* @__PURE__ */ r(P, { open: i.open, anchorEl: t.current, transition: !0, sx: { zIndex: 1600 }, children: ({ TransitionProps: e }) => /* @__PURE__ */ r(
99
+ A,
104
100
  {
105
- onClickAway: (e) => {
106
- e.preventDefault(), e.stopPropagation(), p(!1);
101
+ onClickAway: (o) => {
102
+ o.preventDefault(), o.stopPropagation(), a(!1);
107
103
  },
108
- children: /* @__PURE__ */ t($, { ...r, timeout: 350, children: /* @__PURE__ */ t(
109
- z,
104
+ children: /* @__PURE__ */ r(R, { ...e, timeout: 350, children: /* @__PURE__ */ r(
105
+ M,
110
106
  {
111
107
  variant: "outlined",
112
108
  sx: {
113
109
  borderRadius: 3,
114
- width: (m == null ? void 0 : m.width) || 0,
110
+ width: S?.width || 0,
115
111
  borderColor: "divider",
116
112
  mt: 0.5,
117
113
  border: "0 !important",
118
114
  boxShadow: `0px 8px 16px 0px ${n.grey[100]}, 0px 0px 0px 1px ${n.grey[100]}`
119
115
  },
120
- children: /* @__PURE__ */ c(L, { sx: { p: 0.5 }, children: [
121
- i.userSessions.map((e) => {
122
- const s = i.loadingSessionId === e.id, a = e.id === u.id;
123
- return /* @__PURE__ */ c(
124
- I,
116
+ children: /* @__PURE__ */ d(T, { sx: { p: 0.5 }, children: [
117
+ i.userSessions.map((o) => {
118
+ const k = i.loadingSessionId === o.id, g = o.id === c.id;
119
+ return /* @__PURE__ */ d(
120
+ b,
125
121
  {
126
122
  sx: {
127
123
  position: "relative",
@@ -131,11 +127,11 @@ function sr({
131
127
  }
132
128
  },
133
129
  onClick: () => {
134
- a || R(e);
130
+ g || C(o);
135
131
  },
136
132
  children: [
137
- s && /* @__PURE__ */ t(
138
- F,
133
+ k && /* @__PURE__ */ r(
134
+ z,
139
135
  {
140
136
  sx: {
141
137
  height: "2px",
@@ -146,15 +142,15 @@ function sr({
146
142
  }
147
143
  }
148
144
  ),
149
- /* @__PURE__ */ t(h, { sessionItem: e, active: a })
145
+ /* @__PURE__ */ r(u, { sessionItem: o, active: g })
150
146
  ]
151
147
  },
152
- e.id
148
+ o.id
153
149
  );
154
150
  }),
155
- i.userSessions.length > 0 ? /* @__PURE__ */ t(U, { sx: { m: "0!important", borderColor: "divider" } }) : null,
156
- /* @__PURE__ */ c(
157
- I,
151
+ i.userSessions.length > 0 ? /* @__PURE__ */ r(D, { sx: { m: "0!important", borderColor: "divider" } }) : null,
152
+ /* @__PURE__ */ d(
153
+ b,
158
154
  {
159
155
  sx: {
160
156
  color: "secondary.main",
@@ -166,21 +162,21 @@ function sr({
166
162
  py: 1.5,
167
163
  lineHeight: 1
168
164
  },
169
- onClick: b,
165
+ onClick: h,
170
166
  "data-cy": "sessionManager-switch-trigger",
171
167
  children: [
172
- /* @__PURE__ */ t(
173
- S,
168
+ /* @__PURE__ */ r(
169
+ x,
174
170
  {
175
- component: f,
176
- icon: V,
171
+ component: l,
172
+ icon: j,
177
173
  sx: {
178
174
  fontSize: 20,
179
175
  mr: 0.5
180
176
  }
181
177
  }
182
178
  ),
183
- A("addAnotherAccount")
179
+ y("addAnotherAccount")
184
180
  ]
185
181
  }
186
182
  )
@@ -189,11 +185,11 @@ function sr({
189
185
  ) })
190
186
  }
191
187
  ) })
192
- ] }) : /* @__PURE__ */ t(
193
- h,
188
+ ] }) : /* @__PURE__ */ r(
189
+ u,
194
190
  {
195
- sessionItem: u,
196
- statusContent: /* @__PURE__ */ t(f, { icon: B, color: n.text.hint }),
191
+ sessionItem: c,
192
+ statusContent: /* @__PURE__ */ r(l, { icon: H, color: n.text.hint }),
197
193
  sx: {
198
194
  borderRadius: 1,
199
195
  cursor: "pointer",
@@ -201,11 +197,11 @@ function sr({
201
197
  px: 1.5
202
198
  },
203
199
  "data-cy": "sessionManager-switch-trigger",
204
- onClick: b,
205
- ref: d
200
+ onClick: h,
201
+ ref: t
206
202
  }
207
203
  );
208
204
  }
209
205
  export {
210
- sr as default
206
+ ne as default
211
207
  };
@@ -1,9 +1,9 @@
1
- import { jsxs as s, Fragment as I, jsx as r } from "react/jsx-runtime";
2
- import { useTheme as P, IconButton as B, Popper as F, Fade as R, Paper as U, Box as z, MenuList as T, MenuItem as M, LinearProgress as $, Divider as D } from "@mui/material";
3
- import { Icon as W } from "@iconify/react";
4
- import _ from "@iconify-icons/tabler/user";
5
- import { useRef as j, useEffect as A, Fragment as N } from "react";
6
- import { useMemoizedFn as a, useReactive as O } from "ahooks";
1
+ import { jsxs as i, Fragment as I, jsx as r } from "react/jsx-runtime";
2
+ import { useTheme as P, IconButton as A, Popper as B, Fade as F, Paper as R, Box as U, MenuList as z, MenuItem as T, LinearProgress as M, Divider as $ } from "@mui/material";
3
+ import { Icon as D } from "@iconify/react";
4
+ import W from "@iconify-icons/tabler/user";
5
+ import { useRef as _, useEffect as j, Fragment as N } from "react";
6
+ import { useMemoizedFn as s, useReactive as O } from "ahooks";
7
7
  import Q from "lodash/noop";
8
8
  import H from "@arcblock/icons/lib/DidBrandLogo";
9
9
  import { useBrowser as K } from "@arcblock/react-hooks";
@@ -15,52 +15,52 @@ import J from "../../Typography/index.js";
15
15
  import Y from "./quick-login-item.js";
16
16
  import { getFederatedEnabled as Z, getMaster as oo } from "../../Util/federated.js";
17
17
  import { BLOCKLET_SERVICE_PATH_PREFIX as eo } from "../../Util/constant.js";
18
- function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d = "en" }) {
19
- const { palette: u } = P(), x = a((o, n = {}) => q(G, o, d, "en", n)), L = new URLSearchParams(window.location.search), b = K(), c = j(null), e = O({
18
+ function wo({ session: a, onLogin: f = Q, size: g = 24, dark: h = !1, locale: p = "en" }) {
19
+ const { palette: u } = P(), x = s((o, n = {}) => q(G, o, p, "en", n)), b = new URLSearchParams(window.location.search), L = K(), d = _(null), e = O({
20
20
  open: !1,
21
21
  userSessions: [],
22
22
  loadingSessionId: null,
23
23
  loadAppLogoError: !1
24
- }), w = a((o = !e.open) => {
24
+ }), w = s((o = !e.open) => {
25
25
  e.open = o;
26
- }), v = a(({ openMode: o } = {}) => {
27
- l.login(f, { openMode: o });
28
- }), i = window == null ? void 0 : window.blocklet, S = Z(i), p = oo(i), t = S && p ? p : i, y = (t == null ? void 0 : t.appName) || "DID Connect", m = V(
29
- (t == null ? void 0 : t.appUrl) || "/",
30
- (t == null ? void 0 : t.appLogo) || `${eo}/blocklet/logo?imageFilter=convert&f=png&h=80`
26
+ }), v = s(({ openMode: o } = {}) => {
27
+ a.login(f, { openMode: o });
28
+ }), t = window?.blocklet, S = Z(t), c = oo(t), l = S && c ? c : t, y = l?.appName || "DID Connect", m = V(
29
+ l?.appUrl || "/",
30
+ l?.appLogo || `${eo}/blocklet/logo?imageFilter=convert&f=png&h=80`
31
31
  );
32
- A(() => {
32
+ j(() => {
33
33
  let o;
34
- return !b.arcSphere && L.get("showQuickConnect") !== "false" && (o = setTimeout(async () => {
35
- e.userSessions = await l.getUserSessions(), e.userSessions.length > 0 && (e.open = !0);
34
+ return !L.arcSphere && b.get("showQuickConnect") !== "false" && (o = setTimeout(async () => {
35
+ e.userSessions = await a.getUserSessions(), e.userSessions.length > 0 && (e.open = !0);
36
36
  }, 1500)), () => {
37
37
  clearTimeout(o);
38
38
  };
39
39
  }, []);
40
- const E = a(async (o) => {
40
+ const k = s(async (o) => {
41
41
  e.loadingSessionId = o.id;
42
42
  try {
43
- await l.loginUserSession({ ...o, appPid: i == null ? void 0 : i.appPid });
43
+ await a.loginUserSession({ ...o, appPid: t?.appPid });
44
44
  } catch (n) {
45
45
  console.error("session.loginUserSession.error", n);
46
46
  } finally {
47
47
  e.loadingSessionId = null;
48
48
  }
49
49
  });
50
- return /* @__PURE__ */ s(I, { children: [
50
+ return /* @__PURE__ */ i(I, { children: [
51
51
  /* @__PURE__ */ r(
52
- B,
52
+ A,
53
53
  {
54
- ref: c,
54
+ ref: d,
55
55
  "data-cy": "sessionManager-login",
56
56
  className: "arc-session-user-unlogin",
57
57
  size: "medium",
58
58
  onClick: v,
59
59
  "aria-label": "Login button",
60
60
  children: /* @__PURE__ */ r(
61
- W,
61
+ D,
62
62
  {
63
- icon: _,
63
+ icon: W,
64
64
  fontSize: g,
65
65
  color: h ? "#fff" : "inherit",
66
66
  style: { transform: "scale(1.25)" }
@@ -69,10 +69,10 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
69
69
  }
70
70
  ),
71
71
  /* @__PURE__ */ r(
72
- F,
72
+ B,
73
73
  {
74
74
  open: e.open,
75
- anchorEl: c.current,
75
+ anchorEl: d.current,
76
76
  transition: !0,
77
77
  sx: {
78
78
  zIndex: (o) => o.zIndex.appBar
@@ -87,8 +87,8 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
87
87
  }
88
88
  }
89
89
  ],
90
- children: ({ TransitionProps: o }) => /* @__PURE__ */ r(R, { ...o, children: /* @__PURE__ */ s(
91
- U,
90
+ children: ({ TransitionProps: o }) => /* @__PURE__ */ r(F, { ...o, children: /* @__PURE__ */ i(
91
+ R,
92
92
  {
93
93
  variant: "outlined",
94
94
  sx: {
@@ -101,8 +101,8 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
101
101
  overflow: "hidden"
102
102
  },
103
103
  children: [
104
- /* @__PURE__ */ s(
105
- z,
104
+ /* @__PURE__ */ i(
105
+ U,
106
106
  {
107
107
  sx: {
108
108
  display: "flex",
@@ -149,11 +149,11 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
149
149
  ]
150
150
  }
151
151
  ),
152
- /* @__PURE__ */ r(T, { sx: { p: 0, overflow: "hidden" }, children: e.userSessions.map((n, C) => {
153
- const k = e.loadingSessionId === n.id;
154
- return /* @__PURE__ */ s(N, { children: [
155
- /* @__PURE__ */ s(
156
- M,
152
+ /* @__PURE__ */ r(z, { sx: { p: 0, overflow: "hidden" }, children: e.userSessions.map((n, E) => {
153
+ const C = e.loadingSessionId === n.id;
154
+ return /* @__PURE__ */ i(N, { children: [
155
+ /* @__PURE__ */ i(
156
+ T,
157
157
  {
158
158
  sx: {
159
159
  overflow: "hidden",
@@ -165,11 +165,11 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
165
165
  }
166
166
  },
167
167
  onClick: () => {
168
- E(n);
168
+ k(n);
169
169
  },
170
170
  children: [
171
- k && /* @__PURE__ */ r(
172
- $,
171
+ C && /* @__PURE__ */ r(
172
+ M,
173
173
  {
174
174
  sx: {
175
175
  height: "2px",
@@ -180,13 +180,13 @@ function wo({ session: l, onLogin: f = Q, size: g = 24, dark: h = !1, locale: d
180
180
  }
181
181
  }
182
182
  ),
183
- /* @__PURE__ */ r(Y, { userSession: n, locale: d })
183
+ /* @__PURE__ */ r(Y, { userSession: n, locale: p })
184
184
  ]
185
185
  },
186
186
  n.id
187
187
  ),
188
- C < e.userSessions.length - 1 ? /* @__PURE__ */ r(
189
- D,
188
+ E < e.userSessions.length - 1 ? /* @__PURE__ */ r(
189
+ $,
190
190
  {
191
191
  sx: {
192
192
  mx: 2,
@@ -1,34 +1,30 @@
1
1
  import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { Box as a, Typography as k, Chip as A, alpha as R } from "@mui/material";
3
- import { Icon as y } from "@iconify/react";
4
- import U from "@iconify-icons/material-symbols/swap-horiz-rounded";
5
- import W from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
6
- import { useMemoizedFn as j, useCreation as b } from "ahooks";
7
- import w from "lodash/noop";
8
- import D from "../../Avatar/index.js";
9
- import { getUserAvatar as M } from "../../Util/index.js";
10
- import H from "./session-user-switch.js";
11
- import { getWallet as E } from "../libs/utils.js";
12
- import { translations as F } from "../libs/translation.js";
13
- import { translate as N } from "../../Locale/util.js";
14
- function Y({
2
+ import { Box as n, Typography as b, Chip as w, alpha as v } from "@mui/material";
3
+ import { Icon as p } from "@iconify/react";
4
+ import S from "@iconify-icons/material-symbols/swap-horiz-rounded";
5
+ import C from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
6
+ import { useMemoizedFn as I, useCreation as s } from "ahooks";
7
+ import d from "lodash/noop";
8
+ import z from "../../Avatar/index.js";
9
+ import { getUserAvatar as R } from "../../Util/index.js";
10
+ import k from "./session-user-switch.js";
11
+ import { getWallet as A } from "../libs/utils.js";
12
+ import { translations as U } from "../libs/translation.js";
13
+ import { translate as W } from "../../Locale/util.js";
14
+ function K({
15
15
  session: r,
16
- onSwitchPassport: p,
17
- onSwitchAccount: v,
18
- onBindWallet: S,
19
- onSwitchProfile: C = w,
20
- locale: c = "en",
16
+ onSwitchPassport: a,
17
+ onSwitchAccount: m,
18
+ onBindWallet: u,
19
+ onSwitchProfile: f = d,
20
+ locale: l = "en",
21
21
  isBlocklet: o = !0
22
22
  }) {
23
- var m, f, u, h, g;
24
- const d = j((t, n = {}) => N(F, t, c, "en", n)), I = M((f = (m = r.user) == null ? void 0 : m.avatar) == null ? void 0 : f.replace(/\s/g, encodeURIComponent(" ")), 64), l = b(() => {
25
- var t, n;
26
- return (n = (t = r.user) == null ? void 0 : t.passports) == null ? void 0 : n.find(
27
- (x) => x.name === r.user.role || x.role === r.user.role
28
- );
29
- }, [(u = r == null ? void 0 : r.user) == null ? void 0 : u.passports, (h = r == null ? void 0 : r.user) == null ? void 0 : h.role]), z = b(() => E(r == null ? void 0 : r.user), [r == null ? void 0 : r.user]);
23
+ const c = I((t, y = {}) => W(U, t, l, "en", y)), h = R(r.user?.avatar?.replace(/\s/g, encodeURIComponent(" ")), 64), g = s(() => r.user?.passports?.find(
24
+ (t) => t.name === r.user.role || t.role === r.user.role
25
+ ), [r?.user?.passports, r?.user?.role]), x = s(() => A(r?.user), [r?.user]);
30
26
  return /* @__PURE__ */ i(
31
- a,
27
+ n,
32
28
  {
33
29
  sx: {
34
30
  py: 2,
@@ -40,7 +36,7 @@ function Y({
40
36
  },
41
37
  children: [
42
38
  /* @__PURE__ */ i(
43
- a,
39
+ n,
44
40
  {
45
41
  sx: {
46
42
  display: "flex",
@@ -51,7 +47,7 @@ function Y({
51
47
  },
52
48
  children: [
53
49
  /* @__PURE__ */ i(
54
- a,
50
+ n,
55
51
  {
56
52
  sx: {
57
53
  display: "flex",
@@ -60,9 +56,9 @@ function Y({
60
56
  },
61
57
  children: [
62
58
  /* @__PURE__ */ e(
63
- a,
59
+ n,
64
60
  {
65
- onClick: o ? w : C,
61
+ onClick: o ? d : f,
66
62
  "data-cy": "sessionManager-switch-profile-trigger",
67
63
  sx: {
68
64
  cursor: o ? "default" : "pointer",
@@ -73,7 +69,7 @@ function Y({
73
69
  flexShrink: 0,
74
70
  "&:hover": o ? {} : {
75
71
  "&::after": {
76
- content: `"${d("switch")}"`,
72
+ content: `"${c("switch")}"`,
77
73
  position: "absolute",
78
74
  bottom: 0,
79
75
  background: "rgba(0, 0, 0, 0.2)",
@@ -88,11 +84,11 @@ function Y({
88
84
  }
89
85
  },
90
86
  children: /* @__PURE__ */ e(
91
- D,
87
+ z,
92
88
  {
93
89
  variant: "circle",
94
90
  did: r.user.did,
95
- src: I,
91
+ src: h,
96
92
  size: 48,
97
93
  shape: "circle",
98
94
  sx: {
@@ -102,14 +98,14 @@ function Y({
102
98
  )
103
99
  }
104
100
  ),
105
- /* @__PURE__ */ e(k, { variant: "h6", sx: { wordBreak: "break-word" }, children: r.user.fullName })
101
+ /* @__PURE__ */ e(b, { variant: "h6", sx: { wordBreak: "break-word" }, children: r.user.fullName })
106
102
  ]
107
103
  }
108
104
  ),
109
105
  /* @__PURE__ */ e(
110
- A,
106
+ w,
111
107
  {
112
- label: (l == null ? void 0 : l.title) || ((g = r.user) == null ? void 0 : g.role.toUpperCase()),
108
+ label: g?.title || r.user?.role.toUpperCase(),
113
109
  size: "small",
114
110
  variant: "outlined",
115
111
  clickable: !0,
@@ -125,22 +121,22 @@ function Y({
125
121
  boxShadow: "none"
126
122
  }
127
123
  },
128
- deleteIcon: /* @__PURE__ */ e(y, { icon: U, color: "inherit" }),
129
- onDelete: p,
130
- onClick: p,
124
+ deleteIcon: /* @__PURE__ */ e(p, { icon: S, color: "inherit" }),
125
+ onDelete: a,
126
+ onClick: a,
131
127
  "data-cy": "sessionManager-switch-passport-trigger"
132
128
  }
133
129
  )
134
130
  ]
135
131
  }
136
132
  ),
137
- /* @__PURE__ */ e(H, { session: r, onSwitch: v, isBlocklet: o, locale: c }),
138
- z ? null : /* @__PURE__ */ i(
139
- a,
133
+ /* @__PURE__ */ e(k, { session: r, onSwitch: m, isBlocklet: o, locale: l }),
134
+ x ? null : /* @__PURE__ */ i(
135
+ n,
140
136
  {
141
137
  sx: {
142
138
  color: "secondary.main",
143
- bgcolor: ({ palette: t }) => R(t.secondary.main, 0.05),
139
+ bgcolor: ({ palette: t }) => v(t.secondary.main, 0.05),
144
140
  borderRadius: 1,
145
141
  display: "flex",
146
142
  justifyContent: "space-between",
@@ -151,11 +147,11 @@ function Y({
151
147
  cursor: "pointer",
152
148
  mt: -0.75
153
149
  },
154
- onClick: S,
150
+ onClick: u,
155
151
  "data-cy": "sessionManager-bind-trigger",
156
152
  children: [
157
- d("connectDIDWallet"),
158
- /* @__PURE__ */ e(y, { icon: W, color: "inherit", fontSize: 16 })
153
+ c("connectDIDWallet"),
154
+ /* @__PURE__ */ e(p, { icon: C, color: "inherit", fontSize: 16 })
159
155
  ]
160
156
  }
161
157
  )
@@ -164,5 +160,5 @@ function Y({
164
160
  );
165
161
  }
166
162
  export {
167
- Y as default
163
+ K as default
168
164
  };
@@ -10,7 +10,7 @@ function b({
10
10
  size: t = 24,
11
11
  popperType: i = "click"
12
12
  }) {
13
- const m = p(() => !!(globalThis != null && globalThis.blocklet), []);
13
+ const m = p(() => !!globalThis?.blocklet, []);
14
14
  return r.user ? /* @__PURE__ */ n(
15
15
  u,
16
16
  {