react-virtuoso
Advanced tools
Comparing version 1.0.0-beta.2 to 1.0.0-beta.3
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("@virtuoso.dev/urx"),r=require("@virtuoso.dev/react-urx"),o=(e=require("resize-observer-polyfill"))&&"object"==typeof e&&"default"in e?e.default:e;function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function l(e,n){void 0===n&&(n=!0);var r=t.useRef(null),i=new o((function(t){e(t[0].target)}));return function(e){e&&n?(i.observe(e),r.current=e):(r.current&&i.unobserve(r.current),r.current=null)}}var c="up",m=n.system((function(){var e=n.stream(),t=n.stream(),r=n.statefulStream(0),o=n.stream(),i=n.stream(),a=n.stream();n.connect(e,r);var s=n.statefulStream("down");return n.connect(n.pipe(e,n.scan((function(e,t){return{direction:t<e.prevScrollTop?c:"down",prevScrollTop:t}}),{direction:"down",prevScrollTop:0}),n.map((function(e){return e.direction}))),s),{scrollTop:e,viewportHeight:o,smoothScrollTargetReached:t,scrollTo:i,scrollBy:a,scrollDirection:s,statefulScrollTop:r}}),[],{singleton:!0}),f={lvl:0};function p(e,t,n,r,o){return void 0===r&&(r=f),void 0===o&&(o=f),{k:e,v:t,lvl:n,l:r,r:o}}function d(e){return e===f}function h(){return f}function v(e,t){if(d(e))return f;var n=e.k,r=e.l,o=e.r;if(t===n){if(d(r))return o;if(d(o))return r;var i=function e(t){return d(t.r)?[t.k,t.v]:e(t.r)}(r);return T(x(e,{k:i[0],v:i[1],l:C(r)}))}return T(x(e,t<n?{l:v(r,t)}:{r:v(o,t)}))}function g(e,t){if(!d(e))return t===e.k?e.v:g(t<e.k?e.l:e.r,t)}function I(e,t,n){if(void 0===n&&(n="k"),d(e))return[-Infinity,void 0];if(e[n]===t)return[e.k,e.v];if(e[n]<t){var r=I(e.r,t,n);return-Infinity===r[0]?[e.k,e.v]:r}return I(e.l,t,n)}function S(e,t,n){return d(e)?p(t,n,1):t===e.k?x(e,{k:t,v:n}):function(e){return w(k(e))}(x(e,t<e.k?{l:S(e.l,t,n)}:{r:S(e.r,t,n)}))}function C(e){return d(e.r)?e.l:T(x(e,{r:C(e.r)}))}function x(e,t){return p(void 0!==t.k?t.k:e.k,void 0!==t.v?t.v:e.v,void 0!==t.lvl?t.lvl:e.lvl,void 0!==t.l?t.l:e.l,void 0!==t.r?t.r:e.r)}function y(e){return d(e)||e.lvl>e.r.lvl}function T(e){var t=e.l,n=e.r,r=e.lvl;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(y(t))return k(x(e,{lvl:r-1}));if(d(t)||d(t.r))throw new Error("Unexpected empty nodes");return x(t.r,{l:x(t,{r:t.r.l}),r:x(e,{l:t.r.r,lvl:r-1}),lvl:r})}if(y(e))return w(x(e,{lvl:r-1}));if(d(n)||d(n.l))throw new Error("Unexpected empty nodes");var o=n.l,i=y(o)?n.lvl-1:n.lvl;return x(o,{l:x(e,{r:o.l,lvl:r-1}),r:w(x(n,{l:o.r,lvl:i})),lvl:o.lvl+1})}function b(e,t,n){return d(e)?[]:function(e){if(0===e.length)return[];for(var t=e[0],n=t.k,r=t.v,o=[],i=1;i<=e.length;i++){var a=e[i];o.push({start:n,end:a?a.k-1:Infinity,value:r}),a&&(n=a.k,r=a.v)}return o}(function e(t,n,r){if(d(t))return[];var o=t.k,i=t.v,a=t.r,s=[];return o>n&&(s=s.concat(e(t.l,n,r))),o>=n&&o<=r&&s.push({k:o,v:i}),o<=r&&(s=s.concat(e(a,n,r))),s}(e,I(e,t)[0],n))}function w(e){var t=e.r,n=e.lvl;return d(t)||d(t.r)||t.lvl!==n||t.r.lvl!==n?e:x(t,{l:x(e,{r:t.l}),lvl:n+1})}function k(e){var t=e.l;return d(t)||t.lvl!==e.lvl?e:x(t,{r:x(e,{l:t.r})})}function z(e){var t=e.size,n=e.startIndex,r=e.endIndex;return function(e){return e.start===n&&(e.end===r||Infinity===e.end)&&e.value===t}}function H(e,t){var n=t[0],r=t[1],o=e.sizeTree,i=e.offsetTree,a=o,s=0;if(r.length>0&&d(o)&&2===n.length){var l=n[0].size,c=n[1].size;a=r.reduce((function(e,t){return S(S(e,t,l),t+1,c)}),a)}else{var m=function(e,t,n){void 0===n&&(n=function(){});for(var r,o=d(e)?0:Infinity,i=u(t);!(r=i()).done;){var a=r.value,s=a.size,l=a.startIndex,c=a.endIndex;if(o=Math.min(o,l),d(e))e=S(e,0,s);else{var m=b(e,l-1,c+1);if(!m.some(z(a))){for(var f,p=!1,h=!1,g=u(m);!(f=g()).done;){var I=f.value,C=I.start,x=I.end,y=I.value;p?(c>=C||s===y)&&(e=v(e,C),n(C)):(h=y!==s,p=!0),x>c&&c>=C&&y!==s&&(e=S(e,c+1,y))}h&&(e=S(e,l,s))}}}return[e,o]}(a,n,(function(e){i=v(i,e)}));a=m[0],s=m[1]}if(a===o)return e;var f=0,p=0,C=0;if(0!==s){f=I(i,s-1)[1];var x=I(a,s-1);p=x[0],C=x[1]}else C=g(a,0);for(var y,T=u(b(a,s,Infinity));!(y=T()).done;){var w=y.value,k=w.start,H=w.value,E=(k-p)*C+f;i=S(i,k,E),p=k,f=E,C=H}return{offsetTree:i,sizeTree:a,groupOffsetTree:r.reduce((function(e,t){return S(e,t,L(t,{offsetTree:i,sizeTree:a}))}),h()),lastIndex:p,lastOffset:f,lastSize:C,groupIndices:r}}function L(e,t){if(d(t.offsetTree))return 0;var n=I(t.offsetTree,e),r=n[0],o=n[1];return I(t.sizeTree,e)[1]*(e-r)+o}function E(e,t){if(d(t.groupOffsetTree))return e;for(var n=0;t.groupIndices[n]<=e+n;)n++;return e+n}var F=n.system((function(){var e=n.stream(),t=n.stream(),r=n.stream(),o=n.statefulStream(0),a=n.statefulStream([]),s=n.statefulStream(void 0),u=n.statefulStream(void 0),l=n.statefulStream(void 0),c={offsetTree:h(),sizeTree:h(),groupOffsetTree:h(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},m=n.statefulStream(!1),f=n.statefulStreamFromEmitter(n.pipe(e,n.withLatestFrom(a),n.scan(H,c),n.distinctUntilChanged()),c);n.connect(n.pipe(a,n.withLatestFrom(f),n.map((function(e){var t=e[0],n=e[1];return i({},n,{groupIndices:t,groupOffsetTree:t.reduce((function(e,t){return S(e,t,L(t,n))}),h())})}))),f),n.connect(n.pipe(a,n.mapTo(!0)),m),n.connect(s,u);var p=n.statefulStreamFromEmitter(n.pipe(s,n.map((function(e){return void 0===e}))),!0);n.connect(n.pipe(u,n.filter((function(e){return void 0!==e})),n.map((function(e){return[{startIndex:0,endIndex:0,size:e}]}))),e);var v=n.streamFromEmitter(n.pipe(e,n.withLatestFrom(f),n.scan((function(e,t){var n=t[1];return{changed:n!==e.sizes,sizes:n}}),{changed:!1,sizes:c}),n.map((function(e){return e.changed}))));return n.connect(n.pipe(l,n.filter((function(e){return void 0!==e})),n.map((function(e){return e.length}))),t),n.connect(n.pipe(r,n.withLatestFrom(f),n.map((function(e){var t=e[0],n=e[1];if(n.groupIndices.length>0)throw new Error("Virtuoso: prepending items does not work with groups");return function e(t){return d(t)?[]:[].concat(e(t.l),[{k:t.k,v:t.v}],e(t.r))}(n.sizeTree).reduce((function(e,n){var r=n.k,o=n.v;return{ranges:[].concat(e.ranges,[{startIndex:e.prevIndex,endIndex:r+t-1,size:e.prevSize}]),prevIndex:r+t,prevSize:o}}),{ranges:[],prevIndex:0,prevSize:n.lastSize}).ranges}))),e),n.connect(n.pipe(o,n.scan((function(e,t){return{diff:e.prev-t,prev:t}}),{diff:0,prev:0}),n.map((function(e){return e.diff})),n.filter((function(e){return e>0}))),r),{data:l,totalCount:t,sizeRanges:e,groupIndices:a,defaultItemSize:u,fixedItemSize:s,unshiftWith:r,firstItemIndex:o,sizes:f,listRefresh:v,trackItemSizes:p}}),[],{singleton:!0}),R=function(e,t){return e&&e[0]===t[0]&&e[1]===t[1]},B=function(e,t,n){return"number"==typeof e?n===c&&"top"===t||"down"===n&&"bottom"===t?e:0:n===c?"top"===t?e.main:e.reverse:"bottom"===t?e.main:e.reverse},O=n.system((function(e){var t=e[0],r=t.scrollTop,o=t.viewportHeight,i=n.stream(),a=n.statefulStream(0),s=n.statefulStream(0),u=n.statefulStream(0),l=n.statefulStream(0);return{listBoundary:i,headerHeight:a,footerHeight:s,overscan:l,topListHeight:u,visibleRange:n.statefulStreamFromEmitter(n.pipe(n.combineLatest(n.duc(r),n.duc(o),n.duc(a),n.duc(i,R),n.duc(l),n.duc(u)),n.map((function(e){var t=e[0],n=e[1],r=e[3],o=e[4],i=t-e[2],a="none";return r[0]>t+e[5]&&(a=c),r[1]<t+n&&(a="down"),"none"!==a?[Math.max(i-B(o,"top",a),0),i+n+B(o,"bottom",a)]:null})),n.filter((function(e){return null!=e}))),[0,0])}}),n.tup(m),{singleton:!0});function M(e){var t="number"==typeof e?{index:e}:e;return t.align||(t.align="start"),t.behavior||(t.behavior="auto"),t}var P=n.system((function(e){var t=e[0],r=t.sizes,o=t.totalCount,i=t.listRefresh,a=e[1],s=a.viewportHeight,u=a.scrollTo,l=a.smoothScrollTargetReached,c=e[2].headerHeight,m=n.stream(),f=n.statefulStream(0),p=null,d=null,h=null,v=function(){p&&(p(),p=null),h&&(h(),h=null),d&&(clearTimeout(d),d=null)};return n.connect(n.pipe(m,n.withLatestFrom(r,s,o,f,c),n.map((function(e){var t=e[0],r=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=M(t),f=c.index,g=c.align,S=c.behavior;f=E(f,r);var C=L(f=Math.max(0,f,Math.min(a-1,f)),r)+u;"end"===g?C=Math.round(C-o+I(r.sizeTree,f)[1]):"center"===g?C=Math.round(C-o/2+I(r.sizeTree,f)[1]/2):C-=s;var x=function(e){v(),e&&n.publish(m,t)};if(v(),"smooth"===S){var y=!1;h=n.subscribe(i,(function(e){y=y||e})),p=n.handleNext(l,(function(){x(y)}))}else p=n.handleNext(i,x);return d=setTimeout((function(){v()}),1200),{top:C,behavior:S}}))),u),{scrollToIndex:m,topListHeight:f}}),n.tup(F,m,O),{singleton:!0}),U=n.system((function(e){var t=e[0],r=t.scrollTop,o=t.viewportHeight,i=n.statefulStream(!1),a=n.statefulStream(!0),s=n.stream(),u=n.stream(),l=n.stream(),c=n.statefulStreamFromEmitter(n.pipe(n.merge(n.pipe(n.duc(r),n.skip(1),n.mapTo(!0)),n.pipe(n.duc(r),n.skip(1),n.mapTo(!1),n.debounceTime(200))),n.distinctUntilChanged()),!1);return n.connect(n.pipe(n.duc(r),n.map((function(e){return 0===e})),n.distinctUntilChanged()),a),n.connect(a,u),n.connect(n.pipe(n.combineLatest(n.duc(l),n.duc(r),n.duc(o)),n.map((function(e){var t=e[0];return 0===t.offsetBottom&&e[1]+e[2]-t.bottom>-4})),n.distinctUntilChanged()),i),n.subscribe(i,(function(e){setTimeout((function(){return n.publish(s,e)}))})),{isScrolling:c,isAtTop:a,isAtBottom:i,atTopStateChange:u,atBottomStateChange:s,listStateListener:l}}),n.tup(m)),j=n.system((function(e){var t=e[0],r=t.totalCount,o=t.listRefresh,i=e[1].isAtBottom,a=e[2].scrollToIndex,s=n.statefulStream(!1);return n.subscribe(n.pipe(r,n.withLatestFrom(s,i),n.filter((function(e){return e[1]&&e[2]}))),(function(e){var t=e[0],r=e[1];n.handleNext(o,(function(){var e;n.publish(a,{index:t-1,align:"end",behavior:(e=r,"smooth"===e?"smooth":"auto")})}))})),{followOutput:s}}),n.tup(F,U,P));function V(e){return e.reduce((function(e,t){return e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e}),{totalCount:0,groupIndices:[]})}var A=n.system((function(e){var t=e[0],r=t.totalCount,o=t.groupIndices,i=t.sizes,a=e[1].scrollTop,s=n.stream(),u=n.stream(),l=n.streamFromEmitter(n.pipe(s,n.map(V)));return n.connect(n.pipe(l,n.map(n.prop("totalCount"))),r),n.connect(n.pipe(l,n.map(n.prop("groupIndices"))),o),n.connect(n.pipe(n.combineLatest(a,i),n.filter((function(e){return!d(e[1].groupOffsetTree)})),n.map((function(e){return I(e[1].groupOffsetTree,e[0],"v")[0]})),n.distinctUntilChanged(),n.map((function(e){return[e]}))),u),{groupCounts:s,topItemsIndexes:u}}),n.tup(F,m)),N=n.system((function(e){var t,r=e[0],o=r.sizes,i=r.listRefresh,a=e[1].scrollTop,s=e[2].scrollToIndex,u=n.statefulStream(!0),l=n.statefulStream(0);return n.connect(n.pipe(n.duc(l),n.filter((function(e){return 0!==e})),(void 0===(t=1)&&(t=1),function(e){return function(n){t-- >0&&e(n)}}),n.mapTo(!1)),u),n.subscribe(n.combineLatest(n.duc(l),n.duc(u),i),(function(e){var t=e[0],r=e[1];d(n.getValue(o).sizeTree)||r||(n.handleNext(a,(function(){n.publish(u,!0)})),n.publish(s,t))})),{scrolledToInitialItem:u,initialTopMostItemIndex:l}}),n.tup(F,m,P),{singleton:!0}),G=n.system((function(){return{propsReady:n.statefulStream(!1)}}),[],{singleton:!0}),W={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0};function K(e,t,n){if(0===e.length)return[];if(d(t.groupOffsetTree))return e.map((function(e){return i({},e,{index:e.index+n,originalIndex:e.index})}));for(var r,o=[],a=b(t.groupOffsetTree,e[0].index,e[e.length-1].index),s=void 0,l=0,c=u(e);!(r=c()).done;){var m=r.value;(!s||s.end<m.index)&&(s=a.shift(),l=t.groupIndices.indexOf(s.start)),o.push(i({},m.index===s.start?{type:"group",index:l}:{index:m.index-(l+1)+n,groupIndex:l},{size:m.size,offset:m.offset,originalIndex:m.index,data:m.data}))}return o}function q(e,t,n,r,o){var i=0,a=0;if(e.length>0){i=e[0].offset;var s=e[e.length-1];a=s.offset+s.size}var u=i,l=r.lastOffset+(n-r.lastIndex)*r.lastSize-a;return{items:K(e,r,o),topItems:K(t,r,o),topListHeight:t.reduce((function(e,t){return t.size+e}),0),offsetTop:i,offsetBottom:l,top:u,bottom:a}}var D=n.system((function(e){var t=e[0].statefulScrollTop,r=e[1],o=r.sizes,a=r.totalCount,s=r.data,l=r.firstItemIndex,c=e[2],m=e[3],f=m.visibleRange,p=m.listBoundary,h=m.topListHeight,v=e[4],S=v.scrolledToInitialItem,C=v.initialTopMostItemIndex,x=e[5].topListHeight,y=e[6],T=e[7].propsReady,w=n.statefulStream([]),k=n.stream();n.connect(c.topItemsIndexes,w);var z=n.statefulStreamFromEmitter(n.pipe(n.combineLatest(T,n.duc(f),n.duc(a),n.duc(o),n.duc(C),n.duc(S),n.duc(w),n.duc(l)),n.filter((function(e){return e[0]})),n.withLatestFrom(s),n.map((function(e){var r=e[0],o=r[1],i=o[0],a=o[1],s=r[2],l=r[3],c=r[4],m=r[5],f=r[6],p=r[7],h=e[1],v=l.sizeTree,S=l.offsetTree;if(0===s||0===i&&0===a)return W;if(d(v))return q(function(e,t,n){if(!d(t.groupOffsetTree)){var r=E(e,t);return[{index:I(t.groupOffsetTree,r)[0],size:0,offset:0},{index:r,size:0,offset:0,data:n&&n[0]}]}return[{index:e,size:0,offset:0,data:n&&n[0]}]}(c,l,h),[],s,l,p);var C=[];if(f.length>0)for(var x,y=f[0],T=f[f.length-1],w=0,k=u(b(l.sizeTree,y,T));!(x=k()).done;)for(var z=x.value,H=z.value,L=Math.max(z.start,y),F=Math.min(z.end,T),R=L;R<=F;R++)C.push({index:R,size:H,offset:w,data:h&&h[R]}),w+=H;if(!m)return q([],C,s,l,p);d(l.groupOffsetTree)||(f=[I(l.groupOffsetTree,n.getValue(t),"v")[0]]);var B=f.length>0?f[f.length-1]+1:0,O=Math.max(B,I(S,i,"v")[0]),M=I(S,a,"v")[0],P=s-1;return q(n.tap([],(function(e){for(var t,n=u(b(S,O,M));!(t=n()).done;){var r=t.value,o=r.value,s=r.start,l=g(v,s);r.value<i&&(o+=((s+=Math.floor((i-r.value)/l))-r.start)*l),s<B&&(o+=(B-s)*l,s=B);for(var c=Math.min(r.end,P),m=s;m<=c&&!(o>=a);m++)e.push({index:m,size:l,offset:o,data:h&&h[m]}),o+=l}})),C,s,l,p)}))),W);return n.connect(n.pipe(n.duc(z),n.map(n.prop("topListHeight"))),x),n.connect(x,h),n.connect(z,y.listStateListener),n.connect(n.pipe(n.duc(z),n.map((function(e){return[e.top,e.bottom]}))),p),n.connect(n.pipe(n.duc(z),n.map((function(e){return e.items}))),k),i({listState:z,topItemsIndexes:w,endReached:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){return e.items.length>0})),n.withLatestFrom(a),n.filter((function(e){var t=e[0].items;return t[t.length-1].originalIndex===e[1]-1})),n.map((function(e){return e[1]-1})),n.distinctUntilChanged())),startReached:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){var t=e.items;return t.length>0&&0===t[0].originalIndex})),n.mapTo(0))),rangeChanged:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){return e.items.length>0})),n.map((function(e){var t=e.items;return{startIndex:t[0].originalIndex,endIndex:t[t.length-1].originalIndex}})),n.distinctUntilChanged((function(e,t){return e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex})))),itemsRendered:k},y)}),n.tup(m,F,A,O,N,P,U,G),{singleton:!0}),Y=n.system((function(e){var t=e[0],r=t.sizes,o=t.firstItemIndex,i=e[1].listState,a=e[2].propsReady,s=n.statefulStream(0);return n.connect(n.pipe(n.combineLatest(s,a),n.filter((function(e){return e[1]&&0!==e[0]})),n.withLatestFrom(r,o),n.map((function(e){var t=e[0][0],n=e[1],r=e[2],o=0;if(n.groupIndices.length>0)for(var i,a=u(n.groupIndices);!((i=a()).done||i.value-o>=t);)o++;var s=t+o;return q(Array.from({length:s}).map((function(e,t){return{index:t,size:0,offset:0}})),[],s,n,r)}))),i),{initialItemCount:s}}),n.tup(F,D,G),{singleton:!0}),_=n.system((function(e){var t=e[0].scrollTop,r=e[1].isScrolling,o=n.statefulStream(0),i=n.statefulStream(!1),a=n.stream(),s=n.statefulStream(!1);return n.connect(n.pipe(r,n.filter((function(e){return!e})),n.mapTo(0)),o),n.connect(n.pipe(t,n.throttleTime(100),n.scan((function(e,t){return[e[1],t]}),[0,0]),n.map((function(e){return e[1]-e[0]}))),o),n.connect(n.pipe(o,n.withLatestFrom(s,i,a),n.filter((function(e){return!!e[1]})),n.map((function(e){var t=e[0],n=e[1],r=e[2],o=e[3],i=n.enter;if(r){if((0,n.exit)(t,o))return!1}else if(i(t,o))return!0;return r})),n.distinctUntilChanged()),i),n.subscribe(n.pipe(n.combineLatest(i,o,a),n.withLatestFrom(s)),(function(e){var t=e[0],n=e[1];return t[0]&&n&&n.change&&n.change(t[1],t[2])})),{isSeeking:i,scrollSeekConfiguration:s,scrollVelocity:o,scrollSeekRangeChanged:a}}),n.tup(m,U),{singleton:!0}),Z=n.system((function(e){var t=e[0].topItemsIndexes,r=n.statefulStream(0);return n.connect(n.pipe(r,n.filter((function(e){return e>0})),n.map((function(e){return Array.from({length:e}).map((function(e,t){return t}))}))),t),{topItemCount:r}}),n.tup(D)),$=n.system((function(e){var t=e[0],r=t.footerHeight,o=t.headerHeight,i=e[1].listState,a=n.stream(),s=n.statefulStreamFromEmitter(n.pipe(n.combineLatest(r,o,i),n.map((function(e){var t=e[2];return e[0]+e[1]+t.offsetBottom+t.bottom}))),0);return n.connect(n.duc(s),a),{totalListHeight:s,totalListHeightChanged:a}}),n.tup(O,D),{singleton:!0}),J=n.system((function(e){var t=e[0],r=t.scrollBy,o=e[1].listState,i=e[2],a=i.unshiftWith,s=i.sizes,u=i.listRefresh;return n.connect(n.pipe(o,n.withLatestFrom(t.scrollTop,t.scrollDirection),n.filter((function(e){return 0!==e[1]&&e[2]===c})),n.map((function(e){return e[0]})),n.scan((function(e,t){var n=e[1],r=t.items,o=0;if(n.length>0&&r.length>0&&(0!==n[0].originalIndex||0!==r[0].originalIndex)){var i=function(e){var t=r[e],i=n.find((function(e){return e.originalIndex===t.originalIndex}));return i?t.offset!==i.offset?(o=t.offset-i.offset,"break"):void 0:"continue"};e:for(var a=r.length-1;a>=0;a--)switch(i(a)){case"continue":continue;case"break":break e}}return[o,r]}),[0,[]]),n.filter((function(e){return 0!==e[0]})),n.map((function(e){return{top:e[0],behavior:"auto"}}))),r),n.subscribe(n.pipe(a,n.withLatestFrom(s,o),n.map((function(e){var t=e[2];return{index:t.items[0].index+e[0],offset:L(t.items[0].index,e[1])}}))),(function(e){var t=e.index,o=e.offset;n.handleNext(u,(function(){var e=L(t,n.getValue(s));n.publish(r,{top:e-o})}))})),{}}),n.tup(m,D,F)),Q=n.system((function(e){var t=e[0],r=t.totalCount,o=t.sizeRanges,s=t.fixedItemSize,u=t.defaultItemSize,l=t.trackItemSizes,c=t.data,m=t.firstItemIndex,f=t.groupIndices,p=e[1].initialTopMostItemIndex,d=e[2],h=d.viewportHeight,v=d.scrollTo,g=d.scrollBy,I=d.scrollTop,S=d.smoothScrollTargetReached,C=e[3],x=e[4],y=x.listState,T=x.topItemsIndexes,b=a(x,["listState","topItemsIndexes"]),w=e[5].scrollToIndex,k=e[7].topItemCount,z=e[8].groupCounts,H=e[9];return n.connect(b.rangeChanged,H.scrollSeekRangeChanged),i({totalCount:r,data:c,firstItemIndex:m,sizeRanges:o,viewportHeight:h,scrollTop:I,smoothScrollTargetReached:S,initialTopMostItemIndex:p,topItemsIndexes:T,topItemCount:k,groupCounts:z,fixedItemHeight:s,defaultItemHeight:u,followOutput:C.followOutput,listState:y,scrollTo:v,scrollBy:g,scrollToIndex:w,trackItemSizes:l,groupIndices:f},b,H)}),n.tup(F,N,m,j,D,P,J,Z,A,n.system((function(e){return i({},e[0],e[1],e[2],e[3],e[4])}),n.tup(O,Y,G,_,$))));function X(e){var t,n=!1;return function(){return n||(n=!0,t=e()),t}}var ee=X((function(){if("undefined"==typeof document)return"sticky";var e=document.createElement("div");return e.style.position="-webkit-sticky","-webkit-sticky"===e.style.position?"-webkit-sticky":"sticky"}));function te(e){return e}var ne=n.system((function(){return{itemContent:n.statefulStream((function(e){return"Item "+e})),groupContent:n.statefulStream((function(e){return"Group "+e})),components:n.statefulStream({}),computeItemKey:n.statefulStream(te),headerFooterTag:n.statefulStream("div")}}));function re(e,t){var r=n.stream();return n.subscribe(r,(function(){return console.warn("react-virtuoso: You are using a deprecated property. "+t,"color: red;","color: inherit;","color: blue;")})),n.connect(r,e),r}var oe=n.system((function(e){var t=e[0],r=e[1],o={item:re(r.itemContent,"Rename the %citem%c prop to %citemContent."),group:re(r.groupContent,"Rename the %cgroup%c prop to %cgroupContent."),topItems:re(t.topItemCount,"Rename the %ctopItems%c prop to %ctopItemCount."),itemHeight:re(t.fixedItemHeight,"Rename the %citemHeight%c prop to %cfixedItemHeight."),scrollingStateChange:re(t.isScrolling,"Rename the %cscrollingStateChange%c prop to %cisScrolling."),adjustForPrependedItems:n.stream(),maxHeightCacheSize:n.stream(),footer:n.stream(),header:n.stream(),HeaderContainer:n.stream(),FooterContainer:n.stream(),ItemContainer:n.stream(),ScrollContainer:n.stream(),GroupContainer:n.stream(),ListContainer:n.stream(),emptyComponent:n.stream(),scrollSeek:n.stream()};function s(e,t,o){n.connect(n.pipe(e,n.withLatestFrom(r.components),n.map((function(e){var n,r=e[0],a=e[1];return console.warn("react-virtuoso: "+o+" property is deprecated. Pass components."+t+" instead."),i({},a,((n={})[t]=r,n))}))),r.components)}return n.subscribe(o.adjustForPrependedItems,(function(){console.warn("react-virtuoso: adjustForPrependedItems is no longer supported. Use the firstItemIndex property instead - https://virtuoso.dev/prepend-items.","color: red;","color: inherit;","color: blue;")})),n.subscribe(o.maxHeightCacheSize,(function(){console.warn("react-virtuoso: maxHeightCacheSize is no longer necessary. Setting it has no effect - remove it from your code.")})),n.subscribe(o.HeaderContainer,(function(){console.warn("react-virtuoso: HeaderContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the header component and pass components.Header to change its contents.")})),n.subscribe(o.FooterContainer,(function(){console.warn("react-virtuoso: FooterContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the footer component and pass components.Footer to change its contents.")})),n.subscribe(o.scrollSeek,(function(e){var o=e.placeholder,s=a(e,["placeholder"]);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),n.publish(r.components,i({},n.getValue(r.components),{ScrollSeekPlaceholder:o})),n.publish(t.scrollSeekConfiguration,s)})),s(o.footer,"Footer","footer"),s(o.header,"Header","header"),s(o.ItemContainer,"Item","ItemContainer"),s(o.ListContainer,"List","ListContainer"),s(o.ScrollContainer,"Scroller","ScrollContainer"),s(o.emptyComponent,"EmptyPlaceholder","emptyComponent"),s(o.GroupContainer,"Group","GroupContainer"),i({},t,r,o)}),n.tup(Q,ne)),ie=function(e){return t.createElement("div",{style:{height:e.height}})},ae=t.memo((function(e){var n,r=e.showTopList,o=void 0!==r&&r,i=ve("listState"),a=he("sizeRanges"),s=ve("itemContent"),u=ve("groupContent"),c=(n=a,l((function(e){var t=function(e,t){var n=e.length;if(0===n)return null;for(var r=[],o=0;o<n;o++){var i=e.item(o);if(i&&void 0!==i.dataset.index){var a=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),u=i.offsetHeight;if(0===u)throw new Error("Zero-sized element, this should not happen");if(u!==s){var l=r[r.length-1];0===r.length||l.size!==u||l.endIndex!==a-1?r.push({startIndex:a,endIndex:a,size:u}):r[r.length-1].endIndex++}}}return r}(e.children);null!==t&&n(t)}),ve("trackItemSizes"))),m=ve("components"),f=ve("computeItemKey"),p=ve("isSeeking"),d=ve("components"),h=d.EmptyPlaceholder,v=d.ScrollSeekPlaceholder,g=void 0===v?ie:v,I=d.List,S=void 0===I?"div":I,C=ve("groupIndices").length>0,x=o?{}:{paddingTop:i.offsetTop,paddingBottom:i.offsetBottom},y=m.Item||"div",T=m.Group||"div";return!o&&0===i.items.length&&h?t.createElement(h):t.createElement(S,{ref:c,style:x},(o?i.topItems:i.items).map((function(e){var n=e.originalIndex,r=f(n);return p?t.createElement(g,{key:r,index:e.index,height:e.size}):"group"===e.type?t.createElement(T,{key:r,"data-index":n,"data-known-size":e.size,"data-item-index":e.index},u(e.index)):t.createElement(y,{key:r,"data-index":n,"data-known-size":e.size,"data-item-index":e.index,"data-item-group-index":e.groupIndex},s.apply(null,C?[e.index,e.groupIndex,e.data]:[e.index,e.data]))})))})),se={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},ue={width:"100%",height:"100%",position:"absolute",top:0},le={width:"100%",position:ee(),top:0},ce=t.memo((function(){var e=ve("components"),n=he("headerHeight"),r=ve("headerFooterTag"),o=l((function(e){return n(e.offsetHeight)}));return e.Header?t.createElement(r,{ref:o},t.createElement(e.Header)):null})),me=t.memo((function(){var e=ve("components"),n=he("footerHeight"),r=ve("headerFooterTag"),o=l((function(e){return n(e.offsetHeight)}));return e.Footer?t.createElement(r,{ref:o},t.createElement(e.Footer)):null}));function fe(e){var n=e.usePublisher,r=e.useEmitter,o=e.useEmitterValue;return t.memo((function(e){var s=e.style,u=e.children,l=a(e,["style","children"]),c=n("scrollTop"),m=o("components").Scroller||"div",f=function(e,n){var r=t.useRef(null),o=t.useRef(null),i=t.useRef(null),a=t.useCallback((function(t){var r=t.target.scrollTop;e(Math.max(r,0)),null!==o.current&&r===o.current&&(o.current=null,n(!0),i.current&&(clearTimeout(i.current),i.current=null))}),[e,n]);return t.useEffect((function(){var e=r.current;return a({target:e}),e.addEventListener("scroll",a),function(){e.removeEventListener("scroll",a)}}),[r,a]),{scrollerRef:r,scrollByCallback:function(e){null===o.current&&r.current.scrollBy(e)},scrollToCallback:function(t){var a=r.current;a&&(a.offsetHeight!==a.scrollHeight?(t.top=Math.max(Math.min(a.scrollHeight-a.offsetHeight,t.top),0),"smooth"===t.behavior?(o.current=t.top,i.current&&clearTimeout(i.current),i.current=setTimeout((function(){i.current=null,n(!0)}),1e3)):o.current=null,a.scrollTo(t)):e(a.scrollTop))}}}(c,n("smoothScrollTargetReached")),p=f.scrollerRef,d=f.scrollByCallback;return r("scrollTo",f.scrollToCallback),r("scrollBy",d),t.createElement(m,i({ref:p,style:i({},se,s),tabIndex:0},l),u)}))}var pe=r.systemToComponent(oe,{required:{},optional:{itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",scrollSeekConfiguration:"scrollSeekConfiguration",followOutput:"followOutput",headerFooterTag:"headerFooterTag",data:"data",firstItemIndex:"firstItemIndex",initialItemCount:"initialItemCount",item:"item",group:"group",topItems:"topItems",itemHeight:"itemHeight",scrollingStateChange:"scrollingStateChange",maxHeightCacheSize:"maxHeightCacheSize",footer:"footer",header:"header",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",GroupContainer:"GroupContainer",emptyComponent:"emptyComponent",HeaderContainer:"HeaderContainer",FooterContainer:"FooterContainer",scrollSeek:"scrollSeek"},methods:{scrollToIndex:"scrollToIndex",scrollTo:"scrollTo",scrollBy:"scrollBy",adjustForPrependedItems:"adjustForPrependedItems"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},t.memo((function(e){var r=i({},e),o=he("viewportHeight"),a=l(n.compose(o,n.prop("offsetHeight"))),s=ve("headerHeight");return t.createElement(ge,Object.assign({},r),t.createElement("div",{style:ue,ref:a},t.createElement(ce,null),t.createElement(ae,null),t.createElement(me,null)),t.createElement("div",{style:i({},le,{marginTop:s+"px"})},t.createElement(ae,{showTopList:!0})))}))),de=pe.Component,he=pe.usePublisher,ve=pe.useEmitterValue,ge=fe({usePublisher:he,useEmitterValue:ve,useEmitter:pe.useEmitter}),Ie={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Se={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Ce=Math.ceil,xe=Math.floor,ye=Math.min,Te=Math.max,be=function(e){return Ce(e)-e<.03?Ce(e):xe(e)};function we(e,t){return Array.from({length:t-e+1}).map((function(t,n){return{index:n+e}}))}var ke=n.system((function(e){var t=e[0],r=t.overscan,o=t.visibleRange,a=t.listBoundary,s=e[1],u=s.scrollTop,l=s.viewportHeight,c=s.scrollBy,m=s.scrollTo,f=e[2],p=e[3],d=n.statefulStream(0),h=n.statefulStream(0),v=n.statefulStream(Ie),g=n.statefulStream({height:0,width:0}),I=n.statefulStream({height:0,width:0}),S=n.stream();n.connect(n.pipe(h,n.filter((function(e){return 0!==e})),n.map((function(e){return{items:we(0,e-1),top:0,bottom:0,offsetBottom:0,offsetTop:0,itemHeight:0,itemWidth:0}}))),v),n.connect(n.pipe(n.combineLatest(d,o),n.withLatestFrom(g,I),n.map((function(e){var t=e[0],n=t[0],r=t[1],o=r[0],i=r[1],a=e[1],s=e[2],u=s.height,l=s.width;if(0===n)return Ie;if(0===l)return Se;var c=be(a.width/l),m=c*xe(o/u),f=c*Ce(i/u)-1;f=ye(n-1,f);var p=we(m=ye(f,Te(0,m)),f),d=ze(a,s,p),h=d.top,v=d.bottom;return{items:p,offsetTop:h,offsetBottom:Ce(n/c)*u-v,top:h,bottom:v,itemHeight:u,itemWidth:l}}))),v),n.connect(n.pipe(g,n.map((function(e){return e.height}))),l),n.connect(n.pipe(n.combineLatest(g,I,v),n.map((function(e){var t=ze(e[0],e[1],e[2].items);return[t.top,t.bottom]}))),a),n.connect(n.pipe(a,n.withLatestFrom(v),n.map((function(e){return{bottom:e[0][1],offsetBottom:e[1].offsetBottom}}))),f.listStateListener);var C=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){return e.items.length>0})),n.withLatestFrom(d),n.filter((function(e){var t=e[0].items;return t[t.length-1].index===e[1]-1})),n.map((function(e){return e[1]-1})),n.distinctUntilChanged())),x=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){var t=e.items;return t.length>0&&0===t[0].index})),n.mapTo(0))),y=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){return e.items.length>0})),n.map((function(e){var t=e.items;return{startIndex:t[0].index,endIndex:t[t.length-1].index}})),n.distinctUntilChanged((function(e,t){return e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}))));return n.connect(y,p.scrollSeekRangeChanged),n.connect(n.pipe(S,n.withLatestFrom(g,I,d),n.map((function(e){var t=e[1],n=e[2],r=e[3],o=M(e[0]),i=o.index,a=o.align,s=o.behavior,u=He(t,n,i=Math.max(0,i,Math.min(r-1,i)));return"end"===a?u=Math.round(u-t.height+n.height):"center"===a&&(u=Math.round(u-t.height/2+n.height/2)),{top:u,behavior:s}}))),m),i({totalCount:d,viewportDimensions:g,itemDimensions:I,scrollTop:u,overscan:r,scrollBy:c,scrollTo:m,scrollToIndex:S,initialItemCount:h},p,{gridState:v},f,{startReached:x,endReached:C,rangeChanged:y})}),n.tup(O,m,U,_));function ze(e,t,n){var r=t.height;return void 0===r||0===n.length?{top:0,bottom:0}:{top:He(e,t,n[0].index),bottom:He(e,t,n[n.length-1].index)+r}}function He(e,t,n){var r=be(e.width/t.width);return xe(n/r)*t.height}var Le=function(e){return t.createElement("div",{style:e.style})},Ee=n.system((function(){var e=n.statefulStream((function(e){return"Item "+e})),t=n.statefulStream({}),r=n.statefulStream("virtuoso-grid-item"),o=n.statefulStream("virtuoso-grid-list");return{itemContent:e,components:t,computeItemKey:n.statefulStream(te),itemClassName:r,listClassName:o}})),Fe=n.system((function(e){var t=e[0],r=e[1],o={item:re(r.itemContent,"Rename the %citem%c prop to %citemContent."),ItemContainer:n.stream(),ScrollContainer:n.stream(),ListContainer:n.stream(),emptyComponent:n.stream(),scrollSeek:n.stream()};function s(e,t,o){n.connect(n.pipe(e,n.withLatestFrom(r.components),n.map((function(e){var n,r=e[0],a=e[1];return console.warn("react-virtuoso: "+o+" property is deprecated. Pass components."+t+" instead."),i({},a,((n={})[t]=r,n))}))),r.components)}return n.subscribe(o.scrollSeek,(function(e){var o=e.placeholder,s=a(e,["placeholder"]);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),n.publish(r.components,i({},n.getValue(r.components),{ScrollSeekPlaceholder:o})),n.publish(t.scrollSeekConfiguration,s)})),s(o.ItemContainer,"Item","ItemContainer"),s(o.ListContainer,"List","ListContainer"),s(o.ScrollContainer,"Scroller","ScrollContainer"),i({},t,r,o)}),n.tup(ke,Ee)),Re=t.memo((function(){var e=Pe("gridState"),n=Pe("listClassName"),r=Pe("itemClassName"),o=Pe("itemContent"),i=Pe("computeItemKey"),a=Pe("isSeeking"),s=Pe("components"),u=s.Item,c=void 0===u?"div":u,m=s.List,f=void 0===m?"div":m,p=s.ScrollSeekPlaceholder,d=void 0===p?Le:p,h=Me("itemDimensions"),v=l((function(e){var t=e.firstChild;t&&h({width:t.offsetWidth,height:t.offsetHeight})}));return t.createElement(f,{ref:v,className:n,style:{paddingTop:e.offsetTop,paddingBottom:e.offsetBottom}},e.items.map((function(n){var s=i(n.index);return a?t.createElement(d,{key:s,style:{height:e.itemHeight,width:e.itemWidth}}):t.createElement(c,{className:r,"data-index":n.index,key:s},o(n.index))})))})),Be=r.systemToComponent(Fe,{required:{totalCount:"totalCount"},optional:{overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",item:"item",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",scrollSeek:"scrollSeek"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange"}},t.memo((function(e){var n=i({},e),r=Me("viewportDimensions"),o=l((function(e){r({width:e.offsetWidth,height:e.offsetHeight})}));return t.createElement(Ue,Object.assign({},n),t.createElement("div",{style:ue,ref:o},t.createElement(Re,null)))}))),Oe=Be.Component,Me=Be.usePublisher,Pe=Be.useEmitterValue,Ue=fe({usePublisher:Me,useEmitterValue:Pe,useEmitter:Be.useEmitter}),je=de,Ve=Oe;exports.GroupedVirtuoso=de,exports.Virtuoso=je,exports.VirtuosoGrid=Ve; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("react"),n=require("@virtuoso.dev/urx"),r=require("@virtuoso.dev/react-urx"),o=(e=require("resize-observer-polyfill"))&&"object"==typeof e&&"default"in e?e.default:e;function i(){return(i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function a(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t.indexOf(n=i[r])>=0||(o[n]=e[n]);return o}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function l(e,n){void 0===n&&(n=!0);var r=t.useRef(null),i=new o((function(t){e(t[0].target)}));return function(e){e&&n?(i.observe(e),r.current=e):(r.current&&i.unobserve(r.current),r.current=null)}}var c="up",m=n.system((function(){var e=n.stream(),t=n.stream(),r=n.statefulStream(0),o=n.stream(),i=n.stream(),a=n.stream();n.connect(e,r);var s=n.statefulStream("down");return n.connect(n.pipe(e,n.scan((function(e,t){return{direction:t<e.prevScrollTop?c:"down",prevScrollTop:t}}),{direction:"down",prevScrollTop:0}),n.map((function(e){return e.direction}))),s),{scrollTop:e,viewportHeight:o,smoothScrollTargetReached:t,scrollTo:i,scrollBy:a,scrollDirection:s,statefulScrollTop:r}}),[],{singleton:!0}),f={lvl:0};function p(e,t,n,r,o){return void 0===r&&(r=f),void 0===o&&(o=f),{k:e,v:t,lvl:n,l:r,r:o}}function d(e){return e===f}function h(){return f}function v(e,t){if(d(e))return f;var n=e.k,r=e.l,o=e.r;if(t===n){if(d(r))return o;if(d(o))return r;var i=function e(t){return d(t.r)?[t.k,t.v]:e(t.r)}(r);return T(x(e,{k:i[0],v:i[1],l:S(r)}))}return T(x(e,t<n?{l:v(r,t)}:{r:v(o,t)}))}function g(e,t){if(!d(e))return t===e.k?e.v:g(t<e.k?e.l:e.r,t)}function I(e,t,n){if(void 0===n&&(n="k"),d(e))return[-Infinity,void 0];if(e[n]===t)return[e.k,e.v];if(e[n]<t){var r=I(e.r,t,n);return-Infinity===r[0]?[e.k,e.v]:r}return I(e.l,t,n)}function C(e,t,n){return d(e)?p(t,n,1):t===e.k?x(e,{k:t,v:n}):function(e){return w(k(e))}(x(e,t<e.k?{l:C(e.l,t,n)}:{r:C(e.r,t,n)}))}function S(e){return d(e.r)?e.l:T(x(e,{r:S(e.r)}))}function x(e,t){return p(void 0!==t.k?t.k:e.k,void 0!==t.v?t.v:e.v,void 0!==t.lvl?t.lvl:e.lvl,void 0!==t.l?t.l:e.l,void 0!==t.r?t.r:e.r)}function y(e){return d(e)||e.lvl>e.r.lvl}function T(e){var t=e.l,n=e.r,r=e.lvl;if(n.lvl>=r-1&&t.lvl>=r-1)return e;if(r>n.lvl+1){if(y(t))return k(x(e,{lvl:r-1}));if(d(t)||d(t.r))throw new Error("Unexpected empty nodes");return x(t.r,{l:x(t,{r:t.r.l}),r:x(e,{l:t.r.r,lvl:r-1}),lvl:r})}if(y(e))return w(x(e,{lvl:r-1}));if(d(n)||d(n.l))throw new Error("Unexpected empty nodes");var o=n.l,i=y(o)?n.lvl-1:n.lvl;return x(o,{l:x(e,{r:o.l,lvl:r-1}),r:w(x(n,{l:o.r,lvl:i})),lvl:o.lvl+1})}function b(e,t,n){return d(e)?[]:function(e){if(0===e.length)return[];for(var t=e[0],n=t.k,r=t.v,o=[],i=1;i<=e.length;i++){var a=e[i];o.push({start:n,end:a?a.k-1:Infinity,value:r}),a&&(n=a.k,r=a.v)}return o}(function e(t,n,r){if(d(t))return[];var o=t.k,i=t.v,a=t.r,s=[];return o>n&&(s=s.concat(e(t.l,n,r))),o>=n&&o<=r&&s.push({k:o,v:i}),o<=r&&(s=s.concat(e(a,n,r))),s}(e,I(e,t)[0],n))}function w(e){var t=e.r,n=e.lvl;return d(t)||d(t.r)||t.lvl!==n||t.r.lvl!==n?e:x(t,{l:x(e,{r:t.l}),lvl:n+1})}function k(e){var t=e.l;return d(t)||t.lvl!==e.lvl?e:x(t,{r:x(e,{l:t.r})})}function z(e){var t=e.size,n=e.startIndex,r=e.endIndex;return function(e){return e.start===n&&(e.end===r||Infinity===e.end)&&e.value===t}}function H(e,t){var n=t[0],r=t[1],o=e.sizeTree,i=e.offsetTree,a=o,s=0;if(r.length>0&&d(o)&&2===n.length){var l=n[0].size,c=n[1].size;a=r.reduce((function(e,t){return C(C(e,t,l),t+1,c)}),a)}else{var m=function(e,t,n){void 0===n&&(n=function(){});for(var r,o=d(e)?0:Infinity,i=u(t);!(r=i()).done;){var a=r.value,s=a.size,l=a.startIndex,c=a.endIndex;if(o=Math.min(o,l),d(e))e=C(e,0,s);else{var m=b(e,l-1,c+1);if(!m.some(z(a))){for(var f,p=!1,h=!1,g=u(m);!(f=g()).done;){var I=f.value,S=I.start,x=I.end,y=I.value;p?(c>=S||s===y)&&(e=v(e,S),n(S)):(h=y!==s,p=!0),x>c&&c>=S&&y!==s&&(e=C(e,c+1,y))}h&&(e=C(e,l,s))}}}return[e,o]}(a,n,(function(e){i=v(i,e)}));a=m[0],s=m[1]}if(a===o)return e;var f=0,p=0,S=0;if(0!==s){f=I(i,s-1)[1];var x=I(a,s-1);p=x[0],S=x[1]}else S=g(a,0);for(var y,T=u(b(a,s,Infinity));!(y=T()).done;){var w=y.value,k=w.start,H=w.value,E=(k-p)*S+f;i=C(i,k,E),p=k,f=E,S=H}return{offsetTree:i,sizeTree:a,groupOffsetTree:r.reduce((function(e,t){return C(e,t,L(t,{offsetTree:i,sizeTree:a}))}),h()),lastIndex:p,lastOffset:f,lastSize:S,groupIndices:r}}function L(e,t){if(d(t.offsetTree))return 0;var n=I(t.offsetTree,e),r=n[0],o=n[1];return I(t.sizeTree,e)[1]*(e-r)+o}function E(e,t){if(d(t.groupOffsetTree))return e;for(var n=0;t.groupIndices[n]<=e+n;)n++;return e+n}var F=n.system((function(){var e=n.stream(),t=n.stream(),r=n.stream(),o=n.statefulStream(0),a=n.statefulStream([]),s=n.statefulStream(void 0),u=n.statefulStream(void 0),l=n.statefulStream(void 0),c={offsetTree:h(),sizeTree:h(),groupOffsetTree:h(),lastIndex:0,lastOffset:0,lastSize:0,groupIndices:[]},m=n.statefulStream(!1),f=n.statefulStreamFromEmitter(n.pipe(e,n.withLatestFrom(a),n.scan(H,c),n.distinctUntilChanged()),c);n.connect(n.pipe(a,n.withLatestFrom(f),n.map((function(e){var t=e[0],n=e[1];return i({},n,{groupIndices:t,groupOffsetTree:t.reduce((function(e,t){return C(e,t,L(t,n))}),h())})}))),f),n.connect(n.pipe(a,n.mapTo(!0)),m),n.connect(s,u);var p=n.statefulStreamFromEmitter(n.pipe(s,n.map((function(e){return void 0===e}))),!0);n.connect(n.pipe(u,n.filter((function(e){return void 0!==e})),n.map((function(e){return[{startIndex:0,endIndex:0,size:e}]}))),e);var v=n.streamFromEmitter(n.pipe(e,n.withLatestFrom(f),n.scan((function(e,t){var n=t[1];return{changed:n!==e.sizes,sizes:n}}),{changed:!1,sizes:c}),n.map((function(e){return e.changed}))));return n.connect(n.pipe(l,n.filter((function(e){return void 0!==e})),n.map((function(e){return e.length}))),t),n.connect(n.pipe(r,n.withLatestFrom(f),n.map((function(e){var t=e[0],n=e[1];if(n.groupIndices.length>0)throw new Error("Virtuoso: prepending items does not work with groups");return function e(t){return d(t)?[]:[].concat(e(t.l),[{k:t.k,v:t.v}],e(t.r))}(n.sizeTree).reduce((function(e,n){var r=n.k,o=n.v;return{ranges:[].concat(e.ranges,[{startIndex:e.prevIndex,endIndex:r+t-1,size:e.prevSize}]),prevIndex:r+t,prevSize:o}}),{ranges:[],prevIndex:0,prevSize:n.lastSize}).ranges}))),e),n.connect(n.pipe(o,n.scan((function(e,t){return{diff:e.prev-t,prev:t}}),{diff:0,prev:0}),n.map((function(e){return e.diff})),n.filter((function(e){return e>0}))),r),{data:l,totalCount:t,sizeRanges:e,groupIndices:a,defaultItemSize:u,fixedItemSize:s,unshiftWith:r,firstItemIndex:o,sizes:f,listRefresh:v,trackItemSizes:p}}),[],{singleton:!0}),R=function(e,t){return e&&e[0]===t[0]&&e[1]===t[1]},B=function(e,t,n){return"number"==typeof e?n===c&&"top"===t||"down"===n&&"bottom"===t?e:0:n===c?"top"===t?e.main:e.reverse:"bottom"===t?e.main:e.reverse},O=n.system((function(e){var t=e[0],r=t.scrollTop,o=t.viewportHeight,i=n.stream(),a=n.statefulStream(0),s=n.statefulStream(0),u=n.statefulStream(0),l=n.statefulStream(0);return{listBoundary:i,headerHeight:a,footerHeight:s,overscan:l,topListHeight:u,visibleRange:n.statefulStreamFromEmitter(n.pipe(n.combineLatest(n.duc(r),n.duc(o),n.duc(a),n.duc(i,R),n.duc(l),n.duc(u)),n.map((function(e){var t=e[0],n=e[1],r=e[3],o=e[4],i=t-e[2],a="none";return r[0]>t+e[5]&&(a=c),r[1]<t+n&&(a="down"),"none"!==a?[Math.max(i-B(o,"top",a),0),i+n+B(o,"bottom",a)]:null})),n.filter((function(e){return null!=e}))),[0,0])}}),n.tup(m),{singleton:!0});function M(e){var t="number"==typeof e?{index:e}:e;return t.align||(t.align="start"),t.behavior||(t.behavior="auto"),t}var P=n.system((function(e){var t=e[0],r=t.sizes,o=t.totalCount,i=t.listRefresh,a=e[1],s=a.viewportHeight,u=a.scrollTo,l=a.smoothScrollTargetReached,c=e[2].headerHeight,m=n.stream(),f=n.statefulStream(0),p=null,d=null,h=null,v=function(){p&&(p(),p=null),h&&(h(),h=null),d&&(clearTimeout(d),d=null)};return n.connect(n.pipe(m,n.withLatestFrom(r,s,o,f,c),n.map((function(e){var t=e[0],r=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=M(t),f=c.index,g=c.align,C=c.behavior;f=E(f,r);var S=L(f=Math.max(0,f,Math.min(a-1,f)),r)+u;"end"===g?S=Math.round(S-o+I(r.sizeTree,f)[1]):"center"===g?S=Math.round(S-o/2+I(r.sizeTree,f)[1]/2):S-=s;var x=function(e){v(),e&&n.publish(m,t)};if(v(),"smooth"===C){var y=!1;h=n.subscribe(i,(function(e){y=y||e})),p=n.handleNext(l,(function(){x(y)}))}else p=n.handleNext(i,x);return d=setTimeout((function(){v()}),1200),{top:S,behavior:C}}))),u),{scrollToIndex:m,topListHeight:f}}),n.tup(F,m,O),{singleton:!0}),U=n.system((function(e){var t=e[0],r=t.scrollTop,o=t.viewportHeight,i=n.statefulStream(!1),a=n.statefulStream(!0),s=n.stream(),u=n.stream(),l=n.stream(),c=n.streamFromEmitter(n.pipe(n.merge(n.pipe(n.duc(r),n.skip(1),n.mapTo(!0)),n.pipe(n.duc(r),n.skip(1),n.mapTo(!1),n.debounceTime(200))),n.distinctUntilChanged()));return n.connect(n.pipe(n.duc(r),n.map((function(e){return 0===e})),n.distinctUntilChanged()),a),n.connect(a,u),n.connect(n.pipe(n.combineLatest(n.duc(l),n.duc(r),n.duc(o)),n.map((function(e){var t=e[0];return 0===t.offsetBottom&&e[1]+e[2]-t.bottom>-4})),n.distinctUntilChanged()),i),n.subscribe(i,(function(e){setTimeout((function(){return n.publish(s,e)}))})),{isScrolling:c,isAtTop:a,isAtBottom:i,atTopStateChange:u,atBottomStateChange:s,listStateListener:l}}),n.tup(m)),j=n.system((function(e){var t=e[0],r=t.totalCount,o=t.listRefresh,i=e[1].isAtBottom,a=e[2].scrollToIndex,s=n.statefulStream(!1);return n.subscribe(n.pipe(r,n.withLatestFrom(s,i),n.filter((function(e){return e[1]&&e[2]}))),(function(e){var t=e[0],r=e[1];n.handleNext(o,(function(){var e;n.publish(a,{index:t-1,align:"end",behavior:(e=r,"smooth"===e?"smooth":"auto")})}))})),{followOutput:s}}),n.tup(F,U,P));function V(e){return e.reduce((function(e,t){return e.groupIndices.push(e.totalCount),e.totalCount+=t+1,e}),{totalCount:0,groupIndices:[]})}var A=n.system((function(e){var t=e[0],r=t.totalCount,o=t.groupIndices,i=t.sizes,a=e[1].scrollTop,s=n.stream(),u=n.stream(),l=n.streamFromEmitter(n.pipe(s,n.map(V)));return n.connect(n.pipe(l,n.map(n.prop("totalCount"))),r),n.connect(n.pipe(l,n.map(n.prop("groupIndices"))),o),n.connect(n.pipe(n.combineLatest(a,i),n.filter((function(e){return!d(e[1].groupOffsetTree)})),n.map((function(e){return I(e[1].groupOffsetTree,e[0],"v")[0]})),n.distinctUntilChanged(),n.map((function(e){return[e]}))),u),{groupCounts:s,topItemsIndexes:u}}),n.tup(F,m)),N=n.system((function(e){var t,r=e[0],o=r.sizes,i=r.listRefresh,a=e[1].scrollTop,s=e[2].scrollToIndex,u=n.statefulStream(!0),l=n.statefulStream(0);return n.connect(n.pipe(n.duc(l),n.filter((function(e){return 0!==e})),(void 0===(t=1)&&(t=1),function(e){return function(n){t-- >0&&e(n)}}),n.mapTo(!1)),u),n.subscribe(n.combineLatest(n.duc(l),n.duc(u),i),(function(e){var t=e[0],r=e[1];d(n.getValue(o).sizeTree)||r||(n.handleNext(a,(function(){n.publish(u,!0)})),n.publish(s,t))})),{scrolledToInitialItem:u,initialTopMostItemIndex:l}}),n.tup(F,m,P),{singleton:!0}),G=n.system((function(){return{propsReady:n.statefulStream(!1)}}),[],{singleton:!0}),W={items:[],topItems:[],offsetTop:0,offsetBottom:0,top:0,bottom:0,topListHeight:0};function K(e,t,n){if(0===e.length)return[];if(d(t.groupOffsetTree))return e.map((function(e){return i({},e,{index:e.index+n,originalIndex:e.index})}));for(var r,o=[],a=b(t.groupOffsetTree,e[0].index,e[e.length-1].index),s=void 0,l=0,c=u(e);!(r=c()).done;){var m=r.value;(!s||s.end<m.index)&&(s=a.shift(),l=t.groupIndices.indexOf(s.start)),o.push(i({},m.index===s.start?{type:"group",index:l}:{index:m.index-(l+1)+n,groupIndex:l},{size:m.size,offset:m.offset,originalIndex:m.index,data:m.data}))}return o}function q(e,t,n,r,o){var i=0,a=0;if(e.length>0){i=e[0].offset;var s=e[e.length-1];a=s.offset+s.size}var u=i,l=r.lastOffset+(n-r.lastIndex)*r.lastSize-a;return{items:K(e,r,o),topItems:K(t,r,o),topListHeight:t.reduce((function(e,t){return t.size+e}),0),offsetTop:i,offsetBottom:l,top:u,bottom:a}}var D=n.system((function(e){var t=e[0].statefulScrollTop,r=e[1],o=r.sizes,a=r.totalCount,s=r.data,l=r.firstItemIndex,c=e[2],m=e[3],f=m.visibleRange,p=m.listBoundary,h=m.topListHeight,v=e[4],C=v.scrolledToInitialItem,S=v.initialTopMostItemIndex,x=e[5].topListHeight,y=e[6],T=e[7].propsReady,w=n.statefulStream([]),k=n.stream();n.connect(c.topItemsIndexes,w);var z=n.statefulStreamFromEmitter(n.pipe(n.combineLatest(T,n.duc(f),n.duc(a),n.duc(o),n.duc(S),n.duc(C),n.duc(w),n.duc(l)),n.filter((function(e){return e[0]})),n.withLatestFrom(s),n.map((function(e){var r=e[0],o=r[1],i=o[0],a=o[1],s=r[2],l=r[3],c=r[4],m=r[5],f=r[6],p=r[7],h=e[1],v=l.sizeTree,C=l.offsetTree;if(0===s||0===i&&0===a)return W;if(d(v))return q(function(e,t,n){if(!d(t.groupOffsetTree)){var r=E(e,t);return[{index:I(t.groupOffsetTree,r)[0],size:0,offset:0},{index:r,size:0,offset:0,data:n&&n[0]}]}return[{index:e,size:0,offset:0,data:n&&n[0]}]}(c,l,h),[],s,l,p);var S=[];if(f.length>0)for(var x,y=f[0],T=f[f.length-1],w=0,k=u(b(l.sizeTree,y,T));!(x=k()).done;)for(var z=x.value,H=z.value,L=Math.max(z.start,y),F=Math.min(z.end,T),R=L;R<=F;R++)S.push({index:R,size:H,offset:w,data:h&&h[R]}),w+=H;if(!m)return q([],S,s,l,p);d(l.groupOffsetTree)||(f=[I(l.groupOffsetTree,n.getValue(t),"v")[0]]);var B=f.length>0?f[f.length-1]+1:0,O=Math.max(B,I(C,i,"v")[0]),M=I(C,a,"v")[0],P=s-1;return q(n.tap([],(function(e){for(var t,n=u(b(C,O,M));!(t=n()).done;){var r=t.value,o=r.value,s=r.start,l=g(v,s);r.value<i&&(o+=((s+=Math.floor((i-r.value)/l))-r.start)*l),s<B&&(o+=(B-s)*l,s=B);for(var c=Math.min(r.end,P),m=s;m<=c&&!(o>=a);m++)e.push({index:m,size:l,offset:o,data:h&&h[m]}),o+=l}})),S,s,l,p)}))),W);return n.connect(n.pipe(n.duc(z),n.map(n.prop("topListHeight"))),x),n.connect(x,h),n.connect(z,y.listStateListener),n.connect(n.pipe(n.duc(z),n.map((function(e){return[e.top,e.bottom]}))),p),n.connect(n.pipe(n.duc(z),n.map((function(e){return e.items}))),k),i({listState:z,topItemsIndexes:w,endReached:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){return e.items.length>0})),n.withLatestFrom(a),n.filter((function(e){var t=e[0].items;return t[t.length-1].originalIndex===e[1]-1})),n.map((function(e){return e[1]-1})),n.distinctUntilChanged())),startReached:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){var t=e.items;return t.length>0&&0===t[0].originalIndex})),n.mapTo(0))),rangeChanged:n.streamFromEmitter(n.pipe(n.duc(z),n.filter((function(e){return e.items.length>0})),n.map((function(e){var t=e.items;return{startIndex:t[0].originalIndex,endIndex:t[t.length-1].originalIndex}})),n.distinctUntilChanged((function(e,t){return e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex})))),itemsRendered:k},y)}),n.tup(m,F,A,O,N,P,U,G),{singleton:!0}),Y=n.system((function(e){var t=e[0],r=t.sizes,o=t.firstItemIndex,i=e[1].listState,a=e[2].propsReady,s=n.statefulStream(0);return n.connect(n.pipe(n.combineLatest(s,a),n.filter((function(e){return e[1]&&0!==e[0]})),n.withLatestFrom(r,o),n.map((function(e){var t=e[0][0],n=e[1],r=e[2],o=0;if(n.groupIndices.length>0)for(var i,a=u(n.groupIndices);!((i=a()).done||i.value-o>=t);)o++;var s=t+o;return q(Array.from({length:s}).map((function(e,t){return{index:t,size:0,offset:0}})),[],s,n,r)}))),i),{initialItemCount:s}}),n.tup(F,D,G),{singleton:!0}),_=n.system((function(e){var t=e[0].scrollTop,r=e[1].isScrolling,o=n.statefulStream(0),i=n.statefulStream(!1),a=n.stream(),s=n.statefulStream(!1);return n.connect(n.pipe(r,n.filter((function(e){return!e})),n.mapTo(0)),o),n.connect(n.pipe(t,n.throttleTime(100),n.scan((function(e,t){return[e[1],t]}),[0,0]),n.map((function(e){return e[1]-e[0]}))),o),n.connect(n.pipe(o,n.withLatestFrom(s,i,a),n.filter((function(e){return!!e[1]})),n.map((function(e){var t=e[0],n=e[1],r=e[2],o=e[3],i=n.enter;if(r){if((0,n.exit)(t,o))return!1}else if(i(t,o))return!0;return r})),n.distinctUntilChanged()),i),n.subscribe(n.pipe(n.combineLatest(i,o,a),n.withLatestFrom(s)),(function(e){var t=e[0],n=e[1];return t[0]&&n&&n.change&&n.change(t[1],t[2])})),{isSeeking:i,scrollSeekConfiguration:s,scrollVelocity:o,scrollSeekRangeChanged:a}}),n.tup(m,U),{singleton:!0}),Z=n.system((function(e){var t=e[0].topItemsIndexes,r=n.statefulStream(0);return n.connect(n.pipe(r,n.filter((function(e){return e>0})),n.map((function(e){return Array.from({length:e}).map((function(e,t){return t}))}))),t),{topItemCount:r}}),n.tup(D)),$=n.system((function(e){var t=e[0],r=t.footerHeight,o=t.headerHeight,i=e[1].listState,a=n.stream(),s=n.statefulStreamFromEmitter(n.pipe(n.combineLatest(r,o,i),n.map((function(e){var t=e[2];return e[0]+e[1]+t.offsetBottom+t.bottom}))),0);return n.connect(n.duc(s),a),{totalListHeight:s,totalListHeightChanged:a}}),n.tup(O,D),{singleton:!0}),J=n.system((function(e){var t=e[0],r=t.scrollBy,o=e[1].listState,i=e[2],a=i.unshiftWith,s=i.sizes,u=i.listRefresh;return n.connect(n.pipe(o,n.withLatestFrom(t.scrollTop,t.scrollDirection),n.filter((function(e){return 0!==e[1]&&e[2]===c})),n.map((function(e){return e[0]})),n.scan((function(e,t){var n=e[1],r=t.items,o=0;if(n.length>0&&r.length>0&&(0!==n[0].originalIndex||0!==r[0].originalIndex)){var i=function(e){var t=r[e],i=n.find((function(e){return e.originalIndex===t.originalIndex}));return i?t.offset!==i.offset?(o=t.offset-i.offset,"break"):void 0:"continue"};e:for(var a=r.length-1;a>=0;a--)switch(i(a)){case"continue":continue;case"break":break e}}return[o,r]}),[0,[]]),n.filter((function(e){return 0!==e[0]})),n.map((function(e){return{top:e[0],behavior:"auto"}}))),r),n.subscribe(n.pipe(a,n.withLatestFrom(s,o),n.map((function(e){var t=e[2];return{index:t.items[0].index+e[0],offset:L(t.items[0].index,e[1])}}))),(function(e){var t=e.index,o=e.offset;n.handleNext(u,(function(){var e=L(t,n.getValue(s));n.publish(r,{top:e-o})}))})),{}}),n.tup(m,D,F)),Q=n.system((function(e){var t=e[0],r=t.totalCount,o=t.sizeRanges,s=t.fixedItemSize,u=t.defaultItemSize,l=t.trackItemSizes,c=t.data,m=t.firstItemIndex,f=t.groupIndices,p=e[1].initialTopMostItemIndex,d=e[2],h=d.viewportHeight,v=d.scrollTo,g=d.scrollBy,I=d.scrollTop,C=d.smoothScrollTargetReached,S=e[3],x=e[4],y=x.listState,T=x.topItemsIndexes,b=a(x,["listState","topItemsIndexes"]),w=e[5].scrollToIndex,k=e[7].topItemCount,z=e[8].groupCounts,H=e[9];return n.connect(b.rangeChanged,H.scrollSeekRangeChanged),i({totalCount:r,data:c,firstItemIndex:m,sizeRanges:o,viewportHeight:h,scrollTop:I,smoothScrollTargetReached:C,initialTopMostItemIndex:p,topItemsIndexes:T,topItemCount:k,groupCounts:z,fixedItemHeight:s,defaultItemHeight:u,followOutput:S.followOutput,listState:y,scrollTo:v,scrollBy:g,scrollToIndex:w,trackItemSizes:l,groupIndices:f},b,H)}),n.tup(F,N,m,j,D,P,J,Z,A,n.system((function(e){return i({},e[0],e[1],e[2],e[3],e[4])}),n.tup(O,Y,G,_,$))));function X(e){var t,n=!1;return function(){return n||(n=!0,t=e()),t}}var ee=X((function(){if("undefined"==typeof document)return"sticky";var e=document.createElement("div");return e.style.position="-webkit-sticky","-webkit-sticky"===e.style.position?"-webkit-sticky":"sticky"}));function te(e){return e}var ne=n.system((function(){return{itemContent:n.statefulStream((function(e){return"Item "+e})),groupContent:n.statefulStream((function(e){return"Group "+e})),components:n.statefulStream({}),computeItemKey:n.statefulStream(te),headerFooterTag:n.statefulStream("div")}}));function re(e,t){var r=n.stream();return n.subscribe(r,(function(){return console.warn("react-virtuoso: You are using a deprecated property. "+t,"color: red;","color: inherit;","color: blue;")})),n.connect(r,e),r}var oe=n.system((function(e){var t=e[0],r=e[1],o={item:re(r.itemContent,"Rename the %citem%c prop to %citemContent."),group:re(r.groupContent,"Rename the %cgroup%c prop to %cgroupContent."),topItems:re(t.topItemCount,"Rename the %ctopItems%c prop to %ctopItemCount."),itemHeight:re(t.fixedItemHeight,"Rename the %citemHeight%c prop to %cfixedItemHeight."),scrollingStateChange:re(t.isScrolling,"Rename the %cscrollingStateChange%c prop to %cisScrolling."),adjustForPrependedItems:n.stream(),maxHeightCacheSize:n.stream(),footer:n.stream(),header:n.stream(),HeaderContainer:n.stream(),FooterContainer:n.stream(),ItemContainer:n.stream(),ScrollContainer:n.stream(),GroupContainer:n.stream(),ListContainer:n.stream(),emptyComponent:n.stream(),scrollSeek:n.stream()};function s(e,t,o){n.connect(n.pipe(e,n.withLatestFrom(r.components),n.map((function(e){var n,r=e[0],a=e[1];return console.warn("react-virtuoso: "+o+" property is deprecated. Pass components."+t+" instead."),i({},a,((n={})[t]=r,n))}))),r.components)}return n.subscribe(o.adjustForPrependedItems,(function(){console.warn("react-virtuoso: adjustForPrependedItems is no longer supported. Use the firstItemIndex property instead - https://virtuoso.dev/prepend-items.","color: red;","color: inherit;","color: blue;")})),n.subscribe(o.maxHeightCacheSize,(function(){console.warn("react-virtuoso: maxHeightCacheSize is no longer necessary. Setting it has no effect - remove it from your code.")})),n.subscribe(o.HeaderContainer,(function(){console.warn("react-virtuoso: HeaderContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the header component and pass components.Header to change its contents.")})),n.subscribe(o.FooterContainer,(function(){console.warn("react-virtuoso: FooterContainer is deprecated. Use headerFooterTag if you want to change the wrapper of the footer component and pass components.Footer to change its contents.")})),n.subscribe(o.scrollSeek,(function(e){var o=e.placeholder,s=a(e,["placeholder"]);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),n.publish(r.components,i({},n.getValue(r.components),{ScrollSeekPlaceholder:o})),n.publish(t.scrollSeekConfiguration,s)})),s(o.footer,"Footer","footer"),s(o.header,"Header","header"),s(o.ItemContainer,"Item","ItemContainer"),s(o.ListContainer,"List","ListContainer"),s(o.ScrollContainer,"Scroller","ScrollContainer"),s(o.emptyComponent,"EmptyPlaceholder","emptyComponent"),s(o.GroupContainer,"Group","GroupContainer"),i({},t,r,o)}),n.tup(Q,ne)),ie=function(e){return t.createElement("div",{style:{height:e.height}})},ae=t.memo((function(e){var n,r=e.showTopList,o=void 0!==r&&r,i=ve("listState"),a=he("sizeRanges"),s=ve("itemContent"),u=ve("groupContent"),c=(n=a,l((function(e){var t=function(e,t){var n=e.length;if(0===n)return null;for(var r=[],o=0;o<n;o++){var i=e.item(o);if(i&&void 0!==i.dataset.index){var a=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),u=i.offsetHeight;if(0===u)throw new Error("Zero-sized element, this should not happen");if(u!==s){var l=r[r.length-1];0===r.length||l.size!==u||l.endIndex!==a-1?r.push({startIndex:a,endIndex:a,size:u}):r[r.length-1].endIndex++}}}return r}(e.children);null!==t&&n(t)}),ve("trackItemSizes"))),m=ve("components"),f=ve("computeItemKey"),p=ve("isSeeking"),d=ve("components"),h=d.EmptyPlaceholder,v=d.ScrollSeekPlaceholder,g=void 0===v?ie:v,I=d.List,C=void 0===I?"div":I,S=ve("groupIndices").length>0,x=o?{}:{paddingTop:i.offsetTop,paddingBottom:i.offsetBottom},y=m.Item||"div",T=m.Group||"div";return!o&&0===i.items.length&&h?t.createElement(h):t.createElement(C,{ref:c,style:x},(o?i.topItems:i.items).map((function(e){var n=e.originalIndex,r=f(n);return p?t.createElement(g,{key:r,index:e.index,height:e.size}):"group"===e.type?t.createElement(T,{key:r,"data-index":n,"data-known-size":e.size,"data-item-index":e.index},u(e.index)):t.createElement(y,{key:r,"data-index":n,"data-known-size":e.size,"data-item-index":e.index,"data-item-group-index":e.groupIndex},s.apply(null,S?[e.index,e.groupIndex,e.data]:[e.index,e.data]))})))})),se={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},ue={width:"100%",height:"100%",position:"absolute",top:0},le={width:"100%",position:ee(),top:0},ce=t.memo((function(){var e=ve("components"),n=he("headerHeight"),r=ve("headerFooterTag"),o=l((function(e){return n(e.offsetHeight)}));return e.Header?t.createElement(r,{ref:o},t.createElement(e.Header)):null})),me=t.memo((function(){var e=ve("components"),n=he("footerHeight"),r=ve("headerFooterTag"),o=l((function(e){return n(e.offsetHeight)}));return e.Footer?t.createElement(r,{ref:o},t.createElement(e.Footer)):null}));function fe(e){var n=e.usePublisher,r=e.useEmitter,o=e.useEmitterValue;return t.memo((function(e){var s=e.style,u=e.children,l=a(e,["style","children"]),c=n("scrollTop"),m=o("components").Scroller||"div",f=function(e,n){var r=t.useRef(null),o=t.useRef(null),i=t.useRef(null),a=t.useCallback((function(t){var r=t.target.scrollTop;e(Math.max(r,0)),null!==o.current&&r===o.current&&(o.current=null,n(!0),i.current&&(clearTimeout(i.current),i.current=null))}),[e,n]);return t.useEffect((function(){var e=r.current;return a({target:e}),e.addEventListener("scroll",a),function(){e.removeEventListener("scroll",a)}}),[r,a]),{scrollerRef:r,scrollByCallback:function(e){null===o.current&&r.current.scrollBy(e)},scrollToCallback:function(t){var a=r.current;a&&(a.offsetHeight!==a.scrollHeight?(t.top=Math.max(Math.min(a.scrollHeight-a.offsetHeight,t.top),0),"smooth"===t.behavior?(o.current=t.top,i.current&&clearTimeout(i.current),i.current=setTimeout((function(){i.current=null,n(!0)}),1e3)):o.current=null,a.scrollTo(t)):e(a.scrollTop))}}}(c,n("smoothScrollTargetReached")),p=f.scrollerRef,d=f.scrollByCallback;return r("scrollTo",f.scrollToCallback),r("scrollBy",d),t.createElement(m,i({ref:p,style:i({},se,s),tabIndex:0},l),u)}))}var pe=r.systemToComponent(oe,{required:{},optional:{itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedItemHeight:"fixedItemHeight",scrollSeekConfiguration:"scrollSeekConfiguration",followOutput:"followOutput",headerFooterTag:"headerFooterTag",data:"data",firstItemIndex:"firstItemIndex",initialItemCount:"initialItemCount",item:"item",group:"group",topItems:"topItems",itemHeight:"itemHeight",scrollingStateChange:"scrollingStateChange",maxHeightCacheSize:"maxHeightCacheSize",footer:"footer",header:"header",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",GroupContainer:"GroupContainer",emptyComponent:"emptyComponent",HeaderContainer:"HeaderContainer",FooterContainer:"FooterContainer",scrollSeek:"scrollSeek"},methods:{scrollToIndex:"scrollToIndex",scrollTo:"scrollTo",scrollBy:"scrollBy",adjustForPrependedItems:"adjustForPrependedItems"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},t.memo((function(e){var r=i({},e),o=he("viewportHeight"),a=l(n.compose(o,n.prop("offsetHeight"))),s=ve("headerHeight");return t.createElement(ge,Object.assign({},r),t.createElement("div",{style:ue,ref:a},t.createElement(ce,null),t.createElement(ae,null),t.createElement(me,null)),t.createElement("div",{style:i({},le,{marginTop:s+"px"})},t.createElement(ae,{showTopList:!0})))}))),de=pe.Component,he=pe.usePublisher,ve=pe.useEmitterValue,ge=fe({usePublisher:he,useEmitterValue:ve,useEmitter:pe.useEmitter}),Ie={items:[],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Ce={items:[{index:0}],offsetBottom:0,offsetTop:0,top:0,bottom:0,itemHeight:0,itemWidth:0},Se=Math.ceil,xe=Math.floor,ye=Math.min,Te=Math.max,be=function(e){return Se(e)-e<.03?Se(e):xe(e)};function we(e,t){return Array.from({length:t-e+1}).map((function(t,n){return{index:n+e}}))}var ke=n.system((function(e){var t=e[0],r=t.overscan,o=t.visibleRange,a=t.listBoundary,s=e[1],u=s.scrollTop,l=s.viewportHeight,c=s.scrollBy,m=s.scrollTo,f=e[2],p=e[3],d=n.statefulStream(0),h=n.statefulStream(0),v=n.statefulStream(Ie),g=n.statefulStream({height:0,width:0}),I=n.statefulStream({height:0,width:0}),C=n.stream();n.connect(n.pipe(h,n.filter((function(e){return 0!==e})),n.map((function(e){return{items:we(0,e-1),top:0,bottom:0,offsetBottom:0,offsetTop:0,itemHeight:0,itemWidth:0}}))),v),n.connect(n.pipe(n.combineLatest(d,o),n.withLatestFrom(g,I),n.map((function(e){var t=e[0],n=t[0],r=t[1],o=r[0],i=r[1],a=e[1],s=e[2],u=s.height,l=s.width;if(0===n)return Ie;if(0===l)return Ce;var c=be(a.width/l),m=c*xe(o/u),f=c*Se(i/u)-1;f=ye(n-1,f);var p=we(m=ye(f,Te(0,m)),f),d=ze(a,s,p),h=d.top,v=d.bottom;return{items:p,offsetTop:h,offsetBottom:Se(n/c)*u-v,top:h,bottom:v,itemHeight:u,itemWidth:l}}))),v),n.connect(n.pipe(g,n.map((function(e){return e.height}))),l),n.connect(n.pipe(n.combineLatest(g,I,v),n.map((function(e){var t=ze(e[0],e[1],e[2].items);return[t.top,t.bottom]}))),a),n.connect(n.pipe(a,n.withLatestFrom(v),n.map((function(e){return{bottom:e[0][1],offsetBottom:e[1].offsetBottom}}))),f.listStateListener);var S=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){return e.items.length>0})),n.withLatestFrom(d),n.filter((function(e){var t=e[0].items;return t[t.length-1].index===e[1]-1})),n.map((function(e){return e[1]-1})),n.distinctUntilChanged())),x=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){var t=e.items;return t.length>0&&0===t[0].index})),n.mapTo(0))),y=n.streamFromEmitter(n.pipe(n.duc(v),n.filter((function(e){return e.items.length>0})),n.map((function(e){var t=e.items;return{startIndex:t[0].index,endIndex:t[t.length-1].index}})),n.distinctUntilChanged((function(e,t){return e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex}))));return n.connect(y,p.scrollSeekRangeChanged),n.connect(n.pipe(C,n.withLatestFrom(g,I,d),n.map((function(e){var t=e[1],n=e[2],r=e[3],o=M(e[0]),i=o.index,a=o.align,s=o.behavior,u=He(t,n,i=Math.max(0,i,Math.min(r-1,i)));return"end"===a?u=Math.round(u-t.height+n.height):"center"===a&&(u=Math.round(u-t.height/2+n.height/2)),{top:u,behavior:s}}))),m),i({totalCount:d,viewportDimensions:g,itemDimensions:I,scrollTop:u,overscan:r,scrollBy:c,scrollTo:m,scrollToIndex:C,initialItemCount:h},p,{gridState:v},f,{startReached:x,endReached:S,rangeChanged:y})}),n.tup(O,m,U,_));function ze(e,t,n){var r=t.height;return void 0===r||0===n.length?{top:0,bottom:0}:{top:He(e,t,n[0].index),bottom:He(e,t,n[n.length-1].index)+r}}function He(e,t,n){var r=be(e.width/t.width);return xe(n/r)*t.height}var Le=function(e){return t.createElement("div",{style:e.style})},Ee=n.system((function(){var e=n.statefulStream((function(e){return"Item "+e})),t=n.statefulStream({}),r=n.statefulStream("virtuoso-grid-item"),o=n.statefulStream("virtuoso-grid-list");return{itemContent:e,components:t,computeItemKey:n.statefulStream(te),itemClassName:r,listClassName:o}})),Fe=n.system((function(e){var t=e[0],r=e[1],o={item:re(r.itemContent,"Rename the %citem%c prop to %citemContent."),ItemContainer:n.stream(),ScrollContainer:n.stream(),ListContainer:n.stream(),emptyComponent:n.stream(),scrollSeek:n.stream()};function s(e,t,o){n.connect(n.pipe(e,n.withLatestFrom(r.components),n.map((function(e){var n,r=e[0],a=e[1];return console.warn("react-virtuoso: "+o+" property is deprecated. Pass components."+t+" instead."),i({},a,((n={})[t]=r,n))}))),r.components)}return n.subscribe(o.scrollSeek,(function(e){var o=e.placeholder,s=a(e,["placeholder"]);console.warn("react-virtuoso: scrollSeek property is deprecated. Pass scrollSeekConfiguration and specify the placeholder in components.ScrollSeekPlaceholder instead."),n.publish(r.components,i({},n.getValue(r.components),{ScrollSeekPlaceholder:o})),n.publish(t.scrollSeekConfiguration,s)})),s(o.ItemContainer,"Item","ItemContainer"),s(o.ListContainer,"List","ListContainer"),s(o.ScrollContainer,"Scroller","ScrollContainer"),i({},t,r,o)}),n.tup(ke,Ee)),Re=t.memo((function(){var e=Pe("gridState"),n=Pe("listClassName"),r=Pe("itemClassName"),o=Pe("itemContent"),i=Pe("computeItemKey"),a=Pe("isSeeking"),s=Pe("components"),u=s.Item,c=void 0===u?"div":u,m=s.List,f=void 0===m?"div":m,p=s.ScrollSeekPlaceholder,d=void 0===p?Le:p,h=Me("itemDimensions"),v=l((function(e){var t=e.firstChild;t&&h({width:t.offsetWidth,height:t.offsetHeight})}));return t.createElement(f,{ref:v,className:n,style:{paddingTop:e.offsetTop,paddingBottom:e.offsetBottom}},e.items.map((function(n){var s=i(n.index);return a?t.createElement(d,{key:s,style:{height:e.itemHeight,width:e.itemWidth}}):t.createElement(c,{className:r,"data-index":n.index,key:s},o(n.index))})))})),Be=r.systemToComponent(Fe,{required:{totalCount:"totalCount"},optional:{overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",item:"item",ItemContainer:"ItemContainer",ScrollContainer:"ScrollContainer",ListContainer:"ListContainer",scrollSeek:"scrollSeek"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange"}},t.memo((function(e){var n=i({},e),r=Me("viewportDimensions"),o=l((function(e){r({width:e.offsetWidth,height:e.offsetHeight})}));return t.createElement(Ue,Object.assign({},n),t.createElement("div",{style:ue,ref:o},t.createElement(Re,null)))}))),Oe=Be.Component,Me=Be.usePublisher,Pe=Be.useEmitterValue,Ue=fe({usePublisher:Me,useEmitterValue:Pe,useEmitter:Be.useEmitter}),je=de,Ve=Oe;exports.GroupedVirtuoso=de,exports.Virtuoso=je,exports.VirtuosoGrid=Ve; | ||
//# sourceMappingURL=react-virtuoso.cjs.production.min.js.map |
@@ -22,3 +22,3 @@ export interface ListBottomInfo { | ||
}]) => { | ||
isScrolling: import("@virtuoso.dev/urx").StatefulStream<boolean>; | ||
isScrolling: import("@virtuoso.dev/urx").Stream<boolean>; | ||
isAtTop: import("@virtuoso.dev/urx").StatefulStream<boolean>; | ||
@@ -25,0 +25,0 @@ isAtBottom: import("@virtuoso.dev/urx").StatefulStream<boolean>; |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "1.0.0-beta.2", | ||
"version": "1.0.0-beta.3", | ||
"publishConfig": { | ||
@@ -8,0 +8,0 @@ "tag": "next" |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1279788