@etsoo/toolpad 1.0.7 → 1.0.9
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/build/AppProvider/AppProvider.d.ts +1 -1
- package/build/AppProvider/AppProviderComponent.js +1 -1
- package/build/DashboardLayout/TitleBar.d.ts +2 -1
- package/build/DashboardLayout/TitleBar.js +26 -5
- package/package.json +16 -14
- package/src/AppProvider/AppProvider.tsx +4 -1
- package/src/AppProvider/AppProviderComponent.tsx +1 -1
- package/src/DashboardLayout/TitleBar.tsx +34 -10
- package/build/shared/branding.d.ts +0 -1
- package/build/shared/branding.js +0 -6
- package/src/shared/branding.ts +0 -7
|
@@ -16,7 +16,7 @@ export interface Router {
|
|
|
16
16
|
navigate: Navigate;
|
|
17
17
|
}
|
|
18
18
|
export interface Branding {
|
|
19
|
-
title?: string;
|
|
19
|
+
title?: string | React.ReactNode | [string, (handler: React.MouseEvent<HTMLSpanElement>) => void];
|
|
20
20
|
logo?: React.ReactNode;
|
|
21
21
|
}
|
|
22
22
|
export interface NavigationPageItem {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import React from "react";
|
|
2
|
+
export declare function TitleBar(): number | bigint | boolean | Iterable<React.ReactNode> | Promise<React.AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Stack, styled, Typography, useTheme } from "@mui/material";
|
|
3
3
|
import { Link } from "../shared/Link";
|
|
4
|
-
import { useApplicationTitle } from "../shared/branding";
|
|
5
4
|
import React from "react";
|
|
6
5
|
import { BrandingContext } from "../shared/context";
|
|
7
6
|
const LogoContainer = styled("div")({
|
|
@@ -14,14 +13,36 @@ const LogoContainer = styled("div")({
|
|
|
14
13
|
export function TitleBar() {
|
|
15
14
|
// Theme
|
|
16
15
|
const theme = useTheme();
|
|
17
|
-
// Application title
|
|
18
|
-
const applicationTitle = useApplicationTitle();
|
|
19
16
|
// Branding
|
|
20
17
|
const branding = React.useContext(BrandingContext);
|
|
21
|
-
|
|
18
|
+
// Application title
|
|
19
|
+
const title = branding?.title;
|
|
20
|
+
const [titleUI, hasLink] = React.useMemo(() => {
|
|
21
|
+
if (title == null)
|
|
22
|
+
return [undefined, true];
|
|
23
|
+
if (typeof title === "string" || Array.isArray(title)) {
|
|
24
|
+
let titleString;
|
|
25
|
+
let clickHandler;
|
|
26
|
+
if (Array.isArray(title)) {
|
|
27
|
+
titleString = title[0];
|
|
28
|
+
clickHandler = title[1];
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
titleString = title;
|
|
32
|
+
}
|
|
33
|
+
return [
|
|
34
|
+
_jsx(Typography, { variant: "h6", sx: {
|
|
22
35
|
color: (theme.vars ?? theme).palette.primary.main,
|
|
23
36
|
fontWeight: "700",
|
|
24
37
|
ml: 0.5,
|
|
25
38
|
whiteSpace: "nowrap"
|
|
26
|
-
},
|
|
39
|
+
}, onClick: clickHandler == null ? undefined : (e) => clickHandler(e), children: titleString }),
|
|
40
|
+
true
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
return [title, false];
|
|
44
|
+
}, [title]);
|
|
45
|
+
if (!hasLink)
|
|
46
|
+
return titleUI;
|
|
47
|
+
return (_jsx(Link, { href: "/", style: { color: "inherit", textDecoration: "none" }, children: _jsxs(Stack, { direction: "row", alignItems: "center", children: [branding?.logo && _jsx(LogoContainer, { children: branding.logo }), titleUI] }) }));
|
|
27
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/toolpad",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"author": "ETSOO",
|
|
5
5
|
"description": "Dashboard framework extention based on Toolpad Core",
|
|
6
6
|
"main": "build/index.js",
|
|
@@ -45,31 +45,33 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.26.0",
|
|
47
47
|
"@emotion/css": "^11.13.5",
|
|
48
|
-
"@emotion/react": "^11.
|
|
49
|
-
"@emotion/styled": "^11.
|
|
50
|
-
"@mui/
|
|
51
|
-
"@mui/utils": "6.1.8",
|
|
52
|
-
"@vitejs/plugin-react": "4.3.3",
|
|
48
|
+
"@emotion/react": "^11.14.0",
|
|
49
|
+
"@emotion/styled": "^11.14.0",
|
|
50
|
+
"@mui/utils": "6.3.1",
|
|
53
51
|
"invariant": "2.2.4",
|
|
54
52
|
"path-to-regexp": "6.3.0",
|
|
55
53
|
"prop-types": "15.8.1",
|
|
56
54
|
"react": "^18.3.1"
|
|
57
55
|
},
|
|
56
|
+
"overrides": {
|
|
57
|
+
"react": "$react"
|
|
58
|
+
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@mui/icons-material": "6.1
|
|
60
|
-
"@mui/material": "6.1
|
|
60
|
+
"@mui/icons-material": "6.3.1",
|
|
61
|
+
"@mui/material": "6.3.1",
|
|
61
62
|
"@testing-library/jest-dom": "^6.6.3",
|
|
62
|
-
"@testing-library/react": "^16.0
|
|
63
|
+
"@testing-library/react": "^16.1.0",
|
|
63
64
|
"@types/invariant": "2.2.37",
|
|
64
|
-
"@types/prop-types": "15.7.
|
|
65
|
+
"@types/prop-types": "15.7.14",
|
|
65
66
|
"@types/react": "18.3.12",
|
|
66
67
|
"@types/react-dom": "18.3.1",
|
|
67
|
-
"@
|
|
68
|
+
"@vitejs/plugin-react": "4.3.4",
|
|
69
|
+
"@vitest/browser": "2.1.8",
|
|
68
70
|
"jsdom": "^25.0.1",
|
|
69
71
|
"next": "^15.0.3",
|
|
70
72
|
"next-router-mock": "^0.9.13",
|
|
71
|
-
"playwright": "^1.49.
|
|
72
|
-
"react-router-dom": "7.
|
|
73
|
-
"vitest": "2.1.
|
|
73
|
+
"playwright": "^1.49.1",
|
|
74
|
+
"react-router-dom": "7.1.1",
|
|
75
|
+
"vitest": "2.1.8"
|
|
74
76
|
}
|
|
75
77
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Stack, styled, Typography, useTheme } from "@mui/material";
|
|
2
2
|
import { Link } from "../shared/Link";
|
|
3
|
-
import { useApplicationTitle } from "../shared/branding";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import { BrandingContext } from "../shared/context";
|
|
6
5
|
|
|
@@ -16,16 +15,26 @@ export function TitleBar() {
|
|
|
16
15
|
// Theme
|
|
17
16
|
const theme = useTheme();
|
|
18
17
|
|
|
19
|
-
// Application title
|
|
20
|
-
const applicationTitle = useApplicationTitle();
|
|
21
|
-
|
|
22
18
|
// Branding
|
|
23
19
|
const branding = React.useContext(BrandingContext);
|
|
24
20
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
// Application title
|
|
22
|
+
const title = branding?.title;
|
|
23
|
+
const [titleUI, hasLink] = React.useMemo(() => {
|
|
24
|
+
if (title == null) return [undefined, true];
|
|
25
|
+
|
|
26
|
+
if (typeof title === "string" || Array.isArray(title)) {
|
|
27
|
+
let titleString: string;
|
|
28
|
+
let clickHandler:
|
|
29
|
+
| ((handler: React.MouseEvent<HTMLSpanElement>) => void)
|
|
30
|
+
| undefined;
|
|
31
|
+
if (Array.isArray(title)) {
|
|
32
|
+
titleString = title[0];
|
|
33
|
+
clickHandler = title[1];
|
|
34
|
+
} else {
|
|
35
|
+
titleString = title;
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
29
38
|
<Typography
|
|
30
39
|
variant="h6"
|
|
31
40
|
sx={{
|
|
@@ -34,9 +43,24 @@ export function TitleBar() {
|
|
|
34
43
|
ml: 0.5,
|
|
35
44
|
whiteSpace: "nowrap"
|
|
36
45
|
}}
|
|
46
|
+
onClick={clickHandler == null ? undefined : (e) => clickHandler(e)}
|
|
37
47
|
>
|
|
38
|
-
{
|
|
39
|
-
</Typography
|
|
48
|
+
{titleString}
|
|
49
|
+
</Typography>,
|
|
50
|
+
true
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return [title, false];
|
|
55
|
+
}, [title]);
|
|
56
|
+
|
|
57
|
+
if (!hasLink) return titleUI;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Link href="/" style={{ color: "inherit", textDecoration: "none" }}>
|
|
61
|
+
<Stack direction="row" alignItems="center">
|
|
62
|
+
{branding?.logo && <LogoContainer>{branding.logo}</LogoContainer>}
|
|
63
|
+
{titleUI}
|
|
40
64
|
</Stack>
|
|
41
65
|
</Link>
|
|
42
66
|
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function useApplicationTitle(): string;
|
package/build/shared/branding.js
DELETED