@applica-software-guru/react-admin 1.4.206 → 1.4.208
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/components/ra-buttons/CreateInDialogButton.d.ts +3 -2
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/EditInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-forms/SimpleForm.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +43 -43
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +1424 -1450
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +38 -38
- package/dist/react-admin.umd.js.map +1 -1
- package/package-lock-new.json +10009 -0
- package/package.json +1 -1
- package/src/components/ra-buttons/CreateInDialogButton.tsx +8 -22
- package/src/components/ra-buttons/EditInDialogButton.tsx +4 -17
- package/src/components/ra-forms/SimpleForm.tsx +7 -3
- package/src/components/ra-forms/TabbedForm.tsx +1 -1
- package/src/index.jsx +3 -0
- package/src/playground/components/ra-forms/UserForm.jsx +14 -1
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
useTranslate,
|
|
14
14
|
UseCreateMutateParams
|
|
15
15
|
} from 'react-admin';
|
|
16
|
-
import { Dialog, Fab, useMediaQuery
|
|
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';
|
|
@@ -46,13 +46,14 @@ export type CreateInDialogContentProps = CreateControllerProps & {
|
|
|
46
46
|
redirect: RedirectionSideEffect | boolean | undefined;
|
|
47
47
|
children: React.ReactElement;
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* You can use it to handle the form submission yourself.
|
|
50
|
+
* Good luck with that.
|
|
50
51
|
*/
|
|
51
52
|
onSubmit?: (record: any, close: () => void) => void;
|
|
52
53
|
/**
|
|
53
54
|
* @deprecated Use mutationOptions.onSuccess instead
|
|
54
55
|
*/
|
|
55
|
-
onSuccess?: (data: any) => void;
|
|
56
|
+
onSuccess?: (data: any, close: () => void) => void;
|
|
56
57
|
/**
|
|
57
58
|
* @deprecated Use mutationOptions.onError instead
|
|
58
59
|
*/
|
|
@@ -93,11 +94,10 @@ const CreateInDialogContent = ({
|
|
|
93
94
|
redirect(_redirect as RedirectionSideEffect, resource, data.id, data);
|
|
94
95
|
}
|
|
95
96
|
if (onSuccess) {
|
|
96
|
-
onSuccess(data);
|
|
97
|
+
onSuccess(data, onClose);
|
|
97
98
|
}
|
|
98
|
-
// WARN: This is a temporary solution to handle onSuccess from mutationOptions
|
|
99
99
|
if (props?.mutationOptions?.onSuccess) {
|
|
100
|
-
props.mutationOptions.onSuccess(data, variables, context);
|
|
100
|
+
props.mutationOptions.onSuccess(data, variables, { ...(context as any), onClose });
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
[onClose, onSuccess, queryClient, resource, notify, redirect, _redirect]
|
|
@@ -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} />
|
|
@@ -215,8 +216,6 @@ export function CreateInDialogButton({
|
|
|
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'));
|
|
@@ -238,20 +237,7 @@ export function CreateInDialogButton({
|
|
|
238
237
|
<ContentAdd />
|
|
239
238
|
</Button>
|
|
240
239
|
)}
|
|
241
|
-
<Dialog
|
|
242
|
-
open={open}
|
|
243
|
-
scroll="body"
|
|
244
|
-
sx={{
|
|
245
|
-
'& .MuiToolbar-root': {
|
|
246
|
-
borderTop: `1px solid ${theme.palette.divider}`,
|
|
247
|
-
position: 'initial',
|
|
248
|
-
padding: 2.5
|
|
249
|
-
}
|
|
250
|
-
}}
|
|
251
|
-
onClose={handleClose}
|
|
252
|
-
fullWidth={fullWidth}
|
|
253
|
-
maxWidth={maxWidth}
|
|
254
|
-
>
|
|
240
|
+
<Dialog open={open} scroll="body" onClose={handleClose} fullWidth={fullWidth} maxWidth={maxWidth}>
|
|
255
241
|
<CreateInDialogContent
|
|
256
242
|
{...controllerProps}
|
|
257
243
|
redirect={redirect}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
} from 'react-admin';
|
|
13
13
|
import React, { useCallback, useState } from 'react';
|
|
14
14
|
|
|
15
|
-
import { Breakpoint, Dialog
|
|
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
|
-
|
|
64
|
+
|
|
65
|
+
paddingTop: modal ? 2.5 : 0,
|
|
66
|
+
borderTop: modal ? `1px solid ${theme.palette.divider}` : undefined
|
|
63
67
|
}
|
|
64
68
|
}}
|
|
65
69
|
border={!modal}
|
package/src/index.jsx
CHANGED
|
@@ -57,9 +57,11 @@ export {
|
|
|
57
57
|
useAuthProvider,
|
|
58
58
|
useChoices,
|
|
59
59
|
useChoicesContext,
|
|
60
|
+
useCreateContext,
|
|
60
61
|
useCreateController,
|
|
61
62
|
useDataProvider,
|
|
62
63
|
useEditContext,
|
|
64
|
+
useEditController,
|
|
63
65
|
useGetIdentity,
|
|
64
66
|
useGetList,
|
|
65
67
|
useGetMany,
|
|
@@ -67,6 +69,7 @@ export {
|
|
|
67
69
|
useGetOne,
|
|
68
70
|
useInput,
|
|
69
71
|
useListContext,
|
|
72
|
+
useListController,
|
|
70
73
|
useLocaleState,
|
|
71
74
|
useNotify,
|
|
72
75
|
usePermissions,
|
|
@@ -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
|
);
|