@arcblock/ux 3.1.35 → 3.1.37

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.
@@ -1,7 +1,7 @@
1
1
  import { User, UserCardProps } from '../types';
2
- type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session'> & {
2
+ type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session' | 'onFollowClick'> & {
3
3
  user: User;
4
4
  };
5
- declare function SocialActions({ showSocialActions, session, user }: SocialActionsProps): import("react/jsx-runtime").JSX.Element | null;
5
+ declare function SocialActions({ showSocialActions, session, user, onFollowClick }: SocialActionsProps): import("react/jsx-runtime").JSX.Element | null;
6
6
  export default SocialActions;
7
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>, {}, {}>;
@@ -1,16 +1,16 @@
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";
1
+ import { jsxs as w, jsx as s } from "react/jsx-runtime";
2
+ import { useMemo as l } from "react";
3
+ import { styled as z, Button as C, Box as F } from "@mui/material";
4
4
  import { useMemoizedFn as u } from "ahooks";
5
- import { joinURL as z } from "ufo";
6
- import w from "lodash/noop";
7
- import { Icon as N } from "@iconify/react";
8
- import U from "@mui/icons-material/Notifications";
9
- import k from "@mui/icons-material/NotificationsOff";
10
- import v 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";
5
+ import { joinURL as N } from "ufo";
6
+ import h from "lodash/noop";
7
+ import { Icon as U } from "@iconify/react";
8
+ import v from "@mui/icons-material/Notifications";
9
+ import L from "@mui/icons-material/NotificationsOff";
10
+ import P from "../use-follow.js";
11
+ import { useLocaleContext as g } from "../../Locale/context.js";
12
+ import { translate as y } from "../../Locale/util.js";
13
+ import { isSupportFollow as j } from "../../Util/index.js";
14
14
  const _ = {
15
15
  zh: {
16
16
  chat: "聊天",
@@ -26,83 +26,84 @@ const _ = {
26
26
  follow_success: "Follow success",
27
27
  unfollow_success: "Unfollow success"
28
28
  }
29
- }, P = () => {
29
+ }, B = () => {
30
30
  const { componentMountPoints: o = [] } = window.blocklet || {};
31
31
  return o.find((n) => n.name === "did-comments")?.mountPoint;
32
32
  };
33
- function j({
33
+ function I({
34
34
  user: o,
35
35
  showSocialActions: t,
36
36
  session: n
37
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, {
38
+ const { locale: e } = g() || { locale: "en" }, i = u((d, m = {}) => y(_, d, e, "en", m)), r = l(() => !!n?.user?.did, [n?.user?.did]), c = l(() => B(), []), a = u(() => {
39
+ if (!r) {
40
+ n?.login(h, {
41
41
  openMode: "redirect",
42
42
  redirect: window.location.href
43
43
  });
44
44
  return;
45
45
  }
46
- window.open(z(l, `/chat/dm/${o?.did}`), "_blank");
46
+ window.open(N(c, `/chat/dm/${o?.did}`), "_blank");
47
47
  });
48
- return r(() => (typeof t == "boolean" ? !!t : t?.chat) && !!l, [t, l]) ? /* @__PURE__ */ m(
48
+ return l(() => (typeof t == "boolean" ? !!t : t?.chat) && !!c, [t, c]) ? /* @__PURE__ */ w(
49
49
  x,
50
50
  {
51
51
  className: "user-card__social-actions-chat",
52
52
  variant: "outlined",
53
53
  color: "primary",
54
54
  size: "small",
55
- onClick: c,
55
+ onClick: a,
56
56
  children: [
57
- /* @__PURE__ */ s(N, { icon: "tabler:message-dots", style: { marginRight: 4 } }),
58
- e("chat")
57
+ /* @__PURE__ */ s(U, { icon: "tabler:message-dots", style: { marginRight: 4 } }),
58
+ i("chat")
59
59
  ]
60
60
  }
61
61
  ) : null;
62
62
  }
63
- function B({
63
+ function $({
64
64
  user: o,
65
65
  showSocialActions: t,
66
- session: n
66
+ session: n,
67
+ onFollowClick: e
67
68
  }) {
68
- const { locale: i } = h() || { locale: "en" }, e = u((y, b = {}) => g(_, y, i, "en", b)), d = r(() => !!n?.user?.did, [n?.user?.did]), l = r(() => typeof t == "boolean" ? !!t : t?.follow, [t]), { followed: c, followUser: p, unfollowUser: a } = v({
69
+ const { locale: i } = g() || { locale: "en" }, r = u((p, M = {}) => y(_, p, i, "en", M)), c = l(() => !!n?.user?.did, [n?.user?.did]), a = l(() => typeof t == "boolean" ? !!t : t?.follow, [t]), { followed: f, followUser: d, unfollowUser: m } = P({
69
70
  user: o,
70
- t: e,
71
+ t: r,
71
72
  isMySelf: !1,
72
- visible: !!l
73
- }), f = u(() => {
74
- if (!d) {
75
- n?.login(w, {
73
+ visible: !!a
74
+ }), b = u((p) => {
75
+ if (!c) {
76
+ n?.login(h, {
76
77
  openMode: "redirect",
77
78
  redirect: window.location.href
78
79
  });
79
80
  return;
80
81
  }
81
- c ? a(o.did) : p(o.did);
82
+ f ? m(o.did) : d(o.did), e && typeof e == "function" && e(o, p);
82
83
  });
83
- return l ? /* @__PURE__ */ m(
84
+ return a ? /* @__PURE__ */ w(
84
85
  x,
85
86
  {
86
87
  className: "user-card__social-actions-follow",
87
88
  variant: "outlined",
88
89
  color: "primary",
89
90
  size: "small",
90
- onClick: f,
91
+ onClick: b,
91
92
  children: [
92
- c ? /* @__PURE__ */ s(k, { sx: { fontSize: 14, mr: 0.5 } }) : /* @__PURE__ */ s(U, { sx: { fontSize: 14, mr: 0.5 } }),
93
- e(c ? "unfollow" : "follow")
93
+ f ? /* @__PURE__ */ s(L, { sx: { fontSize: 14, mr: 0.5 } }) : /* @__PURE__ */ s(v, { sx: { fontSize: 14, mr: 0.5 } }),
94
+ r(f ? "unfollow" : "follow")
94
95
  ]
95
96
  }
96
97
  ) : null;
97
98
  }
98
- function Q({ showSocialActions: o, session: t, user: n }) {
99
- const i = r(() => t?.user?.did === n?.did, [t?.user?.did, n?.did]), e = r(() => L(), []);
100
- return i || !e || !o ? null : /* @__PURE__ */ m(M, { className: "user-card__social-actions", sx: { display: "flex", gap: 1 }, children: [
101
- /* @__PURE__ */ s(j, { session: t, user: n, showSocialActions: o }),
102
- /* @__PURE__ */ s(B, { session: t, user: n, showSocialActions: o })
99
+ function S({ showSocialActions: o, session: t, user: n, onFollowClick: e = void 0 }) {
100
+ const i = l(() => t?.user?.did === n?.did, [t?.user?.did, n?.did]), r = l(() => j(), []);
101
+ return i || !r || !o ? null : /* @__PURE__ */ w(F, { className: "user-card__social-actions", sx: { display: "flex", gap: 1 }, children: [
102
+ /* @__PURE__ */ s(I, { session: t, user: n, showSocialActions: o }),
103
+ /* @__PURE__ */ s($, { onFollowClick: e, session: t, user: n, showSocialActions: o })
103
104
  ] });
104
105
  }
105
- const x = C(F)`
106
+ const x = z(C)`
106
107
  color: ${({ theme: o }) => o.palette.text.primary};
107
108
  font-weight: 500;
108
109
  border-color: ${({ theme: o }) => o.palette.grey[300]};
@@ -110,5 +111,5 @@ const x = C(F)`
110
111
  `;
111
112
  export {
112
113
  x as ButtonWrapper,
113
- Q as default
114
+ S as default
114
115
  };
@@ -1,6 +1,6 @@
1
- import { jsxs as i, jsx as t } from "react/jsx-runtime";
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
2
  import { memo as g } from "react";
3
- import { useMediaQuery as y, Box as o, Typography as w, Divider as C } from "@mui/material";
3
+ import { useMediaQuery as w, Box as n, Typography as y, Divider as C } from "@mui/material";
4
4
  import { DID as S } from "../../DID/index.js";
5
5
  import b from "./tooltip-avatar.js";
6
6
  import { renderTopRight as v } from "../components.js";
@@ -9,20 +9,20 @@ import j from "../Cards/social-actions.js";
9
9
  function D({ ...s }) {
10
10
  const {
11
11
  user: e,
12
- showDid: d,
13
- didProps: m,
14
- avatarSize: c,
12
+ showDid: c,
13
+ didProps: d,
14
+ avatarSize: m,
15
15
  shouldShowHoverCard: p,
16
16
  renderCardContent: f,
17
- renderTopRightContent: a,
17
+ renderTopRightContent: l,
18
18
  topRightMaxWidth: h,
19
19
  avatarProps: x,
20
20
  shortenLabelProps: u,
21
- renderName: l,
22
- ...n
23
- } = s, r = y("(max-width:500px)");
24
- return /* @__PURE__ */ i(
25
- o,
21
+ renderName: a,
22
+ ...o
23
+ } = s, i = w("(max-width:500px)");
24
+ return /* @__PURE__ */ r(
25
+ n,
26
26
  {
27
27
  className: "user-card__avatar-content",
28
28
  sx: {
@@ -31,35 +31,35 @@ function D({ ...s }) {
31
31
  alignItems: "center"
32
32
  },
33
33
  children: [
34
- /* @__PURE__ */ i(
35
- o,
34
+ /* @__PURE__ */ r(
35
+ n,
36
36
  {
37
37
  sx: {
38
38
  display: "flex",
39
39
  justifyContent: "space-between",
40
- flexDirection: r ? "column" : "row",
41
- alignItems: r ? "flex-start" : "center",
42
- gap: r ? 2 : 1,
40
+ flexDirection: i ? "column" : "row",
41
+ alignItems: i ? "flex-start" : "center",
42
+ gap: i ? 2 : 1,
43
43
  flex: 1,
44
44
  minWidth: 0,
45
45
  flexWrap: "wrap"
46
46
  },
47
47
  children: [
48
- /* @__PURE__ */ i(o, { sx: { display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, flex: 1 }, children: [
48
+ /* @__PURE__ */ r(n, { sx: { display: "flex", justifyContent: "flex-start", alignItems: "center", gap: 1, flex: 1 }, children: [
49
49
  /* @__PURE__ */ t(
50
50
  b,
51
51
  {
52
52
  user: e,
53
- avatarSize: c,
53
+ avatarSize: m,
54
54
  shouldShowHoverCard: p,
55
55
  renderCardContent: f,
56
56
  avatarProps: x,
57
- ...n
57
+ ...o
58
58
  }
59
59
  ),
60
- /* @__PURE__ */ i(o, { children: [
60
+ /* @__PURE__ */ r(n, { children: [
61
61
  /* @__PURE__ */ t(
62
- w,
62
+ y,
63
63
  {
64
64
  variant: "subtitle1",
65
65
  className: "user-card__full-name-label",
@@ -70,10 +70,10 @@ function D({ ...s }) {
70
70
  fontSize: 18,
71
71
  lineHeight: 1.1
72
72
  },
73
- children: l ? l(e) : /* @__PURE__ */ t(W, { sx: { fontWeight: 500 }, ...u, children: e.fullName || e.email || e.did })
73
+ children: a ? a(e) : /* @__PURE__ */ t(W, { sx: { fontWeight: 500 }, ...u, children: e.fullName || e.email || e.did })
74
74
  }
75
75
  ),
76
- d && e.did ? /* @__PURE__ */ t(
76
+ c && e.did ? /* @__PURE__ */ t(
77
77
  S,
78
78
  {
79
79
  did: e.did,
@@ -82,17 +82,25 @@ function D({ ...s }) {
82
82
  compact: !0,
83
83
  locale: "en",
84
84
  sx: { lineHeight: 1.5 },
85
- ...m ?? {}
85
+ ...d ?? {}
86
86
  }
87
87
  ) : null
88
88
  ] })
89
89
  ] }),
90
- r ? /* @__PURE__ */ t(C, { sx: { width: "100%" } }) : null,
91
- a ? null : /* @__PURE__ */ t(j, { showSocialActions: n.showSocialActions, user: e, session: n.session })
90
+ i ? /* @__PURE__ */ t(C, { sx: { width: "100%" } }) : null,
91
+ l ? null : /* @__PURE__ */ t(
92
+ j,
93
+ {
94
+ onFollowClick: o.onFollowClick,
95
+ showSocialActions: o.showSocialActions,
96
+ user: e,
97
+ session: o.session
98
+ }
99
+ )
92
100
  ]
93
101
  }
94
102
  ),
95
- v(a, h)
103
+ v(l, h)
96
104
  ]
97
105
  }
98
106
  );
@@ -123,5 +123,6 @@ export interface UserCardProps {
123
123
  popupShowSocialActions?: SocialActionProps | boolean;
124
124
  renderCustomContent?: () => React.ReactNode;
125
125
  onAvatarClick?: (user: User, e?: React.MouseEvent<HTMLDivElement>) => void;
126
+ onFollowClick?: (user: User, e?: React.MouseEvent) => void;
126
127
  }
127
128
  export {};
@@ -1,4 +1,4 @@
1
- const e = "3.1.35", s = { "@blocklet/js-sdk": "^1.16.49-beta-20250823-082650-626c1473" }, t = {
1
+ const e = "3.1.37", s = { "@blocklet/js-sdk": "^1.16.49-beta-20250823-082650-626c1473" }, t = {
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.1.35",
3
+ "version": "3.1.37",
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": "52c5cb7cbc7f22fe05f9c1d85559199fb3166d72",
71
+ "gitHead": "2b0893787889c20893e9ff1f8c7a016f386882b4",
72
72
  "dependencies": {
73
- "@arcblock/bridge": "3.1.35",
73
+ "@arcblock/bridge": "3.1.37",
74
74
  "@arcblock/did": "^1.21.3",
75
75
  "@arcblock/did-motif": "^1.1.14",
76
- "@arcblock/icons": "3.1.35",
77
- "@arcblock/nft-display": "3.1.35",
78
- "@arcblock/react-hooks": "3.1.35",
76
+ "@arcblock/icons": "3.1.37",
77
+ "@arcblock/nft-display": "3.1.37",
78
+ "@arcblock/react-hooks": "3.1.37",
79
79
  "@blocklet/js-sdk": "^1.16.49-beta-20250823-082650-626c1473",
80
- "@blocklet/theme": "3.1.35",
80
+ "@blocklet/theme": "3.1.37",
81
81
  "@fontsource/roboto": "~5.1.1",
82
82
  "@fontsource/ubuntu-mono": "^5.2.6",
83
83
  "@iconify-icons/logos": "^1.2.36",
@@ -13,7 +13,7 @@ import { useLocaleContext } from '../../Locale/context';
13
13
  import { translate } from '../../Locale/util';
14
14
  import { isSupportFollow } from '../../Util';
15
15
 
16
- type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session'> & {
16
+ type SocialActionsProps = Pick<UserCardProps, 'showSocialActions' | 'session' | 'onFollowClick'> & {
17
17
  user: User; // 当前卡片显示的用户,要与 session.user 区分开
18
18
  };
19
19
 
@@ -101,10 +101,12 @@ function Follow({
101
101
  user,
102
102
  showSocialActions,
103
103
  session,
104
+ onFollowClick,
104
105
  }: {
105
106
  user: SocialActionsProps['user'];
106
107
  showSocialActions: SocialActionsProps['showSocialActions'];
107
108
  session: SocialActionsProps['session'];
109
+ onFollowClick: SocialActionsProps['onFollowClick'];
108
110
  }) {
109
111
  const { locale } = useLocaleContext() || { locale: 'en' };
110
112
  const t = useMemoizedFn((key, data = {}) => {
@@ -126,7 +128,7 @@ function Follow({
126
128
  isMySelf: false,
127
129
  visible: !!showFollow,
128
130
  });
129
- const handleFollowAction = useMemoizedFn(() => {
131
+ const handleFollowAction = useMemoizedFn((e) => {
130
132
  if (!isLogin) {
131
133
  session?.login(noop, {
132
134
  openMode: 'redirect',
@@ -139,6 +141,9 @@ function Follow({
139
141
  } else {
140
142
  followUser(user.did);
141
143
  }
144
+ if (onFollowClick && typeof onFollowClick === 'function') {
145
+ onFollowClick(user, e);
146
+ }
142
147
  });
143
148
 
144
149
  if (!showFollow) {
@@ -166,7 +171,7 @@ function Follow({
166
171
  // 按钮的显示逻辑
167
172
  // 通用逻辑: 1. user 和 session.user 不能是同一个用户, 2. 相关依赖支持,3. showSocialActions 为 true 或 为 object
168
173
  // 其他逻辑: 1. 如果 session 中没有用户信息,点击后需要重定向到登录页面
169
- function SocialActions({ showSocialActions, session, user }: SocialActionsProps) {
174
+ function SocialActions({ showSocialActions, session, user, onFollowClick = undefined }: SocialActionsProps) {
170
175
  const isSameUser = useMemo(() => {
171
176
  return session?.user?.did === user?.did;
172
177
  }, [session?.user?.did, user?.did]);
@@ -183,7 +188,7 @@ function SocialActions({ showSocialActions, session, user }: SocialActionsProps)
183
188
  return (
184
189
  <Box className="user-card__social-actions" sx={{ display: 'flex', gap: 1 }}>
185
190
  <Chat session={session} user={user} showSocialActions={showSocialActions} />
186
- <Follow session={session} user={user} showSocialActions={showSocialActions} />
191
+ <Follow onFollowClick={onFollowClick} session={session} user={user} showSocialActions={showSocialActions} />
187
192
  </Box>
188
193
  );
189
194
  }
@@ -95,7 +95,12 @@ function MinimalContent({ ...props }: MinimalContentProps) {
95
95
  </Box>
96
96
  {isSmallScreen ? <Divider sx={{ width: '100%' }} /> : null}
97
97
  {!renderTopRightContent ? (
98
- <SocialActions showSocialActions={rest.showSocialActions} user={user!} session={rest.session} />
98
+ <SocialActions
99
+ onFollowClick={rest.onFollowClick}
100
+ showSocialActions={rest.showSocialActions}
101
+ user={user!}
102
+ session={rest.session}
103
+ />
99
104
  ) : null}
100
105
  </Box>
101
106
  {renderTopRight(renderTopRightContent, topRightMaxWidth)}
@@ -160,4 +160,6 @@ export interface UserCardProps {
160
160
 
161
161
  // 头像点击事件
162
162
  onAvatarClick?: (user: User, e?: React.MouseEvent<HTMLDivElement>) => void;
163
+ // 点击follow按钮回调
164
+ onFollowClick?: (user: User, e?: React.MouseEvent) => void;
163
165
  }