@arcblock/ux 2.10.50 → 2.10.52
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ClickToCopy/index.js +22 -13
- package/package.json +5 -5
- package/src/ClickToCopy/index.js +13 -9
package/lib/ClickToCopy/index.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import { useSize } from 'ahooks';
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
5
|
+
import { useSnackbar } from 'notistack';
|
5
6
|
import useCopy from './hook';
|
6
7
|
import Toast, { ToastProvider } from '../Toast';
|
7
8
|
import { mergeProps } from '../Util';
|
@@ -46,6 +47,7 @@ export default function ClickToCopy(props) {
|
|
46
47
|
});
|
47
48
|
const _tip = tip || texts.copy;
|
48
49
|
const _copiedTip = copiedTip || texts.copied;
|
50
|
+
const snackbarContext = useSnackbar();
|
49
51
|
const size = useSize(document.body);
|
50
52
|
const width = size?.width || 0;
|
51
53
|
const onCopy = e => {
|
@@ -55,20 +57,27 @@ export default function ClickToCopy(props) {
|
|
55
57
|
}
|
56
58
|
};
|
57
59
|
const ContainerComponent = unstyled ? UnstyledContainer : Container;
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
children: children || content
|
69
|
-
})
|
60
|
+
const contentChild = /*#__PURE__*/_jsx(Tooltip, {
|
61
|
+
title: copied ? _copiedTip : _tip,
|
62
|
+
...rest,
|
63
|
+
placement: tipPlacement,
|
64
|
+
disableFocusListener: true,
|
65
|
+
children: /*#__PURE__*/_jsx(ContainerComponent, {
|
66
|
+
ref: containerRef,
|
67
|
+
style: style,
|
68
|
+
onClick: onCopy,
|
69
|
+
children: children || content
|
70
70
|
})
|
71
71
|
});
|
72
|
+
if (!snackbarContext) {
|
73
|
+
return /*#__PURE__*/_jsx(ToastProvider, {
|
74
|
+
children: contentChild
|
75
|
+
});
|
76
|
+
}
|
77
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
78
|
+
return /*#__PURE__*/_jsx(_Fragment, {
|
79
|
+
children: contentChild
|
80
|
+
});
|
72
81
|
}
|
73
82
|
ClickToCopy.propTypes = {
|
74
83
|
children: PropTypes.any.isRequired,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.10.
|
3
|
+
"version": "2.10.52",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -64,12 +64,12 @@
|
|
64
64
|
"react": ">=18.2.0",
|
65
65
|
"react-router-dom": ">=6.22.3"
|
66
66
|
},
|
67
|
-
"gitHead": "
|
67
|
+
"gitHead": "81930383a1128ca408ac99b7aaf15be422929606",
|
68
68
|
"dependencies": {
|
69
69
|
"@arcblock/did-motif": "^1.1.13",
|
70
|
-
"@arcblock/icons": "^2.10.
|
71
|
-
"@arcblock/nft-display": "^2.10.
|
72
|
-
"@arcblock/react-hooks": "^2.10.
|
70
|
+
"@arcblock/icons": "^2.10.52",
|
71
|
+
"@arcblock/nft-display": "^2.10.52",
|
72
|
+
"@arcblock/react-hooks": "^2.10.52",
|
73
73
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
74
74
|
"@fontsource/inter": "^5.0.16",
|
75
75
|
"@fontsource/ubuntu-mono": "^5.0.18",
|
package/src/ClickToCopy/index.js
CHANGED
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
|
2
2
|
import { useSize } from 'ahooks';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
4
|
|
5
|
+
import { useSnackbar } from 'notistack';
|
5
6
|
import useCopy from './hook';
|
6
7
|
import Toast, { ToastProvider } from '../Toast';
|
7
8
|
import { mergeProps } from '../Util';
|
@@ -32,6 +33,7 @@ export default function ClickToCopy(props) {
|
|
32
33
|
const { containerRef, copied, copy, texts } = useCopy({ content, locale });
|
33
34
|
const _tip = tip || texts.copy;
|
34
35
|
const _copiedTip = copiedTip || texts.copied;
|
36
|
+
const snackbarContext = useSnackbar();
|
35
37
|
|
36
38
|
const size = useSize(document.body);
|
37
39
|
const width = size?.width || 0;
|
@@ -45,16 +47,18 @@ export default function ClickToCopy(props) {
|
|
45
47
|
};
|
46
48
|
|
47
49
|
const ContainerComponent = unstyled ? UnstyledContainer : Container;
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
</ContainerComponent>
|
55
|
-
</Tooltip>
|
56
|
-
</ToastProvider>
|
50
|
+
const contentChild = (
|
51
|
+
<Tooltip title={copied ? _copiedTip : _tip} {...rest} placement={tipPlacement} disableFocusListener>
|
52
|
+
<ContainerComponent ref={containerRef} style={style} onClick={onCopy}>
|
53
|
+
{children || content}
|
54
|
+
</ContainerComponent>
|
55
|
+
</Tooltip>
|
57
56
|
);
|
57
|
+
if (!snackbarContext) {
|
58
|
+
return <ToastProvider>{contentChild}</ToastProvider>;
|
59
|
+
}
|
60
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
61
|
+
return <>{contentChild}</>;
|
58
62
|
}
|
59
63
|
|
60
64
|
ClickToCopy.propTypes = {
|