feat(mui): ConfirmDialog optional children (extra content below message)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from "react";
|
import { useState, type ReactNode } from "react";
|
||||||
import Dialog from "@mui/material/Dialog";
|
import Dialog from "@mui/material/Dialog";
|
||||||
import DialogTitle from "@mui/material/DialogTitle";
|
import DialogTitle from "@mui/material/DialogTitle";
|
||||||
import DialogContent from "@mui/material/DialogContent";
|
import DialogContent from "@mui/material/DialogContent";
|
||||||
@@ -17,6 +17,8 @@ export interface ConfirmDialogProps {
|
|||||||
cancelText?: string;
|
cancelText?: string;
|
||||||
confirmVariant?: "primary" | "danger";
|
confirmVariant?: "primary" | "danger";
|
||||||
loading?: boolean;
|
loading?: boolean;
|
||||||
|
/** Optional extra content rendered below the message (e.g. a checkbox). */
|
||||||
|
children?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Confirmation dialog over MUI Dialog. Preserves the legacy ConfirmModal prop shape. */
|
/** Confirmation dialog over MUI Dialog. Preserves the legacy ConfirmModal prop shape. */
|
||||||
@@ -30,6 +32,7 @@ export default function ConfirmDialog({
|
|||||||
cancelText = "Zrušit",
|
cancelText = "Zrušit",
|
||||||
confirmVariant = "primary",
|
confirmVariant = "primary",
|
||||||
loading = false,
|
loading = false,
|
||||||
|
children,
|
||||||
}: ConfirmDialogProps) {
|
}: ConfirmDialogProps) {
|
||||||
useDialogScrollLock(isOpen);
|
useDialogScrollLock(isOpen);
|
||||||
// Freeze content + label + loading while open, so neither the message NOR the
|
// Freeze content + label + loading while open, so neither the message NOR the
|
||||||
@@ -59,6 +62,7 @@ export default function ConfirmDialog({
|
|||||||
<DialogTitle>{shown.title}</DialogTitle>
|
<DialogTitle>{shown.title}</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText>{shown.message}</DialogContentText>
|
<DialogContentText>{shown.message}</DialogContentText>
|
||||||
|
{children}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions sx={{ px: 3, pb: 2 }}>
|
<DialogActions sx={{ px: 3, pb: 2 }}>
|
||||||
<MuiButton onClick={onClose} color="inherit" disabled={shown.loading}>
|
<MuiButton onClick={onClose} color="inherit" disabled={shown.loading}>
|
||||||
|
|||||||
Reference in New Issue
Block a user