fix(striker-ui): add dialog with header, add wide option to dialog

main
Tsu-ba-me 1 year ago
parent c05932c261
commit 94db04ede7
  1. 16
      striker-ui/components/ConfirmDialog.tsx
  2. 4
      striker-ui/components/Dialog/Dialog.tsx
  3. 43
      striker-ui/components/Dialog/DialogWithHeader.tsx
  4. 2
      striker-ui/components/Dialog/index.tsx
  5. 12
      striker-ui/components/FormDialog.tsx
  6. 3
      striker-ui/types/ConfirmDialog.d.ts
  7. 24
      striker-ui/types/Dialog.d.ts

@ -10,12 +10,7 @@ import {
useRef, useRef,
} from 'react'; } from 'react';
import { import { DialogActionArea, DialogScrollBox, DialogWithHeader } from './Dialog';
Dialog,
DialogActionArea,
DialogHeader,
DialogScrollBox,
} from './Dialog';
import FlexBox from './FlexBox'; import FlexBox from './FlexBox';
import sxstring from '../lib/sxstring'; import sxstring from '../lib/sxstring';
import { BodyText } from './Text'; import { BodyText } from './Text';
@ -46,6 +41,7 @@ const ConfirmDialog: ForwardRefExoticComponent<
scrollBoxProps, scrollBoxProps,
showClose, showClose,
titleText, titleText,
wide,
// Dependents // Dependents
content = children, content = children,
}, },
@ -77,13 +73,15 @@ const ConfirmDialog: ForwardRefExoticComponent<
); );
return ( return (
<Dialog <DialogWithHeader
dialogProps={dialogProps} dialogProps={dialogProps}
header={titleText}
loading={loading} loading={loading}
openInitially={openInitially} openInitially={openInitially}
ref={dialogRef} ref={dialogRef}
showClose={showClose}
wide={wide}
> >
<DialogHeader showClose={showClose}>{titleText}</DialogHeader>
<FlexBox {...contentContainerProps}> <FlexBox {...contentContainerProps}>
{bodyElement} {bodyElement}
{preActionArea} {preActionArea}
@ -109,7 +107,7 @@ const ConfirmDialog: ForwardRefExoticComponent<
}} }}
/> />
</FlexBox> </FlexBox>
</Dialog> </DialogWithHeader>
); );
}, },
); );

@ -26,6 +26,7 @@ const Dialog: ForwardRefExoticComponent<
dialogProps = {}, dialogProps = {},
loading, loading,
openInitially = false, openInitially = false,
wide,
} = props; } = props;
const { const {
@ -52,10 +53,11 @@ const Dialog: ForwardRefExoticComponent<
const paperSx = useMemo<SxProps<Theme>>( const paperSx = useMemo<SxProps<Theme>>(
() => ({ () => ({
minWidth: wide ? { xs: 'calc(100%)', md: '50em' } : null,
overflow: 'visible', overflow: 'visible',
...externalPaperSx, ...externalPaperSx,
}), }),
[externalPaperSx], [externalPaperSx, wide],
); );
useImperativeHandle( useImperativeHandle(

@ -0,0 +1,43 @@
import {
ForwardRefExoticComponent,
PropsWithChildren,
RefAttributes,
forwardRef,
} from 'react';
import Dialog from './Dialog';
import DialogHeader from './DialogHeader';
const DialogWithHeader: ForwardRefExoticComponent<
PropsWithChildren<DialogWithHeaderProps> &
RefAttributes<DialogForwardedRefContent>
> = forwardRef<DialogForwardedRefContent, DialogWithHeaderProps>(
(props, ref) => {
const {
children,
dialogProps,
header,
loading,
openInitially,
showClose,
wide,
} = props;
return (
<Dialog
dialogProps={dialogProps}
loading={loading}
openInitially={openInitially}
ref={ref}
wide={wide}
>
<DialogHeader showClose={showClose}>{header}</DialogHeader>
{children}
</Dialog>
);
},
);
DialogWithHeader.displayName = 'DialogWithHeader';
export default DialogWithHeader;

@ -2,10 +2,12 @@ import Dialog from './Dialog';
import DialogActionGroup from './DialogActionGroup'; import DialogActionGroup from './DialogActionGroup';
import DialogHeader from './DialogHeader'; import DialogHeader from './DialogHeader';
import DialogScrollBox from './DialogScrollBox'; import DialogScrollBox from './DialogScrollBox';
import DialogWithHeader from './DialogWithHeader';
export { export {
Dialog, Dialog,
DialogActionGroup as DialogActionArea, DialogActionGroup as DialogActionArea,
DialogHeader, DialogHeader,
DialogScrollBox, DialogScrollBox,
DialogWithHeader,
}; };

@ -57,20 +57,12 @@ const FormDialog: ForwardRefExoticComponent<
return ( return (
<ConfirmDialog <ConfirmDialog
dialogProps={{ dialogProps={dialogProps}
...dialogProps,
PaperProps: {
...dialogProps?.PaperProps,
sx: {
minWidth: { xs: '90%', md: '50em' },
...dialogProps?.PaperProps?.sx,
},
},
}}
contentContainerProps={formBodyProps} contentContainerProps={formBodyProps}
proceedButtonProps={{ ...proceedButtonProps, type: 'submit' }} proceedButtonProps={{ ...proceedButtonProps, type: 'submit' }}
scrollContent={scrollContent} scrollContent={scrollContent}
scrollBoxProps={formScrollBoxProps} scrollBoxProps={formScrollBoxProps}
wide
{...restProps} {...restProps}
ref={ref} ref={ref}
> >

@ -19,8 +19,7 @@ type ConfirmDialogOptionalProps = {
scrollBoxProps?: import('@mui/material').BoxProps; scrollBoxProps?: import('@mui/material').BoxProps;
}; };
type ConfirmDialogProps = DialogProps & type ConfirmDialogProps = Omit<DialogWithHeaderProps, 'header'> &
DialogHeaderProps &
ConfirmDialogOptionalProps & { ConfirmDialogOptionalProps & {
actionProceedText: string; actionProceedText: string;
titleText: import('react').ReactNode; titleText: import('react').ReactNode;

@ -7,20 +7,13 @@ type DialogOptionalProps = {
dialogProps?: Partial<import('@mui/material').DialogProps>; dialogProps?: Partial<import('@mui/material').DialogProps>;
loading?: boolean; loading?: boolean;
openInitially?: boolean; openInitially?: boolean;
wide?: boolean;
}; };
type DialogProps = DialogOptionalProps; type DialogProps = DialogOptionalProps;
type DialogForwardedRefContent = DialogContextContent; type DialogForwardedRefContent = DialogContextContent;
/** DialogHeader */
type DialogHeaderOptionalProps = {
showClose?: boolean;
};
type DialogHeaderProps = DialogHeaderOptionalProps;
/** DialogActionGroup */ /** DialogActionGroup */
type ButtonClickEventHandler = Exclude< type ButtonClickEventHandler = Exclude<
@ -41,3 +34,18 @@ type DialogActionGroupOptionalProps = {
}; };
type DialogActionGroupProps = DialogActionGroupOptionalProps; type DialogActionGroupProps = DialogActionGroupOptionalProps;
/** DialogHeader */
type DialogHeaderOptionalProps = {
showClose?: boolean;
};
type DialogHeaderProps = DialogHeaderOptionalProps;
/** DialogWithHeader */
type DialogWithHeaderProps = DialogProps &
DialogHeaderProps & {
header: import('react').ReactNode;
};

Loading…
Cancel
Save