UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

106 lines (105 loc) 4.72 kB
"use client"; import { jsx as w, jsxs as V } from "react/jsx-runtime"; import { d as q } from "./index.CgTHIF3K.js"; import { c as F } from "./index.CEyLAtio.js"; import { isValidElement as M, useState as I, useEffect as O, cloneElement as R } from "react"; import { D as K } from "./Button.Cf1CKq8N.js"; import { DSLink as X } from "../link.DbnvsD3j.js"; import { g as d, r as z } from "./helpers.BbWkXTr3.js"; import '../assets/Breadcrumb.BaYrwrYl.css';const G = "ds-breadcrumb_root_1e9hu_1", H = "ds-breadcrumb_show-all-button_1e9hu_30", T = { root: G, showAllButton: H }, $ = 4, J = ({ aria: o, links: e }) => { var s, a; if (!o || typeof o != "object" || Object.keys(o).length === 0 || !o["aria-label"] && !o["aria-labelledby"] || ((s = o["aria-label"]) == null ? void 0 : s.trim()) === "" && ((a = o["aria-labelledby"]) == null ? void 0 : a.trim()) === "") throw new Error(d("DSBreadcrumb", 'A valid "aria-label" or "aria-labelledby" property is required. Ensure the "aria" prop is a non-empty object and includes either "aria-label" or "aria-labelledby" with a non-empty string value.')); if (Array.isArray(e)) { if (e.length === 0) throw new Error(d("DSBreadcrumb", "The links array must not be empty.")); if (e.length < 2) throw new Error(d("DSBreadcrumb", "The links array must have at least two elements.")); } else throw new Error(d("DSBreadcrumb", z("links", "DSBreadcrumb"))); e.forEach(({ href: t, label: r, wrapper: l }) => { var n; if (l && !M(l)) throw new Error(d("DSBreadcrumb", `The link with label "${r}" provided an invalid ReactElement as wrapper property.`)); l && t && console.warn(d("DSBreadcrumb", `The link with label "${r}" has both a wrapper and an href property. Please use only one.`)), l && M(l) && ((n = l.props) != null && n.children) && console.warn(d("DSBreadcrumb", `The link with label "${r}" contains a wrapper with children. Please remove the children, as they will be replaced. For example: <Link href="#" />`)); }); }, le = (o) => { const e = q.c(40); let s, a, t, r, l; e[0] !== o ? ({ aria: s, className: a, links: t, showAllButtonProps: l, ...r } = o, e[0] = o, e[1] = s, e[2] = a, e[3] = t, e[4] = r, e[5] = l) : (s = e[1], a = e[2], t = e[3], r = e[4], l = e[5]), process.env.NODE_ENV !== "production" && J({ aria: s, links: t }); let n; e[6] !== l ? (n = l || {}, e[6] = l, e[7] = n) : n = e[7]; let i, c; e[8] !== n ? ({ label: c, ...i } = n, e[8] = n, e[9] = i, e[10] = c) : (i = e[9], c = e[10]); const m = c === void 0 ? "Show all links" : c, [h, P] = I(t.length <= $); let S; e[11] !== t.length ? (S = () => { P(t.length <= $); }, e[11] = t.length, e[12] = S) : S = e[12]; let g; e[13] !== t ? (g = [t], e[13] = t, e[14] = g) : g = e[14], O(S, g); let B; e[15] !== a ? (B = F(T.root, a), e[15] = a, e[16] = B) : B = e[16]; const L = B; let k; e[17] !== m || e[18] !== i || e[19] !== h ? (k = () => h ? null : /* @__PURE__ */ w("li", { children: /* @__PURE__ */ w(K, { ...i, className: T.showAllButton, type: "button", title: m, variant: "ghost", onClick: () => P(!0), children: /* @__PURE__ */ w("span", { "aria-hidden": "true", children: "..." }) }) }), e[17] = m, e[18] = i, e[19] = h, e[20] = k) : k = e[20]; const A = k, x = Q; let v; e[21] === Symbol.for("react.memo_cache_sentinel") ? (v = (y) => y.map((C, j) => /* @__PURE__ */ w("li", { children: x(C, y.length - 1, j) }, j)), e[21] = v) : v = e[21]; const _ = v; let D; e[22] !== h ? (D = (y) => _(h ? y : y.slice(-2)), e[22] = h, e[23] = D) : D = e[23]; const N = D; let u; e[24] !== t[0] ? (u = _([t[0]]), e[24] = t[0], e[25] = u) : u = e[25]; let b; e[26] !== A ? (b = A(), e[26] = A, e[27] = b) : b = e[27]; let f; e[28] !== N || e[29] !== t ? (f = N(t.slice(1)), e[28] = N, e[29] = t, e[30] = f) : f = e[30]; let p; e[31] !== b || e[32] !== f || e[33] !== u ? (p = /* @__PURE__ */ V("ol", { children: [ u, b, f ] }), e[31] = b, e[32] = f, e[33] = u, e[34] = p) : p = e[34]; let E; return e[35] !== s || e[36] !== r || e[37] !== L || e[38] !== p ? (E = /* @__PURE__ */ w("nav", { className: L, ...r, ...s, children: p }), e[35] = s, e[36] = r, e[37] = L, e[38] = p, e[39] = E) : E = e[39], E; }; function Q(o, e, s) { const { label: a, href: t, wrapper: r, iconName: l } = o, n = e === 0, i = s === e, c = i && !n ? "page" : void 0, m = /* @__PURE__ */ w(X, { href: r ? void 0 : t, iconName: l, "aria-current": r ? void 0 : c, active: i && !n, children: a }); return r ? R(r, { "aria-current": c, children: m }) : m; } export { le as D, $ as M, J as v };