UNPKG

@lanaco/lnc-react-ui

Version:

React component library

132 lines (131 loc) 3.19 kB
import { jsx as o, jsxs as u, Fragment as z } from "react/jsx-runtime"; import { forwardRef as A, useState as N } from "react"; import { P as t } from "./index-S5Cd7WrG.js"; import { n as c } from "./emotion-styled.browser.esm-CjCaF13H.js"; import { c as O, b as P } from "./utils-DtRLzzTZ.js"; import v from "./Icon.js"; import { u as R } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js"; const $ = c.div` display: inline-flex; flex-wrap: wrap; ${(r) => O( r.theme, "Breadcrumbs", r.size, "enabled" )}; color: ${(r) => P( r.theme, "Breadcrumbs", r.color, "enabled", "text" )}; `, k = c.div` cursor: pointer; `, F = c.span``, V = A((r, g) => { const { separator: a = "/", maxItems: b = 8, itemsAfterCollapse: y = 1, itemsBeforeCollapse: C = 1, //---------------- className: B = "", style: I = {}, color: h = "neutral", size: w = "small", children: T, ...d } = r, S = { theme: R(), size: w, color: h, className: "lnc-ui-breadcrumbs " + B, style: I }, [f, j] = N(!0), x = ({ maxItems: n, itemsAfterCollapse: p, itemsBeforeCollapse: m, children: e }) => typeof (e == null ? void 0 : e.map) != "function" ? /* @__PURE__ */ o( l, { index: 0, length: e.length, separator: a, child: e } ) : e == null ? void 0 : e.map( (i, s) => n <= e.length && f == !0 ? m - 1 >= s || e.length - p <= s ? /* @__PURE__ */ o( l, { index: s, length: e.length, separator: a, child: i }, s ) : m == s && /* @__PURE__ */ u(k, { onClick: (D) => j(!f), children: [ /* @__PURE__ */ o(v, { icon: "ellipsis" }), a, " " ] }, s) : /* @__PURE__ */ o( l, { index: s, length: e.length, separator: a, child: i }, s ) ), l = ({ index: n, length: p, separator: m, child: e }) => /* @__PURE__ */ u(F, { children: [ e, n + 1 !== p && /* @__PURE__ */ u(z, { children: [ " ", m, " " ] }) ] }); return /* @__PURE__ */ o($, { ref: g, ...S, ...d, children: /* @__PURE__ */ o( x, { maxItems: b, itemsAfterCollapse: y, itemsBeforeCollapse: C, children: T } ) }); }); V.propTypes = { separator: t.oneOfType([t.string, t.element]), /** * Specifies the maximum number of breadcrumbs to display. When there are more than the maximum number, only the first itemsBeforeCollapse and last itemsAfterCollapse will be shown, with an ellipsis in between */ maxItems: t.number, /** * If max items is exceeded, the number of items to show after the ellipsis. */ itemsAfterCollapse: t.number, /** * If max items is exceeded, the number of items to show before the ellipsis. */ itemsBeforeCollapse: t.number, //--------------------------------------------------------------- className: t.string, style: t.object, color: t.oneOf([ "primary", "secondary", "success", "warning", "danger", "information", "neutral", "gray" ]), size: t.oneOf(["small", "medium", "large"]) }; export { V as default };