@arcblock/ux 1.16.57 → 1.16.61

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.
@@ -29,6 +29,49 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
29
29
 
30
30
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
31
 
32
+ const extendedColors = {
33
+ danger: {
34
+ contained: {
35
+ backgroundColor: _Colors.default.error.main,
36
+ color: _Colors.default.common.white
37
+ },
38
+ outlined: {
39
+ borderColor: _Colors.default.error.main,
40
+ color: _Colors.default.error.main
41
+ }
42
+ },
43
+ warning: {
44
+ contained: {
45
+ backgroundColor: _Colors.default.warning.main,
46
+ color: _Colors.default.common.white
47
+ },
48
+ outlined: {
49
+ borderColor: _Colors.default.warning.main,
50
+ color: _Colors.default.warning.main
51
+ }
52
+ },
53
+ did: {
54
+ contained: {
55
+ backgroundColor: _Colors.default.did.primary,
56
+ color: _Colors.default.common.white
57
+ },
58
+ outlined: {
59
+ borderColor: _Colors.default.did.primary,
60
+ color: _Colors.default.did.primary
61
+ }
62
+ },
63
+ reverse: {
64
+ contained: {
65
+ backgroundColor: 'rgba(255, 255, 255, 0.9)',
66
+ color: _Colors.default.grey[900]
67
+ },
68
+ outlined: {
69
+ borderColor: _Colors.default.grey[900],
70
+ color: _Colors.default.grey[900]
71
+ }
72
+ }
73
+ };
74
+
32
75
  function _default(BaseComponent) {
33
76
  function WrappedComponent(props) {
34
77
  const newProps = (0, _Util.mergeProps)(props, WrappedComponent, ['style']);
@@ -57,64 +100,22 @@ function _default(BaseComponent) {
57
100
  break;
58
101
 
59
102
  default:
60
- }
103
+ } // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
104
+ // 这里扩展 danger/warning/reverse/did 四种 color
105
+
61
106
 
62
- const styles = Object.assign({}, style, {
107
+ const matched = extendedColors[color] && extendedColors[color][rest.variant];
108
+ const styles = Object.assign({}, style, _objectSpread({
63
109
  boxShadow: 'none',
64
110
  textTransform: 'capitalize'
65
- }); // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
66
- // 这里扩展 danger/warning/reverse 三种 color
67
-
111
+ }, matched));
68
112
  let _rest = rest;
69
113
 
70
- switch (color) {
71
- case 'error':
72
- case 'danger':
73
- {
74
- if (rest.variant === 'contained') {
75
- styles.backgroundColor = _Colors.default.error.main;
76
- styles.color = _Colors.default.common.white;
77
- } else {
78
- styles.borderColor = _Colors.default.error.main;
79
- styles.color = _Colors.default.error.main;
80
- }
81
-
82
- break;
83
- }
84
-
85
- case 'warning':
86
- {
87
- if (rest.variant === 'contained') {
88
- styles.backgroundColor = _Colors.default.warning.main;
89
- styles.color = _Colors.default.common.white;
90
- } else {
91
- styles.borderColor = _Colors.default.warning.main;
92
- styles.color = _Colors.default.warning.main;
93
- }
94
-
95
- break;
96
- }
97
-
98
- case 'reverse':
99
- {
100
- if (rest.variant === 'contained') {
101
- styles.backgroundColor = 'rgba(255, 255, 255, 0.9)';
102
- styles.color = _Colors.default.grey[900];
103
- } else {
104
- styles.borderColor = _Colors.default.grey[900];
105
- styles.color = _Colors.default.grey[900];
106
- }
107
-
108
- break;
109
- }
110
- // 除扩展的几种 color 外, 由 mui button 自己处理 color
111
-
112
- default:
113
- {
114
- _rest = _objectSpread(_objectSpread({}, _rest), {}, {
115
- color
116
- });
117
- }
114
+ if (!matched) {
115
+ // mui button 本身支持的 color 交由 mui 处理
116
+ _rest = _objectSpread(_objectSpread({}, _rest), {}, {
117
+ color
118
+ });
118
119
  }
119
120
 
120
121
  if (rounded) {
@@ -110,7 +110,7 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
110
110
  const MenuItem = (0, _styledComponents.default)(_Button.default).withConfig({
111
111
  displayName: "sidebar__MenuItem",
112
112
  componentId: "sc-gaosgy-1"
113
- })(["&&{display:block;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;}.MuiButton-label{display:flex;flex-direction:column;justify-content:center;align-items:center;}}"], props => props.selected ? gradient : '', props => props.selected ? _teal.default.A700 : 'transparent', gradient, _teal.default.A700);
113
+ })(["&&{display:block;width:100%;transition:all 200ms ease-in-out;background:", ";padding:24px 0;border-left:2px solid ", ";border-radius:0;&:hover{background:", ";border-left-color:", ";}.menu-title{margin-top:8px;font-size:12px;font-weight:500;text-align:center;text-transform:capitalize;letter-spacing:normal;width:80%;}.MuiButton-label{display:flex;flex-direction:column;justify-content:center;align-items:center;}}"], props => props.selected ? gradient : '', props => props.selected ? _teal.default.A700 : 'transparent', gradient, _teal.default.A700);
114
114
 
115
115
  var _default = (0, _reactRouterDom.withRouter)((0, _withTheme.default)(Sidebar));
116
116
 
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+
12
+ var _qrCodeStyling = _interopRequireDefault(require("@solana/qr-code-styling"));
13
+
14
+ const _excluded = ["data", "size", "image", "config"];
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
+
26
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
27
+
28
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
+
30
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
+
32
+ const defaults = {
33
+ margin: 0,
34
+ dotsOptions: {
35
+ type: 'dots'
36
+ },
37
+ cornersSquareOptions: {
38
+ type: 'extra-rounded'
39
+ },
40
+ cornersDotOptions: {
41
+ type: 'dot'
42
+ }
43
+ }; // 该组件用于生成与 android wallet 样式风格相似的 qrcode
44
+ // 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
45
+
46
+ function QRCode(_ref) {
47
+ let {
48
+ data,
49
+ size,
50
+ image,
51
+ config
52
+ } = _ref,
53
+ rest = _objectWithoutProperties(_ref, _excluded);
54
+
55
+ const ref = _react.default.useRef(null);
56
+
57
+ (0, _react.useEffect)(() => {
58
+ const qrCode = new _qrCodeStyling.default(_objectSpread(_objectSpread(_objectSpread({}, defaults), {}, {
59
+ data,
60
+ width: size,
61
+ height: size
62
+ }, image && {
63
+ image,
64
+ imageOptions: {
65
+ crossOrigin: 'anonymous',
66
+ margin: 0
67
+ }
68
+ }), config));
69
+ qrCode.append(ref.current);
70
+ }, [data, size]);
71
+ return /*#__PURE__*/_react.default.createElement("div", Object.assign({
72
+ ref: ref
73
+ }, rest));
74
+ }
75
+
76
+ QRCode.propTypes = {
77
+ // 一般情况下仅使用 data/size/image 即可
78
+ data: _propTypes.default.string.isRequired,
79
+ size: _propTypes.default.number.isRequired,
80
+ image: _propTypes.default.string,
81
+ // 覆盖 qr-code-styling 配置
82
+ config: _propTypes.default.object
83
+ };
84
+ QRCode.defaultProps = {
85
+ image: null,
86
+ config: {}
87
+ };
88
+ var _default = QRCode;
89
+ exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "1.16.57",
3
+ "version": "1.16.61",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -53,14 +53,15 @@
53
53
  "react": ">=16.12.0",
54
54
  "react-ga": "^2.7.0"
55
55
  },
56
- "gitHead": "39bcb1d450409158a35acfdd486d8c79f7dfc5a6",
56
+ "gitHead": "7fea6393d63b83059873613993172a6dc98508ce",
57
57
  "dependencies": {
58
- "@arcblock/icons": "^1.16.57",
59
- "@arcblock/react-hooks": "^1.16.57",
58
+ "@arcblock/icons": "^1.16.61",
59
+ "@arcblock/react-hooks": "^1.16.61",
60
60
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
61
61
  "@fontsource/lato": "^4.5.3",
62
62
  "@material-ui/core": "^4.12.3",
63
63
  "@material-ui/icons": "4.11.2",
64
+ "@solana/qr-code-styling": "^1.6.0-beta.0",
64
65
  "axios": "^0.21.1",
65
66
  "base64-url": "^2.3.3",
66
67
  "copy-to-clipboard": "^3.2.0",
@@ -7,6 +7,25 @@ import Spinner from '../Spinner';
7
7
  import colors from '../Colors';
8
8
  import { mergeProps } from '../Util';
9
9
 
10
+ const extendedColors = {
11
+ danger: {
12
+ contained: { backgroundColor: colors.error.main, color: colors.common.white },
13
+ outlined: { borderColor: colors.error.main, color: colors.error.main },
14
+ },
15
+ warning: {
16
+ contained: { backgroundColor: colors.warning.main, color: colors.common.white },
17
+ outlined: { borderColor: colors.warning.main, color: colors.warning.main },
18
+ },
19
+ did: {
20
+ contained: { backgroundColor: colors.did.primary, color: colors.common.white },
21
+ outlined: { borderColor: colors.did.primary, color: colors.did.primary },
22
+ },
23
+ reverse: {
24
+ contained: { backgroundColor: 'rgba(255, 255, 255, 0.9)', color: colors.grey[900] },
25
+ outlined: { borderColor: colors.grey[900], color: colors.grey[900] },
26
+ },
27
+ };
28
+
10
29
  export default function (BaseComponent) {
11
30
  function WrappedComponent(props) {
12
31
  const newProps = mergeProps(props, WrappedComponent, ['style']);
@@ -24,50 +43,19 @@ export default function (BaseComponent) {
24
43
  break;
25
44
  default:
26
45
  }
46
+
47
+ // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
48
+ // 这里扩展 danger/warning/reverse/did 四种 color
49
+ const matched = extendedColors[color] && extendedColors[color][rest.variant];
27
50
  const styles = Object.assign({}, style, {
28
51
  boxShadow: 'none',
29
52
  textTransform: 'capitalize',
53
+ ...matched,
30
54
  });
31
-
32
- // mui 只支持 4 种 color 值: default/inherit/primary/secondary (传入这 4 种之外的值会报 warning),
33
- // 这里扩展 danger/warning/reverse 三种 color
34
55
  let _rest = rest;
35
- switch (color) {
36
- case 'error':
37
- case 'danger': {
38
- if (rest.variant === 'contained') {
39
- styles.backgroundColor = colors.error.main;
40
- styles.color = colors.common.white;
41
- } else {
42
- styles.borderColor = colors.error.main;
43
- styles.color = colors.error.main;
44
- }
45
- break;
46
- }
47
- case 'warning': {
48
- if (rest.variant === 'contained') {
49
- styles.backgroundColor = colors.warning.main;
50
- styles.color = colors.common.white;
51
- } else {
52
- styles.borderColor = colors.warning.main;
53
- styles.color = colors.warning.main;
54
- }
55
- break;
56
- }
57
- case 'reverse': {
58
- if (rest.variant === 'contained') {
59
- styles.backgroundColor = 'rgba(255, 255, 255, 0.9)';
60
- styles.color = colors.grey[900];
61
- } else {
62
- styles.borderColor = colors.grey[900];
63
- styles.color = colors.grey[900];
64
- }
65
- break;
66
- }
67
- // 除扩展的几种 color 外, 由 mui button 自己处理 color
68
- default: {
69
- _rest = { ..._rest, color };
70
- }
56
+ if (!matched) {
57
+ // mui button 本身支持的 color 交由 mui 处理
58
+ _rest = { ..._rest, color };
71
59
  }
72
60
  if (rounded) {
73
61
  // styles.borderRadius = { small: 16, medium: 18, large: 20 }[rest.size];
@@ -94,6 +94,7 @@ const MenuItem = styled(Button)`
94
94
  background: ${props => (props.selected ? gradient : '')};
95
95
  padding: 24px 0;
96
96
  border-left: 2px solid ${props => (props.selected ? teal.A700 : 'transparent')};
97
+ border-radius: 0;
97
98
 
98
99
  &:hover {
99
100
  background: ${gradient};
@@ -0,0 +1,56 @@
1
+ import React, { useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import QRCodeStyling from '@solana/qr-code-styling';
4
+
5
+ const defaults = {
6
+ margin: 0,
7
+ dotsOptions: {
8
+ type: 'dots',
9
+ },
10
+ cornersSquareOptions: {
11
+ type: 'extra-rounded',
12
+ },
13
+ cornersDotOptions: {
14
+ type: 'dot',
15
+ },
16
+ };
17
+
18
+ // 该组件用于生成与 android wallet 样式风格相似的 qrcode
19
+ // 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
20
+ function QRCode({ data, size, image, config, ...rest }) {
21
+ const ref = React.useRef(null);
22
+ useEffect(() => {
23
+ const qrCode = new QRCodeStyling({
24
+ ...defaults,
25
+ data,
26
+ width: size,
27
+ height: size,
28
+ ...(image && {
29
+ image,
30
+ imageOptions: {
31
+ crossOrigin: 'anonymous',
32
+ margin: 0,
33
+ },
34
+ }),
35
+ ...config,
36
+ });
37
+ qrCode.append(ref.current);
38
+ }, [data, size]);
39
+ return <div ref={ref} {...rest} />;
40
+ }
41
+
42
+ QRCode.propTypes = {
43
+ // 一般情况下仅使用 data/size/image 即可
44
+ data: PropTypes.string.isRequired,
45
+ size: PropTypes.number.isRequired,
46
+ image: PropTypes.string,
47
+ // 覆盖 qr-code-styling 配置
48
+ config: PropTypes.object,
49
+ };
50
+
51
+ QRCode.defaultProps = {
52
+ image: null,
53
+ config: {},
54
+ };
55
+
56
+ export default QRCode;