Module 687972

1,699 characters · in no known chunk
Dependencies
Required by (1)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>l,g:()=>u});var r=n(64700),i=n(715828),s=n(484702),a=n(403431);let o=Object.freeze({spacerTop:0,totalHeight:0,items:[],isSidebarVisible:!1});function l(e){let{sections:t,sectionHeight:n,rowHeight:l,footerHeight:u,sidebarHeight:c,listHeaderHeight:d,chunkSize:_=256,paddingTop:f=0,paddingBottom:p=0,getScrollerState:h,getAnchorId:m}=e,E=(0,s.A)(),g=(0,r.useRef)(o),[A]=(0,r.useState)(()=>new i.A),{dirty:I,chunkStart:T,chunkEnd:S,forceUpdateOnChunkChange:y}=(0,a.A)({chunkSize:_,getScrollerState:h,forceUpdate:E}),{items:v}=g.current,N=null,{scrollTop:C}=h();for(let e of v){if(0===C)break;if("footer"===e.type||"header"===e.type||null==e.anchorId)continue;let t="row"===e.type?e.row:void 0;if(e.offsetTop>=C){N={id:e.anchorId,section:e.section,row:t,scrollOffset:e.offsetTop-C};break}}let R=(0,r.useMemo)(()=>{let e=Math.max(0,T*_);return null!=c&&e<c},[_,T,c]),O=(0,r.useMemo)(()=>I>0?g.current:(A.mergeProps({sectionHeight:n,rowHeight:l,footerHeight:u,listHeaderHeight:d,paddingBottom:p,paddingTop:f,sections:t,getAnchorId:m}),A.compute(Math.max(0,T*_),S*_)),[I,T,S,n,l,u,d,p,f,t,A,_,m]);return(0,r.useLayoutEffect)(()=>void(g.current=O)),{...O,listComputer:A,forceUpdateOnChunkChange:y,anchor:N,isSidebarVisible:R}}function u(e){let{scrollerRef:t,anchor:n,getScrollerState:i,listComputer:s,getAnchorId:a,totalHeight:o}=e;(0,r.useLayoutEffect)(()=>{let{current:e}=t,{scrollTop:r}=i();if(null==n||null==n.row||null==e||null==a||0===r)return;let o=t=>{if(t<0||t>=s.sections[n.section]||a(n.section,n.row)!==n.id)return!1;let[i]=s.computeScrollPosition(n.section,t),o=i-n.scrollOffset;return r!==o&&(e.scrollTop=o),!0};o(n.row)||o(n.row-1)||o(n.row+1)},[o])}}