@actinc/dls
Version:
Design Language System (DLS) for ACT & Encoura front-end projects.
36 lines • 2.83 kB
JavaScript
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
* Copyright (c) ACT, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import Button from '@mui/material/Button';
import Dialog from '@mui/material/Dialog';
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import DialogTitle from '@mui/material/DialogTitle';
import noop from 'lodash/noop';
/**
* Main component for a confirmation dialog. This component can be used in isolation by
* controlling the open state property and then listening for the various close events,
* however the simplest usage for this is the use the ConfirmProvider and useConfirm hook
*/
export var ConfirmDialog = function (props) {
var _a = props.isOpen, isOpen = _a === void 0 ? false : _a, onCancel = props.onCancel, onConfirm = props.onConfirm, onClose = props.onClose, _b = props.title, title = _b === void 0 ? 'Confirmation' : _b, description = props.description, content = props.content, _c = props.confirmationText, confirmationText = _c === void 0 ? 'Ok' : _c, _d = props.cancellationText, cancellationText = _d === void 0 ? 'Cancel' : _d, dialogProps = props.dialogProps, confirmationButtonProps = props.confirmationButtonProps, cancellationButtonProps = props.cancellationButtonProps, titleProps = props.titleProps, contentProps = props.contentProps, _e = props.allowClose, allowClose = _e === void 0 ? false : _e;
return (_jsxs(Dialog, __assign({ fullWidth: true }, dialogProps, { onClose: allowClose ? onClose : noop, open: isOpen, children: [title && _jsx(DialogTitle, __assign({}, titleProps, { children: title })), content ? (_jsx(DialogContent, __assign({}, contentProps, { children: content }))) : (description && (_jsx(DialogContent, __assign({}, contentProps, { children: _jsx(DialogContentText, { children: description }) })))), _jsxs(DialogActions, { children: [_jsx(Button, __assign({ color: "secondary", variant: "outlined" }, cancellationButtonProps, { onClick: onCancel, children: cancellationText })), _jsx(Button, __assign({ color: "primary", variant: "contained" }, confirmationButtonProps, { onClick: onConfirm, children: confirmationText }))] })] })));
};
export default ConfirmDialog;
//# sourceMappingURL=ConfirmDialog.js.map