@frontify/fondue
Version:
Design system of Frontify
81 lines (80 loc) • 2.18 kB
JavaScript
import { jsx as r } from "react/jsx-runtime";
import { useRef as K } from "react";
import { OverflowMenu as M } from "../OverflowMenu/OverflowMenu.es.js";
import { BreadcrumbItem as w } from "./BreadcrumbItem.es.js";
import { CurrentBreadcrumbItem as O } from "./CurrentBreadcrumbItem.es.js";
const R = ({
items: t,
keepRoot: o,
activeInline: k = !1,
truncate: l = !1,
"data-test-id": n
}) => {
const m = K(!0);
return [...t.map(({ label: u, badges: B, bold: C, decorator: a, link: i, onClick: f }, e) => {
const s = `breadcrumb-${e}`, d = o && e === 0, F = e === t.length - 1, g = o ? 2 : 3, b = t.length - g, p = e >= b, v = l && !d && !p, h = e < t.length - 1, I = [];
let c = -1;
switch (!0) {
case F:
return /* @__PURE__ */ r(
O,
{
label: u,
badges: B,
bold: C,
decorator: a,
link: i,
onClick: f,
activeInline: k,
"data-test-id": n
},
s
);
case !l:
case d:
case p:
return /* @__PURE__ */ r(
w,
{
label: u,
decorator: a,
link: i,
onClick: f,
showSeparator: h,
"data-test-id": n
},
s
);
case (v && m.current):
m.current = !1;
for (const $ of t) {
if (c++, c >= b)
break;
if (o && c === 0)
continue;
{
const { label: y, link: L, onClick: j } = $;
I.push({ label: y, link: L, onClick: j });
}
}
return /* @__PURE__ */ r(
w,
{
label: "",
decorator: a,
showSeparator: h,
"data-test-id": `${n}-truncation`,
children: /* @__PURE__ */ r(M, { items: I, "data-test-id": `${n}-overflow-menu` })
},
s
);
default:
return /* @__PURE__ */ r("li", {}, s);
}
})];
};
R.displayname = "FondueFormattedBreadcrumbs";
export {
R as FormattedBreadcrumbs
};
//# sourceMappingURL=FormattedBreadcrumbs.es.js.map