@arcblock/ux 2.13.0 → 2.13.2

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.
@@ -21,6 +21,7 @@ export type AvatarProps = {
21
21
  blockiesPadding?: true | false;
22
22
  responsive?: false | true;
23
23
  } & Omit<import("../Img").ImgProps, "size" | "src">;
24
+ export { Avatar as AvatarProps };
24
25
  /**
25
26
  * Avatar component
26
27
  * @typedef {{
@@ -183,4 +183,7 @@ export default function AvatarWithErrorBoundary(props) {
183
183
  })
184
184
  });
185
185
  }
186
- AvatarWithErrorBoundary.propTypes = Avatar.propTypes;
186
+ AvatarWithErrorBoundary.propTypes = Avatar.propTypes;
187
+
188
+ // Export Avatar for access to its props
189
+ export { Avatar as AvatarProps };
@@ -4,6 +4,7 @@ interface BasicCardProps extends UserCardProps {
4
4
  shouldShowHoverCard: boolean;
5
5
  renderCardContent?: () => React.ReactNode | null;
6
6
  isFull?: boolean;
7
+ avatarProps?: UserCardProps['avatarProps'];
7
8
  }
8
9
  declare function BasicCard(props: BasicCardProps): import("react/jsx-runtime").JSX.Element;
9
10
  export default BasicCard;
@@ -17,7 +17,8 @@ function BasicCard(props) {
17
17
  topRightMaxWidth = 100,
18
18
  renderCustomContent,
19
19
  isFull = true,
20
- infoType = InfoType.Minimal
20
+ infoType = InfoType.Minimal,
21
+ avatarProps
21
22
  } = props;
22
23
  return /*#__PURE__*/_jsxs(Box, {
23
24
  display: "flex",
@@ -32,6 +33,7 @@ function BasicCard(props) {
32
33
  showDid: showDid,
33
34
  didProps: didProps,
34
35
  avatarSize: avatarSize,
36
+ avatarProps: avatarProps,
35
37
  shouldShowHoverCard: shouldShowHoverCard,
36
38
  renderCardContent: renderCardContent,
37
39
  renderTopRightContent: renderTopRightContent,
@@ -9,7 +9,7 @@ function NameOnlyCard(props) {
9
9
  avatarSize = 48
10
10
  } = props;
11
11
  return /*#__PURE__*/_jsxs(_Fragment, {
12
- children: [renderAvatar(user, avatarSize), /*#__PURE__*/_jsx(Typography, {
12
+ children: [renderAvatar(user, avatarSize, props.avatarProps), /*#__PURE__*/_jsx(Typography, {
13
13
  variant: "body1",
14
14
  children: user.fullName || user.email || user.did
15
15
  })]
@@ -1,13 +1,14 @@
1
1
  import React from 'react';
2
- import { CardType } from '../types';
2
+ import { UserCardProps } from '../types';
3
3
  interface CardContainerProps {
4
4
  children: React.ReactNode;
5
- cardType?: CardType;
5
+ cardType?: UserCardProps['cardType'];
6
6
  variant?: 'paper' | 'box';
7
7
  containerRef?: React.RefObject<HTMLDivElement>;
8
+ sx?: UserCardProps['sx'];
8
9
  }
9
10
  /**
10
11
  * 统一的卡片容器组件,处理常见的布局容器样式
11
12
  */
12
- declare function CardContainer({ children, cardType, variant, containerRef }: CardContainerProps): import("react/jsx-runtime").JSX.Element;
13
+ declare function CardContainer({ children, cardType, variant, containerRef, sx, }: CardContainerProps): import("react/jsx-runtime").JSX.Element;
13
14
  export default CardContainer;
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { Box, Paper } from '@mui/material';
4
4
  import { CardType } from '../types';
5
+ import { mergeSx } from '../../Util/style';
5
6
  /**
6
7
  * 统一的卡片容器组件,处理常见的布局容器样式
7
8
  */
@@ -9,7 +10,8 @@ function CardContainer({
9
10
  children,
10
11
  cardType = CardType.Detailed,
11
12
  variant = 'box',
12
- containerRef
13
+ containerRef,
14
+ sx
13
15
  }) {
14
16
  const commonStyles = {
15
17
  minWidth: 320,
@@ -34,12 +36,11 @@ function CardContainer({
34
36
  // Box变体,用于Minimal和NameOnly类型卡片
35
37
  return /*#__PURE__*/_jsx(Box, {
36
38
  ref: containerRef,
37
- sx: {
38
- ...commonStyles,
39
+ sx: mergeSx(commonStyles, {
39
40
  display: 'flex',
40
41
  alignItems: cardType === CardType.AvatarOnly ? 'center' : 'flex-start',
41
42
  gap: 2
42
- },
43
+ }, sx ? sx : null),
43
44
  children: children
44
45
  });
45
46
  }
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
+ import { UserCardProps } from '../types';
2
3
  interface DialogContainerProps {
3
4
  children: React.ReactNode;
5
+ sx?: UserCardProps['sx'];
4
6
  }
5
7
  /**
6
8
  * 统一的卡片容器组件,处理常见的布局容器样式
7
9
  */
8
- declare function DialogContainer({ children }: DialogContainerProps): import("react/jsx-runtime").JSX.Element;
10
+ declare function DialogContainer({ children, sx }: DialogContainerProps): import("react/jsx-runtime").JSX.Element;
9
11
  export default DialogContainer;
@@ -1,16 +1,18 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { Box, useTheme } from '@mui/material';
4
+ import { mergeSx } from '../../Util/style';
4
5
  /**
5
6
  * 统一的卡片容器组件,处理常见的布局容器样式
6
7
  */
7
8
  function DialogContainer({
8
- children
9
+ children,
10
+ sx
9
11
  }) {
10
12
  // Box变体,用于Minimal和NameOnly类型卡片
11
13
  const theme = useTheme();
12
14
  return /*#__PURE__*/_jsx(Box, {
13
- sx: {
15
+ sx: mergeSx({
14
16
  p: 2,
15
17
  backgroundColor: theme.palette.background.paper,
16
18
  border: '1px solid',
@@ -19,7 +21,7 @@ function DialogContainer({
19
21
  maxWidth: 400,
20
22
  minWidth: 320,
21
23
  display: 'flex'
22
- },
24
+ }, sx),
23
25
  children: children
24
26
  });
25
27
  }
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { User } from '../types';
2
+ import { User, UserCardProps } from '../types';
3
3
  interface MinimalContentProps {
4
4
  user: User;
5
5
  showDid: boolean;
@@ -9,6 +9,7 @@ interface MinimalContentProps {
9
9
  didProps: Record<string, any>;
10
10
  renderTopRightContent?: () => React.ReactNode;
11
11
  topRightMaxWidth: number;
12
+ avatarProps?: UserCardProps['avatarProps'];
12
13
  }
13
14
  declare function MinimalContent(props: MinimalContentProps): import("react/jsx-runtime").JSX.Element;
14
15
  declare const _default: React.MemoExoticComponent<typeof MinimalContent>;
@@ -13,7 +13,8 @@ function MinimalContent(props) {
13
13
  shouldShowHoverCard,
14
14
  renderCardContent,
15
15
  renderTopRightContent,
16
- topRightMaxWidth
16
+ topRightMaxWidth,
17
+ avatarProps
17
18
  } = props;
18
19
  return /*#__PURE__*/_jsxs(Box, {
19
20
  display: "flex",
@@ -30,7 +31,8 @@ function MinimalContent(props) {
30
31
  user: user,
31
32
  avatarSize: avatarSize,
32
33
  shouldShowHoverCard: shouldShowHoverCard,
33
- renderCardContent: renderCardContent
34
+ renderCardContent: renderCardContent,
35
+ avatarProps: avatarProps
34
36
  }), /*#__PURE__*/_jsxs(Box, {
35
37
  children: [/*#__PURE__*/_jsx(Typography, {
36
38
  variant: "subtitle1",
@@ -7,10 +7,11 @@ interface TooltipAvatarProps {
7
7
  renderCardContent?: () => React.ReactNode | null;
8
8
  tooltipTitle?: string;
9
9
  tooltipProps?: UserCardProps['tooltipProps'];
10
+ avatarProps?: UserCardProps['avatarProps'];
10
11
  }
11
12
  /**
12
13
  * 统一处理头像的Tooltip显示组件
13
14
  * 根据条件显示普通Tooltip、自定义Tooltip内容或无Tooltip的头像
14
15
  */
15
- declare function TooltipAvatar({ user, avatarSize, shouldShowHoverCard, renderCardContent, tooltipTitle, tooltipProps, }: TooltipAvatarProps): import("react/jsx-runtime").JSX.Element;
16
+ declare function TooltipAvatar({ user, avatarSize, shouldShowHoverCard, renderCardContent, tooltipTitle, tooltipProps, avatarProps, }: TooltipAvatarProps): import("react/jsx-runtime").JSX.Element;
16
17
  export default TooltipAvatar;
@@ -13,8 +13,13 @@ function TooltipAvatar({
13
13
  shouldShowHoverCard,
14
14
  renderCardContent,
15
15
  tooltipTitle,
16
- tooltipProps
16
+ tooltipProps,
17
+ avatarProps
17
18
  }) {
19
+ const avatarElement = /*#__PURE__*/_jsx(Box, {
20
+ display: "inline-block",
21
+ children: renderAvatar(user, avatarSize, avatarProps)
22
+ });
18
23
  // 使用普通文本Tooltip
19
24
  if (tooltipTitle) {
20
25
  return /*#__PURE__*/_jsx(Tooltip, {
@@ -22,12 +27,7 @@ function TooltipAvatar({
22
27
  title: tooltipTitle,
23
28
  placement: "bottom",
24
29
  ...(tooltipProps ?? {}),
25
- children: /*#__PURE__*/_jsx("div", {
26
- style: {
27
- display: 'inline-block'
28
- },
29
- children: renderAvatar(user, avatarSize)
30
- })
30
+ children: avatarElement
31
31
  });
32
32
  }
33
33
 
@@ -50,17 +50,11 @@ function TooltipAvatar({
50
50
  }
51
51
  },
52
52
  ...(tooltipProps ?? {}),
53
- children: /*#__PURE__*/_jsx(Box, {
54
- display: "inline-block",
55
- children: renderAvatar(user, avatarSize)
56
- })
53
+ children: avatarElement
57
54
  });
58
55
  }
59
56
 
60
57
  // 无Tooltip
61
- return /*#__PURE__*/_jsx(Box, {
62
- display: "inline-block",
63
- children: renderAvatar(user, avatarSize)
64
- });
58
+ return avatarElement;
65
59
  }
66
60
  export default TooltipAvatar;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
- import { User } from './types';
3
- export declare const renderAvatar: (user: User, avatarSize?: number) => import("react/jsx-runtime").JSX.Element;
2
+ import { UserCardProps } from './types';
3
+ export declare const renderAvatar: (user: UserCardProps["user"], avatarSize?: number, avatarProps?: UserCardProps["avatarProps"]) => import("react/jsx-runtime").JSX.Element;
4
4
  export declare const renderTopRight: (renderTopRightContent: (() => React.ReactNode) | undefined, topRightMaxWidth: number) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,33 +1,38 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Box, Avatar } from '@mui/material';
3
+ import { Box } from '@mui/material';
4
+ import Avatar from '../Avatar';
4
5
  import { createNameOnlyAvatar } from './utils';
5
6
 
6
7
  // 渲染头像
7
- export const renderAvatar = (user, avatarSize = 48) => {
8
+ export const renderAvatar = (user, avatarSize = 48, avatarProps = undefined) => {
8
9
  // 如果用户没有头像,则显示名称首字母头像
9
10
  if (!user.avatar) {
10
11
  const avatarContent = createNameOnlyAvatar(user);
11
12
  return /*#__PURE__*/_jsx(Avatar, {
13
+ size: avatarSize,
14
+ did: user.did,
15
+ variant: "circle",
12
16
  sx: {
13
- width: avatarSize,
14
- height: avatarSize,
15
17
  fontSize: avatarSize * 0.4,
16
18
  cursor: 'pointer'
17
19
  },
20
+ ...(avatarProps || {}),
18
21
  children: avatarContent
19
22
  });
20
23
  }
21
24
 
22
25
  // 显示用户头像
23
26
  return /*#__PURE__*/_jsx(Avatar, {
24
- sx: {
25
- width: avatarSize,
26
- height: avatarSize,
27
+ size: avatarSize,
28
+ did: user.did,
29
+ variant: "circle",
30
+ style: {
27
31
  cursor: 'pointer'
28
32
  },
29
33
  src: user.avatar,
30
- alt: user.fullName || ''
34
+ alt: user.fullName || '',
35
+ ...(avatarProps || {})
31
36
  });
32
37
  };
33
38
 
@@ -39,10 +39,13 @@ function UserCard(props) {
39
39
 
40
40
  // 渲染卡片内容(用于Tooltip)
41
41
  const renderCardContent = () => {
42
+ const _avatarProps = props.popupAvatarProps || props.avatarProps;
42
43
  return /*#__PURE__*/_jsx(DialogContainer, {
44
+ sx: props.popupSx,
43
45
  children: /*#__PURE__*/_jsx(DetailedCard, {
44
46
  ...props,
45
- shouldShowHoverCard: false
47
+ shouldShowHoverCard: false,
48
+ avatarProps: _avatarProps
46
49
  })
47
50
  });
48
51
  };
@@ -60,6 +63,7 @@ function UserCard(props) {
60
63
  return /*#__PURE__*/_jsx(CardContainer, {
61
64
  containerRef: containerRef,
62
65
  cardType: cardType,
66
+ sx: props.sx,
63
67
  children: /*#__PURE__*/_jsx(DetailedCard, {
64
68
  ...props,
65
69
  shouldShowHoverCard: shouldShowHoverCard,
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { TooltipProps } from '@mui/material';
2
+ import { SxProps, Theme, TooltipProps } from '@mui/material';
3
3
  import { DIDProps } from '../DID';
4
+ import { AvatarProps } from '../Avatar';
4
5
  type UserPublicInfo = {
5
6
  avatar: string;
6
7
  did: string;
@@ -97,7 +98,11 @@ export interface UserCardProps {
97
98
  showHoverCard?: boolean;
98
99
  showDid?: boolean;
99
100
  didProps?: DIDProps;
101
+ avatarProps?: Partial<AvatarProps>;
102
+ popupAvatarProps?: Partial<AvatarProps>;
100
103
  tooltipProps?: Omit<TooltipProps, 'title'>;
104
+ sx?: SxProps<Theme>;
105
+ popupSx?: SxProps<Theme>;
101
106
  renderTopRightContent?: () => React.ReactNode;
102
107
  topRightMaxWidth?: number;
103
108
  renderCustomContent?: () => React.ReactNode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.13.0",
3
+ "version": "2.13.2",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -70,12 +70,12 @@
70
70
  "react": ">=18.2.0",
71
71
  "react-router-dom": ">=6.22.3"
72
72
  },
73
- "gitHead": "6f5c451c75845608ebc3c559ef64c739238b65e1",
73
+ "gitHead": "20a687d035cac39b37ddcbbc478afc416efe2877",
74
74
  "dependencies": {
75
75
  "@arcblock/did-motif": "^1.1.13",
76
- "@arcblock/icons": "^2.13.0",
77
- "@arcblock/nft-display": "^2.13.0",
78
- "@arcblock/react-hooks": "^2.13.0",
76
+ "@arcblock/icons": "^2.13.2",
77
+ "@arcblock/nft-display": "^2.13.2",
78
+ "@arcblock/react-hooks": "^2.13.2",
79
79
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
80
80
  "@fontsource/roboto": "~5.1.1",
81
81
  "@fontsource/ubuntu-mono": "^5.0.18",
@@ -164,3 +164,6 @@ export default function AvatarWithErrorBoundary(props) {
164
164
  }
165
165
 
166
166
  AvatarWithErrorBoundary.propTypes = Avatar.propTypes;
167
+
168
+ // Export Avatar for access to its props
169
+ export { Avatar as AvatarProps };
@@ -9,6 +9,7 @@ interface BasicCardProps extends UserCardProps {
9
9
  shouldShowHoverCard: boolean;
10
10
  renderCardContent?: () => React.ReactNode | null;
11
11
  isFull?: boolean;
12
+ avatarProps?: UserCardProps['avatarProps'];
12
13
  }
13
14
 
14
15
  // 详细卡片模式下的Basic渲染组件
@@ -25,6 +26,7 @@ function BasicCard(props: BasicCardProps) {
25
26
  renderCustomContent,
26
27
  isFull = true,
27
28
  infoType = InfoType.Minimal,
29
+ avatarProps,
28
30
  } = props;
29
31
 
30
32
  return (
@@ -34,6 +36,7 @@ function BasicCard(props: BasicCardProps) {
34
36
  showDid={showDid}
35
37
  didProps={didProps}
36
38
  avatarSize={avatarSize}
39
+ avatarProps={avatarProps}
37
40
  shouldShowHoverCard={shouldShowHoverCard}
38
41
  renderCardContent={renderCardContent}
39
42
  renderTopRightContent={renderTopRightContent}
@@ -8,7 +8,7 @@ function NameOnlyCard(props: UserCardProps) {
8
8
 
9
9
  return (
10
10
  <>
11
- {renderAvatar(user, avatarSize)}
11
+ {renderAvatar(user, avatarSize, props.avatarProps)}
12
12
  <Typography variant="body1">{user.fullName || user.email || user.did}</Typography>
13
13
  </>
14
14
  );
@@ -1,18 +1,26 @@
1
1
  import React from 'react';
2
- import { Box, Paper } from '@mui/material';
3
- import { CardType } from '../types';
2
+ import { Box, Paper, SxProps } from '@mui/material';
3
+ import { UserCardProps, CardType } from '../types';
4
+ import { mergeSx } from '../../Util/style';
4
5
 
5
6
  interface CardContainerProps {
6
7
  children: React.ReactNode;
7
- cardType?: CardType;
8
+ cardType?: UserCardProps['cardType'];
8
9
  variant?: 'paper' | 'box';
9
10
  containerRef?: React.RefObject<HTMLDivElement>;
11
+ sx?: UserCardProps['sx'];
10
12
  }
11
13
 
12
14
  /**
13
15
  * 统一的卡片容器组件,处理常见的布局容器样式
14
16
  */
15
- function CardContainer({ children, cardType = CardType.Detailed, variant = 'box', containerRef }: CardContainerProps) {
17
+ function CardContainer({
18
+ children,
19
+ cardType = CardType.Detailed,
20
+ variant = 'box',
21
+ containerRef,
22
+ sx,
23
+ }: CardContainerProps) {
16
24
  const commonStyles = {
17
25
  minWidth: 320,
18
26
  p: 2,
@@ -38,12 +46,15 @@ function CardContainer({ children, cardType = CardType.Detailed, variant = 'box'
38
46
  return (
39
47
  <Box
40
48
  ref={containerRef}
41
- sx={{
42
- ...commonStyles,
43
- display: 'flex',
44
- alignItems: cardType === CardType.AvatarOnly ? 'center' : 'flex-start',
45
- gap: 2,
46
- }}>
49
+ sx={mergeSx(
50
+ commonStyles,
51
+ {
52
+ display: 'flex',
53
+ alignItems: cardType === CardType.AvatarOnly ? 'center' : 'flex-start',
54
+ gap: 2,
55
+ },
56
+ sx ? (sx as SxProps) : null
57
+ )}>
47
58
  {children}
48
59
  </Box>
49
60
  );
@@ -1,28 +1,34 @@
1
1
  import React from 'react';
2
- import { Box, useTheme } from '@mui/material';
2
+ import { Box, SxProps, useTheme } from '@mui/material';
3
+ import { UserCardProps } from '../types';
4
+ import { mergeSx } from '../../Util/style';
3
5
 
4
6
  interface DialogContainerProps {
5
7
  children: React.ReactNode;
8
+ sx?: UserCardProps['sx'];
6
9
  }
7
10
 
8
11
  /**
9
12
  * 统一的卡片容器组件,处理常见的布局容器样式
10
13
  */
11
- function DialogContainer({ children }: DialogContainerProps) {
14
+ function DialogContainer({ children, sx }: DialogContainerProps) {
12
15
  // Box变体,用于Minimal和NameOnly类型卡片
13
16
  const theme = useTheme();
14
17
  return (
15
18
  <Box
16
- sx={{
17
- p: 2,
18
- backgroundColor: theme.palette.background.paper,
19
- border: '1px solid',
20
- borderColor: 'divider',
21
- borderRadius: 2,
22
- maxWidth: 400,
23
- minWidth: 320,
24
- display: 'flex',
25
- }}>
19
+ sx={mergeSx(
20
+ {
21
+ p: 2,
22
+ backgroundColor: theme.palette.background.paper,
23
+ border: '1px solid',
24
+ borderColor: 'divider',
25
+ borderRadius: 2,
26
+ maxWidth: 400,
27
+ minWidth: 320,
28
+ display: 'flex',
29
+ },
30
+ sx as SxProps
31
+ )}>
26
32
  {children}
27
33
  </Box>
28
34
  );
@@ -1,7 +1,7 @@
1
1
  import React, { memo } from 'react';
2
2
  import { Typography, Box } from '@mui/material';
3
3
  import DID from '../../DID';
4
- import { User } from '../types';
4
+ import { User, UserCardProps } from '../types';
5
5
  import TooltipAvatar from './tooltip-avatar';
6
6
  import { renderTopRight } from '../components';
7
7
 
@@ -14,6 +14,7 @@ interface MinimalContentProps {
14
14
  didProps: Record<string, any>;
15
15
  renderTopRightContent?: () => React.ReactNode;
16
16
  topRightMaxWidth: number;
17
+ avatarProps?: UserCardProps['avatarProps'];
17
18
  }
18
19
 
19
20
  function MinimalContent(props: MinimalContentProps) {
@@ -26,6 +27,7 @@ function MinimalContent(props: MinimalContentProps) {
26
27
  renderCardContent,
27
28
  renderTopRightContent,
28
29
  topRightMaxWidth,
30
+ avatarProps,
29
31
  } = props;
30
32
 
31
33
  return (
@@ -36,6 +38,7 @@ function MinimalContent(props: MinimalContentProps) {
36
38
  avatarSize={avatarSize}
37
39
  shouldShowHoverCard={shouldShowHoverCard}
38
40
  renderCardContent={renderCardContent}
41
+ avatarProps={avatarProps}
39
42
  />
40
43
  <Box>
41
44
  <Typography
@@ -12,6 +12,7 @@ interface TooltipAvatarProps {
12
12
  renderCardContent?: () => React.ReactNode | null;
13
13
  tooltipTitle?: string;
14
14
  tooltipProps?: UserCardProps['tooltipProps'];
15
+ avatarProps?: UserCardProps['avatarProps'];
15
16
  }
16
17
 
17
18
  /**
@@ -25,12 +26,14 @@ function TooltipAvatar({
25
26
  renderCardContent,
26
27
  tooltipTitle,
27
28
  tooltipProps,
29
+ avatarProps,
28
30
  }: TooltipAvatarProps) {
31
+ const avatarElement = <Box display="inline-block">{renderAvatar(user, avatarSize, avatarProps)}</Box>;
29
32
  // 使用普通文本Tooltip
30
33
  if (tooltipTitle) {
31
34
  return (
32
35
  <Tooltip enterDelay={200} title={tooltipTitle} placement="bottom" {...(tooltipProps ?? {})}>
33
- <div style={{ display: 'inline-block' }}>{renderAvatar(user, avatarSize)}</div>
36
+ {avatarElement}
34
37
  </Tooltip>
35
38
  );
36
39
  }
@@ -55,13 +58,13 @@ function TooltipAvatar({
55
58
  },
56
59
  }}
57
60
  {...(tooltipProps ?? {})}>
58
- <Box display="inline-block">{renderAvatar(user, avatarSize)}</Box>
61
+ {avatarElement}
59
62
  </Tooltip>
60
63
  );
61
64
  }
62
65
 
63
66
  // 无Tooltip
64
- return <Box display="inline-block">{renderAvatar(user, avatarSize)}</Box>;
67
+ return avatarElement;
65
68
  }
66
69
 
67
70
  export default TooltipAvatar;
@@ -1,22 +1,29 @@
1
1
  import React from 'react';
2
- import { Box, Avatar } from '@mui/material';
3
- import { User } from './types';
2
+ import { Box } from '@mui/material';
3
+ import Avatar from '../Avatar';
4
+ import { UserCardProps } from './types';
4
5
  import { createNameOnlyAvatar } from './utils';
5
6
 
6
7
  // 渲染头像
7
- export const renderAvatar = (user: User, avatarSize: number = 48) => {
8
+ export const renderAvatar = (
9
+ user: UserCardProps['user'],
10
+ avatarSize: number = 48,
11
+ avatarProps: UserCardProps['avatarProps'] = undefined
12
+ ) => {
8
13
  // 如果用户没有头像,则显示名称首字母头像
9
14
  if (!user.avatar) {
10
15
  const avatarContent = createNameOnlyAvatar(user);
11
16
 
12
17
  return (
13
18
  <Avatar
19
+ size={avatarSize}
20
+ did={user.did}
21
+ variant="circle"
14
22
  sx={{
15
- width: avatarSize,
16
- height: avatarSize,
17
23
  fontSize: avatarSize * 0.4,
18
24
  cursor: 'pointer',
19
- }}>
25
+ }}
26
+ {...(avatarProps || {})}>
20
27
  {avatarContent}
21
28
  </Avatar>
22
29
  );
@@ -25,13 +32,15 @@ export const renderAvatar = (user: User, avatarSize: number = 48) => {
25
32
  // 显示用户头像
26
33
  return (
27
34
  <Avatar
28
- sx={{
29
- width: avatarSize,
30
- height: avatarSize,
35
+ size={avatarSize}
36
+ did={user.did}
37
+ variant="circle"
38
+ style={{
31
39
  cursor: 'pointer',
32
40
  }}
33
41
  src={user.avatar}
34
42
  alt={user.fullName || ''}
43
+ {...(avatarProps || {})}
35
44
  />
36
45
  );
37
46
  };
@@ -38,9 +38,10 @@ function UserCard(props: UserCardProps) {
38
38
 
39
39
  // 渲染卡片内容(用于Tooltip)
40
40
  const renderCardContent = () => {
41
+ const _avatarProps = props.popupAvatarProps || props.avatarProps;
41
42
  return (
42
- <DialogContainer>
43
- <DetailedCard {...props} shouldShowHoverCard={false} />
43
+ <DialogContainer sx={props.popupSx}>
44
+ <DetailedCard {...props} shouldShowHoverCard={false} avatarProps={_avatarProps} />
44
45
  </DialogContainer>
45
46
  );
46
47
  };
@@ -54,7 +55,7 @@ function UserCard(props: UserCardProps) {
54
55
 
55
56
  // 详细卡片模式
56
57
  return (
57
- <CardContainer containerRef={containerRef} cardType={cardType}>
58
+ <CardContainer containerRef={containerRef} cardType={cardType} sx={props.sx}>
58
59
  <DetailedCard {...props} shouldShowHoverCard={shouldShowHoverCard} renderCardContent={renderCardContent} />
59
60
  </CardContainer>
60
61
  );
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
- import { TooltipProps } from '@mui/material';
2
+ import { SxProps, Theme, TooltipProps } from '@mui/material';
3
3
  import { DIDProps } from '../DID';
4
+ import { AvatarProps } from '../Avatar';
4
5
 
5
6
  type UserPublicInfo = {
6
7
  avatar: string;
@@ -115,9 +116,16 @@ export interface UserCardProps {
115
116
  showDid?: boolean;
116
117
  didProps?: DIDProps;
117
118
 
119
+ avatarProps?: Partial<AvatarProps>;
120
+ popupAvatarProps?: Partial<AvatarProps>;
121
+
118
122
  // 弹出层相关属性
119
123
  tooltipProps?: Omit<TooltipProps, 'title'>;
120
124
 
125
+ // 样式相关属性
126
+ sx?: SxProps<Theme>;
127
+ popupSx?: SxProps<Theme>;
128
+
121
129
  // 右上角内容相关属性
122
130
  renderTopRightContent?: () => React.ReactNode;
123
131
  topRightMaxWidth?: number;