@blocklet/ui-react 2.12.12 → 2.12.13
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/Footer/links.js +2 -1
- package/lib/Header/index.js +2 -1
- package/lib/blocklets.js +7 -9
- package/package.json +4 -4
- package/src/Footer/links.jsx +2 -1
- package/src/Header/index.tsx +7 -1
- package/src/blocklets.js +7 -9
package/lib/Footer/links.js
CHANGED
|
@@ -3,6 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
4
|
import { useCreation } from "ahooks";
|
|
5
5
|
import isInteger from "lodash/isInteger";
|
|
6
|
+
import isString from "lodash/isString";
|
|
6
7
|
import { styled } from "@arcblock/ux/lib/Theme";
|
|
7
8
|
import clsx from "clsx";
|
|
8
9
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
@@ -18,7 +19,7 @@ export default function Links({ links, flowLayout, columns, ...rest }) {
|
|
|
18
19
|
let result = label;
|
|
19
20
|
if (render) {
|
|
20
21
|
result = render({ label, link, props });
|
|
21
|
-
} else if (link) {
|
|
22
|
+
} else if (isString(link)) {
|
|
22
23
|
const isExternal = link.startsWith("http") || link.startsWith("//");
|
|
23
24
|
result = /* @__PURE__ */ jsx(
|
|
24
25
|
"a",
|
package/lib/Header/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const parseNavigation = (navigation) => {
|
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
46
|
let props = {};
|
|
47
|
-
if (item.link?.startsWith("http
|
|
47
|
+
if (item.link?.startsWith("http") || item.link?.startsWith("//")) {
|
|
48
48
|
props = {
|
|
49
49
|
target: "_blank",
|
|
50
50
|
rel: "noreferrer"
|
|
@@ -54,6 +54,7 @@ const parseNavigation = (navigation) => {
|
|
|
54
54
|
id: `${counter++}`,
|
|
55
55
|
label: /* @__PURE__ */ jsx("a", { href: item.link, ...props, children: item.title }),
|
|
56
56
|
icon,
|
|
57
|
+
description: item.description,
|
|
57
58
|
link: item.link
|
|
58
59
|
};
|
|
59
60
|
};
|
package/lib/blocklets.js
CHANGED
|
@@ -45,15 +45,12 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
45
45
|
if (!navigation?.length) {
|
|
46
46
|
return navigation;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return title;
|
|
48
|
+
const trans = (text, _locale) => {
|
|
49
|
+
if (text && typeof text === 'object') {
|
|
50
|
+
return text[_locale] || text?.en || text?.zh;
|
|
52
51
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return title;
|
|
52
|
+
|
|
53
|
+
return text;
|
|
57
54
|
};
|
|
58
55
|
|
|
59
56
|
return mapRecursive(
|
|
@@ -61,7 +58,8 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
61
58
|
(item) => {
|
|
62
59
|
return {
|
|
63
60
|
...item,
|
|
64
|
-
title:
|
|
61
|
+
title: trans(item.title, locale),
|
|
62
|
+
description: trans(item.description, locale),
|
|
65
63
|
// 仅对叶结点进行处理
|
|
66
64
|
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
67
65
|
_rawLink: item.link,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.13",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@abtnode/constant": "^1.16.39",
|
|
36
|
-
"@arcblock/bridge": "^2.12.
|
|
37
|
-
"@arcblock/react-hooks": "^2.12.
|
|
36
|
+
"@arcblock/bridge": "^2.12.13",
|
|
37
|
+
"@arcblock/react-hooks": "^2.12.13",
|
|
38
38
|
"@arcblock/ws": "^1.19.15",
|
|
39
39
|
"@blocklet/did-space-react": "^1.0.26",
|
|
40
40
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"jest": "^29.7.0",
|
|
88
88
|
"unbuild": "^2.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "82ab8092972356c7746cb2b1c77bd133ef00ebca"
|
|
91
91
|
}
|
package/src/Footer/links.jsx
CHANGED
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { useCreation } from 'ahooks';
|
|
5
5
|
import isInteger from 'lodash/isInteger';
|
|
6
|
+
import isString from 'lodash/isString';
|
|
6
7
|
import { styled } from '@arcblock/ux/lib/Theme';
|
|
7
8
|
import clsx from 'clsx';
|
|
8
9
|
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
@@ -25,7 +26,7 @@ export default function Links({ links, flowLayout, columns, ...rest }) {
|
|
|
25
26
|
let result = label;
|
|
26
27
|
if (render) {
|
|
27
28
|
result = render({ label, link, props });
|
|
28
|
-
} else if (link) {
|
|
29
|
+
} else if (isString(link)) {
|
|
29
30
|
const isExternal = link.startsWith('http') || link.startsWith('//');
|
|
30
31
|
result = (
|
|
31
32
|
<a
|
package/src/Header/index.tsx
CHANGED
|
@@ -40,6 +40,8 @@ const parseNavigation = (navigation: any) => {
|
|
|
40
40
|
let counter = 1;
|
|
41
41
|
const parseItem = (item: any) => {
|
|
42
42
|
const icon = item.icon ? <Icon icon={item.icon} /> : null;
|
|
43
|
+
|
|
44
|
+
// sub menu
|
|
43
45
|
if (item.items) {
|
|
44
46
|
return {
|
|
45
47
|
id: `${counter++}`,
|
|
@@ -49,12 +51,15 @@ const parseNavigation = (navigation: any) => {
|
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
let props = {};
|
|
52
|
-
|
|
54
|
+
|
|
55
|
+
// external link
|
|
56
|
+
if (item.link?.startsWith('http') || item.link?.startsWith('//')) {
|
|
53
57
|
props = {
|
|
54
58
|
target: '_blank',
|
|
55
59
|
rel: 'noreferrer',
|
|
56
60
|
};
|
|
57
61
|
}
|
|
62
|
+
|
|
58
63
|
return {
|
|
59
64
|
id: `${counter++}`,
|
|
60
65
|
label: (
|
|
@@ -63,6 +68,7 @@ const parseNavigation = (navigation: any) => {
|
|
|
63
68
|
</a>
|
|
64
69
|
),
|
|
65
70
|
icon,
|
|
71
|
+
description: item.description,
|
|
66
72
|
link: item.link,
|
|
67
73
|
};
|
|
68
74
|
};
|
package/src/blocklets.js
CHANGED
|
@@ -45,15 +45,12 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
45
45
|
if (!navigation?.length) {
|
|
46
46
|
return navigation;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return title;
|
|
48
|
+
const trans = (text, _locale) => {
|
|
49
|
+
if (text && typeof text === 'object') {
|
|
50
|
+
return text[_locale] || text?.en || text?.zh;
|
|
52
51
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
return title;
|
|
52
|
+
|
|
53
|
+
return text;
|
|
57
54
|
};
|
|
58
55
|
|
|
59
56
|
return mapRecursive(
|
|
@@ -61,7 +58,8 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
61
58
|
(item) => {
|
|
62
59
|
return {
|
|
63
60
|
...item,
|
|
64
|
-
title:
|
|
61
|
+
title: trans(item.title, locale),
|
|
62
|
+
description: trans(item.description, locale),
|
|
65
63
|
// 仅对叶结点进行处理
|
|
66
64
|
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
67
65
|
_rawLink: item.link,
|