@lanaco/lnc-react-ui
Version:
React component library
7 lines (6 loc) • 1.39 kB
JavaScript
;const b=require("react/jsx-runtime"),s=require("react"),R=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),c=require("./utils-BK6B_Y9X.cjs"),S=require("./emotion-element-f0de968e.browser.esm-B7k6i6lC.cjs"),x=require("./useUpdateEffect-BtMgpgIV.cjs"),D=R.styled.div`
color: ${t=>!t.disabled&&c.getColorRgbaValue(t.theme,"Accordion","primary","enabled","text")};
background-color: transparent;
${t=>c.getComponentTypographyCss(t.theme,"Accordion",t.size,"enabled")};
${t=>t.disabled===!0?c.getDisabledStateCss(t.theme):""}
`,N=s.forwardRef((t,u)=>{const{expanded:r=!1,disabled:i=!1,change:p=()=>{},size:a="small",className:_="",style:C={},children:m,...E}=t,f={theme:S.useTheme(),size:a,style:C,className:"lnc-ui-accordion "+_},[o,l]=s.useState(r);x.useUpdateEffect(()=>{l(r)},[r]);const d=e=>{p(!o,e),l(!o)},y=s.Children.map(m,e=>{var n;if(s.isValidElement(e)&&(e.props.__TYPE__=="ACCORDION_SUMMARY"||((n=e==null?void 0:e.type)==null?void 0:n.displayName)==="ACCORDION_SUMMARY"))return s.cloneElement(e,{size:a,onClick:d,onExpand:d,isExpanded:o,disabled:i})}),A=s.Children.map(m,e=>{var n;if(s.isValidElement(e)&&(e.props.__TYPE__=="ACCORDION_DETAILS"||((n=e==null?void 0:e.type)==null?void 0:n.displayName)==="ACCORDION_DETAILS"))return s.cloneElement(e,{size:a,isExpanded:o})});return b.jsxs(D,{ref:u,...f,disabled:i,...E,children:[y,A]})});module.exports=N;