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