@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,23 @@
|
|
|
1
|
+
import { Create, Edit } from '@applica-software-guru/react-admin'
|
|
2
|
+
import { DeviceForm, DeviceList } from 'components'
|
|
3
|
+
const DeviceCreate = () => (
|
|
4
|
+
<Create>
|
|
5
|
+
<DeviceForm />
|
|
6
|
+
</Create>
|
|
7
|
+
)
|
|
8
|
+
const DeviceEdit = () => (
|
|
9
|
+
<Edit>
|
|
10
|
+
<DeviceForm />
|
|
11
|
+
</Edit>
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const config = {
|
|
15
|
+
list: DeviceList,
|
|
16
|
+
edit: DeviceEdit,
|
|
17
|
+
create: DeviceCreate,
|
|
18
|
+
options: {
|
|
19
|
+
group: 'control-panel'
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default config
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Create, Edit } from '@applica-software-guru/react-admin';
|
|
2
|
+
import { I18nMessageForm, I18nMessageList } from 'components';
|
|
3
|
+
|
|
4
|
+
import { FlagOutlined } from '@ant-design/icons';
|
|
5
|
+
|
|
6
|
+
const MessageCreate = () => (
|
|
7
|
+
<Create>
|
|
8
|
+
<I18nMessageForm />
|
|
9
|
+
</Create>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const MessageEdit = () => (
|
|
13
|
+
<Edit>
|
|
14
|
+
<I18nMessageForm />
|
|
15
|
+
</Edit>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const config = {
|
|
19
|
+
list: I18nMessageList,
|
|
20
|
+
edit: MessageEdit,
|
|
21
|
+
create: MessageCreate,
|
|
22
|
+
options: {
|
|
23
|
+
group: 'control-panel',
|
|
24
|
+
icon: FlagOutlined,
|
|
25
|
+
roles: ['superuser']
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default config;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NotificationList as BaseNotificationList, List } from '@applica-software-guru/react-admin';
|
|
2
|
+
|
|
3
|
+
import { MessageOutlined } from '@ant-design/icons';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
const NotificationList = () => (
|
|
7
|
+
<List>
|
|
8
|
+
<BaseNotificationList />
|
|
9
|
+
</List>
|
|
10
|
+
);
|
|
11
|
+
const config = {
|
|
12
|
+
list: NotificationList,
|
|
13
|
+
options: {
|
|
14
|
+
icon: MessageOutlined,
|
|
15
|
+
group: 'dashboard'
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export default config;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Create, Edit } from '@applica-software-guru/react-admin';
|
|
2
|
+
import { UserForm, UserList } from 'components';
|
|
3
|
+
|
|
4
|
+
import { CONFIGURED_ROLES } from 'config';
|
|
5
|
+
import { UserOutlined } from '@ant-design/icons';
|
|
6
|
+
|
|
7
|
+
const UserCreate = () => (
|
|
8
|
+
<Create>
|
|
9
|
+
<UserForm configuredRoles={CONFIGURED_ROLES} />
|
|
10
|
+
</Create>
|
|
11
|
+
);
|
|
12
|
+
const UserEdit = () => (
|
|
13
|
+
<Edit mutationMode="pessimistic">
|
|
14
|
+
<UserForm configuredRoles={CONFIGURED_ROLES} />
|
|
15
|
+
</Edit>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
const config = {
|
|
19
|
+
list: <UserList configuredRoles={CONFIGURED_ROLES} />,
|
|
20
|
+
edit: UserEdit,
|
|
21
|
+
create: UserCreate,
|
|
22
|
+
options: {
|
|
23
|
+
icon: UserOutlined,
|
|
24
|
+
group: 'control-panel'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default config;
|
package/src/Admin.jsx
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { AdminUI, localStorageStore } from 'react-admin'
|
|
2
|
+
|
|
3
|
+
import AdminContext from './AdminContext'
|
|
4
|
+
|
|
5
|
+
const Admin = (props) => {
|
|
6
|
+
const {
|
|
7
|
+
authProvider,
|
|
8
|
+
catchAll,
|
|
9
|
+
children,
|
|
10
|
+
dashboard,
|
|
11
|
+
dataProvider,
|
|
12
|
+
disableTelemetry,
|
|
13
|
+
history,
|
|
14
|
+
i18nProvider,
|
|
15
|
+
layout,
|
|
16
|
+
loading,
|
|
17
|
+
loginPage,
|
|
18
|
+
authCallbackPage,
|
|
19
|
+
menu, // deprecated, use a custom layout instead
|
|
20
|
+
notification,
|
|
21
|
+
queryClient,
|
|
22
|
+
requireAuth,
|
|
23
|
+
store,
|
|
24
|
+
ready,
|
|
25
|
+
theme,
|
|
26
|
+
title = 'React Admin'
|
|
27
|
+
} = props
|
|
28
|
+
return (
|
|
29
|
+
<AdminContext
|
|
30
|
+
authProvider={authProvider}
|
|
31
|
+
dataProvider={dataProvider}
|
|
32
|
+
i18nProvider={i18nProvider}
|
|
33
|
+
store={store}
|
|
34
|
+
history={history}
|
|
35
|
+
queryClient={queryClient}
|
|
36
|
+
theme={theme}
|
|
37
|
+
>
|
|
38
|
+
<AdminUI
|
|
39
|
+
layout={layout}
|
|
40
|
+
dashboard={dashboard}
|
|
41
|
+
disableTelemetry={disableTelemetry}
|
|
42
|
+
menu={menu}
|
|
43
|
+
catchAll={catchAll}
|
|
44
|
+
title={title}
|
|
45
|
+
loading={loading}
|
|
46
|
+
loginPage={loginPage}
|
|
47
|
+
authCallbackPage={authCallbackPage}
|
|
48
|
+
notification={notification}
|
|
49
|
+
requireAuth={requireAuth}
|
|
50
|
+
ready={ready}
|
|
51
|
+
>
|
|
52
|
+
{children}
|
|
53
|
+
</AdminUI>
|
|
54
|
+
</AdminContext>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
Admin.defaultProps = {
|
|
59
|
+
store: localStorageStore(),
|
|
60
|
+
title: 'Applica Admin'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Admin.propTypes = {
|
|
64
|
+
...AdminUI.propTypes
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export default Admin
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
|
|
3
|
+
import { CoreAdminContext } from 'react-admin'
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
import { ScrollTop } from './components'
|
|
6
|
+
import { ThemeCustomization } from './themes'
|
|
7
|
+
|
|
8
|
+
const AdminContext = ({ children, theme, ...props }) => (
|
|
9
|
+
<CoreAdminContext {...props}>
|
|
10
|
+
<ThemeCustomization themeOverrides={theme}>
|
|
11
|
+
<ScrollTop>{children}</ScrollTop>
|
|
12
|
+
</ThemeCustomization>
|
|
13
|
+
</CoreAdminContext>
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
AdminContext.displayName = 'AdminContext'
|
|
17
|
+
AdminContext.defaultProps = {
|
|
18
|
+
...CoreAdminContext.defaultProps,
|
|
19
|
+
}
|
|
20
|
+
AdminContext.propTypes = {
|
|
21
|
+
...CoreAdminContext.propTypes,
|
|
22
|
+
children: PropTypes.node.isRequired,
|
|
23
|
+
theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default AdminContext
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppConfigProvider,
|
|
3
|
+
MenuConfigProvider,
|
|
4
|
+
MenuPropTypes,
|
|
5
|
+
ThemeConfigProvider
|
|
6
|
+
} from './contexts'
|
|
7
|
+
import { CatchResult, useCliErrorCatcher } from './dev'
|
|
8
|
+
import { Layout, MainIcon, Notification, SmallIcon } from './components'
|
|
9
|
+
import { createI18nProvider, useI18nCatcher, useI18nLanguages } from './i18n'
|
|
10
|
+
|
|
11
|
+
import Admin from './Admin'
|
|
12
|
+
import PropTypes from 'prop-types'
|
|
13
|
+
import { QueryClient } from 'react-query'
|
|
14
|
+
import { useMemo } from 'react'
|
|
15
|
+
|
|
16
|
+
const languageResponseMapper = (response) =>
|
|
17
|
+
response.reduce(
|
|
18
|
+
(messages, message) => ({
|
|
19
|
+
...messages,
|
|
20
|
+
[message.lang]: {
|
|
21
|
+
...(messages[message.lang] || {}),
|
|
22
|
+
[message.code]: message.text
|
|
23
|
+
}
|
|
24
|
+
}),
|
|
25
|
+
{}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const i18nBodyRequestMapper = (locale, message) => ({
|
|
29
|
+
lang: locale,
|
|
30
|
+
code: message,
|
|
31
|
+
text: message
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const queryClient = new QueryClient({
|
|
35
|
+
defaultOptions: {
|
|
36
|
+
queries: {
|
|
37
|
+
refetchOnWindowFocus: false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
const ApplicaAdmin = ({
|
|
43
|
+
theme,
|
|
44
|
+
apiUrl,
|
|
45
|
+
defaultLocale,
|
|
46
|
+
development,
|
|
47
|
+
logoMain,
|
|
48
|
+
logoIcon,
|
|
49
|
+
menu,
|
|
50
|
+
name,
|
|
51
|
+
version,
|
|
52
|
+
dataProvider,
|
|
53
|
+
authProvider,
|
|
54
|
+
notification,
|
|
55
|
+
disableNotification,
|
|
56
|
+
...props
|
|
57
|
+
}) => {
|
|
58
|
+
const languages = useI18nLanguages({
|
|
59
|
+
apiUrl,
|
|
60
|
+
endpoint: '/i18n/messages',
|
|
61
|
+
mapper: languageResponseMapper
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
useI18nCatcher({
|
|
65
|
+
bodyBuilder: i18nBodyRequestMapper,
|
|
66
|
+
apiUrl,
|
|
67
|
+
endpoint: '/i18n/message',
|
|
68
|
+
loading: languages?.loading,
|
|
69
|
+
enabled: development
|
|
70
|
+
})
|
|
71
|
+
useCliErrorCatcher({
|
|
72
|
+
apiUrl,
|
|
73
|
+
endpoint: '/cli/error',
|
|
74
|
+
catcherFn: (error) => {
|
|
75
|
+
var errorMessage = error?.toString()
|
|
76
|
+
var knownErrors = [
|
|
77
|
+
// @see https://github.com/marmelab/react-admin/pull/8884
|
|
78
|
+
'Invalid prop `file` of type `string` supplied to `FileInputPreview`, expected `object`.',
|
|
79
|
+
'Failed prop type: Invalid prop `checked` of type `string` supplied to `ForwardRef(Switch)`, expected `boolean`.',
|
|
80
|
+
'Failed prop type: Invalid prop `checked` of type `string` supplied to `ForwardRef(SwitchBase)`, expected `boolean`.',
|
|
81
|
+
'validateDOMNesting(...): <form> cannot appear as a descendant of <form>.'
|
|
82
|
+
]
|
|
83
|
+
const isKnowBug = knownErrors.some((knownError) => errorMessage?.includes(knownError))
|
|
84
|
+
const result = new CatchResult({
|
|
85
|
+
catch: isKnowBug,
|
|
86
|
+
display: !isKnowBug,
|
|
87
|
+
log: !isKnowBug,
|
|
88
|
+
error
|
|
89
|
+
})
|
|
90
|
+
return result
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const layout = useMemo(
|
|
95
|
+
() => (props) => {
|
|
96
|
+
const _logoMain = name ? <MainIcon title={name} /> : logoMain
|
|
97
|
+
const _logoIcon = name ? <SmallIcon title={name} /> : logoIcon
|
|
98
|
+
return (
|
|
99
|
+
<Layout
|
|
100
|
+
{...props}
|
|
101
|
+
name={name}
|
|
102
|
+
version={version}
|
|
103
|
+
logoMain={_logoMain}
|
|
104
|
+
logoIcon={_logoIcon}
|
|
105
|
+
notification={notification}
|
|
106
|
+
disableNotification={disableNotification}
|
|
107
|
+
/>
|
|
108
|
+
)
|
|
109
|
+
},
|
|
110
|
+
[logoMain, logoIcon, name, version, notification, disableNotification]
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
if (languages?.loading) {
|
|
114
|
+
return null
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const i18nProivder = createI18nProvider({
|
|
118
|
+
languages,
|
|
119
|
+
defaultLocale,
|
|
120
|
+
allowMissing: development
|
|
121
|
+
})
|
|
122
|
+
return (
|
|
123
|
+
<AppConfigProvider>
|
|
124
|
+
<MenuConfigProvider menu={menu}>
|
|
125
|
+
<ThemeConfigProvider>
|
|
126
|
+
<Admin
|
|
127
|
+
theme={theme}
|
|
128
|
+
layout={layout}
|
|
129
|
+
notification={Notification}
|
|
130
|
+
queryClient={queryClient}
|
|
131
|
+
dataProvider={dataProvider}
|
|
132
|
+
authProvider={authProvider}
|
|
133
|
+
i18nProvider={i18nProivder}
|
|
134
|
+
{...props}
|
|
135
|
+
/>
|
|
136
|
+
</ThemeConfigProvider>
|
|
137
|
+
</MenuConfigProvider>
|
|
138
|
+
</AppConfigProvider>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
ApplicaAdmin.defaultProps = {
|
|
143
|
+
...Admin.defaultProps,
|
|
144
|
+
fileFields: [],
|
|
145
|
+
defaultLocale: 'en',
|
|
146
|
+
development: false,
|
|
147
|
+
version: '0.0.0',
|
|
148
|
+
notification: 'entities/notification',
|
|
149
|
+
disableNotification: false
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
ApplicaAdmin.propTypes = {
|
|
153
|
+
...Admin.propTypes,
|
|
154
|
+
/**
|
|
155
|
+
* Eventuali configurazioni aggiuntive da passare al tema.
|
|
156
|
+
*/
|
|
157
|
+
theme: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
|
|
158
|
+
/**
|
|
159
|
+
* URL dell'API da utilizzare nell'applicazione.
|
|
160
|
+
*/
|
|
161
|
+
apiUrl: PropTypes.string.isRequired,
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* La lingua di default da utilizzare nell'applicazione.
|
|
165
|
+
*/
|
|
166
|
+
defaultLocale: PropTypes.string,
|
|
167
|
+
/**
|
|
168
|
+
* Se impostato a true, l'applicazione lavora in modalità sviluppo.
|
|
169
|
+
* In questa modalità, per esempio, l'applicazione è in grando di catturare ed inoltrare al server eventuali messaggi non localizzati.
|
|
170
|
+
*/
|
|
171
|
+
development: PropTypes.bool,
|
|
172
|
+
/**
|
|
173
|
+
* Il logo da visualizzare nella barra laterale quando il menu è espanso lateralmente.
|
|
174
|
+
*/
|
|
175
|
+
logoMain: PropTypes.node,
|
|
176
|
+
/**
|
|
177
|
+
* Eventuale logo da visualizzare nella barra laterale quando il menu è ridotto lateralmente.
|
|
178
|
+
*/
|
|
179
|
+
logoIcon: PropTypes.node,
|
|
180
|
+
/**
|
|
181
|
+
* Configurazione del menu da visualizzare nell'applicazione.
|
|
182
|
+
*/
|
|
183
|
+
menu: PropTypes.arrayOf(MenuPropTypes),
|
|
184
|
+
/**
|
|
185
|
+
* Nome dell'applicazione.
|
|
186
|
+
*/
|
|
187
|
+
name: PropTypes.string,
|
|
188
|
+
/**
|
|
189
|
+
* Versione dell'applicazione.
|
|
190
|
+
*/
|
|
191
|
+
version: PropTypes.string,
|
|
192
|
+
/**
|
|
193
|
+
* Il provider di autenticazione da utilizzare nell'applicazione.
|
|
194
|
+
*/
|
|
195
|
+
authProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
196
|
+
/**
|
|
197
|
+
* Il provider di dati da utilizzare nell'applicazione.
|
|
198
|
+
*/
|
|
199
|
+
dataProvider: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
|
|
200
|
+
/**
|
|
201
|
+
* Indica il nome della risorsa REST da utilizzare per la gestione delle notifiche.
|
|
202
|
+
*/
|
|
203
|
+
notification: PropTypes.string,
|
|
204
|
+
/**
|
|
205
|
+
* Indica se le notifiche devono essere disabilitate.
|
|
206
|
+
*/
|
|
207
|
+
disableNotification: PropTypes.bool
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export default ApplicaAdmin
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import PropTypes from 'prop-types'
|
|
2
|
+
|
|
3
|
+
// third-party
|
|
4
|
+
import { motion, useCycle } from 'framer-motion'
|
|
5
|
+
|
|
6
|
+
// ==============================|| ANIMATION BUTTON ||============================== //
|
|
7
|
+
|
|
8
|
+
export default function AnimateButton({
|
|
9
|
+
children,
|
|
10
|
+
type = 'scale',
|
|
11
|
+
direction = 'right',
|
|
12
|
+
offset = 10,
|
|
13
|
+
scale = {
|
|
14
|
+
hover: 1.05,
|
|
15
|
+
tap: 0.95,
|
|
16
|
+
},
|
|
17
|
+
}) {
|
|
18
|
+
let offset1
|
|
19
|
+
let offset2
|
|
20
|
+
switch (direction) {
|
|
21
|
+
case 'up':
|
|
22
|
+
case 'left':
|
|
23
|
+
offset1 = offset
|
|
24
|
+
offset2 = 0
|
|
25
|
+
break
|
|
26
|
+
case 'right':
|
|
27
|
+
case 'down':
|
|
28
|
+
default:
|
|
29
|
+
offset1 = 0
|
|
30
|
+
offset2 = offset
|
|
31
|
+
break
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const [x, cycleX] = useCycle(offset1, offset2)
|
|
35
|
+
const [y, cycleY] = useCycle(offset1, offset2)
|
|
36
|
+
|
|
37
|
+
switch (type) {
|
|
38
|
+
case 'rotate':
|
|
39
|
+
return (
|
|
40
|
+
<motion.div
|
|
41
|
+
animate={{ rotate: 360 }}
|
|
42
|
+
transition={{
|
|
43
|
+
repeat: Infinity,
|
|
44
|
+
repeatType: 'loop',
|
|
45
|
+
duration: 2,
|
|
46
|
+
repeatDelay: 0,
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</motion.div>
|
|
51
|
+
)
|
|
52
|
+
case 'slide':
|
|
53
|
+
if (direction === 'up' || direction === 'down') {
|
|
54
|
+
return (
|
|
55
|
+
<motion.div
|
|
56
|
+
animate={{ y: y !== undefined ? y : '' }}
|
|
57
|
+
onHoverEnd={() => cycleY()}
|
|
58
|
+
onHoverStart={() => cycleY()}
|
|
59
|
+
>
|
|
60
|
+
{children}
|
|
61
|
+
</motion.div>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
return (
|
|
65
|
+
<motion.div
|
|
66
|
+
animate={{ x: x !== undefined ? x : '' }}
|
|
67
|
+
onHoverEnd={() => cycleX()}
|
|
68
|
+
onHoverStart={() => cycleX()}
|
|
69
|
+
>
|
|
70
|
+
{children}
|
|
71
|
+
</motion.div>
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
case 'scale':
|
|
75
|
+
default:
|
|
76
|
+
if (typeof scale === 'number') {
|
|
77
|
+
scale = {
|
|
78
|
+
hover: scale,
|
|
79
|
+
tap: scale,
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (
|
|
83
|
+
<motion.div whileHover={{ scale: scale?.hover }} whileTap={{ scale: scale?.tap }}>
|
|
84
|
+
{children}
|
|
85
|
+
</motion.div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
AnimateButton.propTypes = {
|
|
91
|
+
children: PropTypes.node,
|
|
92
|
+
offset: PropTypes.number,
|
|
93
|
+
type: PropTypes.oneOf(['slide', 'scale', 'rotate']),
|
|
94
|
+
direction: PropTypes.oneOf(['up', 'down', 'left', 'right']),
|
|
95
|
+
scale: PropTypes.oneOfType([PropTypes.number, PropTypes.object]),
|
|
96
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// material-ui
|
|
2
|
+
import { styled, useTheme } from '@mui/material/styles'
|
|
3
|
+
|
|
4
|
+
import MuiAvatar from '@mui/material/Avatar'
|
|
5
|
+
import PropTypes from 'prop-types'
|
|
6
|
+
// project import
|
|
7
|
+
import getColors from '../../themes/getColors'
|
|
8
|
+
|
|
9
|
+
// ==============================|| AVATAR - COLOR STYLE ||============================== //
|
|
10
|
+
|
|
11
|
+
function getColorStyle({ theme, color, type }) {
|
|
12
|
+
const colors = getColors(theme, color)
|
|
13
|
+
const { lighter, light, main, contrastText } = colors
|
|
14
|
+
|
|
15
|
+
switch (type) {
|
|
16
|
+
case 'filled':
|
|
17
|
+
return {
|
|
18
|
+
color: contrastText,
|
|
19
|
+
backgroundColor: main,
|
|
20
|
+
}
|
|
21
|
+
case 'outlined':
|
|
22
|
+
return {
|
|
23
|
+
color: main,
|
|
24
|
+
border: '1px solid',
|
|
25
|
+
borderColor: main,
|
|
26
|
+
backgroundColor: 'transparent',
|
|
27
|
+
}
|
|
28
|
+
case 'combined':
|
|
29
|
+
return {
|
|
30
|
+
color: main,
|
|
31
|
+
border: '1px solid',
|
|
32
|
+
borderColor: light,
|
|
33
|
+
backgroundColor: lighter,
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
return {
|
|
37
|
+
color: main,
|
|
38
|
+
backgroundColor: lighter,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// ==============================|| AVATAR - SIZE STYLE ||============================== //
|
|
44
|
+
|
|
45
|
+
function getSizeStyle(size) {
|
|
46
|
+
switch (size) {
|
|
47
|
+
case 'badge':
|
|
48
|
+
return {
|
|
49
|
+
border: '2px solid',
|
|
50
|
+
fontSize: '0.675rem',
|
|
51
|
+
width: 20,
|
|
52
|
+
height: 20,
|
|
53
|
+
}
|
|
54
|
+
case 'xs':
|
|
55
|
+
return {
|
|
56
|
+
fontSize: '0.75rem',
|
|
57
|
+
width: 24,
|
|
58
|
+
height: 24,
|
|
59
|
+
}
|
|
60
|
+
case 'sm':
|
|
61
|
+
return {
|
|
62
|
+
fontSize: '0.875rem',
|
|
63
|
+
width: 32,
|
|
64
|
+
height: 32,
|
|
65
|
+
}
|
|
66
|
+
case 'lg':
|
|
67
|
+
return {
|
|
68
|
+
fontSize: '1.2rem',
|
|
69
|
+
width: 52,
|
|
70
|
+
height: 52,
|
|
71
|
+
}
|
|
72
|
+
case 'xl':
|
|
73
|
+
return {
|
|
74
|
+
fontSize: '1.5rem',
|
|
75
|
+
width: 64,
|
|
76
|
+
height: 64,
|
|
77
|
+
}
|
|
78
|
+
case 'md':
|
|
79
|
+
default:
|
|
80
|
+
return {
|
|
81
|
+
fontSize: '1rem',
|
|
82
|
+
width: 40,
|
|
83
|
+
height: 40,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ==============================|| STYLED - AVATAR ||============================== //
|
|
89
|
+
|
|
90
|
+
const AvatarStyle = styled(MuiAvatar, {
|
|
91
|
+
shouldForwardProp: (prop) => prop !== 'color' && prop !== 'type' && prop !== 'size',
|
|
92
|
+
})(({ theme, variant, color, type, size }) => ({
|
|
93
|
+
...getSizeStyle(size),
|
|
94
|
+
...getColorStyle({ variant, theme, color, type }),
|
|
95
|
+
...(size === 'badge' && {
|
|
96
|
+
borderColor: theme.palette.background.default,
|
|
97
|
+
}),
|
|
98
|
+
}))
|
|
99
|
+
|
|
100
|
+
// ==============================|| EXTENDED - AVATAR ||============================== //
|
|
101
|
+
|
|
102
|
+
export default function Avatar({
|
|
103
|
+
variant = 'circular',
|
|
104
|
+
children,
|
|
105
|
+
color = 'primary',
|
|
106
|
+
type,
|
|
107
|
+
size = 'md',
|
|
108
|
+
...others
|
|
109
|
+
}) {
|
|
110
|
+
const theme = useTheme()
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<AvatarStyle variant={variant} theme={theme} color={color} type={type} size={size} {...others}>
|
|
114
|
+
{children}
|
|
115
|
+
</AvatarStyle>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
Avatar.propTypes = {
|
|
120
|
+
children: PropTypes.node,
|
|
121
|
+
color: PropTypes.string,
|
|
122
|
+
type: PropTypes.string,
|
|
123
|
+
size: PropTypes.string,
|
|
124
|
+
variant: PropTypes.string,
|
|
125
|
+
}
|