react-virtuoso
Advanced tools
Comparing version 0.7.1 to 0.8.0
import { VirtuosoProps, VirtuosoState, TItemContainer } from './Virtuoso'; | ||
import { TScrollLocation } from './EngineCommons'; | ||
import { ReactElement, PureComponent } from 'react'; | ||
import { TScrollLocation } from './VirtuosoStore'; | ||
import { TRender } from './VirtuosoList'; | ||
@@ -5,0 +5,0 @@ declare type GroupedVirtuosoProps = Pick<VirtuosoProps, Exclude<keyof VirtuosoProps, 'totalCount' | 'topItems' | 'item'>> & { |
export * from './Virtuoso'; | ||
export * from './GroupedVirtuoso'; | ||
export * from './VirtuosoGrid'; |
@@ -1371,2 +1371,9 @@ 'use strict'; | ||
var buildIsScrolling = function buildIsScrolling(scrollTop$) { | ||
var isScrolling$ = subject(false); | ||
scrollTop$.pipe(skip(1), mapTo(true)).subscribe(isScrolling$.next); | ||
scrollTop$.pipe(skip(1), mapTo(false), debounceTime(200)).subscribe(isScrolling$.next); | ||
return isScrolling$; | ||
}; | ||
var getListTop = function getListTop(items) { | ||
@@ -1396,3 +1403,2 @@ return items.length > 0 ? items[0].offset : 0; | ||
var topItemCount$ = subject(); | ||
var isScrolling$ = subject(false); | ||
var initialOffsetList = OffsetList.create(); | ||
@@ -1460,3 +1466,3 @@ var stickyItems$ = subject([]); | ||
if (totalCount === 0) { | ||
return itemLength === 0 ? items : []; | ||
return []; | ||
} | ||
@@ -1563,4 +1569,2 @@ | ||
})); | ||
scrollTop$.pipe(skip(1), mapTo(true)).subscribe(isScrolling$.next); | ||
scrollTop$.pipe(skip(1), mapTo(false), debounceTime(200)).subscribe(isScrolling$.next); | ||
var scrollTo$ = scrollToIndex$.pipe(withLatestFrom(offsetList$, topListHeight$, stickyItems$, viewportHeight$, totalCount$), map(function (_ref13) { | ||
@@ -1604,2 +1608,3 @@ var location = _ref13[0], | ||
})); | ||
var isScrolling$ = buildIsScrolling(scrollTop$); | ||
return { | ||
@@ -1675,3 +1680,33 @@ groupCounts: makeInput(groupCounts$), | ||
} | ||
var useSize = function useSize(callback) { | ||
var ref = React.useRef(null); | ||
var currentSize = React.useRef([0, 0]); | ||
var observer = new ResizeObserver(function (entries) { | ||
var _entries$0$contentRec = entries[0].contentRect, | ||
width = _entries$0$contentRec.width, | ||
height = _entries$0$contentRec.height; | ||
if (currentSize.current[0] !== width || currentSize.current[1] !== height) { | ||
currentSize.current = [width, height]; | ||
callback({ | ||
element: entries[0].target, | ||
width: width, | ||
height: height | ||
}); | ||
} | ||
}); | ||
var callbackRef = function callbackRef(elRef) { | ||
if (elRef) { | ||
observer.observe(elRef); | ||
ref.current = elRef; | ||
} else { | ||
observer.unobserve(ref.current); | ||
ref.current = null; | ||
} | ||
}; | ||
return callbackRef; | ||
}; | ||
var scrollerStyle = { | ||
@@ -1724,8 +1759,5 @@ height: '40rem', | ||
_ref2$ScrollContainer = _ref2.ScrollContainer, | ||
ScrollContainer = _ref2$ScrollContainer === void 0 ? DefaultScrollContainer : _ref2$ScrollContainer; | ||
var _useContext = React.useContext(VirtuosoContext), | ||
scrollTop = _useContext.scrollTop, | ||
scrollTo = _useContext.scrollTo; | ||
ScrollContainer = _ref2$ScrollContainer === void 0 ? DefaultScrollContainer : _ref2$ScrollContainer, | ||
scrollTop = _ref2.scrollTop, | ||
scrollTo = _ref2.scrollTo; | ||
return React__default.createElement(ScrollContainer, { | ||
@@ -1793,3 +1825,3 @@ style: _extends({}, scrollerStyle, style), | ||
var sheet = styleEl.sheet; | ||
sheet.insertRule("." + stickyClassName + " {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } "); | ||
sheet.insertRule("." + stickyClassName + " {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ", 0); | ||
style.current = styleEl; | ||
@@ -1813,3 +1845,21 @@ return function () { | ||
}; | ||
var viewportStyle = { | ||
top: 0, | ||
position: 'absolute', | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'absolute' | ||
}; | ||
var VirtuosoFiller = function VirtuosoFiller(_ref) { | ||
var height = _ref.height; | ||
return React__default.createElement("div", { | ||
style: { | ||
height: height + "px", | ||
position: 'absolute', | ||
top: 0 | ||
} | ||
}, "\xA0"); | ||
}; | ||
var DefaultFooterContainer = function DefaultFooterContainer(_ref) { | ||
@@ -1905,9 +1955,2 @@ var children = _ref.children, | ||
var viewportStyle = { | ||
top: 0, | ||
position: 'absolute', | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'absolute' | ||
}; | ||
var VirtuosoView = function VirtuosoView(_ref5) { | ||
@@ -1924,2 +1967,4 @@ var style = _ref5.style, | ||
var _useContext2 = React.useContext(VirtuosoContext), | ||
scrollTo = _useContext2.scrollTo, | ||
scrollTop = _useContext2.scrollTop, | ||
totalHeight = _useContext2.totalHeight, | ||
@@ -1934,3 +1979,5 @@ viewportHeight = _useContext2.viewportHeight; | ||
ScrollContainer: ScrollContainer, | ||
className: className | ||
className: className, | ||
scrollTo: scrollTo, | ||
scrollTop: scrollTop | ||
}, React__default.createElement("div", { | ||
@@ -1948,9 +1995,5 @@ ref: viewportCallbackRef, | ||
FooterContainer: FooterContainer | ||
}))), React__default.createElement("div", { | ||
style: { | ||
height: fillerHeight + "px", | ||
position: 'absolute', | ||
top: 0 | ||
} | ||
}, "\xA0"), React__default.createElement(VirtuosoStyle, Object.assign({}, { | ||
}))), React__default.createElement(VirtuosoFiller, { | ||
height: fillerHeight | ||
}), React__default.createElement(VirtuosoStyle, Object.assign({}, { | ||
stickyClassName: stickyClassName | ||
@@ -2114,5 +2157,247 @@ }))); | ||
var ceil = Math.ceil, | ||
floor = Math.floor, | ||
min = Math.min, | ||
max = Math.max; | ||
var hackFloor = function hackFloor(val) { | ||
return ceil(val) - val < 0.01 ? ceil(val) : floor(val); | ||
}; | ||
var VirtuosoGridEngine = function VirtuosoGridEngine() { | ||
var gridDimensions$ = subject([0, 0, undefined, undefined]); | ||
var totalCount$ = subject(0); | ||
var scrollTop$ = subject(0); | ||
var overscan$ = subject(0); | ||
var itemRange$ = subject([0, 0]); | ||
var totalHeight$ = subject(0); | ||
var listOffset$ = subject(0); | ||
var scrollToIndex$ = coldSubject(); | ||
combineLatest(gridDimensions$, scrollTop$, overscan$, totalCount$).pipe(withLatestFrom(itemRange$)).subscribe(function (_ref) { | ||
var _ref$ = _ref[0], | ||
_ref$$ = _ref$[0], | ||
viewportWidth = _ref$$[0], | ||
viewportHeight = _ref$$[1], | ||
itemWidth = _ref$$[2], | ||
itemHeight = _ref$$[3], | ||
scrollTop = _ref$[1], | ||
overscan = _ref$[2], | ||
totalCount = _ref$[3], | ||
itemRange = _ref[1]; | ||
if (itemWidth === undefined || itemHeight === undefined) { | ||
return; | ||
} | ||
var startIndex = itemRange[0], | ||
endIndex = itemRange[1]; | ||
var itemsPerRow = hackFloor(viewportWidth / itemWidth); | ||
var toRowIndex = function toRowIndex(index, roundFunc) { | ||
if (roundFunc === void 0) { | ||
roundFunc = floor; | ||
} | ||
return roundFunc(index / itemsPerRow); | ||
}; | ||
var updateRange = function updateRange(down) { | ||
var _ref2 = down ? [0, overscan] : [overscan, 0], | ||
topOverscan = _ref2[0], | ||
bottomOverscan = _ref2[1]; | ||
var startIndex = itemsPerRow * floor((scrollTop - topOverscan) / itemHeight); | ||
var endIndex = itemsPerRow * ceil((scrollTop + viewportHeight + bottomOverscan) / itemHeight) - 1; | ||
startIndex = max(0, startIndex); | ||
endIndex = min(totalCount - 1, endIndex); | ||
itemRange$.next([startIndex, endIndex]); | ||
listOffset$.next(toRowIndex(startIndex) * itemHeight); | ||
}; | ||
var listTop = itemHeight * toRowIndex(startIndex); | ||
var listBottom = itemHeight * toRowIndex(endIndex) + itemHeight; // user is scrolling up - list top is below the top edge of the viewport | ||
if (listTop > scrollTop) { | ||
updateRange(false); // user is scrolling down - list bottom is above the bottom edge of the viewport | ||
} else if (listBottom < scrollTop + viewportHeight) { | ||
updateRange(true); | ||
} | ||
totalHeight$.next(itemHeight * toRowIndex(totalCount, ceil)); | ||
}); | ||
var scrollTo$ = scrollToIndex$.pipe(withLatestFrom(gridDimensions$, totalCount$), map(function (_ref3) { | ||
var location = _ref3[0], | ||
_ref3$ = _ref3[1], | ||
viewportWidth = _ref3$[0], | ||
viewportHeight = _ref3$[1], | ||
itemWidth = _ref3$[2], | ||
itemHeight = _ref3$[3], | ||
totalCount = _ref3[2]; | ||
if (itemWidth === undefined || itemHeight === undefined) { | ||
return 0; | ||
} | ||
if (typeof location === 'number') { | ||
location = { | ||
index: location, | ||
align: 'start' | ||
}; | ||
} | ||
var _location = location, | ||
index = _location.index, | ||
_location$align = _location.align, | ||
align = _location$align === void 0 ? 'start' : _location$align; | ||
index = Math.max(0, index, Math.min(totalCount - 1, index)); | ||
var itemsPerRow = hackFloor(viewportWidth / itemWidth); | ||
var offset = floor(index / itemsPerRow) * itemHeight; | ||
if (align == 'end') { | ||
offset = offset - viewportHeight + itemHeight; | ||
} else if (align === 'center') { | ||
offset = Math.round(offset - viewportHeight / 2 + itemHeight / 2); | ||
} | ||
return offset; | ||
})); | ||
var isScrolling$ = buildIsScrolling(scrollTop$); | ||
var endReached$ = coldSubject(); | ||
var currentEndIndex = 0; | ||
itemRange$.pipe(withLatestFrom(totalCount$)).subscribe(function (_ref4) { | ||
var _ref4$ = _ref4[0], | ||
_ = _ref4$[0], | ||
endIndex = _ref4$[1], | ||
totalCount = _ref4[1]; | ||
if (totalCount === 0) { | ||
return; | ||
} | ||
if (endIndex === totalCount - 1) { | ||
if (currentEndIndex !== endIndex) { | ||
currentEndIndex = endIndex; | ||
endReached$.next(endIndex); | ||
} | ||
} | ||
}); | ||
return { | ||
gridDimensions: makeInput(gridDimensions$), | ||
totalCount: makeInput(totalCount$), | ||
scrollTop: makeInput(scrollTop$), | ||
overscan: makeInput(overscan$), | ||
scrollToIndex: makeInput(scrollToIndex$), | ||
itemRange: makeOutput(itemRange$), | ||
totalHeight: makeOutput(totalHeight$), | ||
listOffset: makeOutput(listOffset$), | ||
scrollTo: makeOutput(scrollTo$), | ||
isScrolling: makeOutput(isScrolling$), | ||
endReached: makeOutput(endReached$) | ||
}; | ||
}; | ||
var VirtuosoGrid = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inheritsLoose(VirtuosoGrid, _React$PureComponent); | ||
function VirtuosoGrid() { | ||
var _this; | ||
_this = _React$PureComponent.apply(this, arguments) || this; | ||
_this.state = VirtuosoGridEngine(); | ||
return _this; | ||
} | ||
VirtuosoGrid.getDerivedStateFromProps = function getDerivedStateFromProps(props, engine) { | ||
engine.overscan(props.overscan || 0); | ||
engine.totalCount(props.totalCount); | ||
engine.isScrolling(props.scrollingStateChange); | ||
engine.endReached(props.endReached); | ||
return null; | ||
}; | ||
var _proto = VirtuosoGrid.prototype; | ||
_proto.scrollToIndex = function scrollToIndex(location) { | ||
this.state.scrollToIndex(location); | ||
}; | ||
_proto.render = function render() { | ||
return React__default.createElement(VirtuosoGridFC, Object.assign({}, this.props, { | ||
engine: this.state | ||
})); | ||
}; | ||
return VirtuosoGrid; | ||
}(React__default.PureComponent); | ||
var buildItems = function buildItems(_ref, item, itemClassName) { | ||
var startIndex = _ref[0], | ||
endIndex = _ref[1]; | ||
var items = []; | ||
for (var index = startIndex; index <= endIndex; index++) { | ||
items.push(React__default.createElement("div", { | ||
key: index, | ||
className: itemClassName | ||
}, item(index))); | ||
} | ||
return items; | ||
}; | ||
var VirtuosoGridFC = function VirtuosoGridFC(_ref2) { | ||
var ScrollContainer = _ref2.ScrollContainer, | ||
className = _ref2.className, | ||
item = _ref2.item, | ||
_ref2$itemClassName = _ref2.itemClassName, | ||
itemClassName = _ref2$itemClassName === void 0 ? 'virtuoso-grid-item' : _ref2$itemClassName, | ||
_ref2$listClassName = _ref2.listClassName, | ||
listClassName = _ref2$listClassName === void 0 ? 'virtuoso-grid-list' : _ref2$listClassName, | ||
engine = _ref2.engine, | ||
_ref2$style = _ref2.style, | ||
style = _ref2$style === void 0 ? { | ||
height: '40rem' | ||
} : _ref2$style; | ||
var itemRange = engine.itemRange, | ||
listOffset = engine.listOffset, | ||
totalHeight = engine.totalHeight, | ||
gridDimensions = engine.gridDimensions, | ||
scrollTo = engine.scrollTo, | ||
scrollTop = engine.scrollTop; | ||
var fillerHeight = useOutput(totalHeight, 0); | ||
var translate = useOutput(listOffset, 0); | ||
var listStyle = { | ||
marginTop: translate + "px" | ||
}; | ||
var itemIndexRange = useOutput(itemRange, [0, 0]); | ||
var viewportCallbackRef = useSize(function (_ref3) { | ||
var element = _ref3.element, | ||
width = _ref3.width, | ||
height = _ref3.height; | ||
var firstItem = element.firstChild.firstChild; | ||
gridDimensions([width, height, firstItem.offsetWidth, firstItem.offsetHeight]); | ||
}); | ||
return React__default.createElement(VirtuosoScroller, { | ||
style: style, | ||
ScrollContainer: ScrollContainer, | ||
className: className, | ||
scrollTo: scrollTo, | ||
scrollTop: scrollTop | ||
}, React__default.createElement("div", { | ||
ref: viewportCallbackRef, | ||
style: viewportStyle | ||
}, React__default.createElement("div", { | ||
style: listStyle, | ||
className: listClassName | ||
}, buildItems(itemIndexRange, item, itemClassName))), React__default.createElement(VirtuosoFiller, { | ||
height: fillerHeight | ||
})); | ||
}; | ||
exports.GroupedVirtuoso = GroupedVirtuoso; | ||
exports.Virtuoso = Virtuoso; | ||
exports.VirtuosoGrid = VirtuosoGrid; | ||
exports.VirtuosoPresentation = VirtuosoPresentation; | ||
//# sourceMappingURL=react-virtuoso.cjs.development.js.map |
@@ -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 u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e,t,n){return(a=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&&u(i,n.prototype),i}).apply(null,arguments)}function f(e){var t="function"==typeof Map?new Map:void 0;return(f=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 a(e,arguments,s(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)})(e)}var l=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 p(){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 u=function(e){return o.push(e),s([e]),function(){o=o.filter(function(t){return t!==e})}};return{subscribe:u,pipe:c(u)}}function d(e){return function(t,n){n(e(t))}}function y(e){return function(t,n){return n(e)}}function g(e){return function(t,n){e>0?e--:n(t)}}function m(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 w({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}(f(Error)),w=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}(),C=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=C.empty(),n=0,r=!1,i=e.ranges(),o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var u;if(o){if(s>=i.length)break;u=i[s++]}else{if((s=i.next()).done)break;u=s.value}var a=u.start,f=u.end,l=u.value;isNaN(l)?(this.nanIndices.push(a),r||(t=t.insert(n,{startIndex:a,endIndex:Infinity,size:l})),r=!0):r||(t=t.insert(n,{startIndex:a,endIndex:f,size:l}),n+=(f-a+1)*l)}this.offsetTree=t}e.create=function(){return new e(C.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(C.empty().insert(0,r));var o=this.nanIndices,s=Array.isArray(o),u=0;for(o=s?o:o[Symbol.iterator]();;){var a;if(s){if(u>=o.length)break;a=o[u++]}else{if((u=o.next()).done)break;a=u.value}i=i.insert(a,r)}return new e(i)}var f=i.rangesWithin(t-1,n+1);if(f.some(function(e){return e.start===t&&(e.end===n||Infinity===e.end)&&e.value===r}))return this;var l=!1,c=!1,h=f,p=Array.isArray(h),v=0;for(h=p?h:h[Symbol.iterator]();;){var d;if(p){if(v>=h.length)break;d=h[v++]}else{if((v=h.next()).done)break;d=v.value}var y=d.start,g=d.end,m=d.value;l?(n>=y||r===m)&&(i=i.remove(y)):(c=m!==r,l=!0),g>n&&n>=y&&(m===r||isNaN(m)||(i=i.insert(n+1,m)))}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 u;if(o){if(s>=i.length)break;u=i[s++]}else{if((s=i.next()).done)break;u=s.value}var a=u;r=r.insert(a,n).insert(a+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 u=s,a=Math.max(e,u.start),f=Math.min(t,void 0===u.end?Infinity:u.end),l=a;l<=f;l++)n.push({index:l,size:u.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),u=0;for(o=s?o:o[Symbol.iterator]();;){var a;if(s){if(u>=o.length)break;a=o[u++]}else{if((u=o.next()).done)break;a=u.value}var f=a.start,l=a.value,c=l.startIndex,h=l.endIndex,p=l.size,v=f,d=c;if(f<e&&(v+=((d+=Math.floor((e-f)/p))-c)*p),d<n&&(v+=(n-d)*p,d=n),isNaN(p))return i.push({index:d,size:0,offset:v}),i;h=Math.min(h,r);for(var y=d;y<=h&&!(v>t);y++)i.push({index:y,size:p,offset:v}),v+=p}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,u=o.end,a=o.value;t+=((u=Math.min(u,e))-s+1)*(isNaN(a)?0:a)}return t},t.getOffsets=function(e){var t=this,n=C.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}(),M=function(){function e(e){this.count=e.reduce(function(e,t){return e+t+1},0);var t=C.empty(),n=0,r=0,i=e,o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var u;if(o){if(s>=i.length)break;u=i[s++]}else{if((s=i.next()).done)break;u=s.value}var a=u;t=t.insert(r,[n,r]),n++,r+=a+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 O(e){var t;return function(n){t&&t(),n&&(t=e.subscribe(n))}}function T(e){return e.next}var N=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),u=h(0),a=h(0),f=h(0),l=h(),c=h(i),b=h(),k=h(),w=h(!1),C=I.create(),E=h([]),A=p();o&&(C=C.insert(0,0,o));var R=h(C);o||l.pipe(x(R,E)).subscribe(function(e){var t=e[1],n=e[2],r=t,i=e[0],o=Array.isArray(i),s=0;for(i=o?i:i[Symbol.iterator]();;){var u;if(o){if(s>=i.length)break;u=i[s++]}else{if((s=i.next()).done)break;u=s.value}var a=u.start,f=u.end,l=u.size;r=r.empty()&&a==f&&n.indexOf(a)>-1?r.insertSpots(n,l):r.insert(a,f,l)}r!==t&&R.next(r)});var j=new S;b.subscribe(function(e){j=new M(e),c.next(j.totalCount()),E.next(j.groupIndices())});var W=v(R,c).pipe(d(z)),H=v(W,f).pipe(d(function(e){return e[0]+e[1]})),L=v(R,E).pipe(d(function(e){return e[0].getOffsets(e[1])})),V=h([]);v(R,k,c).pipe(m(function(e){return e[1]>0}),d(function(e){var t=e[0],n=Math.max(0,Math.min(e[1]-1,e[2]));return j.transpose(t.indexRange(0,n))})).subscribe(V.next),v(R,L,a).pipe(m(function(e){return!e[1].empty()&&!e[0].empty()}),x(V),d(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 j.transpose([o])})).subscribe(V.next);var F,P,_=V.pipe(d(function(e){return e.reduce(function(e,t){return e+t.size},0)})),D=v(s,a,_,u,f,V.pipe(d(function(e){return e.length&&e[e.length-1].index+1})),c,R).pipe((F=function(e){return function(t,n){var r=n[0],i=n[1],o=n[2],s=n[3],u=n[4],a=n[5],f=n[6],l=n[7],c=t.length;if(0===f)return 0===c?t:[];var h=N(t),p=h-i+s-u-o,v=Math.max(f-1,0);if(p<r||c>0&&(t[0].index<a||t[c-1].index>v)){var d=Math.max(i+o,o);return j.transpose(l.range(d,i+r+2*e-1,a,v))}if(h>i+o){var y=Math.max(i+o-2*e,o);return j.transpose(l.range(y,i+r-1,a,v))}return t}}(n),P=[],function(e,t){t(P=F(P,e))})),q=p(),U=0;D.pipe(d(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&&U!==t&&(U=t,q.next(t))});var G,Y,B=v(D,a,_).pipe(d(function(e){return N(e[0])}));a.pipe(g(1),y(!0)).subscribe(w.next),a.pipe(g(1),y(!1),function(e,t){G=e,Y&&clearTimeout(Y),Y=setTimeout(function(){t(G)},200)}).subscribe(w.next);var J=A.pipe(x(R,_,E,s,c),d(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,u=t.align,a=void 0===u?"start":u;s=Math.max(0,s,Math.min(e[5]-1,s));var f=n.offsetOf(s);return"end"==a?f=f-o+n.itemAt(s).size:"center"===a?f=Math.round(f-o/2+n.itemAt(s).size/2):-1===i.indexOf(s)&&(f-=r),f})),K=E.pipe(),Q=B.pipe(d(function(e){return-e}));return{groupCounts:T(b),itemHeights:T(l),footerHeight:T(f),listHeight:T(u),viewportHeight:T(s),scrollTop:T(a),topItemCount:T(k),totalCount:T(c),scrollToIndex:T(A),list:O(D),topList:O(V),listOffset:O(B),totalHeight:O(H),endReached:O(q),isScrolling:O(w),stickyItems:O(E),groupIndices:O(K),stickyItemsOffset:O(Q),scrollTo:O(J)}},R=function(e,n,i){var o=t.useRef(null),s=t.useRef(0),u=new r(function(t){var n=t[0].contentRect.height;s.current!==n&&(s.current=n,i&&i(t[0].target),e(n))});return function(e){e?(u.observe(e),n&&n(e),o.current=e):(u.unobserve(o.current),o.current=null)}};function j(e,n){var r=t.useState(n),i=r[0],o=r[1];return t.useLayoutEffect(function(){return e(o),function(){e(void 0)}},[]),i}var W={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},H=function(e){var r=e.className,i=e.style,o=e.reportScrollTop,s=e.scrollTo,u=e.children,a=t.useRef(null),f=t.useCallback(function(e){o(e.target.scrollTop)},[]),l=t.useCallback(function(e){e?(e.addEventListener("scroll",f,{passive:!0}),a.current=e):a.current.removeEventListener("scroll",f)},[]);return s(function(e){a.current.scrollTo({top:e})}),n.createElement("div",{ref:l,style:i,tabIndex:0,className:r},u)},L=function(e){var r=e.children,o=e.style,s=e.className,u=e.ScrollContainer,a=void 0===u?H:u,f=t.useContext(l),c=f.scrollTop,h=f.scrollTo;return n.createElement(a,{style:i({},W,o),reportScrollTop:c,scrollTo:h,className:s},r)},V=function(e){var r=e.render,i=e.stickyClassName,o=t.useContext(l),s=o.topList,u=j(o.list,[]),a=j(s,[]),f=[],c=0,h=[],p=a.reduce(function(e,t){return e+t.size},0);return a.forEach(function(e,t){var n=e.index;h.push(n),f.push(r(e,{key:n,"data-index":n,"data-known-size":e.size,className:i,style:{top:c+"px",marginTop:0===t?-p+"px":void 0}})),c+=e.size}),u.forEach(function(e){h.indexOf(e.index)>-1||f.push(r(e,{key:e.index,"data-index":e.index,"data-known-size":e.size}))}),n.createElement(n.Fragment,null," ",f," ")},F=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 } "),r.current=e,function(){document.head.removeChild(r.current),r.current=null}},[]),null},P=function(){return String.fromCharCode(Math.round(25*Math.random()+97))},_=function(){return new Array(12).fill(0).map(P).join("")},D=function(e){return n.createElement("footer",{ref:e.footerRef},e.children)},q=function(e){return n.createElement("div",{ref:e.listRef,style:e.style},e.children)},U=function(e){var r=e.footer,i=e.FooterContainer,o=void 0===i?D:i,s=R(t.useContext(l).footerHeight);return n.createElement(o,{footerRef:s},r())},G=function(e){var r=e.fixedItemHeight,i=e.children,o=e.ListContainer,s=t.useContext(l),u=s.listHeight,a=s.itemHeights,f={marginTop:j(s.listOffset,0)+"px"},c=R(u,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),u=i.offsetHeight;if(u!==s){var a=t[t.length-1];0===t.length||a.size!==u||a.end!==o-1?t.push({start:o,end:o,size:u}):t[t.length-1].end++}}}return t}(e.children);t.length>0&&a(t)}});return n.createElement(o,{listRef:c,style:f},i)},Y={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},B=function(e){var r=e.style,i=e.footer,o=e.item,s=e.fixedItemHeight,u=e.ScrollContainer,a=e.ListContainer,f=e.FooterContainer,c=e.className,h=t.useContext(l),p=h.viewportHeight,v=j(h.totalHeight,0),d=t.useMemo(_,[]),y=R(p);return n.createElement(L,{style:r,ScrollContainer:u,className:c},n.createElement("div",{ref:y,style:Y},n.createElement(G,{fixedItemHeight:s,ListContainer:a},n.createElement(V,{render:o,stickyClassName:d}),i&&n.createElement(U,{footer:i,FooterContainer:f}))),n.createElement("div",{style:{height:v+"px",position:"absolute",top:0}}," "),n.createElement(F,Object.assign({},{stickyClassName:d})))},J=function(e){return n.createElement(l.Provider,{value:e.contextValue},n.createElement(B,{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||q}))},K=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.item(e.index);return i?n.createElement(i,Object.assign({key:t.key},t),o):n.createElement("div",Object.assign({},t),o)},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),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.render=function(){return n.createElement(J,{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);exports.GroupedVirtuoso=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 u=r.props.item(e.transposedIndex,e.groupIndex);return i?n.createElement(i,Object.assign({key:t.key},t),u):n.createElement("div",Object.assign({},t),u)},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),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},r.render=function(){return n.createElement(J,{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),exports.Virtuoso=K,exports.VirtuosoPresentation=J; | ||
"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 p(){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 d(e){return function(t,n){n(e(t))}}function g(e){return function(t,n){return n(e)}}function y(e){return function(t,n){e>0?e--:n(t)}}function m(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 w({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)),w=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}(),C=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=C.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(C.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(C.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,p=Array.isArray(h),v=0;for(h=p?h:h[Symbol.iterator]();;){var d;if(p){if(v>=h.length)break;d=h[v++]}else{if((v=h.next()).done)break;d=v.value}var g=d.start,y=d.end,m=d.value;f?(n>=g||r===m)&&(i=i.remove(g)):(c=m!==r,f=!0),y>n&&n>=g&&(m===r||isNaN(m)||(i=i.insert(n+1,m)))}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,p=f.size,v=l,d=c;if(l<e&&(v+=((d+=Math.floor((e-l)/p))-c)*p),d<n&&(v+=(n-d)*p,d=n),isNaN(p))return i.push({index:d,size:0,offset:v}),i;h=Math.min(h,r);for(var g=d;g<=h&&!(v>t);g++)i.push({index:g,size:p,offset:v}),v+=p}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=C.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=C.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 M(e){var t;return function(n){t&&t(),n&&(t=e.subscribe(n))}}function N(e){return e.next}var O=function(e){var t,n,r=h(!1);return e.pipe(y(1),g(!0)).subscribe(r.next),e.pipe(y(1),g(!1),function(e,r){t=e,n&&clearTimeout(n),n=setTimeout(function(){r(t)},200)}).subscribe(r.next),r},R=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(),y=h(),b=I.create(),k=h([]),w=p();o&&(b=b.insert(0,0,o));var C=h(b);o||f.pipe(x(C,k)).subscribe(function(e){var t=e[1],n=e[2],r=t,i=e[0],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.size;r=r.empty()&&u==l&&n.indexOf(u)>-1?r.insertSpots(n,f):r.insert(u,l,f)}r!==t&&C.next(r)});var E=new S;g.subscribe(function(e){E=new T(e),c.next(E.totalCount()),k.next(E.groupIndices())});var A=v(C,c).pipe(d(z)),j=v(A,l).pipe(d(function(e){return e[0]+e[1]})),H=v(C,k).pipe(d(function(e){return e[0].getOffsets(e[1])})),W=h([]);v(C,y,c).pipe(m(function(e){return e[1]>0}),d(function(e){var t=e[0],n=Math.max(0,Math.min(e[1]-1,e[2]));return E.transpose(t.indexRange(0,n))})).subscribe(W.next),v(C,H,u).pipe(m(function(e){return!e[1].empty()&&!e[0].empty()}),x(W),d(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 E.transpose([o])})).subscribe(W.next);var L,V,F=W.pipe(d(function(e){return e.reduce(function(e,t){return e+t.size},0)})),P=v(s,u,F,a,l,W.pipe(d(function(e){return e.length&&e[e.length-1].index+1})),c,C).pipe((L=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=R(t),p=h-i+s-a-o,v=Math.max(l-1,0);if(p<r||c>0&&(t[0].index<u||t[c-1].index>v)){var d=Math.max(i+o,o);return E.transpose(f.range(d,i+r+2*e-1,u,v))}if(h>i+o){var g=Math.max(i+o-2*e,o);return E.transpose(f.range(g,i+r-1,u,v))}return t}}(n),V=[],function(e,t){t(V=L(V,e))})),_=p(),D=0;P.pipe(d(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&&D!==t&&(D=t,_.next(t))});var q=v(P,u,F).pipe(d(function(e){return R(e[0])})),G=w.pipe(x(C,F,k,s,c),d(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})),U=k.pipe(),Y=q.pipe(d(function(e){return-e})),B=O(u);return{groupCounts:N(g),itemHeights:N(f),footerHeight:N(l),listHeight:N(a),viewportHeight:N(s),scrollTop:N(u),topItemCount:N(y),totalCount:N(c),scrollToIndex:N(w),list:M(P),topList:M(W),listOffset:M(q),totalHeight:M(j),endReached:M(_),isScrolling:M(B),stickyItems:M(k),groupIndices:M(U),stickyItemsOffset:M(Y),scrollTo:M(G)}},j=function(e,n,i){var o=t.useRef(null),s=t.useRef(0),a=new r(function(t){var n=t[0].contentRect.height;s.current!==n&&(s.current=n,i&&i(t[0].target),e(n))});return function(e){e?(a.observe(e),n&&n(e),o.current=e):(a.unobserve(o.current),o.current=null)}};function H(e,n){var r=t.useState(n),i=r[0],o=r[1];return t.useLayoutEffect(function(){return e(o),function(){e(void 0)}},[]),i}var W={height:"40rem",overflowY:"auto",WebkitOverflowScrolling:"touch",position:"relative",outline:"none"},L=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?L: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=H(o.list,[]),u=H(s,[]),l=[],c=0,h=[],p=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?-p+"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("")},q={top:0,position:"absolute",height:"100%",width:"100%",overflow:"absolute"},G=function(e){return n.createElement("div",{style:{height:e.height+"px",position:"absolute",top:0}}," ")},U=function(e){return n.createElement("footer",{ref:e.footerRef},e.children)},Y=function(e){return n.createElement("div",{ref:e.listRef,style:e.style},e.children)},B=function(e){var r=e.footer,i=e.FooterContainer,o=void 0===i?U:i,s=j(t.useContext(f).footerHeight);return n.createElement(o,{footerRef:s},r())},J=function(e){var r=e.fixedItemHeight,i=e.children,o=e.ListContainer,s=t.useContext(f),a=s.listHeight,u=s.itemHeights,l={marginTop:H(s.listOffset,0)+"px"},c=j(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)},K=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),p=h.scrollTo,v=h.scrollTop,d=h.viewportHeight,g=H(h.totalHeight,0),y=t.useMemo(D,[]),m=j(d);return n.createElement(V,{style:r,ScrollContainer:a,className:c,scrollTo:p,scrollTop:v},n.createElement("div",{ref:m,style:q},n.createElement(J,{fixedItemHeight:s,ListContainer:u},n.createElement(F,{render:o,stickyClassName:y}),i&&n.createElement(B,{footer:i,FooterContainer:l}))),n.createElement(G,{height:g}),n.createElement(P,Object.assign({},{stickyClassName:y})))},Q=function(e){return n.createElement(f.Provider,{value:e.contextValue},n.createElement(K,{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||Y}))},X=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.item(e.index);return i?n.createElement(i,Object.assign({key:t.key},t),o):n.createElement("div",Object.assign({},t),o)},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),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},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),null};var r=t.prototype;return r.scrollToIndex=function(e){this.state.scrollToIndex(e)},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<.01?$(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=p();v(e,n,r,t).pipe(x(i)).subscribe(function(e){var t=e[0],n=t[0],r=n[1],a=n[2],u=n[3],l=t[1],f=t[2],c=t[3],h=e[1];if(void 0!==a&&void 0!==u){var p=h[0],v=h[1],d=re(n[0]/a),g=function(e,t){return void 0===t&&(t=ee),t(e/d)},y=function(e){var t=e?[0,f]:[f,0],n=t[1],o=d*ee((l-t[0])/u),a=d*$((l+r+n)/u)-1;o=ne(0,o),a=te(c-1,a),i.next([o,a]),s.next(g(o)*u)},m=u*g(p),x=u*g(v)+u;m>l?y(!1):x<l+r&&y(!0),o.next(u*g(c,$))}});var u=a.pipe(x(e,t),d(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=O(n),f=p(),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:N(e),totalCount:N(t),scrollTop:N(n),overscan:N(r),scrollToIndex:N(a),itemRange:M(i),totalHeight:M(o),listOffset:M(s),scrollTo:M(u),isScrolling:M(l),endReached:M(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.className,f=e.item,c=e.itemClassName,h=void 0===c?"virtuoso-grid-item":c,p=e.listClassName,v=void 0===p?"virtuoso-grid-list":p,d=e.engine,g=e.style,y=void 0===g?{height:"40rem"}:g,m=d.itemRange,x=d.listOffset,b=d.gridDimensions,k=d.scrollTo,w=d.scrollTop,C=H(d.totalHeight,0),I={marginTop:H(x,0)+"px"},E=H(m,[0,0]),S=(i=function(e){var t=e.element.firstChild.firstChild;b([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:y,ScrollContainer:u,className:l,scrollTo:k,scrollTop:w},n.createElement("div",{ref:S,style:q},n.createElement("div",{style:I,className:v},function(e,t,r){for(var i=E[1],o=[],s=E[0];s<=i;s++)o.push(n.createElement("div",{key:s,className:r},t(s)));return o}(0,f,h))),n.createElement(G,{height:C}))};exports.GroupedVirtuoso=Z,exports.Virtuoso=X,exports.VirtuosoGrid=oe,exports.VirtuosoPresentation=Q; | ||
//# sourceMappingURL=react-virtuoso.cjs.production.min.js.map |
@@ -1,2 +0,2 @@ | ||
import React, { createContext, useRef, useState, useLayoutEffect, useContext, useCallback, useMemo, PureComponent } from 'react'; | ||
import React, { createContext, useState, useLayoutEffect, useRef, useCallback, useContext, useMemo, PureComponent } from 'react'; | ||
import ResizeObserver from 'resize-observer-polyfill'; | ||
@@ -1366,2 +1366,9 @@ | ||
var buildIsScrolling = function buildIsScrolling(scrollTop$) { | ||
var isScrolling$ = subject(false); | ||
scrollTop$.pipe(skip(1), mapTo(true)).subscribe(isScrolling$.next); | ||
scrollTop$.pipe(skip(1), mapTo(false), debounceTime(200)).subscribe(isScrolling$.next); | ||
return isScrolling$; | ||
}; | ||
var getListTop = function getListTop(items) { | ||
@@ -1391,3 +1398,2 @@ return items.length > 0 ? items[0].offset : 0; | ||
var topItemCount$ = subject(); | ||
var isScrolling$ = subject(false); | ||
var initialOffsetList = OffsetList.create(); | ||
@@ -1455,3 +1461,3 @@ var stickyItems$ = subject([]); | ||
if (totalCount === 0) { | ||
return itemLength === 0 ? items : []; | ||
return []; | ||
} | ||
@@ -1558,4 +1564,2 @@ | ||
})); | ||
scrollTop$.pipe(skip(1), mapTo(true)).subscribe(isScrolling$.next); | ||
scrollTop$.pipe(skip(1), mapTo(false), debounceTime(200)).subscribe(isScrolling$.next); | ||
var scrollTo$ = scrollToIndex$.pipe(withLatestFrom(offsetList$, topListHeight$, stickyItems$, viewportHeight$, totalCount$), map(function (_ref13) { | ||
@@ -1599,2 +1603,3 @@ var location = _ref13[0], | ||
})); | ||
var isScrolling$ = buildIsScrolling(scrollTop$); | ||
return { | ||
@@ -1670,3 +1675,33 @@ groupCounts: makeInput(groupCounts$), | ||
} | ||
var useSize = function useSize(callback) { | ||
var ref = useRef(null); | ||
var currentSize = useRef([0, 0]); | ||
var observer = new ResizeObserver(function (entries) { | ||
var _entries$0$contentRec = entries[0].contentRect, | ||
width = _entries$0$contentRec.width, | ||
height = _entries$0$contentRec.height; | ||
if (currentSize.current[0] !== width || currentSize.current[1] !== height) { | ||
currentSize.current = [width, height]; | ||
callback({ | ||
element: entries[0].target, | ||
width: width, | ||
height: height | ||
}); | ||
} | ||
}); | ||
var callbackRef = function callbackRef(elRef) { | ||
if (elRef) { | ||
observer.observe(elRef); | ||
ref.current = elRef; | ||
} else { | ||
observer.unobserve(ref.current); | ||
ref.current = null; | ||
} | ||
}; | ||
return callbackRef; | ||
}; | ||
var scrollerStyle = { | ||
@@ -1719,8 +1754,5 @@ height: '40rem', | ||
_ref2$ScrollContainer = _ref2.ScrollContainer, | ||
ScrollContainer = _ref2$ScrollContainer === void 0 ? DefaultScrollContainer : _ref2$ScrollContainer; | ||
var _useContext = useContext(VirtuosoContext), | ||
scrollTop = _useContext.scrollTop, | ||
scrollTo = _useContext.scrollTo; | ||
ScrollContainer = _ref2$ScrollContainer === void 0 ? DefaultScrollContainer : _ref2$ScrollContainer, | ||
scrollTop = _ref2.scrollTop, | ||
scrollTo = _ref2.scrollTo; | ||
return React.createElement(ScrollContainer, { | ||
@@ -1788,3 +1820,3 @@ style: _extends({}, scrollerStyle, style), | ||
var sheet = styleEl.sheet; | ||
sheet.insertRule("." + stickyClassName + " {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } "); | ||
sheet.insertRule("." + stickyClassName + " {\n position: sticky;\n position: -webkit-sticky;\n z-index: 2;\n } ", 0); | ||
style.current = styleEl; | ||
@@ -1808,3 +1840,21 @@ return function () { | ||
}; | ||
var viewportStyle = { | ||
top: 0, | ||
position: 'absolute', | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'absolute' | ||
}; | ||
var VirtuosoFiller = function VirtuosoFiller(_ref) { | ||
var height = _ref.height; | ||
return React.createElement("div", { | ||
style: { | ||
height: height + "px", | ||
position: 'absolute', | ||
top: 0 | ||
} | ||
}, "\xA0"); | ||
}; | ||
var DefaultFooterContainer = function DefaultFooterContainer(_ref) { | ||
@@ -1900,9 +1950,2 @@ var children = _ref.children, | ||
var viewportStyle = { | ||
top: 0, | ||
position: 'absolute', | ||
height: '100%', | ||
width: '100%', | ||
overflow: 'absolute' | ||
}; | ||
var VirtuosoView = function VirtuosoView(_ref5) { | ||
@@ -1919,2 +1962,4 @@ var style = _ref5.style, | ||
var _useContext2 = useContext(VirtuosoContext), | ||
scrollTo = _useContext2.scrollTo, | ||
scrollTop = _useContext2.scrollTop, | ||
totalHeight = _useContext2.totalHeight, | ||
@@ -1929,3 +1974,5 @@ viewportHeight = _useContext2.viewportHeight; | ||
ScrollContainer: ScrollContainer, | ||
className: className | ||
className: className, | ||
scrollTo: scrollTo, | ||
scrollTop: scrollTop | ||
}, React.createElement("div", { | ||
@@ -1943,9 +1990,5 @@ ref: viewportCallbackRef, | ||
FooterContainer: FooterContainer | ||
}))), React.createElement("div", { | ||
style: { | ||
height: fillerHeight + "px", | ||
position: 'absolute', | ||
top: 0 | ||
} | ||
}, "\xA0"), React.createElement(VirtuosoStyle, Object.assign({}, { | ||
}))), React.createElement(VirtuosoFiller, { | ||
height: fillerHeight | ||
}), React.createElement(VirtuosoStyle, Object.assign({}, { | ||
stickyClassName: stickyClassName | ||
@@ -2109,3 +2152,244 @@ }))); | ||
export { GroupedVirtuoso, Virtuoso, VirtuosoPresentation }; | ||
var ceil = Math.ceil, | ||
floor = Math.floor, | ||
min = Math.min, | ||
max = Math.max; | ||
var hackFloor = function hackFloor(val) { | ||
return ceil(val) - val < 0.01 ? ceil(val) : floor(val); | ||
}; | ||
var VirtuosoGridEngine = function VirtuosoGridEngine() { | ||
var gridDimensions$ = subject([0, 0, undefined, undefined]); | ||
var totalCount$ = subject(0); | ||
var scrollTop$ = subject(0); | ||
var overscan$ = subject(0); | ||
var itemRange$ = subject([0, 0]); | ||
var totalHeight$ = subject(0); | ||
var listOffset$ = subject(0); | ||
var scrollToIndex$ = coldSubject(); | ||
combineLatest(gridDimensions$, scrollTop$, overscan$, totalCount$).pipe(withLatestFrom(itemRange$)).subscribe(function (_ref) { | ||
var _ref$ = _ref[0], | ||
_ref$$ = _ref$[0], | ||
viewportWidth = _ref$$[0], | ||
viewportHeight = _ref$$[1], | ||
itemWidth = _ref$$[2], | ||
itemHeight = _ref$$[3], | ||
scrollTop = _ref$[1], | ||
overscan = _ref$[2], | ||
totalCount = _ref$[3], | ||
itemRange = _ref[1]; | ||
if (itemWidth === undefined || itemHeight === undefined) { | ||
return; | ||
} | ||
var startIndex = itemRange[0], | ||
endIndex = itemRange[1]; | ||
var itemsPerRow = hackFloor(viewportWidth / itemWidth); | ||
var toRowIndex = function toRowIndex(index, roundFunc) { | ||
if (roundFunc === void 0) { | ||
roundFunc = floor; | ||
} | ||
return roundFunc(index / itemsPerRow); | ||
}; | ||
var updateRange = function updateRange(down) { | ||
var _ref2 = down ? [0, overscan] : [overscan, 0], | ||
topOverscan = _ref2[0], | ||
bottomOverscan = _ref2[1]; | ||
var startIndex = itemsPerRow * floor((scrollTop - topOverscan) / itemHeight); | ||
var endIndex = itemsPerRow * ceil((scrollTop + viewportHeight + bottomOverscan) / itemHeight) - 1; | ||
startIndex = max(0, startIndex); | ||
endIndex = min(totalCount - 1, endIndex); | ||
itemRange$.next([startIndex, endIndex]); | ||
listOffset$.next(toRowIndex(startIndex) * itemHeight); | ||
}; | ||
var listTop = itemHeight * toRowIndex(startIndex); | ||
var listBottom = itemHeight * toRowIndex(endIndex) + itemHeight; // user is scrolling up - list top is below the top edge of the viewport | ||
if (listTop > scrollTop) { | ||
updateRange(false); // user is scrolling down - list bottom is above the bottom edge of the viewport | ||
} else if (listBottom < scrollTop + viewportHeight) { | ||
updateRange(true); | ||
} | ||
totalHeight$.next(itemHeight * toRowIndex(totalCount, ceil)); | ||
}); | ||
var scrollTo$ = scrollToIndex$.pipe(withLatestFrom(gridDimensions$, totalCount$), map(function (_ref3) { | ||
var location = _ref3[0], | ||
_ref3$ = _ref3[1], | ||
viewportWidth = _ref3$[0], | ||
viewportHeight = _ref3$[1], | ||
itemWidth = _ref3$[2], | ||
itemHeight = _ref3$[3], | ||
totalCount = _ref3[2]; | ||
if (itemWidth === undefined || itemHeight === undefined) { | ||
return 0; | ||
} | ||
if (typeof location === 'number') { | ||
location = { | ||
index: location, | ||
align: 'start' | ||
}; | ||
} | ||
var _location = location, | ||
index = _location.index, | ||
_location$align = _location.align, | ||
align = _location$align === void 0 ? 'start' : _location$align; | ||
index = Math.max(0, index, Math.min(totalCount - 1, index)); | ||
var itemsPerRow = hackFloor(viewportWidth / itemWidth); | ||
var offset = floor(index / itemsPerRow) * itemHeight; | ||
if (align == 'end') { | ||
offset = offset - viewportHeight + itemHeight; | ||
} else if (align === 'center') { | ||
offset = Math.round(offset - viewportHeight / 2 + itemHeight / 2); | ||
} | ||
return offset; | ||
})); | ||
var isScrolling$ = buildIsScrolling(scrollTop$); | ||
var endReached$ = coldSubject(); | ||
var currentEndIndex = 0; | ||
itemRange$.pipe(withLatestFrom(totalCount$)).subscribe(function (_ref4) { | ||
var _ref4$ = _ref4[0], | ||
_ = _ref4$[0], | ||
endIndex = _ref4$[1], | ||
totalCount = _ref4[1]; | ||
if (totalCount === 0) { | ||
return; | ||
} | ||
if (endIndex === totalCount - 1) { | ||
if (currentEndIndex !== endIndex) { | ||
currentEndIndex = endIndex; | ||
endReached$.next(endIndex); | ||
} | ||
} | ||
}); | ||
return { | ||
gridDimensions: makeInput(gridDimensions$), | ||
totalCount: makeInput(totalCount$), | ||
scrollTop: makeInput(scrollTop$), | ||
overscan: makeInput(overscan$), | ||
scrollToIndex: makeInput(scrollToIndex$), | ||
itemRange: makeOutput(itemRange$), | ||
totalHeight: makeOutput(totalHeight$), | ||
listOffset: makeOutput(listOffset$), | ||
scrollTo: makeOutput(scrollTo$), | ||
isScrolling: makeOutput(isScrolling$), | ||
endReached: makeOutput(endReached$) | ||
}; | ||
}; | ||
var VirtuosoGrid = | ||
/*#__PURE__*/ | ||
function (_React$PureComponent) { | ||
_inheritsLoose(VirtuosoGrid, _React$PureComponent); | ||
function VirtuosoGrid() { | ||
var _this; | ||
_this = _React$PureComponent.apply(this, arguments) || this; | ||
_this.state = VirtuosoGridEngine(); | ||
return _this; | ||
} | ||
VirtuosoGrid.getDerivedStateFromProps = function getDerivedStateFromProps(props, engine) { | ||
engine.overscan(props.overscan || 0); | ||
engine.totalCount(props.totalCount); | ||
engine.isScrolling(props.scrollingStateChange); | ||
engine.endReached(props.endReached); | ||
return null; | ||
}; | ||
var _proto = VirtuosoGrid.prototype; | ||
_proto.scrollToIndex = function scrollToIndex(location) { | ||
this.state.scrollToIndex(location); | ||
}; | ||
_proto.render = function render() { | ||
return React.createElement(VirtuosoGridFC, Object.assign({}, this.props, { | ||
engine: this.state | ||
})); | ||
}; | ||
return VirtuosoGrid; | ||
}(React.PureComponent); | ||
var buildItems = function buildItems(_ref, item, itemClassName) { | ||
var startIndex = _ref[0], | ||
endIndex = _ref[1]; | ||
var items = []; | ||
for (var index = startIndex; index <= endIndex; index++) { | ||
items.push(React.createElement("div", { | ||
key: index, | ||
className: itemClassName | ||
}, item(index))); | ||
} | ||
return items; | ||
}; | ||
var VirtuosoGridFC = function VirtuosoGridFC(_ref2) { | ||
var ScrollContainer = _ref2.ScrollContainer, | ||
className = _ref2.className, | ||
item = _ref2.item, | ||
_ref2$itemClassName = _ref2.itemClassName, | ||
itemClassName = _ref2$itemClassName === void 0 ? 'virtuoso-grid-item' : _ref2$itemClassName, | ||
_ref2$listClassName = _ref2.listClassName, | ||
listClassName = _ref2$listClassName === void 0 ? 'virtuoso-grid-list' : _ref2$listClassName, | ||
engine = _ref2.engine, | ||
_ref2$style = _ref2.style, | ||
style = _ref2$style === void 0 ? { | ||
height: '40rem' | ||
} : _ref2$style; | ||
var itemRange = engine.itemRange, | ||
listOffset = engine.listOffset, | ||
totalHeight = engine.totalHeight, | ||
gridDimensions = engine.gridDimensions, | ||
scrollTo = engine.scrollTo, | ||
scrollTop = engine.scrollTop; | ||
var fillerHeight = useOutput(totalHeight, 0); | ||
var translate = useOutput(listOffset, 0); | ||
var listStyle = { | ||
marginTop: translate + "px" | ||
}; | ||
var itemIndexRange = useOutput(itemRange, [0, 0]); | ||
var viewportCallbackRef = useSize(function (_ref3) { | ||
var element = _ref3.element, | ||
width = _ref3.width, | ||
height = _ref3.height; | ||
var firstItem = element.firstChild.firstChild; | ||
gridDimensions([width, height, firstItem.offsetWidth, firstItem.offsetHeight]); | ||
}); | ||
return React.createElement(VirtuosoScroller, { | ||
style: style, | ||
ScrollContainer: ScrollContainer, | ||
className: className, | ||
scrollTo: scrollTo, | ||
scrollTop: scrollTop | ||
}, React.createElement("div", { | ||
ref: viewportCallbackRef, | ||
style: viewportStyle | ||
}, React.createElement("div", { | ||
style: listStyle, | ||
className: listClassName | ||
}, buildItems(itemIndexRange, item, itemClassName))), React.createElement(VirtuosoFiller, { | ||
height: fillerHeight | ||
})); | ||
}; | ||
export { GroupedVirtuoso, Virtuoso, VirtuosoGrid, VirtuosoPresentation }; | ||
//# sourceMappingURL=react-virtuoso.esm.js.map |
@@ -1,2 +0,2 @@ | ||
import { FC } from 'react'; | ||
import { FC, CSSProperties } from 'react'; | ||
export declare const VirtuosoStyle: FC<{ | ||
@@ -6,1 +6,2 @@ stickyClassName: string; | ||
export declare const randomClassName: () => string; | ||
export declare const viewportStyle: CSSProperties; |
@@ -7,2 +7,8 @@ import { TInput, TOutput } from './rxio'; | ||
export declare function useOutput<T>(output: TOutput<T>, initialValue: T): T; | ||
declare type UseSize = (callback: (params: { | ||
element: HTMLElement; | ||
width: number; | ||
height: number; | ||
}) => void) => CallbackRef; | ||
export declare const useSize: UseSize; | ||
export {}; |
import React, { CSSProperties, PureComponent, ReactElement, FC } from 'react'; | ||
import { VirtuosoStore, TScrollLocation } from './VirtuosoStore'; | ||
import { TScrollLocation } from './EngineCommons'; | ||
import { VirtuosoStore } from './VirtuosoStore'; | ||
import { TScrollContainer, TListContainer, TFooterContainer } from './VirtuosoView'; | ||
@@ -4,0 +5,0 @@ import { TRender, TRenderProps } from './VirtuosoList'; |
@@ -11,3 +11,3 @@ /// <reference types="react" /> | ||
totalCount: (value: number) => void; | ||
scrollToIndex: (value: import("./VirtuosoStore").TScrollLocation) => void; | ||
scrollToIndex: (value: import("./EngineCommons").TScrollLocation) => void; | ||
list: (callback: ((val: import("./GroupIndexTransposer").ListItem[]) => void) | undefined) => void; | ||
@@ -14,0 +14,0 @@ topList: (callback: ((val: import("./GroupIndexTransposer").ListItem[]) => void) | undefined) => void; |
@@ -12,2 +12,4 @@ import { FC, CSSProperties } from 'react'; | ||
ScrollContainer?: TScrollContainer; | ||
scrollTop: (scrollTop: number) => void; | ||
scrollTo: (callback: (scrollTop: number) => void) => void; | ||
}>; |
import { ListItem } from './GroupIndexTransposer'; | ||
import { TScrollLocation } from './EngineCommons'; | ||
export interface ItemHeight { | ||
@@ -13,7 +14,2 @@ start: number; | ||
} | ||
interface TScrollLocationWithAlign { | ||
index: number; | ||
align: 'start' | 'center' | 'end'; | ||
} | ||
export declare type TScrollLocation = number | TScrollLocationWithAlign; | ||
declare const VirtuosoStore: ({ overscan, totalCount, itemHeight }: TVirtuosoConstructorParams) => { | ||
@@ -20,0 +16,0 @@ groupCounts: (value: number[]) => void; |
{ | ||
"name": "react-virtuoso", | ||
"version": "0.7.1", | ||
"version": "0.8.0", | ||
"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 not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
6271020
43
53844
4
3