@arcblock/ux 2.2.4 → 2.3.0
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/Layout/dashboard/index.js +5 -9
- package/lib/Layout/dashboard/sidebar.js +9 -5
- package/lib/Layout/dashboard-legacy/sidebar.js +4 -9
- package/lib/withTracker/index.js +19 -34
- package/package.json +5 -5
- package/src/Layout/dashboard/index.js +3 -5
- package/src/Layout/dashboard/sidebar.js +3 -2
- package/src/Layout/dashboard-legacy/sidebar.js +3 -5
- package/src/withTracker/index.js +20 -33
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default =
|
6
|
+
exports.default = DashboardWrapper;
|
7
7
|
|
8
8
|
var _react = require("react");
|
9
9
|
|
@@ -83,10 +83,10 @@ function formatLinks(links, location) {
|
|
83
83
|
to: link.url,
|
84
84
|
children: link.title
|
85
85
|
}),
|
86
|
-
active: !!(0, _reactRouterDom.matchPath)(
|
86
|
+
active: !!(0, _reactRouterDom.matchPath)({
|
87
87
|
path: link.url,
|
88
|
-
|
89
|
-
})
|
88
|
+
end: false
|
89
|
+
}, location.pathname)
|
90
90
|
});
|
91
91
|
});
|
92
92
|
}
|
@@ -209,8 +209,4 @@ DashboardWrapper.propTypes = _objectSpread(_objectSpread({}, Dashboard.propTypes
|
|
209
209
|
});
|
210
210
|
DashboardWrapper.defaultProps = _objectSpread(_objectSpread({}, Dashboard.defaultProps), {}, {
|
211
211
|
legacy: true
|
212
|
-
});
|
213
|
-
|
214
|
-
var _default = (0, _reactRouterDom.withRouter)(DashboardWrapper);
|
215
|
-
|
216
|
-
exports.default = _default;
|
212
|
+
});
|
@@ -66,8 +66,12 @@ function renderLinksItem(item) {
|
|
66
66
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_withExternalLink.NavLink, {
|
67
67
|
to: url,
|
68
68
|
external: external,
|
69
|
-
className:
|
70
|
-
|
69
|
+
className: _ref => {
|
70
|
+
let {
|
71
|
+
isActive
|
72
|
+
} = _ref;
|
73
|
+
return isActive ? 'layout-sidebar-link layout-sidebar-link--active' : 'layout-sidebar-link';
|
74
|
+
},
|
71
75
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
72
76
|
className: "layout-sidebar-icon ".concat(showBadge ? 'layout-sidebar-badge' : ''),
|
73
77
|
children: icon
|
@@ -80,13 +84,13 @@ function renderLinksItem(item) {
|
|
80
84
|
}, url);
|
81
85
|
}
|
82
86
|
|
83
|
-
function Sidebar(
|
87
|
+
function Sidebar(_ref2) {
|
84
88
|
let {
|
85
89
|
links,
|
86
90
|
addons,
|
87
91
|
dense
|
88
|
-
} =
|
89
|
-
rest = _objectWithoutProperties(
|
92
|
+
} = _ref2,
|
93
|
+
rest = _objectWithoutProperties(_ref2, _excluded);
|
90
94
|
|
91
95
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Root, _objectSpread(_objectSpread({}, rest), {}, {
|
92
96
|
className: (0, _clsx.default)({
|
@@ -3,7 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default =
|
6
|
+
exports.default = Sidebar;
|
7
7
|
|
8
8
|
var _react = require("react");
|
9
9
|
|
@@ -27,7 +27,7 @@ var _Logo = _interopRequireDefault(require("../../Logo"));
|
|
27
27
|
|
28
28
|
var _jsxRuntime = require("react/jsx-runtime");
|
29
29
|
|
30
|
-
const _excluded = ["
|
30
|
+
const _excluded = ["images", "links", "prefix", "addons", "logo"];
|
31
31
|
|
32
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
33
33
|
|
@@ -43,7 +43,6 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
43
43
|
|
44
44
|
function Sidebar(_ref) {
|
45
45
|
let {
|
46
|
-
location,
|
47
46
|
images,
|
48
47
|
links,
|
49
48
|
prefix,
|
@@ -53,6 +52,7 @@ function Sidebar(_ref) {
|
|
53
52
|
rest = _objectWithoutProperties(_ref, _excluded);
|
54
53
|
|
55
54
|
const theme = (0, _styles.useTheme)();
|
55
|
+
const location = (0, _reactRouterDom.useLocation)();
|
56
56
|
|
57
57
|
const isSelected = (url, name) => {
|
58
58
|
const pattern = new RegExp("/".concat(name));
|
@@ -100,7 +100,6 @@ function Sidebar(_ref) {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
Sidebar.propTypes = {
|
103
|
-
location: _propTypes.default.object.isRequired,
|
104
103
|
images: _propTypes.default.object.isRequired,
|
105
104
|
links: _propTypes.default.array.isRequired,
|
106
105
|
prefix: _propTypes.default.string,
|
@@ -120,8 +119,4 @@ const gradient = 'linear-gradient(32deg, rgba(144, 255, 230, 0.1), rgba(144, 255
|
|
120
119
|
const MenuItem = (0, _styledComponents.default)(_Button.default).withConfig({
|
121
120
|
displayName: "sidebar__MenuItem",
|
122
121
|
componentId: "sc-gtwxx4-1"
|
123
|
-
})(["&&{display:flex;flex-direction:column;justify-content:center;align-items:center;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%;color:", ";}}"], props => props.selected ? gradient : '', props => props.selected ? _colors.teal.A700 : 'transparent', gradient, _colors.teal.A700, props => props.theme.palette.text.primary);
|
124
|
-
|
125
|
-
var _default = (0, _reactRouterDom.withRouter)(Sidebar);
|
126
|
-
|
127
|
-
exports.default = _default;
|
122
|
+
})(["&&{display:flex;flex-direction:column;justify-content:center;align-items:center;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%;color:", ";}}"], props => props.selected ? gradient : '', props => props.selected ? _colors.teal.A700 : 'transparent', gradient, _colors.teal.A700, props => props.theme.palette.text.primary);
|
package/lib/withTracker/index.js
CHANGED
@@ -5,14 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
|
8
|
-
var _react = require("react");
|
9
|
-
|
10
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
11
|
-
|
12
8
|
var _reactGa = _interopRequireDefault(require("react-ga"));
|
13
9
|
|
14
10
|
var Sentry = _interopRequireWildcard(require("@sentry/browser"));
|
15
11
|
|
12
|
+
var _useDeepCompareEffect = _interopRequireDefault(require("react-use/lib/useDeepCompareEffect"));
|
13
|
+
|
14
|
+
var _useMount = _interopRequireDefault(require("react-use/lib/useMount"));
|
15
|
+
|
16
16
|
var _reactRouterDom = require("react-router-dom");
|
17
17
|
|
18
18
|
var _error_boundary = _interopRequireDefault(require("./error_boundary"));
|
@@ -65,38 +65,23 @@ var _default = function _default(WrappedComponent) {
|
|
65
65
|
}
|
66
66
|
};
|
67
67
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
trackPage(
|
72
|
-
}
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
}
|
81
|
-
}
|
82
|
-
|
83
|
-
render() {
|
84
|
-
if (process.env.NODE_ENV === 'production') {
|
85
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_error_boundary.default, {
|
86
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, _objectSpread({}, this.props))
|
87
|
-
});
|
88
|
-
}
|
89
|
-
|
90
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, _objectSpread({}, this.props));
|
68
|
+
return function TrackedComponent(props) {
|
69
|
+
const location = (0, _reactRouterDom.useLocation)();
|
70
|
+
(0, _useMount.default)(() => {
|
71
|
+
trackPage(location.pathname);
|
72
|
+
});
|
73
|
+
(0, _useDeepCompareEffect.default)(() => {
|
74
|
+
trackPage(location.pathname);
|
75
|
+
}, [location.pathname]);
|
76
|
+
|
77
|
+
if (process.env.NODE_ENV === 'production') {
|
78
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_error_boundary.default, {
|
79
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, _objectSpread({}, props))
|
80
|
+
});
|
91
81
|
}
|
92
82
|
|
93
|
-
|
94
|
-
|
95
|
-
_defineProperty(TrackedComponent, "propTypes", {
|
96
|
-
location: _propTypes.default.object.isRequired
|
97
|
-
});
|
98
|
-
|
99
|
-
return (0, _reactRouterDom.withRouter)(TrackedComponent);
|
83
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, _objectSpread({}, props));
|
84
|
+
};
|
100
85
|
};
|
101
86
|
|
102
87
|
exports.default = _default;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arcblock/ux",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.3.0",
|
4
4
|
"description": "Common used react components for arcblock products",
|
5
5
|
"keywords": [
|
6
6
|
"react",
|
@@ -48,10 +48,10 @@
|
|
48
48
|
"react": ">=18.1.0",
|
49
49
|
"react-ga": "^2.7.0"
|
50
50
|
},
|
51
|
-
"gitHead": "
|
51
|
+
"gitHead": "1d17ca422c95117bbf74c199b21692e478aa5003",
|
52
52
|
"dependencies": {
|
53
|
-
"@arcblock/icons": "^2.
|
54
|
-
"@arcblock/react-hooks": "^2.
|
53
|
+
"@arcblock/icons": "^2.3.0",
|
54
|
+
"@arcblock/react-hooks": "^2.3.0",
|
55
55
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
56
56
|
"@emotion/react": "^11.10.0",
|
57
57
|
"@emotion/styled": "^11.10.0",
|
@@ -79,7 +79,7 @@
|
|
79
79
|
"react-intersection-observer": "^8.34.0",
|
80
80
|
"react-lottie-player": "^1.4.3",
|
81
81
|
"react-player": "^1.15.3",
|
82
|
-
"react-router-dom": "^
|
82
|
+
"react-router-dom": "^6.3.0",
|
83
83
|
"react-shadow": "^19.0.3",
|
84
84
|
"react-use": "^17.4.0",
|
85
85
|
"rebound": "^0.1.0",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { useEffect, useMemo } from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import {
|
3
|
+
import { useLocation, matchPath } from 'react-router-dom';
|
4
4
|
import Helmet from 'react-helmet';
|
5
5
|
import styled from 'styled-components';
|
6
6
|
import { useTheme } from '@mui/material/styles';
|
@@ -39,7 +39,7 @@ function formatLinks(links, location) {
|
|
39
39
|
{link.title}
|
40
40
|
</Link>
|
41
41
|
),
|
42
|
-
active: !!matchPath(
|
42
|
+
active: !!matchPath({ path: link.url, end: false }, location.pathname),
|
43
43
|
};
|
44
44
|
});
|
45
45
|
}
|
@@ -165,7 +165,7 @@ const StyledUxHeader = styled(ResponsiveHeader)`
|
|
165
165
|
`;
|
166
166
|
|
167
167
|
// 兼容旧版 dashboard
|
168
|
-
function DashboardWrapper({ legacy, ...rest }) {
|
168
|
+
export default function DashboardWrapper({ legacy, ...rest }) {
|
169
169
|
if (legacy) {
|
170
170
|
return <DashboardLegacy {...rest} />;
|
171
171
|
}
|
@@ -181,5 +181,3 @@ DashboardWrapper.defaultProps = {
|
|
181
181
|
...Dashboard.defaultProps,
|
182
182
|
legacy: true,
|
183
183
|
};
|
184
|
-
|
185
|
-
export default withRouter(DashboardWrapper);
|
@@ -31,8 +31,9 @@ function renderLinksItem(item) {
|
|
31
31
|
<NavLink
|
32
32
|
to={url}
|
33
33
|
external={external}
|
34
|
-
className=
|
35
|
-
|
34
|
+
className={({ isActive }) =>
|
35
|
+
isActive ? 'layout-sidebar-link layout-sidebar-link--active' : 'layout-sidebar-link'
|
36
|
+
}>
|
36
37
|
<span className={`layout-sidebar-icon ${showBadge ? 'layout-sidebar-badge' : ''}`}>{icon}</span>
|
37
38
|
<Typography component="span" className="layout-sidebar-link-text">
|
38
39
|
{title}
|
@@ -2,7 +2,7 @@ import { memo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
3
3
|
import styled from 'styled-components';
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { Link, useLocation } from 'react-router-dom';
|
6
6
|
import { useTheme } from '@mui/material/styles';
|
7
7
|
import Button from '@mui/material/Button';
|
8
8
|
import Typography from '@mui/material/Typography';
|
@@ -11,8 +11,9 @@ import { teal } from '@mui/material/colors';
|
|
11
11
|
import ImageIcon from '../../Icon/image';
|
12
12
|
import Logo from '../../Logo';
|
13
13
|
|
14
|
-
function Sidebar({
|
14
|
+
export default function Sidebar({ images, links, prefix, addons, logo, ...rest }) {
|
15
15
|
const theme = useTheme();
|
16
|
+
const location = useLocation();
|
16
17
|
const isSelected = (url, name) => {
|
17
18
|
const pattern = new RegExp(`/${name}`);
|
18
19
|
return pattern.test(location.pathname);
|
@@ -47,7 +48,6 @@ function Sidebar({ location, images, links, prefix, addons, logo, ...rest }) {
|
|
47
48
|
}
|
48
49
|
|
49
50
|
Sidebar.propTypes = {
|
50
|
-
location: PropTypes.object.isRequired,
|
51
51
|
images: PropTypes.object.isRequired,
|
52
52
|
links: PropTypes.array.isRequired,
|
53
53
|
prefix: PropTypes.string,
|
@@ -116,5 +116,3 @@ const MenuItem = styled(Button)`
|
|
116
116
|
}
|
117
117
|
}
|
118
118
|
`;
|
119
|
-
|
120
|
-
export default withRouter(Sidebar);
|
package/src/withTracker/index.js
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
/* eslint-disable react/no-deprecated */
|
2
|
-
/* eslint-disable react/static-property-placement */
|
3
1
|
/* eslint-disable import/no-unresolved */
|
4
|
-
import { Component } from 'react';
|
5
|
-
import PropTypes from 'prop-types';
|
6
2
|
import ReactGA from 'react-ga';
|
7
3
|
import * as Sentry from '@sentry/browser';
|
8
|
-
|
4
|
+
|
5
|
+
import useDeepCompareEffect from 'react-use/lib/useDeepCompareEffect';
|
6
|
+
import useMount from 'react-use/lib/useMount';
|
7
|
+
import { useLocation } from 'react-router-dom';
|
9
8
|
|
10
9
|
import ErrorBoundary from './error_boundary';
|
11
10
|
|
@@ -34,37 +33,25 @@ export default (WrappedComponent, options = {}) => {
|
|
34
33
|
}
|
35
34
|
};
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
location: PropTypes.object.isRequired,
|
40
|
-
};
|
41
|
-
|
42
|
-
componentDidMount() {
|
43
|
-
const page = this.props.location.pathname;
|
44
|
-
trackPage(page);
|
45
|
-
}
|
46
|
-
|
47
|
-
componentWillReceiveProps(nextProps) {
|
48
|
-
const currentPage = this.props.location.pathname;
|
49
|
-
const nextPage = nextProps.location.pathname;
|
36
|
+
return function TrackedComponent(props) {
|
37
|
+
const location = useLocation();
|
50
38
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
}
|
39
|
+
useMount(() => {
|
40
|
+
trackPage(location.pathname);
|
41
|
+
});
|
55
42
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
<ErrorBoundary>
|
60
|
-
<WrappedComponent {...this.props} />
|
61
|
-
</ErrorBoundary>
|
62
|
-
);
|
63
|
-
}
|
43
|
+
useDeepCompareEffect(() => {
|
44
|
+
trackPage(location.pathname);
|
45
|
+
}, [location.pathname]);
|
64
46
|
|
65
|
-
|
47
|
+
if (process.env.NODE_ENV === 'production') {
|
48
|
+
return (
|
49
|
+
<ErrorBoundary>
|
50
|
+
<WrappedComponent {...props} />
|
51
|
+
</ErrorBoundary>
|
52
|
+
);
|
66
53
|
}
|
67
|
-
}
|
68
54
|
|
69
|
-
|
55
|
+
return <WrappedComponent {...props} />;
|
56
|
+
};
|
70
57
|
};
|