UNPKG

@lanaco/lnc-react-ui

Version:

React component library

102 lines (101 loc) 2.28 kB
import { jsx as o, jsxs as n, Fragment as x } from "react/jsx-runtime"; import { forwardRef as z, useState as A } from "react"; import { s as u } from "./emotion-styled.browser.esm-DfbrHHed.js"; import { d as N, c as R } from "./utils-BUdHa0nB.js"; import T from "./Icon.js"; import { u as $ } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; const k = u.div` display: inline-flex; flex-wrap: wrap; ${(s) => N( s.theme, "Breadcrumbs", s.size, "enabled" )}; color: ${(s) => R( s.theme, "Breadcrumbs", s.color, "enabled", "text" )}; `, F = u.div` cursor: pointer; `, P = u.span``, K = z((s, g) => { const { separator: r = "/", maxItems: b = 8, itemsAfterCollapse: i = 1, itemsBeforeCollapse: C = 1, //---------------- className: y = "", style: h = {}, color: B = "neutral", size: I = "small", children: w, ...S } = s, d = { theme: $(), size: I, color: B, className: "lnc-ui-breadcrumbs " + y, style: h }, [c, j] = A(!0), v = ({ maxItems: l, itemsAfterCollapse: p, itemsBeforeCollapse: a, children: e }) => typeof (e == null ? void 0 : e.map) != "function" ? /* @__PURE__ */ o( m, { index: 0, length: e.length, separator: r, child: e } ) : e == null ? void 0 : e.map( (f, t) => l <= e.length && c == !0 ? a - 1 >= t || e.length - p <= t ? /* @__PURE__ */ o( m, { index: t, length: e.length, separator: r, child: f }, t ) : a == t && /* @__PURE__ */ n(F, { onClick: () => j(!c), children: [ /* @__PURE__ */ o(T, { icon: "ellipsis" }), r, " " ] }, t) : /* @__PURE__ */ o( m, { index: t, length: e.length, separator: r, child: f }, t ) ), m = ({ index: l, length: p, separator: a, child: e }) => /* @__PURE__ */ n(P, { children: [ e, l + 1 !== p && /* @__PURE__ */ n(x, { children: [ " ", a, " " ] }) ] }); return /* @__PURE__ */ o(k, { ref: g, ...d, ...S, children: /* @__PURE__ */ o( v, { maxItems: b, itemsAfterCollapse: i, itemsBeforeCollapse: C, children: w } ) }); }); export { K as default };