muffin-admin 2.3.9 → 2.3.12

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
@@ -34,6 +34,7 @@ export type AdminResourceProps = {
34
34
  edit: {
35
35
  actions: AdminAction[];
36
36
  inputs: AdminInput[];
37
+ remove?: boolean;
37
38
  } | false;
38
39
  list: {
39
40
  limit: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "2.3.9",
3
+ "version": "2.3.12",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -1,9 +1,12 @@
1
1
  import { useContext } from "react"
2
2
  import {
3
+ DeleteButton,
3
4
  Edit,
4
5
  ListButton,
6
+ SaveButton,
5
7
  ShowButton,
6
8
  SimpleForm,
9
+ Toolbar,
7
10
  TopToolbar,
8
11
  useResourceContext,
9
12
  } from "react-admin"
@@ -19,7 +22,7 @@ export function MuffinResourceEdit(props: AdminResourceProps["edit"]) {
19
22
  } = useContext(AdminPropsContext) as AdminOpts
20
23
 
21
24
  if (!props) return null
22
- const { actions, inputs, ...opts } = props
25
+ const { actions, inputs, remove, ...opts } = props
23
26
 
24
27
  return (
25
28
  <Edit
@@ -27,7 +30,14 @@ export function MuffinResourceEdit(props: AdminResourceProps["edit"]) {
27
30
  mutationMode={mutationMode || "optimistic"}
28
31
  {...opts}
29
32
  >
30
- <SimpleForm>{buildAdmin(["edit-inputs", resourceName], inputs)}</SimpleForm>
33
+ <SimpleForm toolbar={
34
+ <Toolbar>
35
+ <SaveButton />
36
+ {remove && <DeleteButton sx={{
37
+ marginLeft: "auto",
38
+ }} />}
39
+ </Toolbar>
40
+ }>{buildAdmin(["edit-inputs", resourceName], inputs)}</SimpleForm>
31
41
  </Edit>
32
42
  )
33
43
  }
package/src/types.ts CHANGED
@@ -31,11 +31,12 @@ export type AdminResourceProps = {
31
31
  label: string
32
32
  create: AdminInput[] | false
33
33
  edit:
34
- | {
35
- actions: AdminAction[]
36
- inputs: AdminInput[]
37
- }
38
- | false
34
+ | {
35
+ actions: AdminAction[]
36
+ inputs: AdminInput[]
37
+ remove?: boolean
38
+ }
39
+ | false
39
40
  list: {
40
41
  limit: number
41
42
  limitMax: number