docs
This commit is contained in:
20
dist/sigpro-ui.esm.js
vendored
20
dist/sigpro-ui.esm.js
vendored
@@ -1067,19 +1067,21 @@ var MenuModule = /*#__PURE__*/Object.freeze({
|
||||
Menu: Menu
|
||||
});
|
||||
|
||||
/** MODAL (Recommended Method: HTML <dialog>) */
|
||||
/** MODAL REACTIVO NATIVO */
|
||||
const Modal = (props, children) => {
|
||||
const { title, buttons, open, ...rest } = props;
|
||||
const dialogRef = { current: null };
|
||||
|
||||
// Sincronizamos la señal con los métodos nativos del navegador
|
||||
$watch(() => {
|
||||
const el = dialogRef.current;
|
||||
if (!el) return;
|
||||
|
||||
const dialog = dialogRef.current;
|
||||
if (!dialog) return;
|
||||
|
||||
if (open()) {
|
||||
if (!el.open) el.showModal();
|
||||
// Solo abrimos si no está ya abierto (evita bucles)
|
||||
if (!dialog.open) dialog.showModal();
|
||||
} else {
|
||||
if (el.open) el.close();
|
||||
if (dialog.open) dialog.close();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1092,7 +1094,8 @@ const Modal = (props, children) => {
|
||||
...rest,
|
||||
ref: dialogRef,
|
||||
class: "modal",
|
||||
oncancel: close
|
||||
// Importante: Si el usuario pulsa ESC, actualizamos la señal
|
||||
oncancel: () => open(false)
|
||||
}, [
|
||||
$html("div", { class: "modal-box" }, [
|
||||
title ? $html("h3", { class: "text-lg font-bold mb-4" }, title) : null,
|
||||
@@ -1104,12 +1107,13 @@ const Modal = (props, children) => {
|
||||
Button({ type: "button", onclick: close }, tt("close")()),
|
||||
]),
|
||||
]),
|
||||
// Backdrop nativo que sincroniza con la señal
|
||||
$html("form", {
|
||||
method: "dialog",
|
||||
class: "modal-backdrop",
|
||||
onsubmit: close
|
||||
}, [
|
||||
$html("button", { onclick: close }, "close")
|
||||
$html("button", {}, "close")
|
||||
])
|
||||
]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user