@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
39 lines (38 loc) • 1.15 kB
JavaScript
"use client";
import l from "react";
const f = (e) => typeof e != "number" || isNaN(e) ? 0 : e / 16, m = (e, t) => `[STIHL Design System] - [${e}]: ${t}`, d = (e, t) => `The "${e}" prop is required. Please add the "${e}" prop to the ${t} component.`, y = (e, t) => e?.closest(t), u = (e, t, a) => {
let r = !1;
const n = {
fn: t,
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any is needed here to allow any React component type to be checked
displayName: t.displayName || t.name
};
return l.Children.forEach(e, (s) => {
if (r || !l.isValidElement(s))
return;
if (s.type === n.fn) {
r = !0;
return;
}
const i = s.type, o = (
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any is needed here to allow any React component type to be checked
i.displayName || i.name
);
if (typeof o == "string" && o === n.displayName) {
r = !0;
return;
}
const p = s.props;
if (a && p.children && u(p.children, n.fn, a)) {
r = !0;
return;
}
}), r;
};
export {
y as a,
u as c,
m as g,
f as p,
d as r
};