@applica-software-guru/react-admin 1.3.184 → 1.4.0-beta.0
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/bitbucket-pipelines.yml +3 -3
- package/dist/components/ActionsMenu.d.ts +3 -16
- package/dist/components/ActionsMenu.d.ts.map +1 -1
- package/dist/components/MenuPopover/MenuPopover.d.ts.map +1 -1
- package/dist/components/MenuPopover/styles.d.ts.map +1 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts +6 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/EditInDialogButton.d.ts +2 -1
- package/dist/components/ra-buttons/EditInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-custom/ListItem.d.ts +3 -6
- package/dist/components/ra-custom/ListItem.d.ts.map +1 -1
- package/dist/components/ra-fields/BaseAttachmentField.d.ts.map +1 -1
- package/dist/components/ra-fields/DateField.d.ts.map +1 -1
- package/dist/components/ra-fields/EmailField.d.ts.map +1 -1
- package/dist/components/ra-fields/FileField.d.ts.map +1 -1
- package/dist/components/ra-fields/ImageField.d.ts.map +1 -1
- package/dist/components/ra-fields/ReferenceManyField.d.ts +0 -3
- package/dist/components/ra-fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/components/ra-fields/TextField.d.ts.map +1 -1
- package/dist/components/ra-forms/CardForm.d.ts.map +1 -1
- package/dist/components/ra-forms/Create.d.ts.map +1 -1
- package/dist/components/ra-forms/Edit.d.ts +2 -24
- package/dist/components/ra-forms/Edit.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/BaseForm.d.ts.map +1 -1
- package/dist/components/ra-forms/Show.d.ts +2 -1
- package/dist/components/ra-forms/Show.d.ts.map +1 -1
- package/dist/components/ra-forms/SimpleForm.d.ts.map +1 -1
- package/dist/components/ra-forms/SimpleFormIterator.d.ts +1 -1
- package/dist/components/ra-forms/SimpleFormIterator.d.ts.map +1 -1
- package/dist/components/ra-forms/TabbedForm.d.ts.map +1 -1
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts +0 -3
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
- package/dist/components/ra-forms/Toolbar.d.ts.map +1 -1
- package/dist/components/ra-forms/index.d.ts +1 -0
- package/dist/components/ra-forms/index.d.ts.map +1 -1
- package/dist/components/ra-inputs/ArrayInput.d.ts +2 -5
- package/dist/components/ra-inputs/ArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AttachmentInput.d.ts +0 -3
- package/dist/components/ra-inputs/AttachmentInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/BooleanInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/DateInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/DateTimeInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/FileInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/NumberInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SearchInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/TimeInput.d.ts.map +1 -1
- package/dist/components/ra-lists/Datagrid/Datagrid.d.ts +1 -1
- package/dist/components/ra-lists/Datagrid/Datagrid.d.ts.map +1 -1
- package/dist/components/ra-lists/Datagrid/index.d.ts.map +1 -1
- package/dist/components/ra-lists/List.d.ts.map +1 -1
- package/dist/components/ra-lists/SimpleList.d.ts +2 -2
- package/dist/components/ra-lists/SimpleList.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/useApplicaAuthProvider.d.ts +3 -0
- package/dist/hooks/useApplicaAuthProvider.d.ts.map +1 -0
- package/dist/hooks/useMemoizedObject.d.ts +3 -5
- package/dist/hooks/useMemoizedObject.d.ts.map +1 -1
- package/dist/hooks/useResourceTitle.d.ts +7 -1
- package/dist/hooks/useResourceTitle.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +66 -82
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +10426 -10082
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +67 -83
- package/dist/react-admin.umd.js.map +1 -1
- package/index.html +5 -0
- package/package.json +5 -5
- package/src/components/ActionsMenu.tsx +20 -20
- package/src/components/Layout/Provider.tsx +3 -3
- package/src/components/MenuPopover/MenuPopover.jsx +1 -0
- package/src/components/MenuPopover/styles.jsx +7 -3
- package/src/components/ra-buttons/CreateInDialogButton.tsx +19 -13
- package/src/components/ra-buttons/EditInDialogButton.tsx +9 -4
- package/src/components/ra-custom/ListItem.tsx +3 -6
- package/src/components/ra-fields/BaseAttachmentField.tsx +1 -6
- package/src/components/ra-fields/DateField.tsx +1 -4
- package/src/components/ra-fields/EmailField.tsx +1 -4
- package/src/components/ra-fields/FileField.tsx +1 -4
- package/src/components/ra-fields/ImageField.tsx +1 -4
- package/src/components/ra-fields/ReferenceManyField.tsx +1 -7
- package/src/components/ra-fields/TextField.tsx +1 -4
- package/src/components/ra-forms/CardForm.tsx +10 -6
- package/src/components/ra-forms/Create.tsx +8 -5
- package/src/components/ra-forms/Edit.tsx +12 -7
- package/src/components/ra-forms/LongForm/BaseForm.tsx +11 -4
- package/src/components/ra-forms/Show.tsx +18 -19
- package/src/components/ra-forms/SimpleForm.tsx +5 -8
- package/src/components/ra-forms/SimpleFormIterator.tsx +24 -26
- package/src/components/ra-forms/TabbedForm.tsx +5 -5
- package/src/components/ra-forms/TableForm/TableFormIterator.tsx +5 -10
- package/src/components/ra-forms/Toolbar.tsx +1 -4
- package/src/components/ra-forms/index.ts +1 -0
- package/src/components/ra-inputs/ArrayInput.tsx +3 -9
- package/src/components/ra-inputs/AttachmentInput.tsx +1 -7
- package/src/components/ra-inputs/BooleanInput.tsx +1 -4
- package/src/components/ra-inputs/DateInput.tsx +1 -4
- package/src/components/ra-inputs/DateTimeInput.tsx +1 -4
- package/src/components/ra-inputs/FileInput.tsx +1 -4
- package/src/components/ra-inputs/NumberInput.tsx +1 -4
- package/src/components/ra-inputs/SearchInput.tsx +1 -4
- package/src/components/ra-inputs/SelectArrayInput.tsx +1 -4
- package/src/components/ra-inputs/SelectInput.tsx +2 -5
- package/src/components/ra-inputs/TimeInput.tsx +1 -4
- package/src/components/ra-lists/Datagrid/Datagrid.tsx +33 -71
- package/src/components/ra-lists/Datagrid/index.tsx +1 -4
- package/src/components/ra-lists/List.tsx +1 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useApplicaAuthProvider.js +8 -0
- package/src/hooks/useMemoizedObject.tsx +3 -5
- package/src/hooks/{useResourceTitle.jsx → useResourceTitle.ts} +8 -2
- package/src/index.jsx +1 -0
- package/src/playground/types.ts +16 -18
- package/vite.config.js +3 -4
|
@@ -11,16 +11,13 @@ import ActionsMenu from '../ActionsMenu';
|
|
|
11
11
|
import MainCard from '../MainCard';
|
|
12
12
|
import Toolbar from './Toolbar';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
name: 'RaApplicaSimpleForm',
|
|
16
|
-
slot: 'Root'
|
|
17
|
-
})(({ theme, modal }: { theme: any; modal: boolean }) => ({
|
|
14
|
+
const StyledSimpleForm = styled(RaSimpleForm, { slot: 'Root' })(({ theme, modal }: { theme: any; modal: boolean }) => ({
|
|
18
15
|
'& .MuiGrid-root.MuiGrid-container': {
|
|
19
16
|
paddingBottom: theme.spacing(modal ? 0 : 2.5)
|
|
20
17
|
} as any,
|
|
21
|
-
[theme.breakpoints.down('sm')]: {
|
|
22
|
-
|
|
23
|
-
}
|
|
18
|
+
// [theme.breakpoints.down('sm')]: {
|
|
19
|
+
paddingBottom: '0 !important',
|
|
20
|
+
// }
|
|
24
21
|
}));
|
|
25
22
|
|
|
26
23
|
export type SimpleFormProps = RaSimpleFormProps & {
|
|
@@ -71,7 +68,7 @@ export function SimpleForm({
|
|
|
71
68
|
divider
|
|
72
69
|
>
|
|
73
70
|
{/* @ts-ignore */}
|
|
74
|
-
<
|
|
71
|
+
<StyledSimpleForm toolbar={toolbar} {...props} />
|
|
75
72
|
</MainCard>
|
|
76
73
|
);
|
|
77
74
|
}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
import { SimpleFormIterator as RaSimpleFormIterator } from 'react-admin';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
position: 'relative',
|
|
24
|
-
overflow: 'visible',
|
|
25
|
-
transform: 'none',
|
|
26
|
-
marginLeft: 0
|
|
27
|
-
}
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const StyledSimpleFormIterator = styled(RaSimpleFormIterator, { root: 'root' })(({ theme }) => ({
|
|
6
|
+
'& .RaSimpleFormIterator-line': {
|
|
7
|
+
paddingTop: theme.spacing(1),
|
|
8
|
+
paddingBottom: theme.spacing(0.5)
|
|
9
|
+
},
|
|
10
|
+
'& .RaSimpleFormIterator-action': {
|
|
11
|
+
display: 'flex',
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
mb: 1.5
|
|
15
|
+
},
|
|
16
|
+
'& section': {
|
|
17
|
+
width: '100%',
|
|
18
|
+
'& label': {
|
|
19
|
+
position: 'relative',
|
|
20
|
+
overflow: 'visible',
|
|
21
|
+
transform: 'none',
|
|
22
|
+
marginLeft: 0
|
|
28
23
|
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
31
26
|
|
|
27
|
+
export function SimpleFormIterator(props: any): JSX.Element {
|
|
28
|
+
return <StyledSimpleFormIterator {...props} />;
|
|
29
|
+
}
|
|
32
30
|
export default SimpleFormIterator;
|
|
@@ -25,10 +25,7 @@ export type TabbedFormProps = RaTabbedFormProps & {
|
|
|
25
25
|
noPadding?: boolean;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
|
-
const StyledTabbedForm = styled(RaTabbedForm, {
|
|
29
|
-
name: 'RaApplicaTabbedForm',
|
|
30
|
-
slot: 'Root'
|
|
31
|
-
})(({ theme, modal }: { theme: any; modal: boolean }) => ({
|
|
28
|
+
const StyledTabbedForm = styled(RaTabbedForm, { slot: 'Root' })(({ theme, modal }: { theme: any; modal: boolean }) => ({
|
|
32
29
|
'& .MuiGrid-root.MuiGrid-container': {
|
|
33
30
|
paddingBottom: theme.spacing(modal ? 0 : 1)
|
|
34
31
|
} as any,
|
|
@@ -83,7 +80,10 @@ export function TabbedForm(props: TabbedFormProps): JSX.Element {
|
|
|
83
80
|
ml: 2.5,
|
|
84
81
|
mr: 2.5
|
|
85
82
|
},
|
|
86
|
-
|
|
83
|
+
'& .MuiToolbar-root.RaToolbar-desktopToolbar': {
|
|
84
|
+
position: 'initial',
|
|
85
|
+
paddingTop: 0
|
|
86
|
+
},
|
|
87
87
|
'& .MuiToolbar-root': {
|
|
88
88
|
padding: 2.5
|
|
89
89
|
}
|
|
@@ -38,9 +38,6 @@ import get from 'lodash/get';
|
|
|
38
38
|
* </ArrayInput>
|
|
39
39
|
* </Grid>
|
|
40
40
|
* </Grid>
|
|
41
|
-
*
|
|
42
|
-
* @param props
|
|
43
|
-
* @returns
|
|
44
41
|
*/
|
|
45
42
|
export function RawTableFormIterator(props: TableFormIteratorProps): ReactElement | null {
|
|
46
43
|
const {
|
|
@@ -164,8 +161,8 @@ export function RawTableFormIterator(props: TableFormIteratorProps): ReactElemen
|
|
|
164
161
|
sx={
|
|
165
162
|
inset === true
|
|
166
163
|
? {
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
borderRadius: 0
|
|
165
|
+
}
|
|
169
166
|
: { mt: 2, border: `1px solid ${tableBorderColor}` }
|
|
170
167
|
}
|
|
171
168
|
>
|
|
@@ -277,14 +274,12 @@ function AddTableRow(props: any): JSX.Element {
|
|
|
277
274
|
);
|
|
278
275
|
}
|
|
279
276
|
|
|
280
|
-
export const TableFormIterator = styled(RawTableFormIterator, {
|
|
281
|
-
name: 'RaApplicaTableFormIterator',
|
|
282
|
-
slot: 'Root'
|
|
283
|
-
})(({ theme }) => ({
|
|
277
|
+
export const TableFormIterator = styled(RawTableFormIterator, { slot: 'Root' })(({ theme }) => ({
|
|
284
278
|
'& > div.MuiPaper-root': {
|
|
285
279
|
overflowX: 'auto',
|
|
280
|
+
// this decision has been made with Roberto in order to avoid Marco gets angry
|
|
286
281
|
[theme.breakpoints.down('sm')]: {
|
|
287
|
-
width: `calc(100vw - ${theme.spacing(8)})`
|
|
282
|
+
width: `calc(100vw - ${theme.spacing(8.25)})`
|
|
288
283
|
}
|
|
289
284
|
},
|
|
290
285
|
[theme.breakpoints.down('sm')]: {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { styled } from '@mui/system';
|
|
2
2
|
import { Toolbar as RaToolbar, ToolbarProps } from 'react-admin';
|
|
3
3
|
|
|
4
|
-
const StyledToolbar = styled(RaToolbar, {
|
|
5
|
-
name: 'RaApplicaToolbar',
|
|
6
|
-
slot: 'Root'
|
|
7
|
-
})(({ theme }: { theme: any }) => ({
|
|
4
|
+
const StyledToolbar = styled(RaToolbar, { slot: 'Root' })(({ theme }: { theme: any }) => ({
|
|
8
5
|
...theme.mixins.toolbar,
|
|
9
6
|
backgroundColor: theme.palette.background.paper,
|
|
10
7
|
justifyContent: 'flex-end',
|
|
@@ -2,10 +2,7 @@ import { ArrayInput as RaArrayInput, ArrayInputProps as RaArrayInputProps } from
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledArrayInput, { LabeledArrayInputProps } from './LabeledArrayInput';
|
|
4
4
|
|
|
5
|
-
const StyledArrayInput = styled(RaArrayInput, {
|
|
6
|
-
name: 'ApplicaArrayInput',
|
|
7
|
-
slot: 'root'
|
|
8
|
-
})(({ theme }) => ({
|
|
5
|
+
const StyledArrayInput = styled(RaArrayInput, { slot: 'root' })(({ theme }) => ({
|
|
9
6
|
'& .MuiStack-root > label': {
|
|
10
7
|
marginTop: theme.spacing(2)
|
|
11
8
|
},
|
|
@@ -27,11 +24,8 @@ export type ArrayInputProps = RaArrayInputProps &
|
|
|
27
24
|
};
|
|
28
25
|
|
|
29
26
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param {ArrayInputProps}
|
|
34
|
-
* @returns {React.ReactElement}
|
|
27
|
+
* Expose an ArrayInput component with Applica graphic style.
|
|
28
|
+
* If you want to use the pure react-admin component you can use RaArrayInput exposed in the library.
|
|
35
29
|
*/
|
|
36
30
|
export function ArrayInput({ label, addLabel, source, helperText, divider = true, ...props }: ArrayInputProps): React.ReactElement {
|
|
37
31
|
return (
|
|
@@ -20,10 +20,7 @@ const removeDeleteIfNecessary = (disabled: boolean) => {
|
|
|
20
20
|
return {};
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
const StyledFileInput = styled(RaFileInput, {
|
|
24
|
-
name: 'RaApplicaFileInput',
|
|
25
|
-
slot: 'root'
|
|
26
|
-
})(({ disabled, theme }: { disabled: boolean; theme: any }) => ({
|
|
23
|
+
const StyledFileInput = styled(RaFileInput, { slot: 'root' })(({ disabled, theme }: { disabled: boolean; theme: any }) => ({
|
|
27
24
|
'& .previews': {},
|
|
28
25
|
'& .previews>div': {
|
|
29
26
|
marginTop: theme.spacing(1),
|
|
@@ -57,9 +54,6 @@ export type AttachmentInputProps = FileInputProps & {
|
|
|
57
54
|
*
|
|
58
55
|
* @example
|
|
59
56
|
* <AttachmentInput source="attachments" title="name" accept="image/*" multiple>
|
|
60
|
-
*
|
|
61
|
-
* @param {AttachmentInputProps}
|
|
62
|
-
* @returns
|
|
63
57
|
*/
|
|
64
58
|
export function AttachmentInput({
|
|
65
59
|
// @ts-ignore
|
|
@@ -3,10 +3,7 @@ import { styled } from '@mui/material/styles';
|
|
|
3
3
|
import { useTheme } from '@emotion/react';
|
|
4
4
|
import LabeledInput from './LabeledInput';
|
|
5
5
|
|
|
6
|
-
const StyledBooleanInput = styled(RaBooleanInput, {
|
|
7
|
-
name: 'RaApplicaBooleanInput',
|
|
8
|
-
slot: 'Root'
|
|
9
|
-
})(() => ({
|
|
6
|
+
const StyledBooleanInput = styled(RaBooleanInput, { slot: 'Root' })(() => ({
|
|
10
7
|
marginTop: '0 !important'
|
|
11
8
|
}));
|
|
12
9
|
|
|
@@ -2,10 +2,7 @@ import { DateInputProps, DateInput as RaDateInput } from 'react-admin';
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledInput from './LabeledInput';
|
|
4
4
|
|
|
5
|
-
const StyledDateInput = styled(RaDateInput, {
|
|
6
|
-
name: 'RaApplicaDateInput',
|
|
7
|
-
slot: 'root'
|
|
8
|
-
})(({ label }) => ({
|
|
5
|
+
const StyledDateInput = styled(RaDateInput, { slot: 'root' })(({ label }) => ({
|
|
9
6
|
'& legend': {
|
|
10
7
|
width: label === false ? 0 : 'auto'
|
|
11
8
|
}
|
|
@@ -2,10 +2,7 @@ import { DateTimeInputProps, DateTimeInput as RaDateTimeInput } from 'react-admi
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledInput from './LabeledInput';
|
|
4
4
|
|
|
5
|
-
const StyledDateInput = styled(RaDateTimeInput, {
|
|
6
|
-
name: 'RaApplicaDateTimeInput',
|
|
7
|
-
slot: 'root'
|
|
8
|
-
})(({ label }) => ({
|
|
5
|
+
const StyledDateInput = styled(RaDateTimeInput, { slot: 'root' })(({ label }) => ({
|
|
9
6
|
'& legend': {
|
|
10
7
|
width: label === false ? 0 : 'auto'
|
|
11
8
|
}
|
|
@@ -6,10 +6,7 @@ import { useWatch } from 'react-hook-form';
|
|
|
6
6
|
import LabeledInput from './LabeledInput';
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
const StyledFileInput = styled(RaFileInput, {
|
|
10
|
-
name: 'RaApplicaFileInput',
|
|
11
|
-
slot: 'root'
|
|
12
|
-
})(({ theme }) => ({
|
|
9
|
+
const StyledFileInput = styled(RaFileInput, { slot: 'root' })(({ theme }) => ({
|
|
13
10
|
'& .previews': {},
|
|
14
11
|
'& .previews>div': {
|
|
15
12
|
marginTop: theme.spacing(1),
|
|
@@ -2,10 +2,7 @@ import { NumberInputProps, NumberInput as RaNumberInput } from 'react-admin';
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledInput from './LabeledInput';
|
|
4
4
|
|
|
5
|
-
const StyledNumberInput = styled(RaNumberInput, {
|
|
6
|
-
name: 'RaApplicaNumberInput',
|
|
7
|
-
slot: 'root'
|
|
8
|
-
})(({ label }) => ({
|
|
5
|
+
const StyledNumberInput = styled(RaNumberInput, { slot: 'root' })(({ label }) => ({
|
|
9
6
|
'& legend': {
|
|
10
7
|
width: label === false ? 0 : 'auto'
|
|
11
8
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { SearchInput as RaSearchInput, SearchInputProps } from 'react-admin';
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
|
|
4
|
-
const StyledSearchInput = styled(RaSearchInput, {
|
|
5
|
-
name: 'RaApplicaSearchInput',
|
|
6
|
-
slot: 'root'
|
|
7
|
-
})(() => ({}));
|
|
4
|
+
const StyledSearchInput = styled(RaSearchInput, { slot: 'root' })(() => ({}));
|
|
8
5
|
|
|
9
6
|
export function SearchInput(props: SearchInputProps): JSX.Element {
|
|
10
7
|
return <StyledSearchInput {...props} />;
|
|
@@ -2,10 +2,7 @@ import { SelectArrayInput as RaSelectArrayInput, SelectArrayInputProps } from 'r
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledInput from './LabeledInput';
|
|
4
4
|
|
|
5
|
-
const StyledSelectArrayInput = styled(RaSelectArrayInput, {
|
|
6
|
-
name: 'RaApplicaSelectArrayInput',
|
|
7
|
-
slot: 'Root'
|
|
8
|
-
})(({ label }) => ({
|
|
5
|
+
const StyledSelectArrayInput = styled(RaSelectArrayInput, { slot: 'Root' })(({ label }) => ({
|
|
9
6
|
'& legend': {
|
|
10
7
|
width: label === false ? 0 : 'auto'
|
|
11
8
|
},
|
|
@@ -2,10 +2,7 @@ import { SelectInput as RaSelectInput, SelectInputProps as RaSelectInputProps }
|
|
|
2
2
|
import { styled } from '@mui/material/styles';
|
|
3
3
|
import LabeledInput, { LabeledInputProps } from './LabeledInput';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
name: 'RaApplicaSelectArrayInput',
|
|
7
|
-
slot: 'Root'
|
|
8
|
-
})(({ label }) => ({
|
|
5
|
+
const StyledSelectInput = styled(RaSelectInput, { slot: 'Root' })(({ label }) => ({
|
|
9
6
|
'& legend': {
|
|
10
7
|
width: label === false || label === null ? 0 : 'auto'
|
|
11
8
|
}
|
|
@@ -14,7 +11,7 @@ export type SelectInputProps = LabeledInputProps & RaSelectInputProps;
|
|
|
14
11
|
export function SelectInput(props: SelectInputProps): JSX.Element {
|
|
15
12
|
return (
|
|
16
13
|
<LabeledInput {...props}>
|
|
17
|
-
<
|
|
14
|
+
<StyledSelectInput />
|
|
18
15
|
</LabeledInput>
|
|
19
16
|
);
|
|
20
17
|
}
|
|
@@ -17,10 +17,7 @@ function defaultParser(v: string): string {
|
|
|
17
17
|
return v;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const StyledTimeInput = styled(RaTimeInput, {
|
|
21
|
-
name: 'RaApplicaTimeInput',
|
|
22
|
-
slot: 'root'
|
|
23
|
-
})(({ label }) => ({
|
|
20
|
+
const StyledTimeInput = styled(RaTimeInput, { slot: 'root' })(({ label }) => ({
|
|
24
21
|
'& legend': {
|
|
25
22
|
width: label === false ? 0 : 'auto'
|
|
26
23
|
}
|
|
@@ -17,41 +17,41 @@ import BulkActionsToolbar from '../BulkActionsToolbar';
|
|
|
17
17
|
import clsx from 'clsx';
|
|
18
18
|
import DatagridContextProvider from './DatagridContextProvider';
|
|
19
19
|
import difference from 'lodash/difference';
|
|
20
|
-
import PropTypes from 'prop-types';
|
|
21
20
|
import union from 'lodash/union';
|
|
22
21
|
|
|
23
22
|
const defaultBulkActionButtons = <BulkDeleteButton />;
|
|
24
23
|
|
|
25
|
-
export type DatagridProps = RaDatagridProps &
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
export type DatagridProps = RaDatagridProps &
|
|
25
|
+
React.RefAttributes<HTMLTableElement> & {
|
|
26
|
+
/**
|
|
27
|
+
* An alternative to bulkActionButtons, to be used when the actions are too complex to be expressed.
|
|
28
|
+
* In this case you are free to fully control the rendering of the bulk actions toolbar.
|
|
29
|
+
* @see BulkActionsToolbar
|
|
30
|
+
* @example <caption>Using the BulkActionsToolbar component</caption>
|
|
31
|
+
* import { BulkActionsToolbar } from '@applica-software-guru/react-admin';
|
|
32
|
+
* import { BulkDeleteButton } from 'react-admin';
|
|
33
|
+
*
|
|
34
|
+
* const PostBulkActionButtons = props => (
|
|
35
|
+
* <BulkActionsToolbar {...props}>
|
|
36
|
+
* <BulkDeleteButton />
|
|
37
|
+
* // add your custom actions here
|
|
38
|
+
* </BulkActionsToolbar>
|
|
39
|
+
* );
|
|
40
|
+
*
|
|
41
|
+
* @example <caption>Using BulkFloatingActionsToolbar component</caption>
|
|
42
|
+
* import { BulkActionsToolbar } from '@applica-software-guru/react-admin';
|
|
43
|
+
* import { BulkDeleteButton } from 'react-admin';
|
|
44
|
+
*
|
|
45
|
+
* const PostBulkActionButtons = props => (
|
|
46
|
+
* <BulkActionsToolbar {...props}>
|
|
47
|
+
* <BulkDeleteButton />
|
|
48
|
+
* // add your custom actions here
|
|
49
|
+
* </BulkActionsToolbar>
|
|
50
|
+
* );
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
bulkActionsToolbar: React.ReactNode | React.FC | boolean;
|
|
54
|
+
};
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* The Datagrid component renders a list of records as a table.
|
|
@@ -131,7 +131,7 @@ export type DatagridProps = RaDatagridProps & {
|
|
|
131
131
|
* );
|
|
132
132
|
* }
|
|
133
133
|
*/
|
|
134
|
-
export const Datagrid
|
|
134
|
+
export const Datagrid = React.forwardRef((props, ref) => {
|
|
135
135
|
const {
|
|
136
136
|
optimized = false,
|
|
137
137
|
body = optimized ? PureDatagridBody : DatagridBody,
|
|
@@ -156,11 +156,8 @@ export const Datagrid: FC<DatagridProps> = React.forwardRef((props, ref) => {
|
|
|
156
156
|
} = props;
|
|
157
157
|
|
|
158
158
|
const { sort, data, isLoading, onSelect, onToggleItem, selectedIds, setSort, total } = useListContext(props);
|
|
159
|
-
|
|
160
159
|
const hasBulkActions = !!bulkActionButtons !== false;
|
|
161
|
-
|
|
162
160
|
const contextValue = useMemo(() => ({ isRowExpandable, expandSingle }), [isRowExpandable, expandSingle]);
|
|
163
|
-
|
|
164
161
|
const lastSelected = useRef(null);
|
|
165
162
|
|
|
166
163
|
useEffect(() => {
|
|
@@ -278,47 +275,12 @@ export const Datagrid: FC<DatagridProps> = React.forwardRef((props, ref) => {
|
|
|
278
275
|
</DatagridRoot>
|
|
279
276
|
</DatagridContextProvider>
|
|
280
277
|
);
|
|
281
|
-
})
|
|
278
|
+
}) as FC<DatagridProps>;
|
|
282
279
|
|
|
283
280
|
// @ts-ignore
|
|
284
281
|
const createOrCloneElement = (element, props, children) =>
|
|
285
282
|
isValidElement(element) ? cloneElement(element, props, children) : createElement(element, props, children);
|
|
286
283
|
|
|
287
|
-
Datagrid.propTypes = {
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
body: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
290
|
-
// @ts-ignore-line
|
|
291
|
-
bulkActionButtons: PropTypes.oneOfType([PropTypes.bool, PropTypes.element]),
|
|
292
|
-
children: PropTypes.node.isRequired,
|
|
293
|
-
className: PropTypes.string,
|
|
294
|
-
// @ts-ignore
|
|
295
|
-
sort: PropTypes.exact({
|
|
296
|
-
field: PropTypes.string,
|
|
297
|
-
order: PropTypes.oneOf(['ASC', 'DESC'] as const)
|
|
298
|
-
}),
|
|
299
|
-
data: PropTypes.arrayOf(PropTypes.any),
|
|
300
|
-
empty: PropTypes.element,
|
|
301
|
-
// @ts-ignore
|
|
302
|
-
expand: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
303
|
-
// @ts-ignore
|
|
304
|
-
header: PropTypes.oneOfType([PropTypes.element, PropTypes.elementType]),
|
|
305
|
-
hover: PropTypes.bool,
|
|
306
|
-
isLoading: PropTypes.bool,
|
|
307
|
-
onSelect: PropTypes.func,
|
|
308
|
-
onToggleItem: PropTypes.func,
|
|
309
|
-
resource: PropTypes.string,
|
|
310
|
-
// @ts-ignore
|
|
311
|
-
rowClick: PropTypes.oneOfType([PropTypes.string, PropTypes.func, PropTypes.bool]),
|
|
312
|
-
rowSx: PropTypes.func,
|
|
313
|
-
rowStyle: PropTypes.func,
|
|
314
|
-
selectedIds: PropTypes.arrayOf(PropTypes.any),
|
|
315
|
-
setSort: PropTypes.func,
|
|
316
|
-
total: PropTypes.number,
|
|
317
|
-
isRowSelectable: PropTypes.func,
|
|
318
|
-
isRowExpandable: PropTypes.func,
|
|
319
|
-
expandSingle: PropTypes.bool
|
|
320
|
-
};
|
|
321
|
-
|
|
322
284
|
const injectedProps = [
|
|
323
285
|
'isRequired',
|
|
324
286
|
'setFilter',
|
|
@@ -2,10 +2,7 @@ import { Datagrid as RaDatagrid } from './Datagrid';
|
|
|
2
2
|
import { DatagridProps } from 'react-admin';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
4
|
|
|
5
|
-
const StyledDatagrid = styled(RaDatagrid, {
|
|
6
|
-
name: 'ApplicaDatagrid',
|
|
7
|
-
slot: 'root'
|
|
8
|
-
})(({ theme }) => ({
|
|
5
|
+
const StyledDatagrid = styled(RaDatagrid, { slot: 'root' })(({ theme }) => ({
|
|
9
6
|
'& .RaBulkActionsToolbar-toolbar': {
|
|
10
7
|
height: 48
|
|
11
8
|
},
|
|
@@ -88,10 +88,7 @@ const RaList = <RecordType extends RaRecord = any>({
|
|
|
88
88
|
|
|
89
89
|
const defaultFilter = {};
|
|
90
90
|
|
|
91
|
-
const StyledList = styled(RaList, {
|
|
92
|
-
name: 'RaApplicaList',
|
|
93
|
-
slot: 'root'
|
|
94
|
-
})(({ theme }) => ({
|
|
91
|
+
const StyledList = styled(RaList, { slot: 'root' })(({ theme }) => ({
|
|
95
92
|
'& .RaList-main': {
|
|
96
93
|
overflowX: 'auto',
|
|
97
94
|
'& .RaBulkActionsToolbar-toolbar': {
|
package/src/hooks/index.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { useSx } from './mui';
|
|
|
12
12
|
export { default as useTableFormIterator } from './useTableFormIterator';
|
|
13
13
|
export { default as useTableFormIteratorItem } from './useTableFormIteratorItem';
|
|
14
14
|
export { default as useThemeConfig } from './useThemeConfig';
|
|
15
|
+
export { default as useApplicaAuthProvider } from './useApplicaAuthProvider';
|
|
@@ -2,11 +2,9 @@ import _ from 'lodash';
|
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @param object
|
|
9
|
-
* @returns
|
|
5
|
+
* This hook automatically memoizes an object using its value's equality check as a discrimination criterion.
|
|
6
|
+
* PLEASE NOTE!!! The equality check of a JS object is an extremely complex issue.
|
|
7
|
+
* Therefore, this hook should be used with extreme caution, only when strictly necessary and only if you fully master the topic above and its implications in the conditional rendering logic of React
|
|
10
8
|
*/
|
|
11
9
|
function useMemoizedObject<T extends object>(object: T): T {
|
|
12
10
|
if (!_.isPlainObject(object)) {
|
|
@@ -2,7 +2,13 @@ import { useRecordContext, useResourceContext, useTranslate } from 'react-admin'
|
|
|
2
2
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Generate the title of a resource page from its name and the current record.
|
|
7
|
+
*
|
|
8
|
+
* @param title Can be the resource name, a fully qualified translation key, or a boolean to disable the title
|
|
9
|
+
* @returns The title of the resource, based on the current record and the resource name
|
|
10
|
+
*/
|
|
11
|
+
export function useResourceTitle(title: string | boolean | undefined): string | boolean | undefined {
|
|
6
12
|
const record = useRecordContext();
|
|
7
13
|
const translate = useTranslate();
|
|
8
14
|
const resource = useResourceContext();
|
|
@@ -23,6 +29,6 @@ const useResourceTitle = (title) => {
|
|
|
23
29
|
}, [mode, record, resource, translate, title]);
|
|
24
30
|
|
|
25
31
|
return cardTitle;
|
|
26
|
-
}
|
|
32
|
+
}
|
|
27
33
|
|
|
28
34
|
export default useResourceTitle;
|
package/src/index.jsx
CHANGED
package/src/playground/types.ts
CHANGED
|
@@ -46,17 +46,15 @@ export type ApplicaDataProviderConfig = {
|
|
|
46
46
|
|
|
47
47
|
export type ApplicaDataProviderInterface = DataProvider & {
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
49
|
+
* Allows you to get the REST service URL.
|
|
50
50
|
*/
|
|
51
51
|
getApiUrl(): string;
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
53
|
+
* Allows you to retrieve a single file from the server using any mechanisms
|
|
54
|
+
* authentication associated with the dataProvider (e.g. JWT passed through getHeaders).
|
|
55
55
|
*
|
|
56
|
-
* @param
|
|
57
|
-
* @
|
|
58
|
-
*
|
|
59
|
-
* @example Simulazione del download di un file.
|
|
56
|
+
* @param resource Resource to request
|
|
57
|
+
* @example Simple download of a file
|
|
60
58
|
* const attachment = await dataProvider.getFile(`/attachments/post/1/picture/1}`);
|
|
61
59
|
* const link = document.createElement('a');
|
|
62
60
|
* link.href = attachment;
|
|
@@ -66,29 +64,29 @@ export type ApplicaDataProviderInterface = DataProvider & {
|
|
|
66
64
|
*/
|
|
67
65
|
getFile(resource: string): Promise<string>;
|
|
68
66
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* Response code
|
|
67
|
+
* Allows you to make a generic GET call to the REST service.
|
|
68
|
+
* The service response must contain at least 'responseCode' as expected by the applica standard.
|
|
69
|
+
* Response code must be equal to 'ok' if the call was successful.
|
|
72
70
|
*
|
|
73
71
|
* @example
|
|
74
|
-
* //
|
|
72
|
+
* // Example: users?name=Roberto
|
|
75
73
|
* const data = await dataProvider.get("users", { name: "Roberto" })
|
|
76
74
|
*
|
|
77
75
|
*
|
|
78
|
-
* @param resource
|
|
79
|
-
* @param params
|
|
76
|
+
* @param resource Resource to request
|
|
77
|
+
* @param params Query string parameters to insert
|
|
80
78
|
*/
|
|
81
79
|
get(resource: string, params: any): Promise<any>;
|
|
82
80
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* Response code
|
|
81
|
+
* Allows you to make a generic POST call to the REST service.
|
|
82
|
+
* The service response must contain at least 'responseCode' as expected by the applica standard.
|
|
83
|
+
* Response code must be equal to 'ok' if the call was successful.
|
|
86
84
|
*
|
|
87
85
|
* @example
|
|
88
86
|
* const data = await dataProvider.post("users", { name: "Roberto" })
|
|
89
87
|
*
|
|
90
|
-
* @param resource
|
|
91
|
-
* @param params
|
|
88
|
+
* @param resource Resource to request
|
|
89
|
+
* @param params Query string parameters to insert
|
|
92
90
|
*/
|
|
93
91
|
post(resource: string, params: any): Promise<any>;
|
|
94
92
|
};
|