UNPKG

@lunit/oui

Version:

Lunit Oncology UI components

21 lines (20 loc) 2.17 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { CloseSmall } from '../../icons'; import { Box } from '@mui/material'; import theme from '../../theme'; import { Button } from '../Button'; import { StyledDialog, StyledHeaderBox, StyledDialogTitle, StyledDialogContent, StyledDialogActions, } from './Dialog.styled'; function Dialog({ open, title, icon, closable, isPrompt, cancelText, submitText, onClose, text, children, dialogAction, buttonSize = 'small', loading = false, disableSubmit = false, sx, }) { const handleClose = (event, reason) => { if (onClose) { onClose(event, reason); } }; const displayChildren = !text && !!children; return (_jsxs(StyledDialog, { open: open, onClose: handleClose, displayChildren: displayChildren, isPrompt: isPrompt, sx: sx, className: "customDialog", slotProps: { paper: { className: 'dialogPaper', }, }, children: [_jsxs(StyledHeaderBox, { isPrompt: isPrompt, displayChildren: displayChildren, className: "dialogTitle", children: [_jsx(Box, { children: _jsxs(StyledDialogTitle, { children: [icon && _jsx("div", { className: "dialogIcon", children: icon }), title] }) }), closable && (_jsx(Button, { size: "small", variant: "ghost", label: "", disabled: loading, onClick: (event) => handleClose(event, 'cancel'), icon: _jsx(CloseSmall, { sx: { color: theme.palette.neutralGrey[0] } }) }))] }), !displayChildren && _jsx(StyledDialogContent, { children: text }), displayChildren && (_jsx(StyledDialogContent, { className: "childrenDialog", children: children })), dialogAction && _jsx(StyledDialogActions, { children: dialogAction }), !dialogAction && (cancelText || submitText) && (_jsxs(StyledDialogActions, { children: [cancelText && (_jsx(Button, { label: cancelText, size: buttonSize, disabled: loading, variant: "ghost", onClick: () => handleClose(null, 'cancel') })), submitText && (_jsx(Button, { disabled: disableSubmit || loading, loading: loading, label: submitText, size: buttonSize, sx: loading ? { width: '75px' } : null, onClick: () => handleClose(null, 'submit') }))] }))] })); } export default Dialog;