@applica-software-guru/react-admin 1.0.37 → 1.0.38
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-forms/Edit.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +48 -48
- package/dist/react-admin.es.js +6676 -6475
- package/dist/react-admin.umd.js +48 -48
- package/package.json +3 -2
- package/src/components/ra-forms/Edit.jsx +12 -6
- package/src/components/ra-forms/LongForm/LongForm.tsx +4 -1
- package/src/components/ra-forms/LongForm/LongFormTabs.tsx +0 -1
- package/src/components/ra-forms/LongForm/LongFormView.tsx +30 -7
- package/src/components/ra-forms/{SimpleForm.jsx → SimpleForm.tsx} +38 -27
- package/src/index.jsx +3 -0
- package/dist/components/ra-forms/SimpleForm.d.ts +0 -26
- package/dist/components/ra-forms/SimpleForm.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applica-software-guru/react-admin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"private": false,
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"react-hook-form": "^7.43.9",
|
|
71
71
|
"react-router": "^6.1.0",
|
|
72
72
|
"react-router-dom": "^6.1.0",
|
|
73
|
+
"react-sticky-box": "^2.0.4",
|
|
73
74
|
"simplebar": "^6.2.5",
|
|
74
75
|
"simplebar-react": "^3.2.4"
|
|
75
76
|
},
|
|
@@ -96,9 +97,9 @@
|
|
|
96
97
|
"npm-run-all": "^4.1.5",
|
|
97
98
|
"prettier": "^2.7.1",
|
|
98
99
|
"typescript": "^4.6.4",
|
|
100
|
+
"vite": "^4.4.2",
|
|
99
101
|
"vite-plugin-dts": "^2.3.0",
|
|
100
102
|
"vite-plugin-linter": "^2.0.2",
|
|
101
|
-
"vite": "^4.4.2",
|
|
102
103
|
"vitest": "^0.33.0"
|
|
103
104
|
},
|
|
104
105
|
"peerDependencies": {
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { Edit as RaEdit } from 'react-admin'
|
|
2
|
-
import { styled } from '@mui/material/styles'
|
|
1
|
+
import { Edit as RaEdit } from 'react-admin';
|
|
2
|
+
import { styled } from '@mui/material/styles';
|
|
3
3
|
|
|
4
4
|
const StyledEdit = styled(RaEdit, {
|
|
5
5
|
name: 'RaApplicaEdit',
|
|
6
|
-
slot: 'root'
|
|
6
|
+
slot: 'root'
|
|
7
7
|
})(({ theme }) => ({
|
|
8
8
|
'& .RaEdi-card, & > div > div > form': {
|
|
9
|
-
backgroundColor: theme.palette.background.default
|
|
9
|
+
backgroundColor: theme.palette.background.default
|
|
10
10
|
},
|
|
11
|
-
|
|
11
|
+
'& .RaEdit-main>.MuiPaper-root:first-child': {
|
|
12
|
+
// Ci ho messo 4 ore per scrivere questa riga di codice e risolvere un problema con react-sticky-box ed i Long Form.
|
|
13
|
+
// L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
|
|
14
|
+
// di tutti gli elementi presenti all'interno della pagina.
|
|
15
|
+
overflow: 'visible'
|
|
16
|
+
}
|
|
17
|
+
}));
|
|
12
18
|
|
|
13
|
-
export default StyledEdit
|
|
19
|
+
export default StyledEdit;
|
|
@@ -14,6 +14,7 @@ export type LongFormProps = {
|
|
|
14
14
|
tabsDisposition?: Disposition;
|
|
15
15
|
contentDisposition?: Disposition;
|
|
16
16
|
children: React.ReactNode;
|
|
17
|
+
sticky?: boolean;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -40,11 +41,13 @@ LongForm.propTypes = {
|
|
|
40
41
|
syncWithLocation: PropTypes.bool,
|
|
41
42
|
spacing: PropTypes.number,
|
|
42
43
|
tabsDisposition: DispositionProps,
|
|
43
|
-
contentDisposition: DispositionProps
|
|
44
|
+
contentDisposition: DispositionProps,
|
|
45
|
+
sticky: PropTypes.bool
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
LongForm.defaultProps = {
|
|
47
49
|
syncWithLocation: false,
|
|
50
|
+
sticky: true,
|
|
48
51
|
spacing: 2,
|
|
49
52
|
tabsDisposition: { xl: 3, lg: 3, md: 4, sm: 4, xs: 12 },
|
|
50
53
|
contentDisposition: { xl: 9, lg: 9, md: 8, sm: 8, xs: 12 }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Disposition, DispositionProps } from './types';
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { Fragment, useMemo, useState } from 'react';
|
|
3
3
|
import { Route, Routes, matchPath, useLocation, useResolvedPath } from 'react-router';
|
|
4
4
|
import { getTabbedFormTabFullPath, useResourceContext } from 'react-admin';
|
|
5
5
|
|
|
@@ -8,18 +8,24 @@ import LongFormHeader from './LongFormSidebar';
|
|
|
8
8
|
import LongFormTab from './LongFormTab';
|
|
9
9
|
import LongFormTabs from './LongFormTabs';
|
|
10
10
|
import PropTypes from 'prop-types';
|
|
11
|
+
import StickyBox from 'react-sticky-box';
|
|
11
12
|
import { styled } from '@mui/material/styles';
|
|
12
13
|
|
|
13
14
|
const StyledGrid = styled(Grid, {
|
|
14
|
-
name: '
|
|
15
|
+
name: 'ApplicaLongFormView',
|
|
15
16
|
slot: 'Root'
|
|
16
17
|
})(({ theme }) => ({
|
|
17
18
|
'& .MuiToolbar-root': {
|
|
18
19
|
marginTop: theme.spacing(2),
|
|
19
|
-
marginLeft: `-${theme.spacing(
|
|
20
|
-
marginRight: `-${theme.spacing(
|
|
20
|
+
marginLeft: `-${theme.spacing(2)}`,
|
|
21
|
+
marginRight: `-${theme.spacing(2.5)}`,
|
|
21
22
|
marginBottom: `-${theme.spacing(2)}`,
|
|
22
23
|
borderTop: `1px solid ${theme.palette.divider}`
|
|
24
|
+
},
|
|
25
|
+
'& form > .MuiToolbar-root': {
|
|
26
|
+
// È molto importante: questa regola serve per poter inserire form, all'interno di altri form, evitando
|
|
27
|
+
// che la toolbar del form interno recepisca gli stili della regola precedente (che genera un padding strano).
|
|
28
|
+
margin: 0
|
|
23
29
|
}
|
|
24
30
|
}));
|
|
25
31
|
|
|
@@ -34,6 +40,7 @@ export type LongFormViewProps = {
|
|
|
34
40
|
tabs: React.ReactElement;
|
|
35
41
|
tabsDisposition: Disposition;
|
|
36
42
|
contentDisposition: Disposition;
|
|
43
|
+
sticky?: boolean;
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
const LongFormView = ({
|
|
@@ -44,6 +51,7 @@ const LongFormView = ({
|
|
|
44
51
|
tabs,
|
|
45
52
|
tabsDisposition,
|
|
46
53
|
contentDisposition,
|
|
54
|
+
sticky,
|
|
47
55
|
...props
|
|
48
56
|
}: LongFormViewProps) => {
|
|
49
57
|
const [tabValue, setTabValue] = useState(0);
|
|
@@ -71,9 +79,9 @@ const LongFormView = ({
|
|
|
71
79
|
},
|
|
72
80
|
tabChildrens
|
|
73
81
|
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<
|
|
82
|
+
const sidebarContent = useMemo(
|
|
83
|
+
() => (
|
|
84
|
+
<Fragment>
|
|
77
85
|
{topSidebars}
|
|
78
86
|
{syncWithLocation ? (
|
|
79
87
|
<Routes>
|
|
@@ -83,7 +91,22 @@ const LongFormView = ({
|
|
|
83
91
|
renderTabs()
|
|
84
92
|
)}
|
|
85
93
|
{bottomSidebars}
|
|
94
|
+
</Fragment>
|
|
95
|
+
),
|
|
96
|
+
[topSidebars, syncWithLocation, renderTabs, bottomSidebars]
|
|
97
|
+
);
|
|
98
|
+
return (
|
|
99
|
+
<StyledGrid container spacing={spacing * 2}>
|
|
100
|
+
<Grid item {...tabsDisposition}>
|
|
101
|
+
{sticky ? (
|
|
102
|
+
<StickyBox offsetTop={74} offsetBottom={spacing * 2}>
|
|
103
|
+
{sidebarContent}
|
|
104
|
+
</StickyBox>
|
|
105
|
+
) : (
|
|
106
|
+
sidebarContent
|
|
107
|
+
)}
|
|
86
108
|
</Grid>
|
|
109
|
+
|
|
87
110
|
<Grid item {...contentDisposition}>
|
|
88
111
|
{/* All tabs are rendered (not only the one in focus), to allow validation
|
|
89
112
|
on tabs not in focus. The tabs receive a `hidden` property, which they'll
|
|
@@ -1,69 +1,80 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DeleteWithConfirmButton,
|
|
3
3
|
SimpleForm as RaSimpleForm,
|
|
4
|
+
SimpleFormProps as RaSimpleFormProps,
|
|
4
5
|
SaveButton,
|
|
5
|
-
useRecordContext
|
|
6
|
-
} from 'react-admin'
|
|
6
|
+
useRecordContext
|
|
7
|
+
} from 'react-admin';
|
|
7
8
|
|
|
8
|
-
import ActionsMenu from '../ActionsMenu'
|
|
9
|
-
import MainCard from '../MainCard'
|
|
10
|
-
import PropTypes from 'prop-types'
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import { useResourceTitle } from '../../hooks'
|
|
9
|
+
import ActionsMenu from '../ActionsMenu';
|
|
10
|
+
import MainCard from '../MainCard';
|
|
11
|
+
import PropTypes from 'prop-types';
|
|
12
|
+
import Toolbar from './Toolbar';
|
|
13
|
+
import { styled } from '@mui/system';
|
|
14
|
+
import { useResourceTitle } from '../../hooks';
|
|
15
15
|
|
|
16
16
|
const ApplicaStyledSimpleForm = styled(RaSimpleForm, {
|
|
17
17
|
name: 'RaApplicaSimpleForm',
|
|
18
|
-
slot: 'Root'
|
|
19
|
-
})(({ theme, modal }) => ({
|
|
18
|
+
slot: 'Root'
|
|
19
|
+
})(({ theme, modal }: { theme: any; modal: boolean }) => ({
|
|
20
20
|
'& .MuiGrid-root.MuiGrid-container': {
|
|
21
|
-
paddingBottom: theme.spacing(modal ? 2 : 1)
|
|
22
|
-
}
|
|
23
|
-
}))
|
|
21
|
+
paddingBottom: theme.spacing(modal ? 2 : 1)
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
export type SimpleFormProps = RaSimpleFormProps & {
|
|
26
|
+
modal?: boolean;
|
|
27
|
+
content?: boolean;
|
|
28
|
+
subheader?: string | React.ReactNode;
|
|
29
|
+
title?: string | React.ReactNode;
|
|
30
|
+
secondary?: string | React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const SimpleForm = ({ title, modal, content, subheader, secondary, sx, ...props }: SimpleFormProps) => {
|
|
34
|
+
const cardTitle = useResourceTitle(title);
|
|
35
|
+
const record = useRecordContext();
|
|
28
36
|
return (
|
|
37
|
+
// @ts-ignore
|
|
29
38
|
<MainCard
|
|
30
39
|
content={content}
|
|
31
40
|
title={cardTitle}
|
|
32
41
|
subheader={subheader}
|
|
33
42
|
secondary={record?.id ? secondary : null}
|
|
43
|
+
sx={sx}
|
|
34
44
|
border={!modal}
|
|
35
45
|
divider
|
|
36
46
|
>
|
|
47
|
+
{/* @ts-ignore */}
|
|
37
48
|
<ApplicaStyledSimpleForm toolbar={<Toolbar />} {...props} />
|
|
38
49
|
</MainCard>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
50
|
+
);
|
|
51
|
+
};
|
|
41
52
|
|
|
42
53
|
SimpleForm.defaultProps = {
|
|
43
|
-
...RaSimpleForm.defaultProps,
|
|
44
54
|
modal: false,
|
|
45
55
|
content: false,
|
|
46
56
|
subheader: null,
|
|
47
57
|
title: null,
|
|
48
58
|
toolbar: (
|
|
49
59
|
<Toolbar>
|
|
50
|
-
<SaveButton />
|
|
60
|
+
<SaveButton type="button" />
|
|
51
61
|
</Toolbar>
|
|
52
62
|
),
|
|
53
63
|
secondary: (
|
|
54
64
|
<ActionsMenu>
|
|
55
65
|
<DeleteWithConfirmButton />
|
|
56
66
|
</ActionsMenu>
|
|
57
|
-
)
|
|
58
|
-
}
|
|
67
|
+
)
|
|
68
|
+
};
|
|
59
69
|
|
|
60
70
|
SimpleForm.propTypes = {
|
|
61
71
|
...RaSimpleForm.propTypes,
|
|
62
|
-
|
|
72
|
+
modal: PropTypes.bool,
|
|
63
73
|
content: PropTypes.bool,
|
|
74
|
+
contained: PropTypes.bool,
|
|
64
75
|
subheader: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
65
76
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
66
|
-
secondary: PropTypes.oneOfType([PropTypes.node, PropTypes.string, PropTypes.object])
|
|
67
|
-
}
|
|
77
|
+
secondary: PropTypes.oneOfType([PropTypes.node, PropTypes.string, PropTypes.object])
|
|
78
|
+
};
|
|
68
79
|
|
|
69
|
-
export default SimpleForm
|
|
80
|
+
export default SimpleForm;
|
package/src/index.jsx
CHANGED
|
@@ -22,6 +22,7 @@ export {
|
|
|
22
22
|
DeleteWithConfirmButton,
|
|
23
23
|
DeleteWithUndoButton,
|
|
24
24
|
EditButton,
|
|
25
|
+
EditContextProvider,
|
|
25
26
|
FieldTitle,
|
|
26
27
|
email,
|
|
27
28
|
Form,
|
|
@@ -48,7 +49,9 @@ export {
|
|
|
48
49
|
UrlField,
|
|
49
50
|
useArrayInput,
|
|
50
51
|
useAuthProvider,
|
|
52
|
+
useCreateController,
|
|
51
53
|
useDataProvider,
|
|
54
|
+
useEditContext,
|
|
52
55
|
useGetIdentity,
|
|
53
56
|
useGetList,
|
|
54
57
|
useGetMany,
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export default SimpleForm;
|
|
2
|
-
declare function SimpleForm({ title, modal, content, subheader, secondary, ...props }: {
|
|
3
|
-
[x: string]: any;
|
|
4
|
-
title: any;
|
|
5
|
-
modal: any;
|
|
6
|
-
content: any;
|
|
7
|
-
subheader: any;
|
|
8
|
-
secondary: any;
|
|
9
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
declare namespace SimpleForm {
|
|
11
|
-
const defaultProps: any;
|
|
12
|
-
const propTypes: {
|
|
13
|
-
contained: PropTypes.Requireable<boolean>;
|
|
14
|
-
content: PropTypes.Requireable<boolean>;
|
|
15
|
-
subheader: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
16
|
-
title: PropTypes.Requireable<NonNullable<PropTypes.ReactNodeLike>>;
|
|
17
|
-
secondary: PropTypes.Requireable<NonNullable<object | PropTypes.ReactNodeLike>>;
|
|
18
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
19
|
-
defaultValues: PropTypes.Requireable<object>;
|
|
20
|
-
record: PropTypes.Requireable<object>;
|
|
21
|
-
toolbar: PropTypes.Requireable<NonNullable<boolean | PropTypes.ReactElementLike>>;
|
|
22
|
-
validate: PropTypes.Requireable<(...args: any[]) => any>;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
import PropTypes from 'prop-types';
|
|
26
|
-
//# sourceMappingURL=SimpleForm.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SimpleForm.d.ts","sourceRoot":"","sources":["../../../../src/components/ra-forms/SimpleForm.jsx"],"names":[],"mappings":";AAwBA;;;;;;;4CAeC;;;;;;;;;;;;;;;;sBA9BqB,YAAY"}
|