@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
193 lines (192 loc) • 7.3 kB
JavaScript
"use client";
import { jsx as k, jsxs as Y } from "react/jsx-runtime";
import { d as U } from "./index.CgTHIF3K.js";
import { isValidElement as z, useState as Z, createContext as A, forwardRef as J, cloneElement as B, useContext as K } from "react";
import { u as R, a as ee, b as te, c as ne, d as se, o as oe, e as L, f as le, F as ce, g as ae, h as re } from "./floating-ui.react.DCyAzlZ4.js";
import { c as H } from "./index.CEyLAtio.js";
import { g as $, c as q } from "./helpers.BbWkXTr3.js";
import { D as ie } from "./Header.um5MlziB.js";
import { a as ue } from "./floating-ui.dom.VgHc0h4l.js";
import '../assets/MegaMenu.DX9gChtY.css';const de = "ds-mega-menu_root_11fw1_1", fe = "ds-mega-menu_content_11fw1_109", me = "ds-mega-menu_content--variant-full_11fw1_134", Me = "ds-mega-menu_backdrop_11fw1_139", I = {
root: de,
content: fe,
contentVariantFull: me,
backdrop: Me
}, ge = 9, he = (s) => {
const t = U.c(17);
let e;
t[0] !== s ? (e = s === void 0 ? {} : s, t[0] = s, t[1] = e) : e = t[1];
const {
initialOpen: n,
isOpen: o,
onOpenChange: l
} = e, r = n === void 0 ? !1 : n, [M, c] = Z(r), a = o ?? M, f = l ?? c;
let g;
t[2] === Symbol.for("react.memo_cache_sentinel") ? (g = [oe(ge)], t[2] = g) : g = t[2];
let C;
t[3] !== a || t[4] !== f ? (C = {
placement: "bottom-start",
open: a,
onOpenChange: f,
whileElementsMounted: ue,
strategy: "absolute",
transform: !1,
middleware: g
}, t[3] = a, t[4] = f, t[5] = C) : C = t[5];
const i = R(C), m = i.context;
let u;
t[6] === Symbol.for("react.memo_cache_sentinel") ? (u = {
enabled: !0
}, t[6] = u) : u = t[6];
const p = ee(m, u), _ = te(m);
let h;
t[7] === Symbol.for("react.memo_cache_sentinel") ? (h = {
role: "menu"
}, t[7] = h) : h = t[7];
const N = ne(m, h);
let d;
t[8] !== p || t[9] !== _ || t[10] !== N ? (d = [p, _, N], t[8] = p, t[9] = _, t[10] = N, t[11] = d) : d = t[11];
const S = se(d);
let E, D;
return t[12] !== i || t[13] !== S || t[14] !== a || t[15] !== f ? (D = {
open: a,
setOpen: f,
...S,
...i
}, t[12] = i, t[13] = S, t[14] = a, t[15] = f, t[16] = D) : D = t[16], E = D, E;
}, pe = (s) => {
if (!z(s))
throw new Error($("DSMegaMenu", "DSMegaMenu.Anchor child must be a valid React element."));
}, Se = ({
hasContent: s,
hasAnchor: t
}) => {
if (!s)
throw new Error($("DSMegaMenu", "A DSMegaMenu must have a <DSMegaMenu.Content> component as a child. Please add it to the children of DSMegaMenu."));
if (!t)
throw new Error($("DSMegaMenu", "A DSMegaMenu must have a <DSMegaMenu.Anchor> component as a child. Please add it to the children of DSMegaMenu."));
}, Q = A(null), W = () => {
const s = K(Q);
if (s == null)
throw new Error($("DSMegaMenu", "Components like DSMegaMenu.Anchor or DSMegaMenu.Content must be wrapped in <DSMegaMenu />."));
return s;
}, j = (s) => {
const t = U.c(9);
let e, n;
t[0] !== s ? ({
children: e,
...n
} = s, t[0] = s, t[1] = e, t[2] = n) : (e = t[1], n = t[2]);
let o;
t[3] !== n ? (o = {
...n
}, t[3] = n, t[4] = o) : o = t[4];
const l = he(o), r = q(e, j.Content), M = q(e, G);
process.env.NODE_ENV !== "production" && Se({
hasContent: r,
hasAnchor: M
});
let c;
return t[5] !== e || t[6] !== l || t[7] !== n ? (c = /* @__PURE__ */ k(Q.Provider, { value: l, ...n, children: e }), t[5] = e, t[6] = l, t[7] = n, t[8] = c) : c = t[8], c;
}, G = J((s, t) => {
const e = U.c(12);
let n, o;
e[0] !== s ? ({
children: n,
...o
} = s, e[0] = s, e[1] = n, e[2] = o) : (n = e[1], o = e[2]), process.env.NODE_ENV !== "production" && pe(n);
const l = W(), r = n.ref;
let M;
e[3] !== r || e[4] !== l.refs.setReference || e[5] !== t ? (M = [l.refs.setReference, t, r], e[3] = r, e[4] = l.refs.setReference, e[5] = t, e[6] = M) : M = e[6];
const c = L(M);
if (z(n)) {
let a;
return e[7] !== n || e[8] !== l || e[9] !== o || e[10] !== c ? (a = B(n, l.getReferenceProps({
ref: c,
...o,
...n.props,
"data-state": l.open ? "open" : "closed"
})), e[7] = n, e[8] = l, e[9] = o, e[10] = c, e[11] = a) : a = e[11], a;
}
});
G.displayName = "DSMegaMenu.Anchor";
const X = J((s, t) => {
const e = U.c(48);
let n, o, l, r;
e[0] !== s ? ({
style: r,
className: o,
children: n,
...l
} = s, e[0] = s, e[1] = n, e[2] = o, e[3] = l, e[4] = r) : (n = e[1], o = e[2], l = e[3], r = e[4]);
const M = W();
let c, a, f, g;
e[5] !== M ? ({
context: c,
floatingStyles: a,
getFloatingProps: f,
...g
} = M, e[5] = M, e[6] = c, e[7] = a, e[8] = f, e[9] = g) : (c = e[6], a = e[7], f = e[8], g = e[9]);
const {
variant: C,
bannerAreaRef: i,
topBarAreaRef: m,
mainNavigationAreaRef: u
} = K(ie);
let p;
e[10] !== t || e[11] !== g.refs.setFloating ? (p = [g.refs.setFloating, t], e[10] = t, e[11] = g.refs.setFloating, e[12] = p) : p = e[12];
const _ = L(p);
let h;
e[13] === Symbol.for("react.memo_cache_sentinel") ? (h = {
duration: {
open: 400,
close: 400
}
}, e[13] = h) : h = e[13];
const {
isMounted: N,
status: d
} = le(c, h);
let S;
e[14] !== o ? (S = H(I.root, o), e[14] = o, e[15] = S) : S = e[15];
const E = S, D = C === "full";
let V;
e[16] !== D ? (V = H(I.content, {
[I.contentVariantFull]: D
}), e[16] = D, e[17] = V) : V = e[17];
const T = V;
if (!N)
return null;
let w;
e[18] !== d ? (w = /* @__PURE__ */ k("div", { className: I.backdrop, "data-status": d }), e[18] = d, e[19] = w) : w = e[19];
let x;
e[20] !== (i == null ? void 0 : i.current) || e[21] !== (u == null ? void 0 : u.current) || e[22] !== (m == null ? void 0 : m.current) ? (x = () => [u == null ? void 0 : u.current, m == null ? void 0 : m.current, i == null ? void 0 : i.current].filter(Boolean), e[20] = i == null ? void 0 : i.current, e[21] = u == null ? void 0 : u.current, e[22] = m == null ? void 0 : m.current, e[23] = x) : x = e[23];
let F;
e[24] !== a || e[25] !== r ? (F = {
...a,
...r
}, e[24] = a, e[25] = r, e[26] = F) : F = e[26];
let O;
e[27] !== f || e[28] !== l ? (O = f(l), e[27] = f, e[28] = l, e[29] = O) : O = e[29];
let v;
e[30] !== n || e[31] !== T || e[32] !== d ? (v = /* @__PURE__ */ k("div", { className: T, "data-status": d, children: n }), e[30] = n, e[31] = T, e[32] = d, e[33] = v) : v = e[33];
let y;
e[34] !== E || e[35] !== _ || e[36] !== d || e[37] !== O || e[38] !== v || e[39] !== F ? (y = /* @__PURE__ */ k("div", { ref: _, style: F, className: E, "data-status": d, ...O, children: v }), e[34] = E, e[35] = _, e[36] = d, e[37] = O, e[38] = v, e[39] = F, e[40] = y) : y = e[40];
let b;
e[41] !== c || e[42] !== y || e[43] !== x ? (b = /* @__PURE__ */ k(ce, { context: c, modal: !1, outsideElementsInert: !0, getInsideElements: x, children: y }), e[41] = c, e[42] = y, e[43] = x, e[44] = b) : b = e[44];
let P;
return e[45] !== b || e[46] !== w ? (P = /* @__PURE__ */ k(ae, { children: /* @__PURE__ */ Y(re, { lockScroll: !0, children: [
w,
b
] }) }), e[45] = b, e[46] = w, e[47] = P) : P = e[47], P;
});
X.displayName = "DSMegaMenu.Content";
j.Anchor = G;
j.Content = X;
j.displayName = "DSMegaMenu";
export {
j as D,
Se as a,
he as u,
pe as v
};