@arcblock/ux 2.4.14 → 2.4.15
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/ClickToCopy/index.js +14 -15
- package/package.json +4 -4
- package/src/ClickToCopy/index.js +13 -9
package/lib/ClickToCopy/index.js
CHANGED
@@ -17,8 +17,6 @@ var _useWindowSize = _interopRequireDefault(require("react-use/lib/useWindowSize
|
|
17
17
|
|
18
18
|
var _Tooltip = _interopRequireDefault(require("@mui/material/Tooltip"));
|
19
19
|
|
20
|
-
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
21
|
-
|
22
20
|
var _hook = _interopRequireDefault(require("./hook"));
|
23
21
|
|
24
22
|
var _Toast = _interopRequireWildcard(require("../Toast"));
|
@@ -31,9 +29,9 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
31
29
|
|
32
30
|
var _copyButton = _interopRequireDefault(require("./copy-button"));
|
33
31
|
|
34
|
-
var _templateObject;
|
32
|
+
var _templateObject, _templateObject2;
|
35
33
|
|
36
|
-
const _excluded = ["children", "content", "tip", "copiedTip", "tipPlacement", "locale", "style"];
|
34
|
+
const _excluded = ["children", "content", "tip", "copiedTip", "tipPlacement", "locale", "style", "unstyled"];
|
37
35
|
|
38
36
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
39
37
|
|
@@ -63,7 +61,8 @@ function ClickToCopy(props) {
|
|
63
61
|
copiedTip,
|
64
62
|
tipPlacement,
|
65
63
|
locale,
|
66
|
-
style
|
64
|
+
style,
|
65
|
+
unstyled
|
67
66
|
} = newProps,
|
68
67
|
rest = _objectWithoutProperties(newProps, _excluded);
|
69
68
|
|
@@ -93,20 +92,16 @@ function ClickToCopy(props) {
|
|
93
92
|
}
|
94
93
|
};
|
95
94
|
|
95
|
+
const ContainerComponent = unstyled ? UnstyledContainer : Container;
|
96
96
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Toast.ToastProvider, {
|
97
97
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Tooltip.default, _objectSpread(_objectSpread({
|
98
98
|
title: copied ? _copiedTip : _tip
|
99
99
|
}, rest), {}, {
|
100
100
|
placement: tipPlacement,
|
101
101
|
disableFocusListener: true,
|
102
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
102
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(ContainerComponent, {
|
103
103
|
ref: containerRef,
|
104
|
-
|
105
|
-
style: Object.assign({
|
106
|
-
fontSize: 'inherit',
|
107
|
-
color: 'inherit',
|
108
|
-
fontWeight: 'inherit'
|
109
|
-
}, style),
|
104
|
+
style: style,
|
110
105
|
onClick: onCopy,
|
111
106
|
children: children || content
|
112
107
|
})
|
@@ -121,7 +116,9 @@ ClickToCopy.propTypes = {
|
|
121
116
|
tipPlacement: _propTypes.default.string,
|
122
117
|
copiedTip: _propTypes.default.string,
|
123
118
|
locale: _propTypes.default.oneOf(['en', 'zh']),
|
124
|
-
style: _propTypes.default.object
|
119
|
+
style: _propTypes.default.object,
|
120
|
+
// 仅提供点击复制功能, 不提供样式
|
121
|
+
unstyled: _propTypes.default.bool
|
125
122
|
};
|
126
123
|
ClickToCopy.defaultProps = {
|
127
124
|
content: '',
|
@@ -129,6 +126,8 @@ ClickToCopy.defaultProps = {
|
|
129
126
|
copiedTip: '',
|
130
127
|
tipPlacement: 'right',
|
131
128
|
locale: 'en',
|
132
|
-
style: {}
|
129
|
+
style: {},
|
130
|
+
unstyled: false
|
133
131
|
};
|
134
|
-
const Container = (0, _Theme.styled)(
|
132
|
+
const Container = (0, _Theme.styled)('span')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline;\n white-space: pre-wrap;\n word-wrap: break-word;\n overflow-wrap: break-word;\n align-items: center;\n justify-content: start;\n border-radius: 15px;\n padding: 1px 12px;\n background-color: rgba(0, 0, 0, 0.08);\n cursor: pointer;\n"])));
|
133
|
+
const UnstyledContainer = (0, _Theme.styled)('span')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: pointer;\n"])));
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.4.
|
3
|
+
"version": "2.4.15",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -47,10 +47,10 @@
|
|
47
47
|
"react": ">=18.1.0",
|
48
48
|
"react-ga": "^2.7.0"
|
49
49
|
},
|
50
|
-
"gitHead": "
|
50
|
+
"gitHead": "c07a38a4575a4f41e116743b2450e468c19d55f3",
|
51
51
|
"dependencies": {
|
52
|
-
"@arcblock/icons": "^2.4.
|
53
|
-
"@arcblock/react-hooks": "^2.4.
|
52
|
+
"@arcblock/icons": "^2.4.15",
|
53
|
+
"@arcblock/react-hooks": "^2.4.15",
|
54
54
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
55
55
|
"@emotion/react": "^11.10.0",
|
56
56
|
"@emotion/styled": "^11.10.0",
|
package/src/ClickToCopy/index.js
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import PropTypes from 'prop-types';
|
2
2
|
import useWindowSize from 'react-use/lib/useWindowSize';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import Typography from '@mui/material/Typography';
|
5
4
|
|
6
5
|
import useCopy from './hook';
|
7
6
|
import Toast, { ToastProvider } from '../Toast';
|
@@ -12,7 +11,7 @@ export { default as CopyButton } from './copy-button';
|
|
12
11
|
|
13
12
|
export default function ClickToCopy(props) {
|
14
13
|
const newProps = mergeProps(props, ClickToCopy, ['style']);
|
15
|
-
const { children, content, tip, copiedTip, tipPlacement, locale, style, ...rest } = newProps;
|
14
|
+
const { children, content, tip, copiedTip, tipPlacement, locale, style, unstyled, ...rest } = newProps;
|
16
15
|
const { containerRef, copied, copy, texts } = useCopy({ content, locale });
|
17
16
|
const _tip = tip || texts.copy;
|
18
17
|
const _copiedTip = copiedTip || texts.copied;
|
@@ -26,16 +25,14 @@ export default function ClickToCopy(props) {
|
|
26
25
|
}
|
27
26
|
};
|
28
27
|
|
28
|
+
const ContainerComponent = unstyled ? UnstyledContainer : Container;
|
29
|
+
|
29
30
|
return (
|
30
31
|
<ToastProvider>
|
31
32
|
<Tooltip title={copied ? _copiedTip : _tip} {...rest} placement={tipPlacement} disableFocusListener>
|
32
|
-
<
|
33
|
-
ref={containerRef}
|
34
|
-
component="span"
|
35
|
-
style={Object.assign({ fontSize: 'inherit', color: 'inherit', fontWeight: 'inherit' }, style)}
|
36
|
-
onClick={onCopy}>
|
33
|
+
<ContainerComponent ref={containerRef} style={style} onClick={onCopy}>
|
37
34
|
{children || content}
|
38
|
-
</
|
35
|
+
</ContainerComponent>
|
39
36
|
</Tooltip>
|
40
37
|
</ToastProvider>
|
41
38
|
);
|
@@ -49,6 +46,8 @@ ClickToCopy.propTypes = {
|
|
49
46
|
copiedTip: PropTypes.string,
|
50
47
|
locale: PropTypes.oneOf(['en', 'zh']),
|
51
48
|
style: PropTypes.object,
|
49
|
+
// 仅提供点击复制功能, 不提供样式
|
50
|
+
unstyled: PropTypes.bool,
|
52
51
|
};
|
53
52
|
|
54
53
|
ClickToCopy.defaultProps = {
|
@@ -58,9 +57,10 @@ ClickToCopy.defaultProps = {
|
|
58
57
|
tipPlacement: 'right',
|
59
58
|
locale: 'en',
|
60
59
|
style: {},
|
60
|
+
unstyled: false,
|
61
61
|
};
|
62
62
|
|
63
|
-
const Container = styled(
|
63
|
+
const Container = styled('span')`
|
64
64
|
display: inline;
|
65
65
|
white-space: pre-wrap;
|
66
66
|
word-wrap: break-word;
|
@@ -72,3 +72,7 @@ const Container = styled(Typography)`
|
|
72
72
|
background-color: rgba(0, 0, 0, 0.08);
|
73
73
|
cursor: pointer;
|
74
74
|
`;
|
75
|
+
|
76
|
+
const UnstyledContainer = styled('span')`
|
77
|
+
cursor: pointer;
|
78
|
+
`;
|