react-virtualized
Version:
React components for efficiently rendering large, scrollable lists and tabular data
748 lines (741 loc) • 300 kB
JavaScript
!function(global, factory) {
"object" == typeof exports && "undefined" != typeof module ? factory(exports, require("react"), require("react-dom")) : "function" == typeof define && define.amd ? define([ "exports", "react", "react-dom" ], factory) : factory((global = global || self).ReactVirtualized = {}, global.React, global.ReactDOM);
}(this, function(exports, React, ReactDOM) {
"use strict";
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0,
"value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps),
Constructor;
}
function _defineProperty(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj[key] = value, obj;
}
function _extends() {
return (_extends = Object.assign || function(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) Object.prototype.hasOwnProperty.call(source, key) && (target[key] = source[key]);
}
return target;
}).apply(this, arguments);
}
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
enumerableOnly && (symbols = symbols.filter(function(sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
})), keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = null != arguments[i] ? arguments[i] : {};
i % 2 ? ownKeys(source, !0).forEach(function(key) {
_defineProperty(target, key, source[key]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(source).forEach(function(key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
return target;
}
function _inherits(subClass, superClass) {
if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function");
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: !0,
configurable: !0
}
}), superClass && _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(o) {
return o.__proto__ || Object.getPrototypeOf(o);
})(o);
}
function _setPrototypeOf(o, p) {
return (_setPrototypeOf = Object.setPrototypeOf || function(o, p) {
return o.__proto__ = p, o;
})(o, p);
}
function _objectWithoutProperties(source, excluded) {
if (null == source) return {};
var key, i, target = function(source, excluded) {
if (null == source) return {};
var key, i, target = {}, sourceKeys = Object.keys(source);
for (i = 0; i < sourceKeys.length; i++) key = sourceKeys[i], 0 <= excluded.indexOf(key) || (target[key] = source[key]);
return target;
}(source, excluded);
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) key = sourceSymbolKeys[i], 0 <= excluded.indexOf(key) || Object.prototype.propertyIsEnumerable.call(source, key) && (target[key] = source[key]);
}
return target;
}
function _assertThisInitialized(self) {
if (void 0 === self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return self;
}
function _possibleConstructorReturn(self, call) {
return !call || "object" != typeof call && "function" != typeof call ? _assertThisInitialized(self) : call;
}
function _slicedToArray(arr, i) {
return function(arr) {
if (Array.isArray(arr)) return arr;
}(arr) || function(arr, i) {
if (!(Symbol.iterator in Object(arr) || "[object Arguments]" === Object.prototype.toString.call(arr))) return;
var _arr = [], _n = !0, _d = !1, _e = void 0;
try {
for (var _s, _i = arr[Symbol.iterator](); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value),
!i || _arr.length !== i); _n = !0) ;
} catch (err) {
_d = !0, _e = err;
} finally {
try {
_n || null == _i.return || _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}(arr, i) || function() {
throw new TypeError("Invalid attempt to destructure non-iterable instance");
}
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/ ();
}
function _toConsumableArray(arr) {
return function(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
}
}(arr) || function(iter) {
if (Symbol.iterator in Object(iter) || "[object Arguments]" === Object.prototype.toString.call(iter)) return Array.from(iter);
}(arr) || function() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}();
}
function componentWillMount() {
// Call this.constructor.gDSFP to support sub-classes.
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
null != state && this.setState(state);
}
function componentWillReceiveProps(nextProps) {
// Binding "this" is important for shallow renderer support.
this.setState(
// Call this.constructor.gDSFP to support sub-classes.
// Use the setState() updater to ensure state isn't stale in certain edge cases.
function(prevState) {
var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
return null != state ? state : null;
}.bind(this));
}
function componentWillUpdate(nextProps, nextState) {
try {
var prevProps = this.props, prevState = this.state;
this.props = nextProps, this.state = nextState, this.__reactInternalSnapshotFlag = !0,
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(prevProps, prevState);
} finally {
this.props = prevProps, this.state = prevState;
}
}
// React may warn about cWM/cWRP/cWU methods being deprecated.
// Add a flag to suppress these warnings for this special case.
function polyfill(Component) {
var prototype = Component.prototype;
if (!prototype || !prototype.isReactComponent) throw new Error("Can only polyfill class components");
if ("function" != typeof Component.getDerivedStateFromProps && "function" != typeof prototype.getSnapshotBeforeUpdate) return Component;
// If new component APIs are defined, "unsafe" lifecycles won't be called.
// Error if any of these lifecycles are present,
// Because they would work differently between older and newer (16.3+) versions of React.
var foundWillMountName = null, foundWillReceivePropsName = null, foundWillUpdateName = null;
if ("function" == typeof prototype.componentWillMount ? foundWillMountName = "componentWillMount" : "function" == typeof prototype.UNSAFE_componentWillMount && (foundWillMountName = "UNSAFE_componentWillMount"),
"function" == typeof prototype.componentWillReceiveProps ? foundWillReceivePropsName = "componentWillReceiveProps" : "function" == typeof prototype.UNSAFE_componentWillReceiveProps && (foundWillReceivePropsName = "UNSAFE_componentWillReceiveProps"),
"function" == typeof prototype.componentWillUpdate ? foundWillUpdateName = "componentWillUpdate" : "function" == typeof prototype.UNSAFE_componentWillUpdate && (foundWillUpdateName = "UNSAFE_componentWillUpdate"),
null !== foundWillMountName || null !== foundWillReceivePropsName || null !== foundWillUpdateName) {
var componentName = Component.displayName || Component.name, newApiName = "function" == typeof Component.getDerivedStateFromProps ? "getDerivedStateFromProps()" : "getSnapshotBeforeUpdate()";
throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n" + componentName + " uses " + newApiName + " but also contains the following legacy lifecycles:" + (null !== foundWillMountName ? "\n " + foundWillMountName : "") + (null !== foundWillReceivePropsName ? "\n " + foundWillReceivePropsName : "") + (null !== foundWillUpdateName ? "\n " + foundWillUpdateName : "") + "\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks");
}
// React <= 16.2 does not support static getDerivedStateFromProps.
// As a workaround, use cWM and cWRP to invoke the new static lifecycle.
// Newer versions of React will ignore these lifecycles if gDSFP exists.
// React <= 16.2 does not support getSnapshotBeforeUpdate.
// As a workaround, use cWU to invoke the new lifecycle.
// Newer versions of React will ignore that lifecycle if gSBU exists.
if ("function" == typeof Component.getDerivedStateFromProps && (prototype.componentWillMount = componentWillMount,
prototype.componentWillReceiveProps = componentWillReceiveProps), "function" == typeof prototype.getSnapshotBeforeUpdate) {
if ("function" != typeof prototype.componentDidUpdate) throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");
prototype.componentWillUpdate = componentWillUpdate;
var componentDidUpdate = prototype.componentDidUpdate;
prototype.componentDidUpdate = function(prevProps, prevState, maybeSnapshot) {
// 16.3+ will not execute our will-update method;
// It will pass a snapshot value to did-update though.
// Older versions will require our polyfilled will-update value.
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
// Because for <= 15.x versions this might be a "prevContext" object.
// We also can't just check "__reactInternalSnapshot",
// Because get-snapshot might return a falsy value.
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
var snapshot = this.__reactInternalSnapshotFlag ? this.__reactInternalSnapshot : maybeSnapshot;
componentDidUpdate.call(this, prevProps, prevState, snapshot);
};
}
return Component;
}
componentWillUpdate.__suppressDeprecationWarning = componentWillReceiveProps.__suppressDeprecationWarning = componentWillMount.__suppressDeprecationWarning = !0;
var ArrowKeyStepper = function() {
function ArrowKeyStepper() {
var _getPrototypeOf2, _this;
_classCallCheck(this, ArrowKeyStepper);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _defineProperty(_assertThisInitialized(_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(ArrowKeyStepper)).call.apply(_getPrototypeOf2, [ this ].concat(args)))), "state", {
scrollToColumn: 0,
scrollToRow: 0,
instanceProps: {
prevScrollToColumn: 0,
prevScrollToRow: 0
}
}), _defineProperty(_assertThisInitialized(_this), "_columnStartIndex", 0), _defineProperty(_assertThisInitialized(_this), "_columnStopIndex", 0),
_defineProperty(_assertThisInitialized(_this), "_rowStartIndex", 0), _defineProperty(_assertThisInitialized(_this), "_rowStopIndex", 0),
_defineProperty(_assertThisInitialized(_this), "_onKeyDown", function(event) {
var _this$props = _this.props, columnCount = _this$props.columnCount, disabled = _this$props.disabled, mode = _this$props.mode, rowCount = _this$props.rowCount;
if (!disabled) {
var _this$_getScrollState = _this._getScrollState(), scrollToColumnPrevious = _this$_getScrollState.scrollToColumn, scrollToRowPrevious = _this$_getScrollState.scrollToRow, _this$_getScrollState2 = _this._getScrollState(), scrollToColumn = _this$_getScrollState2.scrollToColumn, scrollToRow = _this$_getScrollState2.scrollToRow;
switch (event.key) {
case "ArrowDown":
scrollToRow = "cells" === mode ? Math.min(scrollToRow + 1, rowCount - 1) : Math.min(_this._rowStopIndex + 1, rowCount - 1);
break;
case "ArrowLeft":
scrollToColumn = "cells" === mode ? Math.max(scrollToColumn - 1, 0) : Math.max(_this._columnStartIndex - 1, 0);
break;
case "ArrowRight":
scrollToColumn = "cells" === mode ? Math.min(scrollToColumn + 1, columnCount - 1) : Math.min(_this._columnStopIndex + 1, columnCount - 1);
break;
case "ArrowUp":
scrollToRow = "cells" === mode ? Math.max(scrollToRow - 1, 0) : Math.max(_this._rowStartIndex - 1, 0);
}
scrollToColumn === scrollToColumnPrevious && scrollToRow === scrollToRowPrevious || (event.preventDefault(),
_this._updateScrollState({
scrollToColumn: scrollToColumn,
scrollToRow: scrollToRow
}));
}
}), _defineProperty(_assertThisInitialized(_this), "_onSectionRendered", function(_ref) {
var columnStartIndex = _ref.columnStartIndex, columnStopIndex = _ref.columnStopIndex, rowStartIndex = _ref.rowStartIndex, rowStopIndex = _ref.rowStopIndex;
_this._columnStartIndex = columnStartIndex, _this._columnStopIndex = columnStopIndex,
_this._rowStartIndex = rowStartIndex, _this._rowStopIndex = rowStopIndex;
}), _this;
}
return _inherits(ArrowKeyStepper, React.PureComponent), _createClass(ArrowKeyStepper, [ {
key: "setScrollIndexes",
value: function(_ref2) {
var scrollToColumn = _ref2.scrollToColumn, scrollToRow = _ref2.scrollToRow;
this.setState({
scrollToRow: scrollToRow,
scrollToColumn: scrollToColumn
});
}
}, {
key: "render",
value: function() {
var _this$props2 = this.props, className = _this$props2.className, children = _this$props2.children, _this$_getScrollState3 = this._getScrollState(), scrollToColumn = _this$_getScrollState3.scrollToColumn, scrollToRow = _this$_getScrollState3.scrollToRow;
return React.createElement("div", {
className: className,
onKeyDown: this._onKeyDown
}, children({
onSectionRendered: this._onSectionRendered,
scrollToColumn: scrollToColumn,
scrollToRow: scrollToRow
}));
}
}, {
key: "_getScrollState",
value: function() {
return this.props.isControlled ? this.props : this.state;
}
}, {
key: "_updateScrollState",
value: function(_ref3) {
var scrollToColumn = _ref3.scrollToColumn, scrollToRow = _ref3.scrollToRow, _this$props3 = this.props, isControlled = _this$props3.isControlled, onScrollToChange = _this$props3.onScrollToChange;
"function" == typeof onScrollToChange && onScrollToChange({
scrollToColumn: scrollToColumn,
scrollToRow: scrollToRow
}), isControlled || this.setState({
scrollToColumn: scrollToColumn,
scrollToRow: scrollToRow
});
}
} ], [ {
key: "getDerivedStateFromProps",
value: function(nextProps, prevState) {
return nextProps.isControlled ? {} : nextProps.scrollToColumn !== prevState.instanceProps.prevScrollToColumn || nextProps.scrollToRow !== prevState.instanceProps.prevScrollToRow ? _objectSpread2({}, prevState, {
scrollToColumn: nextProps.scrollToColumn,
scrollToRow: nextProps.scrollToRow,
instanceProps: {
prevScrollToColumn: nextProps.scrollToColumn,
prevScrollToRow: nextProps.scrollToRow
}
}) : {};
}
} ]), ArrowKeyStepper;
}();
function createDetectElementResize(nonce, hostWindow) {
var _window, cancel, raf, attachEvent = void 0 !== (_window = void 0 !== hostWindow ? hostWindow : "undefined" != typeof window ? window : "undefined" != typeof self ? self : global).document && _window.document.attachEvent;
if (!attachEvent) {
var requestFrame = (raf = _window.requestAnimationFrame || _window.mozRequestAnimationFrame || _window.webkitRequestAnimationFrame || function(fn) {
return _window.setTimeout(fn, 20);
}, function(fn) {
return raf(fn);
}), cancelFrame = (cancel = _window.cancelAnimationFrame || _window.mozCancelAnimationFrame || _window.webkitCancelAnimationFrame || _window.clearTimeout,
function(id) {
return cancel(id);
}), resetTriggers = function(element) {
var triggers = element.__resizeTriggers__, expand = triggers.firstElementChild, contract = triggers.lastElementChild, expandChild = expand.firstElementChild;
contract.scrollLeft = contract.scrollWidth, contract.scrollTop = contract.scrollHeight,
expandChild.style.width = expand.offsetWidth + 1 + "px", expandChild.style.height = expand.offsetHeight + 1 + "px",
expand.scrollLeft = expand.scrollWidth, expand.scrollTop = expand.scrollHeight;
}, scrollListener = function(e) {
if (!(e.target.className && "function" == typeof e.target.className.indexOf && e.target.className.indexOf("contract-trigger") < 0 && e.target.className.indexOf("expand-trigger") < 0)) {
var element = this;
resetTriggers(this), this.__resizeRAF__ && cancelFrame(this.__resizeRAF__), this.__resizeRAF__ = requestFrame(function() {
!function(element) {
return element.offsetWidth != element.__resizeLast__.width || element.offsetHeight != element.__resizeLast__.height;
}(element) || (element.__resizeLast__.width = element.offsetWidth, element.__resizeLast__.height = element.offsetHeight,
element.__resizeListeners__.forEach(function(fn) {
fn.call(element, e);
}));
});
}
}, animation = !1, keyframeprefix = "", animationstartevent = "animationstart", domPrefixes = "Webkit Moz O ms".split(" "), startEvents = "webkitAnimationStart animationstart oAnimationStart MSAnimationStart".split(" "), elm = _window.document.createElement("fakeelement");
if (void 0 !== elm.style.animationName && (animation = !0), !1 === animation) for (var i = 0; i < domPrefixes.length; i++) if (void 0 !== elm.style[domPrefixes[i] + "AnimationName"]) {
keyframeprefix = "-" + domPrefixes[i].toLowerCase() + "-", animationstartevent = startEvents[i],
animation = !0;
break;
}
var animationName = "resizeanim", animationKeyframes = "@" + keyframeprefix + "keyframes " + animationName + " { from { opacity: 0; } to { opacity: 0; } } ", animationStyle = keyframeprefix + "animation: 1ms " + animationName + "; ";
}
return {
addResizeListener: function(element, fn) {
if (attachEvent) element.attachEvent("onresize", fn); else {
if (!element.__resizeTriggers__) {
var doc = element.ownerDocument, elementStyle = _window.getComputedStyle(element);
elementStyle && "static" == elementStyle.position && (element.style.position = "relative"),
function(doc) {
if (!doc.getElementById("detectElementResize")) {
var css = (animationKeyframes || "") + ".resize-triggers { " + (animationStyle || "") + 'visibility: hidden; opacity: 0; } .resize-triggers, .resize-triggers > div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; z-index: -1; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }', head = doc.head || doc.getElementsByTagName("head")[0], style = doc.createElement("style");
style.id = "detectElementResize", style.type = "text/css", null != nonce && style.setAttribute("nonce", nonce),
style.styleSheet ? style.styleSheet.cssText = css : style.appendChild(doc.createTextNode(css)),
head.appendChild(style);
}
}(doc), element.__resizeLast__ = {}, element.__resizeListeners__ = [], (element.__resizeTriggers__ = doc.createElement("div")).className = "resize-triggers";
var resizeTriggersHtml = '<div class="expand-trigger"><div></div></div><div class="contract-trigger"></div>';
if (window.trustedTypes) {
var staticPolicy = trustedTypes.createPolicy("react-virtualized-auto-sizer", {
createHTML: function() {
return resizeTriggersHtml;
}
});
element.__resizeTriggers__.innerHTML = staticPolicy.createHTML("");
} else element.__resizeTriggers__.innerHTML = resizeTriggersHtml;
element.appendChild(element.__resizeTriggers__), resetTriggers(element), element.addEventListener("scroll", scrollListener, !0),
animationstartevent && (element.__resizeTriggers__.__animationListener__ = function(e) {
e.animationName == animationName && resetTriggers(element);
}, element.__resizeTriggers__.addEventListener(animationstartevent, element.__resizeTriggers__.__animationListener__));
}
element.__resizeListeners__.push(fn);
}
},
removeResizeListener: function(element, fn) {
if (attachEvent) element.detachEvent("onresize", fn); else if (element.__resizeListeners__.splice(element.__resizeListeners__.indexOf(fn), 1),
!element.__resizeListeners__.length) {
element.removeEventListener("scroll", scrollListener, !0), element.__resizeTriggers__.__animationListener__ && (element.__resizeTriggers__.removeEventListener(animationstartevent, element.__resizeTriggers__.__animationListener__),
element.__resizeTriggers__.__animationListener__ = null);
try {
element.__resizeTriggers__ = !element.removeChild(element.__resizeTriggers__);
} catch (e) {}
}
}
};
}
_defineProperty(ArrowKeyStepper, "defaultProps", {
disabled: !1,
isControlled: !1,
mode: "edges",
scrollToColumn: 0,
scrollToRow: 0
}), polyfill(ArrowKeyStepper);
var AutoSizer = function() {
function AutoSizer() {
var _getPrototypeOf2, _this;
_classCallCheck(this, AutoSizer);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _defineProperty(_assertThisInitialized(_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(AutoSizer)).call.apply(_getPrototypeOf2, [ this ].concat(args)))), "state", {
height: _this.props.defaultHeight || 0,
width: _this.props.defaultWidth || 0
}), _defineProperty(_assertThisInitialized(_this), "_parentNode", void 0), _defineProperty(_assertThisInitialized(_this), "_autoSizer", void 0),
_defineProperty(_assertThisInitialized(_this), "_window", void 0), _defineProperty(_assertThisInitialized(_this), "_detectElementResize", void 0),
_defineProperty(_assertThisInitialized(_this), "_onResize", function() {
var _this$props = _this.props, disableHeight = _this$props.disableHeight, disableWidth = _this$props.disableWidth, onResize = _this$props.onResize;
if (_this._parentNode) {
var height = _this._parentNode.offsetHeight || 0, width = _this._parentNode.offsetWidth || 0, style = (_this._window || window).getComputedStyle(_this._parentNode) || {}, paddingLeft = parseInt(style.paddingLeft, 10) || 0, paddingRight = parseInt(style.paddingRight, 10) || 0, paddingTop = parseInt(style.paddingTop, 10) || 0, paddingBottom = parseInt(style.paddingBottom, 10) || 0, newHeight = height - paddingTop - paddingBottom, newWidth = width - paddingLeft - paddingRight;
(!disableHeight && _this.state.height !== newHeight || !disableWidth && _this.state.width !== newWidth) && (_this.setState({
height: height - paddingTop - paddingBottom,
width: width - paddingLeft - paddingRight
}), onResize({
height: height,
width: width
}));
}
}), _defineProperty(_assertThisInitialized(_this), "_setRef", function(autoSizer) {
_this._autoSizer = autoSizer;
}), _this;
}
return _inherits(AutoSizer, React.Component), _createClass(AutoSizer, [ {
key: "componentDidMount",
value: function() {
var nonce = this.props.nonce;
this._autoSizer && this._autoSizer.parentNode && this._autoSizer.parentNode.ownerDocument && this._autoSizer.parentNode.ownerDocument.defaultView && this._autoSizer.parentNode instanceof this._autoSizer.parentNode.ownerDocument.defaultView.HTMLElement && (this._parentNode = this._autoSizer.parentNode,
this._window = this._autoSizer.parentNode.ownerDocument.defaultView, this._detectElementResize = createDetectElementResize(nonce, this._window),
this._detectElementResize.addResizeListener(this._parentNode, this._onResize), this._onResize());
}
}, {
key: "componentWillUnmount",
value: function() {
this._detectElementResize && this._parentNode && this._detectElementResize.removeResizeListener(this._parentNode, this._onResize);
}
}, {
key: "render",
value: function() {
var _this$props2 = this.props, children = _this$props2.children, className = _this$props2.className, disableHeight = _this$props2.disableHeight, disableWidth = _this$props2.disableWidth, style = _this$props2.style, _this$state = this.state, height = _this$state.height, width = _this$state.width, outerStyle = {
overflow: "visible"
}, childParams = {};
return disableHeight || (outerStyle.height = 0, childParams.height = height), disableWidth || (outerStyle.width = 0,
childParams.width = width), React.createElement("div", {
className: className,
ref: this._setRef,
style: _objectSpread2({}, outerStyle, {}, style)
}, children(childParams));
}
} ]), AutoSizer;
}();
_defineProperty(AutoSizer, "defaultProps", {
onResize: function() {},
disableHeight: !1,
disableWidth: !1,
style: {}
});
var CellMeasurer = function() {
function CellMeasurer() {
var _getPrototypeOf2, _this;
_classCallCheck(this, CellMeasurer);
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _defineProperty(_assertThisInitialized(_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(CellMeasurer)).call.apply(_getPrototypeOf2, [ this ].concat(args)))), "_child", void 0),
_defineProperty(_assertThisInitialized(_this), "_measure", function() {
var _this$props = _this.props, cache = _this$props.cache, _this$props$columnInd = _this$props.columnIndex, columnIndex = void 0 === _this$props$columnInd ? 0 : _this$props$columnInd, parent = _this$props.parent, _this$props$rowIndex = _this$props.rowIndex, rowIndex = void 0 === _this$props$rowIndex ? _this.props.index || 0 : _this$props$rowIndex, _this$_getCellMeasure = _this._getCellMeasurements(), height = _this$_getCellMeasure.height, width = _this$_getCellMeasure.width;
height === cache.getHeight(rowIndex, columnIndex) && width === cache.getWidth(rowIndex, columnIndex) || (cache.set(rowIndex, columnIndex, width, height),
parent && "function" == typeof parent.recomputeGridSize && parent.recomputeGridSize({
columnIndex: columnIndex,
rowIndex: rowIndex
}));
}), _defineProperty(_assertThisInitialized(_this), "_registerChild", function(element) {
!element || element instanceof Element || console.warn("CellMeasurer registerChild expects to be passed Element or null"),
(_this._child = element) && _this._maybeMeasureCell();
}), _this;
}
return _inherits(CellMeasurer, React.PureComponent), _createClass(CellMeasurer, [ {
key: "componentDidMount",
value: function() {
this._maybeMeasureCell();
}
}, {
key: "componentDidUpdate",
value: function() {
this._maybeMeasureCell();
}
}, {
key: "render",
value: function() {
var children = this.props.children;
return "function" == typeof children ? children({
measure: this._measure,
registerChild: this._registerChild
}) : children;
}
}, {
key: "_getCellMeasurements",
value: function() {
var cache = this.props.cache, node = this._child || ReactDOM.findDOMNode(this);
if (node && node.ownerDocument && node.ownerDocument.defaultView && node instanceof node.ownerDocument.defaultView.HTMLElement) {
var styleWidth = node.style.width, styleHeight = node.style.height;
cache.hasFixedWidth() || (node.style.width = "auto"), cache.hasFixedHeight() || (node.style.height = "auto");
var height = Math.ceil(node.offsetHeight), width = Math.ceil(node.offsetWidth);
return styleWidth && (node.style.width = styleWidth), styleHeight && (node.style.height = styleHeight),
{
height: height,
width: width
};
}
return {
height: 0,
width: 0
};
}
}, {
key: "_maybeMeasureCell",
value: function() {
var _this$props2 = this.props, cache = _this$props2.cache, _this$props2$columnIn = _this$props2.columnIndex, columnIndex = void 0 === _this$props2$columnIn ? 0 : _this$props2$columnIn, parent = _this$props2.parent, _this$props2$rowIndex = _this$props2.rowIndex, rowIndex = void 0 === _this$props2$rowIndex ? this.props.index || 0 : _this$props2$rowIndex;
if (!cache.has(rowIndex, columnIndex)) {
var _this$_getCellMeasure2 = this._getCellMeasurements(), height = _this$_getCellMeasure2.height, width = _this$_getCellMeasure2.width;
cache.set(rowIndex, columnIndex, width, height), parent && "function" == typeof parent.invalidateCellSizeAfterRender && parent.invalidateCellSizeAfterRender({
columnIndex: columnIndex,
rowIndex: rowIndex
});
}
}
} ]), CellMeasurer;
}();
_defineProperty(CellMeasurer, "__internalCellMeasurerFlag", !1), CellMeasurer.__internalCellMeasurerFlag = !0;
var CellMeasurerCache = function() {
function CellMeasurerCache() {
var _this = this, params = 0 < arguments.length && void 0 !== arguments[0] ? arguments[0] : {};
_classCallCheck(this, CellMeasurerCache), _defineProperty(this, "_cellHeightCache", {}),
_defineProperty(this, "_cellWidthCache", {}), _defineProperty(this, "_columnWidthCache", {}),
_defineProperty(this, "_rowHeightCache", {}), _defineProperty(this, "_defaultHeight", void 0),
_defineProperty(this, "_defaultWidth", void 0), _defineProperty(this, "_minHeight", void 0),
_defineProperty(this, "_minWidth", void 0), _defineProperty(this, "_keyMapper", void 0),
_defineProperty(this, "_hasFixedHeight", void 0), _defineProperty(this, "_hasFixedWidth", void 0),
_defineProperty(this, "_columnCount", 0), _defineProperty(this, "_rowCount", 0),
_defineProperty(this, "columnWidth", function(_ref) {
var index = _ref.index, key = _this._keyMapper(0, index);
return void 0 !== _this._columnWidthCache[key] ? _this._columnWidthCache[key] : _this._defaultWidth;
}), _defineProperty(this, "rowHeight", function(_ref2) {
var index = _ref2.index, key = _this._keyMapper(index, 0);
return void 0 !== _this._rowHeightCache[key] ? _this._rowHeightCache[key] : _this._defaultHeight;
});
var defaultHeight = params.defaultHeight, defaultWidth = params.defaultWidth, fixedHeight = params.fixedHeight, fixedWidth = params.fixedWidth, keyMapper = params.keyMapper, minHeight = params.minHeight, minWidth = params.minWidth;
this._hasFixedHeight = !0 === fixedHeight, this._hasFixedWidth = !0 === fixedWidth,
this._minHeight = minHeight || 0, this._minWidth = minWidth || 0, this._keyMapper = keyMapper || defaultKeyMapper,
this._defaultHeight = Math.max(this._minHeight, "number" == typeof defaultHeight ? defaultHeight : 30),
this._defaultWidth = Math.max(this._minWidth, "number" == typeof defaultWidth ? defaultWidth : 100),
!1 === this._hasFixedHeight && !1 === this._hasFixedWidth && console.warn("CellMeasurerCache should only measure a cell's width or height. You have configured CellMeasurerCache to measure both. This will result in poor performance."),
!1 === this._hasFixedHeight && 0 === this._defaultHeight && console.warn("Fixed height CellMeasurerCache should specify a :defaultHeight greater than 0. Failing to do so will lead to unnecessary layout and poor performance."),
!1 === this._hasFixedWidth && 0 === this._defaultWidth && console.warn("Fixed width CellMeasurerCache should specify a :defaultWidth greater than 0. Failing to do so will lead to unnecessary layout and poor performance.");
}
return _createClass(CellMeasurerCache, [ {
key: "clear",
value: function(rowIndex, argument_1) {
var columnIndex = 1 < arguments.length && void 0 !== argument_1 ? argument_1 : 0, key = this._keyMapper(rowIndex, columnIndex);
delete this._cellHeightCache[key], delete this._cellWidthCache[key], this._updateCachedColumnAndRowSizes(rowIndex, columnIndex);
}
}, {
key: "clearAll",
value: function() {
this._cellHeightCache = {}, this._cellWidthCache = {}, this._columnWidthCache = {},
this._rowHeightCache = {}, this._rowCount = 0, this._columnCount = 0;
}
}, {
key: "hasFixedHeight",
value: function() {
return this._hasFixedHeight;
}
}, {
key: "hasFixedWidth",
value: function() {
return this._hasFixedWidth;
}
}, {
key: "getHeight",
value: function(rowIndex, argument_1) {
var columnIndex = 1 < arguments.length && void 0 !== argument_1 ? argument_1 : 0;
if (this._hasFixedHeight) return this._defaultHeight;
var _key = this._keyMapper(rowIndex, columnIndex);
return void 0 !== this._cellHeightCache[_key] ? Math.max(this._minHeight, this._cellHeightCache[_key]) : this._defaultHeight;
}
}, {
key: "getWidth",
value: function(rowIndex, argument_1) {
var columnIndex = 1 < arguments.length && void 0 !== argument_1 ? argument_1 : 0;
if (this._hasFixedWidth) return this._defaultWidth;
var _key2 = this._keyMapper(rowIndex, columnIndex);
return void 0 !== this._cellWidthCache[_key2] ? Math.max(this._minWidth, this._cellWidthCache[_key2]) : this._defaultWidth;
}
}, {
key: "has",
value: function(rowIndex, argument_1) {
var columnIndex = 1 < arguments.length && void 0 !== argument_1 ? argument_1 : 0, key = this._keyMapper(rowIndex, columnIndex);
return void 0 !== this._cellHeightCache[key];
}
}, {
key: "set",
value: function(rowIndex, columnIndex, width, height) {
var key = this._keyMapper(rowIndex, columnIndex);
columnIndex >= this._columnCount && (this._columnCount = columnIndex + 1), rowIndex >= this._rowCount && (this._rowCount = rowIndex + 1),
this._cellHeightCache[key] = height, this._cellWidthCache[key] = width, this._updateCachedColumnAndRowSizes(rowIndex, columnIndex);
}
}, {
key: "_updateCachedColumnAndRowSizes",
value: function(rowIndex, columnIndex) {
if (!this._hasFixedWidth) {
for (var columnWidth = 0, i = 0; i < this._rowCount; i++) columnWidth = Math.max(columnWidth, this.getWidth(i, columnIndex));
var columnKey = this._keyMapper(0, columnIndex);
this._columnWidthCache[columnKey] = columnWidth;
}
if (!this._hasFixedHeight) {
for (var rowHeight = 0, _i = 0; _i < this._columnCount; _i++) rowHeight = Math.max(rowHeight, this.getHeight(rowIndex, _i));
var rowKey = this._keyMapper(rowIndex, 0);
this._rowHeightCache[rowKey] = rowHeight;
}
}
}, {
key: "defaultHeight",
get: function() {
return this._defaultHeight;
}
}, {
key: "defaultWidth",
get: function() {
return this._defaultWidth;
}
} ]), CellMeasurerCache;
}();
function defaultKeyMapper(rowIndex, columnIndex) {
return "".concat(rowIndex, "-").concat(columnIndex);
}
function unwrapExports(x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x.default : x;
}
function createCommonjsModule(fn, module) {
return fn(module = {
exports: {}
}, module.exports), module.exports;
}
var reactIs_production_min = createCommonjsModule(function(module, exports) {
Object.defineProperty(exports, "__esModule", {
value: !0
});
var b = "function" == typeof Symbol && Symbol.for, c = b ? Symbol.for("react.element") : 60103, d = b ? Symbol.for("react.portal") : 60106, e = b ? Symbol.for("react.fragment") : 60107, f = b ? Symbol.for("react.strict_mode") : 60108, g = b ? Symbol.for("react.profiler") : 60114, h = b ? Symbol.for("react.provider") : 60109, k = b ? Symbol.for("react.context") : 60110, l = b ? Symbol.for("react.async_mode") : 60111, m = b ? Symbol.for("react.concurrent_mode") : 60111, n = b ? Symbol.for("react.forward_ref") : 60112, p = b ? Symbol.for("react.suspense") : 60113, q = b ? Symbol.for("react.suspense_list") : 60120, r = b ? Symbol.for("react.memo") : 60115, t = b ? Symbol.for("react.lazy") : 60116, v = b ? Symbol.for("react.fundamental") : 60117, w = b ? Symbol.for("react.responder") : 60118, x = b ? Symbol.for("react.scope") : 60119;
function y(a) {
if ("object" == typeof a && null !== a) {
var u = a.$$typeof;
switch (u) {
case c:
switch (a = a.type) {
case l:
case m:
case e:
case g:
case f:
case p:
return a;
default:
switch (a = a && a.$$typeof) {
case k:
case n:
case h:
return a;
default:
return u;
}
}
case t:
case r:
case d:
return u;
}
}
}
function z(a) {
return y(a) === m;
}
exports.typeOf = y, exports.AsyncMode = l, exports.ConcurrentMode = m, exports.ContextConsumer = k,
exports.ContextProvider = h, exports.Element = c, exports.ForwardRef = n, exports.Fragment = e,
exports.Lazy = t, exports.Memo = r, exports.Portal = d, exports.Profiler = g, exports.StrictMode = f,
exports.Suspense = p, exports.isValidElementType = function(a) {
return "string" == typeof a || "function" == typeof a || a === e || a === m || a === g || a === f || a === p || a === q || "object" == typeof a && null !== a && (a.$$typeof === t || a.$$typeof === r || a.$$typeof === h || a.$$typeof === k || a.$$typeof === n || a.$$typeof === v || a.$$typeof === w || a.$$typeof === x);
}, exports.isAsyncMode = function(a) {
return z(a) || y(a) === l;
}, exports.isConcurrentMode = z, exports.isContextConsumer = function(a) {
return y(a) === k;
}, exports.isContextProvider = function(a) {
return y(a) === h;
}, exports.isElement = function(a) {
return "object" == typeof a && null !== a && a.$$typeof === c;
}, exports.isForwardRef = function(a) {
return y(a) === n;
}, exports.isFragment = function(a) {
return y(a) === e;
}, exports.isLazy = function(a) {
return y(a) === t;
}, exports.isMemo = function(a) {
return y(a) === r;
}, exports.isPortal = function(a) {
return y(a) === d;
}, exports.isProfiler = function(a) {
return y(a) === g;
}, exports.isStrictMode = function(a) {
return y(a) === f;
}, exports.isSuspense = function(a) {
return y(a) === p;
};
});
unwrapExports(reactIs_production_min);
reactIs_production_min.typeOf, reactIs_production_min.AsyncMode, reactIs_production_min.ConcurrentMode,
reactIs_production_min.ContextConsumer, reactIs_production_min.ContextProvider,
reactIs_production_min.Element, reactIs_production_min.ForwardRef, reactIs_production_min.Fragment,
reactIs_production_min.Lazy, reactIs_production_min.Memo, reactIs_production_min.Portal,
reactIs_production_min.Profiler, reactIs_production_min.StrictMode, reactIs_production_min.Suspense,
reactIs_production_min.isValidElementType, reactIs_production_min.isAsyncMode, reactIs_production_min.isConcurrentMode,
reactIs_production_min.isContextConsumer, reactIs_production_min.isContextProvider,
reactIs_production_min.isElement, reactIs_production_min.isForwardRef, reactIs_production_min.isFragment,
reactIs_production_min.isLazy, reactIs_production_min.isMemo, reactIs_production_min.isPortal,
reactIs_production_min.isProfiler, reactIs_production_min.isStrictMode, reactIs_production_min.isSuspense;
var reactIs_development = createCommonjsModule(function(module, exports) {
!function() {
Object.defineProperty(exports, "__esModule", {
value: !0
});
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
// nor polyfill, then a plain number is used for performance.
var hasSymbol = "function" == typeof Symbol && Symbol.for, REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for("react.async_mode") : 60111, REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for("react.suspense_list") : 60120, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for("react.fundamental") : 60117, REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for("react.responder") : 60118, REACT_SCOPE_TYPE = hasSymbol ? Symbol.for("react.scope") : 60119;
/**
* Forked from fbjs/warning:
* https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
*
* Only change is we use console.warn instead of console.error,
* and do nothing when 'console' is not supported.
* This really simplifies the code.
* ---
* Similar to invariant but only logs a warning if the condition is not met.
* This can be used to log issues in development environments in critical
* paths. Removing the logging code for production environments will keep the
* same logic and follow the same code paths.
*/
var lowPriorityWarningWithoutStack$1 = function(condition, format) {
if (void 0 === format) throw new Error("`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning message argument");
if (!condition) {
for (var _len2 = arguments.length, args = new Array(2 < _len2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) args[_key2 - 2] = arguments[_key2];
(function(format) {
for (var _len = arguments.length, args = new Array(1 < _len ? _len - 1 : 0), _key = 1; _key < _len; _key++) args[_key - 1] = arguments[_key];
var argIndex = 0, message = "Warning: " + format.replace(/%s/g, function() {
return args[argIndex++];