@applica-software-guru/react-admin 1.3.146 → 1.3.147

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.3.146",
3
+ "version": "1.3.147",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -61,7 +61,7 @@
61
61
  "ra-core": "^4.14.5",
62
62
  "ra-i18n-polyglot": "^4.14.1",
63
63
  "ra-ui-materialui": "4.14.5",
64
- "react-admin": "^4.14.4",
64
+ "react-admin": "4.14.5",
65
65
  "react-device-detect": "^2.2.3",
66
66
  "react-hook-form": "^7.43.9",
67
67
  "react-router": "^6.1.0",
@@ -101,12 +101,12 @@
101
101
  "vitest": "^0.33.0"
102
102
  },
103
103
  "peerDependencies": {
104
- "react": "^18.2.0",
105
- "react-dom": "^18.2.0",
106
- "react-admin": "4.14.5",
107
104
  "@mui/base": "5.0.0-beta.19",
108
105
  "@mui/icons-material": "^5.0.1",
109
106
  "@mui/lab": "5.0.0-alpha.148",
110
- "@mui/material": "5.14.13"
107
+ "@mui/material": "5.14.13",
108
+ "react": "^18.2.0",
109
+ "react-admin": "4.14.5",
110
+ "react-dom": "^18.2.0"
111
111
  }
112
112
  }
@@ -12,7 +12,7 @@ type ICreateProps<
12
12
  > = CreateProps<RecordType, Error, ResultRecordType> & {
13
13
  children: React.ReactNode;
14
14
  useDefaults?: boolean;
15
- queryOptions?: UseQueryOptions
15
+ queryOptions?: UseQueryOptions;
16
16
  };
17
17
 
18
18
  type IResourceDefaultValue = object;
@@ -46,7 +46,13 @@ function Create(props: ICreateProps) {
46
46
  }
47
47
  });
48
48
  }, [resource, useDefaults, search, dataProvider]),
49
- _queryOptions = useMemo<UseQueryOptions>(() => _.chain(queryOptions).extend({ queryKey: [resource, search], queryFn: fetch }).value(), [resource, search, fetch, queryOptions]),
49
+ _queryOptions = useMemo<UseQueryOptions>(
50
+ () =>
51
+ _.chain(queryOptions)
52
+ .extend({ queryKey: [resource, search], queryFn: fetch })
53
+ .value(),
54
+ [resource, search, fetch, queryOptions]
55
+ ),
50
56
  { data, isLoading } = useQuery(_queryOptions),
51
57
  passProps = _.omit(props, ['useDefaults']);
52
58
 
@@ -73,7 +79,8 @@ const StyledCreate = styled(Create, {
73
79
  backgroundColor: theme.palette.background.default
74
80
  },
75
81
  '& .RaCreate-main>.MuiPaper-root:first-of-type': {
76
- overflow: 'visible'
82
+ overflow: 'visible',
83
+ backgroundColor: theme.palette.background.default
77
84
  }
78
85
  }));
79
86
 
@@ -24,7 +24,8 @@ const StyledEdit = styled(RaEdit, {
24
24
  // Ci ho messo 4 ore per scrivere questa riga di codice e risolvere un problema con react-sticky-box ed i Long Form.
25
25
  // L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
26
26
  // di tutti gli elementi presenti all'interno della pagina.
27
- overflow: 'visible'
27
+ overflow: 'visible',
28
+ backgroundColor: theme.palette.background.default
28
29
  }
29
30
  }));
30
31
 
@@ -0,0 +1,70 @@
1
+ import { TabbedForm as RaTabbedForm, TabbedFormProps as RaTabbedFormProps, DeleteWithConfirmButton, SaveButton } from 'react-admin';
2
+ import MainCard from '../MainCard';
3
+ import { useResourceTitle } from '../../hooks';
4
+ import Toolbar from './Toolbar';
5
+ import { styled } from '@mui/system';
6
+ import ActionsMenu from '../ActionsMenu';
7
+
8
+ export type TabbedFormProps = RaTabbedFormProps & {
9
+ modal?: boolean;
10
+ content?: boolean;
11
+ subheader?: string | React.ReactNode;
12
+ title?: string | React.ReactNode | boolean;
13
+ secondary?: string | React.ReactNode;
14
+ };
15
+
16
+ const StyledTabbedForm = styled(RaTabbedForm, {
17
+ name: 'RaApplicaTabbedForm',
18
+ slot: 'Root'
19
+ })(({ theme, modal }: { theme: any; modal: boolean }) => ({
20
+ '& .MuiGrid-root.MuiGrid-container': {
21
+ paddingBottom: theme.spacing(modal ? 0 : 1)
22
+ } as any,
23
+ [theme.breakpoints.down('sm')]: {
24
+ paddingBottom: 0
25
+ }
26
+ }));
27
+
28
+ const ApplicaTabbedForm = (props: TabbedFormProps) => {
29
+ const { title, modal, content, subheader, secondary, sx, ...rest } = props;
30
+ const cardTitle = useResourceTitle(title);
31
+
32
+ return (
33
+ <MainCard
34
+ title={cardTitle}
35
+ modal={modal}
36
+ content={content}
37
+ subheader={subheader}
38
+ secondary={secondary}
39
+ sx={{
40
+ ...sx,
41
+ '& .MuiToolbar-root': {
42
+ paddingLeft: '20px !important',
43
+ paddingRight: '20px !important'
44
+ }
45
+ }}
46
+ border={!modal}
47
+ divider
48
+ >
49
+ {/** @ts-ignore */}
50
+ <StyledTabbedForm toolbar={<Toolbar />} {...rest} />
51
+ </MainCard>
52
+ );
53
+ };
54
+
55
+ ApplicaTabbedForm.defaultProps = {
56
+ toolbar: (
57
+ <Toolbar>
58
+ <SaveButton type="button" />
59
+ </Toolbar>
60
+ ),
61
+ secondary: (
62
+ <ActionsMenu>
63
+ <DeleteWithConfirmButton />
64
+ </ActionsMenu>
65
+ )
66
+ };
67
+
68
+ ApplicaTabbedForm.Tab = RaTabbedForm.Tab;
69
+
70
+ export default ApplicaTabbedForm;
@@ -1,7 +1,7 @@
1
1
  import { Toolbar as RaToolbar } from 'react-admin';
2
2
  import { styled } from '@mui/system';
3
3
 
4
- const ApplicaStyledToolbar = styled(RaToolbar, {
4
+ const StyledToolbar = styled(RaToolbar, {
5
5
  name: 'RaApplicaToolbar',
6
6
  slot: 'Root'
7
7
  })(({ theme }) => ({
@@ -21,7 +21,7 @@ const ApplicaStyledToolbar = styled(RaToolbar, {
21
21
  }
22
22
  }));
23
23
 
24
- const Toolbar = (props) => <ApplicaStyledToolbar {...props} />;
24
+ const Toolbar = (props) => <StyledToolbar {...props} />;
25
25
 
26
26
  Toolbar.defaultProps = {
27
27
  ...RaToolbar.defaultProps
@@ -9,6 +9,9 @@ const useResourceTitle = (title) => {
9
9
  const mode = record?.id ? 'edit' : 'create';
10
10
 
11
11
  const cardTitle = useMemo(() => {
12
+ if (title === false) {
13
+ return undefined;
14
+ }
12
15
  const defaultTitle = `resources.${resource}.title`;
13
16
  return (
14
17
  title ||
@@ -1,19 +0,0 @@
1
- import { TabbedForm as RaTabbedForm } from 'react-admin';
2
- import { styled } from '@mui/system';
3
-
4
- const ApplicaStyledTabbedForm = styled(RaTabbedForm, {
5
- name: 'RaApplicaTabbedForm',
6
- slot: 'Root'
7
- })(() => ({}));
8
-
9
- ApplicaStyledTabbedForm.propTypes = {
10
- ...RaTabbedForm.propTypes
11
- };
12
-
13
- ApplicaStyledTabbedForm.defaultProps = {
14
- ...RaTabbedForm.defaultProps
15
- };
16
-
17
- ApplicaStyledTabbedForm.Tab = RaTabbedForm.Tab;
18
-
19
- export default ApplicaStyledTabbedForm;