UNPKG

@accounter/client

Version:
1 lines 2.46 kB
import{s as e}from"./dist-BmACi7k_.js";import{i as t,o as n}from"./utils-BxkqV8PM.js";import{$ as r,Q as i,Z as a,at as o,et as s,rt as c,tt as l}from"./select-BbuF1w16.js";import{o as u}from"./button-BBCCSbHv.js";var d=e(n(),1),f=t(),p=Object.defineProperty,m=(e,t)=>p(e,`name`,{value:t,configurable:!0}),h=`Collapsible`,[g,_]=c(h),[v,y]=g(h),b=d.forwardRef(m(function(e,t){let{__scopeCollapsible:n,open:i,defaultOpen:s,disabled:c,onOpenChange:l,...u}=e,[p,m]=r({prop:i,defaultProp:s??!1,onChange:l,caller:h});return(0,f.jsx)(v,{scope:n,disabled:c,contentId:a(),open:p,onOpenToggle:d.useCallback(()=>m(e=>!e),[m]),children:(0,f.jsx)(o.div,{"data-state":E(p),"data-disabled":c?``:void 0,...u,ref:t})})},`Collapsible`)),x=`CollapsibleTrigger`,S=d.forwardRef(m(function(e,t){let{__scopeCollapsible:n,...r}=e,i=y(x,n);return(0,f.jsx)(o.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":E(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:l(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),C=`CollapsibleContent`,w=d.forwardRef(m(function(e,t){let{forceMount:n,...r}=e,a=y(C,e.__scopeCollapsible);return(0,f.jsx)(i,{present:n||a.open,children:({present:e})=>(0,f.jsx)(T,{...r,ref:t,present:e})})},`CollapsibleContent`)),T=d.forwardRef(m(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,c=y(C,n),[l,p]=d.useState(r),m=d.useRef(null),h=u(t,m),g=d.useRef(0),_=g.current,v=d.useRef(0),b=v.current,x=c.open||l,S=d.useRef(x),w=d.useRef(void 0);return d.useEffect(()=>{let e=requestAnimationFrame(()=>S.current=!1);return()=>cancelAnimationFrame(e)},[]),s(()=>{let e=m.current;if(e){w.current=w.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();g.current=t.height,v.current=t.width,S.current||(e.style.transitionDuration=w.current.transitionDuration,e.style.animationName=w.current.animationName),p(r)}},[c.open,r]),(0,f.jsx)(o.div,{"data-state":E(c.open),"data-disabled":c.disabled?``:void 0,id:c.contentId,hidden:!x,...a,ref:h,style:{"--radix-collapsible-content-height":_?`${_}px`:void 0,"--radix-collapsible-content-width":b?`${b}px`:void 0,...e.style},children:x&&i})},`CollapsibleContentImpl`));function E(e){return e?`open`:`closed`}m(E,`getState`);var D=b,O=S,k=w;export{O as a,D as i,S as n,_ as o,k as r,w as t};