@applica-software-guru/react-admin 1.3.136 → 1.3.138
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-fields/ReferenceManyField.d.ts +57 -7
- package/dist/components/ra-fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/BaseForm.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts +4 -1
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +49 -49
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +4305 -4294
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +52 -52
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ra-fields/ReferenceManyField.tsx +145 -0
- package/src/components/ra-forms/LongForm/BaseForm.tsx +2 -1
- package/src/components/ra-fields/ReferenceManyField.jsx +0 -80
package/package.json
CHANGED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import { Pagination, ReferenceManyField as RaReferenceManyField, ReferenceManyFieldProps as RaReferenceManyFieldProps } from 'react-admin';
|
|
3
|
+
import { styled } from '@mui/system';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
export type StyledDivProps = {
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type ReferenceManyFieldProps = RaReferenceManyFieldProps & {
|
|
12
|
+
/**
|
|
13
|
+
* Default false, serve ad aggiungere un margine attorno al componente.
|
|
14
|
+
*/
|
|
15
|
+
margin?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Default false, serve ad aggiungere un bordo inferiore al componente.
|
|
18
|
+
*/
|
|
19
|
+
border?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Default undefined, serve ad aggiungere un padding superiore al componente per consentire
|
|
22
|
+
* la visualizzazione della toolbar delle bulk action buttons.
|
|
23
|
+
*/
|
|
24
|
+
bulkActionButtons?: boolean | any;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type StyledRootProps = ReferenceManyFieldProps & {
|
|
28
|
+
theme?: any;
|
|
29
|
+
bulkActionButtons?: boolean | any;
|
|
30
|
+
};
|
|
31
|
+
const StyledDiv = function ({ children, className }: StyledDivProps) {
|
|
32
|
+
return <div className={className}>{children}</div>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
StyledDiv.defaultProps = {
|
|
36
|
+
children: null,
|
|
37
|
+
className: ''
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
StyledDiv.propTypes = {
|
|
41
|
+
children: PropTypes.node,
|
|
42
|
+
className: PropTypes.string
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const StyledRoot = styled(StyledDiv, {
|
|
46
|
+
name: 'RaApplicaReferenceManyField',
|
|
47
|
+
slot: 'root'
|
|
48
|
+
})(({ theme, margin, border, bulkActionButtons }: StyledRootProps) => {
|
|
49
|
+
return {
|
|
50
|
+
marginLeft: !margin ? `-${theme.spacing(2.5)}` : 0,
|
|
51
|
+
marginRight: !margin ? `-${theme.spacing(2.5)}` : 0,
|
|
52
|
+
borderBottom: border ? `1px solid ${theme.palette.divider}` : 'none',
|
|
53
|
+
'& form': {
|
|
54
|
+
padding: theme.spacing(2)
|
|
55
|
+
},
|
|
56
|
+
'& .MuiCardContent-root': {
|
|
57
|
+
borderTop: border ? `1px solid ${theme.palette.divider}` : 'none'
|
|
58
|
+
},
|
|
59
|
+
'& .MuiToolbar-root': {
|
|
60
|
+
[theme.breakpoints.up('sm')]: {
|
|
61
|
+
marginTop: `-${theme.spacing(2)}`,
|
|
62
|
+
marginBottom: theme.spacing(margin ? 0 : 1),
|
|
63
|
+
marginLeft: theme.spacing(margin ? 1 : 2),
|
|
64
|
+
marginRight: theme.spacing(margin ? 1 : 2),
|
|
65
|
+
width: margin ? 'auto' : `calc(100% - ${theme.spacing(5)})`
|
|
66
|
+
},
|
|
67
|
+
[theme.breakpoints.down('md')]: {
|
|
68
|
+
marginTop: 0
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
'& .RaDatagrid-root': {
|
|
72
|
+
overflowX: 'auto',
|
|
73
|
+
paddingTop: bulkActionButtons === false ? 0 : 48,
|
|
74
|
+
[theme.breakpoints.down('sm')]: {
|
|
75
|
+
width: 'calc(100vw - 34px)'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
'& .RaDatagrid-table': {
|
|
79
|
+
borderBottom: `1px solid ${theme.palette.divider}`
|
|
80
|
+
},
|
|
81
|
+
'& .MuiTablePagination-toolbar': {
|
|
82
|
+
marginTop: theme.spacing(1),
|
|
83
|
+
marginBottom: 0
|
|
84
|
+
},
|
|
85
|
+
'& .RaBulkActionsToolbar-collapsed.RaBulkActionsToolbar-toolbar': {
|
|
86
|
+
minHeight: 0
|
|
87
|
+
},
|
|
88
|
+
'& .RaBulkActionsToolbar-toolbar': {
|
|
89
|
+
minHeight: 48,
|
|
90
|
+
bottom: -56,
|
|
91
|
+
'& h6': {
|
|
92
|
+
marginTop: theme.spacing(0.5)
|
|
93
|
+
},
|
|
94
|
+
'& .RaBulkActionsToolbar-topToolbar': {
|
|
95
|
+
marginTop: theme.spacing(1)
|
|
96
|
+
},
|
|
97
|
+
[theme.breakpoints.down('sm')]: {
|
|
98
|
+
bottom: -48,
|
|
99
|
+
borderRadius: 0
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Consente di gestire la visualizzazione di una lista di record correlati ad un record principale.
|
|
107
|
+
* Questo componente è una versione customizzata del componente ReferenceManyField di React-Admin.
|
|
108
|
+
*
|
|
109
|
+
* Se vuoi visualizzare record e non mostrare l'elenco delle azioni disponibili (bulk action buttons)
|
|
110
|
+
* puoi impostare la prop bulkActionButtons a false e, successivamente, se utilizzi un componente interno di tipo <Datagrid />
|
|
111
|
+
* devi impostare la stessa proprietà, bulkActionButtons, a false (in questo modo viene completamente eliminato il padding
|
|
112
|
+
* superiore del componente <Datagrid />).
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* import { ReferenceManyField, Datagrid } from '@applica-software-guru/react-admin';
|
|
116
|
+
*
|
|
117
|
+
* const MyComponent = (props) => (
|
|
118
|
+
* <ReferenceManyField {...props} bulkActionButtons={false}>
|
|
119
|
+
* <Datagrid bulkActionButtons={false}>
|
|
120
|
+
* ...
|
|
121
|
+
* </Datagrid>
|
|
122
|
+
* </ReferenceManyField>
|
|
123
|
+
*
|
|
124
|
+
* @param props {ReferenceManyFieldProps}
|
|
125
|
+
* @returns {JSX.Element}
|
|
126
|
+
*/
|
|
127
|
+
const ReferenceManyField = (props: ReferenceManyFieldProps) => (
|
|
128
|
+
<StyledRoot {...props}>
|
|
129
|
+
{/** @ts-ignore */}
|
|
130
|
+
<RaReferenceManyField pagination={<Pagination />} {...props} />
|
|
131
|
+
</StyledRoot>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
ReferenceManyField.defaultProps = {
|
|
135
|
+
margin: false,
|
|
136
|
+
border: false
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
ReferenceManyField.propTypes = {
|
|
140
|
+
...RaReferenceManyField.propTypes,
|
|
141
|
+
margin: PropTypes.bool,
|
|
142
|
+
border: PropTypes.bool
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default ReferenceManyField;
|
|
@@ -21,7 +21,8 @@ const StyledGrid = styled(Grid, {
|
|
|
21
21
|
borderTop: `1px solid ${theme.palette.divider}`,
|
|
22
22
|
[theme.breakpoints.down('sm')]: {
|
|
23
23
|
position: 'initial !important',
|
|
24
|
-
width: 'auto !important'
|
|
24
|
+
width: 'auto !important',
|
|
25
|
+
marginRight: 0
|
|
25
26
|
}
|
|
26
27
|
},
|
|
27
28
|
'& form > .MuiToolbar-root': {
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import { Pagination, ReferenceManyField as RaReferenceManyField } from 'react-admin';
|
|
3
|
-
import { styled } from '@mui/system';
|
|
4
|
-
const StyledRoot = styled('div', {
|
|
5
|
-
name: 'RaApplicaReferenceManyField',
|
|
6
|
-
slot: 'root'
|
|
7
|
-
})(({ theme, margin, border }) => ({
|
|
8
|
-
marginLeft: !margin ? `-${theme.spacing(2.5)}` : 0,
|
|
9
|
-
marginRight: !margin ? `-${theme.spacing(2.5)}` : 0,
|
|
10
|
-
borderBottom: border ? `1px solid ${theme.palette.divider}` : 'none',
|
|
11
|
-
'& form': {
|
|
12
|
-
padding: theme.spacing(2)
|
|
13
|
-
},
|
|
14
|
-
'& .MuiCardContent-root': {
|
|
15
|
-
borderTop: border ? `1px solid ${theme.palette.divider}` : 'none'
|
|
16
|
-
},
|
|
17
|
-
'& .MuiToolbar-root': {
|
|
18
|
-
[theme.breakpoints.up('sm')]: {
|
|
19
|
-
marginTop: `-${theme.spacing(2)}`,
|
|
20
|
-
marginBottom: theme.spacing(margin ? 0 : 1),
|
|
21
|
-
marginLeft: theme.spacing(margin ? 1 : 2),
|
|
22
|
-
marginRight: theme.spacing(margin ? 1 : 2),
|
|
23
|
-
width: margin ? 'auto' : `calc(100% - ${theme.spacing(5)})`
|
|
24
|
-
},
|
|
25
|
-
[theme.breakpoints.down('md')]: {
|
|
26
|
-
marginTop: 0
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
'& .RaDatagrid-root': {
|
|
30
|
-
overflowX: 'auto',
|
|
31
|
-
paddingTop: 48,
|
|
32
|
-
[theme.breakpoints.down('sm')]: {
|
|
33
|
-
width: 'calc(100vw - 34px)'
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
'& .RaDatagrid-table': {
|
|
37
|
-
borderBottom: `1px solid ${theme.palette.divider}`
|
|
38
|
-
},
|
|
39
|
-
'& .MuiTablePagination-toolbar': {
|
|
40
|
-
marginTop: theme.spacing(1),
|
|
41
|
-
marginBottom: 0
|
|
42
|
-
},
|
|
43
|
-
'& .RaBulkActionsToolbar-collapsed.RaBulkActionsToolbar-toolbar': {
|
|
44
|
-
minHeight: 0
|
|
45
|
-
},
|
|
46
|
-
'& .RaBulkActionsToolbar-toolbar': {
|
|
47
|
-
minHeight: 48,
|
|
48
|
-
bottom: -56,
|
|
49
|
-
'& h6': {
|
|
50
|
-
marginTop: theme.spacing(0.5)
|
|
51
|
-
},
|
|
52
|
-
'& .RaBulkActionsToolbar-topToolbar': {
|
|
53
|
-
marginTop: theme.spacing(1)
|
|
54
|
-
},
|
|
55
|
-
[theme.breakpoints.down('sm')]: {
|
|
56
|
-
bottom: -48,
|
|
57
|
-
borderRadius: 0
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
|
-
const ReferenceManyField = (props) => (
|
|
63
|
-
<StyledRoot>
|
|
64
|
-
<RaReferenceManyField pagination={<Pagination />} {...props} />
|
|
65
|
-
</StyledRoot>
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
ReferenceManyField.defaultProps = {
|
|
69
|
-
...RaReferenceManyField.defaultProps,
|
|
70
|
-
margin: false,
|
|
71
|
-
border: false
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
ReferenceManyField.propTypes = {
|
|
75
|
-
...RaReferenceManyField.propTypes,
|
|
76
|
-
margin: PropTypes.bool,
|
|
77
|
-
border: PropTypes.bool
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export default ReferenceManyField;
|