@applica-software-guru/react-admin 1.3.166 → 1.3.168
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/Layout/Content.d.ts.map +1 -1
- package/dist/components/Layout/Navigation/NavGroup.d.ts.map +1 -1
- package/dist/components/ra-forms/Create.d.ts.map +1 -1
- package/dist/components/ra-forms/Edit.d.ts.map +1 -1
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts +2 -0
- package/dist/components/ra-forms/TableForm/TableFormIterator.d.ts.map +1 -1
- package/dist/components/ra-inputs/BooleanInput.d.ts.map +1 -1
- package/dist/hooks/useLocalStorage.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +59 -59
- package/dist/react-admin.cjs.js.map +1 -1
- package/dist/react-admin.es.js +4407 -4390
- package/dist/react-admin.es.js.map +1 -1
- package/dist/react-admin.umd.js +58 -58
- package/dist/react-admin.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Layout/Content.tsx +6 -1
- package/src/components/Layout/Navigation/NavGroup.jsx +1 -2
- package/src/components/ra-forms/Create.tsx +10 -2
- package/src/components/ra-forms/Edit.jsx +9 -4
- package/src/components/ra-forms/LongForm/BaseForm.tsx +1 -1
- package/src/components/ra-forms/TableForm/TableFormIterator.tsx +16 -4
- package/src/components/ra-inputs/BooleanInput.jsx +3 -1
- package/src/hooks/useLocalStorage.tsx +25 -28
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import { Loading } from 'ra-ui-materialui';
|
|
|
5
5
|
import { ErrorInfo, Suspense, useState } from 'react';
|
|
6
6
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
7
7
|
import Error, { ErrorProps } from './Error';
|
|
8
|
+
import { useTheme } from '@mui/material/styles';
|
|
8
9
|
|
|
9
10
|
type ILayoutContentProps = React.PropsWithChildren & {
|
|
10
11
|
error?: React.ComponentType<ErrorProps>;
|
|
@@ -19,6 +20,7 @@ function LayoutContent(props: ILayoutContentProps) {
|
|
|
19
20
|
const handleError = (error: Error, info: ErrorInfo) => {
|
|
20
21
|
setErrorInfo(info);
|
|
21
22
|
};
|
|
23
|
+
const theme = useTheme();
|
|
22
24
|
|
|
23
25
|
return (
|
|
24
26
|
<ErrorBoundary
|
|
@@ -37,7 +39,10 @@ function LayoutContent(props: ILayoutContentProps) {
|
|
|
37
39
|
position: 'relative',
|
|
38
40
|
minHeight: 'calc(100vh - 110px)',
|
|
39
41
|
display: 'flex',
|
|
40
|
-
flexDirection: 'column'
|
|
42
|
+
flexDirection: 'column',
|
|
43
|
+
[theme.breakpoints.down('sm')]: {
|
|
44
|
+
px: '12px',
|
|
45
|
+
}
|
|
41
46
|
}}
|
|
42
47
|
>
|
|
43
48
|
{props.children}
|
|
@@ -37,8 +37,7 @@ const NavGroup = ({ item, lastItem, remItems, lastItemId, setSelectedItems, sele
|
|
|
37
37
|
const { pathname } = { pathname: '' }; // useLocation()
|
|
38
38
|
const { horizontal, downLg } = useLayoutMediaState();
|
|
39
39
|
const menu = useMenuConfig();
|
|
40
|
-
const { drawerOpen, selectedID } = menu;
|
|
41
|
-
const { activeID } = useMenuConfig();
|
|
40
|
+
const { drawerOpen, selectedID, activeID } = menu;
|
|
42
41
|
|
|
43
42
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
44
43
|
const [currentItem, setCurrentItem] = useState(item);
|
|
@@ -79,9 +79,17 @@ const StyledCreate = styled(Create, {
|
|
|
79
79
|
backgroundColor: theme.palette.background.default
|
|
80
80
|
},
|
|
81
81
|
'& .RaCreate-main>.MuiPaper-root:first-of-type': {
|
|
82
|
-
overflow: 'visible',
|
|
83
82
|
backgroundColor: theme.palette.background.default
|
|
84
|
-
}
|
|
83
|
+
},
|
|
84
|
+
// Ci ho messo 4 ore per scrivere questa riga di codice e risolvere un problema con react-sticky-box ed i Long Form.
|
|
85
|
+
// L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
|
|
86
|
+
// di tutti gli elementi presenti all'interno della pagina.
|
|
87
|
+
'& .RaCreate-main:has(.ApplicaLongFormView)>.MuiPaper-root:first-of-type': {
|
|
88
|
+
overflow: 'visible'
|
|
89
|
+
},
|
|
90
|
+
'& .RaCreate-main:has(.tabbed-form) .MuiTableContainer-root': {
|
|
91
|
+
width: 'inherit',
|
|
92
|
+
},
|
|
85
93
|
}));
|
|
86
94
|
|
|
87
95
|
export default StyledCreate;
|
|
@@ -21,11 +21,16 @@ const StyledEdit = styled(RaEdit, {
|
|
|
21
21
|
borderTop: `1px solid ${theme.palette.divider}`
|
|
22
22
|
},
|
|
23
23
|
'& .RaEdit-main>.MuiPaper-root:first-of-type': {
|
|
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
|
-
// L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
|
|
26
|
-
// di tutti gli elementi presenti all'interno della pagina.
|
|
27
|
-
overflow: 'visible',
|
|
28
24
|
backgroundColor: theme.palette.background.default
|
|
25
|
+
},
|
|
26
|
+
// Ci ho messo 4 ore per scrivere questa riga di codice e risolvere un problema con react-sticky-box ed i Long Form.
|
|
27
|
+
// L'overflow è di default 'hidden', a noi serve visibile per consentire a react-sticky-box di funzionare e gestire la visiblità con ancore
|
|
28
|
+
// di tutti gli elementi presenti all'interno della pagina.
|
|
29
|
+
'& .RaEdit-main:has(.ApplicaLongFormView)>.MuiPaper-root:first-of-type': {
|
|
30
|
+
overflow: 'visible'
|
|
31
|
+
},
|
|
32
|
+
'& .RaEdit-main:has(.tabbed-form) .MuiTableContainer-root': {
|
|
33
|
+
width: 'inherit'
|
|
29
34
|
}
|
|
30
35
|
}));
|
|
31
36
|
|
|
@@ -42,7 +42,7 @@ function BaseForm(props: IBaseFormProps) {
|
|
|
42
42
|
formProps = _.omit(props, ['spacing']);
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
|
-
<Form {...formProps}>
|
|
45
|
+
<Form {...formProps} className='ApplicaLongFormView'>
|
|
46
46
|
<StyledGrid container spacing={spacing * 2}>
|
|
47
47
|
{props.children}
|
|
48
48
|
</StyledGrid>
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from '@mui/material';
|
|
18
18
|
import { FormDataConsumer, RaRecord, useRecordContext, useTranslate, useTranslateLabel } from 'ra-core';
|
|
19
19
|
import { styled, useTheme } from '@mui/material/styles';
|
|
20
|
-
|
|
20
|
+
import ActionsMenu from '../../ActionsMenu';
|
|
21
21
|
import { PlusCircleOutlined } from '@ant-design/icons';
|
|
22
22
|
import PropTypes from 'prop-types';
|
|
23
23
|
import { TableFormIteratorContext } from '../../../contexts';
|
|
@@ -52,6 +52,7 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
52
52
|
disableActions = false,
|
|
53
53
|
disableAdd = false,
|
|
54
54
|
disableRemove = false,
|
|
55
|
+
enableClearAll = false,
|
|
55
56
|
className,
|
|
56
57
|
empty,
|
|
57
58
|
template = {}
|
|
@@ -143,6 +144,7 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
143
144
|
|
|
144
145
|
// @ts-ignore
|
|
145
146
|
const tableBorderColor = theme.palette.mode === 'dark' ? theme.palette.grey.A400 : theme.palette.grey.A800;
|
|
147
|
+
const showClearAllButton = fields.length > 0 && enableClearAll;
|
|
146
148
|
|
|
147
149
|
return fields ? (
|
|
148
150
|
// @ts-ignore
|
|
@@ -175,9 +177,17 @@ const TableFormIterator = (props: TableFormIteratorProps) => {
|
|
|
175
177
|
})}
|
|
176
178
|
|
|
177
179
|
{!disableActions && (
|
|
178
|
-
|
|
179
|
-
<
|
|
180
|
-
|
|
180
|
+
showClearAllButton ? (
|
|
181
|
+
<TableCell key='actions' sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
182
|
+
<ActionsMenu horizontal>
|
|
183
|
+
<Typography color="error" onClick={() => setConfirmIsOpen(true)}>
|
|
184
|
+
{translate('ra.action.delete')}
|
|
185
|
+
</Typography>
|
|
186
|
+
</ActionsMenu>
|
|
187
|
+
</TableCell>
|
|
188
|
+
) : (
|
|
189
|
+
<TableCell key='empty_actions' />
|
|
190
|
+
)
|
|
181
191
|
)}
|
|
182
192
|
</TableRow>
|
|
183
193
|
</TableHead>
|
|
@@ -290,6 +300,7 @@ TableFormIterator.propTypes = {
|
|
|
290
300
|
resource: PropTypes.string,
|
|
291
301
|
translate: PropTypes.func,
|
|
292
302
|
disableAdd: PropTypes.bool,
|
|
303
|
+
enableClearAll: PropTypes.bool,
|
|
293
304
|
disableRemove: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
|
|
294
305
|
TransitionProps: PropTypes.shape({}),
|
|
295
306
|
empty: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
|
|
@@ -303,6 +314,7 @@ export interface TableFormIteratorProps extends Partial<UseFieldArrayReturn> {
|
|
|
303
314
|
disableAdd?: boolean;
|
|
304
315
|
disableActions?: boolean;
|
|
305
316
|
disableRemove?: boolean;
|
|
317
|
+
enableClearAll?: boolean;
|
|
306
318
|
template?: object;
|
|
307
319
|
meta?: {
|
|
308
320
|
// the type defined in FieldArrayRenderProps says error is boolean, which is wrong.
|
|
@@ -7,7 +7,9 @@ import { BooleanInput as RaBooleanInput } from 'react-admin';
|
|
|
7
7
|
const ApplicaStyledBooleanInput = styled(RaBooleanInput, {
|
|
8
8
|
name: 'RaApplicaBooleanInput',
|
|
9
9
|
slot: 'Root'
|
|
10
|
-
})(() => ({
|
|
10
|
+
})(() => ({
|
|
11
|
+
marginTop: '0 !important'
|
|
12
|
+
}));
|
|
11
13
|
|
|
12
14
|
const BooleanInput = ({ horizontal, ...props }) => {
|
|
13
15
|
// eslint-disable-next-line no-unused-vars
|
|
@@ -1,51 +1,48 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
-
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import * as yup from 'yup';
|
|
4
4
|
import { LocalStorage } from '../utils/localStorage';
|
|
5
5
|
|
|
6
6
|
const localStorageInstance = new LocalStorage();
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
yup.string().required().validateSync(key);
|
|
10
|
-
|
|
11
|
-
function buildSetter(key: string, currentValue: unknown, callback: (newValue: unknown) => unknown): (newValue: unknown) => unknown {
|
|
12
|
-
return function (newValue: unknown) {
|
|
13
|
-
const updatedValue = _.isFunction(newValue) ? newValue(currentValue) : newValue;
|
|
14
|
-
localStorageInstance.set(key, updatedValue);
|
|
15
|
-
callback(updatedValue);
|
|
16
|
-
return updatedValue;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
8
|
+
type ISetter = (newValue: unknown) => unknown;
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
function buildSetter(key: string, currentValue: unknown, callback: ISetter): ISetter {
|
|
11
|
+
return function (newValue: unknown) {
|
|
12
|
+
const updatedValue = _.isFunction(newValue) ? newValue(currentValue) : newValue;
|
|
13
|
+
localStorageInstance.set(key, updatedValue);
|
|
14
|
+
callback(updatedValue);
|
|
15
|
+
return updatedValue;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
function useLocalStorage(key: string, defaultValue?: unknown): [unknown, (newValue: unknown) => unknown] {
|
|
20
|
+
yup.string().required().validateSync(key);
|
|
21
|
+
const [state, setState] = useState(localStorageInstance.get(key) ?? defaultValue),
|
|
22
|
+
defaultValueRef = useRef<unknown | undefined>(defaultValue),
|
|
23
|
+
storedDefaultValue = _.isEqual(defaultValueRef.current, defaultValue) ? defaultValueRef.current : defaultValue,
|
|
24
|
+
setterRef = useRef<{ key: string; value: unknown; setter: ISetter } | undefined>(),
|
|
25
|
+
storedSetter = setterRef.current;
|
|
29
26
|
|
|
30
27
|
useEffect(() => {
|
|
31
|
-
|
|
32
|
-
}, [key,
|
|
28
|
+
setState(localStorageInstance.get(key) ?? storedDefaultValue);
|
|
29
|
+
}, [key, storedDefaultValue, setState]);
|
|
33
30
|
|
|
34
31
|
useEffect(() => {
|
|
35
32
|
function listener(value: unknown) {
|
|
36
|
-
|
|
33
|
+
setState(value);
|
|
37
34
|
}
|
|
38
35
|
localStorageInstance.watch(key, listener);
|
|
39
36
|
return () => {
|
|
40
37
|
localStorageInstance.unwatch(key, listener);
|
|
41
38
|
};
|
|
42
|
-
}, [key,
|
|
39
|
+
}, [key, setState]);
|
|
43
40
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
41
|
+
if (key !== storedSetter?.key || !_.isEqual(state, storedSetter?.value)) {
|
|
42
|
+
setterRef.current = { key, value: state, setter: buildSetter(key, state, setState) };
|
|
43
|
+
}
|
|
47
44
|
|
|
48
|
-
return [state, setter];
|
|
45
|
+
return [state, setterRef.current?.setter ?? _.noop];
|
|
49
46
|
}
|
|
50
47
|
|
|
51
48
|
export default useLocalStorage;
|