@arcblock/ux 3.3.5 → 3.3.6
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 +68 -67
- package/lib/SessionUser/index.d.ts +2 -1
- package/lib/SessionUser/index.js +19 -16
- package/lib/package.json.js +1 -1
- package/package.json +7 -7
- package/src/SessionUser/components/logged-in.tsx +3 -1
- package/src/SessionUser/index.tsx +4 -0
|
@@ -7,5 +7,6 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
7
7
|
locale?: Locale;
|
|
8
8
|
size?: number;
|
|
9
9
|
popperType?: 'hover' | 'click';
|
|
10
|
+
profileUrl?: string;
|
|
10
11
|
}
|
|
11
|
-
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, sx, ...rest }: LoggedInProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, profileUrl, sx, ...rest }: LoggedInProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,56 +1,57 @@
|
|
|
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 z } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as T, useEffect as _ } from "react";
|
|
3
|
+
import { useMemoizedFn as n, useCreation as j, useReactive as G } from "ahooks";
|
|
4
4
|
import f from "@arcblock/bridge";
|
|
5
|
-
import { Box as k, IconButton as
|
|
6
|
-
import { Icon as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
5
|
+
import { Box as k, IconButton as H, Popper as N, ClickAwayListener as Q, Fade as V, Paper as q, Divider as S, MenuList as J, MenuItem as K } from "@mui/material";
|
|
6
|
+
import { Icon as X } from "@iconify/react";
|
|
7
|
+
import Y from "@iconify-icons/material-symbols/person-outline-rounded";
|
|
8
|
+
import Z from "@iconify-icons/material-symbols/filter-vintage-outline-rounded";
|
|
9
|
+
import $ from "@iconify-icons/material-symbols/account-circle-off-outline-rounded";
|
|
10
|
+
import ee from "@iconify-icons/material-symbols/featured-seasonal-and-gifts-rounded";
|
|
11
|
+
import re 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 te from "../../Toast/index.js";
|
|
14
|
+
import oe from "../../Avatar/index.js";
|
|
15
|
+
import { getUserAvatar as ie } from "../../Util/index.js";
|
|
16
|
+
import ne from "./user-info.js";
|
|
17
|
+
import { DASHBOARD_URL as ce, PROFILE_URL as le } from "../../Util/constant.js";
|
|
18
|
+
import ae from "../../SessionPermission/index.js";
|
|
19
|
+
import { translations as se } from "../libs/translation.js";
|
|
20
|
+
import { translate as pe } from "../../Locale/util.js";
|
|
21
|
+
import ue from "./did-space.js";
|
|
22
|
+
import { mergeSx as de } from "../../Util/style.js";
|
|
23
|
+
import { createDebug as me } from "../../Util/logger.js";
|
|
24
|
+
import { GA_LAST_ROLE as fe } from "../../withTracker/constant/index.js";
|
|
25
|
+
const he = (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 = me("did-connect");
|
|
29
|
+
function _e({
|
|
30
30
|
session: e,
|
|
31
31
|
onBindWallet: c = h,
|
|
32
32
|
isBlocklet: l = !0,
|
|
33
33
|
locale: u = "en",
|
|
34
34
|
size: b = 24,
|
|
35
35
|
popperType: I = "click",
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
profileUrl: y = le,
|
|
37
|
+
sx: R,
|
|
38
|
+
...C
|
|
38
39
|
}) {
|
|
39
|
-
const a = n((t, o = {}) => se
|
|
40
|
+
const a = n((t, o = {}) => pe(se, t, u, "en", o)), L = j(() => !!globalThis?.blocklet?.settings?.invite?.enabled, []), P = T(null), d = G({
|
|
40
41
|
open: !1
|
|
41
42
|
}), i = n((t = !d.open) => {
|
|
42
43
|
d.open = t;
|
|
43
|
-
}),
|
|
44
|
-
localStorage.setItem(
|
|
44
|
+
}), B = I === "hover" ? { onMouseEnter: () => i(!0), onMouseLeave: () => i(!1) } : { onClick: () => i() }, D = ie(e.user?.avatar?.replace(/\s/g, encodeURIComponent(" "))), O = e.useOAuth(), E = typeof e.usePasskey == "function" ? e.usePasskey() : null, v = n(({ inArcSphere: t = !1 } = {}) => {
|
|
45
|
+
localStorage.setItem(fe, e?.user?.role);
|
|
45
46
|
const o = {};
|
|
46
|
-
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ?
|
|
47
|
-
}), x = n(({ userSession: t, inArcSphere: o = !1 } = {}) => new Promise((
|
|
47
|
+
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ? E.switchPassport(e.user) : ["google", "apple", "email", "github"].includes(e?.user?.sourceProvider) ? O.switchOAuthPassport(e.user) : e.switchPassport(h, o);
|
|
48
|
+
}), x = n(({ userSession: t, inArcSphere: o = !1 } = {}) => new Promise((W) => {
|
|
48
49
|
const A = {};
|
|
49
50
|
o && e.user.sourceAppPid && (A.sourceAppPid = e.user.sourceAppPid);
|
|
50
51
|
const m = {};
|
|
51
52
|
t ? m.userSession = t : (i(!1), m.showQuickConnect = !1), e.switchDid(
|
|
52
53
|
() => {
|
|
53
|
-
i(!1),
|
|
54
|
+
i(!1), W();
|
|
54
55
|
},
|
|
55
56
|
A,
|
|
56
57
|
m
|
|
@@ -58,16 +59,16 @@ function Te({
|
|
|
58
59
|
})), w = n(({ inArcSphere: t = !1 } = {}) => {
|
|
59
60
|
const o = {};
|
|
60
61
|
t && e.user.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e.switchProfile(h, o);
|
|
61
|
-
}), E = n(() => {
|
|
62
|
-
i(!1), e.logout();
|
|
63
62
|
}), M = n(() => {
|
|
64
|
-
i(!1), e.
|
|
63
|
+
i(!1), e.logout();
|
|
65
64
|
}), U = n(() => {
|
|
65
|
+
i(!1), e.bindWallet(c);
|
|
66
|
+
}), F = n(() => {
|
|
66
67
|
i(!1);
|
|
67
|
-
const t =
|
|
68
|
-
|
|
68
|
+
const t = he(e.user.did);
|
|
69
|
+
re(t), te.success(a("inviteCopied"));
|
|
69
70
|
});
|
|
70
|
-
return
|
|
71
|
+
return _(() => {
|
|
71
72
|
f.registerBlocklet("callSwitchPassport", () => {
|
|
72
73
|
g("bridge registerBlocklet: callSwitchPassport"), v({ inArcSphere: !0 });
|
|
73
74
|
}), f.registerBlocklet("callSwitchDid", () => {
|
|
@@ -78,31 +79,31 @@ function Te({
|
|
|
78
79
|
}, []), /* @__PURE__ */ s(
|
|
79
80
|
k,
|
|
80
81
|
{
|
|
81
|
-
sx:
|
|
82
|
+
sx: de(
|
|
82
83
|
{
|
|
83
84
|
display: "inline-flex",
|
|
84
85
|
alignItems: "center",
|
|
85
86
|
justifyContent: "center"
|
|
86
87
|
},
|
|
87
88
|
// @ts-ignore
|
|
88
|
-
|
|
89
|
+
R
|
|
89
90
|
),
|
|
90
|
-
...
|
|
91
|
+
...C,
|
|
91
92
|
children: [
|
|
92
93
|
/* @__PURE__ */ r(
|
|
93
|
-
|
|
94
|
+
H,
|
|
94
95
|
{
|
|
95
96
|
ref: P,
|
|
96
97
|
size: "medium",
|
|
97
98
|
"data-cy": "sessionManager-logout-popup",
|
|
98
99
|
className: "arc-session-user-logged-in",
|
|
99
100
|
"aria-label": "User info button",
|
|
100
|
-
...
|
|
101
|
-
children: /* @__PURE__ */ r(
|
|
101
|
+
...B,
|
|
102
|
+
children: /* @__PURE__ */ r(oe, { variant: "circle", did: e.user.did, src: D, size: b, shape: "circle" })
|
|
102
103
|
}
|
|
103
104
|
),
|
|
104
105
|
/* @__PURE__ */ r(
|
|
105
|
-
|
|
106
|
+
N,
|
|
106
107
|
{
|
|
107
108
|
open: d.open,
|
|
108
109
|
anchorEl: P.current,
|
|
@@ -112,13 +113,13 @@ function Te({
|
|
|
112
113
|
zIndex: 1600
|
|
113
114
|
},
|
|
114
115
|
children: ({ TransitionProps: t }) => /* @__PURE__ */ r(
|
|
115
|
-
|
|
116
|
+
Q,
|
|
116
117
|
{
|
|
117
118
|
onClickAway: (o) => {
|
|
118
119
|
o.preventDefault(), o.stopPropagation(), i(!1);
|
|
119
120
|
},
|
|
120
|
-
children: /* @__PURE__ */ r(
|
|
121
|
-
|
|
121
|
+
children: /* @__PURE__ */ r(V, { ...t, timeout: 350, children: /* @__PURE__ */ s(
|
|
122
|
+
q,
|
|
122
123
|
{
|
|
123
124
|
variant: "outlined",
|
|
124
125
|
sx: {
|
|
@@ -128,7 +129,7 @@ function Te({
|
|
|
128
129
|
},
|
|
129
130
|
children: [
|
|
130
131
|
/* @__PURE__ */ r(
|
|
131
|
-
|
|
132
|
+
ne,
|
|
132
133
|
{
|
|
133
134
|
locale: u,
|
|
134
135
|
isBlocklet: l,
|
|
@@ -136,53 +137,53 @@ function Te({
|
|
|
136
137
|
onSwitchPassport: v,
|
|
137
138
|
onSwitchAccount: x,
|
|
138
139
|
onSwitchProfile: w,
|
|
139
|
-
onBindWallet:
|
|
140
|
+
onBindWallet: U
|
|
140
141
|
}
|
|
141
142
|
),
|
|
142
143
|
/* @__PURE__ */ r(S, { sx: { m: "0 !important" } }),
|
|
143
|
-
/* @__PURE__ */ s(
|
|
144
|
-
l ? /* @__PURE__ */ s(
|
|
145
|
-
/* @__PURE__ */ r(
|
|
144
|
+
/* @__PURE__ */ s(J, { sx: { p: 0 }, children: [
|
|
145
|
+
l ? /* @__PURE__ */ s(z, { children: [
|
|
146
|
+
/* @__PURE__ */ r(ae, { session: e, children: /* @__PURE__ */ r(
|
|
146
147
|
p,
|
|
147
148
|
{
|
|
148
|
-
icon:
|
|
149
|
+
icon: Z,
|
|
149
150
|
title: a("dashboard"),
|
|
150
151
|
component: "a",
|
|
151
|
-
href:
|
|
152
|
+
href: ce,
|
|
152
153
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
153
154
|
}
|
|
154
155
|
) }),
|
|
155
156
|
/* @__PURE__ */ r(
|
|
156
157
|
p,
|
|
157
158
|
{
|
|
158
|
-
icon:
|
|
159
|
+
icon: Y,
|
|
159
160
|
title: a("profile"),
|
|
160
161
|
component: "a",
|
|
161
|
-
href:
|
|
162
|
+
href: y,
|
|
162
163
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
163
164
|
}
|
|
164
165
|
),
|
|
165
|
-
|
|
166
|
+
L && /* @__PURE__ */ r(
|
|
166
167
|
p,
|
|
167
168
|
{
|
|
168
|
-
icon:
|
|
169
|
+
icon: ee,
|
|
169
170
|
title: a("invite"),
|
|
170
171
|
component: "div",
|
|
171
|
-
onClick:
|
|
172
|
+
onClick: F,
|
|
172
173
|
sx: { display: "block", color: "inherit" }
|
|
173
174
|
}
|
|
174
175
|
),
|
|
175
176
|
/* @__PURE__ */ r(S, { sx: { m: "0 !important" } }),
|
|
176
|
-
/* @__PURE__ */ r(
|
|
177
|
+
/* @__PURE__ */ r(ue, { session: e, locale: u })
|
|
177
178
|
] }) : null,
|
|
178
179
|
/* @__PURE__ */ r(
|
|
179
180
|
p,
|
|
180
181
|
{
|
|
181
|
-
icon:
|
|
182
|
+
icon: $,
|
|
182
183
|
title: a("logout"),
|
|
183
184
|
component: "div",
|
|
184
185
|
sx: { color: "error.main" },
|
|
185
|
-
onClick:
|
|
186
|
+
onClick: M,
|
|
186
187
|
"data-cy": "sessionManager-logout-trigger"
|
|
187
188
|
}
|
|
188
189
|
)
|
|
@@ -204,7 +205,7 @@ function p({
|
|
|
204
205
|
...l
|
|
205
206
|
}) {
|
|
206
207
|
return /* @__PURE__ */ r(k, { ...l, sx: { p: 0.5, ...l?.sx }, children: /* @__PURE__ */ s(
|
|
207
|
-
|
|
208
|
+
K,
|
|
208
209
|
{
|
|
209
210
|
sx: {
|
|
210
211
|
display: "flex",
|
|
@@ -217,12 +218,12 @@ function p({
|
|
|
217
218
|
py: 1
|
|
218
219
|
},
|
|
219
220
|
children: [
|
|
220
|
-
/* @__PURE__ */ r(
|
|
221
|
+
/* @__PURE__ */ r(X, { icon: e, fontSize: 24 }),
|
|
221
222
|
c
|
|
222
223
|
]
|
|
223
224
|
}
|
|
224
225
|
) });
|
|
225
226
|
}
|
|
226
227
|
export {
|
|
227
|
-
|
|
228
|
+
_e as default
|
|
228
229
|
};
|
|
@@ -5,5 +5,6 @@ export interface SessionUserProps {
|
|
|
5
5
|
locale?: Locale;
|
|
6
6
|
size?: number;
|
|
7
7
|
popperType?: 'hover' | 'click';
|
|
8
|
+
profileUrl?: string;
|
|
8
9
|
}
|
|
9
|
-
export default function SessionUser({ session, onBindWallet, locale, size, popperType, }: SessionUserProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export default function SessionUser({ session, onBindWallet, locale, size, popperType, profileUrl, }: SessionUserProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/SessionUser/index.js
CHANGED
|
@@ -1,28 +1,31 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useCreation as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import p from "lodash/noop";
|
|
3
|
+
import { useCreation as u } from "ahooks";
|
|
4
|
+
import l from "./components/logged-in.js";
|
|
5
|
+
import c from "./components/un-login.js";
|
|
6
|
+
import { PROFILE_URL as g } from "../Util/constant.js";
|
|
7
|
+
function d({
|
|
7
8
|
session: r,
|
|
8
|
-
onBindWallet:
|
|
9
|
+
onBindWallet: i = p,
|
|
9
10
|
locale: o = "en",
|
|
10
11
|
size: t = 24,
|
|
11
|
-
popperType:
|
|
12
|
+
popperType: n = "click",
|
|
13
|
+
profileUrl: e = g
|
|
12
14
|
}) {
|
|
13
|
-
const
|
|
14
|
-
return r.user ? /* @__PURE__ */
|
|
15
|
-
|
|
15
|
+
const f = u(() => !!globalThis?.blocklet, []);
|
|
16
|
+
return r.user ? /* @__PURE__ */ m(
|
|
17
|
+
l,
|
|
16
18
|
{
|
|
17
|
-
isBlocklet:
|
|
19
|
+
isBlocklet: f,
|
|
18
20
|
session: r,
|
|
19
|
-
onBindWallet:
|
|
21
|
+
onBindWallet: i,
|
|
20
22
|
locale: o,
|
|
21
23
|
size: t,
|
|
22
|
-
popperType:
|
|
24
|
+
popperType: n,
|
|
25
|
+
profileUrl: e
|
|
23
26
|
}
|
|
24
|
-
) : /* @__PURE__ */
|
|
27
|
+
) : /* @__PURE__ */ m(c, { session: r, locale: o, size: t });
|
|
25
28
|
}
|
|
26
29
|
export {
|
|
27
|
-
|
|
30
|
+
d as default
|
|
28
31
|
};
|
package/lib/package.json.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.6",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -68,16 +68,16 @@
|
|
|
68
68
|
"react": "^19.0.0",
|
|
69
69
|
"react-router-dom": "^6.22.3"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "ee100e9010a13a124962ce7ef38c8378c6deca9b",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@arcblock/bridge": "3.3.
|
|
73
|
+
"@arcblock/bridge": "3.3.6",
|
|
74
74
|
"@arcblock/did": "^1.27.16",
|
|
75
75
|
"@arcblock/did-motif": "^1.1.14",
|
|
76
|
-
"@arcblock/icons": "3.3.
|
|
77
|
-
"@arcblock/nft-display": "3.3.
|
|
78
|
-
"@arcblock/react-hooks": "3.3.
|
|
76
|
+
"@arcblock/icons": "3.3.6",
|
|
77
|
+
"@arcblock/nft-display": "3.3.6",
|
|
78
|
+
"@arcblock/react-hooks": "3.3.6",
|
|
79
79
|
"@blocklet/js-sdk": "^1.17.6",
|
|
80
|
-
"@blocklet/theme": "3.3.
|
|
80
|
+
"@blocklet/theme": "3.3.6",
|
|
81
81
|
"@fontsource/roboto": "~5.1.1",
|
|
82
82
|
"@fontsource/ubuntu-mono": "^5.2.6",
|
|
83
83
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -50,6 +50,7 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
50
50
|
locale?: Locale;
|
|
51
51
|
size?: number;
|
|
52
52
|
popperType?: 'hover' | 'click';
|
|
53
|
+
profileUrl?: string;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export default function LoggedIn({
|
|
@@ -59,6 +60,7 @@ export default function LoggedIn({
|
|
|
59
60
|
locale = 'en',
|
|
60
61
|
size = 24,
|
|
61
62
|
popperType = 'click',
|
|
63
|
+
profileUrl = PROFILE_URL,
|
|
62
64
|
sx,
|
|
63
65
|
...rest
|
|
64
66
|
}: LoggedInProps) {
|
|
@@ -243,7 +245,7 @@ export default function LoggedIn({
|
|
|
243
245
|
icon={PersonOutlineRoundedIcon}
|
|
244
246
|
title={t('profile')}
|
|
245
247
|
component="a"
|
|
246
|
-
href={
|
|
248
|
+
href={profileUrl}
|
|
247
249
|
sx={{ display: 'block', textDecoration: 'none', color: 'inherit' }}
|
|
248
250
|
/>
|
|
249
251
|
{isInviteEnabled && (
|
|
@@ -4,6 +4,7 @@ import { useCreation } from 'ahooks';
|
|
|
4
4
|
import LoggedIn from './components/logged-in';
|
|
5
5
|
import UnLogin from './components/un-login';
|
|
6
6
|
import type { Locale, Session } from '../type';
|
|
7
|
+
import { PROFILE_URL } from '../Util/constant';
|
|
7
8
|
|
|
8
9
|
export interface SessionUserProps {
|
|
9
10
|
session: Session;
|
|
@@ -11,6 +12,7 @@ export interface SessionUserProps {
|
|
|
11
12
|
locale?: Locale;
|
|
12
13
|
size?: number;
|
|
13
14
|
popperType?: 'hover' | 'click';
|
|
15
|
+
profileUrl?: string;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export default function SessionUser({
|
|
@@ -19,6 +21,7 @@ export default function SessionUser({
|
|
|
19
21
|
locale = 'en',
|
|
20
22
|
size = 24,
|
|
21
23
|
popperType = 'click',
|
|
24
|
+
profileUrl = PROFILE_URL,
|
|
22
25
|
}: SessionUserProps) {
|
|
23
26
|
const isBlocklet = useCreation(() => {
|
|
24
27
|
return !!globalThis?.blocklet;
|
|
@@ -33,6 +36,7 @@ export default function SessionUser({
|
|
|
33
36
|
locale={locale}
|
|
34
37
|
size={size}
|
|
35
38
|
popperType={popperType}
|
|
39
|
+
profileUrl={profileUrl}
|
|
36
40
|
/>
|
|
37
41
|
);
|
|
38
42
|
}
|