@blocklet/ui-react 2.10.69 → 2.10.71
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
CHANGED
|
@@ -4,6 +4,7 @@ import { useMemo, useLayoutEffect, useContext } from "react";
|
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
6
6
|
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import UxImg from "@arcblock/ux/lib/Img";
|
|
7
8
|
import UxDashboard from "@arcblock/ux/lib/Layout/dashboard";
|
|
8
9
|
import { BlockletMetaProps, SessionManagerProps } from "../types.js";
|
|
9
10
|
import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
@@ -30,14 +31,24 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
30
31
|
localizedNav2 = filterNavByRole(localizedNav2, userRole);
|
|
31
32
|
localizedNav2 = mapRecursive(
|
|
32
33
|
localizedNav2,
|
|
33
|
-
(item) =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
(item) => {
|
|
35
|
+
let icon = null;
|
|
36
|
+
if (item.icon) {
|
|
37
|
+
if (item.icon.startsWith("http") || item.icon.startsWith("data:")) {
|
|
38
|
+
icon = /* @__PURE__ */ jsx(UxImg, { src: item.icon });
|
|
39
|
+
} else {
|
|
40
|
+
icon = /* @__PURE__ */ jsx("iconify-icon", { height: "100%", width: "100%", icon: item.icon });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
title: item.title,
|
|
45
|
+
url: item.link,
|
|
46
|
+
icon,
|
|
47
|
+
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
48
|
+
external: true,
|
|
49
|
+
children: item.items
|
|
50
|
+
};
|
|
51
|
+
},
|
|
41
52
|
"items"
|
|
42
53
|
);
|
|
43
54
|
const flattened2 = flatRecursive(localizedNav2).filter((item) => !!item.url);
|
package/lib/blocklets.js
CHANGED
|
@@ -167,7 +167,7 @@ export const filterNavByRole = (nav, userRole) => {
|
|
|
167
167
|
return filterRecursive(
|
|
168
168
|
nav,
|
|
169
169
|
(item, context) => {
|
|
170
|
-
const isRoleMatched = !item.role || (userRole && item.role.includes(userRole));
|
|
170
|
+
const isRoleMatched = !item.role || (userRole && (item.role.includes(userRole) || item.role.includes('guest')));
|
|
171
171
|
if (!context.isLeaf) {
|
|
172
172
|
return isRoleMatched && context.filteredChildren?.length;
|
|
173
173
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.71",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"url": "https://github.com/ArcBlock/ux/issues"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@arcblock/bridge": "^2.10.
|
|
36
|
-
"@arcblock/react-hooks": "^2.10.
|
|
37
|
-
"@blocklet/did-space-react": "^0.5.
|
|
35
|
+
"@arcblock/bridge": "^2.10.71",
|
|
36
|
+
"@arcblock/react-hooks": "^2.10.71",
|
|
37
|
+
"@blocklet/did-space-react": "^0.5.72",
|
|
38
38
|
"@iconify-icons/logos": "^1.2.36",
|
|
39
39
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
40
40
|
"@iconify/react": "^4.1.1",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"jest": "^29.7.0",
|
|
81
81
|
"unbuild": "^2.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "65592faac533183e4e94e2e1f17eeb3852e2085f"
|
|
84
84
|
}
|
package/src/Dashboard/index.jsx
CHANGED
|
@@ -5,6 +5,7 @@ import { useMemo, useLayoutEffect, useContext } from 'react';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
7
7
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
|
+
import UxImg from '@arcblock/ux/lib/Img';
|
|
8
9
|
import UxDashboard from '@arcblock/ux/lib/Layout/dashboard';
|
|
9
10
|
import { BlockletMetaProps, SessionManagerProps } from '../types';
|
|
10
11
|
import { mapRecursive, flatRecursive, matchPaths } from '../utils';
|
|
@@ -39,14 +40,26 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
39
40
|
// 将 nav 数据处理成 ux dashboard 需要的格式
|
|
40
41
|
localizedNav = mapRecursive(
|
|
41
42
|
localizedNav,
|
|
42
|
-
(item) =>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
(item) => {
|
|
44
|
+
let icon = null;
|
|
45
|
+
|
|
46
|
+
if (item.icon) {
|
|
47
|
+
if (item.icon.startsWith('http') || item.icon.startsWith('data:')) {
|
|
48
|
+
icon = <UxImg src={item.icon} />;
|
|
49
|
+
} else {
|
|
50
|
+
icon = <iconify-icon height="100%" width="100%" icon={item.icon} />;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
title: item.title,
|
|
56
|
+
url: item.link,
|
|
57
|
+
icon,
|
|
58
|
+
// https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
|
|
59
|
+
external: true,
|
|
60
|
+
children: item.items,
|
|
61
|
+
};
|
|
62
|
+
},
|
|
50
63
|
'items'
|
|
51
64
|
);
|
|
52
65
|
// 展平后使用 matchPaths 检测 link#active 状态
|
package/src/blocklets.js
CHANGED
|
@@ -167,7 +167,7 @@ export const filterNavByRole = (nav, userRole) => {
|
|
|
167
167
|
return filterRecursive(
|
|
168
168
|
nav,
|
|
169
169
|
(item, context) => {
|
|
170
|
-
const isRoleMatched = !item.role || (userRole && item.role.includes(userRole));
|
|
170
|
+
const isRoleMatched = !item.role || (userRole && (item.role.includes(userRole) || item.role.includes('guest')));
|
|
171
171
|
if (!context.isLeaf) {
|
|
172
172
|
return isRoleMatched && context.filteredChildren?.length;
|
|
173
173
|
}
|