@blocklet/ui-react 2.4.11 → 2.4.12
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/Dashboard/index.js +15 -8
- package/package.json +4 -4
- package/src/Dashboard/index.js +10 -6
package/lib/Dashboard/index.js
CHANGED
|
@@ -19,6 +19,8 @@ var _Avatar = _interopRequireDefault(require("@arcblock/did-connect/lib/Avatar")
|
|
|
19
19
|
|
|
20
20
|
var _types = require("../types");
|
|
21
21
|
|
|
22
|
+
var _utils = require("../utils");
|
|
23
|
+
|
|
22
24
|
var _blocklets = require("../blocklets");
|
|
23
25
|
|
|
24
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -41,7 +43,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
41
43
|
* 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
|
|
42
44
|
*/
|
|
43
45
|
function Dashboard(_ref) {
|
|
44
|
-
var _formattedBlocklet$na;
|
|
46
|
+
var _formattedBlocklet$na, _localizedNav;
|
|
45
47
|
|
|
46
48
|
let {
|
|
47
49
|
meta
|
|
@@ -77,13 +79,18 @@ function Dashboard(_ref) {
|
|
|
77
79
|
icon: item.icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
78
80
|
className: "iconify",
|
|
79
81
|
"data-icon": item.icon
|
|
80
|
-
}) : null
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
}) : null,
|
|
83
|
+
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
84
|
+
external: true
|
|
85
|
+
})); // link#active 状态检测
|
|
86
|
+
// TODO: 将来支持嵌套 sidenav 时此处逻辑需要调整 (暂时只考虑扁平数据)
|
|
87
|
+
|
|
88
|
+
const matchedIndex = (0, _utils.matchPaths)(localizedNav.map(item => item.link));
|
|
89
|
+
|
|
90
|
+
if ((_localizedNav = localizedNav) !== null && _localizedNav !== void 0 && _localizedNav.length) {
|
|
91
|
+
localizedNav[matchedIndex === -1 ? 0 : matchedIndex].active = true;
|
|
92
|
+
}
|
|
83
93
|
|
|
84
|
-
allLinks.flat().forEach(item => {
|
|
85
|
-
item.external = true;
|
|
86
|
-
});
|
|
87
94
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_dashboard.default, _objectSpread(_objectSpread({
|
|
88
95
|
title: appName,
|
|
89
96
|
fullWidth: true,
|
|
@@ -113,7 +120,7 @@ function Dashboard(_ref) {
|
|
|
113
120
|
})
|
|
114
121
|
})
|
|
115
122
|
}, rest.headerProps),
|
|
116
|
-
links:
|
|
123
|
+
links: localizedNav
|
|
117
124
|
}));
|
|
118
125
|
}
|
|
119
126
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.12",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@arcblock/did-connect": "^2.4.
|
|
34
|
-
"@arcblock/ux": "^2.4.
|
|
33
|
+
"@arcblock/did-connect": "^2.4.12",
|
|
34
|
+
"@arcblock/ux": "^2.4.12",
|
|
35
35
|
"@emotion/react": "^11.10.0",
|
|
36
36
|
"@emotion/styled": "^11.10.0",
|
|
37
37
|
"@iconify/iconify": "^2.2.1",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
54
54
|
"jest": "^24.9.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "67b9da0555a2ee6ddd151b2e0dd1e7bdae6108ef"
|
|
57
57
|
}
|
package/src/Dashboard/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import UxDashboard from '@arcblock/ux/lib/Layout/dashboard';
|
|
|
5
5
|
import DidAddress from '@arcblock/did-connect/lib/Address';
|
|
6
6
|
import DidAvatar from '@arcblock/did-connect/lib/Avatar';
|
|
7
7
|
import { blockletMetaProps } from '../types';
|
|
8
|
+
import { matchPaths } from '../utils';
|
|
8
9
|
import { publicPath, formatBlockletInfo, getLocalizedNavigation } from '../blocklets';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -33,12 +34,15 @@ function Dashboard({ meta, ...rest }) {
|
|
|
33
34
|
url: item.link,
|
|
34
35
|
label: item.title,
|
|
35
36
|
icon: item.icon ? <span className="iconify" data-icon={item.icon} /> : null,
|
|
37
|
+
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
38
|
+
external: true,
|
|
36
39
|
}));
|
|
37
|
-
|
|
38
|
-
//
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
// link#active 状态检测
|
|
41
|
+
// TODO: 将来支持嵌套 sidenav 时此处逻辑需要调整 (暂时只考虑扁平数据)
|
|
42
|
+
const matchedIndex = matchPaths(localizedNav.map((item) => item.link));
|
|
43
|
+
if (localizedNav?.length) {
|
|
44
|
+
localizedNav[matchedIndex === -1 ? 0 : matchedIndex].active = true;
|
|
45
|
+
}
|
|
42
46
|
|
|
43
47
|
return (
|
|
44
48
|
<UxDashboard
|
|
@@ -65,7 +69,7 @@ function Dashboard({ meta, ...rest }) {
|
|
|
65
69
|
),
|
|
66
70
|
...rest.headerProps,
|
|
67
71
|
}}
|
|
68
|
-
links={
|
|
72
|
+
links={localizedNav}
|
|
69
73
|
/>
|
|
70
74
|
);
|
|
71
75
|
}
|