@applica-software-guru/react-admin 1.0.41 → 1.0.43
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/bitbucket-pipelines.yml +2 -0
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/@extended/AnimateButton.d.ts +1 -1
- package/dist/components/@extended/AnimateButton.d.ts.map +1 -1
- package/dist/components/@extended/Avatar.d.ts.map +1 -1
- package/dist/components/@extended/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/@extended/IconButton.d.ts.map +1 -1
- package/dist/components/@extended/LoadingButton.d.ts.map +1 -1
- package/dist/components/@extended/Tooltip.d.ts.map +1 -1
- package/dist/components/@extended/Transitions.d.ts.map +1 -1
- package/dist/components/@extended/progress/CircularWithLabel.d.ts.map +1 -1
- package/dist/components/@extended/progress/CircularWithPath.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.d.ts +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavItem.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerHeader/index.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/MiniDrawerStyled.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/index.d.ts.map +1 -1
- package/dist/components/Layout/Footer.d.ts.map +1 -1
- package/dist/components/Layout/Header/AppBarStyled.d.ts.map +1 -1
- package/dist/components/Layout/Header/HeaderContent/Notification.d.ts.map +1 -1
- package/dist/components/Layout/Header/HeaderContent/NotificationItem.d.ts.map +1 -1
- package/dist/components/Layout/Header/HeaderContent/Profile.d.ts.map +1 -1
- package/dist/components/Layout/Header/HeaderContent/index.d.ts.map +1 -1
- package/dist/components/Layout/Header/index.d.ts.map +1 -1
- package/dist/components/Layout/index.d.ts.map +1 -1
- package/dist/components/MenuPopover/styles.d.ts.map +1 -1
- package/dist/components/Notification.d.ts.map +1 -1
- package/dist/components/ScrollX.d.ts.map +1 -1
- package/dist/components/ra-buttons/EditInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-fields/CoverField.d.ts.map +1 -1
- package/dist/components/ra-fields/DateAgoField.d.ts.map +1 -1
- package/dist/components/ra-fields/ReadonlyField.d.ts.map +1 -1
- package/dist/components/ra-forms/CardForm.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/useFormRootPath.d.ts.map +1 -1
- package/dist/components/ra-forms/TabbedForm.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts.map +1 -1
- package/dist/components/ra-lists/Empty.d.ts.map +1 -1
- package/dist/components/ra-lists/NotificationList/NotificationList.d.ts.map +1 -1
- package/dist/components/ra-lists/NotificationList/button/MarkAsReadedButton.d.ts.map +1 -1
- package/dist/components/ra-lists/NotificationList/field/NotificationField.d.ts.map +1 -1
- package/dist/contexts/MenuConfigContext.d.ts.map +1 -1
- package/dist/contexts/MenuPropTypes.d.ts.map +1 -1
- package/dist/dev/useCliErrorCatcher.d.ts +1 -1
- package/dist/hooks/useMenu.d.ts.map +1 -1
- package/dist/i18n/useI18nCatcher.d.ts +1 -1
- package/dist/i18n/useI18nLanguages.d.ts +1 -1
- package/dist/i18n/useI18nLanguages.d.ts.map +1 -1
- package/dist/i18n/useI18nProvider.d.ts.map +1 -1
- package/dist/react-admin.cjs.js +2 -1
- package/dist/react-admin.cjs.js.map +1 -0
- package/dist/react-admin.es.js +300 -784
- package/dist/react-admin.es.js.map +1 -0
- package/dist/react-admin.umd.js +2 -1
- package/dist/react-admin.umd.js.map +1 -0
- package/dist/themes/overrides/OutlinedInput.d.ts.map +1 -1
- package/dist/themes/palette.d.ts.map +1 -1
- package/dist/themes/theme/theme1.d.ts.map +1 -1
- package/dist/themes/theme/theme2.d.ts.map +1 -1
- package/dist/themes/theme/theme3.d.ts.map +1 -1
- package/dist/themes/theme/theme4.d.ts.map +1 -1
- package/dist/themes/theme/theme5.d.ts.map +1 -1
- package/dist/themes/theme/theme6.d.ts.map +1 -1
- package/dist/themes/theme/theme7.d.ts.map +1 -1
- package/dist/themes/theme/theme8.d.ts.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/lang.d.ts +1 -1
- package/dist/utils/lang.d.ts.map +1 -1
- package/dist/utils/time.d.ts +2 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/Admin.jsx +8 -8
- package/src/AdminContext.jsx +9 -9
- package/src/ApplicaAdmin.jsx +30 -35
- package/src/components/@extended/AnimateButton.jsx +25 -33
- package/src/components/@extended/Avatar.jsx +35 -42
- package/src/components/@extended/Breadcrumbs.jsx +62 -96
- package/src/components/@extended/Dot.jsx +14 -14
- package/src/components/@extended/IconButton.jsx +55 -65
- package/src/components/@extended/LoadingButton.jsx +84 -86
- package/src/components/@extended/Tooltip.jsx +24 -27
- package/src/components/@extended/Transitions.jsx +98 -107
- package/src/components/@extended/index.jsx +10 -10
- package/src/components/@extended/progress/CircularWithLabel.jsx +7 -9
- package/src/components/@extended/progress/CircularWithPath.jsx +9 -18
- package/src/components/@extended/progress/LinearWithIcon.jsx +5 -5
- package/src/components/@extended/progress/LinearWithLabel.jsx +5 -5
- package/src/components/@extended/progress/index.jsx +5 -5
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.jsx +112 -131
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.jsx +67 -88
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavItem.jsx +63 -79
- package/src/components/Layout/Drawer/DrawerContent/Navigation/index.jsx +28 -28
- package/src/components/Layout/Drawer/DrawerContent/index.jsx +7 -7
- package/src/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.jsx +13 -15
- package/src/components/Layout/Drawer/DrawerHeader/index.jsx +17 -22
- package/src/components/Layout/Drawer/HorizontalBar.jsx +17 -17
- package/src/components/Layout/Drawer/MiniDrawerStyled.jsx +27 -29
- package/src/components/Layout/Drawer/index.jsx +21 -24
- package/src/components/Layout/Footer.jsx +7 -12
- package/src/components/Layout/Header/AppBarStyled.jsx +26 -28
- package/src/components/Layout/Header/HeaderContent/MobileSection.jsx +27 -27
- package/src/components/Layout/Header/HeaderContent/Notification.jsx +34 -55
- package/src/components/Layout/Header/HeaderContent/NotificationItem.jsx +24 -36
- package/src/components/Layout/Header/HeaderContent/Profile.jsx +48 -73
- package/src/components/Layout/Header/HeaderContent/index.jsx +16 -18
- package/src/components/Layout/Header/index.jsx +25 -43
- package/src/components/Layout/index.jsx +36 -52
- package/src/components/Loadable.jsx +4 -4
- package/src/components/Loader.jsx +7 -7
- package/src/components/Logo.jsx +14 -14
- package/src/components/MainIcon.jsx +6 -6
- package/src/components/MenuPopover/MenuPopover.jsx +15 -15
- package/src/components/MenuPopover/getPosition.jsx +40 -40
- package/src/components/MenuPopover/index.jsx +3 -3
- package/src/components/MenuPopover/styles.jsx +20 -20
- package/src/components/Notification.jsx +7 -7
- package/src/components/ScrollTop.jsx +13 -13
- package/src/components/ScrollX.jsx +4 -4
- package/src/components/SmallIcon.jsx +6 -6
- package/src/components/ra-buttons/EditInDialogButton.jsx +39 -45
- package/src/components/ra-buttons/ImpersonateUserButton.jsx +20 -20
- package/src/components/ra-buttons/index.jsx +4 -4
- package/src/components/ra-fields/ActionsField.jsx +12 -12
- package/src/components/ra-fields/CoverField.jsx +20 -26
- package/src/components/ra-fields/DateAgoField.jsx +17 -20
- package/src/components/ra-fields/DateField.jsx +14 -14
- package/src/components/ra-fields/EmailField.jsx +14 -14
- package/src/components/ra-fields/FileField.jsx +23 -23
- package/src/components/ra-fields/FunctionField.jsx +5 -5
- package/src/components/ra-fields/ImageField.jsx +11 -11
- package/src/components/ra-fields/ReadonlyField.jsx +40 -42
- package/src/components/ra-fields/ReferenceManyField.jsx +21 -21
- package/src/components/ra-fields/SizeField.jsx +15 -15
- package/src/components/ra-fields/TextField.jsx +14 -14
- package/src/components/ra-fields/index.jsx +15 -15
- package/src/components/ra-forms/CardForm.jsx +34 -40
- package/src/components/ra-forms/LongForm/useFormRootPath.ts +8 -13
- package/src/components/ra-forms/TabbedForm.jsx +10 -10
- package/src/components/ra-forms/Toolbar.jsx +15 -15
- package/src/components/ra-forms/index.jsx +9 -9
- package/src/components/ra-inputs/AutocompleteArrayInput.jsx +7 -7
- package/src/components/ra-inputs/AutocompleteInput.jsx +9 -9
- package/src/components/ra-inputs/BooleanInput.jsx +19 -19
- package/src/components/ra-inputs/DateInput.jsx +13 -13
- package/src/components/ra-inputs/FileInput.jsx +33 -33
- package/src/components/ra-inputs/ImageInput.jsx +19 -19
- package/src/components/ra-inputs/NumberInput.jsx +13 -13
- package/src/components/ra-inputs/RecordInput.jsx +39 -39
- package/src/components/ra-inputs/ReferenceArrayInput.jsx +10 -10
- package/src/components/ra-inputs/ReferenceInput.jsx +10 -10
- package/src/components/ra-inputs/ReferenceManyInput.jsx +13 -24
- package/src/components/ra-inputs/SearchInput.jsx +6 -6
- package/src/components/ra-inputs/SelectArrayInput.jsx +19 -19
- package/src/components/ra-inputs/TimeInput.jsx +21 -21
- package/src/components/ra-lists/Empty.jsx +32 -37
- package/src/components/ra-lists/List.jsx +9 -9
- package/src/components/ra-lists/NotificationList/NotificationList.jsx +14 -16
- package/src/components/ra-lists/NotificationList/button/MarkAsReadedButton.jsx +21 -25
- package/src/components/ra-lists/NotificationList/button/MarkAsUnreadedButton.jsx +19 -19
- package/src/components/ra-lists/NotificationList/button/index.jsx +2 -2
- package/src/components/ra-lists/NotificationList/field/NotificationField.jsx +20 -31
- package/src/components/ra-lists/NotificationList/field/index.jsx +1 -1
- package/src/components/ra-lists/NotificationList/index.jsx +2 -2
- package/src/components/ra-lists/index.jsx +5 -5
- package/src/components/third-party/SimpleBar.jsx +10 -10
- package/src/components/third-party/index.jsx +2 -2
- package/src/contexts/MenuConfigContext.jsx +35 -35
- package/src/contexts/MenuPropTypes.jsx +7 -7
- package/src/contexts/index.jsx +5 -5
- package/src/dev/index.jsx +2 -2
- package/src/dev/useCliErrorCatcher.jsx +32 -32
- package/src/hooks/index.jsx +8 -16
- package/src/hooks/useAppConfig.jsx +4 -4
- package/src/hooks/useBreadcrumbs.jsx +37 -37
- package/src/hooks/useLocalStorage.jsx +16 -16
- package/src/hooks/useMenu.jsx +83 -88
- package/src/hooks/useMenuConfig.jsx +4 -4
- package/src/hooks/useResourceTitle.jsx +13 -13
- package/src/hooks/useThemeConfig.jsx +4 -4
- package/src/i18n/createI18nProvider.jsx +7 -7
- package/src/i18n/index.jsx +4 -4
- package/src/i18n/useI18nCatcher.jsx +26 -26
- package/src/i18n/useI18nLanguages.jsx +12 -16
- package/src/i18n/useI18nProvider.jsx +3 -4
- package/src/themes/getColors.jsx +8 -8
- package/src/themes/getShadow.jsx +17 -17
- package/src/themes/index.jsx +29 -29
- package/src/themes/overrides/Accordion.jsx +9 -9
- package/src/themes/overrides/AccordionDetails.jsx +5 -5
- package/src/themes/overrides/AccordionSummary.jsx +11 -11
- package/src/themes/overrides/Alert.jsx +21 -21
- package/src/themes/overrides/AlertTitle.jsx +5 -5
- package/src/themes/overrides/Autocomplete.jsx +9 -9
- package/src/themes/overrides/Badge.jsx +12 -12
- package/src/themes/overrides/Button.jsx +62 -62
- package/src/themes/overrides/ButtonBase.jsx +4 -4
- package/src/themes/overrides/ButtonGroup.jsx +4 -4
- package/src/themes/overrides/CardContent.jsx +6 -6
- package/src/themes/overrides/Checkbox.jsx +31 -31
- package/src/themes/overrides/Chip.jsx +22 -22
- package/src/themes/overrides/Dialog.jsx +7 -7
- package/src/themes/overrides/DialogContentText.jsx +5 -5
- package/src/themes/overrides/DialogTitle.jsx +5 -5
- package/src/themes/overrides/Fab.jsx +21 -21
- package/src/themes/overrides/IconButton.jsx +8 -8
- package/src/themes/overrides/InputBase.jsx +3 -3
- package/src/themes/overrides/InputLabel.jsx +8 -8
- package/src/themes/overrides/LinearProgress.jsx +6 -6
- package/src/themes/overrides/Link.jsx +4 -4
- package/src/themes/overrides/ListItemButton.jsx +7 -7
- package/src/themes/overrides/ListItemIcon.jsx +5 -5
- package/src/themes/overrides/LoadingButton.jsx +6 -6
- package/src/themes/overrides/OutlinedInput.jsx +20 -21
- package/src/themes/overrides/Pagination.jsx +4 -4
- package/src/themes/overrides/PaginationItem.jsx +55 -55
- package/src/themes/overrides/Popover.jsx +5 -5
- package/src/themes/overrides/Radio.jsx +30 -30
- package/src/themes/overrides/Slider.jsx +20 -20
- package/src/themes/overrides/Switch.jsx +26 -26
- package/src/themes/overrides/Tab.jsx +7 -7
- package/src/themes/overrides/TableBody.jsx +11 -11
- package/src/themes/overrides/TableCell.jsx +12 -12
- package/src/themes/overrides/TableFooter.jsx +5 -5
- package/src/themes/overrides/TableHead.jsx +5 -5
- package/src/themes/overrides/TablePagination.jsx +6 -6
- package/src/themes/overrides/TableRow.jsx +10 -10
- package/src/themes/overrides/Tabs.jsx +5 -5
- package/src/themes/overrides/ToggleButton.jsx +7 -7
- package/src/themes/overrides/Tooltip.jsx +5 -5
- package/src/themes/overrides/TreeItem.jsx +7 -7
- package/src/themes/overrides/Typography.jsx +5 -5
- package/src/themes/overrides/index.jsx +47 -47
- package/src/themes/palette.jsx +22 -34
- package/src/themes/shadows.jsx +4 -4
- package/src/themes/theme/default.jsx +17 -17
- package/src/themes/theme/index.jsx +23 -23
- package/src/themes/theme/theme1.jsx +24 -46
- package/src/themes/theme/theme2.jsx +24 -46
- package/src/themes/theme/theme3.jsx +24 -46
- package/src/themes/theme/theme4.jsx +24 -46
- package/src/themes/theme/theme5.jsx +24 -46
- package/src/themes/theme/theme6.jsx +24 -46
- package/src/themes/theme/theme7.jsx +24 -46
- package/src/themes/theme/theme8.jsx +24 -46
- package/src/themes/typography.jsx +16 -16
- package/src/utils/{lang.js → lang.ts} +4 -4
- package/src/utils/time.ts +14 -0
- package/vite.config.js +11 -10
- package/src/utils/time.js +0 -13
- /package/src/utils/{index.js → index.ts} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import ActionsField from './ActionsField'
|
|
2
|
-
import AttachmentField from './AttachmentField'
|
|
3
|
-
import CoverField from './CoverField'
|
|
4
|
-
import DateAgoField from './DateAgoField'
|
|
5
|
-
import DateField from './DateField'
|
|
6
|
-
import EmailField from './EmailField'
|
|
7
|
-
import FileField from './FileField'
|
|
8
|
-
import FunctionField from './FunctionField'
|
|
9
|
-
import ImageField from './ImageField'
|
|
10
|
-
import ReadonlyField from './ReadonlyField'
|
|
11
|
-
import ReferenceManyField from './ReferenceManyField'
|
|
12
|
-
import SizeField from './SizeField'
|
|
13
|
-
import TextField from './TextField'
|
|
1
|
+
import ActionsField from './ActionsField';
|
|
2
|
+
import AttachmentField from './AttachmentField';
|
|
3
|
+
import CoverField from './CoverField';
|
|
4
|
+
import DateAgoField from './DateAgoField';
|
|
5
|
+
import DateField from './DateField';
|
|
6
|
+
import EmailField from './EmailField';
|
|
7
|
+
import FileField from './FileField';
|
|
8
|
+
import FunctionField from './FunctionField';
|
|
9
|
+
import ImageField from './ImageField';
|
|
10
|
+
import ReadonlyField from './ReadonlyField';
|
|
11
|
+
import ReferenceManyField from './ReferenceManyField';
|
|
12
|
+
import SizeField from './SizeField';
|
|
13
|
+
import TextField from './TextField';
|
|
14
14
|
export {
|
|
15
15
|
ActionsField,
|
|
16
16
|
AttachmentField,
|
|
@@ -24,5 +24,5 @@ export {
|
|
|
24
24
|
ReadonlyField,
|
|
25
25
|
ReferenceManyField,
|
|
26
26
|
SizeField,
|
|
27
|
-
TextField
|
|
28
|
-
}
|
|
27
|
+
TextField
|
|
28
|
+
};
|
|
@@ -1,32 +1,26 @@
|
|
|
1
|
-
import { Form, SaveButton, useResourceContext, useTranslate } from 'react-admin'
|
|
2
|
-
import { Grid, Stack } from '@mui/material'
|
|
3
|
-
import React, { Fragment, useMemo } from 'react'
|
|
1
|
+
import { Form, SaveButton, useResourceContext, useTranslate } from 'react-admin';
|
|
2
|
+
import { Grid, Stack } from '@mui/material';
|
|
3
|
+
import React, { Fragment, useMemo } from 'react';
|
|
4
4
|
|
|
5
|
-
import MainCard from '../MainCard'
|
|
6
|
-
import PropTypes from 'prop-types'
|
|
7
|
-
import Toolbar from './Toolbar'
|
|
8
|
-
import { styled } from '@mui/material/styles'
|
|
9
|
-
import { useThemeConfig } from '../../hooks'
|
|
5
|
+
import MainCard from '../MainCard';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import Toolbar from './Toolbar';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import { useThemeConfig } from '../../hooks';
|
|
10
10
|
|
|
11
11
|
const Section = ({ children, content, title, subheader, secondary, toolbar, ...gridProps }) => {
|
|
12
|
-
const translate = useTranslate()
|
|
13
|
-
const resource = useResourceContext()
|
|
12
|
+
const translate = useTranslate();
|
|
13
|
+
const resource = useResourceContext();
|
|
14
14
|
const { cardTitle, cardSubheader } = useMemo(() => {
|
|
15
|
-
const defaultTitle = title || `resources.${resource}.title
|
|
15
|
+
const defaultTitle = title || `resources.${resource}.title`;
|
|
16
16
|
return {
|
|
17
17
|
cardTitle: translate(defaultTitle, { _: defaultTitle }),
|
|
18
|
-
cardSubheader: subheader !== null ? translate(subheader, { _: subheader }) : null
|
|
19
|
-
}
|
|
20
|
-
}, [resource, subheader, title, translate])
|
|
18
|
+
cardSubheader: subheader !== null ? translate(subheader, { _: subheader }) : null
|
|
19
|
+
};
|
|
20
|
+
}, [resource, subheader, title, translate]);
|
|
21
21
|
return (
|
|
22
22
|
<Grid item {...gridProps}>
|
|
23
|
-
<MainCard
|
|
24
|
-
content={content}
|
|
25
|
-
title={cardTitle}
|
|
26
|
-
subheader={cardSubheader}
|
|
27
|
-
secondary={secondary}
|
|
28
|
-
divider
|
|
29
|
-
>
|
|
23
|
+
<MainCard content={content} title={cardTitle} subheader={cardSubheader} secondary={secondary} divider>
|
|
30
24
|
<Fragment>
|
|
31
25
|
{children}
|
|
32
26
|
{toolbar === true ? (
|
|
@@ -39,8 +33,8 @@ const Section = ({ children, content, title, subheader, secondary, toolbar, ...g
|
|
|
39
33
|
</Fragment>
|
|
40
34
|
</MainCard>
|
|
41
35
|
</Grid>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
36
|
+
);
|
|
37
|
+
};
|
|
44
38
|
|
|
45
39
|
Section.defaultProps = {
|
|
46
40
|
...Grid.defaultProps,
|
|
@@ -54,8 +48,8 @@ Section.defaultProps = {
|
|
|
54
48
|
lg: 12,
|
|
55
49
|
md: 12,
|
|
56
50
|
sm: 12,
|
|
57
|
-
xs: 12
|
|
58
|
-
}
|
|
51
|
+
xs: 12
|
|
52
|
+
};
|
|
59
53
|
|
|
60
54
|
Section.propTypes = {
|
|
61
55
|
...Grid.propTypes,
|
|
@@ -66,33 +60,33 @@ Section.propTypes = {
|
|
|
66
60
|
title: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
|
67
61
|
secondary: PropTypes.oneOfType([PropTypes.node, PropTypes.string, PropTypes.object]),
|
|
68
62
|
spacing: PropTypes.number,
|
|
69
|
-
toolbar: PropTypes.oneOfType([PropTypes.node, PropTypes.bool])
|
|
70
|
-
}
|
|
63
|
+
toolbar: PropTypes.oneOfType([PropTypes.node, PropTypes.bool])
|
|
64
|
+
};
|
|
71
65
|
|
|
72
66
|
const StyledForm = styled(Form, {
|
|
73
67
|
name: 'RaApplicaCardForm',
|
|
74
|
-
slot: 'root'
|
|
68
|
+
slot: 'root'
|
|
75
69
|
})(({ theme, spacing }) => ({
|
|
76
70
|
backgroundColor: 'transparent',
|
|
77
71
|
'& .RaToolbar-desktopToolbar': {
|
|
78
72
|
marginTop: theme.spacing(spacing * 2),
|
|
79
|
-
padding: 0
|
|
80
|
-
}
|
|
81
|
-
}))
|
|
73
|
+
padding: 0
|
|
74
|
+
}
|
|
75
|
+
}));
|
|
82
76
|
|
|
83
77
|
/**
|
|
84
78
|
* @see https://mui.com/material-ui/react-stack/
|
|
85
79
|
*/
|
|
86
80
|
const CardForm = ({ children, spacing, defaultValues, ...gridProps }) => {
|
|
87
|
-
const { spacing: themeSpacing } = useThemeConfig()
|
|
81
|
+
const { spacing: themeSpacing } = useThemeConfig();
|
|
88
82
|
return (
|
|
89
83
|
<StyledForm defaultValues={defaultValues} spacing={spacing || themeSpacing}>
|
|
90
84
|
<Grid container {...gridProps} spacing={spacing || themeSpacing}>
|
|
91
85
|
{children}
|
|
92
86
|
</Grid>
|
|
93
87
|
</StyledForm>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
88
|
+
);
|
|
89
|
+
};
|
|
96
90
|
|
|
97
91
|
CardForm.propTypes = {
|
|
98
92
|
...Grid.propTypes,
|
|
@@ -101,13 +95,13 @@ CardForm.propTypes = {
|
|
|
101
95
|
spacing: PropTypes.number,
|
|
102
96
|
defaultValues: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
103
97
|
record: PropTypes.object,
|
|
104
|
-
validate: PropTypes.func
|
|
105
|
-
}
|
|
98
|
+
validate: PropTypes.func
|
|
99
|
+
};
|
|
106
100
|
|
|
107
101
|
CardForm.defaultProps = {
|
|
108
|
-
...Stack.defaultProps
|
|
109
|
-
}
|
|
102
|
+
...Stack.defaultProps
|
|
103
|
+
};
|
|
110
104
|
|
|
111
|
-
CardForm.Section = Section
|
|
105
|
+
CardForm.Section = Section;
|
|
112
106
|
|
|
113
|
-
export default CardForm
|
|
107
|
+
export default CardForm;
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
import { matchPath, useLocation } from 'react-router-dom'
|
|
1
|
+
import { matchPath, useLocation } from 'react-router-dom';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Restituisce il path di base del form in base ad una serie di specifici match di path che è possibile incontrare.
|
|
5
5
|
*/
|
|
6
6
|
const useFormRootPath = (): string => {
|
|
7
|
-
const location = useLocation()
|
|
7
|
+
const location = useLocation();
|
|
8
8
|
// I possibili match sono ordinati per priorità (è fondamentale).
|
|
9
|
-
const allPossibleMatches = [
|
|
10
|
-
'entities/:resource/create/*',
|
|
11
|
-
':resource/create/*',
|
|
12
|
-
'entities/:resource/:id/*',
|
|
13
|
-
':resource/:id/*'
|
|
14
|
-
]
|
|
9
|
+
const allPossibleMatches = ['entities/:resource/create/*', ':resource/create/*', 'entities/:resource/:id/*', ':resource/:id/*'];
|
|
15
10
|
|
|
16
11
|
for (const possibleMatch of allPossibleMatches) {
|
|
17
|
-
const match = matchPath(possibleMatch, location.pathname)
|
|
12
|
+
const match = matchPath(possibleMatch, location.pathname);
|
|
18
13
|
if (match) {
|
|
19
|
-
return match.pathnameBase
|
|
14
|
+
return match.pathnameBase;
|
|
20
15
|
}
|
|
21
16
|
}
|
|
22
17
|
|
|
23
|
-
return ''
|
|
24
|
-
}
|
|
18
|
+
return '';
|
|
19
|
+
};
|
|
25
20
|
|
|
26
|
-
export default useFormRootPath
|
|
21
|
+
export default useFormRootPath;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { TabbedForm as RaTabbedForm } from 'react-admin'
|
|
2
|
-
import { styled } from '@mui/system'
|
|
1
|
+
import { TabbedForm as RaTabbedForm } from 'react-admin';
|
|
2
|
+
import { styled } from '@mui/system';
|
|
3
3
|
|
|
4
4
|
const ApplicaStyledTabbedForm = styled(RaTabbedForm, {
|
|
5
5
|
name: 'RaApplicaTabbedForm',
|
|
6
|
-
slot: 'Root'
|
|
7
|
-
})(() => ({}))
|
|
6
|
+
slot: 'Root'
|
|
7
|
+
})(() => ({}));
|
|
8
8
|
|
|
9
9
|
ApplicaStyledTabbedForm.propTypes = {
|
|
10
|
-
...RaTabbedForm.propTypes
|
|
11
|
-
}
|
|
10
|
+
...RaTabbedForm.propTypes
|
|
11
|
+
};
|
|
12
12
|
|
|
13
13
|
ApplicaStyledTabbedForm.defaultProps = {
|
|
14
|
-
...RaTabbedForm.defaultProps
|
|
15
|
-
}
|
|
14
|
+
...RaTabbedForm.defaultProps
|
|
15
|
+
};
|
|
16
16
|
|
|
17
|
-
ApplicaStyledTabbedForm.Tab = RaTabbedForm.Tab
|
|
17
|
+
ApplicaStyledTabbedForm.Tab = RaTabbedForm.Tab;
|
|
18
18
|
|
|
19
|
-
export default ApplicaStyledTabbedForm
|
|
19
|
+
export default ApplicaStyledTabbedForm;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Toolbar as RaToolbar } from 'react-admin'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { styled } from '@mui/system'
|
|
1
|
+
import { Toolbar as RaToolbar } from 'react-admin';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { styled } from '@mui/system';
|
|
4
4
|
|
|
5
5
|
const ApplicaStyledToolbar = styled(RaToolbar, {
|
|
6
6
|
name: 'RaApplicaToolbar',
|
|
7
|
-
slot: 'Root'
|
|
7
|
+
slot: 'Root'
|
|
8
8
|
})(({ theme }) => ({
|
|
9
9
|
...theme.mixins.toolbar,
|
|
10
10
|
backgroundColor: theme.palette.background.paper,
|
|
@@ -15,22 +15,22 @@ const ApplicaStyledToolbar = styled(RaToolbar, {
|
|
|
15
15
|
justifyContent: 'right',
|
|
16
16
|
paddingBottom: theme.spacing(2),
|
|
17
17
|
'& > *': {
|
|
18
|
-
marginLeft: theme.spacing(1)
|
|
19
|
-
}
|
|
18
|
+
marginLeft: theme.spacing(1)
|
|
19
|
+
}
|
|
20
20
|
},
|
|
21
21
|
'& .MuiButtonBase-root': {
|
|
22
|
-
marginLeft: theme.spacing(1)
|
|
23
|
-
}
|
|
24
|
-
}))
|
|
22
|
+
marginLeft: theme.spacing(1)
|
|
23
|
+
}
|
|
24
|
+
}));
|
|
25
25
|
|
|
26
|
-
const Toolbar = (props) => <ApplicaStyledToolbar {...props}
|
|
26
|
+
const Toolbar = (props) => <ApplicaStyledToolbar {...props} />;
|
|
27
27
|
|
|
28
28
|
Toolbar.defaultProps = {
|
|
29
|
-
...RaToolbar.defaultProps
|
|
30
|
-
}
|
|
29
|
+
...RaToolbar.defaultProps
|
|
30
|
+
};
|
|
31
31
|
|
|
32
32
|
Toolbar.propTypes = {
|
|
33
|
-
...RaToolbar.propTypes
|
|
34
|
-
}
|
|
33
|
+
...RaToolbar.propTypes
|
|
34
|
+
};
|
|
35
35
|
|
|
36
|
-
export default Toolbar
|
|
36
|
+
export default Toolbar;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import CardForm from './CardForm'
|
|
2
|
-
import Edit from './Edit'
|
|
3
|
-
import FormHeader from './FormHeader'
|
|
4
|
-
import LongForm from './LongForm'
|
|
5
|
-
import SimpleForm from './SimpleForm'
|
|
6
|
-
import SimpleFormIterator from './SimpleFormIterator'
|
|
7
|
-
import TabbedForm from './TabbedForm'
|
|
8
|
-
import Toolbar from './Toolbar'
|
|
9
|
-
export { CardForm, Edit, FormHeader, LongForm, SimpleForm, SimpleFormIterator, TabbedForm, Toolbar }
|
|
1
|
+
import CardForm from './CardForm';
|
|
2
|
+
import Edit from './Edit';
|
|
3
|
+
import FormHeader from './FormHeader';
|
|
4
|
+
import LongForm from './LongForm';
|
|
5
|
+
import SimpleForm from './SimpleForm';
|
|
6
|
+
import SimpleFormIterator from './SimpleFormIterator';
|
|
7
|
+
import TabbedForm from './TabbedForm';
|
|
8
|
+
import Toolbar from './Toolbar';
|
|
9
|
+
export { CardForm, Edit, FormHeader, LongForm, SimpleForm, SimpleFormIterator, TabbedForm, Toolbar };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import LabeledInput from './LabeledInput'
|
|
2
|
-
import { AutocompleteArrayInput as RaAutocompleteArrayInput } from 'react-admin'
|
|
3
|
-
import { styled } from '@mui/material/styles'
|
|
1
|
+
import LabeledInput from './LabeledInput';
|
|
2
|
+
import { AutocompleteArrayInput as RaAutocompleteArrayInput } from 'react-admin';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
|
|
5
5
|
const StyledAutocompleteArrayInput = styled(RaAutocompleteArrayInput, {
|
|
6
6
|
name: 'StyledAutocompleteInput',
|
|
@@ -9,17 +9,17 @@ const StyledAutocompleteArrayInput = styled(RaAutocompleteArrayInput, {
|
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
11
|
}
|
|
12
|
-
}))
|
|
12
|
+
}));
|
|
13
13
|
|
|
14
14
|
// eslint-disable-next-line no-unused-vars
|
|
15
15
|
const AutocompleteArrayInput = ({ ...props }) => (
|
|
16
16
|
<LabeledInput {...props}>
|
|
17
17
|
<StyledAutocompleteArrayInput />
|
|
18
18
|
</LabeledInput>
|
|
19
|
-
)
|
|
19
|
+
);
|
|
20
20
|
AutocompleteArrayInput.propTypes = {
|
|
21
21
|
...RaAutocompleteArrayInput.propTypes,
|
|
22
22
|
...LabeledInput.propTypes
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
|
-
export default AutocompleteArrayInput
|
|
25
|
+
export default AutocompleteArrayInput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import LabeledInput from './LabeledInput'
|
|
2
|
-
import { AutocompleteInput as RaAutocompleteInput } from 'react-admin'
|
|
3
|
-
import { styled } from '@mui/material/styles'
|
|
1
|
+
import LabeledInput from './LabeledInput';
|
|
2
|
+
import { AutocompleteInput as RaAutocompleteInput } from 'react-admin';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
|
|
5
5
|
const StyledAutocompleteInput = styled(RaAutocompleteInput, {
|
|
6
6
|
name: 'StyledAutocompleteInput',
|
|
@@ -9,21 +9,21 @@ const StyledAutocompleteInput = styled(RaAutocompleteInput, {
|
|
|
9
9
|
'& legend': {
|
|
10
10
|
width: label === false ? 0 : 'auto'
|
|
11
11
|
}
|
|
12
|
-
}))
|
|
12
|
+
}));
|
|
13
13
|
|
|
14
14
|
const AutocompleteInput = (props) => {
|
|
15
15
|
// Sanitize props removing "perPage":
|
|
16
16
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
17
|
-
const { perPage, ...rest } = props
|
|
17
|
+
const { perPage, ...rest } = props;
|
|
18
18
|
return (
|
|
19
19
|
<LabeledInput {...rest}>
|
|
20
20
|
<StyledAutocompleteInput />
|
|
21
21
|
</LabeledInput>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
24
|
AutocompleteInput.propTypes = {
|
|
25
25
|
...RaAutocompleteInput.propTypes,
|
|
26
26
|
...LabeledInput.propTypes
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
28
|
|
|
29
|
-
export default AutocompleteInput
|
|
29
|
+
export default AutocompleteInput;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { styled, useTheme } from '@mui/material/styles'
|
|
1
|
+
import { styled, useTheme } from '@mui/material/styles';
|
|
2
2
|
|
|
3
|
-
import LabeledInput from './LabeledInput'
|
|
4
|
-
import PropTypes from 'prop-types'
|
|
5
|
-
import { BooleanInput as RaBooleanInput } from 'react-admin'
|
|
3
|
+
import LabeledInput from './LabeledInput';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { BooleanInput as RaBooleanInput } from 'react-admin';
|
|
6
6
|
|
|
7
7
|
const ApplicaStyledBooleanInput = styled(RaBooleanInput, {
|
|
8
8
|
name: 'RaApplicaBooleanInput',
|
|
9
|
-
slot: 'Root'
|
|
10
|
-
})(() => ({}))
|
|
9
|
+
slot: 'Root'
|
|
10
|
+
})(() => ({}));
|
|
11
11
|
|
|
12
12
|
const BooleanInput = ({ horizontal, ...props }) => {
|
|
13
13
|
// eslint-disable-next-line no-unused-vars
|
|
14
|
-
const theme = useTheme()
|
|
14
|
+
const theme = useTheme();
|
|
15
15
|
return (
|
|
16
16
|
<LabeledInput
|
|
17
17
|
{...props}
|
|
@@ -21,34 +21,34 @@ const BooleanInput = ({ horizontal, ...props }) => {
|
|
|
21
21
|
flexDirection: horizontal ? 'row' : 'column',
|
|
22
22
|
alignItems: horizontal ? 'center' : 'flex-start',
|
|
23
23
|
'& .MuiFormGroup-root': {
|
|
24
|
-
margin: 0
|
|
24
|
+
margin: 0
|
|
25
25
|
},
|
|
26
26
|
'& .MuiFormControlLabel-root': {
|
|
27
27
|
margin: 0,
|
|
28
28
|
'& .MuiTypography-root': {
|
|
29
29
|
display: 'none',
|
|
30
|
-
visibility: 'hidden'
|
|
30
|
+
visibility: 'hidden'
|
|
31
31
|
},
|
|
32
32
|
'& .MuiSwitch-root': {
|
|
33
|
-
marginRight: `-${theme.spacing(0.5)}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
33
|
+
marginRight: `-${theme.spacing(0.5)}`
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
: {}
|
|
38
38
|
}
|
|
39
39
|
>
|
|
40
40
|
<ApplicaStyledBooleanInput />
|
|
41
41
|
</LabeledInput>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
44
|
BooleanInput.defaultProps = {
|
|
45
45
|
...RaBooleanInput.defaultProps,
|
|
46
|
-
...LabeledInput.defaultProps
|
|
47
|
-
}
|
|
46
|
+
...LabeledInput.defaultProps
|
|
47
|
+
};
|
|
48
48
|
BooleanInput.propTypes = {
|
|
49
49
|
...RaBooleanInput.propTypes,
|
|
50
50
|
...LabeledInput.propTypes,
|
|
51
|
-
horizontal: PropTypes.bool
|
|
52
|
-
}
|
|
51
|
+
horizontal: PropTypes.bool
|
|
52
|
+
};
|
|
53
53
|
|
|
54
|
-
export default BooleanInput
|
|
54
|
+
export default BooleanInput;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import LabeledInput from './LabeledInput'
|
|
2
|
-
import { DateInput as RaDateInput } from 'react-admin'
|
|
3
|
-
import { styled } from '@mui/material/styles'
|
|
1
|
+
import LabeledInput from './LabeledInput';
|
|
2
|
+
import { DateInput as RaDateInput } from 'react-admin';
|
|
3
|
+
import { styled } from '@mui/material/styles';
|
|
4
4
|
|
|
5
5
|
const StyledDateInput = styled(RaDateInput, {
|
|
6
6
|
name: 'RaApplicaDateInput',
|
|
7
|
-
slot: 'root'
|
|
7
|
+
slot: 'root'
|
|
8
8
|
})(({ label }) => ({
|
|
9
9
|
'& legend': {
|
|
10
|
-
width: label === false ? 0 : 'auto'
|
|
11
|
-
}
|
|
12
|
-
}))
|
|
10
|
+
width: label === false ? 0 : 'auto'
|
|
11
|
+
}
|
|
12
|
+
}));
|
|
13
13
|
|
|
14
14
|
const DateInput = (props) => (
|
|
15
15
|
<LabeledInput {...props}>
|
|
16
16
|
<StyledDateInput />
|
|
17
17
|
</LabeledInput>
|
|
18
|
-
)
|
|
18
|
+
);
|
|
19
19
|
|
|
20
20
|
DateInput.propTypes = {
|
|
21
21
|
...RaDateInput.propTypes,
|
|
22
|
-
...LabeledInput.propTypes
|
|
23
|
-
}
|
|
22
|
+
...LabeledInput.propTypes
|
|
23
|
+
};
|
|
24
24
|
|
|
25
25
|
DateInput.defaultProps = {
|
|
26
26
|
...RaDateInput.defaultProps,
|
|
27
|
-
...LabeledInput.defaultProps
|
|
28
|
-
}
|
|
27
|
+
...LabeledInput.defaultProps
|
|
28
|
+
};
|
|
29
29
|
|
|
30
|
-
export default DateInput
|
|
30
|
+
export default DateInput;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { FileInput as RaFileInput, useRecordContext } from 'react-admin'
|
|
2
|
-
import React, { useMemo } from 'react'
|
|
1
|
+
import { FileInput as RaFileInput, useRecordContext } from 'react-admin';
|
|
2
|
+
import React, { useMemo } from 'react';
|
|
3
3
|
|
|
4
|
-
import { FileField } from '../ra-fields'
|
|
5
|
-
import LabeledInput from './LabeledInput'
|
|
6
|
-
import PropTypes from 'prop-types'
|
|
7
|
-
import { get } from 'lodash'
|
|
8
|
-
import { styled } from '@mui/material/styles'
|
|
9
|
-
import { useWatch } from 'react-hook-form'
|
|
4
|
+
import { FileField } from '../ra-fields';
|
|
5
|
+
import LabeledInput from './LabeledInput';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import { get } from 'lodash';
|
|
8
|
+
import { styled } from '@mui/material/styles';
|
|
9
|
+
import { useWatch } from 'react-hook-form';
|
|
10
10
|
|
|
11
11
|
const StyledFileInput = styled(RaFileInput, {
|
|
12
12
|
name: 'RaApplicaFileInput',
|
|
13
|
-
slot: 'root'
|
|
13
|
+
slot: 'root'
|
|
14
14
|
})(({ theme }) => ({
|
|
15
15
|
'& .previews': {},
|
|
16
16
|
'& .previews>div': {
|
|
@@ -21,16 +21,16 @@ const StyledFileInput = styled(RaFileInput, {
|
|
|
21
21
|
'& button': {
|
|
22
22
|
float: 'right',
|
|
23
23
|
placeItems: 'flex-end',
|
|
24
|
-
verticalAlign: 'middle'
|
|
24
|
+
verticalAlign: 'middle'
|
|
25
25
|
},
|
|
26
26
|
'&:hover': {
|
|
27
|
-
backgroundColor: theme.palette.action.hover
|
|
27
|
+
backgroundColor: theme.palette.action.hover
|
|
28
28
|
},
|
|
29
29
|
'& .MuiLink-root': {
|
|
30
|
-
fontSize: theme.typography.body1.fontSize
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}))
|
|
30
|
+
fontSize: theme.typography.body1.fontSize
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}));
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* FileInput is designed to be used as single input. It does not support multiple files and
|
|
@@ -47,23 +47,23 @@ const StyledFileInput = styled(RaFileInput, {
|
|
|
47
47
|
*
|
|
48
48
|
*/
|
|
49
49
|
const FileInput = ({ children, title, ...props }) => {
|
|
50
|
-
const file = useWatch({ name: props.source })
|
|
51
|
-
const record = useRecordContext(props)
|
|
52
|
-
const { source } = props
|
|
50
|
+
const file = useWatch({ name: props.source });
|
|
51
|
+
const record = useRecordContext(props);
|
|
52
|
+
const { source } = props;
|
|
53
53
|
// Base64 files are persisted with a simple string that contains the temporary filename.
|
|
54
54
|
// Applica Framework add a suffix to the temporary filename that is the original filename.
|
|
55
55
|
// With a little trick we try (because we are not sure that this is true) to get the original filename.
|
|
56
56
|
const filename = useMemo(() => {
|
|
57
57
|
if (file && file?.title) {
|
|
58
|
-
return file?.title
|
|
58
|
+
return file?.title;
|
|
59
59
|
}
|
|
60
|
-
const filename = get(record, source)
|
|
60
|
+
const filename = get(record, source);
|
|
61
61
|
if (filename) {
|
|
62
|
-
const parts = filename.split('__')
|
|
63
|
-
return parts.length > 0 ? parts[parts.length - 1] : filename
|
|
62
|
+
const parts = filename.split('__');
|
|
63
|
+
return parts.length > 0 ? parts[parts.length - 1] : filename;
|
|
64
64
|
}
|
|
65
|
-
return filename
|
|
66
|
-
}, [record, source, file])
|
|
65
|
+
return filename;
|
|
66
|
+
}, [record, source, file]);
|
|
67
67
|
|
|
68
68
|
return (
|
|
69
69
|
<LabeledInput {...props}>
|
|
@@ -76,23 +76,23 @@ const FileInput = ({ children, title, ...props }) => {
|
|
|
76
76
|
...record,
|
|
77
77
|
[source]: file?.title || get(record, source),
|
|
78
78
|
[`_${source}`]: file?.src || get(record, `_${source}`),
|
|
79
|
-
[title || source]: filename
|
|
80
|
-
}
|
|
79
|
+
[title || source]: filename
|
|
80
|
+
}
|
|
81
81
|
})}
|
|
82
82
|
</StyledFileInput>
|
|
83
83
|
</LabeledInput>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
86
|
|
|
87
87
|
FileInput.propTypes = {
|
|
88
88
|
...RaFileInput.propTypes,
|
|
89
89
|
source: PropTypes.string,
|
|
90
90
|
title: PropTypes.string,
|
|
91
|
-
children: PropTypes.node
|
|
92
|
-
}
|
|
91
|
+
children: PropTypes.node
|
|
92
|
+
};
|
|
93
93
|
|
|
94
94
|
FileInput.defaultProps = {
|
|
95
|
-
children: <FileField
|
|
96
|
-
}
|
|
95
|
+
children: <FileField />
|
|
96
|
+
};
|
|
97
97
|
|
|
98
|
-
export default FileInput
|
|
98
|
+
export default FileInput;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { ImageInput as RaImageInput, useRecordContext } from 'react-admin'
|
|
1
|
+
import { ImageInput as RaImageInput, useRecordContext } from 'react-admin';
|
|
2
2
|
|
|
3
|
-
import { CoverField } from '../ra-fields'
|
|
4
|
-
import LabeledInput from './LabeledInput'
|
|
5
|
-
import PropTypes from 'prop-types'
|
|
6
|
-
import React from 'react'
|
|
7
|
-
import { get } from 'lodash'
|
|
8
|
-
import { useWatch } from 'react-hook-form'
|
|
3
|
+
import { CoverField } from '../ra-fields';
|
|
4
|
+
import LabeledInput from './LabeledInput';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { get } from 'lodash';
|
|
8
|
+
import { useWatch } from 'react-hook-form';
|
|
9
9
|
|
|
10
10
|
const ImageInput = ({ children, title, ...props }) => {
|
|
11
|
-
const file = useWatch({ name: props.source })
|
|
12
|
-
const record = useRecordContext(props)
|
|
13
|
-
const { source } = props
|
|
11
|
+
const file = useWatch({ name: props.source });
|
|
12
|
+
const record = useRecordContext(props);
|
|
13
|
+
const { source } = props;
|
|
14
14
|
return (
|
|
15
15
|
<LabeledInput {...props}>
|
|
16
16
|
<RaImageInput accept="image/*">
|
|
@@ -21,24 +21,24 @@ const ImageInput = ({ children, title, ...props }) => {
|
|
|
21
21
|
record: {
|
|
22
22
|
...record,
|
|
23
23
|
[source]: file?.title || get(record, source),
|
|
24
|
-
[`_${source}`]: file?.src || get(record, `_${source}`)
|
|
25
|
-
}
|
|
24
|
+
[`_${source}`]: file?.src || get(record, `_${source}`)
|
|
25
|
+
}
|
|
26
26
|
})}
|
|
27
27
|
</RaImageInput>
|
|
28
28
|
</LabeledInput>
|
|
29
|
-
)
|
|
30
|
-
}
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
31
|
ImageInput.defaultProps = {
|
|
32
32
|
children: <CoverField />,
|
|
33
|
-
multiple: false
|
|
34
|
-
}
|
|
33
|
+
multiple: false
|
|
34
|
+
};
|
|
35
35
|
|
|
36
36
|
ImageInput.propTypes = {
|
|
37
37
|
...RaImageInput.propTypes,
|
|
38
38
|
source: PropTypes.string,
|
|
39
39
|
title: PropTypes.string,
|
|
40
40
|
children: PropTypes.node,
|
|
41
|
-
multiple: PropTypes.bool
|
|
42
|
-
}
|
|
41
|
+
multiple: PropTypes.bool
|
|
42
|
+
};
|
|
43
43
|
|
|
44
|
-
export default ImageInput
|
|
44
|
+
export default ImageInput;
|