@arcblock/ux 3.4.8 → 3.4.9

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