fix(striker-ui): add general loading prop to ConfirmDialog

main
Tsu-ba-me 2 years ago
parent 85dde72db7
commit 952d95feac
  1. 30
      striker-ui/components/ConfirmDialog.tsx
  2. 1
      striker-ui/types/ConfirmDialog.d.ts

@ -43,6 +43,7 @@ const ConfirmDialog = forwardRef<
...restDialogProps
} = {},
formContent: isFormContent,
loading: isLoading = false,
loadingAction: isLoadingAction = false,
onActionAppend,
onCancelAppend,
@ -208,6 +209,29 @@ const ConfirmDialog = forwardRef<
[isScrollContent, scrollBoxSx],
);
const contentAreaElement = useMemo(
() =>
isLoading ? (
<Spinner />
) : (
<>
<Box {...restScrollBoxProps} sx={combinedScrollBoxSx}>
{contentElement}
</Box>
{preActionArea}
{actionAreaElement}
</>
),
[
actionAreaElement,
combinedScrollBoxSx,
contentElement,
isLoading,
preActionArea,
restScrollBoxProps,
],
);
useImperativeHandle(
ref,
() => ({
@ -232,11 +256,7 @@ const ConfirmDialog = forwardRef<
onSubmit={contentContainerSubmitEventHandler}
{...contentContainerProps}
>
<Box {...restScrollBoxProps} sx={combinedScrollBoxSx}>
{contentElement}
</Box>
{preActionArea}
{actionAreaElement}
{contentAreaElement}
</FlexBox>
</MUIDialog>
);

@ -4,6 +4,7 @@ type ConfirmDialogOptionalProps = {
contentContainerProps?: import('../components/FlexBox').FlexBoxProps;
dialogProps?: Partial<import('@mui/material').DialogProps>;
formContent?: boolean;
loading?: boolean;
loadingAction?: boolean;
onActionAppend?: ContainedButtonProps['onClick'];
onProceedAppend?: ContainedButtonProps['onClick'];

Loading…
Cancel
Save