muffin-admin 1.45.1 → 1.45.3

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.
@@ -10,15 +10,15 @@ const darkTheme = createTheme({
10
10
  palette: { mode: "dark" },
11
11
  });
12
12
  export function MuffinAdmin(props) {
13
- const { resources, auth } = props;
13
+ const { resources, auth, appBarLinks, dashboard } = props;
14
14
  const children = resources.map((resource) => buildAdmin(["resource", resource.name], Object.assign(Object.assign({}, resource), { key: resource.name })));
15
15
  const appBar = (props) => (_jsxs(AppBar, Object.assign({}, props, { children: [_jsx(Typography, { variant: "h6", color: "inherit", id: "react-admin-title", style: {
16
16
  flex: 1,
17
17
  textOverflow: "ellipsis",
18
18
  whiteSpace: "nowrap",
19
19
  overflow: "hidden",
20
- } }), _jsx(ToggleThemeButton, { lightTheme: defaultTheme, darkTheme: darkTheme }), props.appBarLinks.map((info) => (_jsx(Tooltip, { title: info.title, children: _jsx(IconButton, { color: "inherit", href: info.url, children: _jsx(SvgIcon, { component: findIcon(info.icon) }) }) }, info.url)))] })));
21
- return (_jsx(AdminPropsContext.Provider, { value: props, children: _jsx(Admin, { requireAuth: auth.required, dashboard: buildAdmin(["dashboard"]), loginPage: findBuilder(["loginpage"]), authProvider: buildAdmin(["authprovider"], auth), layout: (props) => _jsx(Layout, Object.assign({}, props, { appBar: appBar })), dataProvider: buildAdmin(["dataprovider"], props), children: children }) }));
20
+ } }), _jsx(ToggleThemeButton, { lightTheme: defaultTheme, darkTheme: darkTheme }), appBarLinks.map((info) => (_jsx(Tooltip, { title: info.title, children: _jsx(IconButton, { color: "inherit", href: info.url, children: _jsx(SvgIcon, { component: findIcon(info.icon) }) }) }, info.url)))] })));
21
+ return (_jsx(AdminPropsContext.Provider, { value: props, children: _jsx(Admin, { authProvider: buildAdmin(["authprovider"], auth), dashboard: buildAdmin(["dashboard"], dashboard), dataProvider: buildAdmin(["dataprovider"], props), layout: (props) => _jsx(Layout, Object.assign({}, props, { appBar: appBar })), loginPage: findBuilder(["loginpage"]), requireAuth: auth.required, children: children }) }));
22
22
  }
23
23
  setupAdmin(["admin"], MuffinAdmin);
24
24
  // Initialize login page
@@ -1,2 +1,4 @@
1
1
  import { AdminOpts } from "./types";
2
- export declare function MuffinDashboard(props: AdminOpts["dashboard"]): import("react/jsx-runtime").JSX.Element;
2
+ export declare function MuffinDashboard({ src }: {
3
+ src: AdminOpts["dashboard"];
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -7,10 +7,17 @@ import TableBody from "@mui/material/TableBody";
7
7
  import TableCell from "@mui/material/TableCell";
8
8
  import TableRow from "@mui/material/TableRow";
9
9
  import Typography from "@mui/material/Typography";
10
- export function MuffinDashboard(props) {
11
- return (_jsx(Grid, { container: true, spacing: 1, children: Array.isArray(props) ? (props.map((card, idx) => _jsx(DashboardCard, Object.assign({}, card), idx))) : (_jsx(DashboardCard, Object.assign({}, props))) }));
10
+ import { setupAdmin } from "./utils";
11
+ export function MuffinDashboard({ src }) {
12
+ return (_jsx(Grid, { container: true, spacing: 1, children: _jsx(AdminCards, { src: src }) }));
12
13
  }
13
- function DashboardCard(title, value) {
14
+ function AdminCards({ src }) {
15
+ if (Array.isArray(src))
16
+ return (_jsx(Grid, { container: true, item: true, spacing: 2, children: src.map((card, idx) => (_jsx(AdminCards, { src: card }, idx))) }));
17
+ return _jsx(DashboardCard, Object.assign({}, src));
18
+ }
19
+ function DashboardCard({ title, value }) {
14
20
  return (_jsx(Grid, { item: true, xs: true, children: _jsx(Card, { children: _jsxs(CardContent, { children: [_jsx(Typography, { variant: "h5", component: "h2", m: 2, style: { textAlign: "center" }, children: title }), (Array.isArray(value) && _jsx(AdminTableView, { src: value })) || (_jsx("pre", { children: JSON.stringify(value, null, 2) }))] }) }) }));
15
21
  }
16
22
  const AdminTableView = ({ src }) => (_jsx(Table, { children: _jsx(TableBody, { children: src.map((row, idx) => (_jsx(TableRow, { hover: true, children: row.map((cell, idx) => (_jsx(TableCell, { children: cell }, idx))) }, idx))) }) }));
23
+ setupAdmin(["dashboard"], (dashboard) => () => _jsx(MuffinDashboard, { src: dashboard }));
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./MuffinAdmin";
2
+ export * from "./MuffinDashboard";
2
3
  export * from "./MuffinResource";
3
4
  export * from "./MuffinResourceCreate";
4
5
  export * from "./MuffinResourceEdit";
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { createRoot } from "react-dom/client";
11
11
  import { buildAdmin } from "./utils";
12
12
  export * from "./MuffinAdmin";
13
+ export * from "./MuffinDashboard";
13
14
  export * from "./MuffinResource";
14
15
  export * from "./MuffinResourceCreate";
15
16
  export * from "./MuffinResourceEdit";