react-window 2.0.0-alpha.4 → 2.0.0-alpha.6
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 +75 -35
- package/dist/react-window.js +488 -395
- package/dist/react-window.js.map +1 -0
- package/docs/assets/index-BRVPsmMd.css +1 -0
- package/docs/assets/index-DoMrhaC7.js +68 -0
- package/docs/data/arabic-countries.json +252 -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 +110 -45
- package/docs/generated/js-docs/List.json +79 -49
- 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-D8tyZCWm.js +0 -67
package/dist/react-window.cjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),l=require("react"),B=typeof window<"u"?l.useLayoutEffect:l.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 J({box:e,defaultHeight:t,defaultWidth:s,disabled:i,element:o,mode:u,style:n}){const{styleHeight:f,styleWidth:r}=l.useMemo(()=>({styleHeight:C(n?.height),styleWidth:C(n?.width)}),[n?.height,n?.width]),[d,h]=l.useState({height:t,width:s}),b=i||u==="only-height"&&f!==void 0||u==="only-width"&&r!==void 0||f!==void 0&&r!==void 0;return B(()=>{if(o===null||b)return;const y=new ResizeObserver(v=>{for(const g of v){const{contentRect:w,target:m}=g;o===m&&h(a=>a.height===w.height&&a.width===w.width?a:{height:w.height,width:w.width})}});return y.observe(o,{box:e}),()=>{y?.unobserve(o)}},[e,b,o,f,r]),l.useMemo(()=>({height:f??d.height,width:r??d.width}),[d,f,r])}function K(e){const t=l.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return B(()=>{t.current=e},[e]),l.useCallback(s=>t.current?.(s),[t])}function E(e,t="Assertion error"){if(!e)throw console.error(t),Error(t)}function V({cachedBounds:e,itemCount:t,itemSize:s}){if(t===0)return 0;if(typeof s=="number")return t*s;{const i=e.get(e.size===0?0:e.size-1);E(i!==void 0,"Unexpected bounds cache miss");const o=(i.scrollOffset+i.size)/e.size;return t*o}}function Q({align:e,cachedBounds:t,index:s,itemCount:i,itemSize:o,containerScrollOffset:u,containerSize:n}){const f=V({cachedBounds:t,itemCount:i,itemSize:o}),r=t.get(s),d=Math.max(0,Math.min(f-n,r.scrollOffset)),h=Math.max(0,r.scrollOffset-n+r.size);switch(e==="smart"&&(u>=h&&u<=d?e="auto":e="center"),e){case"start":return d;case"end":return h;case"center":return r.scrollOffset<=n/2?0:r.scrollOffset+r.size/2>=f-n/2?f-n:r.scrollOffset+r.size/2-n/2;case"auto":default:return u>=h&&u<=d?u:u<h?h:d}}function F({cachedBounds:e,containerScrollOffset:t,containerSize:s,itemCount:i,overscanCount:o}){const u=i-1;let n=0,f=-1,r=0;for(;r<u;){const d=e.get(r);if(d.scrollOffset+d.size>t)break;r++}for(n=r,n=Math.max(0,n-o);r<u;){const d=e.get(r);if(d.scrollOffset+d.size>=t+s)break;r++}return f=Math.min(u,r),f=Math.min(i-1,f+o),n<0?[0,-1]:[n,f]}function X({itemCount:e,itemProps:t,itemSize:s}){const i=new Map;return{get(o){for(E(o<e,`Invalid index ${o}`);i.size-1<o;){const n=i.size;let f;switch(typeof s){case"function":{f=s(n,t);break}case"number":{f=s;break}}if(n===0)i.set(n,{size:f,scrollOffset:0});else{const r=i.get(n-1);E(r!==void 0,`Unexpected bounds cache miss for index ${o}`),i.set(n,{scrollOffset:r.scrollOffset+r.size,size:f})}}const u=i.get(o);return E(u!==void 0,`Unexpected bounds cache miss for index ${o}`),u},set(o,u){i.set(o,u)},get size(){return i.size}}}function Z({itemCount:e,itemProps:t,itemSize:s}){return l.useMemo(()=>X({itemCount:e,itemProps:t,itemSize:s}),[e,t,s])}function _({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 U({containerElement:e,containerStyle:t,defaultContainerSize:s=0,direction:i,itemCount:o,itemProps:u,itemSize:n,onResize:f,overscanCount:r}){const[d,h]=l.useState([0,-1]),[b,y]=[Math.min(o-1,d[0]),Math.min(o-1,d[1])],{height:v=s,width:g=s}=J({defaultHeight:i==="vertical"?s:void 0,defaultWidth:i==="horizontal"?s:void 0,element:e,mode:i==="vertical"?"only-height":"only-width",style:t}),w=l.useRef({height:0,width:0}),m=i==="vertical"?v:g,a=_({containerSize:m,itemSize:n});l.useLayoutEffect(()=>{if(typeof f=="function"){const c=w.current;(c.height!==v||c.width!==g)&&(f({height:v,width:g},{...c}),c.height=v,c.width=g)}},[v,f,g]);const p=Z({itemCount:o,itemProps:u,itemSize:a}),O=l.useCallback(c=>p.get(c),[p]),T=l.useCallback(()=>V({cachedBounds:p,itemCount:o,itemSize:a}),[p,o,a]),I=l.useCallback(c=>F({cachedBounds:p,containerScrollOffset:c,containerSize:m,itemCount:o,overscanCount:r}),[p,m,o,r]);B(()=>{const c=(i==="vertical"?e?.scrollTop:e?.scrollLeft)??0;h(I(c))},[e,i,I]),B(()=>{if(!e)return;const c=()=>{h(x=>{const W=i==="vertical"?e.scrollTop:e.scrollLeft,z=F({cachedBounds:p,containerScrollOffset:W,containerSize:m,itemCount:o,overscanCount:r});return z[0]===x[0]&&z[1]===x[1]?x:z})};return e.addEventListener("scroll",c),()=>{e.removeEventListener("scroll",c)}},[p,e,m,i,o,r]);const k=K(({align:c="auto",behavior:x="auto",containerScrollOffset:W,index:z})=>{const $=Q({align:c,cachedBounds:p,containerScrollOffset:W,containerSize:m,index:z,itemCount:o,itemSize:a});if(e)if(typeof e.scrollTo=="function")i==="horizontal"?e.scrollTo({left:$,behavior:x||void 0}):e.scrollTo({behavior:x||void 0,top:$});else{const M=I($);(M[0]!==b||M[1]!==y)&&h(M)}});return{getCellBounds:O,getEstimatedSize:T,scrollToIndex:k,startIndex:b,stopIndex:y}}function Y(e){return l.useMemo(()=>e,Object.values(e))}function P(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 A(e,t){const{style:s,...i}=e,{style:o,...u}=t;return P(s,o)&&P(i,u)}function N({cellComponent:e,cellProps:t,className:s,columnCount:i,columnWidth:o,defaultHeight:u=0,defaultWidth:n=0,gridRef:f,onCellsRendered:r,onResize:d,overscanCount:h=3,rowCount:b,rowHeight:y,style:v,...g}){const w=Y(t),m=l.useMemo(()=>l.memo(e,A),[e]),[a,p]=l.useState(null),{getCellBounds:O,getEstimatedSize:T,startIndex:I,scrollToIndex:k,stopIndex:c}=U({containerElement:a,defaultContainerSize:n,direction:"horizontal",itemCount:i,itemProps:w,itemSize:o,onResize:d,overscanCount:h}),{getCellBounds:x,getEstimatedSize:W,startIndex:z,scrollToIndex:$,stopIndex:M}=U({containerElement:a,defaultContainerSize:u,direction:"vertical",itemCount:b,itemProps:w,itemSize:y,onResize:d,overscanCount:h});l.useImperativeHandle(f,()=>({get element(){return a},scrollToCell({behavior:L="auto",columnAlign:S="auto",columnIndex:R,rowAlign:j="auto",rowIndex:G}){$({align:j,behavior:L,containerScrollOffset:a?.scrollTop??0,index:G}),k({align:S,behavior:L,containerScrollOffset:a?.scrollLeft??0,index:R})},scrollToColumn({align:L="auto",behavior:S="auto",index:R}){k({align:L,behavior:S,containerScrollOffset:a?.scrollLeft??0,index:R})},scrollToRow({align:L="auto",behavior:S="auto",index:R}){$({align:L,behavior:S,containerScrollOffset:a?.scrollTop??0,index:R})}}),[a,k,$]),l.useEffect(()=>{I>=0&&c>=0&&z>=0&&M>=0&&r&&r({columnStartIndex:I,columnStopIndex:c,rowStartIndex:z,rowStopIndex:M})},[r,I,c,z,M]);const D=l.useMemo(()=>{const L=[];if(i>0&&b>0)for(let S=z;S<=M;S++){const R=x(S);for(let j=I;j<=c;j++){const G=O(j);L.push(l.createElement(m,{...w,columnIndex:j,key:`${S}-${j}`,rowIndex:S,style:{position:"absolute",left:0,transform:`translate(${G.scrollOffset}px, ${R.scrollOffset}px)`,height:b>1?R.size:"100%",width:G.size}}))}}return L},[m,w,i,I,c,O,x,b,z,M]);return H.jsx("div",{role:"grid",...g,className:s,ref:p,style:{width:"100%",height:"100%",...v,maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto"},children:H.jsx("div",{className:s,style:{position:"relative",height:W(),width:T()},children:D})})}const ee=l.useState,te=l.useRef;function se({className:e,defaultHeight:t=0,listRef:s,onResize:i,onRowsRendered:o,overscanCount:u=3,rowComponent:n,rowCount:f,rowHeight:r,rowProps:d,style:h,...b}){const y=Y(d),v=l.useMemo(()=>l.memo(n,A),[n]),[g,w]=l.useState(null),{getCellBounds:m,getEstimatedSize:a,scrollToIndex:p,startIndex:O,stopIndex:T}=U({containerElement:g,defaultContainerSize:t,direction:"vertical",itemCount:f,itemProps:y,itemSize:r,onResize:i,overscanCount:u});l.useImperativeHandle(s,()=>({get element(){return g},scrollToRow({align:k="auto",behavior:c="auto",index:x}){p({align:k,behavior:c,containerScrollOffset:g?.scrollTop??0,index:x})}}),[g,p]),l.useEffect(()=>{O>=0&&T>=0&&o&&o({startIndex:O,stopIndex:T})},[o,O,T]);const I=l.useMemo(()=>{const k=[];if(f>0)for(let c=O;c<=T;c++){const x=m(c);k.push(l.createElement(v,{...y,key:c,index:c,style:{position:"absolute",left:0,transform:`translateY(${x.scrollOffset}px)`,height:x.size,width:"100%"}}))}return k},[v,m,f,y,O,T]);return H.jsx("div",{role:"list",...b,className:e,ref:w,style:{...h,maxHeight:"100%",flexGrow:1,overflowY:"auto"},children:H.jsx("div",{className:e,style:{height:a(),position:"relative",width:"100%"},children:I})})}const oe=l.useState,re=l.useRef;let q=-1;function ie(e=!1){if(q===-1||e){const t=document.createElement("div"),s=t.style;s.width="50px",s.height="50px",s.overflow="scroll",document.body.appendChild(t),q=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return q}exports.Grid=N;exports.List=se;exports.getScrollbarSize=ie;exports.useGridCallbackRef=ee;exports.useGridRef=te;exports.useListCallbackRef=oe;exports.useListRef=re;
|
|
2
|
+
//# sourceMappingURL=react-window.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-window.cjs","sources":["../lib/hooks/useIsomorphicLayoutEffect.ts","../lib/utils/parseNumericStyleValue.ts","../lib/hooks/useResizeObserver.ts","../lib/hooks/useStableCallback.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":["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 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 { 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 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 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 (containerScrollOffset: number) =>\n getStartStopIndicesUtil({\n cachedBounds,\n containerScrollOffset,\n containerSize,\n itemCount,\n overscanCount\n }),\n [cachedBounds, containerSize, itemCount, overscanCount]\n );\n\n useIsomorphicLayoutEffect(() => {\n const scrollOffset =\n (direction === \"vertical\"\n ? containerElement?.scrollTop\n : containerElement?.scrollLeft) ?? 0;\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 scrollOffset =\n direction === \"vertical\"\n ? containerElement.scrollTop\n : containerElement.scrollLeft;\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 const scrollOffset = getOffsetForIndex({\n align,\n cachedBounds,\n containerScrollOffset,\n containerSize,\n index,\n itemCount,\n itemSize\n });\n\n if (containerElement) {\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 { 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 dir=rtl (onScroll, scrollToCell, scrollOffset)\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 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 {\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 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: 0,\n transform: `translate(${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 rowCount,\n rowStartIndex,\n rowStopIndex\n ]);\n\n return (\n <div\n role=\"grid\"\n {...rest}\n className={className}\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":["useIsomorphicLayoutEffect","useLayoutEffect","useEffect","parseNumericStyleValue","value","useResizeObserver","box","defaultHeight","defaultWidth","disabledProp","element","mode","style","styleHeight","styleWidth","useMemo","state","setState","useState","disabled","resizeObserver","entries","entry","contentRect","target","prevState","useStableCallback","fn","ref","useRef","useCallback","args","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","containerElement","containerStyle","defaultContainerSize","direction","onResize","indices","setIndices","height","width","prevSizeRef","prevSize","getCellBounds","getEstimatedSizeUtil","getStartStopIndicesUtil","scrollOffset","onScroll","prev","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","recalculate","div"],"mappings":"wIAEaA,EACX,OAAO,OAAW,IAAcC,EAAAA,gBAAkBC,EAAAA,UCD7C,SAASC,EACdC,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,SAASC,EAAkB,CAChC,IAAAC,EACA,cAAAC,EACA,aAAAC,EACA,SAAUC,EACV,QAAAC,EACA,KAAAC,EACA,MAAAC,CACF,EAQG,CACD,KAAM,CAAE,YAAAC,EAAa,WAAAC,CAAA,EAAeC,EAAAA,QAClC,KAAO,CACL,YAAaZ,EAAuBS,GAAO,MAAM,EACjD,WAAYT,EAAuBS,GAAO,KAAK,CAAA,GAEjD,CAACA,GAAO,OAAQA,GAAO,KAAK,CAAA,EAGxB,CAACI,EAAOC,CAAQ,EAAIC,WAGvB,CACD,OAAQX,EACR,MAAOC,CAAA,CACR,EAEKW,EACJV,GACCE,IAAS,eAAiBE,IAAgB,QAC1CF,IAA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O,CACL,GAAGnG,EACH,UAAW,OACX,SAAU,EACV,UAAW,MAAA,EAGb,SAAAwH,EAAAA,IAAC,MAAA,CACC,UAAAhC,EACA,MAAO,CACL,OAAQjE,EAAA,EACR,SAAU,WACV,MAAO,MAAA,EAGR,SAAA2G,CAAA,CAAA,CACH,CAAA,CAGN,CCnIO,MAAMC,GACX7H,EAAAA,SCHW8H,GAAanH,EAAAA,OCN1B,IAAI6B,EAAe,GAEZ,SAASuF,GAAiBC,EAAuB,GAAe,CACrE,GAAIxF,IAAS,IAAMwF,EAAa,CAC9B,MAAMC,EAAM,SAAS,cAAc,KAAK,EAClCvI,EAAQuI,EAAI,MAClBvI,EAAM,MAAQ,OACdA,EAAM,OAAS,OACfA,EAAM,SAAW,SAEjB,SAAS,KAAK,YAAYuI,CAAG,EAE7BzF,EAAOyF,EAAI,YAAcA,EAAI,YAE7B,SAAS,KAAK,YAAYA,CAAG,CAC/B,CAEA,OAAOzF,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, 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`
|
|
91
87
|
*/
|
|
92
|
-
columnWidth: number | ((index: number, cellProps: CellProps) => number);
|
|
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
|
|
102
|
+
*/
|
|
103
|
+
dir?: "ltr" | "rtl";
|
|
93
104
|
/**
|
|
94
105
|
* Ref used to interact with this component's imperative API.
|
|
95
106
|
*
|
|
@@ -107,6 +118,17 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
107
118
|
rowStartIndex: number;
|
|
108
119
|
rowStopIndex: number;
|
|
109
120
|
}) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Callback notified when the Grid's outermost HTMLElement resizes.
|
|
123
|
+
* This may be used to (re)scroll a cell into view.
|
|
124
|
+
*/
|
|
125
|
+
onResize?: (size: {
|
|
126
|
+
height: number;
|
|
127
|
+
width: number;
|
|
128
|
+
}, prevSize: {
|
|
129
|
+
height: number;
|
|
130
|
+
width: number;
|
|
131
|
+
}) => void;
|
|
110
132
|
/**
|
|
111
133
|
* How many additional rows/columns to render outside of the visible area.
|
|
112
134
|
* This can reduce visual flickering near the edges of a grid when scrolling.
|
|
@@ -117,9 +139,12 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
117
139
|
*/
|
|
118
140
|
rowCount: number;
|
|
119
141
|
/**
|
|
120
|
-
* 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`
|
|
121
146
|
*/
|
|
122
|
-
rowHeight: number | ((index: number, cellProps: CellProps) => number);
|
|
147
|
+
rowHeight: number | string | ((index: number, cellProps: CellProps) => number);
|
|
123
148
|
/**
|
|
124
149
|
* Optional CSS properties.
|
|
125
150
|
* The grid of cells will fill the height and width defined by this style.
|
|
@@ -127,7 +152,7 @@ export declare type GridProps<CellProps extends object> = HTMLAttributes<HTMLDiv
|
|
|
127
152
|
style?: CSSProperties;
|
|
128
153
|
};
|
|
129
154
|
|
|
130
|
-
export declare function List<RowProps extends object>({ className, defaultHeight, listRef,
|
|
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;
|
|
131
156
|
|
|
132
157
|
export declare type ListImperativeAPI = {
|
|
133
158
|
get element(): HTMLDivElement | null;
|
|
@@ -138,7 +163,7 @@ export declare type ListImperativeAPI = {
|
|
|
138
163
|
}): void;
|
|
139
164
|
};
|
|
140
165
|
|
|
141
|
-
export declare type ListProps<RowProps extends object> = HTMLAttributes<HTMLDivElement> & {
|
|
166
|
+
export declare type ListProps<RowProps extends object> = Omit<HTMLAttributes<HTMLDivElement>, "onResize"> & {
|
|
142
167
|
/**
|
|
143
168
|
* CSS class name.
|
|
144
169
|
*/
|
|
@@ -156,6 +181,29 @@ export declare type ListProps<RowProps extends object> = HTMLAttributes<HTMLDivE
|
|
|
156
181
|
* ⚠️ The `useListRef` and `useListCallbackRef` hooks are exported for convenience use in TypeScript projects.
|
|
157
182
|
*/
|
|
158
183
|
listRef?: Ref<ListImperativeAPI>;
|
|
184
|
+
/**
|
|
185
|
+
* Callback notified when the List's outermost HTMLElement resizes.
|
|
186
|
+
* This may be used to (re)scroll a row into view.
|
|
187
|
+
*/
|
|
188
|
+
onResize?: (size: {
|
|
189
|
+
height: number;
|
|
190
|
+
width: number;
|
|
191
|
+
}, prevSize: {
|
|
192
|
+
height: number;
|
|
193
|
+
width: number;
|
|
194
|
+
}) => void;
|
|
195
|
+
/**
|
|
196
|
+
* Callback notified when the range of visible rows changes.
|
|
197
|
+
*/
|
|
198
|
+
onRowsRendered?: (args: {
|
|
199
|
+
startIndex: number;
|
|
200
|
+
stopIndex: number;
|
|
201
|
+
}) => void;
|
|
202
|
+
/**
|
|
203
|
+
* How many additional rows to render outside of the visible area.
|
|
204
|
+
* This can reduce visual flickering near the edges of a list when scrolling.
|
|
205
|
+
*/
|
|
206
|
+
overscanCount?: number;
|
|
159
207
|
/**
|
|
160
208
|
* React component responsible for rendering a row.
|
|
161
209
|
*
|
|
@@ -173,27 +221,19 @@ export declare type ListProps<RowProps extends object> = HTMLAttributes<HTMLDivE
|
|
|
173
221
|
*/
|
|
174
222
|
rowCount: number;
|
|
175
223
|
/**
|
|
176
|
-
* 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`
|
|
177
228
|
*/
|
|
178
|
-
rowHeight: number | ((index: number,
|
|
229
|
+
rowHeight: number | string | ((index: number, cellProps: RowProps) => number);
|
|
179
230
|
/**
|
|
180
|
-
* 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.
|
|
181
233
|
*
|
|
182
234
|
* ⚠️ This object must not contain either an `index` or `style` prop.
|
|
183
235
|
*/
|
|
184
236
|
rowProps: ExcludeForbiddenKeys_2<RowProps>;
|
|
185
|
-
/**
|
|
186
|
-
* Callback notified when the range of visible rows changes.
|
|
187
|
-
*/
|
|
188
|
-
onRowsRendered?: (args: {
|
|
189
|
-
startIndex: number;
|
|
190
|
-
stopIndex: number;
|
|
191
|
-
}) => void;
|
|
192
|
-
/**
|
|
193
|
-
* How many additional rows to render outside of the visible area.
|
|
194
|
-
* This can reduce visual flickering near the edges of a list when scrolling.
|
|
195
|
-
*/
|
|
196
|
-
overscanCount?: number;
|
|
197
237
|
/**
|
|
198
238
|
* Optional CSS properties.
|
|
199
239
|
* The list of rows will fill the height defined by this style.
|