@lanaco/lnc-react-ui
Version:
React component library
9 lines (8 loc) • 1.5 kB
JavaScript
;const s=require("react/jsx-runtime"),i=require("react"),u=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),g=require("./utils-BK6B_Y9X.cjs"),S=require("./Icon.cjs"),_=require("./emotion-element-f0de968e.browser.esm-B7k6i6lC.cjs"),v=u.styled.div`
display: inline-flex;
flex-wrap: wrap;
${r=>g.getComponentTypographyCss(r.theme,"Breadcrumbs",r.size,"enabled")};
color: ${r=>g.getColorRgbaValue(r.theme,"Breadcrumbs",r.color,"enabled","text")};
`,z=u.styled.div`
cursor: pointer;
`,A=u.styled.span``,F=i.forwardRef((r,b)=>{const{separator:o="/",maxItems:y=8,itemsAfterCollapse:f=1,itemsBeforeCollapse:j=1,className:x="",style:C={},color:h="neutral",size:q="small",children:B,...I}=r,w={theme:_.useTheme(),size:q,color:h,className:"lnc-ui-breadcrumbs "+x,style:C},[c,d]=i.useState(!0),R=({maxItems:m,itemsAfterCollapse:n,itemsBeforeCollapse:l,children:e})=>typeof(e==null?void 0:e.map)!="function"?s.jsx(a,{index:0,length:e.length,separator:o,child:e}):e==null?void 0:e.map((p,t)=>m<=e.length&&c==!0?l-1>=t||e.length-n<=t?s.jsx(a,{index:t,length:e.length,separator:o,child:p},t):l==t&&s.jsxs(z,{onClick:()=>d(!c),children:[s.jsx(S,{icon:"ellipsis"}),o," "]},t):s.jsx(a,{index:t,length:e.length,separator:o,child:p},t)),a=({index:m,length:n,separator:l,child:e})=>s.jsxs(A,{children:[e,m+1!==n&&s.jsxs(s.Fragment,{children:[" ",l," "]})]});return s.jsx(v,{ref:b,...w,...I,children:s.jsx(R,{maxItems:y,itemsAfterCollapse:f,itemsBeforeCollapse:j,children:B})})});module.exports=F;