Files
sigpro-ui/components/modal.js
natxocc 59e6d972a8
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
changed to new functions
2026-04-22 12:06:34 +02:00

33 lines
927 B
JavaScript

// components/Modal.js
import { h, watch } from "sigpro";
export const Modal = (props) => {
let dialogRef = null;
watch(() => {
const isOpen = typeof props.open === "function" ? props.open() : props.open;
if (!dialogRef) return;
isOpen ? dialogRef.showModal() : dialogRef.close();
});
const close = () => typeof props.open === "function" && props.open(false);
return h("dialog", {
...props,
ref: el => dialogRef = el,
class: `modal ${props.class ?? ''}`,
onclose: close,
oncancel: close
}, [
h("div", { class: "modal-box" }, [
props.title && h("h3", { class: "text-lg font-bold" }, props.title),
props.children,
h("div", { class: "modal-action" }, [
props.actions || h("button", { class: "btn", onclick: close }, "Cerrar")
])
]),
h("form", { method: "dialog", class: "modal-backdrop" }, [
h("button", {}, "close")
])
]);
};