1. import _extends from '@babel/runtime/helpers/esm/extends';
    
  2. import _inheritsLoose from '@babel/runtime/helpers/esm/inheritsLoose';
    
  3. import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';
    
  4. import memoizeOne from 'memoize-one';
    
  5. import { createElement, PureComponent } from 'react';
    
  6. import { flushSync } from 'react-dom';
    
  7. import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/esm/objectWithoutPropertiesLoose';
    
  8. 
    
  9. // Animation frame based implementation of setTimeout.
    
  10. // Inspired by Joe Lambert, https://gist.github.com/joelambert/1002116#file-requesttimeout-js
    
  11. var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
    
  12. var now = hasNativePerformanceNow ? function () {
    
  13.   return performance.now();
    
  14. } : function () {
    
  15.   return Date.now();
    
  16. };
    
  17. function cancelTimeout(timeoutID) {
    
  18.   cancelAnimationFrame(timeoutID.id);
    
  19. }
    
  20. function requestTimeout(callback, delay) {
    
  21.   var start = now();
    
  22. 
    
  23.   function tick() {
    
  24.     if (now() - start >= delay) {
    
  25.       callback.call(null);
    
  26.     } else {
    
  27.       timeoutID.id = requestAnimationFrame(tick);
    
  28.     }
    
  29.   }
    
  30. 
    
  31.   var timeoutID = {
    
  32.     id: requestAnimationFrame(tick)
    
  33.   };
    
  34.   return timeoutID;
    
  35. }
    
  36. 
    
  37. var size = -1; // This utility copied from "dom-helpers" package.
    
  38. 
    
  39. function getScrollbarSize(recalculate) {
    
  40.   if (recalculate === void 0) {
    
  41.     recalculate = false;
    
  42.   }
    
  43. 
    
  44.   if (size === -1 || recalculate) {
    
  45.     var div = document.createElement('div');
    
  46.     var style = div.style;
    
  47.     style.width = '50px';
    
  48.     style.height = '50px';
    
  49.     style.overflow = 'scroll';
    
  50.     document.body.appendChild(div);
    
  51.     size = div.offsetWidth - div.clientWidth;
    
  52.     document.body.removeChild(div);
    
  53.   }
    
  54. 
    
  55.   return size;
    
  56. }
    
  57. var cachedRTLResult = null; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  58. // Chrome does not seem to adhere; its scrollLeft values are positive (measured relative to the left).
    
  59. // Safari's elastic bounce makes detecting this even more complicated wrt potential false positives.
    
  60. // The safest way to check this is to intentionally set a negative offset,
    
  61. // and then verify that the subsequent "scroll" event matches the negative offset.
    
  62. // If it does not match, then we can assume a non-standard RTL scroll implementation.
    
  63. 
    
  64. function getRTLOffsetType(recalculate) {
    
  65.   if (recalculate === void 0) {
    
  66.     recalculate = false;
    
  67.   }
    
  68. 
    
  69.   if (cachedRTLResult === null || recalculate) {
    
  70.     var outerDiv = document.createElement('div');
    
  71.     var outerStyle = outerDiv.style;
    
  72.     outerStyle.width = '50px';
    
  73.     outerStyle.height = '50px';
    
  74.     outerStyle.overflow = 'scroll';
    
  75.     outerStyle.direction = 'rtl';
    
  76.     var innerDiv = document.createElement('div');
    
  77.     var innerStyle = innerDiv.style;
    
  78.     innerStyle.width = '100px';
    
  79.     innerStyle.height = '100px';
    
  80.     outerDiv.appendChild(innerDiv);
    
  81.     document.body.appendChild(outerDiv);
    
  82. 
    
  83.     if (outerDiv.scrollLeft > 0) {
    
  84.       cachedRTLResult = 'positive-descending';
    
  85.     } else {
    
  86.       outerDiv.scrollLeft = 1;
    
  87. 
    
  88.       if (outerDiv.scrollLeft === 0) {
    
  89.         cachedRTLResult = 'negative';
    
  90.       } else {
    
  91.         cachedRTLResult = 'positive-ascending';
    
  92.       }
    
  93.     }
    
  94. 
    
  95.     document.body.removeChild(outerDiv);
    
  96.     return cachedRTLResult;
    
  97.   }
    
  98. 
    
  99.   return cachedRTLResult;
    
  100. }
    
  101. 
    
  102. var IS_SCROLLING_DEBOUNCE_INTERVAL = 150;
    
  103. 
    
  104. var defaultItemKey = function defaultItemKey(_ref) {
    
  105.   var columnIndex = _ref.columnIndex,
    
  106.       data = _ref.data,
    
  107.       rowIndex = _ref.rowIndex;
    
  108.   return rowIndex + ":" + columnIndex;
    
  109. }; // In DEV mode, this Set helps us only log a warning once per component instance.
    
  110. // This avoids spamming the console every time a render happens.
    
  111. 
    
  112. 
    
  113. var devWarningsOverscanCount = null;
    
  114. var devWarningsOverscanRowsColumnsCount = null;
    
  115. var devWarningsTagName = null;
    
  116. 
    
  117. if (process.env.NODE_ENV !== 'production') {
    
  118.   if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
    
  119.     devWarningsOverscanCount =
    
  120.     /*#__PURE__*/
    
  121.     new WeakSet();
    
  122.     devWarningsOverscanRowsColumnsCount =
    
  123.     /*#__PURE__*/
    
  124.     new WeakSet();
    
  125.     devWarningsTagName =
    
  126.     /*#__PURE__*/
    
  127.     new WeakSet();
    
  128.   }
    
  129. }
    
  130. 
    
  131. function createGridComponent(_ref2) {
    
  132.   var _class, _temp;
    
  133. 
    
  134.   var getColumnOffset = _ref2.getColumnOffset,
    
  135.       getColumnStartIndexForOffset = _ref2.getColumnStartIndexForOffset,
    
  136.       getColumnStopIndexForStartIndex = _ref2.getColumnStopIndexForStartIndex,
    
  137.       getColumnWidth = _ref2.getColumnWidth,
    
  138.       getEstimatedTotalHeight = _ref2.getEstimatedTotalHeight,
    
  139.       getEstimatedTotalWidth = _ref2.getEstimatedTotalWidth,
    
  140.       getOffsetForColumnAndAlignment = _ref2.getOffsetForColumnAndAlignment,
    
  141.       getOffsetForRowAndAlignment = _ref2.getOffsetForRowAndAlignment,
    
  142.       getRowHeight = _ref2.getRowHeight,
    
  143.       getRowOffset = _ref2.getRowOffset,
    
  144.       getRowStartIndexForOffset = _ref2.getRowStartIndexForOffset,
    
  145.       getRowStopIndexForStartIndex = _ref2.getRowStopIndexForStartIndex,
    
  146.       initInstanceProps = _ref2.initInstanceProps,
    
  147.       shouldResetStyleCacheOnItemSizeChange = _ref2.shouldResetStyleCacheOnItemSizeChange,
    
  148.       validateProps = _ref2.validateProps;
    
  149.   return _temp = _class =
    
  150.   /*#__PURE__*/
    
  151.   function (_PureComponent) {
    
  152.     _inheritsLoose(Grid, _PureComponent);
    
  153. 
    
  154.     // Always use explicit constructor for React components.
    
  155.     // It produces less code after transpilation. (#26)
    
  156.     // eslint-disable-next-line no-useless-constructor
    
  157.     function Grid(props) {
    
  158.       var _this;
    
  159. 
    
  160.       _this = _PureComponent.call(this, props) || this;
    
  161.       _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_assertThisInitialized(_this)));
    
  162.       _this._resetIsScrollingTimeoutId = null;
    
  163.       _this._outerRef = void 0;
    
  164.       _this.state = {
    
  165.         instance: _assertThisInitialized(_assertThisInitialized(_this)),
    
  166.         isScrolling: false,
    
  167.         horizontalScrollDirection: 'forward',
    
  168.         scrollLeft: typeof _this.props.initialScrollLeft === 'number' ? _this.props.initialScrollLeft : 0,
    
  169.         scrollTop: typeof _this.props.initialScrollTop === 'number' ? _this.props.initialScrollTop : 0,
    
  170.         scrollUpdateWasRequested: false,
    
  171.         verticalScrollDirection: 'forward'
    
  172.       };
    
  173.       _this._callOnItemsRendered = void 0;
    
  174.       _this._callOnItemsRendered = memoizeOne(function (overscanColumnStartIndex, overscanColumnStopIndex, overscanRowStartIndex, overscanRowStopIndex, visibleColumnStartIndex, visibleColumnStopIndex, visibleRowStartIndex, visibleRowStopIndex) {
    
  175.         return _this.props.onItemsRendered({
    
  176.           overscanColumnStartIndex: overscanColumnStartIndex,
    
  177.           overscanColumnStopIndex: overscanColumnStopIndex,
    
  178.           overscanRowStartIndex: overscanRowStartIndex,
    
  179.           overscanRowStopIndex: overscanRowStopIndex,
    
  180.           visibleColumnStartIndex: visibleColumnStartIndex,
    
  181.           visibleColumnStopIndex: visibleColumnStopIndex,
    
  182.           visibleRowStartIndex: visibleRowStartIndex,
    
  183.           visibleRowStopIndex: visibleRowStopIndex
    
  184.         });
    
  185.       });
    
  186.       _this._callOnScroll = void 0;
    
  187.       _this._callOnScroll = memoizeOne(function (scrollLeft, scrollTop, horizontalScrollDirection, verticalScrollDirection, scrollUpdateWasRequested) {
    
  188.         return _this.props.onScroll({
    
  189.           horizontalScrollDirection: horizontalScrollDirection,
    
  190.           scrollLeft: scrollLeft,
    
  191.           scrollTop: scrollTop,
    
  192.           verticalScrollDirection: verticalScrollDirection,
    
  193.           scrollUpdateWasRequested: scrollUpdateWasRequested
    
  194.         });
    
  195.       });
    
  196.       _this._getItemStyle = void 0;
    
  197. 
    
  198.       _this._getItemStyle = function (rowIndex, columnIndex) {
    
  199.         var _this$props = _this.props,
    
  200.             columnWidth = _this$props.columnWidth,
    
  201.             direction = _this$props.direction,
    
  202.             rowHeight = _this$props.rowHeight;
    
  203. 
    
  204.         var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && columnWidth, shouldResetStyleCacheOnItemSizeChange && direction, shouldResetStyleCacheOnItemSizeChange && rowHeight);
    
  205. 
    
  206.         var key = rowIndex + ":" + columnIndex;
    
  207.         var style;
    
  208. 
    
  209.         if (itemStyleCache.hasOwnProperty(key)) {
    
  210.           style = itemStyleCache[key];
    
  211.         } else {
    
  212.           var _style;
    
  213. 
    
  214.           itemStyleCache[key] = style = (_style = {
    
  215.             position: 'absolute'
    
  216.           }, _style[direction === 'rtl' ? 'right' : 'left'] = getColumnOffset(_this.props, columnIndex, _this._instanceProps), _style.top = getRowOffset(_this.props, rowIndex, _this._instanceProps), _style.height = getRowHeight(_this.props, rowIndex, _this._instanceProps), _style.width = getColumnWidth(_this.props, columnIndex, _this._instanceProps), _style);
    
  217.         }
    
  218. 
    
  219.         return style;
    
  220.       };
    
  221. 
    
  222.       _this._getItemStyleCache = void 0;
    
  223.       _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
    
  224.         return {};
    
  225.       });
    
  226. 
    
  227.       _this._onScroll = function (event) {
    
  228.         var _event$currentTarget = event.currentTarget,
    
  229.             clientHeight = _event$currentTarget.clientHeight,
    
  230.             clientWidth = _event$currentTarget.clientWidth,
    
  231.             scrollLeft = _event$currentTarget.scrollLeft,
    
  232.             scrollTop = _event$currentTarget.scrollTop,
    
  233.             scrollHeight = _event$currentTarget.scrollHeight,
    
  234.             scrollWidth = _event$currentTarget.scrollWidth;
    
  235. 
    
  236.         // Force flush sync for scroll updates to reduce visual checkerboarding.
    
  237.         flushSync(() => {
    
  238.           _this.setState(function (prevState) {
    
  239.             if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
    
  240.               // Scroll position may have been updated by cDM/cDU,
    
  241.               // In which case we don't need to trigger another render,
    
  242.               // And we don't want to update state.isScrolling.
    
  243.               return null;
    
  244.             }
    
  245. 
    
  246.             var direction = _this.props.direction; // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  247.             // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  248.             // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
    
  249.             // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
    
  250. 
    
  251.             var calculatedScrollLeft = scrollLeft;
    
  252. 
    
  253.             if (direction === 'rtl') {
    
  254.               switch (getRTLOffsetType()) {
    
  255.                 case 'negative':
    
  256.                   calculatedScrollLeft = -scrollLeft;
    
  257.                   break;
    
  258. 
    
  259.                 case 'positive-descending':
    
  260.                   calculatedScrollLeft = scrollWidth - clientWidth - scrollLeft;
    
  261.                   break;
    
  262.               }
    
  263.             } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  264. 
    
  265. 
    
  266.             calculatedScrollLeft = Math.max(0, Math.min(calculatedScrollLeft, scrollWidth - clientWidth));
    
  267.             var calculatedScrollTop = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
    
  268.             return {
    
  269.               isScrolling: true,
    
  270.               horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
    
  271.               scrollLeft: calculatedScrollLeft,
    
  272.               scrollTop: calculatedScrollTop,
    
  273.               verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward',
    
  274.               scrollUpdateWasRequested: false
    
  275.             };
    
  276.           }, _this._resetIsScrollingDebounced);
    
  277.         });
    
  278.       };
    
  279. 
    
  280.       _this._outerRefSetter = function (ref) {
    
  281.         var outerRef = _this.props.outerRef;
    
  282.         _this._outerRef = ref;
    
  283. 
    
  284.         if (typeof outerRef === 'function') {
    
  285.           outerRef(ref);
    
  286.         } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
    
  287.           outerRef.current = ref;
    
  288.         }
    
  289.       };
    
  290. 
    
  291.       _this._resetIsScrollingDebounced = function () {
    
  292.         if (_this._resetIsScrollingTimeoutId !== null) {
    
  293.           cancelTimeout(_this._resetIsScrollingTimeoutId);
    
  294.         }
    
  295. 
    
  296.         _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL);
    
  297.       };
    
  298. 
    
  299.       _this._resetIsScrolling = function () {
    
  300.         _this._resetIsScrollingTimeoutId = null;
    
  301. 
    
  302.         _this.setState({
    
  303.           isScrolling: false
    
  304.         }, function () {
    
  305.           // Clear style cache after state update has been committed.
    
  306.           // This way we don't break pure sCU for items that don't use isScrolling param.
    
  307.           _this._getItemStyleCache(-1);
    
  308.         });
    
  309.       };
    
  310. 
    
  311.       return _this;
    
  312.     }
    
  313. 
    
  314.     Grid.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
    
  315.       validateSharedProps(nextProps, prevState);
    
  316.       validateProps(nextProps);
    
  317.       return null;
    
  318.     };
    
  319. 
    
  320.     var _proto = Grid.prototype;
    
  321. 
    
  322.     _proto.scrollTo = function scrollTo(_ref3) {
    
  323.       var scrollLeft = _ref3.scrollLeft,
    
  324.           scrollTop = _ref3.scrollTop;
    
  325. 
    
  326.       if (scrollLeft !== undefined) {
    
  327.         scrollLeft = Math.max(0, scrollLeft);
    
  328.       }
    
  329. 
    
  330.       if (scrollTop !== undefined) {
    
  331.         scrollTop = Math.max(0, scrollTop);
    
  332.       }
    
  333. 
    
  334.       this.setState(function (prevState) {
    
  335.         if (scrollLeft === undefined) {
    
  336.           scrollLeft = prevState.scrollLeft;
    
  337.         }
    
  338. 
    
  339.         if (scrollTop === undefined) {
    
  340.           scrollTop = prevState.scrollTop;
    
  341.         }
    
  342. 
    
  343.         if (prevState.scrollLeft === scrollLeft && prevState.scrollTop === scrollTop) {
    
  344.           return null;
    
  345.         }
    
  346. 
    
  347.         return {
    
  348.           horizontalScrollDirection: prevState.scrollLeft < scrollLeft ? 'forward' : 'backward',
    
  349.           scrollLeft: scrollLeft,
    
  350.           scrollTop: scrollTop,
    
  351.           scrollUpdateWasRequested: true,
    
  352.           verticalScrollDirection: prevState.scrollTop < scrollTop ? 'forward' : 'backward'
    
  353.         };
    
  354.       }, this._resetIsScrollingDebounced);
    
  355.     };
    
  356. 
    
  357.     _proto.scrollToItem = function scrollToItem(_ref4) {
    
  358.       var _ref4$align = _ref4.align,
    
  359.           align = _ref4$align === void 0 ? 'auto' : _ref4$align,
    
  360.           columnIndex = _ref4.columnIndex,
    
  361.           rowIndex = _ref4.rowIndex;
    
  362.       var _this$props2 = this.props,
    
  363.           columnCount = _this$props2.columnCount,
    
  364.           height = _this$props2.height,
    
  365.           rowCount = _this$props2.rowCount,
    
  366.           width = _this$props2.width;
    
  367.       var _this$state = this.state,
    
  368.           scrollLeft = _this$state.scrollLeft,
    
  369.           scrollTop = _this$state.scrollTop;
    
  370.       var scrollbarSize = getScrollbarSize();
    
  371. 
    
  372.       if (columnIndex !== undefined) {
    
  373.         columnIndex = Math.max(0, Math.min(columnIndex, columnCount - 1));
    
  374.       }
    
  375. 
    
  376.       if (rowIndex !== undefined) {
    
  377.         rowIndex = Math.max(0, Math.min(rowIndex, rowCount - 1));
    
  378.       }
    
  379. 
    
  380.       var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
    
  381.       var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps); // The scrollbar size should be considered when scrolling an item into view,
    
  382.       // to ensure it's fully visible.
    
  383.       // But we only need to account for its size when it's actually visible.
    
  384. 
    
  385.       var horizontalScrollbarSize = estimatedTotalWidth > width ? scrollbarSize : 0;
    
  386.       var verticalScrollbarSize = estimatedTotalHeight > height ? scrollbarSize : 0;
    
  387.       this.scrollTo({
    
  388.         scrollLeft: columnIndex !== undefined ? getOffsetForColumnAndAlignment(this.props, columnIndex, align, scrollLeft, this._instanceProps, verticalScrollbarSize) : scrollLeft,
    
  389.         scrollTop: rowIndex !== undefined ? getOffsetForRowAndAlignment(this.props, rowIndex, align, scrollTop, this._instanceProps, horizontalScrollbarSize) : scrollTop
    
  390.       });
    
  391.     };
    
  392. 
    
  393.     _proto.componentDidMount = function componentDidMount() {
    
  394.       var _this$props3 = this.props,
    
  395.           initialScrollLeft = _this$props3.initialScrollLeft,
    
  396.           initialScrollTop = _this$props3.initialScrollTop;
    
  397. 
    
  398.       if (this._outerRef != null) {
    
  399.         var outerRef = this._outerRef;
    
  400. 
    
  401.         if (typeof initialScrollLeft === 'number') {
    
  402.           outerRef.scrollLeft = initialScrollLeft;
    
  403.         }
    
  404. 
    
  405.         if (typeof initialScrollTop === 'number') {
    
  406.           outerRef.scrollTop = initialScrollTop;
    
  407.         }
    
  408.       }
    
  409. 
    
  410.       this._callPropsCallbacks();
    
  411.     };
    
  412. 
    
  413.     _proto.componentDidUpdate = function componentDidUpdate() {
    
  414.       var direction = this.props.direction;
    
  415.       var _this$state2 = this.state,
    
  416.           scrollLeft = _this$state2.scrollLeft,
    
  417.           scrollTop = _this$state2.scrollTop,
    
  418.           scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
    
  419. 
    
  420.       if (scrollUpdateWasRequested && this._outerRef != null) {
    
  421.         // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  422.         // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  423.         // So we need to determine which browser behavior we're dealing with, and mimic it.
    
  424.         var outerRef = this._outerRef;
    
  425. 
    
  426.         if (direction === 'rtl') {
    
  427.           switch (getRTLOffsetType()) {
    
  428.             case 'negative':
    
  429.               outerRef.scrollLeft = -scrollLeft;
    
  430.               break;
    
  431. 
    
  432.             case 'positive-ascending':
    
  433.               outerRef.scrollLeft = scrollLeft;
    
  434.               break;
    
  435. 
    
  436.             default:
    
  437.               var clientWidth = outerRef.clientWidth,
    
  438.                   scrollWidth = outerRef.scrollWidth;
    
  439.               outerRef.scrollLeft = scrollWidth - clientWidth - scrollLeft;
    
  440.               break;
    
  441.           }
    
  442.         } else {
    
  443.           outerRef.scrollLeft = Math.max(0, scrollLeft);
    
  444.         }
    
  445. 
    
  446.         outerRef.scrollTop = Math.max(0, scrollTop);
    
  447.       }
    
  448. 
    
  449.       this._callPropsCallbacks();
    
  450.     };
    
  451. 
    
  452.     _proto.componentWillUnmount = function componentWillUnmount() {
    
  453.       if (this._resetIsScrollingTimeoutId !== null) {
    
  454.         cancelTimeout(this._resetIsScrollingTimeoutId);
    
  455.       }
    
  456.     };
    
  457. 
    
  458.     _proto.render = function render() {
    
  459.       var _this$props4 = this.props,
    
  460.           children = _this$props4.children,
    
  461.           className = _this$props4.className,
    
  462.           columnCount = _this$props4.columnCount,
    
  463.           direction = _this$props4.direction,
    
  464.           height = _this$props4.height,
    
  465.           innerRef = _this$props4.innerRef,
    
  466.           innerElementType = _this$props4.innerElementType,
    
  467.           innerTagName = _this$props4.innerTagName,
    
  468.           itemData = _this$props4.itemData,
    
  469.           _this$props4$itemKey = _this$props4.itemKey,
    
  470.           itemKey = _this$props4$itemKey === void 0 ? defaultItemKey : _this$props4$itemKey,
    
  471.           outerElementType = _this$props4.outerElementType,
    
  472.           outerTagName = _this$props4.outerTagName,
    
  473.           rowCount = _this$props4.rowCount,
    
  474.           style = _this$props4.style,
    
  475.           useIsScrolling = _this$props4.useIsScrolling,
    
  476.           width = _this$props4.width;
    
  477.       var isScrolling = this.state.isScrolling;
    
  478. 
    
  479.       var _this$_getHorizontalR = this._getHorizontalRangeToRender(),
    
  480.           columnStartIndex = _this$_getHorizontalR[0],
    
  481.           columnStopIndex = _this$_getHorizontalR[1];
    
  482. 
    
  483.       var _this$_getVerticalRan = this._getVerticalRangeToRender(),
    
  484.           rowStartIndex = _this$_getVerticalRan[0],
    
  485.           rowStopIndex = _this$_getVerticalRan[1];
    
  486. 
    
  487.       var items = [];
    
  488. 
    
  489.       if (columnCount > 0 && rowCount) {
    
  490.         for (var _rowIndex = rowStartIndex; _rowIndex <= rowStopIndex; _rowIndex++) {
    
  491.           for (var _columnIndex = columnStartIndex; _columnIndex <= columnStopIndex; _columnIndex++) {
    
  492.             items.push(createElement(children, {
    
  493.               columnIndex: _columnIndex,
    
  494.               data: itemData,
    
  495.               isScrolling: useIsScrolling ? isScrolling : undefined,
    
  496.               key: itemKey({
    
  497.                 columnIndex: _columnIndex,
    
  498.                 data: itemData,
    
  499.                 rowIndex: _rowIndex
    
  500.               }),
    
  501.               rowIndex: _rowIndex,
    
  502.               style: this._getItemStyle(_rowIndex, _columnIndex)
    
  503.             }));
    
  504.           }
    
  505.         }
    
  506.       } // Read this value AFTER items have been created,
    
  507.       // So their actual sizes (if variable) are taken into consideration.
    
  508. 
    
  509. 
    
  510.       var estimatedTotalHeight = getEstimatedTotalHeight(this.props, this._instanceProps);
    
  511.       var estimatedTotalWidth = getEstimatedTotalWidth(this.props, this._instanceProps);
    
  512.       return createElement(outerElementType || outerTagName || 'div', {
    
  513.         className: className,
    
  514.         onScroll: this._onScroll,
    
  515.         ref: this._outerRefSetter,
    
  516.         style: _extends({
    
  517.           position: 'relative',
    
  518.           height: height,
    
  519.           width: width,
    
  520.           overflow: 'auto',
    
  521.           WebkitOverflowScrolling: 'touch',
    
  522.           willChange: 'transform',
    
  523.           direction: direction
    
  524.         }, style)
    
  525.       }, createElement(innerElementType || innerTagName || 'div', {
    
  526.         children: items,
    
  527.         ref: innerRef,
    
  528.         style: {
    
  529.           height: estimatedTotalHeight,
    
  530.           pointerEvents: isScrolling ? 'none' : undefined,
    
  531.           width: estimatedTotalWidth
    
  532.         }
    
  533.       }));
    
  534.     };
    
  535. 
    
  536.     _proto._callPropsCallbacks = function _callPropsCallbacks() {
    
  537.       var _this$props5 = this.props,
    
  538.           columnCount = _this$props5.columnCount,
    
  539.           onItemsRendered = _this$props5.onItemsRendered,
    
  540.           onScroll = _this$props5.onScroll,
    
  541.           rowCount = _this$props5.rowCount;
    
  542. 
    
  543.       if (typeof onItemsRendered === 'function') {
    
  544.         if (columnCount > 0 && rowCount > 0) {
    
  545.           var _this$_getHorizontalR2 = this._getHorizontalRangeToRender(),
    
  546.               _overscanColumnStartIndex = _this$_getHorizontalR2[0],
    
  547.               _overscanColumnStopIndex = _this$_getHorizontalR2[1],
    
  548.               _visibleColumnStartIndex = _this$_getHorizontalR2[2],
    
  549.               _visibleColumnStopIndex = _this$_getHorizontalR2[3];
    
  550. 
    
  551.           var _this$_getVerticalRan2 = this._getVerticalRangeToRender(),
    
  552.               _overscanRowStartIndex = _this$_getVerticalRan2[0],
    
  553.               _overscanRowStopIndex = _this$_getVerticalRan2[1],
    
  554.               _visibleRowStartIndex = _this$_getVerticalRan2[2],
    
  555.               _visibleRowStopIndex = _this$_getVerticalRan2[3];
    
  556. 
    
  557.           this._callOnItemsRendered(_overscanColumnStartIndex, _overscanColumnStopIndex, _overscanRowStartIndex, _overscanRowStopIndex, _visibleColumnStartIndex, _visibleColumnStopIndex, _visibleRowStartIndex, _visibleRowStopIndex);
    
  558.         }
    
  559.       }
    
  560. 
    
  561.       if (typeof onScroll === 'function') {
    
  562.         var _this$state3 = this.state,
    
  563.             _horizontalScrollDirection = _this$state3.horizontalScrollDirection,
    
  564.             _scrollLeft = _this$state3.scrollLeft,
    
  565.             _scrollTop = _this$state3.scrollTop,
    
  566.             _scrollUpdateWasRequested = _this$state3.scrollUpdateWasRequested,
    
  567.             _verticalScrollDirection = _this$state3.verticalScrollDirection;
    
  568. 
    
  569.         this._callOnScroll(_scrollLeft, _scrollTop, _horizontalScrollDirection, _verticalScrollDirection, _scrollUpdateWasRequested);
    
  570.       }
    
  571.     }; // Lazily create and cache item styles while scrolling,
    
  572.     // So that pure component sCU will prevent re-renders.
    
  573.     // We maintain this cache, and pass a style prop rather than index,
    
  574.     // So that List can clear cached styles and force item re-render if necessary.
    
  575. 
    
  576. 
    
  577.     _proto._getHorizontalRangeToRender = function _getHorizontalRangeToRender() {
    
  578.       var _this$props6 = this.props,
    
  579.           columnCount = _this$props6.columnCount,
    
  580.           overscanColumnCount = _this$props6.overscanColumnCount,
    
  581.           overscanColumnsCount = _this$props6.overscanColumnsCount,
    
  582.           overscanCount = _this$props6.overscanCount,
    
  583.           rowCount = _this$props6.rowCount;
    
  584.       var _this$state4 = this.state,
    
  585.           horizontalScrollDirection = _this$state4.horizontalScrollDirection,
    
  586.           isScrolling = _this$state4.isScrolling,
    
  587.           scrollLeft = _this$state4.scrollLeft;
    
  588.       var overscanCountResolved = overscanColumnCount || overscanColumnsCount || overscanCount || 1;
    
  589. 
    
  590.       if (columnCount === 0 || rowCount === 0) {
    
  591.         return [0, 0, 0, 0];
    
  592.       }
    
  593. 
    
  594.       var startIndex = getColumnStartIndexForOffset(this.props, scrollLeft, this._instanceProps);
    
  595.       var stopIndex = getColumnStopIndexForStartIndex(this.props, startIndex, scrollLeft, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  596.       // If there isn't at least one extra item, tab loops back around.
    
  597. 
    
  598.       var overscanBackward = !isScrolling || horizontalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
    
  599.       var overscanForward = !isScrolling || horizontalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
    
  600.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(columnCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  601.     };
    
  602. 
    
  603.     _proto._getVerticalRangeToRender = function _getVerticalRangeToRender() {
    
  604.       var _this$props7 = this.props,
    
  605.           columnCount = _this$props7.columnCount,
    
  606.           overscanCount = _this$props7.overscanCount,
    
  607.           overscanRowCount = _this$props7.overscanRowCount,
    
  608.           overscanRowsCount = _this$props7.overscanRowsCount,
    
  609.           rowCount = _this$props7.rowCount;
    
  610.       var _this$state5 = this.state,
    
  611.           isScrolling = _this$state5.isScrolling,
    
  612.           verticalScrollDirection = _this$state5.verticalScrollDirection,
    
  613.           scrollTop = _this$state5.scrollTop;
    
  614.       var overscanCountResolved = overscanRowCount || overscanRowsCount || overscanCount || 1;
    
  615. 
    
  616.       if (columnCount === 0 || rowCount === 0) {
    
  617.         return [0, 0, 0, 0];
    
  618.       }
    
  619. 
    
  620.       var startIndex = getRowStartIndexForOffset(this.props, scrollTop, this._instanceProps);
    
  621.       var stopIndex = getRowStopIndexForStartIndex(this.props, startIndex, scrollTop, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  622.       // If there isn't at least one extra item, tab loops back around.
    
  623. 
    
  624.       var overscanBackward = !isScrolling || verticalScrollDirection === 'backward' ? Math.max(1, overscanCountResolved) : 1;
    
  625.       var overscanForward = !isScrolling || verticalScrollDirection === 'forward' ? Math.max(1, overscanCountResolved) : 1;
    
  626.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(rowCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  627.     };
    
  628. 
    
  629.     return Grid;
    
  630.   }(PureComponent), _class.defaultProps = {
    
  631.     direction: 'ltr',
    
  632.     itemData: undefined,
    
  633.     useIsScrolling: false
    
  634.   }, _temp;
    
  635. }
    
  636. 
    
  637. var validateSharedProps = function validateSharedProps(_ref5, _ref6) {
    
  638.   var children = _ref5.children,
    
  639.       direction = _ref5.direction,
    
  640.       height = _ref5.height,
    
  641.       innerTagName = _ref5.innerTagName,
    
  642.       outerTagName = _ref5.outerTagName,
    
  643.       overscanColumnsCount = _ref5.overscanColumnsCount,
    
  644.       overscanCount = _ref5.overscanCount,
    
  645.       overscanRowsCount = _ref5.overscanRowsCount,
    
  646.       width = _ref5.width;
    
  647.   var instance = _ref6.instance;
    
  648. 
    
  649.   if (process.env.NODE_ENV !== 'production') {
    
  650.     if (typeof overscanCount === 'number') {
    
  651.       if (devWarningsOverscanCount && !devWarningsOverscanCount.has(instance)) {
    
  652.         devWarningsOverscanCount.add(instance);
    
  653.         console.warn('The overscanCount prop has been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
    
  654.       }
    
  655.     }
    
  656. 
    
  657.     if (typeof overscanColumnsCount === 'number' || typeof overscanRowsCount === 'number') {
    
  658.       if (devWarningsOverscanRowsColumnsCount && !devWarningsOverscanRowsColumnsCount.has(instance)) {
    
  659.         devWarningsOverscanRowsColumnsCount.add(instance);
    
  660.         console.warn('The overscanColumnsCount and overscanRowsCount props have been deprecated. ' + 'Please use the overscanColumnCount and overscanRowCount props instead.');
    
  661.       }
    
  662.     }
    
  663. 
    
  664.     if (innerTagName != null || outerTagName != null) {
    
  665.       if (devWarningsTagName && !devWarningsTagName.has(instance)) {
    
  666.         devWarningsTagName.add(instance);
    
  667.         console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
    
  668.       }
    
  669.     }
    
  670. 
    
  671.     if (children == null) {
    
  672.       throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
    
  673.     }
    
  674. 
    
  675.     switch (direction) {
    
  676.       case 'ltr':
    
  677.       case 'rtl':
    
  678.         // Valid values
    
  679.         break;
    
  680. 
    
  681.       default:
    
  682.         throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
    
  683.     }
    
  684. 
    
  685.     if (typeof width !== 'number') {
    
  686.       throw Error('An invalid "width" prop has been specified. ' + 'Grids must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
    
  687.     }
    
  688. 
    
  689.     if (typeof height !== 'number') {
    
  690.       throw Error('An invalid "height" prop has been specified. ' + 'Grids must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
    
  691.     }
    
  692.   }
    
  693. };
    
  694. 
    
  695. var DEFAULT_ESTIMATED_ITEM_SIZE = 50;
    
  696. 
    
  697. var getEstimatedTotalHeight = function getEstimatedTotalHeight(_ref, _ref2) {
    
  698.   var rowCount = _ref.rowCount;
    
  699.   var rowMetadataMap = _ref2.rowMetadataMap,
    
  700.       estimatedRowHeight = _ref2.estimatedRowHeight,
    
  701.       lastMeasuredRowIndex = _ref2.lastMeasuredRowIndex;
    
  702.   var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  703.   // https://github.com/bvaughn/react-window/pull/138
    
  704. 
    
  705.   if (lastMeasuredRowIndex >= rowCount) {
    
  706.     lastMeasuredRowIndex = rowCount - 1;
    
  707.   }
    
  708. 
    
  709.   if (lastMeasuredRowIndex >= 0) {
    
  710.     var itemMetadata = rowMetadataMap[lastMeasuredRowIndex];
    
  711.     totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
    
  712.   }
    
  713. 
    
  714.   var numUnmeasuredItems = rowCount - lastMeasuredRowIndex - 1;
    
  715.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedRowHeight;
    
  716.   return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
    
  717. };
    
  718. 
    
  719. var getEstimatedTotalWidth = function getEstimatedTotalWidth(_ref3, _ref4) {
    
  720.   var columnCount = _ref3.columnCount;
    
  721.   var columnMetadataMap = _ref4.columnMetadataMap,
    
  722.       estimatedColumnWidth = _ref4.estimatedColumnWidth,
    
  723.       lastMeasuredColumnIndex = _ref4.lastMeasuredColumnIndex;
    
  724.   var totalSizeOfMeasuredRows = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  725.   // https://github.com/bvaughn/react-window/pull/138
    
  726. 
    
  727.   if (lastMeasuredColumnIndex >= columnCount) {
    
  728.     lastMeasuredColumnIndex = columnCount - 1;
    
  729.   }
    
  730. 
    
  731.   if (lastMeasuredColumnIndex >= 0) {
    
  732.     var itemMetadata = columnMetadataMap[lastMeasuredColumnIndex];
    
  733.     totalSizeOfMeasuredRows = itemMetadata.offset + itemMetadata.size;
    
  734.   }
    
  735. 
    
  736.   var numUnmeasuredItems = columnCount - lastMeasuredColumnIndex - 1;
    
  737.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedColumnWidth;
    
  738.   return totalSizeOfMeasuredRows + totalSizeOfUnmeasuredItems;
    
  739. };
    
  740. 
    
  741. var getItemMetadata = function getItemMetadata(itemType, props, index, instanceProps) {
    
  742.   var itemMetadataMap, itemSize, lastMeasuredIndex;
    
  743. 
    
  744.   if (itemType === 'column') {
    
  745.     itemMetadataMap = instanceProps.columnMetadataMap;
    
  746.     itemSize = props.columnWidth;
    
  747.     lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
    
  748.   } else {
    
  749.     itemMetadataMap = instanceProps.rowMetadataMap;
    
  750.     itemSize = props.rowHeight;
    
  751.     lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
    
  752.   }
    
  753. 
    
  754.   if (index > lastMeasuredIndex) {
    
  755.     var offset = 0;
    
  756. 
    
  757.     if (lastMeasuredIndex >= 0) {
    
  758.       var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  759.       offset = itemMetadata.offset + itemMetadata.size;
    
  760.     }
    
  761. 
    
  762.     for (var i = lastMeasuredIndex + 1; i <= index; i++) {
    
  763.       var size = itemSize(i);
    
  764.       itemMetadataMap[i] = {
    
  765.         offset: offset,
    
  766.         size: size
    
  767.       };
    
  768.       offset += size;
    
  769.     }
    
  770. 
    
  771.     if (itemType === 'column') {
    
  772.       instanceProps.lastMeasuredColumnIndex = index;
    
  773.     } else {
    
  774.       instanceProps.lastMeasuredRowIndex = index;
    
  775.     }
    
  776.   }
    
  777. 
    
  778.   return itemMetadataMap[index];
    
  779. };
    
  780. 
    
  781. var findNearestItem = function findNearestItem(itemType, props, instanceProps, offset) {
    
  782.   var itemMetadataMap, lastMeasuredIndex;
    
  783. 
    
  784.   if (itemType === 'column') {
    
  785.     itemMetadataMap = instanceProps.columnMetadataMap;
    
  786.     lastMeasuredIndex = instanceProps.lastMeasuredColumnIndex;
    
  787.   } else {
    
  788.     itemMetadataMap = instanceProps.rowMetadataMap;
    
  789.     lastMeasuredIndex = instanceProps.lastMeasuredRowIndex;
    
  790.   }
    
  791. 
    
  792.   var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
    
  793. 
    
  794.   if (lastMeasuredItemOffset >= offset) {
    
  795.     // If we've already measured items within this range just use a binary search as it's faster.
    
  796.     return findNearestItemBinarySearch(itemType, props, instanceProps, lastMeasuredIndex, 0, offset);
    
  797.   } else {
    
  798.     // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
    
  799.     // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
    
  800.     // The overall complexity for this approach is O(log n).
    
  801.     return findNearestItemExponentialSearch(itemType, props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
    
  802.   }
    
  803. };
    
  804. 
    
  805. var findNearestItemBinarySearch = function findNearestItemBinarySearch(itemType, props, instanceProps, high, low, offset) {
    
  806.   while (low <= high) {
    
  807.     var middle = low + Math.floor((high - low) / 2);
    
  808.     var currentOffset = getItemMetadata(itemType, props, middle, instanceProps).offset;
    
  809. 
    
  810.     if (currentOffset === offset) {
    
  811.       return middle;
    
  812.     } else if (currentOffset < offset) {
    
  813.       low = middle + 1;
    
  814.     } else if (currentOffset > offset) {
    
  815.       high = middle - 1;
    
  816.     }
    
  817.   }
    
  818. 
    
  819.   if (low > 0) {
    
  820.     return low - 1;
    
  821.   } else {
    
  822.     return 0;
    
  823.   }
    
  824. };
    
  825. 
    
  826. var findNearestItemExponentialSearch = function findNearestItemExponentialSearch(itemType, props, instanceProps, index, offset) {
    
  827.   var itemCount = itemType === 'column' ? props.columnCount : props.rowCount;
    
  828.   var interval = 1;
    
  829. 
    
  830.   while (index < itemCount && getItemMetadata(itemType, props, index, instanceProps).offset < offset) {
    
  831.     index += interval;
    
  832.     interval *= 2;
    
  833.   }
    
  834. 
    
  835.   return findNearestItemBinarySearch(itemType, props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
    
  836. };
    
  837. 
    
  838. var getOffsetForIndexAndAlignment = function getOffsetForIndexAndAlignment(itemType, props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  839.   var size = itemType === 'column' ? props.width : props.height;
    
  840.   var itemMetadata = getItemMetadata(itemType, props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
    
  841.   // To ensure it reflects actual measurements instead of just estimates.
    
  842. 
    
  843.   var estimatedTotalSize = itemType === 'column' ? getEstimatedTotalWidth(props, instanceProps) : getEstimatedTotalHeight(props, instanceProps);
    
  844.   var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
    
  845.   var minOffset = Math.max(0, itemMetadata.offset - size + scrollbarSize + itemMetadata.size);
    
  846. 
    
  847.   if (align === 'smart') {
    
  848.     if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  849.       align = 'auto';
    
  850.     } else {
    
  851.       align = 'center';
    
  852.     }
    
  853.   }
    
  854. 
    
  855.   switch (align) {
    
  856.     case 'start':
    
  857.       return maxOffset;
    
  858. 
    
  859.     case 'end':
    
  860.       return minOffset;
    
  861. 
    
  862.     case 'center':
    
  863.       return Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  864. 
    
  865.     case 'auto':
    
  866.     default:
    
  867.       if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  868.         return scrollOffset;
    
  869.       } else if (minOffset > maxOffset) {
    
  870.         // Because we only take into account the scrollbar size when calculating minOffset
    
  871.         // this value can be larger than maxOffset when at the end of the list
    
  872.         return minOffset;
    
  873.       } else if (scrollOffset < minOffset) {
    
  874.         return minOffset;
    
  875.       } else {
    
  876.         return maxOffset;
    
  877.       }
    
  878. 
    
  879.   }
    
  880. };
    
  881. 
    
  882. var VariableSizeGrid =
    
  883. /*#__PURE__*/
    
  884. createGridComponent({
    
  885.   getColumnOffset: function getColumnOffset(props, index, instanceProps) {
    
  886.     return getItemMetadata('column', props, index, instanceProps).offset;
    
  887.   },
    
  888.   getColumnStartIndexForOffset: function getColumnStartIndexForOffset(props, scrollLeft, instanceProps) {
    
  889.     return findNearestItem('column', props, instanceProps, scrollLeft);
    
  890.   },
    
  891.   getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(props, startIndex, scrollLeft, instanceProps) {
    
  892.     var columnCount = props.columnCount,
    
  893.         width = props.width;
    
  894.     var itemMetadata = getItemMetadata('column', props, startIndex, instanceProps);
    
  895.     var maxOffset = scrollLeft + width;
    
  896.     var offset = itemMetadata.offset + itemMetadata.size;
    
  897.     var stopIndex = startIndex;
    
  898. 
    
  899.     while (stopIndex < columnCount - 1 && offset < maxOffset) {
    
  900.       stopIndex++;
    
  901.       offset += getItemMetadata('column', props, stopIndex, instanceProps).size;
    
  902.     }
    
  903. 
    
  904.     return stopIndex;
    
  905.   },
    
  906.   getColumnWidth: function getColumnWidth(props, index, instanceProps) {
    
  907.     return instanceProps.columnMetadataMap[index].size;
    
  908.   },
    
  909.   getEstimatedTotalHeight: getEstimatedTotalHeight,
    
  910.   getEstimatedTotalWidth: getEstimatedTotalWidth,
    
  911.   getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  912.     return getOffsetForIndexAndAlignment('column', props, index, align, scrollOffset, instanceProps, scrollbarSize);
    
  913.   },
    
  914.   getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(props, index, align, scrollOffset, instanceProps, scrollbarSize) {
    
  915.     return getOffsetForIndexAndAlignment('row', props, index, align, scrollOffset, instanceProps, scrollbarSize);
    
  916.   },
    
  917.   getRowOffset: function getRowOffset(props, index, instanceProps) {
    
  918.     return getItemMetadata('row', props, index, instanceProps).offset;
    
  919.   },
    
  920.   getRowHeight: function getRowHeight(props, index, instanceProps) {
    
  921.     return instanceProps.rowMetadataMap[index].size;
    
  922.   },
    
  923.   getRowStartIndexForOffset: function getRowStartIndexForOffset(props, scrollTop, instanceProps) {
    
  924.     return findNearestItem('row', props, instanceProps, scrollTop);
    
  925.   },
    
  926.   getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(props, startIndex, scrollTop, instanceProps) {
    
  927.     var rowCount = props.rowCount,
    
  928.         height = props.height;
    
  929.     var itemMetadata = getItemMetadata('row', props, startIndex, instanceProps);
    
  930.     var maxOffset = scrollTop + height;
    
  931.     var offset = itemMetadata.offset + itemMetadata.size;
    
  932.     var stopIndex = startIndex;
    
  933. 
    
  934.     while (stopIndex < rowCount - 1 && offset < maxOffset) {
    
  935.       stopIndex++;
    
  936.       offset += getItemMetadata('row', props, stopIndex, instanceProps).size;
    
  937.     }
    
  938. 
    
  939.     return stopIndex;
    
  940.   },
    
  941.   initInstanceProps: function initInstanceProps(props, instance) {
    
  942.     var _ref5 = props,
    
  943.         estimatedColumnWidth = _ref5.estimatedColumnWidth,
    
  944.         estimatedRowHeight = _ref5.estimatedRowHeight;
    
  945.     var instanceProps = {
    
  946.       columnMetadataMap: {},
    
  947.       estimatedColumnWidth: estimatedColumnWidth || DEFAULT_ESTIMATED_ITEM_SIZE,
    
  948.       estimatedRowHeight: estimatedRowHeight || DEFAULT_ESTIMATED_ITEM_SIZE,
    
  949.       lastMeasuredColumnIndex: -1,
    
  950.       lastMeasuredRowIndex: -1,
    
  951.       rowMetadataMap: {}
    
  952.     };
    
  953. 
    
  954.     instance.resetAfterColumnIndex = function (columnIndex, shouldForceUpdate) {
    
  955.       if (shouldForceUpdate === void 0) {
    
  956.         shouldForceUpdate = true;
    
  957.       }
    
  958. 
    
  959.       instance.resetAfterIndices({
    
  960.         columnIndex: columnIndex,
    
  961.         shouldForceUpdate: shouldForceUpdate
    
  962.       });
    
  963.     };
    
  964. 
    
  965.     instance.resetAfterRowIndex = function (rowIndex, shouldForceUpdate) {
    
  966.       if (shouldForceUpdate === void 0) {
    
  967.         shouldForceUpdate = true;
    
  968.       }
    
  969. 
    
  970.       instance.resetAfterIndices({
    
  971.         rowIndex: rowIndex,
    
  972.         shouldForceUpdate: shouldForceUpdate
    
  973.       });
    
  974.     };
    
  975. 
    
  976.     instance.resetAfterIndices = function (_ref6) {
    
  977.       var columnIndex = _ref6.columnIndex,
    
  978.           rowIndex = _ref6.rowIndex,
    
  979.           _ref6$shouldForceUpda = _ref6.shouldForceUpdate,
    
  980.           shouldForceUpdate = _ref6$shouldForceUpda === void 0 ? true : _ref6$shouldForceUpda;
    
  981. 
    
  982.       if (typeof columnIndex === 'number') {
    
  983.         instanceProps.lastMeasuredColumnIndex = Math.min(instanceProps.lastMeasuredColumnIndex, columnIndex - 1);
    
  984.       }
    
  985. 
    
  986.       if (typeof rowIndex === 'number') {
    
  987.         instanceProps.lastMeasuredRowIndex = Math.min(instanceProps.lastMeasuredRowIndex, rowIndex - 1);
    
  988.       } // We could potentially optimize further by only evicting styles after this index,
    
  989.       // But since styles are only cached while scrolling is in progress-
    
  990.       // It seems an unnecessary optimization.
    
  991.       // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
    
  992. 
    
  993. 
    
  994.       instance._getItemStyleCache(-1);
    
  995. 
    
  996.       if (shouldForceUpdate) {
    
  997.         instance.forceUpdate();
    
  998.       }
    
  999.     };
    
  1000. 
    
  1001.     return instanceProps;
    
  1002.   },
    
  1003.   shouldResetStyleCacheOnItemSizeChange: false,
    
  1004.   validateProps: function validateProps(_ref7) {
    
  1005.     var columnWidth = _ref7.columnWidth,
    
  1006.         rowHeight = _ref7.rowHeight;
    
  1007. 
    
  1008.     if (process.env.NODE_ENV !== 'production') {
    
  1009.       if (typeof columnWidth !== 'function') {
    
  1010.         throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
    
  1011.       } else if (typeof rowHeight !== 'function') {
    
  1012.         throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
    
  1013.       }
    
  1014.     }
    
  1015.   }
    
  1016. });
    
  1017. 
    
  1018. var IS_SCROLLING_DEBOUNCE_INTERVAL$1 = 150;
    
  1019. 
    
  1020. var defaultItemKey$1 = function defaultItemKey(index, data) {
    
  1021.   return index;
    
  1022. }; // In DEV mode, this Set helps us only log a warning once per component instance.
    
  1023. // This avoids spamming the console every time a render happens.
    
  1024. 
    
  1025. 
    
  1026. var devWarningsDirection = null;
    
  1027. var devWarningsTagName$1 = null;
    
  1028. 
    
  1029. if (process.env.NODE_ENV !== 'production') {
    
  1030.   if (typeof window !== 'undefined' && typeof window.WeakSet !== 'undefined') {
    
  1031.     devWarningsDirection =
    
  1032.     /*#__PURE__*/
    
  1033.     new WeakSet();
    
  1034.     devWarningsTagName$1 =
    
  1035.     /*#__PURE__*/
    
  1036.     new WeakSet();
    
  1037.   }
    
  1038. }
    
  1039. 
    
  1040. function createListComponent(_ref) {
    
  1041.   var _class, _temp;
    
  1042. 
    
  1043.   var getItemOffset = _ref.getItemOffset,
    
  1044.       getEstimatedTotalSize = _ref.getEstimatedTotalSize,
    
  1045.       getItemSize = _ref.getItemSize,
    
  1046.       getOffsetForIndexAndAlignment = _ref.getOffsetForIndexAndAlignment,
    
  1047.       getStartIndexForOffset = _ref.getStartIndexForOffset,
    
  1048.       getStopIndexForStartIndex = _ref.getStopIndexForStartIndex,
    
  1049.       initInstanceProps = _ref.initInstanceProps,
    
  1050.       shouldResetStyleCacheOnItemSizeChange = _ref.shouldResetStyleCacheOnItemSizeChange,
    
  1051.       validateProps = _ref.validateProps;
    
  1052.   return _temp = _class =
    
  1053.   /*#__PURE__*/
    
  1054.   function (_PureComponent) {
    
  1055.     _inheritsLoose(List, _PureComponent);
    
  1056. 
    
  1057.     // Always use explicit constructor for React components.
    
  1058.     // It produces less code after transpilation. (#26)
    
  1059.     // eslint-disable-next-line no-useless-constructor
    
  1060.     function List(props) {
    
  1061.       var _this;
    
  1062. 
    
  1063.       _this = _PureComponent.call(this, props) || this;
    
  1064.       _this._instanceProps = initInstanceProps(_this.props, _assertThisInitialized(_assertThisInitialized(_this)));
    
  1065.       _this._outerRef = void 0;
    
  1066.       _this._resetIsScrollingTimeoutId = null;
    
  1067.       _this.state = {
    
  1068.         instance: _assertThisInitialized(_assertThisInitialized(_this)),
    
  1069.         isScrolling: false,
    
  1070.         scrollDirection: 'forward',
    
  1071.         scrollOffset: typeof _this.props.initialScrollOffset === 'number' ? _this.props.initialScrollOffset : 0,
    
  1072.         scrollUpdateWasRequested: false
    
  1073.       };
    
  1074.       _this._callOnItemsRendered = void 0;
    
  1075.       _this._callOnItemsRendered = memoizeOne(function (overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex) {
    
  1076.         return _this.props.onItemsRendered({
    
  1077.           overscanStartIndex: overscanStartIndex,
    
  1078.           overscanStopIndex: overscanStopIndex,
    
  1079.           visibleStartIndex: visibleStartIndex,
    
  1080.           visibleStopIndex: visibleStopIndex
    
  1081.         });
    
  1082.       });
    
  1083.       _this._callOnScroll = void 0;
    
  1084.       _this._callOnScroll = memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested) {
    
  1085.         return _this.props.onScroll({
    
  1086.           scrollDirection: scrollDirection,
    
  1087.           scrollOffset: scrollOffset,
    
  1088.           scrollUpdateWasRequested: scrollUpdateWasRequested
    
  1089.         });
    
  1090.       });
    
  1091.       _this._getItemStyle = void 0;
    
  1092. 
    
  1093.       _this._getItemStyle = function (index) {
    
  1094.         var _this$props = _this.props,
    
  1095.             direction = _this$props.direction,
    
  1096.             itemSize = _this$props.itemSize,
    
  1097.             layout = _this$props.layout;
    
  1098. 
    
  1099.         var itemStyleCache = _this._getItemStyleCache(shouldResetStyleCacheOnItemSizeChange && itemSize, shouldResetStyleCacheOnItemSizeChange && layout, shouldResetStyleCacheOnItemSizeChange && direction);
    
  1100. 
    
  1101.         var style;
    
  1102. 
    
  1103.         if (itemStyleCache.hasOwnProperty(index)) {
    
  1104.           style = itemStyleCache[index];
    
  1105.         } else {
    
  1106.           var _style;
    
  1107. 
    
  1108.           var _offset = getItemOffset(_this.props, index, _this._instanceProps);
    
  1109. 
    
  1110.           var size = getItemSize(_this.props, index, _this._instanceProps); // TODO Deprecate direction "horizontal"
    
  1111. 
    
  1112.           var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1113.           itemStyleCache[index] = style = (_style = {
    
  1114.             position: 'absolute'
    
  1115.           }, _style[direction === 'rtl' ? 'right' : 'left'] = isHorizontal ? _offset : 0, _style.top = !isHorizontal ? _offset : 0, _style.height = !isHorizontal ? size : '100%', _style.width = isHorizontal ? size : '100%', _style);
    
  1116.         }
    
  1117. 
    
  1118.         return style;
    
  1119.       };
    
  1120. 
    
  1121.       _this._getItemStyleCache = void 0;
    
  1122.       _this._getItemStyleCache = memoizeOne(function (_, __, ___) {
    
  1123.         return {};
    
  1124.       });
    
  1125. 
    
  1126.       _this._onScrollHorizontal = function (event) {
    
  1127.         var _event$currentTarget = event.currentTarget,
    
  1128.             clientWidth = _event$currentTarget.clientWidth,
    
  1129.             scrollLeft = _event$currentTarget.scrollLeft,
    
  1130.             scrollWidth = _event$currentTarget.scrollWidth;
    
  1131. 
    
  1132.         // Force flush sync for scroll updates to reduce visual checkerboarding.
    
  1133.         flushSync(() => {
    
  1134.           _this.setState(function (prevState) {
    
  1135.             if (prevState.scrollOffset === scrollLeft) {
    
  1136.               // Scroll position may have been updated by cDM/cDU,
    
  1137.               // In which case we don't need to trigger another render,
    
  1138.               // And we don't want to update state.isScrolling.
    
  1139.               return null;
    
  1140.             }
    
  1141. 
    
  1142.             var direction = _this.props.direction;
    
  1143.             var scrollOffset = scrollLeft;
    
  1144. 
    
  1145.             if (direction === 'rtl') {
    
  1146.               // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  1147.               // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  1148.               // It's also easier for this component if we convert offsets to the same format as they would be in for ltr.
    
  1149.               // So the simplest solution is to determine which browser behavior we're dealing with, and convert based on it.
    
  1150.               switch (getRTLOffsetType()) {
    
  1151.                 case 'negative':
    
  1152.                   scrollOffset = -scrollLeft;
    
  1153.                   break;
    
  1154. 
    
  1155.                 case 'positive-descending':
    
  1156.                   scrollOffset = scrollWidth - clientWidth - scrollLeft;
    
  1157.                   break;
    
  1158.               }
    
  1159.             } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  1160. 
    
  1161. 
    
  1162.             scrollOffset = Math.max(0, Math.min(scrollOffset, scrollWidth - clientWidth));
    
  1163.             return {
    
  1164.               isScrolling: true,
    
  1165.               scrollDirection: prevState.scrollOffset < scrollLeft ? 'forward' : 'backward',
    
  1166.               scrollOffset: scrollOffset,
    
  1167.               scrollUpdateWasRequested: false
    
  1168.             };
    
  1169.           }, _this._resetIsScrollingDebounced);
    
  1170.         });
    
  1171.       };
    
  1172. 
    
  1173.       _this._onScrollVertical = function (event) {
    
  1174.         var _event$currentTarget2 = event.currentTarget,
    
  1175.             clientHeight = _event$currentTarget2.clientHeight,
    
  1176.             scrollHeight = _event$currentTarget2.scrollHeight,
    
  1177.             scrollTop = _event$currentTarget2.scrollTop;
    
  1178. 
    
  1179.         // Force flush sync for scroll updates to reduce visual checkerboarding.
    
  1180.         flushSync(() => {
    
  1181.           _this.setState(function (prevState) {
    
  1182.             if (prevState.scrollOffset === scrollTop) {
    
  1183.               // Scroll position may have been updated by cDM/cDU,
    
  1184.               // In which case we don't need to trigger another render,
    
  1185.               // And we don't want to update state.isScrolling.
    
  1186.               return null;
    
  1187.             } // Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
    
  1188. 
    
  1189. 
    
  1190.             var scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
    
  1191.             return {
    
  1192.               isScrolling: true,
    
  1193.               scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
    
  1194.               scrollOffset: scrollOffset,
    
  1195.               scrollUpdateWasRequested: false
    
  1196.             };
    
  1197.           }, _this._resetIsScrollingDebounced);
    
  1198.         });
    
  1199.       };
    
  1200. 
    
  1201.       _this._outerRefSetter = function (ref) {
    
  1202.         var outerRef = _this.props.outerRef;
    
  1203.         _this._outerRef = ref;
    
  1204. 
    
  1205.         if (typeof outerRef === 'function') {
    
  1206.           outerRef(ref);
    
  1207.         } else if (outerRef != null && typeof outerRef === 'object' && outerRef.hasOwnProperty('current')) {
    
  1208.           outerRef.current = ref;
    
  1209.         }
    
  1210.       };
    
  1211. 
    
  1212.       _this._resetIsScrollingDebounced = function () {
    
  1213.         if (_this._resetIsScrollingTimeoutId !== null) {
    
  1214.           cancelTimeout(_this._resetIsScrollingTimeoutId);
    
  1215.         }
    
  1216. 
    
  1217.         _this._resetIsScrollingTimeoutId = requestTimeout(_this._resetIsScrolling, IS_SCROLLING_DEBOUNCE_INTERVAL$1);
    
  1218.       };
    
  1219. 
    
  1220.       _this._resetIsScrolling = function () {
    
  1221.         _this._resetIsScrollingTimeoutId = null;
    
  1222. 
    
  1223.         _this.setState({
    
  1224.           isScrolling: false
    
  1225.         }, function () {
    
  1226.           // Clear style cache after state update has been committed.
    
  1227.           // This way we don't break pure sCU for items that don't use isScrolling param.
    
  1228.           _this._getItemStyleCache(-1, null);
    
  1229.         });
    
  1230.       };
    
  1231. 
    
  1232.       return _this;
    
  1233.     }
    
  1234. 
    
  1235.     List.getDerivedStateFromProps = function getDerivedStateFromProps(nextProps, prevState) {
    
  1236.       validateSharedProps$1(nextProps, prevState);
    
  1237.       validateProps(nextProps);
    
  1238.       return null;
    
  1239.     };
    
  1240. 
    
  1241.     var _proto = List.prototype;
    
  1242. 
    
  1243.     _proto.scrollTo = function scrollTo(scrollOffset) {
    
  1244.       scrollOffset = Math.max(0, scrollOffset);
    
  1245.       this.setState(function (prevState) {
    
  1246.         if (prevState.scrollOffset === scrollOffset) {
    
  1247.           return null;
    
  1248.         }
    
  1249. 
    
  1250.         return {
    
  1251.           scrollDirection: prevState.scrollOffset < scrollOffset ? 'forward' : 'backward',
    
  1252.           scrollOffset: scrollOffset,
    
  1253.           scrollUpdateWasRequested: true
    
  1254.         };
    
  1255.       }, this._resetIsScrollingDebounced);
    
  1256.     };
    
  1257. 
    
  1258.     _proto.scrollToItem = function scrollToItem(index, align) {
    
  1259.       if (align === void 0) {
    
  1260.         align = 'auto';
    
  1261.       }
    
  1262. 
    
  1263.       var itemCount = this.props.itemCount;
    
  1264.       var scrollOffset = this.state.scrollOffset;
    
  1265.       index = Math.max(0, Math.min(index, itemCount - 1));
    
  1266.       this.scrollTo(getOffsetForIndexAndAlignment(this.props, index, align, scrollOffset, this._instanceProps));
    
  1267.     };
    
  1268. 
    
  1269.     _proto.componentDidMount = function componentDidMount() {
    
  1270.       var _this$props2 = this.props,
    
  1271.           direction = _this$props2.direction,
    
  1272.           initialScrollOffset = _this$props2.initialScrollOffset,
    
  1273.           layout = _this$props2.layout;
    
  1274. 
    
  1275.       if (typeof initialScrollOffset === 'number' && this._outerRef != null) {
    
  1276.         var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
    
  1277. 
    
  1278.         if (direction === 'horizontal' || layout === 'horizontal') {
    
  1279.           outerRef.scrollLeft = initialScrollOffset;
    
  1280.         } else {
    
  1281.           outerRef.scrollTop = initialScrollOffset;
    
  1282.         }
    
  1283.       }
    
  1284. 
    
  1285.       this._callPropsCallbacks();
    
  1286.     };
    
  1287. 
    
  1288.     _proto.componentDidUpdate = function componentDidUpdate() {
    
  1289.       var _this$props3 = this.props,
    
  1290.           direction = _this$props3.direction,
    
  1291.           layout = _this$props3.layout;
    
  1292.       var _this$state = this.state,
    
  1293.           scrollOffset = _this$state.scrollOffset,
    
  1294.           scrollUpdateWasRequested = _this$state.scrollUpdateWasRequested;
    
  1295. 
    
  1296.       if (scrollUpdateWasRequested && this._outerRef != null) {
    
  1297.         var outerRef = this._outerRef; // TODO Deprecate direction "horizontal"
    
  1298. 
    
  1299.         if (direction === 'horizontal' || layout === 'horizontal') {
    
  1300.           if (direction === 'rtl') {
    
  1301.             // TRICKY According to the spec, scrollLeft should be negative for RTL aligned elements.
    
  1302.             // This is not the case for all browsers though (e.g. Chrome reports values as positive, measured relative to the left).
    
  1303.             // So we need to determine which browser behavior we're dealing with, and mimic it.
    
  1304.             switch (getRTLOffsetType()) {
    
  1305.               case 'negative':
    
  1306.                 outerRef.scrollLeft = -scrollOffset;
    
  1307.                 break;
    
  1308. 
    
  1309.               case 'positive-ascending':
    
  1310.                 outerRef.scrollLeft = scrollOffset;
    
  1311.                 break;
    
  1312. 
    
  1313.               default:
    
  1314.                 var clientWidth = outerRef.clientWidth,
    
  1315.                     scrollWidth = outerRef.scrollWidth;
    
  1316.                 outerRef.scrollLeft = scrollWidth - clientWidth - scrollOffset;
    
  1317.                 break;
    
  1318.             }
    
  1319.           } else {
    
  1320.             outerRef.scrollLeft = scrollOffset;
    
  1321.           }
    
  1322.         } else {
    
  1323.           outerRef.scrollTop = scrollOffset;
    
  1324.         }
    
  1325.       }
    
  1326. 
    
  1327.       this._callPropsCallbacks();
    
  1328.     };
    
  1329. 
    
  1330.     _proto.componentWillUnmount = function componentWillUnmount() {
    
  1331.       if (this._resetIsScrollingTimeoutId !== null) {
    
  1332.         cancelTimeout(this._resetIsScrollingTimeoutId);
    
  1333.       }
    
  1334.     };
    
  1335. 
    
  1336.     _proto.render = function render() {
    
  1337.       var _this$props4 = this.props,
    
  1338.           children = _this$props4.children,
    
  1339.           className = _this$props4.className,
    
  1340.           direction = _this$props4.direction,
    
  1341.           height = _this$props4.height,
    
  1342.           innerRef = _this$props4.innerRef,
    
  1343.           innerElementType = _this$props4.innerElementType,
    
  1344.           innerTagName = _this$props4.innerTagName,
    
  1345.           itemCount = _this$props4.itemCount,
    
  1346.           itemData = _this$props4.itemData,
    
  1347.           _this$props4$itemKey = _this$props4.itemKey,
    
  1348.           itemKey = _this$props4$itemKey === void 0 ? defaultItemKey$1 : _this$props4$itemKey,
    
  1349.           layout = _this$props4.layout,
    
  1350.           outerElementType = _this$props4.outerElementType,
    
  1351.           outerTagName = _this$props4.outerTagName,
    
  1352.           style = _this$props4.style,
    
  1353.           useIsScrolling = _this$props4.useIsScrolling,
    
  1354.           width = _this$props4.width;
    
  1355.       var isScrolling = this.state.isScrolling; // TODO Deprecate direction "horizontal"
    
  1356. 
    
  1357.       var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1358.       var onScroll = isHorizontal ? this._onScrollHorizontal : this._onScrollVertical;
    
  1359. 
    
  1360.       var _this$_getRangeToRend = this._getRangeToRender(),
    
  1361.           startIndex = _this$_getRangeToRend[0],
    
  1362.           stopIndex = _this$_getRangeToRend[1];
    
  1363. 
    
  1364.       var items = [];
    
  1365. 
    
  1366.       if (itemCount > 0) {
    
  1367.         for (var _index = startIndex; _index <= stopIndex; _index++) {
    
  1368.           items.push(createElement(children, {
    
  1369.             data: itemData,
    
  1370.             key: itemKey(_index, itemData),
    
  1371.             index: _index,
    
  1372.             isScrolling: useIsScrolling ? isScrolling : undefined,
    
  1373.             style: this._getItemStyle(_index)
    
  1374.           }));
    
  1375.         }
    
  1376.       } // Read this value AFTER items have been created,
    
  1377.       // So their actual sizes (if variable) are taken into consideration.
    
  1378. 
    
  1379. 
    
  1380.       var estimatedTotalSize = getEstimatedTotalSize(this.props, this._instanceProps);
    
  1381.       return createElement(outerElementType || outerTagName || 'div', {
    
  1382.         className: className,
    
  1383.         onScroll: onScroll,
    
  1384.         ref: this._outerRefSetter,
    
  1385.         style: _extends({
    
  1386.           position: 'relative',
    
  1387.           height: height,
    
  1388.           width: width,
    
  1389.           overflow: 'auto',
    
  1390.           WebkitOverflowScrolling: 'touch',
    
  1391.           willChange: 'transform',
    
  1392.           direction: direction
    
  1393.         }, style)
    
  1394.       }, createElement(innerElementType || innerTagName || 'div', {
    
  1395.         children: items,
    
  1396.         ref: innerRef,
    
  1397.         style: {
    
  1398.           height: isHorizontal ? '100%' : estimatedTotalSize,
    
  1399.           pointerEvents: isScrolling ? 'none' : undefined,
    
  1400.           width: isHorizontal ? estimatedTotalSize : '100%'
    
  1401.         }
    
  1402.       }));
    
  1403.     };
    
  1404. 
    
  1405.     _proto._callPropsCallbacks = function _callPropsCallbacks() {
    
  1406.       if (typeof this.props.onItemsRendered === 'function') {
    
  1407.         var itemCount = this.props.itemCount;
    
  1408. 
    
  1409.         if (itemCount > 0) {
    
  1410.           var _this$_getRangeToRend2 = this._getRangeToRender(),
    
  1411.               _overscanStartIndex = _this$_getRangeToRend2[0],
    
  1412.               _overscanStopIndex = _this$_getRangeToRend2[1],
    
  1413.               _visibleStartIndex = _this$_getRangeToRend2[2],
    
  1414.               _visibleStopIndex = _this$_getRangeToRend2[3];
    
  1415. 
    
  1416.           this._callOnItemsRendered(_overscanStartIndex, _overscanStopIndex, _visibleStartIndex, _visibleStopIndex);
    
  1417.         }
    
  1418.       }
    
  1419. 
    
  1420.       if (typeof this.props.onScroll === 'function') {
    
  1421.         var _this$state2 = this.state,
    
  1422.             _scrollDirection = _this$state2.scrollDirection,
    
  1423.             _scrollOffset = _this$state2.scrollOffset,
    
  1424.             _scrollUpdateWasRequested = _this$state2.scrollUpdateWasRequested;
    
  1425. 
    
  1426.         this._callOnScroll(_scrollDirection, _scrollOffset, _scrollUpdateWasRequested);
    
  1427.       }
    
  1428.     }; // Lazily create and cache item styles while scrolling,
    
  1429.     // So that pure component sCU will prevent re-renders.
    
  1430.     // We maintain this cache, and pass a style prop rather than index,
    
  1431.     // So that List can clear cached styles and force item re-render if necessary.
    
  1432. 
    
  1433. 
    
  1434.     _proto._getRangeToRender = function _getRangeToRender() {
    
  1435.       var _this$props5 = this.props,
    
  1436.           itemCount = _this$props5.itemCount,
    
  1437.           overscanCount = _this$props5.overscanCount;
    
  1438.       var _this$state3 = this.state,
    
  1439.           isScrolling = _this$state3.isScrolling,
    
  1440.           scrollDirection = _this$state3.scrollDirection,
    
  1441.           scrollOffset = _this$state3.scrollOffset;
    
  1442. 
    
  1443.       if (itemCount === 0) {
    
  1444.         return [0, 0, 0, 0];
    
  1445.       }
    
  1446. 
    
  1447.       var startIndex = getStartIndexForOffset(this.props, scrollOffset, this._instanceProps);
    
  1448.       var stopIndex = getStopIndexForStartIndex(this.props, startIndex, scrollOffset, this._instanceProps); // Overscan by one item in each direction so that tab/focus works.
    
  1449.       // If there isn't at least one extra item, tab loops back around.
    
  1450. 
    
  1451.       var overscanBackward = !isScrolling || scrollDirection === 'backward' ? Math.max(1, overscanCount) : 1;
    
  1452.       var overscanForward = !isScrolling || scrollDirection === 'forward' ? Math.max(1, overscanCount) : 1;
    
  1453.       return [Math.max(0, startIndex - overscanBackward), Math.max(0, Math.min(itemCount - 1, stopIndex + overscanForward)), startIndex, stopIndex];
    
  1454.     };
    
  1455. 
    
  1456.     return List;
    
  1457.   }(PureComponent), _class.defaultProps = {
    
  1458.     direction: 'ltr',
    
  1459.     itemData: undefined,
    
  1460.     layout: 'vertical',
    
  1461.     overscanCount: 2,
    
  1462.     useIsScrolling: false
    
  1463.   }, _temp;
    
  1464. } // NOTE: I considered further wrapping individual items with a pure ListItem component.
    
  1465. // This would avoid ever calling the render function for the same index more than once,
    
  1466. // But it would also add the overhead of a lot of components/fibers.
    
  1467. // I assume people already do this (render function returning a class component),
    
  1468. // So my doing it would just unnecessarily double the wrappers.
    
  1469. 
    
  1470. var validateSharedProps$1 = function validateSharedProps(_ref2, _ref3) {
    
  1471.   var children = _ref2.children,
    
  1472.       direction = _ref2.direction,
    
  1473.       height = _ref2.height,
    
  1474.       layout = _ref2.layout,
    
  1475.       innerTagName = _ref2.innerTagName,
    
  1476.       outerTagName = _ref2.outerTagName,
    
  1477.       width = _ref2.width;
    
  1478.   var instance = _ref3.instance;
    
  1479. 
    
  1480.   if (process.env.NODE_ENV !== 'production') {
    
  1481.     if (innerTagName != null || outerTagName != null) {
    
  1482.       if (devWarningsTagName$1 && !devWarningsTagName$1.has(instance)) {
    
  1483.         devWarningsTagName$1.add(instance);
    
  1484.         console.warn('The innerTagName and outerTagName props have been deprecated. ' + 'Please use the innerElementType and outerElementType props instead.');
    
  1485.       }
    
  1486.     } // TODO Deprecate direction "horizontal"
    
  1487. 
    
  1488. 
    
  1489.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1490. 
    
  1491.     switch (direction) {
    
  1492.       case 'horizontal':
    
  1493.       case 'vertical':
    
  1494.         if (devWarningsDirection && !devWarningsDirection.has(instance)) {
    
  1495.           devWarningsDirection.add(instance);
    
  1496.           console.warn('The direction prop should be either "ltr" (default) or "rtl". ' + 'Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.');
    
  1497.         }
    
  1498. 
    
  1499.         break;
    
  1500. 
    
  1501.       case 'ltr':
    
  1502.       case 'rtl':
    
  1503.         // Valid values
    
  1504.         break;
    
  1505. 
    
  1506.       default:
    
  1507.         throw Error('An invalid "direction" prop has been specified. ' + 'Value should be either "ltr" or "rtl". ' + ("\"" + direction + "\" was specified."));
    
  1508.     }
    
  1509. 
    
  1510.     switch (layout) {
    
  1511.       case 'horizontal':
    
  1512.       case 'vertical':
    
  1513.         // Valid values
    
  1514.         break;
    
  1515. 
    
  1516.       default:
    
  1517.         throw Error('An invalid "layout" prop has been specified. ' + 'Value should be either "horizontal" or "vertical". ' + ("\"" + layout + "\" was specified."));
    
  1518.     }
    
  1519. 
    
  1520.     if (children == null) {
    
  1521.       throw Error('An invalid "children" prop has been specified. ' + 'Value should be a React component. ' + ("\"" + (children === null ? 'null' : typeof children) + "\" was specified."));
    
  1522.     }
    
  1523. 
    
  1524.     if (isHorizontal && typeof width !== 'number') {
    
  1525.       throw Error('An invalid "width" prop has been specified. ' + 'Horizontal lists must specify a number for width. ' + ("\"" + (width === null ? 'null' : typeof width) + "\" was specified."));
    
  1526.     } else if (!isHorizontal && typeof height !== 'number') {
    
  1527.       throw Error('An invalid "height" prop has been specified. ' + 'Vertical lists must specify a number for height. ' + ("\"" + (height === null ? 'null' : typeof height) + "\" was specified."));
    
  1528.     }
    
  1529.   }
    
  1530. };
    
  1531. 
    
  1532. var DEFAULT_ESTIMATED_ITEM_SIZE$1 = 50;
    
  1533. 
    
  1534. var getItemMetadata$1 = function getItemMetadata(props, index, instanceProps) {
    
  1535.   var _ref = props,
    
  1536.       itemSize = _ref.itemSize;
    
  1537.   var itemMetadataMap = instanceProps.itemMetadataMap,
    
  1538.       lastMeasuredIndex = instanceProps.lastMeasuredIndex;
    
  1539. 
    
  1540.   if (index > lastMeasuredIndex) {
    
  1541.     var offset = 0;
    
  1542. 
    
  1543.     if (lastMeasuredIndex >= 0) {
    
  1544.       var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  1545.       offset = itemMetadata.offset + itemMetadata.size;
    
  1546.     }
    
  1547. 
    
  1548.     for (var i = lastMeasuredIndex + 1; i <= index; i++) {
    
  1549.       var size = itemSize(i);
    
  1550.       itemMetadataMap[i] = {
    
  1551.         offset: offset,
    
  1552.         size: size
    
  1553.       };
    
  1554.       offset += size;
    
  1555.     }
    
  1556. 
    
  1557.     instanceProps.lastMeasuredIndex = index;
    
  1558.   }
    
  1559. 
    
  1560.   return itemMetadataMap[index];
    
  1561. };
    
  1562. 
    
  1563. var findNearestItem$1 = function findNearestItem(props, instanceProps, offset) {
    
  1564.   var itemMetadataMap = instanceProps.itemMetadataMap,
    
  1565.       lastMeasuredIndex = instanceProps.lastMeasuredIndex;
    
  1566.   var lastMeasuredItemOffset = lastMeasuredIndex > 0 ? itemMetadataMap[lastMeasuredIndex].offset : 0;
    
  1567. 
    
  1568.   if (lastMeasuredItemOffset >= offset) {
    
  1569.     // If we've already measured items within this range just use a binary search as it's faster.
    
  1570.     return findNearestItemBinarySearch$1(props, instanceProps, lastMeasuredIndex, 0, offset);
    
  1571.   } else {
    
  1572.     // If we haven't yet measured this high, fallback to an exponential search with an inner binary search.
    
  1573.     // The exponential search avoids pre-computing sizes for the full set of items as a binary search would.
    
  1574.     // The overall complexity for this approach is O(log n).
    
  1575.     return findNearestItemExponentialSearch$1(props, instanceProps, Math.max(0, lastMeasuredIndex), offset);
    
  1576.   }
    
  1577. };
    
  1578. 
    
  1579. var findNearestItemBinarySearch$1 = function findNearestItemBinarySearch(props, instanceProps, high, low, offset) {
    
  1580.   while (low <= high) {
    
  1581.     var middle = low + Math.floor((high - low) / 2);
    
  1582.     var currentOffset = getItemMetadata$1(props, middle, instanceProps).offset;
    
  1583. 
    
  1584.     if (currentOffset === offset) {
    
  1585.       return middle;
    
  1586.     } else if (currentOffset < offset) {
    
  1587.       low = middle + 1;
    
  1588.     } else if (currentOffset > offset) {
    
  1589.       high = middle - 1;
    
  1590.     }
    
  1591.   }
    
  1592. 
    
  1593.   if (low > 0) {
    
  1594.     return low - 1;
    
  1595.   } else {
    
  1596.     return 0;
    
  1597.   }
    
  1598. };
    
  1599. 
    
  1600. var findNearestItemExponentialSearch$1 = function findNearestItemExponentialSearch(props, instanceProps, index, offset) {
    
  1601.   var itemCount = props.itemCount;
    
  1602.   var interval = 1;
    
  1603. 
    
  1604.   while (index < itemCount && getItemMetadata$1(props, index, instanceProps).offset < offset) {
    
  1605.     index += interval;
    
  1606.     interval *= 2;
    
  1607.   }
    
  1608. 
    
  1609.   return findNearestItemBinarySearch$1(props, instanceProps, Math.min(index, itemCount - 1), Math.floor(index / 2), offset);
    
  1610. };
    
  1611. 
    
  1612. var getEstimatedTotalSize = function getEstimatedTotalSize(_ref2, _ref3) {
    
  1613.   var itemCount = _ref2.itemCount;
    
  1614.   var itemMetadataMap = _ref3.itemMetadataMap,
    
  1615.       estimatedItemSize = _ref3.estimatedItemSize,
    
  1616.       lastMeasuredIndex = _ref3.lastMeasuredIndex;
    
  1617.   var totalSizeOfMeasuredItems = 0; // Edge case check for when the number of items decreases while a scroll is in progress.
    
  1618.   // https://github.com/bvaughn/react-window/pull/138
    
  1619. 
    
  1620.   if (lastMeasuredIndex >= itemCount) {
    
  1621.     lastMeasuredIndex = itemCount - 1;
    
  1622.   }
    
  1623. 
    
  1624.   if (lastMeasuredIndex >= 0) {
    
  1625.     var itemMetadata = itemMetadataMap[lastMeasuredIndex];
    
  1626.     totalSizeOfMeasuredItems = itemMetadata.offset + itemMetadata.size;
    
  1627.   }
    
  1628. 
    
  1629.   var numUnmeasuredItems = itemCount - lastMeasuredIndex - 1;
    
  1630.   var totalSizeOfUnmeasuredItems = numUnmeasuredItems * estimatedItemSize;
    
  1631.   return totalSizeOfMeasuredItems + totalSizeOfUnmeasuredItems;
    
  1632. };
    
  1633. 
    
  1634. var VariableSizeList =
    
  1635. /*#__PURE__*/
    
  1636. createListComponent({
    
  1637.   getItemOffset: function getItemOffset(props, index, instanceProps) {
    
  1638.     return getItemMetadata$1(props, index, instanceProps).offset;
    
  1639.   },
    
  1640.   getItemSize: function getItemSize(props, index, instanceProps) {
    
  1641.     return instanceProps.itemMetadataMap[index].size;
    
  1642.   },
    
  1643.   getEstimatedTotalSize: getEstimatedTotalSize,
    
  1644.   getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(props, index, align, scrollOffset, instanceProps) {
    
  1645.     var direction = props.direction,
    
  1646.         height = props.height,
    
  1647.         layout = props.layout,
    
  1648.         width = props.width; // TODO Deprecate direction "horizontal"
    
  1649. 
    
  1650.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1651.     var size = isHorizontal ? width : height;
    
  1652.     var itemMetadata = getItemMetadata$1(props, index, instanceProps); // Get estimated total size after ItemMetadata is computed,
    
  1653.     // To ensure it reflects actual measurements instead of just estimates.
    
  1654. 
    
  1655.     var estimatedTotalSize = getEstimatedTotalSize(props, instanceProps);
    
  1656.     var maxOffset = Math.max(0, Math.min(estimatedTotalSize - size, itemMetadata.offset));
    
  1657.     var minOffset = Math.max(0, itemMetadata.offset - size + itemMetadata.size);
    
  1658. 
    
  1659.     if (align === 'smart') {
    
  1660.       if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  1661.         align = 'auto';
    
  1662.       } else {
    
  1663.         align = 'center';
    
  1664.       }
    
  1665.     }
    
  1666. 
    
  1667.     switch (align) {
    
  1668.       case 'start':
    
  1669.         return maxOffset;
    
  1670. 
    
  1671.       case 'end':
    
  1672.         return minOffset;
    
  1673. 
    
  1674.       case 'center':
    
  1675.         return Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1676. 
    
  1677.       case 'auto':
    
  1678.       default:
    
  1679.         if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  1680.           return scrollOffset;
    
  1681.         } else if (scrollOffset < minOffset) {
    
  1682.           return minOffset;
    
  1683.         } else {
    
  1684.           return maxOffset;
    
  1685.         }
    
  1686. 
    
  1687.     }
    
  1688.   },
    
  1689.   getStartIndexForOffset: function getStartIndexForOffset(props, offset, instanceProps) {
    
  1690.     return findNearestItem$1(props, instanceProps, offset);
    
  1691.   },
    
  1692.   getStopIndexForStartIndex: function getStopIndexForStartIndex(props, startIndex, scrollOffset, instanceProps) {
    
  1693.     var direction = props.direction,
    
  1694.         height = props.height,
    
  1695.         itemCount = props.itemCount,
    
  1696.         layout = props.layout,
    
  1697.         width = props.width; // TODO Deprecate direction "horizontal"
    
  1698. 
    
  1699.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1700.     var size = isHorizontal ? width : height;
    
  1701.     var itemMetadata = getItemMetadata$1(props, startIndex, instanceProps);
    
  1702.     var maxOffset = scrollOffset + size;
    
  1703.     var offset = itemMetadata.offset + itemMetadata.size;
    
  1704.     var stopIndex = startIndex;
    
  1705. 
    
  1706.     while (stopIndex < itemCount - 1 && offset < maxOffset) {
    
  1707.       stopIndex++;
    
  1708.       offset += getItemMetadata$1(props, stopIndex, instanceProps).size;
    
  1709.     }
    
  1710. 
    
  1711.     return stopIndex;
    
  1712.   },
    
  1713.   initInstanceProps: function initInstanceProps(props, instance) {
    
  1714.     var _ref4 = props,
    
  1715.         estimatedItemSize = _ref4.estimatedItemSize;
    
  1716.     var instanceProps = {
    
  1717.       itemMetadataMap: {},
    
  1718.       estimatedItemSize: estimatedItemSize || DEFAULT_ESTIMATED_ITEM_SIZE$1,
    
  1719.       lastMeasuredIndex: -1
    
  1720.     };
    
  1721. 
    
  1722.     instance.resetAfterIndex = function (index, shouldForceUpdate) {
    
  1723.       if (shouldForceUpdate === void 0) {
    
  1724.         shouldForceUpdate = true;
    
  1725.       }
    
  1726. 
    
  1727.       instanceProps.lastMeasuredIndex = Math.min(instanceProps.lastMeasuredIndex, index - 1); // We could potentially optimize further by only evicting styles after this index,
    
  1728.       // But since styles are only cached while scrolling is in progress-
    
  1729.       // It seems an unnecessary optimization.
    
  1730.       // It's unlikely that resetAfterIndex() will be called while a user is scrolling.
    
  1731. 
    
  1732.       instance._getItemStyleCache(-1);
    
  1733. 
    
  1734.       if (shouldForceUpdate) {
    
  1735.         instance.forceUpdate();
    
  1736.       }
    
  1737.     };
    
  1738. 
    
  1739.     return instanceProps;
    
  1740.   },
    
  1741.   shouldResetStyleCacheOnItemSizeChange: false,
    
  1742.   validateProps: function validateProps(_ref5) {
    
  1743.     var itemSize = _ref5.itemSize;
    
  1744. 
    
  1745.     if (process.env.NODE_ENV !== 'production') {
    
  1746.       if (typeof itemSize !== 'function') {
    
  1747.         throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a function. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
    
  1748.       }
    
  1749.     }
    
  1750.   }
    
  1751. });
    
  1752. 
    
  1753. var FixedSizeGrid =
    
  1754. /*#__PURE__*/
    
  1755. createGridComponent({
    
  1756.   getColumnOffset: function getColumnOffset(_ref, index) {
    
  1757.     var columnWidth = _ref.columnWidth;
    
  1758.     return index * columnWidth;
    
  1759.   },
    
  1760.   getColumnWidth: function getColumnWidth(_ref2, index) {
    
  1761.     var columnWidth = _ref2.columnWidth;
    
  1762.     return columnWidth;
    
  1763.   },
    
  1764.   getRowOffset: function getRowOffset(_ref3, index) {
    
  1765.     var rowHeight = _ref3.rowHeight;
    
  1766.     return index * rowHeight;
    
  1767.   },
    
  1768.   getRowHeight: function getRowHeight(_ref4, index) {
    
  1769.     var rowHeight = _ref4.rowHeight;
    
  1770.     return rowHeight;
    
  1771.   },
    
  1772.   getEstimatedTotalHeight: function getEstimatedTotalHeight(_ref5) {
    
  1773.     var rowCount = _ref5.rowCount,
    
  1774.         rowHeight = _ref5.rowHeight;
    
  1775.     return rowHeight * rowCount;
    
  1776.   },
    
  1777.   getEstimatedTotalWidth: function getEstimatedTotalWidth(_ref6) {
    
  1778.     var columnCount = _ref6.columnCount,
    
  1779.         columnWidth = _ref6.columnWidth;
    
  1780.     return columnWidth * columnCount;
    
  1781.   },
    
  1782.   getOffsetForColumnAndAlignment: function getOffsetForColumnAndAlignment(_ref7, columnIndex, align, scrollLeft, instanceProps, scrollbarSize) {
    
  1783.     var columnCount = _ref7.columnCount,
    
  1784.         columnWidth = _ref7.columnWidth,
    
  1785.         width = _ref7.width;
    
  1786.     var lastColumnOffset = Math.max(0, columnCount * columnWidth - width);
    
  1787.     var maxOffset = Math.min(lastColumnOffset, columnIndex * columnWidth);
    
  1788.     var minOffset = Math.max(0, columnIndex * columnWidth - width + scrollbarSize + columnWidth);
    
  1789. 
    
  1790.     if (align === 'smart') {
    
  1791.       if (scrollLeft >= minOffset - width && scrollLeft <= maxOffset + width) {
    
  1792.         align = 'auto';
    
  1793.       } else {
    
  1794.         align = 'center';
    
  1795.       }
    
  1796.     }
    
  1797. 
    
  1798.     switch (align) {
    
  1799.       case 'start':
    
  1800.         return maxOffset;
    
  1801. 
    
  1802.       case 'end':
    
  1803.         return minOffset;
    
  1804. 
    
  1805.       case 'center':
    
  1806.         // "Centered" offset is usually the average of the min and max.
    
  1807.         // But near the edges of the list, this doesn't hold true.
    
  1808.         var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1809. 
    
  1810.         if (middleOffset < Math.ceil(width / 2)) {
    
  1811.           return 0; // near the beginning
    
  1812.         } else if (middleOffset > lastColumnOffset + Math.floor(width / 2)) {
    
  1813.           return lastColumnOffset; // near the end
    
  1814.         } else {
    
  1815.           return middleOffset;
    
  1816.         }
    
  1817. 
    
  1818.       case 'auto':
    
  1819.       default:
    
  1820.         if (scrollLeft >= minOffset && scrollLeft <= maxOffset) {
    
  1821.           return scrollLeft;
    
  1822.         } else if (minOffset > maxOffset) {
    
  1823.           // Because we only take into account the scrollbar size when calculating minOffset
    
  1824.           // this value can be larger than maxOffset when at the end of the list
    
  1825.           return minOffset;
    
  1826.         } else if (scrollLeft < minOffset) {
    
  1827.           return minOffset;
    
  1828.         } else {
    
  1829.           return maxOffset;
    
  1830.         }
    
  1831. 
    
  1832.     }
    
  1833.   },
    
  1834.   getOffsetForRowAndAlignment: function getOffsetForRowAndAlignment(_ref8, rowIndex, align, scrollTop, instanceProps, scrollbarSize) {
    
  1835.     var rowHeight = _ref8.rowHeight,
    
  1836.         height = _ref8.height,
    
  1837.         rowCount = _ref8.rowCount;
    
  1838.     var lastRowOffset = Math.max(0, rowCount * rowHeight - height);
    
  1839.     var maxOffset = Math.min(lastRowOffset, rowIndex * rowHeight);
    
  1840.     var minOffset = Math.max(0, rowIndex * rowHeight - height + scrollbarSize + rowHeight);
    
  1841. 
    
  1842.     if (align === 'smart') {
    
  1843.       if (scrollTop >= minOffset - height && scrollTop <= maxOffset + height) {
    
  1844.         align = 'auto';
    
  1845.       } else {
    
  1846.         align = 'center';
    
  1847.       }
    
  1848.     }
    
  1849. 
    
  1850.     switch (align) {
    
  1851.       case 'start':
    
  1852.         return maxOffset;
    
  1853. 
    
  1854.       case 'end':
    
  1855.         return minOffset;
    
  1856. 
    
  1857.       case 'center':
    
  1858.         // "Centered" offset is usually the average of the min and max.
    
  1859.         // But near the edges of the list, this doesn't hold true.
    
  1860.         var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1861. 
    
  1862.         if (middleOffset < Math.ceil(height / 2)) {
    
  1863.           return 0; // near the beginning
    
  1864.         } else if (middleOffset > lastRowOffset + Math.floor(height / 2)) {
    
  1865.           return lastRowOffset; // near the end
    
  1866.         } else {
    
  1867.           return middleOffset;
    
  1868.         }
    
  1869. 
    
  1870.       case 'auto':
    
  1871.       default:
    
  1872.         if (scrollTop >= minOffset && scrollTop <= maxOffset) {
    
  1873.           return scrollTop;
    
  1874.         } else if (minOffset > maxOffset) {
    
  1875.           // Because we only take into account the scrollbar size when calculating minOffset
    
  1876.           // this value can be larger than maxOffset when at the end of the list
    
  1877.           return minOffset;
    
  1878.         } else if (scrollTop < minOffset) {
    
  1879.           return minOffset;
    
  1880.         } else {
    
  1881.           return maxOffset;
    
  1882.         }
    
  1883. 
    
  1884.     }
    
  1885.   },
    
  1886.   getColumnStartIndexForOffset: function getColumnStartIndexForOffset(_ref9, scrollLeft) {
    
  1887.     var columnWidth = _ref9.columnWidth,
    
  1888.         columnCount = _ref9.columnCount;
    
  1889.     return Math.max(0, Math.min(columnCount - 1, Math.floor(scrollLeft / columnWidth)));
    
  1890.   },
    
  1891.   getColumnStopIndexForStartIndex: function getColumnStopIndexForStartIndex(_ref10, startIndex, scrollLeft) {
    
  1892.     var columnWidth = _ref10.columnWidth,
    
  1893.         columnCount = _ref10.columnCount,
    
  1894.         width = _ref10.width;
    
  1895.     var left = startIndex * columnWidth;
    
  1896.     var numVisibleColumns = Math.ceil((width + scrollLeft - left) / columnWidth);
    
  1897.     return Math.max(0, Math.min(columnCount - 1, startIndex + numVisibleColumns - 1 // -1 is because stop index is inclusive
    
  1898.     ));
    
  1899.   },
    
  1900.   getRowStartIndexForOffset: function getRowStartIndexForOffset(_ref11, scrollTop) {
    
  1901.     var rowHeight = _ref11.rowHeight,
    
  1902.         rowCount = _ref11.rowCount;
    
  1903.     return Math.max(0, Math.min(rowCount - 1, Math.floor(scrollTop / rowHeight)));
    
  1904.   },
    
  1905.   getRowStopIndexForStartIndex: function getRowStopIndexForStartIndex(_ref12, startIndex, scrollTop) {
    
  1906.     var rowHeight = _ref12.rowHeight,
    
  1907.         rowCount = _ref12.rowCount,
    
  1908.         height = _ref12.height;
    
  1909.     var top = startIndex * rowHeight;
    
  1910.     var numVisibleRows = Math.ceil((height + scrollTop - top) / rowHeight);
    
  1911.     return Math.max(0, Math.min(rowCount - 1, startIndex + numVisibleRows - 1 // -1 is because stop index is inclusive
    
  1912.     ));
    
  1913.   },
    
  1914.   initInstanceProps: function initInstanceProps(props) {// Noop
    
  1915.   },
    
  1916.   shouldResetStyleCacheOnItemSizeChange: true,
    
  1917.   validateProps: function validateProps(_ref13) {
    
  1918.     var columnWidth = _ref13.columnWidth,
    
  1919.         rowHeight = _ref13.rowHeight;
    
  1920. 
    
  1921.     if (process.env.NODE_ENV !== 'production') {
    
  1922.       if (typeof columnWidth !== 'number') {
    
  1923.         throw Error('An invalid "columnWidth" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (columnWidth === null ? 'null' : typeof columnWidth) + "\" was specified."));
    
  1924.       }
    
  1925. 
    
  1926.       if (typeof rowHeight !== 'number') {
    
  1927.         throw Error('An invalid "rowHeight" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (rowHeight === null ? 'null' : typeof rowHeight) + "\" was specified."));
    
  1928.       }
    
  1929.     }
    
  1930.   }
    
  1931. });
    
  1932. 
    
  1933. var FixedSizeList =
    
  1934. /*#__PURE__*/
    
  1935. createListComponent({
    
  1936.   getItemOffset: function getItemOffset(_ref, index) {
    
  1937.     var itemSize = _ref.itemSize;
    
  1938.     return index * itemSize;
    
  1939.   },
    
  1940.   getItemSize: function getItemSize(_ref2, index) {
    
  1941.     var itemSize = _ref2.itemSize;
    
  1942.     return itemSize;
    
  1943.   },
    
  1944.   getEstimatedTotalSize: function getEstimatedTotalSize(_ref3) {
    
  1945.     var itemCount = _ref3.itemCount,
    
  1946.         itemSize = _ref3.itemSize;
    
  1947.     return itemSize * itemCount;
    
  1948.   },
    
  1949.   getOffsetForIndexAndAlignment: function getOffsetForIndexAndAlignment(_ref4, index, align, scrollOffset) {
    
  1950.     var direction = _ref4.direction,
    
  1951.         height = _ref4.height,
    
  1952.         itemCount = _ref4.itemCount,
    
  1953.         itemSize = _ref4.itemSize,
    
  1954.         layout = _ref4.layout,
    
  1955.         width = _ref4.width;
    
  1956.     // TODO Deprecate direction "horizontal"
    
  1957.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  1958.     var size = isHorizontal ? width : height;
    
  1959.     var lastItemOffset = Math.max(0, itemCount * itemSize - size);
    
  1960.     var maxOffset = Math.min(lastItemOffset, index * itemSize);
    
  1961.     var minOffset = Math.max(0, index * itemSize - size + itemSize);
    
  1962. 
    
  1963.     if (align === 'smart') {
    
  1964.       if (scrollOffset >= minOffset - size && scrollOffset <= maxOffset + size) {
    
  1965.         align = 'auto';
    
  1966.       } else {
    
  1967.         align = 'center';
    
  1968.       }
    
  1969.     }
    
  1970. 
    
  1971.     switch (align) {
    
  1972.       case 'start':
    
  1973.         return maxOffset;
    
  1974. 
    
  1975.       case 'end':
    
  1976.         return minOffset;
    
  1977. 
    
  1978.       case 'center':
    
  1979.         {
    
  1980.           // "Centered" offset is usually the average of the min and max.
    
  1981.           // But near the edges of the list, this doesn't hold true.
    
  1982.           var middleOffset = Math.round(minOffset + (maxOffset - minOffset) / 2);
    
  1983. 
    
  1984.           if (middleOffset < Math.ceil(size / 2)) {
    
  1985.             return 0; // near the beginning
    
  1986.           } else if (middleOffset > lastItemOffset + Math.floor(size / 2)) {
    
  1987.             return lastItemOffset; // near the end
    
  1988.           } else {
    
  1989.             return middleOffset;
    
  1990.           }
    
  1991.         }
    
  1992. 
    
  1993.       case 'auto':
    
  1994.       default:
    
  1995.         if (scrollOffset >= minOffset && scrollOffset <= maxOffset) {
    
  1996.           return scrollOffset;
    
  1997.         } else if (scrollOffset < minOffset) {
    
  1998.           return minOffset;
    
  1999.         } else {
    
  2000.           return maxOffset;
    
  2001.         }
    
  2002. 
    
  2003.     }
    
  2004.   },
    
  2005.   getStartIndexForOffset: function getStartIndexForOffset(_ref5, offset) {
    
  2006.     var itemCount = _ref5.itemCount,
    
  2007.         itemSize = _ref5.itemSize;
    
  2008.     return Math.max(0, Math.min(itemCount - 1, Math.floor(offset / itemSize)));
    
  2009.   },
    
  2010.   getStopIndexForStartIndex: function getStopIndexForStartIndex(_ref6, startIndex, scrollOffset) {
    
  2011.     var direction = _ref6.direction,
    
  2012.         height = _ref6.height,
    
  2013.         itemCount = _ref6.itemCount,
    
  2014.         itemSize = _ref6.itemSize,
    
  2015.         layout = _ref6.layout,
    
  2016.         width = _ref6.width;
    
  2017.     // TODO Deprecate direction "horizontal"
    
  2018.     var isHorizontal = direction === 'horizontal' || layout === 'horizontal';
    
  2019.     var offset = startIndex * itemSize;
    
  2020.     var size = isHorizontal ? width : height;
    
  2021.     var numVisibleItems = Math.ceil((size + scrollOffset - offset) / itemSize);
    
  2022.     return Math.max(0, Math.min(itemCount - 1, startIndex + numVisibleItems - 1 // -1 is because stop index is inclusive
    
  2023.     ));
    
  2024.   },
    
  2025.   initInstanceProps: function initInstanceProps(props) {// Noop
    
  2026.   },
    
  2027.   shouldResetStyleCacheOnItemSizeChange: true,
    
  2028.   validateProps: function validateProps(_ref7) {
    
  2029.     var itemSize = _ref7.itemSize;
    
  2030. 
    
  2031.     if (process.env.NODE_ENV !== 'production') {
    
  2032.       if (typeof itemSize !== 'number') {
    
  2033.         throw Error('An invalid "itemSize" prop has been specified. ' + 'Value should be a number. ' + ("\"" + (itemSize === null ? 'null' : typeof itemSize) + "\" was specified."));
    
  2034.       }
    
  2035.     }
    
  2036.   }
    
  2037. });
    
  2038. 
    
  2039. // Pulled from react-compat
    
  2040. // https://github.com/developit/preact-compat/blob/7c5de00e7c85e2ffd011bf3af02899b63f699d3a/src/index.js#L349
    
  2041. function shallowDiffers(prev, next) {
    
  2042.   for (var attribute in prev) {
    
  2043.     if (!(attribute in next)) {
    
  2044.       return true;
    
  2045.     }
    
  2046.   }
    
  2047. 
    
  2048.   for (var _attribute in next) {
    
  2049.     if (prev[_attribute] !== next[_attribute]) {
    
  2050.       return true;
    
  2051.     }
    
  2052.   }
    
  2053. 
    
  2054.   return false;
    
  2055. }
    
  2056. 
    
  2057. // It knows to compare individual style props and ignore the wrapper object.
    
  2058. // See https://reactjs.org/docs/react-api.html#reactmemo
    
  2059. 
    
  2060. function areEqual(prevProps, nextProps) {
    
  2061.   var prevStyle = prevProps.style,
    
  2062.       prevRest = _objectWithoutPropertiesLoose(prevProps, ["style"]);
    
  2063. 
    
  2064.   var nextStyle = nextProps.style,
    
  2065.       nextRest = _objectWithoutPropertiesLoose(nextProps, ["style"]);
    
  2066. 
    
  2067.   return !shallowDiffers(prevStyle, nextStyle) && !shallowDiffers(prevRest, nextRest);
    
  2068. }
    
  2069. 
    
  2070. // It knows to compare individual style props and ignore the wrapper object.
    
  2071. // See https://reactjs.org/docs/react-component.html#shouldcomponentupdate
    
  2072. 
    
  2073. function shouldComponentUpdate(nextProps, nextState) {
    
  2074.   return !areEqual(this.props, nextProps) || shallowDiffers(this.state, nextState);
    
  2075. }
    
  2076. 
    
  2077. export { VariableSizeGrid, VariableSizeList, FixedSizeGrid, FixedSizeList, areEqual, shouldComponentUpdate };
    
  2078. //# sourceMappingURL=index.esm.js.map