react-admin-component
Version:
react library
31 lines • 1.9 kB
JavaScript
import * as tslib_1 from "tslib";
import React, { useState, useImperativeHandle } from 'react';
import { Modal } from 'antd';
import classNames from 'classnames';
export var ModalContainer = function (_a, ref) {
var title = _a.title, style = _a.style, className = _a.className, children = _a.children, onOk = _a.onOk, onCancel = _a.onCancel, destroyOnClose = _a.destroyOnClose, forceRender = _a.forceRender, _b = _a.autoClose, autoClose = _b === void 0 ? true : _b, _c = _a.width, width = _c === void 0 ? 946 : _c, _d = _a.maskClosable, maskClosable = _d === void 0 ? false : _d, restProps = tslib_1.__rest(_a, ["title", "style", "className", "children", "onOk", "onCancel", "destroyOnClose", "forceRender", "autoClose", "width", "maskClosable"]);
var _e = useState(false), visible = _e[0], setVisible = _e[1];
useImperativeHandle(ref, function () { return ({
open: function () { return changeModalVisible(true); },
close: function () { return changeModalVisible(false); },
}); });
var handleOk = function () {
onOk && onOk();
autoClose && changeModalVisible(false);
};
var handleCancel = function () {
changeModalVisible(false);
onCancel && onCancel();
};
var changeModalVisible = function (flag) {
if (flag === void 0) { flag = true; }
setVisible(flag);
};
return (React.createElement(Modal, tslib_1.__assign({ onOk: handleOk, onCancel: handleCancel, maskClosable: maskClosable, className: classNames('modal-theme-header', className) }, tslib_1.__assign({ visible: visible,
title: title,
style: style,
destroyOnClose: destroyOnClose,
forceRender: forceRender }, (((style && !style.width) || !style) && { width: width }), restProps)), children));
};
export default React.forwardRef(ModalContainer);
//# sourceMappingURL=index.js.map