muffin-admin 3.7.2 → 3.7.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "muffin-admin",
3
- "version": "3.7.2",
3
+ "version": "3.7.4",
4
4
  "description": "NPM package for https://github.com/klen/muffin-admin",
5
5
  "files": [
6
6
  "src",
@@ -116,20 +116,24 @@ export function CommonPayload({ active, onClose, onHandle, schema, title }) {
116
116
  })
117
117
 
118
118
  return (
119
- <AdminModal
120
- maxWidth="sm"
121
- open={active}
122
- onClose={onClose}
123
- title={translate(title, { _: title })}
124
- >
125
- <FormProvider {...form}>
126
- <FormGroupsProvider>
127
- <form onSubmit={formHandleSubmit}>
128
- {inputs}
129
- <PayloadButtons onClose={onClose} />
130
- </form>
131
- </FormGroupsProvider>
132
- </FormProvider>
133
- </AdminModal>
119
+ <FormProvider {...form}>
120
+ <FormGroupsProvider>
121
+ <AdminModal
122
+ maxWidth="sm"
123
+ open={active}
124
+ onClose={onClose}
125
+ title={translate(title, { _: title })}
126
+ actions={
127
+ <PayloadButtons
128
+ onClose={onClose}
129
+ onSubmit={formHandleSubmit}
130
+ isValid={form.formState.isValid}
131
+ />
132
+ }
133
+ >
134
+ {inputs}
135
+ </AdminModal>
136
+ </FormGroupsProvider>
137
+ </FormProvider>
134
138
  )
135
139
  }
@@ -1,17 +1,23 @@
1
1
  import { Stack } from "@mui/material"
2
2
  import { Button } from "react-admin"
3
- import { useFormContext } from "react-hook-form"
4
3
 
5
- export function PayloadButtons({ onClose }) {
6
- const { formState } = useFormContext()
4
+ export function PayloadButtons({
5
+ onClose,
6
+ onSubmit,
7
+ isValid = true,
8
+ }: {
9
+ onClose: () => void
10
+ onSubmit?: (e: any) => void
11
+ isValid: boolean
12
+ }) {
7
13
  return (
8
14
  <Stack direction="row" alignItems="center" justifyContent="flex-end" spacing={1}>
9
15
  <Button
10
- type="submit"
11
16
  label="ra.action.confirm"
12
17
  variant="contained"
13
- disabled={!formState.isValid}
18
+ disabled={!isValid}
14
19
  size="medium"
20
+ onClick={onSubmit}
15
21
  />
16
22
  <Button label="ra.action.cancel" variant="outlined" size="medium" onClick={onClose} />
17
23
  </Stack>