@arcblock/ux 2.1.1 → 2.1.4

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.
@@ -94,7 +94,7 @@ Header.defaultProps = {
94
94
  const Root = _styledComponents.default.div.withConfig({
95
95
  displayName: "header__Root",
96
96
  componentId: "sc-15qnwg1-0"
97
- })(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;padding:8px 0;}.header-logo{display:inline-flex;justify-content:center;position:relative;height:40px;margin-right:16px;img,svg{width:auto;height:100%;}> a{height:100%;line-height:1;}> a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.header-brand{display:flex;flex-direction:column;flex-shrink:0;margin-right:16px;.header-brand-title{display:flex;align-items:center;h2{font-size:16px;}.header-brand-addon{margin-left:8px;}}.header-brand-desc{color:#9397a1;}}.header-addons{display:flex;align-items:center;}", "{.header-brand{margin-right:12px;.header-brand-title{h2{font-size:14px;}}}}", "{.header-container{height:56px;}.header-menu{display:inline-block;}.header-logo{height:32px;}.header-brand{display:none;}}"], props => props.$theme.zIndex.drawer + 1, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('md'));
97
+ })(["position:relative;z-index:", ";font-size:14px;background:", ";.header-container{display:flex;align-items:center;height:64px;padding:0 16px;", "{padding:0;}}.header-logo{display:inline-flex;justify-content:center;position:relative;height:40px;margin-right:16px;img,svg{width:auto;height:100%;}> a{height:100%;line-height:1;}> a::before{position:absolute;top:0;right:0;bottom:0;left:0;background-color:transparent;content:'';}}.header-brand{display:flex;flex-direction:column;flex-shrink:0;margin-right:16px;.header-brand-title{display:flex;align-items:center;h2{font-size:16px;}.header-brand-addon{margin-left:8px;}}.header-brand-desc{color:#9397a1;}}.header-addons{display:flex;align-items:center;}", "{.header-brand{margin-right:12px;.header-brand-title{h2{font-size:14px;}}}}", "{.header-container{height:56px;}.header-menu{display:inline-block;}.header-logo{height:32px;}.header-brand{display:none;}}"], props => props.$theme.zIndex.drawer + 1, props => props.$theme.palette.common.white, props => props.$theme.breakpoints.up('lg'), props => props.$theme.breakpoints.down('lg'), props => props.$theme.breakpoints.down('md'));
98
98
 
99
99
  var _default = Header;
100
100
  exports.default = _default;
@@ -74,7 +74,7 @@ function NavMenu(_ref) {
74
74
  children = filterItems(children);
75
75
 
76
76
  if (!(items !== null && items !== void 0 && items.length) && !((_children = children) !== null && _children !== void 0 && _children.length)) {
77
- return new Error("One of 'items' or 'children' is required by NavMenu component.");
77
+ throw new Error("One of 'items' or 'children' is required by NavMenu component.");
78
78
  }
79
79
 
80
80
  const [state, setState] = (0, _react.useState)({
@@ -54,8 +54,8 @@ function QRCode(_ref) {
54
54
 
55
55
  const ref = _react.default.useRef(null);
56
56
 
57
- (0, _react.useEffect)(() => {
58
- const qrCode = new _qrCodeStyling.default(_objectSpread(_objectSpread(_objectSpread({}, defaults), {}, {
57
+ const options = (0, _react.useMemo)(() => {
58
+ return _objectSpread(_objectSpread(_objectSpread({}, defaults), {}, {
59
59
  data,
60
60
  width: size,
61
61
  height: size
@@ -65,9 +65,18 @@ function QRCode(_ref) {
65
65
  crossOrigin: 'anonymous',
66
66
  margin: 0
67
67
  }
68
- }), config));
69
- qrCode.append(ref.current);
70
- }, [data, size]);
68
+ }), config);
69
+ }, [data, size, image, config]);
70
+ const [qrCode] = (0, _react.useState)(new _qrCodeStyling.default(options));
71
+ (0, _react.useEffect)(() => {
72
+ if (ref.current) {
73
+ qrCode.append(ref.current);
74
+ }
75
+ }, [qrCode, ref]);
76
+ (0, _react.useEffect)(() => {
77
+ if (!qrCode) return;
78
+ qrCode.update(options);
79
+ }, [data, size, image, config]);
71
80
  return /*#__PURE__*/_react.default.createElement("div", Object.assign({
72
81
  ref: ref
73
82
  }, rest));
package/lib/Util/index.js CHANGED
@@ -15,6 +15,7 @@ exports.openWebWallet = openWebWallet;
15
15
  exports.parseQuery = parseQuery;
16
16
  exports.setDateTool = setDateTool;
17
17
  exports.str2color = void 0;
18
+ exports.stringifyQuery = stringifyQuery;
18
19
 
19
20
  var _padStart = _interopRequireDefault(require("lodash/padStart"));
20
21
 
@@ -34,6 +35,11 @@ function parseQuery(str) {
34
35
  return memo;
35
36
  }, {});
36
37
  }
38
+
39
+ function stringifyQuery() {
40
+ let params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
41
+ return new URLSearchParams(params).toString();
42
+ }
37
43
  /**
38
44
  * @param {number} opts.expireInDays
39
45
  * @param {string} opts.path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.1.1",
3
+ "version": "2.1.4",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -52,10 +52,10 @@
52
52
  "react": ">=18.1.0",
53
53
  "react-ga": "^2.7.0"
54
54
  },
55
- "gitHead": "5820d19073c6a79aa1a9c8a56f324eda655930f3",
55
+ "gitHead": "5a92264deb34d879813be444bc26fa3f0cef0672",
56
56
  "dependencies": {
57
- "@arcblock/icons": "^2.1.1",
58
- "@arcblock/react-hooks": "^2.1.1",
57
+ "@arcblock/icons": "^2.1.4",
58
+ "@arcblock/react-hooks": "^2.1.4",
59
59
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
60
60
  "@emotion/react": "^11.9.0",
61
61
  "@emotion/styled": "^11.8.1",
@@ -78,7 +78,11 @@ const Root = styled.div`
78
78
  display: flex;
79
79
  align-items: center;
80
80
  height: 64px;
81
- padding: 8px 0;
81
+ /* mui container 左右 padding 控制, 宽屏下不需要 padding (与 content 对齐), 窄屏下设置 16px padding */
82
+ padding: 0 16px;
83
+ ${props => props.$theme.breakpoints.up('lg')} {
84
+ padding: 0;
85
+ }
82
86
  }
83
87
  .header-logo {
84
88
  display: inline-flex;
@@ -38,7 +38,7 @@ function NavMenu({
38
38
  // eslint-disable-next-line no-param-reassign
39
39
  children = filterItems(children);
40
40
  if (!items?.length && !children?.length) {
41
- return new Error("One of 'items' or 'children' is required by NavMenu component.");
41
+ throw new Error("One of 'items' or 'children' is required by NavMenu component.");
42
42
  }
43
43
  const [state, setState] = useState({ activeId: defaultActiveId, openedIds: [] });
44
44
  const contextValue = useMemo(() => {
@@ -1,4 +1,4 @@
1
- import React, { useEffect } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import QRCodeStyling from '@solana/qr-code-styling';
4
4
 
@@ -19,8 +19,8 @@ const defaults = {
19
19
  // 注意: 依赖的 @solana/qr-code-styling 是一份 fork 版本, 原版本的 margin 配置存在 bug
20
20
  function QRCode({ data, size, image, config, ...rest }) {
21
21
  const ref = React.useRef(null);
22
- useEffect(() => {
23
- const qrCode = new QRCodeStyling({
22
+ const options = useMemo(() => {
23
+ return {
24
24
  ...defaults,
25
25
  data,
26
26
  width: size,
@@ -33,9 +33,22 @@ function QRCode({ data, size, image, config, ...rest }) {
33
33
  },
34
34
  }),
35
35
  ...config,
36
- });
37
- qrCode.append(ref.current);
38
- }, [data, size]);
36
+ };
37
+ }, [data, size, image, config]);
38
+
39
+ const [qrCode] = useState(new QRCodeStyling(options));
40
+
41
+ useEffect(() => {
42
+ if (ref.current) {
43
+ qrCode.append(ref.current);
44
+ }
45
+ }, [qrCode, ref]);
46
+
47
+ useEffect(() => {
48
+ if (!qrCode) return;
49
+ qrCode.update(options);
50
+ }, [data, size, image, config]);
51
+
39
52
  return <div ref={ref} {...rest} />;
40
53
  }
41
54
 
package/src/Util/index.js CHANGED
@@ -17,6 +17,10 @@ export function parseQuery(str) {
17
17
  }, {});
18
18
  }
19
19
 
20
+ export function stringifyQuery(params = {}) {
21
+ return new URLSearchParams(params).toString();
22
+ }
23
+
20
24
  /**
21
25
  * @param {number} opts.expireInDays
22
26
  * @param {string} opts.path