@arcblock/ux 2.4.46 → 2.4.48

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.
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = BlockletStore;
7
7
 
8
+ var _react = require("react");
9
+
8
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
11
 
10
12
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
@@ -21,6 +23,8 @@ var _Img = _interopRequireDefault(require("../Img"));
21
23
 
22
24
  var _Theme = require("../Theme");
23
25
 
26
+ var _utils = require("./utils");
27
+
24
28
  var _jsxRuntime = require("react/jsx-runtime");
25
29
 
26
30
  const _excluded = ["title", "did", "description", "cover", "version", "button", "buttonText", "buttonDisabled", "buttonLoading", "onButtonClick", "onMainClick", "className"];
@@ -115,18 +119,32 @@ function BlockletStore(_ref) {
115
119
  className: "arcblock-blocklet__info",
116
120
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
117
121
  className: "arcblock-blocklet__text",
118
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
122
+ children: [/*#__PURE__*/(0, _react.isValidElement)(title) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
119
123
  component: "h3",
120
124
  variant: "h3",
121
125
  className: "arcblock-blocklet__title",
122
- title: title,
123
126
  children: title
124
- }), description && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
127
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
128
+ component: "h3",
129
+ variant: "h3",
130
+ className: "arcblock-blocklet__title",
131
+ title: (0, _utils.strippedString)(title),
132
+ dangerouslySetInnerHTML: {
133
+ __html: title
134
+ }
135
+ }), /*#__PURE__*/(0, _react.isValidElement)(description) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
125
136
  component: "div",
126
137
  variant: "body2",
127
138
  className: "arcblock-blocklet__describe",
128
- title: description,
129
139
  children: description
140
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_Typography.default, {
141
+ component: "div",
142
+ variant: "body2",
143
+ className: "arcblock-blocklet__describe",
144
+ title: (0, _utils.strippedString)(description),
145
+ dangerouslySetInnerHTML: {
146
+ __html: description
147
+ }
130
148
  })]
131
149
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
132
150
  style: {
@@ -171,9 +189,9 @@ function BlockletStore(_ref) {
171
189
  }
172
190
 
173
191
  BlockletStore.propTypes = {
174
- title: _propTypes.default.string.isRequired,
192
+ title: _propTypes.default.string || _propTypes.default.node,
175
193
  did: _propTypes.default.string,
176
- description: _propTypes.default.string,
194
+ description: _propTypes.default.string || _propTypes.default.node,
177
195
  cover: _propTypes.default.string,
178
196
  buttonText: _propTypes.default.string,
179
197
  buttonDisabled: _propTypes.default.bool,
@@ -185,7 +203,8 @@ BlockletStore.propTypes = {
185
203
  className: _propTypes.default.string
186
204
  };
187
205
  BlockletStore.defaultProps = {
188
- description: null,
206
+ title: '',
207
+ description: '',
189
208
  cover: null,
190
209
  did: null,
191
210
  buttonText: 'Install',
@@ -10,12 +10,22 @@ Object.defineProperty(exports, "ActionButton", {
10
10
  }
11
11
  });
12
12
  exports.default = void 0;
13
+ Object.defineProperty(exports, "strippedString", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _utils.strippedString;
17
+ }
18
+ });
13
19
 
14
- var _utils = _interopRequireDefault(require("./utils"));
20
+ var _utils = _interopRequireWildcard(require("./utils"));
15
21
 
16
22
  var _blocklet = _interopRequireDefault(require("./blocklet"));
17
23
 
18
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
25
 
26
+ 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); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
20
30
  var _default = _blocklet.default;
21
31
  exports.default = _default;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.strippedString = exports.default = void 0;
7
7
 
8
8
  var _Theme = require("../Theme");
9
9
 
@@ -13,4 +13,11 @@ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(
13
13
 
14
14
  const ActionButton = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: transparent !important;\n & > :not(.Mui-disabled) {\n position: relative;\n z-index: 1;\n &::before {\n content: '';\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n top: 0;\n transition: opacity 0.3s;\n }\n &:hover::before {\n opacity: 0;\n }\n &::after {\n content: '';\n position: absolute;\n height: 100%;\n width: 100%;\n top: 0;\n left: 0;\n border-radius: 2px;\n background-color: ", ";\n transform: scale(0.1);\n opacity: 0;\n z-index: -1;\n transition: transform 0.3s, opacity 0.3s, background-color 0.3s;\n }\n &:hover::after {\n opacity: 1;\n transform-origin: center;\n transform: scale(1);\n }\n }\n & > :not(.Mui-disabled) {\n background-color: transparent !important;\n color: ", "!important;\n }\n & > :not(.Mui-disabled) {\n &:hover {\n color: ", "!important;\n }\n }\n"])), props => props.theme.palette.primary.main, props => props.theme.palette.primary.main, props => props.theme.palette.common.white);
15
15
  var _default = ActionButton;
16
- exports.default = _default;
16
+ exports.default = _default;
17
+
18
+ const strippedString = function strippedString() {
19
+ let originalString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
20
+ return originalString.replace(/(<([^>]+)>)/gi, '').trim();
21
+ };
22
+
23
+ exports.strippedString = strippedString;
@@ -30,7 +30,11 @@ function useCopy(_ref) {
30
30
  const [copied, setCopied] = (0, _react.useState)(false);
31
31
  const containerRef = (0, _react.useRef)();
32
32
 
33
- const copy = () => {
33
+ const copy = e => {
34
+ if (e) {
35
+ e.stopPropagation();
36
+ }
37
+
34
38
  (0, _copyToClipboard.default)(content || containerRef.current.textContent);
35
39
  setCopied(true);
36
40
  };
@@ -84,8 +84,8 @@ function ClickToCopy(props) {
84
84
  width
85
85
  } = (0, _useWindowSize.default)();
86
86
 
87
- const onCopy = () => {
88
- copy();
87
+ const onCopy = e => {
88
+ copy(e);
89
89
 
90
90
  if (width < 600) {
91
91
  _Toast.default.success(_copiedTip);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.4.46",
3
+ "version": "2.4.48",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -47,11 +47,11 @@
47
47
  "react": ">=18.1.0",
48
48
  "react-ga": "^2.7.0"
49
49
  },
50
- "gitHead": "4d17961e1473b89161b14d574e5cfade7287939b",
50
+ "gitHead": "7ba461919bba281ba700a2388e4419676b647a01",
51
51
  "dependencies": {
52
52
  "@arcblock/did-motif": "^1.1.10",
53
- "@arcblock/icons": "^2.4.46",
54
- "@arcblock/react-hooks": "^2.4.46",
53
+ "@arcblock/icons": "^2.4.48",
54
+ "@arcblock/react-hooks": "^2.4.48",
55
55
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
56
56
  "@emotion/react": "^11.10.4",
57
57
  "@emotion/styled": "^11.10.4",
@@ -1,3 +1,5 @@
1
+ /* eslint-disable react/no-danger */
2
+ import { isValidElement } from 'react';
1
3
  import PropTypes from 'prop-types';
2
4
  import Typography from '@mui/material/Typography';
3
5
  import CircularProgress from '@mui/material/CircularProgress';
@@ -7,6 +9,7 @@ import useMediaQuery from '@mui/material/useMediaQuery';
7
9
  import Button from '../Button';
8
10
  import Img from '../Img';
9
11
  import { useTheme, styled } from '../Theme';
12
+ import { strippedString } from './utils';
10
13
 
11
14
  const Div = styled('div')`
12
15
  &.arcblock-blocklet {
@@ -154,7 +157,6 @@ export default function BlockletStore({
154
157
  const isUpSm = useMediaQuery(theme.breakpoints.up('sm'));
155
158
  const _onMainClick = wrapHandler(onMainClick);
156
159
  const didAvatarSize = isUpSm ? 80 : 64;
157
-
158
160
  return (
159
161
  <Div className={`${className} arcblock-blocklet`} {...rest}>
160
162
  <div className="arcblock-blocklet__content" onClick={_onMainClick}>
@@ -171,13 +173,32 @@ export default function BlockletStore({
171
173
  )}
172
174
  <div className="arcblock-blocklet__info">
173
175
  <div className="arcblock-blocklet__text">
174
- <Typography component="h3" variant="h3" className="arcblock-blocklet__title" title={title}>
175
- {title}
176
- </Typography>
177
- {description && (
178
- <Typography component="div" variant="body2" className="arcblock-blocklet__describe" title={description}>
176
+ {isValidElement(title) ? (
177
+ <Typography component="h3" variant="h3" className="arcblock-blocklet__title">
178
+ {title}
179
+ </Typography>
180
+ ) : (
181
+ <Typography
182
+ component="h3"
183
+ variant="h3"
184
+ className="arcblock-blocklet__title"
185
+ title={strippedString(title)}
186
+ dangerouslySetInnerHTML={{ __html: title }}
187
+ />
188
+ )}
189
+
190
+ {isValidElement(description) ? (
191
+ <Typography component="div" variant="body2" className="arcblock-blocklet__describe">
179
192
  {description}
180
193
  </Typography>
194
+ ) : (
195
+ <Typography
196
+ component="div"
197
+ variant="body2"
198
+ className="arcblock-blocklet__describe"
199
+ title={strippedString(description)}
200
+ dangerouslySetInnerHTML={{ __html: description }}
201
+ />
181
202
  )}
182
203
  </div>
183
204
  <div
@@ -215,9 +236,9 @@ export default function BlockletStore({
215
236
  );
216
237
  }
217
238
  BlockletStore.propTypes = {
218
- title: PropTypes.string.isRequired,
239
+ title: PropTypes.string || PropTypes.node,
219
240
  did: PropTypes.string,
220
- description: PropTypes.string,
241
+ description: PropTypes.string || PropTypes.node,
221
242
  cover: PropTypes.string,
222
243
  buttonText: PropTypes.string,
223
244
  buttonDisabled: PropTypes.bool,
@@ -230,7 +251,8 @@ BlockletStore.propTypes = {
230
251
  };
231
252
 
232
253
  BlockletStore.defaultProps = {
233
- description: null,
254
+ title: '',
255
+ description: '',
234
256
  cover: null,
235
257
  did: null,
236
258
  buttonText: 'Install',
@@ -1,5 +1,5 @@
1
- import ActionButton from './utils';
1
+ import ActionButton, { strippedString } from './utils';
2
2
  import Blocklet from './blocklet';
3
3
 
4
- export { ActionButton };
4
+ export { ActionButton, strippedString };
5
5
  export default Blocklet;
@@ -49,3 +49,7 @@ const ActionButton = styled('div')`
49
49
  `;
50
50
 
51
51
  export default ActionButton;
52
+
53
+ export const strippedString = (originalString = '') => {
54
+ return originalString.replace(/(<([^>]+)>)/gi, '').trim();
55
+ };
@@ -15,7 +15,11 @@ const translations = {
15
15
  export default function useCopy({ content, locale = 'en' }) {
16
16
  const [copied, setCopied] = useState(false);
17
17
  const containerRef = useRef();
18
- const copy = () => {
18
+ const copy = (e) => {
19
+ if (e) {
20
+ e.stopPropagation();
21
+ }
22
+
19
23
  Copy(content || containerRef.current.textContent);
20
24
  setCopied(true);
21
25
  };
@@ -18,8 +18,9 @@ export default function ClickToCopy(props) {
18
18
 
19
19
  const { width } = useWindowSize();
20
20
 
21
- const onCopy = () => {
22
- copy();
21
+ const onCopy = (e) => {
22
+ copy(e);
23
+
23
24
  if (width < 600) {
24
25
  Toast.success(_copiedTip);
25
26
  }