UNPKG

@rtdui/dialogs

Version:

React dialogs base on Rtdui components

45 lines (42 loc) 1.19 kB
'use client'; import { jsx } from 'react/jsx-runtime'; import { forwardRef, useEffect } from 'react'; import { Dialog } from './Dialog.mjs'; import { dialogs } from './dialogs.store.mjs'; const DialogContainer = forwardRef( (props, ref) => { const { dirtyWarningLabel, // 来源于DialogData的类型定义 onOpen, isDirty, content, // 来源于DialogProps的类型定义 dialogId, onClose, ...others } = props; const handleClose = (result) => { if (isDirty) { dialogs.show({ title: "\u63D0\u9192", mode: "confirm", content: dirtyWarningLabel, onClose: (result2) => result2 === "ok" ? dialogs.hide(dialogId) : void 0 }); } else { dialogs.hide(dialogId); onClose?.(result); } }; useEffect(() => { if (typeof onOpen === "function") { onOpen?.(); } }, []); return /* @__PURE__ */ jsx(Dialog, { ref, ...others, onClose: handleClose, dialogId, children: content }); } ); DialogContainer.displayName = "@rtdui/DialogContainer"; export { DialogContainer }; //# sourceMappingURL=DialogContainer.mjs.map