@arcblock/ux 3.4.7 → 3.4.9
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/SessionUser/components/logged-in.d.ts +2 -1
- package/lib/SessionUser/components/logged-in.js +88 -86
- package/lib/SessionUser/components/user-info.d.ts +2 -1
- package/lib/SessionUser/components/user-info.js +105 -71
- package/lib/SessionUser/index.js +22 -21
- package/lib/package.json.js +1 -1
- package/package.json +9 -9
- package/src/SessionUser/components/logged-in.tsx +4 -1
- package/src/SessionUser/components/user-info.tsx +119 -84
- package/src/SessionUser/index.tsx +3 -0
|
@@ -8,5 +8,6 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
8
8
|
size?: number;
|
|
9
9
|
popperType?: 'hover' | 'click';
|
|
10
10
|
profileUrl?: string;
|
|
11
|
+
mode?: 'minimal' | 'normal';
|
|
11
12
|
}
|
|
12
|
-
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, profileUrl, sx, ...rest }: LoggedInProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, profileUrl, mode, sx, ...rest }: LoggedInProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,125 +1,126 @@
|
|
|
1
|
-
import { jsxs as s, jsx as r, Fragment as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useMemoizedFn as n, useCreation as
|
|
1
|
+
import { jsxs as s, jsx as r, Fragment as T } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as _, useEffect as j } from "react";
|
|
3
|
+
import { useMemoizedFn as n, useCreation as G, useReactive as H } from "ahooks";
|
|
4
4
|
import f from "@arcblock/bridge";
|
|
5
|
-
import { Box as
|
|
6
|
-
import { Icon as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
5
|
+
import { Box as b, IconButton as N, Popper as Q, ClickAwayListener as V, Fade as q, Paper as J, Divider as k, MenuList as K, MenuItem as X } from "@mui/material";
|
|
6
|
+
import { Icon as Y } from "@iconify/react";
|
|
7
|
+
import Z from "@iconify-icons/material-symbols/person-outline-rounded";
|
|
8
|
+
import $ from "@iconify-icons/material-symbols/filter-vintage-outline-rounded";
|
|
9
|
+
import ee from "@iconify-icons/material-symbols/account-circle-off-outline-rounded";
|
|
10
|
+
import re from "@iconify-icons/material-symbols/featured-seasonal-and-gifts-rounded";
|
|
11
|
+
import te from "copy-to-clipboard";
|
|
12
12
|
import h from "lodash/noop";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import { getUserAvatar as
|
|
16
|
-
import
|
|
17
|
-
import { DASHBOARD_URL as
|
|
18
|
-
import
|
|
19
|
-
import { translations as
|
|
20
|
-
import { translate as
|
|
21
|
-
import
|
|
22
|
-
import { mergeSx as
|
|
23
|
-
import { createDebug as
|
|
24
|
-
import { GA_LAST_ROLE as
|
|
25
|
-
const
|
|
13
|
+
import oe from "../../Toast/index.js";
|
|
14
|
+
import ie from "../../Avatar/index.js";
|
|
15
|
+
import { getUserAvatar as ne } from "../../Util/index.js";
|
|
16
|
+
import ce from "./user-info.js";
|
|
17
|
+
import { DASHBOARD_URL as le, PROFILE_URL as ae } from "../../Util/constant.js";
|
|
18
|
+
import se from "../../SessionPermission/index.js";
|
|
19
|
+
import { translations as pe } from "../libs/translation.js";
|
|
20
|
+
import { translate as ue } from "../../Locale/util.js";
|
|
21
|
+
import de from "./did-space.js";
|
|
22
|
+
import { mergeSx as me } from "../../Util/style.js";
|
|
23
|
+
import { createDebug as fe } from "../../Util/logger.js";
|
|
24
|
+
import { GA_LAST_ROLE as he } from "../../withTracker/constant/index.js";
|
|
25
|
+
const ge = (e) => {
|
|
26
26
|
const c = new URL(window.location.href);
|
|
27
27
|
return c.searchParams.set("inviter", e), c.toString();
|
|
28
|
-
}, g =
|
|
29
|
-
function
|
|
28
|
+
}, g = fe("did-connect");
|
|
29
|
+
function je({
|
|
30
30
|
session: e,
|
|
31
31
|
onBindWallet: c = h,
|
|
32
32
|
isBlocklet: l = !0,
|
|
33
33
|
locale: u = "en",
|
|
34
|
-
size:
|
|
35
|
-
popperType:
|
|
36
|
-
profileUrl:
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
size: I = 24,
|
|
35
|
+
popperType: y = "click",
|
|
36
|
+
profileUrl: R = ae,
|
|
37
|
+
mode: P = "normal",
|
|
38
|
+
sx: C,
|
|
39
|
+
...L
|
|
39
40
|
}) {
|
|
40
|
-
const a = n((t, o = {}) => pe
|
|
41
|
+
const a = n((t, o = {}) => ue(pe, t, u, "en", o)), B = G(() => !!globalThis?.blocklet?.settings?.invite?.enabled, []), v = _(null), d = H({
|
|
41
42
|
open: !1
|
|
42
43
|
}), i = n((t = !d.open) => {
|
|
43
44
|
d.open = t;
|
|
44
|
-
}),
|
|
45
|
-
localStorage.setItem(
|
|
45
|
+
}), D = y === "hover" ? { onMouseEnter: () => i(!0), onMouseLeave: () => i(!1) } : { onClick: () => i() }, O = ne(e.user?.avatar?.replace(/\s/g, encodeURIComponent(" "))), E = e.useOAuth(), M = typeof e.usePasskey == "function" ? e.usePasskey() : null, x = n(({ inArcSphere: t = !1 } = {}) => {
|
|
46
|
+
localStorage.setItem(he, e?.user?.role);
|
|
46
47
|
const o = {};
|
|
47
|
-
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ?
|
|
48
|
-
}),
|
|
49
|
-
const
|
|
50
|
-
o && e.user.sourceAppPid && (
|
|
48
|
+
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ? M.switchPassport(e.user) : ["google", "apple", "email", "github"].includes(e?.user?.sourceProvider) ? E.switchOAuthPassport(e.user) : e.switchPassport(h, o);
|
|
49
|
+
}), w = n(({ userSession: t, inArcSphere: o = !1 } = {}) => new Promise((z) => {
|
|
50
|
+
const S = {};
|
|
51
|
+
o && e.user.sourceAppPid && (S.sourceAppPid = e.user.sourceAppPid);
|
|
51
52
|
const m = {};
|
|
52
53
|
t ? m.userSession = t : (i(!1), m.showQuickConnect = !1), e.switchDid(
|
|
53
54
|
() => {
|
|
54
|
-
i(!1),
|
|
55
|
+
i(!1), z();
|
|
55
56
|
},
|
|
56
|
-
|
|
57
|
+
S,
|
|
57
58
|
m
|
|
58
59
|
);
|
|
59
|
-
})),
|
|
60
|
+
})), A = n(({ inArcSphere: t = !1 } = {}) => {
|
|
60
61
|
const o = {};
|
|
61
62
|
t && e.user.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e.switchProfile(h, o);
|
|
62
|
-
}), M = n(() => {
|
|
63
|
-
i(!1), e.logout();
|
|
64
63
|
}), U = n(() => {
|
|
65
|
-
i(!1), e.
|
|
64
|
+
i(!1), e.logout();
|
|
66
65
|
}), F = n(() => {
|
|
66
|
+
i(!1), e.bindWallet(c);
|
|
67
|
+
}), W = n(() => {
|
|
67
68
|
i(!1);
|
|
68
|
-
const t =
|
|
69
|
-
|
|
69
|
+
const t = ge(e.user.did);
|
|
70
|
+
te(t), oe.success(a("inviteCopied"));
|
|
70
71
|
});
|
|
71
|
-
return
|
|
72
|
+
return j(() => {
|
|
72
73
|
f.registerBlocklet("callSwitchPassport", () => {
|
|
73
|
-
g("bridge registerBlocklet: callSwitchPassport"),
|
|
74
|
+
g("bridge registerBlocklet: callSwitchPassport"), x({ inArcSphere: !0 });
|
|
74
75
|
}), f.registerBlocklet("callSwitchDid", () => {
|
|
75
|
-
g("bridge registerBlocklet: callSwitchDid"),
|
|
76
|
+
g("bridge registerBlocklet: callSwitchDid"), w({ inArcSphere: !0 });
|
|
76
77
|
}), f.registerBlocklet("callSwitchProfile", () => {
|
|
77
|
-
g("bridge registerBlocklet: callSwitchProfile"),
|
|
78
|
+
g("bridge registerBlocklet: callSwitchProfile"), A({ inArcSphere: !0 });
|
|
78
79
|
});
|
|
79
80
|
}, []), /* @__PURE__ */ s(
|
|
80
|
-
|
|
81
|
+
b,
|
|
81
82
|
{
|
|
82
|
-
sx:
|
|
83
|
+
sx: me(
|
|
83
84
|
{
|
|
84
85
|
display: "inline-flex",
|
|
85
86
|
alignItems: "center",
|
|
86
87
|
justifyContent: "center"
|
|
87
88
|
},
|
|
88
89
|
// @ts-ignore
|
|
89
|
-
|
|
90
|
+
C
|
|
90
91
|
),
|
|
91
|
-
...
|
|
92
|
+
...L,
|
|
92
93
|
children: [
|
|
93
94
|
/* @__PURE__ */ r(
|
|
94
|
-
|
|
95
|
+
N,
|
|
95
96
|
{
|
|
96
|
-
ref:
|
|
97
|
+
ref: v,
|
|
97
98
|
size: "medium",
|
|
98
99
|
"data-cy": "sessionManager-logout-popup",
|
|
99
100
|
className: "arc-session-user-logged-in",
|
|
100
101
|
"aria-label": "User info button",
|
|
101
|
-
...
|
|
102
|
-
children: /* @__PURE__ */ r(
|
|
102
|
+
...D,
|
|
103
|
+
children: /* @__PURE__ */ r(ie, { variant: "circle", did: e.user.did, src: O, size: I, shape: "circle" })
|
|
103
104
|
}
|
|
104
105
|
),
|
|
105
106
|
/* @__PURE__ */ r(
|
|
106
|
-
|
|
107
|
+
Q,
|
|
107
108
|
{
|
|
108
109
|
open: d.open,
|
|
109
|
-
anchorEl:
|
|
110
|
+
anchorEl: v.current,
|
|
110
111
|
transition: !0,
|
|
111
112
|
placement: "bottom-end",
|
|
112
113
|
sx: {
|
|
113
114
|
zIndex: 1600
|
|
114
115
|
},
|
|
115
116
|
children: ({ TransitionProps: t }) => /* @__PURE__ */ r(
|
|
116
|
-
|
|
117
|
+
V,
|
|
117
118
|
{
|
|
118
119
|
onClickAway: (o) => {
|
|
119
120
|
o.preventDefault(), o.stopPropagation(), i(!1);
|
|
120
121
|
},
|
|
121
|
-
children: /* @__PURE__ */ r(
|
|
122
|
-
|
|
122
|
+
children: /* @__PURE__ */ r(q, { ...t, timeout: 350, children: /* @__PURE__ */ s(
|
|
123
|
+
J,
|
|
123
124
|
{
|
|
124
125
|
variant: "outlined",
|
|
125
126
|
sx: {
|
|
@@ -129,61 +130,62 @@ function _e({
|
|
|
129
130
|
},
|
|
130
131
|
children: [
|
|
131
132
|
/* @__PURE__ */ r(
|
|
132
|
-
|
|
133
|
+
ce,
|
|
133
134
|
{
|
|
134
135
|
locale: u,
|
|
135
136
|
isBlocklet: l,
|
|
136
137
|
session: e,
|
|
137
|
-
onSwitchPassport:
|
|
138
|
-
onSwitchAccount:
|
|
139
|
-
onSwitchProfile:
|
|
140
|
-
onBindWallet:
|
|
138
|
+
onSwitchPassport: x,
|
|
139
|
+
onSwitchAccount: w,
|
|
140
|
+
onSwitchProfile: A,
|
|
141
|
+
onBindWallet: F,
|
|
142
|
+
mode: P
|
|
141
143
|
}
|
|
142
144
|
),
|
|
143
|
-
/* @__PURE__ */ r(
|
|
144
|
-
/* @__PURE__ */ s(
|
|
145
|
-
l ? /* @__PURE__ */ s(
|
|
146
|
-
/* @__PURE__ */ r(
|
|
145
|
+
/* @__PURE__ */ r(k, { sx: { m: "0 !important" } }),
|
|
146
|
+
/* @__PURE__ */ s(K, { sx: { p: 0 }, children: [
|
|
147
|
+
l ? /* @__PURE__ */ s(T, { children: [
|
|
148
|
+
/* @__PURE__ */ r(se, { session: e, children: /* @__PURE__ */ r(
|
|
147
149
|
p,
|
|
148
150
|
{
|
|
149
|
-
icon:
|
|
151
|
+
icon: $,
|
|
150
152
|
title: a("dashboard"),
|
|
151
153
|
component: "a",
|
|
152
|
-
href:
|
|
154
|
+
href: le,
|
|
153
155
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
154
156
|
}
|
|
155
157
|
) }),
|
|
156
158
|
/* @__PURE__ */ r(
|
|
157
159
|
p,
|
|
158
160
|
{
|
|
159
|
-
icon:
|
|
161
|
+
icon: Z,
|
|
160
162
|
title: a("profile"),
|
|
161
163
|
component: "a",
|
|
162
|
-
href:
|
|
164
|
+
href: R,
|
|
163
165
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
164
166
|
}
|
|
165
167
|
),
|
|
166
|
-
|
|
168
|
+
B && /* @__PURE__ */ r(
|
|
167
169
|
p,
|
|
168
170
|
{
|
|
169
|
-
icon:
|
|
171
|
+
icon: re,
|
|
170
172
|
title: a("invite"),
|
|
171
173
|
component: "div",
|
|
172
|
-
onClick:
|
|
174
|
+
onClick: W,
|
|
173
175
|
sx: { display: "block", color: "inherit" }
|
|
174
176
|
}
|
|
175
177
|
),
|
|
176
|
-
/* @__PURE__ */ r(
|
|
177
|
-
/* @__PURE__ */ r(
|
|
178
|
+
/* @__PURE__ */ r(k, { sx: { m: "0 !important" } }),
|
|
179
|
+
P === "normal" ? /* @__PURE__ */ r(de, { session: e, locale: u }) : null
|
|
178
180
|
] }) : null,
|
|
179
181
|
/* @__PURE__ */ r(
|
|
180
182
|
p,
|
|
181
183
|
{
|
|
182
|
-
icon:
|
|
184
|
+
icon: ee,
|
|
183
185
|
title: a("logout"),
|
|
184
186
|
component: "div",
|
|
185
187
|
sx: { color: "error.main" },
|
|
186
|
-
onClick:
|
|
188
|
+
onClick: U,
|
|
187
189
|
"data-cy": "sessionManager-logout-trigger"
|
|
188
190
|
}
|
|
189
191
|
)
|
|
@@ -204,8 +206,8 @@ function p({
|
|
|
204
206
|
title: c,
|
|
205
207
|
...l
|
|
206
208
|
}) {
|
|
207
|
-
return /* @__PURE__ */ r(
|
|
208
|
-
|
|
209
|
+
return /* @__PURE__ */ r(b, { ...l, sx: { p: 0.5, ...l?.sx }, children: /* @__PURE__ */ s(
|
|
210
|
+
X,
|
|
209
211
|
{
|
|
210
212
|
sx: {
|
|
211
213
|
display: "flex",
|
|
@@ -218,12 +220,12 @@ function p({
|
|
|
218
220
|
py: 1
|
|
219
221
|
},
|
|
220
222
|
children: [
|
|
221
|
-
/* @__PURE__ */ r(
|
|
223
|
+
/* @__PURE__ */ r(Y, { icon: e, fontSize: 24 }),
|
|
222
224
|
c
|
|
223
225
|
]
|
|
224
226
|
}
|
|
225
227
|
) });
|
|
226
228
|
}
|
|
227
229
|
export {
|
|
228
|
-
|
|
230
|
+
je as default
|
|
229
231
|
};
|
|
@@ -9,5 +9,6 @@ export interface UserInfoProps {
|
|
|
9
9
|
onSwitchProfile?: () => void;
|
|
10
10
|
locale?: Locale;
|
|
11
11
|
isBlocklet?: true | false;
|
|
12
|
+
mode?: 'minimal' | 'normal';
|
|
12
13
|
}
|
|
13
|
-
export default function UserInfo({ session, onSwitchPassport, onSwitchAccount, onBindWallet, onSwitchProfile, locale, isBlocklet, }: UserInfoProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export default function UserInfo({ session, onSwitchPassport, onSwitchAccount, onBindWallet, onSwitchProfile, locale, isBlocklet, mode, }: UserInfoProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Box as
|
|
3
|
-
import { Icon as
|
|
1
|
+
import { jsxs as o, jsx as e, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { Box as t, Typography as C, Chip as v, alpha as I } from "@mui/material";
|
|
3
|
+
import { Icon as s } from "@iconify/react";
|
|
4
4
|
import S from "@iconify-icons/material-symbols/swap-horiz-rounded";
|
|
5
|
-
import
|
|
6
|
-
import { useMemoizedFn as
|
|
5
|
+
import z from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
|
|
6
|
+
import { useMemoizedFn as R, useCreation as m } from "ahooks";
|
|
7
7
|
import d from "lodash/noop";
|
|
8
|
-
import
|
|
9
|
-
import { getUserAvatar as
|
|
10
|
-
import
|
|
11
|
-
import { getWallet as
|
|
12
|
-
import { translations as
|
|
13
|
-
import { translate as
|
|
14
|
-
|
|
8
|
+
import D from "../../Avatar/index.js";
|
|
9
|
+
import { getUserAvatar as k } from "../../Util/index.js";
|
|
10
|
+
import A from "./session-user-switch.js";
|
|
11
|
+
import { getWallet as U } from "../libs/utils.js";
|
|
12
|
+
import { translations as W } from "../libs/translation.js";
|
|
13
|
+
import { translate as j } from "../../Locale/util.js";
|
|
14
|
+
import M from "../../Tag/index.js";
|
|
15
|
+
function V({
|
|
15
16
|
session: r,
|
|
16
|
-
onSwitchPassport:
|
|
17
|
-
onSwitchAccount:
|
|
18
|
-
onBindWallet:
|
|
19
|
-
onSwitchProfile:
|
|
20
|
-
locale:
|
|
21
|
-
isBlocklet:
|
|
17
|
+
onSwitchPassport: l,
|
|
18
|
+
onSwitchAccount: u,
|
|
19
|
+
onBindWallet: f,
|
|
20
|
+
onSwitchProfile: h = d,
|
|
21
|
+
locale: c = "en",
|
|
22
|
+
isBlocklet: i = !0,
|
|
23
|
+
mode: a = "normal"
|
|
22
24
|
}) {
|
|
23
|
-
const
|
|
24
|
-
(
|
|
25
|
-
), [r?.user?.passports, r?.user?.role]),
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
25
|
+
const p = R((n, b = {}) => j(W, n, c, "en", b)), g = k(r.user?.avatar?.replace(/\s/g, encodeURIComponent(" ")), 64), x = m(() => r.user?.passports?.find(
|
|
26
|
+
(n) => n.name === r.user.role || n.role === r.user.role
|
|
27
|
+
), [r?.user?.passports, r?.user?.role]), y = m(() => U(r?.user), [r?.user]);
|
|
28
|
+
return /* @__PURE__ */ o(
|
|
29
|
+
t,
|
|
28
30
|
{
|
|
29
31
|
sx: {
|
|
30
32
|
py: 2,
|
|
@@ -35,8 +37,8 @@ function K({
|
|
|
35
37
|
gap: 1.5
|
|
36
38
|
},
|
|
37
39
|
children: [
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
40
|
+
/* @__PURE__ */ o(
|
|
41
|
+
t,
|
|
40
42
|
{
|
|
41
43
|
sx: {
|
|
42
44
|
display: "flex",
|
|
@@ -46,8 +48,8 @@ function K({
|
|
|
46
48
|
px: 2
|
|
47
49
|
},
|
|
48
50
|
children: [
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
-
|
|
51
|
+
/* @__PURE__ */ o(
|
|
52
|
+
t,
|
|
51
53
|
{
|
|
52
54
|
sx: {
|
|
53
55
|
display: "flex",
|
|
@@ -55,21 +57,21 @@ function K({
|
|
|
55
57
|
gap: 1.5
|
|
56
58
|
},
|
|
57
59
|
children: [
|
|
58
|
-
/* @__PURE__ */ e(
|
|
59
|
-
|
|
60
|
+
a === "normal" ? /* @__PURE__ */ e(
|
|
61
|
+
t,
|
|
60
62
|
{
|
|
61
|
-
onClick:
|
|
63
|
+
onClick: i ? d : h,
|
|
62
64
|
"data-cy": "sessionManager-switch-profile-trigger",
|
|
63
65
|
sx: {
|
|
64
|
-
cursor:
|
|
66
|
+
cursor: i ? "default" : "pointer",
|
|
65
67
|
position: "relative",
|
|
66
68
|
borderRadius: "100%",
|
|
67
69
|
overflow: "hidden",
|
|
68
70
|
fontSize: 0,
|
|
69
71
|
flexShrink: 0,
|
|
70
|
-
"&:hover":
|
|
72
|
+
"&:hover": i ? {} : {
|
|
71
73
|
"&::after": {
|
|
72
|
-
content: `"${
|
|
74
|
+
content: `"${p("switch")}"`,
|
|
73
75
|
position: "absolute",
|
|
74
76
|
bottom: 0,
|
|
75
77
|
background: "rgba(0, 0, 0, 0.2)",
|
|
@@ -84,28 +86,58 @@ function K({
|
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
children: /* @__PURE__ */ e(
|
|
87
|
-
|
|
89
|
+
D,
|
|
88
90
|
{
|
|
89
91
|
variant: "circle",
|
|
90
92
|
did: r.user.did,
|
|
91
|
-
src:
|
|
93
|
+
src: g,
|
|
92
94
|
size: 48,
|
|
93
95
|
shape: "circle",
|
|
94
96
|
sx: {
|
|
95
|
-
cursor:
|
|
97
|
+
cursor: i ? "unset" : "pointer"
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
)
|
|
99
101
|
}
|
|
100
|
-
),
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
+
) : null,
|
|
103
|
+
/* @__PURE__ */ o(t, { children: [
|
|
104
|
+
/* @__PURE__ */ e(C, { variant: a === "normal" ? "h6" : "h4", sx: { wordBreak: "break-word" }, children: r.user.fullName }),
|
|
105
|
+
a === "normal" ? null : /* @__PURE__ */ o(
|
|
106
|
+
M,
|
|
107
|
+
{
|
|
108
|
+
type: "primary",
|
|
109
|
+
sx: {
|
|
110
|
+
transform: "scale(0.85)",
|
|
111
|
+
transformOrigin: "left",
|
|
112
|
+
color: "white !important",
|
|
113
|
+
display: "flex",
|
|
114
|
+
alignItems: "center"
|
|
115
|
+
},
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ e(
|
|
118
|
+
t,
|
|
119
|
+
{
|
|
120
|
+
sx: {
|
|
121
|
+
mr: 0.75,
|
|
122
|
+
width: 6,
|
|
123
|
+
height: 6,
|
|
124
|
+
backgroundColor: "white",
|
|
125
|
+
borderRadius: "100vw"
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ e(t, { children: "DID CONNECTED" })
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
] })
|
|
102
134
|
]
|
|
103
135
|
}
|
|
104
136
|
),
|
|
105
|
-
/* @__PURE__ */ e(
|
|
106
|
-
|
|
137
|
+
a === "normal" ? /* @__PURE__ */ e(
|
|
138
|
+
v,
|
|
107
139
|
{
|
|
108
|
-
label:
|
|
140
|
+
label: x?.title || r.user?.role.toUpperCase(),
|
|
109
141
|
size: "small",
|
|
110
142
|
variant: "outlined",
|
|
111
143
|
clickable: !0,
|
|
@@ -121,44 +153,46 @@ function K({
|
|
|
121
153
|
boxShadow: "none"
|
|
122
154
|
}
|
|
123
155
|
},
|
|
124
|
-
deleteIcon: /* @__PURE__ */ e(
|
|
125
|
-
onDelete:
|
|
126
|
-
onClick:
|
|
156
|
+
deleteIcon: /* @__PURE__ */ e(s, { icon: S, color: "inherit" }),
|
|
157
|
+
onDelete: l,
|
|
158
|
+
onClick: l,
|
|
127
159
|
"data-cy": "sessionManager-switch-passport-trigger"
|
|
128
160
|
}
|
|
129
|
-
)
|
|
161
|
+
) : null
|
|
130
162
|
]
|
|
131
163
|
}
|
|
132
164
|
),
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
165
|
+
a === "normal" ? /* @__PURE__ */ o(w, { children: [
|
|
166
|
+
/* @__PURE__ */ e(A, { session: r, onSwitch: u, isBlocklet: i, locale: c }),
|
|
167
|
+
y ? null : /* @__PURE__ */ o(
|
|
168
|
+
t,
|
|
169
|
+
{
|
|
170
|
+
sx: {
|
|
171
|
+
color: "secondary.main",
|
|
172
|
+
bgcolor: ({ palette: n }) => I(n.secondary.main, 0.05),
|
|
173
|
+
borderRadius: 1,
|
|
174
|
+
display: "flex",
|
|
175
|
+
justifyContent: "space-between",
|
|
176
|
+
alignItems: "center",
|
|
177
|
+
fontSize: 12,
|
|
178
|
+
py: 0.75,
|
|
179
|
+
px: 1.5,
|
|
180
|
+
cursor: "pointer",
|
|
181
|
+
mt: -0.75
|
|
182
|
+
},
|
|
183
|
+
onClick: f,
|
|
184
|
+
"data-cy": "sessionManager-bind-trigger",
|
|
185
|
+
children: [
|
|
186
|
+
p("connectDIDWallet"),
|
|
187
|
+
/* @__PURE__ */ e(s, { icon: z, color: "inherit", fontSize: 16 })
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
)
|
|
191
|
+
] }) : null
|
|
158
192
|
]
|
|
159
193
|
}
|
|
160
194
|
);
|
|
161
195
|
}
|
|
162
196
|
export {
|
|
163
|
-
|
|
197
|
+
V as default
|
|
164
198
|
};
|
package/lib/SessionUser/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import p from "lodash/noop";
|
|
3
|
-
import { useCreation as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { PROFILE_URL as
|
|
7
|
-
function
|
|
8
|
-
session:
|
|
9
|
-
onBindWallet:
|
|
10
|
-
locale:
|
|
3
|
+
import { useCreation as c } from "ahooks";
|
|
4
|
+
import u from "./components/logged-in.js";
|
|
5
|
+
import g from "./components/un-login.js";
|
|
6
|
+
import { PROFILE_URL as s } from "../Util/constant.js";
|
|
7
|
+
function U({
|
|
8
|
+
session: o,
|
|
9
|
+
onBindWallet: e = p,
|
|
10
|
+
locale: r = "en",
|
|
11
11
|
size: t = 24,
|
|
12
|
-
popperType:
|
|
13
|
-
profileUrl:
|
|
12
|
+
popperType: i = "click",
|
|
13
|
+
profileUrl: n = s
|
|
14
14
|
}) {
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
|
|
15
|
+
const l = c(() => !!globalThis?.blocklet, []), f = globalThis?.blocklet?.SESSION_USER_MODE;
|
|
16
|
+
return o.user ? /* @__PURE__ */ m(
|
|
17
|
+
u,
|
|
18
18
|
{
|
|
19
|
-
isBlocklet:
|
|
20
|
-
session:
|
|
21
|
-
onBindWallet:
|
|
22
|
-
locale:
|
|
19
|
+
isBlocklet: l,
|
|
20
|
+
session: o,
|
|
21
|
+
onBindWallet: e,
|
|
22
|
+
locale: r,
|
|
23
23
|
size: t,
|
|
24
|
-
popperType:
|
|
25
|
-
profileUrl:
|
|
24
|
+
popperType: i,
|
|
25
|
+
profileUrl: n,
|
|
26
|
+
mode: f
|
|
26
27
|
}
|
|
27
|
-
) : /* @__PURE__ */ m(
|
|
28
|
+
) : /* @__PURE__ */ m(g, { session: o, locale: r, size: t });
|
|
28
29
|
}
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
U as default
|
|
31
32
|
};
|
package/lib/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.9",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
"react": "^19.0.0",
|
|
75
75
|
"react-router-dom": "^6.22.3"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "e01324f3084f688f514eed2b5fb8d1c4b3e4247e",
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@arcblock/bridge": "3.4.
|
|
80
|
-
"@arcblock/did": "^1.28.
|
|
79
|
+
"@arcblock/bridge": "3.4.9",
|
|
80
|
+
"@arcblock/did": "^1.28.6",
|
|
81
81
|
"@arcblock/did-motif": "^1.1.14",
|
|
82
|
-
"@arcblock/icons": "3.4.
|
|
83
|
-
"@arcblock/nft-display": "3.4.
|
|
84
|
-
"@arcblock/react-hooks": "3.4.
|
|
82
|
+
"@arcblock/icons": "3.4.9",
|
|
83
|
+
"@arcblock/nft-display": "3.4.9",
|
|
84
|
+
"@arcblock/react-hooks": "3.4.9",
|
|
85
85
|
"@blocklet/js-sdk": "^1.17.7",
|
|
86
|
-
"@blocklet/theme": "3.4.
|
|
86
|
+
"@blocklet/theme": "3.4.9",
|
|
87
87
|
"@fontsource/roboto": "~5.1.1",
|
|
88
88
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
|
89
89
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"@iconify-icons/mdi": "^1.2.48",
|
|
92
92
|
"@iconify-icons/tabler": "^1.2.95",
|
|
93
93
|
"@iconify/react": "^5.2.1",
|
|
94
|
-
"@ocap/mcrypto": "^1.28.
|
|
94
|
+
"@ocap/mcrypto": "^1.28.6",
|
|
95
95
|
"@solana/qr-code-styling": "^1.6.0",
|
|
96
96
|
"@types/dompurify": "^3.2.0",
|
|
97
97
|
"@types/mui-datatables": "^4.3.12",
|
|
@@ -51,6 +51,7 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
51
51
|
size?: number;
|
|
52
52
|
popperType?: 'hover' | 'click';
|
|
53
53
|
profileUrl?: string;
|
|
54
|
+
mode?: 'minimal' | 'normal';
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
export default function LoggedIn({
|
|
@@ -61,6 +62,7 @@ export default function LoggedIn({
|
|
|
61
62
|
size = 24,
|
|
62
63
|
popperType = 'click',
|
|
63
64
|
profileUrl = PROFILE_URL,
|
|
65
|
+
mode = 'normal',
|
|
64
66
|
sx,
|
|
65
67
|
...rest
|
|
66
68
|
}: LoggedInProps) {
|
|
@@ -227,6 +229,7 @@ export default function LoggedIn({
|
|
|
227
229
|
onSwitchAccount={handleSwitchAccount}
|
|
228
230
|
onSwitchProfile={handleSwitchProfile}
|
|
229
231
|
onBindWallet={handleBindWallet}
|
|
232
|
+
mode={mode}
|
|
230
233
|
/>
|
|
231
234
|
<Divider sx={{ m: '0 !important' }} />
|
|
232
235
|
<MenuList sx={{ p: 0 }}>
|
|
@@ -258,7 +261,7 @@ export default function LoggedIn({
|
|
|
258
261
|
/>
|
|
259
262
|
)}
|
|
260
263
|
<Divider sx={{ m: '0 !important' }} />
|
|
261
|
-
<DidSpace session={session} locale={locale} />
|
|
264
|
+
{mode === 'normal' ? <DidSpace session={session} locale={locale} /> : null}
|
|
262
265
|
</>
|
|
263
266
|
) : null}
|
|
264
267
|
<SessionMenuItem
|
|
@@ -12,6 +12,7 @@ import { getWallet } from '../libs/utils';
|
|
|
12
12
|
import { translations } from '../libs/translation';
|
|
13
13
|
import { translate } from '../../Locale/util';
|
|
14
14
|
import type { $TSFixMe, Locale, Session } from '../../type';
|
|
15
|
+
import Tag from '../../Tag';
|
|
15
16
|
|
|
16
17
|
export interface UserInfoProps {
|
|
17
18
|
session: Session;
|
|
@@ -21,6 +22,7 @@ export interface UserInfoProps {
|
|
|
21
22
|
onSwitchProfile?: () => void;
|
|
22
23
|
locale?: Locale;
|
|
23
24
|
isBlocklet?: true | false;
|
|
25
|
+
mode?: 'minimal' | 'normal';
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export default function UserInfo({
|
|
@@ -31,6 +33,7 @@ export default function UserInfo({
|
|
|
31
33
|
onSwitchProfile = noop,
|
|
32
34
|
locale = 'en',
|
|
33
35
|
isBlocklet = true,
|
|
36
|
+
mode = 'normal',
|
|
34
37
|
}: UserInfoProps) {
|
|
35
38
|
const t = useMemoizedFn((key, data = {}) => {
|
|
36
39
|
return translate(translations, key, locale, 'en', data);
|
|
@@ -71,94 +74,126 @@ export default function UserInfo({
|
|
|
71
74
|
alignItems: 'center',
|
|
72
75
|
gap: 1.5,
|
|
73
76
|
}}>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
cursor: isBlocklet ? 'default' : 'pointer',
|
|
79
|
-
position: 'relative',
|
|
80
|
-
borderRadius: '100%',
|
|
81
|
-
overflow: 'hidden',
|
|
82
|
-
fontSize: 0,
|
|
83
|
-
flexShrink: 0,
|
|
84
|
-
'&:hover': isBlocklet
|
|
85
|
-
? {}
|
|
86
|
-
: {
|
|
87
|
-
'&::after': {
|
|
88
|
-
content: `"${t('switch')}"`,
|
|
89
|
-
position: 'absolute',
|
|
90
|
-
bottom: 0,
|
|
91
|
-
background: 'rgba(0, 0, 0, 0.2)',
|
|
92
|
-
left: 0,
|
|
93
|
-
right: 0,
|
|
94
|
-
height: '2.2em',
|
|
95
|
-
color: 'white',
|
|
96
|
-
textAlign: 'center',
|
|
97
|
-
fontSize: '12px',
|
|
98
|
-
lineHeight: '2em',
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
}}>
|
|
102
|
-
<DidAvatar
|
|
103
|
-
variant="circle"
|
|
104
|
-
did={session.user.did}
|
|
105
|
-
src={avatar}
|
|
106
|
-
size={48}
|
|
107
|
-
shape="circle"
|
|
77
|
+
{mode === 'normal' ? (
|
|
78
|
+
<Box
|
|
79
|
+
onClick={isBlocklet ? noop : onSwitchProfile}
|
|
80
|
+
data-cy="sessionManager-switch-profile-trigger"
|
|
108
81
|
sx={{
|
|
109
|
-
cursor: isBlocklet ? '
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
82
|
+
cursor: isBlocklet ? 'default' : 'pointer',
|
|
83
|
+
position: 'relative',
|
|
84
|
+
borderRadius: '100%',
|
|
85
|
+
overflow: 'hidden',
|
|
86
|
+
fontSize: 0,
|
|
87
|
+
flexShrink: 0,
|
|
88
|
+
'&:hover': isBlocklet
|
|
89
|
+
? {}
|
|
90
|
+
: {
|
|
91
|
+
'&::after': {
|
|
92
|
+
content: `"${t('switch')}"`,
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
bottom: 0,
|
|
95
|
+
background: 'rgba(0, 0, 0, 0.2)',
|
|
96
|
+
left: 0,
|
|
97
|
+
right: 0,
|
|
98
|
+
height: '2.2em',
|
|
99
|
+
color: 'white',
|
|
100
|
+
textAlign: 'center',
|
|
101
|
+
fontSize: '12px',
|
|
102
|
+
lineHeight: '2em',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
}}>
|
|
106
|
+
<DidAvatar
|
|
107
|
+
variant="circle"
|
|
108
|
+
did={session.user.did}
|
|
109
|
+
src={avatar}
|
|
110
|
+
size={48}
|
|
111
|
+
shape="circle"
|
|
112
|
+
sx={{
|
|
113
|
+
cursor: isBlocklet ? 'unset' : 'pointer',
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
</Box>
|
|
117
|
+
) : null}
|
|
113
118
|
|
|
114
|
-
<
|
|
115
|
-
{
|
|
116
|
-
|
|
119
|
+
<Box>
|
|
120
|
+
<Typography variant={mode === 'normal' ? 'h6' : 'h4'} sx={{ wordBreak: 'break-word' }}>
|
|
121
|
+
{session.user.fullName}
|
|
122
|
+
</Typography>
|
|
123
|
+
{mode === 'normal' ? null : (
|
|
124
|
+
<Tag
|
|
125
|
+
type="primary"
|
|
126
|
+
sx={{
|
|
127
|
+
transform: 'scale(0.85)',
|
|
128
|
+
transformOrigin: 'left',
|
|
129
|
+
color: 'white !important',
|
|
130
|
+
display: 'flex',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
}}>
|
|
133
|
+
<Box
|
|
134
|
+
sx={{
|
|
135
|
+
mr: 0.75,
|
|
136
|
+
width: 6,
|
|
137
|
+
height: 6,
|
|
138
|
+
backgroundColor: 'white',
|
|
139
|
+
borderRadius: '100vw',
|
|
140
|
+
}}
|
|
141
|
+
/>
|
|
142
|
+
<Box>DID CONNECTED</Box>
|
|
143
|
+
</Tag>
|
|
144
|
+
)}
|
|
145
|
+
</Box>
|
|
117
146
|
</Box>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
{mode === 'normal' ? (
|
|
148
|
+
<Chip
|
|
149
|
+
label={currentRole?.title || session.user?.role.toUpperCase()}
|
|
150
|
+
size="small"
|
|
151
|
+
variant="outlined"
|
|
152
|
+
clickable
|
|
153
|
+
sx={{
|
|
154
|
+
flexShrink: 0,
|
|
155
|
+
fontWeight: 'bold',
|
|
156
|
+
fontSize: '12px',
|
|
157
|
+
color: 'text.primary',
|
|
158
|
+
borderColor: 'grey.100',
|
|
159
|
+
pr: 1,
|
|
160
|
+
pl: 0.5,
|
|
161
|
+
'&:active': {
|
|
162
|
+
boxShadow: 'none',
|
|
163
|
+
},
|
|
164
|
+
}}
|
|
165
|
+
deleteIcon={<Icon icon={SwapHorizRoundedIcon} color="inherit" />}
|
|
166
|
+
onDelete={onSwitchPassport}
|
|
167
|
+
onClick={onSwitchPassport}
|
|
168
|
+
data-cy="sessionManager-switch-passport-trigger"
|
|
169
|
+
/>
|
|
170
|
+
) : null}
|
|
140
171
|
</Box>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
172
|
+
{mode === 'normal' ? (
|
|
173
|
+
<>
|
|
174
|
+
<SessionUserSwitch session={session} onSwitch={onSwitchAccount} isBlocklet={isBlocklet} locale={locale} />
|
|
175
|
+
{!hasBindWallet ? (
|
|
176
|
+
<Box
|
|
177
|
+
sx={{
|
|
178
|
+
color: 'secondary.main',
|
|
179
|
+
bgcolor: ({ palette }) => alpha(palette.secondary.main, 0.05),
|
|
180
|
+
borderRadius: 1,
|
|
181
|
+
display: 'flex',
|
|
182
|
+
justifyContent: 'space-between',
|
|
183
|
+
alignItems: 'center',
|
|
184
|
+
fontSize: 12,
|
|
185
|
+
py: 0.75,
|
|
186
|
+
px: 1.5,
|
|
187
|
+
cursor: 'pointer',
|
|
188
|
+
mt: -0.75,
|
|
189
|
+
}}
|
|
190
|
+
onClick={onBindWallet}
|
|
191
|
+
data-cy="sessionManager-bind-trigger">
|
|
192
|
+
{t('connectDIDWallet')}
|
|
193
|
+
<Icon icon={ArrowRightAltRoundedIcon} color="inherit" fontSize={16} />
|
|
194
|
+
</Box>
|
|
195
|
+
) : null}
|
|
196
|
+
</>
|
|
162
197
|
) : null}
|
|
163
198
|
</Box>
|
|
164
199
|
);
|
|
@@ -27,6 +27,8 @@ export default function SessionUser({
|
|
|
27
27
|
return !!globalThis?.blocklet;
|
|
28
28
|
}, []);
|
|
29
29
|
|
|
30
|
+
const mode = globalThis?.blocklet?.SESSION_USER_MODE;
|
|
31
|
+
|
|
30
32
|
if (session.user) {
|
|
31
33
|
return (
|
|
32
34
|
<LoggedIn
|
|
@@ -37,6 +39,7 @@ export default function SessionUser({
|
|
|
37
39
|
size={size}
|
|
38
40
|
popperType={popperType}
|
|
39
41
|
profileUrl={profileUrl}
|
|
42
|
+
mode={mode}
|
|
40
43
|
/>
|
|
41
44
|
);
|
|
42
45
|
}
|