@applica-software-guru/react-admin 1.4.205 → 1.4.207

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": "@applica-software-guru/react-admin",
3
- "version": "1.4.205",
3
+ "version": "1.4.207",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@ import {
13
13
  useTranslate,
14
14
  UseCreateMutateParams
15
15
  } from 'react-admin';
16
- import { Dialog, Fab, useMediaQuery, useTheme } from '@mui/material';
16
+ import { Dialog, Fab, useMediaQuery } from '@mui/material';
17
17
  import React, { useCallback, useState } from 'react';
18
18
  import { SxProps, Theme, styled } from '@mui/material/styles';
19
19
  import { Toolbar } from '../ra-forms';
@@ -133,6 +133,7 @@ const CreateInDialogContent = ({
133
133
  >
134
134
  {React.cloneElement(children, {
135
135
  ...children.props,
136
+ modal: true,
136
137
  toolbar: (
137
138
  <Toolbar>
138
139
  <Button variant="text" size="medium" label="ra.action.cancel" onClick={onClose} disabled={createProps?.saving} />
@@ -209,14 +210,12 @@ export function CreateInDialogButton({
209
210
  onSubmit,
210
211
  onSuccess,
211
212
  onError,
212
- ...props
213
+ ...controllerProps
213
214
  }: CreateInDialogButtonProps): JSX.Element {
214
215
  const [open, setOpen] = useState(false);
215
216
  const translate = useTranslate();
216
217
  const resource = useResourceContext();
217
218
  const { openDialog, closeDialog } = useAppConfig();
218
- const theme = useTheme();
219
-
220
219
  const handleOpen = useCallback(() => openDialog(resource, () => setOpen(true)), [openDialog, resource]);
221
220
  const handleClose = useCallback(() => closeDialog(resource, () => setOpen(false)), [closeDialog, resource]);
222
221
  const isSmall = fab && useMediaQuery((theme: Theme) => theme.breakpoints.down('md'));
@@ -224,7 +223,6 @@ export function CreateInDialogButton({
224
223
  <>
225
224
  {isSmall ? (
226
225
  <StyledFab
227
- {...props}
228
226
  // @ts-ignore
229
227
  state={scrollStates[String(scrollToTop)]}
230
228
  color="primary"
@@ -235,26 +233,13 @@ export function CreateInDialogButton({
235
233
  <ContentAdd />
236
234
  </StyledFab>
237
235
  ) : (
238
- <Button {...props} sx={sx} label={label} onClick={handleOpen} style={style}>
236
+ <Button sx={sx} label={label} onClick={handleOpen} style={style}>
239
237
  <ContentAdd />
240
238
  </Button>
241
239
  )}
242
- <Dialog
243
- open={open}
244
- scroll="body"
245
- sx={{
246
- '& .MuiToolbar-root': {
247
- borderTop: `1px solid ${theme.palette.divider}`,
248
- position: 'initial',
249
- padding: 2.5
250
- }
251
- }}
252
- onClose={handleClose}
253
- fullWidth={fullWidth}
254
- maxWidth={maxWidth}
255
- >
240
+ <Dialog open={open} scroll="body" onClose={handleClose} fullWidth={fullWidth} maxWidth={maxWidth}>
256
241
  <CreateInDialogContent
257
- {...props}
242
+ {...controllerProps}
258
243
  redirect={redirect}
259
244
  record={record}
260
245
  onClose={handleClose}
@@ -12,7 +12,7 @@ import {
12
12
  } from 'react-admin';
13
13
  import React, { useCallback, useState } from 'react';
14
14
 
15
- import { Breakpoint, Dialog, useTheme } from '@mui/material';
15
+ import { Breakpoint, Dialog } from '@mui/material';
16
16
  import { Edit } from '@mui/icons-material';
17
17
  import { Toolbar } from '../ra-forms';
18
18
  import { useAppConfig } from '../../hooks';
@@ -65,6 +65,8 @@ const EditInDialogContent = ({ onClose, children, mutationMode = 'pessimistic',
65
65
  }}
66
66
  >
67
67
  {React.cloneElement(children, {
68
+ ...children.props,
69
+ modal: true,
68
70
  toolbar: (
69
71
  <Toolbar>
70
72
  <Button variant="text" size="medium" label="ra.action.cancel" onClick={onClose} />
@@ -97,27 +99,12 @@ export function EditInDialogButton({
97
99
  const resource = useResourceContext();
98
100
  const handleOpen = useCallback(() => openDialog(resource, () => setOpen(true)), [openDialog, resource]);
99
101
  const handleClose = useCallback(() => closeDialog(resource, () => setOpen(false)), [closeDialog, resource]);
100
- const theme = useTheme();
101
-
102
102
  return (
103
103
  <>
104
104
  <Button label={label} onClick={handleOpen} style={style}>
105
105
  <Edit />
106
106
  </Button>
107
- <Dialog
108
- open={open}
109
- scroll="body"
110
- sx={{
111
- '& .MuiToolbar-root': {
112
- borderTop: `1px solid ${theme.palette.divider}`,
113
- position: 'initial',
114
- padding: 2.5
115
- }
116
- }}
117
- onClose={handleClose}
118
- fullWidth={fullWidth}
119
- maxWidth={maxWidth}
120
- >
107
+ <Dialog open={open} scroll="body" onClose={handleClose} fullWidth={fullWidth} maxWidth={maxWidth}>
121
108
  <EditInDialogContent {...props} onClose={handleClose}>
122
109
  {children}
123
110
  </EditInDialogContent>
@@ -5,7 +5,7 @@ import {
5
5
  SaveButton,
6
6
  useRecordContext
7
7
  } from 'react-admin';
8
- import { styled } from '@mui/system';
8
+ import { styled, useTheme } from '@mui/system';
9
9
  import { useResourceTitle } from '../../hooks';
10
10
  import ActionsMenu from '../ActionsMenu';
11
11
  import MainCard from '../MainCard';
@@ -13,7 +13,7 @@ import Toolbar from './Toolbar';
13
13
 
14
14
  const StyledSimpleForm = styled(RaSimpleForm, { slot: 'Root' })(({ theme }: { theme: any }) => ({
15
15
  [theme.breakpoints.down('sm')]: {
16
- paddingBottom: '20px',
16
+ paddingBottom: '20px'
17
17
  }
18
18
  }));
19
19
 
@@ -46,6 +46,7 @@ export function SimpleForm({
46
46
  }: SimpleFormProps): JSX.Element {
47
47
  const cardTitle = useResourceTitle(title);
48
48
  const record = useRecordContext();
49
+ const theme = useTheme();
49
50
  return (
50
51
  // @ts-ignore
51
52
  <MainCard
@@ -56,10 +57,13 @@ export function SimpleForm({
56
57
  sx={{
57
58
  ...sx,
58
59
  '& .MuiToolbar-root': {
60
+ position: 'initial',
59
61
  paddingLeft: 2.5,
60
62
  paddingRight: 2.5,
61
63
  paddingBottom: 2.5,
62
- paddingTop: 0
64
+
65
+ paddingTop: modal ? 2.5 : 0,
66
+ borderTop: modal ? `1px solid ${theme.palette.divider}` : undefined
63
67
  }
64
68
  }}
65
69
  border={!modal}
@@ -4,6 +4,7 @@ import {
4
4
  ImageInput,
5
5
  SelectArrayInput,
6
6
  SimpleForm,
7
+ TabbedForm,
7
8
  TableFormIterator,
8
9
  TextInput,
9
10
  useThemeConfig
@@ -11,6 +12,7 @@ import {
11
12
 
12
13
  import { Grid } from '@mui/material';
13
14
  import PropTypes from 'prop-types';
15
+ import { CreateInDialogButton, EditInDialogButton } from '../../../components';
14
16
 
15
17
  const UserForm = ({ configuredRoles }) => {
16
18
  const { spacing } = useThemeConfig();
@@ -42,7 +44,18 @@ const UserForm = ({ configuredRoles }) => {
42
44
  </ArrayInput>
43
45
  </Grid>
44
46
  </Grid>
45
-
47
+ <EditInDialogButton>
48
+ <TabbedForm>
49
+ <TabbedForm.Tab label="ciaooo">
50
+ <TextInput source="ciao" />
51
+ </TabbedForm.Tab>
52
+ </TabbedForm>
53
+ </EditInDialogButton>
54
+ <CreateInDialogButton>
55
+ <SimpleForm>
56
+ <TextInput source="ciao" />
57
+ </SimpleForm>
58
+ </CreateInDialogButton>
46
59
  <BooleanInput source="active" />
47
60
  </SimpleForm>
48
61
  );