UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

45 lines (44 loc) 1.02 kB
"use client"; import { d as c } from "./index.CgTHIF3K.js"; import { useState as u, useEffect as k } from "react"; const i = { base: 0, s: 320, m: 768, l: 1024, xl: 1536 }, a = ["base", "s", "m", "l", "xl"], b = (e) => { let n = "base"; for (const r of a) if (e >= i[r]) n = r; else break; return n; }, l = (e) => e && typeof e == "object" && "base" in e, f = () => { const e = c.c(1), [n, r] = u("base"); let t; e[0] === Symbol.for("react.memo_cache_sentinel") ? (t = [], e[0] = t) : t = e[0], k(() => (o(), window.addEventListener("resize", o), () => window.removeEventListener("resize", o)), t); const o = () => { const s = window.innerWidth; r(b(s)); }; return n; }, B = (e) => { const n = f(); if (e && typeof e != "object" || !l(e)) return e; const r = [...a].reverse(); let t = e.base; for (const o of r) { const s = e[o]; if (s !== void 0 && i[n] >= i[o]) { t = s; break; } } return t; }; export { B as u };