@blocklet/ui-react 2.10.4 → 2.10.6
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/Header/index.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
import { LiteralUnion } from 'type-fest';
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
1
3
|
import { BlockletMetaProps, SessionManagerProps } from '../@types';
|
|
2
|
-
|
|
3
|
-
meta
|
|
4
|
-
addons
|
|
5
|
-
sessionManagerProps
|
|
6
|
-
homeLink
|
|
7
|
-
theme
|
|
8
|
-
hideNavMenu
|
|
4
|
+
type HeaderProps = {
|
|
5
|
+
meta?: BlockletMetaProps;
|
|
6
|
+
addons?: Function | React.ReactNode;
|
|
7
|
+
sessionManagerProps?: SessionManagerProps;
|
|
8
|
+
homeLink?: string | Function;
|
|
9
|
+
theme?: object;
|
|
10
|
+
hideNavMenu?: boolean;
|
|
9
11
|
bordered?: boolean;
|
|
10
|
-
|
|
12
|
+
logo?: React.ReactNode;
|
|
13
|
+
brand?: React.ReactNode;
|
|
14
|
+
brandAddon?: React.ReactNode;
|
|
15
|
+
description?: React.ReactNode;
|
|
16
|
+
children?: React.ReactNode;
|
|
17
|
+
prepend?: React.ReactNode;
|
|
18
|
+
align?: 'left' | 'right';
|
|
19
|
+
maxWidth?: false | LiteralUnion<'xs' | 'sm' | 'md' | 'lg' | 'xl', string>;
|
|
20
|
+
};
|
|
21
|
+
declare const _default: import("react").ComponentType<HeaderProps & Omit<BoxProps, keyof HeaderProps>>;
|
|
11
22
|
export default _default;
|
|
@@ -187,7 +187,10 @@ export default function UserSessions({
|
|
|
187
187
|
options: {
|
|
188
188
|
customBodyRenderLite: (rawIndex) => {
|
|
189
189
|
const x = safeData[rawIndex];
|
|
190
|
-
return x.createdAt ?
|
|
190
|
+
return x.createdAt ? (
|
|
191
|
+
// @ts-expect-error
|
|
192
|
+
/* @__PURE__ */ jsx(RelativeTime, { value: x.createdAt, relativeRange: 3 * 86400 * 1e3, locale })
|
|
193
|
+
) : t("unknown");
|
|
191
194
|
}
|
|
192
195
|
}
|
|
193
196
|
},
|
|
@@ -197,7 +200,10 @@ export default function UserSessions({
|
|
|
197
200
|
options: {
|
|
198
201
|
customBodyRenderLite: (rawIndex) => {
|
|
199
202
|
const x = safeData[rawIndex];
|
|
200
|
-
return x.status === "expired" ? t("expired") :
|
|
203
|
+
return x.status === "expired" ? t("expired") : (
|
|
204
|
+
// @ts-expect-error
|
|
205
|
+
/* @__PURE__ */ jsx(RelativeTime, { value: x.updatedAt, relativeRange: 3 * 86400 * 1e3, locale })
|
|
206
|
+
);
|
|
201
207
|
}
|
|
202
208
|
}
|
|
203
209
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.6",
|
|
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.
|
|
36
|
-
"@arcblock/react-hooks": "^2.10.
|
|
35
|
+
"@arcblock/bridge": "^2.10.6",
|
|
36
|
+
"@arcblock/react-hooks": "^2.10.6",
|
|
37
37
|
"@iconify-icons/logos": "^1.2.36",
|
|
38
38
|
"@iconify-icons/material-symbols": "^1.2.58",
|
|
39
39
|
"@iconify/react": "^4.1.1",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"prop-types": "^15.8.1",
|
|
51
51
|
"react-error-boundary": "^3.1.4",
|
|
52
52
|
"react-placeholder": "^4.1.0",
|
|
53
|
+
"type-fest": "^4.22.0",
|
|
53
54
|
"ua-parser-js": "^1.0.37",
|
|
54
55
|
"ufo": "^1.5.3"
|
|
55
56
|
},
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"jest": "^28.1.3",
|
|
79
80
|
"unbuild": "^2.0.0"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "b167099e5491387e6f7cc2d36d8f8a8e56e8f28d"
|
|
82
83
|
}
|
package/src/Header/index.tsx
CHANGED
|
@@ -7,6 +7,8 @@ import NavMenu from '@arcblock/ux/lib/NavMenu';
|
|
|
7
7
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
8
8
|
import { temp as colors } from '@arcblock/ux/lib/Colors';
|
|
9
9
|
import omit from 'lodash/omit';
|
|
10
|
+
import { LiteralUnion } from 'type-fest';
|
|
11
|
+
import type { BoxProps } from '@mui/material';
|
|
10
12
|
|
|
11
13
|
import Icon from '../Icon';
|
|
12
14
|
import OverridableThemeProvider from '../common/overridable-theme-provider';
|
|
@@ -56,6 +58,24 @@ const parseNavigation = (navigation: any) => {
|
|
|
56
58
|
return { navItems, activeId: matchedIndex >= 0 ? flattened[matchedIndex].id : null };
|
|
57
59
|
};
|
|
58
60
|
|
|
61
|
+
type HeaderProps = {
|
|
62
|
+
meta?: BlockletMetaProps;
|
|
63
|
+
addons?: Function | React.ReactNode;
|
|
64
|
+
sessionManagerProps?: SessionManagerProps;
|
|
65
|
+
homeLink?: string | Function;
|
|
66
|
+
theme?: object;
|
|
67
|
+
hideNavMenu?: boolean;
|
|
68
|
+
bordered?: boolean;
|
|
69
|
+
logo?: React.ReactNode;
|
|
70
|
+
brand?: React.ReactNode;
|
|
71
|
+
brandAddon?: React.ReactNode;
|
|
72
|
+
description?: React.ReactNode;
|
|
73
|
+
children?: React.ReactNode;
|
|
74
|
+
prepend?: React.ReactNode;
|
|
75
|
+
align?: 'left' | 'right';
|
|
76
|
+
maxWidth?: false | LiteralUnion<'xs' | 'sm' | 'md' | 'lg' | 'xl', string>;
|
|
77
|
+
};
|
|
78
|
+
|
|
59
79
|
/**
|
|
60
80
|
* 专门用于 (composable) blocklet 的 Header 组件, 解析 blocklet meta 中的数据, 通过组合 UX 中的 Header & NavMenu 组件来渲染
|
|
61
81
|
*/
|
|
@@ -71,15 +91,7 @@ function Header({
|
|
|
71
91
|
theme: themeOverrides,
|
|
72
92
|
hideNavMenu = false,
|
|
73
93
|
...rest
|
|
74
|
-
}: {
|
|
75
|
-
meta: BlockletMetaProps;
|
|
76
|
-
addons: Function | JSX.Element;
|
|
77
|
-
sessionManagerProps: SessionManagerProps;
|
|
78
|
-
homeLink: string;
|
|
79
|
-
theme: object;
|
|
80
|
-
hideNavMenu: boolean;
|
|
81
|
-
bordered?: boolean;
|
|
82
|
-
}) {
|
|
94
|
+
}: HeaderProps & Omit<BoxProps, keyof HeaderProps>) {
|
|
83
95
|
useWalletHiddenTopbar();
|
|
84
96
|
const { locale } = useLocaleContext() || {};
|
|
85
97
|
const formattedBlocklet = useMemo(() => {
|
|
@@ -209,6 +209,7 @@ export default function UserSessions({
|
|
|
209
209
|
customBodyRenderLite: (rawIndex: number) => {
|
|
210
210
|
const x = safeData[rawIndex];
|
|
211
211
|
return x.createdAt ? (
|
|
212
|
+
// @ts-expect-error
|
|
212
213
|
<RelativeTime value={x.createdAt} relativeRange={3 * 86400 * 1000} locale={locale} />
|
|
213
214
|
) : (
|
|
214
215
|
t('unknown')
|
|
@@ -225,6 +226,7 @@ export default function UserSessions({
|
|
|
225
226
|
return x.status === 'expired' ? (
|
|
226
227
|
t('expired')
|
|
227
228
|
) : (
|
|
229
|
+
// @ts-expect-error
|
|
228
230
|
<RelativeTime value={x.updatedAt} relativeRange={3 * 86400 * 1000} locale={locale} />
|
|
229
231
|
);
|
|
230
232
|
},
|