UNPKG

@stanfordspezi/spezi-web-design-system

Version:

Stanford Biodesign Digital Health Spezi Web Design System

65 lines (64 loc) 1.98 kB
import { jsx as e, jsxs as a } from "react/jsx-runtime"; import { useEffect as v } from "react"; import { B as i } from "./Button-nH76KtOO.mjs"; import { D as p, c as D, g as N, j as x, e as b, f as w } from "./Dialog-Df-tvqUy.mjs"; import z from "./circle-alert-B9UUgLGa.mjs"; const j = ({ status: o = "idle", proceed: t, reset: n, enableBeforeUnload: d = !1, shouldBlock: c = !1, title: m = "Leave this page?", description: s = "You have unsaved changes that will be lost.", stayLabel: f = "Stay", leaveLabel: h = "Leave anyway", ...u }) => { const l = d && c; return v(() => { if (!l) return; const r = (g) => { g.preventDefault(); }; return window.addEventListener("beforeunload", r), () => window.removeEventListener("beforeunload", r); }, [l]), /* @__PURE__ */ e( p, { open: o === "blocked", ...u, children: /* @__PURE__ */ a(D, { size: "sm", children: [ /* @__PURE__ */ a(N, { className: "items-center sm:items-start", children: [ /* @__PURE__ */ e("div", { className: "mb-4 size-8 rounded-lg border shadow-xs", children: /* @__PURE__ */ e("div", { className: "flex-center size-full", children: /* @__PURE__ */ e(z, { className: "text-muted-foreground size-4" }) }) }), /* @__PURE__ */ e(x, { children: m }), s && /* @__PURE__ */ e(b, { children: s }) ] }), /* @__PURE__ */ a(w, { className: "gap-4 pt-2", children: [ /* @__PURE__ */ e( i, { onClick: n, variant: "outline", size: "sm", className: "sm:flex-1", children: f } ), /* @__PURE__ */ e( i, { onClick: t, variant: "default", size: "sm", className: "sm:flex-1", children: h } ) ] }) ] }) } ); }; export { j as N };