@lanaco/lnc-react-ui
Version:
React component library
7 lines (6 loc) • 1.75 kB
JavaScript
;const n=require("react/jsx-runtime"),o=require("react"),b=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),q=require("./utils-BK6B_Y9X.cjs"),w=require("./motion-B_VPZaJq.cjs"),h=require("./emotion-element-f0de968e.browser.esm-B7k6i6lC.cjs"),$=require("./index-DZoWlChs.cjs"),j=b.styled(w.motion.div)`
${t=>t.tuckIn==!0&&`margin-left: ${t.tuckInSize};`}
${t=>t.tuckIn==!0&&`padding-left: ${t.tuckInSize};`}
${t=>t.tuckIn==!0&&`border-left: 2px solid ${q.getColorRgbaValue(t.theme,"MenuItem",t.color,"focus","background","backgroundOpacity")};`}
border-radius: 2px;
`,c=o.forwardRef((t,m)=>{const{item:l,onItemSelected:d=()=>{},defaultOpen:E=!1,tuckIn:p=!0,tuckInSize:_="0.3rem",animation:y={animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},initial:{opacity:0,height:0},transition:{type:"tween",duration:.15,opacity:{duration:.15,ease:"easeOut"},height:{duration:.15}}},className:I="",style:N={},color:s="primary",size:i="small",children:g,...x}=t,S=h.useTheme(),[r,T]=o.useState(E),f=()=>{T(!r)},k=o.cloneElement(l,{isNested:!0,showNested:r,toggleNested:f,color:s,size:i}),M=o.Children.map(g,(e,z)=>{var a,u;if(o.isValidElement(e)&&(e.props.__TYPE__=="MENU_ITEM"||((a=e==null?void 0:e.type)==null?void 0:a.displayName)==="MENU_ITEM"||e.props.__TYPE__=="NESTED_ITEM"||((u=e==null?void 0:e.type)==null?void 0:u.displayName)==="NESTED_ITEM"))return o.cloneElement(e,{color:e.props.color?e.props.color:s,size:i,onItemSelected:d})});return n.jsxs(n.Fragment,{children:[n.jsx(n.Fragment,{children:k}),n.jsx($.AnimatePresence,{children:r&&n.jsx(j,{theme:S,tuckIn:p,tuckInSize:_,color:s,size:i,className:"nested-item-lnc "+I,style:N,ref:m,show:r,...y,...x,children:M})})]})});c.displayName="NESTED_ITEM";module.exports=c;