@stihl-design-system/components
Version:
Welcome to the STIHL Design System react component library.
228 lines (227 loc) • 9.38 kB
JavaScript
"use client";
import { jsxs as K, Fragment as re, jsx as S } from "react/jsx-runtime";
import { d as A } from "./index.cKLI89Eg.js";
import { c as C } from "./index.DQOqod3i.js";
import oe, { isValidElement as te, useRef as le, useEffect as ne, cloneElement as se } from "react";
import { g as ee } from "./helpers.CexwVao7.js";
import '../assets/ActionCard.DeWHOXFn.css';const ie = "ds-action-card_root_wkyrw_1", ce = "ds-action-card_root--elevated_wkyrw_24", de = "ds-action-card_root--clickable_wkyrw_27", me = "ds-action-card_primary-action_wkyrw_36", pe = "ds-action-card_media-wrapper_wkyrw_50", ye = "ds-action-card_header_wkyrw_50", fe = "ds-action-card_footer_wkyrw_50", _e = "ds-action-card_supplementary_wkyrw_50", ue = "ds-action-card_root--horizontal_wkyrw_64", he = "ds-action-card_content_wkyrw_83", Ne = "ds-action-card_content--padding-small_wkyrw_88", be = "ds-action-card_root--horizontal-has-supplementary_wkyrw_96", we = "ds-action-card_root--padding-small_wkyrw_99", ge = "ds-action-card_primary-action-label_wkyrw_179", d = {
root: ie,
rootElevated: ce,
rootClickable: de,
primaryAction: me,
mediaWrapper: pe,
header: ye,
footer: fe,
supplementary: _e,
rootHorizontal: ue,
content: he,
contentPaddingSmall: Ne,
rootHorizontalHasSupplementary: be,
rootPaddingSmall: we,
primaryActionLabel: ge
}, Se = ({
aria: i,
cardElement: e
}) => {
const t = i?.["aria-labelledby"], a = i?.["aria-label"];
if (e) {
if (!t && !a)
throw new Error(ee("DSActionCard", "The 'aria' prop is required and must include either 'aria-labelledby' or 'aria-label'."));
if (t && !e.querySelector("#" + t))
throw new Error(ee("DSActionCard", `The provided 'aria-labelledby' value '${t}' does not match any element ID within the card.`));
}
}, D = (i, e) => {
const t = [];
return oe.Children.forEach(i, (a) => {
if (!te(a))
return;
const o = a.type, r = e, l = r.displayName || r.name, m = o.displayName || o.name;
(a.type === e || m === l) && t.push(a);
}), t;
}, k = (i) => {
const e = A.c(47);
let t, a, o, r, l, m, c, p;
e[0] !== i ? ({
aria: t,
className: o,
classNameContentWrapper: r,
children: a,
orientation: m,
padding: c,
variant: p,
...l
} = i, e[0] = i, e[1] = t, e[2] = a, e[3] = o, e[4] = r, e[5] = l, e[6] = m, e[7] = c, e[8] = p) : (t = e[1], a = e[2], o = e[3], r = e[4], l = e[5], m = e[6], c = e[7], p = e[8]);
const h = m === void 0 ? "vertical" : m, y = c === void 0 ? "medium" : c, b = p === void 0 ? "outlined" : p, N = le(null);
let f;
e[9] !== a ? (f = D(a, Q), e[9] = a, e[10] = f) : f = e[10];
const w = f;
let _;
e[11] !== a ? (_ = D(a, U), e[11] = a, e[12] = _) : _ = e[12];
const u = _;
let n;
e[13] !== a ? (n = D(a, Y), e[13] = a, e[14] = n) : n = e[14];
const s = n;
let g;
e[15] !== a ? (g = D(a, X), e[15] = a, e[16] = g) : g = e[16];
const E = g;
let P;
e[17] !== a ? (P = D(a, Z), e[17] = a, e[18] = P) : P = e[18];
const H = P, F = H.length > 0, M = h === "horizontal", W = y === "small", R = h === "horizontal" && s.length > 0, j = b === "elevated";
let z;
e[19] !== o || e[20] !== F || e[21] !== W || e[22] !== R || e[23] !== j || e[24] !== M ? (z = C(d.root, o, {
[d.rootHorizontal]: M,
[d.rootPaddingSmall]: W,
[d.rootHorizontalHasSupplementary]: R,
[d.rootClickable]: F,
[d.rootElevated]: j
}), e[19] = o, e[20] = F, e[21] = W, e[22] = R, e[23] = j, e[24] = M, e[25] = z) : z = e[25];
const q = z, O = y === "small";
let L;
e[26] !== r || e[27] !== O ? (L = C(d.content, r, {
[d.contentPaddingSmall]: O
}), e[26] = r, e[27] = O, e[28] = L) : L = e[28];
const V = L;
let $;
e[29] !== t ? ($ = () => {
const ae = N.current;
process.env.NODE_ENV !== "production" && Se({
aria: t,
cardElement: ae
});
}, e[29] = t, e[30] = $) : $ = e[30];
const B = t?.["aria-labelledby"], I = t?.["aria-label"];
let T;
e[31] !== B || e[32] !== I ? (T = [B, I], e[31] = B, e[32] = I, e[33] = T) : T = e[33], ne($, T);
const G = t?.["aria-labelledby"], J = t?.["aria-label"];
let v;
e[34] !== V || e[35] !== u || e[36] !== w ? (v = /* @__PURE__ */ K("div", { className: V, children: [
w,
u
] }), e[34] = V, e[35] = u, e[36] = w, e[37] = v) : v = e[37];
let x;
return e[38] !== E || e[39] !== H || e[40] !== l || e[41] !== q || e[42] !== s || e[43] !== G || e[44] !== J || e[45] !== v ? (x = /* @__PURE__ */ K("article", { ...l, "aria-labelledby": G, "aria-label": J, ref: N, className: q, children: [
H,
v,
s,
E
] }), e[38] = E, e[39] = H, e[40] = l, e[41] = q, e[42] = s, e[43] = G, e[44] = J, e[45] = v, e[46] = x) : x = e[46], x;
}, Q = (i) => {
const e = A.c(5), {
children: t,
className: a
} = i;
let o;
e[0] !== a ? (o = C(d.header, a) || void 0, e[0] = a, e[1] = o) : o = e[1];
const r = o;
let l;
return e[2] !== t || e[3] !== r ? (l = /* @__PURE__ */ S("header", { className: r, children: t }), e[2] = t, e[3] = r, e[4] = l) : l = e[4], l;
};
Q.displayName = "DSActionCard.Header";
const U = (i) => {
const e = A.c(5), {
children: t,
className: a
} = i;
let o;
e[0] !== a ? (o = C(d.footer, a) || void 0, e[0] = a, e[1] = o) : o = e[1];
const r = o;
let l;
return e[2] !== t || e[3] !== r ? (l = /* @__PURE__ */ S("footer", { className: r, children: t }), e[2] = t, e[3] = r, e[4] = l) : l = e[4], l;
};
U.displayName = "DSActionCard.Footer";
const X = (i) => {
const e = A.c(5), {
children: t,
className: a
} = i;
let o;
e[0] !== a ? (o = C(d.mediaWrapper, a) || void 0, e[0] = a, e[1] = o) : o = e[1];
const r = o;
let l;
return e[2] !== t || e[3] !== r ? (l = /* @__PURE__ */ S("div", { className: r, children: t }), e[2] = t, e[3] = r, e[4] = l) : l = e[4], l;
};
X.displayName = "DSActionCard.Media";
const Y = (i) => {
const e = A.c(5), {
children: t,
className: a
} = i;
let o;
e[0] !== a ? (o = C(d.supplementary, a) || void 0, e[0] = a, e[1] = o) : o = e[1];
const r = o;
let l;
return e[2] !== t || e[3] !== r ? (l = /* @__PURE__ */ S("div", { className: r, children: t }), e[2] = t, e[3] = r, e[4] = l) : l = e[4], l;
};
Y.displayName = "DSActionCard.Supplementary";
const Z = (i) => {
const e = A.c(56);
let t, a, o, r, l, m;
e[0] !== i ? ({
children: t,
className: a,
href: o,
linkComponent: r,
onClick: l,
...m
} = i, e[0] = i, e[1] = t, e[2] = a, e[3] = o, e[4] = r, e[5] = l, e[6] = m) : (t = e[1], a = e[2], o = e[3], r = e[4], l = e[5], m = e[6]);
let c, p, h, y, b, N, f, w, _, u;
if (e[7] !== t || e[8] !== a || e[9] !== r || e[10] !== m) {
w = /* @__PURE__ */ Symbol.for("react.early_return_sentinel");
e: {
y = C(d.primaryAction, a) || void 0;
const n = m;
if (e[21] !== n ? ({
download: p,
hrefLang: h,
ping: b,
referrerPolicy: N,
rel: f,
target: _,
type: u,
...c
} = n, e[21] = n, e[22] = c, e[23] = p, e[24] = h, e[25] = b, e[26] = N, e[27] = f, e[28] = _, e[29] = u) : (c = e[22], p = e[23], h = e[24], b = e[25], N = e[26], f = e[27], _ = e[28], u = e[29]), r && te(r)) {
let s;
e[30] !== t ? (s = /* @__PURE__ */ S("span", { className: d.primaryActionLabel, children: t }), e[30] = t, e[31] = s) : s = e[31];
let g;
e[32] !== r.props.children || e[33] !== s ? (g = /* @__PURE__ */ K(re, { children: [
s,
r.props.children
] }), e[32] = r.props.children, e[33] = s, e[34] = g) : g = e[34], w = se(r, {
...r.props,
className: C(y, r.props.className),
children: g
});
break e;
}
}
e[7] = t, e[8] = a, e[9] = r, e[10] = m, e[11] = c, e[12] = p, e[13] = h, e[14] = y, e[15] = b, e[16] = N, e[17] = f, e[18] = w, e[19] = _, e[20] = u;
} else
c = e[11], p = e[12], h = e[13], y = e[14], b = e[15], N = e[16], f = e[17], w = e[18], _ = e[19], u = e[20];
if (w !== /* @__PURE__ */ Symbol.for("react.early_return_sentinel"))
return w;
if (o) {
let n;
e[35] !== t ? (n = /* @__PURE__ */ S("span", { className: d.primaryActionLabel, children: t }), e[35] = t, e[36] = n) : n = e[36];
let s;
return e[37] !== c || e[38] !== p || e[39] !== o || e[40] !== h || e[41] !== y || e[42] !== b || e[43] !== N || e[44] !== f || e[45] !== n || e[46] !== _ || e[47] !== u ? (s = /* @__PURE__ */ S("a", { href: o, className: y, download: p, hrefLang: h, ping: b, referrerPolicy: N, rel: f, target: _, type: u, ...c, children: n }), e[37] = c, e[38] = p, e[39] = o, e[40] = h, e[41] = y, e[42] = b, e[43] = N, e[44] = f, e[45] = n, e[46] = _, e[47] = u, e[48] = s) : s = e[48], s;
}
if (l) {
let n;
e[49] !== t ? (n = /* @__PURE__ */ S("span", { className: d.primaryActionLabel, children: t }), e[49] = t, e[50] = n) : n = e[50];
let s;
return e[51] !== c || e[52] !== y || e[53] !== l || e[54] !== n ? (s = /* @__PURE__ */ S("button", { type: "button", className: y, onClick: l, ...c, children: n }), e[51] = c, e[52] = y, e[53] = l, e[54] = n, e[55] = s) : s = e[55], s;
}
return null;
};
Z.displayName = "DSActionCard.PrimaryAction";
k.Header = Q;
k.Footer = U;
k.Media = X;
k.PrimaryAction = Z;
k.Supplementary = Y;
k.displayName = "DSActionCard";
export {
k as D,
D as g,
Se as v
};