@applica-software-guru/react-admin 1.0.38 → 1.0.40

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.
Files changed (36) hide show
  1. package/dist/components/ra-inputs/BooleanInput.d.ts +2 -0
  2. package/dist/components/ra-inputs/BooleanInput.d.ts.map +1 -1
  3. package/dist/components/ra-inputs/DateInput.d.ts +1 -0
  4. package/dist/components/ra-inputs/LabeledInput.d.ts +5 -1
  5. package/dist/components/ra-inputs/LabeledInput.d.ts.map +1 -1
  6. package/dist/components/ra-inputs/NumberInput.d.ts +2 -0
  7. package/dist/components/ra-inputs/SelectArrayInput.d.ts +1 -0
  8. package/dist/components/ra-inputs/SelectInput.d.ts +1 -0
  9. package/dist/components/ra-inputs/SmartTextInput.d.ts +1 -0
  10. package/dist/components/ra-inputs/SmartTextInput.d.ts.map +1 -1
  11. package/dist/components/ra-inputs/TextInput.d.ts +1 -0
  12. package/dist/components/ra-inputs/TimeInput.d.ts +1 -0
  13. package/dist/components/ra-inputs/index.d.ts +2 -1
  14. package/dist/components/ra-inputs/index.d.ts.map +1 -1
  15. package/dist/components/ra-lists/Datagrid.d.ts.map +1 -1
  16. package/dist/index.d.ts +1 -1
  17. package/dist/react-admin.cjs.js +47 -47
  18. package/dist/react-admin.es.js +4627 -4521
  19. package/dist/react-admin.umd.js +50 -50
  20. package/package.json +1 -1
  21. package/playground/src/menu.js +0 -7
  22. package/playground/src/theme.js +3 -5
  23. package/src/components/ra-forms/Edit.jsx +1 -1
  24. package/src/components/ra-forms/SimpleFormIterator.tsx +30 -0
  25. package/src/components/ra-inputs/ArrayInput.tsx +39 -0
  26. package/src/components/ra-inputs/LabeledArrayInput.tsx +116 -0
  27. package/src/components/ra-inputs/LabeledInput.jsx +21 -10
  28. package/src/components/ra-inputs/index.jsx +24 -22
  29. package/src/components/ra-lists/Datagrid.jsx +7 -8
  30. package/src/index.jsx +2 -1
  31. package/dist/components/ra-forms/SimpleFormIterator.d.ts +0 -5
  32. package/dist/components/ra-forms/SimpleFormIterator.d.ts.map +0 -1
  33. package/dist/components/ra-inputs/ArrayInput.d.ts +0 -6
  34. package/dist/components/ra-inputs/ArrayInput.d.ts.map +0 -1
  35. package/src/components/ra-forms/SimpleFormIterator.jsx +0 -14
  36. package/src/components/ra-inputs/ArrayInput.jsx +0 -29
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/react-admin",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,13 +66,6 @@ const config = [
66
66
  type: 'item',
67
67
  url: '/entities/device',
68
68
  icon: TableOutlined
69
- },
70
- {
71
- id: 'entities/work-cycle',
72
- title: 'ra.menu.item.entities/work-cycle',
73
- type: 'item',
74
- url: '/entities/work-cycle',
75
- icon: TableOutlined
76
69
  }
77
70
  ]
78
71
  }
@@ -1,11 +1,9 @@
1
1
  const theme = (theme) => ({
2
2
  components: {
3
3
  MuiPaper: {
4
- styleOverrides: {
5
- backgroundColor: 'yellow'
6
- }
4
+ styleOverrides: {}
7
5
  }
8
6
  }
9
- })
7
+ });
10
8
 
11
- export default theme
9
+ export default theme;
@@ -8,7 +8,7 @@ const StyledEdit = styled(RaEdit, {
8
8
  '& .RaEdi-card, & > div > div > form': {
9
9
  backgroundColor: theme.palette.background.default
10
10
  },
11
- '& .RaEdit-main>.MuiPaper-root:first-child': {
11
+ '& .RaEdit-main>.MuiPaper-root:first-of-type': {
12
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
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
14
  // di tutti gli elementi presenti all'interno della pagina.
@@ -0,0 +1,30 @@
1
+ import { SimpleFormIterator as RaSimpleFormIterator } from 'ra-ui-materialui';
2
+ import { styled } from '@mui/material/styles';
3
+
4
+ // @ts-ignore
5
+ export const SimpleFormIterator = styled(RaSimpleFormIterator, {
6
+ name: 'ApplicaSimpleFormIterator',
7
+ root: 'root'
8
+ })(({ theme }) => ({
9
+ '& .RaSimpleFormIterator-line': {
10
+ paddingTop: theme.spacing(1),
11
+ paddingBottom: theme.spacing(0.5)
12
+ },
13
+ '& .RaSimpleFormIterator-action': {
14
+ display: 'flex',
15
+ flexDirection: 'row',
16
+ alignItems: 'center',
17
+ mb: 1.5
18
+ },
19
+ '& section': {
20
+ width: '100%',
21
+ '& label': {
22
+ position: 'relative',
23
+ overflow: 'visible',
24
+ transform: 'none',
25
+ ml: 0
26
+ }
27
+ }
28
+ }));
29
+
30
+ export default SimpleFormIterator;
@@ -0,0 +1,39 @@
1
+ import LabeledArrayInput, { LabeledArrayInputProps } from './LabeledArrayInput';
2
+ import { ArrayInput as RaArrayInput, ArrayInputProps as RaArrayInputProps } from 'react-admin';
3
+
4
+ import { styled } from '@mui/material/styles';
5
+
6
+ const StyledArrayInput = styled(RaArrayInput, {
7
+ name: 'ApplicaArrayInput',
8
+ slot: 'root'
9
+ })(({ theme }) => ({
10
+ '& label:first-of-type': {
11
+ marginTop: theme.spacing(2)
12
+ },
13
+ marginTop: '0 !important',
14
+ '& .RaSimpleFormIterator-line > .RaSimpleFormIterator-form': {
15
+ paddingBottom: theme.spacing(0.5),
16
+ '& > div': {
17
+ width: '100%'
18
+ }
19
+ }
20
+ }));
21
+
22
+ export type ArrayInputProps = RaArrayInputProps & LabeledArrayInputProps;
23
+
24
+ /**
25
+ * Espone un componente di tipo ArrayInput con stile grafico di Applica.
26
+ * Se vuoi utilizzare il componente puro di react-admin puoi usare RaArrayInput esposto nella libreria.
27
+ *
28
+ * @param {ArrayInputProps}
29
+ * @returns {React.ReactElement}
30
+ */
31
+ const ArrayInput = ({ children, label, addLabel, source, helperText, ...props }: ArrayInputProps): React.ReactElement => (
32
+ <LabeledArrayInput label={label} addLabel={addLabel} source={source} helperText={helperText} divider>
33
+ <StyledArrayInput source={source} label={false} {...props}>
34
+ {children}
35
+ </StyledArrayInput>
36
+ </LabeledArrayInput>
37
+ );
38
+
39
+ export default ArrayInput;
@@ -0,0 +1,116 @@
1
+ import { FormHelperText, InputLabel, Stack, SxProps } from '@mui/material';
2
+
3
+ import { FieldTitle } from 'react-admin';
4
+ import PropTypes from 'prop-types';
5
+ import React from 'react';
6
+ import { useAppConfig } from '../../hooks';
7
+ import { useFormContext } from 'react-hook-form';
8
+ import { useTheme } from '@emotion/react';
9
+
10
+ export type LabeledArrayInputProps = {
11
+ label?: string | boolean;
12
+ addLabel?: boolean;
13
+ resource?: string;
14
+ isRequired?: boolean;
15
+ source: string;
16
+ display?: 'legend' | 'label';
17
+ helperText?: string | boolean;
18
+ divider?: boolean;
19
+ sx?: SxProps;
20
+ children: React.ReactElement;
21
+ };
22
+
23
+ /**
24
+ * Consente di visualizzare un array di input con un label e un helper text con lo stile del tema Mantis.
25
+ *
26
+ * @param {LabeledArrayInputProps}
27
+ * @returns {React.ReactElement}
28
+ */
29
+ const LabeledArrayInput = ({
30
+ label,
31
+ children,
32
+ display,
33
+ helperText,
34
+ sx,
35
+ addLabel,
36
+ divider,
37
+ ...props
38
+ }: LabeledArrayInputProps): React.ReactElement => {
39
+ const theme = useTheme() as any;
40
+ const { getCurrentDialog } = useAppConfig();
41
+ const { source, resource, isRequired } = props;
42
+ const { getFieldState, formState } = useFormContext();
43
+ const { error } = getFieldState(source, formState);
44
+ const dialogResource = getCurrentDialog();
45
+
46
+ return (
47
+ <Stack
48
+ spacing={1}
49
+ sx={{
50
+ '& .MuiFormHelperText-root': {
51
+ // @see: https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/input/SelectArrayInput.tsx#L340
52
+ // the 'invalid' prop is not used inside the react-admin component. This is necessary if we want to support
53
+ // remove error message colorization when the field is in error state.
54
+ color: error ? theme.palette.error.main : theme.palette.text.secondary,
55
+ '& span': {
56
+ display: 'none'
57
+ }
58
+ },
59
+ ...sx
60
+ }}
61
+ >
62
+ {display === 'label' && label !== false && addLabel !== false && (
63
+ <InputLabel
64
+ error={!!error}
65
+ sx={{
66
+ borderBottom: divider ? `1px solid ${theme.palette.divider}` : 'none',
67
+ pb: divider ? 1 : 0,
68
+ mt: divider ? 1 : 0
69
+ }}
70
+ >
71
+ <FieldTitle label={label} source={source} resource={dialogResource || resource} isRequired={isRequired} />
72
+ </InputLabel>
73
+ )}
74
+ {React.isValidElement(children)
75
+ ? React.cloneElement(children, {
76
+ // @ts-ignore
77
+ ...children.props,
78
+ ...props,
79
+ label: display === 'legend' ? label : false
80
+ })
81
+ : children}
82
+ {display === 'label' && helperText && (
83
+ <FormHelperText
84
+ sx={{
85
+ pl: 1.8,
86
+ pb: 2,
87
+ marginTop: '0 !important'
88
+ }}
89
+ error={!!error}
90
+ >
91
+ {helperText}
92
+ </FormHelperText>
93
+ )}
94
+ </Stack>
95
+ );
96
+ };
97
+
98
+ LabeledArrayInput.propTypes = {
99
+ sx: PropTypes.object,
100
+ children: PropTypes.element,
101
+ label: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
102
+ addLabel: PropTypes.bool,
103
+ resource: PropTypes.string,
104
+ isRequired: PropTypes.bool,
105
+ source: PropTypes.string,
106
+ display: PropTypes.oneOf(['legend', 'label']),
107
+ helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
108
+ divider: PropTypes.bool
109
+ };
110
+
111
+ LabeledArrayInput.defaultProps = {
112
+ display: 'label',
113
+ divider: false
114
+ };
115
+
116
+ export default LabeledArrayInput;
@@ -6,7 +6,7 @@ import React from 'react';
6
6
  import { useAppConfig } from '../../hooks';
7
7
  import { useTheme } from '@emotion/react';
8
8
 
9
- const LabeledInput = ({ label, children, display, helperText, sx, addLabel, ...props }) => {
9
+ const LabeledInput = ({ label, children, display, helperText, sx, addLabel, divider, ...props }) => {
10
10
  const theme = useTheme();
11
11
  const { getCurrentDialog } = useAppConfig();
12
12
  const { source, resource, isRequired } = props;
@@ -31,19 +31,28 @@ const LabeledInput = ({ label, children, display, helperText, sx, addLabel, ...p
31
31
  }}
32
32
  >
33
33
  {display === 'label' && label !== false && addLabel !== false && (
34
- <InputLabel error={invalid === true}>
34
+ <InputLabel
35
+ error={invalid === true}
36
+ sx={{
37
+ borderBottom: divider ? `1px solid ${theme.palette.divider}` : 'none',
38
+ pb: divider ? 1 : 0,
39
+ mt: divider ? 1 : 0
40
+ }}
41
+ >
35
42
  <FieldTitle label={label} source={source} resource={dialogResource || resource} isRequired={isRequired} />
36
43
  </InputLabel>
37
44
  )}
38
- {React.cloneElement(children, {
39
- ...children.props,
40
- ...props,
41
- label: display === 'legend' ? label : false
42
- })}
45
+ {React.isValidElement(children)
46
+ ? React.cloneElement(children, {
47
+ ...children.props,
48
+ ...props,
49
+ label: display === 'legend' ? label : false
50
+ })
51
+ : children}
43
52
  {display === 'label' && helperText && (
44
53
  <FormHelperText
45
54
  sx={{
46
- pl: 2,
55
+ pl: 1.8,
47
56
  pb: 2,
48
57
  marginTop: '0 !important'
49
58
  }}
@@ -65,11 +74,13 @@ LabeledInput.propTypes = {
65
74
  isRequired: PropTypes.bool,
66
75
  source: PropTypes.string,
67
76
  display: PropTypes.oneOf(['legend', 'label']),
68
- helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.bool])
77
+ helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
78
+ divider: PropTypes.bool
69
79
  };
70
80
 
71
81
  LabeledInput.defaultProps = {
72
- display: 'label'
82
+ display: 'label',
83
+ divider: false
73
84
  };
74
85
 
75
86
  export default LabeledInput;
@@ -1,23 +1,24 @@
1
- import ArrayInput from './ArrayInput'
2
- import AttachmentInput from './AttachmentInput'
3
- import AutocompleteArrayInput from './AutocompleteArrayInput'
4
- import AutocompleteInput from './AutocompleteInput'
5
- import BooleanInput from './BooleanInput'
6
- import DateInput from './DateInput'
7
- import FileInput from './FileInput'
8
- import ImageInput from './ImageInput'
9
- import LabeledInput from './LabeledInput'
10
- import NumberInput from './NumberInput'
11
- import RecordInput from './RecordInput'
12
- import ReferenceArrayInput from './ReferenceArrayInput'
13
- import ReferenceInput from './ReferenceInput'
14
- import ReferenceManyInput from './ReferenceManyInput'
15
- import SearchInput from './SearchInput'
16
- import SelectArrayInput from './SelectArrayInput'
17
- import SelectInput from './SelectInput'
18
- import SmartTextInput from './SmartTextInput'
19
- import TextInput from './TextInput'
20
- import TimeInput from './TimeInput'
1
+ import ArrayInput from './ArrayInput';
2
+ import AttachmentInput from './AttachmentInput';
3
+ import AutocompleteArrayInput from './AutocompleteArrayInput';
4
+ import AutocompleteInput from './AutocompleteInput';
5
+ import BooleanInput from './BooleanInput';
6
+ import DateInput from './DateInput';
7
+ import FileInput from './FileInput';
8
+ import ImageInput from './ImageInput';
9
+ import LabeledArrayInput from './LabeledArrayInput';
10
+ import LabeledInput from './LabeledInput';
11
+ import NumberInput from './NumberInput';
12
+ import RecordInput from './RecordInput';
13
+ import ReferenceArrayInput from './ReferenceArrayInput';
14
+ import ReferenceInput from './ReferenceInput';
15
+ import ReferenceManyInput from './ReferenceManyInput';
16
+ import SearchInput from './SearchInput';
17
+ import SelectArrayInput from './SelectArrayInput';
18
+ import SelectInput from './SelectInput';
19
+ import SmartTextInput from './SmartTextInput';
20
+ import TextInput from './TextInput';
21
+ import TimeInput from './TimeInput';
21
22
  export {
22
23
  ArrayInput,
23
24
  AttachmentInput,
@@ -28,6 +29,7 @@ export {
28
29
  FileInput,
29
30
  ImageInput,
30
31
  LabeledInput,
32
+ LabeledArrayInput,
31
33
  NumberInput,
32
34
  RecordInput,
33
35
  ReferenceArrayInput,
@@ -38,5 +40,5 @@ export {
38
40
  SelectInput,
39
41
  SmartTextInput,
40
42
  TextInput,
41
- TimeInput,
42
- }
43
+ TimeInput
44
+ };
@@ -1,5 +1,5 @@
1
- import { Datagrid as RaDatagrid } from 'react-admin'
2
- import { styled } from '@mui/material/styles'
1
+ import { Datagrid as RaDatagrid } from 'react-admin';
2
+ import { styled } from '@mui/material/styles';
3
3
 
4
4
  const ApplicaStyledDatagrid = styled(RaDatagrid, {
5
5
  name: 'RaApplicaDatagrid',
@@ -23,20 +23,19 @@ const ApplicaStyledDatagrid = styled(RaDatagrid, {
23
23
  left: -1
24
24
  },
25
25
  '& th': {
26
- backgroundColor: 'yellow',
27
26
  textOverflow: 'ellipsis',
28
27
  overflow: 'hidden',
29
28
  whiteSpace: 'nowrap'
30
29
  }
31
- }))
30
+ }));
32
31
 
33
- const Datagrid = (props) => <ApplicaStyledDatagrid {...props} />
32
+ const Datagrid = (props) => <ApplicaStyledDatagrid {...props} />;
34
33
 
35
34
  Datagrid.propTypes = {
36
35
  ...RaDatagrid.propTypes
37
- }
36
+ };
38
37
  Datagrid.defaultProps = {
39
38
  ...RaDatagrid.defaultProps
40
- }
39
+ };
41
40
 
42
- export default Datagrid
41
+ export default Datagrid;
package/src/index.jsx CHANGED
@@ -7,7 +7,7 @@ export * from './contexts';
7
7
  export * from './utils';
8
8
 
9
9
  export {
10
- ArrayInput,
10
+ ArrayInput as RaArrayInput,
11
11
  ArrayInputContext,
12
12
  BooleanField,
13
13
  BulkDeleteWithConfirmButton,
@@ -42,6 +42,7 @@ export {
42
42
  Resource,
43
43
  ResourceContextProvider,
44
44
  SaveButton,
45
+ SimpleFormIterator as RaSimpleFormIterator,
45
46
  SimpleFormIteratorContext,
46
47
  SimpleList,
47
48
  SingleFieldList,
@@ -1,5 +0,0 @@
1
- export const SimpleFormIterator: import("@emotion/styled").StyledComponent<Pick<import("ra-ui-materialui").SimpleFormIteratorProps, keyof import("ra-ui-materialui").SimpleFormIteratorProps> & import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, {}, {
2
- ref?: import("react").Ref<import("react").Component<import("ra-ui-materialui").SimpleFormIteratorProps, any, any>> | undefined;
3
- }>;
4
- export default SimpleFormIterator;
5
- //# sourceMappingURL=SimpleFormIterator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SimpleFormIterator.d.ts","sourceRoot":"","sources":["../../../../src/components/ra-forms/SimpleFormIterator.jsx"],"names":[],"mappings":"AAGA;;GAQG"}
@@ -1,6 +0,0 @@
1
- export default ArrayInput;
2
- declare function ArrayInput(props: any): import("react/jsx-runtime").JSX.Element;
3
- declare namespace ArrayInput {
4
- const propTypes: any;
5
- }
6
- //# sourceMappingURL=ArrayInput.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ArrayInput.d.ts","sourceRoot":"","sources":["../../../../src/components/ra-inputs/ArrayInput.jsx"],"names":[],"mappings":";AAiBA,iFAIC"}
@@ -1,14 +0,0 @@
1
- import { SimpleFormIterator as RaSimpleFormIterator } from 'ra-ui-materialui'
2
- import { styled } from '@mui/material/styles'
3
-
4
- export const SimpleFormIterator = styled(RaSimpleFormIterator, {
5
- name: 'ApplicaSimpleFormIterator',
6
- root: 'root'
7
- })(({ theme }) => ({
8
- '& .RaSimpleFormIterator-line': {
9
- paddingTop: theme.spacing(1),
10
- paddingBottom: theme.spacing(0.5),
11
- }
12
- }))
13
-
14
- export default SimpleFormIterator
@@ -1,29 +0,0 @@
1
- import LabeledInput from './LabeledInput'
2
- import { ArrayInput as RaArrayInput } from 'react-admin'
3
- import { styled } from '@mui/material/styles'
4
-
5
- const StyledArrayInput = styled(RaArrayInput, {
6
- name: 'RaApplicaArrayInput',
7
- slot: 'root',
8
- })(({ theme }) => ({
9
- marginTop: '0 !important',
10
- '& .RaSimpleFormIterator-line > .RaSimpleFormIterator-form': {
11
- paddingBottom: theme.spacing(0.5),
12
- '& > div': {
13
- width: '100%',
14
- },
15
- },
16
- }))
17
-
18
- const ArrayInput = (props) => (
19
- <LabeledInput {...props}>
20
- <StyledArrayInput {...props} />
21
- </LabeledInput>
22
- )
23
-
24
- ArrayInput.propTypes = {
25
- ...RaArrayInput.propTypes,
26
- ...LabeledInput.propTypes,
27
- }
28
-
29
- export default ArrayInput