import React from 'react';
import './Modal.css';
/**
* Kole UI Modal(React)
* 对齐 modal.json 契约:
* - size: small(320) | default(480) | large(680)
* - 遮罩 rgba(0,0,0,0.45),圆角8px,右下角操作按钮(次+主)
* 受控:
*/
export default function Modal({
open = false,
title = '',
size = 'default', // small | default | large
closable = true,
maskClosable = true,
hideFooter = false,
cancelText = '取消',
okText = '确定',
onClose,
onOk,
footer,
children
}) {
if (!open) return null;
const handleMask = (e) => {
if (maskClosable && e.target === e.currentTarget) onClose && onClose();
};
return (
e.stopPropagation()}>
{title}
{closable && (
)}
{children}
{!hideFooter && (
{footer || (
<>
>
)}
)}
);
}
/*
用法示例:
import Modal from './Modal';
const [open, setOpen] = useState(false);
setOpen(false)} onOk={handleOk}>
对话框内容...
*/