@arcblock/ux 2.12.64 → 2.12.71

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 (74) hide show
  1. package/lib/Config/config-provider.js +9 -0
  2. package/lib/Config/index.d.ts +1 -0
  3. package/lib/Config/index.js +1 -0
  4. package/lib/Datatable/index.d.ts +2 -2
  5. package/lib/Datatable/index.js +2 -2
  6. package/lib/Header/header.js +6 -2
  7. package/lib/Img/index.js +4 -4
  8. package/lib/Locale/selector.js +8 -18
  9. package/lib/NavMenu/style.js +10 -8
  10. package/lib/NavMenu/sub-item-group.js +6 -2
  11. package/lib/SessionBlocklet/index.js +7 -15
  12. package/lib/SessionUser/components/logged-in.js +4 -8
  13. package/lib/Theme/theme.d.ts +2 -0
  14. package/lib/Theme/theme.js +2 -1
  15. package/lib/UserCard/Cards/avatar-only.d.ts +8 -0
  16. package/lib/UserCard/Cards/avatar-only.js +34 -0
  17. package/lib/UserCard/Cards/basic-info.d.ts +9 -0
  18. package/lib/UserCard/Cards/basic-info.js +51 -0
  19. package/lib/UserCard/Cards/index.d.ts +8 -0
  20. package/lib/UserCard/Cards/index.js +24 -0
  21. package/lib/UserCard/Cards/name-only.d.ts +3 -0
  22. package/lib/UserCard/Cards/name-only.js +18 -0
  23. package/lib/UserCard/Container/card.d.ts +13 -0
  24. package/lib/UserCard/Container/card.js +46 -0
  25. package/lib/UserCard/Container/dialog.d.ts +9 -0
  26. package/lib/UserCard/Container/dialog.js +25 -0
  27. package/lib/UserCard/Content/basic.d.ts +7 -0
  28. package/lib/UserCard/Content/basic.js +139 -0
  29. package/lib/UserCard/Content/clock.d.ts +4 -0
  30. package/lib/UserCard/Content/clock.js +68 -0
  31. package/lib/UserCard/Content/left-layout.d.ts +16 -0
  32. package/lib/UserCard/Content/left-layout.js +33 -0
  33. package/lib/UserCard/Content/minimal.d.ts +15 -0
  34. package/lib/UserCard/Content/minimal.js +61 -0
  35. package/lib/UserCard/Content/tooltip-avatar.d.ts +15 -0
  36. package/lib/UserCard/Content/tooltip-avatar.js +61 -0
  37. package/lib/UserCard/components.d.ts +4 -0
  38. package/lib/UserCard/components.js +45 -0
  39. package/lib/UserCard/index.d.ts +5 -0
  40. package/lib/UserCard/index.js +74 -0
  41. package/lib/UserCard/types.d.ts +107 -0
  42. package/lib/UserCard/types.js +42 -0
  43. package/lib/UserCard/utils.d.ts +2 -0
  44. package/lib/UserCard/utils.js +19 -0
  45. package/lib/hooks/use-clock.d.ts +10 -0
  46. package/lib/hooks/use-clock.js +71 -0
  47. package/package.json +5 -5
  48. package/src/Config/config-provider.tsx +7 -0
  49. package/src/Config/index.ts +1 -0
  50. package/src/Datatable/index.jsx +2 -2
  51. package/src/Header/header.tsx +2 -2
  52. package/src/Img/index.jsx +35 -32
  53. package/src/Locale/selector.tsx +7 -14
  54. package/src/NavMenu/style.ts +8 -8
  55. package/src/NavMenu/sub-item-group.tsx +2 -2
  56. package/src/SessionBlocklet/index.tsx +7 -20
  57. package/src/SessionUser/components/logged-in.tsx +4 -6
  58. package/src/Theme/theme.ts +1 -0
  59. package/src/UserCard/Cards/avatar-only.tsx +38 -0
  60. package/src/UserCard/Cards/basic-info.tsx +50 -0
  61. package/src/UserCard/Cards/index.tsx +24 -0
  62. package/src/UserCard/Cards/name-only.tsx +17 -0
  63. package/src/UserCard/Container/card.tsx +52 -0
  64. package/src/UserCard/Container/dialog.tsx +30 -0
  65. package/src/UserCard/Content/basic.tsx +134 -0
  66. package/src/UserCard/Content/clock.tsx +63 -0
  67. package/src/UserCard/Content/left-layout.tsx +40 -0
  68. package/src/UserCard/Content/minimal.tsx +60 -0
  69. package/src/UserCard/Content/tooltip-avatar.tsx +55 -0
  70. package/src/UserCard/components.tsx +49 -0
  71. package/src/UserCard/index.tsx +63 -0
  72. package/src/UserCard/types.ts +129 -0
  73. package/src/UserCard/utils.ts +22 -0
  74. package/src/hooks/use-clock.tsx +61 -0
@@ -0,0 +1,139 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Typography, Box } from '@mui/material';
3
+ import { useCreation } from 'ahooks';
4
+ import styled from '@emotion/styled';
5
+ import LinkIcon from '@arcblock/icons/lib/Link';
6
+ import LocationIcon from '@arcblock/icons/lib/Location';
7
+ import EmailIcon from '@arcblock/icons/lib/Email';
8
+ import TimezoneIcon from '@arcblock/icons/lib/Timezone';
9
+ import { withoutProtocol } from 'ufo';
10
+ import Clock from './clock';
11
+
12
+ /**
13
+ * 格式化链接显示
14
+ * 对于 http/https 协议只显示域名,其他协议显示完整链接
15
+ */
16
+ function formatLinkDisplay(link) {
17
+ return withoutProtocol(link);
18
+ }
19
+ const iconSize = {
20
+ width: 16,
21
+ height: 16
22
+ };
23
+ function BasicContent({
24
+ user,
25
+ isFull = false
26
+ }) {
27
+ const metadata = useCreation(() => {
28
+ return user.metadata ?? {
29
+ joinedAt: user?.createdAt,
30
+ email: user?.email,
31
+ phone: {
32
+ country: 'cn',
33
+ phoneNumber: user?.phone ?? ''
34
+ }
35
+ };
36
+ }, [user]);
37
+
38
+ // 获取第一个链接(如果有)
39
+ const firstLink = metadata.links && metadata.links.length > 0 ? metadata.links[0] : null;
40
+ const moreContent = () => {
41
+ return metadata.timezone ? /*#__PURE__*/_jsxs(Box, {
42
+ display: "flex",
43
+ alignItems: "center",
44
+ gap: 1,
45
+ children: [/*#__PURE__*/_jsx(TimezoneIcon, {
46
+ ...iconSize
47
+ }), /*#__PURE__*/_jsx(Typography, {
48
+ variant: "body2",
49
+ color: "grey.800",
50
+ children: /*#__PURE__*/_jsx(Clock, {
51
+ value: metadata.timezone,
52
+ variant: "body2",
53
+ color: "grey.800"
54
+ })
55
+ })]
56
+ }) : null;
57
+ };
58
+ return /*#__PURE__*/_jsxs(Box, {
59
+ mt: 1,
60
+ display: "flex",
61
+ flexDirection: "column",
62
+ gap: 1.5,
63
+ children: [user.metadata?.bio && /*#__PURE__*/_jsx(Typography, {
64
+ variant: "body2",
65
+ color: "grey.800",
66
+ sx: {
67
+ lineHeight: 1.5,
68
+ display: '-webkit-box',
69
+ WebkitLineClamp: 1,
70
+ WebkitBoxOrient: 'vertical',
71
+ overflow: 'hidden',
72
+ textOverflow: 'ellipsis'
73
+ },
74
+ children: user.metadata.bio
75
+ }), /*#__PURE__*/_jsxs(Box, {
76
+ display: "flex",
77
+ flexDirection: "column",
78
+ gap: 0.5,
79
+ children: [firstLink && /*#__PURE__*/_jsxs(Box, {
80
+ display: "flex",
81
+ alignItems: "center",
82
+ gap: 1,
83
+ children: [/*#__PURE__*/_jsx(LinkIcon, {
84
+ ...iconSize
85
+ }), /*#__PURE__*/_jsx(LinkDiv, {
86
+ children: /*#__PURE__*/_jsx(Typography, {
87
+ component: "a",
88
+ href: firstLink.url,
89
+ style: {
90
+ textDecoration: 'none'
91
+ },
92
+ target: "_blank",
93
+ variant: "body2",
94
+ color: "grey.800",
95
+ rel: "noopener noreferrer",
96
+ children: formatLinkDisplay(firstLink.url)
97
+ })
98
+ })]
99
+ }), metadata.location && /*#__PURE__*/_jsxs(Box, {
100
+ display: "flex",
101
+ alignItems: "center",
102
+ gap: 1,
103
+ children: [/*#__PURE__*/_jsx(LocationIcon, {
104
+ ...iconSize
105
+ }), /*#__PURE__*/_jsx(Typography, {
106
+ variant: "body2",
107
+ color: "grey.800",
108
+ children: metadata.location
109
+ })]
110
+ }), isFull && moreContent(), (metadata.email || user.email) && /*#__PURE__*/_jsxs(Box, {
111
+ display: "flex",
112
+ alignItems: "center",
113
+ gap: 1,
114
+ children: [/*#__PURE__*/_jsx(EmailIcon, {
115
+ ...iconSize
116
+ }), /*#__PURE__*/_jsx(Typography, {
117
+ variant: "body2",
118
+ color: "grey.800",
119
+ children: metadata.email || user.email
120
+ })]
121
+ })]
122
+ })]
123
+ });
124
+ }
125
+ export default BasicContent;
126
+ const LinkDiv = styled('span')`
127
+ flex: 1;
128
+ white-space: nowrap;
129
+ overflow: hidden;
130
+ text-overflow: ellipsis;
131
+
132
+ & > * {
133
+ word-break: break-all;
134
+ }
135
+
136
+ .status {
137
+ margin-left: 8px;
138
+ }
139
+ `;
@@ -0,0 +1,4 @@
1
+ export default function Clock({ value, ...props }: {
2
+ value: string;
3
+ [key: string]: any;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,68 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Tooltip from '@mui/material/Tooltip';
3
+ import Typography from '@mui/material/Typography';
4
+ import Box from '@mui/material/Box';
5
+ import { useMemoizedFn } from 'ahooks';
6
+ import useClock from '../../hooks/use-clock';
7
+ import { translate } from '../../Locale/util';
8
+ import { useLocaleContext } from '../../Locale/context';
9
+ const translations = {
10
+ en: {
11
+ localTime: 'Local Time',
12
+ timezonePhase: {
13
+ dawn: 'AM',
14
+ morning: 'AM',
15
+ afternoon: 'PM',
16
+ night: 'PM'
17
+ }
18
+ },
19
+ zh: {
20
+ localTime: '本地时间',
21
+ timezonePhase: {
22
+ dawn: '凌晨',
23
+ morning: '上午',
24
+ afternoon: '下午',
25
+ night: '晚上'
26
+ }
27
+ }
28
+ };
29
+ export default function Clock({
30
+ value,
31
+ ...props
32
+ }) {
33
+ const {
34
+ locale
35
+ } = useLocaleContext() || {
36
+ locale: 'en'
37
+ };
38
+ const t = useMemoizedFn((key, data = {}) => {
39
+ return translate(translations, key, locale, 'en', data);
40
+ });
41
+ const timeInfo = useClock(value, locale);
42
+ return /*#__PURE__*/_jsxs(Box, {
43
+ sx: {
44
+ whiteSpace: 'nowrap',
45
+ overflow: 'hidden',
46
+ textOverflow: 'ellipsis'
47
+ },
48
+ display: "flex",
49
+ alignItems: "center",
50
+ gap: 1,
51
+ children: [/*#__PURE__*/_jsx(Typography, {
52
+ ...props,
53
+ children: value
54
+ }), /*#__PURE__*/_jsx(Tooltip, {
55
+ enterDelay: 200,
56
+ title: /*#__PURE__*/_jsxs("span", {
57
+ children: [t('localTime'), " ", timeInfo.fullDateTime]
58
+ }),
59
+ placement: "top",
60
+ arrow: true,
61
+ children: /*#__PURE__*/_jsxs(Typography, {
62
+ component: "span",
63
+ fontSize: 14,
64
+ children: ["(", locale === 'zh' ? `${t(`timezonePhase.${timeInfo.phase}`)} ` : '', timeInfo.formattedTime, ")"]
65
+ })
66
+ })]
67
+ });
68
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { User } from '../types';
3
+ interface LeftColumnLayoutProps {
4
+ user: User;
5
+ avatarSize: number;
6
+ shouldShowHoverCard: boolean;
7
+ renderCardContent: () => React.ReactNode;
8
+ followButtonStyle: string;
9
+ isFollowed: boolean;
10
+ followLoading: boolean;
11
+ }
12
+ /**
13
+ * 统一左侧列布局组件,包含头像和关注按钮
14
+ */
15
+ declare function LeftColumnLayout({ user, avatarSize, shouldShowHoverCard, renderCardContent, followButtonStyle, isFollowed, followLoading, }: LeftColumnLayoutProps): import("react/jsx-runtime").JSX.Element;
16
+ export default LeftColumnLayout;
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Box } from '@mui/material';
4
+ import TooltipAvatar from './tooltip-avatar';
5
+ /**
6
+ * 统一左侧列布局组件,包含头像和关注按钮
7
+ */
8
+ function LeftColumnLayout({
9
+ user,
10
+ avatarSize,
11
+ shouldShowHoverCard,
12
+ renderCardContent,
13
+ followButtonStyle,
14
+ isFollowed,
15
+ followLoading
16
+ }) {
17
+ return /*#__PURE__*/_jsx(Box, {
18
+ sx: {
19
+ mr: 2,
20
+ display: 'flex',
21
+ flexDirection: 'column',
22
+ alignItems: 'center',
23
+ gap: 1
24
+ },
25
+ children: /*#__PURE__*/_jsx(TooltipAvatar, {
26
+ user: user,
27
+ avatarSize: avatarSize,
28
+ shouldShowHoverCard: shouldShowHoverCard,
29
+ renderCardContent: renderCardContent
30
+ })
31
+ });
32
+ }
33
+ export default LeftColumnLayout;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { InfoType, User } from '../types';
3
+ interface MinimalContentProps {
4
+ user: User;
5
+ infoType: InfoType;
6
+ showDid: boolean;
7
+ avatarSize: number;
8
+ shouldShowHoverCard: boolean;
9
+ renderCardContent?: () => React.ReactNode | null;
10
+ didProps: Record<string, any>;
11
+ renderTopRightContent?: () => React.ReactNode;
12
+ topRightMaxWidth: number;
13
+ }
14
+ declare function MinimalContent(props: MinimalContentProps): import("react/jsx-runtime").JSX.Element;
15
+ export default MinimalContent;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Typography, Box } from '@mui/material';
4
+ import DID from '../../DID';
5
+ import { InfoType } from '../types';
6
+ import TooltipAvatar from './tooltip-avatar';
7
+ import { renderTopRight } from '../components';
8
+ function MinimalContent(props) {
9
+ const {
10
+ user,
11
+ showDid,
12
+ didProps,
13
+ avatarSize,
14
+ shouldShowHoverCard,
15
+ renderCardContent,
16
+ renderTopRightContent,
17
+ topRightMaxWidth,
18
+ infoType = InfoType.NameOnly
19
+ } = props;
20
+ return /*#__PURE__*/_jsxs(Box, {
21
+ display: "flex",
22
+ justifyContent: "space-between",
23
+ alignItems: "center",
24
+ children: [/*#__PURE__*/_jsxs(Box, {
25
+ display: "flex",
26
+ justifyContent: "flex-start",
27
+ alignItems: "center",
28
+ gap: 2,
29
+ sx: {
30
+ flex: 1,
31
+ minWidth: 0
32
+ },
33
+ children: [/*#__PURE__*/_jsx(TooltipAvatar, {
34
+ user: user,
35
+ avatarSize: avatarSize,
36
+ shouldShowHoverCard: shouldShowHoverCard,
37
+ renderCardContent: renderCardContent
38
+ }), /*#__PURE__*/_jsxs(Box, {
39
+ children: [/*#__PURE__*/_jsx(Typography, {
40
+ variant: "subtitle1",
41
+ fontWeight: 500,
42
+ color: "text.primary",
43
+ fontSize: 18,
44
+ noWrap: true,
45
+ sx: {
46
+ lineHeight: 1.1
47
+ },
48
+ children: user.fullName || user.email || user.did
49
+ }), showDid && user.did && /*#__PURE__*/_jsx(DID, {
50
+ did: user.did,
51
+ size: 14,
52
+ sx: {
53
+ lineHeight: 1.5
54
+ },
55
+ ...didProps
56
+ })]
57
+ })]
58
+ }), renderTopRight(renderTopRightContent, topRightMaxWidth)]
59
+ });
60
+ }
61
+ export default MinimalContent;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import { User } from '../types';
3
+ interface TooltipAvatarProps {
4
+ user: User;
5
+ avatarSize: number;
6
+ shouldShowHoverCard: boolean;
7
+ renderCardContent?: () => React.ReactNode | null;
8
+ tooltipTitle?: string;
9
+ }
10
+ /**
11
+ * 统一处理头像的Tooltip显示组件
12
+ * 根据条件显示普通Tooltip、自定义Tooltip内容或无Tooltip的头像
13
+ */
14
+ declare function TooltipAvatar({ user, avatarSize, shouldShowHoverCard, renderCardContent, tooltipTitle }: TooltipAvatarProps): import("react/jsx-runtime").JSX.Element;
15
+ export default TooltipAvatar;
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Box, Tooltip } from '@mui/material';
4
+ import { renderAvatar } from '../components';
5
+ /**
6
+ * 统一处理头像的Tooltip显示组件
7
+ * 根据条件显示普通Tooltip、自定义Tooltip内容或无Tooltip的头像
8
+ */
9
+ function TooltipAvatar({
10
+ user,
11
+ avatarSize,
12
+ shouldShowHoverCard,
13
+ renderCardContent,
14
+ tooltipTitle
15
+ }) {
16
+ // 使用普通文本Tooltip
17
+ if (tooltipTitle) {
18
+ return /*#__PURE__*/_jsx(Tooltip, {
19
+ enterDelay: 200,
20
+ title: tooltipTitle,
21
+ placement: "bottom",
22
+ children: /*#__PURE__*/_jsx("div", {
23
+ style: {
24
+ display: 'inline-block'
25
+ },
26
+ children: renderAvatar(user, avatarSize)
27
+ })
28
+ });
29
+ }
30
+
31
+ // 使用自定义内容Tooltip
32
+ if (shouldShowHoverCard) {
33
+ return /*#__PURE__*/_jsx(Tooltip, {
34
+ enterDelay: 200,
35
+ title: renderCardContent ? renderCardContent() : null,
36
+ placement: "bottom",
37
+ arrow: false,
38
+ PopperProps: {
39
+ sx: {
40
+ '& .MuiTooltip-tooltip': {
41
+ backgroundColor: 'transparent',
42
+ p: 0,
43
+ maxWidth: 400,
44
+ zIndex: 1000
45
+ }
46
+ }
47
+ },
48
+ children: /*#__PURE__*/_jsx(Box, {
49
+ display: "inline-block",
50
+ children: renderAvatar(user, avatarSize)
51
+ })
52
+ });
53
+ }
54
+
55
+ // 无Tooltip
56
+ return /*#__PURE__*/_jsx(Box, {
57
+ display: "inline-block",
58
+ children: renderAvatar(user, avatarSize)
59
+ });
60
+ }
61
+ export default TooltipAvatar;
@@ -0,0 +1,4 @@
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;
4
+ export declare const renderTopRight: (renderTopRightContent: (() => React.ReactNode) | undefined, topRightMaxWidth: number) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React from 'react';
3
+ import { Box, Avatar } from '@mui/material';
4
+ import { createNameOnlyAvatar } from './utils';
5
+
6
+ // 渲染头像
7
+ export const renderAvatar = (user, avatarSize = 48) => {
8
+ // 如果用户没有头像,则显示名称首字母头像
9
+ if (!user.avatar) {
10
+ const avatarContent = createNameOnlyAvatar(user);
11
+ return /*#__PURE__*/_jsx(Avatar, {
12
+ sx: {
13
+ width: avatarSize,
14
+ height: avatarSize,
15
+ fontSize: avatarSize * 0.4,
16
+ cursor: 'pointer'
17
+ },
18
+ children: avatarContent
19
+ });
20
+ }
21
+
22
+ // 显示用户头像
23
+ return /*#__PURE__*/_jsx(Avatar, {
24
+ sx: {
25
+ width: avatarSize,
26
+ height: avatarSize,
27
+ cursor: 'pointer'
28
+ },
29
+ src: user.avatar,
30
+ alt: user.fullName || ''
31
+ });
32
+ };
33
+
34
+ // 渲染右上角内容
35
+ export const renderTopRight = (renderTopRightContent, topRightMaxWidth) => {
36
+ if (renderTopRightContent) {
37
+ return /*#__PURE__*/_jsx(Box, {
38
+ sx: {
39
+ maxWidth: topRightMaxWidth
40
+ },
41
+ children: renderTopRightContent()
42
+ });
43
+ }
44
+ return null;
45
+ };
@@ -0,0 +1,5 @@
1
+ import type { User } from './types';
2
+ import { UserCardProps } from './types';
3
+ export declare function createNameOnlyAvatar(user: User): string | null;
4
+ declare function UserCard(props: UserCardProps): import("react/jsx-runtime").JSX.Element;
5
+ export default UserCard;
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useRef } from 'react';
3
+ import { CardType } from './types';
4
+ import AvatarOnlyCard from './Cards/avatar-only';
5
+ import DetailedCard from './Cards';
6
+ import DialogContainer from './Container/dialog';
7
+ import CardContainer from './Container/card';
8
+
9
+ // 创建仅显示名称首字母的头像
10
+ export function createNameOnlyAvatar(user) {
11
+ if (!user) return null;
12
+
13
+ // 使用全名或邮箱前缀作为显示内容
14
+ let content = '';
15
+ if (user.fullName) {
16
+ // 提取名称首字母
17
+ content = user.fullName.charAt(0).toUpperCase();
18
+ } else if (user.email) {
19
+ // 使用邮箱前缀首字母
20
+ content = user.email.split('@')[0].charAt(0).toUpperCase();
21
+ } else {
22
+ // 如果都没有,使用DID的第一个字符
23
+ content = user.did ? user.did.charAt(0).toUpperCase() : '?';
24
+ }
25
+ return content;
26
+ }
27
+
28
+ // UserCard组件入口
29
+ function UserCard(props) {
30
+ const {
31
+ user,
32
+ cardType = CardType.Detailed,
33
+ showHoverCard,
34
+ onFollow,
35
+ onUnfollow,
36
+ followLoading = false
37
+ } = props;
38
+
39
+ // 计算是否显示悬停卡片
40
+ // 默认规则:AvatarOnly模式下默认显示悬停卡片,Detailed模式下默认不显示
41
+ const shouldShowHoverCard = showHoverCard !== undefined ? showHoverCard : cardType === CardType.AvatarOnly;
42
+ const containerRef = useRef(null);
43
+
44
+ // 渲染卡片内容(用于Tooltip)
45
+ const renderCardContent = () => {
46
+ return /*#__PURE__*/_jsx(DialogContainer, {
47
+ children: /*#__PURE__*/_jsx(DetailedCard, {
48
+ ...props,
49
+ shouldShowHoverCard: false
50
+ })
51
+ });
52
+ };
53
+
54
+ // 根据卡片类型选择合适的组件
55
+ if (cardType === CardType.AvatarOnly) {
56
+ return /*#__PURE__*/_jsx(AvatarOnlyCard, {
57
+ ...props,
58
+ shouldShowHoverCard: shouldShowHoverCard,
59
+ renderCardContent: renderCardContent
60
+ });
61
+ }
62
+
63
+ // 详细卡片模式
64
+ return /*#__PURE__*/_jsx(CardContainer, {
65
+ containerRef: containerRef,
66
+ cardType: cardType,
67
+ children: /*#__PURE__*/_jsx(DetailedCard, {
68
+ ...props,
69
+ shouldShowHoverCard: shouldShowHoverCard,
70
+ renderCardContent: renderCardContent
71
+ })
72
+ });
73
+ }
74
+ export default UserCard;
@@ -0,0 +1,107 @@
1
+ import React from 'react';
2
+ import { DIDProps } from '../DID';
3
+ type UserPublicInfo = {
4
+ avatar: string;
5
+ did: string;
6
+ fullName: string;
7
+ sourceAppPid: string | null;
8
+ };
9
+ export type UserMetadataLink = {
10
+ url: string;
11
+ favicon?: string;
12
+ };
13
+ export declare enum DurationEnum {
14
+ NoClear = "no_clear",
15
+ ThirtyMinutes = "30_minutes",
16
+ OneHour = "1_hour",
17
+ FourHours = "4_hours",
18
+ Today = "today",
19
+ ThisWeek = "this_week",
20
+ Custom = "custom"
21
+ }
22
+ export declare enum StatusEnum {
23
+ Meeting = "meeting",
24
+ Community = "community",
25
+ Holiday = "holiday",
26
+ OffSick = "off_sick",
27
+ WorkingRemotely = "working_remotely"
28
+ }
29
+ export type UserPhoneProps = {
30
+ country: string;
31
+ phoneNumber?: string;
32
+ };
33
+ export type UserMetadata = {
34
+ bio?: string;
35
+ location?: string;
36
+ timezone?: string;
37
+ joinedAt?: string;
38
+ status?: {
39
+ value: string;
40
+ duration?: DurationEnum;
41
+ dateRange?: Date[];
42
+ };
43
+ links?: UserMetadataLink[];
44
+ cover?: string;
45
+ email?: string;
46
+ phone?: UserPhoneProps;
47
+ };
48
+ export type UserAddress = {
49
+ country?: string;
50
+ province?: string;
51
+ city?: string;
52
+ line1?: string;
53
+ line2?: string;
54
+ postalCode?: string;
55
+ };
56
+ export type User = UserPublicInfo & {
57
+ role: string;
58
+ email?: string;
59
+ phone?: string;
60
+ sourceProvider?: string;
61
+ sourceAppPid?: string;
62
+ lastLoginAt?: string;
63
+ lastLoginIp?: string;
64
+ createdAt?: string;
65
+ passports?: any[];
66
+ didSpace?: Record<string, any>;
67
+ connectedAccounts?: any[];
68
+ locale?: string;
69
+ url: string;
70
+ inviter?: string;
71
+ emailVerified?: boolean;
72
+ phoneVerified?: boolean;
73
+ metadata?: UserMetadata;
74
+ address?: UserAddress;
75
+ };
76
+ export declare const AvatarSize: {
77
+ small: number;
78
+ medium: number;
79
+ large: number;
80
+ xlarge: number;
81
+ };
82
+ export declare enum CardType {
83
+ AvatarOnly = "AvatarOnly",// 仅头像
84
+ Detailed = "Detailed"
85
+ }
86
+ export declare enum InfoType {
87
+ NameOnly = "NameOnly",// 仅显示名称
88
+ Minimal = "Minimal",// 极简模式,显示头像、名称和DID
89
+ Basic = "Basic"
90
+ }
91
+ export interface UserCardProps {
92
+ user: User;
93
+ cardType?: CardType;
94
+ infoType?: InfoType;
95
+ avatarSize?: number;
96
+ showHoverCard?: boolean;
97
+ showDid?: boolean;
98
+ didProps?: DIDProps;
99
+ isFollowed?: boolean;
100
+ onFollow?: (user: User) => void;
101
+ onUnfollow?: (user: User) => void;
102
+ followLoading?: boolean;
103
+ renderTopRightContent?: () => React.ReactNode;
104
+ topRightMaxWidth?: number;
105
+ renderCustomContent?: () => React.ReactNode;
106
+ }
107
+ export {};