@arcblock/ux 2.10.50 → 2.10.51

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- return /*#__PURE__*/_jsx(ToastProvider, {
59
- children: /*#__PURE__*/_jsx(Tooltip, {
60
- title: copied ? _copiedTip : _tip,
61
- ...rest,
62
- placement: tipPlacement,
63
- disableFocusListener: true,
64
- children: /*#__PURE__*/_jsx(ContainerComponent, {
65
- ref: containerRef,
66
- style: style,
67
- onClick: onCopy,
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.50",
3
+ "version": "2.10.51",
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": "45f18af9a51b6bcc346c626341942b8cf4fad994",
67
+ "gitHead": "50d25c76d0450bf7e2a471dcec83a38a4afca2e8",
68
68
  "dependencies": {
69
69
  "@arcblock/did-motif": "^1.1.13",
70
- "@arcblock/icons": "^2.10.50",
71
- "@arcblock/nft-display": "^2.10.50",
72
- "@arcblock/react-hooks": "^2.10.50",
70
+ "@arcblock/icons": "^2.10.51",
71
+ "@arcblock/nft-display": "^2.10.51",
72
+ "@arcblock/react-hooks": "^2.10.51",
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",
@@ -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
- return (
50
- <ToastProvider>
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>
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 = {