UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

93 lines (86 loc) 2.92 kB
import { T, h } from "./chunk-CRWVV7PH.js"; import { s2 as s } from "./chunk-QEHUZJO2.js"; // node_modules/@headlessui/react/dist/hooks/use-outside-click.js import { useEffect as d3, useRef as f } from "react"; // node_modules/@headlessui/react/dist/hooks/use-document-event.js import { useEffect as m } from "react"; function d(e, r, n2) { let o = s(r); m(() => { function t2(u) { o.current(u); } return document.addEventListener(e, t2, n2), () => document.removeEventListener(e, t2, n2); }, [e, n2]); } // node_modules/@headlessui/react/dist/hooks/use-window-event.js import { useEffect as d2 } from "react"; function s2(e, r, n2) { let o = s(r); d2(() => { function t2(i) { o.current(i); } return window.addEventListener(e, t2, n2), () => window.removeEventListener(e, t2, n2); }, [e, n2]); } // node_modules/@headlessui/react/dist/hooks/use-outside-click.js function h2(s3, m2, a = true) { let i = f(false); d3(() => { requestAnimationFrame(() => { i.current = a; }); }, [a]); function c2(e, r) { if (!i.current || e.defaultPrevented) return; let t2 = r(e); if (t2 === null || !t2.getRootNode().contains(t2) || !t2.isConnected) return; let E = function u(n2) { return typeof n2 == "function" ? u(n2()) : Array.isArray(n2) || n2 instanceof Set ? n2 : [n2]; }(s3); for (let u of E) { if (u === null) continue; let n2 = u instanceof HTMLElement ? u : u.current; if (n2 != null && n2.contains(t2) || e.composed && e.composedPath().includes(n2)) return; } return !h(t2, T.Loose) && t2.tabIndex !== -1 && e.preventDefault(), m2(e, t2); } let o = f(null); d("pointerdown", (e) => { var r, t2; i.current && (o.current = ((t2 = (r = e.composedPath) == null ? void 0 : r.call(e)) == null ? void 0 : t2[0]) || e.target); }, true), d("mousedown", (e) => { var r, t2; i.current && (o.current = ((t2 = (r = e.composedPath) == null ? void 0 : r.call(e)) == null ? void 0 : t2[0]) || e.target); }, true), d("click", (e) => { o.current && (c2(e, () => o.current), o.current = null); }, true), d("touchend", (e) => c2(e, () => e.target instanceof HTMLElement ? e.target : null), true), s2("blur", (e) => c2(e, () => window.document.activeElement instanceof HTMLIFrameElement ? window.document.activeElement : null), true); } // node_modules/@headlessui/react/dist/internal/open-closed.js import l, { createContext as t, useContext as p } from "react"; var n = t(null); n.displayName = "OpenClosedContext"; var d4 = ((e) => (e[e.Open = 1] = "Open", e[e.Closed = 2] = "Closed", e[e.Closing = 4] = "Closing", e[e.Opening = 8] = "Opening", e))(d4 || {}); function C() { return p(n); } function c({ value: o, children: r }) { return l.createElement(n.Provider, { value: o }, r); } export { s2 as s, h2 as h, d4 as d, C, c };