@arcblock/ux 2.13.10 → 2.13.11

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.
@@ -17,6 +17,7 @@ function MinimalContent(props) {
17
17
  topRightMaxWidth,
18
18
  avatarProps,
19
19
  shortenLabelProps,
20
+ renderName,
20
21
  ...rest
21
22
  } = props;
22
23
  return /*#__PURE__*/_jsxs(Box, {
@@ -49,7 +50,10 @@ function MinimalContent(props) {
49
50
  sx: {
50
51
  lineHeight: 1.1
51
52
  },
52
- children: /*#__PURE__*/_jsx(ShortenLabel, {
53
+ children: renderName ? renderName(user) : /*#__PURE__*/_jsx(ShortenLabel, {
54
+ sx: {
55
+ fontWeight: 500
56
+ },
53
57
  ...shortenLabelProps,
54
58
  children: user.fullName || user.email || user.did
55
59
  })
@@ -38,7 +38,7 @@ function UserCard(props) {
38
38
  // 默认规则:AvatarOnly模式下默认显示悬停卡片,Detailed模式下默认不显示
39
39
  const shouldShowHoverCard = showHoverCard !== undefined ? showHoverCard : cardType === CardType.AvatarOnly;
40
40
  const containerRef = useRef(null);
41
- const [user, setUser] = useState(null);
41
+ const [user, setUser] = useState(() => props.user || null);
42
42
  useEffect(() => {
43
43
  let isSubscribed = true;
44
44
  if (props.user) {
@@ -67,17 +67,16 @@ function UserCard(props) {
67
67
  // user 存在,则使用 user 渲染头像
68
68
  // 渲染卡片内容(用于Tooltip)
69
69
  const renderCardContent = () => {
70
- const _avatarProps = props.popupAvatarProps || props.avatarProps;
71
- const _shortenLabelProps = props.popupShortenLabelProps || props.shortenLabelProps;
72
70
  return /*#__PURE__*/_jsx(DialogContainer, {
73
71
  sx: props.popupSx,
74
72
  children: /*#__PURE__*/_jsx(DetailedCard, {
75
73
  ...props,
76
74
  shouldShowHoverCard: false,
77
75
  user: user,
78
- avatarProps: _avatarProps,
79
- shortenLabelProps: _shortenLabelProps,
80
- renderFields: props.popupRenderFields
76
+ avatarProps: props.popupAvatarProps,
77
+ shortenLabelProps: props.popupShortenLabelProps,
78
+ renderFields: props.popupRenderFields,
79
+ renderName: props.popupRenderName
81
80
  })
82
81
  });
83
82
  };
@@ -106,6 +106,8 @@ export interface UserCardProps {
106
106
  popupSx?: SxProps<Theme>;
107
107
  shortenLabelProps?: Partial<ShortenLabelProps>;
108
108
  popupShortenLabelProps?: Partial<ShortenLabelProps>;
109
+ renderName?: (user: User) => React.ReactNode;
110
+ popupRenderName?: (user: User) => React.ReactNode;
109
111
  renderFields?: string[];
110
112
  popupRenderFields?: string[];
111
113
  renderTopRightContent?: () => React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.13.10",
3
+ "version": "2.13.11",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -70,14 +70,14 @@
70
70
  "react": ">=18.2.0",
71
71
  "react-router-dom": ">=6.22.3"
72
72
  },
73
- "gitHead": "164845889eb29a84f9da191b79f66c43554f9fa1",
73
+ "gitHead": "32dc7f93255afb229ce70bc9a9777b378ae19c91",
74
74
  "dependencies": {
75
75
  "@arcblock/did-motif": "^1.1.13",
76
- "@arcblock/icons": "^2.13.10",
77
- "@arcblock/nft-display": "^2.13.10",
78
- "@arcblock/react-hooks": "^2.13.10",
76
+ "@arcblock/icons": "^2.13.11",
77
+ "@arcblock/nft-display": "^2.13.11",
78
+ "@arcblock/react-hooks": "^2.13.11",
79
79
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
80
- "@blocklet/theme": "^2.13.10",
80
+ "@blocklet/theme": "^2.13.11",
81
81
  "@fontsource/roboto": "~5.1.1",
82
82
  "@fontsource/ubuntu-mono": "^5.0.18",
83
83
  "@iconify-icons/logos": "^1.2.36",
@@ -27,6 +27,7 @@ function MinimalContent(props: MinimalContentProps) {
27
27
  topRightMaxWidth,
28
28
  avatarProps,
29
29
  shortenLabelProps,
30
+ renderName,
30
31
  ...rest
31
32
  } = props;
32
33
 
@@ -50,7 +51,13 @@ function MinimalContent(props: MinimalContentProps) {
50
51
  fontSize={18}
51
52
  noWrap
52
53
  sx={{ lineHeight: 1.1 }}>
53
- <ShortenLabel {...shortenLabelProps}>{user.fullName || user.email || user.did}</ShortenLabel>
54
+ {renderName ? (
55
+ renderName(user)
56
+ ) : (
57
+ <ShortenLabel sx={{ fontWeight: 500 }} {...shortenLabelProps}>
58
+ {user.fullName || user.email || user.did}
59
+ </ShortenLabel>
60
+ )}
54
61
  </Typography>
55
62
 
56
63
  {showDid && user.did ? (
@@ -38,7 +38,7 @@ function UserCard(props: UserCardProps) {
38
38
  const shouldShowHoverCard = showHoverCard !== undefined ? showHoverCard : cardType === CardType.AvatarOnly;
39
39
 
40
40
  const containerRef = useRef<HTMLDivElement>(null);
41
- const [user, setUser] = useState<User | null>(null);
41
+ const [user, setUser] = useState<User | null>(() => props.user || null);
42
42
 
43
43
  useEffect(() => {
44
44
  let isSubscribed = true;
@@ -64,17 +64,16 @@ function UserCard(props: UserCardProps) {
64
64
  // user 存在,则使用 user 渲染头像
65
65
  // 渲染卡片内容(用于Tooltip)
66
66
  const renderCardContent = () => {
67
- const _avatarProps = props.popupAvatarProps || props.avatarProps;
68
- const _shortenLabelProps = props.popupShortenLabelProps || props.shortenLabelProps;
69
67
  return (
70
68
  <DialogContainer sx={props.popupSx}>
71
69
  <DetailedCard
72
70
  {...props}
73
71
  shouldShowHoverCard={false}
74
72
  user={user!}
75
- avatarProps={_avatarProps}
76
- shortenLabelProps={_shortenLabelProps}
73
+ avatarProps={props.popupAvatarProps}
74
+ shortenLabelProps={props.popupShortenLabelProps}
77
75
  renderFields={props.popupRenderFields}
76
+ renderName={props.popupRenderName}
78
77
  />
79
78
  </DialogContainer>
80
79
  );
@@ -131,6 +131,11 @@ export interface UserCardProps {
131
131
  shortenLabelProps?: Partial<ShortenLabelProps>;
132
132
  popupShortenLabelProps?: Partial<ShortenLabelProps>;
133
133
 
134
+ // 自定义渲染 name
135
+ // 如果设置了 renderName,shortenLabelProps 无效
136
+ renderName?: (user: User) => React.ReactNode;
137
+ popupRenderName?: (user: User) => React.ReactNode;
138
+
134
139
  // 自定义渲染字段
135
140
  renderFields?: string[];
136
141
  popupRenderFields?: string[];