@arcblock/ux 3.3.5 → 3.3.7
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/SplitButton/index.js +28 -25
- package/lib/SplitButton/useClickAway.d.ts +3 -0
- package/lib/SplitButton/useClickAway.js +14 -0
- 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
- package/src/SplitButton/index.tsx +7 -1
- package/src/SplitButton/useClickAway.tsx +24 -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/SplitButton/index.js
CHANGED
|
@@ -1,45 +1,48 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as p, Fragment as P, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as b, useRef as m, createElement as w, isValidElement as E } from "react";
|
|
3
3
|
import { ExpandMore as L } from "@mui/icons-material";
|
|
4
|
-
import { ButtonGroup as S, Popper as
|
|
5
|
-
import
|
|
6
|
-
import { styled as
|
|
7
|
-
|
|
4
|
+
import { ButtonGroup as S, Popper as z, MenuItem as d, Button as u, Paper as R, ClickAwayListener as j, MenuList as G } from "@mui/material";
|
|
5
|
+
import v from "lodash/noop";
|
|
6
|
+
import { styled as f } from "../Theme/index.js";
|
|
7
|
+
import F from "./useClickAway.js";
|
|
8
|
+
function O({ ...o }) {
|
|
8
9
|
const {
|
|
9
|
-
size:
|
|
10
|
+
size: h = "medium",
|
|
10
11
|
color: r = "primary",
|
|
11
12
|
menu: i = [],
|
|
12
13
|
children: l = null,
|
|
13
|
-
variant:
|
|
14
|
-
onClick:
|
|
15
|
-
menuButtonProps:
|
|
16
|
-
...
|
|
17
|
-
} = o, [
|
|
14
|
+
variant: y = "contained",
|
|
15
|
+
onClick: g = v,
|
|
16
|
+
menuButtonProps: x = {},
|
|
17
|
+
...k
|
|
18
|
+
} = o, [C, a] = b(!1), n = m(null), s = m(null), M = Array.isArray(i) ? (
|
|
18
19
|
// eslint-disable-next-line react/no-array-index-key
|
|
19
|
-
i.map((t,
|
|
20
|
-
) : i,
|
|
20
|
+
i.map((t, A) => E(t) ? t : /* @__PURE__ */ w(d, { ...t, key: A }))
|
|
21
|
+
) : i, B = () => {
|
|
21
22
|
a((t) => !t);
|
|
22
|
-
},
|
|
23
|
+
}, c = (t) => {
|
|
23
24
|
n.current && n.current.contains(t.target) || a(!1);
|
|
24
|
-
}
|
|
25
|
+
};
|
|
26
|
+
F(s, c);
|
|
27
|
+
const I = (t) => {
|
|
25
28
|
t.target.closest(".MuiMenuItem-root") && a(!1);
|
|
26
29
|
};
|
|
27
|
-
return /* @__PURE__ */
|
|
28
|
-
/* @__PURE__ */
|
|
29
|
-
typeof l == "function" ? l() : /* @__PURE__ */ e(
|
|
30
|
-
/* @__PURE__ */ e(
|
|
30
|
+
return /* @__PURE__ */ p(P, { children: [
|
|
31
|
+
/* @__PURE__ */ p(T, { variant: y, size: h, color: r, ref: n, ...k, children: [
|
|
32
|
+
typeof l == "function" ? l() : /* @__PURE__ */ e(u, { onClick: g, color: r, children: l }),
|
|
33
|
+
/* @__PURE__ */ e(u, { onClick: B, color: r, ...x, "aria-label": "more functions", children: /* @__PURE__ */ e(L, {}) })
|
|
31
34
|
] }),
|
|
32
|
-
/* @__PURE__ */ e(
|
|
35
|
+
/* @__PURE__ */ e(V, { open: C, anchorEl: n.current, placement: "bottom-end", disablePortal: !1, children: /* @__PURE__ */ e(R, { ref: s, children: /* @__PURE__ */ e(j, { onClickAway: c, children: /* @__PURE__ */ e(G, { onClick: I, children: M }) }) }) })
|
|
33
36
|
] });
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
const
|
|
38
|
+
O.Item = d;
|
|
39
|
+
const T = f(S)`
|
|
37
40
|
> .MuiButtonBase-root:last-of-type {
|
|
38
41
|
min-width: 2em;
|
|
39
42
|
padding-left: 0;
|
|
40
43
|
padding-right: 0;
|
|
41
44
|
}
|
|
42
|
-
`,
|
|
45
|
+
`, V = f(z)`
|
|
43
46
|
z-index: ${(o) => o.theme.zIndex.tooltip};
|
|
44
47
|
.MuiList-root {
|
|
45
48
|
padding: 4px 0;
|
|
@@ -50,5 +53,5 @@ const F = d(S)`
|
|
|
50
53
|
}
|
|
51
54
|
`;
|
|
52
55
|
export {
|
|
53
|
-
|
|
56
|
+
O as default
|
|
54
57
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useEffect as u } from "react";
|
|
2
|
+
function i(t, e) {
|
|
3
|
+
u(() => {
|
|
4
|
+
function n(r) {
|
|
5
|
+
!t || !t.current || t.current.contains(r.target) || e(r);
|
|
6
|
+
}
|
|
7
|
+
return document.addEventListener("click", n, !0), () => {
|
|
8
|
+
document.removeEventListener("click", n, !0);
|
|
9
|
+
};
|
|
10
|
+
}, [t, e]);
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
i as default
|
|
14
|
+
};
|
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.7",
|
|
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": "cd0e3b812192ce054be488bcb60ed3f44e81fdff",
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@arcblock/bridge": "3.3.
|
|
73
|
+
"@arcblock/bridge": "3.3.7",
|
|
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.7",
|
|
77
|
+
"@arcblock/nft-display": "3.3.7",
|
|
78
|
+
"@arcblock/react-hooks": "3.3.7",
|
|
79
79
|
"@blocklet/js-sdk": "^1.17.6",
|
|
80
|
-
"@blocklet/theme": "3.3.
|
|
80
|
+
"@blocklet/theme": "3.3.7",
|
|
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
|
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import noop from 'lodash/noop';
|
|
16
16
|
|
|
17
17
|
import { styled } from '../Theme';
|
|
18
|
+
import useClickAway from './useClickAway';
|
|
18
19
|
|
|
19
20
|
export interface SplitButtonProps extends Omit<ButtonGroupProps, 'children'> {
|
|
20
21
|
menu?:
|
|
@@ -40,6 +41,9 @@ export default function SplitButton({ ...props }: SplitButtonProps) {
|
|
|
40
41
|
|
|
41
42
|
const [open, setOpen] = useState(false);
|
|
42
43
|
const anchorRef = useRef<HTMLDivElement | null>(null);
|
|
44
|
+
// ClickAwayListener 只会监听事件的冒泡阶段,这会导致如果其他事件禁用了冒泡,那么下拉菜单将无法隐藏
|
|
45
|
+
// 所以定义一个 ref 来监听事件的捕获阶段
|
|
46
|
+
const paperRef = useRef<HTMLDivElement | null>(null);
|
|
43
47
|
const menuItems = Array.isArray(menu)
|
|
44
48
|
? // eslint-disable-next-line react/no-array-index-key
|
|
45
49
|
menu.map((item, index) => (isValidElement(item) ? item : <MenuItem {...item} key={index} />))
|
|
@@ -56,6 +60,8 @@ export default function SplitButton({ ...props }: SplitButtonProps) {
|
|
|
56
60
|
setOpen(false);
|
|
57
61
|
};
|
|
58
62
|
|
|
63
|
+
useClickAway(paperRef as React.RefObject<HTMLElement>, handleClose);
|
|
64
|
+
|
|
59
65
|
// 点击 item 后收起下拉菜单, 如果想要点击 action 后不收起下拉菜单, 可以在 item#onClick 时调用 e.stopPropagation()
|
|
60
66
|
const handleItemClick: React.MouseEventHandler<HTMLUListElement> = (e) => {
|
|
61
67
|
if ((e.target as HTMLElement).closest('.MuiMenuItem-root')) {
|
|
@@ -78,7 +84,7 @@ export default function SplitButton({ ...props }: SplitButtonProps) {
|
|
|
78
84
|
</Button>
|
|
79
85
|
</StyledButtonGroup>
|
|
80
86
|
<StyledPopper open={open} anchorEl={anchorRef.current} placement="bottom-end" disablePortal={false}>
|
|
81
|
-
<Paper>
|
|
87
|
+
<Paper ref={paperRef}>
|
|
82
88
|
<ClickAwayListener onClickAway={handleClose}>
|
|
83
89
|
<MenuList onClick={handleItemClick}>{menuItems}</MenuList>
|
|
84
90
|
</ClickAwayListener>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// 监听事件的捕获阶段,用于 ClickAwayListener 无法监听的事件
|
|
4
|
+
function useClickAway(ref: React.RefObject<HTMLElement> | null, onClickAway: (event: MouseEvent) => void) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
function handleClick(event: MouseEvent) {
|
|
7
|
+
if (!ref || !ref.current) return;
|
|
8
|
+
|
|
9
|
+
// 如果点击事件目标在 menu 元素内,阻止菜单关闭
|
|
10
|
+
if (ref.current.contains(event.target as Node)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
onClickAway(event);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
document.addEventListener('click', handleClick, true);
|
|
18
|
+
return () => {
|
|
19
|
+
document.removeEventListener('click', handleClick, true);
|
|
20
|
+
};
|
|
21
|
+
}, [ref, onClickAway]);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default useClickAway;
|