@arcblock/ux 3.4.10 → 3.4.12
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/DIDConnect/auth-apps/auth-apps-info.d.ts +2 -1
- package/lib/DIDConnect/auth-apps/auth-apps-info.js +7 -6
- package/lib/DIDConnect/auth-apps/index.d.ts +6 -2
- package/lib/DIDConnect/auth-apps/index.js +69 -65
- package/lib/SessionUser/components/logged-in.d.ts +3 -1
- package/lib/SessionUser/components/logged-in.js +132 -114
- package/lib/SessionUser/index.d.ts +20 -1
- package/lib/SessionUser/index.js +19 -17
- package/lib/package.json.js +1 -1
- package/package.json +9 -9
- package/src/DIDConnect/auth-apps/auth-apps-info.tsx +3 -1
- package/src/DIDConnect/auth-apps/index.tsx +13 -5
- package/src/SessionUser/components/logged-in.tsx +26 -2
- package/src/SessionUser/index.tsx +21 -0
|
@@ -8,7 +8,8 @@ export type CurrentAppInfo = {
|
|
|
8
8
|
appName: string;
|
|
9
9
|
appUrl: string;
|
|
10
10
|
};
|
|
11
|
-
export default function AuthAppsInfo({ requestAppInfo, currentAppInfo, }: {
|
|
11
|
+
export default function AuthAppsInfo({ requestAppInfo, currentAppInfo, titlePrefix, }: {
|
|
12
12
|
requestAppInfo: RequestAppInfo;
|
|
13
13
|
currentAppInfo: CurrentAppInfo;
|
|
14
|
+
titlePrefix?: string;
|
|
14
15
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsxs as r, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { Box as e, Typography as
|
|
2
|
+
import { Box as e, Typography as s } from "@mui/material";
|
|
3
3
|
import o from "../../Img/index.js";
|
|
4
|
-
function
|
|
4
|
+
function p({
|
|
5
5
|
requestAppInfo: a,
|
|
6
|
-
currentAppInfo: i
|
|
6
|
+
currentAppInfo: i,
|
|
7
|
+
titlePrefix: l = "Authorize"
|
|
7
8
|
}) {
|
|
8
9
|
return /* @__PURE__ */ r(
|
|
9
10
|
e,
|
|
@@ -53,14 +54,14 @@ function m({
|
|
|
53
54
|
}
|
|
54
55
|
),
|
|
55
56
|
/* @__PURE__ */ r(
|
|
56
|
-
|
|
57
|
+
s,
|
|
57
58
|
{
|
|
58
59
|
sx: {
|
|
59
60
|
mb: 1,
|
|
60
61
|
fontSize: "1.2rem"
|
|
61
62
|
},
|
|
62
63
|
children: [
|
|
63
|
-
|
|
64
|
+
l,
|
|
64
65
|
" ",
|
|
65
66
|
/* @__PURE__ */ t(e, { component: "span", sx: { color: "primary.main" }, children: a.appName })
|
|
66
67
|
]
|
|
@@ -71,5 +72,5 @@ function m({
|
|
|
71
72
|
);
|
|
72
73
|
}
|
|
73
74
|
export {
|
|
74
|
-
|
|
75
|
+
p as default
|
|
75
76
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BoxProps } from '@mui/material';
|
|
1
|
+
import { BoxProps, ButtonProps } from '@mui/material';
|
|
2
2
|
import { UserPublicInfo } from '@blocklet/js-sdk';
|
|
3
3
|
import { Ref } from 'react';
|
|
4
4
|
import { RequestAppInfo, CurrentAppInfo } from './auth-apps-info';
|
|
5
5
|
/**
|
|
6
6
|
* @example app/connect-to-did-space?appPid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appDid=zNKp8tdZUanWKnvhwZWvF2hKRutwM9ykLaY8&appName=233&appDescription=456&appUrl=https://bbqaw5mgxc6fnihrwqcejcxvukkdgkk4anwxwk5msvm.did.abtnet.io/zh
|
|
7
7
|
*/
|
|
8
|
-
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, hideButton, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onSwitchPassport, onCancel, ref, disableAuthorizeButton, }: {
|
|
8
|
+
export default function AuthApps({ session, requestAppInfo, currentAppInfo, children, userInfo, hideSwitchConnect, hideAuthorize, hideCancel, hideButton, notThisText, authorizeText, connectText, cancelText, useAnotherText, slotProps, onConnect, onAuthorize, onSwitchConnect, onSwitchPassport, onCancel, ref, disableAuthorizeButton, titlePrefix, }: {
|
|
9
9
|
session: any;
|
|
10
10
|
requestAppInfo: RequestAppInfo;
|
|
11
11
|
currentAppInfo: CurrentAppInfo;
|
|
@@ -24,6 +24,9 @@ export default function AuthApps({ session, requestAppInfo, currentAppInfo, chil
|
|
|
24
24
|
root?: BoxProps;
|
|
25
25
|
didConnectContainer?: object;
|
|
26
26
|
contentContainer?: BoxProps;
|
|
27
|
+
connectButton?: ButtonProps;
|
|
28
|
+
authorizeButton?: ButtonProps;
|
|
29
|
+
cancelButton?: ButtonProps;
|
|
27
30
|
};
|
|
28
31
|
onConnect?: (done: () => void) => void;
|
|
29
32
|
onAuthorize?: (done: () => void) => void;
|
|
@@ -34,4 +37,5 @@ export default function AuthApps({ session, requestAppInfo, currentAppInfo, chil
|
|
|
34
37
|
closeLoading: () => void;
|
|
35
38
|
}>;
|
|
36
39
|
disableAuthorizeButton?: boolean;
|
|
40
|
+
titlePrefix?: string;
|
|
37
41
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import { CircularProgress as u, Box as d, Stack as
|
|
3
|
-
import { useReactive as
|
|
1
|
+
import { jsx as e, jsxs as t, Fragment as p } from "react/jsx-runtime";
|
|
2
|
+
import { CircularProgress as u, Box as d, Stack as K, Button as h, Typography as O, Link as Q } from "@mui/material";
|
|
3
|
+
import { useReactive as V, useMemoizedFn as i } from "ahooks";
|
|
4
4
|
import c from "lodash/noop";
|
|
5
|
-
import { useImperativeHandle as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { translate as
|
|
11
|
-
import { useLocaleContext as
|
|
12
|
-
import
|
|
13
|
-
import { InfoType as
|
|
5
|
+
import { useImperativeHandle as X } from "react";
|
|
6
|
+
import Y from "../did-connect-container.js";
|
|
7
|
+
import Z from "./auth-apps-info.js";
|
|
8
|
+
import _ from "../../Center/index.js";
|
|
9
|
+
import $ from "../landing-page.js";
|
|
10
|
+
import { translate as P } from "../../Locale/util.js";
|
|
11
|
+
import { useLocaleContext as ee } from "../../Locale/context.js";
|
|
12
|
+
import ne from "../../UserCard/index.js";
|
|
13
|
+
import { InfoType as oe, CardType as te } from "../../UserCard/types.js";
|
|
14
14
|
import { mergeSx as f } from "../../Util/style.js";
|
|
15
|
-
import
|
|
16
|
-
const
|
|
15
|
+
import ie from "./switch-role.js";
|
|
16
|
+
const re = {
|
|
17
17
|
en: {
|
|
18
18
|
notThis: "Not you?",
|
|
19
19
|
useAnother: "Use another account",
|
|
@@ -29,7 +29,7 @@ const ie = {
|
|
|
29
29
|
cancel: "取消"
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
function
|
|
32
|
+
function ze({
|
|
33
33
|
session: s,
|
|
34
34
|
requestAppInfo: g,
|
|
35
35
|
currentAppInfo: x,
|
|
@@ -43,51 +43,52 @@ function ye({
|
|
|
43
43
|
authorizeText: b = void 0,
|
|
44
44
|
connectText: k = void 0,
|
|
45
45
|
cancelText: S = void 0,
|
|
46
|
-
useAnotherText:
|
|
47
|
-
slotProps:
|
|
48
|
-
onConnect:
|
|
49
|
-
onAuthorize:
|
|
50
|
-
onSwitchConnect:
|
|
51
|
-
onSwitchPassport:
|
|
52
|
-
onCancel:
|
|
53
|
-
ref:
|
|
54
|
-
disableAuthorizeButton: m = !1
|
|
46
|
+
useAnotherText: B = void 0,
|
|
47
|
+
slotProps: o = void 0,
|
|
48
|
+
onConnect: D = c,
|
|
49
|
+
onAuthorize: I = c,
|
|
50
|
+
onSwitchConnect: L = c,
|
|
51
|
+
onSwitchPassport: R = c,
|
|
52
|
+
onCancel: W = c,
|
|
53
|
+
ref: j,
|
|
54
|
+
disableAuthorizeButton: m = !1,
|
|
55
|
+
titlePrefix: F = void 0
|
|
55
56
|
}) {
|
|
56
|
-
const n =
|
|
57
|
+
const n = V({
|
|
57
58
|
loading: !1
|
|
58
|
-
}), { locale:
|
|
59
|
+
}), { locale: M = "en" } = ee() || {}, r = i((G, J = {}) => P(re, G, M, "en", J)), l = i(() => {
|
|
59
60
|
n.loading = !1;
|
|
60
|
-
}),
|
|
61
|
+
}), U = i(() => {
|
|
62
|
+
n.loading = !0, D?.(l);
|
|
63
|
+
}), H = i(() => {
|
|
64
|
+
n.loading = !0, L?.(l);
|
|
65
|
+
}), N = i(() => {
|
|
61
66
|
n.loading = !0, I?.(l);
|
|
62
|
-
}),
|
|
67
|
+
}), q = i(() => {
|
|
63
68
|
n.loading = !0, R?.(l);
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
}), N = r(() => {
|
|
67
|
-
n.loading = !0, W?.(l);
|
|
68
|
-
}), P = r(() => {
|
|
69
|
-
j?.();
|
|
69
|
+
}), E = i(() => {
|
|
70
|
+
W?.();
|
|
70
71
|
});
|
|
71
|
-
if (
|
|
72
|
+
if (X(j, () => ({
|
|
72
73
|
closeLoading: l
|
|
73
74
|
})), s.loading || !s.initialized)
|
|
74
|
-
return /* @__PURE__ */ e(
|
|
75
|
+
return /* @__PURE__ */ e(_, { children: /* @__PURE__ */ e(u, {}) });
|
|
75
76
|
const a = v ?? s?.user;
|
|
76
|
-
return /* @__PURE__ */ e(
|
|
77
|
+
return /* @__PURE__ */ e($, { did: window.blocklet?.appPid, standalone: !0, children: /* @__PURE__ */ e(
|
|
77
78
|
d,
|
|
78
79
|
{
|
|
79
|
-
...
|
|
80
|
+
...o?.root,
|
|
80
81
|
sx: f(
|
|
81
82
|
{
|
|
82
83
|
width: 420,
|
|
83
84
|
maxWidth: "100%"
|
|
84
85
|
},
|
|
85
|
-
|
|
86
|
+
o?.root?.sx
|
|
86
87
|
),
|
|
87
|
-
children: /* @__PURE__ */ e(
|
|
88
|
+
children: /* @__PURE__ */ e(Y, { hideCloseButton: !0, ...o?.didConnectContainer, children: /* @__PURE__ */ t(
|
|
88
89
|
d,
|
|
89
90
|
{
|
|
90
|
-
...
|
|
91
|
+
...o?.contentContainer,
|
|
91
92
|
sx: f(
|
|
92
93
|
{
|
|
93
94
|
display: "flex",
|
|
@@ -104,25 +105,25 @@ function ye({
|
|
|
104
105
|
},
|
|
105
106
|
bgcolor: "background.paper"
|
|
106
107
|
},
|
|
107
|
-
|
|
108
|
+
o?.contentContainer?.sx
|
|
108
109
|
),
|
|
109
110
|
children: [
|
|
110
|
-
/* @__PURE__ */ e(
|
|
111
|
-
a ? /* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ e(Z, { requestAppInfo: g, currentAppInfo: x, titlePrefix: F }),
|
|
112
|
+
a ? /* @__PURE__ */ t(p, { children: [
|
|
112
113
|
/* @__PURE__ */ e(
|
|
113
|
-
|
|
114
|
+
ne,
|
|
114
115
|
{
|
|
115
116
|
user: a,
|
|
116
117
|
showDid: !0,
|
|
117
|
-
cardType:
|
|
118
|
-
infoType:
|
|
119
|
-
renderTopRightContent: () => /* @__PURE__ */ e(
|
|
118
|
+
cardType: te.Detailed,
|
|
119
|
+
infoType: oe.Minimal,
|
|
120
|
+
renderTopRightContent: () => /* @__PURE__ */ e(ie, { user: a, switchPassport: q })
|
|
120
121
|
}
|
|
121
122
|
),
|
|
122
123
|
/* @__PURE__ */ e(d, {})
|
|
123
124
|
] }) : null,
|
|
124
125
|
C,
|
|
125
|
-
A ? null : /* @__PURE__ */
|
|
126
|
+
A ? null : /* @__PURE__ */ t(p, { children: [
|
|
126
127
|
/* @__PURE__ */ e(
|
|
127
128
|
d,
|
|
128
129
|
{
|
|
@@ -135,7 +136,7 @@ function ye({
|
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
138
|
),
|
|
138
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ t(K, { direction: "row", spacing: 2, children: [
|
|
139
140
|
w ? null : /* @__PURE__ */ e(
|
|
140
141
|
h,
|
|
141
142
|
{
|
|
@@ -143,44 +144,47 @@ function ye({
|
|
|
143
144
|
variant: "outlined",
|
|
144
145
|
size: "large",
|
|
145
146
|
fullWidth: !0,
|
|
146
|
-
onClick:
|
|
147
|
+
onClick: E,
|
|
147
148
|
sx: {
|
|
148
149
|
color: "grey.500"
|
|
149
150
|
},
|
|
150
|
-
|
|
151
|
+
...o?.cancelButton,
|
|
152
|
+
children: S || r("cancel")
|
|
151
153
|
}
|
|
152
154
|
),
|
|
153
|
-
a && !z ? /* @__PURE__ */
|
|
155
|
+
a && !z ? /* @__PURE__ */ t(
|
|
154
156
|
h,
|
|
155
157
|
{
|
|
156
158
|
variant: "contained",
|
|
157
159
|
size: "large",
|
|
158
160
|
fullWidth: !0,
|
|
159
|
-
onClick:
|
|
161
|
+
onClick: N,
|
|
160
162
|
disabled: n.loading || m,
|
|
163
|
+
...o?.authorizeButton,
|
|
161
164
|
children: [
|
|
162
165
|
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
|
163
|
-
b ||
|
|
166
|
+
b || r("authorize")
|
|
164
167
|
]
|
|
165
168
|
}
|
|
166
|
-
) : /* @__PURE__ */
|
|
169
|
+
) : /* @__PURE__ */ t(
|
|
167
170
|
h,
|
|
168
171
|
{
|
|
169
172
|
variant: "contained",
|
|
170
173
|
size: "large",
|
|
171
174
|
fullWidth: !0,
|
|
172
175
|
disabled: n.loading || m,
|
|
173
|
-
onClick:
|
|
176
|
+
onClick: U,
|
|
177
|
+
...o?.connectButton,
|
|
174
178
|
children: [
|
|
175
179
|
n.loading ? /* @__PURE__ */ e(u, { size: 20, sx: { mr: 1 } }) : null,
|
|
176
|
-
k ||
|
|
180
|
+
k || r("connect")
|
|
177
181
|
]
|
|
178
182
|
}
|
|
179
183
|
)
|
|
180
184
|
] })
|
|
181
185
|
] }),
|
|
182
|
-
y || !a ? null : /* @__PURE__ */ e(d, { sx: { textAlign: "center" }, children: /* @__PURE__ */
|
|
183
|
-
|
|
186
|
+
y || !a ? null : /* @__PURE__ */ e(d, { sx: { textAlign: "center" }, children: /* @__PURE__ */ t(
|
|
187
|
+
O,
|
|
184
188
|
{
|
|
185
189
|
variant: "body2",
|
|
186
190
|
sx: {
|
|
@@ -190,17 +194,17 @@ function ye({
|
|
|
190
194
|
gap: 1
|
|
191
195
|
},
|
|
192
196
|
children: [
|
|
193
|
-
T ||
|
|
197
|
+
T || r("notThis"),
|
|
194
198
|
" ",
|
|
195
199
|
/* @__PURE__ */ e(
|
|
196
|
-
|
|
200
|
+
Q,
|
|
197
201
|
{
|
|
198
202
|
underline: "hover",
|
|
199
|
-
onClick:
|
|
203
|
+
onClick: H,
|
|
200
204
|
sx: {
|
|
201
205
|
cursor: "pointer"
|
|
202
206
|
},
|
|
203
|
-
children:
|
|
207
|
+
children: B || r("useAnother")
|
|
204
208
|
}
|
|
205
209
|
)
|
|
206
210
|
]
|
|
@@ -213,5 +217,5 @@ function ye({
|
|
|
213
217
|
) });
|
|
214
218
|
}
|
|
215
219
|
export {
|
|
216
|
-
|
|
220
|
+
ze as default
|
|
217
221
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BoxProps } from '@mui/material';
|
|
2
2
|
import { Locale, Session } from '../../type';
|
|
3
|
+
import { SessionUserProps } from '..';
|
|
3
4
|
export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter' | 'onMouseLeave'> {
|
|
4
5
|
session: Session;
|
|
5
6
|
onBindWallet?: () => void;
|
|
@@ -9,5 +10,6 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
9
10
|
popperType?: 'hover' | 'click';
|
|
10
11
|
profileUrl?: string;
|
|
11
12
|
mode?: 'minimal' | 'normal';
|
|
13
|
+
renderUserButton: SessionUserProps['renderUserButton'];
|
|
12
14
|
}
|
|
13
|
-
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, profileUrl, mode, sx, ...rest }: LoggedInProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export default function LoggedIn({ session, onBindWallet, isBlocklet, locale, size, popperType, profileUrl, mode, sx, renderUserButton, ...rest }: LoggedInProps): string | number | bigint | boolean | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -1,126 +1,144 @@
|
|
|
1
1
|
import { jsxs as s, jsx as r, Fragment as T } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useMemoizedFn as n, useCreation as
|
|
4
|
-
import
|
|
5
|
-
import { Box as
|
|
6
|
-
import { Icon as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
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
|
|
2
|
+
import { useRef as G, useEffect as H } from "react";
|
|
3
|
+
import { useMemoizedFn as n, useCreation as N, useReactive as Q } from "ahooks";
|
|
4
|
+
import v from "@arcblock/bridge";
|
|
5
|
+
import { Box as M, IconButton as V, Popper as q, ClickAwayListener as J, Fade as K, Paper as X, Divider as B, MenuList as Y, MenuItem as Z } from "@mui/material";
|
|
6
|
+
import { Icon as $ } from "@iconify/react";
|
|
7
|
+
import ee from "@iconify-icons/material-symbols/person-outline-rounded";
|
|
8
|
+
import re from "@iconify-icons/material-symbols/filter-vintage-outline-rounded";
|
|
9
|
+
import te from "@iconify-icons/material-symbols/account-circle-off-outline-rounded";
|
|
10
|
+
import oe from "@iconify-icons/material-symbols/featured-seasonal-and-gifts-rounded";
|
|
11
|
+
import ie from "copy-to-clipboard";
|
|
12
|
+
import x from "lodash/noop";
|
|
13
|
+
import ne from "../../Toast/index.js";
|
|
14
|
+
import ce from "../../Avatar/index.js";
|
|
15
|
+
import { getUserAvatar as ae } from "../../Util/index.js";
|
|
16
|
+
import le from "./user-info.js";
|
|
17
|
+
import { DASHBOARD_URL as E, PROFILE_URL as se } from "../../Util/constant.js";
|
|
18
|
+
import pe from "../../SessionPermission/index.js";
|
|
19
|
+
import { translations as ue } from "../libs/translation.js";
|
|
20
|
+
import { translate as de } from "../../Locale/util.js";
|
|
21
|
+
import me from "./did-space.js";
|
|
22
|
+
import { mergeSx as fe } from "../../Util/style.js";
|
|
23
|
+
import { createDebug as he } from "../../Util/logger.js";
|
|
24
|
+
import { GA_LAST_ROLE as ge } from "../../withTracker/constant/index.js";
|
|
25
|
+
const Pe = (e) => {
|
|
26
26
|
const c = new URL(window.location.href);
|
|
27
27
|
return c.searchParams.set("inviter", e), c.toString();
|
|
28
|
-
},
|
|
29
|
-
function
|
|
28
|
+
}, w = he("did-connect");
|
|
29
|
+
function Ge({
|
|
30
30
|
session: e,
|
|
31
|
-
onBindWallet: c =
|
|
32
|
-
isBlocklet:
|
|
33
|
-
locale:
|
|
34
|
-
size:
|
|
35
|
-
popperType:
|
|
36
|
-
profileUrl:
|
|
37
|
-
mode:
|
|
38
|
-
sx:
|
|
39
|
-
|
|
31
|
+
onBindWallet: c = x,
|
|
32
|
+
isBlocklet: a = !0,
|
|
33
|
+
locale: p = "en",
|
|
34
|
+
size: A = 24,
|
|
35
|
+
popperType: S = "click",
|
|
36
|
+
profileUrl: b = se,
|
|
37
|
+
mode: d = "normal",
|
|
38
|
+
sx: U,
|
|
39
|
+
renderUserButton: k,
|
|
40
|
+
...F
|
|
40
41
|
}) {
|
|
41
|
-
const
|
|
42
|
+
const l = n((t, o = {}) => de(ue, t, p, "en", o)), I = N(() => !!globalThis?.blocklet?.settings?.invite?.enabled, []), y = G(null), m = Q({
|
|
42
43
|
open: !1
|
|
43
|
-
}), i = n((t = !
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
localStorage.setItem(
|
|
44
|
+
}), i = n((t = !m.open) => {
|
|
45
|
+
m.open = t;
|
|
46
|
+
}), W = S === "hover" ? { onMouseEnter: () => i(!0), onMouseLeave: () => i(!1) } : { onClick: () => i() }, R = ae(e.user?.avatar?.replace(/\s/g, encodeURIComponent(" "))), _ = e.useOAuth(), j = typeof e.usePasskey == "function" ? e.usePasskey() : null, f = n(({ inArcSphere: t = !1 } = {}) => {
|
|
47
|
+
localStorage.setItem(ge, e?.user?.role);
|
|
47
48
|
const o = {};
|
|
48
|
-
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ?
|
|
49
|
-
}),
|
|
50
|
-
const
|
|
51
|
-
o && e.user.sourceAppPid && (
|
|
52
|
-
const
|
|
53
|
-
t ?
|
|
49
|
+
t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ? j.switchPassport(e.user) : ["google", "apple", "email", "github"].includes(e?.user?.sourceProvider) ? _.switchOAuthPassport(e.user) : e.switchPassport(x, o);
|
|
50
|
+
}), h = n(({ userSession: t, inArcSphere: o = !1 } = {}) => new Promise((z) => {
|
|
51
|
+
const O = {};
|
|
52
|
+
o && e.user.sourceAppPid && (O.sourceAppPid = e.user.sourceAppPid);
|
|
53
|
+
const P = {};
|
|
54
|
+
t ? P.userSession = t : (i(!1), P.showQuickConnect = !1), e.switchDid(
|
|
54
55
|
() => {
|
|
55
56
|
i(!1), z();
|
|
56
57
|
},
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
O,
|
|
59
|
+
P
|
|
59
60
|
);
|
|
60
|
-
})),
|
|
61
|
+
})), g = n(({ inArcSphere: t = !1 } = {}) => {
|
|
61
62
|
const o = {};
|
|
62
|
-
t && e.user.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e.switchProfile(
|
|
63
|
-
}),
|
|
63
|
+
t && e.user.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e.switchProfile(x, o);
|
|
64
|
+
}), C = n(() => {
|
|
64
65
|
i(!1), e.logout();
|
|
65
|
-
}),
|
|
66
|
+
}), L = n(() => {
|
|
66
67
|
i(!1), e.bindWallet(c);
|
|
67
|
-
}),
|
|
68
|
+
}), D = n(() => {
|
|
68
69
|
i(!1);
|
|
69
|
-
const t =
|
|
70
|
-
|
|
70
|
+
const t = Pe(e.user.did);
|
|
71
|
+
ie(t), ne.success(l("inviteCopied"));
|
|
71
72
|
});
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
|
|
77
|
-
}),
|
|
78
|
-
|
|
73
|
+
return H(() => {
|
|
74
|
+
v.registerBlocklet("callSwitchPassport", () => {
|
|
75
|
+
w("bridge registerBlocklet: callSwitchPassport"), f({ inArcSphere: !0 });
|
|
76
|
+
}), v.registerBlocklet("callSwitchDid", () => {
|
|
77
|
+
w("bridge registerBlocklet: callSwitchDid"), h({ inArcSphere: !0 });
|
|
78
|
+
}), v.registerBlocklet("callSwitchProfile", () => {
|
|
79
|
+
w("bridge registerBlocklet: callSwitchProfile"), g({ inArcSphere: !0 });
|
|
79
80
|
});
|
|
80
|
-
}, []),
|
|
81
|
-
|
|
81
|
+
}, []), k ? k({
|
|
82
|
+
isBlocklet: a,
|
|
83
|
+
session: e,
|
|
84
|
+
locale: p,
|
|
85
|
+
size: A,
|
|
86
|
+
popperType: S,
|
|
87
|
+
profileUrl: b,
|
|
88
|
+
dashboardUrl: E,
|
|
89
|
+
mode: d,
|
|
90
|
+
avatar: R,
|
|
91
|
+
isInviteEnabled: I,
|
|
92
|
+
handleSwitchPassport: f,
|
|
93
|
+
handleSwitchAccount: h,
|
|
94
|
+
handleSwitchProfile: g,
|
|
95
|
+
handleBindWallet: L,
|
|
96
|
+
handleOpenInvite: D,
|
|
97
|
+
handleLogout: C
|
|
98
|
+
}) : /* @__PURE__ */ s(
|
|
99
|
+
M,
|
|
82
100
|
{
|
|
83
|
-
sx:
|
|
101
|
+
sx: fe(
|
|
84
102
|
{
|
|
85
103
|
display: "inline-flex",
|
|
86
104
|
alignItems: "center",
|
|
87
105
|
justifyContent: "center"
|
|
88
106
|
},
|
|
89
107
|
// @ts-ignore
|
|
90
|
-
|
|
108
|
+
U
|
|
91
109
|
),
|
|
92
|
-
...
|
|
110
|
+
...F,
|
|
93
111
|
children: [
|
|
94
112
|
/* @__PURE__ */ r(
|
|
95
|
-
|
|
113
|
+
V,
|
|
96
114
|
{
|
|
97
|
-
ref:
|
|
115
|
+
ref: y,
|
|
98
116
|
size: "medium",
|
|
99
117
|
"data-cy": "sessionManager-logout-popup",
|
|
100
118
|
className: "arc-session-user-logged-in",
|
|
101
119
|
"aria-label": "User info button",
|
|
102
|
-
...
|
|
103
|
-
children: /* @__PURE__ */ r(
|
|
120
|
+
...W,
|
|
121
|
+
children: /* @__PURE__ */ r(ce, { variant: "circle", did: e.user.did, src: R, size: A, shape: "circle" })
|
|
104
122
|
}
|
|
105
123
|
),
|
|
106
124
|
/* @__PURE__ */ r(
|
|
107
|
-
|
|
125
|
+
q,
|
|
108
126
|
{
|
|
109
|
-
open:
|
|
110
|
-
anchorEl:
|
|
127
|
+
open: m.open,
|
|
128
|
+
anchorEl: y.current,
|
|
111
129
|
transition: !0,
|
|
112
130
|
placement: "bottom-end",
|
|
113
131
|
sx: {
|
|
114
132
|
zIndex: 1600
|
|
115
133
|
},
|
|
116
134
|
children: ({ TransitionProps: t }) => /* @__PURE__ */ r(
|
|
117
|
-
|
|
135
|
+
J,
|
|
118
136
|
{
|
|
119
137
|
onClickAway: (o) => {
|
|
120
138
|
o.preventDefault(), o.stopPropagation(), i(!1);
|
|
121
139
|
},
|
|
122
|
-
children: /* @__PURE__ */ r(
|
|
123
|
-
|
|
140
|
+
children: /* @__PURE__ */ r(K, { ...t, timeout: 350, children: /* @__PURE__ */ s(
|
|
141
|
+
X,
|
|
124
142
|
{
|
|
125
143
|
variant: "outlined",
|
|
126
144
|
sx: {
|
|
@@ -130,62 +148,62 @@ function je({
|
|
|
130
148
|
},
|
|
131
149
|
children: [
|
|
132
150
|
/* @__PURE__ */ r(
|
|
133
|
-
|
|
151
|
+
le,
|
|
134
152
|
{
|
|
135
|
-
locale:
|
|
136
|
-
isBlocklet:
|
|
153
|
+
locale: p,
|
|
154
|
+
isBlocklet: a,
|
|
137
155
|
session: e,
|
|
138
|
-
onSwitchPassport:
|
|
139
|
-
onSwitchAccount:
|
|
140
|
-
onSwitchProfile:
|
|
141
|
-
onBindWallet:
|
|
142
|
-
mode:
|
|
156
|
+
onSwitchPassport: f,
|
|
157
|
+
onSwitchAccount: h,
|
|
158
|
+
onSwitchProfile: g,
|
|
159
|
+
onBindWallet: L,
|
|
160
|
+
mode: d
|
|
143
161
|
}
|
|
144
162
|
),
|
|
145
|
-
/* @__PURE__ */ r(
|
|
146
|
-
/* @__PURE__ */ s(
|
|
147
|
-
|
|
148
|
-
/* @__PURE__ */ r(
|
|
149
|
-
|
|
163
|
+
/* @__PURE__ */ r(B, { sx: { m: "0 !important" } }),
|
|
164
|
+
/* @__PURE__ */ s(Y, { sx: { p: 0 }, children: [
|
|
165
|
+
a ? /* @__PURE__ */ s(T, { children: [
|
|
166
|
+
/* @__PURE__ */ r(pe, { session: e, children: /* @__PURE__ */ r(
|
|
167
|
+
u,
|
|
150
168
|
{
|
|
151
|
-
icon:
|
|
152
|
-
title:
|
|
169
|
+
icon: re,
|
|
170
|
+
title: l("dashboard"),
|
|
153
171
|
component: "a",
|
|
154
|
-
href:
|
|
172
|
+
href: E,
|
|
155
173
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
156
174
|
}
|
|
157
175
|
) }),
|
|
158
176
|
/* @__PURE__ */ r(
|
|
159
|
-
|
|
177
|
+
u,
|
|
160
178
|
{
|
|
161
|
-
icon:
|
|
162
|
-
title:
|
|
179
|
+
icon: ee,
|
|
180
|
+
title: l("profile"),
|
|
163
181
|
component: "a",
|
|
164
|
-
href:
|
|
182
|
+
href: b,
|
|
165
183
|
sx: { display: "block", textDecoration: "none", color: "inherit" }
|
|
166
184
|
}
|
|
167
185
|
),
|
|
168
|
-
|
|
169
|
-
|
|
186
|
+
I && /* @__PURE__ */ r(
|
|
187
|
+
u,
|
|
170
188
|
{
|
|
171
|
-
icon:
|
|
172
|
-
title:
|
|
189
|
+
icon: oe,
|
|
190
|
+
title: l("invite"),
|
|
173
191
|
component: "div",
|
|
174
|
-
onClick:
|
|
192
|
+
onClick: D,
|
|
175
193
|
sx: { display: "block", color: "inherit" }
|
|
176
194
|
}
|
|
177
195
|
),
|
|
178
|
-
/* @__PURE__ */ r(
|
|
179
|
-
|
|
196
|
+
/* @__PURE__ */ r(B, { sx: { m: "0 !important" } }),
|
|
197
|
+
d === "normal" ? /* @__PURE__ */ r(me, { session: e, locale: p }) : null
|
|
180
198
|
] }) : null,
|
|
181
199
|
/* @__PURE__ */ r(
|
|
182
|
-
|
|
200
|
+
u,
|
|
183
201
|
{
|
|
184
|
-
icon:
|
|
185
|
-
title:
|
|
202
|
+
icon: te,
|
|
203
|
+
title: l("logout"),
|
|
186
204
|
component: "div",
|
|
187
205
|
sx: { color: "error.main" },
|
|
188
|
-
onClick:
|
|
206
|
+
onClick: C,
|
|
189
207
|
"data-cy": "sessionManager-logout-trigger"
|
|
190
208
|
}
|
|
191
209
|
)
|
|
@@ -201,13 +219,13 @@ function je({
|
|
|
201
219
|
}
|
|
202
220
|
);
|
|
203
221
|
}
|
|
204
|
-
function
|
|
222
|
+
function u({
|
|
205
223
|
icon: e,
|
|
206
224
|
title: c,
|
|
207
|
-
...
|
|
225
|
+
...a
|
|
208
226
|
}) {
|
|
209
|
-
return /* @__PURE__ */ r(
|
|
210
|
-
|
|
227
|
+
return /* @__PURE__ */ r(M, { ...a, sx: { p: 0.5, ...a?.sx }, children: /* @__PURE__ */ s(
|
|
228
|
+
Z,
|
|
211
229
|
{
|
|
212
230
|
sx: {
|
|
213
231
|
display: "flex",
|
|
@@ -220,12 +238,12 @@ function p({
|
|
|
220
238
|
py: 1
|
|
221
239
|
},
|
|
222
240
|
children: [
|
|
223
|
-
/* @__PURE__ */ r(
|
|
241
|
+
/* @__PURE__ */ r($, { icon: e, fontSize: 24 }),
|
|
224
242
|
c
|
|
225
243
|
]
|
|
226
244
|
}
|
|
227
245
|
) });
|
|
228
246
|
}
|
|
229
247
|
export {
|
|
230
|
-
|
|
248
|
+
Ge as default
|
|
231
249
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { Locale, Session } from '../type';
|
|
2
3
|
export interface SessionUserProps {
|
|
3
4
|
session: Session;
|
|
@@ -6,5 +7,23 @@ export interface SessionUserProps {
|
|
|
6
7
|
size?: number;
|
|
7
8
|
popperType?: 'hover' | 'click';
|
|
8
9
|
profileUrl?: string;
|
|
10
|
+
renderUserButton?: (props: {
|
|
11
|
+
isBlocklet: boolean;
|
|
12
|
+
session: Session;
|
|
13
|
+
locale: Locale;
|
|
14
|
+
size: number;
|
|
15
|
+
popperType: 'hover' | 'click';
|
|
16
|
+
profileUrl?: string;
|
|
17
|
+
dashboardUrl?: string;
|
|
18
|
+
mode?: any;
|
|
19
|
+
avatar: string;
|
|
20
|
+
isInviteEnabled: boolean;
|
|
21
|
+
handleSwitchPassport: () => void;
|
|
22
|
+
handleSwitchAccount: () => void;
|
|
23
|
+
handleSwitchProfile: () => void;
|
|
24
|
+
handleBindWallet: () => void;
|
|
25
|
+
handleOpenInvite: () => void;
|
|
26
|
+
handleLogout: () => void;
|
|
27
|
+
}) => ReactNode;
|
|
9
28
|
}
|
|
10
|
-
export default function SessionUser({ session, onBindWallet, locale, size, popperType, profileUrl, }: SessionUserProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export default function SessionUser({ session, onBindWallet, locale, size, popperType, profileUrl, renderUserButton, }: SessionUserProps): import("react/jsx-runtime").JSX.Element;
|
package/lib/SessionUser/index.js
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useCreation as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { PROFILE_URL as
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import c from "lodash/noop";
|
|
3
|
+
import { useCreation as u } from "ahooks";
|
|
4
|
+
import g from "./components/logged-in.js";
|
|
5
|
+
import s from "./components/un-login.js";
|
|
6
|
+
import { PROFILE_URL as S } from "../Util/constant.js";
|
|
7
7
|
function U({
|
|
8
8
|
session: o,
|
|
9
|
-
onBindWallet:
|
|
9
|
+
onBindWallet: m = c,
|
|
10
10
|
locale: r = "en",
|
|
11
11
|
size: t = 24,
|
|
12
|
-
popperType:
|
|
13
|
-
profileUrl: n =
|
|
12
|
+
popperType: e = "click",
|
|
13
|
+
profileUrl: n = S,
|
|
14
|
+
renderUserButton: l = void 0
|
|
14
15
|
}) {
|
|
15
|
-
const
|
|
16
|
-
return o.user ? /* @__PURE__ */
|
|
17
|
-
|
|
16
|
+
const f = u(() => !!globalThis?.blocklet, []), p = globalThis?.blocklet?.SESSION_USER_MODE;
|
|
17
|
+
return o.user ? /* @__PURE__ */ i(
|
|
18
|
+
g,
|
|
18
19
|
{
|
|
19
|
-
isBlocklet:
|
|
20
|
+
isBlocklet: f,
|
|
20
21
|
session: o,
|
|
21
|
-
onBindWallet:
|
|
22
|
+
onBindWallet: m,
|
|
22
23
|
locale: r,
|
|
23
24
|
size: t,
|
|
24
|
-
popperType:
|
|
25
|
+
popperType: e,
|
|
25
26
|
profileUrl: n,
|
|
26
|
-
mode:
|
|
27
|
+
mode: p,
|
|
28
|
+
renderUserButton: l
|
|
27
29
|
}
|
|
28
|
-
) : /* @__PURE__ */
|
|
30
|
+
) : /* @__PURE__ */ i(s, { session: o, locale: r, size: t });
|
|
29
31
|
}
|
|
30
32
|
export {
|
|
31
33
|
U as default
|
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.12",
|
|
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": "db4d4378824b5ad63613d8165f1cf3bb76ea5f75",
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"@arcblock/bridge": "3.4.
|
|
80
|
-
"@arcblock/did": "^1.28.
|
|
79
|
+
"@arcblock/bridge": "3.4.12",
|
|
80
|
+
"@arcblock/did": "^1.28.8",
|
|
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.12",
|
|
83
|
+
"@arcblock/nft-display": "3.4.12",
|
|
84
|
+
"@arcblock/react-hooks": "3.4.12",
|
|
85
85
|
"@blocklet/js-sdk": "^1.17.7",
|
|
86
|
-
"@blocklet/theme": "3.4.
|
|
86
|
+
"@blocklet/theme": "3.4.12",
|
|
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.8",
|
|
95
95
|
"@solana/qr-code-styling": "^1.6.0",
|
|
96
96
|
"@types/dompurify": "^3.2.0",
|
|
97
97
|
"@types/mui-datatables": "^4.3.12",
|
|
@@ -16,9 +16,11 @@ export type CurrentAppInfo = {
|
|
|
16
16
|
export default function AuthAppsInfo({
|
|
17
17
|
requestAppInfo,
|
|
18
18
|
currentAppInfo,
|
|
19
|
+
titlePrefix = 'Authorize',
|
|
19
20
|
}: {
|
|
20
21
|
requestAppInfo: RequestAppInfo;
|
|
21
22
|
currentAppInfo: CurrentAppInfo;
|
|
23
|
+
titlePrefix?: string;
|
|
22
24
|
}) {
|
|
23
25
|
return (
|
|
24
26
|
<Box
|
|
@@ -65,7 +67,7 @@ export default function AuthAppsInfo({
|
|
|
65
67
|
mb: 1,
|
|
66
68
|
fontSize: '1.2rem',
|
|
67
69
|
}}>
|
|
68
|
-
|
|
70
|
+
{titlePrefix}{' '}
|
|
69
71
|
<Box component="span" sx={{ color: 'primary.main' }}>
|
|
70
72
|
{requestAppInfo.appName}
|
|
71
73
|
</Box>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Box, BoxProps, Button, CircularProgress, Link, Stack, SxProps, Typography } from '@mui/material';
|
|
1
|
+
import { Box, BoxProps, Button, ButtonProps, CircularProgress, Link, Stack, SxProps, Typography } from '@mui/material';
|
|
2
2
|
import { useMemoizedFn, useReactive } from 'ahooks';
|
|
3
3
|
import noop from 'lodash/noop';
|
|
4
4
|
import type { UserPublicInfo } from '@blocklet/js-sdk';
|
|
@@ -63,6 +63,7 @@ export default function AuthApps({
|
|
|
63
63
|
ref,
|
|
64
64
|
|
|
65
65
|
disableAuthorizeButton = false,
|
|
66
|
+
titlePrefix = undefined,
|
|
66
67
|
}: {
|
|
67
68
|
session: any;
|
|
68
69
|
requestAppInfo: RequestAppInfo;
|
|
@@ -85,6 +86,9 @@ export default function AuthApps({
|
|
|
85
86
|
root?: BoxProps;
|
|
86
87
|
didConnectContainer?: object;
|
|
87
88
|
contentContainer?: BoxProps;
|
|
89
|
+
connectButton?: ButtonProps;
|
|
90
|
+
authorizeButton?: ButtonProps;
|
|
91
|
+
cancelButton?: ButtonProps;
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
onConnect?: (done: () => void) => void;
|
|
@@ -95,6 +99,7 @@ export default function AuthApps({
|
|
|
95
99
|
ref: Ref<{ closeLoading: () => void }>;
|
|
96
100
|
|
|
97
101
|
disableAuthorizeButton?: boolean;
|
|
102
|
+
titlePrefix?: string;
|
|
98
103
|
}) {
|
|
99
104
|
const currentState = useReactive({
|
|
100
105
|
loading: false,
|
|
@@ -172,7 +177,7 @@ export default function AuthApps({
|
|
|
172
177
|
},
|
|
173
178
|
slotProps?.contentContainer?.sx as SxProps
|
|
174
179
|
)}>
|
|
175
|
-
<AuthAppsInfo requestAppInfo={requestAppInfo} currentAppInfo={currentAppInfo} />
|
|
180
|
+
<AuthAppsInfo requestAppInfo={requestAppInfo} currentAppInfo={currentAppInfo} titlePrefix={titlePrefix} />
|
|
176
181
|
|
|
177
182
|
{user ? (
|
|
178
183
|
<>
|
|
@@ -211,7 +216,8 @@ export default function AuthApps({
|
|
|
211
216
|
onClick={handleCancel}
|
|
212
217
|
sx={{
|
|
213
218
|
color: 'grey.500',
|
|
214
|
-
}}
|
|
219
|
+
}}
|
|
220
|
+
{...slotProps?.cancelButton}>
|
|
215
221
|
{cancelText || t('cancel')}
|
|
216
222
|
</Button>
|
|
217
223
|
) : null}
|
|
@@ -221,7 +227,8 @@ export default function AuthApps({
|
|
|
221
227
|
size="large"
|
|
222
228
|
fullWidth
|
|
223
229
|
onClick={handleAuthorize}
|
|
224
|
-
disabled={currentState.loading || disableAuthorizeButton}
|
|
230
|
+
disabled={currentState.loading || disableAuthorizeButton}
|
|
231
|
+
{...slotProps?.authorizeButton}>
|
|
225
232
|
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
|
226
233
|
{authorizeText || t('authorize')}
|
|
227
234
|
</Button>
|
|
@@ -231,7 +238,8 @@ export default function AuthApps({
|
|
|
231
238
|
size="large"
|
|
232
239
|
fullWidth
|
|
233
240
|
disabled={currentState.loading || disableAuthorizeButton}
|
|
234
|
-
onClick={handleConnect}
|
|
241
|
+
onClick={handleConnect}
|
|
242
|
+
{...slotProps?.connectButton}>
|
|
235
243
|
{currentState.loading ? <CircularProgress size={20} sx={{ mr: 1 }} /> : null}
|
|
236
244
|
{connectText || t('connect')}
|
|
237
245
|
</Button>
|
|
@@ -34,6 +34,7 @@ import DidSpace from './did-space';
|
|
|
34
34
|
import { mergeSx } from '../../Util/style';
|
|
35
35
|
import { createDebug } from '../../Util/logger';
|
|
36
36
|
import { GA_LAST_ROLE } from '../../withTracker/constant';
|
|
37
|
+
import type { SessionUserProps } from '..';
|
|
37
38
|
|
|
38
39
|
const getInviteLink = (inviter: string) => {
|
|
39
40
|
const url = new URL(window.location.href);
|
|
@@ -52,6 +53,7 @@ export interface LoggedInProps extends Omit<BoxProps, 'onClick' | 'onMouseEnter'
|
|
|
52
53
|
popperType?: 'hover' | 'click';
|
|
53
54
|
profileUrl?: string;
|
|
54
55
|
mode?: 'minimal' | 'normal';
|
|
56
|
+
renderUserButton: SessionUserProps['renderUserButton'];
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
export default function LoggedIn({
|
|
@@ -64,6 +66,7 @@ export default function LoggedIn({
|
|
|
64
66
|
profileUrl = PROFILE_URL,
|
|
65
67
|
mode = 'normal',
|
|
66
68
|
sx,
|
|
69
|
+
renderUserButton,
|
|
67
70
|
...rest
|
|
68
71
|
}: LoggedInProps) {
|
|
69
72
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -143,7 +146,7 @@ export default function LoggedIn({
|
|
|
143
146
|
onTogglePopper(false);
|
|
144
147
|
session.switchProfile(noop, extraParams);
|
|
145
148
|
});
|
|
146
|
-
const
|
|
149
|
+
const handleLogout = useMemoizedFn(() => {
|
|
147
150
|
onTogglePopper(false);
|
|
148
151
|
session.logout();
|
|
149
152
|
});
|
|
@@ -176,6 +179,27 @@ export default function LoggedIn({
|
|
|
176
179
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
177
180
|
}, []);
|
|
178
181
|
|
|
182
|
+
if (renderUserButton) {
|
|
183
|
+
return renderUserButton({
|
|
184
|
+
isBlocklet,
|
|
185
|
+
session,
|
|
186
|
+
locale,
|
|
187
|
+
size,
|
|
188
|
+
popperType,
|
|
189
|
+
profileUrl,
|
|
190
|
+
dashboardUrl: DASHBOARD_URL,
|
|
191
|
+
mode,
|
|
192
|
+
avatar,
|
|
193
|
+
isInviteEnabled,
|
|
194
|
+
handleSwitchPassport,
|
|
195
|
+
handleSwitchAccount,
|
|
196
|
+
handleSwitchProfile,
|
|
197
|
+
handleBindWallet,
|
|
198
|
+
handleOpenInvite,
|
|
199
|
+
handleLogout,
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
179
203
|
return (
|
|
180
204
|
<Box
|
|
181
205
|
sx={mergeSx(
|
|
@@ -269,7 +293,7 @@ export default function LoggedIn({
|
|
|
269
293
|
title={t('logout')}
|
|
270
294
|
component="div"
|
|
271
295
|
sx={{ color: 'error.main' }}
|
|
272
|
-
onClick={
|
|
296
|
+
onClick={handleLogout}
|
|
273
297
|
data-cy="sessionManager-logout-trigger"
|
|
274
298
|
/>
|
|
275
299
|
</MenuList>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import noop from 'lodash/noop';
|
|
2
2
|
import { useCreation } from 'ahooks';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
3
4
|
|
|
4
5
|
import LoggedIn from './components/logged-in';
|
|
5
6
|
import UnLogin from './components/un-login';
|
|
@@ -13,6 +14,24 @@ export interface SessionUserProps {
|
|
|
13
14
|
size?: number;
|
|
14
15
|
popperType?: 'hover' | 'click';
|
|
15
16
|
profileUrl?: string;
|
|
17
|
+
renderUserButton?: (props: {
|
|
18
|
+
isBlocklet: boolean;
|
|
19
|
+
session: Session;
|
|
20
|
+
locale: Locale;
|
|
21
|
+
size: number;
|
|
22
|
+
popperType: 'hover' | 'click';
|
|
23
|
+
profileUrl?: string;
|
|
24
|
+
dashboardUrl?: string;
|
|
25
|
+
mode?: any;
|
|
26
|
+
avatar: string;
|
|
27
|
+
isInviteEnabled: boolean;
|
|
28
|
+
handleSwitchPassport: () => void;
|
|
29
|
+
handleSwitchAccount: () => void;
|
|
30
|
+
handleSwitchProfile: () => void;
|
|
31
|
+
handleBindWallet: () => void;
|
|
32
|
+
handleOpenInvite: () => void;
|
|
33
|
+
handleLogout: () => void;
|
|
34
|
+
}) => ReactNode;
|
|
16
35
|
}
|
|
17
36
|
|
|
18
37
|
export default function SessionUser({
|
|
@@ -22,6 +41,7 @@ export default function SessionUser({
|
|
|
22
41
|
size = 24,
|
|
23
42
|
popperType = 'click',
|
|
24
43
|
profileUrl = PROFILE_URL,
|
|
44
|
+
renderUserButton = undefined,
|
|
25
45
|
}: SessionUserProps) {
|
|
26
46
|
const isBlocklet = useCreation(() => {
|
|
27
47
|
return !!globalThis?.blocklet;
|
|
@@ -40,6 +60,7 @@ export default function SessionUser({
|
|
|
40
60
|
popperType={popperType}
|
|
41
61
|
profileUrl={profileUrl}
|
|
42
62
|
mode={mode}
|
|
63
|
+
renderUserButton={renderUserButton}
|
|
43
64
|
/>
|
|
44
65
|
);
|
|
45
66
|
}
|