@arcblock/ux 2.12.2 → 2.12.3

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.
@@ -4,6 +4,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } f
4
4
  import { Box } from '@mui/material';
5
5
  import { styled } from '../Theme';
6
6
  import DidAddress from './did-address';
7
+ import { getFontSize } from '../Util';
7
8
 
8
9
  /**
9
10
  * 根据父容器宽度自动切换 compact 模式
@@ -18,7 +19,7 @@ const ResponsiveDidAddress = /*#__PURE__*/forwardRef(({
18
19
  style,
19
20
  className,
20
21
  component = 'span',
21
- size,
22
+ size = 0,
22
23
  ...rest
23
24
  }, ref) => {
24
25
  const [compact, setCompact] = useState(false);
@@ -79,6 +80,8 @@ const ResponsiveDidAddress = /*#__PURE__*/forwardRef(({
79
80
  ref: containerRef,
80
81
  style: style,
81
82
  className: className,
83
+ size: size,
84
+ inline: rest.inline,
82
85
  children: [/*#__PURE__*/_jsx(StyledDidAddress, {
83
86
  style: {
84
87
  position: loading ? 'absolute' : 'static',
@@ -99,10 +102,14 @@ const ResponsiveDidAddress = /*#__PURE__*/forwardRef(({
99
102
  });
100
103
  });
101
104
  export default ResponsiveDidAddress;
102
- const Root = styled(Box)`
105
+ const Root = styled(Box, {
106
+ shouldForwardProp: prop => prop !== 'size'
107
+ })`
103
108
  display: block;
104
109
  width: 100%; /* flex & column & align-items: flex-start 时, 块级元素不会自动铺满容器 */
105
- font-size: 0;
110
+ font-size: ${({
111
+ size
112
+ }) => getFontSize(size)};
106
113
  overflow: hidden;
107
114
  ${({
108
115
  inline
@@ -58,7 +58,7 @@ export declare function openWebWallet({ webWalletUrl, action, locale, url, windo
58
58
  }): {
59
59
  type: string;
60
60
  };
61
- export declare const getFontSize: (size: string) => string;
61
+ export declare const getFontSize: (size: string | number) => string;
62
62
  export declare const isEthereumDid: (did: string) => boolean;
63
63
  export declare const appendParams: (url: string, params: {
64
64
  imageFilter: "crop" | "resize";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.12.2",
3
+ "version": "2.12.3",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -68,12 +68,12 @@
68
68
  "react": ">=18.2.0",
69
69
  "react-router-dom": ">=6.22.3"
70
70
  },
71
- "gitHead": "4dc132cab82765eef5194cf00075a13bd5d8e458",
71
+ "gitHead": "d0ad7fcbd9bbae010ad58235494150e3c0814d43",
72
72
  "dependencies": {
73
73
  "@arcblock/did-motif": "^1.1.13",
74
- "@arcblock/icons": "^2.12.2",
75
- "@arcblock/nft-display": "^2.12.2",
76
- "@arcblock/react-hooks": "^2.12.2",
74
+ "@arcblock/icons": "^2.12.3",
75
+ "@arcblock/nft-display": "^2.12.3",
76
+ "@arcblock/react-hooks": "^2.12.3",
77
77
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
78
78
  "@fontsource/inter": "^5.0.16",
79
79
  "@fontsource/ubuntu-mono": "^5.0.18",
@@ -3,6 +3,7 @@ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } f
3
3
  import { Box } from '@mui/material';
4
4
  import { styled } from '../Theme';
5
5
  import DidAddress, { HTMLDidAddressElement, IDidAddressProps } from './did-address';
6
+ import { getFontSize } from '../Util';
6
7
 
7
8
  /**
8
9
  * 根据父容器宽度自动切换 compact 模式
@@ -14,7 +15,7 @@ import DidAddress, { HTMLDidAddressElement, IDidAddressProps } from './did-addre
14
15
  * - 监听容器宽度变化, 当容器宽度变化时, 对比容器宽度和 did address full-width, => 切换 compact 模式
15
16
  */
16
17
  const ResponsiveDidAddress = forwardRef<HTMLDidAddressElement, IResponsiveDidAddressProps>(
17
- ({ style, className, component = 'span', size, ...rest }, ref) => {
18
+ ({ style, className, component = 'span', size = 0, ...rest }, ref) => {
18
19
  const [compact, setCompact] = useState(false);
19
20
  const isCompact = useLatest(compact);
20
21
  // did address 完整显示时的宽度
@@ -79,7 +80,7 @@ const ResponsiveDidAddress = forwardRef<HTMLDidAddressElement, IResponsiveDidAdd
79
80
  }, [containerWidth, addressFullWidth]);
80
81
 
81
82
  return (
82
- <Root as={component} ref={containerRef} style={style} className={className}>
83
+ <Root as={component} ref={containerRef} style={style} className={className} size={size} inline={rest.inline}>
83
84
  <StyledDidAddress
84
85
  style={{
85
86
  position: loading ? 'absolute' : 'static',
@@ -107,12 +108,17 @@ export interface IResponsiveDidAddressProps extends IDidAddressProps {
107
108
  component?: React.ElementType;
108
109
  }
109
110
 
110
- const Root = styled(Box)`
111
+ type RootProps = {
112
+ size: number;
113
+ inline?: boolean;
114
+ };
115
+
116
+ const Root = styled(Box, { shouldForwardProp: (prop) => prop !== 'size' })<RootProps>`
111
117
  display: block;
112
118
  width: 100%; /* flex & column & align-items: flex-start 时, 块级元素不会自动铺满容器 */
113
- font-size: 0;
119
+ font-size: ${({ size }) => getFontSize(size)};
114
120
  overflow: hidden;
115
- ${({ inline }: any) =>
121
+ ${({ inline }) =>
116
122
  inline &&
117
123
  `
118
124
  display: inline-block;
package/src/Util/index.ts CHANGED
@@ -313,7 +313,7 @@ export function openWebWallet({
313
313
  return { type: 'web' };
314
314
  }
315
315
 
316
- export const getFontSize = (size: string) => {
316
+ export const getFontSize = (size: string | number) => {
317
317
  // 12px 及以上的 size 有效, 否则返回 inherit
318
318
  if (size && Number(size) >= 12) {
319
319
  return `${Number(size)}px`;