UNPKG

@adyen/adyen-platform-experience-web

Version:

![Platform Experience header](https://github.com/Adyen/adyen-platform-experience-web/assets/7926613/18094965-9e01-450e-8dc9-ea84e6b22c2b)

37 lines (36 loc) 887 B
import { useState as b, useEffect as d } from "../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js"; import p from "../core/Context/preact/useCoreContext.js"; const y = (c) => { const { componentRef: i } = p(), [s, o] = b(0), [f, n, a] = c; let r = !1; switch (f) { case "up": r = s >= n; break; case "down": r = s <= n; break; case "only": if (a) { const { min: e, max: t } = a; r = t ? s <= t : e ? s >= e : !1; } else r = s === n; break; } return d(() => { const e = i(); if (!e) return; o(e.offsetWidth); const t = new ResizeObserver((u) => { for (const m of u) m.target === e && o(e.offsetWidth); }); return t.observe(e), () => { t.unobserve(e), t.disconnect(); }; }, []), r; }; export { y as useContainerQuery };