@arcblock/ux 3.4.8 → 3.4.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/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 +103 -68
- 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 +120 -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
|
|
1
|
+
import { jsxs as n, jsx as e, Fragment as w } from "react/jsx-runtime";
|
|
2
|
+
import { Box as o, Typography as C, Chip as v, alpha as I } from "@mui/material";
|
|
3
3
|
import { Icon as p } from "@iconify/react";
|
|
4
4
|
import S from "@iconify-icons/material-symbols/swap-horiz-rounded";
|
|
5
|
-
import
|
|
6
|
-
import { useMemoizedFn as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { getUserAvatar as
|
|
5
|
+
import _ from "@iconify-icons/material-symbols/arrow-right-alt-rounded";
|
|
6
|
+
import { useMemoizedFn as z, useCreation as d } from "ahooks";
|
|
7
|
+
import m from "lodash/noop";
|
|
8
|
+
import R from "../../Avatar/index.js";
|
|
9
|
+
import { getUserAvatar as D } from "../../Util/index.js";
|
|
10
10
|
import k from "./session-user-switch.js";
|
|
11
|
-
import { getWallet as
|
|
12
|
-
import { translations as
|
|
13
|
-
import { translate as
|
|
14
|
-
|
|
11
|
+
import { getWallet as N } from "../libs/utils.js";
|
|
12
|
+
import { translations as A } from "../libs/translation.js";
|
|
13
|
+
import { translate as U } from "../../Locale/util.js";
|
|
14
|
+
import W from "../../Tag/index.js";
|
|
15
|
+
function Q({
|
|
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 = m,
|
|
21
|
+
locale: c = "en",
|
|
22
|
+
isBlocklet: a = !0,
|
|
23
|
+
mode: i = "normal"
|
|
22
24
|
}) {
|
|
23
|
-
const
|
|
25
|
+
const s = z((t, b = {}) => U(A, t, c, "en", b)), g = D(r.user?.avatar?.replace(/\s/g, encodeURIComponent(" ")), 64), x = d(() => r.user?.passports?.find(
|
|
24
26
|
(t) => t.name === r.user.role || t.role === r.user.role
|
|
25
|
-
), [r?.user?.passports, r?.user?.role]),
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
27
|
+
), [r?.user?.passports, r?.user?.role]), y = d(() => N(r?.user), [r?.user]);
|
|
28
|
+
return /* @__PURE__ */ n(
|
|
29
|
+
o,
|
|
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__ */ n(
|
|
41
|
+
o,
|
|
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__ */ n(
|
|
52
|
+
o,
|
|
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
|
+
i === "normal" ? /* @__PURE__ */ e(
|
|
61
|
+
o,
|
|
60
62
|
{
|
|
61
|
-
onClick:
|
|
63
|
+
onClick: a ? m : h,
|
|
62
64
|
"data-cy": "sessionManager-switch-profile-trigger",
|
|
63
65
|
sx: {
|
|
64
|
-
cursor:
|
|
66
|
+
cursor: a ? "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": a ? {} : {
|
|
71
73
|
"&::after": {
|
|
72
|
-
content: `"${
|
|
74
|
+
content: `"${s("switch")}"`,
|
|
73
75
|
position: "absolute",
|
|
74
76
|
bottom: 0,
|
|
75
77
|
background: "rgba(0, 0, 0, 0.2)",
|
|
@@ -84,28 +86,59 @@ function K({
|
|
|
84
86
|
}
|
|
85
87
|
},
|
|
86
88
|
children: /* @__PURE__ */ e(
|
|
87
|
-
|
|
89
|
+
R,
|
|
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: a ? "unset" : "pointer"
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
100
|
)
|
|
99
101
|
}
|
|
100
|
-
),
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
+
) : null,
|
|
103
|
+
/* @__PURE__ */ n(o, { children: [
|
|
104
|
+
/* @__PURE__ */ e(C, { variant: i === "normal" ? "h6" : "h4", sx: { wordBreak: "break-word" }, children: r.user.fullName }),
|
|
105
|
+
i === "normal" ? null : /* @__PURE__ */ n(
|
|
106
|
+
W,
|
|
107
|
+
{
|
|
108
|
+
className: "user-info__connected-tag",
|
|
109
|
+
type: "primary",
|
|
110
|
+
sx: {
|
|
111
|
+
transform: "scale(0.85)",
|
|
112
|
+
transformOrigin: "left",
|
|
113
|
+
display: "flex",
|
|
114
|
+
alignItems: "center"
|
|
115
|
+
},
|
|
116
|
+
children: [
|
|
117
|
+
/* @__PURE__ */ e(
|
|
118
|
+
o,
|
|
119
|
+
{
|
|
120
|
+
className: "user-info__connected-tag__dot",
|
|
121
|
+
sx: {
|
|
122
|
+
mr: 0.75,
|
|
123
|
+
width: 6,
|
|
124
|
+
height: 6,
|
|
125
|
+
backgroundColor: (t) => t.palette.text.contrast,
|
|
126
|
+
borderRadius: "100vw"
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ e(o, { className: "user-info__connected-tag__text", children: "DID CONNECTED" })
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] })
|
|
102
135
|
]
|
|
103
136
|
}
|
|
104
137
|
),
|
|
105
|
-
/* @__PURE__ */ e(
|
|
106
|
-
|
|
138
|
+
i === "normal" ? /* @__PURE__ */ e(
|
|
139
|
+
v,
|
|
107
140
|
{
|
|
108
|
-
label:
|
|
141
|
+
label: x?.title || r.user?.role.toUpperCase(),
|
|
109
142
|
size: "small",
|
|
110
143
|
variant: "outlined",
|
|
111
144
|
clickable: !0,
|
|
@@ -122,43 +155,45 @@ function K({
|
|
|
122
155
|
}
|
|
123
156
|
},
|
|
124
157
|
deleteIcon: /* @__PURE__ */ e(p, { icon: S, color: "inherit" }),
|
|
125
|
-
onDelete:
|
|
126
|
-
onClick:
|
|
158
|
+
onDelete: l,
|
|
159
|
+
onClick: l,
|
|
127
160
|
"data-cy": "sessionManager-switch-passport-trigger"
|
|
128
161
|
}
|
|
129
|
-
)
|
|
162
|
+
) : null
|
|
130
163
|
]
|
|
131
164
|
}
|
|
132
165
|
),
|
|
133
|
-
/* @__PURE__ */
|
|
134
|
-
|
|
135
|
-
n
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
166
|
+
i === "normal" ? /* @__PURE__ */ n(w, { children: [
|
|
167
|
+
/* @__PURE__ */ e(k, { session: r, onSwitch: u, isBlocklet: a, locale: c }),
|
|
168
|
+
y ? null : /* @__PURE__ */ n(
|
|
169
|
+
o,
|
|
170
|
+
{
|
|
171
|
+
sx: {
|
|
172
|
+
color: "secondary.main",
|
|
173
|
+
bgcolor: ({ palette: t }) => I(t.secondary.main, 0.05),
|
|
174
|
+
borderRadius: 1,
|
|
175
|
+
display: "flex",
|
|
176
|
+
justifyContent: "space-between",
|
|
177
|
+
alignItems: "center",
|
|
178
|
+
fontSize: 12,
|
|
179
|
+
py: 0.75,
|
|
180
|
+
px: 1.5,
|
|
181
|
+
cursor: "pointer",
|
|
182
|
+
mt: -0.75
|
|
183
|
+
},
|
|
184
|
+
onClick: f,
|
|
185
|
+
"data-cy": "sessionManager-bind-trigger",
|
|
186
|
+
children: [
|
|
187
|
+
s("connectDIDWallet"),
|
|
188
|
+
/* @__PURE__ */ e(p, { icon: _, color: "inherit", fontSize: 16 })
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
)
|
|
192
|
+
] }) : null
|
|
158
193
|
]
|
|
159
194
|
}
|
|
160
195
|
);
|
|
161
196
|
}
|
|
162
197
|
export {
|
|
163
|
-
|
|
198
|
+
Q as default
|
|
164
199
|
};
|
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.10",
|
|
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": "162768378bf0a1d1e0984d1f01235eafa5bd9bdb",
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@arcblock/bridge": "3.4.
|
|
80
|
-
"@arcblock/did": "^1.28.
|
|
79
|
+
"@arcblock/bridge": "3.4.10",
|
|
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.10",
|
|
83
|
+
"@arcblock/nft-display": "3.4.10",
|
|
84
|
+
"@arcblock/react-hooks": "3.4.10",
|
|
85
85
|
"@blocklet/js-sdk": "^1.17.7",
|
|
86
|
-
"@blocklet/theme": "3.4.
|
|
86
|
+
"@blocklet/theme": "3.4.10",
|
|
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,127 @@ 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
|
+
className="user-info__connected-tag"
|
|
126
|
+
type="primary"
|
|
127
|
+
sx={{
|
|
128
|
+
transform: 'scale(0.85)',
|
|
129
|
+
transformOrigin: 'left',
|
|
130
|
+
display: 'flex',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
}}>
|
|
133
|
+
<Box
|
|
134
|
+
className="user-info__connected-tag__dot"
|
|
135
|
+
sx={{
|
|
136
|
+
mr: 0.75,
|
|
137
|
+
width: 6,
|
|
138
|
+
height: 6,
|
|
139
|
+
backgroundColor: (theme) => theme.palette.text.contrast,
|
|
140
|
+
borderRadius: '100vw',
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
<Box className="user-info__connected-tag__text">DID CONNECTED</Box>
|
|
144
|
+
</Tag>
|
|
145
|
+
)}
|
|
146
|
+
</Box>
|
|
117
147
|
</Box>
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
148
|
+
{mode === 'normal' ? (
|
|
149
|
+
<Chip
|
|
150
|
+
label={currentRole?.title || session.user?.role.toUpperCase()}
|
|
151
|
+
size="small"
|
|
152
|
+
variant="outlined"
|
|
153
|
+
clickable
|
|
154
|
+
sx={{
|
|
155
|
+
flexShrink: 0,
|
|
156
|
+
fontWeight: 'bold',
|
|
157
|
+
fontSize: '12px',
|
|
158
|
+
color: 'text.primary',
|
|
159
|
+
borderColor: 'grey.100',
|
|
160
|
+
pr: 1,
|
|
161
|
+
pl: 0.5,
|
|
162
|
+
'&:active': {
|
|
163
|
+
boxShadow: 'none',
|
|
164
|
+
},
|
|
165
|
+
}}
|
|
166
|
+
deleteIcon={<Icon icon={SwapHorizRoundedIcon} color="inherit" />}
|
|
167
|
+
onDelete={onSwitchPassport}
|
|
168
|
+
onClick={onSwitchPassport}
|
|
169
|
+
data-cy="sessionManager-switch-passport-trigger"
|
|
170
|
+
/>
|
|
171
|
+
) : null}
|
|
140
172
|
</Box>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
173
|
+
{mode === 'normal' ? (
|
|
174
|
+
<>
|
|
175
|
+
<SessionUserSwitch session={session} onSwitch={onSwitchAccount} isBlocklet={isBlocklet} locale={locale} />
|
|
176
|
+
{!hasBindWallet ? (
|
|
177
|
+
<Box
|
|
178
|
+
sx={{
|
|
179
|
+
color: 'secondary.main',
|
|
180
|
+
bgcolor: ({ palette }) => alpha(palette.secondary.main, 0.05),
|
|
181
|
+
borderRadius: 1,
|
|
182
|
+
display: 'flex',
|
|
183
|
+
justifyContent: 'space-between',
|
|
184
|
+
alignItems: 'center',
|
|
185
|
+
fontSize: 12,
|
|
186
|
+
py: 0.75,
|
|
187
|
+
px: 1.5,
|
|
188
|
+
cursor: 'pointer',
|
|
189
|
+
mt: -0.75,
|
|
190
|
+
}}
|
|
191
|
+
onClick={onBindWallet}
|
|
192
|
+
data-cy="sessionManager-bind-trigger">
|
|
193
|
+
{t('connectDIDWallet')}
|
|
194
|
+
<Icon icon={ArrowRightAltRoundedIcon} color="inherit" fontSize={16} />
|
|
195
|
+
</Box>
|
|
196
|
+
) : null}
|
|
197
|
+
</>
|
|
162
198
|
) : null}
|
|
163
199
|
</Box>
|
|
164
200
|
);
|
|
@@ -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
|
}
|