import { FC } from 'react'; import { Box as MUIBox, BoxProps as MUIBoxProps, SxProps, Theme, } from '@mui/material'; type FlexBoxOptionalProps = { row?: boolean; }; type FlexBoxProps = MUIBoxProps & FlexBoxOptionalProps; const FLEX_BOX_DEFAULT_PROPS: Required = { row: false, }; const FlexBox: FC = ({ row: isRow, sx, ...muiBoxRestProps }) => { let rootSxAppend: SxProps = { flexDirection: 'column', }; let notFirstChildSxAppend: SxProps = { marginTop: '1em', }; if (isRow) { rootSxAppend = { alignItems: 'center', flexDirection: 'row', }; notFirstChildSxAppend = { marginLeft: '1em', }; } return ( :not(:first-child)': { ...notFirstChildSxAppend, }, ...sx, }, }} /> ); }; FlexBox.defaultProps = FLEX_BOX_DEFAULT_PROPS; export type { FlexBoxProps }; export default FlexBox;