@blocklet/ui-react 2.4.28 → 2.4.29
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 +7 -6
- package/lib/Footer/brand.js +1 -1
- package/lib/Footer/index.js +9 -22
- package/lib/Footer/internal-footer.js +23 -4
- package/lib/Header/index.js +4 -3
- package/package.json +4 -4
- package/src/Dashboard/index.js +6 -6
- package/src/Footer/brand.js +1 -1
- package/src/Footer/index.js +3 -12
- package/src/Footer/internal-footer.js +13 -1
- package/src/Header/index.js +3 -3
package/lib/Dashboard/index.js
CHANGED
|
@@ -65,15 +65,16 @@ function Dashboard(_ref) {
|
|
|
65
65
|
const {
|
|
66
66
|
locale
|
|
67
67
|
} = (0, _context.useLocaleContext)() || {};
|
|
68
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
69
68
|
const formattedBlocklet = (0, _react.useMemo)(() => {
|
|
69
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
70
|
+
|
|
70
71
|
try {
|
|
71
72
|
return (0, _blocklets.formatBlockletInfo)(blocklet);
|
|
72
73
|
} catch (e) {
|
|
73
74
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
74
75
|
return blocklet;
|
|
75
76
|
}
|
|
76
|
-
}, [
|
|
77
|
+
}, [meta]);
|
|
77
78
|
const {
|
|
78
79
|
localizedNav,
|
|
79
80
|
flattened,
|
|
@@ -100,8 +101,8 @@ function Dashboard(_ref) {
|
|
|
100
101
|
const flattened = (0, _utils.flatRecursive)(localizedNav).filter(item => !!item.url);
|
|
101
102
|
const matchedIndex = (0, _utils.matchPaths)(flattened.map(item => item.url));
|
|
102
103
|
|
|
103
|
-
if (
|
|
104
|
-
flattened[matchedIndex
|
|
104
|
+
if (matchedIndex !== -1) {
|
|
105
|
+
flattened[matchedIndex].active = true;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
return {
|
|
@@ -130,9 +131,9 @@ function Dashboard(_ref) {
|
|
|
130
131
|
}
|
|
131
132
|
} // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
132
133
|
|
|
133
|
-
}, [invalidPathFallback]);
|
|
134
|
+
}, [invalidPathFallback, flattened, matchedIndex]);
|
|
134
135
|
|
|
135
|
-
if (!
|
|
136
|
+
if (!formattedBlocklet.appName) {
|
|
136
137
|
return null;
|
|
137
138
|
}
|
|
138
139
|
|
package/lib/Footer/brand.js
CHANGED
|
@@ -73,4 +73,4 @@ Brand.defaultProps = {
|
|
|
73
73
|
logo: '',
|
|
74
74
|
description: ''
|
|
75
75
|
};
|
|
76
|
-
const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n font-size: 14px;\n a {\n text-decoration: none;\n color: inherit;\n }\n > div:first-
|
|
76
|
+
const Root = (0, _Theme.styled)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex-direction: column;\n font-size: 14px;\n a {\n text-decoration: none;\n color: inherit;\n }\n > div:first-of-type {\n display: flex;\n align-items: center;\n }\n .footer-brand-logo {\n display: flex;\n align-items: center;\n margin-right: 16px;\n line-height: 1;\n img,\n svg {\n width: auto;\n height: 44px;\n max-height: 44px;\n }\n }\n .footer-brand-name {\n font-size: 16px;\n font-weight: bold;\n }\n .footer-brand-desc {\n margin-top: 16px;\n }\n\n ", " {\n width: auto;\n }\n\n ", " {\n .footer-brand-logo {\n img,\n svg {\n height: 32px;\n max-height: 32px;\n }\n }\n }\n"])), props => props.theme.breakpoints.down('sm'), props => props.theme.breakpoints.down('md'));
|
package/lib/Footer/index.js
CHANGED
|
@@ -11,8 +11,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
11
11
|
|
|
12
12
|
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
13
13
|
|
|
14
|
-
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
15
|
-
|
|
16
14
|
var _reactErrorBoundary = require("react-error-boundary");
|
|
17
15
|
|
|
18
16
|
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
@@ -53,7 +51,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
53
51
|
* 专门用于 (composable) blocklet 的 Footer 组件, 基于 blocklet meta 中的数据渲染
|
|
54
52
|
*/
|
|
55
53
|
function Footer(_ref) {
|
|
56
|
-
var _formattedBlocklet$na, _formattedBlocklet$na2, _formattedBlocklet$na3, _theme$background
|
|
54
|
+
var _formattedBlocklet$na, _formattedBlocklet$na2, _formattedBlocklet$na3, _theme$background;
|
|
57
55
|
|
|
58
56
|
let {
|
|
59
57
|
meta,
|
|
@@ -64,17 +62,18 @@ function Footer(_ref) {
|
|
|
64
62
|
const {
|
|
65
63
|
locale
|
|
66
64
|
} = (0, _context.useLocaleContext)() || {};
|
|
67
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
68
65
|
const formattedBlocklet = (0, _react.useMemo)(() => {
|
|
66
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
67
|
+
|
|
69
68
|
try {
|
|
70
69
|
return (0, _blocklets.formatBlockletInfo)(blocklet);
|
|
71
70
|
} catch (e) {
|
|
72
71
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
73
72
|
return blocklet;
|
|
74
73
|
}
|
|
75
|
-
}, [
|
|
74
|
+
}, [meta]);
|
|
76
75
|
|
|
77
|
-
if (!
|
|
76
|
+
if (!formattedBlocklet.appName) {
|
|
78
77
|
return null;
|
|
79
78
|
}
|
|
80
79
|
|
|
@@ -107,23 +106,11 @@ function Footer(_ref) {
|
|
|
107
106
|
label: item.title
|
|
108
107
|
}))
|
|
109
108
|
};
|
|
110
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
109
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_overridableThemeProvider.default, {
|
|
111
110
|
theme: themeOverrides,
|
|
112
|
-
children:
|
|
111
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledInternalFooter, _objectSpread(_objectSpread(_objectSpread({}, props), rest), {}, {
|
|
113
112
|
$bgcolor: theme === null || theme === void 0 ? void 0 : (_theme$background = theme.background) === null || _theme$background === void 0 ? void 0 : _theme$background.footer
|
|
114
|
-
}))
|
|
115
|
-
position: "absolute",
|
|
116
|
-
right: 0,
|
|
117
|
-
bottom: 0,
|
|
118
|
-
sx: {
|
|
119
|
-
color: 'transparent',
|
|
120
|
-
'::selection': {
|
|
121
|
-
background: '#000',
|
|
122
|
-
color: '#fff'
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
children: (_window = window) === null || _window === void 0 ? void 0 : (_window$blocklet = _window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.version
|
|
126
|
-
})]
|
|
113
|
+
}))
|
|
127
114
|
});
|
|
128
115
|
}
|
|
129
116
|
|
|
@@ -136,7 +123,7 @@ Footer.defaultProps = {
|
|
|
136
123
|
meta: {},
|
|
137
124
|
theme: null
|
|
138
125
|
};
|
|
139
|
-
const StyledInternalFooter = (0, _Theme.styled)(_internalFooter.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
126
|
+
const StyledInternalFooter = (0, _Theme.styled)(_internalFooter.default)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-top: 1px solid #eee;\n color: ", ";\n ", "\n font-family: Lato, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n"])), props => props.theme.palette.grey[600], _ref2 => {
|
|
140
127
|
let {
|
|
141
128
|
$bgcolor
|
|
142
129
|
} = _ref2;
|
|
@@ -7,6 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
10
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
11
|
+
|
|
10
12
|
var _brand = _interopRequireDefault(require("./brand"));
|
|
11
13
|
|
|
12
14
|
var _links = _interopRequireDefault(require("./links"));
|
|
@@ -58,6 +60,8 @@ const layoutsKeyByName = layouts.reduce((acc, cur) => _objectSpread(_objectSprea
|
|
|
58
60
|
*/
|
|
59
61
|
|
|
60
62
|
function InternalFooter(props) {
|
|
63
|
+
var _window, _window$blocklet;
|
|
64
|
+
|
|
61
65
|
const {
|
|
62
66
|
brand,
|
|
63
67
|
navigation,
|
|
@@ -126,10 +130,25 @@ function InternalFooter(props) {
|
|
|
126
130
|
throw new Error("layout ".concat(layout, " is not supported."));
|
|
127
131
|
}
|
|
128
132
|
|
|
129
|
-
return /*#__PURE__*/(0, _jsxRuntime.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
134
|
+
position: "relative",
|
|
135
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(LayoutComponent, _objectSpread({
|
|
136
|
+
elements: elements,
|
|
137
|
+
data: props
|
|
138
|
+
}, rest)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
139
|
+
position: "absolute",
|
|
140
|
+
right: 0,
|
|
141
|
+
bottom: 0,
|
|
142
|
+
sx: {
|
|
143
|
+
color: 'transparent',
|
|
144
|
+
'::selection': {
|
|
145
|
+
background: '#000',
|
|
146
|
+
color: '#fff'
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
children: (_window = window) === null || _window === void 0 ? void 0 : (_window$blocklet = _window.blocklet) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.version
|
|
150
|
+
})]
|
|
151
|
+
});
|
|
133
152
|
}
|
|
134
153
|
|
|
135
154
|
InternalFooter.propTypes = {
|
package/lib/Header/index.js
CHANGED
|
@@ -134,17 +134,18 @@ function Header(_ref) {
|
|
|
134
134
|
const {
|
|
135
135
|
locale
|
|
136
136
|
} = (0, _context.useLocaleContext)() || {};
|
|
137
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
138
137
|
const formattedBlocklet = (0, _react.useMemo)(() => {
|
|
138
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
139
|
+
|
|
139
140
|
try {
|
|
140
141
|
return (0, _blocklets.formatBlockletInfo)(blocklet);
|
|
141
142
|
} catch (e) {
|
|
142
143
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
143
144
|
return blocklet;
|
|
144
145
|
}
|
|
145
|
-
}, [
|
|
146
|
+
}, [meta]);
|
|
146
147
|
|
|
147
|
-
if (!
|
|
148
|
+
if (!formattedBlocklet.appName) {
|
|
148
149
|
return null;
|
|
149
150
|
}
|
|
150
151
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.29",
|
|
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.29",
|
|
34
|
+
"@arcblock/ux": "^2.4.29",
|
|
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": "^28.1.3"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c9d01163bf74ae11b95e7799b0748f5a31a3ef56"
|
|
57
57
|
}
|
package/src/Dashboard/index.js
CHANGED
|
@@ -20,15 +20,15 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
20
20
|
const user = sessionCtx?.session?.user;
|
|
21
21
|
const userRole = user?.role;
|
|
22
22
|
const { locale } = useLocaleContext() || {};
|
|
23
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
24
23
|
const formattedBlocklet = useMemo(() => {
|
|
24
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
25
25
|
try {
|
|
26
26
|
return formatBlockletInfo(blocklet);
|
|
27
27
|
} catch (e) {
|
|
28
28
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
29
29
|
return blocklet;
|
|
30
30
|
}
|
|
31
|
-
}, [
|
|
31
|
+
}, [meta]);
|
|
32
32
|
const { localizedNav, flattened, matchedIndex } = useMemo(() => {
|
|
33
33
|
let localizedNav = getLocalizedNavigation(formattedBlocklet?.navigation?.dashboard, locale) || [];
|
|
34
34
|
// 根据 role 筛选 nav 数据
|
|
@@ -49,8 +49,8 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
49
49
|
// 展平后使用 matchPaths 检测 link#active 状态
|
|
50
50
|
const flattened = flatRecursive(localizedNav).filter((item) => !!item.url);
|
|
51
51
|
const matchedIndex = matchPaths(flattened.map((item) => item.url));
|
|
52
|
-
if (
|
|
53
|
-
flattened[matchedIndex
|
|
52
|
+
if (matchedIndex !== -1) {
|
|
53
|
+
flattened[matchedIndex].active = true;
|
|
54
54
|
}
|
|
55
55
|
return { localizedNav, flattened, matchedIndex };
|
|
56
56
|
}, [formattedBlocklet, locale, userRole]);
|
|
@@ -74,9 +74,9 @@ function Dashboard({ meta, fallbackUrl, invalidPathFallback, headerAddons, sessi
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
-
}, [invalidPathFallback]);
|
|
77
|
+
}, [invalidPathFallback, flattened, matchedIndex]);
|
|
78
78
|
|
|
79
|
-
if (!
|
|
79
|
+
if (!formattedBlocklet.appName) {
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
const { did, appLogo, appName } = formattedBlocklet;
|
package/src/Footer/brand.js
CHANGED
package/src/Footer/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { styled } from '@arcblock/ux/lib/Theme';
|
|
4
|
-
import Box from '@mui/material/Box';
|
|
5
4
|
import { withErrorBoundary } from 'react-error-boundary';
|
|
6
5
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
6
|
import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
|
|
@@ -18,16 +17,16 @@ import { blockletMetaProps } from '../types';
|
|
|
18
17
|
*/
|
|
19
18
|
function Footer({ meta, theme: themeOverrides, ...rest }) {
|
|
20
19
|
const { locale } = useLocaleContext() || {};
|
|
21
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
22
20
|
const formattedBlocklet = useMemo(() => {
|
|
21
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
23
22
|
try {
|
|
24
23
|
return formatBlockletInfo(blocklet);
|
|
25
24
|
} catch (e) {
|
|
26
25
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
27
26
|
return blocklet;
|
|
28
27
|
}
|
|
29
|
-
}, [
|
|
30
|
-
if (!
|
|
28
|
+
}, [meta]);
|
|
29
|
+
if (!formattedBlocklet.appName) {
|
|
31
30
|
return null;
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -62,13 +61,6 @@ function Footer({ meta, theme: themeOverrides, ...rest }) {
|
|
|
62
61
|
return (
|
|
63
62
|
<OverridableThemeProvider theme={themeOverrides}>
|
|
64
63
|
<StyledInternalFooter {...props} {...rest} $bgcolor={theme?.background?.footer} />
|
|
65
|
-
<Box
|
|
66
|
-
position="absolute"
|
|
67
|
-
right={0}
|
|
68
|
-
bottom={0}
|
|
69
|
-
sx={{ color: 'transparent', '::selection': { background: '#000', color: '#fff' } }}>
|
|
70
|
-
{window?.blocklet?.version}
|
|
71
|
-
</Box>
|
|
72
64
|
</OverridableThemeProvider>
|
|
73
65
|
);
|
|
74
66
|
}
|
|
@@ -85,7 +77,6 @@ Footer.defaultProps = {
|
|
|
85
77
|
};
|
|
86
78
|
|
|
87
79
|
const StyledInternalFooter = styled(InternalFooter)`
|
|
88
|
-
position: relative;
|
|
89
80
|
border-top: 1px solid #eee;
|
|
90
81
|
color: ${(props) => props.theme.palette.grey[600]};
|
|
91
82
|
${({ $bgcolor }) => $bgcolor && `background-color: ${$bgcolor};`}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
+
import Box from '@mui/material/Box';
|
|
2
3
|
import Brand from './brand';
|
|
3
4
|
import Links from './links';
|
|
4
5
|
import SocialMedia from './social-media';
|
|
@@ -65,7 +66,18 @@ function InternalFooter(props) {
|
|
|
65
66
|
if (!LayoutComponent) {
|
|
66
67
|
throw new Error(`layout ${layout} is not supported.`);
|
|
67
68
|
}
|
|
68
|
-
return
|
|
69
|
+
return (
|
|
70
|
+
<Box position="relative">
|
|
71
|
+
<LayoutComponent elements={elements} data={props} {...rest} />
|
|
72
|
+
<Box
|
|
73
|
+
position="absolute"
|
|
74
|
+
right={0}
|
|
75
|
+
bottom={0}
|
|
76
|
+
sx={{ color: 'transparent', '::selection': { background: '#000', color: '#fff' } }}>
|
|
77
|
+
{window?.blocklet?.version}
|
|
78
|
+
</Box>
|
|
79
|
+
</Box>
|
|
80
|
+
);
|
|
69
81
|
}
|
|
70
82
|
|
|
71
83
|
InternalFooter.propTypes = {
|
package/src/Header/index.js
CHANGED
|
@@ -62,17 +62,17 @@ const parseNavigation = (navigation) => {
|
|
|
62
62
|
// eslint-disable-next-line no-shadow
|
|
63
63
|
function Header({ meta, addons, sessionManagerProps, homeLink, theme: themeOverrides, ...rest }) {
|
|
64
64
|
const { locale } = useLocaleContext() || {};
|
|
65
|
-
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
66
65
|
const formattedBlocklet = useMemo(() => {
|
|
66
|
+
const blocklet = Object.assign({}, window.blocklet, meta);
|
|
67
67
|
try {
|
|
68
68
|
return formatBlockletInfo(blocklet);
|
|
69
69
|
} catch (e) {
|
|
70
70
|
console.error('Failed to format blocklet info', e, blocklet);
|
|
71
71
|
return blocklet;
|
|
72
72
|
}
|
|
73
|
-
}, [
|
|
73
|
+
}, [meta]);
|
|
74
74
|
|
|
75
|
-
if (!
|
|
75
|
+
if (!formattedBlocklet.appName) {
|
|
76
76
|
return null;
|
|
77
77
|
}
|
|
78
78
|
const { did, appLogo, appName, theme } = formattedBlocklet;
|