react-anchorlist 0.2.0 → 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;AAI9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAe,MAAM,UAAU,CAAA;AAgHxF,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":"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,2CAwDrB"}
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,14 +1,14 @@
1
1
  import { UseVirtualEngineReturn } from '../types';
2
2
 
3
3
  /**
4
- * Core virtual engine.
4
+ * Core virtual engine — v0.2.1
5
5
  *
6
- * KEY DESIGN DECISIONS:
7
- * - All scroll/layout state lives in refs, NOT in React state
8
- * - A simple counter state is used ONLY to trigger re-renders
9
- * - virtualItems are computed from refs DURING render (always fresh, zero lag)
10
- * - Scroll handler uses rAF throttle to avoid excessive renders
11
- * - Overscan defaults to 20 items (not 5) for smooth fast-scroll
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
12
  */
13
13
  export declare function useVirtualEngine<T>(options: {
14
14
  items: T[];
@@ -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;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,CAoN5B"}
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 j=require("react/jsx-runtime"),r=require("react");function _(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const t in c)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(c,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>c[t]})}}return e.default=c,Object.freeze(e)}const M=_(r);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 s=0;s<e;s++)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 D{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[s,i]of this.cache){const o=t.get(s);o!==void 0&&e.setSize(o,i)}}}function Y(c,e){if(c.length===0)return 0;let t=0,s=c.length-1;for(;t<s;){const i=t+s>>1;(c[i]??0)<e?t=i+1:s=i}return Math.max(0,t>0&&(c[t]??0)>e?t-1:t)}function $(c,e,t){if(c.length===0)return 0;for(let s=c.length-1;s>=0;s--)if((c[s]??0)<t)return s;return 0}function G(c){const{firstVisible:e,lastVisible:t,itemCount:s,overscan:i}=c;return s===0?{start:0,end:-1}:{start:Math.max(0,e-i),end:Math.min(s-1,t+i)}}function J(c,e){return r.useCallback((t,s)=>{const i=c.current,o=e.current;if(!i||!o)return;const l=o.getOffset(t),p=o.getSize(t),v=(s==null?void 0:s.align)??"start",z=(s==null?void 0:s.behavior)??"auto",x=(s==null?void 0:s.offset)??0;let T;v==="start"?T=l+x:v==="center"?T=l-i.clientHeight/2+p/2+x:T=l-i.clientHeight+p+x,i.scrollTo({top:Math.max(0,T),behavior:z})},[c,e])}function V(c){const{items:e,getKey:t,estimatedItemSize:s,overscan:i,initialAlignment:o}=c,l=r.useRef(null),p=r.useRef(null),v=r.useRef(new D),z=r.useRef([]),x=r.useRef(!1),T=r.useRef(0),b=r.useRef(0),I=r.useRef(null),[,f]=r.useState(0),A=r.useCallback(()=>f(n=>n+1),[]);p.current||(p.current=new q(e.length,s));const w=r.useRef(e.length);if(e.length!==w.current||e.some((n,a)=>{const R=t(n,a);return z.current[a]!==R})){const n=p.current,a=e.map((L,K)=>t(L,K)),R=z.current,k=R.length,C=a.length;C===0?n.resize(0):k===0?n.resize(C):C>k?R.length>0&&a[C-k]===R[0]?n.prepend(C-k):n.resize(C):C<k&&n.resize(C);const m=new Map;a.forEach((L,K)=>m.set(L,K)),v.current.applyToOffsetMap(n,m),z.current=a,w.current=e.length}r.useEffect(()=>{const n=l.current;if(!n)return;const a=()=>{I.current===null&&(I.current=requestAnimationFrame(()=>{I.current=null,T.current=n.scrollTop,b.current=n.clientHeight,A()}))};return n.addEventListener("scroll",a,{passive:!0}),()=>{n.removeEventListener("scroll",a),I.current!==null&&(cancelAnimationFrame(I.current),I.current=null)}},[A]),r.useEffect(()=>{const n=l.current;if(!n)return;b.current=n.clientHeight,T.current=n.scrollTop;const a=new ResizeObserver(([R])=>{R&&(b.current=R.contentRect.height,A())});return a.observe(n),()=>a.disconnect()},[A]),r.useLayoutEffect(()=>{if(x.current||e.length===0)return;const n=l.current;n&&(o==="bottom"&&(n.scrollTop=n.scrollHeight,T.current=n.scrollTop),x.current=!0)},[o,e.length]),r.useEffect(()=>{e.length===0&&(x.current=!1)},[e.length]);const P=r.useCallback((n,a)=>{const R=p.current;if(!R||v.current.get(n)===a)return;v.current.set(n,a);const C=z.current.indexOf(n);if(C===-1)return;R.setSize(C,a)&&A()},[A]),O=r.useCallback((n,a="auto")=>{var R;(R=l.current)==null||R.scrollTo({top:n,behavior:a})},[]),E=J(l,p),S=p.current,d=S?S.totalSize():0,g=l.current,H=(g==null?void 0:g.scrollTop)??T.current,F=(g==null?void 0:g.clientHeight)??b.current;let u=[];if(S&&S.count>0&&F>0){const n=S.getOffsets(),a=S.getSizes(),R=Y(n,H),k=$(n,a,H+F),C=G({firstVisible:R,lastVisible:k,itemCount:S.count,overscan:i});for(let m=C.start;m<=C.end&&m<e.length;m++)u.push({key:z.current[m]??t(e[m],m),index:m,start:S.getOffset(m),size:S.getSize(m),data:e[m]})}else if(S&&S.count>0){const n=Math.min(e.length-1,i*2);for(let a=0;a<=n;a++)u.push({key:z.current[a]??t(e[a],a),index:a,start:S.getOffset(a),size:S.getSize(a),data:e[a]})}const h=g?g.scrollHeight-g.scrollTop-g.clientHeight:1/0;return{scrollerRef:l,virtualItems:u,totalSize:d,measureItem:P,scrollToIndex:E,scrollToOffset:O,isAtTop:H<=0,isAtBottom:h<=0,scrollTop:H}}function Q(c,e){const t=r.useRef(0),s=r.useRef(0),i=r.useRef(!1),o=r.useCallback(()=>{const l=c.current;l&&(t.current=l.scrollTop,s.current=l.scrollHeight,i.current=!0)},[c]);return r.useLayoutEffect(()=>{if(!i.current)return;const l=c.current;if(!l)return;const p=l.scrollHeight-s.current;p>0&&(l.scrollTop=t.current+p),i.current=!1},[e,c]),{prepareAnchor:o}}function U(c,e){const[t,s]=r.useState(!0),i=r.useRef(null);return r.useEffect(()=>{const o=c.current;if(!o)return;const l=()=>{const v=o.scrollHeight-o.scrollTop-o.clientHeight;s(v<=e)},p=()=>{i.current!==null&&cancelAnimationFrame(i.current),i.current=requestAnimationFrame(l)};return o.addEventListener("scroll",p,{passive:!0}),l(),()=>{o.removeEventListener("scroll",p),i.current!==null&&cancelAnimationFrame(i.current)}},[c,e]),t}function W(c){const{itemCount:e,isAtBottom:t,scrollToIndex:s,mode:i}=c,o=r.useRef(e);r.useLayoutEffect(()=>{i&&(e>o.current&&t&&e>0&&s(e-1,{align:"end",behavior:i==="smooth"?"smooth":"auto"}),o.current=e)},[e,t,s,i])}function B(c){const{items:e,getKey:t,estimatedItemSize:s=80,overscan:i=20,atBottomThreshold:o=200,followOutput:l="auto",initialAlignment:p="bottom",onStartReached:v,onEndReached:z,startReachedThreshold:x=300,endReachedThreshold:T=300,scrollToMessageKey:b,onScrollToMessageComplete:I}=c,f=V({items:e,getKey:t,estimatedItemSize:s,overscan:i,initialAlignment:p}),A=U(f.scrollerRef,o),{prepareAnchor:w}=Q(f.scrollerRef,e.length);W({itemCount:e.length,isAtBottom:A,scrollToIndex:f.scrollToIndex,mode:l??!1});const y=r.useRef(!1);r.useEffect(()=>{const d=f.scrollerRef.current;if(!d||!v)return;const g=()=>{d.scrollTop<=x&&!y.current&&(y.current=!0,Promise.resolve(v()).finally(()=>{y.current=!1}))};return d.addEventListener("scroll",g,{passive:!0}),()=>d.removeEventListener("scroll",g)},[f.scrollerRef,v,x]);const P=r.useRef(!1);r.useEffect(()=>{const d=f.scrollerRef.current;if(!d||!z)return;const g=()=>{d.scrollHeight-d.scrollTop-d.clientHeight<=T&&!P.current&&(P.current=!0,Promise.resolve(z()).finally(()=>{P.current=!1}))};return d.addEventListener("scroll",g,{passive:!0}),()=>d.removeEventListener("scroll",g)},[f.scrollerRef,z,T]);const O=r.useRef(null);r.useEffect(()=>{if(!b||O.current===b)return;const d=e.findIndex((g,H)=>t(g,H)===b);d!==-1&&(O.current=b,f.scrollToIndex(d,{align:"center",behavior:"smooth"}),I==null||I())},[b,e,t,f,I]);const E=r.useCallback((d="auto")=>{e.length!==0&&f.scrollToIndex(e.length-1,{align:"end",behavior:d})},[e.length,f]),S=r.useCallback((d,g)=>{const H=e.findIndex((F,u)=>t(F,u)===d);H!==-1&&f.scrollToIndex(H,g)},[e,t,f]);return{scrollerRef:f.scrollerRef,virtualItems:f.virtualItems,totalSize:f.totalSize,measureItem:f.measureItem,scrollToIndex:f.scrollToIndex,scrollToBottom:E,scrollToKey:S,isAtBottom:A,prepareAnchor:w}}function N({virtualItem:c,measureItem:e,children:t}){const s=r.useRef(null);return r.useEffect(()=>{const i=s.current;if(!i)return;const o=new ResizeObserver(([l])=>{l&&e(c.key,l.contentRect.height)});return o.observe(i),()=>o.disconnect()},[c.key,e]),j.jsx("div",{ref:s,style:{position:"absolute",top:0,transform:`translateY(${c.start}px)`,width:"100%",minHeight:c.size},children:t})}function X(c,e){const{data:t,itemContent:s,computeItemKey:i,estimatedItemSize:o=80,overscan:l=20,followOutput:p="auto",atBottomThreshold:v=200,initialAlignment:z="bottom",onStartReached:x,onEndReached:T,startReachedThreshold:b=300,endReachedThreshold:I=300,scrollToMessageKey:f,onScrollToMessageComplete:A,onAtBottomChange:w,components:y={},className:P,style:O}=c,{scrollerRef:E,virtualItems:S,totalSize:d,measureItem:g,scrollToIndex:H,scrollToBottom:F,scrollToKey:u,isAtBottom:h,prepareAnchor:n}=B({items:t,getKey:(m,L)=>i(L,m),estimatedItemSize:o,overscan:l,atBottomThreshold:v,followOutput:p,initialAlignment:z,onStartReached:x,onEndReached:T,startReachedThreshold:b,endReachedThreshold:I,scrollToMessageKey:f,onScrollToMessageComplete:A}),a=M.useRef(h);M.useEffect(()=>{a.current!==h&&(a.current=h,w==null||w(h))},[h,w]),r.useImperativeHandle(e,()=>({scrollToBottom:F,scrollToIndex:H,scrollToKey:u,getScrollTop:()=>{var m;return((m=E.current)==null?void 0:m.scrollTop)??0},isAtBottom:()=>h,prepareAnchor:n}),[F,H,u,E,h,n]);const{Header:R,Footer:k,EmptyPlaceholder:C}=y;return t.length===0&&C?j.jsx(C,{}):j.jsxs("div",{ref:E,className:P,style:{overflow:"auto",height:"100%",position:"relative",...O},children:[R&&j.jsx(R,{}),j.jsx("div",{style:{height:d,position:"relative",width:"100%"},children:S.map(m=>j.jsx(N,{virtualItem:m,measureItem:g,children:s(m.index,m.data)},m.key))}),k&&j.jsx(k,{})]})}const Z=r.forwardRef(X);function ee({data:c,itemContent:e,computeItemKey:t,estimatedItemSize:s=60,overscan:i=20,onEndReached:o,endReachedThreshold:l=300,components:p={},className:v,style:z}){const{scrollerRef:x,virtualItems:T,totalSize:b,measureItem:I}=V({items:c,getKey:(y,P)=>t(P,y),estimatedItemSize:s,overscan:i,initialAlignment:"top"});M.useEffect(()=>{const y=x.current;if(!y||!o)return;let P=!1;const O=()=>{y.scrollHeight-y.scrollTop-y.clientHeight<=l&&!P&&(P=!0,Promise.resolve(o()).finally(()=>{P=!1}))};return y.addEventListener("scroll",O,{passive:!0}),()=>y.removeEventListener("scroll",O)},[x,o,l]);const{Header:f,Footer:A,EmptyPlaceholder:w}=p;return c.length===0&&w?j.jsx(w,{}):j.jsxs("div",{ref:x,className:v,style:{overflow:"auto",height:"100%",position:"relative",...z},children:[f&&j.jsx(f,{}),j.jsx("div",{style:{height:b,position:"relative",width:"100%"},children:T.map(y=>j.jsx(N,{virtualItem:y,measureItem:I,children:e(y.index,y.data)},y.key))}),A&&j.jsx(A,{})]})}function te(c){const{fetcher:e,initialPage:t=1,direction:s="append",getKey:i,onPageLoaded:o,onError:l}=c,[p,v]=r.useState([]),[z,x]=r.useState(t),[T,b]=r.useState(!0),[I,f]=r.useState(!1),[A,w]=r.useState(!1),[y,P]=r.useState(!1),O=r.useRef(new Set),E=r.useRef(!1),S=r.useCallback(u=>i?u.filter(h=>{const n=i(h);return O.current.has(n)?!1:(O.current.add(n),!0)}):u,[i]),d=r.useCallback(async()=>{if(!(E.current||!T)){E.current=!0,P(!0);try{const u=z+1,h=await e(u),n=S(h.data);v(a=>s==="prepend"?[...n,...a]:[...a,...n]),x(u),b(h.hasNextPage),f(h.hasPrevPage),o==null||o(u,n)}catch(u){l==null||l(u instanceof Error?u:new Error(String(u)))}finally{P(!1),E.current=!1}}},[z,T,e,S,s,o,l]),g=r.useCallback(async()=>{if(!(E.current||!I)){E.current=!0,P(!0);try{const u=z-1,h=await e(u),n=S(h.data);v(a=>[...n,...a]),x(u),f(h.hasPrevPage),b(h.hasNextPage),o==null||o(u,n)}catch(u){l==null||l(u instanceof Error?u:new Error(String(u)))}finally{P(!1),E.current=!1}}},[z,I,e,S,o,l]),H=r.useCallback(async()=>{if(!E.current){E.current=!0,w(!0);try{const u=await e(t),h=u.data;if(i){const n=new Set(h.map(i));h.forEach(a=>O.current.add(i(a))),v(a=>{const R=a.filter(k=>!n.has(i(k)));return s==="prepend"?[...h,...R]:[...R,...h]})}else v(h);x(t),b(u.hasNextPage),f(u.hasPrevPage),o==null||o(t,h)}catch(u){l==null||l(u instanceof Error?u:new Error(String(u)))}finally{w(!1),E.current=!1}}},[e,t,i,s,o,l]),F=r.useCallback(()=>{v([]),x(t),b(!0),f(!1),w(!1),P(!1),O.current.clear(),E.current=!1},[t]);return{items:p,loadNextPage:d,loadPrevPage:g,hasNextPage:T,hasPrevPage:I,loading:A,loadingMore:y,refresh:H,reset:F,currentPage:z}}exports.ChatVirtualList=Z;exports.VirtualList=ee;exports.useChatVirtualizer=B;exports.usePagination=te;
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 M, jsxs as q } from "react/jsx-runtime";
2
- import * as _ from "react";
3
- import { useCallback as C, useRef as I, useState as L, useEffect as V, useLayoutEffect as j, forwardRef as $, useImperativeHandle as G } 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,515 +69,526 @@ 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 i = t.get(n);
74
- i !== void 0 && e.setSize(i, 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 U(l, e) {
79
- if (l.length === 0) return 0;
80
- let t = 0, n = l.length - 1;
81
- for (; t < n; ) {
82
- const s = t + n >> 1;
83
- (l[s] ?? 0) < e ? t = s + 1 : n = s;
78
+ function ee(o, e) {
79
+ if (o.length === 0) return 0;
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
- return Math.max(0, t > 0 && (l[t] ?? 0) > e ? t - 1 : t);
85
+ return Math.max(0, t > 0 && (o[t] ?? 0) > e ? t - 1 : t);
86
86
  }
87
- function W(l, e, t) {
88
- if (l.length === 0) return 0;
89
- for (let n = l.length - 1; n >= 0; n--)
90
- if ((l[n] ?? 0) < t) return n;
87
+ function te(o, e, t) {
88
+ if (o.length === 0) return 0;
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 X(l) {
94
- const { firstVisible: e, lastVisible: t, itemCount: n, overscan: s } = l;
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 Z(l, e) {
101
- return C(
102
- (t, n) => {
103
- const s = l.current, i = e.current;
104
- if (!s || !i) return;
105
- const o = i.getOffset(t), m = i.getSize(t), p = (n == null ? void 0 : n.align) ?? "start", v = (n == null ? void 0 : n.behavior) ?? "auto", S = (n == null ? void 0 : n.offset) ?? 0;
106
- let x;
107
- p === "start" ? x = o + S : p === "center" ? x = o - s.clientHeight / 2 + m / 2 + S : x = o - s.clientHeight + m + S, 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
- [l, e]
110
+ [o, e, t]
110
111
  );
111
112
  }
112
- function D(l) {
113
- const { items: e, getKey: t, estimatedItemSize: n, overscan: s, initialAlignment: i } = l, o = I(null), m = I(null), p = I(new Q()), v = I([]), S = I(!1), x = I(0), R = I(0), P = I(null), [, u] = L(0), b = C(() => u((r) => r + 1), []);
114
- m.current || (m.current = new J(e.length, n));
115
- const E = I(e.length);
116
- if (e.length !== E.current || e.some((r, c) => {
117
- const T = t(r, c);
118
- return v.current[c] !== T;
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;
119
121
  })) {
120
- const r = m.current, c = e.map((k, N) => t(k, N)), T = v.current, K = T.length, w = c.length;
121
- w === 0 ? r.resize(0) : K === 0 ? r.resize(w) : w > K ? T.length > 0 && c[w - K] === T[0] ? r.prepend(w - K) : r.resize(w) : w < K && r.resize(w);
122
- const g = /* @__PURE__ */ new Map();
123
- c.forEach((k, N) => g.set(k, N)), p.current.applyToOffsetMap(r, g), v.current = c, E.current = e.length;
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;
124
126
  }
125
- V(() => {
126
- const r = o.current;
127
- if (!r) return;
128
- const c = () => {
129
- P.current === null && (P.current = requestAnimationFrame(() => {
130
- P.current = null, x.current = r.scrollTop, R.current = r.clientHeight, b();
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();
131
133
  }));
132
134
  };
133
- return r.addEventListener("scroll", c, { passive: !0 }), () => {
134
- r.removeEventListener("scroll", c), P.current !== null && (cancelAnimationFrame(P.current), P.current = null);
135
+ return c.addEventListener("scroll", f, { passive: !0 }), () => {
136
+ c.removeEventListener("scroll", f), l.current !== null && (cancelAnimationFrame(l.current), l.current = null);
135
137
  };
136
- }, [b]), V(() => {
137
- const r = o.current;
138
- if (!r) return;
139
- R.current = r.clientHeight, x.current = r.scrollTop;
140
- const c = new ResizeObserver(([T]) => {
141
- T && (R.current = T.contentRect.height, b());
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());
142
144
  });
143
- return c.observe(r), () => c.disconnect();
144
- }, [b]), j(() => {
145
- if (S.current || e.length === 0) return;
146
- const r = o.current;
147
- r && (i === "bottom" && (r.scrollTop = r.scrollHeight, x.current = r.scrollTop), S.current = !0);
148
- }, [i, e.length]), V(() => {
149
- e.length === 0 && (S.current = !1);
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);
150
152
  }, [e.length]);
151
- const A = C((r, c) => {
152
- const T = m.current;
153
- if (!T || p.current.get(r) === c) return;
154
- p.current.set(r, c);
155
- const w = v.current.indexOf(r);
156
- if (w === -1) return;
157
- T.setSize(w, c) && b();
158
- }, [b]), O = C(
159
- (r, c = "auto") => {
160
- var T;
161
- (T = o.current) == null || T.scrollTo({ top: r, behavior: c });
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 });
162
164
  },
163
165
  []
164
- ), H = Z(o, m), y = m.current, h = y ? y.totalSize() : 0, d = o.current, F = (d == null ? void 0 : d.scrollTop) ?? x.current, B = (d == null ? void 0 : d.clientHeight) ?? R.current;
165
- let a = [];
166
- if (y && y.count > 0 && B > 0) {
167
- const r = y.getOffsets(), c = y.getSizes(), T = U(r, F), K = W(r, c, F + B), w = X({
168
- firstVisible: T,
169
- lastVisible: K,
170
- itemCount: y.count,
171
- overscan: s
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
172
178
  });
173
- for (let g = w.start; g <= w.end && g < e.length; g++)
174
- a.push({
175
- key: v.current[g] ?? t(e[g], g),
176
- index: g,
177
- start: y.getOffset(g),
178
- size: y.getSize(g),
179
- data: e[g]
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]
180
186
  });
181
- } else if (y && y.count > 0) {
182
- const r = Math.min(e.length - 1, s * 2);
183
- for (let c = 0; c <= r; c++)
184
- a.push({
185
- key: v.current[c] ?? t(e[c], c),
186
- index: c,
187
- start: y.getOffset(c),
188
- size: y.getSize(c),
189
- data: e[c]
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]
190
196
  });
191
197
  }
192
- const f = d ? d.scrollHeight - d.scrollTop - d.clientHeight : 1 / 0;
198
+ const _ = P ? P.scrollHeight - P.scrollTop - P.clientHeight : 1 / 0;
193
199
  return {
194
- scrollerRef: o,
195
- virtualItems: a,
196
- totalSize: h,
200
+ scrollerRef: s,
201
+ innerRef: y,
202
+ virtualItems: b,
203
+ totalSize: w,
197
204
  measureItem: A,
198
- scrollToIndex: H,
199
- scrollToOffset: O,
200
- isAtTop: F <= 0,
201
- isAtBottom: f <= 0,
202
- scrollTop: F
205
+ scrollToIndex: M,
206
+ scrollToOffset: T,
207
+ isAtTop: L <= 1,
208
+ isAtBottom: _ <= 1,
209
+ scrollTop: L
203
210
  };
204
211
  }
205
- function ee(l, e) {
206
- const t = I(0), n = I(0), s = I(!1), i = C(() => {
207
- const o = l.current;
208
- o && (t.current = o.scrollTop, n.current = o.scrollHeight, s.current = !0);
209
- }, [l]);
210
- return j(() => {
211
- if (!s.current) return;
212
- const o = l.current;
213
- if (!o) return;
214
- const m = o.scrollHeight - n.current;
215
- m > 0 && (o.scrollTop = t.current + m), s.current = !1;
216
- }, [e, l]), { prepareAnchor: i };
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);
216
+ }, [o]);
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 };
217
224
  }
218
- function te(l, e) {
219
- const [t, n] = L(!0), s = I(null);
220
- return V(() => {
221
- const i = l.current;
222
- if (!i) return;
223
- const o = () => {
224
- const p = i.scrollHeight - i.scrollTop - i.clientHeight;
225
- n(p <= e);
226
- }, m = () => {
227
- s.current !== null && cancelAnimationFrame(s.current), s.current = requestAnimationFrame(o);
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);
228
235
  };
229
- return i.addEventListener("scroll", m, { passive: !0 }), o(), () => {
230
- i.removeEventListener("scroll", m), 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);
231
238
  };
232
- }, [l, e]), t;
239
+ }, [o, e]), t;
233
240
  }
234
- function re(l) {
235
- const { itemCount: e, isAtBottom: t, scrollToIndex: n, mode: s } = l, i = I(e);
236
- j(() => {
237
- s && (e > i.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, {
238
245
  align: "end",
239
- behavior: s === "smooth" ? "smooth" : "auto"
240
- }), i.current = e);
241
- }, [e, t, n, s]);
246
+ behavior: r === "smooth" ? "smooth" : "auto"
247
+ }), n.current = e);
248
+ }, [e, t, i, r]);
242
249
  }
243
- function ne(l) {
250
+ function ce(o) {
244
251
  const {
245
252
  items: e,
246
253
  getKey: t,
247
- estimatedItemSize: n = 80,
248
- overscan: s = 20,
249
- atBottomThreshold: i = 200,
250
- followOutput: o = "auto",
251
- initialAlignment: m = "bottom",
252
- onStartReached: p,
253
- onEndReached: v,
254
- startReachedThreshold: S = 300,
255
- endReachedThreshold: x = 300,
256
- scrollToMessageKey: R,
257
- onScrollToMessageComplete: P
258
- } = l, u = D({
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({
259
266
  items: e,
260
267
  getKey: t,
261
- estimatedItemSize: n,
262
- overscan: s,
263
- initialAlignment: m
264
- }), b = te(u.scrollerRef, i), { prepareAnchor: E } = ee(u.scrollerRef, e.length);
265
- re({
268
+ estimatedItemSize: i,
269
+ overscan: r,
270
+ initialAlignment: y
271
+ }), B = ie(l.scrollerRef, n), { prepareAnchor: R } = se(l.scrollerRef, e.length);
272
+ oe({
266
273
  itemCount: e.length,
267
- isAtBottom: b,
268
- scrollToIndex: u.scrollToIndex,
269
- mode: o ?? !1
274
+ isAtBottom: B,
275
+ scrollToIndex: l.scrollToIndex,
276
+ mode: s ?? !1
270
277
  });
271
- const z = I(!1);
272
- V(() => {
273
- const h = u.scrollerRef.current;
274
- if (!h || !p) return;
275
- const d = () => {
276
- h.scrollTop <= S && !z.current && (z.current = !0, Promise.resolve(p()).finally(() => {
277
- z.current = !1;
278
+ const F = x(!1);
279
+ N(() => {
280
+ const a = l.scrollerRef.current;
281
+ if (!a || !h) return;
282
+ const w = () => {
283
+ a.scrollTop <= m && !F.current && (F.current = !0, Promise.resolve(h()).finally(() => {
284
+ F.current = !1;
278
285
  }));
279
286
  };
280
- return h.addEventListener("scroll", d, { passive: !0 }), () => h.removeEventListener("scroll", d);
281
- }, [u.scrollerRef, p, S]);
282
- const A = I(!1);
283
- V(() => {
284
- const h = u.scrollerRef.current;
285
- if (!h || !v) return;
286
- const d = () => {
287
- h.scrollHeight - h.scrollTop - h.clientHeight <= x && !A.current && (A.current = !0, Promise.resolve(v()).finally(() => {
288
- A.current = !1;
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;
293
+ const w = () => {
294
+ a.scrollHeight - a.scrollTop - a.clientHeight <= H && !d.current && (d.current = !0, Promise.resolve(I()).finally(() => {
295
+ d.current = !1;
289
296
  }));
290
297
  };
291
- return h.addEventListener("scroll", d, { passive: !0 }), () => h.removeEventListener("scroll", d);
292
- }, [u.scrollerRef, v, x]);
293
- const O = I(null);
294
- V(() => {
295
- if (!R || O.current === R) return;
296
- const h = e.findIndex((d, F) => t(d, F) === R);
297
- h !== -1 && (O.current = R, u.scrollToIndex(h, { align: "center", behavior: "smooth" }), P == null || P());
298
- }, [R, e, t, u, P]);
299
- const H = C(
300
- (h = "auto") => {
301
- e.length !== 0 && u.scrollToIndex(e.length - 1, { align: "end", behavior: h });
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 });
302
309
  },
303
- [e.length, u]
304
- ), y = C(
305
- (h, d) => {
306
- const F = e.findIndex((B, a) => t(B, a) === h);
307
- F !== -1 && u.scrollToIndex(F, d);
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);
308
315
  },
309
- [e, t, u]
316
+ [e, t, l]
310
317
  );
311
318
  return {
312
- scrollerRef: u.scrollerRef,
313
- virtualItems: u.virtualItems,
314
- totalSize: u.totalSize,
315
- measureItem: u.measureItem,
316
- scrollToIndex: u.scrollToIndex,
317
- scrollToBottom: H,
318
- scrollToKey: y,
319
- isAtBottom: b,
320
- prepareAnchor: E
319
+ scrollerRef: l.scrollerRef,
320
+ innerRef: l.innerRef,
321
+ virtualItems: l.virtualItems,
322
+ totalSize: l.totalSize,
323
+ measureItem: l.measureItem,
324
+ scrollToIndex: l.scrollToIndex,
325
+ scrollToBottom: T,
326
+ scrollToKey: M,
327
+ isAtBottom: B,
328
+ prepareAnchor: R
321
329
  };
322
330
  }
323
- function Y({
324
- virtualItem: l,
331
+ function Q({
332
+ virtualItem: o,
325
333
  measureItem: e,
326
334
  children: t
327
335
  }) {
328
- const n = I(null);
329
- return V(() => {
330
- const s = n.current;
331
- if (!s) return;
332
- const i = new ResizeObserver(([o]) => {
333
- o && e(l.key, o.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);
334
342
  });
335
- return i.observe(s), () => i.disconnect();
336
- }, [l.key, e]), /* @__PURE__ */ M(
343
+ return n.observe(r), () => n.disconnect();
344
+ }, [o.key, e]), /* @__PURE__ */ C(
337
345
  "div",
338
346
  {
339
- ref: n,
347
+ ref: i,
340
348
  style: {
341
349
  position: "absolute",
342
350
  top: 0,
343
351
  // transform instead of top: avoids reflow, uses GPU compositor layer
344
- transform: `translateY(${l.start}px)`,
352
+ transform: `translateY(${o.start}px)`,
345
353
  width: "100%",
346
354
  // Reserve estimated height to prevent layout collapse before first measure
347
- minHeight: l.size
355
+ minHeight: o.size
348
356
  },
349
357
  children: t
350
358
  }
351
359
  );
352
360
  }
353
- function se(l, e) {
361
+ function le(o, e) {
354
362
  const {
355
363
  data: t,
356
- itemContent: n,
357
- computeItemKey: s,
358
- estimatedItemSize: i = 80,
359
- overscan: o = 20,
360
- followOutput: m = "auto",
361
- atBottomThreshold: p = 200,
362
- initialAlignment: v = "bottom",
363
- onStartReached: S,
364
- onEndReached: x,
365
- startReachedThreshold: R = 300,
366
- endReachedThreshold: P = 300,
367
- scrollToMessageKey: u,
368
- onScrollToMessageComplete: b,
369
- onAtBottomChange: E,
370
- components: z = {},
371
- className: A,
372
- style: O
373
- } = l, {
374
- scrollerRef: H,
375
- virtualItems: y,
376
- totalSize: h,
377
- measureItem: d,
378
- scrollToIndex: F,
379
- scrollToBottom: B,
380
- scrollToKey: a,
381
- isAtBottom: f,
382
- prepareAnchor: r
383
- } = ne({
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
381
+ } = o, {
382
+ scrollerRef: T,
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({
384
393
  items: t,
385
- getKey: (g, k) => s(k, g),
386
- estimatedItemSize: i,
387
- overscan: o,
388
- atBottomThreshold: p,
389
- followOutput: m,
390
- initialAlignment: v,
391
- onStartReached: S,
392
- onEndReached: x,
393
- startReachedThreshold: R,
394
- endReachedThreshold: P,
395
- scrollToMessageKey: u,
396
- onScrollToMessageComplete: b
397
- }), c = _.useRef(f);
398
- _.useEffect(() => {
399
- c.current !== f && (c.current = f, E == null || E(f));
400
- }, [f, E]), G(
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(
401
410
  e,
402
411
  () => ({
403
- scrollToBottom: B,
404
- scrollToIndex: F,
405
- scrollToKey: a,
412
+ scrollToBottom: u,
413
+ scrollToIndex: L,
414
+ scrollToKey: S,
406
415
  getScrollTop: () => {
407
416
  var g;
408
- return ((g = H.current) == null ? void 0 : g.scrollTop) ?? 0;
417
+ return ((g = T.current) == null ? void 0 : g.scrollTop) ?? 0;
409
418
  },
410
- isAtBottom: () => f,
411
- prepareAnchor: r
419
+ isAtBottom: () => z,
420
+ prepareAnchor: b
412
421
  }),
413
- [B, F, a, H, f, r]
422
+ [u, L, S, T, z, b]
414
423
  );
415
- const { Header: T, Footer: K, EmptyPlaceholder: w } = z;
416
- return t.length === 0 && w ? /* @__PURE__ */ M(w, {}) : /* @__PURE__ */ q(
424
+ const { Header: j, Footer: c, EmptyPlaceholder: f } = F;
425
+ return t.length === 0 && f ? /* @__PURE__ */ C(f, {}) : /* @__PURE__ */ G(
417
426
  "div",
418
427
  {
419
- ref: H,
420
- className: A,
428
+ ref: T,
429
+ className: d,
421
430
  style: {
422
431
  overflow: "auto",
423
432
  height: "100%",
424
433
  position: "relative",
425
- ...O
434
+ overscrollBehaviorY: "contain",
435
+ ...A
426
436
  },
427
437
  children: [
428
- T && /* @__PURE__ */ M(T, {}),
429
- /* @__PURE__ */ M("div", { style: { height: h, position: "relative", width: "100%" }, children: y.map((g) => /* @__PURE__ */ M(
430
- Y,
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,
431
441
  {
432
442
  virtualItem: g,
433
- measureItem: d,
434
- children: n(g.index, g.data)
443
+ measureItem: P,
444
+ children: i(g.index, g.data)
435
445
  },
436
446
  g.key
437
447
  )) }),
438
- K && /* @__PURE__ */ M(K, {})
448
+ c && /* @__PURE__ */ C(c, {})
439
449
  ]
440
450
  }
441
451
  );
442
452
  }
443
- const ce = $(se);
444
- function le({
445
- data: l,
453
+ const fe = U(le);
454
+ function he({
455
+ data: o,
446
456
  itemContent: e,
447
457
  computeItemKey: t,
448
- estimatedItemSize: n = 60,
449
- overscan: s = 20,
450
- onEndReached: i,
451
- endReachedThreshold: o = 300,
452
- components: m = {},
453
- className: p,
454
- 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
455
465
  }) {
456
- const { scrollerRef: S, virtualItems: x, totalSize: R, measureItem: P } = D({
457
- items: l,
458
- getKey: (z, A) => t(A, z),
459
- estimatedItemSize: n,
460
- overscan: s,
466
+ const { scrollerRef: m, innerRef: H, virtualItems: p, totalSize: v, measureItem: l } = J({
467
+ items: o,
468
+ getKey: (d, A) => t(A, d),
469
+ estimatedItemSize: i,
470
+ overscan: r,
461
471
  initialAlignment: "top"
462
472
  });
463
- _.useEffect(() => {
464
- const z = S.current;
465
- if (!z || !i) return;
473
+ D.useEffect(() => {
474
+ const d = m.current;
475
+ if (!d || !n) return;
466
476
  let A = !1;
467
- const O = () => {
468
- z.scrollHeight - z.scrollTop - z.clientHeight <= o && !A && (A = !0, Promise.resolve(i()).finally(() => {
477
+ const T = () => {
478
+ d.scrollHeight - d.scrollTop - d.clientHeight <= s && !A && (A = !0, Promise.resolve(n()).finally(() => {
469
479
  A = !1;
470
480
  }));
471
481
  };
472
- return z.addEventListener("scroll", O, { passive: !0 }), () => z.removeEventListener("scroll", O);
473
- }, [S, i, o]);
474
- const { Header: u, Footer: b, EmptyPlaceholder: E } = m;
475
- return l.length === 0 && E ? /* @__PURE__ */ M(E, {}) : /* @__PURE__ */ q(
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(
476
486
  "div",
477
487
  {
478
- ref: S,
479
- className: p,
488
+ ref: m,
489
+ className: h,
480
490
  style: {
481
491
  overflow: "auto",
482
492
  height: "100%",
483
493
  position: "relative",
484
- ...v
494
+ overscrollBehaviorY: "contain",
495
+ ...I
485
496
  },
486
497
  children: [
487
- u && /* @__PURE__ */ M(u, {}),
488
- /* @__PURE__ */ M("div", { style: { height: R, position: "relative", width: "100%" }, children: x.map((z) => /* @__PURE__ */ M(
489
- Y,
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,
490
501
  {
491
- virtualItem: z,
492
- measureItem: P,
493
- children: e(z.index, z.data)
502
+ virtualItem: d,
503
+ measureItem: l,
504
+ children: e(d.index, d.data)
494
505
  },
495
- z.key
506
+ d.key
496
507
  )) }),
497
- b && /* @__PURE__ */ M(b, {})
508
+ R && /* @__PURE__ */ C(R, {})
498
509
  ]
499
510
  }
500
511
  );
501
512
  }
502
- function ae(l) {
513
+ function de(o) {
503
514
  const {
504
515
  fetcher: e,
505
516
  initialPage: t = 1,
506
- direction: n = "append",
507
- getKey: s,
508
- onPageLoaded: i,
509
- onError: o
510
- } = l, [m, p] = L([]), [v, S] = L(t), [x, R] = L(!0), [P, u] = L(!1), [b, E] = L(!1), [z, A] = L(!1), O = I(/* @__PURE__ */ new Set()), H = I(!1), y = C(
511
- (a) => s ? a.filter((f) => {
512
- const r = s(f);
513
- return O.current.has(r) ? !1 : (O.current.add(r), !0);
514
- }) : a,
515
- [s]
516
- ), h = C(async () => {
517
- if (!(H.current || !x)) {
518
- H.current = !0, A(!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);
519
530
  try {
520
- const a = v + 1, f = await e(a), r = y(f.data);
521
- p(
522
- (c) => n === "prepend" ? [...r, ...c] : [...c, ...r]
523
- ), S(a), R(f.hasNextPage), u(f.hasPrevPage), i == null || i(a, r);
524
- } catch (a) {
525
- o == null || o(a instanceof Error ? a : new Error(String(a)));
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)));
526
537
  } finally {
527
- A(!1), H.current = !1;
538
+ d(!1), T.current = !1;
528
539
  }
529
540
  }
530
- }, [v, x, e, y, n, i, o]), d = C(async () => {
531
- if (!(H.current || !P)) {
532
- H.current = !0, A(!0);
541
+ }, [I, H, e, M, i, n, s]), w = K(async () => {
542
+ if (!(T.current || !v)) {
543
+ T.current = !0, d(!0);
533
544
  try {
534
- const a = v - 1, f = await e(a), r = y(f.data);
535
- p((c) => [...r, ...c]), S(a), u(f.hasPrevPage), R(f.hasNextPage), i == null || i(a, r);
536
- } catch (a) {
537
- o == null || o(a instanceof Error ? a : new Error(String(a)));
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)));
538
549
  } finally {
539
- A(!1), H.current = !1;
550
+ d(!1), T.current = !1;
540
551
  }
541
552
  }
542
- }, [v, P, e, y, i, o]), F = C(async () => {
543
- if (!H.current) {
544
- H.current = !0, E(!0);
553
+ }, [I, v, e, M, n, s]), P = K(async () => {
554
+ if (!T.current) {
555
+ T.current = !0, R(!0);
545
556
  try {
546
- const a = await e(t), f = a.data;
547
- if (s) {
548
- const r = new Set(f.map(s));
549
- f.forEach((c) => O.current.add(s(c))), p((c) => {
550
- const T = c.filter((K) => !r.has(s(K)));
551
- return n === "prepend" ? [...f, ...T] : [...T, ...f];
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];
552
563
  });
553
564
  } else
554
- p(f);
555
- S(t), R(a.hasNextPage), u(a.hasPrevPage), i == null || i(t, f);
556
- } catch (a) {
557
- o == null || o(a instanceof Error ? a : new Error(String(a)));
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)));
558
569
  } finally {
559
- E(!1), H.current = !1;
570
+ R(!1), T.current = !1;
560
571
  }
561
572
  }
562
- }, [e, t, s, n, i, o]), B = C(() => {
563
- p([]), S(t), R(!0), u(!1), E(!1), A(!1), O.current.clear(), H.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;
564
575
  }, [t]);
565
576
  return {
566
- items: m,
567
- loadNextPage: h,
568
- loadPrevPage: d,
569
- hasNextPage: x,
570
- hasPrevPage: P,
571
- loading: b,
572
- loadingMore: z,
573
- refresh: F,
574
- reset: B,
575
- currentPage: v
577
+ items: y,
578
+ loadNextPage: a,
579
+ loadPrevPage: w,
580
+ hasNextPage: H,
581
+ hasPrevPage: v,
582
+ loading: B,
583
+ loadingMore: F,
584
+ refresh: P,
585
+ reset: L,
586
+ currentPage: I
576
587
  };
577
588
  }
578
589
  export {
579
- ce as ChatVirtualList,
580
- le as VirtualList,
581
- ne as useChatVirtualizer,
582
- ae as usePagination
590
+ fe as ChatVirtualList,
591
+ he as VirtualList,
592
+ ce as useChatVirtualizer,
593
+ de as usePagination
583
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;
@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AAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,iBAAiB,KAAK,IAAI,CAAA;IAChE,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,cAAc,KAAK,IAAI,CAAA;IACnE,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,OAAO,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,MAAM,WAAW,wBAAwB,CAAC,CAAC;IACzC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC5C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IACzC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACzD,aAAa,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.2.0",
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",