@arcblock/ux 2.11.34 → 2.11.36
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, { ReactNode } from 'react';
|
|
4
4
|
import type { Locale } from '../type';
|
5
5
|
export interface HTMLDidAddressElement extends HTMLDivElement {
|
6
6
|
copy: () => void;
|
7
|
+
getEl: () => HTMLDivElement;
|
7
8
|
}
|
8
9
|
export interface IDidAddressProps extends BoxProps {
|
9
10
|
component?: React.ElementType;
|
@@ -69,7 +69,8 @@ const DidAddress = /*#__PURE__*/forwardRef((props, ref) => {
|
|
69
69
|
handleCopy();
|
70
70
|
};
|
71
71
|
useImperativeHandle(ref, () => new Proxy({
|
72
|
-
copy: handleCopy
|
72
|
+
copy: handleCopy,
|
73
|
+
getEl: () => rootRef.current
|
73
74
|
}, {
|
74
75
|
get(target, key) {
|
75
76
|
return target[key] || rootRef.current?.[key];
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
-
import { useSize } from 'ahooks';
|
2
|
+
import { useLatest, useSize } from 'ahooks';
|
3
3
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
4
4
|
import { Box } from '@mui/material';
|
5
5
|
import { styled } from '../Theme';
|
@@ -22,6 +22,7 @@ const ResponsiveDidAddress = /*#__PURE__*/forwardRef(({
|
|
22
22
|
...rest
|
23
23
|
}, ref) => {
|
24
24
|
const [compact, setCompact] = useState(false);
|
25
|
+
const isCompact = useLatest(compact);
|
25
26
|
// did address 完整显示时的宽度
|
26
27
|
const [addressFullWidth, setAddressFullWidth] = useState(null);
|
27
28
|
const containerRef = useRef(null);
|
@@ -36,9 +37,20 @@ const ResponsiveDidAddress = /*#__PURE__*/forwardRef(({
|
|
36
37
|
|
37
38
|
// 存储完整显示时 address 组件的宽度
|
38
39
|
useEffect(() => {
|
39
|
-
|
40
|
-
|
40
|
+
const innerWidth = innerRef.current?.offsetWidth || 0;
|
41
|
+
let resizeObserver = null;
|
42
|
+
setAddressFullWidth(innerWidth);
|
43
|
+
|
44
|
+
// 由于自定义字体的缘故,innerRef 的初始宽度可能发生二次改变,使用 observer 监听捕获
|
45
|
+
resizeObserver = new ResizeObserver(() => {
|
46
|
+
if (!isCompact.current && innerRef.current?.offsetWidth !== innerWidth) {
|
47
|
+
setAddressFullWidth(innerRef.current?.offsetWidth);
|
48
|
+
}
|
49
|
+
});
|
50
|
+
if (innerRef.current) {
|
51
|
+
resizeObserver.observe(innerRef.current.getEl());
|
41
52
|
}
|
53
|
+
return () => resizeObserver.disconnect();
|
42
54
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
43
55
|
}, []);
|
44
56
|
useEffect(() => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.11.
|
3
|
+
"version": "2.11.36",
|
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": "
|
71
|
+
"gitHead": "43e4b6ab36c25fa46a52befc364971fd25f45767",
|
72
72
|
"dependencies": {
|
73
73
|
"@arcblock/did-motif": "^1.1.13",
|
74
|
-
"@arcblock/icons": "^2.11.
|
75
|
-
"@arcblock/nft-display": "^2.11.
|
76
|
-
"@arcblock/react-hooks": "^2.11.
|
74
|
+
"@arcblock/icons": "^2.11.36",
|
75
|
+
"@arcblock/nft-display": "^2.11.36",
|
76
|
+
"@arcblock/react-hooks": "^2.11.36",
|
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",
|
@@ -23,6 +23,7 @@ const translations: Translations = {
|
|
23
23
|
|
24
24
|
export interface HTMLDidAddressElement extends HTMLDivElement {
|
25
25
|
copy: () => void;
|
26
|
+
getEl: () => HTMLDivElement;
|
26
27
|
}
|
27
28
|
export interface IDidAddressProps extends BoxProps {
|
28
29
|
component?: React.ElementType;
|
@@ -98,6 +99,7 @@ const DidAddress = forwardRef<HTMLDidAddressElement, IDidAddressProps>((props, r
|
|
98
99
|
new Proxy(
|
99
100
|
{
|
100
101
|
copy: handleCopy,
|
102
|
+
getEl: () => rootRef.current,
|
101
103
|
},
|
102
104
|
{
|
103
105
|
get(target: any, key: string) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { useSize } from 'ahooks';
|
1
|
+
import { useLatest, useSize } from 'ahooks';
|
2
2
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
|
3
3
|
import { Box } from '@mui/material';
|
4
4
|
import { styled } from '../Theme';
|
@@ -17,6 +17,7 @@ import DidAddress, { HTMLDidAddressElement, IDidAddressProps } from './did-addre
|
|
17
17
|
const ResponsiveDidAddress = forwardRef<HTMLDidAddressElement, IResponsiveDidAddressProps>(
|
18
18
|
({ style, className, component = 'span', ...rest }, ref) => {
|
19
19
|
const [compact, setCompact] = useState(false);
|
20
|
+
const isCompact = useLatest(compact);
|
20
21
|
// did address 完整显示时的宽度
|
21
22
|
const [addressFullWidth, setAddressFullWidth] = useState<number | null | undefined>(null);
|
22
23
|
const containerRef = useRef<HTMLDivElement>(null);
|
@@ -39,9 +40,23 @@ const ResponsiveDidAddress = forwardRef<HTMLDidAddressElement, IResponsiveDidAdd
|
|
39
40
|
|
40
41
|
// 存储完整显示时 address 组件的宽度
|
41
42
|
useEffect(() => {
|
42
|
-
|
43
|
-
|
43
|
+
const innerWidth = innerRef.current?.offsetWidth || 0;
|
44
|
+
let resizeObserver: ResizeObserver | null = null;
|
45
|
+
|
46
|
+
setAddressFullWidth(innerWidth);
|
47
|
+
|
48
|
+
// 由于自定义字体的缘故,innerRef 的初始宽度可能发生二次改变,使用 observer 监听捕获
|
49
|
+
resizeObserver = new ResizeObserver(() => {
|
50
|
+
if (!isCompact.current && innerRef.current?.offsetWidth !== innerWidth) {
|
51
|
+
setAddressFullWidth(innerRef.current?.offsetWidth);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
|
55
|
+
if (innerRef.current) {
|
56
|
+
resizeObserver.observe(innerRef.current.getEl());
|
44
57
|
}
|
58
|
+
|
59
|
+
return () => resizeObserver.disconnect();
|
45
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
46
61
|
}, []);
|
47
62
|
|