Files
aurora-admin/site/sources/modal/jsx.txt
T
aurora-admin c65a69c34e
Deploy to GitHub Pages / deploy (push) Failing after 16s
Regression / regression (push) Failing after 15m2s
feat(P4): precompute移植+app.js sources双向回填+回归1003/1003+验收体积/文件/data.json
2026-09-12 14:18:41 +08:00

65 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from 'react';
import './Modal.css';
/**
* Aurora Admin Modal(React)
* 对齐 modal.json 契约:
* - size: small(320) | default(480) | large(680)
* - 遮罩 rgba(0,0,0,0.45),圆角8px,右下角操作按钮(次+主)
* 受控:<Modal open={open} onClose={setOpen} onOk={...} />
*/
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 (
<div className="aa-mask" onClick={handleMask}>
<div className={`aa-modal aa-modal--${size}`} role="dialog" onClick={(e) => e.stopPropagation()}>
<div className="aa-modal__header">
<span>{title}</span>
{closable && (
<button className="aa-modal__close" aria-label="关闭" onClick={() => onClose && onClose()}>✕</button>
)}
</div>
<div className="aa-modal__body">{children}</div>
{!hideFooter && (
<div className="aa-modal__footer">
{footer || (
<>
<button className="btn-base btn-ghost" onClick={() => onClose && onClose()}>{cancelText}</button>
<button className="btn-base btn-primary" onClick={() => onOk && onOk()}>{okText}</button>
</>
)}
</div>
)}
</div>
</div>
);
}
/*
用法示例:
import Modal from './Modal';
const [open, setOpen] = useState(false);
<Modal open={open} title="提示" size="default" onClose={() => setOpen(false)} onOk={handleOk}>
对话框内容...
</Modal>
*/