virtua 0.1.8 → 0.1.9
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/lib/core/cache.d.ts +1 -1
- package/lib/core/store.d.ts +4 -6
- package/lib/core/utils.d.ts +2 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/package.json +3 -1
package/lib/core/cache.d.ts
CHANGED
|
@@ -10,8 +10,8 @@ export type Cache = DeepReadonly<{
|
|
|
10
10
|
export declare const getItemSize: (cache: Cache, index: number) => number;
|
|
11
11
|
export declare const setItemSize: (cache: Writeable<Cache>, index: number, size: number) => void;
|
|
12
12
|
export declare const computeTotalSize: (cache: Writeable<Cache>) => number;
|
|
13
|
+
export declare const computeStartOffset: (cache: Writeable<Cache>, index: number) => number;
|
|
13
14
|
export declare const findStartIndexWithOffset: (cache: Cache, offset: number, prevStartIndex: number, prevOffset: number) => number;
|
|
14
15
|
export declare const findEndIndex: (cache: Cache, i: number, distance: number) => number;
|
|
15
16
|
export declare const hasUnmeasuredItemsInRange: (cache: Cache, startIndex: number, endIndex: number) => boolean;
|
|
16
|
-
export declare const computeStartOffset: (cache: Writeable<Cache>, index: number) => number;
|
|
17
17
|
export declare const resetCache: (length: number, itemSize: number, cache?: Cache) => Cache;
|
package/lib/core/store.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
export type ScrollJump = Readonly<[index: number, sizeDiff: number][]>;
|
|
2
|
+
export type ItemResize = [index: number, size: number];
|
|
3
|
+
type ItemsRange = [startIndex: number, endIndex: number];
|
|
2
4
|
export declare const ACTION_UPDATE_CACHE_LENGTH = 0;
|
|
3
5
|
export declare const ACTION_UPDATE_ITEM_SIZES = 1;
|
|
4
6
|
export declare const ACTION_UPDATE_VIEWPORT = 2;
|
|
5
7
|
export declare const ACTION_HANDLE_SCROLL = 3;
|
|
6
|
-
type Actions = [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number] | [
|
|
7
|
-
type: typeof ACTION_UPDATE_ITEM_SIZES,
|
|
8
|
-
entries: [index: number, size: number][]
|
|
9
|
-
] | [
|
|
8
|
+
type Actions = [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number] | [type: typeof ACTION_UPDATE_ITEM_SIZES, entries: ItemResize[]] | [
|
|
10
9
|
type: typeof ACTION_UPDATE_VIEWPORT,
|
|
11
10
|
rect: {
|
|
12
11
|
_width: number;
|
|
@@ -14,8 +13,7 @@ type Actions = [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number] | [
|
|
|
14
13
|
}
|
|
15
14
|
] | [type: typeof ACTION_HANDLE_SCROLL, offset: number];
|
|
16
15
|
export type VirtualStore = {
|
|
17
|
-
|
|
18
|
-
_getEndIndex(): number;
|
|
16
|
+
_getRange(): ItemsRange;
|
|
19
17
|
_isUnmeasuredItem(index: number): boolean;
|
|
20
18
|
_hasUnmeasuredItemsInRange(startIndex: number): boolean;
|
|
21
19
|
_getItemOffset(index: number): number;
|
package/lib/core/utils.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare const min: (...values: number[]) => number;
|
|
2
2
|
export declare const max: (...values: number[]) => number;
|
|
3
3
|
export declare const abs: (x: number) => number;
|
|
4
|
+
export declare const now: () => number;
|
|
4
5
|
export declare const exists: <T>(v: T) => v is Exclude<T, null | undefined>;
|
|
5
6
|
export declare const range: <T>(length: number, cb: (i: number) => T) => T[];
|
|
6
7
|
export declare const debounce: <T extends (...args: any[]) => void>(fn: T, ms: number) => {
|
|
7
8
|
(): void;
|
|
8
9
|
_cancel: () => void;
|
|
9
10
|
};
|
|
11
|
+
export declare const throttle: <T extends (...args: any[]) => void>(fn: T, ms: number) => (...args: Parameters<T>) => void;
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=require("react/jsx-runtime"),t=require("react"),r=require("use-sync-external-store/shim/index.js");const n=Math.min,o=Math.max,
|
|
1
|
+
var e=require("react/jsx-runtime"),t=require("react"),r=require("use-sync-external-store/shim/index.js");const n=Math.min,o=Math.max,s=Math.abs,l=Date.now,i=e=>null!=e,c=(e,t)=>Array.from({length:e},((e,r)=>t(r))),u=(e,t)=>{const r=e.t[t];return-1===r?e.o:r},a=(e,t,r)=>{if(!e.l)return 0;if(e.i>=t)return r?e.u[t]+u(e,t):e.u[t];let n=e.i,o=e.u[n];for(;n<=t&&(e.u[n]=o,n!==t||r);)o+=u(e,n),n++;return e.i=t,o},d=(e,t)=>a(e,t),_=(e,t,r)=>{let s=0;if(r>=0)for(;t<e.l-1;){const n=u(e,t++);if((s+=n)>=r){s-n/2>=r&&t--;break}}else for(;t>0;){const n=u(e,--t);if((s-=n)<=r){s+n/2<r&&t++;break}}return n(o(t,0),e.l-1)},f=(e,t,r,n)=>_(e,r,t-n),h=_,m=(e,t,r)=>({o:t,l:e,i:r?n(r.i,e-1):0,t:c(e,(e=>{const t=r&&r.t[e];return i(t)?t:-1})),u:c(e,(e=>{if(0===e)return 0;const t=r&&r.u[e];return i(t)?t:-1}))}),g="undefined"!=typeof window?t.useLayoutEffect:t.useEffect,w=(e,t)=>r.useSyncExternalStore(e,t,t),p="current",S=e=>{const r=t.useRef();return r[p]||(r[p]=e())},y=t.memo((({_:r,h:n,m:o,g:s,p:l})=>{const i=t.useRef(null),c=w(o.S,(()=>o.I(s))),u=w(o.S,(()=>o.v(s)));return g((()=>n.T(i[p],s)),[s]),e.jsx(l,{ref:i,style:t.useMemo((()=>{const e=o.R(),t=o.M()?"right":"left",r={margin:0,padding:0,position:"absolute",[e?"height":"width"]:"100%",[e?"top":t]:0,[e?t:"top"]:c};return e&&(r.display="flex"),u&&(r.visibility="hidden"),r}),[c,u]),children:r})})),z=t.forwardRef((({children:r,style:n,scrollSize:o,horizontal:s,rtl:l},i)=>e.jsx("div",{ref:i,style:n,children:e.jsx("div",{style:t.useMemo((()=>{const e=s?o:"100%",t=s?"100%":o;return{position:"absolute",top:0,[l?"right":"left"]:0,width:e,height:t,minWidth:e,minHeight:t}}),[o]),children:r})}))),I=({_:r,O:n,m:o,p:s,P:l})=>{const i=w(o.S,o.k),c=w(o.S,o.q),u=i>=c?i:c,a=o.R();return e.jsx(s,{ref:n,scrollSize:u,horizontal:a,rtl:o.M(),style:t.useMemo((()=>({overflow:a?"auto hidden":"hidden auto",position:"relative",contain:"strict",width:"100%",height:"100%",padding:0,margin:0,...l})),[l]),children:r})},v=t.forwardRef((({children:r,itemSize:c=40,overscan:_=4,horizontal:v,rtl:x,endThreshold:b=0,style:T,element:R=z,itemElement:M="div",onEndReached:O},P)=>{const k=t.useMemo((()=>{const e=[];return t.Children.forEach(r,(t=>{(e=>!i(e)||"boolean"==typeof e)(t)||e.push(t)})),e}),[r]),q=k.length,D=S((()=>((e,t,r,o)=>{let s,l=0,i=0,c=0,_=[],g=m(e,t),w=[0,0];const p=new Set,S=()=>r?l:i;return{D(){const[e,t]=w,r=d(g,e),n=f(g,c,e,r),o=h(g,n,S());return e===n&&t===o?w:w=[n,o]},v:e=>-1===g.t[e],j:e=>((e,t,r)=>{for(let n=t;n<=r;n++)if(-1===e.t[n])return!0;return!1})(g,e,h(g,e,S())),I:e=>d(g,e),q:()=>S(),k:()=>(e=>a(e,e.l-1,!0))(g),A:()=>g.l,F:()=>_,R:()=>r,M:()=>o,H:e=>f(g,e,0,0),U:()=>(s&&s[1](),new Promise(((e,t)=>{s=[()=>{Promise.resolve().then((()=>{e(),s=void 0}))},t]}))),S:e=>(p.add(e),()=>{p.delete(e)}),W(e,r){(()=>{switch(e){case 0:return g.l!==r&&(g=m(r,t,g),!0);case 1:{const e=r.filter((([e,t])=>g.t[e]!==t));if(!e.length)return!1;const t=[];return e.forEach((([e,r])=>{t.push([e,r-u(g,e)]),((e,t,r)=>{e.t[t]=r,e.i=n(t,e.i)})(g,e,r)})),_=t,!0}case 2:return(l!==r.C||i!==r.J)&&(l=r.C,i=r.J,!0);case 3:{const e=c;return(c=r)!==e}}})()&&(p.forEach((e=>{e()})),s&&1===e&&s[0]())}}})(q,c,!!v,!!x))),[j,A]=w(D.S,D.D),E=w(D.S,D.F),F=t.useRef(null),H=t.useRef(-1),[U,W]=t.useState(new Set),C=S((()=>(e=>{let t,r,n,o=-1,c=0,u=!1;const a=e.R(),d=e.M(),_=a?"scrollLeft":"scrollTop",f=new WeakMap,h=()=>n||(n=new ResizeObserver((t=>{const n=[];for(const o of t)if(o.target===r)e.W(2,{C:o.contentRect.width,J:o.contentRect.height});else{const e=f.get(o.target);i(e)&&n.push([e,o.contentRect[a?"width":"height"]])}n.length&&(e.W(1,n),u=!0)}))),m=()=>r?e.R()?r.scrollWidth:r.scrollHeight:0,g=(e,n)=>{if(r){if(d){if(!i(t)){const e=r[_];r[_]=1,t=0===r[_],r[_]=e}t&&(e*=-1)}n?r[_]+=e:(r[_]=e,c=3)}};return{L(t){r=t;const n=h(),f=()=>{let r=t[_];d&&(r=s(r)),o!==r&&(0!==c&&u?u=!1:3!==c&&(c=o>r?2:1),e.W(3,o=r))},m=(()=>{let e;const t=()=>{i(e)&&clearTimeout(e)},r=()=>{t(),e=setTimeout((()=>{e=null,f(),c=0,W(new Set)}),150)};return r.V=t,r})(),g=()=>{f(),m()},w=(()=>{let t=l()-50;return(...r)=>{const n=l();t+50<n&&(t=n,(t=>{0!==c&&(t.ctrlKey||(a?t.deltaX:t.deltaY)&&o>0&&o<e.k()-e.q()&&m())})(...r))}})();return n.observe(t),t.addEventListener("scroll",g),t.addEventListener("wheel",w,{passive:!0}),()=>{n.disconnect(),t.removeEventListener("scroll",g),t.removeEventListener("wheel",w),m.V()}},T(e,t){const r=h();return f.set(e,t),r.observe(e),()=>{f.delete(e),r.unobserve(e)}},B:()=>r?r[_]:0,G:()=>c,K:m,N:g,X:async(t,r)=>{const n=()=>{let t=r();const n=m(),o=e.q();return n-(t+o)<=0&&(t=n-o),t};if(e.j(t)){do{e.W(3,n());try{await e.U()}catch(e){return}}while(e.j(t));g(n())}else{const t=n();g(t),e.W(3,t)}}}})(D))),J=n(q,D.A());g((()=>{D.W(0,q)}),[q]),g((()=>C.L(F[p])),[]),g((()=>{if(!E.length)return;const e=C.G();if(2===e){const e=E.reduce(((e,[,t])=>e+t),0);e&&C.N(e,!0)}else if(3===e){const e=0===j,t=A-(J-1)==0,r=E.reduce(((r,[n,o])=>(n<j?e||(r+=o):!e&&t&&(r+=o),r)),0);r&&C.N(r,!0)}}),[E]),t.useEffect((()=>{O&&(H[p]>J&&(H[p]=-1),J-1-A<=b&&H[p]<J&&(H[p]=J,O()))}),[A]),t.useImperativeHandle(P,(()=>({get scrollOffset(){return C.B()},get scrollSize(){return C.K()},scrollToIndex(e){e=o(n(e,J-1),0),C.X(e,(()=>D.I(e)))},scrollToOffset(e){e=o(e,0),C.X(D.H(e),(()=>e))}})),[J]);const L=o(j-_,0),V=n(A+_,J-1),B=t.useMemo((()=>{const t=[];for(let e=L;e<=V;e++)U.add(e);return U.forEach((r=>{const n=k[r];t.push(e.jsx(y,{h:C,m:D,g:r,p:M,_:n},(null==n?void 0:n.key)||r))})),t}),[k,U,L,V]);return e.jsx(I,{O:F,m:D,p:R,P:T,_:B})}));exports.List=v;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/src/core/utils.ts","../src/src/core/cache.ts","../src/src/react/useIsomorphicLayoutEffect.ts","../src/src/react/useSyncExternalStore.ts","../src/src/react/utils.ts","../src/src/react/useStatic.ts","../src/src/react/List.tsx","../src/src/core/store.ts","../src/src/core/scroller.ts"],"sourcesContent":["export const min = Math.min;\nexport const max = Math.max;\nexport const abs = Math.abs;\n\nexport const exists = <T>(v: T): v is Exclude<T, null | undefined> => v != null;\n\nexport const range = <T>(length: number, cb: (i: number) => T): T[] =>\n Array.from({ length }, (_, i) => cb(i));\n\nexport const debounce = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let id: NodeJS.Timeout | undefined | null;\n\n const cancel = () => {\n if (exists(id)) {\n clearTimeout(id);\n }\n };\n const debouncedFn = () => {\n cancel();\n id = setTimeout(() => {\n id = null;\n fn();\n }, ms);\n };\n debouncedFn._cancel = cancel;\n return debouncedFn;\n};\n","import type { DeepReadonly, Writeable } from \"./types\";\nimport { exists, max, min, range } from \"./utils\";\n\nexport const UNCACHED = -1;\n\nexport type Cache = DeepReadonly<{\n _defaultItemSize: number;\n _length: number;\n _sizes: number[];\n _measuredOffsetIndex: number;\n _offsets: number[];\n}>;\n\nexport const getItemSize = (cache: Cache, index: number): number => {\n const size = cache._sizes[index]!;\n return size === UNCACHED ? cache._defaultItemSize : size;\n};\n\nexport const setItemSize = (\n cache: Writeable<Cache>,\n index: number,\n size: number\n) => {\n cache._sizes[index] = size;\n // mark as dirty\n cache._measuredOffsetIndex = min(index, cache._measuredOffsetIndex);\n};\n\nexport const computeTotalSize = (cache: Writeable<Cache>): number => {\n if (!cache._length) return 0;\n const lastIndex = cache._length - 1;\n if (cache._measuredOffsetIndex >= lastIndex) {\n return cache._offsets[lastIndex]! + getItemSize(cache, lastIndex);\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= lastIndex) {\n cache._offsets[i] = top;\n top += getItemSize(cache, i);\n i++;\n }\n\n cache._measuredOffsetIndex = lastIndex;\n return top;\n};\n\nconst findIndex = (cache: Cache, i: number, distance: number): number => {\n let sum = 0;\n if (distance >= 0) {\n // search forward\n while (i < cache._length - 1) {\n if ((sum += getItemSize(cache, i++)) >= distance) {\n break;\n }\n }\n if (sum - getItemSize(cache, i) / 2 >= distance) {\n i--;\n }\n } else {\n // search backward\n while (i > 0) {\n if ((sum -= getItemSize(cache, --i)) <= distance) {\n break;\n }\n }\n if (sum + getItemSize(cache, i) / 2 < distance) {\n i++;\n }\n }\n\n return min(max(i, 0), cache._length - 1);\n};\n\nexport const findStartIndexWithOffset = (\n cache: Cache,\n offset: number,\n prevStartIndex: number,\n prevOffset: number\n): number => {\n return findIndex(cache, prevStartIndex, offset - prevOffset);\n};\n\nexport const findEndIndex = findIndex;\n\nexport const hasUnmeasuredItemsInRange = (\n cache: Cache,\n startIndex: number,\n endIndex: number\n): boolean => {\n for (let i = startIndex; i <= endIndex; i++) {\n if (cache._sizes[i] === UNCACHED) {\n return true;\n }\n }\n return false;\n};\n\nexport const computeStartOffset = (\n cache: Writeable<Cache>,\n index: number\n): number => {\n if (!cache._length) return 0;\n if (cache._measuredOffsetIndex >= index) {\n return cache._offsets[index]!;\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= index) {\n cache._offsets[i] = top;\n if (i === index) {\n break;\n }\n top += getItemSize(cache, i);\n i++;\n }\n cache._measuredOffsetIndex = index;\n return top;\n};\n\nexport const resetCache = (\n length: number,\n itemSize: number,\n cache?: Cache\n): Cache => {\n return {\n _defaultItemSize: itemSize,\n _length: length,\n _measuredOffsetIndex: cache\n ? min(cache._measuredOffsetIndex, length - 1)\n : 0,\n _sizes: range(length, (i) => {\n const size = cache && cache._sizes[i];\n if (exists(size)) {\n return size;\n }\n return UNCACHED;\n }),\n _offsets: range(length, (i) => {\n if (i === 0) {\n // first offset must be 0\n return 0;\n }\n const offset = cache && cache._offsets[i];\n if (exists(offset)) {\n return offset;\n }\n return UNCACHED;\n }),\n };\n};\n","import { useEffect, useLayoutEffect } from \"react\";\n\n// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useSyncExternalStore as _useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nexport const useSyncExternalStore = <T>(\n subscibe: (onStoreChange: () => void) => () => void,\n getSnapShot: () => T\n): T => {\n return _useSyncExternalStore(subscibe, getSnapShot, getSnapShot);\n};\n","export const refKey = \"current\";\n","import { useRef } from \"react\";\nimport { refKey } from \"./utils\";\n\nexport const useStatic = <T>(init: () => T): T => {\n const ref = useRef<T>();\n return ref[refKey] || (ref[refKey] = init());\n};\n","import {\n Children,\n memo,\n useRef,\n useMemo,\n CSSProperties,\n ReactElement,\n forwardRef,\n useImperativeHandle,\n ReactNode,\n useEffect,\n RefObject,\n useState,\n} from \"react\";\nimport {\n ACTION_UPDATE_CACHE_LENGTH,\n VirtualStore,\n createVirtualStore,\n} from \"../core/store\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport { exists, max, min } from \"../core/utils\";\nimport {\n createScroller,\n Scroller,\n SCROLL_MANUAL,\n SCROLL_UP,\n} from \"../core/scroller\";\nimport { refKey } from \"./utils\";\nimport { useStatic } from \"./useStatic\";\n\nconst INITIAL_END_REACHED_INDEX = -1;\n\ntype ItemProps = {\n _children: ReactNode;\n _scroller: Scroller;\n _store: VirtualStore;\n _index: number;\n _element: \"div\";\n};\n\nconst Item = memo(\n ({\n _children: children,\n _scroller: scroller,\n _store: store,\n _index: index,\n _element: Element,\n }: ItemProps): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n\n const offset = useSyncExternalStore(store._subscribe, () =>\n store._getItemOffset(index)\n );\n const hide = useSyncExternalStore(store._subscribe, () =>\n store._isUnmeasuredItem(index)\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n useIsomorphicLayoutEffect(\n () => scroller._initItem(ref[refKey]!, index),\n [index]\n );\n\n return (\n <Element\n ref={ref}\n style={useMemo<CSSProperties>(() => {\n const isHorizontal = store._isHorizontal();\n const leftOrRightKey = store._isRtl() ? \"right\" : \"left\";\n const style: CSSProperties = {\n margin: 0,\n padding: 0,\n position: \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : leftOrRightKey]: 0,\n [isHorizontal ? leftOrRightKey : \"top\"]: offset,\n // willChange: \"transform\",\n };\n if (isHorizontal) {\n style.display = \"flex\";\n }\n if (hide) {\n style.visibility = \"hidden\";\n }\n return style;\n }, [offset, hide])}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst isInvalidElement = <T extends ReactNode>(\n e: T\n): e is Extract<T, null | undefined | boolean> =>\n !exists(e) || typeof e === \"boolean\";\n\nexport interface CustomWindowComponentProps {\n children: ReactNode;\n style: CSSProperties;\n scrollSize: number;\n horizontal: boolean;\n rtl: boolean;\n}\n\nconst DefaultWindow = forwardRef<any, CustomWindowComponentProps>(\n ({ children, style, scrollSize, horizontal, rtl }, ref): ReactElement => {\n return (\n <div ref={ref} style={style}>\n <div\n style={useMemo<CSSProperties>(() => {\n const width = horizontal ? scrollSize : \"100%\";\n const height = horizontal ? \"100%\" : scrollSize;\n return {\n position: \"absolute\",\n top: 0,\n [rtl ? \"right\" : \"left\"]: 0,\n width,\n height,\n minWidth: width,\n minHeight: height,\n };\n }, [scrollSize])}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n\nexport type CustomWindowComponent = typeof DefaultWindow;\n\nconst Window = ({\n _children: children,\n _ref: ref,\n _store: store,\n _element: Element,\n _style: style,\n}: {\n _children: ReactNode;\n _ref: RefObject<HTMLDivElement>;\n _store: VirtualStore;\n _element: CustomWindowComponent;\n _style: CSSProperties | undefined;\n}) => {\n const scrollSize = useSyncExternalStore(\n store._subscribe,\n store._getScrollSize\n );\n const viewportSize = useSyncExternalStore(\n store._subscribe,\n store._getViewportSize\n );\n const clampedScrollSize =\n scrollSize >= viewportSize ? scrollSize : viewportSize;\n\n const horizontal = store._isHorizontal();\n return (\n <Element\n ref={ref}\n scrollSize={clampedScrollSize}\n horizontal={horizontal}\n rtl={store._isRtl()}\n style={useMemo<CSSProperties>(\n () => ({\n overflow: horizontal ? \"auto hidden\" : \"hidden auto\",\n position: \"relative\",\n contain: \"strict\",\n // transform: \"translate3d(0px, 0px, 0px)\",\n // willChange: \"scroll-position\",\n // backfaceVisibility: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 0,\n margin: 0,\n ...style,\n }),\n [style]\n )}\n >\n {children}\n </Element>\n );\n};\n\nexport interface CustomItemComponentProps {\n style: CSSProperties;\n children: ReactNode;\n}\n\nexport type CustomItemComponent = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<CustomItemComponentProps> & React.RefAttributes<any>\n>;\n\ntype CustomItemComponentOrElement =\n | keyof JSX.IntrinsicElements\n | CustomItemComponent;\n\n/**\n * Methods of {@link List}.\n */\nexport interface ListHandle {\n /**\n * Get current scrollTop or scrollLeft.\n */\n scrollOffset: number;\n /**\n * Get current scrollHeight or scrollWidth.\n */\n scrollSize: number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n */\n scrollToIndex(index: number): void;\n /**\n * Scroll to the item specified by offset.\n * @param offset offset from start\n */\n scrollToOffset(offset: number): void;\n}\n\n/**\n * Props of {@link List}.\n */\nexport interface ListProps {\n /**\n * Elements rendered by this component.\n */\n children: ReactNode;\n /**\n * Item size hint for unmeasured items. It's recommended to specify this prop if item sizes are fixed and known, or much larger than the defaultValue. It will help to reduce scroll jump when items are measured.\n * @defaultValue 40\n */\n itemSize?: number;\n /**\n * Number of items to render above/below the visible bounds of the list. You can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 4\n */\n overscan?: number;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * You have to set true if you use this component under `direction: rtl` style.\n */\n rtl?: boolean;\n /**\n * Number of items to be the margin from the end of the scroll. See also {@link onEndReached}.\n * @defaultValue 0\n */\n endThreshold?: number;\n /**\n * Inline style prop to override style of scrollable element.\n */\n style?: CSSProperties;\n /**\n * Customized element type for scrollable element.\n * @defaultValue {@link DefaultWindow}\n */\n element?: CustomWindowComponent;\n /**\n * Customized element type for item element.\n * @defaultValue \"div\"\n */\n itemElement?: CustomItemComponentOrElement;\n /**\n * Callback invoked when scrolling reached to the end. The margin from the end is specified by {@link endThreshold}.\n */\n onEndReached?: () => void;\n}\n\n/**\n * Virtualized list component. See {@link ListProps} and {@link ListHandle}.\n */\nexport const List = forwardRef<ListHandle, ListProps>(\n (\n {\n children,\n itemSize: itemSizeProp = 40,\n overscan = 4,\n horizontal: horizontalProp,\n rtl: rtlProp,\n endThreshold = 0,\n style: styleProp,\n element = DefaultWindow,\n itemElement = \"div\",\n onEndReached,\n },\n ref\n ): ReactElement => {\n // Memoize element array\n const elements = useMemo(() => {\n const arr: ReactNode[] = [];\n Children.forEach(children, (e) => {\n if (isInvalidElement(e)) {\n return;\n }\n arr.push(e);\n });\n return arr;\n }, [children]);\n const elementsCount = elements.length;\n\n // https://github.com/facebook/react/issues/25191#issuecomment-1237456448\n const store = useStatic(() =>\n createVirtualStore(\n elementsCount,\n itemSizeProp,\n !!horizontalProp,\n !!rtlProp\n )\n );\n const startIndex = useSyncExternalStore(\n store._subscribe,\n store._getStartIndex\n );\n const endIndex = useSyncExternalStore(store._subscribe, store._getEndIndex);\n const jump = useSyncExternalStore(store._subscribe, store._getJump);\n const rootRef = useRef<HTMLDivElement>(null);\n const onEndReachedCalledIndex = useRef<number>(INITIAL_END_REACHED_INDEX);\n\n const [mountedIndexes, reset] = useState<Set<number>>(new Set<number>());\n const scroller = useStatic(() =>\n createScroller(store, () => {\n reset(new Set());\n })\n );\n\n // The elements length and cached items length are different just after element is added/removed.\n const count = min(elementsCount, store._getItemCount());\n\n // So update cache length. Updating state in render will cause warn so use useEffect for now.\n useIsomorphicLayoutEffect(() => {\n store._update(ACTION_UPDATE_CACHE_LENGTH, elementsCount);\n }, [elementsCount]);\n\n useIsomorphicLayoutEffect(() => scroller._initRoot(rootRef[refKey]!), []);\n\n useIsomorphicLayoutEffect(() => {\n if (!jump.length) return;\n\n // Compensate scroll jump\n const scrollDirection = scroller._getScrollDirection();\n if (scrollDirection === SCROLL_UP) {\n const diff = jump.reduce((acc, [, j]) => acc + j, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else if (scrollDirection === SCROLL_MANUAL) {\n const isStartInView = startIndex === 0;\n const isEndInView = endIndex - (count - 1) === 0;\n const diff = jump.reduce((acc, [index, j]) => {\n if (index < startIndex) {\n // Keep start if scroll position is not stuck to the start\n if (!isStartInView) {\n acc += j;\n }\n } else {\n // Keep end if scroll position is stuck to the end\n if (!isStartInView && isEndInView) {\n acc += j;\n }\n }\n return acc;\n }, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else {\n // NOP\n }\n }, [jump]);\n\n useEffect(() => {\n if (!onEndReached) return;\n\n if (onEndReachedCalledIndex[refKey] > count) {\n // Probably items have been refreshed, so reset index\n onEndReachedCalledIndex[refKey] = INITIAL_END_REACHED_INDEX;\n }\n\n const endMargin = count - 1 - endIndex;\n if (\n endMargin <= endThreshold &&\n onEndReachedCalledIndex[refKey] < count\n ) {\n onEndReachedCalledIndex[refKey] = count;\n onEndReached();\n }\n }, [endIndex]);\n\n useImperativeHandle(\n ref,\n () => {\n return {\n get scrollOffset() {\n return scroller._getScrollPosition();\n },\n get scrollSize() {\n return scroller._getActualScrollSize();\n },\n scrollToIndex(index) {\n index = max(min(index, count - 1), 0);\n\n scroller._scrollTo(index, () => store._getItemOffset(index));\n },\n scrollToOffset(offset) {\n offset = max(offset, 0);\n\n scroller._scrollTo(\n store._getItemIndexForScrollTo(offset),\n () => offset\n );\n },\n };\n },\n [count]\n );\n\n const startIndexWithMargin = max(startIndex - overscan, 0);\n const endIndexWithMargin = min(endIndex + overscan, count - 1);\n const items = useMemo(() => {\n const res: ReactElement[] = [];\n for (let i = startIndexWithMargin; i <= endIndexWithMargin; i++) {\n // https://github.com/sergi/virtual-list/commit/8e7e06dc63568334c1ab809ea83c1be36572e9ed\n mountedIndexes.add(i);\n }\n mountedIndexes.forEach((i) => {\n const e = elements[i];\n res.push(\n <Item\n key={(e as { key?: ReactElement[\"key\"] })?.key || i}\n _scroller={scroller}\n _store={store}\n _index={i}\n _element={itemElement as \"div\"}\n _children={e}\n />\n );\n });\n return res;\n }, [elements, mountedIndexes, startIndexWithMargin, endIndexWithMargin]);\n\n return (\n <Window\n _ref={rootRef}\n _store={store}\n _element={element}\n _style={styleProp}\n _children={items}\n />\n );\n }\n);\n","import {\n findStartIndexWithOffset,\n resetCache,\n getItemSize,\n computeTotalSize,\n findEndIndex,\n computeStartOffset,\n Cache,\n UNCACHED,\n setItemSize,\n hasUnmeasuredItemsInRange,\n} from \"./cache\";\nimport type { Writeable } from \"./types\";\n\nexport type ScrollJump = Readonly<[index: number, sizeDiff: number][]>;\n\ntype State = {\n _startIndex: number;\n _viewportWidth: number;\n _viewportHeight: number;\n _cache: Cache;\n _jump: ScrollJump;\n};\n\nexport const ACTION_UPDATE_CACHE_LENGTH = 0;\nexport const ACTION_UPDATE_ITEM_SIZES = 1;\nexport const ACTION_UPDATE_VIEWPORT = 2;\nexport const ACTION_HANDLE_SCROLL = 3;\n\ntype Actions =\n | [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number]\n | [\n type: typeof ACTION_UPDATE_ITEM_SIZES,\n entries: [index: number, size: number][]\n ]\n | [\n type: typeof ACTION_UPDATE_VIEWPORT,\n rect: { _width: number; _height: number }\n ]\n | [type: typeof ACTION_HANDLE_SCROLL, offset: number];\n\nexport type VirtualStore = {\n _getStartIndex(): number;\n _getEndIndex(): number;\n _isUnmeasuredItem(index: number): boolean;\n _hasUnmeasuredItemsInRange(startIndex: number): boolean;\n _getItemOffset(index: number): number;\n _getViewportSize(): number;\n _getScrollSize(): number;\n _getItemCount(): number;\n _getJump(): ScrollJump;\n _isHorizontal(): boolean;\n _isRtl(): boolean;\n _getItemIndexForScrollTo(offset: number): number;\n _waitForScrollDestinationItemsMeasured(): Promise<void>;\n _subscribe(cb: () => void): () => void;\n _update(...action: Actions): void;\n};\n\nexport const createVirtualStore = (\n itemCount: number,\n itemSize: number,\n isHorizontal: boolean,\n isRtl: boolean\n): VirtualStore => {\n const subscribers = new Set<() => void>();\n const state: State = {\n _startIndex: 0,\n _viewportWidth: 0,\n _viewportHeight: 0,\n _cache: resetCache(itemCount, itemSize),\n _jump: [],\n };\n const getViewportSize = (): number =>\n isHorizontal ? state._viewportWidth : state._viewportHeight;\n\n let scrollToQueue: [() => void, () => void] | undefined;\n\n return {\n _getStartIndex() {\n return state._startIndex;\n },\n _getEndIndex() {\n return findEndIndex(state._cache, state._startIndex, getViewportSize());\n },\n _isUnmeasuredItem(index) {\n return state._cache._sizes[index] === UNCACHED;\n },\n _hasUnmeasuredItemsInRange(startIndex) {\n return hasUnmeasuredItemsInRange(\n state._cache,\n startIndex,\n findEndIndex(state._cache, startIndex, getViewportSize())\n );\n },\n _getItemOffset(index) {\n return computeStartOffset(state._cache as Writeable<Cache>, index);\n },\n _getViewportSize() {\n return getViewportSize();\n },\n _getScrollSize() {\n return computeTotalSize(state._cache as Writeable<Cache>);\n },\n _getItemCount() {\n return state._cache._length;\n },\n _getJump() {\n return state._jump;\n },\n _isHorizontal() {\n return isHorizontal;\n },\n _isRtl() {\n return isRtl;\n },\n _getItemIndexForScrollTo(offset) {\n return findStartIndexWithOffset(state._cache, offset, 0, 0);\n },\n _waitForScrollDestinationItemsMeasured() {\n if (scrollToQueue) {\n // Cancel waiting scrollTo\n scrollToQueue[1]();\n }\n // The measurement will be done asynchronously and the timing is not predictable so we use promise.\n // For example, ResizeObserver may not fire when window is not visible.\n return new Promise((resolve, reject) => {\n scrollToQueue = [\n () => {\n // HACK: It should be resolved in the next microtask that is after React's render\n Promise.resolve().then(() => {\n resolve();\n scrollToQueue = undefined;\n });\n },\n reject,\n ];\n });\n },\n _subscribe(cb) {\n subscribers.add(cb);\n return () => {\n subscribers.delete(cb);\n };\n },\n _update(type, payload) {\n const mutated = ((): boolean => {\n switch (type) {\n case ACTION_UPDATE_CACHE_LENGTH: {\n if (state._cache._length === payload) return false;\n state._cache = resetCache(payload, itemSize, state._cache);\n return true;\n }\n case ACTION_UPDATE_ITEM_SIZES: {\n const updated = payload.filter(\n ([index, size]) => state._cache._sizes[index] !== size\n );\n // Skip if all items are cached and not updated\n if (!updated.length) {\n return false;\n }\n\n const jump: [index: number, sizeDiff: number][] = [];\n updated.forEach(([index, size]) => {\n jump.push([index, size - getItemSize(state._cache, index)]);\n setItemSize(state._cache as Writeable<Cache>, index, size);\n });\n state._jump = jump;\n return true;\n }\n case ACTION_UPDATE_VIEWPORT: {\n if (\n state._viewportWidth === payload._width &&\n state._viewportHeight === payload._height\n ) {\n return false;\n }\n state._viewportWidth = payload._width;\n state._viewportHeight = payload._height;\n return true;\n }\n case ACTION_HANDLE_SCROLL: {\n const prevStartIndex = state._startIndex;\n const prevOffset = computeStartOffset(\n state._cache as Writeable<Cache>,\n prevStartIndex\n );\n if (prevOffset === payload) {\n return false;\n }\n return (\n (state._startIndex = findStartIndexWithOffset(\n state._cache,\n payload,\n prevStartIndex,\n prevOffset\n )) !== prevStartIndex\n );\n }\n }\n })();\n\n if (mutated) {\n subscribers.forEach((cb) => {\n cb();\n });\n if (scrollToQueue && type === ACTION_UPDATE_ITEM_SIZES) {\n scrollToQueue[0]();\n }\n }\n },\n };\n};\n","import {\n ACTION_HANDLE_SCROLL,\n ACTION_UPDATE_ITEM_SIZES,\n ACTION_UPDATE_VIEWPORT,\n VirtualStore,\n} from \"./store\";\nimport { abs, debounce, exists } from \"./utils\";\n\nexport const SCROLL_STOP = 0;\nexport const SCROLL_DOWN = 1;\nexport const SCROLL_UP = 2;\nexport const SCROLL_MANUAL = 3;\ntype ScrollDirection =\n | typeof SCROLL_STOP\n | typeof SCROLL_DOWN\n | typeof SCROLL_UP\n | typeof SCROLL_MANUAL;\n\nexport type Scroller = {\n _initRoot: (rootElement: HTMLElement) => () => void;\n _initItem: (itemElement: HTMLElement, index: number) => () => void;\n _getScrollPosition: () => number;\n _getScrollDirection: () => ScrollDirection;\n _getActualScrollSize: () => number;\n _updateScrollPosition: (offset: number, diff?: boolean) => void;\n _scrollTo: (index: number, getCurrentOffset: () => number) => void;\n};\n\nexport const createScroller = (\n store: VirtualStore,\n notifyStop: () => void\n): Scroller => {\n let prevOffset = -1;\n let scrollDirection: ScrollDirection = SCROLL_STOP;\n let resized = false;\n let isNegativeOffset: boolean | undefined;\n let rootElement: HTMLElement | undefined;\n let _ro: ResizeObserver | undefined;\n const isHorizontal = store._isHorizontal();\n const isRtl = store._isRtl();\n const scrollToKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const mountedIndexes = new WeakMap<Element, number>();\n const getResizeObserver = (): ResizeObserver => {\n // Initialize ResizeObserver lazily for SSR\n return (\n _ro ||\n (_ro = new ResizeObserver((entries) => {\n // https://www.w3.org/TR/resize-observer/#intro\n const resizes: [index: number, size: number][] = [];\n for (const entry of entries) {\n if (entry.target === rootElement) {\n store._update(ACTION_UPDATE_VIEWPORT, {\n _width: entry.contentRect.width,\n _height: entry.contentRect.height,\n });\n } else {\n const index = mountedIndexes.get(entry.target);\n if (exists(index)) {\n resizes.push([\n index,\n entry.contentRect[isHorizontal ? \"width\" : \"height\"],\n ]);\n }\n }\n }\n\n if (resizes.length) {\n store._update(ACTION_UPDATE_ITEM_SIZES, resizes);\n resized = true;\n }\n }))\n );\n };\n const getActualScrollSize = (): number => {\n if (!rootElement) return 0;\n // Use element's scrollHeight/scrollWidth instead of stored scrollSize.\n // This is because stored size may differ from the actual size, for example when a new item is added and not yet measured.\n return store._isHorizontal()\n ? rootElement.scrollWidth\n : rootElement.scrollHeight;\n };\n const updateScrollPosition = (offset: number, diff?: boolean) => {\n if (!rootElement) return;\n if (isRtl) {\n if (!exists(isNegativeOffset)) {\n // Assume offset type in rtl direction.\n // The scroll position is negative in spec however its not in some browsers, for example Chrome earlier than v85.\n // https://github.com/othree/jquery.rtl-scroll-type\n const prev = rootElement[scrollToKey];\n rootElement[scrollToKey] = 1;\n isNegativeOffset = rootElement[scrollToKey] === 0;\n rootElement[scrollToKey] = prev;\n }\n if (isNegativeOffset) {\n offset *= -1;\n }\n }\n if (diff) {\n rootElement[scrollToKey] += offset;\n } else {\n rootElement[scrollToKey] = offset;\n scrollDirection = SCROLL_MANUAL;\n }\n };\n const scrollTo = async (index: number, getCurrentOffset: () => number) => {\n const getOffset = (): number => {\n let offset = getCurrentOffset();\n const scrollSize = getActualScrollSize();\n const viewportSize = store._getViewportSize();\n if (scrollSize - (offset + viewportSize) <= 0) {\n // Adjust if the offset is over the end, to get correct startIndex.\n offset = scrollSize - viewportSize;\n }\n return offset;\n };\n\n if (store._hasUnmeasuredItemsInRange(index)) {\n do {\n // In order to scroll to the correct position, mount the items and measure their sizes before scrolling.\n store._update(ACTION_HANDLE_SCROLL, getOffset());\n try {\n // Wait for the scroll destination items to be measured.\n await store._waitForScrollDestinationItemsMeasured();\n } catch (e) {\n // canceled\n return;\n }\n } while (store._hasUnmeasuredItemsInRange(index));\n\n // Scroll with the updated value\n updateScrollPosition(getOffset());\n } else {\n const offset = getOffset();\n updateScrollPosition(offset);\n // Sync viewport to scroll destination\n store._update(ACTION_HANDLE_SCROLL, offset);\n }\n };\n\n return {\n _initRoot(root) {\n rootElement = root;\n const ro = getResizeObserver();\n\n const syncViewportToScrollPosition = () => {\n let offset = root[scrollToKey];\n if (isRtl) {\n // The scroll position may be negative value in rtl direction.\n // https://github.com/othree/jquery.rtl-scroll-type\n offset = abs(offset);\n }\n if (prevOffset === offset) {\n return;\n }\n // Skip scroll direction detection just after resizing because it may result in the opposite direction.\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (scrollDirection === SCROLL_STOP || !resized) {\n // Ignore until manual scrolling\n if (scrollDirection !== SCROLL_MANUAL) {\n scrollDirection = prevOffset > offset ? SCROLL_UP : SCROLL_DOWN;\n }\n } else {\n resized = false;\n }\n store._update(ACTION_HANDLE_SCROLL, (prevOffset = offset));\n };\n\n const onScrollStopped = debounce(() => {\n // Check scroll position once just after scrolling stopped\n syncViewportToScrollPosition();\n scrollDirection = SCROLL_STOP;\n notifyStop();\n }, 300);\n\n const onScroll = () => {\n syncViewportToScrollPosition();\n onScrollStopped();\n };\n\n ro.observe(root);\n root.addEventListener(\"scroll\", onScroll);\n\n return () => {\n ro.disconnect();\n root.removeEventListener(\"scroll\", onScroll);\n onScrollStopped._cancel();\n };\n },\n _initItem(el, i) {\n const ro = getResizeObserver();\n mountedIndexes.set(el, i);\n ro.observe(el);\n return () => {\n mountedIndexes.delete(el);\n ro.unobserve(el);\n };\n },\n _getScrollPosition() {\n if (!rootElement) return 0;\n return rootElement[scrollToKey];\n },\n _getScrollDirection() {\n return scrollDirection;\n },\n _getActualScrollSize: getActualScrollSize,\n _updateScrollPosition: updateScrollPosition,\n _scrollTo: scrollTo,\n };\n};\n"],"names":["min","Math","max","abs","exists","v","range","length","cb","Array","from","_","i","getItemSize","cache","index","size","_sizes","_defaultItemSize","findIndex","distance","sum","_length","findStartIndexWithOffset","offset","prevStartIndex","prevOffset","findEndIndex","computeStartOffset","_measuredOffsetIndex","_offsets","top","resetCache","itemSize","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useSyncExternalStore","subscibe","getSnapShot","_useSyncExternalStore","refKey","useStatic","init","ref","useRef","Item","memo","_children","children","_scroller","scroller","_store","store","_index","_element","Element","_subscribe","_getItemOffset","hide","_isUnmeasuredItem","_initItem","_jsx","style","useMemo","isHorizontal","_isHorizontal","leftOrRightKey","_isRtl","margin","padding","position","display","visibility","DefaultWindow","forwardRef","scrollSize","horizontal","rtl","jsx","width","height","minWidth","minHeight","Window","_ref","_style","_getScrollSize","viewportSize","_getViewportSize","clampedScrollSize","overflow","contain","List","itemSizeProp","overscan","horizontalProp","rtlProp","endThreshold","styleProp","element","itemElement","onEndReached","elements","arr","Children","forEach","e","isInvalidElement","push","elementsCount","createVirtualStore","itemCount","isRtl","subscribers","Set","state","_startIndex","_viewportWidth","_viewportHeight","_cache","_jump","getViewportSize","scrollToQueue","_getStartIndex","_getEndIndex","_hasUnmeasuredItemsInRange","startIndex","hasUnmeasuredItemsInRange","endIndex","lastIndex","computeTotalSize","_getItemCount","_getJump","_getItemIndexForScrollTo","_waitForScrollDestinationItemsMeasured","Promise","resolve","reject","then","undefined","add","delete","_update","type","payload","updated","filter","jump","setItemSize","_width","_height","rootRef","onEndReachedCalledIndex","mountedIndexes","reset","useState","createScroller","isNegativeOffset","rootElement","_ro","scrollDirection","resized","scrollToKey","WeakMap","getResizeObserver","ResizeObserver","entries","resizes","entry","target","contentRect","get","getActualScrollSize","scrollWidth","scrollHeight","updateScrollPosition","diff","prev","_initRoot","root","ro","syncViewportToScrollPosition","onScrollStopped","debounce","id","cancel","clearTimeout","debouncedFn","setTimeout","_cancel","onScroll","observe","addEventListener","disconnect","removeEventListener","el","set","unobserve","_getScrollPosition","_getScrollDirection","_getActualScrollSize","_updateScrollPosition","_scrollTo","async","getCurrentOffset","getOffset","count","reduce","acc","j","isStartInView","isEndInView","useImperativeHandle","scrollOffset","scrollToIndex","scrollToOffset","startIndexWithMargin","endIndexWithMargin","items","res","key"],"mappings":"yGAAO,MAAMA,EAAMC,KAAKD,IACXE,EAAMD,KAAKC,IACXC,EAAMF,KAAKE,IAEXC,EAAaC,GAAiD,MAALA,EAEzDC,EAAQA,CAAIC,EAAgBC,IACvCC,MAAMC,KAAK,CAAEH,WAAU,CAACI,EAAGC,IAAMJ,EAAGI,KCMzBC,EAAcA,CAACC,EAAcC,KACxC,MAAMC,EAAOF,EAAMG,EAAOF,GAC1B,OAZsB,IAYfC,EAAoBF,EAAMI,EAAmBF,CAAI,EAgCpDG,EAAYA,CAACL,EAAcF,EAAWQ,KAC1C,IAAIC,EAAM,EACV,GAAID,GAAY,EAAG,CAEjB,KAAOR,EAAIE,EAAMQ,EAAU,MACpBD,GAAOR,EAAYC,EAAOF,OAASQ,KAItCC,EAAMR,EAAYC,EAAOF,GAAK,GAAKQ,GACrCR,GAEH,KAAM,CAEL,KAAOA,EAAI,MACJS,GAAOR,EAAYC,IAASF,KAAOQ,KAItCC,EAAMR,EAAYC,EAAOF,GAAK,EAAIQ,GACpCR,GAEH,CAED,OAAOZ,EAAIE,EAAIU,EAAG,GAAIE,EAAMQ,EAAU,EAAE,EAG7BC,EA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3J,EAAAA,SAAQ,KACpB,MAAM4J,EAAsB,GAC5B,IAAK,IAAIjN,EAAI8M,EAAsB9M,GAAK+M,EAAoB/M,IAE1D+I,EAAeb,IAAIlI,GAerB,OAbA+I,EAAehD,SAAS/F,IACtB,MAAMgG,EAAIJ,EAAS5F,GACnBiN,EAAI/G,KACF/C,MAAChB,GAECI,EAAWC,EACXC,EAAQC,EACRC,EAAQ3C,EACR4C,EAAU8C,EACVrD,EAAW2D,IALLA,aAAC,EAADA,EAAqCkH,MAAOlN,GAOrD,IAEIiN,CAAG,GACT,CAACrH,EAAUmD,EAAgB+D,EAAsBC,IAEpD,OACE5J,EAACiB,IAAAK,EACC,CAAAC,EAAMmE,EACNpG,EAAQC,EACRE,EAAU6C,EACVd,EAAQa,EACRnD,EAAW2K,GACX"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/src/core/utils.ts","../src/src/core/cache.ts","../src/src/react/useIsomorphicLayoutEffect.ts","../src/src/react/useSyncExternalStore.ts","../src/src/react/utils.ts","../src/src/react/useStatic.ts","../src/src/react/List.tsx","../src/src/core/store.ts","../src/src/core/scroller.ts"],"sourcesContent":["export const min = Math.min;\nexport const max = Math.max;\nexport const abs = Math.abs;\nexport const now = Date.now;\n\nexport const exists = <T>(v: T): v is Exclude<T, null | undefined> => v != null;\n\nexport const range = <T>(length: number, cb: (i: number) => T): T[] =>\n Array.from({ length }, (_, i) => cb(i));\n\nexport const debounce = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let id: NodeJS.Timeout | undefined | null;\n\n const cancel = () => {\n if (exists(id)) {\n clearTimeout(id);\n }\n };\n const debouncedFn = () => {\n cancel();\n id = setTimeout(() => {\n id = null;\n fn();\n }, ms);\n };\n debouncedFn._cancel = cancel;\n return debouncedFn;\n};\n\nexport const throttle = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let time = now() - ms;\n return (...args: Parameters<T>) => {\n const n = now();\n if (time + ms < n) {\n time = n;\n fn(...args);\n }\n };\n};\n","import type { DeepReadonly, Writeable } from \"./types\";\nimport { exists, max, min, range } from \"./utils\";\n\nexport const UNCACHED = -1;\n\nexport type Cache = DeepReadonly<{\n _defaultItemSize: number;\n _length: number;\n _sizes: number[];\n _measuredOffsetIndex: number;\n _offsets: number[];\n}>;\n\nexport const getItemSize = (cache: Cache, index: number): number => {\n const size = cache._sizes[index]!;\n return size === UNCACHED ? cache._defaultItemSize : size;\n};\n\nexport const setItemSize = (\n cache: Writeable<Cache>,\n index: number,\n size: number\n) => {\n cache._sizes[index] = size;\n // mark as dirty\n cache._measuredOffsetIndex = min(index, cache._measuredOffsetIndex);\n};\n\nconst computeOffset = (\n cache: Writeable<Cache>,\n index: number,\n isTotal?: boolean\n): number => {\n if (!cache._length) return 0;\n if (cache._measuredOffsetIndex >= index) {\n if (isTotal) {\n return cache._offsets[index]! + getItemSize(cache, index);\n } else {\n return cache._offsets[index]!;\n }\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= index) {\n cache._offsets[i] = top;\n if (i === index && !isTotal) {\n break;\n }\n top += getItemSize(cache, i);\n i++;\n }\n // mark as measured\n cache._measuredOffsetIndex = index;\n return top;\n};\n\nexport const computeTotalSize = (cache: Writeable<Cache>): number => {\n return computeOffset(cache, cache._length - 1, true);\n};\n\nexport const computeStartOffset = (\n cache: Writeable<Cache>,\n index: number\n): number => {\n return computeOffset(cache, index);\n};\n\nconst findIndex = (cache: Cache, i: number, distance: number): number => {\n let sum = 0;\n if (distance >= 0) {\n // search forward\n while (i < cache._length - 1) {\n const h = getItemSize(cache, i++);\n if ((sum += h) >= distance) {\n if (sum - h / 2 >= distance) {\n i--;\n }\n break;\n }\n }\n } else {\n // search backward\n while (i > 0) {\n const h = getItemSize(cache, --i);\n if ((sum -= h) <= distance) {\n if (sum + h / 2 < distance) {\n i++;\n }\n break;\n }\n }\n }\n\n return min(max(i, 0), cache._length - 1);\n};\n\nexport const findStartIndexWithOffset = (\n cache: Cache,\n offset: number,\n prevStartIndex: number,\n prevOffset: number\n): number => {\n return findIndex(cache, prevStartIndex, offset - prevOffset);\n};\n\nexport const findEndIndex = findIndex;\n\nexport const hasUnmeasuredItemsInRange = (\n cache: Cache,\n startIndex: number,\n endIndex: number\n): boolean => {\n for (let i = startIndex; i <= endIndex; i++) {\n if (cache._sizes[i] === UNCACHED) {\n return true;\n }\n }\n return false;\n};\n\nexport const resetCache = (\n length: number,\n itemSize: number,\n cache?: Cache\n): Cache => {\n return {\n _defaultItemSize: itemSize,\n _length: length,\n _measuredOffsetIndex: cache\n ? min(cache._measuredOffsetIndex, length - 1)\n : 0,\n _sizes: range(length, (i) => {\n const size = cache && cache._sizes[i];\n if (exists(size)) {\n return size;\n }\n return UNCACHED;\n }),\n _offsets: range(length, (i) => {\n if (i === 0) {\n // first offset must be 0\n return 0;\n }\n const offset = cache && cache._offsets[i];\n if (exists(offset)) {\n return offset;\n }\n return UNCACHED;\n }),\n };\n};\n","import { useEffect, useLayoutEffect } from \"react\";\n\n// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useSyncExternalStore as _useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nexport const useSyncExternalStore = <T>(\n subscibe: (onStoreChange: () => void) => () => void,\n getSnapShot: () => T\n): T => {\n return _useSyncExternalStore(subscibe, getSnapShot, getSnapShot);\n};\n","export const refKey = \"current\";\n","import { useRef } from \"react\";\nimport { refKey } from \"./utils\";\n\nexport const useStatic = <T>(init: () => T): T => {\n const ref = useRef<T>();\n return ref[refKey] || (ref[refKey] = init());\n};\n","import {\n Children,\n memo,\n useRef,\n useMemo,\n CSSProperties,\n ReactElement,\n forwardRef,\n useImperativeHandle,\n ReactNode,\n useEffect,\n RefObject,\n useState,\n} from \"react\";\nimport {\n ACTION_UPDATE_CACHE_LENGTH,\n VirtualStore,\n createVirtualStore,\n} from \"../core/store\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport { exists, max, min } from \"../core/utils\";\nimport {\n createScroller,\n Scroller,\n SCROLL_MANUAL,\n SCROLL_UP,\n} from \"../core/scroller\";\nimport { refKey } from \"./utils\";\nimport { useStatic } from \"./useStatic\";\n\nconst INITIAL_END_REACHED_INDEX = -1;\n\ntype ItemProps = {\n _children: ReactNode;\n _scroller: Scroller;\n _store: VirtualStore;\n _index: number;\n _element: \"div\";\n};\n\nconst Item = memo(\n ({\n _children: children,\n _scroller: scroller,\n _store: store,\n _index: index,\n _element: Element,\n }: ItemProps): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n\n const offset = useSyncExternalStore(store._subscribe, () =>\n store._getItemOffset(index)\n );\n const hide = useSyncExternalStore(store._subscribe, () =>\n store._isUnmeasuredItem(index)\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n useIsomorphicLayoutEffect(\n () => scroller._initItem(ref[refKey]!, index),\n [index]\n );\n\n return (\n <Element\n ref={ref}\n style={useMemo<CSSProperties>(() => {\n const isHorizontal = store._isHorizontal();\n const leftOrRightKey = store._isRtl() ? \"right\" : \"left\";\n const style: CSSProperties = {\n margin: 0,\n padding: 0,\n position: \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : leftOrRightKey]: 0,\n [isHorizontal ? leftOrRightKey : \"top\"]: offset,\n // willChange: \"transform\",\n };\n if (isHorizontal) {\n style.display = \"flex\";\n }\n if (hide) {\n style.visibility = \"hidden\";\n }\n return style;\n }, [offset, hide])}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst isInvalidElement = <T extends ReactNode>(\n e: T\n): e is Extract<T, null | undefined | boolean> =>\n !exists(e) || typeof e === \"boolean\";\n\nexport interface CustomWindowComponentProps {\n children: ReactNode;\n style: CSSProperties;\n scrollSize: number;\n horizontal: boolean;\n rtl: boolean;\n}\n\nconst DefaultWindow = forwardRef<any, CustomWindowComponentProps>(\n ({ children, style, scrollSize, horizontal, rtl }, ref): ReactElement => {\n return (\n <div ref={ref} style={style}>\n <div\n style={useMemo<CSSProperties>(() => {\n const width = horizontal ? scrollSize : \"100%\";\n const height = horizontal ? \"100%\" : scrollSize;\n return {\n position: \"absolute\",\n top: 0,\n [rtl ? \"right\" : \"left\"]: 0,\n width,\n height,\n minWidth: width,\n minHeight: height,\n };\n }, [scrollSize])}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n\nexport type CustomWindowComponent = typeof DefaultWindow;\n\nconst Window = ({\n _children: children,\n _ref: ref,\n _store: store,\n _element: Element,\n _style: style,\n}: {\n _children: ReactNode;\n _ref: RefObject<HTMLDivElement>;\n _store: VirtualStore;\n _element: CustomWindowComponent;\n _style: CSSProperties | undefined;\n}) => {\n const scrollSize = useSyncExternalStore(\n store._subscribe,\n store._getScrollSize\n );\n const viewportSize = useSyncExternalStore(\n store._subscribe,\n store._getViewportSize\n );\n const clampedScrollSize =\n scrollSize >= viewportSize ? scrollSize : viewportSize;\n\n const horizontal = store._isHorizontal();\n return (\n <Element\n ref={ref}\n scrollSize={clampedScrollSize}\n horizontal={horizontal}\n rtl={store._isRtl()}\n style={useMemo<CSSProperties>(\n () => ({\n overflow: horizontal ? \"auto hidden\" : \"hidden auto\",\n position: \"relative\",\n contain: \"strict\",\n // transform: \"translate3d(0px, 0px, 0px)\",\n // willChange: \"scroll-position\",\n // backfaceVisibility: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 0,\n margin: 0,\n ...style,\n }),\n [style]\n )}\n >\n {children}\n </Element>\n );\n};\n\nexport interface CustomItemComponentProps {\n style: CSSProperties;\n children: ReactNode;\n}\n\nexport type CustomItemComponent = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<CustomItemComponentProps> & React.RefAttributes<any>\n>;\n\ntype CustomItemComponentOrElement =\n | keyof JSX.IntrinsicElements\n | CustomItemComponent;\n\n/**\n * Methods of {@link List}.\n */\nexport interface ListHandle {\n /**\n * Get current scrollTop or scrollLeft.\n */\n scrollOffset: number;\n /**\n * Get current scrollHeight or scrollWidth.\n */\n scrollSize: number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n */\n scrollToIndex(index: number): void;\n /**\n * Scroll to the item specified by offset.\n * @param offset offset from start\n */\n scrollToOffset(offset: number): void;\n}\n\n/**\n * Props of {@link List}.\n */\nexport interface ListProps {\n /**\n * Elements rendered by this component.\n */\n children: ReactNode;\n /**\n * Item size hint for unmeasured items. It's recommended to specify this prop if item sizes are fixed and known, or much larger than the defaultValue. It will help to reduce scroll jump when items are measured.\n * @defaultValue 40\n */\n itemSize?: number;\n /**\n * Number of items to render above/below the visible bounds of the list. You can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 4\n */\n overscan?: number;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * You have to set true if you use this component under `direction: rtl` style.\n */\n rtl?: boolean;\n /**\n * Number of items to be the margin from the end of the scroll. See also {@link onEndReached}.\n * @defaultValue 0\n */\n endThreshold?: number;\n /**\n * Inline style prop to override style of scrollable element.\n */\n style?: CSSProperties;\n /**\n * Customized element type for scrollable element.\n * @defaultValue {@link DefaultWindow}\n */\n element?: CustomWindowComponent;\n /**\n * Customized element type for item element.\n * @defaultValue \"div\"\n */\n itemElement?: CustomItemComponentOrElement;\n /**\n * Callback invoked when scrolling reached to the end. The margin from the end is specified by {@link endThreshold}.\n */\n onEndReached?: () => void;\n}\n\n/**\n * Virtualized list component. See {@link ListProps} and {@link ListHandle}.\n */\nexport const List = forwardRef<ListHandle, ListProps>(\n (\n {\n children,\n itemSize: itemSizeProp = 40,\n overscan = 4,\n horizontal: horizontalProp,\n rtl: rtlProp,\n endThreshold = 0,\n style: styleProp,\n element = DefaultWindow,\n itemElement = \"div\",\n onEndReached,\n },\n ref\n ): ReactElement => {\n // Memoize element array\n const elements = useMemo(() => {\n const arr: ReactNode[] = [];\n Children.forEach(children, (e) => {\n if (isInvalidElement(e)) {\n return;\n }\n arr.push(e);\n });\n return arr;\n }, [children]);\n const elementsCount = elements.length;\n\n // https://github.com/facebook/react/issues/25191#issuecomment-1237456448\n const store = useStatic(() =>\n createVirtualStore(\n elementsCount,\n itemSizeProp,\n !!horizontalProp,\n !!rtlProp\n )\n );\n const [startIndex, endIndex] = useSyncExternalStore(\n store._subscribe,\n store._getRange\n );\n const jump = useSyncExternalStore(store._subscribe, store._getJump);\n const rootRef = useRef<HTMLDivElement>(null);\n const onEndReachedCalledIndex = useRef<number>(INITIAL_END_REACHED_INDEX);\n\n const [mountedIndexes, reset] = useState<Set<number>>(new Set<number>());\n const scroller = useStatic(() =>\n createScroller(store, () => {\n reset(new Set());\n })\n );\n\n // The elements length and cached items length are different just after element is added/removed.\n const count = min(elementsCount, store._getItemCount());\n\n // So update cache length. Updating state in render will cause warn so use useEffect for now.\n useIsomorphicLayoutEffect(() => {\n store._update(ACTION_UPDATE_CACHE_LENGTH, elementsCount);\n }, [elementsCount]);\n\n useIsomorphicLayoutEffect(() => scroller._initRoot(rootRef[refKey]!), []);\n\n useIsomorphicLayoutEffect(() => {\n if (!jump.length) return;\n\n // Compensate scroll jump\n const scrollDirection = scroller._getScrollDirection();\n if (scrollDirection === SCROLL_UP) {\n const diff = jump.reduce((acc, [, j]) => acc + j, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else if (scrollDirection === SCROLL_MANUAL) {\n const isStartInView = startIndex === 0;\n const isEndInView = endIndex - (count - 1) === 0;\n const diff = jump.reduce((acc, [index, j]) => {\n if (index < startIndex) {\n // Keep start if scroll position is not stuck to the start\n if (!isStartInView) {\n acc += j;\n }\n } else {\n // Keep end if scroll position is stuck to the end\n if (!isStartInView && isEndInView) {\n acc += j;\n }\n }\n return acc;\n }, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else {\n // NOP\n }\n }, [jump]);\n\n useEffect(() => {\n if (!onEndReached) return;\n\n if (onEndReachedCalledIndex[refKey] > count) {\n // Probably items have been refreshed, so reset index\n onEndReachedCalledIndex[refKey] = INITIAL_END_REACHED_INDEX;\n }\n\n const endMargin = count - 1 - endIndex;\n if (\n endMargin <= endThreshold &&\n onEndReachedCalledIndex[refKey] < count\n ) {\n onEndReachedCalledIndex[refKey] = count;\n onEndReached();\n }\n }, [endIndex]);\n\n useImperativeHandle(\n ref,\n () => {\n return {\n get scrollOffset() {\n return scroller._getScrollPosition();\n },\n get scrollSize() {\n return scroller._getActualScrollSize();\n },\n scrollToIndex(index) {\n index = max(min(index, count - 1), 0);\n\n scroller._scrollTo(index, () => store._getItemOffset(index));\n },\n scrollToOffset(offset) {\n offset = max(offset, 0);\n\n scroller._scrollTo(\n store._getItemIndexForScrollTo(offset),\n () => offset\n );\n },\n };\n },\n [count]\n );\n\n const startIndexWithMargin = max(startIndex - overscan, 0);\n const endIndexWithMargin = min(endIndex + overscan, count - 1);\n const items = useMemo(() => {\n const res: ReactElement[] = [];\n for (let i = startIndexWithMargin; i <= endIndexWithMargin; i++) {\n // https://github.com/sergi/virtual-list/commit/8e7e06dc63568334c1ab809ea83c1be36572e9ed\n mountedIndexes.add(i);\n }\n mountedIndexes.forEach((i) => {\n const e = elements[i];\n res.push(\n <Item\n key={(e as { key?: ReactElement[\"key\"] })?.key || i}\n _scroller={scroller}\n _store={store}\n _index={i}\n _element={itemElement as \"div\"}\n _children={e}\n />\n );\n });\n return res;\n }, [elements, mountedIndexes, startIndexWithMargin, endIndexWithMargin]);\n\n return (\n <Window\n _ref={rootRef}\n _store={store}\n _element={element}\n _style={styleProp}\n _children={items}\n />\n );\n }\n);\n","import {\n findStartIndexWithOffset,\n resetCache,\n getItemSize,\n computeTotalSize,\n findEndIndex,\n computeStartOffset,\n Cache,\n UNCACHED,\n setItemSize,\n hasUnmeasuredItemsInRange,\n} from \"./cache\";\nimport type { Writeable } from \"./types\";\n\nexport type ScrollJump = Readonly<[index: number, sizeDiff: number][]>;\nexport type ItemResize = [index: number, size: number];\ntype ItemsRange = [startIndex: number, endIndex: number];\n\nexport const ACTION_UPDATE_CACHE_LENGTH = 0;\nexport const ACTION_UPDATE_ITEM_SIZES = 1;\nexport const ACTION_UPDATE_VIEWPORT = 2;\nexport const ACTION_HANDLE_SCROLL = 3;\n\ntype Actions =\n | [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number]\n | [type: typeof ACTION_UPDATE_ITEM_SIZES, entries: ItemResize[]]\n | [\n type: typeof ACTION_UPDATE_VIEWPORT,\n rect: { _width: number; _height: number }\n ]\n | [type: typeof ACTION_HANDLE_SCROLL, offset: number];\n\nexport type VirtualStore = {\n _getRange(): ItemsRange;\n _isUnmeasuredItem(index: number): boolean;\n _hasUnmeasuredItemsInRange(startIndex: number): boolean;\n _getItemOffset(index: number): number;\n _getViewportSize(): number;\n _getScrollSize(): number;\n _getItemCount(): number;\n _getJump(): ScrollJump;\n _isHorizontal(): boolean;\n _isRtl(): boolean;\n _getItemIndexForScrollTo(offset: number): number;\n _waitForScrollDestinationItemsMeasured(): Promise<void>;\n _subscribe(cb: () => void): () => void;\n _update(...action: Actions): void;\n};\n\nexport const createVirtualStore = (\n itemCount: number,\n itemSize: number,\n isHorizontal: boolean,\n isRtl: boolean\n): VirtualStore => {\n let viewportWidth = 0;\n let viewportHeight = 0;\n let scrollOffset = 0;\n let jump: ScrollJump = [];\n let cache = resetCache(itemCount, itemSize);\n let _prevRange: ItemsRange = [0, 0];\n let _scrollToQueue: [() => void, () => void] | undefined;\n\n const subscribers = new Set<() => void>();\n const getViewportSize = (): number =>\n isHorizontal ? viewportWidth : viewportHeight;\n\n return {\n _getRange() {\n const [prevStartIndex, prevEndIndex] = _prevRange;\n const prevOffset = computeStartOffset(\n cache as Writeable<Cache>,\n prevStartIndex\n );\n const start = findStartIndexWithOffset(\n cache,\n scrollOffset,\n prevStartIndex,\n prevOffset\n );\n const end = findEndIndex(cache, start, getViewportSize());\n if (prevStartIndex === start && prevEndIndex === end) {\n return _prevRange;\n }\n return (_prevRange = [start, end]);\n },\n _isUnmeasuredItem(index) {\n return cache._sizes[index] === UNCACHED;\n },\n _hasUnmeasuredItemsInRange(startIndex) {\n return hasUnmeasuredItemsInRange(\n cache,\n startIndex,\n findEndIndex(cache, startIndex, getViewportSize())\n );\n },\n _getItemOffset(index) {\n return computeStartOffset(cache as Writeable<Cache>, index);\n },\n _getViewportSize() {\n return getViewportSize();\n },\n _getScrollSize() {\n return computeTotalSize(cache as Writeable<Cache>);\n },\n _getItemCount() {\n return cache._length;\n },\n _getJump() {\n return jump;\n },\n _isHorizontal() {\n return isHorizontal;\n },\n _isRtl() {\n return isRtl;\n },\n _getItemIndexForScrollTo(offset) {\n return findStartIndexWithOffset(cache, offset, 0, 0);\n },\n _waitForScrollDestinationItemsMeasured() {\n if (_scrollToQueue) {\n // Cancel waiting scrollTo\n _scrollToQueue[1]();\n }\n // The measurement will be done asynchronously and the timing is not predictable so we use promise.\n // For example, ResizeObserver may not fire when window is not visible.\n return new Promise((resolve, reject) => {\n _scrollToQueue = [\n () => {\n // HACK: It should be resolved in the next microtask that is after React's render\n Promise.resolve().then(() => {\n resolve();\n _scrollToQueue = undefined;\n });\n },\n reject,\n ];\n });\n },\n _subscribe(cb) {\n subscribers.add(cb);\n return () => {\n subscribers.delete(cb);\n };\n },\n _update(type, payload) {\n const mutated = ((): boolean => {\n switch (type) {\n case ACTION_UPDATE_CACHE_LENGTH: {\n if (cache._length === payload) return false;\n cache = resetCache(payload, itemSize, cache);\n return true;\n }\n case ACTION_UPDATE_ITEM_SIZES: {\n const updated = payload.filter(\n ([index, size]) => cache._sizes[index] !== size\n );\n // Skip if all items are cached and not updated\n if (!updated.length) {\n return false;\n }\n\n const updatedJump: [index: number, sizeDiff: number][] = [];\n updated.forEach(([index, size]) => {\n updatedJump.push([index, size - getItemSize(cache, index)]);\n setItemSize(cache as Writeable<Cache>, index, size);\n });\n jump = updatedJump;\n return true;\n }\n case ACTION_UPDATE_VIEWPORT: {\n if (\n viewportWidth === payload._width &&\n viewportHeight === payload._height\n ) {\n return false;\n }\n viewportWidth = payload._width;\n viewportHeight = payload._height;\n return true;\n }\n case ACTION_HANDLE_SCROLL: {\n const prevOffset = scrollOffset;\n return (scrollOffset = payload) !== prevOffset;\n }\n }\n })();\n\n if (mutated) {\n subscribers.forEach((cb) => {\n cb();\n });\n if (_scrollToQueue && type === ACTION_UPDATE_ITEM_SIZES) {\n _scrollToQueue[0]();\n }\n }\n },\n };\n};\n","import {\n ACTION_HANDLE_SCROLL,\n ACTION_UPDATE_ITEM_SIZES,\n ACTION_UPDATE_VIEWPORT,\n ItemResize,\n VirtualStore,\n} from \"./store\";\nimport { abs, debounce, throttle, exists } from \"./utils\";\n\nexport const SCROLL_STOP = 0;\nexport const SCROLL_DOWN = 1;\nexport const SCROLL_UP = 2;\nexport const SCROLL_MANUAL = 3;\ntype ScrollDirection =\n | typeof SCROLL_STOP\n | typeof SCROLL_DOWN\n | typeof SCROLL_UP\n | typeof SCROLL_MANUAL;\n\nexport type Scroller = {\n _initRoot: (rootElement: HTMLElement) => () => void;\n _initItem: (itemElement: HTMLElement, index: number) => () => void;\n _getScrollPosition: () => number;\n _getScrollDirection: () => ScrollDirection;\n _getActualScrollSize: () => number;\n _updateScrollPosition: (offset: number, diff?: boolean) => void;\n _scrollTo: (index: number, getCurrentOffset: () => number) => void;\n};\n\nexport const createScroller = (\n store: VirtualStore,\n notifyStop: () => void\n): Scroller => {\n let prevOffset = -1;\n let scrollDirection: ScrollDirection = SCROLL_STOP;\n let resized = false;\n let isNegativeOffset: boolean | undefined;\n let rootElement: HTMLElement | undefined;\n let _ro: ResizeObserver | undefined;\n const isHorizontal = store._isHorizontal();\n const isRtl = store._isRtl();\n const scrollToKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const mountedIndexes = new WeakMap<Element, number>();\n const getResizeObserver = (): ResizeObserver => {\n // Initialize ResizeObserver lazily for SSR\n return (\n _ro ||\n (_ro = new ResizeObserver((entries) => {\n // https://www.w3.org/TR/resize-observer/#intro\n const resizes: ItemResize[] = [];\n for (const entry of entries) {\n if (entry.target === rootElement) {\n store._update(ACTION_UPDATE_VIEWPORT, {\n _width: entry.contentRect.width,\n _height: entry.contentRect.height,\n });\n } else {\n const index = mountedIndexes.get(entry.target);\n if (exists(index)) {\n resizes.push([\n index,\n entry.contentRect[isHorizontal ? \"width\" : \"height\"],\n ]);\n }\n }\n }\n\n if (resizes.length) {\n store._update(ACTION_UPDATE_ITEM_SIZES, resizes);\n resized = true;\n }\n }))\n );\n };\n const getActualScrollSize = (): number => {\n if (!rootElement) return 0;\n // Use element's scrollHeight/scrollWidth instead of stored scrollSize.\n // This is because stored size may differ from the actual size, for example when a new item is added and not yet measured.\n return store._isHorizontal()\n ? rootElement.scrollWidth\n : rootElement.scrollHeight;\n };\n const updateScrollPosition = (offset: number, diff?: boolean) => {\n if (!rootElement) return;\n if (isRtl) {\n if (!exists(isNegativeOffset)) {\n // Assume offset type in rtl direction.\n // The scroll position is negative in spec however its not in some browsers, for example Chrome earlier than v85.\n // https://github.com/othree/jquery.rtl-scroll-type\n const prev = rootElement[scrollToKey];\n rootElement[scrollToKey] = 1;\n isNegativeOffset = rootElement[scrollToKey] === 0;\n rootElement[scrollToKey] = prev;\n }\n if (isNegativeOffset) {\n offset *= -1;\n }\n }\n if (diff) {\n rootElement[scrollToKey] += offset;\n } else {\n rootElement[scrollToKey] = offset;\n scrollDirection = SCROLL_MANUAL;\n }\n };\n const scrollTo = async (index: number, getCurrentOffset: () => number) => {\n const getOffset = (): number => {\n let offset = getCurrentOffset();\n const scrollSize = getActualScrollSize();\n const viewportSize = store._getViewportSize();\n if (scrollSize - (offset + viewportSize) <= 0) {\n // Adjust if the offset is over the end, to get correct startIndex.\n offset = scrollSize - viewportSize;\n }\n return offset;\n };\n\n if (store._hasUnmeasuredItemsInRange(index)) {\n do {\n // In order to scroll to the correct position, mount the items and measure their sizes before scrolling.\n store._update(ACTION_HANDLE_SCROLL, getOffset());\n try {\n // Wait for the scroll destination items to be measured.\n await store._waitForScrollDestinationItemsMeasured();\n } catch (e) {\n // canceled\n return;\n }\n } while (store._hasUnmeasuredItemsInRange(index));\n\n // Scroll with the updated value\n updateScrollPosition(getOffset());\n } else {\n const offset = getOffset();\n updateScrollPosition(offset);\n // Sync viewport to scroll destination\n store._update(ACTION_HANDLE_SCROLL, offset);\n }\n };\n\n return {\n _initRoot(root) {\n rootElement = root;\n const ro = getResizeObserver();\n\n const syncViewportToScrollPosition = () => {\n let offset = root[scrollToKey];\n if (isRtl) {\n // The scroll position may be negative value in rtl direction.\n // https://github.com/othree/jquery.rtl-scroll-type\n offset = abs(offset);\n }\n if (prevOffset === offset) {\n return;\n }\n // Skip scroll direction detection just after resizing because it may result in the opposite direction.\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (scrollDirection === SCROLL_STOP || !resized) {\n // Ignore until manual scrolling\n if (scrollDirection !== SCROLL_MANUAL) {\n scrollDirection = prevOffset > offset ? SCROLL_UP : SCROLL_DOWN;\n }\n } else {\n resized = false;\n }\n store._update(ACTION_HANDLE_SCROLL, (prevOffset = offset));\n };\n\n const onScrollStopped = debounce(() => {\n // Check scroll position once just after scrolling stopped\n syncViewportToScrollPosition();\n scrollDirection = SCROLL_STOP;\n notifyStop();\n }, 150);\n\n const onScroll = () => {\n syncViewportToScrollPosition();\n onScrollStopped();\n };\n\n // Infer scroll state also from wheel events\n // Sometimes scroll events do not fire when frame dropped even if the visual have been already scrolled\n const onWheel = throttle((e: WheelEvent) => {\n if (scrollDirection === SCROLL_STOP) {\n // Scroll start should be detected with scroll event\n return;\n }\n if (e.ctrlKey) {\n // Probably a pinch-to-zoom gesture\n return;\n }\n // Get delta before checking deltaMode for firefox behavior\n // https://github.com/w3c/uievents/issues/181#issuecomment-392648065\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1392460#c34\n if (isHorizontal ? e.deltaX : e.deltaY) {\n if (\n prevOffset > 0 &&\n prevOffset < store._getScrollSize() - store._getViewportSize()\n ) {\n onScrollStopped();\n }\n }\n }, 50);\n\n ro.observe(root);\n root.addEventListener(\"scroll\", onScroll);\n root.addEventListener(\"wheel\", onWheel, { passive: true });\n\n return () => {\n ro.disconnect();\n root.removeEventListener(\"scroll\", onScroll);\n root.removeEventListener(\"wheel\", onWheel);\n onScrollStopped._cancel();\n };\n },\n _initItem(el, i) {\n const ro = getResizeObserver();\n mountedIndexes.set(el, i);\n ro.observe(el);\n return () => {\n mountedIndexes.delete(el);\n ro.unobserve(el);\n };\n },\n _getScrollPosition() {\n if (!rootElement) return 0;\n return rootElement[scrollToKey];\n },\n _getScrollDirection() {\n return scrollDirection;\n },\n _getActualScrollSize: getActualScrollSize,\n _updateScrollPosition: updateScrollPosition,\n _scrollTo: scrollTo,\n };\n};\n"],"names":["min","Math","max","abs","now","Date","exists","v","range","length","cb","Array","from","_","i","getItemSize","cache","index","size","_sizes","_defaultItemSize","computeOffset","isTotal","_length","_measuredOffsetIndex","_offsets","top","computeStartOffset","findIndex","distance","sum","h","findStartIndexWithOffset","offset","prevStartIndex","prevOffset","findEndIndex","resetCache","itemSize","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useSyncExternalStore","subscibe","getSnapShot","_useSyncExternalStore","refKey","useStatic","init","ref","useRef","Item","memo","_children","children","_scroller","scroller","_store","store","_index","_element","Element","_subscribe","_getItemOffset","hide","_isUnmeasuredItem","_initItem","_jsx","style","useMemo","isHorizontal","_isHorizontal","leftOrRightKey","_isRtl","margin","padding","position","display","visibility","DefaultWindow","forwardRef","scrollSize","horizontal","rtl","jsx","width","height","minWidth","minHeight","Window","_ref","_style","_getScrollSize","viewportSize","_getViewportSize","clampedScrollSize","overflow","contain","List","itemSizeProp","overscan","horizontalProp","rtlProp","endThreshold","styleProp","element","itemElement","onEndReached","elements","arr","Children","forEach","e","isInvalidElement","push","elementsCount","createVirtualStore","itemCount","isRtl","_scrollToQueue","viewportWidth","viewportHeight","scrollOffset","jump","_prevRange","subscribers","Set","getViewportSize","_getRange","prevEndIndex","start","end","_hasUnmeasuredItemsInRange","startIndex","hasUnmeasuredItemsInRange","endIndex","computeTotalSize","_getItemCount","_getJump","_getItemIndexForScrollTo","_waitForScrollDestinationItemsMeasured","Promise","resolve","reject","then","undefined","add","delete","_update","type","payload","updated","filter","updatedJump","setItemSize","_width","_height","rootRef","onEndReachedCalledIndex","mountedIndexes","reset","useState","createScroller","isNegativeOffset","rootElement","_ro","scrollDirection","resized","scrollToKey","WeakMap","getResizeObserver","ResizeObserver","entries","resizes","entry","target","contentRect","get","getActualScrollSize","scrollWidth","scrollHeight","updateScrollPosition","diff","prev","_initRoot","root","ro","syncViewportToScrollPosition","onScrollStopped","debounce","id","cancel","clearTimeout","debouncedFn","setTimeout","_cancel","onScroll","onWheel","throttle","time","args","n","ctrlKey","deltaX","deltaY","fn","observe","addEventListener","passive","disconnect","removeEventListener","el","set","unobserve","_getScrollPosition","_getScrollDirection","_getActualScrollSize","_updateScrollPosition","_scrollTo","async","getCurrentOffset","getOffset","count","reduce","acc","j","isStartInView","isEndInView","useImperativeHandle","scrollToIndex","scrollToOffset","startIndexWithMargin","endIndexWithMargin","items","res","key"],"mappings":"yGAAO,MAAMA,EAAMC,KAAKD,IACXE,EAAMD,KAAKC,IACXC,EAAMF,KAAKE,IACXC,EAAMC,KAAKD,IAEXE,EAAaC,GAAiD,MAALA,EAEzDC,EAAQA,CAAIC,EAAgBC,IACvCC,MAAMC,KAAK,CAAEH,WAAU,CAACI,EAAGC,IAAMJ,EAAGI,KCKzBC,EAAcA,CAACC,EAAcC,KACxC,MAAMC,EAAOF,EAAMG,EAAOF,GAC1B,OAZsB,IAYfC,EAAoBF,EAAMI,EAAmBF,CAAI,EAapDG,EAAgBA,CACpBL,EACAC,EACAK,KAEA,IAAKN,EAAMO,EAAS,OAAO,EAC3B,GAAIP,EAAMQ,GAAwBP,EAChC,OAAIK,EACKN,EAAMS,EAASR,GAAUF,EAAYC,EA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B,EACGrI,iBACF,OAAOzB,EAASgK,GACjB,EACDa,cAAcrN,GACZA,EAAQf,EAAIF,EAAIiB,EAAO8M,EAAQ,GAAI,GAEnCtK,EAASkK,EAAU1M,GAAO,IAAM0C,EAAMK,EAAe/C,IACtD,EACDsN,eAAetM,GACbA,EAAS/B,EAAI+B,EAAQ,GAErBwB,EAASkK,EACPhK,EAAMiF,EAAyB3G,IAC/B,IAAMA,GAET,KAGL,CAAC8L,IAGH,MAAMS,EAAuBtO,EAAIoI,EAAajC,EAAU,GAClDoI,EAAqBzO,EAAIwI,EAAWnC,EAAU0H,EAAQ,GACtDW,EAAQpK,EAAAA,SAAQ,KACpB,MAAMqK,EAAsB,GAC5B,IAAK,IAAI7N,EAAI0N,EAAsB1N,GAAK2N,EAAoB3N,IAE1DkJ,EAAeb,IAAIrI,GAerB,OAbAkJ,EAAehD,SAASlG,IACtB,MAAMmG,EAAIJ,EAAS/F,GACnB6N,EAAIxH,KACF/C,MAAChB,GAECI,EAAWC,EACXC,EAAQC,EACRC,EAAQ9C,EACR+C,EAAU8C,EACVrD,EAAW2D,IALLA,aAAC,EAADA,EAAqC2H,MAAO9N,GAOrD,IAEI6N,CAAG,GACT,CAAC9H,EAAUmD,EAAgBwE,EAAsBC,IAEpD,OACErK,EAACiB,IAAAK,EACC,CAAAC,EAAMmE,EACNpG,EAAQC,EACRE,EAAU6C,EACVd,EAAQa,EACRnD,EAAWoL,GACX"}
|
package/lib/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useLayoutEffect as t,useEffect as r,useRef as n,memo as o,useMemo as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useLayoutEffect as t,useEffect as r,useRef as n,memo as o,useMemo as s,forwardRef as l,Children as i,useState as c,useImperativeHandle as u}from"react";import{useSyncExternalStore as a}from"use-sync-external-store/shim/index.js";const d=Math.min,f=Math.max,_=Math.abs,h=Date.now,m=e=>null!=e,g=(e,t)=>Array.from({length:e},((e,r)=>t(r))),p=(e,t)=>{const r=e.t[t];return-1===r?e.o:r},w=(e,t,r)=>{if(!e.l)return 0;if(e.i>=t)return r?e.u[t]+p(e,t):e.u[t];let n=e.i,o=e.u[n];for(;n<=t&&(e.u[n]=o,n!==t||r);)o+=p(e,n),n++;return e.i=t,o},S=(e,t)=>w(e,t),y=(e,t,r)=>{let n=0;if(r>=0)for(;t<e.l-1;){const o=p(e,t++);if((n+=o)>=r){n-o/2>=r&&t--;break}}else for(;t>0;){const o=p(e,--t);if((n-=o)<=r){n+o/2<r&&t++;break}}return d(f(t,0),e.l-1)},z=(e,t,r,n)=>y(e,r,t-n),I=y,x=(e,t,r)=>({o:t,l:e,i:r?d(r.i,e-1):0,t:g(e,(e=>{const t=r&&r.t[e];return m(t)?t:-1})),u:g(e,(e=>{if(0===e)return 0;const t=r&&r.u[e];return m(t)?t:-1}))}),v="undefined"!=typeof window?t:r,b=(e,t)=>a(e,t,t),T="current",R=e=>{const t=n();return t[T]||(t[T]=e())},M=/*#__PURE__*/o((({_:t,h:r,m:o,g:l,p:i})=>{const c=n(null),u=b(o.S,(()=>o.I(l))),a=b(o.S,(()=>o.v(l)));return v((()=>r.T(c[T],l)),[l]),e(i,{ref:c,style:s((()=>{const e=o.R(),t=o.M()?"right":"left",r={margin:0,padding:0,position:"absolute",[e?"height":"width"]:"100%",[e?"top":t]:0,[e?t:"top"]:u};return e&&(r.display="flex"),a&&(r.visibility="hidden"),r}),[u,a]),children:t})})),O=/*#__PURE__*/l((({children:t,style:r,scrollSize:n,horizontal:o,rtl:l},i)=>e("div",{ref:i,style:r,children:e("div",{style:s((()=>{const e=o?n:"100%",t=o?"100%":n;return{position:"absolute",top:0,[l?"right":"left"]:0,width:e,height:t,minWidth:e,minHeight:t}}),[n]),children:t})}))),P=({_:t,O:r,m:n,p:o,P:l})=>{const i=b(n.S,n.k),c=b(n.S,n.D),u=i>=c?i:c,a=n.R();return e(o,{ref:r,scrollSize:u,horizontal:a,rtl:n.M(),style:s((()=>({overflow:a?"auto hidden":"hidden auto",position:"relative",contain:"strict",width:"100%",height:"100%",padding:0,margin:0,...l})),[l]),children:t})},k=/*#__PURE__*/l((({children:t,itemSize:o=40,overscan:l=4,horizontal:a,rtl:g,endThreshold:y=0,style:k,element:D=O,itemElement:E="div",onEndReached:j},A)=>{const F=s((()=>{const e=[];return i.forEach(t,(t=>{(e=>!m(e)||"boolean"==typeof e)(t)||e.push(t)})),e}),[t]),H=F.length,U=R((()=>((e,t,r,n)=>{let o,s=0,l=0,i=0,c=[],u=x(e,t),a=[0,0];const f=new Set,_=()=>r?s:l;return{j(){const[e,t]=a,r=S(u,e),n=z(u,i,e,r),o=I(u,n,_());return e===n&&t===o?a:a=[n,o]},v:e=>-1===u.t[e],A:e=>((e,t,r)=>{for(let n=t;n<=r;n++)if(-1===e.t[n])return!0;return!1})(u,e,I(u,e,_())),I:e=>S(u,e),D:()=>_(),k:()=>(e=>w(e,e.l-1,!0))(u),F:()=>u.l,H:()=>c,R:()=>r,M:()=>n,U:e=>z(u,e,0,0),W:()=>(o&&o[1](),new Promise(((e,t)=>{o=[()=>{Promise.resolve().then((()=>{e(),o=void 0}))},t]}))),S:e=>(f.add(e),()=>{f.delete(e)}),C(e,r){(()=>{switch(e){case 0:return u.l!==r&&(u=x(r,t,u),!0);case 1:{const e=r.filter((([e,t])=>u.t[e]!==t));if(!e.length)return!1;const t=[];return e.forEach((([e,r])=>{t.push([e,r-p(u,e)]),((e,t,r)=>{e.t[t]=r,e.i=d(t,e.i)})(u,e,r)})),c=t,!0}case 2:return(s!==r.J||l!==r.L)&&(s=r.J,l=r.L,!0);case 3:{const e=i;return(i=r)!==e}}})()&&(f.forEach((e=>{e()})),o&&1===e&&o[0]())}}})(H,o,!!a,!!g))),[W,C]=b(U.S,U.j),J=b(U.S,U.H),L=n(null),V=n(-1),[q,B]=c(new Set),G=R((()=>(e=>{let t,r,n,o=-1,s=0,l=!1;const i=e.R(),c=e.M(),u=i?"scrollLeft":"scrollTop",a=new WeakMap,d=()=>n||(n=new ResizeObserver((t=>{const n=[];for(const o of t)if(o.target===r)e.C(2,{J:o.contentRect.width,L:o.contentRect.height});else{const e=a.get(o.target);m(e)&&n.push([e,o.contentRect[i?"width":"height"]])}n.length&&(e.C(1,n),l=!0)}))),f=()=>r?e.R()?r.scrollWidth:r.scrollHeight:0,g=(e,n)=>{if(r){if(c){if(!m(t)){const e=r[u];r[u]=1,t=0===r[u],r[u]=e}t&&(e*=-1)}n?r[u]+=e:(r[u]=e,s=3)}};return{V(t){r=t;const n=d(),a=()=>{let r=t[u];c&&(r=_(r)),o!==r&&(0!==s&&l?l=!1:3!==s&&(s=o>r?2:1),e.C(3,o=r))},f=(()=>{let e;const t=()=>{m(e)&&clearTimeout(e)},r=()=>{t(),e=setTimeout((()=>{e=null,a(),s=0,B(new Set)}),150)};return r.q=t,r})(),g=()=>{a(),f()},p=(()=>{let t=h()-50;return(...r)=>{const n=h();t+50<n&&(t=n,(t=>{0!==s&&(t.ctrlKey||(i?t.deltaX:t.deltaY)&&o>0&&o<e.k()-e.D()&&f())})(...r))}})();return n.observe(t),t.addEventListener("scroll",g),t.addEventListener("wheel",p,{passive:!0}),()=>{n.disconnect(),t.removeEventListener("scroll",g),t.removeEventListener("wheel",p),f.q()}},T(e,t){const r=d();return a.set(e,t),r.observe(e),()=>{a.delete(e),r.unobserve(e)}},B:()=>r?r[u]:0,G:()=>s,K:f,N:g,X:async(t,r)=>{const n=()=>{let t=r();const n=f(),o=e.D();return n-(t+o)<=0&&(t=n-o),t};if(e.A(t)){do{e.C(3,n());try{await e.W()}catch(e){return}}while(e.A(t));g(n())}else{const t=n();g(t),e.C(3,t)}}}})(U))),K=d(H,U.F());v((()=>{U.C(0,H)}),[H]),v((()=>G.V(L[T])),[]),v((()=>{if(!J.length)return;const e=G.G();if(2===e){const e=J.reduce(((e,[,t])=>e+t),0);e&&G.N(e,!0)}else if(3===e){const e=0===W,t=C-(K-1)==0,r=J.reduce(((r,[n,o])=>(n<W?e||(r+=o):!e&&t&&(r+=o),r)),0);r&&G.N(r,!0)}}),[J]),r((()=>{j&&(V[T]>K&&(V[T]=-1),K-1-C<=y&&V[T]<K&&(V[T]=K,j()))}),[C]),u(A,(()=>({get scrollOffset(){return G.B()},get scrollSize(){return G.K()},scrollToIndex(e){e=f(d(e,K-1),0),G.X(e,(()=>U.I(e)))},scrollToOffset(e){e=f(e,0),G.X(U.U(e),(()=>e))}})),[K]);const N=f(W-l,0),Q=d(C+l,K-1),X=s((()=>{const t=[];for(let e=N;e<=Q;e++)q.add(e);return q.forEach((r=>{const n=F[r];t.push(e(M,{h:G,m:U,g:r,p:E,_:n},(null==n?void 0:n.key)||r))})),t}),[F,q,N,Q]);return e(P,{O:L,m:U,p:D,P:k,_:X})}));export{k as List};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../src/src/core/utils.ts","../src/src/core/cache.ts","../src/src/react/useIsomorphicLayoutEffect.ts","../src/src/react/useSyncExternalStore.ts","../src/src/react/utils.ts","../src/src/react/useStatic.ts","../src/src/react/List.tsx","../src/src/core/store.ts","../src/src/core/scroller.ts"],"sourcesContent":["export const min = Math.min;\nexport const max = Math.max;\nexport const abs = Math.abs;\n\nexport const exists = <T>(v: T): v is Exclude<T, null | undefined> => v != null;\n\nexport const range = <T>(length: number, cb: (i: number) => T): T[] =>\n Array.from({ length }, (_, i) => cb(i));\n\nexport const debounce = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let id: NodeJS.Timeout | undefined | null;\n\n const cancel = () => {\n if (exists(id)) {\n clearTimeout(id);\n }\n };\n const debouncedFn = () => {\n cancel();\n id = setTimeout(() => {\n id = null;\n fn();\n }, ms);\n };\n debouncedFn._cancel = cancel;\n return debouncedFn;\n};\n","import type { DeepReadonly, Writeable } from \"./types\";\nimport { exists, max, min, range } from \"./utils\";\n\nexport const UNCACHED = -1;\n\nexport type Cache = DeepReadonly<{\n _defaultItemSize: number;\n _length: number;\n _sizes: number[];\n _measuredOffsetIndex: number;\n _offsets: number[];\n}>;\n\nexport const getItemSize = (cache: Cache, index: number): number => {\n const size = cache._sizes[index]!;\n return size === UNCACHED ? cache._defaultItemSize : size;\n};\n\nexport const setItemSize = (\n cache: Writeable<Cache>,\n index: number,\n size: number\n) => {\n cache._sizes[index] = size;\n // mark as dirty\n cache._measuredOffsetIndex = min(index, cache._measuredOffsetIndex);\n};\n\nexport const computeTotalSize = (cache: Writeable<Cache>): number => {\n if (!cache._length) return 0;\n const lastIndex = cache._length - 1;\n if (cache._measuredOffsetIndex >= lastIndex) {\n return cache._offsets[lastIndex]! + getItemSize(cache, lastIndex);\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= lastIndex) {\n cache._offsets[i] = top;\n top += getItemSize(cache, i);\n i++;\n }\n\n cache._measuredOffsetIndex = lastIndex;\n return top;\n};\n\nconst findIndex = (cache: Cache, i: number, distance: number): number => {\n let sum = 0;\n if (distance >= 0) {\n // search forward\n while (i < cache._length - 1) {\n if ((sum += getItemSize(cache, i++)) >= distance) {\n break;\n }\n }\n if (sum - getItemSize(cache, i) / 2 >= distance) {\n i--;\n }\n } else {\n // search backward\n while (i > 0) {\n if ((sum -= getItemSize(cache, --i)) <= distance) {\n break;\n }\n }\n if (sum + getItemSize(cache, i) / 2 < distance) {\n i++;\n }\n }\n\n return min(max(i, 0), cache._length - 1);\n};\n\nexport const findStartIndexWithOffset = (\n cache: Cache,\n offset: number,\n prevStartIndex: number,\n prevOffset: number\n): number => {\n return findIndex(cache, prevStartIndex, offset - prevOffset);\n};\n\nexport const findEndIndex = findIndex;\n\nexport const hasUnmeasuredItemsInRange = (\n cache: Cache,\n startIndex: number,\n endIndex: number\n): boolean => {\n for (let i = startIndex; i <= endIndex; i++) {\n if (cache._sizes[i] === UNCACHED) {\n return true;\n }\n }\n return false;\n};\n\nexport const computeStartOffset = (\n cache: Writeable<Cache>,\n index: number\n): number => {\n if (!cache._length) return 0;\n if (cache._measuredOffsetIndex >= index) {\n return cache._offsets[index]!;\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= index) {\n cache._offsets[i] = top;\n if (i === index) {\n break;\n }\n top += getItemSize(cache, i);\n i++;\n }\n cache._measuredOffsetIndex = index;\n return top;\n};\n\nexport const resetCache = (\n length: number,\n itemSize: number,\n cache?: Cache\n): Cache => {\n return {\n _defaultItemSize: itemSize,\n _length: length,\n _measuredOffsetIndex: cache\n ? min(cache._measuredOffsetIndex, length - 1)\n : 0,\n _sizes: range(length, (i) => {\n const size = cache && cache._sizes[i];\n if (exists(size)) {\n return size;\n }\n return UNCACHED;\n }),\n _offsets: range(length, (i) => {\n if (i === 0) {\n // first offset must be 0\n return 0;\n }\n const offset = cache && cache._offsets[i];\n if (exists(offset)) {\n return offset;\n }\n return UNCACHED;\n }),\n };\n};\n","import { useEffect, useLayoutEffect } from \"react\";\n\n// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useSyncExternalStore as _useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nexport const useSyncExternalStore = <T>(\n subscibe: (onStoreChange: () => void) => () => void,\n getSnapShot: () => T\n): T => {\n return _useSyncExternalStore(subscibe, getSnapShot, getSnapShot);\n};\n","export const refKey = \"current\";\n","import { useRef } from \"react\";\nimport { refKey } from \"./utils\";\n\nexport const useStatic = <T>(init: () => T): T => {\n const ref = useRef<T>();\n return ref[refKey] || (ref[refKey] = init());\n};\n","import {\n Children,\n memo,\n useRef,\n useMemo,\n CSSProperties,\n ReactElement,\n forwardRef,\n useImperativeHandle,\n ReactNode,\n useEffect,\n RefObject,\n useState,\n} from \"react\";\nimport {\n ACTION_UPDATE_CACHE_LENGTH,\n VirtualStore,\n createVirtualStore,\n} from \"../core/store\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport { exists, max, min } from \"../core/utils\";\nimport {\n createScroller,\n Scroller,\n SCROLL_MANUAL,\n SCROLL_UP,\n} from \"../core/scroller\";\nimport { refKey } from \"./utils\";\nimport { useStatic } from \"./useStatic\";\n\nconst INITIAL_END_REACHED_INDEX = -1;\n\ntype ItemProps = {\n _children: ReactNode;\n _scroller: Scroller;\n _store: VirtualStore;\n _index: number;\n _element: \"div\";\n};\n\nconst Item = memo(\n ({\n _children: children,\n _scroller: scroller,\n _store: store,\n _index: index,\n _element: Element,\n }: ItemProps): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n\n const offset = useSyncExternalStore(store._subscribe, () =>\n store._getItemOffset(index)\n );\n const hide = useSyncExternalStore(store._subscribe, () =>\n store._isUnmeasuredItem(index)\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n useIsomorphicLayoutEffect(\n () => scroller._initItem(ref[refKey]!, index),\n [index]\n );\n\n return (\n <Element\n ref={ref}\n style={useMemo<CSSProperties>(() => {\n const isHorizontal = store._isHorizontal();\n const leftOrRightKey = store._isRtl() ? \"right\" : \"left\";\n const style: CSSProperties = {\n margin: 0,\n padding: 0,\n position: \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : leftOrRightKey]: 0,\n [isHorizontal ? leftOrRightKey : \"top\"]: offset,\n // willChange: \"transform\",\n };\n if (isHorizontal) {\n style.display = \"flex\";\n }\n if (hide) {\n style.visibility = \"hidden\";\n }\n return style;\n }, [offset, hide])}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst isInvalidElement = <T extends ReactNode>(\n e: T\n): e is Extract<T, null | undefined | boolean> =>\n !exists(e) || typeof e === \"boolean\";\n\nexport interface CustomWindowComponentProps {\n children: ReactNode;\n style: CSSProperties;\n scrollSize: number;\n horizontal: boolean;\n rtl: boolean;\n}\n\nconst DefaultWindow = forwardRef<any, CustomWindowComponentProps>(\n ({ children, style, scrollSize, horizontal, rtl }, ref): ReactElement => {\n return (\n <div ref={ref} style={style}>\n <div\n style={useMemo<CSSProperties>(() => {\n const width = horizontal ? scrollSize : \"100%\";\n const height = horizontal ? \"100%\" : scrollSize;\n return {\n position: \"absolute\",\n top: 0,\n [rtl ? \"right\" : \"left\"]: 0,\n width,\n height,\n minWidth: width,\n minHeight: height,\n };\n }, [scrollSize])}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n\nexport type CustomWindowComponent = typeof DefaultWindow;\n\nconst Window = ({\n _children: children,\n _ref: ref,\n _store: store,\n _element: Element,\n _style: style,\n}: {\n _children: ReactNode;\n _ref: RefObject<HTMLDivElement>;\n _store: VirtualStore;\n _element: CustomWindowComponent;\n _style: CSSProperties | undefined;\n}) => {\n const scrollSize = useSyncExternalStore(\n store._subscribe,\n store._getScrollSize\n );\n const viewportSize = useSyncExternalStore(\n store._subscribe,\n store._getViewportSize\n );\n const clampedScrollSize =\n scrollSize >= viewportSize ? scrollSize : viewportSize;\n\n const horizontal = store._isHorizontal();\n return (\n <Element\n ref={ref}\n scrollSize={clampedScrollSize}\n horizontal={horizontal}\n rtl={store._isRtl()}\n style={useMemo<CSSProperties>(\n () => ({\n overflow: horizontal ? \"auto hidden\" : \"hidden auto\",\n position: \"relative\",\n contain: \"strict\",\n // transform: \"translate3d(0px, 0px, 0px)\",\n // willChange: \"scroll-position\",\n // backfaceVisibility: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 0,\n margin: 0,\n ...style,\n }),\n [style]\n )}\n >\n {children}\n </Element>\n );\n};\n\nexport interface CustomItemComponentProps {\n style: CSSProperties;\n children: ReactNode;\n}\n\nexport type CustomItemComponent = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<CustomItemComponentProps> & React.RefAttributes<any>\n>;\n\ntype CustomItemComponentOrElement =\n | keyof JSX.IntrinsicElements\n | CustomItemComponent;\n\n/**\n * Methods of {@link List}.\n */\nexport interface ListHandle {\n /**\n * Get current scrollTop or scrollLeft.\n */\n scrollOffset: number;\n /**\n * Get current scrollHeight or scrollWidth.\n */\n scrollSize: number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n */\n scrollToIndex(index: number): void;\n /**\n * Scroll to the item specified by offset.\n * @param offset offset from start\n */\n scrollToOffset(offset: number): void;\n}\n\n/**\n * Props of {@link List}.\n */\nexport interface ListProps {\n /**\n * Elements rendered by this component.\n */\n children: ReactNode;\n /**\n * Item size hint for unmeasured items. It's recommended to specify this prop if item sizes are fixed and known, or much larger than the defaultValue. It will help to reduce scroll jump when items are measured.\n * @defaultValue 40\n */\n itemSize?: number;\n /**\n * Number of items to render above/below the visible bounds of the list. You can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 4\n */\n overscan?: number;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * You have to set true if you use this component under `direction: rtl` style.\n */\n rtl?: boolean;\n /**\n * Number of items to be the margin from the end of the scroll. See also {@link onEndReached}.\n * @defaultValue 0\n */\n endThreshold?: number;\n /**\n * Inline style prop to override style of scrollable element.\n */\n style?: CSSProperties;\n /**\n * Customized element type for scrollable element.\n * @defaultValue {@link DefaultWindow}\n */\n element?: CustomWindowComponent;\n /**\n * Customized element type for item element.\n * @defaultValue \"div\"\n */\n itemElement?: CustomItemComponentOrElement;\n /**\n * Callback invoked when scrolling reached to the end. The margin from the end is specified by {@link endThreshold}.\n */\n onEndReached?: () => void;\n}\n\n/**\n * Virtualized list component. See {@link ListProps} and {@link ListHandle}.\n */\nexport const List = forwardRef<ListHandle, ListProps>(\n (\n {\n children,\n itemSize: itemSizeProp = 40,\n overscan = 4,\n horizontal: horizontalProp,\n rtl: rtlProp,\n endThreshold = 0,\n style: styleProp,\n element = DefaultWindow,\n itemElement = \"div\",\n onEndReached,\n },\n ref\n ): ReactElement => {\n // Memoize element array\n const elements = useMemo(() => {\n const arr: ReactNode[] = [];\n Children.forEach(children, (e) => {\n if (isInvalidElement(e)) {\n return;\n }\n arr.push(e);\n });\n return arr;\n }, [children]);\n const elementsCount = elements.length;\n\n // https://github.com/facebook/react/issues/25191#issuecomment-1237456448\n const store = useStatic(() =>\n createVirtualStore(\n elementsCount,\n itemSizeProp,\n !!horizontalProp,\n !!rtlProp\n )\n );\n const startIndex = useSyncExternalStore(\n store._subscribe,\n store._getStartIndex\n );\n const endIndex = useSyncExternalStore(store._subscribe, store._getEndIndex);\n const jump = useSyncExternalStore(store._subscribe, store._getJump);\n const rootRef = useRef<HTMLDivElement>(null);\n const onEndReachedCalledIndex = useRef<number>(INITIAL_END_REACHED_INDEX);\n\n const [mountedIndexes, reset] = useState<Set<number>>(new Set<number>());\n const scroller = useStatic(() =>\n createScroller(store, () => {\n reset(new Set());\n })\n );\n\n // The elements length and cached items length are different just after element is added/removed.\n const count = min(elementsCount, store._getItemCount());\n\n // So update cache length. Updating state in render will cause warn so use useEffect for now.\n useIsomorphicLayoutEffect(() => {\n store._update(ACTION_UPDATE_CACHE_LENGTH, elementsCount);\n }, [elementsCount]);\n\n useIsomorphicLayoutEffect(() => scroller._initRoot(rootRef[refKey]!), []);\n\n useIsomorphicLayoutEffect(() => {\n if (!jump.length) return;\n\n // Compensate scroll jump\n const scrollDirection = scroller._getScrollDirection();\n if (scrollDirection === SCROLL_UP) {\n const diff = jump.reduce((acc, [, j]) => acc + j, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else if (scrollDirection === SCROLL_MANUAL) {\n const isStartInView = startIndex === 0;\n const isEndInView = endIndex - (count - 1) === 0;\n const diff = jump.reduce((acc, [index, j]) => {\n if (index < startIndex) {\n // Keep start if scroll position is not stuck to the start\n if (!isStartInView) {\n acc += j;\n }\n } else {\n // Keep end if scroll position is stuck to the end\n if (!isStartInView && isEndInView) {\n acc += j;\n }\n }\n return acc;\n }, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else {\n // NOP\n }\n }, [jump]);\n\n useEffect(() => {\n if (!onEndReached) return;\n\n if (onEndReachedCalledIndex[refKey] > count) {\n // Probably items have been refreshed, so reset index\n onEndReachedCalledIndex[refKey] = INITIAL_END_REACHED_INDEX;\n }\n\n const endMargin = count - 1 - endIndex;\n if (\n endMargin <= endThreshold &&\n onEndReachedCalledIndex[refKey] < count\n ) {\n onEndReachedCalledIndex[refKey] = count;\n onEndReached();\n }\n }, [endIndex]);\n\n useImperativeHandle(\n ref,\n () => {\n return {\n get scrollOffset() {\n return scroller._getScrollPosition();\n },\n get scrollSize() {\n return scroller._getActualScrollSize();\n },\n scrollToIndex(index) {\n index = max(min(index, count - 1), 0);\n\n scroller._scrollTo(index, () => store._getItemOffset(index));\n },\n scrollToOffset(offset) {\n offset = max(offset, 0);\n\n scroller._scrollTo(\n store._getItemIndexForScrollTo(offset),\n () => offset\n );\n },\n };\n },\n [count]\n );\n\n const startIndexWithMargin = max(startIndex - overscan, 0);\n const endIndexWithMargin = min(endIndex + overscan, count - 1);\n const items = useMemo(() => {\n const res: ReactElement[] = [];\n for (let i = startIndexWithMargin; i <= endIndexWithMargin; i++) {\n // https://github.com/sergi/virtual-list/commit/8e7e06dc63568334c1ab809ea83c1be36572e9ed\n mountedIndexes.add(i);\n }\n mountedIndexes.forEach((i) => {\n const e = elements[i];\n res.push(\n <Item\n key={(e as { key?: ReactElement[\"key\"] })?.key || i}\n _scroller={scroller}\n _store={store}\n _index={i}\n _element={itemElement as \"div\"}\n _children={e}\n />\n );\n });\n return res;\n }, [elements, mountedIndexes, startIndexWithMargin, endIndexWithMargin]);\n\n return (\n <Window\n _ref={rootRef}\n _store={store}\n _element={element}\n _style={styleProp}\n _children={items}\n />\n );\n }\n);\n","import {\n findStartIndexWithOffset,\n resetCache,\n getItemSize,\n computeTotalSize,\n findEndIndex,\n computeStartOffset,\n Cache,\n UNCACHED,\n setItemSize,\n hasUnmeasuredItemsInRange,\n} from \"./cache\";\nimport type { Writeable } from \"./types\";\n\nexport type ScrollJump = Readonly<[index: number, sizeDiff: number][]>;\n\ntype State = {\n _startIndex: number;\n _viewportWidth: number;\n _viewportHeight: number;\n _cache: Cache;\n _jump: ScrollJump;\n};\n\nexport const ACTION_UPDATE_CACHE_LENGTH = 0;\nexport const ACTION_UPDATE_ITEM_SIZES = 1;\nexport const ACTION_UPDATE_VIEWPORT = 2;\nexport const ACTION_HANDLE_SCROLL = 3;\n\ntype Actions =\n | [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number]\n | [\n type: typeof ACTION_UPDATE_ITEM_SIZES,\n entries: [index: number, size: number][]\n ]\n | [\n type: typeof ACTION_UPDATE_VIEWPORT,\n rect: { _width: number; _height: number }\n ]\n | [type: typeof ACTION_HANDLE_SCROLL, offset: number];\n\nexport type VirtualStore = {\n _getStartIndex(): number;\n _getEndIndex(): number;\n _isUnmeasuredItem(index: number): boolean;\n _hasUnmeasuredItemsInRange(startIndex: number): boolean;\n _getItemOffset(index: number): number;\n _getViewportSize(): number;\n _getScrollSize(): number;\n _getItemCount(): number;\n _getJump(): ScrollJump;\n _isHorizontal(): boolean;\n _isRtl(): boolean;\n _getItemIndexForScrollTo(offset: number): number;\n _waitForScrollDestinationItemsMeasured(): Promise<void>;\n _subscribe(cb: () => void): () => void;\n _update(...action: Actions): void;\n};\n\nexport const createVirtualStore = (\n itemCount: number,\n itemSize: number,\n isHorizontal: boolean,\n isRtl: boolean\n): VirtualStore => {\n const subscribers = new Set<() => void>();\n const state: State = {\n _startIndex: 0,\n _viewportWidth: 0,\n _viewportHeight: 0,\n _cache: resetCache(itemCount, itemSize),\n _jump: [],\n };\n const getViewportSize = (): number =>\n isHorizontal ? state._viewportWidth : state._viewportHeight;\n\n let scrollToQueue: [() => void, () => void] | undefined;\n\n return {\n _getStartIndex() {\n return state._startIndex;\n },\n _getEndIndex() {\n return findEndIndex(state._cache, state._startIndex, getViewportSize());\n },\n _isUnmeasuredItem(index) {\n return state._cache._sizes[index] === UNCACHED;\n },\n _hasUnmeasuredItemsInRange(startIndex) {\n return hasUnmeasuredItemsInRange(\n state._cache,\n startIndex,\n findEndIndex(state._cache, startIndex, getViewportSize())\n );\n },\n _getItemOffset(index) {\n return computeStartOffset(state._cache as Writeable<Cache>, index);\n },\n _getViewportSize() {\n return getViewportSize();\n },\n _getScrollSize() {\n return computeTotalSize(state._cache as Writeable<Cache>);\n },\n _getItemCount() {\n return state._cache._length;\n },\n _getJump() {\n return state._jump;\n },\n _isHorizontal() {\n return isHorizontal;\n },\n _isRtl() {\n return isRtl;\n },\n _getItemIndexForScrollTo(offset) {\n return findStartIndexWithOffset(state._cache, offset, 0, 0);\n },\n _waitForScrollDestinationItemsMeasured() {\n if (scrollToQueue) {\n // Cancel waiting scrollTo\n scrollToQueue[1]();\n }\n // The measurement will be done asynchronously and the timing is not predictable so we use promise.\n // For example, ResizeObserver may not fire when window is not visible.\n return new Promise((resolve, reject) => {\n scrollToQueue = [\n () => {\n // HACK: It should be resolved in the next microtask that is after React's render\n Promise.resolve().then(() => {\n resolve();\n scrollToQueue = undefined;\n });\n },\n reject,\n ];\n });\n },\n _subscribe(cb) {\n subscribers.add(cb);\n return () => {\n subscribers.delete(cb);\n };\n },\n _update(type, payload) {\n const mutated = ((): boolean => {\n switch (type) {\n case ACTION_UPDATE_CACHE_LENGTH: {\n if (state._cache._length === payload) return false;\n state._cache = resetCache(payload, itemSize, state._cache);\n return true;\n }\n case ACTION_UPDATE_ITEM_SIZES: {\n const updated = payload.filter(\n ([index, size]) => state._cache._sizes[index] !== size\n );\n // Skip if all items are cached and not updated\n if (!updated.length) {\n return false;\n }\n\n const jump: [index: number, sizeDiff: number][] = [];\n updated.forEach(([index, size]) => {\n jump.push([index, size - getItemSize(state._cache, index)]);\n setItemSize(state._cache as Writeable<Cache>, index, size);\n });\n state._jump = jump;\n return true;\n }\n case ACTION_UPDATE_VIEWPORT: {\n if (\n state._viewportWidth === payload._width &&\n state._viewportHeight === payload._height\n ) {\n return false;\n }\n state._viewportWidth = payload._width;\n state._viewportHeight = payload._height;\n return true;\n }\n case ACTION_HANDLE_SCROLL: {\n const prevStartIndex = state._startIndex;\n const prevOffset = computeStartOffset(\n state._cache as Writeable<Cache>,\n prevStartIndex\n );\n if (prevOffset === payload) {\n return false;\n }\n return (\n (state._startIndex = findStartIndexWithOffset(\n state._cache,\n payload,\n prevStartIndex,\n prevOffset\n )) !== prevStartIndex\n );\n }\n }\n })();\n\n if (mutated) {\n subscribers.forEach((cb) => {\n cb();\n });\n if (scrollToQueue && type === ACTION_UPDATE_ITEM_SIZES) {\n scrollToQueue[0]();\n }\n }\n },\n };\n};\n","import {\n ACTION_HANDLE_SCROLL,\n ACTION_UPDATE_ITEM_SIZES,\n ACTION_UPDATE_VIEWPORT,\n VirtualStore,\n} from \"./store\";\nimport { abs, debounce, exists } from \"./utils\";\n\nexport const SCROLL_STOP = 0;\nexport const SCROLL_DOWN = 1;\nexport const SCROLL_UP = 2;\nexport const SCROLL_MANUAL = 3;\ntype ScrollDirection =\n | typeof SCROLL_STOP\n | typeof SCROLL_DOWN\n | typeof SCROLL_UP\n | typeof SCROLL_MANUAL;\n\nexport type Scroller = {\n _initRoot: (rootElement: HTMLElement) => () => void;\n _initItem: (itemElement: HTMLElement, index: number) => () => void;\n _getScrollPosition: () => number;\n _getScrollDirection: () => ScrollDirection;\n _getActualScrollSize: () => number;\n _updateScrollPosition: (offset: number, diff?: boolean) => void;\n _scrollTo: (index: number, getCurrentOffset: () => number) => void;\n};\n\nexport const createScroller = (\n store: VirtualStore,\n notifyStop: () => void\n): Scroller => {\n let prevOffset = -1;\n let scrollDirection: ScrollDirection = SCROLL_STOP;\n let resized = false;\n let isNegativeOffset: boolean | undefined;\n let rootElement: HTMLElement | undefined;\n let _ro: ResizeObserver | undefined;\n const isHorizontal = store._isHorizontal();\n const isRtl = store._isRtl();\n const scrollToKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const mountedIndexes = new WeakMap<Element, number>();\n const getResizeObserver = (): ResizeObserver => {\n // Initialize ResizeObserver lazily for SSR\n return (\n _ro ||\n (_ro = new ResizeObserver((entries) => {\n // https://www.w3.org/TR/resize-observer/#intro\n const resizes: [index: number, size: number][] = [];\n for (const entry of entries) {\n if (entry.target === rootElement) {\n store._update(ACTION_UPDATE_VIEWPORT, {\n _width: entry.contentRect.width,\n _height: entry.contentRect.height,\n });\n } else {\n const index = mountedIndexes.get(entry.target);\n if (exists(index)) {\n resizes.push([\n index,\n entry.contentRect[isHorizontal ? \"width\" : \"height\"],\n ]);\n }\n }\n }\n\n if (resizes.length) {\n store._update(ACTION_UPDATE_ITEM_SIZES, resizes);\n resized = true;\n }\n }))\n );\n };\n const getActualScrollSize = (): number => {\n if (!rootElement) return 0;\n // Use element's scrollHeight/scrollWidth instead of stored scrollSize.\n // This is because stored size may differ from the actual size, for example when a new item is added and not yet measured.\n return store._isHorizontal()\n ? rootElement.scrollWidth\n : rootElement.scrollHeight;\n };\n const updateScrollPosition = (offset: number, diff?: boolean) => {\n if (!rootElement) return;\n if (isRtl) {\n if (!exists(isNegativeOffset)) {\n // Assume offset type in rtl direction.\n // The scroll position is negative in spec however its not in some browsers, for example Chrome earlier than v85.\n // https://github.com/othree/jquery.rtl-scroll-type\n const prev = rootElement[scrollToKey];\n rootElement[scrollToKey] = 1;\n isNegativeOffset = rootElement[scrollToKey] === 0;\n rootElement[scrollToKey] = prev;\n }\n if (isNegativeOffset) {\n offset *= -1;\n }\n }\n if (diff) {\n rootElement[scrollToKey] += offset;\n } else {\n rootElement[scrollToKey] = offset;\n scrollDirection = SCROLL_MANUAL;\n }\n };\n const scrollTo = async (index: number, getCurrentOffset: () => number) => {\n const getOffset = (): number => {\n let offset = getCurrentOffset();\n const scrollSize = getActualScrollSize();\n const viewportSize = store._getViewportSize();\n if (scrollSize - (offset + viewportSize) <= 0) {\n // Adjust if the offset is over the end, to get correct startIndex.\n offset = scrollSize - viewportSize;\n }\n return offset;\n };\n\n if (store._hasUnmeasuredItemsInRange(index)) {\n do {\n // In order to scroll to the correct position, mount the items and measure their sizes before scrolling.\n store._update(ACTION_HANDLE_SCROLL, getOffset());\n try {\n // Wait for the scroll destination items to be measured.\n await store._waitForScrollDestinationItemsMeasured();\n } catch (e) {\n // canceled\n return;\n }\n } while (store._hasUnmeasuredItemsInRange(index));\n\n // Scroll with the updated value\n updateScrollPosition(getOffset());\n } else {\n const offset = getOffset();\n updateScrollPosition(offset);\n // Sync viewport to scroll destination\n store._update(ACTION_HANDLE_SCROLL, offset);\n }\n };\n\n return {\n _initRoot(root) {\n rootElement = root;\n const ro = getResizeObserver();\n\n const syncViewportToScrollPosition = () => {\n let offset = root[scrollToKey];\n if (isRtl) {\n // The scroll position may be negative value in rtl direction.\n // https://github.com/othree/jquery.rtl-scroll-type\n offset = abs(offset);\n }\n if (prevOffset === offset) {\n return;\n }\n // Skip scroll direction detection just after resizing because it may result in the opposite direction.\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (scrollDirection === SCROLL_STOP || !resized) {\n // Ignore until manual scrolling\n if (scrollDirection !== SCROLL_MANUAL) {\n scrollDirection = prevOffset > offset ? SCROLL_UP : SCROLL_DOWN;\n }\n } else {\n resized = false;\n }\n store._update(ACTION_HANDLE_SCROLL, (prevOffset = offset));\n };\n\n const onScrollStopped = debounce(() => {\n // Check scroll position once just after scrolling stopped\n syncViewportToScrollPosition();\n scrollDirection = SCROLL_STOP;\n notifyStop();\n }, 300);\n\n const onScroll = () => {\n syncViewportToScrollPosition();\n onScrollStopped();\n };\n\n ro.observe(root);\n root.addEventListener(\"scroll\", onScroll);\n\n return () => {\n ro.disconnect();\n root.removeEventListener(\"scroll\", onScroll);\n onScrollStopped._cancel();\n };\n },\n _initItem(el, i) {\n const ro = getResizeObserver();\n mountedIndexes.set(el, i);\n ro.observe(el);\n return () => {\n mountedIndexes.delete(el);\n ro.unobserve(el);\n };\n },\n _getScrollPosition() {\n if (!rootElement) return 0;\n return rootElement[scrollToKey];\n },\n _getScrollDirection() {\n return scrollDirection;\n },\n _getActualScrollSize: getActualScrollSize,\n _updateScrollPosition: updateScrollPosition,\n _scrollTo: scrollTo,\n };\n};\n"],"names":["min","Math","max","abs","exists","v","range","length","cb","Array","from","_","i","getItemSize","cache","index","size","_sizes","_defaultItemSize","findIndex","distance","sum","_length","findStartIndexWithOffset","offset","prevStartIndex","prevOffset","findEndIndex","computeStartOffset","_measuredOffsetIndex","_offsets","top","resetCache","itemSize","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useSyncExternalStore","subscibe","getSnapShot","_useSyncExternalStore","refKey","useStatic","init","ref","useRef","Item","memo","_children","children","_scroller","scroller","_store","store","_index","_element","Element","_subscribe","_getItemOffset","hide","_isUnmeasuredItem","_initItem","_jsx","style","useMemo","isHorizontal","_isHorizontal","leftOrRightKey","_isRtl","margin","padding","position","display","visibility","DefaultWindow","forwardRef","scrollSize","horizontal","rtl","width","height","minWidth","minHeight","Window","_ref","_style","_getScrollSize","viewportSize","_getViewportSize","clampedScrollSize","overflow","contain","List","itemSizeProp","overscan","horizontalProp","rtlProp","endThreshold","styleProp","element","itemElement","onEndReached","elements","arr","Children","forEach","e","isInvalidElement","push","elementsCount","createVirtualStore","itemCount","isRtl","subscribers","Set","state","_startIndex","_viewportWidth","_viewportHeight","_cache","_jump","getViewportSize","scrollToQueue","_getStartIndex","_getEndIndex","_hasUnmeasuredItemsInRange","startIndex","hasUnmeasuredItemsInRange","endIndex","lastIndex","computeTotalSize","_getItemCount","_getJump","_getItemIndexForScrollTo","_waitForScrollDestinationItemsMeasured","Promise","resolve","reject","then","undefined","add","delete","_update","type","payload","updated","filter","jump","setItemSize","_width","_height","rootRef","onEndReachedCalledIndex","mountedIndexes","reset","useState","createScroller","isNegativeOffset","rootElement","_ro","scrollDirection","resized","scrollToKey","WeakMap","getResizeObserver","ResizeObserver","entries","resizes","entry","target","contentRect","get","getActualScrollSize","scrollWidth","scrollHeight","updateScrollPosition","diff","prev","_initRoot","root","ro","syncViewportToScrollPosition","onScrollStopped","debounce","id","cancel","clearTimeout","debouncedFn","setTimeout","_cancel","onScroll","observe","addEventListener","disconnect","removeEventListener","el","set","unobserve","_getScrollPosition","_getScrollDirection","_getActualScrollSize","_updateScrollPosition","_scrollTo","async","getCurrentOffset","getOffset","count","reduce","acc","j","isStartInView","isEndInView","useImperativeHandle","scrollOffset","scrollToIndex","scrollToOffset","startIndexWithMargin","endIndexWithMargin","items","res","key"],"mappings":"oRAAO,MAAMA,EAAMC,KAAKD,IACXE,EAAMD,KAAKC,IACXC,EAAMF,KAAKE,IAEXC,EAAaC,GAAiD,MAALA,EAEzDC,EAAQA,CAAIC,EAAgBC,IACvCC,MAAMC,KAAK,CAAEH,WAAU,CAACI,EAAGC,IAAMJ,EAAGI,KCMzBC,EAAcA,CAACC,EAAcC,KACxC,MAAMC,EAAOF,EAAMG,EAAOF,GAC1B,OAZsB,IAYfC,EAAoBF,EAAMI,EAAmBF,CAAI,EAgCpDG,EAAYA,CAACL,EAAcF,EAAWQ,KAC1C,IAAIC,EAAM,EACV,GAAID,GAAY,EAAG,CAEjB,KAAOR,EAAIE,EAAMQ,EAAU,MACpBD,GAAOR,EAAYC,EAAOF,OAASQ,KAItCC,EAAMR,EAAYC,EAAOF,GAAK,GAAKQ,GACrCR,GAEH,KAAM,CAEL,KAAOA,EAAI,MACJS,GAAOR,EAAYC,IAASF,KAAOQ,KAItCC,EAAMR,EAAYC,EAAOF,GAAK,EAAIQ,GACpCR,GAEH,CAED,OAAOZ,EAAIE,EAAIU,EAAG,GAAIE,EAAMQ,EAAU,EAAE,EAG7BC,EAA2BA,CACtCT,EACAU,EACAC,EACAC,IAEOP,EAAUL,EAAOW,EAAgBD,EAASE,GAGtCC,EAAeR,EAefS,EAAqBA,CAChCd,EACAC,KAEA,IAAKD,EAAMQ,EAAS,OAAO,EAC3B,GAAIR,EAAMe,GAAwBd,EAChC,OAAOD,EAAMgB,EAASf,GAGxB,IAAIH,EAAIE,EAAMe,EACVE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AAsBC,IAEpD,OACE3J,EAACqB,EACC,CAAAC,EAAMmE,EACNnG,EAAQC,EACRE,EAAU4C,EACVd,EAAQa,EACRlD,EAAW0K,GACX"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../src/src/core/utils.ts","../src/src/core/cache.ts","../src/src/react/useIsomorphicLayoutEffect.ts","../src/src/react/useSyncExternalStore.ts","../src/src/react/utils.ts","../src/src/react/useStatic.ts","../src/src/react/List.tsx","../src/src/core/store.ts","../src/src/core/scroller.ts"],"sourcesContent":["export const min = Math.min;\nexport const max = Math.max;\nexport const abs = Math.abs;\nexport const now = Date.now;\n\nexport const exists = <T>(v: T): v is Exclude<T, null | undefined> => v != null;\n\nexport const range = <T>(length: number, cb: (i: number) => T): T[] =>\n Array.from({ length }, (_, i) => cb(i));\n\nexport const debounce = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let id: NodeJS.Timeout | undefined | null;\n\n const cancel = () => {\n if (exists(id)) {\n clearTimeout(id);\n }\n };\n const debouncedFn = () => {\n cancel();\n id = setTimeout(() => {\n id = null;\n fn();\n }, ms);\n };\n debouncedFn._cancel = cancel;\n return debouncedFn;\n};\n\nexport const throttle = <T extends (...args: any[]) => void>(\n fn: T,\n ms: number\n) => {\n let time = now() - ms;\n return (...args: Parameters<T>) => {\n const n = now();\n if (time + ms < n) {\n time = n;\n fn(...args);\n }\n };\n};\n","import type { DeepReadonly, Writeable } from \"./types\";\nimport { exists, max, min, range } from \"./utils\";\n\nexport const UNCACHED = -1;\n\nexport type Cache = DeepReadonly<{\n _defaultItemSize: number;\n _length: number;\n _sizes: number[];\n _measuredOffsetIndex: number;\n _offsets: number[];\n}>;\n\nexport const getItemSize = (cache: Cache, index: number): number => {\n const size = cache._sizes[index]!;\n return size === UNCACHED ? cache._defaultItemSize : size;\n};\n\nexport const setItemSize = (\n cache: Writeable<Cache>,\n index: number,\n size: number\n) => {\n cache._sizes[index] = size;\n // mark as dirty\n cache._measuredOffsetIndex = min(index, cache._measuredOffsetIndex);\n};\n\nconst computeOffset = (\n cache: Writeable<Cache>,\n index: number,\n isTotal?: boolean\n): number => {\n if (!cache._length) return 0;\n if (cache._measuredOffsetIndex >= index) {\n if (isTotal) {\n return cache._offsets[index]! + getItemSize(cache, index);\n } else {\n return cache._offsets[index]!;\n }\n }\n\n let i = cache._measuredOffsetIndex;\n let top = cache._offsets[i]!;\n while (i <= index) {\n cache._offsets[i] = top;\n if (i === index && !isTotal) {\n break;\n }\n top += getItemSize(cache, i);\n i++;\n }\n // mark as measured\n cache._measuredOffsetIndex = index;\n return top;\n};\n\nexport const computeTotalSize = (cache: Writeable<Cache>): number => {\n return computeOffset(cache, cache._length - 1, true);\n};\n\nexport const computeStartOffset = (\n cache: Writeable<Cache>,\n index: number\n): number => {\n return computeOffset(cache, index);\n};\n\nconst findIndex = (cache: Cache, i: number, distance: number): number => {\n let sum = 0;\n if (distance >= 0) {\n // search forward\n while (i < cache._length - 1) {\n const h = getItemSize(cache, i++);\n if ((sum += h) >= distance) {\n if (sum - h / 2 >= distance) {\n i--;\n }\n break;\n }\n }\n } else {\n // search backward\n while (i > 0) {\n const h = getItemSize(cache, --i);\n if ((sum -= h) <= distance) {\n if (sum + h / 2 < distance) {\n i++;\n }\n break;\n }\n }\n }\n\n return min(max(i, 0), cache._length - 1);\n};\n\nexport const findStartIndexWithOffset = (\n cache: Cache,\n offset: number,\n prevStartIndex: number,\n prevOffset: number\n): number => {\n return findIndex(cache, prevStartIndex, offset - prevOffset);\n};\n\nexport const findEndIndex = findIndex;\n\nexport const hasUnmeasuredItemsInRange = (\n cache: Cache,\n startIndex: number,\n endIndex: number\n): boolean => {\n for (let i = startIndex; i <= endIndex; i++) {\n if (cache._sizes[i] === UNCACHED) {\n return true;\n }\n }\n return false;\n};\n\nexport const resetCache = (\n length: number,\n itemSize: number,\n cache?: Cache\n): Cache => {\n return {\n _defaultItemSize: itemSize,\n _length: length,\n _measuredOffsetIndex: cache\n ? min(cache._measuredOffsetIndex, length - 1)\n : 0,\n _sizes: range(length, (i) => {\n const size = cache && cache._sizes[i];\n if (exists(size)) {\n return size;\n }\n return UNCACHED;\n }),\n _offsets: range(length, (i) => {\n if (i === 0) {\n // first offset must be 0\n return 0;\n }\n const offset = cache && cache._offsets[i];\n if (exists(offset)) {\n return offset;\n }\n return UNCACHED;\n }),\n };\n};\n","import { useEffect, useLayoutEffect } from \"react\";\n\n// https://gist.github.com/gaearon/e7d97cdf38a2907924ea12e4ebdf3c85\nexport const useIsomorphicLayoutEffect =\n typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n","import { useSyncExternalStore as _useSyncExternalStore } from \"use-sync-external-store/shim/index.js\";\n\nexport const useSyncExternalStore = <T>(\n subscibe: (onStoreChange: () => void) => () => void,\n getSnapShot: () => T\n): T => {\n return _useSyncExternalStore(subscibe, getSnapShot, getSnapShot);\n};\n","export const refKey = \"current\";\n","import { useRef } from \"react\";\nimport { refKey } from \"./utils\";\n\nexport const useStatic = <T>(init: () => T): T => {\n const ref = useRef<T>();\n return ref[refKey] || (ref[refKey] = init());\n};\n","import {\n Children,\n memo,\n useRef,\n useMemo,\n CSSProperties,\n ReactElement,\n forwardRef,\n useImperativeHandle,\n ReactNode,\n useEffect,\n RefObject,\n useState,\n} from \"react\";\nimport {\n ACTION_UPDATE_CACHE_LENGTH,\n VirtualStore,\n createVirtualStore,\n} from \"../core/store\";\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\nimport { useSyncExternalStore } from \"./useSyncExternalStore\";\nimport { exists, max, min } from \"../core/utils\";\nimport {\n createScroller,\n Scroller,\n SCROLL_MANUAL,\n SCROLL_UP,\n} from \"../core/scroller\";\nimport { refKey } from \"./utils\";\nimport { useStatic } from \"./useStatic\";\n\nconst INITIAL_END_REACHED_INDEX = -1;\n\ntype ItemProps = {\n _children: ReactNode;\n _scroller: Scroller;\n _store: VirtualStore;\n _index: number;\n _element: \"div\";\n};\n\nconst Item = memo(\n ({\n _children: children,\n _scroller: scroller,\n _store: store,\n _index: index,\n _element: Element,\n }: ItemProps): ReactElement => {\n const ref = useRef<HTMLDivElement>(null);\n\n const offset = useSyncExternalStore(store._subscribe, () =>\n store._getItemOffset(index)\n );\n const hide = useSyncExternalStore(store._subscribe, () =>\n store._isUnmeasuredItem(index)\n );\n\n // The index may be changed if elements are inserted to or removed from the start of props.children\n useIsomorphicLayoutEffect(\n () => scroller._initItem(ref[refKey]!, index),\n [index]\n );\n\n return (\n <Element\n ref={ref}\n style={useMemo<CSSProperties>(() => {\n const isHorizontal = store._isHorizontal();\n const leftOrRightKey = store._isRtl() ? \"right\" : \"left\";\n const style: CSSProperties = {\n margin: 0,\n padding: 0,\n position: \"absolute\",\n [isHorizontal ? \"height\" : \"width\"]: \"100%\",\n [isHorizontal ? \"top\" : leftOrRightKey]: 0,\n [isHorizontal ? leftOrRightKey : \"top\"]: offset,\n // willChange: \"transform\",\n };\n if (isHorizontal) {\n style.display = \"flex\";\n }\n if (hide) {\n style.visibility = \"hidden\";\n }\n return style;\n }, [offset, hide])}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst isInvalidElement = <T extends ReactNode>(\n e: T\n): e is Extract<T, null | undefined | boolean> =>\n !exists(e) || typeof e === \"boolean\";\n\nexport interface CustomWindowComponentProps {\n children: ReactNode;\n style: CSSProperties;\n scrollSize: number;\n horizontal: boolean;\n rtl: boolean;\n}\n\nconst DefaultWindow = forwardRef<any, CustomWindowComponentProps>(\n ({ children, style, scrollSize, horizontal, rtl }, ref): ReactElement => {\n return (\n <div ref={ref} style={style}>\n <div\n style={useMemo<CSSProperties>(() => {\n const width = horizontal ? scrollSize : \"100%\";\n const height = horizontal ? \"100%\" : scrollSize;\n return {\n position: \"absolute\",\n top: 0,\n [rtl ? \"right\" : \"left\"]: 0,\n width,\n height,\n minWidth: width,\n minHeight: height,\n };\n }, [scrollSize])}\n >\n {children}\n </div>\n </div>\n );\n }\n);\n\nexport type CustomWindowComponent = typeof DefaultWindow;\n\nconst Window = ({\n _children: children,\n _ref: ref,\n _store: store,\n _element: Element,\n _style: style,\n}: {\n _children: ReactNode;\n _ref: RefObject<HTMLDivElement>;\n _store: VirtualStore;\n _element: CustomWindowComponent;\n _style: CSSProperties | undefined;\n}) => {\n const scrollSize = useSyncExternalStore(\n store._subscribe,\n store._getScrollSize\n );\n const viewportSize = useSyncExternalStore(\n store._subscribe,\n store._getViewportSize\n );\n const clampedScrollSize =\n scrollSize >= viewportSize ? scrollSize : viewportSize;\n\n const horizontal = store._isHorizontal();\n return (\n <Element\n ref={ref}\n scrollSize={clampedScrollSize}\n horizontal={horizontal}\n rtl={store._isRtl()}\n style={useMemo<CSSProperties>(\n () => ({\n overflow: horizontal ? \"auto hidden\" : \"hidden auto\",\n position: \"relative\",\n contain: \"strict\",\n // transform: \"translate3d(0px, 0px, 0px)\",\n // willChange: \"scroll-position\",\n // backfaceVisibility: \"hidden\",\n width: \"100%\",\n height: \"100%\",\n padding: 0,\n margin: 0,\n ...style,\n }),\n [style]\n )}\n >\n {children}\n </Element>\n );\n};\n\nexport interface CustomItemComponentProps {\n style: CSSProperties;\n children: ReactNode;\n}\n\nexport type CustomItemComponent = React.ForwardRefExoticComponent<\n React.PropsWithoutRef<CustomItemComponentProps> & React.RefAttributes<any>\n>;\n\ntype CustomItemComponentOrElement =\n | keyof JSX.IntrinsicElements\n | CustomItemComponent;\n\n/**\n * Methods of {@link List}.\n */\nexport interface ListHandle {\n /**\n * Get current scrollTop or scrollLeft.\n */\n scrollOffset: number;\n /**\n * Get current scrollHeight or scrollWidth.\n */\n scrollSize: number;\n /**\n * Scroll to the item specified by index.\n * @param index index of item\n */\n scrollToIndex(index: number): void;\n /**\n * Scroll to the item specified by offset.\n * @param offset offset from start\n */\n scrollToOffset(offset: number): void;\n}\n\n/**\n * Props of {@link List}.\n */\nexport interface ListProps {\n /**\n * Elements rendered by this component.\n */\n children: ReactNode;\n /**\n * Item size hint for unmeasured items. It's recommended to specify this prop if item sizes are fixed and known, or much larger than the defaultValue. It will help to reduce scroll jump when items are measured.\n * @defaultValue 40\n */\n itemSize?: number;\n /**\n * Number of items to render above/below the visible bounds of the list. You can increase to avoid showing blank items in fast scrolling.\n * @defaultValue 4\n */\n overscan?: number;\n /**\n * If true, rendered as a horizontally scrollable list. Otherwise rendered as a vertically scrollable list.\n */\n horizontal?: boolean;\n /**\n * You have to set true if you use this component under `direction: rtl` style.\n */\n rtl?: boolean;\n /**\n * Number of items to be the margin from the end of the scroll. See also {@link onEndReached}.\n * @defaultValue 0\n */\n endThreshold?: number;\n /**\n * Inline style prop to override style of scrollable element.\n */\n style?: CSSProperties;\n /**\n * Customized element type for scrollable element.\n * @defaultValue {@link DefaultWindow}\n */\n element?: CustomWindowComponent;\n /**\n * Customized element type for item element.\n * @defaultValue \"div\"\n */\n itemElement?: CustomItemComponentOrElement;\n /**\n * Callback invoked when scrolling reached to the end. The margin from the end is specified by {@link endThreshold}.\n */\n onEndReached?: () => void;\n}\n\n/**\n * Virtualized list component. See {@link ListProps} and {@link ListHandle}.\n */\nexport const List = forwardRef<ListHandle, ListProps>(\n (\n {\n children,\n itemSize: itemSizeProp = 40,\n overscan = 4,\n horizontal: horizontalProp,\n rtl: rtlProp,\n endThreshold = 0,\n style: styleProp,\n element = DefaultWindow,\n itemElement = \"div\",\n onEndReached,\n },\n ref\n ): ReactElement => {\n // Memoize element array\n const elements = useMemo(() => {\n const arr: ReactNode[] = [];\n Children.forEach(children, (e) => {\n if (isInvalidElement(e)) {\n return;\n }\n arr.push(e);\n });\n return arr;\n }, [children]);\n const elementsCount = elements.length;\n\n // https://github.com/facebook/react/issues/25191#issuecomment-1237456448\n const store = useStatic(() =>\n createVirtualStore(\n elementsCount,\n itemSizeProp,\n !!horizontalProp,\n !!rtlProp\n )\n );\n const [startIndex, endIndex] = useSyncExternalStore(\n store._subscribe,\n store._getRange\n );\n const jump = useSyncExternalStore(store._subscribe, store._getJump);\n const rootRef = useRef<HTMLDivElement>(null);\n const onEndReachedCalledIndex = useRef<number>(INITIAL_END_REACHED_INDEX);\n\n const [mountedIndexes, reset] = useState<Set<number>>(new Set<number>());\n const scroller = useStatic(() =>\n createScroller(store, () => {\n reset(new Set());\n })\n );\n\n // The elements length and cached items length are different just after element is added/removed.\n const count = min(elementsCount, store._getItemCount());\n\n // So update cache length. Updating state in render will cause warn so use useEffect for now.\n useIsomorphicLayoutEffect(() => {\n store._update(ACTION_UPDATE_CACHE_LENGTH, elementsCount);\n }, [elementsCount]);\n\n useIsomorphicLayoutEffect(() => scroller._initRoot(rootRef[refKey]!), []);\n\n useIsomorphicLayoutEffect(() => {\n if (!jump.length) return;\n\n // Compensate scroll jump\n const scrollDirection = scroller._getScrollDirection();\n if (scrollDirection === SCROLL_UP) {\n const diff = jump.reduce((acc, [, j]) => acc + j, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else if (scrollDirection === SCROLL_MANUAL) {\n const isStartInView = startIndex === 0;\n const isEndInView = endIndex - (count - 1) === 0;\n const diff = jump.reduce((acc, [index, j]) => {\n if (index < startIndex) {\n // Keep start if scroll position is not stuck to the start\n if (!isStartInView) {\n acc += j;\n }\n } else {\n // Keep end if scroll position is stuck to the end\n if (!isStartInView && isEndInView) {\n acc += j;\n }\n }\n return acc;\n }, 0);\n if (diff) {\n scroller._updateScrollPosition(diff, true);\n }\n } else {\n // NOP\n }\n }, [jump]);\n\n useEffect(() => {\n if (!onEndReached) return;\n\n if (onEndReachedCalledIndex[refKey] > count) {\n // Probably items have been refreshed, so reset index\n onEndReachedCalledIndex[refKey] = INITIAL_END_REACHED_INDEX;\n }\n\n const endMargin = count - 1 - endIndex;\n if (\n endMargin <= endThreshold &&\n onEndReachedCalledIndex[refKey] < count\n ) {\n onEndReachedCalledIndex[refKey] = count;\n onEndReached();\n }\n }, [endIndex]);\n\n useImperativeHandle(\n ref,\n () => {\n return {\n get scrollOffset() {\n return scroller._getScrollPosition();\n },\n get scrollSize() {\n return scroller._getActualScrollSize();\n },\n scrollToIndex(index) {\n index = max(min(index, count - 1), 0);\n\n scroller._scrollTo(index, () => store._getItemOffset(index));\n },\n scrollToOffset(offset) {\n offset = max(offset, 0);\n\n scroller._scrollTo(\n store._getItemIndexForScrollTo(offset),\n () => offset\n );\n },\n };\n },\n [count]\n );\n\n const startIndexWithMargin = max(startIndex - overscan, 0);\n const endIndexWithMargin = min(endIndex + overscan, count - 1);\n const items = useMemo(() => {\n const res: ReactElement[] = [];\n for (let i = startIndexWithMargin; i <= endIndexWithMargin; i++) {\n // https://github.com/sergi/virtual-list/commit/8e7e06dc63568334c1ab809ea83c1be36572e9ed\n mountedIndexes.add(i);\n }\n mountedIndexes.forEach((i) => {\n const e = elements[i];\n res.push(\n <Item\n key={(e as { key?: ReactElement[\"key\"] })?.key || i}\n _scroller={scroller}\n _store={store}\n _index={i}\n _element={itemElement as \"div\"}\n _children={e}\n />\n );\n });\n return res;\n }, [elements, mountedIndexes, startIndexWithMargin, endIndexWithMargin]);\n\n return (\n <Window\n _ref={rootRef}\n _store={store}\n _element={element}\n _style={styleProp}\n _children={items}\n />\n );\n }\n);\n","import {\n findStartIndexWithOffset,\n resetCache,\n getItemSize,\n computeTotalSize,\n findEndIndex,\n computeStartOffset,\n Cache,\n UNCACHED,\n setItemSize,\n hasUnmeasuredItemsInRange,\n} from \"./cache\";\nimport type { Writeable } from \"./types\";\n\nexport type ScrollJump = Readonly<[index: number, sizeDiff: number][]>;\nexport type ItemResize = [index: number, size: number];\ntype ItemsRange = [startIndex: number, endIndex: number];\n\nexport const ACTION_UPDATE_CACHE_LENGTH = 0;\nexport const ACTION_UPDATE_ITEM_SIZES = 1;\nexport const ACTION_UPDATE_VIEWPORT = 2;\nexport const ACTION_HANDLE_SCROLL = 3;\n\ntype Actions =\n | [type: typeof ACTION_UPDATE_CACHE_LENGTH, length: number]\n | [type: typeof ACTION_UPDATE_ITEM_SIZES, entries: ItemResize[]]\n | [\n type: typeof ACTION_UPDATE_VIEWPORT,\n rect: { _width: number; _height: number }\n ]\n | [type: typeof ACTION_HANDLE_SCROLL, offset: number];\n\nexport type VirtualStore = {\n _getRange(): ItemsRange;\n _isUnmeasuredItem(index: number): boolean;\n _hasUnmeasuredItemsInRange(startIndex: number): boolean;\n _getItemOffset(index: number): number;\n _getViewportSize(): number;\n _getScrollSize(): number;\n _getItemCount(): number;\n _getJump(): ScrollJump;\n _isHorizontal(): boolean;\n _isRtl(): boolean;\n _getItemIndexForScrollTo(offset: number): number;\n _waitForScrollDestinationItemsMeasured(): Promise<void>;\n _subscribe(cb: () => void): () => void;\n _update(...action: Actions): void;\n};\n\nexport const createVirtualStore = (\n itemCount: number,\n itemSize: number,\n isHorizontal: boolean,\n isRtl: boolean\n): VirtualStore => {\n let viewportWidth = 0;\n let viewportHeight = 0;\n let scrollOffset = 0;\n let jump: ScrollJump = [];\n let cache = resetCache(itemCount, itemSize);\n let _prevRange: ItemsRange = [0, 0];\n let _scrollToQueue: [() => void, () => void] | undefined;\n\n const subscribers = new Set<() => void>();\n const getViewportSize = (): number =>\n isHorizontal ? viewportWidth : viewportHeight;\n\n return {\n _getRange() {\n const [prevStartIndex, prevEndIndex] = _prevRange;\n const prevOffset = computeStartOffset(\n cache as Writeable<Cache>,\n prevStartIndex\n );\n const start = findStartIndexWithOffset(\n cache,\n scrollOffset,\n prevStartIndex,\n prevOffset\n );\n const end = findEndIndex(cache, start, getViewportSize());\n if (prevStartIndex === start && prevEndIndex === end) {\n return _prevRange;\n }\n return (_prevRange = [start, end]);\n },\n _isUnmeasuredItem(index) {\n return cache._sizes[index] === UNCACHED;\n },\n _hasUnmeasuredItemsInRange(startIndex) {\n return hasUnmeasuredItemsInRange(\n cache,\n startIndex,\n findEndIndex(cache, startIndex, getViewportSize())\n );\n },\n _getItemOffset(index) {\n return computeStartOffset(cache as Writeable<Cache>, index);\n },\n _getViewportSize() {\n return getViewportSize();\n },\n _getScrollSize() {\n return computeTotalSize(cache as Writeable<Cache>);\n },\n _getItemCount() {\n return cache._length;\n },\n _getJump() {\n return jump;\n },\n _isHorizontal() {\n return isHorizontal;\n },\n _isRtl() {\n return isRtl;\n },\n _getItemIndexForScrollTo(offset) {\n return findStartIndexWithOffset(cache, offset, 0, 0);\n },\n _waitForScrollDestinationItemsMeasured() {\n if (_scrollToQueue) {\n // Cancel waiting scrollTo\n _scrollToQueue[1]();\n }\n // The measurement will be done asynchronously and the timing is not predictable so we use promise.\n // For example, ResizeObserver may not fire when window is not visible.\n return new Promise((resolve, reject) => {\n _scrollToQueue = [\n () => {\n // HACK: It should be resolved in the next microtask that is after React's render\n Promise.resolve().then(() => {\n resolve();\n _scrollToQueue = undefined;\n });\n },\n reject,\n ];\n });\n },\n _subscribe(cb) {\n subscribers.add(cb);\n return () => {\n subscribers.delete(cb);\n };\n },\n _update(type, payload) {\n const mutated = ((): boolean => {\n switch (type) {\n case ACTION_UPDATE_CACHE_LENGTH: {\n if (cache._length === payload) return false;\n cache = resetCache(payload, itemSize, cache);\n return true;\n }\n case ACTION_UPDATE_ITEM_SIZES: {\n const updated = payload.filter(\n ([index, size]) => cache._sizes[index] !== size\n );\n // Skip if all items are cached and not updated\n if (!updated.length) {\n return false;\n }\n\n const updatedJump: [index: number, sizeDiff: number][] = [];\n updated.forEach(([index, size]) => {\n updatedJump.push([index, size - getItemSize(cache, index)]);\n setItemSize(cache as Writeable<Cache>, index, size);\n });\n jump = updatedJump;\n return true;\n }\n case ACTION_UPDATE_VIEWPORT: {\n if (\n viewportWidth === payload._width &&\n viewportHeight === payload._height\n ) {\n return false;\n }\n viewportWidth = payload._width;\n viewportHeight = payload._height;\n return true;\n }\n case ACTION_HANDLE_SCROLL: {\n const prevOffset = scrollOffset;\n return (scrollOffset = payload) !== prevOffset;\n }\n }\n })();\n\n if (mutated) {\n subscribers.forEach((cb) => {\n cb();\n });\n if (_scrollToQueue && type === ACTION_UPDATE_ITEM_SIZES) {\n _scrollToQueue[0]();\n }\n }\n },\n };\n};\n","import {\n ACTION_HANDLE_SCROLL,\n ACTION_UPDATE_ITEM_SIZES,\n ACTION_UPDATE_VIEWPORT,\n ItemResize,\n VirtualStore,\n} from \"./store\";\nimport { abs, debounce, throttle, exists } from \"./utils\";\n\nexport const SCROLL_STOP = 0;\nexport const SCROLL_DOWN = 1;\nexport const SCROLL_UP = 2;\nexport const SCROLL_MANUAL = 3;\ntype ScrollDirection =\n | typeof SCROLL_STOP\n | typeof SCROLL_DOWN\n | typeof SCROLL_UP\n | typeof SCROLL_MANUAL;\n\nexport type Scroller = {\n _initRoot: (rootElement: HTMLElement) => () => void;\n _initItem: (itemElement: HTMLElement, index: number) => () => void;\n _getScrollPosition: () => number;\n _getScrollDirection: () => ScrollDirection;\n _getActualScrollSize: () => number;\n _updateScrollPosition: (offset: number, diff?: boolean) => void;\n _scrollTo: (index: number, getCurrentOffset: () => number) => void;\n};\n\nexport const createScroller = (\n store: VirtualStore,\n notifyStop: () => void\n): Scroller => {\n let prevOffset = -1;\n let scrollDirection: ScrollDirection = SCROLL_STOP;\n let resized = false;\n let isNegativeOffset: boolean | undefined;\n let rootElement: HTMLElement | undefined;\n let _ro: ResizeObserver | undefined;\n const isHorizontal = store._isHorizontal();\n const isRtl = store._isRtl();\n const scrollToKey = isHorizontal ? \"scrollLeft\" : \"scrollTop\";\n const mountedIndexes = new WeakMap<Element, number>();\n const getResizeObserver = (): ResizeObserver => {\n // Initialize ResizeObserver lazily for SSR\n return (\n _ro ||\n (_ro = new ResizeObserver((entries) => {\n // https://www.w3.org/TR/resize-observer/#intro\n const resizes: ItemResize[] = [];\n for (const entry of entries) {\n if (entry.target === rootElement) {\n store._update(ACTION_UPDATE_VIEWPORT, {\n _width: entry.contentRect.width,\n _height: entry.contentRect.height,\n });\n } else {\n const index = mountedIndexes.get(entry.target);\n if (exists(index)) {\n resizes.push([\n index,\n entry.contentRect[isHorizontal ? \"width\" : \"height\"],\n ]);\n }\n }\n }\n\n if (resizes.length) {\n store._update(ACTION_UPDATE_ITEM_SIZES, resizes);\n resized = true;\n }\n }))\n );\n };\n const getActualScrollSize = (): number => {\n if (!rootElement) return 0;\n // Use element's scrollHeight/scrollWidth instead of stored scrollSize.\n // This is because stored size may differ from the actual size, for example when a new item is added and not yet measured.\n return store._isHorizontal()\n ? rootElement.scrollWidth\n : rootElement.scrollHeight;\n };\n const updateScrollPosition = (offset: number, diff?: boolean) => {\n if (!rootElement) return;\n if (isRtl) {\n if (!exists(isNegativeOffset)) {\n // Assume offset type in rtl direction.\n // The scroll position is negative in spec however its not in some browsers, for example Chrome earlier than v85.\n // https://github.com/othree/jquery.rtl-scroll-type\n const prev = rootElement[scrollToKey];\n rootElement[scrollToKey] = 1;\n isNegativeOffset = rootElement[scrollToKey] === 0;\n rootElement[scrollToKey] = prev;\n }\n if (isNegativeOffset) {\n offset *= -1;\n }\n }\n if (diff) {\n rootElement[scrollToKey] += offset;\n } else {\n rootElement[scrollToKey] = offset;\n scrollDirection = SCROLL_MANUAL;\n }\n };\n const scrollTo = async (index: number, getCurrentOffset: () => number) => {\n const getOffset = (): number => {\n let offset = getCurrentOffset();\n const scrollSize = getActualScrollSize();\n const viewportSize = store._getViewportSize();\n if (scrollSize - (offset + viewportSize) <= 0) {\n // Adjust if the offset is over the end, to get correct startIndex.\n offset = scrollSize - viewportSize;\n }\n return offset;\n };\n\n if (store._hasUnmeasuredItemsInRange(index)) {\n do {\n // In order to scroll to the correct position, mount the items and measure their sizes before scrolling.\n store._update(ACTION_HANDLE_SCROLL, getOffset());\n try {\n // Wait for the scroll destination items to be measured.\n await store._waitForScrollDestinationItemsMeasured();\n } catch (e) {\n // canceled\n return;\n }\n } while (store._hasUnmeasuredItemsInRange(index));\n\n // Scroll with the updated value\n updateScrollPosition(getOffset());\n } else {\n const offset = getOffset();\n updateScrollPosition(offset);\n // Sync viewport to scroll destination\n store._update(ACTION_HANDLE_SCROLL, offset);\n }\n };\n\n return {\n _initRoot(root) {\n rootElement = root;\n const ro = getResizeObserver();\n\n const syncViewportToScrollPosition = () => {\n let offset = root[scrollToKey];\n if (isRtl) {\n // The scroll position may be negative value in rtl direction.\n // https://github.com/othree/jquery.rtl-scroll-type\n offset = abs(offset);\n }\n if (prevOffset === offset) {\n return;\n }\n // Skip scroll direction detection just after resizing because it may result in the opposite direction.\n // Scroll events are dispatched enough so it's ok to skip some of them.\n if (scrollDirection === SCROLL_STOP || !resized) {\n // Ignore until manual scrolling\n if (scrollDirection !== SCROLL_MANUAL) {\n scrollDirection = prevOffset > offset ? SCROLL_UP : SCROLL_DOWN;\n }\n } else {\n resized = false;\n }\n store._update(ACTION_HANDLE_SCROLL, (prevOffset = offset));\n };\n\n const onScrollStopped = debounce(() => {\n // Check scroll position once just after scrolling stopped\n syncViewportToScrollPosition();\n scrollDirection = SCROLL_STOP;\n notifyStop();\n }, 150);\n\n const onScroll = () => {\n syncViewportToScrollPosition();\n onScrollStopped();\n };\n\n // Infer scroll state also from wheel events\n // Sometimes scroll events do not fire when frame dropped even if the visual have been already scrolled\n const onWheel = throttle((e: WheelEvent) => {\n if (scrollDirection === SCROLL_STOP) {\n // Scroll start should be detected with scroll event\n return;\n }\n if (e.ctrlKey) {\n // Probably a pinch-to-zoom gesture\n return;\n }\n // Get delta before checking deltaMode for firefox behavior\n // https://github.com/w3c/uievents/issues/181#issuecomment-392648065\n // https://bugzilla.mozilla.org/show_bug.cgi?id=1392460#c34\n if (isHorizontal ? e.deltaX : e.deltaY) {\n if (\n prevOffset > 0 &&\n prevOffset < store._getScrollSize() - store._getViewportSize()\n ) {\n onScrollStopped();\n }\n }\n }, 50);\n\n ro.observe(root);\n root.addEventListener(\"scroll\", onScroll);\n root.addEventListener(\"wheel\", onWheel, { passive: true });\n\n return () => {\n ro.disconnect();\n root.removeEventListener(\"scroll\", onScroll);\n root.removeEventListener(\"wheel\", onWheel);\n onScrollStopped._cancel();\n };\n },\n _initItem(el, i) {\n const ro = getResizeObserver();\n mountedIndexes.set(el, i);\n ro.observe(el);\n return () => {\n mountedIndexes.delete(el);\n ro.unobserve(el);\n };\n },\n _getScrollPosition() {\n if (!rootElement) return 0;\n return rootElement[scrollToKey];\n },\n _getScrollDirection() {\n return scrollDirection;\n },\n _getActualScrollSize: getActualScrollSize,\n _updateScrollPosition: updateScrollPosition,\n _scrollTo: scrollTo,\n };\n};\n"],"names":["min","Math","max","abs","now","Date","exists","v","range","length","cb","Array","from","_","i","getItemSize","cache","index","size","_sizes","_defaultItemSize","computeOffset","isTotal","_length","_measuredOffsetIndex","_offsets","top","computeStartOffset","findIndex","distance","sum","h","findStartIndexWithOffset","offset","prevStartIndex","prevOffset","findEndIndex","resetCache","itemSize","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useSyncExternalStore","subscibe","getSnapShot","_useSyncExternalStore","refKey","useStatic","init","ref","useRef","Item","memo","_children","children","_scroller","scroller","_store","store","_index","_element","Element","_subscribe","_getItemOffset","hide","_isUnmeasuredItem","_initItem","_jsx","style","useMemo","isHorizontal","_isHorizontal","leftOrRightKey","_isRtl","margin","padding","position","display","visibility","DefaultWindow","forwardRef","scrollSize","horizontal","rtl","width","height","minWidth","minHeight","Window","_ref","_style","_getScrollSize","viewportSize","_getViewportSize","clampedScrollSize","overflow","contain","List","itemSizeProp","overscan","horizontalProp","rtlProp","endThreshold","styleProp","element","itemElement","onEndReached","elements","arr","Children","forEach","e","isInvalidElement","push","elementsCount","createVirtualStore","itemCount","isRtl","_scrollToQueue","viewportWidth","viewportHeight","scrollOffset","jump","_prevRange","subscribers","Set","getViewportSize","_getRange","prevEndIndex","start","end","_hasUnmeasuredItemsInRange","startIndex","hasUnmeasuredItemsInRange","endIndex","computeTotalSize","_getItemCount","_getJump","_getItemIndexForScrollTo","_waitForScrollDestinationItemsMeasured","Promise","resolve","reject","then","undefined","add","delete","_update","type","payload","updated","filter","updatedJump","setItemSize","_width","_height","rootRef","onEndReachedCalledIndex","mountedIndexes","reset","useState","createScroller","isNegativeOffset","rootElement","_ro","scrollDirection","resized","scrollToKey","WeakMap","getResizeObserver","ResizeObserver","entries","resizes","entry","target","contentRect","get","getActualScrollSize","scrollWidth","scrollHeight","updateScrollPosition","diff","prev","_initRoot","root","ro","syncViewportToScrollPosition","onScrollStopped","debounce","id","cancel","clearTimeout","debouncedFn","setTimeout","_cancel","onScroll","onWheel","throttle","time","args","n","ctrlKey","deltaX","deltaY","fn","observe","addEventListener","passive","disconnect","removeEventListener","el","set","unobserve","_getScrollPosition","_getScrollDirection","_getActualScrollSize","_updateScrollPosition","_scrollTo","async","getCurrentOffset","getOffset","count","reduce","acc","j","isStartInView","isEndInView","useImperativeHandle","scrollToIndex","scrollToOffset","startIndexWithMargin","endIndexWithMargin","items","res","key"],"mappings":"oRAAO,MAAMA,EAAMC,KAAKD,IACXE,EAAMD,KAAKC,IACXC,EAAMF,KAAKE,IACXC,EAAMC,KAAKD,IAEXE,EAAaC,GAAiD,MAALA,EAEzDC,EAAQA,CAAIC,EAAgBC,IACvCC,MAAMC,KAAK,CAAEH,WAAU,CAACI,EAAGC,IAAMJ,EAAGI,KCKzBC,EAAcA,CAACC,EAAcC,KACxC,MAAMC,EAAOF,EAAMG,EAAOF,GAC1B,OAZsB,IAYfC,EAAoBF,EAAMI,EAAmBF,CAAI,EAapDG,EAAgBA,CACpBL,EACAC,EACAK,KAEA,IAAKN,EAAMO,EAAS,OAAO,EAC3B,GAAIP,EAAMQ,GAAwBP,EAChC,OAAIK,EACKN,EAAMS,EAASR,GAAUF,EAAYC,EAAOC,GAE5CD,EAAMS,EAASR,GAI1B,IAAIH,EAAIE,EAAMQ,EACVE,EAAMV,EAAMS,EAASX,GACzB,KAAOA,GAAKG,IACVD,EAAMS,EAASX,GAAKY,EAChBZ,IAAMG,GAAUK,IAGpBI,GAAOX,EAAYC,EAAOF,GAC1BA,IAIF,OADAE,EAAMQ,EAAuBP,EACtBS,CAAG,EAOCC,EAAqBA,CAChCX,EACAC,IAEOI,EAAcL,EAAOC,GAGxBW,EAAYA,CAACZ,EAAcF,EAAWe,KAC1C,IAAIC,EAAM,EACV,GAAID,GAAY,EAEd,KAAOf,EAAIE,EAAMO,EA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,EAAehD,SAASjG,IACtB,MAAMkG,EAAIJ,EAAS9F,GACnB4N,EAAIxH,KACF9C,EAAChB,GAECI,EAAWC,EACXC,EAAQC,EACRC,EAAQ9C,EACR+C,EAAU6C,EACVpD,EAAW0D,IALLA,aAAC,EAADA,EAAqC2H,MAAO7N,GAOrD,IAEI4N,CAAG,GACT,CAAC9H,EAAUmD,EAAgBwE,EAAsBC,IAEpD,OACEpK,EAACqB,EACC,CAAAC,EAAMmE,EACNnG,EAAQC,EACRE,EAAU4C,EACVd,EAAQa,EACRlD,EAAWmL,GACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "virtua",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Simple, fast, small and flexible virtual list component for React.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/index.mjs",
|
|
@@ -58,6 +58,8 @@
|
|
|
58
58
|
"react-cool-virtual": "0.7.0",
|
|
59
59
|
"react-dom": "18.2.0",
|
|
60
60
|
"react-is": "18.2.0",
|
|
61
|
+
"react-merge-refs": "2.0.1",
|
|
62
|
+
"react-select": "5.7.2",
|
|
61
63
|
"react-virtualized": "9.22.3",
|
|
62
64
|
"react-virtuoso": "4.2.0",
|
|
63
65
|
"react-window": "1.8.8",
|