Build 542549stable
Module 396533
1,313 characters · in 73a53725ad9b9a6b.jsDependencies
Source Raw
function(e,t,u){u.d(t,{A:()=>s});var r=u(64700),n=u(17928),l=u(775602);function s(e){let{key:t,isExpanded:u,durationMs:s=100,minHeightOverride:c,maxHeightOverride:i,maxAnimationHeight:a}=e,f=(0,n.bG)([l.A],()=>l.A.useReducedMotion),[o,h]=r.useState(null),d=r.useCallback(()=>{},[]),p=r.useRef(null),y=r.useRef(null),R=r.useRef(t),g=r.useRef(s);g.current=s;let k=r.useRef(c);k.current=c;let m=r.useRef(i);m.current=i;let b=r.useRef(a);b.current=a;let[A,C]=r.useState(!1),v=r.useCallback(()=>C(!1),[]);return r.useLayoutEffect(()=>{void 0!==t&&(p.current=null,y.current=null,C(!1))},[t]),r.useLayoutEffect(()=>{if(null==o)return;let{height:e}=o.getBoundingClientRect();!u&&(null==p.current||e<p.current)&&(p.current=e),u&&(null==y.current||e>y.current)&&(y.current=e);let r=k.current??p.current,n=m.current??y.current,l=R.current!==t;if(R.current=t,null==r||null==n||l)return;let s=Math.min(b.current??n,n),c=u?r:s,i=u?s:r;if(c===i)return;C(!0),o.style.height=`${c}px`,o.style.transition="";let a=null;return a=requestAnimationFrame(()=>{a=null,o.style.height=`${i}px`,o.style.transition=`height ${g.current}ms ease-in-out`}),()=>null!=a?cancelAnimationFrame(a):void 0},[t,o,u]),r.useLayoutEffect(()=>{null==o||A||(o.style.height="",o.style.transition="")},[t,o,A]),{ref:f?d:h,isTransitioning:A,onTransitionEnd:v}}}