@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
46 lines (45 loc) • 943 B
JavaScript
"use client";
import { useState as u } from "react";
import { u as c } from "./useIsomorphicLayoutEffect.CnJ9AMFS.js";
const o = {
base: 0,
s: 320,
m: 768,
l: 1024,
xl: 1536
}, a = ["base", "s", "m", "l", "xl"], k = (e) => {
let n = "base";
for (const t of a)
if (e >= o[t])
n = t;
else
break;
return n;
}, f = (e) => e && typeof e == "object" && "base" in e, b = () => {
const [e, n] = u(void 0);
c(() => (t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t)), []);
const t = () => {
const r = window.innerWidth;
n(k(r));
};
return e;
}, B = (e) => {
const n = b();
if (!n)
return !1;
if (e && typeof e != "object" || !f(e))
return e;
const t = [...a].reverse();
let r = e.base;
for (const s of t) {
const i = e[s];
if (i !== void 0 && o[n] >= o[s]) {
r = i;
break;
}
}
return r;
};
export {
B as u
};