react-virtuoso
Advanced tools
Comparing version 0.12.1 to 0.12.2
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),n=e(t),r=e(require("resize-observer-polyfill"));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 o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t,n){return(u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&a(i,n.prototype),i}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return u(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}var f=t.createContext(void 0);function c(e){return function(){var t=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e,t){return t(e)}:1===t.length?t[0]:function(e,n){var r=function(e){return n(e)};t.slice().reverse().forEach(function(e){var t=r;r=function(n){return e(n,t)}}),r(e)}}.apply(void 0,arguments);return function(e,t){var n=function(n){return e(function(e){return t(e,n)})};return{subscribe:n,pipe:c(n)}}(e,t)}}function h(e,t){void 0===t&&(t=!0);var n=[],r=e,i=function(e){return n.push(e),void 0!==r&&e(r),function(){n=n.filter(function(t){return t!==e})}};return{next:function(e){t&&e===r||(r=e,n.forEach(function(t){return t(e)}))},subscribe:i,pipe:c(i),subscribers:n}}function d(){var e=[],t=function(t){return e.push(t),function(){e=e.filter(function(e){return e!==t})}};return{next:function(t){e.forEach(function(e){return e(t)})},subscribe:t,pipe:c(t)}}function v(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length),o=[],s=function(e){r.every(function(e){return e})&&e.forEach(function(e){return e(i)})};t.forEach(function(e,t){e.subscribe(function(e){r[t]=!0,i[t]=e,s(o)})});var a=function(e){return o.push(e),s([e]),function(){o=o.filter(function(t){return t!==e})}};return{subscribe:a,pipe:c(a)}}function p(e){return function(t,n){n(e(t))}}function g(e){return function(t,n){return n(e)}}function m(e){return function(t,n){e>0?e--:n(t)}}function y(e){return function(t,n){e(t)&&n(t)}}function x(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length);return t.forEach(function(e,t){e.subscribe(function(e){i[t]=e,r[t]=!0})}),function(e,t){r.every(function(e){return e})&&t([e].concat(i))}}var b=new(function(){function e(){this.level=0}var t=e.prototype;return t.rebalance=function(){return this},t.adjust=function(){return this},t.remove=function(){return this},t.find=function(){},t.findWith=function(){},t.findMax=function(){return-Infinity},t.findMaxValue=function(){},t.insert=function(e,t){return new C({key:e,value:t,level:1})},t.walkWithin=function(){return[]},t.walk=function(){return[]},t.ranges=function(){return[]},t.rangesWithin=function(){return[]},t.empty=function(){return!0},t.isSingle=function(){return!0},t.isInvariant=function(){return!0},t.keys=function(){return[]},e}());Object.freeze(b);var k=function(e){function t(t){return e.call(this,"Unreachable case: "+t)||this}return o(t,e),t}(l(Error)),C=function(){function e(e){var t=e.value,n=e.level,r=e.left,i=void 0===r?b:r,o=e.right,s=void 0===o?b:o;this.key=e.key,this.value=t,this.level=n,this.left=i,this.right=s}var t=e.prototype;return t.remove=function(e){var t=this.left,n=this.right;if(e===this.key){if(t.empty())return n;if(n.empty())return t;var r=t.last();return this.clone({key:r[0],value:r[1],left:t.deleteLast()}).adjust()}return e<this.key?this.clone({left:t.remove(e)}).adjust():this.clone({right:n.remove(e)}).adjust()},t.empty=function(){return!1},t.find=function(e){return e===this.key?this.value:e<this.key?this.left.find(e):this.right.find(e)},t.findWith=function(e){var t=e(this.value);switch(t){case-1:return this.left.findWith(e);case 0:return[this.key,this.value];case 1:return this.right.findWith(e);default:throw new k(t)}},t.findMax=function(e){if(this.key===e)return e;if(this.key<e){var t=this.right.findMax(e);return-Infinity===t?this.key:t}return this.left.findMax(e)},t.findMaxValue=function(e){if(this.key===e)return this.value;if(this.key<e){var t=this.right.findMaxValue(e);return void 0===t?this.value:t}return this.left.findMaxValue(e)},t.insert=function(e,t){return e===this.key?this.clone({key:e,value:t}):e<this.key?this.clone({left:this.left.insert(e,t)}).rebalance():this.clone({right:this.right.insert(e,t)}).rebalance()},t.walkWithin=function(e,t){var n=this.key,r=this.value,i=[];return n>e&&(i=i.concat(this.left.walkWithin(e,t))),n>=e&&n<=t&&i.push({key:n,value:r}),n<=t&&(i=i.concat(this.right.walkWithin(e,t))),i},t.walk=function(){return[].concat(this.left.walk(),[{key:this.key,value:this.value}],this.right.walk())},t.last=function(){return this.right.empty()?[this.key,this.value]:this.right.last()},t.deleteLast=function(){return this.right.empty()?this.left:this.clone({right:this.right.deleteLast()}).adjust()},t.clone=function(t){return new e({key:void 0!==t.key?t.key:this.key,value:void 0!==t.value?t.value:this.value,level:void 0!==t.level?t.level:this.level,left:void 0!==t.left?t.left:this.left,right:void 0!==t.right?t.right:this.right})},t.isSingle=function(){return this.level>this.right.level},t.rebalance=function(){return this.skew().split()},t.adjust=function(){var e=this.left,t=this.right,n=this.level;if(t.level>=n-1&&e.level>=n-1)return this;if(n>t.level+1){if(e.isSingle())return this.clone({level:n-1}).skew();if(e.empty()||e.right.empty())throw new Error("Unexpected empty nodes");return e.right.clone({left:e.clone({right:e.right.left}),right:this.clone({left:e.right.right,level:n-1}),level:n})}if(this.isSingle())return this.clone({level:n-1}).split();if(t.empty()||t.left.empty())throw new Error("Unexpected empty nodes");var r=t.left,i=r.isSingle()?t.level-1:t.level;return r.clone({left:this.clone({right:r.left,level:n-1}),right:t.clone({left:r.right,level:i}).split(),level:r.level+1})},t.isInvariant=function(){var e=this.left,t=this.right,n=this.level;return n===e.level+1&&(n===t.level||n===t.level+1)&&!(!t.empty()&&n<=t.right.level)&&e.isInvariant()&&t.isInvariant()},t.keys=function(){return[].concat(this.left.keys(),[this.key],this.right.keys())},t.ranges=function(){return this.toRanges(this.walk())},t.rangesWithin=function(e,t){return this.toRanges(this.walkWithin(e,t))},t.toRanges=function(e){if(0===e.length)return[];for(var t=e[0],n=t.key,r=t.value,i=[],o=1;o<=e.length;o++){var s=e[o];i.push({start:n,end:s?s.key-1:Infinity,value:r}),s&&(n=s.key,r=s.value)}return i},t.split=function(){var e=this.right,t=this.level;return e.empty()||e.right.empty()||e.level!=t||e.right.level!=t?this:e.clone({left:this.clone({right:e.left}),level:t+1})},t.skew=function(){var e=this.left;return e.empty()||e.level!==this.level?this:e.clone({right:this.clone({left:e.right})})},e}(),w=function(){function e(e){this.root=e}e.empty=function(){return new e(b)};var t=e.prototype;return t.find=function(e){return this.root.find(e)},t.findMax=function(e){return this.root.findMax(e)},t.findMaxValue=function(e){if(this.empty())throw new Error("Searching for max value in an empty tree");return this.root.findMaxValue(e)},t.findWith=function(e){return this.root.findWith(e)},t.insert=function(t,n){return new e(this.root.insert(t,n))},t.remove=function(t){return new e(this.root.remove(t))},t.empty=function(){return this.root.empty()},t.keys=function(){return this.root.keys()},t.walk=function(){return this.root.walk()},t.walkWithin=function(e,t){var n=this.root.findMax(e);return this.root.walkWithin(n,t)},t.ranges=function(){return this.root.ranges()},t.rangesWithin=function(e,t){var n=this.root.findMax(e);return this.root.rangesWithin(n,t)},t.isInvariant=function(){return this.root.isInvariant()},e}(),I=function(){function e(e){this.nanIndices=[],this.rangeTree=e;var t=w.empty(),n=0,r=!1,i=e.ranges(),o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a.start,l=a.end,f=a.value;isNaN(f)?(this.nanIndices.push(u),r||(t=t.insert(n,{startIndex:u,endIndex:Infinity,size:f})),r=!0):r||(t=t.insert(n,{startIndex:u,endIndex:l,size:f}),n+=(l-u+1)*f)}this.offsetTree=t}e.create=function(){return new e(w.empty())};var t=e.prototype;return t.empty=function(){return this.rangeTree.empty()},t.insert=function(t,n,r){var i=this.rangeTree;if(i.empty())return new e(i.insert(0,r));if(this.nanIndices.length&&this.nanIndices.indexOf(n)>-1){if(i.find(this.nanIndices[0]-1)===r)return new e(w.empty().insert(0,r));var o=this.nanIndices,s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}i=i.insert(u,r)}return new e(i)}var l=i.rangesWithin(t-1,n+1);if(l.some(function(e){return e.start===t&&(e.end===n||Infinity===e.end)&&e.value===r}))return this;var f=!1,c=!1,h=l,d=Array.isArray(h),v=0;for(h=d?h:h[Symbol.iterator]();;){var p;if(d){if(v>=h.length)break;p=h[v++]}else{if((v=h.next()).done)break;p=v.value}var g=p.start,m=p.end,y=p.value;f?(n>=g||r===y)&&(i=i.remove(g)):(c=y!==r,f=!0),m>n&&n>=g&&(y===r||isNaN(y)||(i=i.insert(n+1,y)))}return c&&(i=i.insert(t,r)),i===this.rangeTree?this:new e(i)},t.insertSpots=function(t,n){if(this.empty()){var r=this.rangeTree,i=t,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;r=r.insert(u,n).insert(u+1,NaN)}return new e(r)}throw new Error("attempting to overwrite non-empty tree")},t.offsetOf=function(e){if(this.offsetTree.empty())return 0;var t=this.offsetTree.findWith(function(t){return t.startIndex>e?-1:t.endIndex<e?1:0});if(t){var n=t[1];return t[0]+(e-n.startIndex)*n.size}throw new Error("Requested offset outside of the known ones, index: "+e)},t.itemAt=function(e){return{index:e,size:this.rangeTree.findMaxValue(e),offset:NaN}},t.indexRange=function(e,t){if(0===t)return[];if(this.rangeTree.empty())return[{index:0,size:0,offset:NaN}];var n=[],r=this.rangeTree.rangesWithin(e,t),i=Array.isArray(r),o=0;for(r=i?r:r[Symbol.iterator]();;){var s;if(i){if(o>=r.length)break;s=r[o++]}else{if((o=r.next()).done)break;s=o.value}for(var a=s,u=Math.max(e,a.start),l=Math.min(t,void 0===a.end?Infinity:a.end),f=u;f<=l;f++)n.push({index:f,size:a.value,offset:NaN})}return n},t.range=function(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=Infinity),this.offsetTree.empty())return[{index:0,size:0,offset:0}];var i=[],o=this.offsetTree.rangesWithin(e,t),s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}var l=u.start,f=u.value,c=f.startIndex,h=f.endIndex,d=f.size,v=l,p=c;if(l<e&&(v+=((p+=Math.floor((e-l)/d))-c)*d),p<n&&(v+=(n-p)*d,p=n),isNaN(d))return i.push({index:p,size:0,offset:v}),i;h=Math.min(h,r);for(var g=p;g<=h&&!(v>t);g++)i.push({index:g,size:d,offset:v}),v+=d}return i},t.total=function(e){var t=0,n=this.rangeTree.rangesWithin(0,e),r=Array.isArray(n),i=0;for(n=r?n:n[Symbol.iterator]();;){var o;if(r){if(i>=n.length)break;o=n[i++]}else{if((i=n.next()).done)break;o=i.value}var s=o.start,a=o.end,u=o.value;t+=((a=Math.min(a,e))-s+1)*(isNaN(u)?0:u)}return t},t.getOffsets=function(e){var t=this,n=w.empty();return e.forEach(function(e){var r=t.offsetOf(e);n=n.insert(r,e)}),new E(n)},e}(),E=function(){function e(e){this.tree=e}var t=e.prototype;return t.findMaxValue=function(e){return this.tree.findMaxValue(e)},t.empty=function(){return this.tree.empty()},e}(),S=function(){function e(){}return e.prototype.transpose=function(e){return e.map(function(e){return{groupIndex:0,index:e.index,offset:e.offset,size:e.size,transposedIndex:e.index,type:"item"}})},e}(),T=function(){function e(e){this.count=e.reduce(function(e,t){return e+t+1},0);var t=w.empty(),n=0,r=0,i=e,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;t=t.insert(r,[n,r]),n++,r+=u+1}this.tree=t}var t=e.prototype;return t.totalCount=function(){return this.count},t.transpose=function(e){var t=this;return e.map(function(e){var n=t.tree.find(e.index);if(n)return{groupIndex:n[0],index:e.index,offset:e.offset,size:e.size,type:"group"};var r=t.tree.findMaxValue(e.index)[0];return{groupIndex:r,index:e.index,offset:e.offset,size:e.size,transposedIndex:e.index-r-1,type:"item"}})},t.groupIndices=function(){return this.tree.keys()},e}();function R(e){var t;return function(n){t&&t(),n&&(t=e.subscribe(n))}}function M(e){return e.next}var N=function(e){var t,n,r=h(!1);return e.pipe(m(1),g(!0)).subscribe(r.next),e.pipe(m(1),g(!1),function(e,r){t=e,n&&clearTimeout(n),n=setTimeout(function(){r(t)},200)}).subscribe(r.next),r},O=function(e){return e.length>0?e[0].offset:0},z=function(e){return e[0].total(e[1]-1)},A=function(e){var t=e.overscan,n=void 0===t?0:t,r=e.totalCount,i=void 0===r?0:r,o=e.itemHeight,s=h(0),a=h(0),u=h(0),l=h(0),f=h(),c=h(i),g=h(),m=h(),b=I.create(),k=!1,C=h([]),w=h(),E=d();o&&(b=b.insert(0,0,o));var A=h(b);o||f.pipe(x(A,C)).subscribe(function(e){var t=e[0],n=e[1],r=e[2],i=k?I.create():n;k&&(i=I.create(),k=!1);var o=t,s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}var l=u.start,f=u.end,c=u.size;i=i.empty()&&l==f&&r.indexOf(l)>-1?i.insertSpots(r,c):i.insert(l,f,c)}i!==n&&A.next(i)});var H=new S;g.subscribe(function(e){H=new T(e),c.next(H.totalCount()),C.next(H.groupIndices())});var L=v(A,c).pipe(p(z)),W=v(L,l).pipe(p(function(e){return e[0]+e[1]})),j=v(A,C).pipe(p(function(e){return e[0].getOffsets(e[1])})),V=h([]);v(A,m,c).pipe(y(function(e){return e[1]>0}),p(function(e){var t=e[0],n=Math.max(0,Math.min(e[1]-1,e[2]));return H.transpose(t.indexRange(0,n))})).subscribe(V.next),v(A,j,u).pipe(y(function(e){return!e[1].empty()&&!e[0].empty()}),x(V),p(function(e){var t=e[0],n=t[0],r=e[1],i=t[1].findMaxValue(Math.max(t[2],0));if(1===r.length&&r[0].index===i)return r;var o=n.itemAt(i);return H.transpose([o])})).subscribe(V.next);var F,P,_=V.pipe(p(function(e){return e.reduce(function(e,t){return e+t.size},0)})),D=V.pipe(p(function(e){return e.length&&e[e.length-1].index+1})),U=v(s,u,_,a,l,D,c,A).pipe((F=function(e){return function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],l=n[6],f=n[7],c=t.length;if(0===l)return[];var h=O(t),d=h-i+s-a-o,v=Math.max(l-1,0);if(d<r||c>0&&(t[0].index<u||t[c-1].index>v)){var p=Math.max(i+o,o);return H.transpose(f.range(p,i+r+2*e-1,u,v))}if(h>i+o){var g=Math.max(i+o-2*e,o);return H.transpose(f.range(g,i+r-1,u,v))}return t}}(n),P=[],function(e,t){t(P=F(P,e))})),q=d(),G=0;U.pipe(p(function(e){return e.length?e[e.length-1].index:0})).pipe(x(c)).subscribe(function(e){var t=e[0],n=e[1];0!==n&&t===n-1&&G!==t&&(G=t,q.next(t))});var K=v(U,u,_).pipe(p(function(e){return O(e[0])})),Y=E.pipe(x(A,_,C,s,c),p(function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];"number"==typeof t&&(t={index:t,align:"start"});var s=t.index,a=t.align,u=void 0===a?"start":a;s=Math.max(0,s,Math.min(e[5]-1,s));var l=n.offsetOf(s);return"end"==u?l=l-o+n.itemAt(s).size:"center"===u?l=Math.round(l-o/2+n.itemAt(s).size/2):-1===i.indexOf(s)&&(l-=r),l})),B=w.subscribe(function(e){f.next([{start:0,end:0,size:30}]),s.next(30*e),k=!0,B()}),J=C.pipe(),Q=K.pipe(p(function(e){return-e})),X=N(u);return{groupCounts:M(g),itemHeights:M(f),footerHeight:M(l),listHeight:M(a),viewportHeight:M(s),scrollTop:M(u),topItemCount:M(m),totalCount:M(c),scrollToIndex:M(E),initialItemCount:M(w),list:R(U),itemsRendered:R(U),topList:R(V),listOffset:R(K),totalHeight:R(W),endReached:R(q),totalListHeightChanged:R(W),isScrolling:R(X),stickyItems:R(C),groupIndices:R(J),stickyItemsOffset:R(Q),scrollTo:R(Y)}},H=function(e,n,i){var o=t.useRef(null),s=t.useRef(0),a=t.useRef(0),u=new r(function(t){var n=t[0].contentRect.height;s.current!==n&&(s.current=n,i&&(a.current=window.requestAnimationFrame(function(){return i(t[0].target)})),e(n))});return t.useEffect(function(){return function(){return window.cancelAnimationFrame(a.current)}},[]),function(e){e?(u.observe(e),n&&n(e),o.current=e):(u.unobserve(o.current),o.current=null)}};function L(e,n){var r=t.useState(function(e,t){return function(){var n=t;return e(function(e){n=e}),n}}(e,n)),i=r[0],o=r[1];return t.useLayoutEffect(function(){return e(o),function(){return e(void 0)}},[]),i}var W={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},j=function(e){var r=e.className,i=e.style,o=e.reportScrollTop,s=e.scrollTo,a=e.children,u=t.useRef(null),l=t.useCallback(function(e){o(e.target.scrollTop)},[]),f=t.useCallback(function(e){e?(e.addEventListener("scroll",l,{passive:!0}),u.current=e):u.current.removeEventListener("scroll",l)},[]);return s(function(e){u.current.scrollTo({top:e})}),n.createElement("div",{ref:f,style:i,tabIndex:0,className:r},a)},V=function(e){var t=e.children,r=e.className,o=e.ScrollContainer,s=e.scrollTop,a=e.scrollTo;return n.createElement(void 0===o?j:o,{style:i({},W,e.style),reportScrollTop:s,scrollTo:a,className:r},t)},F=function(e){var r=e.render,i=e.stickyClassName,o=t.useContext(f),s=o.topList,a=L(o.list,[]),u=L(s,[]),l=[],c=0,h=[],d=u.reduce(function(e,t){return e+t.size},0);return u.forEach(function(e,t){var n=e.index;h.push(n),l.push(r(e,{key:n,"data-index":n,"data-known-size":e.size,className:i,style:{top:c+"px",marginTop:0===t?-d+"px":void 0}})),c+=e.size}),a.forEach(function(e){h.indexOf(e.index)>-1||l.push(r(e,{key:e.index,"data-index":e.index,"data-known-size":e.size}))}),n.createElement(n.Fragment,null," ",l," ")},P=function(e){var n=e.stickyClassName,r=t.useRef(null);return t.useLayoutEffect(function(){var e=document.createElement("style");return document.head.appendChild(e),e.sheet.insertRule("."+n+" {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ",0),r.current=e,function(){document.head.removeChild(r.current),r.current=null}},[]),null},_=function(){return String.fromCharCode(Math.round(25*Math.random()+97))},D=function(){return new Array(12).fill(0).map(_).join("")},U={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},q=function(e){return n.createElement("div",{style:{height:e.height+"px",position:"absolute",top:0}}," ")},G=function(e){return n.createElement("footer",{ref:e.footerRef},e.children)},K=function(e){return n.createElement("div",{ref:e.listRef,style:e.style},e.children)},Y=function(e){var r=e.footer,i=e.FooterContainer,o=void 0===i?G:i,s=H(t.useContext(f).footerHeight);return n.createElement(o,{footerRef:s},r())},B=function(e){var r=e.fixedItemHeight,i=e.children,o=e.ListContainer,s=t.useContext(f),a=s.listHeight,u=s.itemHeights,l={marginTop:L(s.listOffset,0)+"px"},c=H(a,function(){},function(e){if(!r){var t=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e.item(n);if(i&&void 0!==i.dataset.index){var o=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),a=i.offsetHeight;if(a!==s){var u=t[t.length-1];0===t.length||u.size!==a||u.end!==o-1?t.push({start:o,end:o,size:a}):t[t.length-1].end++}}}return t}(e.children);t.length>0&&u(t)}});return n.createElement(o,{listRef:c,style:l},i)},J=function(e){var r=e.style,i=e.footer,o=e.item,s=e.fixedItemHeight,a=e.ScrollContainer,u=e.ListContainer,l=e.FooterContainer,c=e.className,h=t.useContext(f),d=h.scrollTo,v=h.scrollTop,p=h.viewportHeight,g=L(h.totalHeight,0),m=t.useMemo(D,[]),y=H(p);return n.createElement(V,{style:r,ScrollContainer:a,className:c,scrollTo:d,scrollTop:v},n.createElement("div",{ref:y,style:U},n.createElement(B,{fixedItemHeight:s,ListContainer:u},n.createElement(F,{render:o,stickyClassName:m}),i&&n.createElement(Y,{footer:i,FooterContainer:l}))),n.createElement(q,{height:g}),n.createElement(P,Object.assign({},{stickyClassName:m})))},Q=function(e){return n.createElement(f.Provider,{value:e.contextValue},n.createElement(J,{style:e.style||{},className:e.className,item:e.item,footer:e.footer,fixedItemHeight:void 0!==e.itemHeight,ScrollContainer:e.ScrollContainer,FooterContainer:e.FooterContainer,ListContainer:e.ListContainer||K}))},X=function(e){function t(t){var r;return(r=e.call(this,t)||this).itemRender=function(e,t){var o=t.key,s=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(t,["key"]),a=r.props,u=a.computeItemKey,l=a.item,f=a.ItemContainer,c=void 0===f?"div":f;return u&&(o=u(e.index)),n.createElement(c,i({},s,{key:o}),l(e.index))},r.state=A(t),r}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.isScrolling(e.scrollingStateChange),t.endReached(e.endReached),t.topItemCount(e.topItems||0),t.totalCount(e.totalCount),e.initialItemCount&&t.initialItemCount(e.initialItemCount),t.itemsRendered(e.itemsRendered),t.totalListHeightChanged(e.totalListHeightChanged),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},r.render=function(){return n.createElement(Q,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},t}(t.PureComponent),Z=function(e){function t(t){var r;return(r=e.call(this,t)||this).itemRender=function(e,t){var i=r.props.ItemContainer,o=r.props.GroupContainer||i;if("group"==e.type){var s=r.props.group(e.groupIndex);return o?n.createElement(o,Object.assign({key:t.key},t),s):n.createElement("div",Object.assign({},t),s)}var a=r.props.item(e.transposedIndex,e.groupIndex);return i?n.createElement(i,Object.assign({key:t.key},t),a):n.createElement("div",Object.assign({},t),a)},r.state=A(t),r}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.endReached(e.endReached),t.isScrolling(e.scrollingStateChange),t.groupCounts(e.groupCounts),t.groupIndices(e.groupIndices),t.itemsRendered(e.itemsRendered),t.totalListHeightChanged(e.totalListHeightChanged),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},r.render=function(){return n.createElement(Q,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},t}(t.PureComponent),$=Math.ceil,ee=Math.floor,te=Math.min,ne=Math.max,re=function(e){return $(e)-e<.03?$(e):ee(e)},ie=function(){var e=h([0,0,void 0,void 0]),t=h(0),n=h(0),r=h(0),i=h([0,0]),o=h(0),s=h(0),a=d();v(e,n,r,t).pipe(x(i)).subscribe(function(e){var t=e[0],n=t[0],r=n[0],a=n[1],u=n[2],l=n[3],f=t[1],c=t[2],h=t[3],d=e[1];if(void 0!==u&&void 0!==l){if(0==h)return i.next([0,-1]),void s.next(0);var v=d[0],p=d[1],g=re(r/u),m=function(e,t){return void 0===t&&(t=ee),t(e/g)},y=function(e){var t=e?[0,c]:[c,0],n=t[1],r=g*ee((f-t[0])/l),o=g*$((f+a+n)/l)-1;o=te(h-1,o),r=te(o,ne(0,r)),i.next([r,o]),s.next(m(r)*l)},x=l*m(v),b=l*m(p)+l;h<p-1?y(!0):x>f?y(!1):b<f+a&&y(!0),o.next(l*m(h,$))}});var u=a.pipe(x(e,t),p(function(e){var t=e[0],n=e[1],r=n[0],i=n[1],o=n[2],s=n[3];if(void 0===o||void 0===s)return 0;"number"==typeof t&&(t={index:t,align:"start"});var a=t.index,u=t.align,l=void 0===u?"start":u;a=Math.max(0,a,Math.min(e[2]-1,a));var f=re(r/o),c=ee(a/f)*s;return"end"==l?c=c-i+s:"center"===l&&(c=Math.round(c-i/2+s/2)),c})),l=N(n),f=d(),c=0;return i.pipe(x(t)).subscribe(function(e){var t=e[0][1],n=e[1];0!==n&&t===n-1&&c!==t&&(c=t,f.next(t))}),{gridDimensions:M(e),totalCount:M(t),scrollTop:M(n),overscan:M(r),scrollToIndex:M(a),itemRange:R(i),totalHeight:R(o),listOffset:R(s),scrollTo:R(u),isScrolling:R(l),endReached:R(f)}},oe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).state=ie(),t}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.overscan(e.overscan||0),t.totalCount(e.totalCount),t.isScrolling(e.scrollingStateChange),t.endReached(e.endReached),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.render=function(){return n.createElement(se,Object.assign({},this.props,{engine:this.state}))},t}(n.PureComponent),se=function(e){var i,o,s,a,u=e.ScrollContainer,l=e.ItemContainer,f=void 0===l?"div":l,c=e.ListContainer,h=void 0===c?"div":c,d=e.className,v=e.item,p=e.itemClassName,g=void 0===p?"virtuoso-grid-item":p,m=e.listClassName,y=void 0===m?"virtuoso-grid-list":m,x=e.engine,b=e.style,k=void 0===b?{height:"40rem"}:b,C=x.itemRange,w=x.listOffset,I=x.gridDimensions,E=x.scrollTo,S=x.scrollTop,T=L(x.totalHeight,0),R={marginTop:L(w,0)+"px"},M=L(C,[0,0]),N=(i=function(e){var t=e.element.firstChild.firstChild;I([e.width,e.height,t.offsetWidth,t.offsetHeight])},o=t.useRef(null),s=t.useRef([0,0]),a=new r(function(e){var t=e[0].contentRect,n=t.width,r=t.height;s.current[0]===n&&s.current[1]===r||(s.current=[n,r],i({element:e[0].target,width:n,height:r}))}),function(e){e?(a.observe(e),o.current=e):(a.unobserve(o.current),o.current=null)});return n.createElement(V,{style:k,ScrollContainer:u,className:d,scrollTo:E,scrollTop:S},n.createElement("div",{ref:N,style:U},n.createElement(h,{style:R,className:y},function(e,t,r,i){for(var o=M[1],s=[],a=M[0];a<=o;a++)s.push(n.createElement(i,{key:a,className:r},t(a)));return s}(0,v,g,f))),n.createElement(q,{height:T}))};exports.GroupedVirtuoso=Z,exports.Virtuoso=X,exports.VirtuosoGrid=oe,exports.VirtuosoPresentation=Q; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=require("react"),n=e(t),r=e(require("resize-observer-polyfill"));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 o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function s(e){return(s=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t,n){return(u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&a(i,n.prototype),i}).apply(null,arguments)}function l(e){var t="function"==typeof Map?new Map:void 0;return(l=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return u(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),a(n,e)})(e)}var f=t.createContext(void 0);function c(e){return function(){var t=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return 0===t.length?function(e,t){return t(e)}:1===t.length?t[0]:function(e,n){var r=function(e){return n(e)};t.slice().reverse().forEach(function(e){var t=r;r=function(n){return e(n,t)}}),r(e)}}.apply(void 0,arguments);return function(e,t){var n=function(n){return e(function(e){return t(e,n)})};return{subscribe:n,pipe:c(n)}}(e,t)}}function h(e,t){void 0===t&&(t=!0);var n=[],r=e,i=function(e){return n.push(e),void 0!==r&&e(r),function(){n=n.filter(function(t){return t!==e})}};return{next:function(e){t&&e===r||(r=e,n.forEach(function(t){return t(e)}))},subscribe:i,pipe:c(i),subscribers:n}}function d(){var e=[],t=function(t){return e.push(t),function(){e=e.filter(function(e){return e!==t})}};return{next:function(t){e.forEach(function(e){return e(t)})},subscribe:t,pipe:c(t)}}function v(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length),o=[],s=function(e){r.every(function(e){return e})&&e.forEach(function(e){return e(i)})};t.forEach(function(e,t){e.subscribe(function(e){r[t]=!0,i[t]=e,s(o)})});var a=function(e){return o.push(e),s([e]),function(){o=o.filter(function(t){return t!==e})}};return{subscribe:a,pipe:c(a)}}function p(e){return function(t,n){n(e(t))}}function g(e){return function(t,n){return n(e)}}function m(e){return function(t,n){e>0?e--:n(t)}}function y(e){return function(t,n){e(t)&&n(t)}}function x(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=Array(t.length).fill(!1),i=Array(t.length);return t.forEach(function(e,t){e.subscribe(function(e){i[t]=e,r[t]=!0})}),function(e,t){r.every(function(e){return e})&&t([e].concat(i))}}var b=new(function(){function e(){this.level=0}var t=e.prototype;return t.rebalance=function(){return this},t.adjust=function(){return this},t.remove=function(){return this},t.find=function(){},t.findWith=function(){},t.findMax=function(){return-Infinity},t.findMaxValue=function(){},t.insert=function(e,t){return new C({key:e,value:t,level:1})},t.walkWithin=function(){return[]},t.walk=function(){return[]},t.ranges=function(){return[]},t.rangesWithin=function(){return[]},t.empty=function(){return!0},t.isSingle=function(){return!0},t.isInvariant=function(){return!0},t.keys=function(){return[]},e}());Object.freeze(b);var k=function(e){function t(t){return e.call(this,"Unreachable case: "+t)||this}return o(t,e),t}(l(Error)),C=function(){function e(e){var t=e.value,n=e.level,r=e.left,i=void 0===r?b:r,o=e.right,s=void 0===o?b:o;this.key=e.key,this.value=t,this.level=n,this.left=i,this.right=s}var t=e.prototype;return t.remove=function(e){var t=this.left,n=this.right;if(e===this.key){if(t.empty())return n;if(n.empty())return t;var r=t.last();return this.clone({key:r[0],value:r[1],left:t.deleteLast()}).adjust()}return e<this.key?this.clone({left:t.remove(e)}).adjust():this.clone({right:n.remove(e)}).adjust()},t.empty=function(){return!1},t.find=function(e){return e===this.key?this.value:e<this.key?this.left.find(e):this.right.find(e)},t.findWith=function(e){var t=e(this.value);switch(t){case-1:return this.left.findWith(e);case 0:return[this.key,this.value];case 1:return this.right.findWith(e);default:throw new k(t)}},t.findMax=function(e){if(this.key===e)return e;if(this.key<e){var t=this.right.findMax(e);return-Infinity===t?this.key:t}return this.left.findMax(e)},t.findMaxValue=function(e){if(this.key===e)return this.value;if(this.key<e){var t=this.right.findMaxValue(e);return void 0===t?this.value:t}return this.left.findMaxValue(e)},t.insert=function(e,t){return e===this.key?this.clone({key:e,value:t}):e<this.key?this.clone({left:this.left.insert(e,t)}).rebalance():this.clone({right:this.right.insert(e,t)}).rebalance()},t.walkWithin=function(e,t){var n=this.key,r=this.value,i=[];return n>e&&(i=i.concat(this.left.walkWithin(e,t))),n>=e&&n<=t&&i.push({key:n,value:r}),n<=t&&(i=i.concat(this.right.walkWithin(e,t))),i},t.walk=function(){return[].concat(this.left.walk(),[{key:this.key,value:this.value}],this.right.walk())},t.last=function(){return this.right.empty()?[this.key,this.value]:this.right.last()},t.deleteLast=function(){return this.right.empty()?this.left:this.clone({right:this.right.deleteLast()}).adjust()},t.clone=function(t){return new e({key:void 0!==t.key?t.key:this.key,value:void 0!==t.value?t.value:this.value,level:void 0!==t.level?t.level:this.level,left:void 0!==t.left?t.left:this.left,right:void 0!==t.right?t.right:this.right})},t.isSingle=function(){return this.level>this.right.level},t.rebalance=function(){return this.skew().split()},t.adjust=function(){var e=this.left,t=this.right,n=this.level;if(t.level>=n-1&&e.level>=n-1)return this;if(n>t.level+1){if(e.isSingle())return this.clone({level:n-1}).skew();if(e.empty()||e.right.empty())throw new Error("Unexpected empty nodes");return e.right.clone({left:e.clone({right:e.right.left}),right:this.clone({left:e.right.right,level:n-1}),level:n})}if(this.isSingle())return this.clone({level:n-1}).split();if(t.empty()||t.left.empty())throw new Error("Unexpected empty nodes");var r=t.left,i=r.isSingle()?t.level-1:t.level;return r.clone({left:this.clone({right:r.left,level:n-1}),right:t.clone({left:r.right,level:i}).split(),level:r.level+1})},t.isInvariant=function(){var e=this.left,t=this.right,n=this.level;return n===e.level+1&&(n===t.level||n===t.level+1)&&!(!t.empty()&&n<=t.right.level)&&e.isInvariant()&&t.isInvariant()},t.keys=function(){return[].concat(this.left.keys(),[this.key],this.right.keys())},t.ranges=function(){return this.toRanges(this.walk())},t.rangesWithin=function(e,t){return this.toRanges(this.walkWithin(e,t))},t.toRanges=function(e){if(0===e.length)return[];for(var t=e[0],n=t.key,r=t.value,i=[],o=1;o<=e.length;o++){var s=e[o];i.push({start:n,end:s?s.key-1:Infinity,value:r}),s&&(n=s.key,r=s.value)}return i},t.split=function(){var e=this.right,t=this.level;return e.empty()||e.right.empty()||e.level!=t||e.right.level!=t?this:e.clone({left:this.clone({right:e.left}),level:t+1})},t.skew=function(){var e=this.left;return e.empty()||e.level!==this.level?this:e.clone({right:this.clone({left:e.right})})},e}(),w=function(){function e(e){this.root=e}e.empty=function(){return new e(b)};var t=e.prototype;return t.find=function(e){return this.root.find(e)},t.findMax=function(e){return this.root.findMax(e)},t.findMaxValue=function(e){if(this.empty())throw new Error("Searching for max value in an empty tree");return this.root.findMaxValue(e)},t.findWith=function(e){return this.root.findWith(e)},t.insert=function(t,n){return new e(this.root.insert(t,n))},t.remove=function(t){return new e(this.root.remove(t))},t.empty=function(){return this.root.empty()},t.keys=function(){return this.root.keys()},t.walk=function(){return this.root.walk()},t.walkWithin=function(e,t){var n=this.root.findMax(e);return this.root.walkWithin(n,t)},t.ranges=function(){return this.root.ranges()},t.rangesWithin=function(e,t){var n=this.root.findMax(e);return this.root.rangesWithin(n,t)},t.isInvariant=function(){return this.root.isInvariant()},e}(),I=function(){function e(e){this.nanIndices=[],this.rangeTree=e;var t=w.empty(),n=0,r=!1,i=e.ranges(),o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a.start,l=a.end,f=a.value;isNaN(f)?(this.nanIndices.push(u),r||(t=t.insert(n,{startIndex:u,endIndex:Infinity,size:f})),r=!0):r||(t=t.insert(n,{startIndex:u,endIndex:l,size:f}),n+=(l-u+1)*f)}this.offsetTree=t}e.create=function(){return new e(w.empty())};var t=e.prototype;return t.empty=function(){return this.rangeTree.empty()},t.insert=function(t,n,r){var i=this.rangeTree;if(i.empty())return new e(i.insert(0,r));if(this.nanIndices.length&&this.nanIndices.indexOf(n)>-1){if(i.find(this.nanIndices[0]-1)===r)return new e(w.empty().insert(0,r));var o=this.nanIndices,s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}i=i.insert(u,r)}return new e(i)}var l=i.rangesWithin(t-1,n+1);if(l.some(function(e){return e.start===t&&(e.end===n||Infinity===e.end)&&e.value===r}))return this;var f=!1,c=!1,h=l,d=Array.isArray(h),v=0;for(h=d?h:h[Symbol.iterator]();;){var p;if(d){if(v>=h.length)break;p=h[v++]}else{if((v=h.next()).done)break;p=v.value}var g=p.start,m=p.end,y=p.value;f?(n>=g||r===y)&&(i=i.remove(g)):(c=y!==r,f=!0),m>n&&n>=g&&(y===r||isNaN(y)||(i=i.insert(n+1,y)))}return c&&(i=i.insert(t,r)),i===this.rangeTree?this:new e(i)},t.insertSpots=function(t,n){if(this.empty()){var r=this.rangeTree,i=t,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;r=r.insert(u,n).insert(u+1,NaN)}return new e(r)}throw new Error("attempting to overwrite non-empty tree")},t.offsetOf=function(e){if(this.offsetTree.empty())return 0;var t=this.offsetTree.findWith(function(t){return t.startIndex>e?-1:t.endIndex<e?1:0});if(t){var n=t[1];return t[0]+(e-n.startIndex)*n.size}throw new Error("Requested offset outside of the known ones, index: "+e)},t.itemAt=function(e){return{index:e,size:this.rangeTree.findMaxValue(e),offset:NaN}},t.indexRange=function(e,t){if(this.rangeTree.empty())return[{index:0,size:0,offset:NaN}];var n=[],r=this.rangeTree.rangesWithin(e,t),i=Array.isArray(r),o=0;for(r=i?r:r[Symbol.iterator]();;){var s;if(i){if(o>=r.length)break;s=r[o++]}else{if((o=r.next()).done)break;s=o.value}for(var a=s,u=Math.max(e,a.start),l=Math.min(t,void 0===a.end?Infinity:a.end),f=u;f<=l;f++)n.push({index:f,size:a.value,offset:NaN})}return n},t.range=function(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=Infinity),this.offsetTree.empty())return[{index:0,size:0,offset:0}];var i=[],o=this.offsetTree.rangesWithin(e,t),s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}var l=u.start,f=u.value,c=f.startIndex,h=f.endIndex,d=f.size,v=l,p=c;if(l<e&&(v+=((p+=Math.floor((e-l)/d))-c)*d),p<n&&(v+=(n-p)*d,p=n),isNaN(d))return i.push({index:p,size:0,offset:v}),i;h=Math.min(h,r);for(var g=p;g<=h&&!(v>t);g++)i.push({index:g,size:d,offset:v}),v+=d}return i},t.total=function(e){var t=0,n=this.rangeTree.rangesWithin(0,e),r=Array.isArray(n),i=0;for(n=r?n:n[Symbol.iterator]();;){var o;if(r){if(i>=n.length)break;o=n[i++]}else{if((i=n.next()).done)break;o=i.value}var s=o.start,a=o.end,u=o.value;t+=((a=Math.min(a,e))-s+1)*(isNaN(u)?0:u)}return t},t.getOffsets=function(e){var t=this,n=w.empty();return e.forEach(function(e){var r=t.offsetOf(e);n=n.insert(r,e)}),new E(n)},e}(),E=function(){function e(e){this.tree=e}var t=e.prototype;return t.findMaxValue=function(e){return this.tree.findMaxValue(e)},t.empty=function(){return this.tree.empty()},e}(),S=function(){function e(){}return e.prototype.transpose=function(e){return e.map(function(e){return{groupIndex:0,index:e.index,offset:e.offset,size:e.size,transposedIndex:e.index,type:"item"}})},e}(),T=function(){function e(e){this.count=e.reduce(function(e,t){return e+t+1},0);var t=w.empty(),n=0,r=0,i=e,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var a;if(o){if(s>=i.length)break;a=i[s++]}else{if((s=i.next()).done)break;a=s.value}var u=a;t=t.insert(r,[n,r]),n++,r+=u+1}this.tree=t}var t=e.prototype;return t.totalCount=function(){return this.count},t.transpose=function(e){var t=this;return e.map(function(e){var n=t.tree.find(e.index);if(n)return{groupIndex:n[0],index:e.index,offset:e.offset,size:e.size,type:"group"};var r=t.tree.findMaxValue(e.index)[0];return{groupIndex:r,index:e.index,offset:e.offset,size:e.size,transposedIndex:e.index-r-1,type:"item"}})},t.groupIndices=function(){return this.tree.keys()},e}();function R(e){var t;return function(n){t&&t(),n&&(t=e.subscribe(n))}}function M(e){return e.next}var N=function(e){var t,n,r=h(!1);return e.pipe(m(1),g(!0)).subscribe(r.next),e.pipe(m(1),g(!1),function(e,r){t=e,n&&clearTimeout(n),n=setTimeout(function(){r(t)},200)}).subscribe(r.next),r},O=function(e){return e.length>0?e[0].offset:0},z=function(e){return e[0].total(e[1]-1)},A=function(e){var t=e.overscan,n=void 0===t?0:t,r=e.totalCount,i=void 0===r?0:r,o=e.itemHeight,s=h(0),a=h(0),u=h(0),l=h(0),f=h(),c=h(i),g=h(),m=h(),b=I.create(),k=!1,C=h([]),w=h(),E=d();o&&(b=b.insert(0,0,o));var A=h(b);o||f.pipe(x(A,C)).subscribe(function(e){var t=e[0],n=e[1],r=e[2],i=k?I.create():n;k&&(i=I.create(),k=!1);var o=t,s=Array.isArray(o),a=0;for(o=s?o:o[Symbol.iterator]();;){var u;if(s){if(a>=o.length)break;u=o[a++]}else{if((a=o.next()).done)break;u=a.value}var l=u.start,f=u.end,c=u.size;i=i.empty()&&l==f&&r.indexOf(l)>-1?i.insertSpots(r,c):i.insert(l,f,c)}i!==n&&A.next(i)});var H=new S;g.subscribe(function(e){H=new T(e),c.next(H.totalCount()),C.next(H.groupIndices())});var L=v(A,c).pipe(p(z)),W=v(L,l).pipe(p(function(e){return e[0]+e[1]})),j=v(A,C).pipe(p(function(e){return e[0].getOffsets(e[1])})),V=h([]);v(A,m,c).pipe(y(function(e){return e[1]>0}),p(function(e){var t=e[0],n=Math.max(0,Math.min(e[1]-1,e[2]));return H.transpose(t.indexRange(0,n))})).subscribe(V.next),v(A,j,u).pipe(y(function(e){return!e[1].empty()&&!e[0].empty()}),x(V),p(function(e){var t=e[0],n=t[0],r=e[1],i=t[1].findMaxValue(Math.max(t[2],0));if(1===r.length&&r[0].index===i)return r;var o=n.itemAt(i);return H.transpose([o])})).subscribe(V.next);var F,P,_=V.pipe(p(function(e){return e.reduce(function(e,t){return e+t.size},0)})),D=V.pipe(p(function(e){return e.length&&e[e.length-1].index+1})),U=v(s,u,_,a,l,D,c,A).pipe((F=function(e){return function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],a=n[4],u=n[5],l=n[6],f=n[7],c=t.length;if(0===l)return[];var h=O(t),d=h-i+s-a-o,v=Math.max(l-1,0);if(d<r||c>0&&(t[0].index<u||t[c-1].index>v)){var p=Math.max(i+o,o);return H.transpose(f.range(p,i+r+2*e-1,u,v))}if(h>i+o){var g=Math.max(i+o-2*e,o);return H.transpose(f.range(g,i+r-1,u,v))}return t}}(n),P=[],function(e,t){t(P=F(P,e))})),q=d(),G=0;U.pipe(p(function(e){return e.length?e[e.length-1].index:0})).pipe(x(c)).subscribe(function(e){var t=e[0],n=e[1];0!==n&&t===n-1&&G!==t&&(G=t,q.next(t))});var K=v(U,u,_).pipe(p(function(e){return O(e[0])})),Y=E.pipe(x(A,_,C,s,c),p(function(e){var t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];"number"==typeof t&&(t={index:t,align:"start"});var s=t.index,a=t.align,u=void 0===a?"start":a;s=Math.max(0,s,Math.min(e[5]-1,s));var l=n.offsetOf(s);return"end"==u?l=l-o+n.itemAt(s).size:"center"===u?l=Math.round(l-o/2+n.itemAt(s).size/2):-1===i.indexOf(s)&&(l-=r),l})),B=w.subscribe(function(e){f.next([{start:0,end:0,size:30}]),s.next(30*e),k=!0,B()}),J=C.pipe(),Q=K.pipe(p(function(e){return-e})),X=N(u);return{groupCounts:M(g),itemHeights:M(f),footerHeight:M(l),listHeight:M(a),viewportHeight:M(s),scrollTop:M(u),topItemCount:M(m),totalCount:M(c),scrollToIndex:M(E),initialItemCount:M(w),list:R(U),itemsRendered:R(U),topList:R(V),listOffset:R(K),totalHeight:R(W),endReached:R(q),totalListHeightChanged:R(W),isScrolling:R(X),stickyItems:R(C),groupIndices:R(J),stickyItemsOffset:R(Q),scrollTo:R(Y)}},H=function(e,n,i){var o=t.useRef(null),s=t.useRef(0),a=t.useRef(0),u=new r(function(t){var n=t[0].contentRect.height;s.current!==n&&(s.current=n,i&&(a.current=window.requestAnimationFrame(function(){return i(t[0].target)})),e(n))});return t.useEffect(function(){return function(){return window.cancelAnimationFrame(a.current)}},[]),function(e){e?(u.observe(e),n&&n(e),o.current=e):(u.unobserve(o.current),o.current=null)}};function L(e,n){var r=t.useState(function(e,t){return function(){var n=t;return e(function(e){n=e}),n}}(e,n)),i=r[0],o=r[1];return t.useLayoutEffect(function(){return e(o),function(){return e(void 0)}},[]),i}var W={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},j=function(e){var r=e.className,i=e.style,o=e.reportScrollTop,s=e.scrollTo,a=e.children,u=t.useRef(null),l=t.useCallback(function(e){o(e.target.scrollTop)},[]),f=t.useCallback(function(e){e?(e.addEventListener("scroll",l,{passive:!0}),u.current=e):u.current.removeEventListener("scroll",l)},[]);return s(function(e){u.current.scrollTo({top:e})}),n.createElement("div",{ref:f,style:i,tabIndex:0,className:r},a)},V=function(e){var t=e.children,r=e.className,o=e.ScrollContainer,s=e.scrollTop,a=e.scrollTo;return n.createElement(void 0===o?j:o,{style:i({},W,e.style),reportScrollTop:s,scrollTo:a,className:r},t)},F=function(e){var r=e.render,i=e.stickyClassName,o=t.useContext(f),s=o.topList,a=L(o.list,[]),u=L(s,[]),l=[],c=0,h=[],d=u.reduce(function(e,t){return e+t.size},0);return u.forEach(function(e,t){var n=e.index;h.push(n),l.push(r(e,{key:n,"data-index":n,"data-known-size":e.size,className:i,style:{top:c+"px",marginTop:0===t?-d+"px":void 0}})),c+=e.size}),a.forEach(function(e){h.indexOf(e.index)>-1||l.push(r(e,{key:e.index,"data-index":e.index,"data-known-size":e.size}))}),n.createElement(n.Fragment,null," ",l," ")},P=function(e){var n=e.stickyClassName,r=t.useRef(null);return t.useLayoutEffect(function(){var e=document.createElement("style");return document.head.appendChild(e),e.sheet.insertRule("."+n+" {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ",0),r.current=e,function(){document.head.removeChild(r.current),r.current=null}},[]),null},_=function(){return String.fromCharCode(Math.round(25*Math.random()+97))},D=function(){return new Array(12).fill(0).map(_).join("")},U={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},q=function(e){return n.createElement("div",{style:{height:e.height+"px",position:"absolute",top:0}}," ")},G=function(e){return n.createElement("footer",{ref:e.footerRef},e.children)},K=function(e){return n.createElement("div",{ref:e.listRef,style:e.style},e.children)},Y=function(e){var r=e.footer,i=e.FooterContainer,o=void 0===i?G:i,s=H(t.useContext(f).footerHeight);return n.createElement(o,{footerRef:s},r())},B=function(e){var r=e.fixedItemHeight,i=e.children,o=e.ListContainer,s=t.useContext(f),a=s.listHeight,u=s.itemHeights,l={marginTop:L(s.listOffset,0)+"px"},c=H(a,function(){},function(e){if(!r){var t=function(e){for(var t=[],n=0,r=e.length;n<r;n++){var i=e.item(n);if(i&&void 0!==i.dataset.index){var o=parseInt(i.dataset.index),s=parseInt(i.dataset.knownSize),a=i.offsetHeight;if(a!==s){var u=t[t.length-1];0===t.length||u.size!==a||u.end!==o-1?t.push({start:o,end:o,size:a}):t[t.length-1].end++}}}return t}(e.children);t.length>0&&u(t)}});return n.createElement(o,{listRef:c,style:l},i)},J=function(e){var r=e.style,i=e.footer,o=e.item,s=e.fixedItemHeight,a=e.ScrollContainer,u=e.ListContainer,l=e.FooterContainer,c=e.className,h=t.useContext(f),d=h.scrollTo,v=h.scrollTop,p=h.viewportHeight,g=L(h.totalHeight,0),m=t.useMemo(D,[]),y=H(p);return n.createElement(V,{style:r,ScrollContainer:a,className:c,scrollTo:d,scrollTop:v},n.createElement("div",{ref:y,style:U},n.createElement(B,{fixedItemHeight:s,ListContainer:u},n.createElement(F,{render:o,stickyClassName:m}),i&&n.createElement(Y,{footer:i,FooterContainer:l}))),n.createElement(q,{height:g}),n.createElement(P,Object.assign({},{stickyClassName:m})))},Q=function(e){return n.createElement(f.Provider,{value:e.contextValue},n.createElement(J,{style:e.style||{},className:e.className,item:e.item,footer:e.footer,fixedItemHeight:void 0!==e.itemHeight,ScrollContainer:e.ScrollContainer,FooterContainer:e.FooterContainer,ListContainer:e.ListContainer||K}))},X=function(e){function t(t){var r;return(r=e.call(this,t)||this).itemRender=function(e,t){var o=t.key,s=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(t,["key"]),a=r.props,u=a.computeItemKey,l=a.item,f=a.ItemContainer,c=void 0===f?"div":f;return u&&(o=u(e.index)),n.createElement(c,i({},s,{key:o}),l(e.index))},r.state=A(t),r}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.isScrolling(e.scrollingStateChange),t.endReached(e.endReached),t.topItemCount(e.topItems||0),t.totalCount(e.totalCount),e.initialItemCount&&t.initialItemCount(e.initialItemCount),t.itemsRendered(e.itemsRendered),t.totalListHeightChanged(e.totalListHeightChanged),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},r.render=function(){return n.createElement(Q,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},t}(t.PureComponent),Z=function(e){function t(t){var r;return(r=e.call(this,t)||this).itemRender=function(e,t){var i=r.props.ItemContainer,o=r.props.GroupContainer||i;if("group"==e.type){var s=r.props.group(e.groupIndex);return o?n.createElement(o,Object.assign({key:t.key},t),s):n.createElement("div",Object.assign({},t),s)}var a=r.props.item(e.transposedIndex,e.groupIndex);return i?n.createElement(i,Object.assign({key:t.key},t),a):n.createElement("div",Object.assign({},t),a)},r.state=A(t),r}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.endReached(e.endReached),t.isScrolling(e.scrollingStateChange),t.groupCounts(e.groupCounts),t.groupIndices(e.groupIndices),t.itemsRendered(e.itemsRendered),t.totalListHeightChanged(e.totalListHeightChanged),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.componentWillUnmount=function(){this.state.itemsRendered(void 0),this.state.totalListHeightChanged(void 0)},r.render=function(){return n.createElement(Q,{contextValue:this.state,style:this.props.style,className:this.props.className,item:this.itemRender,footer:this.props.footer,itemHeight:this.props.itemHeight,ScrollContainer:this.props.ScrollContainer,FooterContainer:this.props.FooterContainer,ListContainer:this.props.ListContainer})},t}(t.PureComponent),$=Math.ceil,ee=Math.floor,te=Math.min,ne=Math.max,re=function(e){return $(e)-e<.03?$(e):ee(e)},ie=function(){var e=h([0,0,void 0,void 0]),t=h(0),n=h(0),r=h(0),i=h([0,0]),o=h(0),s=h(0),a=d();v(e,n,r,t).pipe(x(i)).subscribe(function(e){var t=e[0],n=t[0],r=n[0],a=n[1],u=n[2],l=n[3],f=t[1],c=t[2],h=t[3],d=e[1];if(void 0!==u&&void 0!==l){if(0==h)return i.next([0,-1]),void s.next(0);var v=d[0],p=d[1],g=re(r/u),m=function(e,t){return void 0===t&&(t=ee),t(e/g)},y=function(e){var t=e?[0,c]:[c,0],n=t[1],r=g*ee((f-t[0])/l),o=g*$((f+a+n)/l)-1;o=te(h-1,o),r=te(o,ne(0,r)),i.next([r,o]),s.next(m(r)*l)},x=l*m(v),b=l*m(p)+l;h<p-1?y(!0):x>f?y(!1):b<f+a&&y(!0),o.next(l*m(h,$))}});var u=a.pipe(x(e,t),p(function(e){var t=e[0],n=e[1],r=n[0],i=n[1],o=n[2],s=n[3];if(void 0===o||void 0===s)return 0;"number"==typeof t&&(t={index:t,align:"start"});var a=t.index,u=t.align,l=void 0===u?"start":u;a=Math.max(0,a,Math.min(e[2]-1,a));var f=re(r/o),c=ee(a/f)*s;return"end"==l?c=c-i+s:"center"===l&&(c=Math.round(c-i/2+s/2)),c})),l=N(n),f=d(),c=0;return i.pipe(x(t)).subscribe(function(e){var t=e[0][1],n=e[1];0!==n&&t===n-1&&c!==t&&(c=t,f.next(t))}),{gridDimensions:M(e),totalCount:M(t),scrollTop:M(n),overscan:M(r),scrollToIndex:M(a),itemRange:R(i),totalHeight:R(o),listOffset:R(s),scrollTo:R(u),isScrolling:R(l),endReached:R(f)}},oe=function(e){function t(){var t;return(t=e.apply(this,arguments)||this).state=ie(),t}o(t,e),t.getDerivedStateFromProps=function(e,t){return t.overscan(e.overscan||0),t.totalCount(e.totalCount),t.isScrolling(e.scrollingStateChange),t.endReached(e.endReached),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.render=function(){return n.createElement(se,Object.assign({},this.props,{engine:this.state}))},t}(n.PureComponent),se=function(e){var i,o,s,a,u=e.ScrollContainer,l=e.ItemContainer,f=void 0===l?"div":l,c=e.ListContainer,h=void 0===c?"div":c,d=e.className,v=e.item,p=e.itemClassName,g=void 0===p?"virtuoso-grid-item":p,m=e.listClassName,y=void 0===m?"virtuoso-grid-list":m,x=e.engine,b=e.style,k=void 0===b?{height:"40rem"}:b,C=x.itemRange,w=x.listOffset,I=x.gridDimensions,E=x.scrollTo,S=x.scrollTop,T=L(x.totalHeight,0),R={marginTop:L(w,0)+"px"},M=L(C,[0,0]),N=(i=function(e){var t=e.element.firstChild.firstChild;I([e.width,e.height,t.offsetWidth,t.offsetHeight])},o=t.useRef(null),s=t.useRef([0,0]),a=new r(function(e){var t=e[0].contentRect,n=t.width,r=t.height;s.current[0]===n&&s.current[1]===r||(s.current=[n,r],i({element:e[0].target,width:n,height:r}))}),function(e){e?(a.observe(e),o.current=e):(a.unobserve(o.current),o.current=null)});return n.createElement(V,{style:k,ScrollContainer:u,className:d,scrollTo:E,scrollTop:S},n.createElement("div",{ref:N,style:U},n.createElement(h,{style:R,className:y},function(e,t,r,i){for(var o=M[1],s=[],a=M[0];a<=o;a++)s.push(n.createElement(i,{key:a,className:r},t(a)));return s}(0,v,g,f))),n.createElement(q,{height:T}))};exports.GroupedVirtuoso=Z,exports.Virtuoso=X,exports.VirtuosoGrid=oe,exports.VirtuosoPresentation=Q; | ||
//# sourceMappingURL=react-virtuoso.cjs.production.min.js.map |
@@ -12,3 +12,2 @@ /// <reference types="react" /> | ||
scrollToIndex: (value: import("./EngineCommons").TScrollLocation) => void; | ||
initialItemCount: (value: number) => void; | ||
list: (callback: ((val: import("./GroupIndexTransposer").ListItem[]) => void) | undefined) => void; | ||
@@ -15,0 +14,0 @@ topList: (callback: ((val: import("./GroupIndexTransposer").ListItem[]) => void) | undefined) => void; |
{ | ||
"name": "react-virtuoso", | ||
"version": "0.12.1", | ||
"version": "0.12.2", | ||
"homepage": "https://virtuoso.dev", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
2
0
3466867
33
29821