react-window 2.3.4 → 2.4.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
@@ -34,7 +34,7 @@ Frequently asked questions can be found [here](https://react-window.vercel.app/c
34
34
 
35
35
  ## Documentation
36
36
 
37
- Documentation for this project is available at [react-window.vercel.app](https://react-window.vercel.app/); version 1.x documentation can be found at [react-window-v1.vercel.app](https://react-window-v1.vercel.app/).
37
+ Documentation for this project is available at [react-window.vercel.app](https://react-window.vercel.app/).
38
38
 
39
39
  ### List
40
40
 
@@ -72,10 +72,11 @@ Additionally it will receive prop values passed to <code>rowProps</code>.</p>
72
72
  <td><p>Row height; the following formats are supported:</p>
73
73
  <ul>
74
74
  <li>number of pixels (number)</li>
75
- <li>percentage of the grid&#39;s current height (string)</li>
76
- <li>function that returns the row height (in pixels) given an index and <code>cellProps</code></li>
75
+ <li>percentage of the list&#39;s current height (string)</li>
76
+ <li>function that returns the row height (in pixels) given an index and <code>rowProps</code></li>
77
77
  <li>dynamic row height cache returned by the <code>useDynamicRowHeight</code> hook</li>
78
78
  </ul>
79
+ <p>ℹ️ Percentage heights can&#39;t be resolved during server rendering unless a <code>defaultHeight</code> (or a pixel height via the <code>style</code> prop) is specified.</p>
79
80
  <p>⚠️ Dynamic row heights are not as efficient as predetermined sizes.
80
81
  It&#39;s recommended to provide your own height values if they can be determined ahead of time.</p>
81
82
  </td>
@@ -117,21 +118,33 @@ The list of rows will fill the height defined by this style.</p>
117
118
  </tr>
118
119
  <tr>
119
120
  <td>children</td>
120
- <td><p>Additional content to be rendered within the list (above cells).
121
+ <td><p>Additional content to be rendered within the list (above rows).
121
122
  This property can be used to render things like overlays or tooltips.</p>
122
123
  </td>
123
124
  </tr>
124
125
  <tr>
125
126
  <td>defaultHeight</td>
126
- <td><p>Default height of list for initial render.
127
- This value is important for server rendering.</p>
127
+ <td><p>Default height of list (in pixels) for initial render, before its actual height has been measured.</p>
128
+ <p>ℹ️ Lists can&#39;t be measured during server rendering, so this value determines how many rows are server rendered.
129
+ It&#39;s recommended to set this to the expected height of the list (or to specify a pixel height via the <code>style</code> prop).</p>
130
+ </td>
131
+ </tr>
132
+ <tr>
133
+ <td>defaultScrollOffset</td>
134
+ <td><p>Initial scroll offset (in pixels) of the list.
135
+ This value is only applied once, when the list first mounts with at least one row.</p>
136
+ <p>ℹ️ Server-rendered HTML can&#39;t be pre-scrolled, so server rendering always starts at the first row;
137
+ the default scroll offset is applied once the list hydrates.</p>
138
+ <p>⚠️ If the list can&#39;t be scrolled that far when the offset is applied (e.g. it is hidden with <code>display: none</code>,
139
+ or uses percentage row heights before its height has been measured), the offset is clamped or ignored and not retried.
140
+ Specify a <code>defaultHeight</code> (or a pixel height via the <code>style</code> prop) when using percentage row heights.</p>
128
141
  </td>
129
142
  </tr>
130
143
  <tr>
131
144
  <td>listRef</td>
132
145
  <td><p>Ref used to interact with this component&#39;s imperative API.</p>
133
146
  <p>This API has imperative methods for scrolling and a getter for the outermost DOM element.</p>
134
- <p>ℹ️ The <code>useListRef</code> and <code>useListCallbackRef</code> hooks are exported for convenience use in TypeScript projects.</p>
147
+ <p>ℹ️ The <code>useListRef</code> and <code>useListCallbackRef</code> hooks are exported for convenience in TypeScript projects.</p>
135
148
  </td>
136
149
  </tr>
137
150
  <tr>
@@ -198,7 +211,7 @@ Either static sizes or something that can be derived (from the data in `CellProp
198
211
  <tr>
199
212
  <td>cellComponent</td>
200
213
  <td><p>React component responsible for rendering a cell.</p>
201
- <p>This component will receive an <code>index</code> and <code>style</code> prop by default.
214
+ <p>This component will receive <code>columnIndex</code>, <code>rowIndex</code>, and <code>style</code> props by default.
202
215
  Additionally it will receive prop values passed to <code>cellProps</code>.</p>
203
216
  <p>ℹ️ The prop types for this component are exported as <code>CellComponentProps</code></p>
204
217
  </td>
@@ -223,6 +236,7 @@ Grid will automatically re-render cells when values in this object change.</p>
223
236
  <li>percentage of the grid&#39;s current width (string)</li>
224
237
  <li>function that returns the column width (in pixels) given an index and <code>cellProps</code></li>
225
238
  </ul>
239
+ <p>ℹ️ Percentage widths can&#39;t be resolved during server rendering unless a <code>defaultWidth</code> (or a pixel width via the <code>style</code> prop) is specified.</p>
226
240
  </td>
227
241
  </tr>
228
242
  <tr>
@@ -238,6 +252,7 @@ Grid will automatically re-render cells when values in this object change.</p>
238
252
  <li>percentage of the grid&#39;s current height (string)</li>
239
253
  <li>function that returns the row height (in pixels) given an index and <code>cellProps</code></li>
240
254
  </ul>
255
+ <p>ℹ️ Percentage heights can&#39;t be resolved during server rendering unless a <code>defaultHeight</code> (or a pixel height via the <code>style</code> prop) is specified.</p>
241
256
  </td>
242
257
  </tr>
243
258
  </tbody>
@@ -265,6 +280,8 @@ Grid will automatically re-render cells when values in this object change.</p>
265
280
  <tr>
266
281
  <td>dir</td>
267
282
  <td><p>Indicates the directionality of grid cells.</p>
283
+ <p>ℹ️ The directionality of an ancestor element can&#39;t be detected during server rendering;
284
+ specify this prop explicitly for server-rendered right-to-left grids.</p>
268
285
  <p>ℹ️ See HTML <code>dir</code> <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir">global attribute</a> for more information.</p>
269
286
  </td>
270
287
  </tr>
@@ -293,20 +310,44 @@ It is important to always <code>useCallback</code> for this prop; do not use an
293
310
  </tr>
294
311
  <tr>
295
312
  <td>defaultHeight</td>
296
- <td><p>Default height of grid for initial render.
297
- This value is important for server rendering.</p>
313
+ <td><p>Default height of grid (in pixels) for initial render, before its actual height has been measured.</p>
314
+ <p>ℹ️ Grids can&#39;t be measured during server rendering, so this value determines how many rows are server rendered.
315
+ It&#39;s recommended to set this to the expected height of the grid (or to specify a pixel height via the <code>style</code> prop).</p>
316
+ </td>
317
+ </tr>
318
+ <tr>
319
+ <td>defaultScrollLeft</td>
320
+ <td><p>Initial horizontal scroll offset (in pixels) of the grid.
321
+ This value is only applied once, when the grid first mounts with at least one column.</p>
322
+ <p>ℹ️ Server-rendered HTML can&#39;t be pre-scrolled, so server rendering always starts at the first column;
323
+ the default scroll offset is applied once the grid hydrates.</p>
324
+ <p>⚠️ If the grid can&#39;t be scrolled that far when the offset is applied (e.g. it is hidden with <code>display: none</code>,
325
+ or uses percentage column widths before its width has been measured), the offset is clamped or ignored and not retried.
326
+ Specify a <code>defaultWidth</code> (or a pixel width via the <code>style</code> prop) when using percentage column widths.</p>
327
+ </td>
328
+ </tr>
329
+ <tr>
330
+ <td>defaultScrollTop</td>
331
+ <td><p>Initial vertical scroll offset (in pixels) of the grid.
332
+ This value is only applied once, when the grid first mounts with at least one row.</p>
333
+ <p>ℹ️ Server-rendered HTML can&#39;t be pre-scrolled, so server rendering always starts at the first row;
334
+ the default scroll offset is applied once the grid hydrates.</p>
335
+ <p>⚠️ If the grid can&#39;t be scrolled that far when the offset is applied (e.g. it is hidden with <code>display: none</code>,
336
+ or uses percentage row heights before its height has been measured), the offset is clamped or ignored and not retried.
337
+ Specify a <code>defaultHeight</code> (or a pixel height via the <code>style</code> prop) when using percentage row heights.</p>
298
338
  </td>
299
339
  </tr>
300
340
  <tr>
301
341
  <td>defaultWidth</td>
302
- <td><p>Default width of grid for initial render.
303
- This value is important for server rendering.</p>
342
+ <td><p>Default width of grid (in pixels) for initial render, before its actual width has been measured.</p>
343
+ <p>ℹ️ Grids can&#39;t be measured during server rendering, so this value determines how many columns are server rendered.
344
+ It&#39;s recommended to set this to the expected width of the grid (or to specify a pixel width via the <code>style</code> prop).</p>
304
345
  </td>
305
346
  </tr>
306
347
  <tr>
307
348
  <td>gridRef</td>
308
349
  <td><p>Imperative Grid API.</p>
309
- <p>ℹ️ The <code>useGridRef</code> and <code>useGridCallbackRef</code> hooks are exported for convenience use in TypeScript projects.</p>
350
+ <p>ℹ️ The <code>useGridRef</code> and <code>useGridCallbackRef</code> hooks are exported for convenience in TypeScript projects.</p>
310
351
  </td>
311
352
  </tr>
312
353
  <tr>
@@ -339,8 +380,8 @@ It is important to always <code>useCallback</code> for this prop; do not use an
339
380
  </tr>
340
381
  <tr>
341
382
  <td>tagName</td>
342
- <td><p>Can be used to override the root HTML element rendered by the List component.
343
- The default value is &quot;div&quot;, meaning that List renders an HTMLDivElement as its root.</p>
383
+ <td><p>Can be used to override the root HTML element rendered by the Grid component.
384
+ The default value is &quot;div&quot;, meaning that Grid renders an HTMLDivElement as its root.</p>
344
385
  <p>⚠️ In most use cases the default ARIA roles are sufficient and this prop is not needed.</p>
345
386
  </td>
346
387
  </tr>
@@ -1,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),c=require("react");function he(e){let t=e;for(;t;){if(t.dir)return t.dir==="rtl";t=t.parentElement}return!1}function ve(e,t){const[s,r]=c.useState(t==="rtl");return c.useLayoutEffect(()=>{t?r(t==="rtl"):e&&r(he(e))},[t,e]),s}const U=typeof window<"u"?c.useLayoutEffect:c.useEffect;function ee(e){return e?.ownerDocument.defaultView??window}function ie(e){return ee(e).ResizeObserver??(typeof ResizeObserver<"u"?ResizeObserver:void 0)}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 pe({box:e,defaultHeight:t,defaultWidth:s,disabled:r,element:n,mode:i,style:a}){const{styleHeight:u,styleWidth:l}=c.useMemo(()=>({styleHeight:se(a?.height),styleWidth:se(a?.width)}),[a?.height,a?.width]),[f,v]=c.useState({height:t,width:s}),o=r||i==="only-height"&&u!==void 0||i==="only-width"&&l!==void 0||u!==void 0&&l!==void 0;return U(()=>{if(n===null||o)return;const h=ie(n);if(!h)return;const d=new h(g=>{for(const p of g){const{contentRect:w,target:b}=p;n===b&&v(S=>S.height===w.height&&S.width===w.width?S:{height:w.height,width:w.width})}});return d.observe(n,{box:e}),()=>{d?.unobserve(n)}},[e,o,n,u,l]),c.useMemo(()=>({height:u??f.height,width:l??f.width}),[f,u,l])}function D(e){const t=c.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return U(()=>{t.current=e},[e]),c.useCallback((...s)=>t.current?.(...s),[t])}const re=new WeakMap;function ge(e=!1,t=document){let s=re.get(t);if(s===void 0||e){const r=t.createElement("div"),n=r.style;n.width="50px",n.height="50px",n.overflow="scroll",n.direction="rtl";const i=t.createElement("div"),a=i.style;a.width="100px",a.height="100px",r.appendChild(i),t.body.appendChild(r),r.scrollLeft>0?s="positive-descending":(r.scrollLeft=1,r.scrollLeft===0?s="negative":s="positive-ascending"),t.body.removeChild(r),re.set(t,s)}return s}function Z({containerElement:e,direction:t,isRtl:s,scrollOffset:r}){if(t==="horizontal"&&s)switch(ge(!1,e?.ownerDocument??document)){case"negative":return-r;case"positive-descending":{if(e){const{clientWidth:n,scrollWidth:i}=e;return i-n-r}break}}return r}function A(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function C(e,t){if(e===t)return!0;if(!!e!=!!t||(A(e!==void 0),A(t!==void 0),Object.keys(e).length!==Object.keys(t).length))return!1;for(const s in e)if(!Object.hasOwn(t,s)||!Object.is(t[s],e[s]))return!1;return!0}function ce({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);A(r!==void 0,"Unexpected bounds cache miss");const n=(r.scrollOffset+r.size)/e.size;return t*n}}function be({align:e,cachedBounds:t,index:s,itemCount:r,itemSize:n,containerScrollOffset:i,containerSize:a}){if(s<0||s>=r)throw RangeError(`Invalid index specified: ${s}`,{cause:`Index ${s} is not within the range of 0 - ${r-1}`});const u=t.get(s),l=ce({cachedBounds:t,itemCount:r,itemSize:n}),f=Math.max(0,Math.min(l-a,u.scrollOffset)),v=Math.max(0,u.scrollOffset-a+u.size),o=u.size>a?i>=u.scrollOffset&&i<=v:i>=v&&i<=u.scrollOffset;switch(e==="smart"&&(e=o?"auto":"center"),e){case"start":return f;case"end":return v;case"center":return Math.max(0,Math.min(l-a,u.scrollOffset+u.size/2-a/2));case"auto":default:return o?i:i<v?v:f}}function Q({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:r,overscanCount:n}){const i=r-1;if(r===0)return{startIndexVisible:0,stopIndexVisible:-1,startIndexOverscan:0,stopIndexOverscan:-1};let a,u;const{itemSize:l}=e;if(l!==void 0&&l>0)a=Math.max(0,Math.min(i,Math.floor(t/l))),u=Math.max(a,Math.min(i,Math.ceil((t+s)/l)-1));else{let f=0,v=Math.min(i,Math.max(0,e.size-1));for(;f<v;){const o=Math.floor((f+v)/2),h=e.get(o);h.scrollOffset+h.size>t?v=o:f=o+1}for(;f<i;){const o=e.get(f);if(o.scrollOffset+o.size>t)break;f++}for(a=f,u=f;u<i;){const o=e.get(u);if(o.scrollOffset+o.size>=t+s)break;u++}}return{startIndexVisible:a,stopIndexVisible:u,startIndexOverscan:Math.max(0,a-n),stopIndexOverscan:Math.min(i,u+n)}}function xe({itemCount:e,itemProps:t,itemSize:s}){const r=new Map;return{itemSize:typeof s=="number"?s:void 0,get(n){if(A(n<e,`Invalid index ${n}`),typeof s=="number"){A(n>=0,`Invalid index ${n}`);let a=r.get(n);return a===void 0&&(a={size:s,scrollOffset:n*s},r.set(n,a)),a}for(;r.size-1<n;){const a=r.size,u=s(a,t);if(a===0)r.set(a,{size:u,scrollOffset:0});else{const l=r.get(a-1);A(l!==void 0,`Unexpected bounds cache miss for index ${n}`),r.set(a,{scrollOffset:l.scrollOffset+l.size,size:u})}}const i=r.get(n);return A(i!==void 0,`Unexpected bounds cache miss for index ${n}`),i},set(n,i){r.set(n,i)},get size(){return r.size}}}function we({itemCount:e,itemProps:t,itemSize:s}){return c.useMemo(()=>xe({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function Ie({containerSize:e,itemSize:t}){let s;switch(typeof t){case"string":{A(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),A(e!==void 0,"Container size must be defined if a percentage item size is specified"),s=e*parseFloat(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:a,itemSize:u,onResize:l,overscanCount:f}){const{height:v=s,width:o=s}=pe({defaultHeight:r==="vertical"?s:void 0,defaultWidth:r==="horizontal"?s:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:t}),h=c.useRef({height:0,width:0}),d=r==="vertical"?v:o,g=Ie({containerSize:d,itemSize:u});c.useLayoutEffect(()=>{if(typeof l=="function"){const x=h.current;(x.height!==v||x.width!==o)&&(l({height:v,width:o},{...x}),x.height=v,x.width=o)}},[v,l,o]);const p=we({itemCount:i,itemProps:a,itemSize:g}),w=c.useCallback(x=>p.get(x),[p]),[b,S]=c.useState(()=>Q({cachedBounds:p,containerScrollOffset:0,containerSize:d,itemCount:i,overscanCount:f})),{startIndexVisible:R,startIndexOverscan:T,stopIndexVisible:H,stopIndexOverscan:I}={startIndexVisible:Math.min(i-1,b.startIndexVisible),startIndexOverscan:Math.min(i-1,b.startIndexOverscan),stopIndexVisible:Math.min(i-1,b.stopIndexVisible),stopIndexOverscan:Math.min(i-1,b.stopIndexOverscan)},q=c.useCallback(()=>ce({cachedBounds:p,itemCount:i,itemSize:g}),[p,i,g]),m=c.useCallback(x=>{const O=Z({containerElement:e,direction:r,isRtl:n,scrollOffset:x});return Q({cachedBounds:p,containerScrollOffset:O,containerSize:d,itemCount:i,overscanCount:f})},[p,e,d,r,n,i,f]);U(()=>{const x=(r==="vertical"?e?.scrollTop:e?.scrollLeft)??0;S(m(x))},[e,r,m]),U(()=>{if(!e)return;const x=()=>{S(O=>{const{scrollLeft:V,scrollTop:y}=e,M=Z({containerElement:e,direction:r,isRtl:n,scrollOffset:r==="vertical"?y:V}),B=Q({cachedBounds:p,containerScrollOffset:M,containerSize:d,itemCount:i,overscanCount:f});return C(B,O)?O:B})};return e.addEventListener("scroll",x),()=>{e.removeEventListener("scroll",x)}},[p,e,d,r,n,i,f]);const G=D(({align:x="auto",containerScrollOffset:O,index:V})=>{let y=be({align:x,cachedBounds:p,containerScrollOffset:Z({containerElement:e,direction:r,isRtl:n,scrollOffset:O}),containerSize:d,index:V,itemCount:i,itemSize:g});if(e){if(y=Z({containerElement:e,direction:r,isRtl:n,scrollOffset:y}),typeof e.scrollTo!="function"){const M=m(y);C(b,M)||S(M)}return y}});return{getCellBounds:w,getEstimatedSize:q,scrollToIndex:G,startIndexOverscan:T,startIndexVisible:R,stopIndexOverscan:I,stopIndexVisible:H}}function le(e){const[t,s]=c.useState(e);return C(t,e)?t:(s(e),e)}function ae(e,t){const{ariaAttributes:s,style:r,...n}=e,{ariaAttributes:i,style:a,...u}=t;return C(s,i)&&C(r,a)&&C(n,u)}function me({cellComponent:e,cellProps:t,children:s,className:r,columnCount:n,columnKey:i,columnWidth:a,defaultHeight:u=0,defaultWidth:l=0,dir:f,gridRef:v,onCellsRendered:o,onResize:h,overscanCount:d=3,rowCount:g,rowHeight:p,rowKey:w,style:b,tagName:S="div",...R}){const T=le(t),H=c.useMemo(()=>c.memo(e,ae),[e]),[I,q]=c.useState(null),m=ve(I,f),{getCellBounds:G,getEstimatedSize:x,startIndexOverscan:O,startIndexVisible:V,scrollToIndex:y,stopIndexOverscan:M,stopIndexVisible:B}=K({containerElement:I,containerStyle:b,defaultContainerSize:l,direction:"horizontal",isRtl:m,itemCount:n,itemProps:T,itemSize:a,onResize:h,overscanCount:d}),{getCellBounds:k,getEstimatedSize:E,startIndexOverscan:L,startIndexVisible:X,scrollToIndex:J,stopIndexOverscan:_,stopIndexVisible:te}=K({containerElement:I,containerStyle:b,defaultContainerSize:u,direction:"vertical",itemCount:g,itemProps:T,itemSize:p,onResize:h,overscanCount:d});c.useImperativeHandle(v,()=>({get element(){return I},scrollToCell({behavior:W="auto",columnAlign:z="auto",columnIndex:j,rowAlign:F="auto",rowIndex:$}){const N=y({align:z,containerScrollOffset:I?.scrollLeft??0,index:j}),de=J({align:F,containerScrollOffset:I?.scrollTop??0,index:$});typeof I?.scrollTo=="function"&&I.scrollTo({behavior:W,left:N,top:de})},scrollToColumn({align:W="auto",behavior:z="auto",index:j}){const F=y({align:W,containerScrollOffset:I?.scrollLeft??0,index:j});typeof I?.scrollTo=="function"&&I.scrollTo({behavior:z,left:F})},scrollToRow({align:W="auto",behavior:z="auto",index:j}){const F=J({align:W,containerScrollOffset:I?.scrollTop??0,index:j});typeof I?.scrollTo=="function"&&I.scrollTo({behavior:z,top:F})}}),[I,y,J]),c.useEffect(()=>{O>=0&&M>=0&&L>=0&&_>=0&&o&&o({columnStartIndex:V,columnStopIndex:B,rowStartIndex:X,rowStopIndex:te},{columnStartIndex:O,columnStopIndex:M,rowStartIndex:L,rowStopIndex:_})},[o,O,V,M,B,L,X,_,te]);const ue=c.useMemo(()=>{const W=[];if(n>0&&g>0)for(let z=L;z<=_;z++){const j=k(z),F=[];for(let $=O;$<=M;$++){const N=G($);F.push(c.createElement(H,{...T,ariaAttributes:{"aria-colindex":$+1,role:"gridcell"},columnIndex:$,key:i?i({columnIndex:$,data:T,rowIndex:z}):$,rowIndex:z,style:{position:"absolute",left:m?void 0:0,right:m?0:void 0,transform:`translate(${m?-N.scrollOffset:N.scrollOffset}px, ${j.scrollOffset}px)`,height:j.size,width:N.size}}))}W.push(P.jsx("div",{role:"row","aria-rowindex":z+1,children:F},w?w({data:T,rowIndex:z}):z))}return W},[H,T,n,i,O,M,G,k,m,g,w,L,_]),fe=P.jsx("div",{"aria-hidden":!0,style:{height:E(),width:x(),zIndex:-1}});return c.createElement(S,{"aria-colcount":n,"aria-rowcount":g,role:"grid",...R,className:r,dir:f,ref:q,style:{position:"relative",maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...b}},ue,s,fe)}const Oe=c.useState,ze=c.useRef;function Se(e){return e!=null&&typeof e=="object"&&"getAverageRowHeight"in e&&typeof e.getAverageRowHeight=="function"}function ye({element:e,getCellBounds:t,isDynamicRowHeight:s,rowCount:r,rowElements:n,scrollToIndex:i}){const a=c.useRef(null),u=c.useRef(void 0),l=D(()=>{a.current=null,u.current!==void 0&&(u.current.view.cancelAnimationFrame(u.current.id),u.current=void 0)}),f=D(()=>{const o=ee(e);u.current={id:o.requestAnimationFrame(v),view:o}}),v=D(()=>{u.current=void 0;const o=a.current;if(!o)return;if(!e||!s||o.index>=r||performance.now()>=o.deadline){l();return}const h=i({align:o.align,containerScrollOffset:e.scrollTop,index:o.index});if(h!==void 0){const d=Math.max(0,Math.min(h,e.scrollHeight-e.clientHeight));if(Math.abs(d-e.scrollTop)>1)o.stableFrames=0,e.scrollTo({behavior:"instant",top:d});else{const g=n.current;if(!(g.some(b=>b.getAttribute(Y)===`${o.index}`)&&g.every(b=>{const S=Number(b.getAttribute(Y));return Math.abs(t(S).size-b.offsetHeight)<=1})))o.stableFrames=0;else if(++o.stableFrames>=2){l();return}}}f()});return U(()=>{if(!e)return;const o=h=>{switch(h.key){case"ArrowUp":case"ArrowDown":case"PageUp":case"PageDown":case"Home":case"End":case" ":l()}};return e.addEventListener("wheel",l,{passive:!0}),e.addEventListener("touchstart",l,{passive:!0}),e.addEventListener("pointerdown",l),e.addEventListener("keydown",o),()=>{l(),e.removeEventListener("wheel",l),e.removeEventListener("touchstart",l),e.removeEventListener("pointerdown",l),e.removeEventListener("keydown",o)}},[l,e]),c.useCallback(({align:o="auto",behavior:h="auto",index:d})=>{s&&o==="smart"&&(o=i({align:"auto",containerScrollOffset:e?.scrollTop??0,index:d})===(e?.scrollTop??0)?"auto":"center");const g=i({align:o,containerScrollOffset:e?.scrollTop??0,index:d});l(),typeof e?.scrollTo=="function"&&(s&&(a.current={align:o,index:d,deadline:performance.now()+1e3,stableFrames:0},f()),e.scrollTo({behavior:s?"instant":h,top:g}))},[l,e,s,f,i])}const Y="data-react-window-index",ne="data-react-window-sizer";function Me({children:e,className:t,defaultHeight:s=0,listRef:r,onResize:n,onRowsRendered:i,overscanCount:a=3,rowComponent:u,rowCount:l,rowHeight:f,rowKey:v,rowProps:o,tagName:h="div",style:d,...g}){const p=le(o),w=c.useMemo(()=>c.memo(u,ae),[u]),[b,S]=c.useState(null),R=Se(f),T=c.useMemo(()=>R?k=>f.getRowHeight(k)??f.getAverageRowHeight():f,[R,f]),{getCellBounds:H,getEstimatedSize:I,scrollToIndex:q,startIndexOverscan:m,startIndexVisible:G,stopIndexOverscan:x,stopIndexVisible:O}=K({containerElement:b,containerStyle:d,defaultContainerSize:s,direction:"vertical",itemCount:l,itemProps:p,itemSize:T,onResize:n,overscanCount:a}),V=c.useRef([]),y=ye({element:b,getCellBounds:H,isDynamicRowHeight:R,rowCount:l,rowElements:V,scrollToIndex:q});c.useImperativeHandle(r,()=>({get element(){return b},scrollToRow:y}),[b,y]),U(()=>{if(!b)return;const k=Array.from(b.children).slice(0,m<0?0:x-m+1).filter((E,L)=>{if(E.hasAttribute(ne))return!1;const X=`${m+L}`;return E.setAttribute(Y,X),!0});if(V.current=k,R)return f.observeRowElements(k)},[w,b,R,l,f,v,p,m,x]),c.useEffect(()=>{m>=0&&x>=0&&i&&i({startIndex:G,stopIndex:O},{startIndex:m,stopIndex:x})},[i,m,G,x,O]);const M=c.useMemo(()=>{const k=[];if(l>0)for(let E=m;E<=x;E++){const L=H(E);k.push(c.createElement(w,{...p,ariaAttributes:{"aria-posinset":E+1,"aria-setsize":l,role:"listitem"},key:v?v(E,p):E,index:E,style:{position:"absolute",left:0,transform:`translateY(${L.scrollOffset}px)`,height:R?void 0:L.size,width:"100%"}}))}return k},[w,H,R,l,v,p,m,x]),B=P.jsx("div",{"aria-hidden":!0,[ne]:"",style:{height:I(),width:"100%",zIndex:-1}});return c.createElement(h,{role:"list",...g,className:t,ref:S,style:{position:"relative",maxHeight:"100%",flexGrow:1,overflowY:"auto",...d}},M,e,B)}function Ee({defaultRowHeight:e,key:t}){const[s,r]=c.useState({key:t,map:new Map});s.key!==t&&r({key:t,map:new Map});const{map:n}=s,i=c.useCallback(()=>{let o=0;return n.forEach(h=>{o+=h}),o===0?e:o/n.size},[e,n]),a=c.useCallback(o=>{const h=n.get(o);return h!==void 0?h:e},[e,n]),u=c.useCallback((o,h)=>{r(d=>{if(d.map.get(o)===h)return d;const g=new Map(d.map);return g.set(o,h),{...d,map:g}})},[]),l=D(o=>{o.length!==0&&o.forEach(h=>{const{borderBoxSize:d,target:g}=h,p=g.getAttribute(Y);A(p!==null,`Invalid ${Y} attribute value`);const w=parseInt(p),{blockSize:b}=d[0];b&&u(w,b)})}),f=c.useRef(null);c.useEffect(()=>()=>{f.current?.resizeObserver.disconnect(),f.current=null},[]);const v=c.useCallback(o=>{const h=[];return o.forEach(d=>{const g=ee(d);if(f.current?.view!==g){f.current?.resizeObserver.disconnect();const w=ie(d);f.current=w?{resizeObserver:new w(l),view:g}:null}const p=f.current?.resizeObserver;p&&(p.observe(d),h.push([d,p]))}),()=>{h.forEach(([d,g])=>g.unobserve(d))}},[l]);return c.useMemo(()=>({getAverageRowHeight:i,getRowHeight:a,setRowHeight:u,observeRowElements:v}),[i,a,u,v])}const Re=c.useState,Te=c.useRef,oe=new WeakMap;function ke(e=!1,t=document){let s=oe.get(t);if(s===void 0||e){const r=t.createElement("div"),n=r.style;n.width="50px",n.height="50px",n.overflow="scroll",t.body.appendChild(r),s=r.offsetWidth-r.clientWidth,t.body.removeChild(r),oe.set(t,s)}return s}exports.Grid=me;exports.List=Me;exports.getScrollbarSize=ke;exports.useDynamicRowHeight=Ee;exports.useGridCallbackRef=Oe;exports.useGridRef=ze;exports.useListCallbackRef=Re;exports.useListRef=Te;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ee=require("react/jsx-runtime"),n=require("react"),W=typeof window<"u"?n.useLayoutEffect:n.useEffect;function ue(e){let t=e;for(;t;){if(t.dir)return t.dir==="rtl";t=t.parentElement}return!1}function xe(e,t){const[s,o]=n.useState(t==="rtl");return W(()=>{t?o(t==="rtl"):e&&o(ue(e))},[t,e]),s}function we(){return()=>{}}function de(){return n.useSyncExternalStore(we,()=>!1,()=>!0)}function oe(e){return e?.ownerDocument.defaultView??window}function he(e){return oe(e).ResizeObserver??(typeof ResizeObserver<"u"?ResizeObserver:void 0)}function ne(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function Ie({box:e,defaultHeight:t,defaultWidth:s,disabled:o,element:r,mode:l,style:i}){const{styleHeight:a,styleWidth:f}=n.useMemo(()=>({styleHeight:ne(i?.height),styleWidth:ne(i?.width)}),[i?.height,i?.width]),[p,u]=n.useState({height:t,width:s}),c=o||l==="only-height"&&a!==void 0||l==="only-width"&&f!==void 0||a!==void 0&&f!==void 0;return W(()=>{if(r===null||c)return;const d=he(r);if(!d)return;const b=new d(h=>{for(const w of h){const{contentRect:v,target:m}=w;r===m&&u(x=>x.height===v.height&&x.width===v.width?x:{height:v.height,width:v.width})}});return b.observe(r,{box:e}),()=>{b?.unobserve(r)}},[e,c,r,a,f]),n.useMemo(()=>({height:a??p.height,width:f??p.width}),[p,a,f])}function Q(e){const t=n.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return W(()=>{t.current=e},[e]),n.useCallback((...s)=>t.current?.(...s),[t])}const le=new WeakMap;function Oe(e=!1,t=document){let s=le.get(t);if(s===void 0||e){const o=t.createElement("div"),r=o.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";const l=t.createElement("div"),i=l.style;i.width="100px",i.height="100px",o.appendChild(l),t.body.appendChild(o),o.scrollLeft>0?s="positive-descending":(o.scrollLeft=1,o.scrollLeft===0?s="negative":s="positive-ascending"),t.body.removeChild(o),le.set(t,s)}return s}function J({containerElement:e,direction:t,isRtl:s,scrollOffset:o}){if(t==="horizontal"&&s)switch(Oe(!1,e?.ownerDocument??document)){case"negative":return-o;case"positive-descending":{if(e){const{clientWidth:r,scrollWidth:l}=e;return l-r-o}break}}return o}function H(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function D(e,t){if(e===t)return!0;if(!!e!=!!t||(H(e!==void 0),H(t!==void 0),Object.keys(e).length!==Object.keys(t).length))return!1;for(const s in e)if(!Object.hasOwn(t,s)||!Object.is(t[s],e[s]))return!1;return!0}function ve({cachedBounds:e,itemCount:t,itemSize:s}){if(t===0)return 0;if(typeof s=="number")return t*s;{const o=e.get(e.size===0?0:e.size-1);H(o!==void 0,"Unexpected bounds cache miss");const r=(o.scrollOffset+o.size)/e.size;return t*r}}function me({align:e,cachedBounds:t,index:s,itemCount:o,itemSize:r,containerScrollOffset:l,containerSize:i}){if(s<0||s>=o)throw RangeError(`Invalid index specified: ${s}`,{cause:`Index ${s} is not within the range of 0 - ${o-1}`});const a=t.get(s),f=ve({cachedBounds:t,itemCount:o,itemSize:r}),p=Math.max(0,Math.min(f-i,a.scrollOffset)),u=Math.max(0,a.scrollOffset-i+a.size),c=a.size>i?l>=a.scrollOffset&&l<=u:l>=u&&l<=a.scrollOffset;switch(e==="smart"&&(e=c?"auto":"center"),e){case"start":return p;case"end":return u;case"center":return Math.max(0,Math.min(f-i,a.scrollOffset+a.size/2-i/2));case"auto":default:return c?l:l<u?u:p}}function re({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:o,overscanCount:r}){const l=o-1;if(o===0)return{startIndexVisible:0,stopIndexVisible:-1,startIndexOverscan:0,stopIndexOverscan:-1};let i,a;const{itemSize:f}=e;if(f!==void 0&&f>0)i=Math.max(0,Math.min(l,Math.floor(t/f))),a=Math.max(i,Math.min(l,Math.ceil((t+s)/f)-1));else{let p=0,u=Math.min(l,Math.max(0,e.size-1));for(;p<u;){const c=Math.floor((p+u)/2),d=e.get(c);d.scrollOffset+d.size>t?u=c:p=c+1}for(;p<l;){const c=e.get(p);if(c.scrollOffset+c.size>t)break;p++}for(i=p,a=p;a<l;){const c=e.get(a);if(c.scrollOffset+c.size>=t+s)break;a++}}return{startIndexVisible:i,stopIndexVisible:a,startIndexOverscan:Math.max(0,i-r),stopIndexOverscan:Math.min(l,a+r)}}function Se({itemCount:e,itemProps:t,itemSize:s}){const o=new Map;return{itemSize:typeof s=="number"?s:void 0,get(r){if(H(r<e,`Invalid index ${r}`),typeof s=="number"){H(r>=0,`Invalid index ${r}`);let i=o.get(r);return i===void 0&&(i={size:s,scrollOffset:r*s},o.set(r,i)),i}for(;o.size-1<r;){const i=o.size,a=s(i,t);if(i===0)o.set(i,{size:a,scrollOffset:0});else{const f=o.get(i-1);H(f!==void 0,`Unexpected bounds cache miss for index ${r}`),o.set(i,{scrollOffset:f.scrollOffset+f.size,size:a})}}const l=o.get(r);return H(l!==void 0,`Unexpected bounds cache miss for index ${r}`),l},set(r,l){o.set(r,l)},get size(){return o.size}}}function ze({itemCount:e,itemProps:t,itemSize:s}){return n.useMemo(()=>Se({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function ye({containerSize:e,itemSize:t}){let s;switch(typeof t){case"string":{H(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),H(e!==void 0,"Container size must be defined if a percentage item size is specified"),s=e*parseFloat(t)/100;break}default:{s=t;break}}return s}function ie({containerElement:e,containerStyle:t,defaultContainerSize:s=0,defaultScrollOffset:o=0,direction:r,isRtl:l=!1,itemCount:i,itemProps:a,itemSize:f,onResize:p,overscanCount:u}){const{height:c=s,width:d=s}=Ie({defaultHeight:r==="vertical"?s:void 0,defaultWidth:r==="horizontal"?s:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:t}),b=n.useRef({height:0,width:0}),h=r==="vertical"?c:d,w=ye({containerSize:h,itemSize:f});W(()=>{if(typeof p=="function"){const g=b.current;(g.height!==c||g.width!==d)&&(p({height:c,width:d},{...g}),g.height=c,g.width=d)}},[c,p,d]);const v=ze({itemCount:i,itemProps:a,itemSize:w}),m=de(),[x]=n.useState(()=>m?0:o),N=n.useCallback(g=>v.get(g),[v]),[z,_]=n.useState(()=>re({cachedBounds:v,containerScrollOffset:x,containerSize:h,itemCount:i,overscanCount:u})),{startIndexVisible:L,startIndexOverscan:j,stopIndexVisible:O,stopIndexOverscan:P}={startIndexVisible:Math.min(i-1,z.startIndexVisible),startIndexOverscan:Math.min(i-1,z.startIndexOverscan),stopIndexVisible:Math.min(i-1,z.stopIndexVisible),stopIndexOverscan:Math.min(i-1,z.stopIndexOverscan)},A=n.useCallback(()=>ve({cachedBounds:v,itemCount:i,itemSize:w}),[v,i,w]),G=n.useCallback(g=>{const I=J({containerElement:e,direction:r,isRtl:l,scrollOffset:g});return re({cachedBounds:v,containerScrollOffset:I,containerSize:h,itemCount:i,overscanCount:u})},[v,e,h,r,l,i,u]),Y=n.useRef(!1);W(()=>{if(!e||i===0||Y.current||(Y.current=!0,o<=0))return;const g=r==="horizontal"&&ue(e);if(J({containerElement:e,direction:r,isRtl:g,scrollOffset:r==="vertical"?e.scrollTop:e.scrollLeft})!==0)return;const y=J({containerElement:e,direction:r,isRtl:g,scrollOffset:o});typeof e.scrollTo=="function"?e.scrollTo({behavior:"instant",[r==="vertical"?"top":"left"]:y}):r==="vertical"?e.scrollTop=y:e.scrollLeft=y},[e,i]),W(()=>{const g=e?G(r==="vertical"?e.scrollTop:e.scrollLeft):re({cachedBounds:v,containerScrollOffset:x,containerSize:h,itemCount:i,overscanCount:u});_(I=>D(g,I)?I:g)},[v,e,h,r,G,x,i,u]),W(()=>{if(!e)return;const g=()=>{_(I=>{const{scrollLeft:y,scrollTop:T}=e,k=J({containerElement:e,direction:r,isRtl:l,scrollOffset:r==="vertical"?T:y}),E=re({cachedBounds:v,containerScrollOffset:k,containerSize:h,itemCount:i,overscanCount:u});return D(E,I)?I:E})};return e.addEventListener("scroll",g),()=>{e.removeEventListener("scroll",g)}},[v,e,h,r,l,i,u]);const S=Q(({align:g="auto",containerScrollOffset:I,index:y})=>{let T=me({align:g,cachedBounds:v,containerScrollOffset:J({containerElement:e,direction:r,isRtl:l,scrollOffset:I}),containerSize:h,index:y,itemCount:i,itemSize:w});if(e){if(T=J({containerElement:e,direction:r,isRtl:l,scrollOffset:T}),typeof e.scrollTo!="function"){const k=G(T);D(z,k)||_(k)}return T}});return{getCellBounds:N,getEstimatedSize:A,scrollToIndex:S,startIndexOverscan:j,startIndexVisible:L,stopIndexOverscan:P,stopIndexVisible:O}}function pe(e){const[t,s]=n.useState(e);return D(t,e)?t:(s(e),e)}function be(e,t){const{ariaAttributes:s,style:o,...r}=e,{ariaAttributes:l,style:i,...a}=t;return D(s,l)&&D(o,i)&&D(r,a)}function Re({cellComponent:e,cellProps:t,children:s,className:o,columnCount:r,columnKey:l,columnWidth:i,defaultHeight:a=0,defaultScrollLeft:f=0,defaultScrollTop:p=0,defaultWidth:u=0,dir:c,gridRef:d,onCellsRendered:b,onResize:h,overscanCount:w=3,rowCount:v,rowHeight:m,rowKey:x,style:N,tagName:z="div",..._}){const L=pe(t),j=n.useMemo(()=>n.memo(e,be),[e]),[O,P]=n.useState(null),A=xe(O,c),{getCellBounds:G,getEstimatedSize:Y,startIndexOverscan:S,startIndexVisible:g,scrollToIndex:I,stopIndexOverscan:y,stopIndexVisible:T}=ie({containerElement:O,containerStyle:N,defaultContainerSize:u,defaultScrollOffset:f,direction:"horizontal",isRtl:A,itemCount:r,itemProps:L,itemSize:i,onResize:h,overscanCount:w}),{getCellBounds:k,getEstimatedSize:E,startIndexOverscan:C,startIndexVisible:se,scrollToIndex:X,stopIndexOverscan:q,stopIndexVisible:V}=ie({containerElement:O,containerStyle:N,defaultContainerSize:a,defaultScrollOffset:p,direction:"vertical",itemCount:v,itemProps:L,itemSize:m,onResize:h,overscanCount:w});n.useImperativeHandle(d,()=>({get element(){return O},scrollToCell({behavior:F="auto",columnAlign:R="auto",columnIndex:B,rowAlign:U="auto",rowIndex:$}){const K=I({align:R,containerScrollOffset:O?.scrollLeft??0,index:B}),ge=X({align:U,containerScrollOffset:O?.scrollTop??0,index:$});typeof O?.scrollTo=="function"&&O.scrollTo({behavior:F,left:K,top:ge})},scrollToColumn({align:F="auto",behavior:R="auto",index:B}){const U=I({align:F,containerScrollOffset:O?.scrollLeft??0,index:B});typeof O?.scrollTo=="function"&&O.scrollTo({behavior:R,left:U})},scrollToRow({align:F="auto",behavior:R="auto",index:B}){const U=X({align:F,containerScrollOffset:O?.scrollTop??0,index:B});typeof O?.scrollTo=="function"&&O.scrollTo({behavior:R,top:U})}}),[O,I,X]),n.useEffect(()=>{S>=0&&y>=0&&C>=0&&q>=0&&b&&b({columnStartIndex:g,columnStopIndex:T,rowStartIndex:se,rowStopIndex:V},{columnStartIndex:S,columnStopIndex:y,rowStartIndex:C,rowStopIndex:q})},[b,S,g,y,T,C,se,q,V]);const M=n.useMemo(()=>{const F=[];if(r>0&&v>0)for(let R=C;R<=q;R++){const B=k(R),U=[];for(let $=S;$<=y;$++){const K=G($);U.push(n.createElement(j,{...L,ariaAttributes:{"aria-colindex":$+1,role:"gridcell"},columnIndex:$,key:l?l({columnIndex:$,data:L,rowIndex:R}):$,rowIndex:R,style:{position:"absolute",left:A?void 0:0,right:A?0:void 0,transform:`translate(${A?-K.scrollOffset:K.scrollOffset}px, ${B.scrollOffset}px)`,height:B.size,width:K.size}}))}F.push(ee.jsx("div",{role:"row","aria-rowindex":R+1,children:U},x?x({data:L,rowIndex:R}):R))}return F},[j,L,r,l,S,y,G,k,A,v,x,C,q]),Z=ee.jsx("div",{"aria-hidden":!0,style:{height:E(),width:Y(),zIndex:-1}});return n.createElement(z,{"aria-colcount":r,"aria-rowcount":v,role:"grid",..._,className:o,dir:c,ref:P,style:{position:"relative",maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...N}},M,s,Z)}const Te=n.useState,Me=n.useRef;function Ae({callback:e,element:t,enabled:s=!0}){const o=Q(e);n.useEffect(()=>{if(!s||!t)return;const r=oe(t);let l=r.requestAnimationFrame(()=>{l=r.requestAnimationFrame(o)});return()=>{r.cancelAnimationFrame(l)}},[t,s,o])}function Le(e){return e!=null&&typeof e=="object"&&"getAverageRowHeight"in e&&typeof e.getAverageRowHeight=="function"}function ke({element:e,getCellBounds:t,isDynamicRowHeight:s,rowCount:o,rowElements:r,scrollToIndex:l}){const i=n.useRef(null),a=n.useRef(void 0),f=Q(()=>{i.current=null,a.current!==void 0&&(a.current.view.cancelAnimationFrame(a.current.id),a.current=void 0)}),p=Q(()=>{const c=oe(e);a.current={id:c.requestAnimationFrame(u),view:c}}),u=Q(()=>{a.current=void 0;const c=i.current;if(!c)return;if(!e||!s||c.index>=o||performance.now()>=c.deadline){f();return}const d=l({align:c.align,containerScrollOffset:e.scrollTop,index:c.index});if(d!==void 0){const b=Math.max(0,Math.min(d,e.scrollHeight-e.clientHeight));if(Math.abs(b-e.scrollTop)>1)c.stableFrames=0,e.scrollTo({behavior:"instant",top:b});else{const h=r.current;if(!(h.some(m=>m.getAttribute(te)===`${c.index}`)&&h.every(m=>{const x=Number(m.getAttribute(te));return Math.abs(t(x).size-m.offsetHeight)<=1})))c.stableFrames=0;else if(++c.stableFrames>=2){f();return}}}p()});return W(()=>{if(!e)return;const c=d=>{switch(d.key){case"ArrowUp":case"ArrowDown":case"PageUp":case"PageDown":case"Home":case"End":case" ":f()}};return e.addEventListener("wheel",f,{passive:!0}),e.addEventListener("touchstart",f,{passive:!0}),e.addEventListener("pointerdown",f),e.addEventListener("keydown",c),()=>{f(),e.removeEventListener("wheel",f),e.removeEventListener("touchstart",f),e.removeEventListener("pointerdown",f),e.removeEventListener("keydown",c)}},[f,e]),n.useCallback(({align:c="auto",behavior:d="auto",index:b})=>{s&&c==="smart"&&(c=l({align:"auto",containerScrollOffset:e?.scrollTop??0,index:b})===(e?.scrollTop??0)?"auto":"center");const h=l({align:c,containerScrollOffset:e?.scrollTop??0,index:b});f(),typeof e?.scrollTo=="function"&&(s&&(i.current={align:c,index:b,deadline:performance.now()+1e3,stableFrames:0},p()),e.scrollTo({behavior:s?"instant":d,top:h}))},[f,e,s,p,l])}const te="data-react-window-index",ce="data-react-window-sizer";function Ee({children:e,className:t,defaultHeight:s=0,defaultScrollOffset:o=0,listRef:r,onResize:l,onRowsRendered:i,overscanCount:a=3,rowComponent:f,rowCount:p,rowHeight:u,rowKey:c,rowProps:d,tagName:b="div",style:h,...w}){const v=pe(d),m=n.useMemo(()=>n.memo(f,be),[f]),[x,N]=n.useState(null),z=Le(u),_=n.useMemo(()=>z?V=>u.getRowHeight(V)??u.getAverageRowHeight():u,[z,u]),L=de(),[j,O]=n.useState(()=>L&&z),P=n.useRef(u);W(()=>{j&&P.current!==u&&O(!1)},[j,u]),Ae({callback:()=>O(!1),element:x,enabled:j});const{getCellBounds:A,getEstimatedSize:G,scrollToIndex:Y,startIndexOverscan:S,startIndexVisible:g,stopIndexOverscan:I,stopIndexVisible:y}=ie({containerElement:x,containerStyle:h,defaultContainerSize:s,defaultScrollOffset:o,direction:"vertical",itemCount:p,itemProps:v,itemSize:_,onResize:l,overscanCount:a}),T=n.useRef([]),k=ke({element:x,getCellBounds:A,isDynamicRowHeight:z,rowCount:p,rowElements:T,scrollToIndex:Y});n.useImperativeHandle(r,()=>({get element(){return x},scrollToRow:k}),[x,k]),W(()=>{if(!x)return;const V=Array.from(x.children).slice(0,S<0?0:I-S+1).filter((M,Z)=>{if(M.hasAttribute(ce))return!1;const F=`${S+Z}`;return M.setAttribute(te,F),!0});if(T.current=V,z)return u.observeRowElements(V)},[m,x,z,p,u,c,v,S,I]),n.useEffect(()=>{S>=0&&I>=0&&i&&i({startIndex:g,stopIndex:y},{startIndex:S,stopIndex:I})},[i,S,g,I,y]);const E=j&&z&&S===0,C=n.useMemo(()=>{const V=[];if(p>0)for(let M=S;M<=I;M++){const Z=A(M);V.push(n.createElement(m,{...v,ariaAttributes:{"aria-posinset":M+1,"aria-setsize":p,role:"listitem"},key:c?c(M,v):M,index:M,style:E?{width:"100%"}:{position:"absolute",left:0,transform:`translateY(${Z.scrollOffset}px)`,height:z?void 0:Z.size,width:"100%"}}))}return V},[m,A,z,E,p,c,v,S,I]),se=ee.jsx("div",{"aria-hidden":!0,[ce]:"",style:{position:E?"absolute":void 0,top:E?0:void 0,height:G(),width:"100%",zIndex:-1}},"sizer"),X=ee.jsx(n.Fragment,{children:e},"children"),q=ee.jsx(n.Fragment,{children:C},"rows");return n.createElement(b,{role:"list",...w,className:t,ref:N,style:{position:"relative",maxHeight:"100%",flexGrow:1,overflowY:"auto",...h}},...E?[X,q]:[q,X],se)}function ae(e){const t=new Map;return e!==void 0&&e.forEach((s,o)=>{Number.isFinite(s)&&s>0&&t.set(o,s)}),t}function Ve({defaultRowHeight:e,initialRowHeights:t,key:s}){const[o,r]=n.useState(()=>({key:s,map:ae(t)}));o.key!==s&&r({key:s,map:ae(t)});const{map:l}=o,i=n.useCallback(()=>{let d=0;return l.forEach(b=>{d+=b}),d===0?e:d/l.size},[e,l]),a=n.useCallback(d=>{const b=l.get(d);return b!==void 0?b:e},[e,l]),f=n.useCallback((d,b)=>{r(h=>{if(h.map.get(d)===b)return h;const w=new Map(h.map);return w.set(d,b),{...h,map:w}})},[]),p=Q(d=>{d.length!==0&&d.forEach(b=>{const{borderBoxSize:h,target:w}=b,v=w.getAttribute(te);H(v!==null,`Invalid ${te} attribute value`);const m=parseInt(v),{blockSize:x}=h[0];x&&f(m,x)})}),u=n.useRef(null);n.useEffect(()=>()=>{u.current?.resizeObserver.disconnect(),u.current=null},[]);const c=n.useCallback(d=>{const b=[];return d.forEach(h=>{const w=oe(h);if(u.current?.view!==w){u.current?.resizeObserver.disconnect();const m=he(h);u.current=m?{resizeObserver:new m(p),view:w}:null}const v=u.current?.resizeObserver;v&&(v.observe(h),b.push([h,v]))}),()=>{b.forEach(([h,w])=>w.unobserve(h))}},[p]);return n.useMemo(()=>({getAverageRowHeight:i,getRowHeight:a,setRowHeight:f,observeRowElements:c}),[i,a,f,c])}const Fe=n.useState,We=n.useRef,fe=new WeakMap;function He(e=!1,t=typeof document<"u"?document:void 0){if(t===void 0)return 0;let s=fe.get(t);if(s===void 0||e){const o=t.createElement("div"),r=o.style;r.width="50px",r.height="50px",r.overflow="scroll",t.body.appendChild(o),s=o.offsetWidth-o.clientWidth,t.body.removeChild(o),fe.set(t,s)}return s}exports.Grid=Re;exports.List=Ee;exports.getScrollbarSize=He;exports.useDynamicRowHeight=Ve;exports.useGridCallbackRef=Te;exports.useGridRef=Me;exports.useListCallbackRef=Fe;exports.useListRef=We;
2
2
  //# sourceMappingURL=react-window.cjs.map