@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
155 lines (154 loc) • 6.76 kB
JavaScript
"use client";
import { jsxs as U, jsx as i } from "react/jsx-runtime";
import { d as ce } from "./index.CgTHIF3K.js";
import { c as O } from "./index.CEyLAtio.js";
import { forwardRef as ie, useRef as me, useState as pe, useImperativeHandle as de, useEffect as oe } from "react";
import { DSHeading as ue } from "../heading.BXFBZhKv.js";
import { D as he } from "./Icon.CAXZUNWo.js";
import { NumberIndicator as fe } from "../numberindicator.BPWvqr7f.js";
import { g as ee } from "./helpers.CcqWV-wZ.js";
import '../assets/Accordion.DOcfZwq8.css';const _e = "ds-accordion_details_pa5bl_1", ye = "ds-accordion_summary_pa5bl_115", Se = "ds-accordion_summary--utility--m_pa5bl_154", be = "ds-accordion_summary--flush_pa5bl_183", ge = "ds-accordion_summary--small_pa5bl_251", ve = "ds-accordion_summary-content-wrapper_pa5bl_256", Ce = "ds-accordion_summary-content-wrapper--flush_pa5bl_262", We = "ds-accordion_summary-content-wrapper--chevron-left_pa5bl_266", Ne = "ds-accordion_heading-summary-wrapper_pa5bl_271", we = "ds-accordion_heading-summary_pa5bl_271", De = "ds-accordion_hint_pa5bl_281", Oe = "ds-accordion_icon_pa5bl_295", Ee = "ds-accordion_icon--open_pa5bl_306", Fe = "ds-accordion_content-wrapper_pa5bl_318", Ie = "ds-accordion_content-wrapper--flush_pa5bl_324", Ae = "ds-accordion_content-wrapper--small_pa5bl_328", t = {
details: _e,
summary: ye,
summaryUtilityM: Se,
summaryFlush: be,
summarySmall: ge,
summaryContentWrapper: ve,
summaryContentWrapperFlush: Ce,
summaryContentWrapperChevronLeft: We,
headingSummaryWrapper: Ne,
headingSummary: we,
hint: De,
icon: Oe,
iconOpen: Ee,
contentWrapper: Fe,
contentWrapperFlush: Ie,
contentWrapperSmall: Ae
}, Ue = ["medium", "small"], qe = ["left", "right"], Te = ({
children: v,
hint: q,
numberIndicatorValue: e,
summary: s
}) => {
if (!v)
throw new Error(ee("DSAccordion", "The component requires children to be set."));
if (!s)
throw new Error(ee("DSAccordion", "The summary prop is required. Please add the summary prop to the DSAccordion component."));
if (q && e)
throw new Error(ee("DSAccordion", "The hint and numberIndicator props cannot be used together. Please remove either the hint prop or the numberIndicatorValue prop."));
}, Pe = ie((v, q) => {
const e = ce.c(65);
let s, m, a, o, p, r, C, W, N, w;
e[0] !== v ? ({
children: s,
summary: r,
chevronPosition: C,
className: m,
hint: a,
isFlush: W,
isOpen: N,
numberIndicatorValue: o,
size: w,
...p
} = v, e[0] = v, e[1] = s, e[2] = m, e[3] = a, e[4] = o, e[5] = p, e[6] = r, e[7] = C, e[8] = W, e[9] = N, e[10] = w) : (s = e[1], m = e[2], a = e[3], o = e[4], p = e[5], r = e[6], C = e[7], W = e[8], N = e[9], w = e[10]);
const le = C === void 0 ? "right" : C, n = W === void 0 ? !1 : W, c = N === void 0 ? !1 : N, te = w === void 0 ? "medium" : w;
process.env.NODE_ENV !== "production" && Te({
children: s,
hint: a,
numberIndicatorValue: o,
summary: r
});
const l = me(null), [Z, re] = pe(c);
let E;
e[11] === Symbol.for("react.memo_cache_sentinel") ? (E = () => l.current, e[11] = E) : E = e[11], de(q, E);
let F;
e[12] === Symbol.for("react.memo_cache_sentinel") ? (F = () => {
l.current && re(l.current.open);
}, e[12] = F) : F = e[12];
let I;
e[13] !== c ? (I = [c], e[13] = c, e[14] = I) : I = e[14], oe(F, I);
let A, T;
e[15] === Symbol.for("react.memo_cache_sentinel") ? (A = () => {
var ne;
const se = () => {
l.current && re(l.current.open);
};
return (ne = l.current) == null || ne.addEventListener("toggle", se), () => {
var ae;
(ae = l.current) == null || ae.removeEventListener("toggle", se);
};
}, T = [], e[15] = A, e[16] = T) : (A = e[15], T = e[16]), oe(A, T);
let P, x, L;
const D = typeof r == "object" && r !== void 0;
D && ({
headingSize: P,
headingTag: x,
headingText: L
} = r);
let R;
e[17] !== m ? (R = O(t.details, m), e[17] = m, e[18] = R) : R = e[18];
const $ = R, k = te === "small", B = !D;
let j;
e[19] !== n || e[20] !== k || e[21] !== B ? (j = O(t.summary, {
[t.summaryFlush]: n,
[t.summarySmall]: k,
[t.summaryUtilityM]: B
}), e[19] = n, e[20] = k, e[21] = B, e[22] = j) : j = e[22];
const G = j, J = le === "left";
let z;
e[23] !== n || e[24] !== J ? (z = O(t.summaryContentWrapper, {
[t.summaryContentWrapperFlush]: n,
[t.summaryContentWrapperChevronLeft]: J
}), e[23] = n, e[24] = J, e[25] = z) : z = e[25];
const K = z;
let M;
e[26] !== Z ? (M = O(t.icon, {
[t.iconOpen]: Z
}), e[26] = Z, e[27] = M) : M = e[27];
const Q = M, X = te === "small";
let V;
e[28] !== n || e[29] !== X ? (V = O(t.contentWrapper, {
[t.contentWrapperFlush]: n,
[t.contentWrapperSmall]: X
}), e[28] = n, e[29] = X, e[30] = V) : V = e[30];
const Y = V;
let d;
e[31] !== P || e[32] !== x || e[33] !== L || e[34] !== D || e[35] !== r ? (d = D ? /* @__PURE__ */ i(ue, { tag: x, size: P, children: L }) : r, e[31] = P, e[32] = x, e[33] = L, e[34] = D, e[35] = r, e[36] = d) : d = e[36];
let u;
e[37] !== o ? (u = o && /* @__PURE__ */ i("div", { children: /* @__PURE__ */ i(fe, { label: o }) }), e[37] = o, e[38] = u) : u = e[38];
let h;
e[39] !== d || e[40] !== u ? (h = /* @__PURE__ */ U("div", { className: t.headingSummary, children: [
d,
u
] }), e[39] = d, e[40] = u, e[41] = h) : h = e[41];
let f;
e[42] !== a ? (f = a && /* @__PURE__ */ i("div", { className: t.hint, children: a }), e[42] = a, e[43] = f) : f = e[43];
let _;
e[44] !== h || e[45] !== f ? (_ = /* @__PURE__ */ U("div", { className: t.headingSummaryWrapper, children: [
h,
f
] }), e[44] = h, e[45] = f, e[46] = _) : _ = e[46];
let y;
e[47] !== Q ? (y = /* @__PURE__ */ i(he, { name: "chevron-down", "aria-hidden": "true", className: Q }), e[47] = Q, e[48] = y) : y = e[48];
let S;
e[49] !== K || e[50] !== _ || e[51] !== y ? (S = /* @__PURE__ */ U("div", { className: K, children: [
_,
y
] }), e[49] = K, e[50] = _, e[51] = y, e[52] = S) : S = e[52];
let b;
e[53] !== G || e[54] !== S ? (b = /* @__PURE__ */ i("summary", { className: G, children: S }), e[53] = G, e[54] = S, e[55] = b) : b = e[55];
let g;
e[56] !== s || e[57] !== Y ? (g = /* @__PURE__ */ i("div", { className: Y, children: s }), e[56] = s, e[57] = Y, e[58] = g) : g = e[58];
let H;
return e[59] !== $ || e[60] !== c || e[61] !== p || e[62] !== b || e[63] !== g ? (H = /* @__PURE__ */ U("details", { ...p, ref: l, className: $, open: c, children: [
b,
g
] }), e[59] = $, e[60] = c, e[61] = p, e[62] = b, e[63] = g, e[64] = H) : H = e[64], H;
});
Pe.displayName = "DSAccordion";
export {
Ue as A,
qe as C,
Pe as D,
Te as v
};