UNPKG

@stihl-design-system/components

Version:

Welcome to the STIHL Design System react component library.

104 lines (103 loc) 4.62 kB
"use client"; import { jsx as w, jsxs as V } from "react/jsx-runtime"; import { d as q } from "./index.D-sRdssb.js"; import { c as F } from "./index.DL9mof6u.js"; import { isValidElement as M, useState as I, useEffect as O, cloneElement as R } from "react"; import { D as K } from "./Button.Cn5yg7dG.js"; import { DSLink as X } from "../link.DoiK003-.js"; import { g as d, r as z } from "./helpers.CexwVao7.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: r, links: e }) => { if (!r || typeof r != "object" || Object.keys(r).length === 0 || !r["aria-label"] && !r["aria-labelledby"] || r["aria-label"]?.trim() === "" && r["aria-labelledby"]?.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: o, label: l, wrapper: t }) => { if (t && !M(t)) throw new Error(d("DSBreadcrumb", `The link with label "${l}" provided an invalid ReactElement as wrapper property.`)); t && o && console.warn(d("DSBreadcrumb", `The link with label "${l}" has both a wrapper and an href property. Please use only one.`)), t && M(t) && t.props?.children && console.warn(d("DSBreadcrumb", `The link with label "${l}" contains a wrapper with children. Please remove the children, as they will be replaced. For example: <Link href="#" />`)); }); }, le = (r) => { const e = q.c(40); let o, l, t, s, i; e[0] !== r ? ({ aria: o, className: l, links: t, showAllButtonProps: i, ...s } = r, e[0] = r, e[1] = o, e[2] = l, e[3] = t, e[4] = s, e[5] = i) : (o = e[1], l = e[2], t = e[3], s = e[4], i = e[5]), process.env.NODE_ENV !== "production" && J({ aria: o, links: t }); let n; e[6] !== i ? (n = i || {}, e[6] = i, e[7] = n) : n = e[7]; let a, c; e[8] !== n ? ({ label: c, ...a } = n, e[8] = n, e[9] = a, e[10] = c) : (a = 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] !== l ? (B = F(T.root, l), e[15] = l, e[16] = B) : B = e[16]; const L = B; let k; e[17] !== m || e[18] !== a || e[19] !== h ? (k = () => h ? null : /* @__PURE__ */ w("li", { children: /* @__PURE__ */ w(K, { ...a, 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] = a, 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] !== o || e[36] !== s || e[37] !== L || e[38] !== p ? (E = /* @__PURE__ */ w("nav", { className: L, ...s, ...o, children: p }), e[35] = o, e[36] = s, e[37] = L, e[38] = p, e[39] = E) : E = e[39], E; }; function Q(r, e, o) { const { label: l, href: t, wrapper: s, iconName: i } = r, n = e === 0, a = o === e, c = a && !n ? "page" : void 0, m = /* @__PURE__ */ w(X, { href: s ? void 0 : t, iconName: i, "aria-current": s ? void 0 : c, active: a && !n, children: l }); return s ? R(s, { "aria-current": c, children: m }) : m; } export { le as D, $ as M, J as v };