@blocklet/ui-react 2.10.70 → 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.
@@ -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
- title: item.title,
35
- url: item.link,
36
- icon: item.icon ? /* @__PURE__ */ jsx("iconify-icon", { height: "100%", width: "100%", icon: item.icon }) : null,
37
- // https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
38
- external: true,
39
- children: item.items
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);
@@ -241,7 +241,9 @@ export default function UserCenter({
241
241
  variant: "h4",
242
242
  sx: {
243
243
  py: 1.5,
244
+ fontSize: "18px !important",
244
245
  fontWeight: 700,
246
+ lineHeight: 1.5,
245
247
  display: {
246
248
  xs: "none",
247
249
  md: "block"
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.70",
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,8 +32,8 @@
32
32
  "url": "https://github.com/ArcBlock/ux/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@arcblock/bridge": "^2.10.70",
36
- "@arcblock/react-hooks": "^2.10.70",
35
+ "@arcblock/bridge": "^2.10.71",
36
+ "@arcblock/react-hooks": "^2.10.71",
37
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",
@@ -80,5 +80,5 @@
80
80
  "jest": "^29.7.0",
81
81
  "unbuild": "^2.0.0"
82
82
  },
83
- "gitHead": "59a8b91d34af3a62d9f720c626f3279384a467c2"
83
+ "gitHead": "65592faac533183e4e94e2e1f17eeb3852e2085f"
84
84
  }
@@ -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
- title: item.title,
44
- url: item.link,
45
- icon: item.icon ? <iconify-icon height="100%" width="100%" icon={item.icon} /> : null,
46
- // https://github.com/ArcBlock/ux/issues/755#issuecomment-1208692620
47
- external: true,
48
- children: item.items,
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 状态
@@ -289,7 +289,9 @@ export default function UserCenter({
289
289
  variant="h4"
290
290
  sx={{
291
291
  py: 1.5,
292
+ fontSize: '18px !important',
292
293
  fontWeight: 700,
294
+ lineHeight: 1.5,
293
295
  display: {
294
296
  xs: 'none',
295
297
  md: 'block',
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
  }