@arcblock/ux 3.0.9 → 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.
- package/lib/Address/did-address.js +47 -49
- package/lib/Address/responsive-did-address.js +53 -57
- package/lib/Avatar/index.js +16 -16
- package/lib/BlockletV2/blocklet.js +64 -64
- package/lib/BlockletV2/components/tooltip-icon.js +26 -27
- package/lib/CardSelector/index.js +1 -2
- package/lib/ClickToCopy/hook.js +10 -11
- package/lib/ClickToCopy/index.js +16 -16
- package/lib/Config/theme-mode-toggle.js +7 -8
- package/lib/DID/index.js +131 -133
- package/lib/DIDConnect/app-info-item.js +18 -18
- package/lib/DIDConnect/auth-apps/index.js +83 -84
- package/lib/DIDConnect/did-connect-container.js +89 -90
- package/lib/DIDConnect/did-connect-footer.js +25 -25
- package/lib/DIDConnect/landing-page.js +17 -17
- package/lib/DIDConnect/powered-by.js +11 -11
- package/lib/DIDConnect/request-storage-access-api-dialog.js +36 -37
- package/lib/DIDConnect/with-container.js +66 -68
- package/lib/Dialog/use-confirm.js +40 -43
- package/lib/Earth/index.js +21 -22
- package/lib/Footer/index.js +15 -16
- package/lib/Header/responsive-header.js +23 -24
- package/lib/Layout/dashboard/index.js +63 -72
- package/lib/Layout/dashboard/sidebar.js +20 -21
- package/lib/Layout/dashboard-legacy/index.js +52 -52
- package/lib/Locale/context.js +36 -37
- package/lib/Locale/selector.js +40 -42
- package/lib/NFTDisplay/index.js +114 -118
- package/lib/NFTDisplay/render-svg.js +12 -12
- package/lib/NavMenu/nav-menu.js +159 -161
- package/lib/NavMenu/sub-container.js +25 -26
- package/lib/PageScroller/index.js +28 -32
- package/lib/Passport/passport.js +11 -11
- package/lib/PhoneInput/country-select.js +38 -38
- package/lib/PhoneInput/index.js +65 -66
- package/lib/Screenshot/index.js +26 -27
- package/lib/SessionBlocklet/index.js +87 -93
- package/lib/SessionPermission/index.js +5 -9
- package/lib/SessionUser/components/did-space.js +24 -25
- package/lib/SessionUser/components/logged-in.js +122 -127
- package/lib/SessionUser/components/quick-login-item.js +41 -42
- package/lib/SessionUser/components/session-user-item.js +35 -36
- package/lib/SessionUser/components/session-user-switch.js +81 -85
- package/lib/SessionUser/components/un-login.js +41 -41
- package/lib/SessionUser/components/user-info.js +43 -47
- package/lib/SessionUser/index.js +1 -1
- package/lib/SessionUser/libs/utils.js +24 -30
- package/lib/SharedBridge/index.js +35 -35
- package/lib/Theme/index.js +16 -16
- package/lib/Theme/theme.js +42 -43
- package/lib/Toast/index.js +24 -25
- package/lib/Typography/index.js +42 -42
- package/lib/UserCard/Content/basic.js +91 -93
- package/lib/UserCard/Content/shorten-label.js +9 -9
- package/lib/UserCard/components.js +15 -15
- package/lib/Util/deprecate.js +1 -1
- package/lib/Util/federated.js +28 -32
- package/lib/Util/iframe.js +9 -10
- package/lib/Util/index.js +134 -135
- package/lib/Util/security.js +9 -10
- package/lib/Util/wallet.js +6 -9
- package/lib/VerificationCode/index.js +26 -28
- package/lib/hooks/use-blocklet-logo.js +11 -14
- package/lib/ux.css +1 -1
- package/lib/withTracker/index.js +13 -14
- package/package.json +9 -10
@@ -1,50 +1,46 @@
|
|
1
|
-
import { jsx as
|
2
|
-
import { useTheme as
|
3
|
-
import { useRef as
|
4
|
-
import { useMemoizedFn as
|
5
|
-
import { Icon as
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import
|
11
|
-
import { getVisitorId as
|
12
|
-
import { translate as
|
13
|
-
import { translations as
|
14
|
-
function
|
15
|
-
session:
|
16
|
-
onSwitch:
|
17
|
-
isBlocklet:
|
18
|
-
locale:
|
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
|
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
|
-
|
26
|
-
if (
|
27
|
-
const
|
28
|
-
i.userSessions =
|
25
|
+
L(async () => {
|
26
|
+
if (f) {
|
27
|
+
const e = await s.getUserSessions();
|
28
|
+
i.userSessions = e;
|
29
29
|
}
|
30
30
|
});
|
31
|
-
const
|
32
|
-
|
33
|
-
|
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
|
35
|
+
return e || {
|
40
36
|
__isDefault: !0,
|
41
|
-
appName:
|
42
|
-
appPid:
|
43
|
-
userDid:
|
44
|
-
visitorId:
|
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:
|
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,
|
59
|
-
i.open =
|
60
|
-
}),
|
61
|
-
|
62
|
-
}),
|
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 =
|
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
|
70
|
-
/* @__PURE__ */
|
71
|
-
|
65
|
+
return f ? /* @__PURE__ */ d(w, { children: [
|
66
|
+
/* @__PURE__ */ r(
|
67
|
+
u,
|
72
68
|
{
|
73
|
-
sessionItem:
|
74
|
-
statusContent: /* @__PURE__ */
|
75
|
-
|
69
|
+
sessionItem: c,
|
70
|
+
statusContent: /* @__PURE__ */ r(
|
71
|
+
x,
|
76
72
|
{
|
77
|
-
component:
|
78
|
-
icon:
|
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: () =>
|
99
|
-
ref:
|
94
|
+
onClick: () => a(),
|
95
|
+
ref: t
|
100
96
|
}
|
101
97
|
),
|
102
|
-
/* @__PURE__ */
|
103
|
-
|
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: (
|
106
|
-
|
101
|
+
onClickAway: (o) => {
|
102
|
+
o.preventDefault(), o.stopPropagation(), a(!1);
|
107
103
|
},
|
108
|
-
children: /* @__PURE__ */
|
109
|
-
|
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:
|
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__ */
|
121
|
-
i.userSessions.map((
|
122
|
-
const
|
123
|
-
return /* @__PURE__ */
|
124
|
-
|
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
|
-
|
130
|
+
g || C(o);
|
135
131
|
},
|
136
132
|
children: [
|
137
|
-
|
138
|
-
|
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__ */
|
145
|
+
/* @__PURE__ */ r(u, { sessionItem: o, active: g })
|
150
146
|
]
|
151
147
|
},
|
152
|
-
|
148
|
+
o.id
|
153
149
|
);
|
154
150
|
}),
|
155
|
-
i.userSessions.length > 0 ? /* @__PURE__ */
|
156
|
-
/* @__PURE__ */
|
157
|
-
|
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:
|
165
|
+
onClick: h,
|
170
166
|
"data-cy": "sessionManager-switch-trigger",
|
171
167
|
children: [
|
172
|
-
/* @__PURE__ */
|
173
|
-
|
168
|
+
/* @__PURE__ */ r(
|
169
|
+
x,
|
174
170
|
{
|
175
|
-
component:
|
176
|
-
icon:
|
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
|
-
|
179
|
+
y("addAnotherAccount")
|
184
180
|
]
|
185
181
|
}
|
186
182
|
)
|
@@ -189,11 +185,11 @@ function sr({
|
|
189
185
|
) })
|
190
186
|
}
|
191
187
|
) })
|
192
|
-
] }) : /* @__PURE__ */
|
193
|
-
|
188
|
+
] }) : /* @__PURE__ */ r(
|
189
|
+
u,
|
194
190
|
{
|
195
|
-
sessionItem:
|
196
|
-
statusContent: /* @__PURE__ */
|
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:
|
205
|
-
ref:
|
200
|
+
onClick: h,
|
201
|
+
ref: t
|
206
202
|
}
|
207
203
|
);
|
208
204
|
}
|
209
205
|
export {
|
210
|
-
|
206
|
+
ne as default
|
211
207
|
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { jsxs as
|
2
|
-
import { useTheme as P, IconButton as
|
3
|
-
import { Icon as
|
4
|
-
import
|
5
|
-
import { useRef as
|
6
|
-
import { useMemoizedFn as
|
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:
|
19
|
-
const { palette: u } = P(), x =
|
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 =
|
24
|
+
}), w = s((o = !e.open) => {
|
25
25
|
e.open = o;
|
26
|
-
}), v =
|
27
|
-
|
28
|
-
}),
|
29
|
-
|
30
|
-
|
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
|
-
|
32
|
+
j(() => {
|
33
33
|
let o;
|
34
|
-
return !
|
35
|
-
e.userSessions = await
|
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
|
40
|
+
const k = s(async (o) => {
|
41
41
|
e.loadingSessionId = o.id;
|
42
42
|
try {
|
43
|
-
await
|
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__ */
|
50
|
+
return /* @__PURE__ */ i(I, { children: [
|
51
51
|
/* @__PURE__ */ r(
|
52
|
-
|
52
|
+
A,
|
53
53
|
{
|
54
|
-
ref:
|
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
|
-
|
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
|
-
|
72
|
+
B,
|
73
73
|
{
|
74
74
|
open: e.open,
|
75
|
-
anchorEl:
|
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(
|
91
|
-
|
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__ */
|
105
|
-
|
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(
|
153
|
-
const
|
154
|
-
return /* @__PURE__ */
|
155
|
-
/* @__PURE__ */
|
156
|
-
|
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
|
-
|
168
|
+
k(n);
|
169
169
|
},
|
170
170
|
children: [
|
171
|
-
|
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:
|
183
|
+
/* @__PURE__ */ r(Y, { userSession: n, locale: p })
|
184
184
|
]
|
185
185
|
},
|
186
186
|
n.id
|
187
187
|
),
|
188
|
-
|
189
|
-
|
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
|
3
|
-
import { Icon as
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import { useMemoizedFn as
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import { getUserAvatar as
|
10
|
-
import
|
11
|
-
import { getWallet as
|
12
|
-
import { translations as
|
13
|
-
import { translate as
|
14
|
-
function
|
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:
|
17
|
-
onSwitchAccount:
|
18
|
-
onBindWallet:
|
19
|
-
onSwitchProfile:
|
20
|
-
locale:
|
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
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
59
|
+
n,
|
64
60
|
{
|
65
|
-
onClick: o ?
|
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: `"${
|
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
|
-
|
87
|
+
z,
|
92
88
|
{
|
93
89
|
variant: "circle",
|
94
90
|
did: r.user.did,
|
95
|
-
src:
|
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(
|
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
|
-
|
106
|
+
w,
|
111
107
|
{
|
112
|
-
label:
|
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(
|
129
|
-
onDelete:
|
130
|
-
onClick:
|
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(
|
138
|
-
|
139
|
-
|
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 }) =>
|
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:
|
150
|
+
onClick: u,
|
155
151
|
"data-cy": "sessionManager-bind-trigger",
|
156
152
|
children: [
|
157
|
-
|
158
|
-
/* @__PURE__ */ e(
|
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
|
-
|
163
|
+
K as default
|
168
164
|
};
|
package/lib/SessionUser/index.js
CHANGED