@applica-software-guru/react-admin 1.0.47 → 1.0.52

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.0.47",
3
+ "version": "1.0.52",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  import { Card, CardContent, CardHeader, Divider, Typography } from '@mui/material';
2
- import { lighten, useTheme } from '@mui/material/styles';
2
+ import { SxProps, lighten, useTheme } from '@mui/material/styles';
3
3
 
4
4
  import PropTypes from 'prop-types';
5
5
  import { forwardRef } from 'react';
@@ -9,6 +9,74 @@ const headerSX = {
9
9
  '& .MuiCardHeader-action': { m: '0px auto', alignSelf: 'center' }
10
10
  };
11
11
 
12
+ export type MainCardProps = {
13
+ /**
14
+ * Indicates if the card must be rendered with a border.
15
+ */
16
+ border?: boolean;
17
+ /**
18
+ * Indicates if the card must be rendered with a box shadow.
19
+ */
20
+ boxShadow?: boolean;
21
+ /**
22
+ * The content of the card.
23
+ */
24
+ children?: React.ReactNode | React.ReactNode[];
25
+ /**
26
+ * The subheader of the card.
27
+ */
28
+ subheader?: React.ReactNode | string;
29
+ /**
30
+ * Indicates if the card must be rendered with a content.
31
+ */
32
+ content?: boolean;
33
+ /**
34
+ * The class name of the content.
35
+ */
36
+ contentClass?: string;
37
+ /**
38
+ * The style of the content.
39
+ */
40
+ contentSX?: SxProps | any;
41
+ /**
42
+ * Indicates if the title of the card must be rendered with a dark color.
43
+ */
44
+ darkTitle?: boolean;
45
+ /**
46
+ * Indicates if the card must be rendered with a divider.
47
+ */
48
+ divider?: boolean;
49
+ /**
50
+ * The elevation of the card.
51
+ */
52
+ elevation?: number;
53
+ /**
54
+ * The secondary content of the card.
55
+ */
56
+ secondary?: React.ReactNode | string | object;
57
+ /**
58
+ * The shadow of the card.
59
+ * @example '0px 0px 0px 0px rgba(0,0,0,0.2)'
60
+ */
61
+ shadow?: string;
62
+ /**
63
+ * The style of the card.
64
+ */
65
+ sx?: SxProps | any;
66
+ /**
67
+ * The title of the card.
68
+ */
69
+ title?: React.ReactNode | string | object;
70
+ /**
71
+ * Indicates if the card must be rendered as a modal.
72
+ */
73
+ modal?: boolean;
74
+ /**
75
+ * The color of the card.
76
+ */
77
+ color?: 'default' | 'primary' | 'secondary';
78
+ };
79
+
12
80
  const MainCard = forwardRef(
13
81
  (
14
82
  {
@@ -28,14 +96,15 @@ const MainCard = forwardRef(
28
96
  modal = false,
29
97
  color = 'default',
30
98
  ...others
31
- },
99
+ }: MainCardProps,
32
100
  ref
33
101
  ) => {
34
- const theme = useTheme();
102
+ const theme = useTheme() as any;
35
103
  boxShadow = theme.palette.mode === 'dark' ? boxShadow || true : boxShadow;
36
104
  return (
37
105
  <Card
38
106
  elevation={elevation || 0}
107
+ // @ts-ignore
39
108
  ref={ref}
40
109
  {...others}
41
110
  sx={{
@@ -69,6 +138,7 @@ const MainCard = forwardRef(
69
138
  }}
70
139
  >
71
140
  {!darkTitle && title && (
141
+ /** @ts-ignore */
72
142
  <CardHeader
73
143
  sx={headerSX}
74
144
  titleTypographyProps={{ variant: 'subtitle1' }}
@@ -77,6 +147,7 @@ const MainCard = forwardRef(
77
147
  subheader={subheader}
78
148
  />
79
149
  )}
150
+ {/** @ts-ignore */}
80
151
  {darkTitle && title && <CardHeader sx={headerSX} title={<Typography variant="h4">{title}</Typography>} action={secondary} />}
81
152
  {title && divider && <Divider />}
82
153
  {content && <CardContent sx={contentSX}>{children}</CardContent>}
@@ -1,8 +1,9 @@
1
- import { Datagrid as RaDatagrid } from 'react-admin';
1
+ import { DatagridProps, Datagrid as RaDatagrid } from 'react-admin';
2
+
2
3
  import { styled } from '@mui/material/styles';
3
4
 
4
5
  const ApplicaStyledDatagrid = styled(RaDatagrid, {
5
- name: 'RaApplicaDatagrid',
6
+ name: 'ApplicaDatagrid',
6
7
  slot: 'root'
7
8
  })(() => ({
8
9
  // Resolve an issue related to the visualization of the bulk actions toolbar.
@@ -29,7 +30,17 @@ const ApplicaStyledDatagrid = styled(RaDatagrid, {
29
30
  }
30
31
  }));
31
32
 
32
- const Datagrid = (props) => <ApplicaStyledDatagrid {...props} />;
33
+ /**
34
+ * This component is a wrapper of the React-Admin Datagrid component.
35
+ * It is used to customize the Datagrid component.
36
+ * It is used by the List component.
37
+ * It is not meant to be used directly.
38
+ * Thsi version is designed by Applica for Mantis and expose few overrides on css styles based on this theme.
39
+ *
40
+ * @param {DatagridProps} props
41
+ * @returns {JSX.Element}
42
+ */
43
+ const Datagrid = (props: DatagridProps): JSX.Element => <ApplicaStyledDatagrid {...props} />;
33
44
 
34
45
  Datagrid.propTypes = {
35
46
  ...RaDatagrid.propTypes
@@ -8,11 +8,40 @@ import PropTypes from 'prop-types';
8
8
  import { Typography } from '@mui/material';
9
9
  import { styled } from '@mui/material/styles';
10
10
 
11
+ export type EmptyProps = {
12
+ /**
13
+ * The actions of the empty page.
14
+ *
15
+ * @example <Button label="Refresh" onClick={refresh} />
16
+ * @example <Button label="Add" onClick={add} />
17
+ * @example <Button label="Export" onClick={export} />
18
+ * @example <Button label="Import" onClick={import} />
19
+ **/
20
+ actions?: React.ReactNode;
21
+ /**
22
+ * The class name of the empty page.
23
+ *
24
+ * @example 'my-custom-empty'
25
+ * @example 'my-custom-empty my-custom-empty--full-width'
26
+ **/
27
+ className?: string;
28
+ };
29
+
11
30
  const StyledToolbar = styled('div')(({ theme }) => ({
12
31
  padding: theme.spacing(2)
13
32
  }));
14
33
 
15
- const Empty = ({ actions, className, ...props }) => {
34
+ /**
35
+ * The Empty component is used to display a message when the list is empty.
36
+ * This component can be used only inside a List component.
37
+ *
38
+ * @example
39
+ * <List empty={<Empty actions={<Button label="Add" onClick={add} />} />} />
40
+ *
41
+ * @param {EmptyProps}
42
+ * @returns {JSX.Element}
43
+ */
44
+ const Empty = ({ actions, className, ...props }: EmptyProps): JSX.Element => {
16
45
  const { hasCreate } = useResourceDefinition(props);
17
46
  const resource = useResourceContext(props);
18
47
 
@@ -50,7 +79,7 @@ const Empty = ({ actions, className, ...props }) => {
50
79
  );
51
80
  };
52
81
 
53
- const PREFIX = 'RaApplicaEmpty';
82
+ const PREFIX = 'ApplicaEmpty';
54
83
 
55
84
  export const EmptyClasses = {
56
85
  message: `${PREFIX}-message`,
@@ -1,5 +1,6 @@
1
+ import { ListProps, List as RaList } from 'react-admin';
2
+
1
3
  import MainCard from '../MainCard';
2
- import { List as RaList } from 'react-admin';
3
4
  import { styled } from '@mui/system';
4
5
 
5
6
  const ApplicaStyledList = styled(RaList, {
@@ -63,7 +64,7 @@ const ApplicaStyledList = styled(RaList, {
63
64
  }
64
65
  }));
65
66
 
66
- const List = (props) => {
67
+ const List = (props: ListProps): JSX.Element => {
67
68
  return (
68
69
  <MainCard content={false}>
69
70
  <ApplicaStyledList {...RaList.defaultProps} {...props} />
package/src/index.jsx CHANGED
@@ -1,5 +1,6 @@
1
1
  export { default as Admin } from './Admin';
2
2
  export { default as ApplicaAdmin } from './ApplicaAdmin';
3
+ export { ThemeCustomization as ThemeProvider } from './themes';
3
4
 
4
5
  export * from './hooks';
5
6
  export * from './components';
File without changes