@arcblock/ux 3.1.28 → 3.1.31

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.
Files changed (50) hide show
  1. package/lib/SessionUser/components/logged-in.js +41 -39
  2. package/lib/UserCard/Cards/avatar-only.js +11 -22
  3. package/lib/UserCard/Cards/index.js +4 -12
  4. package/lib/UserCard/Cards/social-actions.d.ts +7 -0
  5. package/lib/UserCard/Cards/social-actions.js +112 -0
  6. package/lib/UserCard/Content/minimal.js +62 -47
  7. package/lib/UserCard/index.d.ts +2 -0
  8. package/lib/UserCard/index.js +31 -28
  9. package/lib/UserCard/types.d.ts +8 -1
  10. package/lib/UserCard/types.js +4 -4
  11. package/lib/UserCard/use-follow.d.ts +16 -0
  12. package/lib/UserCard/use-follow.js +67 -0
  13. package/lib/Util/index.d.ts +15 -0
  14. package/lib/Util/index.js +191 -171
  15. package/lib/package.json.js +9 -0
  16. package/lib/withTracker/action/bind-wallet.d.ts +14 -0
  17. package/lib/withTracker/action/bind-wallet.js +1 -0
  18. package/lib/withTracker/action/login.d.ts +15 -0
  19. package/lib/withTracker/action/login.js +1 -0
  20. package/lib/withTracker/action/pay.d.ts +12 -0
  21. package/lib/withTracker/action/pay.js +1 -0
  22. package/lib/withTracker/action/switch-passport.d.ts +18 -0
  23. package/lib/withTracker/action/switch-passport.js +1 -0
  24. package/lib/withTracker/constant/index.d.ts +3 -0
  25. package/lib/withTracker/constant/index.js +6 -0
  26. package/lib/withTracker/env.d.ts +1 -0
  27. package/lib/withTracker/env.js +4 -0
  28. package/lib/withTracker/index.d.ts +2 -0
  29. package/lib/withTracker/index.js +21 -17
  30. package/package.json +10 -8
  31. package/src/SessionUser/components/logged-in.tsx +2 -0
  32. package/src/UserCard/Cards/avatar-only.tsx +1 -15
  33. package/src/UserCard/Cards/index.tsx +2 -11
  34. package/src/UserCard/Cards/social-actions.tsx +196 -0
  35. package/src/UserCard/Content/minimal.tsx +43 -31
  36. package/src/UserCard/UserCard.stories.jsx +1 -0
  37. package/src/UserCard/index.tsx +6 -0
  38. package/src/UserCard/types.ts +10 -1
  39. package/src/UserCard/use-follow.tsx +119 -0
  40. package/src/Util/index.ts +67 -0
  41. package/src/withTracker/action/bind-wallet.tsx +17 -0
  42. package/src/withTracker/action/login.tsx +18 -0
  43. package/src/withTracker/action/pay.tsx +14 -0
  44. package/src/withTracker/action/switch-passport.tsx +20 -0
  45. package/src/withTracker/constant/index.tsx +3 -0
  46. package/src/withTracker/env.tsx +1 -0
  47. package/src/withTracker/index.tsx +8 -11
  48. package/lib/UserCard/Cards/name-only.d.ts +0 -5
  49. package/lib/UserCard/Cards/name-only.js +0 -13
  50. package/src/UserCard/Cards/name-only.tsx +0 -17
@@ -1,8 +1,8 @@
1
1
  import { jsxs as s, jsx as r, Fragment as W } from "react/jsx-runtime";
2
- import { useRef as z, useEffect as j } from "react";
3
- import { useMemoizedFn as n, useCreation as T, useReactive as _ } from "ahooks";
2
+ import { useRef as z, useEffect as T } from "react";
3
+ import { useMemoizedFn as n, useCreation as _, useReactive as j } from "ahooks";
4
4
  import f from "@arcblock/bridge";
5
- import { Box as S, IconButton as H, Popper as N, ClickAwayListener as Q, Fade as V, Paper as q, Divider as k, MenuList as G, MenuItem as J } from "@mui/material";
5
+ import { Box as k, IconButton as G, Popper as H, ClickAwayListener as N, Fade as Q, Paper as V, Divider as S, MenuList as q, MenuItem as J } from "@mui/material";
6
6
  import { Icon as K } from "@iconify/react";
7
7
  import X from "@iconify-icons/material-symbols/person-outline-rounded";
8
8
  import Y from "@iconify-icons/material-symbols/filter-vintage-outline-rounded";
@@ -15,33 +15,35 @@ import te from "../../Avatar/index.js";
15
15
  import { getUserAvatar as oe } from "../../Util/index.js";
16
16
  import ie from "./user-info.js";
17
17
  import { DASHBOARD_URL as ne, PROFILE_URL as ce } from "../../Util/constant.js";
18
- import ae from "../../SessionPermission/index.js";
19
- import { translations as le } from "../libs/translation.js";
18
+ import le from "../../SessionPermission/index.js";
19
+ import { translations as ae } from "../libs/translation.js";
20
20
  import { translate as se } from "../../Locale/util.js";
21
21
  import pe from "./did-space.js";
22
22
  import { mergeSx as ue } from "../../Util/style.js";
23
23
  import { createDebug as de } from "../../Util/logger.js";
24
- const me = (e) => {
24
+ import { GA_LAST_ROLE as me } from "../../withTracker/constant/index.js";
25
+ const fe = (e) => {
25
26
  const c = new URL(window.location.href);
26
27
  return c.searchParams.set("inviter", e), c.toString();
27
28
  }, g = de("did-connect");
28
- function We({
29
+ function Te({
29
30
  session: e,
30
31
  onBindWallet: c = h,
31
- isBlocklet: a = !0,
32
+ isBlocklet: l = !0,
32
33
  locale: u = "en",
33
34
  size: b = 24,
34
35
  popperType: I = "click",
35
36
  sx: y,
36
37
  ...R
37
38
  }) {
38
- const l = n((t, o = {}) => se(le, t, u, "en", o)), C = T(() => !!globalThis?.blocklet?.settings?.invite?.enabled, []), P = z(null), d = _({
39
+ const a = n((t, o = {}) => se(ae, t, u, "en", o)), C = _(() => !!globalThis?.blocklet?.settings?.invite?.enabled, []), P = z(null), d = j({
39
40
  open: !1
40
41
  }), i = n((t = !d.open) => {
41
42
  d.open = t;
42
- }), B = I === "hover" ? { onMouseEnter: () => i(!0), onMouseLeave: () => i(!1) } : { onClick: () => i() }, D = oe(e.user?.avatar?.replace(/\s/g, encodeURIComponent(" "))), L = e.useOAuth(), O = typeof e.usePasskey == "function" ? e.usePasskey() : null, v = n(({ inArcSphere: t = !1 } = {}) => {
43
+ }), L = I === "hover" ? { onMouseEnter: () => i(!0), onMouseLeave: () => i(!1) } : { onClick: () => i() }, B = oe(e.user?.avatar?.replace(/\s/g, encodeURIComponent(" "))), D = e.useOAuth(), O = typeof e.usePasskey == "function" ? e.usePasskey() : null, v = n(({ inArcSphere: t = !1 } = {}) => {
44
+ localStorage.setItem(me, e?.user?.role);
43
45
  const o = {};
44
- t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ? O.switchPassport(e.user) : ["google", "apple", "email", "github"].includes(e?.user?.sourceProvider) ? L.switchOAuthPassport(e.user) : e.switchPassport(h, o);
46
+ t && e?.user?.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e?.user?.sourceProvider === "passkey" ? O.switchPassport(e.user) : ["google", "apple", "email", "github"].includes(e?.user?.sourceProvider) ? D.switchOAuthPassport(e.user) : e.switchPassport(h, o);
45
47
  }), x = n(({ userSession: t, inArcSphere: o = !1 } = {}) => new Promise((F) => {
46
48
  const A = {};
47
49
  o && e.user.sourceAppPid && (A.sourceAppPid = e.user.sourceAppPid);
@@ -56,16 +58,16 @@ function We({
56
58
  })), w = n(({ inArcSphere: t = !1 } = {}) => {
57
59
  const o = {};
58
60
  t && e.user.sourceAppPid && (o.sourceAppPid = e.user.sourceAppPid), i(!1), e.switchProfile(h, o);
59
- }), M = n(() => {
60
- i(!1), e.logout();
61
61
  }), E = n(() => {
62
+ i(!1), e.logout();
63
+ }), M = n(() => {
62
64
  i(!1), e.bindWallet(c);
63
65
  }), U = n(() => {
64
66
  i(!1);
65
- const t = me(e.user.did);
66
- ee(t), re.success(l("inviteCopied"));
67
+ const t = fe(e.user.did);
68
+ ee(t), re.success(a("inviteCopied"));
67
69
  });
68
- return j(() => {
70
+ return T(() => {
69
71
  f.registerBlocklet("callSwitchPassport", () => {
70
72
  g("bridge registerBlocklet: callSwitchPassport"), v({ inArcSphere: !0 });
71
73
  }), f.registerBlocklet("callSwitchDid", () => {
@@ -74,7 +76,7 @@ function We({
74
76
  g("bridge registerBlocklet: callSwitchProfile"), w({ inArcSphere: !0 });
75
77
  });
76
78
  }, []), /* @__PURE__ */ s(
77
- S,
79
+ k,
78
80
  {
79
81
  sx: ue(
80
82
  {
@@ -88,19 +90,19 @@ function We({
88
90
  ...R,
89
91
  children: [
90
92
  /* @__PURE__ */ r(
91
- H,
93
+ G,
92
94
  {
93
95
  ref: P,
94
96
  size: "medium",
95
97
  "data-cy": "sessionManager-logout-popup",
96
98
  className: "arc-session-user-logged-in",
97
99
  "aria-label": "User info button",
98
- ...B,
99
- children: /* @__PURE__ */ r(te, { variant: "circle", did: e.user.did, src: D, size: b, shape: "circle" })
100
+ ...L,
101
+ children: /* @__PURE__ */ r(te, { variant: "circle", did: e.user.did, src: B, size: b, shape: "circle" })
100
102
  }
101
103
  ),
102
104
  /* @__PURE__ */ r(
103
- N,
105
+ H,
104
106
  {
105
107
  open: d.open,
106
108
  anchorEl: P.current,
@@ -110,13 +112,13 @@ function We({
110
112
  zIndex: 1600
111
113
  },
112
114
  children: ({ TransitionProps: t }) => /* @__PURE__ */ r(
113
- Q,
115
+ N,
114
116
  {
115
117
  onClickAway: (o) => {
116
118
  o.preventDefault(), o.stopPropagation(), i(!1);
117
119
  },
118
- children: /* @__PURE__ */ r(V, { ...t, timeout: 350, children: /* @__PURE__ */ s(
119
- q,
120
+ children: /* @__PURE__ */ r(Q, { ...t, timeout: 350, children: /* @__PURE__ */ s(
121
+ V,
120
122
  {
121
123
  variant: "outlined",
122
124
  sx: {
@@ -129,22 +131,22 @@ function We({
129
131
  ie,
130
132
  {
131
133
  locale: u,
132
- isBlocklet: a,
134
+ isBlocklet: l,
133
135
  session: e,
134
136
  onSwitchPassport: v,
135
137
  onSwitchAccount: x,
136
138
  onSwitchProfile: w,
137
- onBindWallet: E
139
+ onBindWallet: M
138
140
  }
139
141
  ),
140
- /* @__PURE__ */ r(k, { sx: { m: "0 !important" } }),
141
- /* @__PURE__ */ s(G, { sx: { p: 0 }, children: [
142
- a ? /* @__PURE__ */ s(W, { children: [
143
- /* @__PURE__ */ r(ae, { session: e, children: /* @__PURE__ */ r(
142
+ /* @__PURE__ */ r(S, { sx: { m: "0 !important" } }),
143
+ /* @__PURE__ */ s(q, { sx: { p: 0 }, children: [
144
+ l ? /* @__PURE__ */ s(W, { children: [
145
+ /* @__PURE__ */ r(le, { session: e, children: /* @__PURE__ */ r(
144
146
  p,
145
147
  {
146
148
  icon: Y,
147
- title: l("dashboard"),
149
+ title: a("dashboard"),
148
150
  component: "a",
149
151
  href: ne,
150
152
  sx: { display: "block", textDecoration: "none", color: "inherit" }
@@ -154,7 +156,7 @@ function We({
154
156
  p,
155
157
  {
156
158
  icon: X,
157
- title: l("profile"),
159
+ title: a("profile"),
158
160
  component: "a",
159
161
  href: ce,
160
162
  sx: { display: "block", textDecoration: "none", color: "inherit" }
@@ -164,23 +166,23 @@ function We({
164
166
  p,
165
167
  {
166
168
  icon: $,
167
- title: l("invite"),
169
+ title: a("invite"),
168
170
  component: "div",
169
171
  onClick: U,
170
172
  sx: { display: "block", color: "inherit" }
171
173
  }
172
174
  ),
173
- /* @__PURE__ */ r(k, { sx: { m: "0 !important" } }),
175
+ /* @__PURE__ */ r(S, { sx: { m: "0 !important" } }),
174
176
  /* @__PURE__ */ r(pe, { session: e, locale: u })
175
177
  ] }) : null,
176
178
  /* @__PURE__ */ r(
177
179
  p,
178
180
  {
179
181
  icon: Z,
180
- title: l("logout"),
182
+ title: a("logout"),
181
183
  component: "div",
182
184
  sx: { color: "error.main" },
183
- onClick: M,
185
+ onClick: E,
184
186
  "data-cy": "sessionManager-logout-trigger"
185
187
  }
186
188
  )
@@ -199,9 +201,9 @@ function We({
199
201
  function p({
200
202
  icon: e,
201
203
  title: c,
202
- ...a
204
+ ...l
203
205
  }) {
204
- return /* @__PURE__ */ r(S, { ...a, sx: { p: 0.5, ...a?.sx }, children: /* @__PURE__ */ s(
206
+ return /* @__PURE__ */ r(k, { ...l, sx: { p: 0.5, ...l?.sx }, children: /* @__PURE__ */ s(
205
207
  J,
206
208
  {
207
209
  sx: {
@@ -222,5 +224,5 @@ function p({
222
224
  ) });
223
225
  }
224
226
  export {
225
- We as default
227
+ Te as default
226
228
  };
@@ -1,29 +1,18 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { InfoType as d } from "../types.js";
3
- import l from "../Content/tooltip-avatar.js";
4
- function u(i) {
5
- const { user: r, infoType: n, avatarSize: o = 48, shouldShowHoverCard: f = !1, renderCardContent: e, ...t } = i;
6
- return n === d.NameOnly ? /* @__PURE__ */ a(
7
- l,
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import d from "../Content/tooltip-avatar.js";
3
+ function p(r) {
4
+ const { user: o, infoType: f, avatarSize: t = 48, shouldShowHoverCard: a = !1, renderCardContent: e, ...n } = r;
5
+ return /* @__PURE__ */ s(
6
+ d,
8
7
  {
9
- user: r,
10
- avatarSize: o,
11
- shouldShowHoverCard: !1,
8
+ user: o,
9
+ avatarSize: t,
10
+ shouldShowHoverCard: a,
12
11
  renderCardContent: e,
13
- tooltipTitle: r.fullName || r.email || r.did,
14
- ...t
15
- }
16
- ) : /* @__PURE__ */ a(
17
- l,
18
- {
19
- user: r,
20
- avatarSize: o,
21
- shouldShowHoverCard: f,
22
- renderCardContent: e,
23
- ...t
12
+ ...n
24
13
  }
25
14
  );
26
15
  }
27
16
  export {
28
- u as default
17
+ p as default
29
18
  };
@@ -1,16 +1,8 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { InfoType as a } from "../types.js";
3
- import i from "./name-only.js";
4
- import m from "./basic-info.js";
5
- function l({ ...r }) {
6
- const { infoType: e = a.Minimal } = r;
7
- switch (e) {
8
- case a.NameOnly:
9
- return /* @__PURE__ */ t(i, { ...r });
10
- default:
11
- return /* @__PURE__ */ t(m, { ...r });
12
- }
2
+ import a from "./basic-info.js";
3
+ function i({ ...r }) {
4
+ return /* @__PURE__ */ t(a, { ...r });
13
5
  }
14
6
  export {
15
- l as default
7
+ i as default
16
8
  };
@@ -0,0 +1,7 @@
1
+ import { User, UserCardProps } from '../types';
2
+ type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session'> & {
3
+ user: User;
4
+ };
5
+ declare function SocialActions({ showSocialActions, session, user }: SocialActionsProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export default SocialActions;
7
+ export declare const ButtonWrapper: import('@emotion/styled').StyledComponent<import('@mui/material').ButtonOwnProps & Omit<import('@mui/material').ButtonBaseOwnProps, "classes"> & import('@mui/material/OverridableComponent').CommonProps & Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "action" | "disabled" | "color" | "className" | "style" | "classes" | "children" | "sx" | "variant" | "tabIndex" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "href" | "loading" | "loadingIndicator" | "loadingPosition" | "size" | "startIcon"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
@@ -0,0 +1,112 @@
1
+ import { jsxs as m, jsx as s } from "react/jsx-runtime";
2
+ import { useMemo as r } from "react";
3
+ import { styled as C, Button as F, Box as M } from "@mui/material";
4
+ import { useMemoizedFn as u } from "ahooks";
5
+ import { joinURL as N } from "ufo";
6
+ import w from "lodash/noop";
7
+ import { Icon as U } from "@iconify/react";
8
+ import k from "@mui/icons-material/Notifications";
9
+ import v from "@mui/icons-material/NotificationsOff";
10
+ import z from "../use-follow.js";
11
+ import { useLocaleContext as h } from "../../Locale/context.js";
12
+ import { translate as g } from "../../Locale/util.js";
13
+ import { isSupportFollow as L } from "../../Util/index.js";
14
+ const _ = {
15
+ zh: {
16
+ chat: "聊天",
17
+ follow: "关注",
18
+ unfollow: "取消关注",
19
+ follow_success: "关注成功",
20
+ unfollow_success: "取消关注成功"
21
+ },
22
+ en: {
23
+ chat: "Chat",
24
+ follow: "Follow",
25
+ unfollow: "Unfollow",
26
+ follow_success: "Follow success",
27
+ unfollow_success: "Unfollow success"
28
+ }
29
+ }, P = () => {
30
+ const { componentMountPoints: o = [] } = window.blocklet || {};
31
+ return o.find((n) => n.name === "did-comments")?.mountPoint;
32
+ };
33
+ function j({
34
+ user: o,
35
+ showSocialActions: t,
36
+ session: n
37
+ }) {
38
+ const { locale: i } = h() || { locale: "en" }, e = u((a, f = {}) => g(_, a, i, "en", f)), d = r(() => !!n?.user?.did, [n?.user?.did]), l = r(() => P(), []), c = u(() => {
39
+ if (!d) {
40
+ n?.login(w, {
41
+ openMode: "redirect",
42
+ redirect: window.location.href
43
+ });
44
+ return;
45
+ }
46
+ window.open(N(l, `/chat/dm/${o?.did}`), "_blank");
47
+ });
48
+ return r(() => (typeof t == "boolean" ? !!t : t?.chat) && !!l, [t, l]) ? /* @__PURE__ */ m(
49
+ x,
50
+ {
51
+ className: "user-card__social-actions-chat",
52
+ variant: "outlined",
53
+ color: "inherit",
54
+ onClick: c,
55
+ children: [
56
+ /* @__PURE__ */ s(U, { icon: "tabler:message-dots", style: { marginRight: 4 } }),
57
+ e("chat")
58
+ ]
59
+ }
60
+ ) : null;
61
+ }
62
+ function B({
63
+ user: o,
64
+ showSocialActions: t,
65
+ session: n
66
+ }) {
67
+ const { locale: i } = h() || { locale: "en" }, e = u((b, y = {}) => g(_, b, i, "en", y)), d = r(() => !!n?.user?.did, [n?.user?.did]), l = r(() => typeof t == "boolean" ? !!t : t?.follow, [t]), { followed: c, followUser: p, unfollowUser: a } = z({
68
+ user: o,
69
+ t: e,
70
+ isMySelf: !1,
71
+ visible: !!l
72
+ }), f = u(() => {
73
+ if (!d) {
74
+ n?.login(w, {
75
+ openMode: "redirect",
76
+ redirect: window.location.href
77
+ });
78
+ return;
79
+ }
80
+ c ? a(o.did) : p(o.did);
81
+ });
82
+ return l ? /* @__PURE__ */ m(
83
+ x,
84
+ {
85
+ className: "user-card__social-actions-follow",
86
+ variant: "outlined",
87
+ color: "inherit",
88
+ onClick: f,
89
+ children: [
90
+ c ? /* @__PURE__ */ s(v, { sx: { fontSize: 14, mr: 0.5 } }) : /* @__PURE__ */ s(k, { sx: { fontSize: 14, mr: 0.5 } }),
91
+ e(c ? "unfollow" : "follow")
92
+ ]
93
+ }
94
+ ) : null;
95
+ }
96
+ function Q({ showSocialActions: o, session: t, user: n }) {
97
+ const i = r(() => t?.user?.did === n?.did, [t?.user?.did, n?.did]), e = r(() => L(), []);
98
+ return i || !e || !o ? null : /* @__PURE__ */ m(M, { className: "user-card__social-actions", sx: { display: "flex", gap: 1 }, children: [
99
+ /* @__PURE__ */ s(j, { session: t, user: n, showSocialActions: o }),
100
+ /* @__PURE__ */ s(B, { session: t, user: n, showSocialActions: o })
101
+ ] });
102
+ }
103
+ const x = C(F)`
104
+ color: ${({ theme: o }) => o.palette.text.primary};
105
+ font-weight: 500;
106
+ border-color: ${({ theme: o }) => o.palette.grey[300]};
107
+ line-height: 1.5;
108
+ `;
109
+ export {
110
+ x as ButtonWrapper,
111
+ Q as default
112
+ };
@@ -1,27 +1,28 @@
1
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
- import { memo as x } from "react";
3
- import { Box as o, Typography as g } from "@mui/material";
1
+ import { jsxs as o, jsx as t } from "react/jsx-runtime";
2
+ import { memo as u } from "react";
3
+ import { Box as r, Typography as g } from "@mui/material";
4
4
  import { DID as y } from "../../DID/index.js";
5
5
  import C from "./tooltip-avatar.js";
6
6
  import { renderTopRight as b } from "../components.js";
7
- import v from "./shorten-label.js";
8
- function W({ ...n }) {
7
+ import S from "./shorten-label.js";
8
+ import v from "../Cards/social-actions.js";
9
+ function w({ ...a }) {
9
10
  const {
10
11
  user: e,
11
- showDid: a,
12
+ showDid: s,
12
13
  didProps: l,
13
- avatarSize: s,
14
- shouldShowHoverCard: d,
15
- renderCardContent: m,
14
+ avatarSize: d,
15
+ shouldShowHoverCard: m,
16
+ renderCardContent: c,
16
17
  renderTopRightContent: p,
17
- topRightMaxWidth: c,
18
- avatarProps: f,
19
- shortenLabelProps: h,
20
- renderName: i,
21
- ...u
22
- } = n;
23
- return /* @__PURE__ */ r(
24
- o,
18
+ topRightMaxWidth: f,
19
+ avatarProps: h,
20
+ shortenLabelProps: x,
21
+ renderName: n,
22
+ ...i
23
+ } = a;
24
+ return /* @__PURE__ */ o(
25
+ r,
25
26
  {
26
27
  className: "user-card__avatar-content",
27
28
  sx: {
@@ -30,56 +31,70 @@ function W({ ...n }) {
30
31
  alignItems: "center"
31
32
  },
32
33
  children: [
33
- /* @__PURE__ */ r(
34
- o,
34
+ /* @__PURE__ */ o(
35
+ r,
35
36
  {
36
37
  sx: {
37
38
  display: "flex",
38
- justifyContent: "flex-start",
39
+ justifyContent: "space-between",
39
40
  alignItems: "center",
40
41
  gap: 1,
41
42
  flex: 1,
42
43
  minWidth: 0
43
44
  },
44
45
  children: [
45
- /* @__PURE__ */ t(
46
- C,
47
- {
48
- user: e,
49
- avatarSize: s,
50
- shouldShowHoverCard: d,
51
- renderCardContent: m,
52
- avatarProps: f,
53
- ...u
54
- }
55
- ),
56
- /* @__PURE__ */ r(o, { children: [
46
+ /* @__PURE__ */ o(r, { sx: { display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, flex: 1 }, children: [
57
47
  /* @__PURE__ */ t(
58
- g,
48
+ C,
59
49
  {
60
- variant: "subtitle1",
61
- className: "user-card__full-name-label",
62
- noWrap: !0,
63
- sx: {
64
- fontWeight: 500,
65
- color: "text.primary",
66
- fontSize: 18,
67
- lineHeight: 1.1
68
- },
69
- children: i ? i(e) : /* @__PURE__ */ t(v, { sx: { fontWeight: 500 }, ...h, children: e.fullName || e.email || e.did })
50
+ user: e,
51
+ avatarSize: d,
52
+ shouldShowHoverCard: m,
53
+ renderCardContent: c,
54
+ avatarProps: h,
55
+ ...i
70
56
  }
71
57
  ),
72
- a && e.did ? /* @__PURE__ */ t(y, { did: e.did, size: 14, copyable: !0, compact: !0, locale: "en", sx: { lineHeight: 1.5 }, ...l ?? {} }) : null
73
- ] })
58
+ /* @__PURE__ */ o(r, { children: [
59
+ /* @__PURE__ */ t(
60
+ g,
61
+ {
62
+ variant: "subtitle1",
63
+ className: "user-card__full-name-label",
64
+ noWrap: !0,
65
+ sx: {
66
+ fontWeight: 500,
67
+ color: "text.primary",
68
+ fontSize: 18,
69
+ lineHeight: 1.1
70
+ },
71
+ children: n ? n(e) : /* @__PURE__ */ t(S, { sx: { fontWeight: 500 }, ...x, children: e.fullName || e.email || e.did })
72
+ }
73
+ ),
74
+ s && e.did ? /* @__PURE__ */ t(
75
+ y,
76
+ {
77
+ did: e.did,
78
+ size: 14,
79
+ copyable: !0,
80
+ compact: !0,
81
+ locale: "en",
82
+ sx: { lineHeight: 1.5 },
83
+ ...l ?? {}
84
+ }
85
+ ) : null
86
+ ] })
87
+ ] }),
88
+ /* @__PURE__ */ t(v, { showSocialActions: i.showSocialActions, user: e, session: i.session })
74
89
  ]
75
90
  }
76
91
  ),
77
- b(p, c)
92
+ b(p, f)
78
93
  ]
79
94
  }
80
95
  );
81
96
  }
82
- const D = x(W);
97
+ const D = u(w);
83
98
  export {
84
99
  D as default
85
100
  };
@@ -1,4 +1,6 @@
1
1
  import { User, UserCardProps } from './types';
2
+ import { default as SocialActions } from './Cards/social-actions';
2
3
  export declare function createNameOnlyAvatar(user: User): string | null;
3
4
  declare function UserCard(props: UserCardProps): import("react/jsx-runtime").JSX.Element;
4
5
  export default UserCard;
6
+ export { SocialActions };
@@ -1,11 +1,12 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { useRef as v, useState as C, useEffect as y, useMemo as P } from "react";
3
- import { CardType as o } from "./types.js";
4
- import A from "./Cards/avatar-only.js";
5
- import m from "./Cards/index.js";
6
- import D from "./Container/dialog.js";
7
- import S from "./Container/card.js";
8
- import w from "../Avatar/index.js";
2
+ import { useRef as v, useState as A, useEffect as C, useMemo as S } from "react";
3
+ import { CardType as d } from "./types.js";
4
+ import y from "./Cards/avatar-only.js";
5
+ import c from "./Cards/index.js";
6
+ import w from "./Container/dialog.js";
7
+ import P from "./Container/card.js";
8
+ import D from "../Avatar/index.js";
9
+ import { default as j } from "./Cards/social-actions.js";
9
10
  import { isUserDid as x, getUserByDid as U } from "./utils.js";
10
11
  function L(e) {
11
12
  if (!e) return null;
@@ -13,64 +14,66 @@ function L(e) {
13
14
  return e.fullName ? r = e.fullName.charAt(0).toUpperCase() : e.email ? r = e.email.split("@")[0].charAt(0).toUpperCase() : r = e.did ? e.did.charAt(0).toUpperCase() : "?", r;
14
15
  }
15
16
  function B(e) {
16
- const { cardType: r = o.Detailed, showHoverCard: l } = e, u = l !== void 0 ? l : r === o.AvatarOnly, c = v(null), [i, f] = C(() => e.user || null);
17
- y(() => {
17
+ const { cardType: r = d.Detailed, showHoverCard: l } = e, u = l !== void 0 ? l : r === d.AvatarOnly, m = v(null), [i, s] = A(() => e.user || null);
18
+ C(() => {
18
19
  let a = !0;
19
- return e.user ? f(e.user) : e.did && x(e.did) && !e.user && U(e.did).then((d) => {
20
- a && f(d || { fullName: "Anonymous", did: e.did, avatar: "" });
20
+ return e.user ? s(e.user) : e.did && x(e.did) && !e.user && U(e.did).then((n) => {
21
+ a && s(n || { fullName: "Anonymous", did: e.did, avatar: "" });
21
22
  }), () => {
22
23
  a = !1;
23
24
  };
24
25
  }, [e.did, e.user]);
25
- const n = P(() => {
26
+ const o = S(() => {
26
27
  if (!i)
27
28
  return null;
28
- const { avatar: a = "", ...d } = i;
29
+ const { avatar: a = "", ...n } = i;
29
30
  if (a) {
30
31
  const h = a.split("?")[1] || "";
31
32
  return {
32
- ...d,
33
+ ...n,
33
34
  avatar: h ? a : `${a}?imageFilter=resize&w=48&h=48`
34
35
  };
35
36
  }
36
37
  return i;
37
38
  }, [i]);
38
- if (!n)
39
- return /* @__PURE__ */ t(w, { did: e.did, size: e.avatarSize, useProxyFallback: !0, ...e.avatarProps });
40
- const s = () => /* @__PURE__ */ t(D, { sx: e.popupSx, children: /* @__PURE__ */ t(
41
- m,
39
+ if (!o)
40
+ return /* @__PURE__ */ t(D, { did: e.did, size: e.avatarSize, useProxyFallback: !0, ...e.avatarProps });
41
+ const f = () => /* @__PURE__ */ t(w, { sx: e.popupSx, children: /* @__PURE__ */ t(
42
+ c,
42
43
  {
43
44
  ...e,
44
45
  shouldShowHoverCard: !1,
45
- user: n,
46
+ user: o,
46
47
  avatarProps: e.popupAvatarProps,
47
48
  shortenLabelProps: e.popupShortenLabelProps || e.shortenLabelProps,
48
49
  renderFields: e.popupRenderFields,
49
50
  renderName: e.popupRenderName,
50
51
  infoType: e.popupInfoType || e.infoType,
51
52
  didProps: e.popupDidProps || e.didProps,
52
- showDid: e.popupShowDid || e.showDid
53
+ showDid: e.popupShowDid || e.showDid,
54
+ showSocialActions: e.popupShowSocialActions === void 0 ? e.showSocialActions : e.popupShowSocialActions
53
55
  }
54
56
  ) });
55
- return r === o.AvatarOnly ? /* @__PURE__ */ t(
56
- A,
57
+ return r === d.AvatarOnly ? /* @__PURE__ */ t(
58
+ y,
57
59
  {
58
60
  ...e,
59
61
  shouldShowHoverCard: u,
60
- renderCardContent: s,
61
- user: n
62
+ renderCardContent: f,
63
+ user: o
62
64
  }
63
- ) : /* @__PURE__ */ t(S, { containerRef: c, cardType: r, sx: e.sx, children: /* @__PURE__ */ t(
64
- m,
65
+ ) : /* @__PURE__ */ t(P, { containerRef: m, cardType: r, sx: e.sx, children: /* @__PURE__ */ t(
66
+ c,
65
67
  {
66
68
  ...e,
67
69
  shouldShowHoverCard: u,
68
- renderCardContent: s,
69
- user: n
70
+ renderCardContent: f,
71
+ user: o
70
72
  }
71
73
  ) });
72
74
  }
73
75
  export {
76
+ j as SocialActions,
74
77
  L as createNameOnlyAvatar,
75
78
  B as default
76
79
  };