react-window 2.0.0-alpha.5 → 2.0.0-alpha.7
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/dist/react-window.cjs +2 -1
- package/dist/react-window.cjs.map +1 -0
- package/dist/react-window.d.ts +41 -23
- package/dist/react-window.js +558 -404
- package/dist/react-window.js.map +1 -0
- package/docs/assets/index-BLMZr8Ze.css +1 -0
- package/docs/assets/index-Cvqxb3fG.js +68 -0
- package/docs/generated/code-snippets/FixedHeightRowComponent.json +2 -2
- package/docs/generated/code-snippets/FlexboxLayout.json +2 -2
- package/docs/generated/code-snippets/HorizontalList.json +4 -0
- package/docs/generated/code-snippets/HorizontalListCellRenderer.json +4 -0
- package/docs/generated/code-snippets/ListVariableRowHeights.json +2 -2
- package/docs/generated/code-snippets/RtlGrid.json +4 -0
- package/docs/generated/js-docs/Grid.json +83 -45
- package/docs/generated/js-docs/List.json +7 -4
- package/docs/index.html +2 -2
- package/docs/stats.html +1 -1
- package/package.json +2 -1
- package/docs/assets/index-BsBvdJUI.css +0 -1
- package/docs/assets/index-DcPBnht2.js +0 -67
package/dist/react-window.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),n=require("react"),P=typeof window<"u"?n.useLayoutEffect:n.useEffect;function C(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function q({box:e,defaultHeight:s,defaultWidth:l,disabled:r,element:t,mode:f,style:c}){const{styleHeight:u,styleWidth:o}=n.useMemo(()=>({styleHeight:C(c?.height),styleWidth:C(c?.width)}),[c?.height,c?.width]),[a,v]=n.useState({height:s,width:l}),M=r||f==="only-height"&&u!==void 0||f==="only-width"&&o!==void 0||u!==void 0&&o!==void 0;return P(()=>{if(t===null||M)return;const O=new ResizeObserver(m=>{for(const I of m){const{contentRect:w,target:b}=I;t===b&&v(d=>d.height===w.height&&d.width===w.width?d:{height:w.height,width:w.width})}});return O.observe(t,{box:e}),()=>{O?.unobserve(t)}},[e,M,t,u,o]),n.useMemo(()=>({height:u??a.height,width:o??a.width}),[a,u,o])}function F(e){const s=n.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return P(()=>{s.current=e},[e]),n.useCallback(l=>s.current?.(l),[s])}function L(e,s="Assertion error"){if(!e)throw console.error(s),Error(s)}function N({cachedBounds:e,itemCount:s,itemSize:l}){if(typeof l=="number")return s*l;if(e.size>0){const r=e.get(e.size-1);L(r!==void 0,"Unexpected bounds cache miss");const t=(r.scrollOffset+r.size)/e.size;return s*t}else return 0}function Y({align:e,cachedBounds:s,index:l,itemCount:r,containerScrollOffset:t,containerSize:f}){const c=s.get(r-1).scrollOffset,u=c+c-f,o=Math.max(0,s.get(l+1).scrollOffset-f),a=Math.min(c,s.get(l).scrollOffset);switch(e==="smart"&&(t>=o&&t<=a?e="auto":e="center"),e){case"start":return Math.min(u,a);case"end":return o;case"center":{const v=Math.round(o+(a-o)/2);return v<Math.ceil(f/2)?0:v>u?u:v}case"auto":default:return t>=o&&t<=a?t:t<o?o:a}}function A({cachedBounds:e,containerScrollOffset:s,containerSize:l,itemCount:r,overscanCount:t}){const f=r-1;let c=0,u=-1,o=0;for(;o<f;){const a=e.get(o);if(a.scrollOffset+a.size>s)break;o++}for(c=o,c=Math.max(0,c-t);o<f;){const a=e.get(o);if(a.scrollOffset+a.size>=s+l)break;o++}return u=Math.min(f,o),u=Math.min(r-1,u+t),c<0?[0,-1]:[c,u]}function _({itemCount:e,itemProps:s,itemSize:l}){const r=new Map;return{get(t){for(L(t<e,`Invalid index ${t}`);r.size-1<t;){const c=r.size,u=typeof l=="number"?l:l(c,s);if(c===0)r.set(c,{size:u,scrollOffset:0});else{const o=r.get(c-1);L(o!==void 0,`Unexpected bounds cache miss for index ${t}`),r.set(c,{scrollOffset:o.scrollOffset+o.size,size:u})}}const f=r.get(t);return L(f!==void 0,`Unexpected bounds cache miss for index ${t}`),f},set(t,f){r.set(t,f)},get size(){return r.size}}}function D({itemCount:e,itemProps:s,itemSize:l}){return n.useMemo(()=>_({itemCount:e,itemProps:s,itemSize:l}),[e,s,l])}function G({containerElement:e,containerStyle:s,defaultContainerSize:l=0,direction:r,itemCount:t,itemProps:f,itemSize:c,onResize:u,overscanCount:o}){const[a,v]=n.useState([0,-1]),[M,O]=[Math.min(t-1,a[0]),Math.min(t-1,a[1])],{height:m=l,width:I=l}=q({defaultHeight:r==="vertical"?l:void 0,defaultWidth:r==="horizontal"?l:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:s}),w=n.useRef({height:0,width:0});n.useLayoutEffect(()=>{if(typeof u=="function"){const i=w.current;(i.height!==m||i.width!==I)&&(u({height:m,width:I},{...i}),i.height=m,i.width=I)}},[m,u,I]);const b=r==="vertical"?m:I,d=D({itemCount:t,itemProps:f,itemSize:c}),y=n.useCallback(i=>d.get(i),[d]),R=n.useCallback(()=>N({cachedBounds:d,itemCount:t,itemSize:c}),[d,t,c]),g=n.useCallback(i=>A({cachedBounds:d,containerScrollOffset:i,containerSize:b,itemCount:t,overscanCount:o}),[d,b,t,o]);P(()=>{const i=(r==="vertical"?e?.scrollTop:e?.scrollLeft)??0;v(g(i))},[e,r,g]);const h=F(({align:i="auto",behavior:T="auto",containerScrollOffset:x,index:p})=>{const k=Y({align:i,cachedBounds:d,containerScrollOffset:x,containerSize:b,index:p,itemCount:t});r==="horizontal"?e?.scrollTo({left:k,behavior:T||void 0}):e?.scrollTo({behavior:T||void 0,top:k})});return{getCellBounds:y,getEstimatedHeight:R,onScroll:()=>{const i=g((r==="vertical"?e?.scrollTop:e?.scrollLeft)??0);(i[0]!==M||i[1]!==O)&&v(i)},scrollToIndex:h,startIndex:M,stopIndex:O}}function B(e){return n.useMemo(()=>e,Object.values(e))}function W(e,s){if(e===s)return!0;if(!!e!=!!s||(L(e!==void 0),L(s!==void 0),Object.keys(e).length!==Object.keys(s).length))return!1;for(const l in e)if(!Object.is(s[l],e[l]))return!1;return!0}function U(e,s){const{style:l,...r}=e,{style:t,...f}=s;return W(l,t)&&W(r,f)}const V=()=>{};function J({cellComponent:e,cellProps:s,className:l,columnCount:r,columnWidth:t,defaultHeight:f=0,defaultWidth:c=0,gridRef:u,onCellsRendered:o,onResize:a,onScroll:v=V,overscanCount:M=3,rowCount:O,rowHeight:m,style:I,...w}){const b=B(s),d=n.useMemo(()=>n.memo(e,U),[e]),[y,R]=n.useState(null),g=G({containerElement:y,defaultContainerSize:c,direction:"horizontal",itemCount:r,itemProps:b,itemSize:t,onResize:a,overscanCount:M}),h=G({containerElement:y,defaultContainerSize:f,direction:"vertical",itemCount:O,itemProps:b,itemSize:m,onResize:a,overscanCount:M}),{startIndex:i,stopIndex:T}=g,{startIndex:x,stopIndex:p}=h;n.useImperativeHandle(u,()=>({get element(){return y},scrollToCell({behavior:S="auto",columnAlign:z="auto",columnIndex:E,rowAlign:H="auto",rowIndex:j}){h?.scrollToIndex({align:H,behavior:S,containerScrollOffset:y?.scrollTop??0,index:j}),g?.scrollToIndex({align:z,behavior:S,containerScrollOffset:y?.scrollLeft??0,index:E})},scrollToColumn({align:S="auto",behavior:z="auto",index:E}){g?.scrollToIndex({align:S,behavior:z,containerScrollOffset:y?.scrollLeft??0,index:E})},scrollToRow({align:S="auto",behavior:z="auto",index:E}){h?.scrollToIndex({align:S,behavior:z,containerScrollOffset:y?.scrollTop??0,index:E})}}),[g,y,h]),n.useEffect(()=>{i>=0&&T>=0&&x>=0&&p>=0&&o&&o({columnStartIndex:i,columnStopIndex:T,rowStartIndex:x,rowStopIndex:p})},[o,i,T,x,p]);const k=n.useMemo(()=>{const S=[];if(g&&r>0&&h&&O>0)for(let z=x;z<=p;z++){const E=h.getCellBounds(z);for(let H=i;H<=T;H++){const j=g.getCellBounds(H);S.push(n.createElement(d,{...b,columnIndex:H,key:`${z}-${H}`,rowIndex:z,style:{position:"absolute",left:0,transform:`translate(${j.scrollOffset}px, ${E.scrollOffset}px)`,height:E.size,width:j.size}}))}}return S},[d,b,r,i,T,g,O,x,p,h]);return $.jsx("div",{role:"grid",...w,className:l,onScroll:S=>{g.onScroll(),h.onScroll(),v(S)},ref:R,style:{...I,maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto"},children:$.jsx("div",{className:l,style:{position:"relative",height:h?.getEstimatedHeight(),width:g?.getEstimatedHeight()},children:k})})}const K=n.useState,Q=n.useRef;function X({className:e,defaultHeight:s=0,listRef:l,onResize:r,onRowsRendered:t,onScroll:f=V,overscanCount:c=3,rowComponent:u,rowCount:o,rowHeight:a,rowProps:v,style:M,...O}){const m=B(v),I=n.useMemo(()=>n.memo(u,U),[u]),[w,b]=n.useState(null),{getCellBounds:d,getEstimatedHeight:y,onScroll:R,scrollToIndex:g,startIndex:h,stopIndex:i}=G({containerElement:w,defaultContainerSize:s,direction:"vertical",itemCount:o,itemProps:m,itemSize:a,onResize:r,overscanCount:c});n.useImperativeHandle(l,()=>({get element(){return w},scrollToRow({align:x="auto",behavior:p="auto",index:k}){g({align:x,behavior:p,containerScrollOffset:w?.scrollTop??0,index:k})}}),[w,g]),n.useEffect(()=>{h>=0&&i>=0&&t&&t({startIndex:h,stopIndex:i})},[t,h,i]);const T=n.useMemo(()=>{const x=[];if(o>0)for(let p=h;p<=i;p++){const k=d(p);x.push(n.createElement(I,{...m,key:p,index:p,style:{position:"absolute",left:0,transform:`translateY(${k.scrollOffset}px)`,height:k.size,width:"100%"}}))}return x},[I,d,o,m,h,i]);return $.jsx("div",{role:"list",...O,className:e,onScroll:x=>{R(),f(x)},ref:b,style:{...M,maxHeight:"100%",flexGrow:1,overflowY:"auto"},children:$.jsx("div",{className:e,style:{height:y(),position:"relative",width:"100%"},children:T})})}const Z=n.useState,ee=n.useRef;exports.Grid=J;exports.List=X;exports.useGridCallbackRef=K;exports.useGridRef=Q;exports.useListCallbackRef=Z;exports.useListRef=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),n=require("react");function Z(e){let t=e;for(;t;){if(t.dir)return t.dir==="rtl";t=t.parentElement}return!1}function _(e,t){const[s,r]=n.useState(t==="rtl");return n.useLayoutEffect(()=>{e&&(t||r(Z(e)))},[t,e]),s}const F=typeof window<"u"?n.useLayoutEffect:n.useEffect;function P(e){if(e!==void 0)switch(typeof e){case"number":return e;case"string":{if(e.endsWith("px"))return parseFloat(e);break}}}function N({box:e,defaultHeight:t,defaultWidth:s,disabled:r,element:o,mode:l,style:c}){const{styleHeight:f,styleWidth:i}=n.useMemo(()=>({styleHeight:P(c?.height),styleWidth:P(c?.width)}),[c?.height,c?.width]),[u,g]=n.useState({height:t,width:s}),z=r||l==="only-height"&&f!==void 0||l==="only-width"&&i!==void 0||f!==void 0&&i!==void 0;return F(()=>{if(o===null||z)return;const x=new ResizeObserver(L=>{for(const v of L){const{contentRect:w,target:S}=v;o===S&&g(p=>p.height===w.height&&p.width===w.width?p:{height:w.height,width:w.width})}});return x.observe(o,{box:e}),()=>{x?.unobserve(o)}},[e,z,o,f,i]),n.useMemo(()=>({height:f??u.height,width:i??u.width}),[u,f,i])}function ee(e){const t=n.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return F(()=>{t.current=e},[e]),n.useCallback(s=>t.current?.(s),[t])}let G=null;function te(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"),o=r.style;return o.width="100px",o.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 U({containerElement:e,direction:t,isRtl:s,scrollOffset:r}){if(t==="horizontal"&&s)switch(te()){case"negative":return-r;case"positive-descending":{if(e){const{clientWidth:o,scrollLeft:l,scrollWidth:c}=e;return c-o-l}break}}return r}function E(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function J({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);E(r!==void 0,"Unexpected bounds cache miss");const o=(r.scrollOffset+r.size)/e.size;return t*o}}function se({align:e,cachedBounds:t,index:s,itemCount:r,itemSize:o,containerScrollOffset:l,containerSize:c}){const f=J({cachedBounds:t,itemCount:r,itemSize:o}),i=t.get(s),u=Math.max(0,Math.min(f-c,i.scrollOffset)),g=Math.max(0,i.scrollOffset-c+i.size);switch(e==="smart"&&(l>=g&&l<=u?e="auto":e="center"),e){case"start":return u;case"end":return g;case"center":return i.scrollOffset<=c/2?0:i.scrollOffset+i.size/2>=f-c/2?f-c:i.scrollOffset+i.size/2-c/2;case"auto":default:return l>=g&&l<=u?l:l<g?g:u}}function Y({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:r,overscanCount:o}){const l=r-1;let c=0,f=-1,i=0;for(;i<l;){const u=e.get(i);if(u.scrollOffset+u.size>t)break;i++}for(c=i,c=Math.max(0,c-o);i<l;){const u=e.get(i);if(u.scrollOffset+u.size>=t+s)break;i++}return f=Math.min(l,i),f=Math.min(r-1,f+o),c<0?[0,-1]:[c,f]}function re({itemCount:e,itemProps:t,itemSize:s}){const r=new Map;return{get(o){for(E(o<e,`Invalid index ${o}`);r.size-1<o;){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 i=r.get(c-1);E(i!==void 0,`Unexpected bounds cache miss for index ${o}`),r.set(c,{scrollOffset:i.scrollOffset+i.size,size:f})}}const l=r.get(o);return E(l!==void 0,`Unexpected bounds cache miss for index ${o}`),l},set(o,l){r.set(o,l)},get size(){return r.size}}}function oe({itemCount:e,itemProps:t,itemSize:s}){return n.useMemo(()=>re({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function le({containerSize:e,itemSize:t}){let s;switch(typeof t){case"string":{E(t.endsWith("%"),`Invalid item size: "${t}"; string values must be percentages (e.g. "100%")`),E(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 D({containerElement:e,containerStyle:t,defaultContainerSize:s=0,direction:r,isRtl:o=!1,itemCount:l,itemProps:c,itemSize:f,onResize:i,overscanCount:u}){const[g,z]=n.useState([0,-1]),[x,L]=[Math.min(l-1,g[0]),Math.min(l-1,g[1])],{height:v=s,width:w=s}=N({defaultHeight:r==="vertical"?s:void 0,defaultWidth:r==="horizontal"?s:void 0,element:e,mode:r==="vertical"?"only-height":"only-width",style:t}),S=n.useRef({height:0,width:0}),p=r==="vertical"?v:w,a=le({containerSize:p,itemSize:f});n.useLayoutEffect(()=>{if(typeof i=="function"){const d=S.current;(d.height!==v||d.width!==w)&&(i({height:v,width:w},{...d}),d.height=v,d.width=w)}},[v,i,w]);const h=oe({itemCount:l,itemProps:c,itemSize:a}),y=n.useCallback(d=>h.get(d),[h]),W=n.useCallback(()=>J({cachedBounds:h,itemCount:l,itemSize:a}),[h,l,a]),k=n.useCallback(d=>{const b=U({containerElement:e,direction:r,isRtl:o,scrollOffset:d});return Y({cachedBounds:h,containerScrollOffset:b,containerSize:p,itemCount:l,overscanCount:u})},[h,e,p,r,o,l,u]);F(()=>{const d=(r==="vertical"?e?.scrollTop:e?.scrollLeft)??0;z(k(d))},[e,r,k]),F(()=>{if(!e)return;const d=()=>{z(b=>{const{scrollLeft:$,scrollTop:H}=e,I=U({containerElement:e,direction:r,isRtl:o,scrollOffset:r==="vertical"?H:$}),O=Y({cachedBounds:h,containerScrollOffset:I,containerSize:p,itemCount:l,overscanCount:u});return O[0]===b[0]&&O[1]===b[1]?b:O})};return e.addEventListener("scroll",d),()=>{e.removeEventListener("scroll",d)}},[h,e,p,r,l,u]);const m=ee(({align:d="auto",behavior:b="auto",containerScrollOffset:$,index:H})=>{let I=se({align:d,cachedBounds:h,containerScrollOffset:$,containerSize:p,index:H,itemCount:l,itemSize:a});if(e)if(I=U({containerElement:e,direction:r,isRtl:o,scrollOffset:I}),typeof e.scrollTo=="function")r==="horizontal"?e.scrollTo({left:I,behavior:b||void 0}):e.scrollTo({behavior:b||void 0,top:I});else{const O=k(I);(O[0]!==x||O[1]!==L)&&z(O)}});return{getCellBounds:y,getEstimatedSize:W,scrollToIndex:m,startIndex:x,stopIndex:L}}function K(e){return n.useMemo(()=>e,Object.values(e))}function A(e,t){if(e===t)return!0;if(!!e!=!!t||(E(e!==void 0),E(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 Q(e,t){const{style:s,...r}=e,{style:o,...l}=t;return A(s,o)&&A(r,l)}function ie({cellComponent:e,cellProps:t,className:s,columnCount:r,columnWidth:o,defaultHeight:l=0,defaultWidth:c=0,dir:f,gridRef:i,onCellsRendered:u,onResize:g,overscanCount:z=3,rowCount:x,rowHeight:L,style:v,...w}){const S=K(t),p=n.useMemo(()=>n.memo(e,Q),[e]),[a,h]=n.useState(null),y=_(a,f),{getCellBounds:W,getEstimatedSize:k,startIndex:m,scrollToIndex:d,stopIndex:b}=D({containerElement:a,defaultContainerSize:c,direction:"horizontal",isRtl:y,itemCount:r,itemProps:S,itemSize:o,onResize:g,overscanCount:z}),{getCellBounds:$,getEstimatedSize:H,startIndex:I,scrollToIndex:O,stopIndex:B}=D({containerElement:a,defaultContainerSize:l,direction:"vertical",itemCount:x,itemProps:S,itemSize:L,onResize:g,overscanCount:z});n.useImperativeHandle(i,()=>({get element(){return a},scrollToCell({behavior:M="auto",columnAlign:T="auto",columnIndex:R,rowAlign:j="auto",rowIndex:C}){O({align:j,behavior:M,containerScrollOffset:a?.scrollTop??0,index:C}),d({align:T,behavior:M,containerScrollOffset:a?.scrollLeft??0,index:R})},scrollToColumn({align:M="auto",behavior:T="auto",index:R}){d({align:M,behavior:T,containerScrollOffset:a?.scrollLeft??0,index:R})},scrollToRow({align:M="auto",behavior:T="auto",index:R}){O({align:M,behavior:T,containerScrollOffset:a?.scrollTop??0,index:R})}}),[a,d,O]),n.useEffect(()=>{m>=0&&b>=0&&I>=0&&B>=0&&u&&u({columnStartIndex:m,columnStopIndex:b,rowStartIndex:I,rowStopIndex:B})},[u,m,b,I,B]);const X=n.useMemo(()=>{const M=[];if(r>0&&x>0)for(let T=I;T<=B;T++){const R=$(T);for(let j=m;j<=b;j++){const C=W(j);M.push(n.createElement(p,{...S,columnIndex:j,key:`${T}-${j}`,rowIndex:T,style:{position:"absolute",left:y?void 0:0,right:y?0:void 0,transform:`translate(${y?-C.scrollOffset:C.scrollOffset}px, ${R.scrollOffset}px)`,height:x>1?R.size:"100%",width:C.size}}))}}return M},[p,S,r,m,b,W,$,y,x,I,B]);return q.jsx("div",{role:"grid",...w,className:s,dir:f,ref:h,style:{width:"100%",height:"100%",...v,maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto"},children:q.jsx("div",{className:s,style:{position:"relative",height:H(),width:k()},children:X})})}const ne=n.useState,ce=n.useRef;function fe({className:e,defaultHeight:t=0,listRef:s,onResize:r,onRowsRendered:o,overscanCount:l=3,rowComponent:c,rowCount:f,rowHeight:i,rowProps:u,style:g,...z}){const x=K(u),L=n.useMemo(()=>n.memo(c,Q),[c]),[v,w]=n.useState(null),{getCellBounds:S,getEstimatedSize:p,scrollToIndex:a,startIndex:h,stopIndex:y}=D({containerElement:v,defaultContainerSize:t,direction:"vertical",itemCount:f,itemProps:x,itemSize:i,onResize:r,overscanCount:l});n.useImperativeHandle(s,()=>({get element(){return v},scrollToRow({align:k="auto",behavior:m="auto",index:d}){a({align:k,behavior:m,containerScrollOffset:v?.scrollTop??0,index:d})}}),[v,a]),n.useEffect(()=>{h>=0&&y>=0&&o&&o({startIndex:h,stopIndex:y})},[o,h,y]);const W=n.useMemo(()=>{const k=[];if(f>0)for(let m=h;m<=y;m++){const d=S(m);k.push(n.createElement(L,{...x,key:m,index:m,style:{position:"absolute",left:0,transform:`translateY(${d.scrollOffset}px)`,height:d.size,width:"100%"}}))}return k},[L,S,f,x,h,y]);return q.jsx("div",{role:"list",...z,className:e,ref:w,style:{...g,maxHeight:"100%",flexGrow:1,overflowY:"auto"},children:q.jsx("div",{className:e,style:{height:p(),position:"relative",width:"100%"},children:W})})}const ue=n.useState,de=n.useRef;let V=-1;function ae(e=!1){if(V===-1||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",document.body.appendChild(t),V=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return V}exports.Grid=ie;exports.List=fe;exports.getScrollbarSize=ae;exports.useGridCallbackRef=ne;exports.useGridRef=ce;exports.useListCallbackRef=ue;exports.useListRef=de;
|
|
2
|
+
//# sourceMappingURL=react-window.cjs.map
|
|
@@ -0,0 +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/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/shallowCompare.ts","../lib/utils/arePropsEqual.ts","../lib/components/grid/Grid.tsx","../lib/components/grid/useGridCallbackRef.ts","../lib/components/grid/useGridRef.ts","../lib/components/list/List.tsx","../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;\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 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 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 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}): [number, number] {\n const maxIndex = itemCount - 1;\n\n let startIndex = 0;\n let stopIndex = -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 startIndex = currentIndex;\n startIndex = Math.max(0, startIndex - 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 stopIndex = Math.min(maxIndex, currentIndex);\n stopIndex = Math.min(itemCount - 1, stopIndex + overscanCount);\n\n return startIndex < 0 ? [0, -1] : [startIndex, stopIndex];\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 { 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 [indices, setIndices] = useState([0, -1]);\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 [startIndex, stopIndex] = [\n Math.min(itemCount - 1, indices[0]),\n Math.min(itemCount - 1, indices[1])\n ];\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 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 (next[0] === prev[0] && next[1] === prev[1]) {\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 behavior = \"auto\",\n containerScrollOffset,\n index\n }: {\n align?: Align;\n behavior?: ScrollBehavior;\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 if (direction === \"horizontal\") {\n containerElement.scrollTo({\n left: scrollOffset,\n behavior: behavior || undefined\n });\n } else {\n containerElement.scrollTo({\n behavior: behavior || undefined,\n top: scrollOffset\n });\n }\n } else {\n // Special case for environments like jsdom that don't implement scrollTo\n const next = getStartStopIndices(scrollOffset);\n if (next[0] !== startIndex || next[1] !== stopIndex) {\n setIndices(next);\n }\n }\n }\n }\n );\n\n return {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndex,\n stopIndex\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 { 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 { 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: { style: CSSProperties },\n nextProps: { style: CSSProperties }\n): boolean {\n const { style: prevStyle, ...prevRest } = prevProps;\n const { style: nextStyle, ...nextRest } = nextProps;\n\n return (\n shallowCompare(prevStyle, nextStyle) && shallowCompare(prevRest, nextRest)\n );\n}\n","import {\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactNode\n} from \"react\";\nimport { useIsRtl } from \"../../core/useIsRtl\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { GridProps } from \"./types\";\n\n// TODO Handle scrollbar sizes (add width/height if necessary)\n\nexport function Grid<CellProps extends object>({\n cellComponent: CellComponentProp,\n cellProps: cellPropsUnstable,\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 ...rest\n}: GridProps<CellProps>) {\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 startIndex: columnStartIndex,\n scrollToIndex: scrollToColumnIndex,\n stopIndex: columnStopIndex\n } = useVirtualizer({\n containerElement: element,\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 startIndex: rowStartIndex,\n scrollToIndex: scrollToRowIndex,\n stopIndex: rowStopIndex\n } = useVirtualizer({\n containerElement: element,\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 scrollToRowIndex({\n align: rowAlign,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index: rowIndex\n });\n scrollToColumnIndex({\n align: columnAlign,\n behavior,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index: columnIndex\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 scrollToColumnIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollLeft ?? 0,\n index\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 scrollToRowIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n }\n }),\n [element, scrollToColumnIndex, scrollToRowIndex]\n );\n\n useEffect(() => {\n if (\n columnStartIndex >= 0 &&\n columnStopIndex >= 0 &&\n rowStartIndex >= 0 &&\n rowStopIndex >= 0 &&\n onCellsRendered\n ) {\n onCellsRendered({\n columnStartIndex,\n columnStopIndex,\n rowStartIndex,\n rowStopIndex\n });\n }\n }, [\n onCellsRendered,\n columnStartIndex,\n columnStopIndex,\n rowStartIndex,\n rowStopIndex\n ]);\n\n const cells = useMemo(() => {\n const children: ReactNode[] = [];\n if (columnCount > 0 && rowCount > 0) {\n for (let rowIndex = rowStartIndex; rowIndex <= rowStopIndex; rowIndex++) {\n const rowBounds = getRowBounds(rowIndex);\n for (\n let columnIndex = columnStartIndex;\n columnIndex <= columnStopIndex;\n columnIndex++\n ) {\n const columnBounds = getColumnBounds(columnIndex);\n\n children.push(\n <CellComponent\n {...(cellProps as CellProps)}\n columnIndex={columnIndex}\n key={`${rowIndex}-${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: rowCount > 1 ? rowBounds.size : \"100%\",\n width: columnBounds.size\n }}\n />\n );\n }\n }\n }\n return children;\n }, [\n CellComponent,\n cellProps,\n columnCount,\n columnStartIndex,\n columnStopIndex,\n getColumnBounds,\n getRowBounds,\n isRtl,\n rowCount,\n rowStartIndex,\n rowStopIndex\n ]);\n\n return (\n <div\n role=\"grid\"\n {...rest}\n className={className}\n dir={dir}\n ref={setElement}\n style={{\n width: \"100%\",\n height: \"100%\",\n ...style,\n maxHeight: \"100%\",\n maxWidth: \"100%\",\n flexGrow: 1,\n overflow: \"auto\"\n }}\n >\n <div\n className={className}\n style={{\n position: \"relative\",\n height: getEstimatedHeight(),\n width: getEstimatedWidth()\n }}\n >\n {cells}\n </div>\n </div>\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 {\n memo,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n type ReactNode\n} from \"react\";\nimport { useVirtualizer } from \"../../core/useVirtualizer\";\nimport { useMemoizedObject } from \"../../hooks/useMemoizedObject\";\nimport type { Align } from \"../../types\";\nimport { arePropsEqual } from \"../../utils/arePropsEqual\";\nimport type { ListProps } from \"./types\";\n\nexport function List<RowProps extends object>({\n className,\n defaultHeight = 0,\n listRef,\n onResize,\n onRowsRendered,\n overscanCount = 3,\n rowComponent: RowComponentProp,\n rowCount,\n rowHeight,\n rowProps: rowPropsUnstable,\n style,\n ...rest\n}: ListProps<RowProps>) {\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 {\n getCellBounds,\n getEstimatedSize,\n scrollToIndex,\n startIndex,\n stopIndex\n } = useVirtualizer({\n containerElement: element,\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 scrollToIndex({\n align,\n behavior,\n containerScrollOffset: element?.scrollTop ?? 0,\n index\n });\n }\n }),\n [element, scrollToIndex]\n );\n\n useEffect(() => {\n if (startIndex >= 0 && stopIndex >= 0 && onRowsRendered) {\n onRowsRendered({\n startIndex,\n stopIndex\n });\n }\n }, [onRowsRendered, startIndex, stopIndex]);\n\n const rows = useMemo(() => {\n const children: ReactNode[] = [];\n if (rowCount > 0) {\n for (let index = startIndex; index <= stopIndex; index++) {\n const bounds = getCellBounds(index);\n\n children.push(\n <RowComponent\n {...(rowProps as RowProps)}\n key={index}\n index={index}\n style={{\n position: \"absolute\",\n left: 0,\n transform: `translateY(${bounds.scrollOffset}px)`,\n height: bounds.size,\n width: \"100%\"\n }}\n />\n );\n }\n }\n return children;\n }, [RowComponent, getCellBounds, rowCount, rowProps, startIndex, stopIndex]);\n\n return (\n <div\n role=\"list\"\n {...rest}\n className={className}\n ref={setElement}\n style={{\n ...style,\n maxHeight: \"100%\",\n flexGrow: 1,\n overflowY: \"auto\"\n }}\n >\n <div\n className={className}\n style={{\n height: getEstimatedSize(),\n position: \"relative\",\n width: \"100%\"\n }}\n >\n {rows}\n </div>\n </div>\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","getEstimatedSize","cachedBounds","itemCount","itemSize","bounds","averageItemSize","getOffsetForIndex","align","index","containerScrollOffset","containerSize","estimatedTotalSize","maxOffset","minOffset","getStartStopIndices","overscanCount","maxIndex","startIndex","stopIndex","currentIndex","createCachedBounds","itemProps","cache","size","previousRowBounds","useCachedBounds","useItemSize","itemSizeProp","useVirtualizer","containerStyle","defaultContainerSize","onResize","indices","setIndices","height","width","prevSizeRef","prevSize","getCellBounds","getEstimatedSizeUtil","getStartStopIndicesUtil","onScroll","prev","scrollTop","next","scrollToIndex","behavior","useMemoizedObject","unstableObject","shallowCompare","a","b","key","arePropsEqual","prevProps","nextProps","prevStyle","prevRest","nextStyle","nextRest","Grid","CellComponentProp","cellPropsUnstable","className","columnCount","columnWidth","gridRef","onCellsRendered","rowCount","rowHeight","rest","cellProps","CellComponent","memo","setElement","getColumnBounds","getEstimatedWidth","columnStartIndex","scrollToColumnIndex","columnStopIndex","getRowBounds","getEstimatedHeight","rowStartIndex","scrollToRowIndex","rowStopIndex","useImperativeHandle","columnAlign","columnIndex","rowAlign","rowIndex","cells","children","rowBounds","columnBounds","createElement","jsx","useGridCallbackRef","useGridRef","List","listRef","onRowsRendered","RowComponentProp","rowPropsUnstable","rowProps","RowComponent","rows","useListCallbackRef","useListRef","getScrollbarSize","div"],"mappings":"wIAAO,SAASA,EAAMC,EAAsB,CAC1C,IAAIC,EAAqCD,EACzC,KAAOC,GAAgB,CACrB,GAAIA,EAAe,IACjB,OAAOA,EAAe,MAAQ,MAGhCA,EAAiBA,EAAe,aAClC,CAEA,MAAO,EACT,CCRO,SAASC,EACdF,EACAG,EACA,CACA,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAAAA,SAASH,IAAQ,KAAK,EAEhDI,OAAAA,EAAAA,gBAAgB,IAAM,CAChBP,IACGG,GACHE,EAASN,EAAMC,CAAO,CAAC,EAG7B,EAAG,CAACG,EAAKH,CAAO,CAAC,EAEVI,CACT,CChBO,MAAMI,EACX,OAAO,OAAW,IAAcD,EAAAA,gBAAkBE,EAAAA,UCD7C,SAASC,EACdN,EACoB,CACpB,GAAIA,IAAU,OACZ,OAAQ,OAAOA,EAAA,CACb,IAAK,SACH,OAAOA,EAET,IAAK,SAAU,CACb,GAAIA,EAAM,SAAS,IAAI,EACrB,OAAO,WAAWA,CAAK,EAEzB,KACF,CAAA,CAGN,CCdO,SAASO,EAAkB,CAChC,IAAAC,EACA,cAAAC,EACA,aAAAC,EACA,SAAUC,EACV,QAAAf,EACA,KAAAgB,EACA,MAAAC,CACF,EAQG,CACD,KAAM,CAAE,YAAAC,EAAa,WAAAC,CAAA,EAAeC,EAAAA,QAClC,KAAO,CACL,YAAaV,E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GAASU,EAAWV,IAAS,CACxD,MAAMJ,EAASkC,EAAc9B,CAAK,EAElCmF,EAAS,KACPG,EAAAA,cAACU,EAAA,CACE,GAAID,EACL,IAAK/F,EACL,MAAAA,EACA,MAAO,CACL,SAAU,WACV,KAAM,EACN,UAAW,cAAcJ,EAAO,YAAY,MAC5C,OAAQA,EAAO,KACf,MAAO,MAAA,CACT,CAAA,CACF,CAEJ,CAEF,OAAOuF,CACT,EAAG,CAACa,EAAclE,EAAe8B,EAAUmC,EAAUtF,EAAYC,CAAS,CAAC,EAE3E,OACE6E,EAAAA,IAAC,MAAA,CACC,KAAK,OACJ,GAAGzB,EACJ,UAAAP,EACA,IAAKW,EACL,MAAO,CACL,GAAG9G,EACH,UAAW,OACX,SAAU,EACV,UAAW,MAAA,EAGb,SAAAmI,EAAAA,IAAC,MAAA,CACC,UAAAhC,EACA,MAAO,CACL,OAAQ/D,EAAA,EACR,SAAU,WACV,MAAO,MAAA,EAGR,SAAAyG,CAAA,CAAA,CACH,CAAA,CAGN,CCnIO,MAAMC,GACXzJ,EAAAA,SCHW0J,GAAa/H,EAAAA,OCN1B,IAAI2C,EAAe,GAEZ,SAASqF,GAAiB3H,EAAuB,GAAe,CACrE,GAAIsC,IAAS,IAAMtC,EAAa,CAC9B,MAAM4H,EAAM,SAAS,cAAc,KAAK,EAClCjJ,EAAQiJ,EAAI,MAClBjJ,EAAM,MAAQ,OACdA,EAAM,OAAS,OACfA,EAAM,SAAW,SAEjB,SAAS,KAAK,YAAYiJ,CAAG,EAE7BtF,EAAOsF,EAAI,YAAcA,EAAI,YAE7B,SAAS,KAAK,YAAYA,CAAG,CAC/B,CAEA,OAAOtF,CACT"}
|
package/dist/react-window.d.ts
CHANGED
|
@@ -25,7 +25,9 @@ declare type ForbiddenKeys = "columnIndex" | "rowIndex" | "style";
|
|
|
25
25
|
|
|
26
26
|
declare type ForbiddenKeys_2 = "index" | "style";
|
|
27
27
|
|
|
28
|
-
export declare function
|
|
28
|
+
export declare function getScrollbarSize(recalculate?: boolean): number;
|
|
29
|
+
|
|
30
|
+
export declare function Grid<CellProps extends object>({ cellComponent: CellComponentProp, cellProps: cellPropsUnstable, className, columnCount, columnWidth, defaultHeight, defaultWidth, dir, gridRef, onCellsRendered, onResize, overscanCount, rowCount, rowHeight, style, ...rest }: GridProps<CellProps>): JSX.Element;
|
|
29
31
|
|
|
30
32
|
export declare type GridImperativeAPI = {
|
|
31
33
|
get element(): HTMLDivElement | null;
|
|
@@ -48,21 +50,11 @@ export declare type GridImperativeAPI = {
|
|
|
48
50
|
}): void;
|
|
49
51
|
};
|
|
50
52
|
|
|
51
|
-
export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDivElement> & {
|
|
53
|
+
export declare type GridProps<CellProps extends object> = Omit<HTMLAttributes<HTMLDivElement>, "onResize"> & {
|
|
52
54
|
/**
|
|
53
55
|
* CSS class name.
|
|
54
56
|
*/
|
|
55
57
|
className?: string;
|
|
56
|
-
/**
|
|
57
|
-
* Default height of grid for initial render.
|
|
58
|
-
* This value is important for server rendering.
|
|
59
|
-
*/
|
|
60
|
-
defaultHeight?: number;
|
|
61
|
-
/**
|
|
62
|
-
* Default width of grid for initial render.
|
|
63
|
-
* This value is important for server rendering.
|
|
64
|
-
*/
|
|
65
|
-
defaultWidth?: number;
|
|
66
58
|
/**
|
|
67
59
|
* React component responsible for rendering a cell.
|
|
68
60
|
*
|
|
@@ -77,9 +69,10 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
77
69
|
style: CSSProperties;
|
|
78
70
|
} & CellProps) => ReactNode;
|
|
79
71
|
/**
|
|
80
|
-
* Additional props to be passed to the
|
|
72
|
+
* Additional props to be passed to the cell-rendering component.
|
|
73
|
+
* Grid will automatically re-render cells when values in this object change.
|
|
81
74
|
*
|
|
82
|
-
* ⚠️ This object must not contain either an `
|
|
75
|
+
* ⚠️ This object must not contain either an `index` or `style` prop.
|
|
83
76
|
*/
|
|
84
77
|
cellProps: ExcludeForbiddenKeys<CellProps>;
|
|
85
78
|
/**
|
|
@@ -87,9 +80,27 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
87
80
|
*/
|
|
88
81
|
columnCount: number;
|
|
89
82
|
/**
|
|
90
|
-
* Column width
|
|
83
|
+
* Column width; the following formats are supported:
|
|
84
|
+
* - number of pixels (number)
|
|
85
|
+
* - percentage of the grid's current width (string)
|
|
86
|
+
* - function that returns the row width (in pixels) given an index and `cellProps`
|
|
87
|
+
*/
|
|
88
|
+
columnWidth: number | string | ((index: number, cellProps: CellProps) => number);
|
|
89
|
+
/**
|
|
90
|
+
* Default height of grid for initial render.
|
|
91
|
+
* This value is important for server rendering.
|
|
92
|
+
*/
|
|
93
|
+
defaultHeight?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Default width of grid for initial render.
|
|
96
|
+
* This value is important for server rendering.
|
|
97
|
+
*/
|
|
98
|
+
defaultWidth?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Corresponds to the HTML dir attribute:
|
|
101
|
+
* https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/dir
|
|
91
102
|
*/
|
|
92
|
-
|
|
103
|
+
dir?: "ltr" | "rtl";
|
|
93
104
|
/**
|
|
94
105
|
* Ref used to interact with this component's imperative API.
|
|
95
106
|
*
|
|
@@ -128,9 +139,12 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
128
139
|
*/
|
|
129
140
|
rowCount: number;
|
|
130
141
|
/**
|
|
131
|
-
* Row height
|
|
142
|
+
* Row height; the following formats are supported:
|
|
143
|
+
* - number of pixels (number)
|
|
144
|
+
* - percentage of the grid's current height (string)
|
|
145
|
+
* - function that returns the row height (in pixels) given an index and `cellProps`
|
|
132
146
|
*/
|
|
133
|
-
rowHeight: number | ((index: number, cellProps: CellProps) => number);
|
|
147
|
+
rowHeight: number | string | ((index: number, cellProps: CellProps) => number);
|
|
134
148
|
/**
|
|
135
149
|
* Optional CSS properties.
|
|
136
150
|
* The grid of cells will fill the height and width defined by this style.
|
|
@@ -138,7 +152,7 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
138
152
|
style?: CSSProperties;
|
|
139
153
|
};
|
|
140
154
|
|
|
141
|
-
export declare function List<RowProps extends object>({ className, defaultHeight, listRef, onResize, onRowsRendered,
|
|
155
|
+
export declare function List<RowProps extends object>({ className, defaultHeight, listRef, onResize, onRowsRendered, overscanCount, rowComponent: RowComponentProp, rowCount, rowHeight, rowProps: rowPropsUnstable, style, ...rest }: ListProps<RowProps>): JSX.Element;
|
|
142
156
|
|
|
143
157
|
export declare type ListImperativeAPI = {
|
|
144
158
|
get element(): HTMLDivElement | null;
|
|
@@ -149,7 +163,7 @@ export declare type ListImperativeAPI = {
|
|
|
149
163
|
}): void;
|
|
150
164
|
};
|
|
151
165
|
|
|
152
|
-
export declare type ListProps<RowProps extends object> = HTMLAttributes<HTMLDivElement> & {
|
|
166
|
+
export declare type ListProps<RowProps extends object> = Omit<HTMLAttributes<HTMLDivElement>, "onResize"> & {
|
|
153
167
|
/**
|
|
154
168
|
* CSS class name.
|
|
155
169
|
*/
|
|
@@ -207,11 +221,15 @@ export declare type ListProps<RowProps extends object> = HTMLAttributes<HTMLDivE
|
|
|
207
221
|
*/
|
|
208
222
|
rowCount: number;
|
|
209
223
|
/**
|
|
210
|
-
* Row height
|
|
224
|
+
* Row height; the following formats are supported:
|
|
225
|
+
* - number of pixels (number)
|
|
226
|
+
* - percentage of the grid's current height (string)
|
|
227
|
+
* - function that returns the row height (in pixels) given an index and `cellProps`
|
|
211
228
|
*/
|
|
212
|
-
rowHeight: number | ((index: number,
|
|
229
|
+
rowHeight: number | string | ((index: number, cellProps: RowProps) => number);
|
|
213
230
|
/**
|
|
214
|
-
* Additional props to be passed to the
|
|
231
|
+
* Additional props to be passed to the row-rendering component.
|
|
232
|
+
* List will automatically re-render rows when values in this object change.
|
|
215
233
|
*
|
|
216
234
|
* ⚠️ This object must not contain either an `index` or `style` prop.
|
|
217
235
|
*/
|