react-window 2.2.7 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -149,6 +149,17 @@ This may be used to (re)scroll a row into view.</p>
149
149
  <td>overscanCount</td>
150
150
  <td><p>How many additional rows to render outside of the visible area.
151
151
  This can reduce visual flickering near the edges of a list when scrolling.</p>
152
+ </td>
153
+ </tr>
154
+ <tr>
155
+ <td>rowKey</td>
156
+ <td><p>Lists use the row index as a <code>key</code> by default.
157
+ This prop can provide a custom <code>key</code> value.</p>
158
+ <p>ℹ️ Custom keys can ensure better UX for sortable or filterable lists,
159
+ particularly if your row components are stateful.
160
+ Refer to the <a href="https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key">React documentation</a> for more info.</p>
161
+ <p>⚠️ This prop cannot be auto-memoized because it is called during render.
162
+ It is important to always <code>useCallback</code> for this prop; do not use an inline function.</p>
152
163
  </td>
153
164
  </tr>
154
165
  <tr>
@@ -267,6 +278,17 @@ The grid of cells will fill the height and width defined by this style.</p>
267
278
  <td>children</td>
268
279
  <td><p>Additional content to be rendered within the grid (above cells).
269
280
  This property can be used to render things like overlays or tooltips.</p>
281
+ </td>
282
+ </tr>
283
+ <tr>
284
+ <td>columnKey</td>
285
+ <td><p>Grids use the column index as a <code>key</code> by default.
286
+ This prop can be used along with the <code>rowKey</code> prop to provide a custom <code>key</code> value.</p>
287
+ <p>ℹ️ Custom keys can ensure better UX for sortable or filterable grids,
288
+ particularly if your cell components are stateful.
289
+ Refer to the <a href="https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key">React documentation</a> for more info.</p>
290
+ <p>⚠️ This prop cannot be auto-memoized because it is called during render.
291
+ It is important to always <code>useCallback</code> for this prop; do not use an inline function.</p>
270
292
  </td>
271
293
  </tr>
272
294
  <tr>
@@ -302,6 +324,17 @@ This may be used to (re)scroll a cell into view.</p>
302
324
  <td>overscanCount</td>
303
325
  <td><p>How many additional rows/columns to render outside of the visible area.
304
326
  This can reduce visual flickering near the edges of a grid when scrolling.</p>
327
+ </td>
328
+ </tr>
329
+ <tr>
330
+ <td>rowKey</td>
331
+ <td><p>Grids use the row index as a <code>key</code> by default.
332
+ This prop can be used along with the <code>columnKey</code> prop to provide a custom <code>key</code> value.</p>
333
+ <p>ℹ️ Custom keys can ensure better UX for sortable or filterable grids,
334
+ particularly if your cell components are stateful.
335
+ Refer to the <a href="https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key">React documentation</a> for more info.</p>
336
+ <p>⚠️ This prop cannot be auto-memoized because it is called during render.
337
+ It is important to always <code>useCallback</code> for this prop; do not use an inline function.</p>
305
338
  </td>
306
339
  </tr>
307
340
  <tr>
@@ -1,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const J=require("react/jsx-runtime"),o=require("react");function ce(e){let t=e;for(;t;){if(t.dir)return t.dir==="rtl";t=t.parentElement}return!1}function ae(e,t){const[s,r]=o.useState(t==="rtl");return o.useLayoutEffect(()=>{e&&(t||r(ce(e)))},[t,e]),s}const _=typeof window<"u"?o.useLayoutEffect:o.useEffect;function ee(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function ue({box:e,defaultHeight:t,defaultWidth:s,disabled:r,element:n,mode:i,style:l}){const{styleHeight:f,styleWidth:c}=o.useMemo(()=>({styleHeight:ee(l?.height),styleWidth:ee(l?.width)}),[l?.height,l?.width]),[a,d]=o.useState({height:t,width:s}),u=r||i==="only-height"&&f!==void 0||i==="only-width"&&c!==void 0||f!==void 0&&c!==void 0;return _(()=>{if(n===null||u)return;const g=new ResizeObserver(p=>{for(const I of p){const{contentRect:h,target:w}=I;n===w&&d(y=>y.height===h.height&&y.width===h.width?y:{height:h.height,width:h.width})}});return g.observe(n,{box:e}),()=>{g?.unobserve(n)}},[e,u,n,f,c]),o.useMemo(()=>({height:f??a.height,width:c??a.width}),[a,f,c])}function te(e){const t=o.useRef(()=>{throw new Error("Cannot call during render.")});return _(()=>{t.current=e},[e]),o.useCallback(s=>t.current?.(s),[t])}let D=null;function fe(e=!1){if(D===null||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",s.direction="rtl";const r=document.createElement("div"),n=r.style;return n.width="100px",n.height="100px",t.appendChild(r),document.body.appendChild(t),t.scrollLeft>0?D="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?D="negative":D="positive-ascending"),document.body.removeChild(t),D}return D}function N({containerElement:e,direction:t,isRtl:s,scrollOffset:r}){if(t==="horizontal"&&s)switch(fe()){case"negative":return-r;case"positive-descending":{if(e){const{clientWidth:n,scrollLeft:i,scrollWidth:l}=e;return l-n-i}break}}return r}function V(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function F(e,t){if(e===t)return!0;if(!!e!=!!t||(V(e!==void 0),V(t!==void 0),Object.keys(e).length!==Object.keys(t).length))return!1;for(const s in e)if(!Object.is(t[s],e[s]))return!1;return!0}function se({cachedBounds:e,itemCount:t,itemSize:s}){if(t===0)return 0;if(typeof s=="number")return t*s;{const r=e.get(e.size===0?0:e.size-1);V(r!==void 0,"Unexpected bounds cache miss");const n=(r.scrollOffset+r.size)/e.size;return t*n}}function de({align:e,cachedBounds:t,index:s,itemCount:r,itemSize:n,containerScrollOffset:i,containerSize:l}){if(s<0||s>=r)throw RangeError(`Invalid index specified: ${s}`,{cause:`Index ${s} is not within the range of 0 - ${r-1}`});const f=se({cachedBounds:t,itemCount:r,itemSize:n}),c=t.get(s),a=Math.max(0,Math.min(f-l,c.scrollOffset)),d=Math.max(0,c.scrollOffset-l+c.size);switch(e==="smart"&&(i>=d&&i<=a?e="auto":e="center"),e){case"start":return a;case"end":return d;case"center":return c.scrollOffset<=l/2?0:c.scrollOffset+c.size/2>=f-l/2?f-l:c.scrollOffset+c.size/2-l/2;case"auto":default:return i>=d&&i<=a?i:i<d?d:a}}function Y({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:r,overscanCount:n}){const i=r-1;let l=0,f=-1,c=0,a=-1,d=0;for(;d<i;){const u=e.get(d);if(u.scrollOffset+u.size>t)break;d++}for(l=d,c=Math.max(0,l-n);d<i;){const u=e.get(d);if(u.scrollOffset+u.size>=t+s)break;d++}return f=Math.min(i,d),a=Math.min(r-1,f+n),l<0&&(l=0,f=-1,c=0,a=-1),{startIndexVisible:l,stopIndexVisible:f,startIndexOverscan:c,stopIndexOverscan:a}}function he({itemCount:e,itemProps:t,itemSize:s}){const r=new Map;return{get(n){for(V(n<e,`Invalid index ${n}`);r.size-1<n;){const l=r.size;let f;switch(typeof s){case"function":{f=s(l,t);break}case"number":{f=s;break}}if(l===0)r.set(l,{size:f,scrollOffset:0});else{const c=r.get(l-1);V(c!==void 0,`Unexpected bounds cache miss for index ${n}`),r.set(l,{scrollOffset:c.scrollOffset+c.size,size:f})}}const i=r.get(n);return V(i!==void 0,`Unexpected bounds cache miss for index ${n}`),i},set(n,i){r.set(n,i)},get size(){return r.size}}}function ge({itemCount:e,itemProps:t,itemSize:s}){return o.useMemo(()=>he({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function pe({containerSize:e,itemSize:t}){let s;switch(typeof t){case"string":{V(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),V(e!==void 0,"Container size must be defined if a percentage item size is specified"),s=e*parseInt(t)/100;break}default:{s=t;break}}return s}function K({containerElement:e,containerStyle:t,defaultContainerSize:s=0,direction:r,isRtl:n=!1,itemCount:i,itemProps:l,itemSize:f,onResize:c,overscanCount:a}){const{height:d=s,width:u=s}=ue({defaultHeight:r==="vertical"?s:void 0,defaultWidth:r==="horizontal"?s:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:t}),g=o.useRef({height:0,width:0}),p=r==="vertical"?d:u,I=pe({containerSize:p,itemSize:f});o.useLayoutEffect(()=>{if(typeof c=="function"){const x=g.current;(x.height!==d||x.width!==u)&&(c({height:d,width:u},{...x}),x.height=d,x.width=u)}},[d,c,u]);const h=ge({itemCount:i,itemProps:l,itemSize:I}),w=o.useCallback(x=>h.get(x),[h]),[y,O]=o.useState(()=>Y({cachedBounds:h,containerScrollOffset:0,containerSize:p,itemCount:i,overscanCount:a})),{startIndexVisible:B,startIndexOverscan:b,stopIndexVisible:G,stopIndexOverscan:M}={startIndexVisible:Math.min(i-1,y.startIndexVisible),startIndexOverscan:Math.min(i-1,y.startIndexOverscan),stopIndexVisible:Math.min(i-1,y.stopIndexVisible),stopIndexOverscan:Math.min(i-1,y.stopIndexOverscan)},z=o.useCallback(()=>se({cachedBounds:h,itemCount:i,itemSize:I}),[h,i,I]),A=o.useCallback(x=>{const T=N({containerElement:e,direction:r,isRtl:n,scrollOffset:x});return Y({cachedBounds:h,containerScrollOffset:T,containerSize:p,itemCount:i,overscanCount:a})},[h,e,p,r,n,i,a]);_(()=>{const x=(r==="vertical"?e?.scrollTop:e?.scrollLeft)??0;O(A(x))},[e,r,A]),_(()=>{if(!e)return;const x=()=>{O(T=>{const{scrollLeft:E,scrollTop:m}=e,v=N({containerElement:e,direction:r,isRtl:n,scrollOffset:r==="vertical"?m:E}),k=Y({cachedBounds:h,containerScrollOffset:v,containerSize:p,itemCount:i,overscanCount:a});return F(k,T)?T:k})};return e.addEventListener("scroll",x),()=>{e.removeEventListener("scroll",x)}},[h,e,p,r,i,a]);const S=te(({align:x="auto",containerScrollOffset:T,index:E})=>{let m=de({align:x,cachedBounds:h,containerScrollOffset:T,containerSize:p,index:E,itemCount:i,itemSize:I});if(e){if(m=N({containerElement:e,direction:r,isRtl:n,scrollOffset:m}),typeof e.scrollTo!="function"){const v=A(m);F(y,v)||O(v)}return m}});return{getCellBounds:w,getEstimatedSize:z,scrollToIndex:S,startIndexOverscan:b,startIndexVisible:B,stopIndexOverscan:M,stopIndexVisible:G}}function re(e){return o.useMemo(()=>e,Object.values(e))}function ne(e,t){const{ariaAttributes:s,style:r,...n}=e,{ariaAttributes:i,style:l,...f}=t;return F(s,i)&&F(r,l)&&F(n,f)}function xe({cellComponent:e,cellProps:t,children:s,className:r,columnCount:n,columnWidth:i,defaultHeight:l=0,defaultWidth:f=0,dir:c,gridRef:a,onCellsRendered:d,onResize:u,overscanCount:g=3,rowCount:p,rowHeight:I,style:h,tagName:w="div",...y}){const O=re(t),B=o.useMemo(()=>o.memo(e,ne),[e]),[b,G]=o.useState(null),M=ae(b,c),{getCellBounds:z,getEstimatedSize:A,startIndexOverscan:S,startIndexVisible:x,scrollToIndex:T,stopIndexOverscan:E,stopIndexVisible:m}=K({containerElement:b,containerStyle:h,defaultContainerSize:f,direction:"horizontal",isRtl:M,itemCount:n,itemProps:O,itemSize:i,onResize:u,overscanCount:g}),{getCellBounds:v,getEstimatedSize:k,startIndexOverscan:L,startIndexVisible:Z,scrollToIndex:C,stopIndexOverscan:U,stopIndexVisible:P}=K({containerElement:b,containerStyle:h,defaultContainerSize:l,direction:"vertical",itemCount:p,itemProps:O,itemSize:I,onResize:u,overscanCount:g});o.useImperativeHandle(a,()=>({get element(){return b},scrollToCell({behavior:$="auto",columnAlign:R="auto",columnIndex:H,rowAlign:j="auto",rowIndex:W}){const q=T({align:R,containerScrollOffset:b?.scrollLeft??0,index:H}),le=C({align:j,containerScrollOffset:b?.scrollTop??0,index:W});typeof b?.scrollTo=="function"&&b.scrollTo({behavior:$,left:q,top:le})},scrollToColumn({align:$="auto",behavior:R="auto",index:H}){const j=T({align:$,containerScrollOffset:b?.scrollLeft??0,index:H});typeof b?.scrollTo=="function"&&b.scrollTo({behavior:R,left:j})},scrollToRow({align:$="auto",behavior:R="auto",index:H}){const j=C({align:$,containerScrollOffset:b?.scrollTop??0,index:H});typeof b?.scrollTo=="function"&&b.scrollTo({behavior:R,top:j})}}),[b,T,C]),o.useEffect(()=>{S>=0&&E>=0&&L>=0&&U>=0&&d&&d({columnStartIndex:x,columnStopIndex:m,rowStartIndex:Z,rowStopIndex:P},{columnStartIndex:S,columnStopIndex:E,rowStartIndex:L,rowStopIndex:U})},[d,S,x,E,m,L,Z,U,P]);const oe=o.useMemo(()=>{const $=[];if(n>0&&p>0)for(let R=L;R<=U;R++){const H=v(R),j=[];for(let W=S;W<=E;W++){const q=z(W);j.push(o.createElement(B,{...O,ariaAttributes:{"aria-colindex":W+1,role:"gridcell"},columnIndex:W,key:W,rowIndex:R,style:{position:"absolute",left:M?void 0:0,right:M?0:void 0,transform:`translate(${M?-q.scrollOffset:q.scrollOffset}px, ${H.scrollOffset}px)`,height:H.size,width:q.size}}))}$.push(J.jsx("div",{role:"row","aria-rowindex":R+1,children:j},R))}return $},[B,O,n,S,E,z,v,M,p,L,U]),ie=J.jsx("div",{"aria-hidden":!0,style:{height:k(),width:A(),zIndex:-1}});return o.createElement(w,{"aria-colcount":n,"aria-rowcount":p,role:"grid",...y,className:r,dir:c,ref:G,style:{position:"relative",maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...h}},oe,s,ie)}const be=o.useState,ve=o.useRef;function me(e){return e!=null&&typeof e=="object"&&"getAverageRowHeight"in e&&typeof e.getAverageRowHeight=="function"}const Q="data-react-window-index";function Ie({children:e,className:t,defaultHeight:s=0,listRef:r,onResize:n,onRowsRendered:i,overscanCount:l=3,rowComponent:f,rowCount:c,rowHeight:a,rowProps:d,tagName:u="div",style:g,...p}){const I=re(d),h=o.useMemo(()=>o.memo(f,ne),[f]),[w,y]=o.useState(null),O=me(a),B=o.useMemo(()=>O?m=>a.getRowHeight(m)??a.getAverageRowHeight():a,[O,a]),{getCellBounds:b,getEstimatedSize:G,scrollToIndex:M,startIndexOverscan:z,startIndexVisible:A,stopIndexOverscan:S,stopIndexVisible:x}=K({containerElement:w,containerStyle:g,defaultContainerSize:s,direction:"vertical",itemCount:c,itemProps:I,itemSize:B,onResize:n,overscanCount:l});o.useImperativeHandle(r,()=>({get element(){return w},scrollToRow({align:m="auto",behavior:v="auto",index:k}){const L=M({align:m,containerScrollOffset:w?.scrollTop??0,index:k});typeof w?.scrollTo=="function"&&w.scrollTo({behavior:v,top:L})}}),[w,M]),_(()=>{if(!w)return;const m=Array.from(w.children).filter((v,k)=>{if(v.hasAttribute("aria-hidden"))return!1;const L=`${z+k}`;return v.setAttribute(Q,L),!0});if(O)return a.observeRowElements(m)},[w,O,a,z,S]),o.useEffect(()=>{z>=0&&S>=0&&i&&i({startIndex:A,stopIndex:x},{startIndex:z,stopIndex:S})},[i,z,A,S,x]);const T=o.useMemo(()=>{const m=[];if(c>0)for(let v=z;v<=S;v++){const k=b(v);m.push(o.createElement(h,{...I,ariaAttributes:{"aria-posinset":v+1,"aria-setsize":c,role:"listitem"},key:v,index:v,style:{position:"absolute",left:0,transform:`translateY(${k.scrollOffset}px)`,height:O?void 0:k.size,width:"100%"}}))}return m},[h,b,O,c,I,z,S]),E=J.jsx("div",{"aria-hidden":!0,style:{height:G(),width:"100%",zIndex:-1}});return o.createElement(u,{role:"list",...p,className:t,ref:y,style:{position:"relative",maxHeight:"100%",flexGrow:1,overflowY:"auto",...g}},T,e,E)}function we({defaultRowHeight:e,key:t}){const[s,r]=o.useState({key:t,map:new Map});s.key!==t&&r({key:t,map:new Map});const{map:n}=s,i=o.useCallback(()=>{let u=0;return n.forEach(g=>{u+=g}),u===0?e:u/n.size},[e,n]),l=o.useCallback(u=>{const g=n.get(u);return g!==void 0?g:(n.set(u,e),e)},[e,n]),f=o.useCallback((u,g)=>{r(p=>{if(p.map.get(u)===g)return p;const I=new Map(p.map);return I.set(u,g),{...p,map:I}})},[]),c=te(u=>{u.length!==0&&u.forEach(g=>{const{borderBoxSize:p,target:I}=g,h=I.getAttribute(Q);V(h!==null,`Invalid ${Q} attribute value`);const w=parseInt(h),{blockSize:y}=p[0];y&&f(w,y)})}),[a]=o.useState(()=>{if(typeof ResizeObserver<"u")return new ResizeObserver(c)});o.useEffect(()=>{if(a)return()=>{a.disconnect()}},[a]);const d=o.useCallback(u=>a?(u.forEach(g=>a.observe(g)),()=>{u.forEach(g=>a.unobserve(g))}):()=>{},[a]);return o.useMemo(()=>({getAverageRowHeight:i,getRowHeight:l,setRowHeight:f,observeRowElements:d}),[i,l,f,d])}const ye=o.useState,Oe=o.useRef;let X=-1;function Se(e=!1){if(X===-1||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",document.body.appendChild(t),X=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return X}exports.Grid=xe;exports.List=Ie;exports.getScrollbarSize=Se;exports.useDynamicRowHeight=we;exports.useGridCallbackRef=be;exports.useGridRef=ve;exports.useListCallbackRef=ye;exports.useListRef=Oe;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react/jsx-runtime"),i=require("react");function ue(e){let t=e;for(;t;){if(t.dir)return t.dir==="rtl";t=t.parentElement}return!1}function fe(e,t){const[s,r]=i.useState(t==="rtl");return i.useLayoutEffect(()=>{e&&(t||r(ue(e)))},[t,e]),s}const N=typeof window<"u"?i.useLayoutEffect:i.useEffect;function se(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function de({box:e,defaultHeight:t,defaultWidth:s,disabled:r,element:n,mode:o,style:c}){const{styleHeight:f,styleWidth:u}=i.useMemo(()=>({styleHeight:se(c?.height),styleWidth:se(c?.width)}),[c?.height,c?.width]),[l,d]=i.useState({height:t,width:s}),a=r||o==="only-height"&&f!==void 0||o==="only-width"&&u!==void 0||f!==void 0&&u!==void 0;return N(()=>{if(n===null||a)return;const x=new ResizeObserver(b=>{for(const I of b){const{contentRect:g,target:z}=I;n===z&&d(h=>h.height===g.height&&h.width===g.width?h:{height:g.height,width:g.width})}});return x.observe(n,{box:e}),()=>{x?.unobserve(n)}},[e,a,n,f,u]),i.useMemo(()=>({height:f??l.height,width:u??l.width}),[l,f,u])}function re(e){const t=i.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return N(()=>{t.current=e},[e]),i.useCallback((...s)=>t.current?.(...s),[t])}let G=null;function he(e=!1){if(G===null||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",s.direction="rtl";const r=document.createElement("div"),n=r.style;return n.width="100px",n.height="100px",t.appendChild(r),document.body.appendChild(t),t.scrollLeft>0?G="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?G="negative":G="positive-ascending"),document.body.removeChild(t),G}return G}function X({containerElement:e,direction:t,isRtl:s,scrollOffset:r}){if(t==="horizontal"&&s)switch(he()){case"negative":return-r;case"positive-descending":{if(e){const{clientWidth:n,scrollLeft:o,scrollWidth:c}=e;return c-n-o}break}}return r}function L(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function C(e,t){if(e===t)return!0;if(!!e!=!!t||(L(e!==void 0),L(t!==void 0),Object.keys(e).length!==Object.keys(t).length))return!1;for(const s in e)if(!Object.is(t[s],e[s]))return!1;return!0}function ne({cachedBounds:e,itemCount:t,itemSize:s}){if(t===0)return 0;if(typeof s=="number")return t*s;{const r=e.get(e.size===0?0:e.size-1);L(r!==void 0,"Unexpected bounds cache miss");const n=(r.scrollOffset+r.size)/e.size;return t*n}}function ge({align:e,cachedBounds:t,index:s,itemCount:r,itemSize:n,containerScrollOffset:o,containerSize:c}){if(s<0||s>=r)throw RangeError(`Invalid index specified: ${s}`,{cause:`Index ${s} is not within the range of 0 - ${r-1}`});const f=ne({cachedBounds:t,itemCount:r,itemSize:n}),u=t.get(s),l=Math.max(0,Math.min(f-c,u.scrollOffset)),d=Math.max(0,u.scrollOffset-c+u.size);switch(e==="smart"&&(o>=d&&o<=l?e="auto":e="center"),e){case"start":return l;case"end":return d;case"center":return u.scrollOffset<=c/2?0:u.scrollOffset+u.size/2>=f-c/2?f-c:u.scrollOffset+u.size/2-c/2;case"auto":default:return o>=d&&o<=l?o:o<d?d:l}}function J({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:r,overscanCount:n}){const o=r-1;let c=0,f=-1,u=0,l=-1,d=0;for(;d<o;){const a=e.get(d);if(a.scrollOffset+a.size>t)break;d++}for(c=d,u=Math.max(0,c-n);d<o;){const a=e.get(d);if(a.scrollOffset+a.size>=t+s)break;d++}return f=Math.min(o,d),l=Math.min(r-1,f+n),c<0&&(c=0,f=-1,u=0,l=-1),{startIndexVisible:c,stopIndexVisible:f,startIndexOverscan:u,stopIndexOverscan:l}}function pe({itemCount:e,itemProps:t,itemSize:s}){const r=new Map;return{get(n){for(L(n<e,`Invalid index ${n}`);r.size-1<n;){const c=r.size;let f;switch(typeof s){case"function":{f=s(c,t);break}case"number":{f=s;break}}if(c===0)r.set(c,{size:f,scrollOffset:0});else{const u=r.get(c-1);L(u!==void 0,`Unexpected bounds cache miss for index ${n}`),r.set(c,{scrollOffset:u.scrollOffset+u.size,size:f})}}const o=r.get(n);return L(o!==void 0,`Unexpected bounds cache miss for index ${n}`),o},set(n,o){r.set(n,o)},get size(){return r.size}}}function xe({itemCount:e,itemProps:t,itemSize:s}){return i.useMemo(()=>pe({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function be({containerSize:e,itemSize:t}){let s;switch(typeof t){case"string":{L(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),L(e!==void 0,"Container size must be defined if a percentage item size is specified"),s=e*parseInt(t)/100;break}default:{s=t;break}}return s}function P({containerElement:e,containerStyle:t,defaultContainerSize:s=0,direction:r,isRtl:n=!1,itemCount:o,itemProps:c,itemSize:f,onResize:u,overscanCount:l}){const{height:d=s,width:a=s}=de({defaultHeight:r==="vertical"?s:void 0,defaultWidth:r==="horizontal"?s:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:t}),x=i.useRef({height:0,width:0}),b=r==="vertical"?d:a,I=be({containerSize:b,itemSize:f});i.useLayoutEffect(()=>{if(typeof u=="function"){const p=x.current;(p.height!==d||p.width!==a)&&(u({height:d,width:a},{...p}),p.height=d,p.width=a)}},[d,u,a]);const g=xe({itemCount:o,itemProps:c,itemSize:I}),z=i.useCallback(p=>g.get(p),[g]),[h,j]=i.useState(()=>J({cachedBounds:g,containerScrollOffset:0,containerSize:b,itemCount:o,overscanCount:l})),{startIndexVisible:R,startIndexOverscan:E,stopIndexVisible:W,stopIndexOverscan:v}={startIndexVisible:Math.min(o-1,h.startIndexVisible),startIndexOverscan:Math.min(o-1,h.startIndexOverscan),stopIndexVisible:Math.min(o-1,h.stopIndexVisible),stopIndexOverscan:Math.min(o-1,h.stopIndexOverscan)},D=i.useCallback(()=>ne({cachedBounds:g,itemCount:o,itemSize:I}),[g,o,I]),O=i.useCallback(p=>{const S=X({containerElement:e,direction:r,isRtl:n,scrollOffset:p});return J({cachedBounds:g,containerScrollOffset:S,containerSize:b,itemCount:o,overscanCount:l})},[g,e,b,r,n,o,l]);N(()=>{const p=(r==="vertical"?e?.scrollTop:e?.scrollLeft)??0;j(O(p))},[e,r,O]),N(()=>{if(!e)return;const p=()=>{j(S=>{const{scrollLeft:V,scrollTop:T}=e,m=X({containerElement:e,direction:r,isRtl:n,scrollOffset:r==="vertical"?T:V}),w=J({cachedBounds:g,containerScrollOffset:m,containerSize:b,itemCount:o,overscanCount:l});return C(w,S)?S:w})};return e.addEventListener("scroll",p),()=>{e.removeEventListener("scroll",p)}},[g,e,b,r,o,l]);const B=re(({align:p="auto",containerScrollOffset:S,index:V})=>{let T=ge({align:p,cachedBounds:g,containerScrollOffset:S,containerSize:b,index:V,itemCount:o,itemSize:I});if(e){if(T=X({containerElement:e,direction:r,isRtl:n,scrollOffset:T}),typeof e.scrollTo!="function"){const m=O(T);C(h,m)||j(m)}return T}});return{getCellBounds:z,getEstimatedSize:D,scrollToIndex:B,startIndexOverscan:E,startIndexVisible:R,stopIndexOverscan:v,stopIndexVisible:W}}function oe(e){return i.useMemo(()=>e,Object.values(e))}function ie(e,t){const{ariaAttributes:s,style:r,...n}=e,{ariaAttributes:o,style:c,...f}=t;return C(s,o)&&C(r,c)&&C(n,f)}function ve({cellComponent:e,cellProps:t,children:s,className:r,columnCount:n,columnKey:o,columnWidth:c,defaultHeight:f=0,defaultWidth:u=0,dir:l,gridRef:d,onCellsRendered:a,onResize:x,overscanCount:b=3,rowCount:I,rowHeight:g,rowKey:z,style:h,tagName:j="div",...R}){const E=oe(t),W=i.useMemo(()=>i.memo(e,ie),[e]),[v,D]=i.useState(null),O=fe(v,l),{getCellBounds:B,getEstimatedSize:p,startIndexOverscan:S,startIndexVisible:V,scrollToIndex:T,stopIndexOverscan:m,stopIndexVisible:w}=P({containerElement:v,containerStyle:h,defaultContainerSize:u,direction:"horizontal",isRtl:O,itemCount:n,itemProps:E,itemSize:c,onResize:x,overscanCount:b}),{getCellBounds:k,getEstimatedSize:U,startIndexOverscan:q,startIndexVisible:ee,scrollToIndex:Y,stopIndexOverscan:F,stopIndexVisible:te}=P({containerElement:v,containerStyle:h,defaultContainerSize:f,direction:"vertical",itemCount:I,itemProps:E,itemSize:g,onResize:x,overscanCount:b});i.useImperativeHandle(d,()=>({get element(){return v},scrollToCell({behavior:A="auto",columnAlign:y="auto",columnIndex:$,rowAlign:H="auto",rowIndex:M}){const _=T({align:y,containerScrollOffset:v?.scrollLeft??0,index:$}),ae=Y({align:H,containerScrollOffset:v?.scrollTop??0,index:M});typeof v?.scrollTo=="function"&&v.scrollTo({behavior:A,left:_,top:ae})},scrollToColumn({align:A="auto",behavior:y="auto",index:$}){const H=T({align:A,containerScrollOffset:v?.scrollLeft??0,index:$});typeof v?.scrollTo=="function"&&v.scrollTo({behavior:y,left:H})},scrollToRow({align:A="auto",behavior:y="auto",index:$}){const H=Y({align:A,containerScrollOffset:v?.scrollTop??0,index:$});typeof v?.scrollTo=="function"&&v.scrollTo({behavior:y,top:H})}}),[v,T,Y]),i.useEffect(()=>{S>=0&&m>=0&&q>=0&&F>=0&&a&&a({columnStartIndex:V,columnStopIndex:w,rowStartIndex:ee,rowStopIndex:te},{columnStartIndex:S,columnStopIndex:m,rowStartIndex:q,rowStopIndex:F})},[a,S,V,m,w,q,ee,F,te]);const le=i.useMemo(()=>{const A=[];if(n>0&&I>0)for(let y=q;y<=F;y++){const $=k(y),H=[];for(let M=S;M<=m;M++){const _=B(M);H.push(i.createElement(W,{...E,ariaAttributes:{"aria-colindex":M+1,role:"gridcell"},columnIndex:M,key:o?o({columnIndex:M,data:E,rowIndex:y}):M,rowIndex:y,style:{position:"absolute",left:O?void 0:0,right:O?0:void 0,transform:`translate(${O?-_.scrollOffset:_.scrollOffset}px, ${$.scrollOffset}px)`,height:$.size,width:_.size}}))}A.push(Z.jsx("div",{role:"row","aria-rowindex":y+1,children:H},z?z({data:E,rowIndex:y}):y))}return A},[W,E,n,o,S,m,B,k,O,I,z,q,F]),ce=Z.jsx("div",{"aria-hidden":!0,style:{height:U(),width:p(),zIndex:-1}});return i.createElement(j,{"aria-colcount":n,"aria-rowcount":I,role:"grid",...R,className:r,dir:l,ref:D,style:{position:"relative",maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...h}},le,s,ce)}const me=i.useState,Ie=i.useRef;function we(e){return e!=null&&typeof e=="object"&&"getAverageRowHeight"in e&&typeof e.getAverageRowHeight=="function"}const K="data-react-window-index";function Oe({children:e,className:t,defaultHeight:s=0,listRef:r,onResize:n,onRowsRendered:o,overscanCount:c=3,rowComponent:f,rowCount:u,rowHeight:l,rowKey:d,rowProps:a,tagName:x="div",style:b,...I}){const g=oe(a),z=i.useMemo(()=>i.memo(f,ie),[f]),[h,j]=i.useState(null),R=we(l),E=i.useMemo(()=>R?m=>l.getRowHeight(m)??l.getAverageRowHeight():l,[R,l]),{getCellBounds:W,getEstimatedSize:v,scrollToIndex:D,startIndexOverscan:O,startIndexVisible:B,stopIndexOverscan:p,stopIndexVisible:S}=P({containerElement:h,containerStyle:b,defaultContainerSize:s,direction:"vertical",itemCount:u,itemProps:g,itemSize:E,onResize:n,overscanCount:c});i.useImperativeHandle(r,()=>({get element(){return h},scrollToRow({align:m="auto",behavior:w="auto",index:k}){const U=D({align:m,containerScrollOffset:h?.scrollTop??0,index:k});typeof h?.scrollTo=="function"&&h.scrollTo({behavior:w,top:U})}}),[h,D]),N(()=>{if(!h)return;const m=Array.from(h.children).filter((w,k)=>{if(w.hasAttribute("aria-hidden"))return!1;const U=`${O+k}`;return w.setAttribute(K,U),!0});if(R)return l.observeRowElements(m)},[h,R,l,O,p]),i.useEffect(()=>{O>=0&&p>=0&&o&&o({startIndex:B,stopIndex:S},{startIndex:O,stopIndex:p})},[o,O,B,p,S]);const V=i.useMemo(()=>{const m=[];if(u>0)for(let w=O;w<=p;w++){const k=W(w);m.push(i.createElement(z,{...g,ariaAttributes:{"aria-posinset":w+1,"aria-setsize":u,role:"listitem"},key:d?d(w,g):w,index:w,style:{position:"absolute",left:0,transform:`translateY(${k.scrollOffset}px)`,height:R?void 0:k.size,width:"100%"}}))}return m},[z,W,R,u,d,g,O,p]),T=Z.jsx("div",{"aria-hidden":!0,style:{height:v(),width:"100%",zIndex:-1}});return i.createElement(x,{role:"list",...I,className:t,ref:j,style:{position:"relative",maxHeight:"100%",flexGrow:1,overflowY:"auto",...b}},V,e,T)}function Se({defaultRowHeight:e,key:t}){const[s,r]=i.useState({key:t,map:new Map});s.key!==t&&r({key:t,map:new Map});const{map:n}=s,o=i.useCallback(()=>{let a=0;return n.forEach(x=>{a+=x}),a===0?e:a/n.size},[e,n]),c=i.useCallback(a=>{const x=n.get(a);return x!==void 0?x:(n.set(a,e),e)},[e,n]),f=i.useCallback((a,x)=>{r(b=>{if(b.map.get(a)===x)return b;const I=new Map(b.map);return I.set(a,x),{...b,map:I}})},[]),u=re(a=>{a.length!==0&&a.forEach(x=>{const{borderBoxSize:b,target:I}=x,g=I.getAttribute(K);L(g!==null,`Invalid ${K} attribute value`);const z=parseInt(g),{blockSize:h}=b[0];h&&f(z,h)})}),[l]=i.useState(()=>{if(typeof ResizeObserver<"u")return new ResizeObserver(u)});i.useEffect(()=>{if(l)return()=>{l.disconnect()}},[l]);const d=i.useCallback(a=>l?(a.forEach(x=>l.observe(x)),()=>{a.forEach(x=>l.unobserve(x))}):()=>{},[l]);return i.useMemo(()=>({getAverageRowHeight:o,getRowHeight:c,setRowHeight:f,observeRowElements:d}),[o,c,f,d])}const ye=i.useState,ze=i.useRef;let Q=-1;function Te(e=!1){if(Q===-1||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",document.body.appendChild(t),Q=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Q}exports.Grid=ve;exports.List=Oe;exports.getScrollbarSize=Te;exports.useDynamicRowHeight=Se;exports.useGridCallbackRef=me;exports.useGridRef=Ie;exports.useListCallbackRef=ye;exports.useListRef=ze;
2
2
  //# sourceMappingURL=react-window.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-window.cjs","sources":["../lib/utils/isRtl.ts","../lib/core/useIsRtl.ts","../lib/hooks/useIsomorphicLayoutEffect.ts","../lib/utils/parseNumericStyleValue.ts","../lib/hooks/useResizeObserver.ts","../lib/hooks/useStableCallback.ts","../lib/utils/getRTLOffsetType.ts","../lib/utils/adjustScrollOffsetForRtl.ts","../lib/utils/assert.ts","../lib/utils/shallowCompare.ts","../lib/core/getEstimatedSize.ts","../lib/core/getOffsetForIndex.ts","../lib/core/getStartStopIndices.ts","../lib/core/createCachedBounds.ts","../lib/core/useCachedBounds.ts","../lib/core/useItemSize.ts","../lib/core/useVirtualizer.ts","../lib/hooks/useMemoizedObject.ts","../lib/utils/arePropsEqual.ts","../lib/components/grid/Grid.tsx","../lib/components/grid/useGridCallbackRef.ts","../lib/components/grid/useGridRef.ts","../lib/components/list/isDynamicRowHeight.ts","../lib/components/list/List.tsx","../lib/components/list/useDynamicRowHeight.ts","../lib/components/list/useListCallbackRef.ts","../lib/components/list/useListRef.ts","../lib/utils/getScrollbarSize.ts"],"sourcesContent":["export function isRtl(element: HTMLElement) {\n let currentElement: HTMLElement | null = element;\n while (currentElement) {\n if (currentElement.dir) {\n return currentElement.dir === \"rtl\";\n }\n\n currentElement = currentElement.parentElement;\n }\n\n return false;\n}\n","import { useLayoutEffect, useState, type HTMLAttributes } from \"react\";\nimport { isRtl } from \"../utils/isRtl\";\n\nexport function useIsRtl(\n element: HTMLElement | null,\n dir: HTMLAttributes<HTMLElement>[\"dir\"]\n) {\n const [value, setValue] = useState(dir === \"rtl\");\n\n useLayoutEffect(() => {\n if (element) {\n if (!dir) {\n setValue(isRtl(element));\n }\n }\n }, [dir, element]);\n\n return value;\n}\n","import { useEffect, useLayoutEffect } from \"react\";\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import type { CSSProperties } from \"react\";\n\nexport function parseNumericStyleValue(\n value: CSSProperties[\"height\"]\n): number | undefined {\n if (value !== undefined) {\n switch (typeof value) {\n case \"number\": {\n return value;\n }\n case \"string\": {\n if (value.endsWith(\"px\")) {\n return parseFloat(value);\n }\n break;\n }\n }\n }\n}\n","import { useMemo, useState, type CSSProperties } from \"react\";\nimport { parseNumericStyleValue } from \"../utils/parseNumericStyleValue\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nexport function useResizeObserver({\n box,\n defaultHeight,\n defaultWidth,\n disabled: disabledProp,\n element,\n mode,\n style\n}: {\n box?: ResizeObserverBoxOptions;\n defaultHeight?: number;\n defaultWidth?: number;\n disabled?: boolean;\n element: HTMLElement | null;\n mode?: \"only-height\" | \"only-width\";\n style: CSSProperties | undefined;\n}) {\n const { styleHeight, styleWidth } = useMemo(\n () => ({\n styleHeight: parseNumericStyleValue(style?.height),\n styleWidth: parseNumericStyleValue(style?.width)\n }),\n [style?.height, style?.width]\n );\n\n const [state, setState] = useState<{\n height: number | undefined;\n width: number | undefined;\n }>({\n height: defaultHeight,\n width: defaultWidth\n });\n\n const disabled =\n disabledProp ||\n (mode === \"only-height\" && styleHeight !== undefined) ||\n (mode === \"only-width\" && styleWidth !== undefined) ||\n (styleHeight !== undefined && styleWidth !== undefined);\n\n useIsomorphicLayoutEffect(() => {\n if (element === null || disabled) {\n return;\n }\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const { contentRect, target } = entry;\n if (element === target) {\n setState((prevState) => {\n if (\n prevState.height === contentRect.height &&\n prevState.width === contentRect.width\n ) {\n return prevState;\n }\n\n return {\n height: contentRect.height,\n width: contentRect.width\n };\n });\n }\n }\n });\n resizeObserver.observe(element, { box });\n\n return () => {\n resizeObserver?.unobserve(element);\n };\n }, [box, disabled, element, styleHeight, styleWidth]);\n\n return useMemo(\n () => ({\n height: styleHeight ?? state.height,\n width: styleWidth ?? state.width\n }),\n [state, styleHeight, styleWidth]\n );\n}\n","import { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n// Forked from useEventCallback (usehooks-ts)\nexport function useStableCallback<Args, Return>(\n fn: (args: Args) => Return\n): (args: Args) => Return {\n const ref = useRef<typeof fn>(() => {\n throw new Error(\"Cannot call during render.\");\n });\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n\n return useCallback((args: Args) => ref.current?.(args), [ref]) as (\n args: Args\n ) => Return;\n}\n","export type RTLOffsetType =\n | \"negative\"\n | \"positive-descending\"\n | \"positive-ascending\";\n\nlet cachedRTLResult: RTLOffsetType | null = null;\n\n// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.\n// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).\n// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.\n// The safest way to check this is to intentionally set a negative offset,\n// and then verify that the subsequent \"scroll\" event matches the negative offset.\n// If it does not match, then we can assume a non-standard RTL scroll implementation.\nexport function getRTLOffsetType(recalculate: boolean = false): RTLOffsetType {\n if (cachedRTLResult === null || recalculate) {\n const outerDiv = document.createElement(\"div\");\n const outerStyle = outerDiv.style;\n outerStyle.width = \"50px\";\n outerStyle.height = \"50px\";\n outerStyle.overflow = \"scroll\";\n outerStyle.direction = \"rtl\";\n\n const innerDiv = document.createElement(\"div\");\n const innerStyle = innerDiv.style;\n innerStyle.width = \"100px\";\n innerStyle.height = \"100px\";\n\n outerDiv.appendChild(innerDiv);\n\n document.body.appendChild(outerDiv);\n\n if (outerDiv.scrollLeft > 0) {\n cachedRTLResult = \"positive-descending\";\n } else {\n outerDiv.scrollLeft = 1;\n if (outerDiv.scrollLeft === 0) {\n cachedRTLResult = \"negative\";\n } else {\n cachedRTLResult = \"positive-ascending\";\n }\n }\n\n document.body.removeChild(outerDiv);\n\n return cachedRTLResult;\n }\n\n return cachedRTLResult;\n}\n","import type { Direction } from \"../core/types\";\nimport { getRTLOffsetType } from \"./getRTLOffsetType\";\n\nexport function adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n}: {\n containerElement: HTMLElement | null;\n direction: Direction;\n isRtl: boolean;\n scrollOffset: number;\n}) {\n // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.\n // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).\n // So we need to determine which browser behavior we're dealing with, and mimic it.\n if (direction === \"horizontal\") {\n if (isRtl) {\n switch (getRTLOffsetType()) {\n case \"negative\": {\n return -scrollOffset;\n }\n case \"positive-descending\": {\n if (containerElement) {\n const { clientWidth, scrollLeft, scrollWidth } = containerElement;\n return scrollWidth - clientWidth - scrollLeft;\n }\n break;\n }\n }\n }\n }\n return scrollOffset;\n}\n","export function assert(\n expectedCondition: unknown,\n message: string = \"Assertion error\"\n): asserts expectedCondition {\n if (!expectedCondition) {\n console.error(message);\n\n throw Error(message);\n }\n}\n","import { assert } from \"./assert\";\n\nexport function shallowCompare<Type extends object>(\n a: Type | undefined,\n b: Type | undefined\n) {\n if (a === b) {\n return true;\n }\n\n if (!!a !== !!b) {\n return false;\n }\n\n assert(a !== undefined);\n assert(b !== undefined);\n\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n for (const key in a) {\n if (!Object.is(b[key], a[key])) {\n return false;\n }\n }\n\n return true;\n}\n","import type { CachedBounds, SizeFunction } from \"./types\";\nimport { assert } from \"../utils/assert\";\n\nexport function getEstimatedSize<Props extends object>({\n cachedBounds,\n itemCount,\n itemSize\n}: {\n cachedBounds: CachedBounds;\n itemCount: number;\n itemSize: number | SizeFunction<Props>;\n}) {\n if (itemCount === 0) {\n return 0;\n } else if (typeof itemSize === \"number\") {\n return itemCount * itemSize;\n } else {\n const bounds = cachedBounds.get(\n cachedBounds.size === 0 ? 0 : cachedBounds.size - 1\n );\n assert(bounds !== undefined, \"Unexpected bounds cache miss\");\n\n const averageItemSize =\n (bounds.scrollOffset + bounds.size) / cachedBounds.size;\n\n return itemCount * averageItemSize;\n }\n}\n","import type { Align } from \"../types\";\nimport { getEstimatedSize } from \"./getEstimatedSize\";\nimport type { CachedBounds, SizeFunction } from \"./types\";\n\nexport function getOffsetForIndex<Props extends object>({\n align,\n cachedBounds,\n index,\n itemCount,\n itemSize,\n containerScrollOffset,\n containerSize\n}: {\n align: Align;\n cachedBounds: CachedBounds;\n index: number;\n itemCount: number;\n itemSize: number | SizeFunction<Props>;\n containerScrollOffset: number;\n containerSize: number;\n}) {\n if (index < 0 || index >= itemCount) {\n throw RangeError(`Invalid index specified: ${index}`, {\n cause: `Index ${index} is not within the range of 0 - ${itemCount - 1}`\n });\n }\n\n const estimatedTotalSize = getEstimatedSize({\n cachedBounds,\n itemCount,\n itemSize\n });\n\n const bounds = cachedBounds.get(index);\n const maxOffset = Math.max(\n 0,\n Math.min(estimatedTotalSize - containerSize, bounds.scrollOffset)\n );\n const minOffset = Math.max(\n 0,\n bounds.scrollOffset - containerSize + bounds.size\n );\n\n if (align === \"smart\") {\n if (\n containerScrollOffset >= minOffset &&\n containerScrollOffset <= maxOffset\n ) {\n align = \"auto\";\n } else {\n align = \"center\";\n }\n }\n\n switch (align) {\n case \"start\": {\n return maxOffset;\n }\n case \"end\": {\n return minOffset;\n }\n case \"center\": {\n if (bounds.scrollOffset <= containerSize / 2) {\n // Too near the beginning to center-align\n return 0;\n } else if (\n bounds.scrollOffset + bounds.size / 2 >=\n estimatedTotalSize - containerSize / 2\n ) {\n // Too near the end to center-align\n return estimatedTotalSize - containerSize;\n } else {\n return bounds.scrollOffset + bounds.size / 2 - containerSize / 2;\n }\n }\n case \"auto\":\n default: {\n if (\n containerScrollOffset >= minOffset &&\n containerScrollOffset <= maxOffset\n ) {\n return containerScrollOffset;\n } else if (containerScrollOffset < minOffset) {\n return minOffset;\n } else {\n return maxOffset;\n }\n }\n }\n}\n","import type { CachedBounds } from \"./types\";\n\nexport function getStartStopIndices({\n cachedBounds,\n containerScrollOffset,\n containerSize,\n itemCount,\n overscanCount\n}: {\n cachedBounds: CachedBounds;\n containerScrollOffset: number;\n containerSize: number;\n itemCount: number;\n overscanCount: number;\n}): {\n startIndexVisible: number;\n stopIndexVisible: number;\n startIndexOverscan: number;\n stopIndexOverscan: number;\n} {\n const maxIndex = itemCount - 1;\n\n let startIndexVisible = 0;\n let stopIndexVisible = -1;\n let startIndexOverscan = 0;\n let stopIndexOverscan = -1;\n let currentIndex = 0;\n\n while (currentIndex < maxIndex) {\n const bounds = cachedBounds.get(currentIndex);\n\n if (bounds.scrollOffset + bounds.size > containerScrollOffset) {\n break;\n }\n\n currentIndex++;\n }\n\n startIndexVisible = currentIndex;\n startIndexOverscan = Math.max(0, startIndexVisible - overscanCount);\n\n while (currentIndex < maxIndex) {\n const bounds = cachedBounds.get(currentIndex);\n\n if (\n bounds.scrollOffset + bounds.size >=\n containerScrollOffset + containerSize\n ) {\n break;\n }\n\n currentIndex++;\n }\n\n stopIndexVisible = Math.min(maxIndex, currentIndex);\n stopIndexOverscan = Math.min(itemCount - 1, stopIndexVisible + overscanCount);\n\n if (startIndexVisible < 0) {\n startIndexVisible = 0;\n stopIndexVisible = -1;\n startIndexOverscan = 0;\n stopIndexOverscan = -1;\n }\n\n return {\n startIndexVisible,\n stopIndexVisible,\n startIndexOverscan,\n stopIndexOverscan\n };\n}\n","import { assert } from \"../utils/assert\";\nimport type { Bounds, CachedBounds, SizeFunction } from \"./types\";\n\nexport function createCachedBounds<Props extends object>({\n itemCount,\n itemProps,\n itemSize\n}: {\n itemCount: number;\n itemProps: Props;\n itemSize: number | SizeFunction<Props>;\n}): CachedBounds {\n const cache = new Map<number, Bounds>();\n\n return {\n get(index: number) {\n assert(index < itemCount, `Invalid index ${index}`);\n\n while (cache.size - 1 < index) {\n const currentIndex = cache.size;\n\n let size: number;\n switch (typeof itemSize) {\n case \"function\": {\n size = itemSize(currentIndex, itemProps);\n break;\n }\n case \"number\": {\n size = itemSize;\n break;\n }\n }\n\n if (currentIndex === 0) {\n cache.set(currentIndex, {\n size,\n scrollOffset: 0\n });\n } else {\n const previousRowBounds = cache.get(currentIndex - 1);\n assert(\n previousRowBounds !== undefined,\n `Unexpected bounds cache miss for index ${index}`\n );\n\n cache.set(currentIndex, {\n scrollOffset:\n previousRowBounds.scrollOffset + previousRowBounds.size,\n size\n });\n }\n }\n\n const bounds = cache.get(index);\n assert(\n bounds !== undefined,\n `Unexpected bounds cache miss for index ${index}`\n );\n\n return bounds;\n },\n set(index: number, bounds: Bounds) {\n cache.set(index, bounds);\n },\n get size() {\n return cache.size;\n }\n };\n}\n","import { useMemo } from \"react\";\nimport { createCachedBounds } from \"./createCachedBounds\";\nimport type { CachedBounds, SizeFunction } from \"./types\";\n\nexport function useCachedBounds<Props extends object>({\n itemCount,\n itemProps,\n itemSize\n}: {\n itemCount: number;\n itemProps: Props;\n itemSize: number | SizeFunction<Props>;\n}): CachedBounds {\n return useMemo(\n () =>\n createCachedBounds({\n itemCount,\n itemProps,\n itemSize\n }),\n [itemCount, itemProps, itemSize]\n );\n}\n","import { assert } from \"../utils/assert\";\nimport type { SizeFunction } from \"./types\";\n\nexport function useItemSize<Props extends object>({\n containerSize,\n itemSize: itemSizeProp\n}: {\n containerSize: number;\n itemSize: number | string | SizeFunction<Props>;\n}) {\n let itemSize: number | SizeFunction<Props>;\n switch (typeof itemSizeProp) {\n case \"string\": {\n assert(\n itemSizeProp.endsWith(\"%\"),\n `Invalid item size: \"${itemSizeProp}\"; string values must be percentages (e.g. \"100%\")`\n );\n assert(\n containerSize !== undefined,\n \"Container size must be defined if a percentage item size is specified\"\n );\n\n itemSize = (containerSize * parseInt(itemSizeProp)) / 100;\n break;\n }\n default: {\n itemSize = itemSizeProp;\n break;\n }\n }\n\n return itemSize;\n}\n","import {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties\n} from \"react\";\nimport { useIsomorphicLayoutEffect } from \"../hooks/useIsomorphicLayoutEffect\";\nimport { useResizeObserver } from \"../hooks/useResizeObserver\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport type { Align } from \"../types\";\nimport { adjustScrollOffsetForRtl } from \"../utils/adjustScrollOffsetForRtl\";\nimport { shallowCompare } from \"../utils/shallowCompare\";\nimport { getEstimatedSize as getEstimatedSizeUtil } from \"./getEstimatedSize\";\nimport { getOffsetForIndex } from \"./getOffsetForIndex\";\nimport { getStartStopIndices as getStartStopIndicesUtil } from \"./getStartStopIndices\";\nimport type { Direction, SizeFunction } from \"./types\";\nimport { useCachedBounds } from \"./useCachedBounds\";\nimport { useItemSize } from \"./useItemSize\";\n\nexport function useVirtualizer<Props extends object>({\n containerElement,\n containerStyle,\n defaultContainerSize = 0,\n direction,\n isRtl = false,\n itemCount,\n itemProps,\n itemSize: itemSizeProp,\n onResize,\n overscanCount\n}: {\n containerElement: HTMLElement | null;\n containerStyle?: CSSProperties;\n defaultContainerSize?: number;\n direction: Direction;\n isRtl?: boolean;\n itemCount: number;\n itemProps: Props;\n itemSize: number | string | SizeFunction<Props>;\n onResize:\n | ((\n size: { height: number; width: number },\n prevSize: { height: number; width: number }\n ) => void)\n | undefined;\n overscanCount: number;\n}) {\n const { height = defaultContainerSize, width = defaultContainerSize } =\n useResizeObserver({\n defaultHeight:\n direction === \"vertical\" ? defaultContainerSize : undefined,\n defaultWidth:\n direction === \"horizontal\" ? defaultContainerSize : undefined,\n element: containerElement,\n mode: direction === \"vertical\" ? \"only-height\" : \"only-width\",\n style: containerStyle\n });\n\n const prevSizeRef = useRef<{ height: number; width: number }>({\n height: 0,\n width: 0\n });\n\n const containerSize = direction === \"vertical\" ? height : width;\n\n const itemSize = useItemSize({ containerSize, itemSize: itemSizeProp });\n\n useLayoutEffect(() => {\n if (typeof onResize === \"function\") {\n const prevSize = prevSizeRef.current;\n\n if (prevSize.height !== height || prevSize.width !== width) {\n onResize({ height, width }, { ...prevSize });\n\n prevSize.height = height;\n prevSize.width = width;\n }\n }\n }, [height, onResize, width]);\n\n const cachedBounds = useCachedBounds({\n itemCount,\n itemProps,\n itemSize\n });\n\n const getCellBounds = useCallback(\n (index: number) => cachedBounds.get(index),\n [cachedBounds]\n );\n\n const [indices, setIndices] = useState<{\n startIndexVisible: number;\n stopIndexVisible: number;\n startIndexOverscan: number;\n stopIndexOverscan: number;\n }>(() =>\n getStartStopIndicesUtil({\n cachedBounds,\n // TODO Potentially support a defaultScrollOffset prop?\n containerScrollOffset: 0,\n containerSize,\n itemCount,\n overscanCount\n })\n );\n\n // Guard against temporarily invalid indices that may occur when item count decreases\n // Cached bounds object will be re-created and a second render will restore things\n const {\n startIndexVisible,\n startIndexOverscan,\n stopIndexVisible,\n stopIndexOverscan\n } = {\n startIndexVisible: Math.min(itemCount - 1, indices.startIndexVisible),\n startIndexOverscan: Math.min(itemCount - 1, indices.startIndexOverscan),\n stopIndexVisible: Math.min(itemCount - 1, indices.stopIndexVisible),\n stopIndexOverscan: Math.min(itemCount - 1, indices.stopIndexOverscan)\n };\n\n const getEstimatedSize = useCallback(\n () =>\n getEstimatedSizeUtil({\n cachedBounds,\n itemCount,\n itemSize\n }),\n [cachedBounds, itemCount, itemSize]\n );\n\n const getStartStopIndices = useCallback(\n (scrollOffset: number) => {\n const containerScrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n });\n\n return getStartStopIndicesUtil({\n cachedBounds,\n containerScrollOffset,\n containerSize,\n itemCount,\n overscanCount\n });\n },\n [\n cachedBounds,\n containerElement,\n containerSize,\n direction,\n isRtl,\n itemCount,\n overscanCount\n ]\n );\n\n useIsomorphicLayoutEffect(() => {\n const scrollOffset =\n (direction === \"vertical\"\n ? containerElement?.scrollTop\n : containerElement?.scrollLeft) ?? 0;\n\n setIndices(getStartStopIndices(scrollOffset));\n }, [containerElement, direction, getStartStopIndices]);\n\n useIsomorphicLayoutEffect(() => {\n if (!containerElement) {\n return;\n }\n\n const onScroll = () => {\n setIndices((prev) => {\n const { scrollLeft, scrollTop } = containerElement;\n\n const scrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset: direction === \"vertical\" ? scrollTop : scrollLeft\n });\n\n const next = getStartStopIndicesUtil({\n cachedBounds,\n containerScrollOffset: scrollOffset,\n containerSize,\n itemCount,\n overscanCount\n });\n\n if (shallowCompare(next, prev)) {\n return prev;\n }\n\n return next;\n });\n };\n\n containerElement.addEventListener(\"scroll\", onScroll);\n\n return () => {\n containerElement.removeEventListener(\"scroll\", onScroll);\n };\n }, [\n cachedBounds,\n containerElement,\n containerSize,\n direction,\n itemCount,\n overscanCount\n ]);\n\n const scrollToIndex = useStableCallback(\n ({\n align = \"auto\",\n containerScrollOffset,\n index\n }: {\n align?: Align;\n containerScrollOffset: number;\n index: number;\n }) => {\n let scrollOffset = getOffsetForIndex({\n align,\n cachedBounds,\n containerScrollOffset,\n containerSize,\n index,\n itemCount,\n itemSize\n });\n\n if (containerElement) {\n scrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n });\n\n if (typeof containerElement.scrollTo !== \"function\") {\n // Special case for environments like jsdom that don't implement scrollTo\n const next = getStartStopIndices(scrollOffset);\n if (!shallowCompare(indices, next)) {\n setIndices(next);\n }\n }\n\n return scrollOffset;\n }\n }\n );\n\n return {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n };\n}\n","import { useMemo } from \"react\";\n\nexport function useMemoizedObject<Type extends object>(\n unstableObject: Type\n): Type {\n return useMemo(() => {\n return unstableObject;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, Object.values(unstableObject));\n}\n","import type { CSSProperties } from \"react\";\nimport { shallowCompare } from \"./shallowCompare\";\n\n// Custom comparison function for React.memo()\n// It knows to compare individual style props and ignore the wrapper object.\n// See https://react.dev/reference/react/memo#memo\nexport function arePropsEqual(\n prevProps: { ariaAttributes: object; style: CSSProperties },\n nextProps: { ariaAttributes: object; style: CSSProperties }\n): boolean {\n const {\n ariaAttributes: prevAriaAttributes,\n style: prevStyle,\n ...prevRest\n } = prevProps;\n const {\n ariaAttributes: nextAriaAttributes,\n style: nextStyle,\n ...nextRest\n } = nextProps;\n\n return (\n shallowCompare(prevAriaAttributes, nextAriaAttributes) &&\n shallowCompare(prevStyle, nextStyle) &&\n shallowCompare(prevRest, nextRest)\n );\n}\n","\"use client\";\n\nimport {\n createElement,\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode\n} from \"react\";\nimport { useIsRtl } from \"../../core/useIsRtl\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align, TagNames } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { GridProps } from \"./types\";\n\n/**\n * Renders data with many rows and columns.\n *\n * ℹ️ Unlike `List` rows, `Grid` cell sizes must be known ahead of time.\n * Either static sizes or something that can be derived (from the data in `CellProps`) without rendering.\n */\nexport function Grid<\n CellProps extends object,\n TagName extends TagNames = \"div\"\n>({\n cellComponent: CellComponentProp,\n cellProps: cellPropsUnstable,\n children,\n className,\n columnCount,\n columnWidth,\n defaultHeight = 0,\n defaultWidth = 0,\n dir,\n gridRef,\n onCellsRendered,\n onResize,\n overscanCount = 3,\n rowCount,\n rowHeight,\n style,\n tagName = \"div\" as TagName,\n ...rest\n}: GridProps<CellProps, TagName>): ReactElement {\n const cellProps = useMemoizedObject(cellPropsUnstable);\n const CellComponent = useMemo(\n () => memo(CellComponentProp, arePropsEqual),\n [CellComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const isRtl = useIsRtl(element, dir);\n\n const {\n getCellBounds: getColumnBounds,\n getEstimatedSize: getEstimatedWidth,\n startIndexOverscan: columnStartIndexOverscan,\n startIndexVisible: columnStartIndexVisible,\n scrollToIndex: scrollToColumnIndex,\n stopIndexOverscan: columnStopIndexOverscan,\n stopIndexVisible: columnStopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultWidth,\n direction: \"horizontal\",\n isRtl,\n itemCount: columnCount,\n itemProps: cellProps,\n itemSize: columnWidth,\n onResize,\n overscanCount\n });\n\n const {\n getCellBounds: getRowBounds,\n getEstimatedSize: getEstimatedHeight,\n startIndexOverscan: rowStartIndexOverscan,\n startIndexVisible: rowStartIndexVisible,\n scrollToIndex: scrollToRowIndex,\n stopIndexOverscan: rowStopIndexOverscan,\n stopIndexVisible: rowStopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: cellProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n gridRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToCell({\n behavior = \"auto\",\n columnAlign = \"auto\",\n columnIndex,\n rowAlign = \"auto\",\n rowIndex\n }: {\n behavior?: ScrollBehavior;\n columnAlign?: Align;\n columnIndex: number;\n rowAlign?: Align;\n rowIndex: number;\n }) {\n const left = scrollToColumnIndex({\n align: columnAlign,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index: columnIndex\n });\n const top = scrollToRowIndex({\n align: rowAlign,\n containerScrollOffset: element?.scrollTop ?? 0,\n index: rowIndex\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n left,\n top\n });\n }\n },\n\n scrollToColumn({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const left = scrollToColumnIndex({\n align,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n left\n });\n }\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const top = scrollToRowIndex({\n align,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n top\n });\n }\n }\n }),\n [element, scrollToColumnIndex, scrollToRowIndex]\n );\n\n useEffect(() => {\n if (\n columnStartIndexOverscan >= 0 &&\n columnStopIndexOverscan >= 0 &&\n rowStartIndexOverscan >= 0 &&\n rowStopIndexOverscan >= 0 &&\n onCellsRendered\n ) {\n onCellsRendered(\n {\n columnStartIndex: columnStartIndexVisible,\n columnStopIndex: columnStopIndexVisible,\n rowStartIndex: rowStartIndexVisible,\n rowStopIndex: rowStopIndexVisible\n },\n {\n columnStartIndex: columnStartIndexOverscan,\n columnStopIndex: columnStopIndexOverscan,\n rowStartIndex: rowStartIndexOverscan,\n rowStopIndex: rowStopIndexOverscan\n }\n );\n }\n }, [\n onCellsRendered,\n columnStartIndexOverscan,\n columnStartIndexVisible,\n columnStopIndexOverscan,\n columnStopIndexVisible,\n rowStartIndexOverscan,\n rowStartIndexVisible,\n rowStopIndexOverscan,\n rowStopIndexVisible\n ]);\n\n const cells = useMemo(() => {\n const children: ReactNode[] = [];\n if (columnCount > 0 && rowCount > 0) {\n for (\n let rowIndex = rowStartIndexOverscan;\n rowIndex <= rowStopIndexOverscan;\n rowIndex++\n ) {\n const rowBounds = getRowBounds(rowIndex);\n\n const columns: ReactNode[] = [];\n\n for (\n let columnIndex = columnStartIndexOverscan;\n columnIndex <= columnStopIndexOverscan;\n columnIndex++\n ) {\n const columnBounds = getColumnBounds(columnIndex);\n\n columns.push(\n <CellComponent\n {...(cellProps as CellProps)}\n ariaAttributes={{\n \"aria-colindex\": columnIndex + 1,\n role: \"gridcell\"\n }}\n columnIndex={columnIndex}\n key={columnIndex}\n rowIndex={rowIndex}\n style={{\n position: \"absolute\",\n left: isRtl ? undefined : 0,\n right: isRtl ? 0 : undefined,\n transform: `translate(${isRtl ? -columnBounds.scrollOffset : columnBounds.scrollOffset}px, ${rowBounds.scrollOffset}px)`,\n height: rowBounds.size,\n width: columnBounds.size\n }}\n />\n );\n }\n\n children.push(\n <div key={rowIndex} role=\"row\" aria-rowindex={rowIndex + 1}>\n {columns}\n </div>\n );\n }\n }\n return children;\n }, [\n CellComponent,\n cellProps,\n columnCount,\n columnStartIndexOverscan,\n columnStopIndexOverscan,\n getColumnBounds,\n getRowBounds,\n isRtl,\n rowCount,\n rowStartIndexOverscan,\n rowStopIndexOverscan\n ]);\n\n const sizingElement = (\n <div\n aria-hidden\n style={{\n height: getEstimatedHeight(),\n width: getEstimatedWidth(),\n zIndex: -1\n }}\n ></div>\n );\n\n return createElement(\n tagName,\n {\n \"aria-colcount\": columnCount,\n \"aria-rowcount\": rowCount,\n role: \"grid\",\n ...rest,\n className,\n dir,\n ref: setElement,\n style: {\n position: \"relative\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n flexGrow: 1,\n overflow: \"auto\",\n ...style\n }\n },\n cells,\n children,\n sizingElement\n );\n}\n","import { useState } from \"react\";\nimport type { GridImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref callback for the Grid component.\n *\n * Use this hook when you need to share the ref with another component or hook.\n */\nexport const useGridCallbackRef =\n useState as typeof useState<GridImperativeAPI | null>;\n","import { useRef } from \"react\";\nimport type { GridImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the Grid component.\n */\nexport const useGridRef = useRef as typeof useRef<GridImperativeAPI>;\n","import type { DynamicRowHeight } from \"./types\";\n\nexport function isDynamicRowHeight(value: unknown): value is DynamicRowHeight {\n return (\n value != null &&\n typeof value === \"object\" &&\n \"getAverageRowHeight\" in value &&\n typeof value.getAverageRowHeight === \"function\"\n );\n}\n","\"use client\";\n\nimport {\n createElement,\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode\n} from \"react\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useIsomorphicLayoutEffect } from \"../../hooks/useIsomorphicLayoutEffect\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align, TagNames } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport { isDynamicRowHeight as isDynamicRowHeightUtil } from \"./isDynamicRowHeight\";\nimport type { ListProps } from \"./types\";\n\nexport const DATA_ATTRIBUTE_LIST_INDEX = \"data-react-window-index\";\n\n/**\n * Renders data with many rows.\n */\nexport function List<\n RowProps extends object,\n TagName extends TagNames = \"div\"\n>({\n children,\n className,\n defaultHeight = 0,\n listRef,\n onResize,\n onRowsRendered,\n overscanCount = 3,\n rowComponent: RowComponentProp,\n rowCount,\n rowHeight: rowHeightProp,\n rowProps: rowPropsUnstable,\n tagName = \"div\" as TagName,\n style,\n ...rest\n}: ListProps<RowProps, TagName>): ReactElement {\n const rowProps = useMemoizedObject(rowPropsUnstable);\n const RowComponent = useMemo(\n () => memo(RowComponentProp, arePropsEqual),\n [RowComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const isDynamicRowHeight = isDynamicRowHeightUtil(rowHeightProp);\n\n const rowHeight = useMemo(() => {\n if (isDynamicRowHeight) {\n return (index: number) => {\n return (\n rowHeightProp.getRowHeight(index) ??\n rowHeightProp.getAverageRowHeight()\n );\n };\n }\n\n return rowHeightProp;\n }, [isDynamicRowHeight, rowHeightProp]);\n\n const {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: rowProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n listRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const top = scrollToIndex({\n align,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n top\n });\n }\n }\n }),\n [element, scrollToIndex]\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!element) {\n return;\n }\n\n const rows = Array.from(element.children).filter((item, index) => {\n if (item.hasAttribute(\"aria-hidden\")) {\n // Ignore sizing element\n return false;\n }\n\n const attribute = `${startIndexOverscan + index}`;\n item.setAttribute(DATA_ATTRIBUTE_LIST_INDEX, attribute);\n\n return true;\n });\n\n if (isDynamicRowHeight) {\n return rowHeightProp.observeRowElements(rows);\n }\n }, [\n element,\n isDynamicRowHeight,\n rowHeightProp,\n startIndexOverscan,\n stopIndexOverscan\n ]);\n\n useEffect(() => {\n if (startIndexOverscan >= 0 && stopIndexOverscan >= 0 && onRowsRendered) {\n onRowsRendered(\n {\n startIndex: startIndexVisible,\n stopIndex: stopIndexVisible\n },\n {\n startIndex: startIndexOverscan,\n stopIndex: stopIndexOverscan\n }\n );\n }\n }, [\n onRowsRendered,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n ]);\n\n const rows = useMemo(() => {\n const children: ReactNode[] = [];\n if (rowCount > 0) {\n for (\n let index = startIndexOverscan;\n index <= stopIndexOverscan;\n index++\n ) {\n const bounds = getCellBounds(index);\n\n children.push(\n <RowComponent\n {...(rowProps as RowProps)}\n ariaAttributes={{\n \"aria-posinset\": index + 1,\n \"aria-setsize\": rowCount,\n role: \"listitem\"\n }}\n key={index}\n index={index}\n style={{\n position: \"absolute\",\n left: 0,\n transform: `translateY(${bounds.scrollOffset}px)`,\n // In case of dynamic row heights, don't specify a height style\n // otherwise a default/estimated height would mask the actual height\n height: isDynamicRowHeight ? undefined : bounds.size,\n width: \"100%\"\n }}\n />\n );\n }\n }\n return children;\n }, [\n RowComponent,\n getCellBounds,\n isDynamicRowHeight,\n rowCount,\n rowProps,\n startIndexOverscan,\n stopIndexOverscan\n ]);\n\n const sizingElement = (\n <div\n aria-hidden\n style={{\n height: getEstimatedSize(),\n width: \"100%\",\n zIndex: -1\n }}\n ></div>\n );\n\n return createElement(\n tagName,\n {\n role: \"list\",\n ...rest,\n className,\n ref: setElement,\n style: {\n position: \"relative\",\n maxHeight: \"100%\",\n flexGrow: 1,\n overflowY: \"auto\",\n ...style\n }\n },\n rows,\n children,\n sizingElement\n );\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useStableCallback } from \"../../hooks/useStableCallback\";\nimport { assert } from \"../../utils/assert\";\nimport { DATA_ATTRIBUTE_LIST_INDEX } from \"./List\";\nimport type { DynamicRowHeight } from \"./types\";\n\nexport function useDynamicRowHeight({\n defaultRowHeight,\n key\n}: {\n defaultRowHeight: number;\n key?: string | number;\n}) {\n const [state, setState] = useState<{\n key: string | number | undefined;\n map: Map<number, number>;\n }>({\n key,\n map: new Map()\n });\n\n if (state.key !== key) {\n setState({\n key,\n map: new Map()\n });\n }\n\n const { map } = state;\n\n const getAverageRowHeight = useCallback(() => {\n let totalHeight = 0;\n\n map.forEach((height) => {\n totalHeight += height;\n });\n\n if (totalHeight === 0) {\n return defaultRowHeight;\n }\n\n return totalHeight / map.size;\n }, [defaultRowHeight, map]);\n\n const getRowHeight = useCallback(\n (index: number) => {\n const measuredHeight = map.get(index);\n if (measuredHeight !== undefined) {\n return measuredHeight;\n }\n\n // Temporarily store default height in the cache map to avoid scroll jumps if rowProps change\n // Else rowProps changes can impact the average height, and cause rows to shift up or down within the list\n // see github.com/bvaughn/react-window/issues/863\n map.set(index, defaultRowHeight);\n\n return defaultRowHeight;\n },\n [defaultRowHeight, map]\n );\n\n const setRowHeight = useCallback((index: number, size: number) => {\n setState((prevState) => {\n if (prevState.map.get(index) === size) {\n return prevState;\n }\n\n const clonedMap = new Map(prevState.map);\n clonedMap.set(index, size);\n\n return {\n ...prevState,\n map: clonedMap\n };\n });\n }, []);\n\n const resizeObserverCallback = useStableCallback(\n (entries: ResizeObserverEntry[]) => {\n if (entries.length === 0) {\n return;\n }\n\n entries.forEach((entry) => {\n const { borderBoxSize, target } = entry;\n\n const attribute = target.getAttribute(DATA_ATTRIBUTE_LIST_INDEX);\n assert(\n attribute !== null,\n `Invalid ${DATA_ATTRIBUTE_LIST_INDEX} attribute value`\n );\n\n const index = parseInt(attribute);\n\n const { blockSize: height } = borderBoxSize[0];\n if (!height) {\n // Ignore heights that have not yet been measured (e.g. <img> elements that have not yet loaded)\n return;\n }\n\n setRowHeight(index, height);\n });\n }\n );\n\n const [resizeObserver] = useState(() => {\n if (typeof ResizeObserver !== \"undefined\") {\n return new ResizeObserver(resizeObserverCallback);\n }\n });\n\n useEffect(() => {\n if (resizeObserver) {\n return () => {\n resizeObserver.disconnect();\n };\n }\n }, [resizeObserver]);\n\n const observeRowElements = useCallback(\n (elements: Element[] | NodeListOf<Element>) => {\n if (resizeObserver) {\n elements.forEach((element) => resizeObserver.observe(element));\n return () => {\n elements.forEach((element) => resizeObserver.unobserve(element));\n };\n }\n return () => {};\n },\n [resizeObserver]\n );\n\n return useMemo<DynamicRowHeight>(\n () => ({\n getAverageRowHeight,\n getRowHeight,\n setRowHeight,\n observeRowElements\n }),\n [getAverageRowHeight, getRowHeight, setRowHeight, observeRowElements]\n );\n}\n","import { useState } from \"react\";\nimport type { ListImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref callback for the List component.\n *\n * Use this hook when you need to share the ref with another component or hook.\n */\nexport const useListCallbackRef =\n useState as typeof useState<ListImperativeAPI | null>;\n","import { useRef } from \"react\";\nimport type { ListImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the List component.\n */\nexport const useListRef = useRef as typeof useRef<ListImperativeAPI>;\n","let size: number = -1;\n\nexport function getScrollbarSize(recalculate: boolean = false): number {\n if (size === -1 || recalculate) {\n const div = document.createElement(\"div\");\n const style = div.style;\n style.width = \"50px\";\n style.height = \"50px\";\n style.overflow = \"scroll\";\n\n document.body.appendChild(div);\n\n size = div.offsetWidth - div.clientWidth;\n\n document.body.removeChild(div);\n }\n\n return size;\n}\n\nexport function setScrollbarSizeForTests(value: number) {\n size = value;\n}\n"],"names":["isRtl","element","currentElement","useIsRtl","dir","value","setValue","useState","useLayoutEffect","useIsomorphicLayoutEffect","useEffect","parseNumericStyleValue","useResizeObserver","box","defaultHeight","defaultWidth","disabledProp","mode","style","styleHeight","styleWidth","useMemo","state","setState","disabled","resizeObserver","entries","entry","contentRect","target","prevState","useStableCallback","fn","ref","useRef","useCallback","args","cachedRTLResult","getRTLOffsetType","recalculate","outerDiv","outerStyle","innerDiv","innerStyle","adjustScrollOffsetForRtl","containerElement","direction","scrollOffset","clientWidth","scrollLeft","scrollWidth","assert","expectedCondition","message","shallowCompare","a","b","key","getEstimatedSize","cachedBounds","itemCount","itemSize","bounds","averageItemSize","getOffsetForIndex","align","index","containerScrollOffset","containerSize","estimatedTotalSize","maxOffset","minOffset","getStartStopIndices","overscanCount","maxIndex","startIndexVisible","stopIndexVisible","startIndexOverscan","stopIndexOverscan","currentIndex","createCachedBounds","itemProps","cache","size","previousRowBounds","useCachedBounds","useItemSize","itemSizeProp","useVirtualizer","containerStyle","defaultContainerSize","onResize","height","width","prevSizeRef","prevSize","getCellBounds","indices","setIndices","getStartStopIndicesUtil","getEstimatedSizeUtil","onScroll","prev","scrollTop","next","scrollToIndex","useMemoizedObject","unstableObject","arePropsEqual","prevProps","nextProps","prevAriaAttributes","prevStyle","prevRest","nextAriaAttributes","nextStyle","nextRest","Grid","CellComponentProp","cellPropsUnstable","children","className","columnCount","columnWidth","gridRef","onCellsRendered","rowCount","rowHeight","tagName","rest","cellProps","CellComponent","memo","setElement","getColumnBounds","getEstimatedWidth","columnStartIndexOverscan","columnStartIndexVisible","scrollToColumnIndex","columnStopIndexOverscan","columnStopIndexVisible","getRowBounds","getEstimatedHeight","rowStartIndexOverscan","rowStartIndexVisible","scrollToRowIndex","rowStopIndexOverscan","rowStopIndexVisible","useImperativeHandle","behavior","columnAlign","columnIndex","rowAlign","rowIndex","left","top","cells","rowBounds","columns","columnBounds","createElement","jsx","sizingElement","useGridCallbackRef","useGridRef","isDynamicRowHeight","DATA_ATTRIBUTE_LIST_INDEX","List","listRef","onRowsRendered","RowComponentProp","rowHeightProp","rowPropsUnstable","rowProps","RowComponent","isDynamicRowHeightUtil","rows","item","attribute","useDynamicRowHeight","defaultRowHeight","map","getAverageRowHeight","totalHeight","getRowHeight","measuredHeight","setRowHeight","clonedMap","resizeObserverCallback","borderBoxSize","observeRowElements","elements","useListCallbackRef","useListRef","getScrollbarSize","div"],"mappings":"qJAAO,SAASA,GAAMC,EAAsB,CAC1C,IAAIC,EAAqCD,EACzC,KAAOC,GAAgB,CACrB,GAAIA,EAAe,IACjB,OAAOA,EAAe,MAAQ,MAGhCA,EAAiBA,EAAe,aAClC,CAEA,MAAO,EACT,CCRO,SAASC,GACdF,EACAG,EACA,CACA,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAASH,IAAQ,KAAK,EAEhDI,OAAAA,EAAAA,gBAAgB,IAAM,CAChBP,IACGG,GACHE,EAASN,GAAMC,CAAO,CAAC,EAG7B,EAAG,CAACG,EAAKH,CAAO,CAAC,EAEVI,CACT,CChBO,MAAMI,EACX,OAAO,OAAW,IAAcD,EAAAA,gBAAkBE,EAAAA,UCD7C,SAASC,GACdN,EACoB,CACpB,GAAIA,IAAU,OACZ,OAAQ,OAAOA,EAAA,CACb,IAA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Aa/J,EAAAA,OCN1B,IAAIiD,EAAe,GAEZ,SAAS+G,GAAiB3J,EAAuB,GAAe,CACrE,GAAI4C,IAAS,IAAM5C,EAAa,CAC9B,MAAM4J,EAAM,SAAS,cAAc,KAAK,EAClCjL,EAAQiL,EAAI,MAClBjL,EAAM,MAAQ,OACdA,EAAM,OAAS,OACfA,EAAM,SAAW,SAEjB,SAAS,KAAK,YAAYiL,CAAG,EAE7BhH,EAAOgH,EAAI,YAAcA,EAAI,YAE7B,SAAS,KAAK,YAAYA,CAAG,CAC/B,CAEA,OAAOhH,CACT"}
1
+ {"version":3,"file":"react-window.cjs","sources":["../lib/utils/isRtl.ts","../lib/core/useIsRtl.ts","../lib/hooks/useIsomorphicLayoutEffect.ts","../lib/utils/parseNumericStyleValue.ts","../lib/hooks/useResizeObserver.ts","../lib/hooks/useStableCallback.ts","../lib/utils/getRTLOffsetType.ts","../lib/utils/adjustScrollOffsetForRtl.ts","../lib/utils/assert.ts","../lib/utils/shallowCompare.ts","../lib/core/getEstimatedSize.ts","../lib/core/getOffsetForIndex.ts","../lib/core/getStartStopIndices.ts","../lib/core/createCachedBounds.ts","../lib/core/useCachedBounds.ts","../lib/core/useItemSize.ts","../lib/core/useVirtualizer.ts","../lib/hooks/useMemoizedObject.ts","../lib/utils/arePropsEqual.ts","../lib/components/grid/Grid.tsx","../lib/components/grid/useGridCallbackRef.ts","../lib/components/grid/useGridRef.ts","../lib/components/list/isDynamicRowHeight.ts","../lib/components/list/List.tsx","../lib/components/list/useDynamicRowHeight.ts","../lib/components/list/useListCallbackRef.ts","../lib/components/list/useListRef.ts","../lib/utils/getScrollbarSize.ts"],"sourcesContent":["export function isRtl(element: HTMLElement) {\n let currentElement: HTMLElement | null = element;\n while (currentElement) {\n if (currentElement.dir) {\n return currentElement.dir === \"rtl\";\n }\n\n currentElement = currentElement.parentElement;\n }\n\n return false;\n}\n","import { useLayoutEffect, useState, type HTMLAttributes } from \"react\";\nimport { isRtl } from \"../utils/isRtl\";\n\nexport function useIsRtl(\n element: HTMLElement | null,\n dir: HTMLAttributes<HTMLElement>[\"dir\"]\n) {\n const [value, setValue] = useState(dir === \"rtl\");\n\n useLayoutEffect(() => {\n if (element) {\n if (!dir) {\n setValue(isRtl(element));\n }\n }\n }, [dir, element]);\n\n return value;\n}\n","import { useEffect, useLayoutEffect } from \"react\";\n\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import type { CSSProperties } from \"react\";\n\nexport function parseNumericStyleValue(\n value: CSSProperties[\"height\"]\n): number | undefined {\n if (value !== undefined) {\n switch (typeof value) {\n case \"number\": {\n return value;\n }\n case \"string\": {\n if (value.endsWith(\"px\")) {\n return parseFloat(value);\n }\n break;\n }\n }\n }\n}\n","import { useMemo, useState, type CSSProperties } from \"react\";\nimport { parseNumericStyleValue } from \"../utils/parseNumericStyleValue\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nexport function useResizeObserver({\n box,\n defaultHeight,\n defaultWidth,\n disabled: disabledProp,\n element,\n mode,\n style\n}: {\n box?: ResizeObserverBoxOptions;\n defaultHeight?: number;\n defaultWidth?: number;\n disabled?: boolean;\n element: HTMLElement | null;\n mode?: \"only-height\" | \"only-width\";\n style: CSSProperties | undefined;\n}) {\n const { styleHeight, styleWidth } = useMemo(\n () => ({\n styleHeight: parseNumericStyleValue(style?.height),\n styleWidth: parseNumericStyleValue(style?.width)\n }),\n [style?.height, style?.width]\n );\n\n const [state, setState] = useState<{\n height: number | undefined;\n width: number | undefined;\n }>({\n height: defaultHeight,\n width: defaultWidth\n });\n\n const disabled =\n disabledProp ||\n (mode === \"only-height\" && styleHeight !== undefined) ||\n (mode === \"only-width\" && styleWidth !== undefined) ||\n (styleHeight !== undefined && styleWidth !== undefined);\n\n useIsomorphicLayoutEffect(() => {\n if (element === null || disabled) {\n return;\n }\n\n const resizeObserver = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const { contentRect, target } = entry;\n if (element === target) {\n setState((prevState) => {\n if (\n prevState.height === contentRect.height &&\n prevState.width === contentRect.width\n ) {\n return prevState;\n }\n\n return {\n height: contentRect.height,\n width: contentRect.width\n };\n });\n }\n }\n });\n resizeObserver.observe(element, { box });\n\n return () => {\n resizeObserver?.unobserve(element);\n };\n }, [box, disabled, element, styleHeight, styleWidth]);\n\n return useMemo(\n () => ({\n height: styleHeight ?? state.height,\n width: styleWidth ?? state.width\n }),\n [state, styleHeight, styleWidth]\n );\n}\n","import { useCallback, useRef } from \"react\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\n// Forked from useEventCallback (usehooks-ts)\nexport function useStableCallback<Args extends unknown[], Return>(\n fn: (...args: Args) => Return\n): (...args: Args) => Return;\nexport function useStableCallback<Args extends unknown[], Return>(\n fn: ((...args: Args) => Return) | undefined\n): ((...args: Args) => Return) | undefined;\nexport function useStableCallback<Args extends unknown[], Return>(\n fn: ((...args: Args) => Return) | undefined\n): ((...args: Args) => Return) | undefined {\n const ref = useRef<typeof fn>(() => {\n // This error ensures components don't render with previous/stale function\n throw new Error(\"Cannot call an event handler while rendering.\");\n });\n\n useIsomorphicLayoutEffect(() => {\n ref.current = fn;\n }, [fn]);\n\n return useCallback((...args: Args) => ref.current?.(...args), [ref]) as (\n ...args: Args\n ) => Return;\n}\n","export type RTLOffsetType =\n | \"negative\"\n | \"positive-descending\"\n | \"positive-ascending\";\n\nlet cachedRTLResult: RTLOffsetType | null = null;\n\n// TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.\n// Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).\n// Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.\n// The safest way to check this is to intentionally set a negative offset,\n// and then verify that the subsequent \"scroll\" event matches the negative offset.\n// If it does not match, then we can assume a non-standard RTL scroll implementation.\nexport function getRTLOffsetType(recalculate: boolean = false): RTLOffsetType {\n if (cachedRTLResult === null || recalculate) {\n const outerDiv = document.createElement(\"div\");\n const outerStyle = outerDiv.style;\n outerStyle.width = \"50px\";\n outerStyle.height = \"50px\";\n outerStyle.overflow = \"scroll\";\n outerStyle.direction = \"rtl\";\n\n const innerDiv = document.createElement(\"div\");\n const innerStyle = innerDiv.style;\n innerStyle.width = \"100px\";\n innerStyle.height = \"100px\";\n\n outerDiv.appendChild(innerDiv);\n\n document.body.appendChild(outerDiv);\n\n if (outerDiv.scrollLeft > 0) {\n cachedRTLResult = \"positive-descending\";\n } else {\n outerDiv.scrollLeft = 1;\n if (outerDiv.scrollLeft === 0) {\n cachedRTLResult = \"negative\";\n } else {\n cachedRTLResult = \"positive-ascending\";\n }\n }\n\n document.body.removeChild(outerDiv);\n\n return cachedRTLResult;\n }\n\n return cachedRTLResult;\n}\n","import type { Direction } from \"../core/types\";\nimport { getRTLOffsetType } from \"./getRTLOffsetType\";\n\nexport function adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n}: {\n containerElement: HTMLElement | null;\n direction: Direction;\n isRtl: boolean;\n scrollOffset: number;\n}) {\n // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.\n // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).\n // So we need to determine which browser behavior we're dealing with, and mimic it.\n if (direction === \"horizontal\") {\n if (isRtl) {\n switch (getRTLOffsetType()) {\n case \"negative\": {\n return -scrollOffset;\n }\n case \"positive-descending\": {\n if (containerElement) {\n const { clientWidth, scrollLeft, scrollWidth } = containerElement;\n return scrollWidth - clientWidth - scrollLeft;\n }\n break;\n }\n }\n }\n }\n return scrollOffset;\n}\n","export function assert(\n expectedCondition: unknown,\n message: string = \"Assertion error\"\n): asserts expectedCondition {\n if (!expectedCondition) {\n console.error(message);\n\n throw Error(message);\n }\n}\n","import { assert } from \"./assert\";\n\nexport function shallowCompare<Type extends object>(\n a: Type | undefined,\n b: Type | undefined\n) {\n if (a === b) {\n return true;\n }\n\n if (!!a !== !!b) {\n return false;\n }\n\n assert(a !== undefined);\n assert(b !== undefined);\n\n if (Object.keys(a).length !== Object.keys(b).length) {\n return false;\n }\n\n for (const key in a) {\n if (!Object.is(b[key], a[key])) {\n return false;\n }\n }\n\n return true;\n}\n","import type { CachedBounds, SizeFunction } from \"./types\";\nimport { assert } from \"../utils/assert\";\n\nexport function getEstimatedSize<Props extends object>({\n cachedBounds,\n itemCount,\n itemSize\n}: {\n cachedBounds: CachedBounds;\n itemCount: number;\n itemSize: number | SizeFunction<Props>;\n}) {\n if (itemCount === 0) {\n return 0;\n } else if (typeof itemSize === \"number\") {\n return itemCount * itemSize;\n } else {\n const bounds = cachedBounds.get(\n cachedBounds.size === 0 ? 0 : cachedBounds.size - 1\n );\n assert(bounds !== undefined, \"Unexpected bounds cache miss\");\n\n const averageItemSize =\n (bounds.scrollOffset + bounds.size) / cachedBounds.size;\n\n return itemCount * averageItemSize;\n }\n}\n","import type { Align } from \"../types\";\nimport { getEstimatedSize } from \"./getEstimatedSize\";\nimport type { CachedBounds, SizeFunction } from \"./types\";\n\nexport function getOffsetForIndex<Props extends object>({\n align,\n cachedBounds,\n index,\n itemCount,\n itemSize,\n containerScrollOffset,\n containerSize\n}: {\n align: Align;\n cachedBounds: CachedBounds;\n index: number;\n itemCount: number;\n itemSize: number | SizeFunction<Props>;\n containerScrollOffset: number;\n containerSize: number;\n}) {\n if (index < 0 || index >= itemCount) {\n throw RangeError(`Invalid index specified: ${index}`, {\n cause: `Index ${index} is not within the range of 0 - ${itemCount - 1}`\n });\n }\n\n const estimatedTotalSize = getEstimatedSize({\n cachedBounds,\n itemCount,\n itemSize\n });\n\n const bounds = cachedBounds.get(index);\n const maxOffset = Math.max(\n 0,\n Math.min(estimatedTotalSize - containerSize, bounds.scrollOffset)\n );\n const minOffset = Math.max(\n 0,\n bounds.scrollOffset - containerSize + bounds.size\n );\n\n if (align === \"smart\") {\n if (\n containerScrollOffset >= minOffset &&\n containerScrollOffset <= maxOffset\n ) {\n align = \"auto\";\n } else {\n align = \"center\";\n }\n }\n\n switch (align) {\n case \"start\": {\n return maxOffset;\n }\n case \"end\": {\n return minOffset;\n }\n case \"center\": {\n if (bounds.scrollOffset <= containerSize / 2) {\n // Too near the beginning to center-align\n return 0;\n } else if (\n bounds.scrollOffset + bounds.size / 2 >=\n estimatedTotalSize - containerSize / 2\n ) {\n // Too near the end to center-align\n return estimatedTotalSize - containerSize;\n } else {\n return bounds.scrollOffset + bounds.size / 2 - containerSize / 2;\n }\n }\n case \"auto\":\n default: {\n if (\n containerScrollOffset >= minOffset &&\n containerScrollOffset <= maxOffset\n ) {\n return containerScrollOffset;\n } else if (containerScrollOffset < minOffset) {\n return minOffset;\n } else {\n return maxOffset;\n }\n }\n }\n}\n","import type { CachedBounds } from \"./types\";\n\nexport function getStartStopIndices({\n cachedBounds,\n containerScrollOffset,\n containerSize,\n itemCount,\n overscanCount\n}: {\n cachedBounds: CachedBounds;\n containerScrollOffset: number;\n containerSize: number;\n itemCount: number;\n overscanCount: number;\n}): {\n startIndexVisible: number;\n stopIndexVisible: number;\n startIndexOverscan: number;\n stopIndexOverscan: number;\n} {\n const maxIndex = itemCount - 1;\n\n let startIndexVisible = 0;\n let stopIndexVisible = -1;\n let startIndexOverscan = 0;\n let stopIndexOverscan = -1;\n let currentIndex = 0;\n\n while (currentIndex < maxIndex) {\n const bounds = cachedBounds.get(currentIndex);\n\n if (bounds.scrollOffset + bounds.size > containerScrollOffset) {\n break;\n }\n\n currentIndex++;\n }\n\n startIndexVisible = currentIndex;\n startIndexOverscan = Math.max(0, startIndexVisible - overscanCount);\n\n while (currentIndex < maxIndex) {\n const bounds = cachedBounds.get(currentIndex);\n\n if (\n bounds.scrollOffset + bounds.size >=\n containerScrollOffset + containerSize\n ) {\n break;\n }\n\n currentIndex++;\n }\n\n stopIndexVisible = Math.min(maxIndex, currentIndex);\n stopIndexOverscan = Math.min(itemCount - 1, stopIndexVisible + overscanCount);\n\n if (startIndexVisible < 0) {\n startIndexVisible = 0;\n stopIndexVisible = -1;\n startIndexOverscan = 0;\n stopIndexOverscan = -1;\n }\n\n return {\n startIndexVisible,\n stopIndexVisible,\n startIndexOverscan,\n stopIndexOverscan\n };\n}\n","import { assert } from \"../utils/assert\";\nimport type { Bounds, CachedBounds, SizeFunction } from \"./types\";\n\nexport function createCachedBounds<Props extends object>({\n itemCount,\n itemProps,\n itemSize\n}: {\n itemCount: number;\n itemProps: Props;\n itemSize: number | SizeFunction<Props>;\n}): CachedBounds {\n const cache = new Map<number, Bounds>();\n\n return {\n get(index: number) {\n assert(index < itemCount, `Invalid index ${index}`);\n\n while (cache.size - 1 < index) {\n const currentIndex = cache.size;\n\n let size: number;\n switch (typeof itemSize) {\n case \"function\": {\n size = itemSize(currentIndex, itemProps);\n break;\n }\n case \"number\": {\n size = itemSize;\n break;\n }\n }\n\n if (currentIndex === 0) {\n cache.set(currentIndex, {\n size,\n scrollOffset: 0\n });\n } else {\n const previousRowBounds = cache.get(currentIndex - 1);\n assert(\n previousRowBounds !== undefined,\n `Unexpected bounds cache miss for index ${index}`\n );\n\n cache.set(currentIndex, {\n scrollOffset:\n previousRowBounds.scrollOffset + previousRowBounds.size,\n size\n });\n }\n }\n\n const bounds = cache.get(index);\n assert(\n bounds !== undefined,\n `Unexpected bounds cache miss for index ${index}`\n );\n\n return bounds;\n },\n set(index: number, bounds: Bounds) {\n cache.set(index, bounds);\n },\n get size() {\n return cache.size;\n }\n };\n}\n","import { useMemo } from \"react\";\nimport { createCachedBounds } from \"./createCachedBounds\";\nimport type { CachedBounds, SizeFunction } from \"./types\";\n\nexport function useCachedBounds<Props extends object>({\n itemCount,\n itemProps,\n itemSize\n}: {\n itemCount: number;\n itemProps: Props;\n itemSize: number | SizeFunction<Props>;\n}): CachedBounds {\n return useMemo(\n () =>\n createCachedBounds({\n itemCount,\n itemProps,\n itemSize\n }),\n [itemCount, itemProps, itemSize]\n );\n}\n","import { assert } from \"../utils/assert\";\nimport type { SizeFunction } from \"./types\";\n\nexport function useItemSize<Props extends object>({\n containerSize,\n itemSize: itemSizeProp\n}: {\n containerSize: number;\n itemSize: number | string | SizeFunction<Props>;\n}) {\n let itemSize: number | SizeFunction<Props>;\n switch (typeof itemSizeProp) {\n case \"string\": {\n assert(\n itemSizeProp.endsWith(\"%\"),\n `Invalid item size: \"${itemSizeProp}\"; string values must be percentages (e.g. \"100%\")`\n );\n assert(\n containerSize !== undefined,\n \"Container size must be defined if a percentage item size is specified\"\n );\n\n itemSize = (containerSize * parseInt(itemSizeProp)) / 100;\n break;\n }\n default: {\n itemSize = itemSizeProp;\n break;\n }\n }\n\n return itemSize;\n}\n","import {\n useCallback,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties\n} from \"react\";\nimport { useIsomorphicLayoutEffect } from \"../hooks/useIsomorphicLayoutEffect\";\nimport { useResizeObserver } from \"../hooks/useResizeObserver\";\nimport { useStableCallback } from \"../hooks/useStableCallback\";\nimport type { Align } from \"../types\";\nimport { adjustScrollOffsetForRtl } from \"../utils/adjustScrollOffsetForRtl\";\nimport { shallowCompare } from \"../utils/shallowCompare\";\nimport { getEstimatedSize as getEstimatedSizeUtil } from \"./getEstimatedSize\";\nimport { getOffsetForIndex } from \"./getOffsetForIndex\";\nimport { getStartStopIndices as getStartStopIndicesUtil } from \"./getStartStopIndices\";\nimport type { Direction, SizeFunction } from \"./types\";\nimport { useCachedBounds } from \"./useCachedBounds\";\nimport { useItemSize } from \"./useItemSize\";\n\nexport function useVirtualizer<Props extends object>({\n containerElement,\n containerStyle,\n defaultContainerSize = 0,\n direction,\n isRtl = false,\n itemCount,\n itemProps,\n itemSize: itemSizeProp,\n onResize,\n overscanCount\n}: {\n containerElement: HTMLElement | null;\n containerStyle?: CSSProperties;\n defaultContainerSize?: number;\n direction: Direction;\n isRtl?: boolean;\n itemCount: number;\n itemProps: Props;\n itemSize: number | string | SizeFunction<Props>;\n onResize:\n | ((\n size: { height: number; width: number },\n prevSize: { height: number; width: number }\n ) => void)\n | undefined;\n overscanCount: number;\n}) {\n const { height = defaultContainerSize, width = defaultContainerSize } =\n useResizeObserver({\n defaultHeight:\n direction === \"vertical\" ? defaultContainerSize : undefined,\n defaultWidth:\n direction === \"horizontal\" ? defaultContainerSize : undefined,\n element: containerElement,\n mode: direction === \"vertical\" ? \"only-height\" : \"only-width\",\n style: containerStyle\n });\n\n const prevSizeRef = useRef<{ height: number; width: number }>({\n height: 0,\n width: 0\n });\n\n const containerSize = direction === \"vertical\" ? height : width;\n\n const itemSize = useItemSize({ containerSize, itemSize: itemSizeProp });\n\n useLayoutEffect(() => {\n if (typeof onResize === \"function\") {\n const prevSize = prevSizeRef.current;\n\n if (prevSize.height !== height || prevSize.width !== width) {\n onResize({ height, width }, { ...prevSize });\n\n prevSize.height = height;\n prevSize.width = width;\n }\n }\n }, [height, onResize, width]);\n\n const cachedBounds = useCachedBounds({\n itemCount,\n itemProps,\n itemSize\n });\n\n const getCellBounds = useCallback(\n (index: number) => cachedBounds.get(index),\n [cachedBounds]\n );\n\n const [indices, setIndices] = useState<{\n startIndexVisible: number;\n stopIndexVisible: number;\n startIndexOverscan: number;\n stopIndexOverscan: number;\n }>(() =>\n getStartStopIndicesUtil({\n cachedBounds,\n // TODO Potentially support a defaultScrollOffset prop?\n containerScrollOffset: 0,\n containerSize,\n itemCount,\n overscanCount\n })\n );\n\n // Guard against temporarily invalid indices that may occur when item count decreases\n // Cached bounds object will be re-created and a second render will restore things\n const {\n startIndexVisible,\n startIndexOverscan,\n stopIndexVisible,\n stopIndexOverscan\n } = {\n startIndexVisible: Math.min(itemCount - 1, indices.startIndexVisible),\n startIndexOverscan: Math.min(itemCount - 1, indices.startIndexOverscan),\n stopIndexVisible: Math.min(itemCount - 1, indices.stopIndexVisible),\n stopIndexOverscan: Math.min(itemCount - 1, indices.stopIndexOverscan)\n };\n\n const getEstimatedSize = useCallback(\n () =>\n getEstimatedSizeUtil({\n cachedBounds,\n itemCount,\n itemSize\n }),\n [cachedBounds, itemCount, itemSize]\n );\n\n const getStartStopIndices = useCallback(\n (scrollOffset: number) => {\n const containerScrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n });\n\n return getStartStopIndicesUtil({\n cachedBounds,\n containerScrollOffset,\n containerSize,\n itemCount,\n overscanCount\n });\n },\n [\n cachedBounds,\n containerElement,\n containerSize,\n direction,\n isRtl,\n itemCount,\n overscanCount\n ]\n );\n\n useIsomorphicLayoutEffect(() => {\n const scrollOffset =\n (direction === \"vertical\"\n ? containerElement?.scrollTop\n : containerElement?.scrollLeft) ?? 0;\n\n setIndices(getStartStopIndices(scrollOffset));\n }, [containerElement, direction, getStartStopIndices]);\n\n useIsomorphicLayoutEffect(() => {\n if (!containerElement) {\n return;\n }\n\n const onScroll = () => {\n setIndices((prev) => {\n const { scrollLeft, scrollTop } = containerElement;\n\n const scrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset: direction === \"vertical\" ? scrollTop : scrollLeft\n });\n\n const next = getStartStopIndicesUtil({\n cachedBounds,\n containerScrollOffset: scrollOffset,\n containerSize,\n itemCount,\n overscanCount\n });\n\n if (shallowCompare(next, prev)) {\n return prev;\n }\n\n return next;\n });\n };\n\n containerElement.addEventListener(\"scroll\", onScroll);\n\n return () => {\n containerElement.removeEventListener(\"scroll\", onScroll);\n };\n }, [\n cachedBounds,\n containerElement,\n containerSize,\n direction,\n itemCount,\n overscanCount\n ]);\n\n const scrollToIndex = useStableCallback(\n ({\n align = \"auto\",\n containerScrollOffset,\n index\n }: {\n align?: Align;\n containerScrollOffset: number;\n index: number;\n }) => {\n let scrollOffset = getOffsetForIndex({\n align,\n cachedBounds,\n containerScrollOffset,\n containerSize,\n index,\n itemCount,\n itemSize\n });\n\n if (containerElement) {\n scrollOffset = adjustScrollOffsetForRtl({\n containerElement,\n direction,\n isRtl,\n scrollOffset\n });\n\n if (typeof containerElement.scrollTo !== \"function\") {\n // Special case for environments like jsdom that don't implement scrollTo\n const next = getStartStopIndices(scrollOffset);\n if (!shallowCompare(indices, next)) {\n setIndices(next);\n }\n }\n\n return scrollOffset;\n }\n }\n );\n\n return {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n };\n}\n","import { useMemo } from \"react\";\n\nexport function useMemoizedObject<Type extends object>(\n unstableObject: Type\n): Type {\n return useMemo(() => {\n return unstableObject;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, Object.values(unstableObject));\n}\n","import type { CSSProperties } from \"react\";\nimport { shallowCompare } from \"./shallowCompare\";\n\n// Custom comparison function for React.memo()\n// It knows to compare individual style props and ignore the wrapper object.\n// See https://react.dev/reference/react/memo#memo\nexport function arePropsEqual(\n prevProps: { ariaAttributes: object; style: CSSProperties },\n nextProps: { ariaAttributes: object; style: CSSProperties }\n): boolean {\n const {\n ariaAttributes: prevAriaAttributes,\n style: prevStyle,\n ...prevRest\n } = prevProps;\n const {\n ariaAttributes: nextAriaAttributes,\n style: nextStyle,\n ...nextRest\n } = nextProps;\n\n return (\n shallowCompare(prevAriaAttributes, nextAriaAttributes) &&\n shallowCompare(prevStyle, nextStyle) &&\n shallowCompare(prevRest, nextRest)\n );\n}\n","\"use client\";\n\nimport {\n createElement,\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode\n} from \"react\";\nimport { useIsRtl } from \"../../core/useIsRtl\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align, TagNames } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { GridProps } from \"./types\";\n\n/**\n * Renders data with many rows and columns.\n *\n * ℹ️ Unlike `List` rows, `Grid` cell sizes must be known ahead of time.\n * Either static sizes or something that can be derived (from the data in `CellProps`) without rendering.\n */\nexport function Grid<\n CellProps extends object,\n TagName extends TagNames = \"div\"\n>({\n cellComponent: CellComponentProp,\n cellProps: cellPropsUnstable,\n children,\n className,\n columnCount,\n columnKey,\n columnWidth,\n defaultHeight = 0,\n defaultWidth = 0,\n dir,\n gridRef,\n onCellsRendered,\n onResize,\n overscanCount = 3,\n rowCount,\n rowHeight,\n rowKey,\n style,\n tagName = \"div\" as TagName,\n ...rest\n}: GridProps<CellProps, TagName>): ReactElement {\n const cellProps = useMemoizedObject(cellPropsUnstable);\n const CellComponent = useMemo(\n () => memo(CellComponentProp, arePropsEqual),\n [CellComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const isRtl = useIsRtl(element, dir);\n\n const {\n getCellBounds: getColumnBounds,\n getEstimatedSize: getEstimatedWidth,\n startIndexOverscan: columnStartIndexOverscan,\n startIndexVisible: columnStartIndexVisible,\n scrollToIndex: scrollToColumnIndex,\n stopIndexOverscan: columnStopIndexOverscan,\n stopIndexVisible: columnStopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultWidth,\n direction: \"horizontal\",\n isRtl,\n itemCount: columnCount,\n itemProps: cellProps,\n itemSize: columnWidth,\n onResize,\n overscanCount\n });\n\n const {\n getCellBounds: getRowBounds,\n getEstimatedSize: getEstimatedHeight,\n startIndexOverscan: rowStartIndexOverscan,\n startIndexVisible: rowStartIndexVisible,\n scrollToIndex: scrollToRowIndex,\n stopIndexOverscan: rowStopIndexOverscan,\n stopIndexVisible: rowStopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: cellProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n gridRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToCell({\n behavior = \"auto\",\n columnAlign = \"auto\",\n columnIndex,\n rowAlign = \"auto\",\n rowIndex\n }: {\n behavior?: ScrollBehavior;\n columnAlign?: Align;\n columnIndex: number;\n rowAlign?: Align;\n rowIndex: number;\n }) {\n const left = scrollToColumnIndex({\n align: columnAlign,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index: columnIndex\n });\n const top = scrollToRowIndex({\n align: rowAlign,\n containerScrollOffset: element?.scrollTop ?? 0,\n index: rowIndex\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n left,\n top\n });\n }\n },\n\n scrollToColumn({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const left = scrollToColumnIndex({\n align,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n left\n });\n }\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const top = scrollToRowIndex({\n align,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n top\n });\n }\n }\n }),\n [element, scrollToColumnIndex, scrollToRowIndex]\n );\n\n useEffect(() => {\n if (\n columnStartIndexOverscan >= 0 &&\n columnStopIndexOverscan >= 0 &&\n rowStartIndexOverscan >= 0 &&\n rowStopIndexOverscan >= 0 &&\n onCellsRendered\n ) {\n onCellsRendered(\n {\n columnStartIndex: columnStartIndexVisible,\n columnStopIndex: columnStopIndexVisible,\n rowStartIndex: rowStartIndexVisible,\n rowStopIndex: rowStopIndexVisible\n },\n {\n columnStartIndex: columnStartIndexOverscan,\n columnStopIndex: columnStopIndexOverscan,\n rowStartIndex: rowStartIndexOverscan,\n rowStopIndex: rowStopIndexOverscan\n }\n );\n }\n }, [\n onCellsRendered,\n columnStartIndexOverscan,\n columnStartIndexVisible,\n columnStopIndexOverscan,\n columnStopIndexVisible,\n rowStartIndexOverscan,\n rowStartIndexVisible,\n rowStopIndexOverscan,\n rowStopIndexVisible\n ]);\n\n const cells = useMemo(() => {\n const children: ReactNode[] = [];\n if (columnCount > 0 && rowCount > 0) {\n for (\n let rowIndex = rowStartIndexOverscan;\n rowIndex <= rowStopIndexOverscan;\n rowIndex++\n ) {\n const rowBounds = getRowBounds(rowIndex);\n\n const columns: ReactNode[] = [];\n\n for (\n let columnIndex = columnStartIndexOverscan;\n columnIndex <= columnStopIndexOverscan;\n columnIndex++\n ) {\n const columnBounds = getColumnBounds(columnIndex);\n\n columns.push(\n <CellComponent\n {...(cellProps as CellProps)}\n ariaAttributes={{\n \"aria-colindex\": columnIndex + 1,\n role: \"gridcell\"\n }}\n columnIndex={columnIndex}\n key={\n columnKey\n ? columnKey({\n columnIndex,\n data: cellProps,\n rowIndex\n })\n : columnIndex\n }\n rowIndex={rowIndex}\n style={{\n position: \"absolute\",\n left: isRtl ? undefined : 0,\n right: isRtl ? 0 : undefined,\n transform: `translate(${isRtl ? -columnBounds.scrollOffset : columnBounds.scrollOffset}px, ${rowBounds.scrollOffset}px)`,\n height: rowBounds.size,\n width: columnBounds.size\n }}\n />\n );\n }\n\n children.push(\n <div\n key={\n rowKey\n ? rowKey({\n data: cellProps,\n rowIndex\n })\n : rowIndex\n }\n role=\"row\"\n aria-rowindex={rowIndex + 1}\n >\n {columns}\n </div>\n );\n }\n }\n return children;\n }, [\n CellComponent,\n cellProps,\n columnCount,\n columnKey,\n columnStartIndexOverscan,\n columnStopIndexOverscan,\n getColumnBounds,\n getRowBounds,\n isRtl,\n rowCount,\n rowKey,\n rowStartIndexOverscan,\n rowStopIndexOverscan\n ]);\n\n const sizingElement = (\n <div\n aria-hidden\n style={{\n height: getEstimatedHeight(),\n width: getEstimatedWidth(),\n zIndex: -1\n }}\n ></div>\n );\n\n return createElement(\n tagName,\n {\n \"aria-colcount\": columnCount,\n \"aria-rowcount\": rowCount,\n role: \"grid\",\n ...rest,\n className,\n dir,\n ref: setElement,\n style: {\n position: \"relative\",\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n flexGrow: 1,\n overflow: \"auto\",\n ...style\n }\n },\n cells,\n children,\n sizingElement\n );\n}\n","import { useState } from \"react\";\nimport type { GridImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref callback for the Grid component.\n *\n * Use this hook when you need to share the ref with another component or hook.\n */\nexport const useGridCallbackRef =\n useState as typeof useState<GridImperativeAPI | null>;\n","import { useRef } from \"react\";\nimport type { GridImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the Grid component.\n */\nexport const useGridRef = useRef as typeof useRef<GridImperativeAPI>;\n","import type { DynamicRowHeight } from \"./types\";\n\nexport function isDynamicRowHeight(value: unknown): value is DynamicRowHeight {\n return (\n value != null &&\n typeof value === \"object\" &&\n \"getAverageRowHeight\" in value &&\n typeof value.getAverageRowHeight === \"function\"\n );\n}\n","\"use client\";\n\nimport {\n createElement,\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactElement,\n type ReactNode\n} from \"react\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useIsomorphicLayoutEffect } from \"../../hooks/useIsomorphicLayoutEffect\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align, TagNames } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport { isDynamicRowHeight as isDynamicRowHeightUtil } from \"./isDynamicRowHeight\";\nimport type { ListProps } from \"./types\";\n\nexport const DATA_ATTRIBUTE_LIST_INDEX = \"data-react-window-index\";\n\n/**\n * Renders data with many rows.\n */\nexport function List<\n RowProps extends object,\n TagName extends TagNames = \"div\"\n>({\n children,\n className,\n defaultHeight = 0,\n listRef,\n onResize,\n onRowsRendered,\n overscanCount = 3,\n rowComponent: RowComponentProp,\n rowCount,\n rowHeight: rowHeightProp,\n rowKey,\n rowProps: rowPropsUnstable,\n tagName = \"div\" as TagName,\n style,\n ...rest\n}: ListProps<RowProps, TagName>): ReactElement {\n const rowProps = useMemoizedObject(rowPropsUnstable);\n const RowComponent = useMemo(\n () => memo(RowComponentProp, arePropsEqual),\n [RowComponentProp]\n );\n\n const [element, setElement] = useState<HTMLDivElement | null>(null);\n\n const isDynamicRowHeight = isDynamicRowHeightUtil(rowHeightProp);\n\n const rowHeight = useMemo(() => {\n if (isDynamicRowHeight) {\n return (index: number) => {\n return (\n rowHeightProp.getRowHeight(index) ??\n rowHeightProp.getAverageRowHeight()\n );\n };\n }\n\n return rowHeightProp;\n }, [isDynamicRowHeight, rowHeightProp]);\n\n const {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n } = useVirtualizer({\n containerElement: element,\n containerStyle: style,\n defaultContainerSize: defaultHeight,\n direction: \"vertical\",\n itemCount: rowCount,\n itemProps: rowProps,\n itemSize: rowHeight,\n onResize,\n overscanCount\n });\n\n useImperativeHandle(\n listRef,\n () => ({\n get element() {\n return element;\n },\n\n scrollToRow({\n align = \"auto\",\n behavior = \"auto\",\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\n index: number;\n }) {\n const top = scrollToIndex({\n align,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n\n if (typeof element?.scrollTo === \"function\") {\n element.scrollTo({\n behavior,\n top\n });\n }\n }\n }),\n [element, scrollToIndex]\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!element) {\n return;\n }\n\n const rows = Array.from(element.children).filter((item, index) => {\n if (item.hasAttribute(\"aria-hidden\")) {\n // Ignore sizing element\n return false;\n }\n\n const attribute = `${startIndexOverscan + index}`;\n item.setAttribute(DATA_ATTRIBUTE_LIST_INDEX, attribute);\n\n return true;\n });\n\n if (isDynamicRowHeight) {\n return rowHeightProp.observeRowElements(rows);\n }\n }, [\n element,\n isDynamicRowHeight,\n rowHeightProp,\n startIndexOverscan,\n stopIndexOverscan\n ]);\n\n useEffect(() => {\n if (startIndexOverscan >= 0 && stopIndexOverscan >= 0 && onRowsRendered) {\n onRowsRendered(\n {\n startIndex: startIndexVisible,\n stopIndex: stopIndexVisible\n },\n {\n startIndex: startIndexOverscan,\n stopIndex: stopIndexOverscan\n }\n );\n }\n }, [\n onRowsRendered,\n startIndexOverscan,\n startIndexVisible,\n stopIndexOverscan,\n stopIndexVisible\n ]);\n\n const rows = useMemo(() => {\n const children: ReactNode[] = [];\n if (rowCount > 0) {\n for (\n let index = startIndexOverscan;\n index <= stopIndexOverscan;\n index++\n ) {\n const bounds = getCellBounds(index);\n\n children.push(\n <RowComponent\n {...(rowProps as RowProps)}\n ariaAttributes={{\n \"aria-posinset\": index + 1,\n \"aria-setsize\": rowCount,\n role: \"listitem\"\n }}\n key={rowKey ? rowKey(index, rowProps) : index}\n index={index}\n style={{\n position: \"absolute\",\n left: 0,\n transform: `translateY(${bounds.scrollOffset}px)`,\n // In case of dynamic row heights, don't specify a height style\n // otherwise a default/estimated height would mask the actual height\n height: isDynamicRowHeight ? undefined : bounds.size,\n width: \"100%\"\n }}\n />\n );\n }\n }\n return children;\n }, [\n RowComponent,\n getCellBounds,\n isDynamicRowHeight,\n rowCount,\n rowKey,\n rowProps,\n startIndexOverscan,\n stopIndexOverscan\n ]);\n\n const sizingElement = (\n <div\n aria-hidden\n style={{\n height: getEstimatedSize(),\n width: \"100%\",\n zIndex: -1\n }}\n ></div>\n );\n\n return createElement(\n tagName,\n {\n role: \"list\",\n ...rest,\n className,\n ref: setElement,\n style: {\n position: \"relative\",\n maxHeight: \"100%\",\n flexGrow: 1,\n overflowY: \"auto\",\n ...style\n }\n },\n rows,\n children,\n sizingElement\n );\n}\n","import { useCallback, useEffect, useMemo, useState } from \"react\";\nimport { useStableCallback } from \"../../hooks/useStableCallback\";\nimport { assert } from \"../../utils/assert\";\nimport { DATA_ATTRIBUTE_LIST_INDEX } from \"./List\";\nimport type { DynamicRowHeight } from \"./types\";\n\nexport function useDynamicRowHeight({\n defaultRowHeight,\n key\n}: {\n defaultRowHeight: number;\n key?: string | number;\n}) {\n const [state, setState] = useState<{\n key: string | number | undefined;\n map: Map<number, number>;\n }>({\n key,\n map: new Map()\n });\n\n if (state.key !== key) {\n setState({\n key,\n map: new Map()\n });\n }\n\n const { map } = state;\n\n const getAverageRowHeight = useCallback(() => {\n let totalHeight = 0;\n\n map.forEach((height) => {\n totalHeight += height;\n });\n\n if (totalHeight === 0) {\n return defaultRowHeight;\n }\n\n return totalHeight / map.size;\n }, [defaultRowHeight, map]);\n\n const getRowHeight = useCallback(\n (index: number) => {\n const measuredHeight = map.get(index);\n if (measuredHeight !== undefined) {\n return measuredHeight;\n }\n\n // Temporarily store default height in the cache map to avoid scroll jumps if rowProps change\n // Else rowProps changes can impact the average height, and cause rows to shift up or down within the list\n // see github.com/bvaughn/react-window/issues/863\n map.set(index, defaultRowHeight);\n\n return defaultRowHeight;\n },\n [defaultRowHeight, map]\n );\n\n const setRowHeight = useCallback((index: number, size: number) => {\n setState((prevState) => {\n if (prevState.map.get(index) === size) {\n return prevState;\n }\n\n const clonedMap = new Map(prevState.map);\n clonedMap.set(index, size);\n\n return {\n ...prevState,\n map: clonedMap\n };\n });\n }, []);\n\n const resizeObserverCallback = useStableCallback(\n (entries: ResizeObserverEntry[]) => {\n if (entries.length === 0) {\n return;\n }\n\n entries.forEach((entry) => {\n const { borderBoxSize, target } = entry;\n\n const attribute = target.getAttribute(DATA_ATTRIBUTE_LIST_INDEX);\n assert(\n attribute !== null,\n `Invalid ${DATA_ATTRIBUTE_LIST_INDEX} attribute value`\n );\n\n const index = parseInt(attribute);\n\n const { blockSize: height } = borderBoxSize[0];\n if (!height) {\n // Ignore heights that have not yet been measured (e.g. <img> elements that have not yet loaded)\n return;\n }\n\n setRowHeight(index, height);\n });\n }\n );\n\n const [resizeObserver] = useState(() => {\n if (typeof ResizeObserver !== \"undefined\") {\n return new ResizeObserver(resizeObserverCallback);\n }\n });\n\n useEffect(() => {\n if (resizeObserver) {\n return () => {\n resizeObserver.disconnect();\n };\n }\n }, [resizeObserver]);\n\n const observeRowElements = useCallback(\n (elements: Element[] | NodeListOf<Element>) => {\n if (resizeObserver) {\n elements.forEach((element) => resizeObserver.observe(element));\n return () => {\n elements.forEach((element) => resizeObserver.unobserve(element));\n };\n }\n return () => {};\n },\n [resizeObserver]\n );\n\n return useMemo<DynamicRowHeight>(\n () => ({\n getAverageRowHeight,\n getRowHeight,\n setRowHeight,\n observeRowElements\n }),\n [getAverageRowHeight, getRowHeight, setRowHeight, observeRowElements]\n );\n}\n","import { useState } from \"react\";\nimport type { ListImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref callback for the List component.\n *\n * Use this hook when you need to share the ref with another component or hook.\n */\nexport const useListCallbackRef =\n useState as typeof useState<ListImperativeAPI | null>;\n","import { useRef } from \"react\";\nimport type { ListImperativeAPI } from \"./types\";\n\n/**\n * Convenience hook to return a properly typed ref for the List component.\n */\nexport const useListRef = useRef as typeof useRef<ListImperativeAPI>;\n","let size: number = -1;\n\nexport function getScrollbarSize(recalculate: boolean = false): number {\n if (size === -1 || recalculate) {\n const div = document.createElement(\"div\");\n const style = div.style;\n style.width = \"50px\";\n style.height = \"50px\";\n style.overflow = \"scroll\";\n\n document.body.appendChild(div);\n\n size = div.offsetWidth - div.clientWidth;\n\n document.body.removeChild(div);\n }\n\n return size;\n}\n\nexport function setScrollbarSizeForTests(value: number) {\n size = value;\n}\n"],"names":["isRtl","element","currentElement","useIsRtl","dir","value","setValue","useState","useLayoutEffect","useIsomorphicLayoutEffect","useEffect","parseNumericStyleValue","useResizeObserver","box","defaultHeight","defaultWidth","disabledProp","mode","style","styleHeight","styleWidth","useMemo","state","setState","disabled","resizeObserver","entries","entry","contentRect","target","prevState","useStableCallback","fn","ref","useRef","useCallback","args","cachedRTLResult","getRTLOffsetType","recalculate","outerDiv","outerStyle","innerDiv","innerStyle","adjustScrollOffsetForRtl","containerElement","direction","scrollOffset","clientWidth","scrollLeft","scrollWidth","assert","expectedCondition","message","shallowCompare","a","b","key","getEstimatedSize","cachedBounds","itemCount","itemSize","bounds","averageItemSize","getOffsetForIndex","align","index","containerScrollOffset","containerSize","estimatedTotalSize","maxOffset","minOffset","getStartStopIndices","overscanCount","maxIndex","startIndexVisible","stopIndexVisible","startIndexOverscan","stopIndexOverscan","currentIndex","createCachedBounds","itemProps","cache","size","previousRowBounds","useCachedBounds","useItemSize","itemSizeProp","useVirtualizer","containerStyle","defaultContainerSize","onResize","height","width","prevSizeRef","prevSize","getCellBounds","indices","setIndices","getStartStopIndicesUtil","getEstimatedSizeUtil","onScroll","prev","scrollTop","next","scrollToIndex","useMemoizedObject","unstableObject","arePropsEqual","prevProps","nextProps","prevAriaAttributes","prevStyle","prevRest","nextAriaAttributes","nextStyle","nextRest","Grid","CellComponentProp","cellPropsUnstable","children","className","columnCount","columnKey","columnWidth","gridRef","onCellsRendered","rowCount","rowHeight","rowKey","tagName","rest","cellProps","CellComponent","memo","setElement","getColumnBounds","getEstimatedWidth","columnStartIndexOverscan","columnStartIndexVisible","scrollToColumnIndex","columnStopIndexOverscan","columnStopIndexVisible","getRowBounds","getEstimatedHeight","rowStartIndexOverscan","rowStartIndexVisible","scrollToRowIndex","rowStopIndexOverscan","rowStopIndexVisible","useImperativeHandle","behavior","columnAlign","columnIndex","rowAlign","rowIndex","left","top","cells","rowBounds","columns","columnBounds","createElement","jsx","sizingElement","useGridCallbackRef","useGridRef","isDynamicRowHeight","DATA_ATTRIBUTE_LIST_INDEX","List","listRef","onRowsRendered","RowComponentProp","rowHeightProp","rowPropsUnstable","rowProps","RowComponent","isDynamicRowHeightUtil","rows","item","attribute","useDynamicRowHeight","defaultRowHeight","map","getAverageRowHeight","totalHeight","getRowHeight","measuredHeight","setRowHeight","clonedMap","resizeObserverCallback","borderBoxSize","observeRowElements","elements","useListCallbackRef","useListRef","getScrollbarSize","div"],"mappings":"qJAAO,SAASA,GAAMC,EAAsB,CAC1C,IAAIC,EAAqCD,EACzC,KAAOC,GAAgB,CACrB,GAAIA,EAAe,IACjB,OAAOA,EAAe,MAAQ,MAGhCA,EAAiBA,EAAe,aAClC,CAEA,MAAO,EACT,CC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AIlB,EAAAA,SAAS,IAAM,CACtC,GAAI,OAAO,eAAmB,IAC5B,OAAO,IAAI,eAAeuL,CAAsB,CAEpD,CAAC,EAEDpL,EAAAA,UAAU,IAAM,CACd,GAAIe,EACF,MAAO,IAAM,CACXA,EAAe,WAAA,CACjB,CAEJ,EAAG,CAACA,CAAc,CAAC,EAEnB,MAAMuK,EAAqB7J,EAAAA,YACxB8J,GACKxK,GACFwK,EAAS,QAAShM,GAAYwB,EAAe,QAAQxB,CAAO,CAAC,EACtD,IAAM,CACXgM,EAAS,QAAShM,GAAYwB,EAAe,UAAUxB,CAAO,CAAC,CACjE,GAEK,IAAM,CAAC,EAEhB,CAACwB,CAAc,CAAA,EAGjB,OAAOJ,EAAAA,QACL,KAAO,CACL,oBAAAmK,EACA,aAAAE,EACA,aAAAE,EACA,mBAAAI,CAAA,GAEF,CAACR,EAAqBE,EAAcE,EAAcI,CAAkB,CAAA,CAExE,CCrIO,MAAME,GACX3L,EAAAA,SCHW4L,GAAajK,EAAAA,OCN1B,IAAIiD,EAAe,GAEZ,SAASiH,GAAiB7J,EAAuB,GAAe,CACrE,GAAI4C,IAAS,IAAM5C,EAAa,CAC9B,MAAM8J,EAAM,SAAS,cAAc,KAAK,EAClCnL,EAAQmL,EAAI,MAClBnL,EAAM,MAAQ,OACdA,EAAM,OAAS,OACfA,EAAM,SAAW,SAEjB,SAAS,KAAK,YAAYmL,CAAG,EAE7BlH,EAAOkH,EAAI,YAAcA,EAAI,YAE7B,SAAS,KAAK,YAAYA,CAAG,CAC/B,CAEA,OAAOlH,CACT"}
@@ -41,7 +41,7 @@ export declare function getScrollbarSize(recalculate?: boolean): number;
41
41
  * ℹ️ Unlike `List` rows, `Grid` cell sizes must be known ahead of time.
42
42
  * Either static sizes or something that can be derived (from the data in `CellProps`) without rendering.
43
43
  */
44
- export declare function Grid<CellProps extends object, TagName extends TagNames = "div">({ cellComponent: CellComponentProp, cellProps: cellPropsUnstable, children, className, columnCount, columnWidth, defaultHeight, defaultWidth, dir, gridRef, onCellsRendered, onResize, overscanCount, rowCount, rowHeight, style, tagName, ...rest }: GridProps<CellProps, TagName>): ReactElement;
44
+ export declare function Grid<CellProps extends object, TagName extends TagNames = "div">({ cellComponent: CellComponentProp, cellProps: cellPropsUnstable, children, className, columnCount, columnKey, columnWidth, defaultHeight, defaultWidth, dir, gridRef, onCellsRendered, onResize, overscanCount, rowCount, rowHeight, rowKey, style, tagName, ...rest }: GridProps<CellProps, TagName>): ReactElement;
45
45
 
46
46
  /**
47
47
  * Ref used to interact with this component's imperative API.
@@ -141,6 +141,22 @@ export declare type GridProps<CellProps extends object, TagName extends TagNames
141
141
  * Number of columns to be rendered in the grid.
142
142
  */
143
143
  columnCount: number;
144
+ /**
145
+ * Grids use the column index as a `key` by default.
146
+ * This prop can be used along with the `rowKey` prop to provide a custom `key` value.
147
+ *
148
+ * ℹ️ Custom keys can ensure better UX for sortable or filterable grids,
149
+ * particularly if your cell components are stateful.
150
+ * Refer to the [React documentation](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) for more info.
151
+ *
152
+ * ⚠️ This prop cannot be auto-memoized because it is called during render.
153
+ * It is important to always `useCallback` for this prop; do not use an inline function.
154
+ */
155
+ columnKey?: (args: {
156
+ columnIndex: number;
157
+ data: CellProps;
158
+ rowIndex: number;
159
+ }) => React.Key;
144
160
  /**
145
161
  * Column width; the following formats are supported:
146
162
  * - number of pixels (number)
@@ -262,6 +278,21 @@ export declare type GridProps<CellProps extends object, TagName extends TagNames
262
278
  * - function that returns the row height (in pixels) given an index and `cellProps`
263
279
  */
264
280
  rowHeight: number | string | ((index: number, cellProps: CellProps) => number);
281
+ /**
282
+ * Grids use the row index as a `key` by default.
283
+ * This prop can be used along with the `columnKey` prop to provide a custom `key` value.
284
+ *
285
+ * ℹ️ Custom keys can ensure better UX for sortable or filterable grids,
286
+ * particularly if your cell components are stateful.
287
+ * Refer to the [React documentation](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) for more info.
288
+ *
289
+ * ⚠️ This prop cannot be auto-memoized because it is called during render.
290
+ * It is important to always `useCallback` for this prop; do not use an inline function.
291
+ */
292
+ rowKey?: (args: {
293
+ data: CellProps;
294
+ rowIndex: number;
295
+ }) => React.Key;
265
296
  /**
266
297
  * Optional CSS properties.
267
298
  * The grid of cells will fill the height and width defined by this style.
@@ -279,7 +310,7 @@ export declare type GridProps<CellProps extends object, TagName extends TagNames
279
310
  /**
280
311
  * Renders data with many rows.
281
312
  */
282
- export declare function List<RowProps extends object, TagName extends TagNames = "div">({ children, className, defaultHeight, listRef, onResize, onRowsRendered, overscanCount, rowComponent: RowComponentProp, rowCount, rowHeight: rowHeightProp, rowProps: rowPropsUnstable, tagName, style, ...rest }: ListProps<RowProps, TagName>): ReactElement;
313
+ export declare function List<RowProps extends object, TagName extends TagNames = "div">({ children, className, defaultHeight, listRef, onResize, onRowsRendered, overscanCount, rowComponent: RowComponentProp, rowCount, rowHeight: rowHeightProp, rowKey, rowProps: rowPropsUnstable, tagName, style, ...rest }: ListProps<RowProps, TagName>): ReactElement;
283
314
 
284
315
  /**
285
316
  * Imperative List API.
@@ -407,6 +438,18 @@ export declare type ListProps<RowProps extends object, TagName extends TagNames
407
438
  * It's recommended to provide your own height values if they can be determined ahead of time.
408
439
  */
409
440
  rowHeight: number | string | ((index: number, cellProps: RowProps) => number) | DynamicRowHeight;
441
+ /**
442
+ * Lists use the row index as a `key` by default.
443
+ * This prop can provide a custom `key` value.
444
+ *
445
+ * ℹ️ Custom keys can ensure better UX for sortable or filterable lists,
446
+ * particularly if your row components are stateful.
447
+ * Refer to the [React documentation](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) for more info.
448
+ *
449
+ * ⚠️ This prop cannot be auto-memoized because it is called during render.
450
+ * It is important to always `useCallback` for this prop; do not use an inline function.
451
+ */
452
+ rowKey?: (index: number, data: RowProps) => React.Key;
410
453
  /**
411
454
  * Additional props to be passed to the row-rendering component.
412
455
  * List will automatically re-render rows when values in this object change.