@arcblock/ux 2.13.42 → 2.13.43

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.
package/lib/Img/index.js CHANGED
@@ -122,6 +122,7 @@ function Img({
122
122
  "data-id": "2",
123
123
  ref: ref,
124
124
  style: outerStyle,
125
+ className: "arcblock_ux_img-wrapper",
125
126
  ...rest,
126
127
  sx: mergeSx({
127
128
  [`& .${classes.root}`]: {
@@ -1,5 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Typography, Box, Grid } from '@mui/material';
2
+ import Typography from '@mui/material/Typography';
3
+ import Box from '@mui/material/Box';
4
+ import Grid from '@mui/material/Grid';
5
+ import useTheme from '@mui/material/styles/useTheme';
3
6
  import { useCreation, useMemoizedFn } from 'ahooks';
4
7
  import styled from '@emotion/styled';
5
8
  import isArray from 'lodash/isArray';
@@ -28,6 +31,15 @@ const IconMap = {
28
31
  function formatLinkDisplay(link) {
29
32
  return withoutProtocol(link);
30
33
  }
34
+
35
+ /**
36
+ * dark mode 下,转换 icon 颜色
37
+ */
38
+ function convertIconColor(isDark) {
39
+ return isDark ? {
40
+ filter: 'brightness(0) saturate(100%) invert(1)'
41
+ } : {};
42
+ }
31
43
  const iconSize = {
32
44
  width: 16,
33
45
  height: 16
@@ -38,13 +50,16 @@ const iconSize = {
38
50
  function TimeZoneField({
39
51
  value
40
52
  }) {
53
+ const theme = useTheme();
54
+ const isDark = theme.palette.mode === 'dark';
41
55
  return /*#__PURE__*/_jsxs(Box, {
42
56
  display: "flex",
43
57
  alignItems: "center",
44
58
  gap: 1,
45
59
  className: "user-card__timezone-field",
46
60
  children: [/*#__PURE__*/_jsx(TimezoneIcon, {
47
- ...iconSize
61
+ ...iconSize,
62
+ style: convertIconColor(isDark)
48
63
  }), /*#__PURE__*/_jsx(Clock, {
49
64
  value: value,
50
65
  variant: "body2",
@@ -56,6 +71,8 @@ function LinkField({
56
71
  value
57
72
  }) {
58
73
  const [useFallback, setUseFallback] = useState(false);
74
+ const theme = useTheme();
75
+ const isDark = theme.palette.mode === 'dark';
59
76
  const faviconUrl = useCreation(() => {
60
77
  try {
61
78
  const url = new URL(value);
@@ -82,7 +99,8 @@ function LinkField({
82
99
  },
83
100
  onError: handleImageError
84
101
  }) : /*#__PURE__*/_jsx(LinkIcon, {
85
- ...iconSize
102
+ ...iconSize,
103
+ style: convertIconColor(isDark)
86
104
  }), /*#__PURE__*/_jsx(LineText, {
87
105
  variant: "body2",
88
106
  color: "grey.800",
@@ -109,16 +127,21 @@ function BasicField({
109
127
  children
110
128
  }) {
111
129
  const Icon = IconMap[field];
130
+ const theme = useTheme();
131
+ const isDark = theme.palette.mode === 'dark';
132
+ const iconColor = convertIconColor(isDark);
112
133
  return /*#__PURE__*/_jsxs(Box, {
113
134
  display: "flex",
114
135
  alignItems: "center",
115
136
  gap: 1,
116
137
  className: `user-card__${field}-field`,
117
138
  children: [Icon ? /*#__PURE__*/_jsx(Icon, {
118
- ...iconSize
139
+ ...iconSize,
140
+ style: iconColor
119
141
  }) : /*#__PURE__*/_jsx(IconifyIcon, {
120
142
  icon: infoCircleIcon,
121
- ...iconSize
143
+ ...iconSize,
144
+ ...iconColor
122
145
  }), /*#__PURE__*/_jsx(LineText, {
123
146
  variant: "body2",
124
147
  color: "grey.800",
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Box, Tooltip } from '@mui/material';
3
+ import { Tooltip } from '@mui/material';
4
4
  import Zoom from '@mui/material/Zoom';
5
5
  import { renderAvatar } from '../components';
6
6
  /**
@@ -17,10 +17,7 @@ function TooltipAvatar({
17
17
  avatarProps,
18
18
  onAvatarClick
19
19
  }) {
20
- const avatarElement = /*#__PURE__*/_jsx(Box, {
21
- display: "inline-block",
22
- children: renderAvatar(user, avatarSize, avatarProps, onAvatarClick, shouldShowHoverCard || !!tooltipTitle)
23
- });
20
+ const avatarElement = renderAvatar(user, avatarSize, avatarProps, onAvatarClick, shouldShowHoverCard || !!tooltipTitle);
24
21
  // 使用普通文本Tooltip
25
22
  if (tooltipTitle) {
26
23
  return /*#__PURE__*/_jsx(Tooltip, {
@@ -37,17 +37,21 @@ export const renderAvatar = (user, avatarSize = 48, avatarProps = undefined, onA
37
37
  }
38
38
 
39
39
  // 显示用户头像
40
- return /*#__PURE__*/_jsx(Avatar, {
41
- size: avatarSize,
42
- did: user.did,
43
- variant: "circle",
44
- style: {
45
- cursor: shouldShowHoverCard || onAvatarClick ? 'pointer' : 'default'
46
- },
47
- onClick: onClick,
48
- src: user.avatar,
49
- alt: user.fullName || '',
50
- ...(avatarProps || {})
40
+ return /*#__PURE__*/_jsx(Box, {
41
+ className: "user-card__avatar",
42
+ display: "flex",
43
+ children: /*#__PURE__*/_jsx(Avatar, {
44
+ size: avatarSize,
45
+ did: user.did,
46
+ variant: "circle",
47
+ style: {
48
+ cursor: shouldShowHoverCard || onAvatarClick ? 'pointer' : 'default'
49
+ },
50
+ onClick: onClick,
51
+ src: user.avatar,
52
+ alt: user.fullName || '',
53
+ ...(avatarProps || {})
54
+ })
51
55
  });
52
56
  };
53
57
 
@@ -78,10 +78,12 @@ function UserCard(props) {
78
78
  shouldShowHoverCard: false,
79
79
  user: user,
80
80
  avatarProps: props.popupAvatarProps,
81
- shortenLabelProps: props.popupShortenLabelProps,
81
+ shortenLabelProps: props.popupShortenLabelProps || props.shortenLabelProps,
82
82
  renderFields: props.popupRenderFields,
83
83
  renderName: props.popupRenderName,
84
- infoType: props.popupInfoType || props.infoType
84
+ infoType: props.popupInfoType || props.infoType,
85
+ didProps: props.popupDidProps || props.didProps,
86
+ showDid: props.popupShowDid || props.showDid
85
87
  })
86
88
  });
87
89
  };
@@ -99,6 +99,8 @@ export interface UserCardProps {
99
99
  showHoverCard?: boolean;
100
100
  showDid?: boolean;
101
101
  didProps?: Partial<DIDProps>;
102
+ popupDidProps?: Partial<DIDProps>;
103
+ popupShowDid?: boolean;
102
104
  avatarProps?: Partial<AvatarProps>;
103
105
  popupAvatarProps?: Partial<AvatarProps>;
104
106
  tooltipProps?: Partial<TooltipProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.13.42",
3
+ "version": "2.13.43",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -71,14 +71,14 @@
71
71
  "react": ">=18.2.0",
72
72
  "react-router-dom": ">=6.22.3"
73
73
  },
74
- "gitHead": "30e0b6eaccfe6847ba5404894e8ce76b352053e6",
74
+ "gitHead": "9b65dc9fcef38218cbf4852cb31a1b76afffab33",
75
75
  "dependencies": {
76
76
  "@arcblock/did-motif": "^1.1.13",
77
- "@arcblock/icons": "^2.13.42",
78
- "@arcblock/nft-display": "^2.13.42",
79
- "@arcblock/react-hooks": "^2.13.42",
77
+ "@arcblock/icons": "^2.13.43",
78
+ "@arcblock/nft-display": "^2.13.43",
79
+ "@arcblock/react-hooks": "^2.13.43",
80
80
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
81
- "@blocklet/theme": "^2.13.42",
81
+ "@blocklet/theme": "^2.13.43",
82
82
  "@fontsource/roboto": "~5.1.1",
83
83
  "@fontsource/ubuntu-mono": "^5.0.18",
84
84
  "@iconify-icons/logos": "^1.2.36",
package/src/Img/index.jsx CHANGED
@@ -127,6 +127,7 @@ function Img({
127
127
  data-id="2"
128
128
  ref={ref}
129
129
  style={outerStyle}
130
+ className="arcblock_ux_img-wrapper"
130
131
  {...rest}
131
132
  sx={mergeSx(
132
133
  {
@@ -1,4 +1,7 @@
1
- import { Typography, Box, Grid } from '@mui/material';
1
+ import Typography from '@mui/material/Typography';
2
+ import Box from '@mui/material/Box';
3
+ import Grid from '@mui/material/Grid';
4
+ import useTheme from '@mui/material/styles/useTheme';
2
5
  import { useCreation, useMemoizedFn } from 'ahooks';
3
6
  import styled from '@emotion/styled';
4
7
  import isArray from 'lodash/isArray';
@@ -10,7 +13,7 @@ import LocationIcon from '@arcblock/icons/lib/Location';
10
13
  import EmailIcon from '@arcblock/icons/lib/Email';
11
14
  import TimezoneIcon from '@arcblock/icons/lib/Timezone';
12
15
  import { joinURL, withoutProtocol } from 'ufo';
13
- import { Fragment, useState, useMemo, useCallback } from 'react';
16
+ import { useState, useMemo, useCallback, cloneElement } from 'react';
14
17
 
15
18
  import { User } from '../types';
16
19
  import Clock from './clock';
@@ -31,6 +34,16 @@ function formatLinkDisplay(link: string): string {
31
34
  return withoutProtocol(link);
32
35
  }
33
36
 
37
+ /**
38
+ * dark mode 下,转换 icon 颜色
39
+ */
40
+ function convertIconColor(isDark: boolean) {
41
+ return isDark
42
+ ? {
43
+ filter: 'brightness(0) saturate(100%) invert(1)',
44
+ }
45
+ : {};
46
+ }
34
47
  const iconSize = {
35
48
  width: 16,
36
49
  height: 16,
@@ -49,9 +62,11 @@ interface RenderItem {
49
62
  }
50
63
 
51
64
  function TimeZoneField({ value }: { value: string }) {
65
+ const theme = useTheme();
66
+ const isDark = theme.palette.mode === 'dark';
52
67
  return (
53
68
  <Box display="flex" alignItems="center" gap={1} className="user-card__timezone-field">
54
- <TimezoneIcon {...iconSize} />
69
+ <TimezoneIcon {...iconSize} style={convertIconColor(isDark)} />
55
70
  <Clock value={value} variant="body2" color="grey.800" />
56
71
  </Box>
57
72
  );
@@ -59,6 +74,8 @@ function TimeZoneField({ value }: { value: string }) {
59
74
 
60
75
  function LinkField({ value }: { value: string }) {
61
76
  const [useFallback, setUseFallback] = useState(false);
77
+ const theme = useTheme();
78
+ const isDark = theme.palette.mode === 'dark';
62
79
  const faviconUrl = useCreation(() => {
63
80
  try {
64
81
  const url = new URL(value);
@@ -82,7 +99,7 @@ function LinkField({ value }: { value: string }) {
82
99
  onError={handleImageError}
83
100
  />
84
101
  ) : (
85
- <LinkIcon {...iconSize} />
102
+ <LinkIcon {...iconSize} style={convertIconColor(isDark)} />
86
103
  )}
87
104
  <LineText variant="body2" color="grey.800">
88
105
  <Typography
@@ -102,9 +119,16 @@ function LinkField({ value }: { value: string }) {
102
119
 
103
120
  function BasicField({ field, value, children }: { field: string; value: string; children?: React.ReactNode }) {
104
121
  const Icon = IconMap[field as keyof typeof IconMap];
122
+ const theme = useTheme();
123
+ const isDark = theme.palette.mode === 'dark';
124
+ const iconColor = convertIconColor(isDark);
105
125
  return (
106
126
  <Box key={field} display="flex" alignItems="center" gap={1} className={`user-card__${field}-field`}>
107
- {Icon ? <Icon {...iconSize} /> : <IconifyIcon icon={infoCircleIcon} {...iconSize} />}
127
+ {Icon ? (
128
+ <Icon {...iconSize} style={iconColor} />
129
+ ) : (
130
+ <IconifyIcon icon={infoCircleIcon} {...iconSize} {...iconColor} />
131
+ )}
108
132
  <LineText variant="body2" color="grey.800">
109
133
  {children ?? value}
110
134
  </LineText>
@@ -29,10 +29,12 @@ function TooltipAvatar({
29
29
  avatarProps,
30
30
  onAvatarClick,
31
31
  }: TooltipAvatarProps) {
32
- const avatarElement = (
33
- <Box display="inline-block">
34
- {renderAvatar(user, avatarSize, avatarProps, onAvatarClick, shouldShowHoverCard || !!tooltipTitle)}
35
- </Box>
32
+ const avatarElement = renderAvatar(
33
+ user,
34
+ avatarSize,
35
+ avatarProps,
36
+ onAvatarClick,
37
+ shouldShowHoverCard || !!tooltipTitle
36
38
  );
37
39
  // 使用普通文本Tooltip
38
40
  if (tooltipTitle) {
@@ -43,18 +43,20 @@ export const renderAvatar = (
43
43
 
44
44
  // 显示用户头像
45
45
  return (
46
- <Avatar
47
- size={avatarSize}
48
- did={user.did}
49
- variant="circle"
50
- style={{
51
- cursor: shouldShowHoverCard || onAvatarClick ? 'pointer' : 'default',
52
- }}
53
- onClick={onClick}
54
- src={user.avatar}
55
- alt={user.fullName || ''}
56
- {...(avatarProps || {})}
57
- />
46
+ <Box className="user-card__avatar" display="flex">
47
+ <Avatar
48
+ size={avatarSize}
49
+ did={user.did}
50
+ variant="circle"
51
+ style={{
52
+ cursor: shouldShowHoverCard || onAvatarClick ? 'pointer' : 'default',
53
+ }}
54
+ onClick={onClick}
55
+ src={user.avatar}
56
+ alt={user.fullName || ''}
57
+ {...(avatarProps || {})}
58
+ />
59
+ </Box>
58
60
  );
59
61
  };
60
62
 
@@ -71,10 +71,12 @@ function UserCard(props: UserCardProps) {
71
71
  shouldShowHoverCard={false}
72
72
  user={user!}
73
73
  avatarProps={props.popupAvatarProps}
74
- shortenLabelProps={props.popupShortenLabelProps}
74
+ shortenLabelProps={props.popupShortenLabelProps || props.shortenLabelProps}
75
75
  renderFields={props.popupRenderFields}
76
76
  renderName={props.popupRenderName}
77
77
  infoType={props.popupInfoType || props.infoType}
78
+ didProps={props.popupDidProps || props.didProps}
79
+ showDid={props.popupShowDid || props.showDid}
78
80
  />
79
81
  </DialogContainer>
80
82
  );
@@ -116,6 +116,8 @@ export interface UserCardProps {
116
116
  showHoverCard?: boolean;
117
117
  showDid?: boolean;
118
118
  didProps?: Partial<DIDProps>;
119
+ popupDidProps?: Partial<DIDProps>;
120
+ popupShowDid?: boolean;
119
121
 
120
122
  avatarProps?: Partial<AvatarProps>;
121
123
  popupAvatarProps?: Partial<AvatarProps>;