react-virtualized
Version:
React components for efficiently rendering large, scrollable lists and tabular data
781 lines (778 loc) • 276 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.ReactVirtualized = {}, global.React, global.ReactDOM);
}(this, function(exports, React, ReactDOM) {
"use strict";
/**
* 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 componentWillMount() {
// Call this.constructor.gDSFP to support sub-classes.
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
null !== state && void 0 !== 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 && void 0 !== 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;
}
componentWillMount.__suppressDeprecationWarning = !0, componentWillReceiveProps.__suppressDeprecationWarning = !0,
componentWillUpdate.__suppressDeprecationWarning = !0;
var classCallCheck = function(instance, Constructor) {
if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function");
}, createClass = 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);
}
}
return function(Constructor, protoProps, staticProps) {
return protoProps && defineProperties(Constructor.prototype, protoProps), staticProps && defineProperties(Constructor, staticProps),
Constructor;
};
}(), defineProperty = function(obj, key, value) {
return key in obj ? Object.defineProperty(obj, key, {
value: value,
enumerable: !0,
configurable: !0,
writable: !0
}) : obj[key] = value, obj;
}, _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;
}, inherits = function(subClass, superClass) {
if ("function" != typeof superClass && null !== superClass) throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: !1,
writable: !0,
configurable: !0
}
}), superClass && (Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass);
}, objectWithoutProperties = function(obj, keys) {
var target = {};
for (var i in obj) keys.indexOf(i) >= 0 || Object.prototype.hasOwnProperty.call(obj, i) && (target[i] = obj[i]);
return target;
}, possibleConstructorReturn = function(self, call) {
if (!self) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
return !call || "object" != typeof call && "function" != typeof call ? self : call;
}, slicedToArray = function() {
return function(arr, i) {
if (Array.isArray(arr)) return arr;
if (Symbol.iterator in Object(arr)) return function(arr, i) {
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 && _i.return && _i.return();
} finally {
if (_d) throw _e;
}
}
return _arr;
}(arr, i);
throw new TypeError("Invalid attempt to destructure non-iterable instance");
};
}(), ArrowKeyStepper = function(_React$PureComponent) {
function ArrowKeyStepper() {
var _ref, _temp, _this;
classCallCheck(this, ArrowKeyStepper);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _temp = _this = possibleConstructorReturn(this, (_ref = ArrowKeyStepper.__proto__ || Object.getPrototypeOf(ArrowKeyStepper)).call.apply(_ref, [ this ].concat(args))),
_this.state = {
scrollToColumn: 0,
scrollToRow: 0
}, _this._columnStartIndex = 0, _this._columnStopIndex = 0, _this._rowStartIndex = 0,
_this._rowStopIndex = 0, _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
}));
}
}, _this._onSectionRendered = function(_ref2) {
var columnStartIndex = _ref2.columnStartIndex, columnStopIndex = _ref2.columnStopIndex, rowStartIndex = _ref2.rowStartIndex, rowStopIndex = _ref2.rowStopIndex;
_this._columnStartIndex = columnStartIndex, _this._columnStopIndex = columnStopIndex,
_this._rowStartIndex = rowStartIndex, _this._rowStopIndex = rowStopIndex;
}, possibleConstructorReturn(_this, _temp);
}
return inherits(ArrowKeyStepper, _React$PureComponent), createClass(ArrowKeyStepper, [ {
key: "setScrollIndexes",
value: function(_ref3) {
var scrollToColumn = _ref3.scrollToColumn, scrollToRow = _ref3.scrollToRow;
this.setState({
scrollToRow: scrollToRow,
scrollToColumn: scrollToColumn
});
}
}, {
key: "render",
value: function() {
var _props = this.props, className = _props.className, children = _props.children, _getScrollState2 = this._getScrollState(), scrollToColumn = _getScrollState2.scrollToColumn, scrollToRow = _getScrollState2.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(_ref4) {
var scrollToColumn = _ref4.scrollToColumn, scrollToRow = _ref4.scrollToRow, _props2 = this.props, isControlled = _props2.isControlled, onScrollToChange = _props2.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 ? null : nextProps.scrollToColumn !== prevState.scrollToColumn || nextProps.scrollToRow !== prevState.scrollToRow ? {
scrollToColumn: nextProps.scrollToColumn,
scrollToRow: nextProps.scrollToRow
} : null;
}
} ]), ArrowKeyStepper;
}(React.PureComponent);
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",
element.__resizeTriggers__.innerHTML = '<div class="expand-trigger"><div></div></div><div class="contract-trigger"></div>',
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) {}
}
}
};
}
ArrowKeyStepper.defaultProps = {
disabled: !1,
isControlled: !1,
mode: "edges",
scrollToColumn: 0,
scrollToRow: 0
}, polyfill(ArrowKeyStepper);
var AutoSizer = function(_React$PureComponent) {
function AutoSizer() {
var _ref, _temp, _this;
classCallCheck(this, AutoSizer);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _temp = _this = possibleConstructorReturn(this, (_ref = AutoSizer.__proto__ || Object.getPrototypeOf(AutoSizer)).call.apply(_ref, [ this ].concat(args))),
_this.state = {
height: _this.props.defaultHeight || 0,
width: _this.props.defaultWidth || 0
}, _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
}));
}
}, _this._setRef = function(autoSizer) {
_this._autoSizer = autoSizer;
}, possibleConstructorReturn(_this, _temp);
}
return inherits(AutoSizer, _React$PureComponent), 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 _props = this.props, children = _props.children, className = _props.className, disableHeight = _props.disableHeight, disableWidth = _props.disableWidth, style = _props.style, _state = this.state, height = _state.height, width = _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: _extends({}, outerStyle, style)
}, children(childParams));
}
} ]), AutoSizer;
}(React.PureComponent);
AutoSizer.defaultProps = {
onResize: function() {},
disableHeight: !1,
disableWidth: !1,
style: {}
};
var CellMeasurer = function(_React$PureComponent) {
function CellMeasurer() {
var _ref, _temp, _this;
classCallCheck(this, CellMeasurer);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) args[_key] = arguments[_key];
return _temp = _this = possibleConstructorReturn(this, (_ref = CellMeasurer.__proto__ || Object.getPrototypeOf(CellMeasurer)).call.apply(_ref, [ this ].concat(args))),
_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
}));
}, possibleConstructorReturn(_this, _temp);
}
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
}) : children;
}
}, {
key: "_getCellMeasurements",
value: function() {
var cache = this.props.cache, node = 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 _props = this.props, cache = _props.cache, _props$columnIndex = _props.columnIndex, columnIndex = void 0 === _props$columnIndex ? 0 : _props$columnIndex, parent = _props.parent, _props$rowIndex = _props.rowIndex, rowIndex = void 0 === _props$rowIndex ? this.props.index || 0 : _props$rowIndex;
if (!cache.has(rowIndex, columnIndex)) {
var _getCellMeasurements2 = this._getCellMeasurements(), height = _getCellMeasurements2.height, width = _getCellMeasurements2.width;
cache.set(rowIndex, columnIndex, width, height), parent && "function" == typeof parent.invalidateCellSizeAfterRender && parent.invalidateCellSizeAfterRender({
columnIndex: columnIndex,
rowIndex: rowIndex
});
}
}
} ]), CellMeasurer;
}(React.PureComponent);
CellMeasurer.__internalCellMeasurerFlag = !1, CellMeasurer.__internalCellMeasurerFlag = !0;
var DEFAULT_HEIGHT = 30, DEFAULT_WIDTH = 100, CellMeasurerCache = function() {
function CellMeasurerCache() {
var _this = this, params = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
classCallCheck(this, CellMeasurerCache), this._cellHeightCache = {}, this._cellWidthCache = {},
this._columnWidthCache = {}, this._rowHeightCache = {}, this._columnCount = 0, this._rowCount = 0,
this.columnWidth = function(_ref) {
var index = _ref.index, key = _this._keyMapper(0, index);
return _this._columnWidthCache.hasOwnProperty(key) ? _this._columnWidthCache[key] : _this._defaultWidth;
}, this.rowHeight = function(_ref2) {
var index = _ref2.index, key = _this._keyMapper(index, 0);
return _this._rowHeightCache.hasOwnProperty(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 : DEFAULT_HEIGHT),
this._defaultWidth = Math.max(this._minWidth, "number" == typeof defaultWidth ? defaultWidth : DEFAULT_WIDTH),
!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) {
var columnIndex = arguments.length > 1 && void 0 !== arguments[1] ? arguments[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) {
var columnIndex = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
if (this._hasFixedHeight) return this._defaultHeight;
var _key = this._keyMapper(rowIndex, columnIndex);
return this._cellHeightCache.hasOwnProperty(_key) ? Math.max(this._minHeight, this._cellHeightCache[_key]) : this._defaultHeight;
}
}, {
key: "getWidth",
value: function(rowIndex) {
var columnIndex = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0;
if (this._hasFixedWidth) return this._defaultWidth;
var _key2 = this._keyMapper(rowIndex, columnIndex);
return this._cellWidthCache.hasOwnProperty(_key2) ? Math.max(this._minWidth, this._cellWidthCache[_key2]) : this._defaultWidth;
}
}, {
key: "has",
value: function(rowIndex) {
var columnIndex = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, key = this._keyMapper(rowIndex, columnIndex);
return this._cellHeightCache.hasOwnProperty(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 rowIndex + "-" + columnIndex;
}
/**
* 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 makeEmptyFunction(arg) {
return function() {
return arg;
};
}
/**
* This function accepts and discards inputs; it has no side effects. This is
* primarily useful idiomatically for overridable function endpoints which
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
*/ var emptyFunction = function() {};
emptyFunction.thatReturns = makeEmptyFunction, emptyFunction.thatReturnsFalse = makeEmptyFunction(!1),
emptyFunction.thatReturnsTrue = makeEmptyFunction(!0), emptyFunction.thatReturnsNull = makeEmptyFunction(null),
emptyFunction.thatReturnsThis = function() {
return this;
}, emptyFunction.thatReturnsArgument = function(arg) {
return arg;
};
var emptyFunction_1 = emptyFunction, validateFormat = function(format) {};
/**
* 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.
*
*/
/**
* Use invariant() to assert state which your program assumes to be true.
*
* Provide sprintf-style format (only %s is supported) and arguments
* to provide information about what broke and what you were
* expecting.
*
* The invariant message will be stripped in production, but the invariant
* will remain to ensure logic does not differ in production.
*/ validateFormat = function(format) {
if (void 0 === format) throw new Error("invariant requires an error message argument");
};
var invariant_1 = function(condition, format, a, b, c, d, e, f) {
if (validateFormat(format), !condition) {
var error;
if (void 0 === format) error = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings."); else {
var args = [ a, b, c, d, e, f ], argIndex = 0;
(error = new Error(format.replace(/%s/g, function() {
return args[argIndex++];
}))).name = "Invariant Violation";
}
// we don't care about invariant's own frame
throw error.framesToPop = 1, error;
}
}, warning_1 = function(condition, format) {
if (void 0 === format) throw new Error("`warning(condition, format, ...args)` requires a warning message argument");
if (0 !== format.indexOf("Failed Composite propType: ") && !condition) {
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) args[_key2 - 2] = arguments[_key2];
(function(format) {
for (var _len = arguments.length, args = Array(_len > 1 ? _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++];
});
"undefined" != typeof console && console.error(message);
try {
// --- Welcome to debugging React ---
// This error was thrown as a convenience so that you can use this stack
// to find the callsite that caused this warning to fire.
throw new Error(message);
} catch (x) {}
}).apply(void 0, [ format ].concat(args));
}
}, getOwnPropertySymbols = Object.getOwnPropertySymbols, hasOwnProperty = Object.prototype.hasOwnProperty, propIsEnumerable = Object.prototype.propertyIsEnumerable;
/**
* 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 objectAssign = function() {
try {
if (!Object.assign) return !1;
// Detect buggy property enumeration order in older V8 versions.
// https://bugs.chromium.org/p/v8/issues/detail?id=4118
var test1 = new String("abc");
// eslint-disable-line no-new-wrappers
if (test1[5] = "de", "5" === Object.getOwnPropertyNames(test1)[0]) return !1;
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
for (var test2 = {}, i = 0; i < 10; i++) test2["_" + String.fromCharCode(i)] = i;
if ("0123456789" !== Object.getOwnPropertyNames(test2).map(function(n) {
return test2[n];
}).join("")) return !1;
// https://bugs.chromium.org/p/v8/issues/detail?id=3056
var test3 = {};
return "abcdefghijklmnopqrst".split("").forEach(function(letter) {
test3[letter] = letter;
}), "abcdefghijklmnopqrst" === Object.keys(Object.assign({}, test3)).join("");
} catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return !1;
}
}() ? Object.assign : function(target, source) {
for (var from, symbols, to = function(val) {
if (null === val || void 0 === val) throw new TypeError("Object.assign cannot be called with null or undefined");
return Object(val);
}(target), s = 1; s < arguments.length; s++) {
for (var key in from = Object(arguments[s])) hasOwnProperty.call(from, key) && (to[key] = from[key]);
if (getOwnPropertySymbols) {
symbols = getOwnPropertySymbols(from);
for (var i = 0; i < symbols.length; i++) propIsEnumerable.call(from, symbols[i]) && (to[symbols[i]] = from[symbols[i]]);
}
}
return to;
}, ReactPropTypesSecret_1 = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED", invariant$1 = invariant_1, warning$1 = warning_1, ReactPropTypesSecret$1 = ReactPropTypesSecret_1, loggedTypeFailures = {};
/**
* 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.
*/ var module, checkPropTypes_1 =
/**
* Assert that the values match with the type specs.
* Error messages are memorized and will only be shown once.
*
* @param {object} typeSpecs Map of name to a ReactPropType
* @param {object} values Runtime values that need to be type-checked
* @param {string} location e.g. "prop", "context", "child context"
* @param {string} componentName Name of the component for error messages.
* @param {?Function} getStack Returns the component stack.
* @private
*/
function(typeSpecs, values, location, componentName, getStack) {
for (var typeSpecName in typeSpecs) if (typeSpecs.hasOwnProperty(typeSpecName)) {
var error;
// Prop type validation may throw. In case they do, we don't want to
// fail the render phase where it didn't fail before. So we log it.
// After these have been cleaned up, we'll let them throw.
try {
// This is intentionally an invariant that gets caught. It's the same
// behavior as without this statement except with a better message.
invariant$1("function" == typeof typeSpecs[typeSpecName], "%s: %s type `%s` is invalid; it must be a function, usually from the `prop-types` package, but received `%s`.", componentName || "React class", location, typeSpecName, typeof typeSpecs[typeSpecName]),
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
} catch (ex) {
error = ex;
}
if (warning$1(!error || error instanceof Error, "%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error),
error instanceof Error && !(error.message in loggedTypeFailures)) {
// Only monitor this failure once because there tends to be a lot of the
// same error.
loggedTypeFailures[error.message] = !0;
var stack = getStack ? getStack() : "";
warning$1(!1, "Failed %s type: %s%s", location, error.message, null != stack ? stack : "");
}
}
}, factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
/* global Symbol */
var ITERATOR_SYMBOL = "function" == typeof Symbol && Symbol.iterator, FAUX_ITERATOR_SYMBOL = "@@iterator";
/**
* Collection of methods that allow declaration and validation of props that are
* supplied to React components. Example usage:
*
* var Props = require('ReactPropTypes');
* var MyArticle = React.createClass({
* propTypes: {
* // An optional string prop named "description".
* description: Props.string,
*
* // A required enum prop named "category".
* category: Props.oneOf(['News','Photos']).isRequired,
*
* // A prop named "dialog" that requires an instance of Dialog.
* dialog: Props.instanceOf(Dialog).isRequired
* },
* render: function() { ... }
* });
*
* A more formal specification of how these methods are used:
*
* type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
* decl := ReactPropTypes.{type}(.isRequired)?
*
* Each and every declaration produces a function with the same signature. This
* allows the creation of custom validation functions. For example:
*
* var MyLink = React.createClass({
* propTypes: {
* // An optional string or URI prop named "href".
* href: function(props, propName, componentName) {
* var propValue = props[propName];
* if (propValue != null && typeof propValue !== 'string' &&
* !(propValue instanceof URI)) {
* return new Error(
* 'Expected a string or an URI for ' + propName + ' in ' +
* componentName
* );
* }
* }
* },
* render: function() {...}
* });
*
* @internal
*/
var ANONYMOUS = "<<anonymous>>", ReactPropTypes = {
array: createPrimitiveTypeChecker("array"),
bool: createPrimitiveTypeChecker("boolean"),
func: createPrimitiveTypeChecker("function"),
number: createPrimitiveTypeChecker("number"),
object: createPrimitiveTypeChecker("object"),
string: createPrimitiveTypeChecker("string"),
symbol: createPrimitiveTypeChecker("symbol"),
any: createChainableTypeChecker(emptyFunction_1.thatReturnsNull),
arrayOf: function(typeChecker) {
return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) {
if ("function" != typeof typeChecker) return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
var propValue = props[propName];
if (!Array.isArray(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` supplied to `" + componentName + "`, expected an array.");
}
for (var i = 0; i < propValue.length; i++) {
var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret_1);
if (error instanceof Error) return error;
}
return null;
});
},
element: function() {
return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
if (!isValidElement(propValue)) {
var propType = getPropType(propValue);
return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement.");
}
return null;
});
}(),
instanceOf: function(expectedClass) {
return createChainableTypeChecker(function(props, propName, componentName, location, propFullName) {
if (!(props[propName] instanceof expectedClass)) {
var expectedClassName