react-anchorlist 0.1.1 → 0.2.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ChatVirtualList.d.ts","sourceRoot":"","sources":["../../src/components/ChatVirtualList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAK9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAA;AAuGxF,eAAO,MAAM,eAAe,EAAuC,CAAC,CAAC,EACnE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;CAAE,KACxE,KAAK,CAAC,YAAY,CAAA"}
1
+ {"version":3,"file":"ChatVirtualList.d.ts","sourceRoot":"","sources":["../../src/components/ChatVirtualList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAA;AAkHxF,eAAO,MAAM,eAAe,EAAuC,CAAC,CAAC,EACnE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAA;CAAE,KACxE,KAAK,CAAC,YAAY,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"VirtualList.d.ts","sourceRoot":"","sources":["../../src/components/VirtualList.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE7D,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAC7B,IAAI,EACJ,WAAW,EACX,cAAc,EACd,iBAAsB,EACtB,QAAY,EACZ,YAAY,EACZ,mBAAyB,EACzB,UAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB,CAAC,CAAC,CAAC,2CAoDrB"}
1
+ {"version":3,"file":"VirtualList.d.ts","sourceRoot":"","sources":["../../src/components/VirtualList.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAE7D,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,CAAC,EAAE,EAC7B,IAAI,EACJ,WAAW,EACX,cAAc,EACd,iBAAsB,EACtB,QAAa,EACb,YAAY,EACZ,mBAAyB,EACzB,UAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,gBAAgB,CAAC,CAAC,CAAC,2CAyDrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useChatVirtualizer.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatVirtualizer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC7C,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAA;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;IACxC,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IACnC,cAAc,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3C,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAA;CACvC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CA6G9B"}
1
+ {"version":3,"file":"useChatVirtualizer.d.ts","sourceRoot":"","sources":["../../src/hooks/useChatVirtualizer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,UAAU,CAAA;AAE3E;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC7C,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAA;IACnD,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;IACxC,gBAAgB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAA;IACnC,cAAc,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,YAAY,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACzC,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;IAC3C,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAA;CACvC,GAAG,wBAAwB,CAAC,CAAC,CAAC,CA8G9B"}
@@ -2,5 +2,5 @@ import { OffsetMap } from '../core/offsetMap';
2
2
  import { ScrollToIndexOpts } from '../types';
3
3
 
4
4
  /** Programmatic scroll to a given item index with alignment support */
5
- export declare function useScrollToIndex(scrollerRef: React.RefObject<HTMLDivElement>, offsetMapRef: React.MutableRefObject<OffsetMap | null>): (index: number, opts?: ScrollToIndexOpts) => void;
5
+ export declare function useScrollToIndex(scrollerRef: React.RefObject<HTMLDivElement>, offsetMapRef: React.MutableRefObject<OffsetMap | null>, innerRef?: React.RefObject<HTMLDivElement>): (index: number, opts?: ScrollToIndexOpts) => void;
6
6
  //# sourceMappingURL=useScrollToIndex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollToIndex.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollToIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,SAAS,GAAG,IAAI,CAAC,GACrD,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CA2BnD"}
1
+ {"version":3,"file":"useScrollToIndex.d.ts","sourceRoot":"","sources":["../../src/hooks/useScrollToIndex.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAEjD,uEAAuE;AACvE,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,EAC5C,YAAY,EAAE,KAAK,CAAC,gBAAgB,CAAC,SAAS,GAAG,IAAI,CAAC,EACtD,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,GACzC,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CA6BnD"}
@@ -1,5 +1,15 @@
1
1
  import { UseVirtualEngineReturn } from '../types';
2
2
 
3
+ /**
4
+ * Core virtual engine — v0.2.1
5
+ *
6
+ * DESIGN:
7
+ * - Scroll/layout state lives in refs, NOT React state
8
+ * - A simple counter triggers re-renders
9
+ * - virtualItems computed DURING render from refs (always fresh, zero lag)
10
+ * - innerRef tracks the virtual container offset (accounts for Header)
11
+ * - overscroll-behavior: contain prevents native bounce
12
+ */
3
13
  export declare function useVirtualEngine<T>(options: {
4
14
  items: T[];
5
15
  getKey: (item: T, index: number) => string | number;
@@ -1 +1 @@
1
- {"version":3,"file":"useVirtualEngine.d.ts","sourceRoot":"","sources":["../../src/hooks/useVirtualEngine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,UAAU,CAAA;AA6BnE,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC3C,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAA;IACnD,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,KAAK,GAAG,QAAQ,CAAA;CACnC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CA2K5B"}
1
+ {"version":3,"file":"useVirtualEngine.d.ts","sourceRoot":"","sources":["../../src/hooks/useVirtualEngine.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,sBAAsB,EAAe,MAAM,UAAU,CAAA;AAEnE;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE;IAC3C,KAAK,EAAE,CAAC,EAAE,CAAA;IACV,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,CAAA;IACnD,iBAAiB,EAAE,MAAM,CAAA;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,gBAAgB,EAAE,KAAK,GAAG,QAAQ,CAAA;CACnC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAqN5B"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),c=require("react");function D(s){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const K=D(c);class q{constructor(e,t){this.defaultSize=t,this.sizes=e>0?Array(e).fill(t):[],this.offsets=e>0?Array(e).fill(0):[],e>0&&this._recalcFrom(0)}_recalcFrom(e){for(let t=e;t<this.sizes.length;t++)this.offsets[t]=t===0?0:(this.offsets[t-1]??0)+(this.sizes[t-1]??this.defaultSize)}getOffset(e){return this.offsets[e]??0}getSize(e){return this.sizes[e]??this.defaultSize}setSize(e,t){return this.sizes[e]===t?!1:(this.sizes[e]=t,this._recalcFrom(e+1),!0)}prepend(e){const t=Array(e).fill(this.defaultSize);this.sizes=[...t,...this.sizes],this.offsets=Array(this.sizes.length).fill(0),this._recalcFrom(0)}append(e){const t=this.sizes.length;for(let r=0;r<e;r++)this.sizes.push(this.defaultSize),this.offsets.push(0);this._recalcFrom(t)}resize(e){const t=this.sizes.length;e>t?this.append(e-t):e<t&&(this.sizes=this.sizes.slice(0,e),this.offsets=this.offsets.slice(0,e))}totalSize(){if(this.sizes.length===0)return 0;const e=this.sizes.length-1;return(this.offsets[e]??0)+(this.sizes[e]??this.defaultSize)}get count(){return this.sizes.length}getOffsets(){return this.offsets}getSizes(){return this.sizes}}class G{constructor(){this.cache=new Map}get(e){return this.cache.get(e)}set(e,t){this.cache.set(e,t)}has(e){return this.cache.has(e)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}applyToOffsetMap(e,t){for(const[r,i]of this.cache){const a=t.get(r);a!==void 0&&e.setSize(a,i)}}}function U(s,e){if(s.length===0)return 0;let t=0,r=s.length-1;for(;t<r;){const i=t+r>>1;(s[i]??0)<e?t=i+1:r=i}return Math.max(0,t>0&&(s[t]??0)>e?t-1:t)}function Z(s,e,t){if(s.length===0)return 0;for(let r=s.length-1;r>=0;r--)if((s[r]??0)<t)return r;return 0}function Y(s){const{firstVisible:e,lastVisible:t,itemCount:r,overscan:i}=s;return r===0?{start:0,end:-1}:{start:Math.max(0,e-i),end:Math.min(r-1,t+i)}}function $(s,e){return c.useCallback((t,r)=>{const i=s.current,a=e.current;if(!i||!a)return;const l=a.getOffset(t),d=a.getSize(t),S=(r==null?void 0:r.align)??"start",y=(r==null?void 0:r.behavior)??"auto",v=(r==null?void 0:r.offset)??0;let E;S==="start"?E=l+v:S==="center"?E=l-i.clientHeight/2+d/2+v:E=l-i.clientHeight+d+v,i.scrollTo({top:Math.max(0,E),behavior:y})},[s,e])}function J(s,e){switch(e.type){case"SCROLL":return{...s,scrollTop:e.scrollTop,totalSize:e.totalSize,renderRange:e.renderRange};case"RESIZE_CONTAINER":return{...s,containerHeight:e.height,totalSize:e.totalSize,renderRange:e.renderRange};case"MEASURE":return{...s,totalSize:e.totalSize};case"ITEMS_CHANGED":return{...s,renderRange:e.renderRange,totalSize:e.totalSize}}}function N(s){const{items:e,getKey:t,estimatedItemSize:r,overscan:i,initialAlignment:a}=s,l=c.useRef(null),d=c.useRef(null),S=c.useRef(new G),y=c.useRef([]),v=c.useRef(!1),E=c.useRef(i);E.current=i,d.current||(d.current=new q(e.length,r));const z=c.useCallback((o,m)=>{const n=d.current;if(!n||n.count===0)return{start:0,end:-1};const u=n.getOffsets(),h=n.getSizes(),T=U(u,o),I=Z(u,h,o+m);return Y({firstVisible:T,lastVisible:I,itemCount:n.count,overscan:E.current})},[]),[b,f]=c.useReducer(J,{renderRange:{start:0,end:Math.min(e.length-1,i*2)},scrollTop:0,containerHeight:0,totalSize:d.current.totalSize()});c.useEffect(()=>{const o=d.current,m=e.map((M,F)=>t(M,F)),n=y.current,u=n.length,h=m.length;h===0?o.resize(0):u===0?o.resize(h):h>u?n.length>0&&m[h-u]===n[0]?o.prepend(h-u):o.resize(h):h<u&&o.resize(h);const T=new Map;m.forEach((M,F)=>T.set(M,F)),S.current.applyToOffsetMap(o,T),y.current=m;const I=l.current,k=(I==null?void 0:I.scrollTop)??0,L=(I==null?void 0:I.clientHeight)??0,j=z(k,L);f({type:"ITEMS_CHANGED",renderRange:j,totalSize:o.totalSize()})},[e,t,z]),c.useEffect(()=>{const o=l.current;if(!o)return;const m=()=>{const n=d.current,u=o.scrollTop,h=o.clientHeight,T=z(u,h);f({type:"SCROLL",scrollTop:u,totalSize:n.totalSize(),renderRange:T})};return o.addEventListener("scroll",m,{passive:!0}),()=>o.removeEventListener("scroll",m)},[z]),c.useEffect(()=>{const o=l.current;if(!o)return;const m=new ResizeObserver(([n])=>{if(!n)return;const u=n.contentRect.height,h=d.current,T=o.scrollTop,I=z(T,u);f({type:"RESIZE_CONTAINER",height:u,totalSize:h.totalSize(),renderRange:I})});return m.observe(o),()=>m.disconnect()},[z]),c.useEffect(()=>{if(v.current||e.length===0)return;const o=l.current;o&&(a==="bottom"&&(o.scrollTop=o.scrollHeight),v.current=!0)},[a,e.length]);const O=c.useCallback((o,m)=>{const n=d.current;if(!n)return;S.current.set(o,m);const u=y.current.indexOf(o);if(u===-1)return;n.setSize(u,m)&&f({type:"MEASURE",totalSize:n.totalSize()})},[]),P=c.useCallback((o,m="auto")=>{var n;(n=l.current)==null||n.scrollTo({top:o,behavior:m})},[]),p=$(l,d),R=d.current,{start:A,end:x}=b.renderRange,w=[];if(R&&x>=A)for(let o=A;o<=x&&o<e.length;o++)w.push({key:y.current[o]??t(e[o],o),index:o,start:R.getOffset(o),size:R.getSize(o),data:e[o]});const g=l.current,C=g?g.scrollHeight-g.scrollTop-g.clientHeight:1/0;return{scrollerRef:l,virtualItems:w,totalSize:b.totalSize,measureItem:O,scrollToIndex:p,scrollToOffset:P,isAtTop:b.scrollTop<=0,isAtBottom:C<=0,scrollTop:b.scrollTop}}function Q(s,e){const t=c.useRef(0),r=c.useRef(0),i=c.useRef(!1),a=c.useCallback(()=>{const l=s.current;l&&(t.current=l.scrollTop,r.current=l.scrollHeight,i.current=!0)},[s]);return c.useLayoutEffect(()=>{if(!i.current)return;const l=s.current;if(!l)return;const d=l.scrollHeight-r.current;d>0&&(l.scrollTop=t.current+d),i.current=!1},[e,s]),{prepareAnchor:a}}function W(s,e){const[t,r]=c.useState(!0),i=c.useRef(null);return c.useEffect(()=>{const a=s.current;if(!a)return;const l=()=>{const S=a.scrollHeight-a.scrollTop-a.clientHeight;r(S<=e)},d=()=>{i.current!==null&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(l)};return a.addEventListener("scroll",d,{passive:!0}),l(),()=>{a.removeEventListener("scroll",d),i.current!==null&&cancelAnimationFrame(i.current)}},[s,e]),t}function X(s){const{itemCount:e,isAtBottom:t,scrollToIndex:r,mode:i}=s,a=c.useRef(e);c.useLayoutEffect(()=>{i&&(e>a.current&&t&&e>0&&r(e-1,{align:"end",behavior:i==="smooth"?"smooth":"auto"}),a.current=e)},[e,t,r,i])}function V(s){const{items:e,getKey:t,estimatedItemSize:r=80,overscan:i=5,atBottomThreshold:a=200,followOutput:l="auto",initialAlignment:d="bottom",onStartReached:S,onEndReached:y,startReachedThreshold:v=300,endReachedThreshold:E=300,scrollToMessageKey:z,onScrollToMessageComplete:b}=s,f=N({items:e,getKey:t,estimatedItemSize:r,overscan:i,initialAlignment:d}),O=W(f.scrollerRef,a),{prepareAnchor:P}=Q(f.scrollerRef,e.length);X({itemCount:e.length,isAtBottom:O,scrollToIndex:f.scrollToIndex,mode:l??!1});const p=c.useRef(!1);c.useEffect(()=>{const g=f.scrollerRef.current;if(!g||!S)return;const C=()=>{g.scrollTop<=v&&!p.current&&(p.current=!0,Promise.resolve(S()).finally(()=>{p.current=!1}))};return g.addEventListener("scroll",C,{passive:!0}),()=>g.removeEventListener("scroll",C)},[f.scrollerRef,S,v]);const R=c.useRef(!1);c.useEffect(()=>{const g=f.scrollerRef.current;if(!g||!y)return;const C=()=>{g.scrollHeight-g.scrollTop-g.clientHeight<=E&&!R.current&&(R.current=!0,Promise.resolve(y()).finally(()=>{R.current=!1}))};return g.addEventListener("scroll",C,{passive:!0}),()=>g.removeEventListener("scroll",C)},[f.scrollerRef,y,E]);const A=c.useRef(null);c.useEffect(()=>{if(!z||A.current===z)return;const g=e.findIndex((C,o)=>t(C,o)===z);g!==-1&&(A.current=z,f.scrollToIndex(g,{align:"center",behavior:"smooth"}),b==null||b())},[z,e,t,f,b]);const x=c.useCallback((g="auto")=>{e.length!==0&&f.scrollToIndex(e.length-1,{align:"end",behavior:g})},[e.length,f]),w=c.useCallback((g,C)=>{const o=e.findIndex((m,n)=>t(m,n)===g);o!==-1&&f.scrollToIndex(o,C)},[e,t,f]);return{scrollerRef:f.scrollerRef,virtualItems:f.virtualItems,totalSize:f.totalSize,measureItem:f.measureItem,scrollToIndex:f.scrollToIndex,scrollToBottom:x,scrollToKey:w,isAtBottom:O,prepareAnchor:P}}function B({scrollerRef:s,totalSize:e,children:t,className:r,style:i}){return H.jsx("div",{ref:s,className:r,style:{overflow:"auto",height:"100%",position:"relative",...i},children:H.jsx("div",{style:{height:e,position:"relative",width:"100%"},children:t})})}function _({virtualItem:s,measureItem:e,children:t}){const r=c.useRef(null);return c.useEffect(()=>{const i=r.current;if(!i)return;const a=new ResizeObserver(([l])=>{l&&e(s.key,l.contentRect.height)});return a.observe(i),()=>a.disconnect()},[s.key,e]),H.jsx("div",{ref:r,style:{position:"absolute",top:0,transform:`translateY(${s.start}px)`,width:"100%",minHeight:s.size},children:t})}function ee(s,e){const{data:t,itemContent:r,computeItemKey:i,estimatedItemSize:a=80,overscan:l=5,followOutput:d="auto",atBottomThreshold:S=200,initialAlignment:y="bottom",onStartReached:v,onEndReached:E,startReachedThreshold:z=300,endReachedThreshold:b=300,scrollToMessageKey:f,onScrollToMessageComplete:O,onAtBottomChange:P,components:p={},className:R,style:A}=s,{scrollerRef:x,virtualItems:w,totalSize:g,measureItem:C,scrollToIndex:o,scrollToBottom:m,scrollToKey:n,isAtBottom:u,prepareAnchor:h}=V({items:t,getKey:(j,M)=>i(M,j),estimatedItemSize:a,overscan:l,atBottomThreshold:S,followOutput:d,initialAlignment:y,onStartReached:v,onEndReached:E,startReachedThreshold:z,endReachedThreshold:b,scrollToMessageKey:f,onScrollToMessageComplete:O}),T=K.useRef(u);K.useEffect(()=>{T.current!==u&&(T.current=u,P==null||P(u))},[u,P]),c.useImperativeHandle(e,()=>({scrollToBottom:m,scrollToIndex:o,scrollToKey:n,getScrollTop:()=>{var j;return((j=x.current)==null?void 0:j.scrollTop)??0},isAtBottom:()=>u,prepareAnchor:h}),[m,o,n,x,u,h]);const{Header:I,Footer:k,EmptyPlaceholder:L}=p;return t.length===0&&L?H.jsx(L,{}):H.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[I&&H.jsx(I,{}),H.jsx(B,{scrollerRef:x,totalSize:g,className:R,style:{flex:1,minHeight:0,...A},children:w.map(j=>H.jsx(_,{virtualItem:j,measureItem:C,children:r(j.index,j.data)},j.key))}),k&&H.jsx(k,{})]})}const te=c.forwardRef(ee);function re({data:s,itemContent:e,computeItemKey:t,estimatedItemSize:r=80,overscan:i=5,onEndReached:a,endReachedThreshold:l=300,components:d={},className:S,style:y}){const{scrollerRef:v,virtualItems:E,totalSize:z,measureItem:b}=N({items:s,getKey:(p,R)=>t(R,p),estimatedItemSize:r,overscan:i,initialAlignment:"top"});K.useEffect(()=>{const p=v.current;if(!p||!a)return;let R=!1;const A=()=>{p.scrollHeight-p.scrollTop-p.clientHeight<=l&&!R&&(R=!0,Promise.resolve(a()).finally(()=>{R=!1}))};return p.addEventListener("scroll",A,{passive:!0}),()=>p.removeEventListener("scroll",A)},[v,a,l]);const{Header:f,Footer:O,EmptyPlaceholder:P}=d;return s.length===0&&P?H.jsx(P,{}):H.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[f&&H.jsx(f,{}),H.jsx(B,{scrollerRef:v,totalSize:z,className:S,style:{flex:1,minHeight:0,...y},children:E.map(p=>H.jsx(_,{virtualItem:p,measureItem:b,children:e(p.index,p.data)},p.key))}),O&&H.jsx(O,{})]})}function se(s){const{fetcher:e,initialPage:t=1,direction:r="append",getKey:i,onPageLoaded:a,onError:l}=s,[d,S]=c.useState([]),[y,v]=c.useState(t),[E,z]=c.useState(!0),[b,f]=c.useState(!1),[O,P]=c.useState(!1),[p,R]=c.useState(!1),A=c.useRef(new Set),x=c.useRef(!1),w=c.useCallback(n=>i?n.filter(u=>{const h=i(u);return A.current.has(h)?!1:(A.current.add(h),!0)}):n,[i]),g=c.useCallback(async()=>{if(!(x.current||!E)){x.current=!0,R(!0);try{const n=y+1,u=await e(n),h=w(u.data);S(T=>r==="prepend"?[...h,...T]:[...T,...h]),v(n),z(u.hasNextPage),f(u.hasPrevPage),a==null||a(n,h)}catch(n){l==null||l(n instanceof Error?n:new Error(String(n)))}finally{R(!1),x.current=!1}}},[y,E,e,w,r,a,l]),C=c.useCallback(async()=>{if(!(x.current||!b)){x.current=!0,R(!0);try{const n=y-1,u=await e(n),h=w(u.data);S(T=>[...h,...T]),v(n),f(u.hasPrevPage),z(u.hasNextPage),a==null||a(n,h)}catch(n){l==null||l(n instanceof Error?n:new Error(String(n)))}finally{R(!1),x.current=!1}}},[y,b,e,w,a,l]),o=c.useCallback(async()=>{if(!x.current){x.current=!0,P(!0);try{const n=await e(t),u=n.data;if(i){const h=new Set(u.map(i));u.forEach(T=>A.current.add(i(T))),S(T=>{const I=T.filter(k=>!h.has(i(k)));return r==="prepend"?[...u,...I]:[...I,...u]})}else S(u);v(t),z(n.hasNextPage),f(n.hasPrevPage),a==null||a(t,u)}catch(n){l==null||l(n instanceof Error?n:new Error(String(n)))}finally{P(!1),x.current=!1}}},[e,t,i,r,a,l]),m=c.useCallback(()=>{S([]),v(t),z(!0),f(!1),P(!1),R(!1),A.current.clear(),x.current=!1},[t]);return{items:d,loadNextPage:g,loadPrevPage:C,hasNextPage:E,hasPrevPage:b,loading:O,loadingMore:p,refresh:o,reset:m,currentPage:y}}exports.ChatVirtualList=te;exports.VirtualList=re;exports.useChatVirtualizer=V;exports.usePagination=se;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),r=require("react");function $(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const _=$(r);class G{constructor(e,t){this.defaultSize=t,this.sizes=e>0?Array(e).fill(t):[],this.offsets=e>0?Array(e).fill(0):[],e>0&&this._recalcFrom(0)}_recalcFrom(e){for(let t=e;t<this.sizes.length;t++)this.offsets[t]=t===0?0:(this.offsets[t-1]??0)+(this.sizes[t-1]??this.defaultSize)}getOffset(e){return this.offsets[e]??0}getSize(e){return this.sizes[e]??this.defaultSize}setSize(e,t){return this.sizes[e]===t?!1:(this.sizes[e]=t,this._recalcFrom(e+1),!0)}prepend(e){const t=Array(e).fill(this.defaultSize);this.sizes=[...t,...this.sizes],this.offsets=Array(this.sizes.length).fill(0),this._recalcFrom(0)}append(e){const t=this.sizes.length;for(let i=0;i<e;i++)this.sizes.push(this.defaultSize),this.offsets.push(0);this._recalcFrom(t)}resize(e){const t=this.sizes.length;e>t?this.append(e-t):e<t&&(this.sizes=this.sizes.slice(0,e),this.offsets=this.offsets.slice(0,e))}totalSize(){if(this.sizes.length===0)return 0;const e=this.sizes.length-1;return(this.offsets[e]??0)+(this.sizes[e]??this.defaultSize)}get count(){return this.sizes.length}getOffsets(){return this.offsets}getSizes(){return this.sizes}}class J{constructor(){this.cache=new Map}get(e){return this.cache.get(e)}set(e,t){this.cache.set(e,t)}has(e){return this.cache.has(e)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}applyToOffsetMap(e,t){for(const[i,s]of this.cache){const c=t.get(i);c!==void 0&&e.setSize(c,s)}}}function Q(n,e){if(n.length===0)return 0;let t=0,i=n.length-1;for(;t<i;){const s=t+i>>1;(n[s]??0)<e?t=s+1:i=s}return Math.max(0,t>0&&(n[t]??0)>e?t-1:t)}function U(n,e,t){if(n.length===0)return 0;for(let i=n.length-1;i>=0;i--)if((n[i]??0)<t)return i;return 0}function W(n){const{firstVisible:e,lastVisible:t,itemCount:i,overscan:s}=n;return i===0?{start:0,end:-1}:{start:Math.max(0,e-s),end:Math.min(i-1,t+s)}}function X(n,e,t){return r.useCallback((i,s)=>{var a;const c=n.current,o=e.current;if(!c||!o)return;const S=((a=t==null?void 0:t.current)==null?void 0:a.offsetTop)??0,d=o.getOffset(i),x=o.getSize(i),p=(s==null?void 0:s.align)??"start",E=(s==null?void 0:s.behavior)??"auto",v=(s==null?void 0:s.offset)??0;let z;p==="start"?z=S+d+v:p==="center"?z=S+d-c.clientHeight/2+x/2+v:z=S+d-c.clientHeight+x+v,c.scrollTo({top:Math.max(0,z),behavior:E})},[n,e,t])}function q(n){var B;const{items:e,getKey:t,estimatedItemSize:i,overscan:s,initialAlignment:c}=n,o=r.useRef(null),S=r.useRef(null),d=r.useRef(null),x=r.useRef(new J),p=r.useRef([]),E=r.useRef(!1),v=r.useRef(0),z=r.useRef(0),a=r.useRef(null),[,j]=r.useState(0),b=r.useCallback(()=>j(l=>l+1),[]);d.current||(d.current=new G(e.length,i));const H=r.useRef(e.length);if(e.length!==H.current||e.some((l,h)=>{const m=t(l,h);return p.current[h]!==m})){const l=d.current,h=e.map((V,N)=>t(V,N)),m=p.current,M=m.length,O=h.length;O===0?l.resize(0):M===0?l.resize(O):O>M?m.length>0&&h[O-M]===m[0]?l.prepend(O-M):l.resize(O):O<M&&l.resize(O);const w=new Map;h.forEach((V,N)=>w.set(V,N)),x.current.applyToOffsetMap(l,w),p.current=h,H.current=e.length}r.useEffect(()=>{const l=o.current;if(!l)return;const h=()=>{a.current===null&&(a.current=requestAnimationFrame(()=>{a.current=null,v.current=l.scrollTop,z.current=l.clientHeight,b()}))};return l.addEventListener("scroll",h,{passive:!0}),()=>{l.removeEventListener("scroll",h),a.current!==null&&(cancelAnimationFrame(a.current),a.current=null)}},[b]),r.useEffect(()=>{const l=o.current;if(!l)return;z.current=l.clientHeight,v.current=l.scrollTop;const h=new ResizeObserver(([m])=>{m&&(z.current=m.contentRect.height,b())});return h.observe(l),()=>h.disconnect()},[b]),r.useLayoutEffect(()=>{if(E.current||e.length===0)return;const l=o.current;l&&(c==="bottom"&&(l.scrollTop=l.scrollHeight,v.current=l.scrollTop),E.current=!0)},[c,e.length]),r.useEffect(()=>{e.length===0&&(E.current=!1)},[e.length]);const P=r.useCallback((l,h)=>{const m=d.current;if(!m||x.current.get(l)===h)return;x.current.set(l,h);const O=p.current.indexOf(l);if(O===-1)return;m.setSize(O,h)&&b()},[b]),R=r.useCallback((l,h="auto")=>{var m;(m=o.current)==null||m.scrollTo({top:l,behavior:h})},[]),F=X(o,d,S),u=d.current,C=u?u.totalSize():0,I=o.current,L=(I==null?void 0:I.scrollTop)??v.current,f=(I==null?void 0:I.clientHeight)??z.current,T=((B=S.current)==null?void 0:B.offsetTop)??0,y=Math.max(0,L-T);let A=[];if(u&&u.count>0&&f>0){const l=u.getOffsets(),h=u.getSizes(),m=Q(l,y),M=U(l,h,y+f),O=W({firstVisible:m,lastVisible:M,itemCount:u.count,overscan:s});for(let w=O.start;w<=O.end&&w<e.length;w++)A.push({key:p.current[w]??t(e[w],w),index:w,start:u.getOffset(w),size:u.getSize(w),data:e[w]})}else if(u&&u.count>0){const l=Math.min(e.length-1,s*2);for(let h=0;h<=l;h++)A.push({key:p.current[h]??t(e[h],h),index:h,start:u.getOffset(h),size:u.getSize(h),data:e[h]})}const K=I?I.scrollHeight-I.scrollTop-I.clientHeight:1/0;return{scrollerRef:o,innerRef:S,virtualItems:A,totalSize:C,measureItem:P,scrollToIndex:F,scrollToOffset:R,isAtTop:L<=1,isAtBottom:K<=1,scrollTop:L}}function Z(n,e){const t=r.useRef(0),i=r.useRef(0),s=r.useRef(!1),c=r.useCallback(()=>{const o=n.current;o&&(t.current=o.scrollTop,i.current=o.scrollHeight,s.current=!0)},[n]);return r.useLayoutEffect(()=>{if(!s.current)return;const o=n.current;if(!o)return;const S=o.scrollHeight-i.current;S>0&&(o.scrollTop=t.current+S),s.current=!1},[e,n]),{prepareAnchor:c}}function ee(n,e){const[t,i]=r.useState(!0),s=r.useRef(null);return r.useEffect(()=>{const c=n.current;if(!c)return;const o=()=>{const d=c.scrollHeight-c.scrollTop-c.clientHeight;i(d<=e)},S=()=>{s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(o)};return c.addEventListener("scroll",S,{passive:!0}),o(),()=>{c.removeEventListener("scroll",S),s.current!==null&&cancelAnimationFrame(s.current)}},[n,e]),t}function te(n){const{itemCount:e,isAtBottom:t,scrollToIndex:i,mode:s}=n,c=r.useRef(e);r.useLayoutEffect(()=>{s&&(e>c.current&&t&&e>0&&i(e-1,{align:"end",behavior:s==="smooth"?"smooth":"auto"}),c.current=e)},[e,t,i,s])}function D(n){const{items:e,getKey:t,estimatedItemSize:i=80,overscan:s=20,atBottomThreshold:c=200,followOutput:o="auto",initialAlignment:S="bottom",onStartReached:d,onEndReached:x,startReachedThreshold:p=300,endReachedThreshold:E=300,scrollToMessageKey:v,onScrollToMessageComplete:z}=n,a=q({items:e,getKey:t,estimatedItemSize:i,overscan:s,initialAlignment:S}),j=ee(a.scrollerRef,c),{prepareAnchor:b}=Z(a.scrollerRef,e.length);te({itemCount:e.length,isAtBottom:j,scrollToIndex:a.scrollToIndex,mode:o??!1});const H=r.useRef(!1);r.useEffect(()=>{const u=a.scrollerRef.current;if(!u||!d)return;const C=()=>{u.scrollTop<=p&&!H.current&&(H.current=!0,Promise.resolve(d()).finally(()=>{H.current=!1}))};return u.addEventListener("scroll",C,{passive:!0}),()=>u.removeEventListener("scroll",C)},[a.scrollerRef,d,p]);const g=r.useRef(!1);r.useEffect(()=>{const u=a.scrollerRef.current;if(!u||!x)return;const C=()=>{u.scrollHeight-u.scrollTop-u.clientHeight<=E&&!g.current&&(g.current=!0,Promise.resolve(x()).finally(()=>{g.current=!1}))};return u.addEventListener("scroll",C,{passive:!0}),()=>u.removeEventListener("scroll",C)},[a.scrollerRef,x,E]);const P=r.useRef(null);r.useEffect(()=>{if(!v||P.current===v)return;const u=e.findIndex((C,I)=>t(C,I)===v);u!==-1&&(P.current=v,a.scrollToIndex(u,{align:"center",behavior:"smooth"}),z==null||z())},[v,e,t,a,z]);const R=r.useCallback((u="auto")=>{e.length!==0&&a.scrollToIndex(e.length-1,{align:"end",behavior:u})},[e.length,a]),F=r.useCallback((u,C)=>{const I=e.findIndex((L,f)=>t(L,f)===u);I!==-1&&a.scrollToIndex(I,C)},[e,t,a]);return{scrollerRef:a.scrollerRef,innerRef:a.innerRef,virtualItems:a.virtualItems,totalSize:a.totalSize,measureItem:a.measureItem,scrollToIndex:a.scrollToIndex,scrollToBottom:R,scrollToKey:F,isAtBottom:j,prepareAnchor:b}}function Y({virtualItem:n,measureItem:e,children:t}){const i=r.useRef(null);return r.useEffect(()=>{const s=i.current;if(!s)return;const c=new ResizeObserver(([o])=>{o&&e(n.key,o.contentRect.height)});return c.observe(s),()=>c.disconnect()},[n.key,e]),k.jsx("div",{ref:i,style:{position:"absolute",top:0,transform:`translateY(${n.start}px)`,width:"100%",minHeight:n.size},children:t})}function re(n,e){const{data:t,itemContent:i,computeItemKey:s,estimatedItemSize:c=80,overscan:o=20,followOutput:S="auto",atBottomThreshold:d=200,initialAlignment:x="bottom",onStartReached:p,onEndReached:E,startReachedThreshold:v=300,endReachedThreshold:z=300,scrollToMessageKey:a,onScrollToMessageComplete:j,onAtBottomChange:b,components:H={},className:g,style:P}=n,{scrollerRef:R,innerRef:F,virtualItems:u,totalSize:C,measureItem:I,scrollToIndex:L,scrollToBottom:f,scrollToKey:T,isAtBottom:y,prepareAnchor:A}=D({items:t,getKey:(m,M)=>s(M,m),estimatedItemSize:c,overscan:o,atBottomThreshold:d,followOutput:S,initialAlignment:x,onStartReached:p,onEndReached:E,startReachedThreshold:v,endReachedThreshold:z,scrollToMessageKey:a,onScrollToMessageComplete:j}),K=_.useRef(y);_.useEffect(()=>{K.current!==y&&(K.current=y,b==null||b(y))},[y,b]),r.useImperativeHandle(e,()=>({scrollToBottom:f,scrollToIndex:L,scrollToKey:T,getScrollTop:()=>{var m;return((m=R.current)==null?void 0:m.scrollTop)??0},isAtBottom:()=>y,prepareAnchor:A}),[f,L,T,R,y,A]);const{Header:B,Footer:l,EmptyPlaceholder:h}=H;return t.length===0&&h?k.jsx(h,{}):k.jsxs("div",{ref:R,className:g,style:{overflow:"auto",height:"100%",position:"relative",overscrollBehaviorY:"contain",...P},children:[B&&k.jsx(B,{}),k.jsx("div",{ref:F,style:{height:C,position:"relative",width:"100%"},children:u.map(m=>k.jsx(Y,{virtualItem:m,measureItem:I,children:i(m.index,m.data)},m.key))}),l&&k.jsx(l,{})]})}const se=r.forwardRef(re);function ne({data:n,itemContent:e,computeItemKey:t,estimatedItemSize:i=60,overscan:s=20,onEndReached:c,endReachedThreshold:o=300,components:S={},className:d,style:x}){const{scrollerRef:p,innerRef:E,virtualItems:v,totalSize:z,measureItem:a}=q({items:n,getKey:(g,P)=>t(P,g),estimatedItemSize:i,overscan:s,initialAlignment:"top"});_.useEffect(()=>{const g=p.current;if(!g||!c)return;let P=!1;const R=()=>{g.scrollHeight-g.scrollTop-g.clientHeight<=o&&!P&&(P=!0,Promise.resolve(c()).finally(()=>{P=!1}))};return g.addEventListener("scroll",R,{passive:!0}),()=>g.removeEventListener("scroll",R)},[p,c,o]);const{Header:j,Footer:b,EmptyPlaceholder:H}=S;return n.length===0&&H?k.jsx(H,{}):k.jsxs("div",{ref:p,className:d,style:{overflow:"auto",height:"100%",position:"relative",overscrollBehaviorY:"contain",...x},children:[j&&k.jsx(j,{}),k.jsx("div",{ref:E,style:{height:z,position:"relative",width:"100%"},children:v.map(g=>k.jsx(Y,{virtualItem:g,measureItem:a,children:e(g.index,g.data)},g.key))}),b&&k.jsx(b,{})]})}function ie(n){const{fetcher:e,initialPage:t=1,direction:i="append",getKey:s,onPageLoaded:c,onError:o}=n,[S,d]=r.useState([]),[x,p]=r.useState(t),[E,v]=r.useState(!0),[z,a]=r.useState(!1),[j,b]=r.useState(!1),[H,g]=r.useState(!1),P=r.useRef(new Set),R=r.useRef(!1),F=r.useCallback(f=>s?f.filter(T=>{const y=s(T);return P.current.has(y)?!1:(P.current.add(y),!0)}):f,[s]),u=r.useCallback(async()=>{if(!(R.current||!E)){R.current=!0,g(!0);try{const f=x+1,T=await e(f),y=F(T.data);d(A=>i==="prepend"?[...y,...A]:[...A,...y]),p(f),v(T.hasNextPage),a(T.hasPrevPage),c==null||c(f,y)}catch(f){o==null||o(f instanceof Error?f:new Error(String(f)))}finally{g(!1),R.current=!1}}},[x,E,e,F,i,c,o]),C=r.useCallback(async()=>{if(!(R.current||!z)){R.current=!0,g(!0);try{const f=x-1,T=await e(f),y=F(T.data);d(A=>[...y,...A]),p(f),a(T.hasPrevPage),v(T.hasNextPage),c==null||c(f,y)}catch(f){o==null||o(f instanceof Error?f:new Error(String(f)))}finally{g(!1),R.current=!1}}},[x,z,e,F,c,o]),I=r.useCallback(async()=>{if(!R.current){R.current=!0,b(!0);try{const f=await e(t),T=f.data;if(s){const y=new Set(T.map(s));T.forEach(A=>P.current.add(s(A))),d(A=>{const K=A.filter(B=>!y.has(s(B)));return i==="prepend"?[...T,...K]:[...K,...T]})}else d(T);p(t),v(f.hasNextPage),a(f.hasPrevPage),c==null||c(t,T)}catch(f){o==null||o(f instanceof Error?f:new Error(String(f)))}finally{b(!1),R.current=!1}}},[e,t,s,i,c,o]),L=r.useCallback(()=>{d([]),p(t),v(!0),a(!1),b(!1),g(!1),P.current.clear(),R.current=!1},[t]);return{items:S,loadNextPage:u,loadPrevPage:C,hasNextPage:E,hasPrevPage:z,loading:j,loadingMore:H,refresh:I,reset:L,currentPage:x}}exports.ChatVirtualList=se;exports.VirtualList=ne;exports.useChatVirtualizer=D;exports.usePagination=ie;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { jsx as b, jsxs as D } from "react/jsx-runtime";
2
- import * as k from "react";
3
- import { useCallback as O, useRef as E, useReducer as q, useEffect as K, useLayoutEffect as j, useState as L, forwardRef as Y, useImperativeHandle as $ } from "react";
4
- class J {
1
+ import { jsx as C, jsxs as G } from "react/jsx-runtime";
2
+ import * as D from "react";
3
+ import { useCallback as K, useRef as x, useState as k, useEffect as N, useLayoutEffect as $, forwardRef as U, useImperativeHandle as W } from "react";
4
+ class X {
5
5
  constructor(e, t) {
6
6
  this.defaultSize = t, this.sizes = e > 0 ? Array(e).fill(t) : [], this.offsets = e > 0 ? Array(e).fill(0) : [], e > 0 && this._recalcFrom(0);
7
7
  }
@@ -25,7 +25,7 @@ class J {
25
25
  }
26
26
  append(e) {
27
27
  const t = this.sizes.length;
28
- for (let n = 0; n < e; n++)
28
+ for (let i = 0; i < e; i++)
29
29
  this.sizes.push(this.defaultSize), this.offsets.push(0);
30
30
  this._recalcFrom(t);
31
31
  }
@@ -48,7 +48,7 @@ class J {
48
48
  return this.sizes;
49
49
  }
50
50
  }
51
- class Q {
51
+ class Z {
52
52
  constructor() {
53
53
  this.cache = /* @__PURE__ */ new Map();
54
54
  }
@@ -69,294 +69,282 @@ class Q {
69
69
  }
70
70
  /** Re-applies all cached sizes to the OffsetMap using a key→index map */
71
71
  applyToOffsetMap(e, t) {
72
- for (const [n, s] of this.cache) {
73
- const l = t.get(n);
74
- l !== void 0 && e.setSize(l, s);
72
+ for (const [i, r] of this.cache) {
73
+ const n = t.get(i);
74
+ n !== void 0 && e.setSize(n, r);
75
75
  }
76
76
  }
77
77
  }
78
- function W(o, e) {
78
+ function ee(o, e) {
79
79
  if (o.length === 0) return 0;
80
- let t = 0, n = o.length - 1;
81
- for (; t < n; ) {
82
- const s = t + n >> 1;
83
- (o[s] ?? 0) < e ? t = s + 1 : n = s;
80
+ let t = 0, i = o.length - 1;
81
+ for (; t < i; ) {
82
+ const r = t + i >> 1;
83
+ (o[r] ?? 0) < e ? t = r + 1 : i = r;
84
84
  }
85
85
  return Math.max(0, t > 0 && (o[t] ?? 0) > e ? t - 1 : t);
86
86
  }
87
- function X(o, e, t) {
87
+ function te(o, e, t) {
88
88
  if (o.length === 0) return 0;
89
- for (let n = o.length - 1; n >= 0; n--)
90
- if ((o[n] ?? 0) < t) return n;
89
+ for (let i = o.length - 1; i >= 0; i--)
90
+ if ((o[i] ?? 0) < t) return i;
91
91
  return 0;
92
92
  }
93
- function ee(o) {
94
- const { firstVisible: e, lastVisible: t, itemCount: n, overscan: s } = o;
95
- return n === 0 ? { start: 0, end: -1 } : {
96
- start: Math.max(0, e - s),
97
- end: Math.min(n - 1, t + s)
93
+ function re(o) {
94
+ const { firstVisible: e, lastVisible: t, itemCount: i, overscan: r } = o;
95
+ return i === 0 ? { start: 0, end: -1 } : {
96
+ start: Math.max(0, e - r),
97
+ end: Math.min(i - 1, t + r)
98
98
  };
99
99
  }
100
- function te(o, e) {
101
- return O(
102
- (t, n) => {
103
- const s = o.current, l = e.current;
104
- if (!s || !l) return;
105
- const c = l.getOffset(t), h = l.getSize(t), p = (n == null ? void 0 : n.align) ?? "start", v = (n == null ? void 0 : n.behavior) ?? "auto", y = (n == null ? void 0 : n.offset) ?? 0;
106
- let x;
107
- p === "start" ? x = c + y : p === "center" ? x = c - s.clientHeight / 2 + h / 2 + y : x = c - s.clientHeight + h + y, s.scrollTo({ top: Math.max(0, x), behavior: v });
100
+ function ne(o, e, t) {
101
+ return K(
102
+ (i, r) => {
103
+ var l;
104
+ const n = o.current, s = e.current;
105
+ if (!n || !s) return;
106
+ const y = ((l = t == null ? void 0 : t.current) == null ? void 0 : l.offsetTop) ?? 0, h = s.getOffset(i), I = s.getSize(i), m = (r == null ? void 0 : r.align) ?? "start", H = (r == null ? void 0 : r.behavior) ?? "auto", p = (r == null ? void 0 : r.offset) ?? 0;
107
+ let v;
108
+ m === "start" ? v = y + h + p : m === "center" ? v = y + h - n.clientHeight / 2 + I / 2 + p : v = y + h - n.clientHeight + I + p, n.scrollTo({ top: Math.max(0, v), behavior: H });
108
109
  },
109
- [o, e]
110
+ [o, e, t]
110
111
  );
111
112
  }
112
- function re(o, e) {
113
- switch (e.type) {
114
- case "SCROLL":
115
- return { ...o, scrollTop: e.scrollTop, totalSize: e.totalSize, renderRange: e.renderRange };
116
- case "RESIZE_CONTAINER":
117
- return { ...o, containerHeight: e.height, totalSize: e.totalSize, renderRange: e.renderRange };
118
- case "MEASURE":
119
- return { ...o, totalSize: e.totalSize };
120
- case "ITEMS_CHANGED":
121
- return { ...o, renderRange: e.renderRange, totalSize: e.totalSize };
113
+ function J(o) {
114
+ var j;
115
+ const { items: e, getKey: t, estimatedItemSize: i, overscan: r, initialAlignment: n } = o, s = x(null), y = x(null), h = x(null), I = x(new Z()), m = x([]), H = x(!1), p = x(0), v = x(0), l = x(null), [, B] = k(0), R = K(() => B((c) => c + 1), []);
116
+ h.current || (h.current = new X(e.length, i));
117
+ const F = x(e.length);
118
+ if (e.length !== F.current || e.some((c, f) => {
119
+ const g = t(c, f);
120
+ return m.current[f] !== g;
121
+ })) {
122
+ const c = h.current, f = e.map((Y, q) => t(Y, q)), g = m.current, V = g.length, E = f.length;
123
+ E === 0 ? c.resize(0) : V === 0 ? c.resize(E) : E > V ? g.length > 0 && f[E - V] === g[0] ? c.prepend(E - V) : c.resize(E) : E < V && c.resize(E);
124
+ const O = /* @__PURE__ */ new Map();
125
+ f.forEach((Y, q) => O.set(Y, q)), I.current.applyToOffsetMap(c, O), m.current = f, F.current = e.length;
122
126
  }
123
- }
124
- function G(o) {
125
- const { items: e, getKey: t, estimatedItemSize: n, overscan: s, initialAlignment: l } = o, c = E(null), h = E(null), p = E(new Q()), v = E([]), y = E(!1), x = E(s);
126
- x.current = s, h.current || (h.current = new J(e.length, n));
127
- const z = O((i, g) => {
128
- const r = h.current;
129
- if (!r || r.count === 0) return { start: 0, end: -1 };
130
- const a = r.getOffsets(), f = r.getSizes(), R = W(a, i), A = X(a, f, i + g);
131
- return ee({
132
- firstVisible: R,
133
- lastVisible: A,
134
- itemCount: r.count,
135
- overscan: x.current
136
- });
137
- }, []), [I, u] = q(re, {
138
- renderRange: { start: 0, end: Math.min(e.length - 1, s * 2) },
139
- scrollTop: 0,
140
- containerHeight: 0,
141
- totalSize: h.current.totalSize()
142
- });
143
- K(() => {
144
- const i = h.current, g = e.map((B, _) => t(B, _)), r = v.current, a = r.length, f = g.length;
145
- f === 0 ? i.resize(0) : a === 0 ? i.resize(f) : f > a ? r.length > 0 && g[f - a] === r[0] ? i.prepend(f - a) : i.resize(f) : f < a && i.resize(f);
146
- const R = /* @__PURE__ */ new Map();
147
- g.forEach((B, _) => R.set(B, _)), p.current.applyToOffsetMap(i, R), v.current = g;
148
- const A = c.current, N = (A == null ? void 0 : A.scrollTop) ?? 0, V = (A == null ? void 0 : A.clientHeight) ?? 0, F = z(N, V);
149
- u({ type: "ITEMS_CHANGED", renderRange: F, totalSize: i.totalSize() });
150
- }, [e, t, z]), K(() => {
151
- const i = c.current;
152
- if (!i) return;
153
- const g = () => {
154
- const r = h.current, a = i.scrollTop, f = i.clientHeight, R = z(a, f);
155
- u({ type: "SCROLL", scrollTop: a, totalSize: r.totalSize(), renderRange: R });
127
+ N(() => {
128
+ const c = s.current;
129
+ if (!c) return;
130
+ const f = () => {
131
+ l.current === null && (l.current = requestAnimationFrame(() => {
132
+ l.current = null, p.current = c.scrollTop, v.current = c.clientHeight, R();
133
+ }));
134
+ };
135
+ return c.addEventListener("scroll", f, { passive: !0 }), () => {
136
+ c.removeEventListener("scroll", f), l.current !== null && (cancelAnimationFrame(l.current), l.current = null);
156
137
  };
157
- return i.addEventListener("scroll", g, { passive: !0 }), () => i.removeEventListener("scroll", g);
158
- }, [z]), K(() => {
159
- const i = c.current;
160
- if (!i) return;
161
- const g = new ResizeObserver(([r]) => {
162
- if (!r) return;
163
- const a = r.contentRect.height, f = h.current, R = i.scrollTop, A = z(R, a);
164
- u({ type: "RESIZE_CONTAINER", height: a, totalSize: f.totalSize(), renderRange: A });
138
+ }, [R]), N(() => {
139
+ const c = s.current;
140
+ if (!c) return;
141
+ v.current = c.clientHeight, p.current = c.scrollTop;
142
+ const f = new ResizeObserver(([g]) => {
143
+ g && (v.current = g.contentRect.height, R());
165
144
  });
166
- return g.observe(i), () => g.disconnect();
167
- }, [z]), K(() => {
168
- if (y.current || e.length === 0) return;
169
- const i = c.current;
170
- i && (l === "bottom" && (i.scrollTop = i.scrollHeight), y.current = !0);
171
- }, [l, e.length]);
172
- const M = O((i, g) => {
173
- const r = h.current;
174
- if (!r) return;
175
- p.current.set(i, g);
176
- const a = v.current.indexOf(i);
177
- if (a === -1) return;
178
- r.setSize(a, g) && u({ type: "MEASURE", totalSize: r.totalSize() });
179
- }, []), H = O(
180
- (i, g = "auto") => {
181
- var r;
182
- (r = c.current) == null || r.scrollTo({ top: i, behavior: g });
145
+ return f.observe(c), () => f.disconnect();
146
+ }, [R]), $(() => {
147
+ if (H.current || e.length === 0) return;
148
+ const c = s.current;
149
+ c && (n === "bottom" && (c.scrollTop = c.scrollHeight, p.current = c.scrollTop), H.current = !0);
150
+ }, [n, e.length]), N(() => {
151
+ e.length === 0 && (H.current = !1);
152
+ }, [e.length]);
153
+ const A = K((c, f) => {
154
+ const g = h.current;
155
+ if (!g || I.current.get(c) === f) return;
156
+ I.current.set(c, f);
157
+ const E = m.current.indexOf(c);
158
+ if (E === -1) return;
159
+ g.setSize(E, f) && R();
160
+ }, [R]), T = K(
161
+ (c, f = "auto") => {
162
+ var g;
163
+ (g = s.current) == null || g.scrollTo({ top: c, behavior: f });
183
164
  },
184
165
  []
185
- ), m = te(c, h), S = h.current, { start: P, end: T } = I.renderRange, C = [];
186
- if (S && T >= P)
187
- for (let i = P; i <= T && i < e.length; i++)
188
- C.push({
189
- key: v.current[i] ?? t(e[i], i),
190
- index: i,
191
- start: S.getOffset(i),
192
- size: S.getSize(i),
193
- data: e[i]
166
+ ), M = ne(s, h, y), a = h.current, w = a ? a.totalSize() : 0, P = s.current, L = (P == null ? void 0 : P.scrollTop) ?? p.current, u = (P == null ? void 0 : P.clientHeight) ?? v.current, S = ((j = y.current) == null ? void 0 : j.offsetTop) ?? 0, z = Math.max(0, L - S);
167
+ let b = [];
168
+ if (a && a.count > 0 && u > 0) {
169
+ const c = a.getOffsets(), f = a.getSizes(), g = ee(c, z), V = te(
170
+ c,
171
+ f,
172
+ z + u
173
+ ), E = re({
174
+ firstVisible: g,
175
+ lastVisible: V,
176
+ itemCount: a.count,
177
+ overscan: r
178
+ });
179
+ for (let O = E.start; O <= E.end && O < e.length; O++)
180
+ b.push({
181
+ key: m.current[O] ?? t(e[O], O),
182
+ index: O,
183
+ start: a.getOffset(O),
184
+ size: a.getSize(O),
185
+ data: e[O]
194
186
  });
195
- const d = c.current, w = d ? d.scrollHeight - d.scrollTop - d.clientHeight : 1 / 0;
187
+ } else if (a && a.count > 0) {
188
+ const c = Math.min(e.length - 1, r * 2);
189
+ for (let f = 0; f <= c; f++)
190
+ b.push({
191
+ key: m.current[f] ?? t(e[f], f),
192
+ index: f,
193
+ start: a.getOffset(f),
194
+ size: a.getSize(f),
195
+ data: e[f]
196
+ });
197
+ }
198
+ const _ = P ? P.scrollHeight - P.scrollTop - P.clientHeight : 1 / 0;
196
199
  return {
197
- scrollerRef: c,
198
- virtualItems: C,
199
- totalSize: I.totalSize,
200
- measureItem: M,
201
- scrollToIndex: m,
202
- scrollToOffset: H,
203
- isAtTop: I.scrollTop <= 0,
204
- isAtBottom: w <= 0,
205
- scrollTop: I.scrollTop
200
+ scrollerRef: s,
201
+ innerRef: y,
202
+ virtualItems: b,
203
+ totalSize: w,
204
+ measureItem: A,
205
+ scrollToIndex: M,
206
+ scrollToOffset: T,
207
+ isAtTop: L <= 1,
208
+ isAtBottom: _ <= 1,
209
+ scrollTop: L
206
210
  };
207
211
  }
208
- function ne(o, e) {
209
- const t = E(0), n = E(0), s = E(!1), l = O(() => {
210
- const c = o.current;
211
- c && (t.current = c.scrollTop, n.current = c.scrollHeight, s.current = !0);
212
+ function se(o, e) {
213
+ const t = x(0), i = x(0), r = x(!1), n = K(() => {
214
+ const s = o.current;
215
+ s && (t.current = s.scrollTop, i.current = s.scrollHeight, r.current = !0);
212
216
  }, [o]);
213
- return j(() => {
214
- if (!s.current) return;
215
- const c = o.current;
216
- if (!c) return;
217
- const h = c.scrollHeight - n.current;
218
- h > 0 && (c.scrollTop = t.current + h), s.current = !1;
219
- }, [e, o]), { prepareAnchor: l };
217
+ return $(() => {
218
+ if (!r.current) return;
219
+ const s = o.current;
220
+ if (!s) return;
221
+ const y = s.scrollHeight - i.current;
222
+ y > 0 && (s.scrollTop = t.current + y), r.current = !1;
223
+ }, [e, o]), { prepareAnchor: n };
220
224
  }
221
- function se(o, e) {
222
- const [t, n] = L(!0), s = E(null);
223
- return K(() => {
224
- const l = o.current;
225
- if (!l) return;
226
- const c = () => {
227
- const p = l.scrollHeight - l.scrollTop - l.clientHeight;
228
- n(p <= e);
229
- }, h = () => {
230
- s.current !== null && cancelAnimationFrame(s.current), s.current = requestAnimationFrame(c);
225
+ function ie(o, e) {
226
+ const [t, i] = k(!0), r = x(null);
227
+ return N(() => {
228
+ const n = o.current;
229
+ if (!n) return;
230
+ const s = () => {
231
+ const h = n.scrollHeight - n.scrollTop - n.clientHeight;
232
+ i(h <= e);
233
+ }, y = () => {
234
+ r.current !== null && cancelAnimationFrame(r.current), r.current = requestAnimationFrame(s);
231
235
  };
232
- return l.addEventListener("scroll", h, { passive: !0 }), c(), () => {
233
- l.removeEventListener("scroll", h), s.current !== null && cancelAnimationFrame(s.current);
236
+ return n.addEventListener("scroll", y, { passive: !0 }), s(), () => {
237
+ n.removeEventListener("scroll", y), r.current !== null && cancelAnimationFrame(r.current);
234
238
  };
235
239
  }, [o, e]), t;
236
240
  }
237
- function ie(o) {
238
- const { itemCount: e, isAtBottom: t, scrollToIndex: n, mode: s } = o, l = E(e);
239
- j(() => {
240
- s && (e > l.current && t && e > 0 && n(e - 1, {
241
+ function oe(o) {
242
+ const { itemCount: e, isAtBottom: t, scrollToIndex: i, mode: r } = o, n = x(e);
243
+ $(() => {
244
+ r && (e > n.current && t && e > 0 && i(e - 1, {
241
245
  align: "end",
242
- behavior: s === "smooth" ? "smooth" : "auto"
243
- }), l.current = e);
244
- }, [e, t, n, s]);
246
+ behavior: r === "smooth" ? "smooth" : "auto"
247
+ }), n.current = e);
248
+ }, [e, t, i, r]);
245
249
  }
246
- function oe(o) {
250
+ function ce(o) {
247
251
  const {
248
252
  items: e,
249
253
  getKey: t,
250
- estimatedItemSize: n = 80,
251
- overscan: s = 5,
252
- atBottomThreshold: l = 200,
253
- followOutput: c = "auto",
254
- initialAlignment: h = "bottom",
255
- onStartReached: p,
256
- onEndReached: v,
257
- startReachedThreshold: y = 300,
258
- endReachedThreshold: x = 300,
259
- scrollToMessageKey: z,
260
- onScrollToMessageComplete: I
261
- } = o, u = G({
254
+ estimatedItemSize: i = 80,
255
+ overscan: r = 20,
256
+ atBottomThreshold: n = 200,
257
+ followOutput: s = "auto",
258
+ initialAlignment: y = "bottom",
259
+ onStartReached: h,
260
+ onEndReached: I,
261
+ startReachedThreshold: m = 300,
262
+ endReachedThreshold: H = 300,
263
+ scrollToMessageKey: p,
264
+ onScrollToMessageComplete: v
265
+ } = o, l = J({
262
266
  items: e,
263
267
  getKey: t,
264
- estimatedItemSize: n,
265
- overscan: s,
266
- initialAlignment: h
267
- }), M = se(u.scrollerRef, l), { prepareAnchor: H } = ne(u.scrollerRef, e.length);
268
- ie({
268
+ estimatedItemSize: i,
269
+ overscan: r,
270
+ initialAlignment: y
271
+ }), B = ie(l.scrollerRef, n), { prepareAnchor: R } = se(l.scrollerRef, e.length);
272
+ oe({
269
273
  itemCount: e.length,
270
- isAtBottom: M,
271
- scrollToIndex: u.scrollToIndex,
272
- mode: c ?? !1
274
+ isAtBottom: B,
275
+ scrollToIndex: l.scrollToIndex,
276
+ mode: s ?? !1
273
277
  });
274
- const m = E(!1);
275
- K(() => {
276
- const d = u.scrollerRef.current;
277
- if (!d || !p) return;
278
+ const F = x(!1);
279
+ N(() => {
280
+ const a = l.scrollerRef.current;
281
+ if (!a || !h) return;
278
282
  const w = () => {
279
- d.scrollTop <= y && !m.current && (m.current = !0, Promise.resolve(p()).finally(() => {
280
- m.current = !1;
283
+ a.scrollTop <= m && !F.current && (F.current = !0, Promise.resolve(h()).finally(() => {
284
+ F.current = !1;
281
285
  }));
282
286
  };
283
- return d.addEventListener("scroll", w, { passive: !0 }), () => d.removeEventListener("scroll", w);
284
- }, [u.scrollerRef, p, y]);
285
- const S = E(!1);
286
- K(() => {
287
- const d = u.scrollerRef.current;
288
- if (!d || !v) return;
287
+ return a.addEventListener("scroll", w, { passive: !0 }), () => a.removeEventListener("scroll", w);
288
+ }, [l.scrollerRef, h, m]);
289
+ const d = x(!1);
290
+ N(() => {
291
+ const a = l.scrollerRef.current;
292
+ if (!a || !I) return;
289
293
  const w = () => {
290
- d.scrollHeight - d.scrollTop - d.clientHeight <= x && !S.current && (S.current = !0, Promise.resolve(v()).finally(() => {
291
- S.current = !1;
294
+ a.scrollHeight - a.scrollTop - a.clientHeight <= H && !d.current && (d.current = !0, Promise.resolve(I()).finally(() => {
295
+ d.current = !1;
292
296
  }));
293
297
  };
294
- return d.addEventListener("scroll", w, { passive: !0 }), () => d.removeEventListener("scroll", w);
295
- }, [u.scrollerRef, v, x]);
296
- const P = E(null);
297
- K(() => {
298
- if (!z || P.current === z) return;
299
- const d = e.findIndex((w, i) => t(w, i) === z);
300
- d !== -1 && (P.current = z, u.scrollToIndex(d, { align: "center", behavior: "smooth" }), I == null || I());
301
- }, [z, e, t, u, I]);
302
- const T = O(
303
- (d = "auto") => {
304
- e.length !== 0 && u.scrollToIndex(e.length - 1, { align: "end", behavior: d });
298
+ return a.addEventListener("scroll", w, { passive: !0 }), () => a.removeEventListener("scroll", w);
299
+ }, [l.scrollerRef, I, H]);
300
+ const A = x(null);
301
+ N(() => {
302
+ if (!p || A.current === p) return;
303
+ const a = e.findIndex((w, P) => t(w, P) === p);
304
+ a !== -1 && (A.current = p, l.scrollToIndex(a, { align: "center", behavior: "smooth" }), v == null || v());
305
+ }, [p, e, t, l, v]);
306
+ const T = K(
307
+ (a = "auto") => {
308
+ e.length !== 0 && l.scrollToIndex(e.length - 1, { align: "end", behavior: a });
305
309
  },
306
- [e.length, u]
307
- ), C = O(
308
- (d, w) => {
309
- const i = e.findIndex((g, r) => t(g, r) === d);
310
- i !== -1 && u.scrollToIndex(i, w);
310
+ [e.length, l]
311
+ ), M = K(
312
+ (a, w) => {
313
+ const P = e.findIndex((L, u) => t(L, u) === a);
314
+ P !== -1 && l.scrollToIndex(P, w);
311
315
  },
312
- [e, t, u]
316
+ [e, t, l]
313
317
  );
314
318
  return {
315
- scrollerRef: u.scrollerRef,
316
- virtualItems: u.virtualItems,
317
- totalSize: u.totalSize,
318
- measureItem: u.measureItem,
319
- scrollToIndex: u.scrollToIndex,
319
+ scrollerRef: l.scrollerRef,
320
+ innerRef: l.innerRef,
321
+ virtualItems: l.virtualItems,
322
+ totalSize: l.totalSize,
323
+ measureItem: l.measureItem,
324
+ scrollToIndex: l.scrollToIndex,
320
325
  scrollToBottom: T,
321
- scrollToKey: C,
322
- isAtBottom: M,
323
- prepareAnchor: H
326
+ scrollToKey: M,
327
+ isAtBottom: B,
328
+ prepareAnchor: R
324
329
  };
325
330
  }
326
- function U({
327
- scrollerRef: o,
328
- totalSize: e,
329
- children: t,
330
- className: n,
331
- style: s
332
- }) {
333
- return /* @__PURE__ */ b(
334
- "div",
335
- {
336
- ref: o,
337
- className: n,
338
- style: { overflow: "auto", height: "100%", position: "relative", ...s },
339
- children: /* @__PURE__ */ b("div", { style: { height: e, position: "relative", width: "100%" }, children: t })
340
- }
341
- );
342
- }
343
- function Z({
331
+ function Q({
344
332
  virtualItem: o,
345
333
  measureItem: e,
346
334
  children: t
347
335
  }) {
348
- const n = E(null);
349
- return K(() => {
350
- const s = n.current;
351
- if (!s) return;
352
- const l = new ResizeObserver(([c]) => {
353
- c && e(o.key, c.contentRect.height);
336
+ const i = x(null);
337
+ return N(() => {
338
+ const r = i.current;
339
+ if (!r) return;
340
+ const n = new ResizeObserver(([s]) => {
341
+ s && e(o.key, s.contentRect.height);
354
342
  });
355
- return l.observe(s), () => l.disconnect();
356
- }, [o.key, e]), /* @__PURE__ */ b(
343
+ return n.observe(r), () => n.disconnect();
344
+ }, [o.key, e]), /* @__PURE__ */ C(
357
345
  "div",
358
346
  {
359
- ref: n,
347
+ ref: i,
360
348
  style: {
361
349
  position: "absolute",
362
350
  top: 0,
@@ -370,226 +358,237 @@ function Z({
370
358
  }
371
359
  );
372
360
  }
373
- function ce(o, e) {
361
+ function le(o, e) {
374
362
  const {
375
363
  data: t,
376
- itemContent: n,
377
- computeItemKey: s,
378
- estimatedItemSize: l = 80,
379
- overscan: c = 5,
380
- followOutput: h = "auto",
381
- atBottomThreshold: p = 200,
382
- initialAlignment: v = "bottom",
383
- onStartReached: y,
384
- onEndReached: x,
385
- startReachedThreshold: z = 300,
386
- endReachedThreshold: I = 300,
387
- scrollToMessageKey: u,
388
- onScrollToMessageComplete: M,
389
- onAtBottomChange: H,
390
- components: m = {},
391
- className: S,
392
- style: P
364
+ itemContent: i,
365
+ computeItemKey: r,
366
+ estimatedItemSize: n = 80,
367
+ overscan: s = 20,
368
+ followOutput: y = "auto",
369
+ atBottomThreshold: h = 200,
370
+ initialAlignment: I = "bottom",
371
+ onStartReached: m,
372
+ onEndReached: H,
373
+ startReachedThreshold: p = 300,
374
+ endReachedThreshold: v = 300,
375
+ scrollToMessageKey: l,
376
+ onScrollToMessageComplete: B,
377
+ onAtBottomChange: R,
378
+ components: F = {},
379
+ className: d,
380
+ style: A
393
381
  } = o, {
394
382
  scrollerRef: T,
395
- virtualItems: C,
396
- totalSize: d,
397
- measureItem: w,
398
- scrollToIndex: i,
399
- scrollToBottom: g,
400
- scrollToKey: r,
401
- isAtBottom: a,
402
- prepareAnchor: f
403
- } = oe({
383
+ innerRef: M,
384
+ virtualItems: a,
385
+ totalSize: w,
386
+ measureItem: P,
387
+ scrollToIndex: L,
388
+ scrollToBottom: u,
389
+ scrollToKey: S,
390
+ isAtBottom: z,
391
+ prepareAnchor: b
392
+ } = ce({
404
393
  items: t,
405
- getKey: (F, B) => s(B, F),
406
- estimatedItemSize: l,
407
- overscan: c,
408
- atBottomThreshold: p,
409
- followOutput: h,
410
- initialAlignment: v,
411
- onStartReached: y,
412
- onEndReached: x,
413
- startReachedThreshold: z,
414
- endReachedThreshold: I,
415
- scrollToMessageKey: u,
416
- onScrollToMessageComplete: M
417
- }), R = k.useRef(a);
418
- k.useEffect(() => {
419
- R.current !== a && (R.current = a, H == null || H(a));
420
- }, [a, H]), $(
394
+ getKey: (g, V) => r(V, g),
395
+ estimatedItemSize: n,
396
+ overscan: s,
397
+ atBottomThreshold: h,
398
+ followOutput: y,
399
+ initialAlignment: I,
400
+ onStartReached: m,
401
+ onEndReached: H,
402
+ startReachedThreshold: p,
403
+ endReachedThreshold: v,
404
+ scrollToMessageKey: l,
405
+ onScrollToMessageComplete: B
406
+ }), _ = D.useRef(z);
407
+ D.useEffect(() => {
408
+ _.current !== z && (_.current = z, R == null || R(z));
409
+ }, [z, R]), W(
421
410
  e,
422
411
  () => ({
423
- scrollToBottom: g,
424
- scrollToIndex: i,
425
- scrollToKey: r,
412
+ scrollToBottom: u,
413
+ scrollToIndex: L,
414
+ scrollToKey: S,
426
415
  getScrollTop: () => {
427
- var F;
428
- return ((F = T.current) == null ? void 0 : F.scrollTop) ?? 0;
416
+ var g;
417
+ return ((g = T.current) == null ? void 0 : g.scrollTop) ?? 0;
429
418
  },
430
- isAtBottom: () => a,
431
- prepareAnchor: f
419
+ isAtBottom: () => z,
420
+ prepareAnchor: b
432
421
  }),
433
- [g, i, r, T, a, f]
422
+ [u, L, S, T, z, b]
434
423
  );
435
- const { Header: A, Footer: N, EmptyPlaceholder: V } = m;
436
- return t.length === 0 && V ? /* @__PURE__ */ b(V, {}) : /* @__PURE__ */ D("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
437
- A && /* @__PURE__ */ b(A, {}),
438
- /* @__PURE__ */ b(
439
- U,
440
- {
441
- scrollerRef: T,
442
- totalSize: d,
443
- className: S,
444
- style: { flex: 1, minHeight: 0, ...P },
445
- children: C.map((F) => /* @__PURE__ */ b(
446
- Z,
424
+ const { Header: j, Footer: c, EmptyPlaceholder: f } = F;
425
+ return t.length === 0 && f ? /* @__PURE__ */ C(f, {}) : /* @__PURE__ */ G(
426
+ "div",
427
+ {
428
+ ref: T,
429
+ className: d,
430
+ style: {
431
+ overflow: "auto",
432
+ height: "100%",
433
+ position: "relative",
434
+ overscrollBehaviorY: "contain",
435
+ ...A
436
+ },
437
+ children: [
438
+ j && /* @__PURE__ */ C(j, {}),
439
+ /* @__PURE__ */ C("div", { ref: M, style: { height: w, position: "relative", width: "100%" }, children: a.map((g) => /* @__PURE__ */ C(
440
+ Q,
447
441
  {
448
- virtualItem: F,
449
- measureItem: w,
450
- children: n(F.index, F.data)
442
+ virtualItem: g,
443
+ measureItem: P,
444
+ children: i(g.index, g.data)
451
445
  },
452
- F.key
453
- ))
454
- }
455
- ),
456
- N && /* @__PURE__ */ b(N, {})
457
- ] });
446
+ g.key
447
+ )) }),
448
+ c && /* @__PURE__ */ C(c, {})
449
+ ]
450
+ }
451
+ );
458
452
  }
459
- const ue = Y(ce);
460
- function fe({
453
+ const fe = U(le);
454
+ function he({
461
455
  data: o,
462
456
  itemContent: e,
463
457
  computeItemKey: t,
464
- estimatedItemSize: n = 80,
465
- overscan: s = 5,
466
- onEndReached: l,
467
- endReachedThreshold: c = 300,
468
- components: h = {},
469
- className: p,
470
- style: v
458
+ estimatedItemSize: i = 60,
459
+ overscan: r = 20,
460
+ onEndReached: n,
461
+ endReachedThreshold: s = 300,
462
+ components: y = {},
463
+ className: h,
464
+ style: I
471
465
  }) {
472
- const { scrollerRef: y, virtualItems: x, totalSize: z, measureItem: I } = G({
466
+ const { scrollerRef: m, innerRef: H, virtualItems: p, totalSize: v, measureItem: l } = J({
473
467
  items: o,
474
- getKey: (m, S) => t(S, m),
475
- estimatedItemSize: n,
476
- overscan: s,
468
+ getKey: (d, A) => t(A, d),
469
+ estimatedItemSize: i,
470
+ overscan: r,
477
471
  initialAlignment: "top"
478
472
  });
479
- k.useEffect(() => {
480
- const m = y.current;
481
- if (!m || !l) return;
482
- let S = !1;
483
- const P = () => {
484
- m.scrollHeight - m.scrollTop - m.clientHeight <= c && !S && (S = !0, Promise.resolve(l()).finally(() => {
485
- S = !1;
473
+ D.useEffect(() => {
474
+ const d = m.current;
475
+ if (!d || !n) return;
476
+ let A = !1;
477
+ const T = () => {
478
+ d.scrollHeight - d.scrollTop - d.clientHeight <= s && !A && (A = !0, Promise.resolve(n()).finally(() => {
479
+ A = !1;
486
480
  }));
487
481
  };
488
- return m.addEventListener("scroll", P, { passive: !0 }), () => m.removeEventListener("scroll", P);
489
- }, [y, l, c]);
490
- const { Header: u, Footer: M, EmptyPlaceholder: H } = h;
491
- return o.length === 0 && H ? /* @__PURE__ */ b(H, {}) : /* @__PURE__ */ D("div", { style: { display: "flex", flexDirection: "column", height: "100%" }, children: [
492
- u && /* @__PURE__ */ b(u, {}),
493
- /* @__PURE__ */ b(
494
- U,
495
- {
496
- scrollerRef: y,
497
- totalSize: z,
498
- className: p,
499
- style: { flex: 1, minHeight: 0, ...v },
500
- children: x.map((m) => /* @__PURE__ */ b(
501
- Z,
482
+ return d.addEventListener("scroll", T, { passive: !0 }), () => d.removeEventListener("scroll", T);
483
+ }, [m, n, s]);
484
+ const { Header: B, Footer: R, EmptyPlaceholder: F } = y;
485
+ return o.length === 0 && F ? /* @__PURE__ */ C(F, {}) : /* @__PURE__ */ G(
486
+ "div",
487
+ {
488
+ ref: m,
489
+ className: h,
490
+ style: {
491
+ overflow: "auto",
492
+ height: "100%",
493
+ position: "relative",
494
+ overscrollBehaviorY: "contain",
495
+ ...I
496
+ },
497
+ children: [
498
+ B && /* @__PURE__ */ C(B, {}),
499
+ /* @__PURE__ */ C("div", { ref: H, style: { height: v, position: "relative", width: "100%" }, children: p.map((d) => /* @__PURE__ */ C(
500
+ Q,
502
501
  {
503
- virtualItem: m,
504
- measureItem: I,
505
- children: e(m.index, m.data)
502
+ virtualItem: d,
503
+ measureItem: l,
504
+ children: e(d.index, d.data)
506
505
  },
507
- m.key
508
- ))
509
- }
510
- ),
511
- M && /* @__PURE__ */ b(M, {})
512
- ] });
506
+ d.key
507
+ )) }),
508
+ R && /* @__PURE__ */ C(R, {})
509
+ ]
510
+ }
511
+ );
513
512
  }
514
- function he(o) {
513
+ function de(o) {
515
514
  const {
516
515
  fetcher: e,
517
516
  initialPage: t = 1,
518
- direction: n = "append",
519
- getKey: s,
520
- onPageLoaded: l,
521
- onError: c
522
- } = o, [h, p] = L([]), [v, y] = L(t), [x, z] = L(!0), [I, u] = L(!1), [M, H] = L(!1), [m, S] = L(!1), P = E(/* @__PURE__ */ new Set()), T = E(!1), C = O(
523
- (r) => s ? r.filter((a) => {
524
- const f = s(a);
525
- return P.current.has(f) ? !1 : (P.current.add(f), !0);
526
- }) : r,
527
- [s]
528
- ), d = O(async () => {
529
- if (!(T.current || !x)) {
530
- T.current = !0, S(!0);
517
+ direction: i = "append",
518
+ getKey: r,
519
+ onPageLoaded: n,
520
+ onError: s
521
+ } = o, [y, h] = k([]), [I, m] = k(t), [H, p] = k(!0), [v, l] = k(!1), [B, R] = k(!1), [F, d] = k(!1), A = x(/* @__PURE__ */ new Set()), T = x(!1), M = K(
522
+ (u) => r ? u.filter((S) => {
523
+ const z = r(S);
524
+ return A.current.has(z) ? !1 : (A.current.add(z), !0);
525
+ }) : u,
526
+ [r]
527
+ ), a = K(async () => {
528
+ if (!(T.current || !H)) {
529
+ T.current = !0, d(!0);
531
530
  try {
532
- const r = v + 1, a = await e(r), f = C(a.data);
533
- p(
534
- (R) => n === "prepend" ? [...f, ...R] : [...R, ...f]
535
- ), y(r), z(a.hasNextPage), u(a.hasPrevPage), l == null || l(r, f);
536
- } catch (r) {
537
- c == null || c(r instanceof Error ? r : new Error(String(r)));
531
+ const u = I + 1, S = await e(u), z = M(S.data);
532
+ h(
533
+ (b) => i === "prepend" ? [...z, ...b] : [...b, ...z]
534
+ ), m(u), p(S.hasNextPage), l(S.hasPrevPage), n == null || n(u, z);
535
+ } catch (u) {
536
+ s == null || s(u instanceof Error ? u : new Error(String(u)));
538
537
  } finally {
539
- S(!1), T.current = !1;
538
+ d(!1), T.current = !1;
540
539
  }
541
540
  }
542
- }, [v, x, e, C, n, l, c]), w = O(async () => {
543
- if (!(T.current || !I)) {
544
- T.current = !0, S(!0);
541
+ }, [I, H, e, M, i, n, s]), w = K(async () => {
542
+ if (!(T.current || !v)) {
543
+ T.current = !0, d(!0);
545
544
  try {
546
- const r = v - 1, a = await e(r), f = C(a.data);
547
- p((R) => [...f, ...R]), y(r), u(a.hasPrevPage), z(a.hasNextPage), l == null || l(r, f);
548
- } catch (r) {
549
- c == null || c(r instanceof Error ? r : new Error(String(r)));
545
+ const u = I - 1, S = await e(u), z = M(S.data);
546
+ h((b) => [...z, ...b]), m(u), l(S.hasPrevPage), p(S.hasNextPage), n == null || n(u, z);
547
+ } catch (u) {
548
+ s == null || s(u instanceof Error ? u : new Error(String(u)));
550
549
  } finally {
551
- S(!1), T.current = !1;
550
+ d(!1), T.current = !1;
552
551
  }
553
552
  }
554
- }, [v, I, e, C, l, c]), i = O(async () => {
553
+ }, [I, v, e, M, n, s]), P = K(async () => {
555
554
  if (!T.current) {
556
- T.current = !0, H(!0);
555
+ T.current = !0, R(!0);
557
556
  try {
558
- const r = await e(t), a = r.data;
559
- if (s) {
560
- const f = new Set(a.map(s));
561
- a.forEach((R) => P.current.add(s(R))), p((R) => {
562
- const A = R.filter((N) => !f.has(s(N)));
563
- return n === "prepend" ? [...a, ...A] : [...A, ...a];
557
+ const u = await e(t), S = u.data;
558
+ if (r) {
559
+ const z = new Set(S.map(r));
560
+ S.forEach((b) => A.current.add(r(b))), h((b) => {
561
+ const _ = b.filter((j) => !z.has(r(j)));
562
+ return i === "prepend" ? [...S, ..._] : [..._, ...S];
564
563
  });
565
564
  } else
566
- p(a);
567
- y(t), z(r.hasNextPage), u(r.hasPrevPage), l == null || l(t, a);
568
- } catch (r) {
569
- c == null || c(r instanceof Error ? r : new Error(String(r)));
565
+ h(S);
566
+ m(t), p(u.hasNextPage), l(u.hasPrevPage), n == null || n(t, S);
567
+ } catch (u) {
568
+ s == null || s(u instanceof Error ? u : new Error(String(u)));
570
569
  } finally {
571
- H(!1), T.current = !1;
570
+ R(!1), T.current = !1;
572
571
  }
573
572
  }
574
- }, [e, t, s, n, l, c]), g = O(() => {
575
- p([]), y(t), z(!0), u(!1), H(!1), S(!1), P.current.clear(), T.current = !1;
573
+ }, [e, t, r, i, n, s]), L = K(() => {
574
+ h([]), m(t), p(!0), l(!1), R(!1), d(!1), A.current.clear(), T.current = !1;
576
575
  }, [t]);
577
576
  return {
578
- items: h,
579
- loadNextPage: d,
577
+ items: y,
578
+ loadNextPage: a,
580
579
  loadPrevPage: w,
581
- hasNextPage: x,
582
- hasPrevPage: I,
583
- loading: M,
584
- loadingMore: m,
585
- refresh: i,
586
- reset: g,
587
- currentPage: v
580
+ hasNextPage: H,
581
+ hasPrevPage: v,
582
+ loading: B,
583
+ loadingMore: F,
584
+ refresh: P,
585
+ reset: L,
586
+ currentPage: I
588
587
  };
589
588
  }
590
589
  export {
591
- ue as ChatVirtualList,
592
- fe as VirtualList,
593
- oe as useChatVirtualizer,
594
- he as usePagination
590
+ fe as ChatVirtualList,
591
+ he as VirtualList,
592
+ ce as useChatVirtualizer,
593
+ de as usePagination
595
594
  };
package/dist/types.d.ts CHANGED
@@ -94,6 +94,7 @@ export interface VirtualListProps<T> {
94
94
  }
95
95
  export interface UseVirtualEngineReturn<T> {
96
96
  scrollerRef: React.RefObject<HTMLDivElement>;
97
+ innerRef: React.RefObject<HTMLDivElement>;
97
98
  virtualItems: VirtualItem<T>[];
98
99
  totalSize: number;
99
100
  measureItem: (key: string | number, size: number) => void;
@@ -109,6 +110,7 @@ export interface RenderRange {
109
110
  }
110
111
  export interface UseChatVirtualizerReturn<T> {
111
112
  scrollerRef: React.RefObject<HTMLDivElement>;
113
+ innerRef: React.RefObject<HTMLDivElement>;
112
114
  virtualItems: VirtualItem<T>[];
113
115
  totalSize: number;
114
116
  measureItem: (key: string | number, size: number) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAEnC,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,CAAA;CACR;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IAClC,QAAQ,CAAC,EAAE,cAAc,CAAA;IACzB,8CAA8C;IAC9C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,qBAAqB,CAAC,CAAC,GAAG,OAAO;IAChD,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC5B,gBAAgB,CA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,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAChE,cAAc,EAAE,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;IACnD,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAA;IACrE,UAAU,EAAE,OAAO,CAAA;IACnB,aAAa,EAAE,MAAM,IAAI,CAAA;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-anchorlist",
3
- "version": "0.1.1",
3
+ "version": "0.2.1",
4
4
  "description": "High-performance chat virtualizer for React — no flicker, no hacks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",