@applica-software-guru/react-admin 1.0.32 → 1.0.34
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/.eslintrc.json +43 -0
- package/.husky/pre-commit +4 -0
- package/.nvmrc +1 -0
- package/.prettierrc +8 -0
- package/bitbucket-pipelines.yml +30 -0
- package/dist/Admin.d.ts +1 -1
- package/dist/ApplicaAdmin.d.ts +3 -3
- package/dist/ApplicaAdmin.d.ts.map +1 -1
- package/dist/components/@extended/AnimateButton.d.ts +5 -5
- package/dist/components/@extended/Avatar.d.ts +3 -3
- package/dist/components/@extended/Breadcrumbs.d.ts +5 -5
- package/dist/components/@extended/Dot.d.ts +1 -1
- package/dist/components/@extended/Tooltip.d.ts +1 -1
- package/dist/components/ActionsMenu.d.ts +1 -1
- package/dist/components/ActionsMenu.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts +1 -1
- package/dist/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.d.ts.map +1 -1
- package/dist/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.d.ts +5 -5
- package/dist/components/Layout/Header/AppBarStyled.d.ts +13 -13
- package/dist/components/Layout/Header/HeaderContent/NotificationItem.d.ts +3 -3
- package/dist/components/Logo.d.ts +2 -2
- package/dist/components/MenuPopover/MenuPopover.d.ts +1 -1
- package/dist/components/Notification.d.ts +5 -1
- package/dist/components/Notification.d.ts.map +1 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts +16 -1
- package/dist/components/ra-buttons/CreateInDialogButton.d.ts.map +1 -1
- package/dist/components/ra-buttons/ImpersonateUserButton.d.ts +1 -1
- package/dist/components/ra-fields/ActionsField.d.ts +1 -1
- package/dist/components/ra-fields/ActionsField.d.ts.map +1 -1
- package/dist/components/ra-fields/AttachmentField.d.ts +19 -1
- package/dist/components/ra-fields/AttachmentField.d.ts.map +1 -1
- package/dist/components/ra-fields/BaseAttachmentField.d.ts +2 -2
- package/dist/components/ra-fields/CoverField.d.ts +19 -1
- package/dist/components/ra-fields/CoverField.d.ts.map +1 -1
- package/dist/components/ra-fields/EmailField.d.ts +12 -1
- package/dist/components/ra-fields/FileField.d.ts +19 -1
- package/dist/components/ra-fields/FileField.d.ts.map +1 -1
- package/dist/components/ra-fields/ImageField.d.ts +15 -1
- package/dist/components/ra-fields/ImageField.d.ts.map +1 -1
- package/dist/components/ra-fields/ReadonlyField.d.ts +1 -1
- package/dist/components/ra-fields/ReferenceManyField.d.ts +32 -2
- package/dist/components/ra-fields/ReferenceManyField.d.ts.map +1 -1
- package/dist/components/ra-forms/Edit.d.ts +24 -1
- package/dist/components/ra-forms/Edit.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormHeader.d.ts +1 -1
- package/dist/components/ra-forms/LongForm/LongFormHeader.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormTab.d.ts +4 -4
- package/dist/components/ra-forms/LongForm/LongFormTab.d.ts.map +1 -1
- package/dist/components/ra-forms/LongForm/LongFormTabs.d.ts +2 -2
- package/dist/components/ra-forms/SimpleForm.d.ts +13 -1
- package/dist/components/ra-forms/SimpleForm.d.ts.map +1 -1
- package/dist/components/ra-forms/TabbedForm.d.ts +9 -1
- package/dist/components/ra-forms/TabbedForm.d.ts.map +1 -1
- package/dist/components/ra-forms/Toolbar.d.ts +5 -1
- package/dist/components/ra-inputs/AttachmentInput.d.ts +20 -1
- package/dist/components/ra-inputs/AttachmentInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts +1 -2
- package/dist/components/ra-inputs/AutocompleteArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/AutocompleteInput.d.ts +1 -2
- package/dist/components/ra-inputs/AutocompleteInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/BooleanInput.d.ts +19 -2
- package/dist/components/ra-inputs/BooleanInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/DateInput.d.ts +11 -1
- package/dist/components/ra-inputs/FileInput.d.ts +21 -1
- package/dist/components/ra-inputs/FileInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/LabeledInput.d.ts +2 -2
- package/dist/components/ra-inputs/NumberInput.d.ts +19 -2
- package/dist/components/ra-inputs/RecordInput.d.ts +1 -1
- package/dist/components/ra-inputs/ReferenceArrayInput.d.ts +25 -2
- package/dist/components/ra-inputs/ReferenceArrayInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceInput.d.ts +26 -2
- package/dist/components/ra-inputs/ReferenceInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts +34 -2
- package/dist/components/ra-inputs/ReferenceManyInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/SelectArrayInput.d.ts +18 -1
- package/dist/components/ra-inputs/SelectInput.d.ts +21 -1
- package/dist/components/ra-inputs/SmartTextInput.d.ts +17 -1
- package/dist/components/ra-inputs/SmartTextInput.d.ts.map +1 -1
- package/dist/components/ra-inputs/TextInput.d.ts +16 -2
- package/dist/components/ra-inputs/TimeInput.d.ts +11 -1
- package/dist/components/ra-lists/Datagrid.d.ts +616 -2
- package/dist/components/ra-lists/List.d.ts +28 -2
- package/dist/contexts/AppConfigContext.d.ts +1 -1
- package/dist/contexts/MenuConfigContext.d.ts +4 -4
- package/dist/dev/useCliErrorCatcher.d.ts +5 -5
- package/dist/hooks/useAppConfig.d.ts +1 -1
- package/dist/hooks/useBreadcrumbs.d.ts +2 -2
- package/dist/hooks/useMenu.d.ts +2 -2
- package/dist/hooks/useMenu.d.ts.map +1 -1
- package/dist/hooks/useMenuConfig.d.ts +2 -2
- package/dist/i18n/createI18nProvider.d.ts +1 -1
- package/dist/i18n/useI18nCatcher.d.ts +4 -4
- package/dist/i18n/useI18nLanguages.d.ts +4 -4
- package/dist/i18n/useI18nProvider.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/react-admin.cjs.js +25 -25
- package/dist/react-admin.es.js +304 -315
- package/dist/react-admin.umd.js +25 -25
- package/dist/themes/overrides/PaginationItem.d.ts +72 -72
- package/jsconfig.json +31 -0
- package/jsconfig.node.json +10 -0
- package/package.json +6 -5
- package/playground/config-overrides.js +31 -0
- package/playground/jsconfig.json +9 -0
- package/playground/package-lock.json +17764 -0
- package/playground/package.json +69 -0
- package/playground/public/favicon-dark.png +0 -0
- package/playground/public/favicon-light.png +0 -0
- package/playground/public/index.html +46 -0
- package/playground/src/App.js +49 -0
- package/playground/src/build.json +1 -0
- package/playground/src/components/index.js +5 -0
- package/playground/src/components/pages/CustomPage.jsx +7 -0
- package/playground/src/components/pages/index.jsx +2 -0
- package/playground/src/components/ra-buttons/index.js +1 -0
- package/playground/src/components/ra-fields/UserPictureField.js +20 -0
- package/playground/src/components/ra-fields/index.js +2 -0
- package/playground/src/components/ra-forms/DeviceForm.js +36 -0
- package/playground/src/components/ra-forms/I18nMessageForm.js +24 -0
- package/playground/src/components/ra-forms/UserForm.js +51 -0
- package/playground/src/components/ra-forms/index.js +5 -0
- package/playground/src/components/ra-inputs/LangSelectInput.js +4 -0
- package/playground/src/components/ra-inputs/YesOrNoSelectInput.js +14 -0
- package/playground/src/components/ra-inputs/index.js +3 -0
- package/playground/src/components/ra-lists/DeviceList.js +33 -0
- package/playground/src/components/ra-lists/I18nMessageList.js +20 -0
- package/playground/src/components/ra-lists/UserList.js +96 -0
- package/playground/src/components/ra-lists/index.js +4 -0
- package/playground/src/config.js +19 -0
- package/playground/src/contexts/index.js +1 -0
- package/playground/src/hooks/index.js +1 -0
- package/playground/src/index.js +10 -0
- package/playground/src/menu.js +72 -0
- package/playground/src/react-app-env.d.js +1 -0
- package/playground/src/reportWebVitals.js +13 -0
- package/playground/src/resource/device.js +23 -0
- package/playground/src/resource/i18n-message.js +29 -0
- package/playground/src/resource/index.js +4 -0
- package/playground/src/resource/notification.js +18 -0
- package/playground/src/resource/user.js +28 -0
- package/playground/src/theme.js +3 -0
- package/src/Admin.jsx +67 -0
- package/src/AdminContext.jsx +26 -0
- package/src/ApplicaAdmin.jsx +210 -0
- package/src/assets/README.md +7 -0
- package/src/assets/logo-icon.png +0 -0
- package/src/assets/logo-main.png +0 -0
- package/src/components/@extended/AnimateButton.jsx +96 -0
- package/src/components/@extended/Avatar.jsx +125 -0
- package/src/components/@extended/Breadcrumbs.jsx +324 -0
- package/src/components/@extended/Dot.jsx +35 -0
- package/src/components/@extended/IconButton.jsx +166 -0
- package/src/components/@extended/LoadingButton.jsx +228 -0
- package/src/components/@extended/Tooltip.jsx +67 -0
- package/src/components/@extended/Transitions.jsx +125 -0
- package/src/components/@extended/index.jsx +11 -0
- package/src/components/@extended/progress/CircularWithLabel.jsx +34 -0
- package/src/components/@extended/progress/CircularWithPath.jsx +74 -0
- package/src/components/@extended/progress/LinearWithIcon.jsx +22 -0
- package/src/components/@extended/progress/LinearWithLabel.jsx +23 -0
- package/src/components/@extended/progress/index.jsx +6 -0
- package/src/components/ActionsMenu.jsx +77 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavCollapse.jsx +440 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavGroup.jsx +359 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/NavItem.jsx +259 -0
- package/src/components/Layout/Drawer/DrawerContent/Navigation/index.jsx +73 -0
- package/src/components/Layout/Drawer/DrawerContent/index.jsx +19 -0
- package/src/components/Layout/Drawer/DrawerHeader/DrawerHeaderStyled.jsx +20 -0
- package/src/components/Layout/Drawer/DrawerHeader/index.jsx +44 -0
- package/src/components/Layout/Drawer/HorizontalBar.jsx +55 -0
- package/src/components/Layout/Drawer/MiniDrawerStyled.jsx +47 -0
- package/src/components/Layout/Drawer/index.jsx +63 -0
- package/src/components/Layout/Footer.jsx +23 -0
- package/src/components/Layout/Header/AppBarStyled.jsx +34 -0
- package/src/components/Layout/Header/HeaderContent/MobileSection.jsx +91 -0
- package/src/components/Layout/Header/HeaderContent/Notification.jsx +179 -0
- package/src/components/Layout/Header/HeaderContent/NotificationItem.jsx +109 -0
- package/src/components/Layout/Header/HeaderContent/Profile.jsx +181 -0
- package/src/components/Layout/Header/HeaderContent/index.jsx +38 -0
- package/src/components/Layout/Header/index.jsx +99 -0
- package/src/components/Layout/index.jsx +119 -0
- package/src/components/Loadable.jsx +11 -0
- package/src/components/Loader.jsx +21 -0
- package/src/components/Logo.jsx +29 -0
- package/src/components/MainCard.jsx +111 -0
- package/src/components/MainIcon.jsx +20 -0
- package/src/components/MenuPopover/MenuPopover.jsx +61 -0
- package/src/components/MenuPopover/getPosition.jsx +98 -0
- package/src/components/MenuPopover/index.jsx +3 -0
- package/src/components/MenuPopover/styles.jsx +87 -0
- package/src/components/Notification.jsx +13 -0
- package/src/components/ScrollTop.jsx +24 -0
- package/src/components/ScrollX.jsx +10 -0
- package/src/components/SmallIcon.jsx +14 -0
- package/src/components/index.jsx +36 -0
- package/src/components/ra-buttons/CreateInDialogButton.jsx +203 -0
- package/src/components/ra-buttons/EditInDialogButton.jsx +108 -0
- package/src/components/ra-buttons/ImpersonateUserButton.jsx +41 -0
- package/src/components/ra-buttons/index.jsx +4 -0
- package/src/components/ra-fields/ActionsField.jsx +33 -0
- package/src/components/ra-fields/AttachmentField.jsx +82 -0
- package/src/components/ra-fields/BaseAttachmentField.jsx +72 -0
- package/src/components/ra-fields/CoverField.jsx +83 -0
- package/src/components/ra-fields/DateAgoField.jsx +35 -0
- package/src/components/ra-fields/DateField.jsx +27 -0
- package/src/components/ra-fields/EmailField.jsx +27 -0
- package/src/components/ra-fields/FileField.jsx +40 -0
- package/src/components/ra-fields/FunctionField.jsx +9 -0
- package/src/components/ra-fields/ImageField.jsx +20 -0
- package/src/components/ra-fields/ReadonlyField.jsx +107 -0
- package/src/components/ra-fields/ReferenceManyField.jsx +63 -0
- package/src/components/ra-fields/SizeField.jsx +32 -0
- package/src/components/ra-fields/TextField.jsx +27 -0
- package/src/components/ra-fields/index.jsx +28 -0
- package/src/components/ra-forms/CardForm.jsx +113 -0
- package/src/components/ra-forms/Edit.jsx +13 -0
- package/src/components/ra-forms/FormHeader.jsx +42 -0
- package/src/components/ra-forms/LongForm/DispositionProps.jsx +10 -0
- package/src/components/ra-forms/LongForm/LongForm.jsx +38 -0
- package/src/components/ra-forms/LongForm/LongFormHeader.jsx +24 -0
- package/src/components/ra-forms/LongForm/LongFormTab.jsx +121 -0
- package/src/components/ra-forms/LongForm/LongFormTabs.jsx +63 -0
- package/src/components/ra-forms/LongForm/LongFormView.jsx +129 -0
- package/src/components/ra-forms/LongForm/index.jsx +2 -0
- package/src/components/ra-forms/LongForm/useFormRootPath.jsx +22 -0
- package/src/components/ra-forms/SimpleForm.jsx +69 -0
- package/src/components/ra-forms/TabbedForm.jsx +19 -0
- package/src/components/ra-forms/Toolbar.jsx +36 -0
- package/src/components/ra-forms/index.jsx +8 -0
- package/src/components/ra-inputs/ArrayInput.jsx +29 -0
- package/src/components/ra-inputs/AttachmentInput.jsx +57 -0
- package/src/components/ra-inputs/AutocompleteArrayInput.jsx +25 -0
- package/src/components/ra-inputs/AutocompleteInput.jsx +24 -0
- package/src/components/ra-inputs/BooleanInput.jsx +54 -0
- package/src/components/ra-inputs/DateInput.jsx +30 -0
- package/src/components/ra-inputs/FileInput.jsx +98 -0
- package/src/components/ra-inputs/ImageInput.jsx +44 -0
- package/src/components/ra-inputs/LabeledInput.jsx +80 -0
- package/src/components/ra-inputs/NumberInput.jsx +28 -0
- package/src/components/ra-inputs/RecordInput.jsx +102 -0
- package/src/components/ra-inputs/ReferenceArrayInput.jsx +23 -0
- package/src/components/ra-inputs/ReferenceInput.jsx +23 -0
- package/src/components/ra-inputs/ReferenceManyInput.jsx +44 -0
- package/src/components/ra-inputs/SearchInput.jsx +14 -0
- package/src/components/ra-inputs/SelectArrayInput.jsx +45 -0
- package/src/components/ra-inputs/SelectInput.jsx +24 -0
- package/src/components/ra-inputs/SmartTextInput.jsx +52 -0
- package/src/components/ra-inputs/TextInput.jsx +20 -0
- package/src/components/ra-inputs/TimeInput.jsx +46 -0
- package/src/components/ra-inputs/index.jsx +42 -0
- package/src/components/ra-lists/Datagrid.jsx +42 -0
- package/src/components/ra-lists/Empty.jsx +94 -0
- package/src/components/ra-lists/List.jsx +81 -0
- package/src/components/ra-lists/NotificationList/NotificationList.jsx +41 -0
- package/src/components/ra-lists/NotificationList/button/MarkAsReadedButton.jsx +57 -0
- package/src/components/ra-lists/NotificationList/button/MarkAsUnreadedButton.jsx +56 -0
- package/src/components/ra-lists/NotificationList/button/index.jsx +2 -0
- package/src/components/ra-lists/NotificationList/field/NotificationField.jsx +80 -0
- package/src/components/ra-lists/NotificationList/field/index.jsx +1 -0
- package/src/components/ra-lists/NotificationList/index.jsx +2 -0
- package/src/components/ra-lists/index.jsx +5 -0
- package/src/components/third-party/SimpleBar.jsx +61 -0
- package/src/components/third-party/index.jsx +3 -0
- package/src/contexts/AppConfigContext.jsx +54 -0
- package/src/contexts/MenuConfigContext.jsx +93 -0
- package/src/contexts/MenuPropTypes.jsx +19 -0
- package/src/contexts/ThemeConfigContext.jsx +138 -0
- package/src/contexts/index.jsx +5 -0
- package/src/dev/index.jsx +2 -0
- package/src/dev/useCliErrorCatcher.jsx +86 -0
- package/src/hooks/index.jsx +16 -0
- package/src/hooks/useAppConfig.jsx +6 -0
- package/src/hooks/useBreadcrumbs.jsx +68 -0
- package/src/hooks/useLocalStorage.jsx +31 -0
- package/src/hooks/useMenu.jsx +223 -0
- package/src/hooks/useMenuConfig.jsx +6 -0
- package/src/hooks/useResourceTitle.jsx +25 -0
- package/src/hooks/useThemeConfig.jsx +6 -0
- package/src/i18n/createI18nProvider.jsx +15 -0
- package/src/i18n/index.jsx +4 -0
- package/src/i18n/useI18nCatcher.jsx +71 -0
- package/src/i18n/useI18nLanguages.jsx +22 -0
- package/src/i18n/useI18nProvider.jsx +5 -0
- package/src/index.jsx +67 -0
- package/src/themes/getColors.jsx +18 -0
- package/src/themes/getShadow.jsx +37 -0
- package/src/themes/index.jsx +70 -0
- package/src/themes/overrides/Accordion.jsx +27 -0
- package/src/themes/overrides/AccordionDetails.jsx +14 -0
- package/src/themes/overrides/AccordionSummary.jsx +33 -0
- package/src/themes/overrides/Alert.jsx +72 -0
- package/src/themes/overrides/AlertTitle.jsx +15 -0
- package/src/themes/overrides/Autocomplete.jsx +23 -0
- package/src/themes/overrides/Badge.jsx +36 -0
- package/src/themes/overrides/Button.jsx +229 -0
- package/src/themes/overrides/ButtonBase.jsx +12 -0
- package/src/themes/overrides/ButtonGroup.jsx +11 -0
- package/src/themes/overrides/CardContent.jsx +16 -0
- package/src/themes/overrides/Checkbox.jsx +125 -0
- package/src/themes/overrides/Chip.jsx +75 -0
- package/src/themes/overrides/Dialog.jsx +18 -0
- package/src/themes/overrides/DialogContentText.jsx +14 -0
- package/src/themes/overrides/DialogTitle.jsx +14 -0
- package/src/themes/overrides/Fab.jsx +77 -0
- package/src/themes/overrides/IconButton.jsx +28 -0
- package/src/themes/overrides/InputBase.jsx +13 -0
- package/src/themes/overrides/InputLabel.jsx +25 -0
- package/src/themes/overrides/LinearProgress.jsx +17 -0
- package/src/themes/overrides/Link.jsx +11 -0
- package/src/themes/overrides/ListItemButton.jsx +18 -0
- package/src/themes/overrides/ListItemIcon.jsx +14 -0
- package/src/themes/overrides/LoadingButton.jsx +17 -0
- package/src/themes/overrides/OutlinedInput.jsx +54 -0
- package/src/themes/overrides/Pagination.jsx +11 -0
- package/src/themes/overrides/PaginationItem.jsx +211 -0
- package/src/themes/overrides/Popover.jsx +13 -0
- package/src/themes/overrides/Radio.jsx +121 -0
- package/src/themes/overrides/Slider.jsx +66 -0
- package/src/themes/overrides/Switch.jsx +88 -0
- package/src/themes/overrides/Tab.jsx +24 -0
- package/src/themes/overrides/TableBody.jsx +27 -0
- package/src/themes/overrides/TableCell.jsx +44 -0
- package/src/themes/overrides/TableFooter.jsx +15 -0
- package/src/themes/overrides/TableHead.jsx +15 -0
- package/src/themes/overrides/TablePagination.jsx +16 -0
- package/src/themes/overrides/TableRow.jsx +25 -0
- package/src/themes/overrides/Tabs.jsx +13 -0
- package/src/themes/overrides/ToggleButton.jsx +20 -0
- package/src/themes/overrides/Tooltip.jsx +13 -0
- package/src/themes/overrides/TreeItem.jsx +18 -0
- package/src/themes/overrides/Typography.jsx +13 -0
- package/src/themes/overrides/index.jsx +98 -0
- package/src/themes/palette.jsx +78 -0
- package/src/themes/shadows.jsx +27 -0
- package/src/themes/theme/default.jsx +98 -0
- package/src/themes/theme/index.jsx +44 -0
- package/src/themes/theme/theme1.jsx +128 -0
- package/src/themes/theme/theme2.jsx +128 -0
- package/src/themes/theme/theme3.jsx +128 -0
- package/src/themes/theme/theme4.jsx +128 -0
- package/src/themes/theme/theme5.jsx +128 -0
- package/src/themes/theme/theme6.jsx +128 -0
- package/src/themes/theme/theme7.jsx +128 -0
- package/src/themes/theme/theme8.jsx +128 -0
- package/src/themes/typography.jsx +71 -0
- package/src/utils/index.js +2 -0
- package/src/utils/lang.js +12 -0
- package/src/utils/time.js +13 -0
- package/tsconfig.json +28 -0
- package/vite.config.js +74 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Toolbar as RaToolbar } from 'react-admin'
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { styled } from '@mui/system'
|
|
4
|
+
|
|
5
|
+
const ApplicaStyledToolbar = styled(RaToolbar, {
|
|
6
|
+
name: 'RaApplicaToolbar',
|
|
7
|
+
slot: 'Root',
|
|
8
|
+
})(({ theme }) => ({
|
|
9
|
+
...theme.mixins.toolbar,
|
|
10
|
+
backgroundColor: theme.palette.background.paper,
|
|
11
|
+
justifyContent: 'flex-end',
|
|
12
|
+
// Fix: needed to avoid disalignment with the top content.
|
|
13
|
+
paddingRight: `20px !important`,
|
|
14
|
+
'& .RaToolbar-defaultToolbar': {
|
|
15
|
+
justifyContent: 'right',
|
|
16
|
+
paddingBottom: theme.spacing(2),
|
|
17
|
+
'& > *': {
|
|
18
|
+
marginLeft: theme.spacing(1),
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
'& .MuiButtonBase-root': {
|
|
22
|
+
marginLeft: theme.spacing(1),
|
|
23
|
+
},
|
|
24
|
+
}))
|
|
25
|
+
|
|
26
|
+
const Toolbar = (props) => <ApplicaStyledToolbar {...props} />
|
|
27
|
+
|
|
28
|
+
Toolbar.defaultProps = {
|
|
29
|
+
...RaToolbar.defaultProps,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Toolbar.propTypes = {
|
|
33
|
+
...RaToolbar.propTypes,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Toolbar
|
|
@@ -0,0 +1,8 @@
|
|
|
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 TabbedForm from './TabbedForm'
|
|
7
|
+
import Toolbar from './Toolbar'
|
|
8
|
+
export { CardForm, Edit, FormHeader, LongForm, SimpleForm, TabbedForm, Toolbar }
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { FileInput as RaFileInput, useRecordContext } from 'react-admin'
|
|
2
|
+
|
|
3
|
+
import { AttachmentField } from '../ra-fields'
|
|
4
|
+
import LabeledInput from './LabeledInput'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import { styled } from '@mui/material/styles'
|
|
8
|
+
|
|
9
|
+
const StyledFileInput = styled(RaFileInput, {
|
|
10
|
+
name: 'RaApplicaFileInput',
|
|
11
|
+
slot: 'root',
|
|
12
|
+
})(({ theme }) => ({
|
|
13
|
+
'& .previews': {},
|
|
14
|
+
'& .previews>div': {
|
|
15
|
+
marginTop: theme.spacing(1),
|
|
16
|
+
padding: theme.spacing(1.5),
|
|
17
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
18
|
+
borderRadius: theme.shape.borderRadius,
|
|
19
|
+
'& button': {
|
|
20
|
+
float: 'right',
|
|
21
|
+
placeItems: 'flex-end',
|
|
22
|
+
verticalAlign: 'middle',
|
|
23
|
+
},
|
|
24
|
+
'&:hover': {
|
|
25
|
+
backgroundColor: theme.palette.action.hover,
|
|
26
|
+
},
|
|
27
|
+
'& .MuiLink-root': {
|
|
28
|
+
fontSize: theme.typography.body1.fontSize,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}))
|
|
32
|
+
|
|
33
|
+
const AttachmentInput = ({ children, ...props }) => {
|
|
34
|
+
const record = useRecordContext(props)
|
|
35
|
+
const property = props?.source
|
|
36
|
+
const entityId = record?.id
|
|
37
|
+
return (
|
|
38
|
+
<LabeledInput {...props}>
|
|
39
|
+
<StyledFileInput>
|
|
40
|
+
{React.cloneElement(children, { ...children.props, entityId, property })}
|
|
41
|
+
</StyledFileInput>
|
|
42
|
+
</LabeledInput>
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
AttachmentInput.propTypes = {
|
|
47
|
+
...RaFileInput.propTypes,
|
|
48
|
+
children: PropTypes.node,
|
|
49
|
+
multiple: PropTypes.bool,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
AttachmentInput.defaultProps = {
|
|
53
|
+
children: <AttachmentField title="name" source="path" />,
|
|
54
|
+
multiple: true,
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default AttachmentInput
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { AutocompleteArrayInput as RaAutocompleteArrayInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
|
|
5
|
+
const StyledAutocompleteArrayInput = styled(RaAutocompleteArrayInput, {
|
|
6
|
+
name: 'StyledAutocompleteInput',
|
|
7
|
+
root: 'root'
|
|
8
|
+
})(({ label }) => ({
|
|
9
|
+
'& legend': {
|
|
10
|
+
width: label === false ? 0 : 'auto'
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line no-unused-vars
|
|
15
|
+
const AutocompleteArrayInput = ({ ...props }) => (
|
|
16
|
+
<LabeledInput {...props}>
|
|
17
|
+
<StyledAutocompleteArrayInput />
|
|
18
|
+
</LabeledInput>
|
|
19
|
+
)
|
|
20
|
+
AutocompleteArrayInput.propTypes = {
|
|
21
|
+
...RaAutocompleteArrayInput.propTypes,
|
|
22
|
+
...LabeledInput.propTypes
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default AutocompleteArrayInput
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { AutocompleteInput as RaAutocompleteInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
|
|
5
|
+
const StyledAutocompleteInput = styled(RaAutocompleteInput, {
|
|
6
|
+
name: 'StyledAutocompleteInput',
|
|
7
|
+
root: 'root'
|
|
8
|
+
})(({ label }) => ({
|
|
9
|
+
'& legend': {
|
|
10
|
+
width: label === false ? 0 : 'auto'
|
|
11
|
+
}
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
const AutocompleteInput = ({ ...props }) => (
|
|
15
|
+
<LabeledInput {...props}>
|
|
16
|
+
<StyledAutocompleteInput />
|
|
17
|
+
</LabeledInput>
|
|
18
|
+
)
|
|
19
|
+
AutocompleteInput.propTypes = {
|
|
20
|
+
...RaAutocompleteInput.propTypes,
|
|
21
|
+
...LabeledInput.propTypes
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default AutocompleteInput
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { styled, useTheme } from '@mui/material/styles'
|
|
2
|
+
|
|
3
|
+
import LabeledInput from './LabeledInput'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
import { BooleanInput as RaBooleanInput } from 'react-admin'
|
|
6
|
+
|
|
7
|
+
const ApplicaStyledBooleanInput = styled(RaBooleanInput, {
|
|
8
|
+
name: 'RaApplicaBooleanInput',
|
|
9
|
+
slot: 'Root',
|
|
10
|
+
})(() => ({}))
|
|
11
|
+
|
|
12
|
+
const BooleanInput = ({ horizontal, ...props }) => {
|
|
13
|
+
// eslint-disable-next-line no-unused-vars
|
|
14
|
+
const theme = useTheme()
|
|
15
|
+
return (
|
|
16
|
+
<LabeledInput
|
|
17
|
+
{...props}
|
|
18
|
+
sx={
|
|
19
|
+
horizontal
|
|
20
|
+
? {
|
|
21
|
+
flexDirection: horizontal ? 'row' : 'column',
|
|
22
|
+
alignItems: horizontal ? 'center' : 'flex-start',
|
|
23
|
+
'& .MuiFormGroup-root': {
|
|
24
|
+
margin: 0,
|
|
25
|
+
},
|
|
26
|
+
'& .MuiFormControlLabel-root': {
|
|
27
|
+
margin: 0,
|
|
28
|
+
'& .MuiTypography-root': {
|
|
29
|
+
display: 'none',
|
|
30
|
+
visibility: 'hidden',
|
|
31
|
+
},
|
|
32
|
+
'& .MuiSwitch-root': {
|
|
33
|
+
marginRight: `-${theme.spacing(0.5)}`,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
: {}
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
<ApplicaStyledBooleanInput />
|
|
41
|
+
</LabeledInput>
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
BooleanInput.defaultProps = {
|
|
45
|
+
...RaBooleanInput.defaultProps,
|
|
46
|
+
...LabeledInput.defaultProps,
|
|
47
|
+
}
|
|
48
|
+
BooleanInput.propTypes = {
|
|
49
|
+
...RaBooleanInput.propTypes,
|
|
50
|
+
...LabeledInput.propTypes,
|
|
51
|
+
horizontal: PropTypes.bool,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default BooleanInput
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { DateInput as RaDateInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
|
|
5
|
+
const StyledDateInput = styled(RaDateInput, {
|
|
6
|
+
name: 'RaApplicaDateInput',
|
|
7
|
+
slot: 'root',
|
|
8
|
+
})(({ label }) => ({
|
|
9
|
+
'& legend': {
|
|
10
|
+
width: label === false ? 0 : 'auto',
|
|
11
|
+
},
|
|
12
|
+
}))
|
|
13
|
+
|
|
14
|
+
const DateInput = (props) => (
|
|
15
|
+
<LabeledInput {...props}>
|
|
16
|
+
<StyledDateInput />
|
|
17
|
+
</LabeledInput>
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
DateInput.propTypes = {
|
|
21
|
+
...RaDateInput.propTypes,
|
|
22
|
+
...LabeledInput.propTypes,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
DateInput.defaultProps = {
|
|
26
|
+
...RaDateInput.defaultProps,
|
|
27
|
+
...LabeledInput.defaultProps,
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default DateInput
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { FileInput as RaFileInput, useRecordContext } from 'react-admin'
|
|
2
|
+
import React, { useMemo } from 'react'
|
|
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'
|
|
10
|
+
|
|
11
|
+
const StyledFileInput = styled(RaFileInput, {
|
|
12
|
+
name: 'RaApplicaFileInput',
|
|
13
|
+
slot: 'root',
|
|
14
|
+
})(({ theme }) => ({
|
|
15
|
+
'& .previews': {},
|
|
16
|
+
'& .previews>div': {
|
|
17
|
+
marginTop: theme.spacing(1),
|
|
18
|
+
padding: theme.spacing(1.5),
|
|
19
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
20
|
+
borderRadius: theme.shape.borderRadius,
|
|
21
|
+
'& button': {
|
|
22
|
+
float: 'right',
|
|
23
|
+
placeItems: 'flex-end',
|
|
24
|
+
verticalAlign: 'middle',
|
|
25
|
+
},
|
|
26
|
+
'&:hover': {
|
|
27
|
+
backgroundColor: theme.palette.action.hover,
|
|
28
|
+
},
|
|
29
|
+
'& .MuiLink-root': {
|
|
30
|
+
fontSize: theme.typography.body1.fontSize,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}))
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* FileInput is designed to be used as single input. It does not support multiple files and
|
|
37
|
+
* can be used only for base64 encoded files using applica framework.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // If you hav an object class with @File annotation, you can map it to a FileInput:
|
|
41
|
+
* import { FileInput } from 'ra-ui-applica';
|
|
42
|
+
* ...
|
|
43
|
+
* <FileInput source="file_property" />
|
|
44
|
+
*
|
|
45
|
+
* The component will handle create and delete operations related to the source field associated
|
|
46
|
+
* in conjuction with Applica Framework backend API services.
|
|
47
|
+
*
|
|
48
|
+
*/
|
|
49
|
+
const FileInput = ({ children, title, ...props }) => {
|
|
50
|
+
const file = useWatch({ name: props.source })
|
|
51
|
+
const record = useRecordContext(props)
|
|
52
|
+
const { source } = props
|
|
53
|
+
// Base64 files are persisted with a simple string that contains the temporary filename.
|
|
54
|
+
// Applica Framework add a suffix to the temporary filename that is the original filename.
|
|
55
|
+
// With a little trick we try (because we are not sure that this is true) to get the original filename.
|
|
56
|
+
const filename = useMemo(() => {
|
|
57
|
+
if (file && file?.title) {
|
|
58
|
+
return file?.title
|
|
59
|
+
}
|
|
60
|
+
const filename = get(record, source)
|
|
61
|
+
if (filename) {
|
|
62
|
+
const parts = filename.split('__')
|
|
63
|
+
return parts.length > 0 ? parts[parts.length - 1] : filename
|
|
64
|
+
}
|
|
65
|
+
return filename
|
|
66
|
+
}, [record, source, file])
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<LabeledInput {...props}>
|
|
70
|
+
<StyledFileInput>
|
|
71
|
+
{React.cloneElement(children, {
|
|
72
|
+
...children.props,
|
|
73
|
+
title: title || source,
|
|
74
|
+
source,
|
|
75
|
+
record: {
|
|
76
|
+
...record,
|
|
77
|
+
[source]: file?.title || get(record, source),
|
|
78
|
+
[`_${source}`]: file?.src || get(record, `_${source}`),
|
|
79
|
+
[title || source]: filename,
|
|
80
|
+
},
|
|
81
|
+
})}
|
|
82
|
+
</StyledFileInput>
|
|
83
|
+
</LabeledInput>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
FileInput.propTypes = {
|
|
88
|
+
...RaFileInput.propTypes,
|
|
89
|
+
source: PropTypes.string,
|
|
90
|
+
title: PropTypes.string,
|
|
91
|
+
children: PropTypes.node,
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
FileInput.defaultProps = {
|
|
95
|
+
children: <FileField />,
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default FileInput
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ImageInput as RaImageInput, useRecordContext } from 'react-admin'
|
|
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'
|
|
9
|
+
|
|
10
|
+
const ImageInput = ({ children, title, ...props }) => {
|
|
11
|
+
const file = useWatch({ name: props.source })
|
|
12
|
+
const record = useRecordContext(props)
|
|
13
|
+
const { source } = props
|
|
14
|
+
return (
|
|
15
|
+
<LabeledInput {...props}>
|
|
16
|
+
<RaImageInput accept="image/*">
|
|
17
|
+
{React.cloneElement(children, {
|
|
18
|
+
...children.props,
|
|
19
|
+
title,
|
|
20
|
+
source,
|
|
21
|
+
record: {
|
|
22
|
+
...record,
|
|
23
|
+
[source]: file?.title || get(record, source),
|
|
24
|
+
[`_${source}`]: file?.src || get(record, `_${source}`),
|
|
25
|
+
},
|
|
26
|
+
})}
|
|
27
|
+
</RaImageInput>
|
|
28
|
+
</LabeledInput>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
ImageInput.defaultProps = {
|
|
32
|
+
children: <CoverField />,
|
|
33
|
+
multiple: false,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ImageInput.propTypes = {
|
|
37
|
+
...RaImageInput.propTypes,
|
|
38
|
+
source: PropTypes.string,
|
|
39
|
+
title: PropTypes.string,
|
|
40
|
+
children: PropTypes.node,
|
|
41
|
+
multiple: PropTypes.bool,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default ImageInput
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { FieldTitle, useInput } from 'react-admin'
|
|
2
|
+
import { FormHelperText, InputLabel, Stack } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
import React from 'react'
|
|
6
|
+
import { useAppConfig } from '../../hooks'
|
|
7
|
+
import { useTheme } from '@emotion/react'
|
|
8
|
+
|
|
9
|
+
const LabeledInput = ({ label, children, display, helperText, sx, ...props }) => {
|
|
10
|
+
const theme = useTheme()
|
|
11
|
+
const { getCurrentDialog } = useAppConfig()
|
|
12
|
+
const { source, resource, isRequired } = props
|
|
13
|
+
const {
|
|
14
|
+
fieldState: { invalid },
|
|
15
|
+
} = useInput(props)
|
|
16
|
+
const dialogResource = getCurrentDialog()
|
|
17
|
+
return (
|
|
18
|
+
<Stack
|
|
19
|
+
spacing={1}
|
|
20
|
+
sx={{
|
|
21
|
+
'& .MuiFormHelperText-root': {
|
|
22
|
+
// @see: https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/input/SelectArrayInput.tsx#L340
|
|
23
|
+
// the 'invalid' prop is not used inside the react-admin component. This is necessary if we want to support
|
|
24
|
+
// remove error message colorization when the field is in error state.
|
|
25
|
+
color: invalid ? theme.palette.error.main : theme.palette.text.secondary,
|
|
26
|
+
'& span': {
|
|
27
|
+
display: 'none',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
...sx,
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
{display === 'label' && label !== false && (
|
|
34
|
+
<InputLabel error={invalid === true}>
|
|
35
|
+
<FieldTitle
|
|
36
|
+
label={label}
|
|
37
|
+
source={source}
|
|
38
|
+
resource={dialogResource || resource}
|
|
39
|
+
isRequired={isRequired}
|
|
40
|
+
/>
|
|
41
|
+
</InputLabel>
|
|
42
|
+
)}
|
|
43
|
+
{React.cloneElement(children, {
|
|
44
|
+
...children.props,
|
|
45
|
+
...props,
|
|
46
|
+
label: display === 'legend' ? label : false,
|
|
47
|
+
})}
|
|
48
|
+
{display === 'label' && helperText && (
|
|
49
|
+
<FormHelperText
|
|
50
|
+
sx={{
|
|
51
|
+
pl: 2,
|
|
52
|
+
pb: 2,
|
|
53
|
+
marginTop: '0 !important',
|
|
54
|
+
}}
|
|
55
|
+
error={invalid === true}
|
|
56
|
+
>
|
|
57
|
+
{helperText}
|
|
58
|
+
</FormHelperText>
|
|
59
|
+
)}
|
|
60
|
+
</Stack>
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
LabeledInput.propTypes = {
|
|
65
|
+
sx: PropTypes.object,
|
|
66
|
+
children: PropTypes.element,
|
|
67
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
68
|
+
addLabel: PropTypes.bool,
|
|
69
|
+
resource: PropTypes.string,
|
|
70
|
+
isRequired: PropTypes.bool,
|
|
71
|
+
source: PropTypes.string,
|
|
72
|
+
display: PropTypes.oneOf(['legend', 'label']),
|
|
73
|
+
helperText: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
LabeledInput.defaultProps = {
|
|
77
|
+
display: 'label',
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default LabeledInput
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import LabeledInput from './LabeledInput'
|
|
2
|
+
import { NumberInput as RaNumberInput } from 'react-admin'
|
|
3
|
+
import { styled } from '@mui/material/styles'
|
|
4
|
+
const StyledNumberInput = styled(RaNumberInput, {
|
|
5
|
+
name: 'RaApplicaNumberInput',
|
|
6
|
+
slot: 'root',
|
|
7
|
+
})(({ label }) => ({
|
|
8
|
+
'& legend': {
|
|
9
|
+
width: label === false ? 0 : 'auto',
|
|
10
|
+
},
|
|
11
|
+
}))
|
|
12
|
+
const NumberInput = (props) => (
|
|
13
|
+
<LabeledInput {...props}>
|
|
14
|
+
<StyledNumberInput />
|
|
15
|
+
</LabeledInput>
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
NumberInput.propTypes = {
|
|
19
|
+
...RaNumberInput.propTypes,
|
|
20
|
+
...LabeledInput.propTypes,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
NumberInput.defaultProps = {
|
|
24
|
+
...RaNumberInput.defaultProps,
|
|
25
|
+
...LabeledInput.defaultProps,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default NumberInput
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react'
|
|
2
|
+
import { useDataProvider, useRecordContext, useResourceContext } from 'react-admin'
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
import { TextField } from '@mui/material'
|
|
6
|
+
import { get } from 'lodash'
|
|
7
|
+
|
|
8
|
+
const RecordInput = ({ source, minWidth = 300, children }) => {
|
|
9
|
+
const resource = useResourceContext()
|
|
10
|
+
const record = useRecordContext()
|
|
11
|
+
const [value, setValue] = useState(get(record, source, ''))
|
|
12
|
+
const [updating, setUpdating] = useState(false)
|
|
13
|
+
const handleChange = useCallback((evt) => setValue(evt.target.value), [])
|
|
14
|
+
const dataProvider = useDataProvider()
|
|
15
|
+
|
|
16
|
+
const handleKeyPress = useCallback(
|
|
17
|
+
(evt) => {
|
|
18
|
+
if (evt.key !== 'Enter') {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
setUpdating(true)
|
|
22
|
+
dataProvider
|
|
23
|
+
.update(resource, {
|
|
24
|
+
id: record.id,
|
|
25
|
+
data: {
|
|
26
|
+
...record,
|
|
27
|
+
[source]: value,
|
|
28
|
+
_changed: source,
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
.then(() => setUpdating(false))
|
|
32
|
+
},
|
|
33
|
+
[value, dataProvider, resource, record, source],
|
|
34
|
+
)
|
|
35
|
+
const handleBlur = useCallback(() => {
|
|
36
|
+
const currentValue = get(record, source)
|
|
37
|
+
if (currentValue === value) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
setUpdating(true)
|
|
41
|
+
dataProvider
|
|
42
|
+
.update(resource, {
|
|
43
|
+
id: record.id,
|
|
44
|
+
data: {
|
|
45
|
+
...record,
|
|
46
|
+
[source]: value,
|
|
47
|
+
_changed: source,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
.then(() => setUpdating(false))
|
|
51
|
+
}, [value, dataProvider, resource, source, record])
|
|
52
|
+
|
|
53
|
+
const handleRemoteChange = useCallback(
|
|
54
|
+
(value) => {
|
|
55
|
+
setUpdating(true)
|
|
56
|
+
dataProvider
|
|
57
|
+
.update(resource, {
|
|
58
|
+
id: record.id,
|
|
59
|
+
data: {
|
|
60
|
+
...record,
|
|
61
|
+
[source]: value,
|
|
62
|
+
_changed: source,
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
.then(() => setUpdating(false))
|
|
66
|
+
},
|
|
67
|
+
[dataProvider, resource, source, record],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
useEffect(() => setValue(get(record, source)), [record, source])
|
|
71
|
+
|
|
72
|
+
if (children) {
|
|
73
|
+
return React.cloneElement(children, {
|
|
74
|
+
...children.props,
|
|
75
|
+
source,
|
|
76
|
+
value,
|
|
77
|
+
onChange: handleRemoteChange,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<TextField
|
|
83
|
+
value={value}
|
|
84
|
+
disabled={updating}
|
|
85
|
+
onChange={handleChange}
|
|
86
|
+
onKeyPress={handleKeyPress}
|
|
87
|
+
onBlur={handleBlur}
|
|
88
|
+
style={{ minWidth, width: '100%' }}
|
|
89
|
+
multiline
|
|
90
|
+
InputProps={{ 'arial-label': 'naked' }}
|
|
91
|
+
size="small"
|
|
92
|
+
/>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
RecordInput.propTypes = {
|
|
97
|
+
source: PropTypes.string.isRequired,
|
|
98
|
+
minWidth: PropTypes.number,
|
|
99
|
+
children: PropTypes.element,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default RecordInput
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import { ReferenceArrayInput as RaReferenceArrayInput } from 'react-admin'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const ReferenceArrayInput = ({ children, ...props }) => (
|
|
6
|
+
<RaReferenceArrayInput {...props}>
|
|
7
|
+
{React.cloneElement(children, {
|
|
8
|
+
...props,
|
|
9
|
+
source: children.props.source || props.source,
|
|
10
|
+
})}
|
|
11
|
+
</RaReferenceArrayInput>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
ReferenceArrayInput.propTypes = {
|
|
15
|
+
...RaReferenceArrayInput.propTypes,
|
|
16
|
+
children: PropTypes.element,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ReferenceArrayInput.defaultProps = {
|
|
20
|
+
...RaReferenceArrayInput.defaultProps,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default ReferenceArrayInput
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
import { ReferenceInput as RaReferenceInput } from 'react-admin'
|
|
3
|
+
import React from 'react'
|
|
4
|
+
|
|
5
|
+
const ReferenceInput = ({ children, ...props }) => (
|
|
6
|
+
<RaReferenceInput {...props}>
|
|
7
|
+
{React.cloneElement(children, {
|
|
8
|
+
...props,
|
|
9
|
+
source: children.props.source || props.source,
|
|
10
|
+
})}
|
|
11
|
+
</RaReferenceInput>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
ReferenceInput.propTypes = {
|
|
15
|
+
...RaReferenceInput.propTypes,
|
|
16
|
+
children: PropTypes.element,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
ReferenceInput.defaultProps = {
|
|
20
|
+
...RaReferenceInput.defaultProps,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default ReferenceInput
|