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.
package/dist/types.d.ts CHANGED
@@ -57,7 +57,7 @@ export type AdminOpts = {
57
57
  };
58
58
  apiUrl: string;
59
59
  appBarLinks: [{
60
- ulr: string;
60
+ url: string;
61
61
  title: string;
62
62
  icon?: string;
63
63
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "1.45.1",
3
+ "version": "1.45.3",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -30,19 +30,19 @@
30
30
  "validator": "^13.9.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@types/node": "20.3.2",
34
- "@types/react": "18.2.14",
35
- "@types/react-dom": "18.2.6",
33
+ "@types/node": "20.5.0",
34
+ "@types/react": "18.2.20",
35
+ "@types/react-dom": "18.2.7",
36
36
  "@types/react-window": "^1.8.5",
37
- "@typescript-eslint/eslint-plugin": "^6.3.0",
38
- "@typescript-eslint/parser": "^6.3.0",
37
+ "@typescript-eslint/eslint-plugin": "^6.4.0",
38
+ "@typescript-eslint/parser": "^6.4.0",
39
39
  "dotenv": "^16.3.1",
40
- "eslint": "8.46.0",
40
+ "eslint": "8.47.0",
41
41
  "eslint-config-prettier": "^9.0.0",
42
42
  "eslint-plugin-prettier": "^5.0.0",
43
43
  "html-webpack-plugin": "^5.5.3",
44
44
  "husky": "^8.0.1",
45
- "prettier": "^3.0.1",
45
+ "prettier": "^3.0.2",
46
46
  "prettier-plugin-organize-imports": "^3.2.3",
47
47
  "ts-loader": "^9.4.4",
48
48
  "typescript": "^5.1.6",
@@ -20,7 +20,7 @@ const darkTheme = createTheme({
20
20
  })
21
21
 
22
22
  export function MuffinAdmin(props: AdminOpts) {
23
- const { resources, auth } = props
23
+ const { resources, auth, appBarLinks, dashboard } = props
24
24
  const children = resources.map((resource) =>
25
25
  buildAdmin(["resource", resource.name], {
26
26
  ...resource,
@@ -41,7 +41,7 @@ export function MuffinAdmin(props: AdminOpts) {
41
41
  }}
42
42
  />
43
43
  <ToggleThemeButton lightTheme={defaultTheme} darkTheme={darkTheme} />
44
- {props.appBarLinks.map((info) => (
44
+ {appBarLinks.map((info) => (
45
45
  <Tooltip key={info.url} title={info.title}>
46
46
  <IconButton color="inherit" href={info.url}>
47
47
  <SvgIcon component={findIcon(info.icon)} />
@@ -54,12 +54,12 @@ export function MuffinAdmin(props: AdminOpts) {
54
54
  return (
55
55
  <AdminPropsContext.Provider value={props}>
56
56
  <Admin
57
- requireAuth={auth.required}
58
- dashboard={buildAdmin(["dashboard"])}
59
- loginPage={findBuilder(["loginpage"])}
60
57
  authProvider={buildAdmin(["authprovider"], auth)}
61
- layout={(props) => <Layout {...props} appBar={appBar} />}
58
+ dashboard={buildAdmin(["dashboard"], dashboard)}
62
59
  dataProvider={buildAdmin(["dataprovider"], props) as unknown as DataProvider}
60
+ layout={(props) => <Layout {...props} appBar={appBar} />}
61
+ loginPage={findBuilder(["loginpage"])}
62
+ requireAuth={auth.required}
63
63
  >
64
64
  {children}
65
65
  </Admin>
@@ -7,20 +7,30 @@ import TableCell from "@mui/material/TableCell"
7
7
  import TableRow from "@mui/material/TableRow"
8
8
  import Typography from "@mui/material/Typography"
9
9
  import { AdminDashboardBlock, AdminOpts } from "./types"
10
+ import { setupAdmin } from "./utils"
10
11
 
11
- export function MuffinDashboard(props: AdminOpts["dashboard"]) {
12
+ export function MuffinDashboard({ src }: { src: AdminOpts["dashboard"] }) {
12
13
  return (
13
14
  <Grid container spacing={1}>
14
- {Array.isArray(props) ? (
15
- props.map((card, idx) => <DashboardCard key={idx} {...card} />)
16
- ) : (
17
- <DashboardCard {...props} />
18
- )}
15
+ <AdminCards src={src} />
19
16
  </Grid>
20
17
  )
21
18
  }
22
19
 
23
- function DashboardCard(title, value: AdminDashboardBlock) {
20
+ function AdminCards({ src }: { src: AdminDashboardBlock | AdminDashboardBlock[] }) {
21
+ if (Array.isArray(src))
22
+ return (
23
+ <Grid container item spacing={2}>
24
+ {src.map((card, idx) => (
25
+ <AdminCards key={idx} src={card} />
26
+ ))}
27
+ </Grid>
28
+ )
29
+
30
+ return <DashboardCard {...src} />
31
+ }
32
+
33
+ function DashboardCard({ title, value }: AdminDashboardBlock) {
24
34
  return (
25
35
  <Grid item xs>
26
36
  <Card>
@@ -50,3 +60,5 @@ const AdminTableView = ({ src }) => (
50
60
  </TableBody>
51
61
  </Table>
52
62
  )
63
+
64
+ setupAdmin(["dashboard"], (dashboard) => () => <MuffinDashboard src={dashboard} />)
package/src/index.tsx CHANGED
@@ -2,6 +2,7 @@ import { createRoot } from "react-dom/client"
2
2
  import { buildAdmin } from "./utils"
3
3
 
4
4
  export * from "./MuffinAdmin"
5
+ export * from "./MuffinDashboard"
5
6
  export * from "./MuffinResource"
6
7
  export * from "./MuffinResourceCreate"
7
8
  export * from "./MuffinResourceEdit"
package/src/types.ts CHANGED
@@ -57,7 +57,7 @@ export type AdminOpts = {
57
57
  mutationMode?: "optimistic" | "pessimistic" | "undoable"
58
58
  }
59
59
  apiUrl: string
60
- appBarLinks: [{ ulr: string; title: string; icon?: string }]
60
+ appBarLinks: [{ url: string; title: string; icon?: string }]
61
61
  auth: {
62
62
  identityURL: string
63
63
  authorizeURL: string