import { ActionsMenu } from '@/components/ActionsMenu'; import { MainCard } from '@/components/MainCard'; import { Toolbar } from '@/components/ra-forms/Toolbar'; import { useResourceTitle } from '@/hooks'; import { Box, useTheme } from '@mui/material'; import { styled } from '@mui/system'; import { PropsWithChildren } from 'react'; import { TabbedForm as RaTabbedForm, TabbedFormProps as RaTabbedFormProps, SaveButton, TabProps } from 'react-admin'; import { DeleteWithConfirmButton } from '@/components/ra-buttons'; type StackTabProps = TabProps & PropsWithChildren>; const StyledTabbedForm = styled(RaTabbedForm, { slot: 'Root' })(({ theme }: { theme: any }) => ({ '& .MuiGrid-root.MuiGrid-container': { paddingBottom: 0 } as any, [theme.breakpoints.down('sm')]: { paddingBottom: 0, '& .MuiTableContainer-root': { paddingBottom: theme.spacing(1) } } })); type TabbedFormWithNoPaddingProps = PropsWithChildren>; function TabbedFormWithNoPadding({ children }: TabbedFormWithNoPaddingProps): JSX.Element { return <>{children}; } function TabbedForm(props: TabbedFormProps): JSX.Element { const { title: _title, modal, content, subheader, secondary = ( ), sx, noPadding, toolbar = ( ), ...rest } = props; const title = useResourceTitle(_title); const theme = useTheme(); return ( .MuiDivider-root': { ml: 2.5, mr: 2.5 }, '& .MuiToolbar-root.RaToolbar-desktopToolbar': { paddingTop: modal ? theme.spacing(2.5) : 0 }, '& .MuiToolbar-root': { padding: theme.spacing(2.5), borderTop: modal ? `1px solid ${theme.palette.divider}` : undefined } }} border={!modal} divider > {/** @ts-ignore */} ); } type TabbedFormProps = RaTabbedFormProps & { modal?: boolean; content?: boolean; subheader?: string | React.ReactNode; title?: string | React.ReactNode | boolean; secondary?: string | React.ReactNode; /** * Indicates if the form should have no padding. * If true, the form will have no padding and you will be **responsible** for adding padding to the form's tabs. */ noPadding?: boolean; }; /** * Useful when you have tabbed form with noPadding and you want to add padding to the tabs. * This component render inside a TabbedForm with noPadding and add padding to the tabs. */ function TabStack({ children, ...props }: StackTabProps): JSX.Element { return ( {children} ); } TabbedForm.Tab = RaTabbedForm.Tab; TabbedForm.TabStack = TabStack; export { TabbedForm }; export type { TabbedFormProps };