Skip to content

Instantly share code, notes, and snippets.

@daveduthie
Created March 29, 2018 17:03
Show Gist options
  • Save daveduthie/00fa828b92615dc3469350bbebca03e4 to your computer and use it in GitHub Desktop.
Save daveduthie/00fa828b92615dc3469350bbebca03e4 to your computer and use it in GitHub Desktop.
Something to point an externs generator at (https://jmmk.github.io/javascript-externs-generator/)
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["ReactDataGrid"] = factory(require("react"), require("react-dom"));
else
root["ReactDataGrid"] = factory(root["React"], root["ReactDOM"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_6__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(217);
/***/ }),
/* 1 */,
/* 2 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 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.
*/
if (false) {
var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' &&
Symbol.for &&
Symbol.for('react.element')) ||
0xeac7;
var isValidElement = function(object) {
return typeof object === 'object' &&
object !== null &&
object.$$typeof === REACT_ELEMENT_TYPE;
};
// By explicitly using `prop-types` you are opting into new development behavior.
// http://fb.me/prop-types-in-prod
var throwOnDirectAccess = true;
module.exports = require('./factoryWithTypeCheckers')(isValidElement, throwOnDirectAccess);
} else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(112)();
}
/***/ }),
/* 4 */,
/* 5 */,
/* 6 */
/***/ (function(module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_6__;
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2015 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
function classNames() {
var classes = '';
var arg;
for (var i = 0; i < arguments.length; i++) {
arg = arguments[i];
if (!arg) {
continue;
}
if ('string' === typeof arg || 'number' === typeof arg) {
classes += ' ' + arg;
} else if (Object.prototype.toString.call(arg) === '[object Array]') {
classes += ' ' + classNames.apply(null, arg);
} else if ('object' === typeof arg) {
for (var key in arg) {
if (!arg.hasOwnProperty(key) || !arg[key]) {
continue;
}
classes += ' ' + key;
}
}
}
return classes.substr(1);
}
// safely export classNames for node / browserify
if (typeof module !== 'undefined' && module.exports) {
module.exports = classNames;
}
// safely export classNames for RequireJS
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
return classNames;
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
/***/ }),
/* 8 */
/***/ (function(module, exports) {
'use strict';
module.exports = {
getColumn: function getColumn(columns, idx) {
if (Array.isArray(columns)) {
return columns[idx];
} else if (typeof Immutable !== 'undefined') {
return columns.get(idx);
}
},
spliceColumn: function spliceColumn(metrics, idx, column) {
if (Array.isArray(metrics.columns)) {
metrics.columns.splice(idx, 1, column);
} else if (typeof Immutable !== 'undefined') {
metrics.columns = metrics.columns.splice(idx, 1, column);
}
return metrics;
},
getSize: function getSize(columns) {
if (Array.isArray(columns)) {
return columns.length;
} else if (typeof Immutable !== 'undefined') {
return columns.size;
}
},
// Logic extented to allow for functions to be passed down in column.editable
// this allows us to deicde whether we can be edting from a cell level
canEdit: function canEdit(col, rowData, enableCellSelect) {
if (!col) return false;
if (col.editable != null && typeof col.editable === 'function') {
return enableCellSelect === true && col.editable(rowData);
}
return enableCellSelect === true && (!!col.editor || !!col.editable);
},
getValue: function getValue(column, property) {
var value = void 0;
if (column.toJSON && column.get) {
value = column.get(property);
} else {
value = column[property];
}
return value;
}
};
/***/ }),
/* 9 */
/***/ (function(module, exports) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function() {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
var result = [];
for(var i = 0; i < this.length; i++) {
var item = this[i];
if(item[2]) {
result.push("@media " + item[2] + "{" + item[1] + "}");
} else {
result.push(item[1]);
}
}
return result.join("");
};
// import a list of modules into the list
list.i = function(modules, mediaQuery) {
if(typeof modules === "string")
modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for(var i = 0; i < this.length; i++) {
var id = this[i][0];
if(typeof id === "number")
alreadyImportedModules[id] = true;
}
for(i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if(mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if(mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};
/***/ }),
/* 10 */,
/* 11 */
/***/ (function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {},
memoize = function(fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
},
isOldIE = memoize(function() {
return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase());
}),
getHeadElement = memoize(function () {
return document.head || document.getElementsByTagName("head")[0];
}),
singletonElement = null,
singletonCounter = 0,
styleElementsInsertedAtTop = [];
module.exports = function(list, options) {
if(false) {
if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (typeof options.singleton === "undefined") options.singleton = isOldIE();
// By default, add <style> tags to the bottom of <head>.
if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
var styles = listToStyles(list);
addStylesToDom(styles, options);
return function update(newList) {
var mayRemove = [];
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList);
addStylesToDom(newStyles, options);
}
for(var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for(var j = 0; j < domStyle.parts.length; j++)
domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
}
function addStylesToDom(styles, options) {
for(var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles(list) {
var styles = [];
var newStyles = {};
for(var i = 0; i < list.length; i++) {
var item = list[i];
var id = item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id])
styles.push(newStyles[id] = {id: id, parts: [part]});
else
newStyles[id].parts.push(part);
}
return styles;
}
function insertStyleElement(options, styleElement) {
var head = getHeadElement();
var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if(!lastStyleElementInsertedAtTop) {
head.insertBefore(styleElement, head.firstChild);
} else if(lastStyleElementInsertedAtTop.nextSibling) {
head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
} else {
head.appendChild(styleElement);
}
styleElementsInsertedAtTop.push(styleElement);
} else if (options.insertAt === "bottom") {
head.appendChild(styleElement);
} else {
throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
}
}
function removeStyleElement(styleElement) {
styleElement.parentNode.removeChild(styleElement);
var idx = styleElementsInsertedAtTop.indexOf(styleElement);
if(idx >= 0) {
styleElementsInsertedAtTop.splice(idx, 1);
}
}
function createStyleElement(options) {
var styleElement = document.createElement("style");
styleElement.type = "text/css";
insertStyleElement(options, styleElement);
return styleElement;
}
function createLinkElement(options) {
var linkElement = document.createElement("link");
linkElement.rel = "stylesheet";
insertStyleElement(options, linkElement);
return linkElement;
}
function addStyle(obj, options) {
var styleElement, update, remove;
if (options.singleton) {
var styleIndex = singletonCounter++;
styleElement = singletonElement || (singletonElement = createStyleElement(options));
update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
} else if(obj.sourceMap &&
typeof URL === "function" &&
typeof URL.createObjectURL === "function" &&
typeof URL.revokeObjectURL === "function" &&
typeof Blob === "function" &&
typeof btoa === "function") {
styleElement = createLinkElement(options);
update = updateLink.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
if(styleElement.href)
URL.revokeObjectURL(styleElement.href);
};
} else {
styleElement = createStyleElement(options);
update = applyToTag.bind(null, styleElement);
remove = function() {
removeStyleElement(styleElement);
};
}
update(obj);
return function updateStyle(newObj) {
if(newObj) {
if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
return;
update(obj = newObj);
} else {
remove();
}
};
}
var replaceText = (function () {
var textStore = [];
return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();
function applyToSingletonTag(styleElement, index, remove, obj) {
var css = remove ? "" : obj.css;
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = styleElement.childNodes;
if (childNodes[index]) styleElement.removeChild(childNodes[index]);
if (childNodes.length) {
styleElement.insertBefore(cssNode, childNodes[index]);
} else {
styleElement.appendChild(cssNode);
}
}
}
function applyToTag(styleElement, obj) {
var css = obj.css;
var media = obj.media;
if(media) {
styleElement.setAttribute("media", media)
}
if(styleElement.styleSheet) {
styleElement.styleSheet.cssText = css;
} else {
while(styleElement.firstChild) {
styleElement.removeChild(styleElement.firstChild);
}
styleElement.appendChild(document.createTextNode(css));
}
}
function updateLink(linkElement, obj) {
var css = obj.css;
var sourceMap = obj.sourceMap;
if(sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
var blob = new Blob([css], { type: "text/css" });
var oldSrc = linkElement.href;
linkElement.href = URL.createObjectURL(blob);
if(oldSrc)
URL.revokeObjectURL(oldSrc);
}
/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
module.exports = {
selected: _propTypes2['default'].object.isRequired,
copied: _propTypes2['default'].object,
dragged: _propTypes2['default'].object,
onCellClick: _propTypes2['default'].func.isRequired,
onCellDoubleClick: _propTypes2['default'].func.isRequired,
onCommit: _propTypes2['default'].func.isRequired,
onCommitCancel: _propTypes2['default'].func.isRequired,
handleDragEnterRow: _propTypes2['default'].func.isRequired,
handleTerminateDrag: _propTypes2['default'].func.isRequired,
getCellActions: _propTypes2['default'].func
};
/***/ }),
/* 13 */,
/* 14 */,
/* 15 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var ExcelColumnShape = {
name: _propTypes2['default'].node.isRequired,
key: _propTypes2['default'].string.isRequired,
width: _propTypes2['default'].number.isRequired,
filterable: _propTypes2['default'].bool
};
module.exports = ExcelColumnShape;
/***/ }),
/* 16 */,
/* 17 */,
/* 18 */
/***/ (function(module, exports) {
"use strict";
function createObjectWithProperties(originalObj, properties) {
var result = {};
for (var _iterator = properties, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var property = _ref;
if (property in originalObj) {
result[property] = originalObj[property];
}
}
return result;
}
module.exports = createObjectWithProperties;
/***/ }),
/* 19 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2014-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 (global, factory) {
true ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.Immutable = factory());
}(this, function () { 'use strict';var SLICE$0 = Array.prototype.slice;
function createClass(ctor, superClass) {
if (superClass) {
ctor.prototype = Object.create(superClass.prototype);
}
ctor.prototype.constructor = ctor;
}
function Iterable(value) {
return isIterable(value) ? value : Seq(value);
}
createClass(KeyedIterable, Iterable);
function KeyedIterable(value) {
return isKeyed(value) ? value : KeyedSeq(value);
}
createClass(IndexedIterable, Iterable);
function IndexedIterable(value) {
return isIndexed(value) ? value : IndexedSeq(value);
}
createClass(SetIterable, Iterable);
function SetIterable(value) {
return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
}
function isIterable(maybeIterable) {
return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
}
function isKeyed(maybeKeyed) {
return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
}
function isIndexed(maybeIndexed) {
return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
}
function isAssociative(maybeAssociative) {
return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
}
function isOrdered(maybeOrdered) {
return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
}
Iterable.isIterable = isIterable;
Iterable.isKeyed = isKeyed;
Iterable.isIndexed = isIndexed;
Iterable.isAssociative = isAssociative;
Iterable.isOrdered = isOrdered;
Iterable.Keyed = KeyedIterable;
Iterable.Indexed = IndexedIterable;
Iterable.Set = SetIterable;
var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
// Used for setting prototype methods that IE8 chokes on.
var DELETE = 'delete';
// Constants describing the size of trie nodes.
var SHIFT = 5; // Resulted in best performance after ______?
var SIZE = 1 << SHIFT;
var MASK = SIZE - 1;
// A consistent shared value representing "not set" which equals nothing other
// than itself, and nothing that could be provided externally.
var NOT_SET = {};
// Boolean references, Rough equivalent of `bool &`.
var CHANGE_LENGTH = { value: false };
var DID_ALTER = { value: false };
function MakeRef(ref) {
ref.value = false;
return ref;
}
function SetRef(ref) {
ref && (ref.value = true);
}
// A function which returns a value representing an "owner" for transient writes
// to tries. The return value will only ever equal itself, and will not equal
// the return of any subsequent call of this function.
function OwnerID() {}
// http://jsperf.com/copy-array-inline
function arrCopy(arr, offset) {
offset = offset || 0;
var len = Math.max(0, arr.length - offset);
var newArr = new Array(len);
for (var ii = 0; ii < len; ii++) {
newArr[ii] = arr[ii + offset];
}
return newArr;
}
function ensureSize(iter) {
if (iter.size === undefined) {
iter.size = iter.__iterate(returnTrue);
}
return iter.size;
}
function wrapIndex(iter, index) {
// This implements "is array index" which the ECMAString spec defines as:
//
// A String property name P is an array index if and only if
// ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
// to 2^32−1.
//
// http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
if (typeof index !== 'number') {
var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
if ('' + uint32Index !== index || uint32Index === 4294967295) {
return NaN;
}
index = uint32Index;
}
return index < 0 ? ensureSize(iter) + index : index;
}
function returnTrue() {
return true;
}
function wholeSlice(begin, end, size) {
return (begin === 0 || (size !== undefined && begin <= -size)) &&
(end === undefined || (size !== undefined && end >= size));
}
function resolveBegin(begin, size) {
return resolveIndex(begin, size, 0);
}
function resolveEnd(end, size) {
return resolveIndex(end, size, size);
}
function resolveIndex(index, size, defaultIndex) {
return index === undefined ?
defaultIndex :
index < 0 ?
Math.max(0, size + index) :
size === undefined ?
index :
Math.min(size, index);
}
/* global Symbol */
var ITERATE_KEYS = 0;
var ITERATE_VALUES = 1;
var ITERATE_ENTRIES = 2;
var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
var FAUX_ITERATOR_SYMBOL = '@@iterator';
var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
function Iterator(next) {
this.next = next;
}
Iterator.prototype.toString = function() {
return '[Iterator]';
};
Iterator.KEYS = ITERATE_KEYS;
Iterator.VALUES = ITERATE_VALUES;
Iterator.ENTRIES = ITERATE_ENTRIES;
Iterator.prototype.inspect =
Iterator.prototype.toSource = function () { return this.toString(); }
Iterator.prototype[ITERATOR_SYMBOL] = function () {
return this;
};
function iteratorValue(type, k, v, iteratorResult) {
var value = type === 0 ? k : type === 1 ? v : [k, v];
iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
value: value, done: false
});
return iteratorResult;
}
function iteratorDone() {
return { value: undefined, done: true };
}
function hasIterator(maybeIterable) {
return !!getIteratorFn(maybeIterable);
}
function isIterator(maybeIterator) {
return maybeIterator && typeof maybeIterator.next === 'function';
}
function getIterator(iterable) {
var iteratorFn = getIteratorFn(iterable);
return iteratorFn && iteratorFn.call(iterable);
}
function getIteratorFn(iterable) {
var iteratorFn = iterable && (
(REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
iterable[FAUX_ITERATOR_SYMBOL]
);
if (typeof iteratorFn === 'function') {
return iteratorFn;
}
}
function isArrayLike(value) {
return value && typeof value.length === 'number';
}
createClass(Seq, Iterable);
function Seq(value) {
return value === null || value === undefined ? emptySequence() :
isIterable(value) ? value.toSeq() : seqFromValue(value);
}
Seq.of = function(/*...values*/) {
return Seq(arguments);
};
Seq.prototype.toSeq = function() {
return this;
};
Seq.prototype.toString = function() {
return this.__toString('Seq {', '}');
};
Seq.prototype.cacheResult = function() {
if (!this._cache && this.__iterateUncached) {
this._cache = this.entrySeq().toArray();
this.size = this._cache.length;
}
return this;
};
// abstract __iterateUncached(fn, reverse)
Seq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, true);
};
// abstract __iteratorUncached(type, reverse)
Seq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, true);
};
createClass(KeyedSeq, Seq);
function KeyedSeq(value) {
return value === null || value === undefined ?
emptySequence().toKeyedSeq() :
isIterable(value) ?
(isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
keyedSeqFromValue(value);
}
KeyedSeq.prototype.toKeyedSeq = function() {
return this;
};
createClass(IndexedSeq, Seq);
function IndexedSeq(value) {
return value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
}
IndexedSeq.of = function(/*...values*/) {
return IndexedSeq(arguments);
};
IndexedSeq.prototype.toIndexedSeq = function() {
return this;
};
IndexedSeq.prototype.toString = function() {
return this.__toString('Seq [', ']');
};
IndexedSeq.prototype.__iterate = function(fn, reverse) {
return seqIterate(this, fn, reverse, false);
};
IndexedSeq.prototype.__iterator = function(type, reverse) {
return seqIterator(this, type, reverse, false);
};
createClass(SetSeq, Seq);
function SetSeq(value) {
return (
value === null || value === undefined ? emptySequence() :
!isIterable(value) ? indexedSeqFromValue(value) :
isKeyed(value) ? value.entrySeq() : value
).toSetSeq();
}
SetSeq.of = function(/*...values*/) {
return SetSeq(arguments);
};
SetSeq.prototype.toSetSeq = function() {
return this;
};
Seq.isSeq = isSeq;
Seq.Keyed = KeyedSeq;
Seq.Set = SetSeq;
Seq.Indexed = IndexedSeq;
var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
Seq.prototype[IS_SEQ_SENTINEL] = true;
createClass(ArraySeq, IndexedSeq);
function ArraySeq(array) {
this._array = array;
this.size = array.length;
}
ArraySeq.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
};
ArraySeq.prototype.__iterate = function(fn, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
return ii + 1;
}
}
return ii;
};
ArraySeq.prototype.__iterator = function(type, reverse) {
var array = this._array;
var maxIndex = array.length - 1;
var ii = 0;
return new Iterator(function()
{return ii > maxIndex ?
iteratorDone() :
iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
);
};
createClass(ObjectSeq, KeyedSeq);
function ObjectSeq(object) {
var keys = Object.keys(object);
this._object = object;
this._keys = keys;
this.size = keys.length;
}
ObjectSeq.prototype.get = function(key, notSetValue) {
if (notSetValue !== undefined && !this.has(key)) {
return notSetValue;
}
return this._object[key];
};
ObjectSeq.prototype.has = function(key) {
return this._object.hasOwnProperty(key);
};
ObjectSeq.prototype.__iterate = function(fn, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var key = keys[reverse ? maxIndex - ii : ii];
if (fn(object[key], key, this) === false) {
return ii + 1;
}
}
return ii;
};
ObjectSeq.prototype.__iterator = function(type, reverse) {
var object = this._object;
var keys = this._keys;
var maxIndex = keys.length - 1;
var ii = 0;
return new Iterator(function() {
var key = keys[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, key, object[key]);
});
};
ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
createClass(IterableSeq, IndexedSeq);
function IterableSeq(iterable) {
this._iterable = iterable;
this.size = iterable.length || iterable.size;
}
IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
var iterations = 0;
if (isIterator(iterator)) {
var step;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
}
return iterations;
};
IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterable = this._iterable;
var iterator = getIterator(iterable);
if (!isIterator(iterator)) {
return new Iterator(iteratorDone);
}
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step : iteratorValue(type, iterations++, step.value);
});
};
createClass(IteratorSeq, IndexedSeq);
function IteratorSeq(iterator) {
this._iterator = iterator;
this._iteratorCache = [];
}
IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
while (iterations < cache.length) {
if (fn(cache[iterations], iterations++, this) === false) {
return iterations;
}
}
var step;
while (!(step = iterator.next()).done) {
var val = step.value;
cache[iterations] = val;
if (fn(val, iterations++, this) === false) {
break;
}
}
return iterations;
};
IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = this._iterator;
var cache = this._iteratorCache;
var iterations = 0;
return new Iterator(function() {
if (iterations >= cache.length) {
var step = iterator.next();
if (step.done) {
return step;
}
cache[iterations] = step.value;
}
return iteratorValue(type, iterations, cache[iterations++]);
});
};
// # pragma Helper functions
function isSeq(maybeSeq) {
return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
}
var EMPTY_SEQ;
function emptySequence() {
return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
}
function keyedSeqFromValue(value) {
var seq =
Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
typeof value === 'object' ? new ObjectSeq(value) :
undefined;
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of [k, v] entries, '+
'or keyed object: ' + value
);
}
return seq;
}
function indexedSeqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value);
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values: ' + value
);
}
return seq;
}
function seqFromValue(value) {
var seq = maybeIndexedSeqFromValue(value) ||
(typeof value === 'object' && new ObjectSeq(value));
if (!seq) {
throw new TypeError(
'Expected Array or iterable object of values, or keyed object: ' + value
);
}
return seq;
}
function maybeIndexedSeqFromValue(value) {
return (
isArrayLike(value) ? new ArraySeq(value) :
isIterator(value) ? new IteratorSeq(value) :
hasIterator(value) ? new IterableSeq(value) :
undefined
);
}
function seqIterate(seq, fn, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
for (var ii = 0; ii <= maxIndex; ii++) {
var entry = cache[reverse ? maxIndex - ii : ii];
if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
return ii + 1;
}
}
return ii;
}
return seq.__iterateUncached(fn, reverse);
}
function seqIterator(seq, type, reverse, useKeys) {
var cache = seq._cache;
if (cache) {
var maxIndex = cache.length - 1;
var ii = 0;
return new Iterator(function() {
var entry = cache[reverse ? maxIndex - ii : ii];
return ii++ > maxIndex ?
iteratorDone() :
iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
});
}
return seq.__iteratorUncached(type, reverse);
}
function fromJS(json, converter) {
return converter ?
fromJSWith(converter, json, '', {'': json}) :
fromJSDefault(json);
}
function fromJSWith(converter, json, key, parentJSON) {
if (Array.isArray(json)) {
return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
if (isPlainObj(json)) {
return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
}
return json;
}
function fromJSDefault(json) {
if (Array.isArray(json)) {
return IndexedSeq(json).map(fromJSDefault).toList();
}
if (isPlainObj(json)) {
return KeyedSeq(json).map(fromJSDefault).toMap();
}
return json;
}
function isPlainObj(value) {
return value && (value.constructor === Object || value.constructor === undefined);
}
/**
* An extension of the "same-value" algorithm as [described for use by ES6 Map
* and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
*
* NaN is considered the same as NaN, however -0 and 0 are considered the same
* value, which is different from the algorithm described by
* [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
*
* This is extended further to allow Objects to describe the values they
* represent, by way of `valueOf` or `equals` (and `hashCode`).
*
* Note: because of this extension, the key equality of Immutable.Map and the
* value equality of Immutable.Set will differ from ES6 Map and Set.
*
* ### Defining custom values
*
* The easiest way to describe the value an object represents is by implementing
* `valueOf`. For example, `Date` represents a value by returning a unix
* timestamp for `valueOf`:
*
* var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
* var date2 = new Date(1234567890000);
* date1.valueOf(); // 1234567890000
* assert( date1 !== date2 );
* assert( Immutable.is( date1, date2 ) );
*
* Note: overriding `valueOf` may have other implications if you use this object
* where JavaScript expects a primitive, such as implicit string coercion.
*
* For more complex types, especially collections, implementing `valueOf` may
* not be performant. An alternative is to implement `equals` and `hashCode`.
*
* `equals` takes another object, presumably of similar type, and returns true
* if the it is equal. Equality is symmetrical, so the same result should be
* returned if this and the argument are flipped.
*
* assert( a.equals(b) === b.equals(a) );
*
* `hashCode` returns a 32bit integer number representing the object which will
* be used to determine how to store the value object in a Map or Set. You must
* provide both or neither methods, one must not exist without the other.
*
* Also, an important relationship between these methods must be upheld: if two
* values are equal, they *must* return the same hashCode. If the values are not
* equal, they might have the same hashCode; this is called a hash collision,
* and while undesirable for performance reasons, it is acceptable.
*
* if (a.equals(b)) {
* assert( a.hashCode() === b.hashCode() );
* }
*
* All Immutable collections implement `equals` and `hashCode`.
*
*/
function is(valueA, valueB) {
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
if (typeof valueA.valueOf === 'function' &&
typeof valueB.valueOf === 'function') {
valueA = valueA.valueOf();
valueB = valueB.valueOf();
if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
return true;
}
if (!valueA || !valueB) {
return false;
}
}
if (typeof valueA.equals === 'function' &&
typeof valueB.equals === 'function' &&
valueA.equals(valueB)) {
return true;
}
return false;
}
function deepEqual(a, b) {
if (a === b) {
return true;
}
if (
!isIterable(b) ||
a.size !== undefined && b.size !== undefined && a.size !== b.size ||
a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
isKeyed(a) !== isKeyed(b) ||
isIndexed(a) !== isIndexed(b) ||
isOrdered(a) !== isOrdered(b)
) {
return false;
}
if (a.size === 0 && b.size === 0) {
return true;
}
var notAssociative = !isAssociative(a);
if (isOrdered(a)) {
var entries = a.entries();
return b.every(function(v, k) {
var entry = entries.next().value;
return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
}) && entries.next().done;
}
var flipped = false;
if (a.size === undefined) {
if (b.size === undefined) {
if (typeof a.cacheResult === 'function') {
a.cacheResult();
}
} else {
flipped = true;
var _ = a;
a = b;
b = _;
}
}
var allEqual = true;
var bSize = b.__iterate(function(v, k) {
if (notAssociative ? !a.has(v) :
flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
allEqual = false;
return false;
}
});
return allEqual && a.size === bSize;
}
createClass(Repeat, IndexedSeq);
function Repeat(value, times) {
if (!(this instanceof Repeat)) {
return new Repeat(value, times);
}
this._value = value;
this.size = times === undefined ? Infinity : Math.max(0, times);
if (this.size === 0) {
if (EMPTY_REPEAT) {
return EMPTY_REPEAT;
}
EMPTY_REPEAT = this;
}
}
Repeat.prototype.toString = function() {
if (this.size === 0) {
return 'Repeat []';
}
return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
};
Repeat.prototype.get = function(index, notSetValue) {
return this.has(index) ? this._value : notSetValue;
};
Repeat.prototype.includes = function(searchValue) {
return is(this._value, searchValue);
};
Repeat.prototype.slice = function(begin, end) {
var size = this.size;
return wholeSlice(begin, end, size) ? this :
new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
};
Repeat.prototype.reverse = function() {
return this;
};
Repeat.prototype.indexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return 0;
}
return -1;
};
Repeat.prototype.lastIndexOf = function(searchValue) {
if (is(this._value, searchValue)) {
return this.size;
}
return -1;
};
Repeat.prototype.__iterate = function(fn, reverse) {
for (var ii = 0; ii < this.size; ii++) {
if (fn(this._value, ii, this) === false) {
return ii + 1;
}
}
return ii;
};
Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
var ii = 0;
return new Iterator(function()
{return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
);
};
Repeat.prototype.equals = function(other) {
return other instanceof Repeat ?
is(this._value, other._value) :
deepEqual(other);
};
var EMPTY_REPEAT;
function invariant(condition, error) {
if (!condition) throw new Error(error);
}
createClass(Range, IndexedSeq);
function Range(start, end, step) {
if (!(this instanceof Range)) {
return new Range(start, end, step);
}
invariant(step !== 0, 'Cannot step a Range by 0');
start = start || 0;
if (end === undefined) {
end = Infinity;
}
step = step === undefined ? 1 : Math.abs(step);
if (end < start) {
step = -step;
}
this._start = start;
this._end = end;
this._step = step;
this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
if (this.size === 0) {
if (EMPTY_RANGE) {
return EMPTY_RANGE;
}
EMPTY_RANGE = this;
}
}
Range.prototype.toString = function() {
if (this.size === 0) {
return 'Range []';
}
return 'Range [ ' +
this._start + '...' + this._end +
(this._step !== 1 ? ' by ' + this._step : '') +
' ]';
};
Range.prototype.get = function(index, notSetValue) {
return this.has(index) ?
this._start + wrapIndex(this, index) * this._step :
notSetValue;
};
Range.prototype.includes = function(searchValue) {
var possibleIndex = (searchValue - this._start) / this._step;
return possibleIndex >= 0 &&
possibleIndex < this.size &&
possibleIndex === Math.floor(possibleIndex);
};
Range.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
begin = resolveBegin(begin, this.size);
end = resolveEnd(end, this.size);
if (end <= begin) {
return new Range(0, 0);
}
return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
};
Range.prototype.indexOf = function(searchValue) {
var offsetValue = searchValue - this._start;
if (offsetValue % this._step === 0) {
var index = offsetValue / this._step;
if (index >= 0 && index < this.size) {
return index
}
}
return -1;
};
Range.prototype.lastIndexOf = function(searchValue) {
return this.indexOf(searchValue);
};
Range.prototype.__iterate = function(fn, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
for (var ii = 0; ii <= maxIndex; ii++) {
if (fn(value, ii, this) === false) {
return ii + 1;
}
value += reverse ? -step : step;
}
return ii;
};
Range.prototype.__iterator = function(type, reverse) {
var maxIndex = this.size - 1;
var step = this._step;
var value = reverse ? this._start + maxIndex * step : this._start;
var ii = 0;
return new Iterator(function() {
var v = value;
value += reverse ? -step : step;
return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
});
};
Range.prototype.equals = function(other) {
return other instanceof Range ?
this._start === other._start &&
this._end === other._end &&
this._step === other._step :
deepEqual(this, other);
};
var EMPTY_RANGE;
createClass(Collection, Iterable);
function Collection() {
throw TypeError('Abstract');
}
createClass(KeyedCollection, Collection);function KeyedCollection() {}
createClass(IndexedCollection, Collection);function IndexedCollection() {}
createClass(SetCollection, Collection);function SetCollection() {}
Collection.Keyed = KeyedCollection;
Collection.Indexed = IndexedCollection;
Collection.Set = SetCollection;
var imul =
typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
Math.imul :
function imul(a, b) {
a = a | 0; // int
b = b | 0; // int
var c = a & 0xffff;
var d = b & 0xffff;
// Shift by 0 fixes the sign on the high part.
return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
};
// v8 has an optimization for storing 31-bit signed numbers.
// Values which have either 00 or 11 as the high order bits qualify.
// This function drops the highest order bit in a signed number, maintaining
// the sign bit.
function smi(i32) {
return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
}
function hash(o) {
if (o === false || o === null || o === undefined) {
return 0;
}
if (typeof o.valueOf === 'function') {
o = o.valueOf();
if (o === false || o === null || o === undefined) {
return 0;
}
}
if (o === true) {
return 1;
}
var type = typeof o;
if (type === 'number') {
if (o !== o || o === Infinity) {
return 0;
}
var h = o | 0;
if (h !== o) {
h ^= o * 0xFFFFFFFF;
}
while (o > 0xFFFFFFFF) {
o /= 0xFFFFFFFF;
h ^= o;
}
return smi(h);
}
if (type === 'string') {
return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
}
if (typeof o.hashCode === 'function') {
return o.hashCode();
}
if (type === 'object') {
return hashJSObj(o);
}
if (typeof o.toString === 'function') {
return hashString(o.toString());
}
throw new Error('Value type ' + type + ' cannot be hashed.');
}
function cachedHashString(string) {
var hash = stringHashCache[string];
if (hash === undefined) {
hash = hashString(string);
if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
STRING_HASH_CACHE_SIZE = 0;
stringHashCache = {};
}
STRING_HASH_CACHE_SIZE++;
stringHashCache[string] = hash;
}
return hash;
}
// http://jsperf.com/hashing-strings
function hashString(string) {
// This is the hash from JVM
// The hash code for a string is computed as
// s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
// where s[i] is the ith character of the string and n is the length of
// the string. We "mod" the result to make it between 0 (inclusive) and 2^31
// (exclusive) by dropping high bits.
var hash = 0;
for (var ii = 0; ii < string.length; ii++) {
hash = 31 * hash + string.charCodeAt(ii) | 0;
}
return smi(hash);
}
function hashJSObj(obj) {
var hash;
if (usingWeakMap) {
hash = weakMap.get(obj);
if (hash !== undefined) {
return hash;
}
}
hash = obj[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
if (!canDefineProperty) {
hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
if (hash !== undefined) {
return hash;
}
hash = getIENodeHash(obj);
if (hash !== undefined) {
return hash;
}
}
hash = ++objHashUID;
if (objHashUID & 0x40000000) {
objHashUID = 0;
}
if (usingWeakMap) {
weakMap.set(obj, hash);
} else if (isExtensible !== undefined && isExtensible(obj) === false) {
throw new Error('Non-extensible objects are not allowed as keys.');
} else if (canDefineProperty) {
Object.defineProperty(obj, UID_HASH_KEY, {
'enumerable': false,
'configurable': false,
'writable': false,
'value': hash
});
} else if (obj.propertyIsEnumerable !== undefined &&
obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
// Since we can't define a non-enumerable property on the object
// we'll hijack one of the less-used non-enumerable properties to
// save our hash on it. Since this is a function it will not show up in
// `JSON.stringify` which is what we want.
obj.propertyIsEnumerable = function() {
return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
};
obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
} else if (obj.nodeType !== undefined) {
// At this point we couldn't get the IE `uniqueID` to use as a hash
// and we couldn't use a non-enumerable property to exploit the
// dontEnum bug so we simply add the `UID_HASH_KEY` on the node
// itself.
obj[UID_HASH_KEY] = hash;
} else {
throw new Error('Unable to set a non-enumerable property on object.');
}
return hash;
}
// Get references to ES5 object methods.
var isExtensible = Object.isExtensible;
// True if Object.defineProperty works as expected. IE8 fails this test.
var canDefineProperty = (function() {
try {
Object.defineProperty({}, '@', {});
return true;
} catch (e) {
return false;
}
}());
// IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
// and avoid memory leaks from the IE cloneNode bug.
function getIENodeHash(node) {
if (node && node.nodeType > 0) {
switch (node.nodeType) {
case 1: // Element
return node.uniqueID;
case 9: // Document
return node.documentElement && node.documentElement.uniqueID;
}
}
}
// If possible, use a WeakMap.
var usingWeakMap = typeof WeakMap === 'function';
var weakMap;
if (usingWeakMap) {
weakMap = new WeakMap();
}
var objHashUID = 0;
var UID_HASH_KEY = '__immutablehash__';
if (typeof Symbol === 'function') {
UID_HASH_KEY = Symbol(UID_HASH_KEY);
}
var STRING_HASH_CACHE_MIN_STRLEN = 16;
var STRING_HASH_CACHE_MAX_SIZE = 255;
var STRING_HASH_CACHE_SIZE = 0;
var stringHashCache = {};
function assertNotInfinite(size) {
invariant(
size !== Infinity,
'Cannot perform this action with an infinite size.'
);
}
createClass(Map, KeyedCollection);
// @pragma Construction
function Map(value) {
return value === null || value === undefined ? emptyMap() :
isMap(value) && !isOrdered(value) ? value :
emptyMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
Map.of = function() {var keyValues = SLICE$0.call(arguments, 0);
return emptyMap().withMutations(function(map ) {
for (var i = 0; i < keyValues.length; i += 2) {
if (i + 1 >= keyValues.length) {
throw new Error('Missing value for key: ' + keyValues[i]);
}
map.set(keyValues[i], keyValues[i + 1]);
}
});
};
Map.prototype.toString = function() {
return this.__toString('Map {', '}');
};
// @pragma Access
Map.prototype.get = function(k, notSetValue) {
return this._root ?
this._root.get(0, undefined, k, notSetValue) :
notSetValue;
};
// @pragma Modification
Map.prototype.set = function(k, v) {
return updateMap(this, k, v);
};
Map.prototype.setIn = function(keyPath, v) {
return this.updateIn(keyPath, NOT_SET, function() {return v});
};
Map.prototype.remove = function(k) {
return updateMap(this, k, NOT_SET);
};
Map.prototype.deleteIn = function(keyPath) {
return this.updateIn(keyPath, function() {return NOT_SET});
};
Map.prototype.update = function(k, notSetValue, updater) {
return arguments.length === 1 ?
k(this) :
this.updateIn([k], notSetValue, updater);
};
Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
if (!updater) {
updater = notSetValue;
notSetValue = undefined;
}
var updatedValue = updateInDeepMap(
this,
forceIterator(keyPath),
notSetValue,
updater
);
return updatedValue === NOT_SET ? undefined : updatedValue;
};
Map.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._root = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyMap();
};
// @pragma Composition
Map.prototype.merge = function(/*...iters*/) {
return mergeIntoMapWith(this, undefined, arguments);
};
Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, merger, iters);
};
Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.merge === 'function' ?
m.merge.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoMapWith(this, deepMerger, arguments);
};
Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoMapWith(this, deepMergerWith(merger), iters);
};
Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
return this.updateIn(
keyPath,
emptyMap(),
function(m ) {return typeof m.mergeDeep === 'function' ?
m.mergeDeep.apply(m, iters) :
iters[iters.length - 1]}
);
};
Map.prototype.sort = function(comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator));
};
Map.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedMap(sortFactory(this, comparator, mapper));
};
// @pragma Mutability
Map.prototype.withMutations = function(fn) {
var mutable = this.asMutable();
fn(mutable);
return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
};
Map.prototype.asMutable = function() {
return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
};
Map.prototype.asImmutable = function() {
return this.__ensureOwner();
};
Map.prototype.wasAltered = function() {
return this.__altered;
};
Map.prototype.__iterator = function(type, reverse) {
return new MapIterator(this, type, reverse);
};
Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
this._root && this._root.iterate(function(entry ) {
iterations++;
return fn(entry[1], entry[0], this$0);
}, reverse);
return iterations;
};
Map.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeMap(this.size, this._root, ownerID, this.__hash);
};
function isMap(maybeMap) {
return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
}
Map.isMap = isMap;
var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
var MapPrototype = Map.prototype;
MapPrototype[IS_MAP_SENTINEL] = true;
MapPrototype[DELETE] = MapPrototype.remove;
MapPrototype.removeIn = MapPrototype.deleteIn;
// #pragma Trie Nodes
function ArrayMapNode(ownerID, entries) {
this.ownerID = ownerID;
this.entries = entries;
}
ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && entries.length === 1) {
return; // undefined
}
if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
return createNodes(ownerID, entries, key, value);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new ArrayMapNode(ownerID, newEntries);
};
function BitmapIndexedNode(ownerID, bitmap, nodes) {
this.ownerID = ownerID;
this.bitmap = bitmap;
this.nodes = nodes;
}
BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
var bitmap = this.bitmap;
return (bitmap & bit) === 0 ? notSetValue :
this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
};
BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var bit = 1 << keyHashFrag;
var bitmap = this.bitmap;
var exists = (bitmap & bit) !== 0;
if (!exists && value === NOT_SET) {
return this;
}
var idx = popCount(bitmap & (bit - 1));
var nodes = this.nodes;
var node = exists ? nodes[idx] : undefined;
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
}
if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
return nodes[idx ^ 1];
}
if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
return newNode;
}
var isEditable = ownerID && ownerID === this.ownerID;
var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
var newNodes = exists ? newNode ?
setIn(nodes, idx, newNode, isEditable) :
spliceOut(nodes, idx, isEditable) :
spliceIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.bitmap = newBitmap;
this.nodes = newNodes;
return this;
}
return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
};
function HashArrayMapNode(ownerID, count, nodes) {
this.ownerID = ownerID;
this.count = count;
this.nodes = nodes;
}
HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var node = this.nodes[idx];
return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
};
HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var removed = value === NOT_SET;
var nodes = this.nodes;
var node = nodes[idx];
if (removed && !node) {
return this;
}
var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
if (newNode === node) {
return this;
}
var newCount = this.count;
if (!node) {
newCount++;
} else if (!newNode) {
newCount--;
if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
return packNodes(ownerID, nodes, newCount, idx);
}
}
var isEditable = ownerID && ownerID === this.ownerID;
var newNodes = setIn(nodes, idx, newNode, isEditable);
if (isEditable) {
this.count = newCount;
this.nodes = newNodes;
return this;
}
return new HashArrayMapNode(ownerID, newCount, newNodes);
};
function HashCollisionNode(ownerID, keyHash, entries) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entries = entries;
}
HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
var entries = this.entries;
for (var ii = 0, len = entries.length; ii < len; ii++) {
if (is(key, entries[ii][0])) {
return entries[ii][1];
}
}
return notSetValue;
};
HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (keyHash === undefined) {
keyHash = hash(key);
}
var removed = value === NOT_SET;
if (keyHash !== this.keyHash) {
if (removed) {
return this;
}
SetRef(didAlter);
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
}
var entries = this.entries;
var idx = 0;
for (var len = entries.length; idx < len; idx++) {
if (is(key, entries[idx][0])) {
break;
}
}
var exists = idx < len;
if (exists ? entries[idx][1] === value : removed) {
return this;
}
SetRef(didAlter);
(removed || !exists) && SetRef(didChangeSize);
if (removed && len === 2) {
return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
}
var isEditable = ownerID && ownerID === this.ownerID;
var newEntries = isEditable ? entries : arrCopy(entries);
if (exists) {
if (removed) {
idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
} else {
newEntries[idx] = [key, value];
}
} else {
newEntries.push([key, value]);
}
if (isEditable) {
this.entries = newEntries;
return this;
}
return new HashCollisionNode(ownerID, this.keyHash, newEntries);
};
function ValueNode(ownerID, keyHash, entry) {
this.ownerID = ownerID;
this.keyHash = keyHash;
this.entry = entry;
}
ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
};
ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
var removed = value === NOT_SET;
var keyMatch = is(key, this.entry[0]);
if (keyMatch ? value === this.entry[1] : removed) {
return this;
}
SetRef(didAlter);
if (removed) {
SetRef(didChangeSize);
return; // undefined
}
if (keyMatch) {
if (ownerID && ownerID === this.ownerID) {
this.entry[1] = value;
return this;
}
return new ValueNode(ownerID, this.keyHash, [key, value]);
}
SetRef(didChangeSize);
return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
};
// #pragma Iterators
ArrayMapNode.prototype.iterate =
HashCollisionNode.prototype.iterate = function (fn, reverse) {
var entries = this.entries;
for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
return false;
}
}
}
BitmapIndexedNode.prototype.iterate =
HashArrayMapNode.prototype.iterate = function (fn, reverse) {
var nodes = this.nodes;
for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
var node = nodes[reverse ? maxIndex - ii : ii];
if (node && node.iterate(fn, reverse) === false) {
return false;
}
}
}
ValueNode.prototype.iterate = function (fn, reverse) {
return fn(this.entry);
}
createClass(MapIterator, Iterator);
function MapIterator(map, type, reverse) {
this._type = type;
this._reverse = reverse;
this._stack = map._root && mapIteratorFrame(map._root);
}
MapIterator.prototype.next = function() {
var type = this._type;
var stack = this._stack;
while (stack) {
var node = stack.node;
var index = stack.index++;
var maxIndex;
if (node.entry) {
if (index === 0) {
return mapIteratorValue(type, node.entry);
}
} else if (node.entries) {
maxIndex = node.entries.length - 1;
if (index <= maxIndex) {
return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
}
} else {
maxIndex = node.nodes.length - 1;
if (index <= maxIndex) {
var subNode = node.nodes[this._reverse ? maxIndex - index : index];
if (subNode) {
if (subNode.entry) {
return mapIteratorValue(type, subNode.entry);
}
stack = this._stack = mapIteratorFrame(subNode, stack);
}
continue;
}
}
stack = this._stack = this._stack.__prev;
}
return iteratorDone();
};
function mapIteratorValue(type, entry) {
return iteratorValue(type, entry[0], entry[1]);
}
function mapIteratorFrame(node, prev) {
return {
node: node,
index: 0,
__prev: prev
};
}
function makeMap(size, root, ownerID, hash) {
var map = Object.create(MapPrototype);
map.size = size;
map._root = root;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_MAP;
function emptyMap() {
return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
}
function updateMap(map, k, v) {
var newRoot;
var newSize;
if (!map._root) {
if (v === NOT_SET) {
return map;
}
newSize = 1;
newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
} else {
var didChangeSize = MakeRef(CHANGE_LENGTH);
var didAlter = MakeRef(DID_ALTER);
newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
if (!didAlter.value) {
return map;
}
newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
}
if (map.__ownerID) {
map.size = newSize;
map._root = newRoot;
map.__hash = undefined;
map.__altered = true;
return map;
}
return newRoot ? makeMap(newSize, newRoot) : emptyMap();
}
function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
if (!node) {
if (value === NOT_SET) {
return node;
}
SetRef(didAlter);
SetRef(didChangeSize);
return new ValueNode(ownerID, keyHash, [key, value]);
}
return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
}
function isLeafNode(node) {
return node.constructor === ValueNode || node.constructor === HashCollisionNode;
}
function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
if (node.keyHash === keyHash) {
return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
}
var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
var newNode;
var nodes = idx1 === idx2 ?
[mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
}
function createNodes(ownerID, entries, key, value) {
if (!ownerID) {
ownerID = new OwnerID();
}
var node = new ValueNode(ownerID, hash(key), [key, value]);
for (var ii = 0; ii < entries.length; ii++) {
var entry = entries[ii];
node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
}
return node;
}
function packNodes(ownerID, nodes, count, excluding) {
var bitmap = 0;
var packedII = 0;
var packedNodes = new Array(count);
for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
var node = nodes[ii];
if (node !== undefined && ii !== excluding) {
bitmap |= bit;
packedNodes[packedII++] = node;
}
}
return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
}
function expandNodes(ownerID, nodes, bitmap, including, node) {
var count = 0;
var expandedNodes = new Array(SIZE);
for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
}
expandedNodes[including] = node;
return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
}
function mergeIntoMapWith(map, merger, iterables) {
var iters = [];
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = KeyedIterable(value);
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
return mergeIntoCollectionWith(map, merger, iters);
}
function deepMerger(existing, value, key) {
return existing && existing.mergeDeep && isIterable(value) ?
existing.mergeDeep(value) :
is(existing, value) ? existing : value;
}
function deepMergerWith(merger) {
return function(existing, value, key) {
if (existing && existing.mergeDeepWith && isIterable(value)) {
return existing.mergeDeepWith(merger, value);
}
var nextValue = merger(existing, value, key);
return is(existing, nextValue) ? existing : nextValue;
};
}
function mergeIntoCollectionWith(collection, merger, iters) {
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return collection;
}
if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
return collection.constructor(iters[0]);
}
return collection.withMutations(function(collection ) {
var mergeIntoMap = merger ?
function(value, key) {
collection.update(key, NOT_SET, function(existing )
{return existing === NOT_SET ? value : merger(existing, value, key)}
);
} :
function(value, key) {
collection.set(key, value);
}
for (var ii = 0; ii < iters.length; ii++) {
iters[ii].forEach(mergeIntoMap);
}
});
}
function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
var isNotSet = existing === NOT_SET;
var step = keyPathIter.next();
if (step.done) {
var existingValue = isNotSet ? notSetValue : existing;
var newValue = updater(existingValue);
return newValue === existingValue ? existing : newValue;
}
invariant(
isNotSet || (existing && existing.set),
'invalid keyPath'
);
var key = step.value;
var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
var nextUpdated = updateInDeepMap(
nextExisting,
keyPathIter,
notSetValue,
updater
);
return nextUpdated === nextExisting ? existing :
nextUpdated === NOT_SET ? existing.remove(key) :
(isNotSet ? emptyMap() : existing).set(key, nextUpdated);
}
function popCount(x) {
x = x - ((x >> 1) & 0x55555555);
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
x = x + (x >> 8);
x = x + (x >> 16);
return x & 0x7f;
}
function setIn(array, idx, val, canEdit) {
var newArray = canEdit ? array : arrCopy(array);
newArray[idx] = val;
return newArray;
}
function spliceIn(array, idx, val, canEdit) {
var newLen = array.length + 1;
if (canEdit && idx + 1 === newLen) {
array[idx] = val;
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
newArray[ii] = val;
after = -1;
} else {
newArray[ii] = array[ii + after];
}
}
return newArray;
}
function spliceOut(array, idx, canEdit) {
var newLen = array.length - 1;
if (canEdit && idx === newLen) {
array.pop();
return array;
}
var newArray = new Array(newLen);
var after = 0;
for (var ii = 0; ii < newLen; ii++) {
if (ii === idx) {
after = 1;
}
newArray[ii] = array[ii + after];
}
return newArray;
}
var MAX_ARRAY_MAP_SIZE = SIZE / 4;
var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
createClass(List, IndexedCollection);
// @pragma Construction
function List(value) {
var empty = emptyList();
if (value === null || value === undefined) {
return empty;
}
if (isList(value)) {
return value;
}
var iter = IndexedIterable(value);
var size = iter.size;
if (size === 0) {
return empty;
}
assertNotInfinite(size);
if (size > 0 && size < SIZE) {
return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
}
return empty.withMutations(function(list ) {
list.setSize(size);
iter.forEach(function(v, i) {return list.set(i, v)});
});
}
List.of = function(/*...values*/) {
return this(arguments);
};
List.prototype.toString = function() {
return this.__toString('List [', ']');
};
// @pragma Access
List.prototype.get = function(index, notSetValue) {
index = wrapIndex(this, index);
if (index >= 0 && index < this.size) {
index += this._origin;
var node = listNodeFor(this, index);
return node && node.array[index & MASK];
}
return notSetValue;
};
// @pragma Modification
List.prototype.set = function(index, value) {
return updateList(this, index, value);
};
List.prototype.remove = function(index) {
return !this.has(index) ? this :
index === 0 ? this.shift() :
index === this.size - 1 ? this.pop() :
this.splice(index, 1);
};
List.prototype.insert = function(index, value) {
return this.splice(index, 0, value);
};
List.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = this._origin = this._capacity = 0;
this._level = SHIFT;
this._root = this._tail = null;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyList();
};
List.prototype.push = function(/*...values*/) {
var values = arguments;
var oldSize = this.size;
return this.withMutations(function(list ) {
setListBounds(list, 0, oldSize + values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(oldSize + ii, values[ii]);
}
});
};
List.prototype.pop = function() {
return setListBounds(this, 0, -1);
};
List.prototype.unshift = function(/*...values*/) {
var values = arguments;
return this.withMutations(function(list ) {
setListBounds(list, -values.length);
for (var ii = 0; ii < values.length; ii++) {
list.set(ii, values[ii]);
}
});
};
List.prototype.shift = function() {
return setListBounds(this, 1);
};
// @pragma Composition
List.prototype.merge = function(/*...iters*/) {
return mergeIntoListWith(this, undefined, arguments);
};
List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, merger, iters);
};
List.prototype.mergeDeep = function(/*...iters*/) {
return mergeIntoListWith(this, deepMerger, arguments);
};
List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return mergeIntoListWith(this, deepMergerWith(merger), iters);
};
List.prototype.setSize = function(size) {
return setListBounds(this, 0, size);
};
// @pragma Iteration
List.prototype.slice = function(begin, end) {
var size = this.size;
if (wholeSlice(begin, end, size)) {
return this;
}
return setListBounds(
this,
resolveBegin(begin, size),
resolveEnd(end, size)
);
};
List.prototype.__iterator = function(type, reverse) {
var index = 0;
var values = iterateList(this, reverse);
return new Iterator(function() {
var value = values();
return value === DONE ?
iteratorDone() :
iteratorValue(type, index++, value);
});
};
List.prototype.__iterate = function(fn, reverse) {
var index = 0;
var values = iterateList(this, reverse);
var value;
while ((value = values()) !== DONE) {
if (fn(value, index++, this) === false) {
break;
}
}
return index;
};
List.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
return this;
}
return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
};
function isList(maybeList) {
return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
}
List.isList = isList;
var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
var ListPrototype = List.prototype;
ListPrototype[IS_LIST_SENTINEL] = true;
ListPrototype[DELETE] = ListPrototype.remove;
ListPrototype.setIn = MapPrototype.setIn;
ListPrototype.deleteIn =
ListPrototype.removeIn = MapPrototype.removeIn;
ListPrototype.update = MapPrototype.update;
ListPrototype.updateIn = MapPrototype.updateIn;
ListPrototype.mergeIn = MapPrototype.mergeIn;
ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
ListPrototype.withMutations = MapPrototype.withMutations;
ListPrototype.asMutable = MapPrototype.asMutable;
ListPrototype.asImmutable = MapPrototype.asImmutable;
ListPrototype.wasAltered = MapPrototype.wasAltered;
function VNode(array, ownerID) {
this.array = array;
this.ownerID = ownerID;
}
// TODO: seems like these methods are very similar
VNode.prototype.removeBefore = function(ownerID, level, index) {
if (index === level ? 1 << level : 0 || this.array.length === 0) {
return this;
}
var originIndex = (index >>> level) & MASK;
if (originIndex >= this.array.length) {
return new VNode([], ownerID);
}
var removingFirst = originIndex === 0;
var newChild;
if (level > 0) {
var oldChild = this.array[originIndex];
newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
if (newChild === oldChild && removingFirst) {
return this;
}
}
if (removingFirst && !newChild) {
return this;
}
var editable = editableVNode(this, ownerID);
if (!removingFirst) {
for (var ii = 0; ii < originIndex; ii++) {
editable.array[ii] = undefined;
}
}
if (newChild) {
editable.array[originIndex] = newChild;
}
return editable;
};
VNode.prototype.removeAfter = function(ownerID, level, index) {
if (index === (level ? 1 << level : 0) || this.array.length === 0) {
return this;
}
var sizeIndex = ((index - 1) >>> level) & MASK;
if (sizeIndex >= this.array.length) {
return this;
}
var newChild;
if (level > 0) {
var oldChild = this.array[sizeIndex];
newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
if (newChild === oldChild && sizeIndex === this.array.length - 1) {
return this;
}
}
var editable = editableVNode(this, ownerID);
editable.array.splice(sizeIndex + 1);
if (newChild) {
editable.array[sizeIndex] = newChild;
}
return editable;
};
var DONE = {};
function iterateList(list, reverse) {
var left = list._origin;
var right = list._capacity;
var tailPos = getTailOffset(right);
var tail = list._tail;
return iterateNodeOrLeaf(list._root, list._level, 0);
function iterateNodeOrLeaf(node, level, offset) {
return level === 0 ?
iterateLeaf(node, offset) :
iterateNode(node, level, offset);
}
function iterateLeaf(node, offset) {
var array = offset === tailPos ? tail && tail.array : node && node.array;
var from = offset > left ? 0 : left - offset;
var to = right - offset;
if (to > SIZE) {
to = SIZE;
}
return function() {
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
return array && array[idx];
};
}
function iterateNode(node, level, offset) {
var values;
var array = node && node.array;
var from = offset > left ? 0 : (left - offset) >> level;
var to = ((right - offset) >> level) + 1;
if (to > SIZE) {
to = SIZE;
}
return function() {
do {
if (values) {
var value = values();
if (value !== DONE) {
return value;
}
values = null;
}
if (from === to) {
return DONE;
}
var idx = reverse ? --to : from++;
values = iterateNodeOrLeaf(
array && array[idx], level - SHIFT, offset + (idx << level)
);
} while (true);
};
}
}
function makeList(origin, capacity, level, root, tail, ownerID, hash) {
var list = Object.create(ListPrototype);
list.size = capacity - origin;
list._origin = origin;
list._capacity = capacity;
list._level = level;
list._root = root;
list._tail = tail;
list.__ownerID = ownerID;
list.__hash = hash;
list.__altered = false;
return list;
}
var EMPTY_LIST;
function emptyList() {
return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
}
function updateList(list, index, value) {
index = wrapIndex(list, index);
if (index !== index) {
return list;
}
if (index >= list.size || index < 0) {
return list.withMutations(function(list ) {
index < 0 ?
setListBounds(list, index).set(0, value) :
setListBounds(list, 0, index + 1).set(index, value)
});
}
index += list._origin;
var newTail = list._tail;
var newRoot = list._root;
var didAlter = MakeRef(DID_ALTER);
if (index >= getTailOffset(list._capacity)) {
newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
} else {
newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
}
if (!didAlter.value) {
return list;
}
if (list.__ownerID) {
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
}
function updateVNode(node, ownerID, level, index, value, didAlter) {
var idx = (index >>> level) & MASK;
var nodeHas = node && idx < node.array.length;
if (!nodeHas && value === undefined) {
return node;
}
var newNode;
if (level > 0) {
var lowerNode = node && node.array[idx];
var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
if (newLowerNode === lowerNode) {
return node;
}
newNode = editableVNode(node, ownerID);
newNode.array[idx] = newLowerNode;
return newNode;
}
if (nodeHas && node.array[idx] === value) {
return node;
}
SetRef(didAlter);
newNode = editableVNode(node, ownerID);
if (value === undefined && idx === newNode.array.length - 1) {
newNode.array.pop();
} else {
newNode.array[idx] = value;
}
return newNode;
}
function editableVNode(node, ownerID) {
if (ownerID && node && ownerID === node.ownerID) {
return node;
}
return new VNode(node ? node.array.slice() : [], ownerID);
}
function listNodeFor(list, rawIndex) {
if (rawIndex >= getTailOffset(list._capacity)) {
return list._tail;
}
if (rawIndex < 1 << (list._level + SHIFT)) {
var node = list._root;
var level = list._level;
while (node && level > 0) {
node = node.array[(rawIndex >>> level) & MASK];
level -= SHIFT;
}
return node;
}
}
function setListBounds(list, begin, end) {
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
end = end | 0;
}
var owner = list.__ownerID || new OwnerID();
var oldOrigin = list._origin;
var oldCapacity = list._capacity;
var newOrigin = oldOrigin + begin;
var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
return list;
}
// If it's going to end after it starts, it's empty.
if (newOrigin >= newCapacity) {
return list.clear();
}
var newLevel = list._level;
var newRoot = list._root;
// New origin might need creating a higher root.
var offsetShift = 0;
while (newOrigin + offsetShift < 0) {
newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
newLevel += SHIFT;
offsetShift += 1 << newLevel;
}
if (offsetShift) {
newOrigin += offsetShift;
oldOrigin += offsetShift;
newCapacity += offsetShift;
oldCapacity += offsetShift;
}
var oldTailOffset = getTailOffset(oldCapacity);
var newTailOffset = getTailOffset(newCapacity);
// New size might need creating a higher root.
while (newTailOffset >= 1 << (newLevel + SHIFT)) {
newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
newLevel += SHIFT;
}
// Locate or create the new tail.
var oldTail = list._tail;
var newTail = newTailOffset < oldTailOffset ?
listNodeFor(list, newCapacity - 1) :
newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
// Merge Tail into tree.
if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
newRoot = editableVNode(newRoot, owner);
var node = newRoot;
for (var level = newLevel; level > SHIFT; level -= SHIFT) {
var idx = (oldTailOffset >>> level) & MASK;
node = node.array[idx] = editableVNode(node.array[idx], owner);
}
node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
}
// If the size has been reduced, there's a chance the tail needs to be trimmed.
if (newCapacity < oldCapacity) {
newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
}
// If the new origin is within the tail, then we do not need a root.
if (newOrigin >= newTailOffset) {
newOrigin -= newTailOffset;
newCapacity -= newTailOffset;
newLevel = SHIFT;
newRoot = null;
newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
// Otherwise, if the root has been trimmed, garbage collect.
} else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
offsetShift = 0;
// Identify the new top root node of the subtree of the old root.
while (newRoot) {
var beginIndex = (newOrigin >>> newLevel) & MASK;
if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
break;
}
if (beginIndex) {
offsetShift += (1 << newLevel) * beginIndex;
}
newLevel -= SHIFT;
newRoot = newRoot.array[beginIndex];
}
// Trim the new sides of the new root.
if (newRoot && newOrigin > oldOrigin) {
newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
}
if (newRoot && newTailOffset < oldTailOffset) {
newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
}
if (offsetShift) {
newOrigin -= offsetShift;
newCapacity -= offsetShift;
}
}
if (list.__ownerID) {
list.size = newCapacity - newOrigin;
list._origin = newOrigin;
list._capacity = newCapacity;
list._level = newLevel;
list._root = newRoot;
list._tail = newTail;
list.__hash = undefined;
list.__altered = true;
return list;
}
return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
}
function mergeIntoListWith(list, merger, iterables) {
var iters = [];
var maxSize = 0;
for (var ii = 0; ii < iterables.length; ii++) {
var value = iterables[ii];
var iter = IndexedIterable(value);
if (iter.size > maxSize) {
maxSize = iter.size;
}
if (!isIterable(value)) {
iter = iter.map(function(v ) {return fromJS(v)});
}
iters.push(iter);
}
if (maxSize > list.size) {
list = list.setSize(maxSize);
}
return mergeIntoCollectionWith(list, merger, iters);
}
function getTailOffset(size) {
return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
}
createClass(OrderedMap, Map);
// @pragma Construction
function OrderedMap(value) {
return value === null || value === undefined ? emptyOrderedMap() :
isOrderedMap(value) ? value :
emptyOrderedMap().withMutations(function(map ) {
var iter = KeyedIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v, k) {return map.set(k, v)});
});
}
OrderedMap.of = function(/*...values*/) {
return this(arguments);
};
OrderedMap.prototype.toString = function() {
return this.__toString('OrderedMap {', '}');
};
// @pragma Access
OrderedMap.prototype.get = function(k, notSetValue) {
var index = this._map.get(k);
return index !== undefined ? this._list.get(index)[1] : notSetValue;
};
// @pragma Modification
OrderedMap.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._map.clear();
this._list.clear();
return this;
}
return emptyOrderedMap();
};
OrderedMap.prototype.set = function(k, v) {
return updateOrderedMap(this, k, v);
};
OrderedMap.prototype.remove = function(k) {
return updateOrderedMap(this, k, NOT_SET);
};
OrderedMap.prototype.wasAltered = function() {
return this._map.wasAltered() || this._list.wasAltered();
};
OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._list.__iterate(
function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
reverse
);
};
OrderedMap.prototype.__iterator = function(type, reverse) {
return this._list.fromEntrySeq().__iterator(type, reverse);
};
OrderedMap.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
var newList = this._list.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
this._list = newList;
return this;
}
return makeOrderedMap(newMap, newList, ownerID, this.__hash);
};
function isOrderedMap(maybeOrderedMap) {
return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
}
OrderedMap.isOrderedMap = isOrderedMap;
OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
function makeOrderedMap(map, list, ownerID, hash) {
var omap = Object.create(OrderedMap.prototype);
omap.size = map ? map.size : 0;
omap._map = map;
omap._list = list;
omap.__ownerID = ownerID;
omap.__hash = hash;
return omap;
}
var EMPTY_ORDERED_MAP;
function emptyOrderedMap() {
return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
}
function updateOrderedMap(omap, k, v) {
var map = omap._map;
var list = omap._list;
var i = map.get(k);
var has = i !== undefined;
var newMap;
var newList;
if (v === NOT_SET) { // removed
if (!has) {
return omap;
}
if (list.size >= SIZE && list.size >= map.size * 2) {
newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
if (omap.__ownerID) {
newMap.__ownerID = newList.__ownerID = omap.__ownerID;
}
} else {
newMap = map.remove(k);
newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
}
} else {
if (has) {
if (v === list.get(i)[1]) {
return omap;
}
newMap = map;
newList = list.set(i, [k, v]);
} else {
newMap = map.set(k, list.size);
newList = list.set(list.size, [k, v]);
}
}
if (omap.__ownerID) {
omap.size = newMap.size;
omap._map = newMap;
omap._list = newList;
omap.__hash = undefined;
return omap;
}
return makeOrderedMap(newMap, newList);
}
createClass(ToKeyedSequence, KeyedSeq);
function ToKeyedSequence(indexed, useKeys) {
this._iter = indexed;
this._useKeys = useKeys;
this.size = indexed.size;
}
ToKeyedSequence.prototype.get = function(key, notSetValue) {
return this._iter.get(key, notSetValue);
};
ToKeyedSequence.prototype.has = function(key) {
return this._iter.has(key);
};
ToKeyedSequence.prototype.valueSeq = function() {
return this._iter.valueSeq();
};
ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
var reversedSequence = reverseFactory(this, true);
if (!this._useKeys) {
reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
}
return reversedSequence;
};
ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
var mappedSequence = mapFactory(this, mapper, context);
if (!this._useKeys) {
mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
}
return mappedSequence;
};
ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var ii;
return this._iter.__iterate(
this._useKeys ?
function(v, k) {return fn(v, k, this$0)} :
((ii = reverse ? resolveSize(this) : 0),
function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
reverse
);
};
ToKeyedSequence.prototype.__iterator = function(type, reverse) {
if (this._useKeys) {
return this._iter.__iterator(type, reverse);
}
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var ii = reverse ? resolveSize(this) : 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, reverse ? --ii : ii++, step.value, step);
});
};
ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
createClass(ToIndexedSequence, IndexedSeq);
function ToIndexedSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToIndexedSequence.prototype.includes = function(value) {
return this._iter.includes(value);
};
ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
var iterations = 0;
return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
};
ToIndexedSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, iterations++, step.value, step)
});
};
createClass(ToSetSequence, SetSeq);
function ToSetSequence(iter) {
this._iter = iter;
this.size = iter.size;
}
ToSetSequence.prototype.has = function(key) {
return this._iter.includes(key);
};
ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
};
ToSetSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
var step = iterator.next();
return step.done ? step :
iteratorValue(type, step.value, step.value, step);
});
};
createClass(FromEntriesSequence, KeyedSeq);
function FromEntriesSequence(entries) {
this._iter = entries;
this.size = entries.size;
}
FromEntriesSequence.prototype.entrySeq = function() {
return this._iter.toSeq();
};
FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._iter.__iterate(function(entry ) {
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return fn(
indexedIterable ? entry.get(1) : entry[1],
indexedIterable ? entry.get(0) : entry[0],
this$0
);
}
}, reverse);
};
FromEntriesSequence.prototype.__iterator = function(type, reverse) {
var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
// Check if entry exists first so array access doesn't throw for holes
// in the parent iteration.
if (entry) {
validateEntry(entry);
var indexedIterable = isIterable(entry);
return iteratorValue(
type,
indexedIterable ? entry.get(0) : entry[0],
indexedIterable ? entry.get(1) : entry[1],
step
);
}
}
});
};
ToIndexedSequence.prototype.cacheResult =
ToKeyedSequence.prototype.cacheResult =
ToSetSequence.prototype.cacheResult =
FromEntriesSequence.prototype.cacheResult =
cacheResultThrough;
function flipFactory(iterable) {
var flipSequence = makeSequence(iterable);
flipSequence._iter = iterable;
flipSequence.size = iterable.size;
flipSequence.flip = function() {return iterable};
flipSequence.reverse = function () {
var reversedSequence = iterable.reverse.apply(this); // super.reverse()
reversedSequence.flip = function() {return iterable.reverse()};
return reversedSequence;
};
flipSequence.has = function(key ) {return iterable.includes(key)};
flipSequence.includes = function(key ) {return iterable.has(key)};
flipSequence.cacheResult = cacheResultThrough;
flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
}
flipSequence.__iteratorUncached = function(type, reverse) {
if (type === ITERATE_ENTRIES) {
var iterator = iterable.__iterator(type, reverse);
return new Iterator(function() {
var step = iterator.next();
if (!step.done) {
var k = step.value[0];
step.value[0] = step.value[1];
step.value[1] = k;
}
return step;
});
}
return iterable.__iterator(
type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
reverse
);
}
return flipSequence;
}
function mapFactory(iterable, mapper, context) {
var mappedSequence = makeSequence(iterable);
mappedSequence.size = iterable.size;
mappedSequence.has = function(key ) {return iterable.has(key)};
mappedSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v === NOT_SET ?
notSetValue :
mapper.call(context, v, key, iterable);
};
mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(
function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
reverse
);
}
mappedSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
return new Iterator(function() {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
return iteratorValue(
type,
key,
mapper.call(context, entry[1], key, iterable),
step
);
});
}
return mappedSequence;
}
function reverseFactory(iterable, useKeys) {
var reversedSequence = makeSequence(iterable);
reversedSequence._iter = iterable;
reversedSequence.size = iterable.size;
reversedSequence.reverse = function() {return iterable};
if (iterable.flip) {
reversedSequence.flip = function () {
var flipSequence = flipFactory(iterable);
flipSequence.reverse = function() {return iterable.flip()};
return flipSequence;
};
}
reversedSequence.get = function(key, notSetValue)
{return iterable.get(useKeys ? key : -1 - key, notSetValue)};
reversedSequence.has = function(key )
{return iterable.has(useKeys ? key : -1 - key)};
reversedSequence.includes = function(value ) {return iterable.includes(value)};
reversedSequence.cacheResult = cacheResultThrough;
reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
};
reversedSequence.__iterator =
function(type, reverse) {return iterable.__iterator(type, !reverse)};
return reversedSequence;
}
function filterFactory(iterable, predicate, context, useKeys) {
var filterSequence = makeSequence(iterable);
if (useKeys) {
filterSequence.has = function(key ) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
};
filterSequence.get = function(key, notSetValue) {
var v = iterable.get(key, NOT_SET);
return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
v : notSetValue;
};
}
filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
}, reverse);
return iterations;
};
filterSequence.__iteratorUncached = function (type, reverse) {
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterations = 0;
return new Iterator(function() {
while (true) {
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var key = entry[0];
var value = entry[1];
if (predicate.call(context, value, key, iterable)) {
return iteratorValue(type, useKeys ? key : iterations++, value, step);
}
}
});
}
return filterSequence;
}
function countByFactory(iterable, grouper, context) {
var groups = Map().asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
0,
function(a ) {return a + 1}
);
});
return groups.asImmutable();
}
function groupByFactory(iterable, grouper, context) {
var isKeyedIter = isKeyed(iterable);
var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
iterable.__iterate(function(v, k) {
groups.update(
grouper.call(context, v, k, iterable),
function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
);
});
var coerce = iterableClass(iterable);
return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
}
function sliceFactory(iterable, begin, end, useKeys) {
var originalSize = iterable.size;
// Sanitize begin & end using this shorthand for ToInt32(argument)
// http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
if (begin !== undefined) {
begin = begin | 0;
}
if (end !== undefined) {
if (end === Infinity) {
end = originalSize;
} else {
end = end | 0;
}
}
if (wholeSlice(begin, end, originalSize)) {
return iterable;
}
var resolvedBegin = resolveBegin(begin, originalSize);
var resolvedEnd = resolveEnd(end, originalSize);
// begin or end will be NaN if they were provided as negative numbers and
// this iterable's size is unknown. In that case, cache first so there is
// a known size and these do not resolve to NaN.
if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
}
// Note: resolvedEnd is undefined when the original sequence's length is
// unknown and this slice did not supply an end and should contain all
// elements after resolvedBegin.
// In that case, resolvedSize will be NaN and sliceSize will remain undefined.
var resolvedSize = resolvedEnd - resolvedBegin;
var sliceSize;
if (resolvedSize === resolvedSize) {
sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
}
var sliceSeq = makeSequence(iterable);
// If iterable.size is undefined, the size of the realized sliceSeq is
// unknown at this point unless the number of items to slice is 0
sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
sliceSeq.get = function (index, notSetValue) {
index = wrapIndex(this, index);
return index >= 0 && index < sliceSize ?
iterable.get(index + resolvedBegin, notSetValue) :
notSetValue;
}
}
sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (sliceSize === 0) {
return 0;
}
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var skipped = 0;
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k) {
if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
iterations !== sliceSize;
}
});
return iterations;
};
sliceSeq.__iteratorUncached = function(type, reverse) {
if (sliceSize !== 0 && reverse) {
return this.cacheResult().__iterator(type, reverse);
}
// Don't bother instantiating parent iterator if taking 0.
var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
var skipped = 0;
var iterations = 0;
return new Iterator(function() {
while (skipped++ < resolvedBegin) {
iterator.next();
}
if (++iterations > sliceSize) {
return iteratorDone();
}
var step = iterator.next();
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations - 1, undefined, step);
} else {
return iteratorValue(type, iterations - 1, step.value[1], step);
}
});
}
return sliceSeq;
}
function takeWhileFactory(iterable, predicate, context) {
var takeSequence = makeSequence(iterable);
takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var iterations = 0;
iterable.__iterate(function(v, k, c)
{return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
);
return iterations;
};
takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var iterating = true;
return new Iterator(function() {
if (!iterating) {
return iteratorDone();
}
var step = iterator.next();
if (step.done) {
return step;
}
var entry = step.value;
var k = entry[0];
var v = entry[1];
if (!predicate.call(context, v, k, this$0)) {
iterating = false;
return iteratorDone();
}
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return takeSequence;
}
function skipWhileFactory(iterable, predicate, context, useKeys) {
var skipSequence = makeSequence(iterable);
skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterate(fn, reverse);
}
var isSkipping = true;
var iterations = 0;
iterable.__iterate(function(v, k, c) {
if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
iterations++;
return fn(v, useKeys ? k : iterations - 1, this$0);
}
});
return iterations;
};
skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
if (reverse) {
return this.cacheResult().__iterator(type, reverse);
}
var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
var skipping = true;
var iterations = 0;
return new Iterator(function() {
var step, k, v;
do {
step = iterator.next();
if (step.done) {
if (useKeys || type === ITERATE_VALUES) {
return step;
} else if (type === ITERATE_KEYS) {
return iteratorValue(type, iterations++, undefined, step);
} else {
return iteratorValue(type, iterations++, step.value[1], step);
}
}
var entry = step.value;
k = entry[0];
v = entry[1];
skipping && (skipping = predicate.call(context, v, k, this$0));
} while (skipping);
return type === ITERATE_ENTRIES ? step :
iteratorValue(type, k, v, step);
});
};
return skipSequence;
}
function concatFactory(iterable, values) {
var isKeyedIterable = isKeyed(iterable);
var iters = [iterable].concat(values).map(function(v ) {
if (!isIterable(v)) {
v = isKeyedIterable ?
keyedSeqFromValue(v) :
indexedSeqFromValue(Array.isArray(v) ? v : [v]);
} else if (isKeyedIterable) {
v = KeyedIterable(v);
}
return v;
}).filter(function(v ) {return v.size !== 0});
if (iters.length === 0) {
return iterable;
}
if (iters.length === 1) {
var singleton = iters[0];
if (singleton === iterable ||
isKeyedIterable && isKeyed(singleton) ||
isIndexed(iterable) && isIndexed(singleton)) {
return singleton;
}
}
var concatSeq = new ArraySeq(iters);
if (isKeyedIterable) {
concatSeq = concatSeq.toKeyedSeq();
} else if (!isIndexed(iterable)) {
concatSeq = concatSeq.toSetSeq();
}
concatSeq = concatSeq.flatten(true);
concatSeq.size = iters.reduce(
function(sum, seq) {
if (sum !== undefined) {
var size = seq.size;
if (size !== undefined) {
return sum + size;
}
}
},
0
);
return concatSeq;
}
function flattenFactory(iterable, depth, useKeys) {
var flatSequence = makeSequence(iterable);
flatSequence.__iterateUncached = function(fn, reverse) {
var iterations = 0;
var stopped = false;
function flatDeep(iter, currentDepth) {var this$0 = this;
iter.__iterate(function(v, k) {
if ((!depth || currentDepth < depth) && isIterable(v)) {
flatDeep(v, currentDepth + 1);
} else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
stopped = true;
}
return !stopped;
}, reverse);
}
flatDeep(iterable, 0);
return iterations;
}
flatSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(type, reverse);
var stack = [];
var iterations = 0;
return new Iterator(function() {
while (iterator) {
var step = iterator.next();
if (step.done !== false) {
iterator = stack.pop();
continue;
}
var v = step.value;
if (type === ITERATE_ENTRIES) {
v = v[1];
}
if ((!depth || stack.length < depth) && isIterable(v)) {
stack.push(iterator);
iterator = v.__iterator(type, reverse);
} else {
return useKeys ? step : iteratorValue(type, iterations++, v, step);
}
}
return iteratorDone();
});
}
return flatSequence;
}
function flatMapFactory(iterable, mapper, context) {
var coerce = iterableClass(iterable);
return iterable.toSeq().map(
function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
).flatten(true);
}
function interposeFactory(iterable, separator) {
var interposedSequence = makeSequence(iterable);
interposedSequence.size = iterable.size && iterable.size * 2 -1;
interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
var iterations = 0;
iterable.__iterate(function(v, k)
{return (!iterations || fn(separator, iterations++, this$0) !== false) &&
fn(v, iterations++, this$0) !== false},
reverse
);
return iterations;
};
interposedSequence.__iteratorUncached = function(type, reverse) {
var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
var iterations = 0;
var step;
return new Iterator(function() {
if (!step || iterations % 2) {
step = iterator.next();
if (step.done) {
return step;
}
}
return iterations % 2 ?
iteratorValue(type, iterations++, separator) :
iteratorValue(type, iterations++, step.value, step);
});
};
return interposedSequence;
}
function sortFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
var isKeyedIterable = isKeyed(iterable);
var index = 0;
var entries = iterable.toSeq().map(
function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
).toArray();
entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
isKeyedIterable ?
function(v, i) { entries[i].length = 2; } :
function(v, i) { entries[i] = v[1]; }
);
return isKeyedIterable ? KeyedSeq(entries) :
isIndexed(iterable) ? IndexedSeq(entries) :
SetSeq(entries);
}
function maxFactory(iterable, comparator, mapper) {
if (!comparator) {
comparator = defaultComparator;
}
if (mapper) {
var entry = iterable.toSeq()
.map(function(v, k) {return [v, mapper(v, k, iterable)]})
.reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
return entry && entry[0];
} else {
return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
}
}
function maxCompare(comparator, a, b) {
var comp = comparator(b, a);
// b is considered the new max if the comparator declares them equal, but
// they are not equal and b is in fact a nullish value.
return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
}
function zipWithFactory(keyIter, zipper, iters) {
var zipSequence = makeSequence(keyIter);
zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
// Note: this a generic base implementation of __iterate in terms of
// __iterator which may be more generically useful in the future.
zipSequence.__iterate = function(fn, reverse) {
/* generic:
var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
iterations++;
if (fn(step.value[1], step.value[0], this) === false) {
break;
}
}
return iterations;
*/
// indexed:
var iterator = this.__iterator(ITERATE_VALUES, reverse);
var step;
var iterations = 0;
while (!(step = iterator.next()).done) {
if (fn(step.value, iterations++, this) === false) {
break;
}
}
return iterations;
};
zipSequence.__iteratorUncached = function(type, reverse) {
var iterators = iters.map(function(i )
{return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
);
var iterations = 0;
var isDone = false;
return new Iterator(function() {
var steps;
if (!isDone) {
steps = iterators.map(function(i ) {return i.next()});
isDone = steps.some(function(s ) {return s.done});
}
if (isDone) {
return iteratorDone();
}
return iteratorValue(
type,
iterations++,
zipper.apply(null, steps.map(function(s ) {return s.value}))
);
});
};
return zipSequence
}
// #pragma Helper Functions
function reify(iter, seq) {
return isSeq(iter) ? seq : iter.constructor(seq);
}
function validateEntry(entry) {
if (entry !== Object(entry)) {
throw new TypeError('Expected [K, V] tuple: ' + entry);
}
}
function resolveSize(iter) {
assertNotInfinite(iter.size);
return ensureSize(iter);
}
function iterableClass(iterable) {
return isKeyed(iterable) ? KeyedIterable :
isIndexed(iterable) ? IndexedIterable :
SetIterable;
}
function makeSequence(iterable) {
return Object.create(
(
isKeyed(iterable) ? KeyedSeq :
isIndexed(iterable) ? IndexedSeq :
SetSeq
).prototype
);
}
function cacheResultThrough() {
if (this._iter.cacheResult) {
this._iter.cacheResult();
this.size = this._iter.size;
return this;
} else {
return Seq.prototype.cacheResult.call(this);
}
}
function defaultComparator(a, b) {
return a > b ? 1 : a < b ? -1 : 0;
}
function forceIterator(keyPath) {
var iter = getIterator(keyPath);
if (!iter) {
// Array might not be iterable in this environment, so we need a fallback
// to our wrapped type.
if (!isArrayLike(keyPath)) {
throw new TypeError('Expected iterable or array-like: ' + keyPath);
}
iter = getIterator(Iterable(keyPath));
}
return iter;
}
createClass(Record, KeyedCollection);
function Record(defaultValues, name) {
var hasInitialized;
var RecordType = function Record(values) {
if (values instanceof RecordType) {
return values;
}
if (!(this instanceof RecordType)) {
return new RecordType(values);
}
if (!hasInitialized) {
hasInitialized = true;
var keys = Object.keys(defaultValues);
setProps(RecordTypePrototype, keys);
RecordTypePrototype.size = keys.length;
RecordTypePrototype._name = name;
RecordTypePrototype._keys = keys;
RecordTypePrototype._defaultValues = defaultValues;
}
this._map = Map(values);
};
var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
RecordTypePrototype.constructor = RecordType;
return RecordType;
}
Record.prototype.toString = function() {
return this.__toString(recordName(this) + ' {', '}');
};
// @pragma Access
Record.prototype.has = function(k) {
return this._defaultValues.hasOwnProperty(k);
};
Record.prototype.get = function(k, notSetValue) {
if (!this.has(k)) {
return notSetValue;
}
var defaultVal = this._defaultValues[k];
return this._map ? this._map.get(k, defaultVal) : defaultVal;
};
// @pragma Modification
Record.prototype.clear = function() {
if (this.__ownerID) {
this._map && this._map.clear();
return this;
}
var RecordType = this.constructor;
return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
};
Record.prototype.set = function(k, v) {
if (!this.has(k)) {
throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
}
if (this._map && !this._map.has(k)) {
var defaultVal = this._defaultValues[k];
if (v === defaultVal) {
return this;
}
}
var newMap = this._map && this._map.set(k, v);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.remove = function(k) {
if (!this.has(k)) {
return this;
}
var newMap = this._map && this._map.remove(k);
if (this.__ownerID || newMap === this._map) {
return this;
}
return makeRecord(this, newMap);
};
Record.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
};
Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
};
Record.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map && this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return makeRecord(this, newMap, ownerID);
};
var RecordPrototype = Record.prototype;
RecordPrototype[DELETE] = RecordPrototype.remove;
RecordPrototype.deleteIn =
RecordPrototype.removeIn = MapPrototype.removeIn;
RecordPrototype.merge = MapPrototype.merge;
RecordPrototype.mergeWith = MapPrototype.mergeWith;
RecordPrototype.mergeIn = MapPrototype.mergeIn;
RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
RecordPrototype.setIn = MapPrototype.setIn;
RecordPrototype.update = MapPrototype.update;
RecordPrototype.updateIn = MapPrototype.updateIn;
RecordPrototype.withMutations = MapPrototype.withMutations;
RecordPrototype.asMutable = MapPrototype.asMutable;
RecordPrototype.asImmutable = MapPrototype.asImmutable;
function makeRecord(likeRecord, map, ownerID) {
var record = Object.create(Object.getPrototypeOf(likeRecord));
record._map = map;
record.__ownerID = ownerID;
return record;
}
function recordName(record) {
return record._name || record.constructor.name || 'Record';
}
function setProps(prototype, names) {
try {
names.forEach(setProp.bind(undefined, prototype));
} catch (error) {
// Object.defineProperty failed. Probably IE8.
}
}
function setProp(prototype, name) {
Object.defineProperty(prototype, name, {
get: function() {
return this.get(name);
},
set: function(value) {
invariant(this.__ownerID, 'Cannot set on an immutable record.');
this.set(name, value);
}
});
}
createClass(Set, SetCollection);
// @pragma Construction
function Set(value) {
return value === null || value === undefined ? emptySet() :
isSet(value) && !isOrdered(value) ? value :
emptySet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
Set.of = function(/*...values*/) {
return this(arguments);
};
Set.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
Set.prototype.toString = function() {
return this.__toString('Set {', '}');
};
// @pragma Access
Set.prototype.has = function(value) {
return this._map.has(value);
};
// @pragma Modification
Set.prototype.add = function(value) {
return updateSet(this, this._map.set(value, true));
};
Set.prototype.remove = function(value) {
return updateSet(this, this._map.remove(value));
};
Set.prototype.clear = function() {
return updateSet(this, this._map.clear());
};
// @pragma Composition
Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
iters = iters.filter(function(x ) {return x.size !== 0});
if (iters.length === 0) {
return this;
}
if (this.size === 0 && !this.__ownerID && iters.length === 1) {
return this.constructor(iters[0]);
}
return this.withMutations(function(set ) {
for (var ii = 0; ii < iters.length; ii++) {
SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
}
});
};
Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (!iters.every(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
if (iters.length === 0) {
return this;
}
iters = iters.map(function(iter ) {return SetIterable(iter)});
var originalSet = this;
return this.withMutations(function(set ) {
originalSet.forEach(function(value ) {
if (iters.some(function(iter ) {return iter.includes(value)})) {
set.remove(value);
}
});
});
};
Set.prototype.merge = function() {
return this.union.apply(this, arguments);
};
Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
return this.union.apply(this, iters);
};
Set.prototype.sort = function(comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator));
};
Set.prototype.sortBy = function(mapper, comparator) {
// Late binding
return OrderedSet(sortFactory(this, comparator, mapper));
};
Set.prototype.wasAltered = function() {
return this._map.wasAltered();
};
Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
};
Set.prototype.__iterator = function(type, reverse) {
return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
};
Set.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
var newMap = this._map.__ensureOwner(ownerID);
if (!ownerID) {
this.__ownerID = ownerID;
this._map = newMap;
return this;
}
return this.__make(newMap, ownerID);
};
function isSet(maybeSet) {
return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
}
Set.isSet = isSet;
var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
var SetPrototype = Set.prototype;
SetPrototype[IS_SET_SENTINEL] = true;
SetPrototype[DELETE] = SetPrototype.remove;
SetPrototype.mergeDeep = SetPrototype.merge;
SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
SetPrototype.withMutations = MapPrototype.withMutations;
SetPrototype.asMutable = MapPrototype.asMutable;
SetPrototype.asImmutable = MapPrototype.asImmutable;
SetPrototype.__empty = emptySet;
SetPrototype.__make = makeSet;
function updateSet(set, newMap) {
if (set.__ownerID) {
set.size = newMap.size;
set._map = newMap;
return set;
}
return newMap === set._map ? set :
newMap.size === 0 ? set.__empty() :
set.__make(newMap);
}
function makeSet(map, ownerID) {
var set = Object.create(SetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_SET;
function emptySet() {
return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
}
createClass(OrderedSet, Set);
// @pragma Construction
function OrderedSet(value) {
return value === null || value === undefined ? emptyOrderedSet() :
isOrderedSet(value) ? value :
emptyOrderedSet().withMutations(function(set ) {
var iter = SetIterable(value);
assertNotInfinite(iter.size);
iter.forEach(function(v ) {return set.add(v)});
});
}
OrderedSet.of = function(/*...values*/) {
return this(arguments);
};
OrderedSet.fromKeys = function(value) {
return this(KeyedIterable(value).keySeq());
};
OrderedSet.prototype.toString = function() {
return this.__toString('OrderedSet {', '}');
};
function isOrderedSet(maybeOrderedSet) {
return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
}
OrderedSet.isOrderedSet = isOrderedSet;
var OrderedSetPrototype = OrderedSet.prototype;
OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
OrderedSetPrototype.__empty = emptyOrderedSet;
OrderedSetPrototype.__make = makeOrderedSet;
function makeOrderedSet(map, ownerID) {
var set = Object.create(OrderedSetPrototype);
set.size = map ? map.size : 0;
set._map = map;
set.__ownerID = ownerID;
return set;
}
var EMPTY_ORDERED_SET;
function emptyOrderedSet() {
return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
}
createClass(Stack, IndexedCollection);
// @pragma Construction
function Stack(value) {
return value === null || value === undefined ? emptyStack() :
isStack(value) ? value :
emptyStack().unshiftAll(value);
}
Stack.of = function(/*...values*/) {
return this(arguments);
};
Stack.prototype.toString = function() {
return this.__toString('Stack [', ']');
};
// @pragma Access
Stack.prototype.get = function(index, notSetValue) {
var head = this._head;
index = wrapIndex(this, index);
while (head && index--) {
head = head.next;
}
return head ? head.value : notSetValue;
};
Stack.prototype.peek = function() {
return this._head && this._head.value;
};
// @pragma Modification
Stack.prototype.push = function(/*...values*/) {
if (arguments.length === 0) {
return this;
}
var newSize = this.size + arguments.length;
var head = this._head;
for (var ii = arguments.length - 1; ii >= 0; ii--) {
head = {
value: arguments[ii],
next: head
};
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pushAll = function(iter) {
iter = IndexedIterable(iter);
if (iter.size === 0) {
return this;
}
assertNotInfinite(iter.size);
var newSize = this.size;
var head = this._head;
iter.reverse().forEach(function(value ) {
newSize++;
head = {
value: value,
next: head
};
});
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
Stack.prototype.pop = function() {
return this.slice(1);
};
Stack.prototype.unshift = function(/*...values*/) {
return this.push.apply(this, arguments);
};
Stack.prototype.unshiftAll = function(iter) {
return this.pushAll(iter);
};
Stack.prototype.shift = function() {
return this.pop.apply(this, arguments);
};
Stack.prototype.clear = function() {
if (this.size === 0) {
return this;
}
if (this.__ownerID) {
this.size = 0;
this._head = undefined;
this.__hash = undefined;
this.__altered = true;
return this;
}
return emptyStack();
};
Stack.prototype.slice = function(begin, end) {
if (wholeSlice(begin, end, this.size)) {
return this;
}
var resolvedBegin = resolveBegin(begin, this.size);
var resolvedEnd = resolveEnd(end, this.size);
if (resolvedEnd !== this.size) {
// super.slice(begin, end);
return IndexedCollection.prototype.slice.call(this, begin, end);
}
var newSize = this.size - resolvedBegin;
var head = this._head;
while (resolvedBegin--) {
head = head.next;
}
if (this.__ownerID) {
this.size = newSize;
this._head = head;
this.__hash = undefined;
this.__altered = true;
return this;
}
return makeStack(newSize, head);
};
// @pragma Mutability
Stack.prototype.__ensureOwner = function(ownerID) {
if (ownerID === this.__ownerID) {
return this;
}
if (!ownerID) {
this.__ownerID = ownerID;
this.__altered = false;
return this;
}
return makeStack(this.size, this._head, ownerID, this.__hash);
};
// @pragma Iteration
Stack.prototype.__iterate = function(fn, reverse) {
if (reverse) {
return this.reverse().__iterate(fn);
}
var iterations = 0;
var node = this._head;
while (node) {
if (fn(node.value, iterations++, this) === false) {
break;
}
node = node.next;
}
return iterations;
};
Stack.prototype.__iterator = function(type, reverse) {
if (reverse) {
return this.reverse().__iterator(type);
}
var iterations = 0;
var node = this._head;
return new Iterator(function() {
if (node) {
var value = node.value;
node = node.next;
return iteratorValue(type, iterations++, value);
}
return iteratorDone();
});
};
function isStack(maybeStack) {
return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
}
Stack.isStack = isStack;
var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
var StackPrototype = Stack.prototype;
StackPrototype[IS_STACK_SENTINEL] = true;
StackPrototype.withMutations = MapPrototype.withMutations;
StackPrototype.asMutable = MapPrototype.asMutable;
StackPrototype.asImmutable = MapPrototype.asImmutable;
StackPrototype.wasAltered = MapPrototype.wasAltered;
function makeStack(size, head, ownerID, hash) {
var map = Object.create(StackPrototype);
map.size = size;
map._head = head;
map.__ownerID = ownerID;
map.__hash = hash;
map.__altered = false;
return map;
}
var EMPTY_STACK;
function emptyStack() {
return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
}
/**
* Contributes additional methods to a constructor
*/
function mixin(ctor, methods) {
var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
Object.keys(methods).forEach(keyCopier);
Object.getOwnPropertySymbols &&
Object.getOwnPropertySymbols(methods).forEach(keyCopier);
return ctor;
}
Iterable.Iterator = Iterator;
mixin(Iterable, {
// ### Conversion to other types
toArray: function() {
assertNotInfinite(this.size);
var array = new Array(this.size || 0);
this.valueSeq().__iterate(function(v, i) { array[i] = v; });
return array;
},
toIndexedSeq: function() {
return new ToIndexedSequence(this);
},
toJS: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
).__toJS();
},
toJSON: function() {
return this.toSeq().map(
function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
).__toJS();
},
toKeyedSeq: function() {
return new ToKeyedSequence(this, true);
},
toMap: function() {
// Use Late Binding here to solve the circular dependency.
return Map(this.toKeyedSeq());
},
toObject: function() {
assertNotInfinite(this.size);
var object = {};
this.__iterate(function(v, k) { object[k] = v; });
return object;
},
toOrderedMap: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedMap(this.toKeyedSeq());
},
toOrderedSet: function() {
// Use Late Binding here to solve the circular dependency.
return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
},
toSet: function() {
// Use Late Binding here to solve the circular dependency.
return Set(isKeyed(this) ? this.valueSeq() : this);
},
toSetSeq: function() {
return new ToSetSequence(this);
},
toSeq: function() {
return isIndexed(this) ? this.toIndexedSeq() :
isKeyed(this) ? this.toKeyedSeq() :
this.toSetSeq();
},
toStack: function() {
// Use Late Binding here to solve the circular dependency.
return Stack(isKeyed(this) ? this.valueSeq() : this);
},
toList: function() {
// Use Late Binding here to solve the circular dependency.
return List(isKeyed(this) ? this.valueSeq() : this);
},
// ### Common JavaScript methods and properties
toString: function() {
return '[Iterable]';
},
__toString: function(head, tail) {
if (this.size === 0) {
return head + tail;
}
return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
},
// ### ES6 Collection methods (ES6 Array and Map)
concat: function() {var values = SLICE$0.call(arguments, 0);
return reify(this, concatFactory(this, values));
},
includes: function(searchValue) {
return this.some(function(value ) {return is(value, searchValue)});
},
entries: function() {
return this.__iterator(ITERATE_ENTRIES);
},
every: function(predicate, context) {
assertNotInfinite(this.size);
var returnValue = true;
this.__iterate(function(v, k, c) {
if (!predicate.call(context, v, k, c)) {
returnValue = false;
return false;
}
});
return returnValue;
},
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, true));
},
find: function(predicate, context, notSetValue) {
var entry = this.findEntry(predicate, context);
return entry ? entry[1] : notSetValue;
},
forEach: function(sideEffect, context) {
assertNotInfinite(this.size);
return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
},
join: function(separator) {
assertNotInfinite(this.size);
separator = separator !== undefined ? '' + separator : ',';
var joined = '';
var isFirst = true;
this.__iterate(function(v ) {
isFirst ? (isFirst = false) : (joined += separator);
joined += v !== null && v !== undefined ? v.toString() : '';
});
return joined;
},
keys: function() {
return this.__iterator(ITERATE_KEYS);
},
map: function(mapper, context) {
return reify(this, mapFactory(this, mapper, context));
},
reduce: function(reducer, initialReduction, context) {
assertNotInfinite(this.size);
var reduction;
var useFirst;
if (arguments.length < 2) {
useFirst = true;
} else {
reduction = initialReduction;
}
this.__iterate(function(v, k, c) {
if (useFirst) {
useFirst = false;
reduction = v;
} else {
reduction = reducer.call(context, reduction, v, k, c);
}
});
return reduction;
},
reduceRight: function(reducer, initialReduction, context) {
var reversed = this.toKeyedSeq().reverse();
return reversed.reduce.apply(reversed, arguments);
},
reverse: function() {
return reify(this, reverseFactory(this, true));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, true));
},
some: function(predicate, context) {
return !this.every(not(predicate), context);
},
sort: function(comparator) {
return reify(this, sortFactory(this, comparator));
},
values: function() {
return this.__iterator(ITERATE_VALUES);
},
// ### More sequential methods
butLast: function() {
return this.slice(0, -1);
},
isEmpty: function() {
return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
},
count: function(predicate, context) {
return ensureSize(
predicate ? this.toSeq().filter(predicate, context) : this
);
},
countBy: function(grouper, context) {
return countByFactory(this, grouper, context);
},
equals: function(other) {
return deepEqual(this, other);
},
entrySeq: function() {
var iterable = this;
if (iterable._cache) {
// We cache as an entries array, so we can just return the cache!
return new ArraySeq(iterable._cache);
}
var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
return entriesSequence;
},
filterNot: function(predicate, context) {
return this.filter(not(predicate), context);
},
findEntry: function(predicate, context, notSetValue) {
var found = notSetValue;
this.__iterate(function(v, k, c) {
if (predicate.call(context, v, k, c)) {
found = [k, v];
return false;
}
});
return found;
},
findKey: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry && entry[0];
},
findLast: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
},
findLastEntry: function(predicate, context, notSetValue) {
return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
},
findLastKey: function(predicate, context) {
return this.toKeyedSeq().reverse().findKey(predicate, context);
},
first: function() {
return this.find(returnTrue);
},
flatMap: function(mapper, context) {
return reify(this, flatMapFactory(this, mapper, context));
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, true));
},
fromEntrySeq: function() {
return new FromEntriesSequence(this);
},
get: function(searchKey, notSetValue) {
return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
},
getIn: function(searchKeyPath, notSetValue) {
var nested = this;
// Note: in an ES6 environment, we would prefer:
// for (var key of searchKeyPath) {
var iter = forceIterator(searchKeyPath);
var step;
while (!(step = iter.next()).done) {
var key = step.value;
nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
if (nested === NOT_SET) {
return notSetValue;
}
}
return nested;
},
groupBy: function(grouper, context) {
return groupByFactory(this, grouper, context);
},
has: function(searchKey) {
return this.get(searchKey, NOT_SET) !== NOT_SET;
},
hasIn: function(searchKeyPath) {
return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
},
isSubset: function(iter) {
iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
return this.every(function(value ) {return iter.includes(value)});
},
isSuperset: function(iter) {
iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
return iter.isSubset(this);
},
keyOf: function(searchValue) {
return this.findKey(function(value ) {return is(value, searchValue)});
},
keySeq: function() {
return this.toSeq().map(keyMapper).toIndexedSeq();
},
last: function() {
return this.toSeq().reverse().first();
},
lastKeyOf: function(searchValue) {
return this.toKeyedSeq().reverse().keyOf(searchValue);
},
max: function(comparator) {
return maxFactory(this, comparator);
},
maxBy: function(mapper, comparator) {
return maxFactory(this, comparator, mapper);
},
min: function(comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
},
minBy: function(mapper, comparator) {
return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
},
rest: function() {
return this.slice(1);
},
skip: function(amount) {
return this.slice(Math.max(0, amount));
},
skipLast: function(amount) {
return reify(this, this.toSeq().reverse().skip(amount).reverse());
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, true));
},
skipUntil: function(predicate, context) {
return this.skipWhile(not(predicate), context);
},
sortBy: function(mapper, comparator) {
return reify(this, sortFactory(this, comparator, mapper));
},
take: function(amount) {
return this.slice(0, Math.max(0, amount));
},
takeLast: function(amount) {
return reify(this, this.toSeq().reverse().take(amount).reverse());
},
takeWhile: function(predicate, context) {
return reify(this, takeWhileFactory(this, predicate, context));
},
takeUntil: function(predicate, context) {
return this.takeWhile(not(predicate), context);
},
valueSeq: function() {
return this.toIndexedSeq();
},
// ### Hashable Object
hashCode: function() {
return this.__hash || (this.__hash = hashIterable(this));
}
// ### Internal
// abstract __iterate(fn, reverse)
// abstract __iterator(type, reverse)
});
// var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
// var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
// var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
// var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
var IterablePrototype = Iterable.prototype;
IterablePrototype[IS_ITERABLE_SENTINEL] = true;
IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
IterablePrototype.__toJS = IterablePrototype.toArray;
IterablePrototype.__toStringMapper = quoteString;
IterablePrototype.inspect =
IterablePrototype.toSource = function() { return this.toString(); };
IterablePrototype.chain = IterablePrototype.flatMap;
IterablePrototype.contains = IterablePrototype.includes;
mixin(KeyedIterable, {
// ### More sequential methods
flip: function() {
return reify(this, flipFactory(this));
},
mapEntries: function(mapper, context) {var this$0 = this;
var iterations = 0;
return reify(this,
this.toSeq().map(
function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
).fromEntrySeq()
);
},
mapKeys: function(mapper, context) {var this$0 = this;
return reify(this,
this.toSeq().flip().map(
function(k, v) {return mapper.call(context, k, v, this$0)}
).flip()
);
}
});
var KeyedIterablePrototype = KeyedIterable.prototype;
KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
mixin(IndexedIterable, {
// ### Conversion to other types
toKeyedSeq: function() {
return new ToKeyedSequence(this, false);
},
// ### ES6 Collection methods (ES6 Array and Map)
filter: function(predicate, context) {
return reify(this, filterFactory(this, predicate, context, false));
},
findIndex: function(predicate, context) {
var entry = this.findEntry(predicate, context);
return entry ? entry[0] : -1;
},
indexOf: function(searchValue) {
var key = this.keyOf(searchValue);
return key === undefined ? -1 : key;
},
lastIndexOf: function(searchValue) {
var key = this.lastKeyOf(searchValue);
return key === undefined ? -1 : key;
},
reverse: function() {
return reify(this, reverseFactory(this, false));
},
slice: function(begin, end) {
return reify(this, sliceFactory(this, begin, end, false));
},
splice: function(index, removeNum /*, ...values*/) {
var numArgs = arguments.length;
removeNum = Math.max(removeNum | 0, 0);
if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
return this;
}
// If index is negative, it should resolve relative to the size of the
// collection. However size may be expensive to compute if not cached, so
// only call count() if the number is in fact negative.
index = resolveBegin(index, index < 0 ? this.count() : this.size);
var spliced = this.slice(0, index);
return reify(
this,
numArgs === 1 ?
spliced :
spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
);
},
// ### More collection methods
findLastIndex: function(predicate, context) {
var entry = this.findLastEntry(predicate, context);
return entry ? entry[0] : -1;
},
first: function() {
return this.get(0);
},
flatten: function(depth) {
return reify(this, flattenFactory(this, depth, false));
},
get: function(index, notSetValue) {
index = wrapIndex(this, index);
return (index < 0 || (this.size === Infinity ||
(this.size !== undefined && index > this.size))) ?
notSetValue :
this.find(function(_, key) {return key === index}, undefined, notSetValue);
},
has: function(index) {
index = wrapIndex(this, index);
return index >= 0 && (this.size !== undefined ?
this.size === Infinity || index < this.size :
this.indexOf(index) !== -1
);
},
interpose: function(separator) {
return reify(this, interposeFactory(this, separator));
},
interleave: function(/*...iterables*/) {
var iterables = [this].concat(arrCopy(arguments));
var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
var interleaved = zipped.flatten(true);
if (zipped.size) {
interleaved.size = zipped.size * iterables.length;
}
return reify(this, interleaved);
},
keySeq: function() {
return Range(0, this.size);
},
last: function() {
return this.get(-1);
},
skipWhile: function(predicate, context) {
return reify(this, skipWhileFactory(this, predicate, context, false));
},
zip: function(/*, ...iterables */) {
var iterables = [this].concat(arrCopy(arguments));
return reify(this, zipWithFactory(this, defaultZipper, iterables));
},
zipWith: function(zipper/*, ...iterables */) {
var iterables = arrCopy(arguments);
iterables[0] = this;
return reify(this, zipWithFactory(this, zipper, iterables));
}
});
IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
mixin(SetIterable, {
// ### ES6 Collection methods (ES6 Array and Map)
get: function(value, notSetValue) {
return this.has(value) ? value : notSetValue;
},
includes: function(value) {
return this.has(value);
},
// ### More sequential methods
keySeq: function() {
return this.valueSeq();
}
});
SetIterable.prototype.has = IterablePrototype.includes;
SetIterable.prototype.contains = SetIterable.prototype.includes;
// Mixin subclasses
mixin(KeyedSeq, KeyedIterable.prototype);
mixin(IndexedSeq, IndexedIterable.prototype);
mixin(SetSeq, SetIterable.prototype);
mixin(KeyedCollection, KeyedIterable.prototype);
mixin(IndexedCollection, IndexedIterable.prototype);
mixin(SetCollection, SetIterable.prototype);
// #pragma Helper functions
function keyMapper(v, k) {
return k;
}
function entryMapper(v, k) {
return [k, v];
}
function not(predicate) {
return function() {
return !predicate.apply(this, arguments);
}
}
function neg(predicate) {
return function() {
return -predicate.apply(this, arguments);
}
}
function quoteString(value) {
return typeof value === 'string' ? JSON.stringify(value) : String(value);
}
function defaultZipper() {
return arrCopy(arguments);
}
function defaultNegComparator(a, b) {
return a < b ? 1 : a > b ? -1 : 0;
}
function hashIterable(iterable) {
if (iterable.size === Infinity) {
return 0;
}
var ordered = isOrdered(iterable);
var keyed = isKeyed(iterable);
var h = ordered ? 1 : 0;
var size = iterable.__iterate(
keyed ?
ordered ?
function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
ordered ?
function(v ) { h = 31 * h + hash(v) | 0; } :
function(v ) { h = h + hash(v) | 0; }
);
return murmurHashOfSize(size, h);
}
function murmurHashOfSize(size, h) {
h = imul(h, 0xCC9E2D51);
h = imul(h << 15 | h >>> -15, 0x1B873593);
h = imul(h << 13 | h >>> -13, 5);
h = (h + 0xE6546B64 | 0) ^ size;
h = imul(h ^ h >>> 16, 0x85EBCA6B);
h = imul(h ^ h >>> 13, 0xC2B2AE35);
h = smi(h ^ h >>> 16);
return h;
}
function hashMerge(a, b) {
return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
}
var Immutable = {
Iterable: Iterable,
Seq: Seq,
Collection: Collection,
Map: Map,
OrderedMap: OrderedMap,
List: List,
Stack: Stack,
Set: Set,
OrderedSet: OrderedSet,
Record: Record,
Range: Range,
Repeat: Repeat,
is: is,
fromJS: fromJS
};
return Immutable;
}));
/***/ }),
/* 20 */
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(228);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(11)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../node_modules/css-loader/index.js!./react-data-grid-header.css", function() {
var newContent = require("!!../node_modules/css-loader/index.js!./react-data-grid-header.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/* 21 */,
/* 22 */,
/* 23 */
/***/ (function(module, exports) {
'use strict';
var isFunction = function isFunction(functionToCheck) {
var getType = {};
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]';
};
module.exports = isFunction;
/***/ }),
/* 24 */,
/* 25 */,
/* 26 */
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(227);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(11)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../node_modules/css-loader/index.js!./react-data-grid-core.css", function() {
var newContent = require("!!../node_modules/css-loader/index.js!./react-data-grid-core.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/* 27 */
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(229);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(11)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../node_modules/css-loader/index.js!./react-data-grid-row.css", function() {
var newContent = require("!!../node_modules/css-loader/index.js!./react-data-grid-row.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/* 28 */,
/* 29 */,
/* 30 */,
/* 31 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _keyMirror = __webpack_require__(231);
var _keyMirror2 = _interopRequireDefault(_keyMirror);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var constants = {
UpdateActions: (0, _keyMirror2['default'])({
CELL_UPDATE: null,
COLUMN_FILL: null,
COPY_PASTE: null,
CELL_DRAG: null
}),
DragItemTypes: {
Column: 'column'
},
CellExpand: {
DOWN_TRIANGLE: String.fromCharCode('9660'),
RIGHT_TRIANGLE: String.fromCharCode('9654')
}
};
module.exports = constants;
/***/ }),
/* 32 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var shallowCloneObject = __webpack_require__(70);
var sameColumn = __webpack_require__(194);
var ColumnUtils = __webpack_require__(8);
var getScrollbarSize = __webpack_require__(33);
var isColumnsImmutable = __webpack_require__(72);
function setColumnWidths(columns, totalWidth) {
return columns.map(function (column) {
var colInfo = Object.assign({}, column);
if (column.width) {
if (/^([0-9]+)%$/.exec(column.width.toString())) {
colInfo.width = Math.floor(column.width / 100 * totalWidth);
}
}
return colInfo;
});
}
function setDefferedColumnWidths(columns, unallocatedWidth, minColumnWidth) {
var defferedColumns = columns.filter(function (c) {
return !c.width;
});
return columns.map(function (column) {
if (!column.width && column.width !== 0) {
if (unallocatedWidth <= 0) {
column.width = minColumnWidth;
} else {
var columnWidth = Math.floor(unallocatedWidth / ColumnUtils.getSize(defferedColumns));
if (columnWidth < minColumnWidth) {
column.width = minColumnWidth;
} else {
column.width = columnWidth;
}
}
}
return column;
});
}
function setColumnOffsets(columns) {
var left = 0;
return columns.map(function (column) {
column.left = left;
left += column.width;
return column;
});
}
/**
* Update column metrics calculation.
*
* @param {ColumnMetricsType} metrics
*/
function recalculate(metrics) {
// compute width for columns which specify width
var columns = setColumnWidths(metrics.columns, metrics.totalWidth);
var unallocatedWidth = columns.filter(function (c) {
return c.width;
}).reduce(function (w, column) {
return w - column.width;
}, metrics.totalWidth);
unallocatedWidth -= getScrollbarSize();
var width = columns.filter(function (c) {
return c.width;
}).reduce(function (w, column) {
return w + column.width;
}, 0);
// compute width for columns which doesn't specify width
columns = setDefferedColumnWidths(columns, unallocatedWidth, metrics.minColumnWidth);
// compute left offset
columns = setColumnOffsets(columns);
return {
columns: columns,
width: width,
totalWidth: metrics.totalWidth,
minColumnWidth: metrics.minColumnWidth
};
}
/**
* Update column metrics calculation by resizing a column.
*
* @param {ColumnMetricsType} metrics
* @param {Column} column
* @param {number} width
*/
function resizeColumn(metrics, index, width) {
var column = ColumnUtils.getColumn(metrics.columns, index);
var metricsClone = shallowCloneObject(metrics);
metricsClone.columns = metrics.columns.slice(0);
var updatedColumn = shallowCloneObject(column);
updatedColumn.width = Math.max(width, metricsClone.minColumnWidth);
metricsClone = ColumnUtils.spliceColumn(metricsClone, index, updatedColumn);
return recalculate(metricsClone);
}
function areColumnsImmutable(prevColumns, nextColumns) {
return isColumnsImmutable(prevColumns) && isColumnsImmutable(nextColumns);
}
function compareEachColumn(prevColumns, nextColumns, isSameColumn) {
var i = void 0;
var len = void 0;
var column = void 0;
var prevColumnsByKey = {};
var nextColumnsByKey = {};
if (ColumnUtils.getSize(prevColumns) !== ColumnUtils.getSize(nextColumns)) {
return false;
}
for (i = 0, len = ColumnUtils.getSize(prevColumns); i < len; i++) {
column = prevColumns[i];
prevColumnsByKey[column.key] = column;
}
for (i = 0, len = ColumnUtils.getSize(nextColumns); i < len; i++) {
column = nextColumns[i];
nextColumnsByKey[column.key] = column;
var prevColumn = prevColumnsByKey[column.key];
if (prevColumn === undefined || !isSameColumn(prevColumn, column)) {
return false;
}
}
for (i = 0, len = ColumnUtils.getSize(prevColumns); i < len; i++) {
column = prevColumns[i];
var nextColumn = nextColumnsByKey[column.key];
if (nextColumn === undefined) {
return false;
}
}
return true;
}
function sameColumns(prevColumns, nextColumns, isSameColumn) {
if (areColumnsImmutable(prevColumns, nextColumns)) {
return prevColumns === nextColumns;
}
return compareEachColumn(prevColumns, nextColumns, isSameColumn);
}
module.exports = { recalculate: recalculate, resizeColumn: resizeColumn, sameColumn: sameColumn, sameColumns: sameColumns };
/***/ }),
/* 33 */
/***/ (function(module, exports) {
'use strict';
var size = void 0;
function getScrollbarSize() {
if (size === undefined) {
var outer = document.createElement('div');
outer.style.width = '50px';
outer.style.height = '50px';
outer.style.position = 'absolute';
outer.style.top = '-200px';
outer.style.left = '-200px';
var inner = document.createElement('div');
inner.style.height = '100px';
inner.style.width = '100%';
outer.appendChild(inner);
document.body.appendChild(outer);
var outerWidth = outer.clientWidth;
outer.style.overflowY = 'scroll';
var innerWidth = inner.clientWidth;
document.body.removeChild(outer);
size = outerWidth - innerWidth;
}
return size;
}
module.exports = getScrollbarSize;
/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(225);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(11)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../node_modules/css-loader/index.js!./react-data-grid-cell.css", function() {
var newContent = require("!!../node_modules/css-loader/index.js!./react-data-grid-cell.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/* 35 */,
/* 36 */,
/* 37 */,
/* 38 */,
/* 39 */,
/* 40 */,
/* 41 */,
/* 42 */,
/* 43 */,
/* 44 */,
/* 45 */,
/* 46 */,
/* 47 */,
/* 48 */,
/* 49 */,
/* 50 */,
/* 51 */,
/* 52 */,
/* 53 */,
/* 54 */,
/* 55 */,
/* 56 */,
/* 57 */,
/* 58 */,
/* 59 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _underscore = __webpack_require__(110);
var _underscore2 = _interopRequireDefault(_underscore);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _CellAction = __webpack_require__(191);
var _CellAction2 = _interopRequireDefault(_CellAction);
var _CellExpand = __webpack_require__(192);
var _CellExpand2 = _interopRequireDefault(_CellExpand);
var _ChildRowDeleteButton = __webpack_require__(193);
var _ChildRowDeleteButton2 = _interopRequireDefault(_ChildRowDeleteButton);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var joinClasses = __webpack_require__(7);
var EditorContainer = __webpack_require__(211);
var ExcelColumn = __webpack_require__(15);
var isFunction = __webpack_require__(23);
var CellMetaDataShape = __webpack_require__(12);
var SimpleCellFormatter = __webpack_require__(69);
var ColumnUtils = __webpack_require__(8);
var createObjectWithProperties = __webpack_require__(18);
__webpack_require__(34);
// The list of the propTypes that we want to include in the Cell div
var knownDivPropertyKeys = ['height', 'tabIndex', 'value'];
var Cell = function (_React$Component) {
_inherits(Cell, _React$Component);
function Cell() {
var _temp, _this, _ret;
_classCallCheck(this, Cell);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
isCellValueChanging: false,
isLockChanging: false
}, _this.onCellClick = function (e) {
var meta = _this.props.cellMetaData;
if (meta != null && meta.onCellClick && typeof meta.onCellClick === 'function') {
meta.onCellClick({ rowIdx: _this.props.rowIdx, idx: _this.props.idx }, e);
}
}, _this.onCellFocus = function () {
var meta = _this.props.cellMetaData;
if (meta != null && meta.onCellFocus && typeof meta.onCellFocus === 'function') {
meta.onCellFocus({ rowIdx: _this.props.rowIdx, idx: _this.props.idx });
}
}, _this.onCellContextMenu = function () {
var meta = _this.props.cellMetaData;
if (meta != null && meta.onCellContextMenu && typeof meta.onCellContextMenu === 'function') {
meta.onCellContextMenu({ rowIdx: _this.props.rowIdx, idx: _this.props.idx });
}
}, _this.onCellDoubleClick = function (e) {
var meta = _this.props.cellMetaData;
if (meta != null && meta.onCellDoubleClick && typeof meta.onCellDoubleClick === 'function') {
meta.onCellDoubleClick({ rowIdx: _this.props.rowIdx, idx: _this.props.idx }, e);
}
}, _this.onCellExpand = function (e) {
e.stopPropagation();
var meta = _this.props.cellMetaData;
if (meta != null && meta.onCellExpand != null) {
meta.onCellExpand({ rowIdx: _this.props.rowIdx, idx: _this.props.idx, rowData: _this.props.rowData, expandArgs: _this.props.expandableOptions });
}
}, _this.onCellKeyDown = function (e) {
if (_this.canExpand() && e.key === 'Enter') {
_this.onCellExpand(e);
}
}, _this.onDeleteSubRow = function () {
var meta = _this.props.cellMetaData;
if (meta != null && meta.onDeleteSubRow != null) {
meta.onDeleteSubRow({ rowIdx: _this.props.rowIdx, idx: _this.props.idx, rowData: _this.props.rowData, expandArgs: _this.props.expandableOptions });
}
}, _this.onDragHandleDoubleClick = function (e) {
e.stopPropagation();
var meta = _this.props.cellMetaData;
if (meta != null && meta.onDragHandleDoubleClick && typeof meta.onDragHandleDoubleClick === 'function') {
meta.onDragHandleDoubleClick({ rowIdx: _this.props.rowIdx, idx: _this.props.idx, rowData: _this.getRowData(), e: e });
}
}, _this.onDragOver = function (e) {
e.preventDefault();
}, _this.getStyle = function () {
var style = {
position: 'absolute',
width: _this.props.column.width,
height: _this.props.height,
left: _this.props.column.left,
contain: 'layout'
};
return style;
}, _this.getFormatter = function () {
var col = _this.props.column;
if (_this.isActive()) {
return React.createElement(EditorContainer, { rowData: _this.getRowData(), rowIdx: _this.props.rowIdx, value: _this.props.value, idx: _this.props.idx, cellMetaData: _this.props.cellMetaData, column: col, height: _this.props.height });
}
return _this.props.column.formatter;
}, _this.getRowData = function () {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.props;
return props.rowData.toJSON ? props.rowData.toJSON() : props.rowData;
}, _this.getFormatterDependencies = function () {
// convention based method to get corresponding Id or Name of any Name or Id property
if (typeof _this.props.column.getRowMetaData === 'function') {
return _this.props.column.getRowMetaData(_this.getRowData(), _this.props.column);
}
}, _this.getCellClass = function () {
var className = joinClasses(_this.props.column.cellClass, 'react-grid-Cell', _this.props.className, _this.props.column.locked ? 'react-grid-Cell--locked' : null);
var extraClasses = joinClasses({
'row-selected': _this.props.isRowSelected,
editing: _this.isActive(),
copied: _this.isCopied() || _this.wasDraggedOver() || _this.isDraggedOverUpwards() || _this.isDraggedOverDownwards(),
'is-dragged-over-up': _this.isDraggedOverUpwards(),
'is-dragged-over-down': _this.isDraggedOverDownwards(),
'was-dragged-over': _this.wasDraggedOver(),
'cell-tooltip': _this.props.tooltip ? true : false,
'rdg-child-cell': _this.props.expandableOptions && _this.props.expandableOptions.subRowDetails && _this.props.expandableOptions.treeDepth > 0,
'last-column': _this.props.column.isLastColumn
});
return joinClasses(className, extraClasses);
}, _this.getUpdateCellClass = function () {
return _this.props.column.getUpdateCellClass ? _this.props.column.getUpdateCellClass(_this.props.selectedColumn, _this.props.column, _this.state.isCellValueChanging) : '';
}, _this.isColumnSelected = function () {
var meta = _this.props.cellMetaData;
if (meta == null) {
return false;
}
return meta.selected && meta.selected.idx === _this.props.idx;
}, _this.isSelected = function () {
var meta = _this.props.cellMetaData;
if (meta == null) {
return false;
}
return meta.selected && meta.selected.rowIdx === _this.props.rowIdx && meta.selected.idx === _this.props.idx;
}, _this.isActive = function () {
var meta = _this.props.cellMetaData;
if (meta == null) {
return false;
}
return _this.isSelected() && meta.selected.active === true;
}, _this.isCellSelectionChanging = function (nextProps) {
var meta = _this.props.cellMetaData;
if (meta == null) {
return false;
}
var nextSelected = nextProps.cellMetaData.selected;
if (meta.selected && nextSelected) {
return _this.props.idx === nextSelected.idx || _this.props.idx === meta.selected.idx;
}
return true;
}, _this.isCellSelectEnabled = function () {
var meta = _this.props.cellMetaData;
if (meta == null) {
return false;
}
return meta.enableCellSelect;
}, _this.hasChangedDependentValues = function (nextProps) {
var currentColumn = _this.props.column;
var hasChangedDependentValues = false;
if (currentColumn.getRowMetaData) {
var currentRowMetaData = currentColumn.getRowMetaData(_this.getRowData(), currentColumn);
var nextColumn = nextProps.column;
var nextRowMetaData = nextColumn.getRowMetaData(_this.getRowData(nextProps), nextColumn);
hasChangedDependentValues = !_underscore2['default'].isEqual(currentRowMetaData, nextRowMetaData);
}
return hasChangedDependentValues;
}, _this.applyUpdateClass = function () {
var updateCellClass = _this.getUpdateCellClass();
// -> removing the class
if (updateCellClass != null && updateCellClass !== '') {
var cellDOMNode = _this.node;
if (cellDOMNode.classList) {
cellDOMNode.classList.remove(updateCellClass);
// -> and re-adding the class
cellDOMNode.classList.add(updateCellClass);
} else if (cellDOMNode.className.indexOf(updateCellClass) === -1) {
// IE9 doesn't support classList, nor (I think) altering element.className
// without replacing it wholesale.
cellDOMNode.className = cellDOMNode.className + ' ' + updateCellClass;
}
}
}, _this.setScrollLeft = function (scrollLeft) {
var node = _this.node;
if (node) {
var transform = 'translate3d(' + scrollLeft + 'px, 0px, 0px)';
node.style.webkitTransform = transform;
node.style.transform = transform;
}
}, _this.removeScroll = function () {
var node = _this.node;
if (node) {
node.style.webkitTransform = null;
node.style.transform = null;
}
}, _this.isCopied = function () {
var copied = _this.props.cellMetaData.copied;
return copied && copied.rowIdx === _this.props.rowIdx && copied.idx === _this.props.idx;
}, _this.isDraggedOver = function () {
var dragged = _this.props.cellMetaData.dragged;
return dragged && dragged.overRowIdx === _this.props.rowIdx && dragged.idx === _this.props.idx;
}, _this.wasDraggedOver = function () {
var dragged = _this.props.cellMetaData.dragged;
return dragged && (dragged.overRowIdx < _this.props.rowIdx && _this.props.rowIdx < dragged.rowIdx || dragged.overRowIdx > _this.props.rowIdx && _this.props.rowIdx > dragged.rowIdx) && dragged.idx === _this.props.idx;
}, _this.isDraggedCellChanging = function (nextProps) {
var isChanging = void 0;
var dragged = _this.props.cellMetaData.dragged;
var nextDragged = nextProps.cellMetaData.dragged;
if (dragged) {
isChanging = nextDragged && _this.props.idx === nextDragged.idx || dragged && _this.props.idx === dragged.idx;
return isChanging;
}
return false;
}, _this.isCopyCellChanging = function (nextProps) {
var isChanging = void 0;
var copied = _this.props.cellMetaData.copied;
var nextCopied = nextProps.cellMetaData.copied;
if (copied) {
isChanging = nextCopied && _this.props.idx === nextCopied.idx || copied && _this.props.idx === copied.idx;
return isChanging;
}
return false;
}, _this.isDraggedOverUpwards = function () {
var dragged = _this.props.cellMetaData.dragged;
return !_this.isSelected() && _this.isDraggedOver() && _this.props.rowIdx < dragged.rowIdx;
}, _this.isDraggedOverDownwards = function () {
var dragged = _this.props.cellMetaData.dragged;
return !_this.isSelected() && _this.isDraggedOver() && _this.props.rowIdx > dragged.rowIdx;
}, _this.isFocusedOnBody = function () {
return document.activeElement == null || document.activeElement.nodeName && typeof document.activeElement.nodeName === 'string' && document.activeElement.nodeName.toLowerCase() === 'body';
}, _this.isFocusedOnCell = function () {
return document.activeElement && document.activeElement.className.indexOf('react-grid-Cell') !== -1;
}, _this.checkFocus = function () {
if (_this.isSelected() && !_this.isActive()) {
if (_this.props.isScrolling && !_this.props.cellMetaData.isScrollingVerticallyWithKeyboard && !_this.props.cellMetaData.isScrollingHorizontallyWithKeyboard) {
return;
}
// If the enableCellAutoFocus is set in the ReactDataGrid props, it will allow the cell to take focus when the browser is focused on the body.
// Otherwise, only focus to the current cell if the currently active node in the document is within the data grid.
// Meaning focus should not be stolen from elements that the grid doesnt control.
var cellAutoFocusEnabled = _this.props.cellMetaData && _this.props.cellMetaData.enableCellAutoFocus;
var dataGridDOMNode = _this.props.cellMetaData && _this.props.cellMetaData.getDataGridDOMNode ? _this.props.cellMetaData.getDataGridDOMNode() : null;
if (_this.isFocusedOnCell() || cellAutoFocusEnabled && _this.isFocusedOnBody() || dataGridDOMNode && dataGridDOMNode.contains(document.activeElement)) {
var cellDOMNode = _this.node;
if (cellDOMNode) {
cellDOMNode.focus();
}
}
}
}, _this.canEdit = function () {
return _this.props.column.editor != null || _this.props.column.editable;
}, _this.canExpand = function () {
return _this.props.expandableOptions && _this.props.expandableOptions.canExpand;
}, _this.createColumEventCallBack = function (onColumnEvent, info) {
return function (e) {
onColumnEvent(e, info);
};
}, _this.createCellEventCallBack = function (gridEvent, columnEvent) {
return function (e) {
gridEvent(e);
columnEvent(e);
};
}, _this.createEventDTO = function (gridEvents, columnEvents, onColumnEvent) {
var allEvents = Object.assign({}, gridEvents);
for (var eventKey in columnEvents) {
if (columnEvents.hasOwnProperty(eventKey)) {
var event = columnEvents[event];
var eventInfo = { idx: _this.props.idx, rowIdx: _this.props.rowIdx, rowId: _this.props.rowData[_this.props.cellMetaData.rowKey], name: eventKey };
var eventCallback = _this.createColumEventCallBack(onColumnEvent, eventInfo);
if (allEvents.hasOwnProperty(eventKey)) {
var currentEvent = allEvents[eventKey];
allEvents[eventKey] = _this.createCellEventCallBack(currentEvent, eventCallback);
} else {
allEvents[eventKey] = eventCallback;
}
}
}
return allEvents;
}, _this.getEvents = function () {
var columnEvents = _this.props.column ? Object.assign({}, _this.props.column.events) : undefined;
var onColumnEvent = _this.props.cellMetaData ? _this.props.cellMetaData.onColumnEvent : undefined;
var gridEvents = {
onClick: _this.onCellClick,
onFocus: _this.onCellFocus,
onDoubleClick: _this.onCellDoubleClick,
onContextMenu: _this.onCellContextMenu,
onDragOver: _this.onDragOver
};
if (!columnEvents || !onColumnEvent) {
return gridEvents;
}
return _this.createEventDTO(gridEvents, columnEvents, onColumnEvent);
}, _this.getKnownDivProps = function () {
return createObjectWithProperties(_this.props, knownDivPropertyKeys);
}, _this.renderCellContent = function (props) {
var CellContent = void 0;
var Formatter = _this.getFormatter();
if (React.isValidElement(Formatter)) {
props.dependentValues = _this.getFormatterDependencies();
CellContent = React.cloneElement(Formatter, props);
} else if (isFunction(Formatter)) {
CellContent = React.createElement(Formatter, { value: _this.props.value, dependentValues: _this.getFormatterDependencies() });
} else {
CellContent = React.createElement(SimpleCellFormatter, { value: _this.props.value });
}
var isExpandCell = _this.props.expandableOptions ? _this.props.expandableOptions.field === _this.props.column.key : false;
var treeDepth = _this.props.expandableOptions ? _this.props.expandableOptions.treeDepth : 0;
var marginLeft = _this.props.expandableOptions && isExpandCell ? _this.props.expandableOptions.treeDepth * 30 : 0;
var cellExpander = void 0;
var cellDeleter = void 0;
if (_this.canExpand()) {
cellExpander = React.createElement(_CellExpand2['default'], { expandableOptions: _this.props.expandableOptions, onCellExpand: _this.onCellExpand });
}
var isDeleteSubRowEnabled = _this.props.cellMetaData.onDeleteSubRow ? true : false;
if (treeDepth > 0 && isExpandCell) {
cellDeleter = React.createElement(_ChildRowDeleteButton2['default'], { treeDepth: treeDepth, cellHeight: _this.props.height, siblingIndex: _this.props.expandableOptions.subRowDetails.siblingIndex, numberSiblings: _this.props.expandableOptions.subRowDetails.numberSiblings, onDeleteSubRow: _this.onDeleteSubRow, isDeleteSubRowEnabled: isDeleteSubRowEnabled });
}
return React.createElement(
'div',
{ className: 'react-grid-Cell__value' },
cellDeleter,
React.createElement(
'div',
{ style: { marginLeft: marginLeft } },
React.createElement(
'span',
null,
CellContent
),
' ',
_this.props.cellControls,
' ',
cellExpander
)
);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Cell.prototype.componentDidMount = function componentDidMount() {
this.checkFocus();
};
Cell.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
this.setState({
isCellValueChanging: this.props.isCellValueChanging(this.props.value, nextProps.value),
isLockChanging: this.props.column.locked !== nextProps.column.locked
});
};
Cell.prototype.componentDidUpdate = function componentDidUpdate() {
this.checkFocus();
var dragged = this.props.cellMetaData.dragged;
if (dragged && dragged.complete === true) {
this.props.cellMetaData.handleTerminateDrag();
}
if (this.state.isCellValueChanging && this.props.selectedColumn != null) {
this.applyUpdateClass();
}
if (this.state.isLockChanging && !this.props.column.locked) {
this.removeScroll();
}
};
Cell.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
var shouldUpdate = this.props.column.width !== nextProps.column.width || this.props.column.left !== nextProps.column.left || this.props.column.cellClass !== nextProps.column.cellClass || this.props.height !== nextProps.height || this.props.rowIdx !== nextProps.rowIdx || this.isCellSelectionChanging(nextProps) || this.isDraggedCellChanging(nextProps) || this.isCopyCellChanging(nextProps) || this.props.isRowSelected !== nextProps.isRowSelected || this.isSelected() || this.props.isCellValueChanging(this.props.value, nextProps.value) || this.props.forceUpdate === true || this.props.className !== nextProps.className || this.props.expandableOptions !== nextProps.expandableOptions || this.hasChangedDependentValues(nextProps) || this.props.column.locked !== nextProps.column.locked;
return shouldUpdate;
};
Cell.prototype.getCellActions = function getCellActions() {
var _props = this.props,
cellMetaData = _props.cellMetaData,
column = _props.column,
rowData = _props.rowData;
if (cellMetaData && cellMetaData.getCellActions) {
var cellActions = cellMetaData.getCellActions(column, rowData);
if (cellActions && cellActions.length) {
return cellActions.map(function (action, index) {
return React.createElement(_CellAction2['default'], { key: index, action: action, isFirst: index === 0 });
});
}
return null;
}
return null;
};
Cell.prototype.render = function render() {
var _this2 = this;
if (this.props.column.hidden) {
return null;
}
var style = this.getStyle();
var className = this.getCellClass();
var cellActions = this.getCellActions();
var cellContent = this.props.children || this.renderCellContent({
value: this.props.value,
column: this.props.column,
rowIdx: this.props.rowIdx,
isExpanded: this.props.isExpanded
});
var dragHandle = !this.isActive() && ColumnUtils.canEdit(this.props.column, this.props.rowData, this.props.cellMetaData.enableCellSelect) ? React.createElement(
'div',
{ className: 'drag-handle', draggable: 'true', onDoubleClick: this.onDragHandleDoubleClick },
React.createElement('span', { style: { display: 'none' } })
) : null;
var events = this.getEvents();
var tooltip = this.props.tooltip ? React.createElement(
'span',
{ className: 'cell-tooltip-text' },
this.props.tooltip
) : null;
return React.createElement(
'div',
_extends({}, this.getKnownDivProps(), { className: className, style: style }, events, { ref: function ref(node) {
_this2.node = node;
} }),
cellActions,
cellContent,
dragHandle,
tooltip
);
};
return Cell;
}(React.Component);
Cell.propTypes = {
rowIdx: _propTypes2['default'].number.isRequired,
idx: _propTypes2['default'].number.isRequired,
selected: _propTypes2['default'].shape({
idx: _propTypes2['default'].number.isRequired
}),
selectedColumn: _propTypes2['default'].object,
height: _propTypes2['default'].number,
tabIndex: _propTypes2['default'].number,
column: _propTypes2['default'].shape(ExcelColumn).isRequired,
value: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number, _propTypes2['default'].object, _propTypes2['default'].bool]),
isExpanded: _propTypes2['default'].bool,
isRowSelected: _propTypes2['default'].bool,
cellMetaData: _propTypes2['default'].shape(CellMetaDataShape).isRequired,
handleDragStart: _propTypes2['default'].func,
className: _propTypes2['default'].string,
cellControls: _propTypes2['default'].any,
rowData: _propTypes2['default'].object.isRequired,
forceUpdate: _propTypes2['default'].bool,
expandableOptions: _propTypes2['default'].object.isRequired,
isScrolling: _propTypes2['default'].bool.isRequired,
tooltip: _propTypes2['default'].string,
isCellValueChanging: _propTypes2['default'].func,
children: _propTypes2['default'].oneOfType([_propTypes2['default'].arrayOf(_propTypes2['default'].node), _propTypes2['default'].node])
};
Cell.defaultProps = {
tabIndex: 0,
isExpanded: false,
value: '',
isCellValueChanging: function isCellValueChanging(value, nextValue) {
return value !== nextValue;
}
};
module.exports = Cell;
/***/ }),
/* 60 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var ReactDOM = __webpack_require__(6);
var joinClasses = __webpack_require__(7);
var ExcelColumn = __webpack_require__(15);
var ResizeHandle = __webpack_require__(206);
__webpack_require__(20);
function simpleCellRenderer(objArgs) {
var headerText = objArgs.column.rowType === 'header' ? objArgs.column.name : '';
return React.createElement(
'div',
{ className: 'widget-HeaderCell__value' },
headerText
);
}
var HeaderCell = function (_React$Component) {
_inherits(HeaderCell, _React$Component);
function HeaderCell() {
var _temp, _this, _ret;
_classCallCheck(this, HeaderCell);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = { resizing: false }, _this.onDragStart = function (e) {
_this.setState({ resizing: true });
// need to set dummy data for FF
if (e && e.dataTransfer && e.dataTransfer.setData) e.dataTransfer.setData('text/plain', 'dummy');
}, _this.onDrag = function (e) {
var resize = _this.props.onResize || null; // for flows sake, doesnt recognise a null check direct
if (resize) {
var _width = _this.getWidthFromMouseEvent(e);
if (_width > 0) {
resize(_this.props.column, _width);
}
}
}, _this.onDragEnd = function (e) {
var width = _this.getWidthFromMouseEvent(e);
_this.props.onResizeEnd(_this.props.column, width);
_this.setState({ resizing: false });
}, _this.getWidthFromMouseEvent = function (e) {
var right = e.pageX || e.touches && e.touches[0] && e.touches[0].pageX || e.changedTouches && e.changedTouches[e.changedTouches.length - 1].pageX;
var left = ReactDOM.findDOMNode(_this).getBoundingClientRect().left;
return right - left;
}, _this.getCell = function () {
if (React.isValidElement(_this.props.renderer)) {
// if it is a string, it's an HTML element, and column is not a valid property, so only pass height
if (typeof _this.props.renderer.type === 'string') {
return React.cloneElement(_this.props.renderer, { height: _this.props.height });
}
return React.cloneElement(_this.props.renderer, { column: _this.props.column, height: _this.props.height });
}
return _this.props.renderer({ column: _this.props.column });
}, _this.getStyle = function () {
return {
width: _this.props.column.width,
left: _this.props.column.left,
display: 'inline-block',
position: 'absolute',
height: _this.props.height,
margin: 0,
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
};
}, _this.setScrollLeft = function (scrollLeft) {
var node = ReactDOM.findDOMNode(_this);
node.style.webkitTransform = 'translate3d(' + scrollLeft + 'px, 0px, 0px)';
node.style.transform = 'translate3d(' + scrollLeft + 'px, 0px, 0px)';
}, _this.removeScroll = function () {
var node = ReactDOM.findDOMNode(_this);
if (node) {
var transform = 'none';
node.style.webkitTransform = transform;
node.style.transform = transform;
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
HeaderCell.prototype.render = function render() {
var resizeHandle = void 0;
if (this.props.column.resizable) {
resizeHandle = React.createElement(ResizeHandle, {
onDrag: this.onDrag,
onDragStart: this.onDragStart,
onDragEnd: this.onDragEnd
});
}
var className = joinClasses({
'react-grid-HeaderCell': true,
'react-grid-HeaderCell--resizing': this.state.resizing,
'react-grid-HeaderCell--locked': this.props.column.locked
});
className = joinClasses(className, this.props.className, this.props.column.cellClass);
var cell = this.getCell();
return React.createElement(
'div',
{ className: className, style: this.getStyle() },
cell,
resizeHandle
);
};
return HeaderCell;
}(React.Component);
HeaderCell.propTypes = {
renderer: _propTypes2['default'].oneOfType([_propTypes2['default'].func, _propTypes2['default'].element]).isRequired,
column: _propTypes2['default'].shape(ExcelColumn).isRequired,
onResize: _propTypes2['default'].func.isRequired,
height: _propTypes2['default'].number.isRequired,
onResizeEnd: _propTypes2['default'].func.isRequired,
className: _propTypes2['default'].string
};
HeaderCell.defaultProps = {
renderer: simpleCellRenderer
};
module.exports = HeaderCell;
/***/ }),
/* 61 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _OverflowCell = __webpack_require__(202);
var _OverflowCell2 = _interopRequireDefault(_OverflowCell);
var _RowComparer = __webpack_require__(62);
var _RowComparer2 = _interopRequireDefault(_RowComparer);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var joinClasses = __webpack_require__(7);
var Cell = __webpack_require__(59);
var columnUtils = __webpack_require__(8);
var cellMetaDataShape = __webpack_require__(12);
var createObjectWithProperties = __webpack_require__(18);
__webpack_require__(27);
var CellExpander = function (_React$Component) {
_inherits(CellExpander, _React$Component);
function CellExpander() {
_classCallCheck(this, CellExpander);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
CellExpander.prototype.render = function render() {
return React.createElement(Cell, this.props);
};
return CellExpander;
}(React.Component);
// The list of the propTypes that we want to include in the Row div
var knownDivPropertyKeys = ['height'];
var Row = function (_React$Component2) {
_inherits(Row, _React$Component2);
function Row() {
var _temp, _this2, _ret;
_classCallCheck(this, Row);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this2 = _possibleConstructorReturn(this, _React$Component2.call.apply(_React$Component2, [this].concat(args))), _this2), _this2.handleDragEnter = function () {
var handleDragEnterRow = _this2.props.cellMetaData.handleDragEnterRow;
if (handleDragEnterRow) {
handleDragEnterRow(_this2.props.idx);
}
}, _this2.getSelectedColumn = function () {
if (_this2.props.cellMetaData) {
var selected = _this2.props.cellMetaData.selected;
if (selected && selected.idx) {
return columnUtils.getColumn(_this2.props.columns, selected.idx);
}
}
}, _this2.getCellRenderer = function (columnKey) {
var CellRenderer = _this2.props.cellRenderer;
if (_this2.props.subRowDetails && _this2.props.subRowDetails.field === columnKey) {
return CellExpander;
}
return CellRenderer;
}, _this2.getCell = function (column, i, selectedColumn) {
var CellRenderer = _this2.props.cellRenderer;
var _this2$props = _this2.props,
colVisibleStart = _this2$props.colVisibleStart,
colVisibleEnd = _this2$props.colVisibleEnd,
idx = _this2$props.idx,
cellMetaData = _this2$props.cellMetaData;
var key = column.key,
formatter = column.formatter,
locked = column.locked;
var baseCellProps = { key: key + '-' + idx, idx: i, rowIdx: idx, height: _this2.getRowHeight(), column: column, cellMetaData: cellMetaData };
if ((i < colVisibleStart || i > colVisibleEnd) && !locked) {
return React.createElement(_OverflowCell2['default'], _extends({ ref: function ref(node) {
return _this2[key] = node;
} }, baseCellProps));
}
var _this2$props2 = _this2.props,
row = _this2$props2.row,
isSelected = _this2$props2.isSelected;
var cellProps = {
ref: function ref(node) {
return _this2[key] = node;
},
value: _this2.getCellValue(key || i),
rowData: row,
isRowSelected: isSelected,
expandableOptions: _this2.getExpandableOptions(key),
selectedColumn: selectedColumn,
formatter: formatter,
isScrolling: _this2.props.isScrolling
};
return React.createElement(CellRenderer, _extends({}, baseCellProps, cellProps));
}, _this2.getCells = function () {
var cells = [];
var lockedCells = [];
var selectedColumn = _this2.getSelectedColumn();
var lastColumnIdx = _this2.props.columns.size - 1;
if (_this2.props.columns) {
_this2.props.columns.forEach(function (column, i) {
if (i === lastColumnIdx) {
column.isLastColumn = true;
}
var cell = _this2.getCell(column, i, selectedColumn);
if (column.locked) {
lockedCells.push(cell);
} else {
cells.push(cell);
}
});
}
return cells.concat(lockedCells);
}, _this2.getRowHeight = function () {
var rows = _this2.props.expandedRows || null;
if (rows && _this2.props.idx) {
var row = rows[_this2.props.idx] || null;
if (row) {
return row.height;
}
}
return _this2.props.height;
}, _this2.getCellValue = function (key) {
var val = void 0;
if (key === 'select-row') {
return _this2.props.isSelected;
} else if (typeof _this2.props.row.get === 'function') {
val = _this2.props.row.get(key);
} else {
val = _this2.props.row[key];
}
return val;
}, _this2.isContextMenuDisplayed = function () {
if (_this2.props.cellMetaData) {
var selected = _this2.props.cellMetaData.selected;
if (selected && selected.contextMenuDisplayed && selected.rowIdx === _this2.props.idx) {
return true;
}
}
return false;
}, _this2.getExpandableOptions = function (columnKey) {
var subRowDetails = _this2.props.subRowDetails;
if (subRowDetails) {
return { canExpand: subRowDetails && subRowDetails.field === columnKey && (subRowDetails.children && subRowDetails.children.length > 0 || subRowDetails.group === true), field: subRowDetails.field, expanded: subRowDetails && subRowDetails.expanded, children: subRowDetails && subRowDetails.children, treeDepth: subRowDetails ? subRowDetails.treeDepth : 0, subRowDetails: subRowDetails };
}
return {};
}, _this2.setScrollLeft = function (scrollLeft) {
_this2.props.columns.forEach(function (column) {
if (column.locked) {
if (!_this2[column.key]) return;
_this2[column.key].setScrollLeft(scrollLeft);
}
});
}, _this2.getKnownDivProps = function () {
return createObjectWithProperties(_this2.props, knownDivPropertyKeys);
}, _this2.renderCell = function (props) {
if (typeof _this2.props.cellRenderer === 'function') {
_this2.props.cellRenderer.call(_this2, props);
}
if (React.isValidElement(_this2.props.cellRenderer)) {
return React.cloneElement(_this2.props.cellRenderer, props);
}
return _this2.props.cellRenderer(props);
}, _temp), _possibleConstructorReturn(_this2, _ret);
}
Row.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return (0, _RowComparer2['default'])(nextProps, this.props);
};
Row.prototype.render = function render() {
var className = joinClasses('react-grid-Row', 'react-grid-Row--' + (this.props.idx % 2 === 0 ? 'even' : 'odd'), {
'row-selected': this.props.isSelected,
'row-context-menu': this.isContextMenuDisplayed()
}, this.props.extraClasses);
var style = {
height: this.getRowHeight(this.props),
overflow: 'hidden',
contain: 'layout'
};
var cells = this.getCells();
return React.createElement(
'div',
_extends({}, this.getKnownDivProps(), { className: className, style: style, onDragEnter: this.handleDragEnter }),
React.isValidElement(this.props.row) ? this.props.row : cells
);
};
return Row;
}(React.Component);
Row.displayName = 'Row';
Row.propTypes = {
height: _propTypes2['default'].number.isRequired,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].array]).isRequired,
row: _propTypes2['default'].any.isRequired,
cellRenderer: _propTypes2['default'].func,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape),
isSelected: _propTypes2['default'].bool,
idx: _propTypes2['default'].number.isRequired,
expandedRows: _propTypes2['default'].arrayOf(_propTypes2['default'].object),
extraClasses: _propTypes2['default'].string,
forceUpdate: _propTypes2['default'].bool,
subRowDetails: _propTypes2['default'].object,
isRowHovered: _propTypes2['default'].bool,
colVisibleStart: _propTypes2['default'].number.isRequired,
colVisibleEnd: _propTypes2['default'].number.isRequired,
colDisplayStart: _propTypes2['default'].number.isRequired,
colDisplayEnd: _propTypes2['default'].number.isRequired,
isScrolling: _propTypes2['default'].bool.isRequired
};
Row.defaultProps = {
cellRenderer: Cell,
isSelected: false,
height: 35
};
module.exports = Row;
/***/ }),
/* 62 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.shouldRowUpdate = undefined;
var _ColumnMetrics = __webpack_require__(32);
var _ColumnMetrics2 = _interopRequireDefault(_ColumnMetrics);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function doesRowContainSelectedCell(props) {
var selected = props.cellMetaData.selected;
if (selected && selected.rowIdx === props.idx) {
return true;
}
return false;
}
function willRowBeDraggedOver(props) {
var dragged = props.cellMetaData.dragged;
return dragged != null && (dragged.rowIdx >= 0 || dragged.complete === true);
}
function hasRowBeenCopied(props) {
var copied = props.cellMetaData.copied;
return copied != null && copied.rowIdx === props.idx;
}
var shouldRowUpdate = exports.shouldRowUpdate = function shouldRowUpdate(nextProps, currentProps) {
return !_ColumnMetrics2['default'].sameColumns(currentProps.columns, nextProps.columns, _ColumnMetrics2['default'].sameColumn) || doesRowContainSelectedCell(currentProps) || doesRowContainSelectedCell(nextProps) || willRowBeDraggedOver(nextProps) || nextProps.row !== currentProps.row || currentProps.colDisplayStart !== nextProps.colDisplayStart || currentProps.colDisplayEnd !== nextProps.colDisplayEnd || currentProps.colVisibleStart !== nextProps.colVisibleStart || currentProps.colVisibleEnd !== nextProps.colVisibleEnd || hasRowBeenCopied(currentProps) || currentProps.isSelected !== nextProps.isSelected || nextProps.height !== currentProps.height || currentProps.isOver !== nextProps.isOver || currentProps.expandedRows !== nextProps.expandedRows || currentProps.canDrop !== nextProps.canDrop || currentProps.forceUpdate === true || currentProps.extraClasses !== nextProps.extraClasses;
};
exports['default'] = shouldRowUpdate;
/***/ }),
/* 63 */
/***/ (function(module, exports) {
'use strict';
var RowUtils = {
get: function get(row, property) {
if (typeof row.get === 'function') {
return row.get(property);
}
return row[property];
},
isRowSelected: function isRowSelected(keys, indexes, isSelectedKey, rowData, rowIdx) {
if (indexes && Object.prototype.toString.call(indexes) === '[object Array]') {
return indexes.indexOf(rowIdx) > -1;
} else if (keys && keys.rowKey && keys.values && Object.prototype.toString.call(keys.values) === '[object Array]') {
return keys.values.indexOf(rowData[keys.rowKey]) > -1;
} else if (isSelectedKey && rowData && typeof isSelectedKey === 'string') {
return rowData[isSelectedKey];
}
return false;
}
};
module.exports = RowUtils;
/***/ }),
/* 64 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.SimpleRowsContainer = undefined;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var SimpleRowsContainer = function SimpleRowsContainer(props) {
return _react2['default'].createElement(
'div',
{ key: 'rows-container' },
props.rows
);
};
SimpleRowsContainer.propTypes = {
width: _propTypes2['default'].number,
rows: _propTypes2['default'].array
};
var RowsContainer = function (_React$Component) {
_inherits(RowsContainer, _React$Component);
function RowsContainer(props) {
_classCallCheck(this, RowsContainer);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.plugins = props.window ? props.window.ReactDataGridPlugins : window.ReactDataGridPlugins;
_this.hasContextMenu = _this.hasContextMenu.bind(_this);
_this.renderRowsWithContextMenu = _this.renderRowsWithContextMenu.bind(_this);
_this.getContextMenuContainer = _this.getContextMenuContainer.bind(_this);
_this.state = { ContextMenuContainer: _this.getContextMenuContainer(props) };
return _this;
}
RowsContainer.prototype.getContextMenuContainer = function getContextMenuContainer() {
if (this.hasContextMenu()) {
if (!this.plugins) {
throw new Error('You need to include ReactDataGrid UiPlugins in order to initialise context menu');
}
return this.plugins.Menu.ContextMenuLayer('reactDataGridContextMenu')(SimpleRowsContainer);
}
};
RowsContainer.prototype.hasContextMenu = function hasContextMenu() {
return this.props.contextMenu && _react2['default'].isValidElement(this.props.contextMenu);
};
RowsContainer.prototype.renderRowsWithContextMenu = function renderRowsWithContextMenu() {
var ContextMenuRowsContainer = this.state.ContextMenuContainer;
var newProps = { rowIdx: this.props.rowIdx, idx: this.props.idx };
var contextMenu = _react2['default'].cloneElement(this.props.contextMenu, newProps);
// Initialise the context menu if it is available
return _react2['default'].createElement(
'div',
null,
_react2['default'].createElement(ContextMenuRowsContainer, this.props),
contextMenu
);
};
RowsContainer.prototype.render = function render() {
return this.hasContextMenu() ? this.renderRowsWithContextMenu() : _react2['default'].createElement(SimpleRowsContainer, this.props);
};
return RowsContainer;
}(_react2['default'].Component);
RowsContainer.propTypes = {
contextMenu: _propTypes2['default'].element,
rowIdx: _propTypes2['default'].number,
idx: _propTypes2['default'].number,
window: _propTypes2['default'].object
};
exports['default'] = RowsContainer;
exports.SimpleRowsContainer = SimpleRowsContainer;
/***/ }),
/* 65 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
__webpack_require__(76);
var CheckboxEditor = function (_React$Component) {
_inherits(CheckboxEditor, _React$Component);
function CheckboxEditor() {
var _temp, _this, _ret;
_classCallCheck(this, CheckboxEditor);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleChange = function (e) {
_this.props.column.onCellChange(_this.props.rowIdx, _this.props.column.key, _this.props.dependentValues, e);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
CheckboxEditor.prototype.render = function render() {
var checked = this.props.value != null ? this.props.value : false;
var checkboxName = 'checkbox' + this.props.rowIdx;
return React.createElement(
'div',
{ className: 'react-grid-checkbox-container checkbox-align', onClick: this.handleChange },
React.createElement('input', { className: 'react-grid-checkbox', type: 'checkbox', name: checkboxName, checked: checked }),
React.createElement('label', { htmlFor: checkboxName, className: 'react-grid-checkbox-label' })
);
};
return CheckboxEditor;
}(React.Component);
CheckboxEditor.propTypes = {
value: _propTypes2['default'].bool,
rowIdx: _propTypes2['default'].number,
column: _propTypes2['default'].shape({
key: _propTypes2['default'].string,
onCellChange: _propTypes2['default'].func
}),
dependentValues: _propTypes2['default'].object
};
module.exports = CheckboxEditor;
/***/ }),
/* 66 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var ReactDOM = __webpack_require__(6);
var ExcelColumn = __webpack_require__(15);
var EditorBase = function (_React$Component) {
_inherits(EditorBase, _React$Component);
function EditorBase() {
_classCallCheck(this, EditorBase);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
EditorBase.prototype.getStyle = function getStyle() {
return {
width: '100%'
};
};
EditorBase.prototype.getValue = function getValue() {
var updated = {};
updated[this.props.column.key] = this.getInputNode().value;
return updated;
};
EditorBase.prototype.getInputNode = function getInputNode() {
var domNode = ReactDOM.findDOMNode(this);
if (domNode.tagName === 'INPUT') {
return domNode;
}
return domNode.querySelector('input:not([type=hidden])');
};
EditorBase.prototype.inheritContainerStyles = function inheritContainerStyles() {
return true;
};
return EditorBase;
}(React.Component);
EditorBase.propTypes = {
onKeyDown: _propTypes2['default'].func.isRequired,
value: _propTypes2['default'].any.isRequired,
onBlur: _propTypes2['default'].func.isRequired,
column: _propTypes2['default'].shape(ExcelColumn).isRequired,
commit: _propTypes2['default'].func.isRequired
};
module.exports = EditorBase;
/***/ }),
/* 67 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var EditorBase = __webpack_require__(66);
var SimpleTextEditor = function (_EditorBase) {
_inherits(SimpleTextEditor, _EditorBase);
function SimpleTextEditor() {
_classCallCheck(this, SimpleTextEditor);
return _possibleConstructorReturn(this, _EditorBase.apply(this, arguments));
}
SimpleTextEditor.prototype.render = function render() {
var _this2 = this;
return React.createElement('input', { ref: function ref(node) {
return _this2.input = node;
}, type: 'text', onBlur: this.props.onBlur, className: 'form-control', defaultValue: this.props.value });
};
return SimpleTextEditor;
}(EditorBase);
module.exports = SimpleTextEditor;
/***/ }),
/* 68 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var SelectAll = function SelectAll(props) {
return _react2['default'].createElement(
'div',
{ className: 'react-grid-checkbox-container checkbox-align' },
_react2['default'].createElement('input', {
className: 'react-grid-checkbox',
type: 'checkbox',
name: 'select-all-checkbox',
id: 'select-all-checkbox',
ref: props.inputRef,
onChange: props.onChange
}),
_react2['default'].createElement('label', { htmlFor: 'select-all-checkbox', className: 'react-grid-checkbox-label' })
);
};
SelectAll.propTypes = {
onChange: _propTypes2['default'].func,
inputRef: _propTypes2['default'].func
};
exports['default'] = SelectAll;
/***/ }),
/* 69 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var SimpleCellFormatter = function (_React$Component) {
_inherits(SimpleCellFormatter, _React$Component);
function SimpleCellFormatter() {
_classCallCheck(this, SimpleCellFormatter);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
SimpleCellFormatter.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return nextProps.value !== this.props.value;
};
SimpleCellFormatter.prototype.render = function render() {
return React.createElement(
'div',
{ title: this.props.value },
this.props.value
);
};
return SimpleCellFormatter;
}(React.Component);
SimpleCellFormatter.propTypes = {
value: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number, _propTypes2['default'].object, _propTypes2['default'].bool]).isRequired
};
module.exports = SimpleCellFormatter;
/***/ }),
/* 70 */
/***/ (function(module, exports) {
"use strict";
function shallowCloneObject(obj) {
var result = {};
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
result[k] = obj[k];
}
}
return result;
}
module.exports = shallowCloneObject;
/***/ }),
/* 71 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _immutable = __webpack_require__(19);
module.exports = {
isEmptyArray: __webpack_require__(218),
isEmptyObject: __webpack_require__(219),
isFunction: __webpack_require__(23),
isImmutableCollection: __webpack_require__(220),
getMixedTypeValueRetriever: __webpack_require__(222),
isColumnsImmutable: __webpack_require__(72),
isImmutableMap: __webpack_require__(221),
last: function last(arrayOrList) {
if (arrayOrList == null) {
throw new Error('arrayOrCollection is null');
}
if (_immutable.List.isList(arrayOrList)) {
return arrayOrList.last();
}
if (Array.isArray(arrayOrList)) {
return arrayOrList[arrayOrList.length - 1];
}
throw new Error('Cant get last of: ' + (typeof arrayOrList === 'undefined' ? 'undefined' : _typeof(arrayOrList)));
}
};
/***/ }),
/* 72 */
/***/ (function(module, exports) {
'use strict';
module.exports = function isColumnsImmutable(columns) {
return typeof Immutable !== 'undefined' && columns instanceof Immutable.List;
};
/***/ }),
/* 73 */
/***/ (function(module, exports) {
'use strict';
exports.__esModule = true;
function isKeyPrintable(keycode) {
var valid = keycode > 47 && keycode < 58 || // number keys
keycode === 32 || keycode === 13 || // spacebar & return key(s) (if you want to allow carriage returns)
keycode > 64 && keycode < 91 || // letter keys
keycode > 95 && keycode < 112 || // numpad keys
keycode > 185 && keycode < 193 || // ;=,-./` (in order)
keycode > 218 && keycode < 223; // [\]' (in order)
return valid;
}
function isCtrlKeyHeldDown(e) {
return (e.ctrlKey === true || e.metaKey === true) && e.key !== 'Control';
}
exports.isKeyPrintable = isKeyPrintable;
exports.isCtrlKeyHeldDown = isCtrlKeyHeldDown;
/***/ }),
/* 74 */,
/* 75 */
/***/ (function(module, exports) {
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule shallowEqual
* @typechecks
*
*/
'use strict';
var hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Performs equality by iterating through keys on an object and returning false
* when any key has values which are not strictly equal between the arguments.
* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA, objB) {
if (objA === objB) {
return true;
}
if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
var bHasOwnProperty = hasOwnProperty.bind(objB);
for (var i = 0; i < keysA.length; i++) {
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
return false;
}
}
return true;
}
module.exports = shallowEqual;
/***/ }),
/* 76 */
/***/ (function(module, exports, __webpack_require__) {
// style-loader: Adds some css to the DOM by adding a <style> tag
// load the styles
var content = __webpack_require__(226);
if(typeof content === 'string') content = [[module.id, content, '']];
// add the styles to the DOM
var update = __webpack_require__(11)(content, {});
if(content.locals) module.exports = content.locals;
// Hot Module Replacement
if(false) {
// When the styles change, update the <style> tags
if(!content.locals) {
module.hot.accept("!!../node_modules/css-loader/index.js!./react-data-grid-checkbox.css", function() {
var newContent = require("!!../node_modules/css-loader/index.js!./react-data-grid-checkbox.css");
if(typeof newContent === 'string') newContent = [[module.id, newContent, '']];
update(newContent);
});
}
// When the module is disposed, remove the <style> tags
module.hot.dispose(function() { update(); });
}
/***/ }),
/* 77 */,
/* 78 */,
/* 79 */,
/* 80 */,
/* 81 */,
/* 82 */,
/* 83 */,
/* 84 */,
/* 85 */,
/* 86 */,
/* 87 */,
/* 88 */,
/* 89 */,
/* 90 */,
/* 91 */,
/* 92 */,
/* 93 */,
/* 94 */,
/* 95 */,
/* 96 */,
/* 97 */,
/* 98 */,
/* 99 */,
/* 100 */,
/* 101 */,
/* 102 */,
/* 103 */,
/* 104 */,
/* 105 */,
/* 106 */,
/* 107 */,
/* 108 */,
/* 109 */,
/* 110 */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.8.3
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(function() {
// Baseline setup
// --------------
// Establish the root object, `window` in the browser, or `exports` on the server.
var root = this;
// Save the previous value of the `_` variable.
var previousUnderscore = root._;
// Save bytes in the minified (but not gzipped) version:
var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype;
// Create quick reference variables for speed access to core prototypes.
var
push = ArrayProto.push,
slice = ArrayProto.slice,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty;
// All **ECMAScript 5** native function implementations that we hope to use
// are declared here.
var
nativeIsArray = Array.isArray,
nativeKeys = Object.keys,
nativeBind = FuncProto.bind,
nativeCreate = Object.create;
// Naked function reference for surrogate-prototype-swapping.
var Ctor = function(){};
// Create a safe reference to the Underscore object for use below.
var _ = function(obj) {
if (obj instanceof _) return obj;
if (!(this instanceof _)) return new _(obj);
this._wrapped = obj;
};
// Export the Underscore object for **Node.js**, with
// backwards-compatibility for the old `require()` API. If we're in
// the browser, add `_` as a global object.
if (true) {
if (typeof module !== 'undefined' && module.exports) {
exports = module.exports = _;
}
exports._ = _;
} else {
root._ = _;
}
// Current version.
_.VERSION = '1.8.3';
// Internal function that returns an efficient (for current engines) version
// of the passed-in callback, to be repeatedly applied in other Underscore
// functions.
var optimizeCb = function(func, context, argCount) {
if (context === void 0) return func;
switch (argCount == null ? 3 : argCount) {
case 1: return function(value) {
return func.call(context, value);
};
case 2: return function(value, other) {
return func.call(context, value, other);
};
case 3: return function(value, index, collection) {
return func.call(context, value, index, collection);
};
case 4: return function(accumulator, value, index, collection) {
return func.call(context, accumulator, value, index, collection);
};
}
return function() {
return func.apply(context, arguments);
};
};
// A mostly-internal function to generate callbacks that can be applied
// to each element in a collection, returning the desired result — either
// identity, an arbitrary callback, a property matcher, or a property accessor.
var cb = function(value, context, argCount) {
if (value == null) return _.identity;
if (_.isFunction(value)) return optimizeCb(value, context, argCount);
if (_.isObject(value)) return _.matcher(value);
return _.property(value);
};
_.iteratee = function(value, context) {
return cb(value, context, Infinity);
};
// An internal function for creating assigner functions.
var createAssigner = function(keysFunc, undefinedOnly) {
return function(obj) {
var length = arguments.length;
if (length < 2 || obj == null) return obj;
for (var index = 1; index < length; index++) {
var source = arguments[index],
keys = keysFunc(source),
l = keys.length;
for (var i = 0; i < l; i++) {
var key = keys[i];
if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key];
}
}
return obj;
};
};
// An internal function for creating a new object that inherits from another.
var baseCreate = function(prototype) {
if (!_.isObject(prototype)) return {};
if (nativeCreate) return nativeCreate(prototype);
Ctor.prototype = prototype;
var result = new Ctor;
Ctor.prototype = null;
return result;
};
var property = function(key) {
return function(obj) {
return obj == null ? void 0 : obj[key];
};
};
// Helper for collection methods to determine whether a collection
// should be iterated as an array or as an object
// Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength
// Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094
var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1;
var getLength = property('length');
var isArrayLike = function(collection) {
var length = getLength(collection);
return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX;
};
// Collection Functions
// --------------------
// The cornerstone, an `each` implementation, aka `forEach`.
// Handles raw objects in addition to array-likes. Treats all
// sparse array-likes as if they were dense.
_.each = _.forEach = function(obj, iteratee, context) {
iteratee = optimizeCb(iteratee, context);
var i, length;
if (isArrayLike(obj)) {
for (i = 0, length = obj.length; i < length; i++) {
iteratee(obj[i], i, obj);
}
} else {
var keys = _.keys(obj);
for (i = 0, length = keys.length; i < length; i++) {
iteratee(obj[keys[i]], keys[i], obj);
}
}
return obj;
};
// Return the results of applying the iteratee to each element.
_.map = _.collect = function(obj, iteratee, context) {
iteratee = cb(iteratee, context);
var keys = !isArrayLike(obj) && _.keys(obj),
length = (keys || obj).length,
results = Array(length);
for (var index = 0; index < length; index++) {
var currentKey = keys ? keys[index] : index;
results[index] = iteratee(obj[currentKey], currentKey, obj);
}
return results;
};
// Create a reducing function iterating left or right.
function createReduce(dir) {
// Optimized iterator function as using arguments.length
// in the main function will deoptimize the, see #1991.
function iterator(obj, iteratee, memo, keys, index, length) {
for (; index >= 0 && index < length; index += dir) {
var currentKey = keys ? keys[index] : index;
memo = iteratee(memo, obj[currentKey], currentKey, obj);
}
return memo;
}
return function(obj, iteratee, memo, context) {
iteratee = optimizeCb(iteratee, context, 4);
var keys = !isArrayLike(obj) && _.keys(obj),
length = (keys || obj).length,
index = dir > 0 ? 0 : length - 1;
// Determine the initial value if none is provided.
if (arguments.length < 3) {
memo = obj[keys ? keys[index] : index];
index += dir;
}
return iterator(obj, iteratee, memo, keys, index, length);
};
}
// **Reduce** builds up a single result from a list of values, aka `inject`,
// or `foldl`.
_.reduce = _.foldl = _.inject = createReduce(1);
// The right-associative version of reduce, also known as `foldr`.
_.reduceRight = _.foldr = createReduce(-1);
// Return the first value which passes a truth test. Aliased as `detect`.
_.find = _.detect = function(obj, predicate, context) {
var key;
if (isArrayLike(obj)) {
key = _.findIndex(obj, predicate, context);
} else {
key = _.findKey(obj, predicate, context);
}
if (key !== void 0 && key !== -1) return obj[key];
};
// Return all the elements that pass a truth test.
// Aliased as `select`.
_.filter = _.select = function(obj, predicate, context) {
var results = [];
predicate = cb(predicate, context);
_.each(obj, function(value, index, list) {
if (predicate(value, index, list)) results.push(value);
});
return results;
};
// Return all the elements for which a truth test fails.
_.reject = function(obj, predicate, context) {
return _.filter(obj, _.negate(cb(predicate)), context);
};
// Determine whether all of the elements match a truth test.
// Aliased as `all`.
_.every = _.all = function(obj, predicate, context) {
predicate = cb(predicate, context);
var keys = !isArrayLike(obj) && _.keys(obj),
length = (keys || obj).length;
for (var index = 0; index < length; index++) {
var currentKey = keys ? keys[index] : index;
if (!predicate(obj[currentKey], currentKey, obj)) return false;
}
return true;
};
// Determine if at least one element in the object matches a truth test.
// Aliased as `any`.
_.some = _.any = function(obj, predicate, context) {
predicate = cb(predicate, context);
var keys = !isArrayLike(obj) && _.keys(obj),
length = (keys || obj).length;
for (var index = 0; index < length; index++) {
var currentKey = keys ? keys[index] : index;
if (predicate(obj[currentKey], currentKey, obj)) return true;
}
return false;
};
// Determine if the array or object contains a given item (using `===`).
// Aliased as `includes` and `include`.
_.contains = _.includes = _.include = function(obj, item, fromIndex, guard) {
if (!isArrayLike(obj)) obj = _.values(obj);
if (typeof fromIndex != 'number' || guard) fromIndex = 0;
return _.indexOf(obj, item, fromIndex) >= 0;
};
// Invoke a method (with arguments) on every item in a collection.
_.invoke = function(obj, method) {
var args = slice.call(arguments, 2);
var isFunc = _.isFunction(method);
return _.map(obj, function(value) {
var func = isFunc ? method : value[method];
return func == null ? func : func.apply(value, args);
});
};
// Convenience version of a common use case of `map`: fetching a property.
_.pluck = function(obj, key) {
return _.map(obj, _.property(key));
};
// Convenience version of a common use case of `filter`: selecting only objects
// containing specific `key:value` pairs.
_.where = function(obj, attrs) {
return _.filter(obj, _.matcher(attrs));
};
// Convenience version of a common use case of `find`: getting the first object
// containing specific `key:value` pairs.
_.findWhere = function(obj, attrs) {
return _.find(obj, _.matcher(attrs));
};
// Return the maximum element (or element-based computation).
_.max = function(obj, iteratee, context) {
var result = -Infinity, lastComputed = -Infinity,
value, computed;
if (iteratee == null && obj != null) {
obj = isArrayLike(obj) ? obj : _.values(obj);
for (var i = 0, length = obj.length; i < length; i++) {
value = obj[i];
if (value > result) {
result = value;
}
}
} else {
iteratee = cb(iteratee, context);
_.each(obj, function(value, index, list) {
computed = iteratee(value, index, list);
if (computed > lastComputed || computed === -Infinity && result === -Infinity) {
result = value;
lastComputed = computed;
}
});
}
return result;
};
// Return the minimum element (or element-based computation).
_.min = function(obj, iteratee, context) {
var result = Infinity, lastComputed = Infinity,
value, computed;
if (iteratee == null && obj != null) {
obj = isArrayLike(obj) ? obj : _.values(obj);
for (var i = 0, length = obj.length; i < length; i++) {
value = obj[i];
if (value < result) {
result = value;
}
}
} else {
iteratee = cb(iteratee, context);
_.each(obj, function(value, index, list) {
computed = iteratee(value, index, list);
if (computed < lastComputed || computed === Infinity && result === Infinity) {
result = value;
lastComputed = computed;
}
});
}
return result;
};
// Shuffle a collection, using the modern version of the
// [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
_.shuffle = function(obj) {
var set = isArrayLike(obj) ? obj : _.values(obj);
var length = set.length;
var shuffled = Array(length);
for (var index = 0, rand; index < length; index++) {
rand = _.random(0, index);
if (rand !== index) shuffled[index] = shuffled[rand];
shuffled[rand] = set[index];
}
return shuffled;
};
// Sample **n** random values from a collection.
// If **n** is not specified, returns a single random element.
// The internal `guard` argument allows it to work with `map`.
_.sample = function(obj, n, guard) {
if (n == null || guard) {
if (!isArrayLike(obj)) obj = _.values(obj);
return obj[_.random(obj.length - 1)];
}
return _.shuffle(obj).slice(0, Math.max(0, n));
};
// Sort the object's values by a criterion produced by an iteratee.
_.sortBy = function(obj, iteratee, context) {
iteratee = cb(iteratee, context);
return _.pluck(_.map(obj, function(value, index, list) {
return {
value: value,
index: index,
criteria: iteratee(value, index, list)
};
}).sort(function(left, right) {
var a = left.criteria;
var b = right.criteria;
if (a !== b) {
if (a > b || a === void 0) return 1;
if (a < b || b === void 0) return -1;
}
return left.index - right.index;
}), 'value');
};
// An internal function used for aggregate "group by" operations.
var group = function(behavior) {
return function(obj, iteratee, context) {
var result = {};
iteratee = cb(iteratee, context);
_.each(obj, function(value, index) {
var key = iteratee(value, index, obj);
behavior(result, value, key);
});
return result;
};
};
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_.groupBy = group(function(result, value, key) {
if (_.has(result, key)) result[key].push(value); else result[key] = [value];
});
// Indexes the object's values by a criterion, similar to `groupBy`, but for
// when you know that your index values will be unique.
_.indexBy = group(function(result, value, key) {
result[key] = value;
});
// Counts instances of an object that group by a certain criterion. Pass
// either a string attribute to count by, or a function that returns the
// criterion.
_.countBy = group(function(result, value, key) {
if (_.has(result, key)) result[key]++; else result[key] = 1;
});
// Safely create a real, live array from anything iterable.
_.toArray = function(obj) {
if (!obj) return [];
if (_.isArray(obj)) return slice.call(obj);
if (isArrayLike(obj)) return _.map(obj, _.identity);
return _.values(obj);
};
// Return the number of elements in an object.
_.size = function(obj) {
if (obj == null) return 0;
return isArrayLike(obj) ? obj.length : _.keys(obj).length;
};
// Split a collection into two arrays: one whose elements all satisfy the given
// predicate, and one whose elements all do not satisfy the predicate.
_.partition = function(obj, predicate, context) {
predicate = cb(predicate, context);
var pass = [], fail = [];
_.each(obj, function(value, key, obj) {
(predicate(value, key, obj) ? pass : fail).push(value);
});
return [pass, fail];
};
// Array Functions
// ---------------
// Get the first element of an array. Passing **n** will return the first N
// values in the array. Aliased as `head` and `take`. The **guard** check
// allows it to work with `_.map`.
_.first = _.head = _.take = function(array, n, guard) {
if (array == null) return void 0;
if (n == null || guard) return array[0];
return _.initial(array, array.length - n);
};
// Returns everything but the last entry of the array. Especially useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N.
_.initial = function(array, n, guard) {
return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
};
// Get the last element of an array. Passing **n** will return the last N
// values in the array.
_.last = function(array, n, guard) {
if (array == null) return void 0;
if (n == null || guard) return array[array.length - 1];
return _.rest(array, Math.max(0, array.length - n));
};
// Returns everything but the first entry of the array. Aliased as `tail` and `drop`.
// Especially useful on the arguments object. Passing an **n** will return
// the rest N values in the array.
_.rest = _.tail = _.drop = function(array, n, guard) {
return slice.call(array, n == null || guard ? 1 : n);
};
// Trim out all falsy values from an array.
_.compact = function(array) {
return _.filter(array, _.identity);
};
// Internal implementation of a recursive `flatten` function.
var flatten = function(input, shallow, strict, startIndex) {
var output = [], idx = 0;
for (var i = startIndex || 0, length = getLength(input); i < length; i++) {
var value = input[i];
if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) {
//flatten current level of array or arguments object
if (!shallow) value = flatten(value, shallow, strict);
var j = 0, len = value.length;
output.length += len;
while (j < len) {
output[idx++] = value[j++];
}
} else if (!strict) {
output[idx++] = value;
}
}
return output;
};
// Flatten out an array, either recursively (by default), or just one level.
_.flatten = function(array, shallow) {
return flatten(array, shallow, false);
};
// Return a version of the array that does not contain the specified value(s).
_.without = function(array) {
return _.difference(array, slice.call(arguments, 1));
};
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// Aliased as `unique`.
_.uniq = _.unique = function(array, isSorted, iteratee, context) {
if (!_.isBoolean(isSorted)) {
context = iteratee;
iteratee = isSorted;
isSorted = false;
}
if (iteratee != null) iteratee = cb(iteratee, context);
var result = [];
var seen = [];
for (var i = 0, length = getLength(array); i < length; i++) {
var value = array[i],
computed = iteratee ? iteratee(value, i, array) : value;
if (isSorted) {
if (!i || seen !== computed) result.push(value);
seen = computed;
} else if (iteratee) {
if (!_.contains(seen, computed)) {
seen.push(computed);
result.push(value);
}
} else if (!_.contains(result, value)) {
result.push(value);
}
}
return result;
};
// Produce an array that contains the union: each distinct element from all of
// the passed-in arrays.
_.union = function() {
return _.uniq(flatten(arguments, true, true));
};
// Produce an array that contains every item shared between all the
// passed-in arrays.
_.intersection = function(array) {
var result = [];
var argsLength = arguments.length;
for (var i = 0, length = getLength(array); i < length; i++) {
var item = array[i];
if (_.contains(result, item)) continue;
for (var j = 1; j < argsLength; j++) {
if (!_.contains(arguments[j], item)) break;
}
if (j === argsLength) result.push(item);
}
return result;
};
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
_.difference = function(array) {
var rest = flatten(arguments, true, true, 1);
return _.filter(array, function(value){
return !_.contains(rest, value);
});
};
// Zip together multiple lists into a single array -- elements that share
// an index go together.
_.zip = function() {
return _.unzip(arguments);
};
// Complement of _.zip. Unzip accepts an array of arrays and groups
// each array's elements on shared indices
_.unzip = function(array) {
var length = array && _.max(array, getLength).length || 0;
var result = Array(length);
for (var index = 0; index < length; index++) {
result[index] = _.pluck(array, index);
}
return result;
};
// Converts lists into objects. Pass either a single array of `[key, value]`
// pairs, or two parallel arrays of the same length -- one of keys, and one of
// the corresponding values.
_.object = function(list, values) {
var result = {};
for (var i = 0, length = getLength(list); i < length; i++) {
if (values) {
result[list[i]] = values[i];
} else {
result[list[i][0]] = list[i][1];
}
}
return result;
};
// Generator function to create the findIndex and findLastIndex functions
function createPredicateIndexFinder(dir) {
return function(array, predicate, context) {
predicate = cb(predicate, context);
var length = getLength(array);
var index = dir > 0 ? 0 : length - 1;
for (; index >= 0 && index < length; index += dir) {
if (predicate(array[index], index, array)) return index;
}
return -1;
};
}
// Returns the first index on an array-like that passes a predicate test
_.findIndex = createPredicateIndexFinder(1);
_.findLastIndex = createPredicateIndexFinder(-1);
// Use a comparator function to figure out the smallest index at which
// an object should be inserted so as to maintain order. Uses binary search.
_.sortedIndex = function(array, obj, iteratee, context) {
iteratee = cb(iteratee, context, 1);
var value = iteratee(obj);
var low = 0, high = getLength(array);
while (low < high) {
var mid = Math.floor((low + high) / 2);
if (iteratee(array[mid]) < value) low = mid + 1; else high = mid;
}
return low;
};
// Generator function to create the indexOf and lastIndexOf functions
function createIndexFinder(dir, predicateFind, sortedIndex) {
return function(array, item, idx) {
var i = 0, length = getLength(array);
if (typeof idx == 'number') {
if (dir > 0) {
i = idx >= 0 ? idx : Math.max(idx + length, i);
} else {
length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1;
}
} else if (sortedIndex && idx && length) {
idx = sortedIndex(array, item);
return array[idx] === item ? idx : -1;
}
if (item !== item) {
idx = predicateFind(slice.call(array, i, length), _.isNaN);
return idx >= 0 ? idx + i : -1;
}
for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) {
if (array[idx] === item) return idx;
}
return -1;
};
}
// Return the position of the first occurrence of an item in an array,
// or -1 if the item is not included in the array.
// If the array is large and already in sort order, pass `true`
// for **isSorted** to use binary search.
_.indexOf = createIndexFinder(1, _.findIndex, _.sortedIndex);
_.lastIndexOf = createIndexFinder(-1, _.findLastIndex);
// Generate an integer Array containing an arithmetic progression. A port of
// the native Python `range()` function. See
// [the Python documentation](http://docs.python.org/library/functions.html#range).
_.range = function(start, stop, step) {
if (stop == null) {
stop = start || 0;
start = 0;
}
step = step || 1;
var length = Math.max(Math.ceil((stop - start) / step), 0);
var range = Array(length);
for (var idx = 0; idx < length; idx++, start += step) {
range[idx] = start;
}
return range;
};
// Function (ahem) Functions
// ------------------
// Determines whether to execute a function as a constructor
// or a normal function with the provided arguments
var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) {
if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args);
var self = baseCreate(sourceFunc.prototype);
var result = sourceFunc.apply(self, args);
if (_.isObject(result)) return result;
return self;
};
// Create a function bound to a given object (assigning `this`, and arguments,
// optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if
// available.
_.bind = function(func, context) {
if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function');
var args = slice.call(arguments, 2);
var bound = function() {
return executeBound(func, bound, context, this, args.concat(slice.call(arguments)));
};
return bound;
};
// Partially apply a function by creating a version that has had some of its
// arguments pre-filled, without changing its dynamic `this` context. _ acts
// as a placeholder, allowing any combination of arguments to be pre-filled.
_.partial = function(func) {
var boundArgs = slice.call(arguments, 1);
var bound = function() {
var position = 0, length = boundArgs.length;
var args = Array(length);
for (var i = 0; i < length; i++) {
args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i];
}
while (position < arguments.length) args.push(arguments[position++]);
return executeBound(func, bound, this, this, args);
};
return bound;
};
// Bind a number of an object's methods to that object. Remaining arguments
// are the method names to be bound. Useful for ensuring that all callbacks
// defined on an object belong to it.
_.bindAll = function(obj) {
var i, length = arguments.length, key;
if (length <= 1) throw new Error('bindAll must be passed function names');
for (i = 1; i < length; i++) {
key = arguments[i];
obj[key] = _.bind(obj[key], obj);
}
return obj;
};
// Memoize an expensive function by storing its results.
_.memoize = function(func, hasher) {
var memoize = function(key) {
var cache = memoize.cache;
var address = '' + (hasher ? hasher.apply(this, arguments) : key);
if (!_.has(cache, address)) cache[address] = func.apply(this, arguments);
return cache[address];
};
memoize.cache = {};
return memoize;
};
// Delays a function for the given number of milliseconds, and then calls
// it with the arguments supplied.
_.delay = function(func, wait) {
var args = slice.call(arguments, 2);
return setTimeout(function(){
return func.apply(null, args);
}, wait);
};
// Defers a function, scheduling it to run after the current call stack has
// cleared.
_.defer = _.partial(_.delay, _, 1);
// Returns a function, that, when invoked, will only be triggered at most once
// during a given window of time. Normally, the throttled function will run
// as much as it can, without ever going more than once per `wait` duration;
// but if you'd like to disable the execution on the leading edge, pass
// `{leading: false}`. To disable execution on the trailing edge, ditto.
_.throttle = function(func, wait, options) {
var context, args, result;
var timeout = null;
var previous = 0;
if (!options) options = {};
var later = function() {
previous = options.leading === false ? 0 : _.now();
timeout = null;
result = func.apply(context, args);
if (!timeout) context = args = null;
};
return function() {
var now = _.now();
if (!previous && options.leading === false) previous = now;
var remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0 || remaining > wait) {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
previous = now;
result = func.apply(context, args);
if (!timeout) context = args = null;
} else if (!timeout && options.trailing !== false) {
timeout = setTimeout(later, remaining);
}
return result;
};
};
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
_.debounce = function(func, wait, immediate) {
var timeout, args, context, timestamp, result;
var later = function() {
var last = _.now() - timestamp;
if (last < wait && last >= 0) {
timeout = setTimeout(later, wait - last);
} else {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
if (!timeout) context = args = null;
}
}
};
return function() {
context = this;
args = arguments;
timestamp = _.now();
var callNow = immediate && !timeout;
if (!timeout) timeout = setTimeout(later, wait);
if (callNow) {
result = func.apply(context, args);
context = args = null;
}
return result;
};
};
// Returns the first function passed as an argument to the second,
// allowing you to adjust arguments, run code before and after, and
// conditionally execute the original function.
_.wrap = function(func, wrapper) {
return _.partial(wrapper, func);
};
// Returns a negated version of the passed-in predicate.
_.negate = function(predicate) {
return function() {
return !predicate.apply(this, arguments);
};
};
// Returns a function that is the composition of a list of functions, each
// consuming the return value of the function that follows.
_.compose = function() {
var args = arguments;
var start = args.length - 1;
return function() {
var i = start;
var result = args[start].apply(this, arguments);
while (i--) result = args[i].call(this, result);
return result;
};
};
// Returns a function that will only be executed on and after the Nth call.
_.after = function(times, func) {
return function() {
if (--times < 1) {
return func.apply(this, arguments);
}
};
};
// Returns a function that will only be executed up to (but not including) the Nth call.
_.before = function(times, func) {
var memo;
return function() {
if (--times > 0) {
memo = func.apply(this, arguments);
}
if (times <= 1) func = null;
return memo;
};
};
// Returns a function that will be executed at most one time, no matter how
// often you call it. Useful for lazy initialization.
_.once = _.partial(_.before, 2);
// Object Functions
// ----------------
// Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed.
var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString');
var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString',
'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
function collectNonEnumProps(obj, keys) {
var nonEnumIdx = nonEnumerableProps.length;
var constructor = obj.constructor;
var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto;
// Constructor is a special case.
var prop = 'constructor';
if (_.has(obj, prop) && !_.contains(keys, prop)) keys.push(prop);
while (nonEnumIdx--) {
prop = nonEnumerableProps[nonEnumIdx];
if (prop in obj && obj[prop] !== proto[prop] && !_.contains(keys, prop)) {
keys.push(prop);
}
}
}
// Retrieve the names of an object's own properties.
// Delegates to **ECMAScript 5**'s native `Object.keys`
_.keys = function(obj) {
if (!_.isObject(obj)) return [];
if (nativeKeys) return nativeKeys(obj);
var keys = [];
for (var key in obj) if (_.has(obj, key)) keys.push(key);
// Ahem, IE < 9.
if (hasEnumBug) collectNonEnumProps(obj, keys);
return keys;
};
// Retrieve all the property names of an object.
_.allKeys = function(obj) {
if (!_.isObject(obj)) return [];
var keys = [];
for (var key in obj) keys.push(key);
// Ahem, IE < 9.
if (hasEnumBug) collectNonEnumProps(obj, keys);
return keys;
};
// Retrieve the values of an object's properties.
_.values = function(obj) {
var keys = _.keys(obj);
var length = keys.length;
var values = Array(length);
for (var i = 0; i < length; i++) {
values[i] = obj[keys[i]];
}
return values;
};
// Returns the results of applying the iteratee to each element of the object
// In contrast to _.map it returns an object
_.mapObject = function(obj, iteratee, context) {
iteratee = cb(iteratee, context);
var keys = _.keys(obj),
length = keys.length,
results = {},
currentKey;
for (var index = 0; index < length; index++) {
currentKey = keys[index];
results[currentKey] = iteratee(obj[currentKey], currentKey, obj);
}
return results;
};
// Convert an object into a list of `[key, value]` pairs.
_.pairs = function(obj) {
var keys = _.keys(obj);
var length = keys.length;
var pairs = Array(length);
for (var i = 0; i < length; i++) {
pairs[i] = [keys[i], obj[keys[i]]];
}
return pairs;
};
// Invert the keys and values of an object. The values must be serializable.
_.invert = function(obj) {
var result = {};
var keys = _.keys(obj);
for (var i = 0, length = keys.length; i < length; i++) {
result[obj[keys[i]]] = keys[i];
}
return result;
};
// Return a sorted list of the function names available on the object.
// Aliased as `methods`
_.functions = _.methods = function(obj) {
var names = [];
for (var key in obj) {
if (_.isFunction(obj[key])) names.push(key);
}
return names.sort();
};
// Extend a given object with all the properties in passed-in object(s).
_.extend = createAssigner(_.allKeys);
// Assigns a given object with all the own properties in the passed-in object(s)
// (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign)
_.extendOwn = _.assign = createAssigner(_.keys);
// Returns the first key on an object that passes a predicate test
_.findKey = function(obj, predicate, context) {
predicate = cb(predicate, context);
var keys = _.keys(obj), key;
for (var i = 0, length = keys.length; i < length; i++) {
key = keys[i];
if (predicate(obj[key], key, obj)) return key;
}
};
// Return a copy of the object only containing the whitelisted properties.
_.pick = function(object, oiteratee, context) {
var result = {}, obj = object, iteratee, keys;
if (obj == null) return result;
if (_.isFunction(oiteratee)) {
keys = _.allKeys(obj);
iteratee = optimizeCb(oiteratee, context);
} else {
keys = flatten(arguments, false, false, 1);
iteratee = function(value, key, obj) { return key in obj; };
obj = Object(obj);
}
for (var i = 0, length = keys.length; i < length; i++) {
var key = keys[i];
var value = obj[key];
if (iteratee(value, key, obj)) result[key] = value;
}
return result;
};
// Return a copy of the object without the blacklisted properties.
_.omit = function(obj, iteratee, context) {
if (_.isFunction(iteratee)) {
iteratee = _.negate(iteratee);
} else {
var keys = _.map(flatten(arguments, false, false, 1), String);
iteratee = function(value, key) {
return !_.contains(keys, key);
};
}
return _.pick(obj, iteratee, context);
};
// Fill in a given object with default properties.
_.defaults = createAssigner(_.allKeys, true);
// Creates an object that inherits from the given prototype object.
// If additional properties are provided then they will be added to the
// created object.
_.create = function(prototype, props) {
var result = baseCreate(prototype);
if (props) _.extendOwn(result, props);
return result;
};
// Create a (shallow-cloned) duplicate of an object.
_.clone = function(obj) {
if (!_.isObject(obj)) return obj;
return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
};
// Invokes interceptor with the obj, and then returns obj.
// The primary purpose of this method is to "tap into" a method chain, in
// order to perform operations on intermediate results within the chain.
_.tap = function(obj, interceptor) {
interceptor(obj);
return obj;
};
// Returns whether an object has a given set of `key:value` pairs.
_.isMatch = function(object, attrs) {
var keys = _.keys(attrs), length = keys.length;
if (object == null) return !length;
var obj = Object(object);
for (var i = 0; i < length; i++) {
var key = keys[i];
if (attrs[key] !== obj[key] || !(key in obj)) return false;
}
return true;
};
// Internal recursive comparison function for `isEqual`.
var eq = function(a, b, aStack, bStack) {
// Identical objects are equal. `0 === -0`, but they aren't identical.
// See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).
if (a === b) return a !== 0 || 1 / a === 1 / b;
// A strict comparison is necessary because `null == undefined`.
if (a == null || b == null) return a === b;
// Unwrap any wrapped objects.
if (a instanceof _) a = a._wrapped;
if (b instanceof _) b = b._wrapped;
// Compare `[[Class]]` names.
var className = toString.call(a);
if (className !== toString.call(b)) return false;
switch (className) {
// Strings, numbers, regular expressions, dates, and booleans are compared by value.
case '[object RegExp]':
// RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i')
case '[object String]':
// Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
// equivalent to `new String("5")`.
return '' + a === '' + b;
case '[object Number]':
// `NaN`s are equivalent, but non-reflexive.
// Object(NaN) is equivalent to NaN
if (+a !== +a) return +b !== +b;
// An `egal` comparison is performed for other numeric values.
return +a === 0 ? 1 / +a === 1 / b : +a === +b;
case '[object Date]':
case '[object Boolean]':
// Coerce dates and booleans to numeric primitive values. Dates are compared by their
// millisecond representations. Note that invalid dates with millisecond representations
// of `NaN` are not equivalent.
return +a === +b;
}
var areArrays = className === '[object Array]';
if (!areArrays) {
if (typeof a != 'object' || typeof b != 'object') return false;
// Objects with different constructors are not equivalent, but `Object`s or `Array`s
// from different frames are.
var aCtor = a.constructor, bCtor = b.constructor;
if (aCtor !== bCtor && !(_.isFunction(aCtor) && aCtor instanceof aCtor &&
_.isFunction(bCtor) && bCtor instanceof bCtor)
&& ('constructor' in a && 'constructor' in b)) {
return false;
}
}
// Assume equality for cyclic structures. The algorithm for detecting cyclic
// structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
// Initializing stack of traversed objects.
// It's done here since we only need them for objects and arrays comparison.
aStack = aStack || [];
bStack = bStack || [];
var length = aStack.length;
while (length--) {
// Linear search. Performance is inversely proportional to the number of
// unique nested structures.
if (aStack[length] === a) return bStack[length] === b;
}
// Add the first object to the stack of traversed objects.
aStack.push(a);
bStack.push(b);
// Recursively compare objects and arrays.
if (areArrays) {
// Compare array lengths to determine if a deep comparison is necessary.
length = a.length;
if (length !== b.length) return false;
// Deep compare the contents, ignoring non-numeric properties.
while (length--) {
if (!eq(a[length], b[length], aStack, bStack)) return false;
}
} else {
// Deep compare objects.
var keys = _.keys(a), key;
length = keys.length;
// Ensure that both objects contain the same number of properties before comparing deep equality.
if (_.keys(b).length !== length) return false;
while (length--) {
// Deep compare each member
key = keys[length];
if (!(_.has(b, key) && eq(a[key], b[key], aStack, bStack))) return false;
}
}
// Remove the first object from the stack of traversed objects.
aStack.pop();
bStack.pop();
return true;
};
// Perform a deep comparison to check if two objects are equal.
_.isEqual = function(a, b) {
return eq(a, b);
};
// Is a given array, string, or object empty?
// An "empty" object has no enumerable own-properties.
_.isEmpty = function(obj) {
if (obj == null) return true;
if (isArrayLike(obj) && (_.isArray(obj) || _.isString(obj) || _.isArguments(obj))) return obj.length === 0;
return _.keys(obj).length === 0;
};
// Is a given value a DOM element?
_.isElement = function(obj) {
return !!(obj && obj.nodeType === 1);
};
// Is a given value an array?
// Delegates to ECMA5's native Array.isArray
_.isArray = nativeIsArray || function(obj) {
return toString.call(obj) === '[object Array]';
};
// Is a given variable an object?
_.isObject = function(obj) {
var type = typeof obj;
return type === 'function' || type === 'object' && !!obj;
};
// Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError.
_.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) {
_['is' + name] = function(obj) {
return toString.call(obj) === '[object ' + name + ']';
};
});
// Define a fallback version of the method in browsers (ahem, IE < 9), where
// there isn't any inspectable "Arguments" type.
if (!_.isArguments(arguments)) {
_.isArguments = function(obj) {
return _.has(obj, 'callee');
};
}
// Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8,
// IE 11 (#1621), and in Safari 8 (#1929).
if (typeof /./ != 'function' && typeof Int8Array != 'object') {
_.isFunction = function(obj) {
return typeof obj == 'function' || false;
};
}
// Is a given object a finite number?
_.isFinite = function(obj) {
return isFinite(obj) && !isNaN(parseFloat(obj));
};
// Is the given value `NaN`? (NaN is the only number which does not equal itself).
_.isNaN = function(obj) {
return _.isNumber(obj) && obj !== +obj;
};
// Is a given value a boolean?
_.isBoolean = function(obj) {
return obj === true || obj === false || toString.call(obj) === '[object Boolean]';
};
// Is a given value equal to null?
_.isNull = function(obj) {
return obj === null;
};
// Is a given variable undefined?
_.isUndefined = function(obj) {
return obj === void 0;
};
// Shortcut function for checking if an object has a given property directly
// on itself (in other words, not on a prototype).
_.has = function(obj, key) {
return obj != null && hasOwnProperty.call(obj, key);
};
// Utility Functions
// -----------------
// Run Underscore.js in *noConflict* mode, returning the `_` variable to its
// previous owner. Returns a reference to the Underscore object.
_.noConflict = function() {
root._ = previousUnderscore;
return this;
};
// Keep the identity function around for default iteratees.
_.identity = function(value) {
return value;
};
// Predicate-generating functions. Often useful outside of Underscore.
_.constant = function(value) {
return function() {
return value;
};
};
_.noop = function(){};
_.property = property;
// Generates a function for a given object that returns a given property.
_.propertyOf = function(obj) {
return obj == null ? function(){} : function(key) {
return obj[key];
};
};
// Returns a predicate for checking whether an object has a given set of
// `key:value` pairs.
_.matcher = _.matches = function(attrs) {
attrs = _.extendOwn({}, attrs);
return function(obj) {
return _.isMatch(obj, attrs);
};
};
// Run a function **n** times.
_.times = function(n, iteratee, context) {
var accum = Array(Math.max(0, n));
iteratee = optimizeCb(iteratee, context, 1);
for (var i = 0; i < n; i++) accum[i] = iteratee(i);
return accum;
};
// Return a random integer between min and max (inclusive).
_.random = function(min, max) {
if (max == null) {
max = min;
min = 0;
}
return min + Math.floor(Math.random() * (max - min + 1));
};
// A (possibly faster) way to get the current timestamp as an integer.
_.now = Date.now || function() {
return new Date().getTime();
};
// List of HTML entities for escaping.
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};
var unescapeMap = _.invert(escapeMap);
// Functions for escaping and unescaping strings to/from HTML interpolation.
var createEscaper = function(map) {
var escaper = function(match) {
return map[match];
};
// Regexes for identifying a key that needs to be escaped
var source = '(?:' + _.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');
return function(string) {
string = string == null ? '' : '' + string;
return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string;
};
};
_.escape = createEscaper(escapeMap);
_.unescape = createEscaper(unescapeMap);
// If the value of the named `property` is a function then invoke it with the
// `object` as context; otherwise, return it.
_.result = function(object, property, fallback) {
var value = object == null ? void 0 : object[property];
if (value === void 0) {
value = fallback;
}
return _.isFunction(value) ? value.call(object) : value;
};
// Generate a unique integer id (unique within the entire client session).
// Useful for temporary DOM ids.
var idCounter = 0;
_.uniqueId = function(prefix) {
var id = ++idCounter + '';
return prefix ? prefix + id : id;
};
// By default, Underscore uses ERB-style template delimiters, change the
// following template settings to use alternative delimiters.
_.templateSettings = {
evaluate : /<%([\s\S]+?)%>/g,
interpolate : /<%=([\s\S]+?)%>/g,
escape : /<%-([\s\S]+?)%>/g
};
// When customizing `templateSettings`, if you don't want to define an
// interpolation, evaluation or escaping regex, we need one that is
// guaranteed not to match.
var noMatch = /(.)^/;
// Certain characters need to be escaped so that they can be put into a
// string literal.
var escapes = {
"'": "'",
'\\': '\\',
'\r': 'r',
'\n': 'n',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
var escaper = /\\|'|\r|\n|\u2028|\u2029/g;
var escapeChar = function(match) {
return '\\' + escapes[match];
};
// JavaScript micro-templating, similar to John Resig's implementation.
// Underscore templating handles arbitrary delimiters, preserves whitespace,
// and correctly escapes quotes within interpolated code.
// NB: `oldSettings` only exists for backwards compatibility.
_.template = function(text, settings, oldSettings) {
if (!settings && oldSettings) settings = oldSettings;
settings = _.defaults({}, settings, _.templateSettings);
// Combine delimiters into one regular expression via alternation.
var matcher = RegExp([
(settings.escape || noMatch).source,
(settings.interpolate || noMatch).source,
(settings.evaluate || noMatch).source
].join('|') + '|$', 'g');
// Compile the template source, escaping string literals appropriately.
var index = 0;
var source = "__p+='";
text.replace(matcher, function(match, escape, interpolate, evaluate, offset) {
source += text.slice(index, offset).replace(escaper, escapeChar);
index = offset + match.length;
if (escape) {
source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'";
} else if (interpolate) {
source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'";
} else if (evaluate) {
source += "';\n" + evaluate + "\n__p+='";
}
// Adobe VMs need the match returned to produce the correct offest.
return match;
});
source += "';\n";
// If a variable is not specified, place data values in local scope.
if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
source = "var __t,__p='',__j=Array.prototype.join," +
"print=function(){__p+=__j.call(arguments,'');};\n" +
source + 'return __p;\n';
try {
var render = new Function(settings.variable || 'obj', '_', source);
} catch (e) {
e.source = source;
throw e;
}
var template = function(data) {
return render.call(this, data, _);
};
// Provide the compiled source as a convenience for precompilation.
var argument = settings.variable || 'obj';
template.source = 'function(' + argument + '){\n' + source + '}';
return template;
};
// Add a "chain" function. Start chaining a wrapped Underscore object.
_.chain = function(obj) {
var instance = _(obj);
instance._chain = true;
return instance;
};
// OOP
// ---------------
// If Underscore is called as a function, it returns a wrapped object that
// can be used OO-style. This wrapper holds altered versions of all the
// underscore functions. Wrapped objects may be chained.
// Helper function to continue chaining intermediate results.
var result = function(instance, obj) {
return instance._chain ? _(obj).chain() : obj;
};
// Add your own custom functions to the Underscore object.
_.mixin = function(obj) {
_.each(_.functions(obj), function(name) {
var func = _[name] = obj[name];
_.prototype[name] = function() {
var args = [this._wrapped];
push.apply(args, arguments);
return result(this, func.apply(_, args));
};
});
};
// Add all of the Underscore functions to the wrapper object.
_.mixin(_);
// Add all mutator Array functions to the wrapper.
_.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = ArrayProto[name];
_.prototype[name] = function() {
var obj = this._wrapped;
method.apply(obj, arguments);
if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0];
return result(this, obj);
};
});
// Add all accessor Array functions to the wrapper.
_.each(['concat', 'join', 'slice'], function(name) {
var method = ArrayProto[name];
_.prototype[name] = function() {
return result(this, method.apply(this._wrapped, arguments));
};
});
// Extracts the result from a wrapped and chained object.
_.prototype.value = function() {
return this._wrapped;
};
// Provide unwrapping proxy for some methods used in engine operations
// such as arithmetic and JSON stringification.
_.prototype.valueOf = _.prototype.toJSON = _.prototype.value;
_.prototype.toString = function() {
return '' + this._wrapped;
};
// AMD registration happens at the end for compatibility with AMD loaders
// that may not enforce next-turn semantics on modules. Even though general
// practice for AMD registration is to be anonymous, underscore registers
// as a named module because, like jQuery, it is a base library that is
// popular enough to be bundled in a third party lib, but not be part of
// an AMD load request. Those cases could generate an error when an
// anonymous define() is called outside of a loader request.
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = function() {
return _;
}.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
}.call(this));
/***/ }),
/* 111 */,
/* 112 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 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 strict';
var emptyFunction = __webpack_require__(114);
var invariant = __webpack_require__(115);
var ReactPropTypesSecret = __webpack_require__(113);
module.exports = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
invariant(
false,
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
'Use PropTypes.checkPropTypes() to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
};
shim.isRequired = shim;
function getShim() {
return shim;
};
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim
};
ReactPropTypes.checkPropTypes = emptyFunction;
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/***/ }),
/* 113 */
/***/ (function(module, exports) {
/**
* 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 strict';
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/* 114 */
/***/ (function(module, exports) {
"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 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() {};
emptyFunction.thatReturns = makeEmptyFunction;
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
emptyFunction.thatReturnsThis = function () {
return this;
};
emptyFunction.thatReturnsArgument = function (arg) {
return arg;
};
module.exports = emptyFunction;
/***/ }),
/* 115 */
/***/ (function(module, exports, __webpack_require__) {
/**
* 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 strict';
/**
* 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.
*/
var validateFormat = function validateFormat(format) {};
if (false) {
validateFormat = function validateFormat(format) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
};
}
function invariant(condition, format, a, b, c, d, e, f) {
validateFormat(format);
if (!condition) {
var error;
if (format === undefined) {
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];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/***/ }),
/* 116 */,
/* 117 */,
/* 118 */,
/* 119 */,
/* 120 */,
/* 121 */,
/* 122 */,
/* 123 */,
/* 124 */,
/* 125 */,
/* 126 */,
/* 127 */,
/* 128 */,
/* 129 */,
/* 130 */,
/* 131 */,
/* 132 */,
/* 133 */,
/* 134 */,
/* 135 */,
/* 136 */,
/* 137 */,
/* 138 */,
/* 139 */,
/* 140 */,
/* 141 */,
/* 142 */,
/* 143 */,
/* 144 */,
/* 145 */,
/* 146 */,
/* 147 */,
/* 148 */,
/* 149 */,
/* 150 */,
/* 151 */,
/* 152 */,
/* 153 */,
/* 154 */,
/* 155 */,
/* 156 */,
/* 157 */,
/* 158 */,
/* 159 */,
/* 160 */,
/* 161 */,
/* 162 */,
/* 163 */,
/* 164 */,
/* 165 */,
/* 166 */,
/* 167 */,
/* 168 */,
/* 169 */,
/* 170 */,
/* 171 */,
/* 172 */,
/* 173 */,
/* 174 */,
/* 175 */,
/* 176 */,
/* 177 */,
/* 178 */,
/* 179 */,
/* 180 */,
/* 181 */,
/* 182 */,
/* 183 */,
/* 184 */,
/* 185 */,
/* 186 */,
/* 187 */,
/* 188 */,
/* 189 */,
/* 190 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _scrollUtils = __webpack_require__(223);
var _shallowEqual = __webpack_require__(75);
var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
var _RowsContainer = __webpack_require__(64);
var _RowsContainer2 = _interopRequireDefault(_RowsContainer);
var _RowGroup = __webpack_require__(207);
var _RowGroup2 = _interopRequireDefault(_RowGroup);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var joinClasses = __webpack_require__(7);
var Row = __webpack_require__(61);
var cellMetaDataShape = __webpack_require__(12);
var RowUtils = __webpack_require__(63);
__webpack_require__(26);
var Canvas = function (_React$Component) {
_inherits(Canvas, _React$Component);
function Canvas() {
var _temp, _this, _ret;
_classCallCheck(this, Canvas);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
displayStart: _this.props.displayStart,
displayEnd: _this.props.displayEnd,
scrollingTimeout: null
}, _this._currentRowsLength = 0, _this._currentRowsRange = { start: 0, end: 0 }, _this._scroll = { scrollTop: 0, scrollLeft: 0 }, _this.appendScrollShim = function () {
if (!_this._scrollShim) {
var size = _this._scrollShimSize();
var shim = (0, _scrollUtils.createScrollShim)(size);
_this.canvas.appendChild(shim);
_this._scrollShim = shim;
}
_this._scheduleRemoveScrollShim();
}, _this._scrollShimSize = function () {
return {
width: _this.props.width,
height: _this.props.length * _this.props.rowHeight
};
}, _this._scheduleRemoveScrollShim = function () {
if (_this._scheduleRemoveScrollShimTimer) {
clearTimeout(_this._scheduleRemoveScrollShimTimer);
}
_this._scheduleRemoveScrollShimTimer = setTimeout(_this._removeScrollShim, 200);
}, _this._removeScrollShim = function () {
if (_this._scrollShim) {
_this._scrollShim.parentNode.removeChild(_this._scrollShim);
_this._scrollShim = undefined;
}
}, _this.onRows = function () {
if (_this._currentRowsRange !== { start: 0, end: 0 }) {
_this.props.onRows(_this._currentRowsRange);
_this._currentRowsRange = { start: 0, end: 0 };
}
}, _this.onScroll = function (e) {
if (_this.canvas !== e.target) {
return;
}
_this.appendScrollShim();
var scrollLeft = e.target.scrollLeft;
var scrollTop = e.target.scrollTop;
var scroll = { scrollTop: scrollTop, scrollLeft: scrollLeft };
_this._scroll = scroll;
_this.props.onScroll(scroll);
}, _this.getRows = function (displayStart, displayEnd) {
_this._currentRowsRange = { start: displayStart, end: displayEnd };
if (Array.isArray(_this.props.rowGetter)) {
return _this.props.rowGetter.slice(displayStart, displayEnd);
}
var rows = [];
var i = displayStart;
while (i < displayEnd) {
var row = _this.props.rowGetter(i);
var subRowDetails = {};
if (_this.props.getSubRowDetails) {
subRowDetails = _this.props.getSubRowDetails(row);
}
rows.push({ row: row, subRowDetails: subRowDetails });
i++;
}
return rows;
}, _this.getScrollbarWidth = function () {
// Get the scrollbar width
var scrollbarWidth = _this.canvas.offsetWidth - _this.canvas.clientWidth;
return scrollbarWidth;
}, _this.getScroll = function () {
var _this$canvas = _this.canvas,
scrollTop = _this$canvas.scrollTop,
scrollLeft = _this$canvas.scrollLeft;
return { scrollTop: scrollTop, scrollLeft: scrollLeft };
}, _this.isRowSelected = function (idx, row) {
// Use selectedRows if set
if (_this.props.selectedRows !== null) {
var selectedRows = _this.props.selectedRows.filter(function (r) {
var rowKeyValue = row.get ? row.get(_this.props.rowKey) : row[_this.props.rowKey];
return r[_this.props.rowKey] === rowKeyValue;
});
return selectedRows.length > 0 && selectedRows[0].isSelected;
}
// Else use new rowSelection props
if (_this.props.rowSelection) {
var _this$props$rowSelect = _this.props.rowSelection,
keys = _this$props$rowSelect.keys,
indexes = _this$props$rowSelect.indexes,
isSelectedKey = _this$props$rowSelect.isSelectedKey;
return RowUtils.isRowSelected(keys, indexes, isSelectedKey, row, idx);
}
return false;
}, _this.setScrollLeft = function (scrollLeft) {
if (_this._currentRowsLength !== 0) {
if (!_this.rows) return;
for (var i = 0, len = _this._currentRowsLength; i < len; i++) {
if (_this.rows[i]) {
var row = _this.getRowByRef(i);
if (row && row.setScrollLeft) {
row.setScrollLeft(scrollLeft);
}
}
}
}
}, _this.getRowByRef = function (i) {
// check if wrapped with React DND drop target
var wrappedRow = _this.rows[i].getDecoratedComponentInstance ? _this.rows[i].getDecoratedComponentInstance(i) : null;
if (wrappedRow) {
return wrappedRow.row;
}
return _this.rows[i];
}, _this.renderRow = function (props) {
var row = props.row;
if (row.__metaData && row.__metaData.getRowRenderer) {
return row.__metaData.getRowRenderer(_this.props, props.idx);
}
if (row.__metaData && row.__metaData.isGroup) {
return React.createElement(_RowGroup2['default'], _extends({}, props, row.__metaData, {
name: row.name,
renderer: _this.props.rowGroupRenderer }));
}
var RowsRenderer = _this.props.rowRenderer;
if (typeof RowsRenderer === 'function') {
return React.createElement(RowsRenderer, props);
}
if (React.isValidElement(_this.props.rowRenderer)) {
return React.cloneElement(_this.props.rowRenderer, props);
}
}, _this.renderPlaceholder = function (key, height) {
// just renders empty cells
// if we wanted to show gridlines, we'd need classes and position as with renderScrollingPlaceholder
return React.createElement(
'div',
{ key: key, style: { height: height } },
_this.props.columns.map(function (column, idx) {
return React.createElement('div', { style: { width: column.width }, key: idx });
})
);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Canvas.prototype.componentWillMount = function componentWillMount() {
this.rows = [];
this._currentRowsLength = 0;
this._currentRowsRange = { start: 0, end: 0 };
this._scroll = { scrollTop: 0, scrollLeft: 0 };
};
Canvas.prototype.componentDidMount = function componentDidMount() {
this.onRows();
};
Canvas.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.displayStart !== this.state.displayStart || nextProps.displayEnd !== this.state.displayEnd) {
this.setState({
displayStart: nextProps.displayStart,
displayEnd: nextProps.displayEnd
});
}
};
Canvas.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
var shouldUpdate = nextState.displayStart !== this.state.displayStart || nextState.displayEnd !== this.state.displayEnd || nextState.scrollingTimeout !== this.state.scrollingTimeout || this.props.scrollToRowIndex !== nextProps.scrollToRowIndex || nextProps.rowsCount !== this.props.rowsCount || nextProps.rowHeight !== this.props.rowHeight || nextProps.columns !== this.props.columns || nextProps.width !== this.props.width || nextProps.height !== this.props.height || nextProps.cellMetaData !== this.props.cellMetaData || this.props.colDisplayStart !== nextProps.colDisplayStart || this.props.colDisplayEnd !== nextProps.colDisplayEnd || this.props.colVisibleStart !== nextProps.colVisibleStart || this.props.colVisibleEnd !== nextProps.colVisibleEnd || !(0, _shallowEqual2['default'])(nextProps.style, this.props.style) || this.props.isScrolling !== nextProps.isScrolling;
return shouldUpdate;
};
Canvas.prototype.componentWillUnmount = function componentWillUnmount() {
this._currentRowsLength = 0;
this._currentRowsRange = { start: 0, end: 0 };
this._scroll = { scrollTop: 0, scrollLeft: 0 };
};
Canvas.prototype.componentDidUpdate = function componentDidUpdate() {
if (this._scroll.scrollTop !== 0 && this._scroll.scrollLeft !== 0) {
this.setScrollLeft(this._scroll.scrollLeft);
}
if (this.props.scrollToRowIndex !== 0) {
this.canvas.scrollTop = Math.min(this.props.scrollToRowIndex * this.props.rowHeight, this.props.rowsCount * this.props.rowHeight - this.props.height);
}
this.onRows();
};
Canvas.prototype.render = function render() {
var _this2 = this;
var _state = this.state,
displayStart = _state.displayStart,
displayEnd = _state.displayEnd;
var _props = this.props,
rowHeight = _props.rowHeight,
rowsCount = _props.rowsCount;
var rows = this.getRows(displayStart, displayEnd).map(function (r, idx) {
return _this2.renderRow({
key: 'row-' + (displayStart + idx),
ref: function ref(node) {
return _this2.rows[idx] = node;
},
idx: displayStart + idx,
visibleStart: _this2.props.visibleStart,
visibleEnd: _this2.props.visibleEnd,
row: r.row,
height: rowHeight,
onMouseOver: _this2.onMouseOver,
columns: _this2.props.columns,
isSelected: _this2.isRowSelected(displayStart + idx, r.row, displayStart, displayEnd),
expandedRows: _this2.props.expandedRows,
cellMetaData: _this2.props.cellMetaData,
subRowDetails: r.subRowDetails,
colVisibleStart: _this2.props.colVisibleStart,
colVisibleEnd: _this2.props.colVisibleEnd,
colDisplayStart: _this2.props.colDisplayStart,
colDisplayEnd: _this2.props.colDisplayEnd,
isScrolling: _this2.props.isScrolling
});
});
this._currentRowsLength = rows.length;
if (displayStart > 0) {
rows.unshift(this.renderPlaceholder('top', displayStart * rowHeight));
}
if (rowsCount - displayEnd > 0) {
rows.push(this.renderPlaceholder('bottom', (rowsCount - displayEnd) * rowHeight));
}
var style = {
position: 'absolute',
top: 0,
left: 0,
overflowX: 'auto',
overflowY: 'scroll',
width: this.props.totalWidth,
height: this.props.height
};
return React.createElement(
'div',
{
ref: function ref(div) {
_this2.canvas = div;
},
style: style,
onScroll: this.onScroll,
className: joinClasses('react-grid-Canvas', this.props.className, { opaque: this.props.cellMetaData.selected && this.props.cellMetaData.selected.active }) },
React.createElement(_RowsContainer2['default'], {
width: this.props.width,
rows: rows,
contextMenu: this.props.contextMenu,
rowIdx: this.props.cellMetaData.selected.rowIdx,
idx: this.props.cellMetaData.selected.idx })
);
};
return Canvas;
}(React.Component);
Canvas.displayName = 'Canvas';
Canvas.propTypes = {
rowRenderer: _propTypes2['default'].oneOfType([_propTypes2['default'].func, _propTypes2['default'].element]),
rowHeight: _propTypes2['default'].number.isRequired,
height: _propTypes2['default'].number.isRequired,
width: _propTypes2['default'].number,
totalWidth: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
style: _propTypes2['default'].string,
className: _propTypes2['default'].string,
displayStart: _propTypes2['default'].number.isRequired,
displayEnd: _propTypes2['default'].number.isRequired,
visibleStart: _propTypes2['default'].number.isRequired,
visibleEnd: _propTypes2['default'].number.isRequired,
colVisibleStart: _propTypes2['default'].number.isRequired,
colVisibleEnd: _propTypes2['default'].number.isRequired,
colDisplayStart: _propTypes2['default'].number.isRequired,
colDisplayEnd: _propTypes2['default'].number.isRequired,
rowsCount: _propTypes2['default'].number.isRequired,
rowGetter: _propTypes2['default'].oneOfType([_propTypes2['default'].func.isRequired, _propTypes2['default'].array.isRequired]),
expandedRows: _propTypes2['default'].array,
onRows: _propTypes2['default'].func,
onScroll: _propTypes2['default'].func,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].array]).isRequired,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape).isRequired,
selectedRows: _propTypes2['default'].array,
rowKey: _propTypes2['default'].string,
rowScrollTimeout: _propTypes2['default'].number,
scrollToRowIndex: _propTypes2['default'].number,
contextMenu: _propTypes2['default'].element,
getSubRowDetails: _propTypes2['default'].func,
rowSelection: _propTypes2['default'].oneOfType([_propTypes2['default'].shape({
indexes: _propTypes2['default'].arrayOf(_propTypes2['default'].number).isRequired
}), _propTypes2['default'].shape({
isSelectedKey: _propTypes2['default'].string.isRequired
}), _propTypes2['default'].shape({
keys: _propTypes2['default'].shape({
values: _propTypes2['default'].array.isRequired,
rowKey: _propTypes2['default'].string.isRequired
}).isRequired
})]),
rowGroupRenderer: _propTypes2['default'].func,
isScrolling: _propTypes2['default'].bool,
length: _propTypes2['default'].number
};
Canvas.defaultProps = {
rowRenderer: Row,
onRows: function onRows() {},
selectedRows: [],
rowScrollTimeout: 0
};
module.exports = Canvas;
/***/ }),
/* 191 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _classnames = __webpack_require__(7);
var _classnames2 = _interopRequireDefault(_classnames);
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _CellActionShape = __webpack_require__(203);
var _CellActionShape2 = _interopRequireDefault(_CellActionShape);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CellAction = function (_React$Component) {
_inherits(CellAction, _React$Component);
function CellAction() {
var _temp, _this, _ret;
_classCallCheck(this, CellAction);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = { isMenuOpen: false }, _this.onToggleMenu = function () {
_this.setState(function (prevState) {
return { isMenuOpen: !prevState.isMenuOpen };
});
}, _this.onHideMenu = function () {
_this.setState({ isMenuOpen: false });
}, _this.onGetMenuOptions = function () {
return _this.props.action.actions.map(function (action, index) {
return _react2['default'].createElement(
'span',
{ key: index, onClick: action.callback },
action.text
);
});
}, _this.isActionMenu = function () {
return !_this.props.action.callback && _this.props.action.actions && _this.props.action.actions.length;
}, _this.onActionButtonBlur = function () {
if (_this.isActionMenu()) {
_this.onHideMenu();
}
}, _this.onActionIconClick = function () {
if (!_this.isActionMenu()) {
_this.props.action.callback();
} else if (_this.props.action.actions && _this.props.action.actions.length) {
_this.onToggleMenu();
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
CellAction.prototype.render = function render() {
var isActionMenu = this.isActionMenu();
var cellActionClasses = (0, _classnames2['default'])('rdg-cell-action', {
'rdg-cell-action-last': this.props.isFirst
});
var actionButtonClasses = (0, _classnames2['default'])('rdg-cell-action-button', {
'rdg-cell-action-button-toggled': this.state.isMenuOpen
});
return _react2['default'].createElement(
'div',
{ className: cellActionClasses, onMouseLeave: this.onActionButtonBlur },
_react2['default'].createElement(
'div',
{ className: actionButtonClasses, onClick: this.onActionIconClick },
_react2['default'].createElement('span', { className: this.props.action.icon })
),
isActionMenu && this.state.isMenuOpen && _react2['default'].createElement(
'div',
{ className: 'rdg-cell-action-menu' },
this.onGetMenuOptions()
)
);
};
return CellAction;
}(_react2['default'].Component);
CellAction.propTypes = {
action: _propTypes2['default'].shape(_CellActionShape2['default']).isRequired,
isFirst: _propTypes2['default'].bool.isRequired
};
exports['default'] = CellAction;
/***/ }),
/* 192 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _AppConstants = __webpack_require__(31);
var _AppConstants2 = _interopRequireDefault(_AppConstants);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var CellExpand = function (_React$Component) {
_inherits(CellExpand, _React$Component);
function CellExpand(props) {
_classCallCheck(this, CellExpand);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.onCellExpand = function (e) {
_this.setState({ expanded: !_this.state.expanded });
_this.props.onCellExpand(e);
};
var expanded = props.expandableOptions && props.expandableOptions.expanded;
_this.state = { expanded: expanded };
return _this;
}
CellExpand.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var expanded = nextProps.expandableOptions && nextProps.expandableOptions.expanded;
if (this.state.expanded !== expanded) {
this.setState({ expanded: expanded });
}
};
CellExpand.prototype.render = function render() {
return _react2['default'].createElement(
'span',
{ className: 'rdg-cell-expand', onClick: this.onCellExpand },
this.state.expanded ? _AppConstants2['default'].CellExpand.DOWN_TRIANGLE : _AppConstants2['default'].CellExpand.RIGHT_TRIANGLE
);
};
return CellExpand;
}(_react2['default'].Component);
CellExpand.propTypes = {
expandableOptions: _propTypes2['default'].object.isRequired,
onCellExpand: _propTypes2['default'].func.isRequired
};
exports['default'] = CellExpand;
/***/ }),
/* 193 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _classnames = __webpack_require__(7);
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var ChildRowDeleteButton = function ChildRowDeleteButton(_ref) {
var treeDepth = _ref.treeDepth,
cellHeight = _ref.cellHeight,
siblingIndex = _ref.siblingIndex,
numberSiblings = _ref.numberSiblings,
onDeleteSubRow = _ref.onDeleteSubRow,
isDeleteSubRowEnabled = _ref.isDeleteSubRowEnabled,
_ref$allowAddChildRow = _ref.allowAddChildRow,
allowAddChildRow = _ref$allowAddChildRow === undefined ? true : _ref$allowAddChildRow;
var lastSibling = siblingIndex === numberSiblings - 1;
var className = (0, _classnames2['default'])({ 'rdg-child-row-action-cross': allowAddChildRow === true || !lastSibling }, { 'rdg-child-row-action-cross-last': allowAddChildRow === false && (lastSibling || numberSiblings === 1) });
var height = 12;
var width = 12;
var left = treeDepth * 15;
var top = (cellHeight - 12) / 2;
return _react2['default'].createElement(
'div',
null,
_react2['default'].createElement('div', { className: className }),
isDeleteSubRowEnabled && _react2['default'].createElement(
'div',
{ style: { left: left, top: top, width: width, height: height }, className: 'rdg-child-row-btn', onClick: onDeleteSubRow },
_react2['default'].createElement('div', { className: 'glyphicon glyphicon-remove-sign' })
)
);
};
exports['default'] = ChildRowDeleteButton;
/***/ }),
/* 194 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var isValidElement = __webpack_require__(2).isValidElement;
module.exports = function sameColumn(a, b) {
var k = void 0;
for (k in a) {
if (a.hasOwnProperty(k)) {
if (typeof a[k] === 'function' && typeof b[k] === 'function' || isValidElement(a[k]) && isValidElement(b[k])) {
continue;
}
if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
return false;
}
}
}
for (k in b) {
if (b.hasOwnProperty(k) && !a.hasOwnProperty(k)) {
return false;
}
}
return true;
};
/***/ }),
/* 195 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var createObjectWithProperties = __webpack_require__(18);
__webpack_require__(20);
// The list of the propTypes that we want to include in the Draggable div
var knownDivPropertyKeys = ['onDragStart', 'onDragEnd', 'onDrag', 'style'];
var Draggable = function (_React$Component) {
_inherits(Draggable, _React$Component);
function Draggable() {
var _temp, _this, _ret;
_classCallCheck(this, Draggable);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = {
drag: null
}, _this.onMouseDown = function (e) {
var drag = _this.props.onDragStart(e);
if (drag === null && e.button !== 0) {
return;
}
window.addEventListener('mouseup', _this.onMouseUp);
window.addEventListener('mousemove', _this.onMouseMove);
window.addEventListener('touchend', _this.onMouseUp);
window.addEventListener('touchmove', _this.onMouseMove);
_this.setState({ drag: drag });
}, _this.onMouseMove = function (e) {
if (_this.state.drag === null) {
return;
}
if (e.preventDefault) {
e.preventDefault();
}
_this.props.onDrag(e);
}, _this.onMouseUp = function (e) {
_this.cleanUp();
_this.props.onDragEnd(e, _this.state.drag);
_this.setState({ drag: null });
}, _this.cleanUp = function () {
window.removeEventListener('mouseup', _this.onMouseUp);
window.removeEventListener('mousemove', _this.onMouseMove);
window.removeEventListener('touchend', _this.onMouseUp);
window.removeEventListener('touchmove', _this.onMouseMove);
}, _this.getKnownDivProps = function () {
return createObjectWithProperties(_this.props, knownDivPropertyKeys);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Draggable.prototype.componentWillUnmount = function componentWillUnmount() {
this.cleanUp();
};
Draggable.prototype.render = function render() {
return React.createElement('div', _extends({}, this.getKnownDivProps(), {
onMouseDown: this.onMouseDown,
onTouchStart: this.onMouseDown,
className: 'react-grid-HeaderCell__draggable' }));
};
return Draggable;
}(React.Component);
Draggable.propTypes = {
onDragStart: _propTypes2['default'].func,
onDragEnd: _propTypes2['default'].func,
onDrag: _propTypes2['default'].func,
component: _propTypes2['default'].oneOfType([_propTypes2['default'].func, _propTypes2['default'].constructor]),
style: _propTypes2['default'].object
};
Draggable.defaultProps = {
onDragStart: function onDragStart() {
return true;
},
onDragEnd: function onDragEnd() {},
onDrag: function onDrag() {}
};
module.exports = Draggable;
/***/ }),
/* 196 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _ColumnUtils = __webpack_require__(8);
var _ColumnUtils2 = _interopRequireDefault(_ColumnUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var EmptyChildRow = function (_React$Component) {
_inherits(EmptyChildRow, _React$Component);
function EmptyChildRow() {
_classCallCheck(this, EmptyChildRow);
var _this = _possibleConstructorReturn(this, _React$Component.call(this));
_this.onAddSubRow = _this.onAddSubRow.bind(_this);
return _this;
}
EmptyChildRow.prototype.onAddSubRow = function onAddSubRow() {
this.props.onAddSubRow(this.props.parentRowId);
};
EmptyChildRow.prototype.getFixedColumnsWidth = function getFixedColumnsWidth() {
var fixedWidth = 0;
var size = _ColumnUtils2['default'].getSize(this.props.columns);
for (var i = 0; i < size; i++) {
var column = _ColumnUtils2['default'].getColumn(this.props.columns, i);
if (column) {
if (_ColumnUtils2['default'].getValue(column, 'locked')) {
fixedWidth += _ColumnUtils2['default'].getValue(column, 'width');
}
}
}
return fixedWidth;
};
EmptyChildRow.prototype.render = function render() {
var _this2 = this;
var _props = this.props,
cellHeight = _props.cellHeight,
treeDepth = _props.treeDepth;
var height = 12;
var width = 12;
var left = treeDepth * 15;
var top = (cellHeight - 12) / 2;
var style = {
height: cellHeight,
borderBottom: '1px solid #dddddd'
};
var expandColumn = _ColumnUtils2['default'].getColumn(this.props.columns.filter(function (c) {
return c.key === _this2.props.expandColumnKey;
}), 0);
var cellLeft = expandColumn ? expandColumn.left : 0;
return _react2['default'].createElement(
'div',
{ className: 'react-grid-Row rdg-add-child-row-container', style: style },
_react2['default'].createElement(
'div',
{ className: 'react-grid-Cell', style: { position: 'absolute', height: cellHeight, width: '100%', left: cellLeft } },
_react2['default'].createElement(
'div',
{ className: 'rdg-empty-child-row', style: { marginLeft: '30px', lineHeight: cellHeight + 'px' } },
_react2['default'].createElement('div', { className: '\'rdg-child-row-action-cross rdg-child-row-action-cross-last' }),
_react2['default'].createElement(
'div',
{ style: { left: left, top: top, width: width, height: height }, className: 'rdg-child-row-btn', onClick: this.onAddSubRow },
_react2['default'].createElement('div', { className: 'glyphicon glyphicon-plus-sign' })
)
)
)
);
};
return EmptyChildRow;
}(_react2['default'].Component);
EmptyChildRow.propTypes = {
treeDepth: _propTypes2['default'].number.isRequired,
cellHeight: _propTypes2['default'].number.isRequired,
onAddSubRow: _propTypes2['default'].func.isRequired,
parentRowId: _propTypes2['default'].number,
columns: _propTypes2['default'].array.isRequired,
expandColumnKey: _propTypes2['default'].string.isRequired
};
exports['default'] = EmptyChildRow;
/***/ }),
/* 197 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var ReactDOM = __webpack_require__(6);
var Header = __webpack_require__(198);
var Viewport = __webpack_require__(208);
var cellMetaDataShape = __webpack_require__(12);
__webpack_require__(26);
var Grid = function (_React$Component) {
_inherits(Grid, _React$Component);
function Grid() {
var _temp, _this, _ret;
_classCallCheck(this, Grid);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.getStyle = function () {
return {
overflow: 'hidden',
outline: 0,
position: 'relative',
minHeight: _this.props.minHeight
};
}, _this._onScroll = function () {
if (_this._scrollLeft !== undefined) {
_this.header.setScrollLeft(_this._scrollLeft);
if (_this.viewport) {
_this.viewport.setScrollLeft(_this._scrollLeft);
}
}
}, _this.onScroll = function (props) {
if (_this._scrollLeft !== props.scrollLeft) {
_this._scrollLeft = props.scrollLeft;
_this._onScroll();
}
}, _this.onHeaderScroll = function (e) {
var scrollLeft = e.target.scrollLeft;
if (_this._scrollLeft !== scrollLeft) {
_this._scrollLeft = scrollLeft;
_this.header.setScrollLeft(scrollLeft);
var canvas = ReactDOM.findDOMNode(_this.viewport.canvas);
canvas.scrollLeft = scrollLeft;
_this.viewport.canvas.setScrollLeft(scrollLeft);
}
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Grid.prototype.componentDidMount = function componentDidMount() {
this._scrollLeft = this.viewport ? this.viewport.getScroll().scrollLeft : 0;
this._onScroll();
};
Grid.prototype.componentDidUpdate = function componentDidUpdate() {
this._onScroll();
};
Grid.prototype.componentWillMount = function componentWillMount() {
this._scrollLeft = undefined;
};
Grid.prototype.componentWillUnmount = function componentWillUnmount() {
this._scrollLeft = undefined;
};
Grid.prototype.render = function render() {
var _this2 = this;
var headerRows = this.props.headerRows || [{ ref: function ref(node) {
return _this2.row = node;
} }];
var EmptyRowsView = this.props.emptyRowsView;
return React.createElement(
'div',
{ style: this.getStyle(), className: 'react-grid-Grid' },
React.createElement(Header, {
ref: function ref(input) {
_this2.header = input;
},
columnMetrics: this.props.columnMetrics,
onColumnResize: this.props.onColumnResize,
height: this.props.rowHeight,
totalWidth: this.props.totalWidth,
headerRows: headerRows,
sortColumn: this.props.sortColumn,
sortDirection: this.props.sortDirection,
draggableHeaderCell: this.props.draggableHeaderCell,
onSort: this.props.onSort,
onHeaderDrop: this.props.onHeaderDrop,
onScroll: this.onHeaderScroll,
getValidFilterValues: this.props.getValidFilterValues,
cellMetaData: this.props.cellMetaData
}),
this.props.rowsCount >= 1 || this.props.rowsCount === 0 && !this.props.emptyRowsView ? React.createElement(
'div',
{
ref: function ref(node) {
_this2.viewPortContainer = node;
},
tabIndex: this.props.tabIndex,
onKeyDown: this.props.onViewportKeydown,
onKeyUp: this.props.onViewportKeyup,
onClick: this.props.onViewportClick,
onDoubleClick: this.props.onViewportDoubleClick,
onDragStart: this.props.onViewportDragStart,
onDragEnd: this.props.onViewportDragEnd },
React.createElement(Viewport, {
ref: function ref(node) {
_this2.viewport = node;
},
rowKey: this.props.rowKey,
width: this.props.columnMetrics.width,
rowHeight: this.props.rowHeight,
rowRenderer: this.props.rowRenderer,
rowGetter: this.props.rowGetter,
rowsCount: this.props.rowsCount,
selectedRows: this.props.selectedRows,
expandedRows: this.props.expandedRows,
columnMetrics: this.props.columnMetrics,
totalWidth: this.props.totalWidth,
onScroll: this.onScroll,
onRows: this.props.onRows,
cellMetaData: this.props.cellMetaData,
rowOffsetHeight: this.props.rowOffsetHeight || this.props.rowHeight * headerRows.length,
minHeight: this.props.minHeight,
rowScrollTimeout: this.props.rowScrollTimeout,
scrollToRowIndex: this.props.scrollToRowIndex,
contextMenu: this.props.contextMenu,
rowSelection: this.props.rowSelection,
getSubRowDetails: this.props.getSubRowDetails,
rowGroupRenderer: this.props.rowGroupRenderer,
overScan: this.props.overScan
})
) : React.createElement(
'div',
{ ref: function ref(node) {
_this2.emptyView = node;
}, className: 'react-grid-Empty' },
React.createElement(EmptyRowsView, null)
)
);
};
return Grid;
}(React.Component);
Grid.displayName = 'Grid';
Grid.propTypes = {
rowGetter: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].func]).isRequired,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].object]),
tabIndex: _propTypes2['default'].number,
columnMetrics: _propTypes2['default'].object,
minHeight: _propTypes2['default'].number,
totalWidth: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
headerRows: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].func]),
rowHeight: _propTypes2['default'].number,
rowRenderer: _propTypes2['default'].oneOfType([_propTypes2['default'].element, _propTypes2['default'].func]),
emptyRowsView: _propTypes2['default'].func,
expandedRows: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].func]),
selectedRows: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].func]),
rowSelection: _propTypes2['default'].oneOfType([_propTypes2['default'].shape({
indexes: _propTypes2['default'].arrayOf(_propTypes2['default'].number).isRequired
}), _propTypes2['default'].shape({
isSelectedKey: _propTypes2['default'].string.isRequired
}), _propTypes2['default'].shape({
keys: _propTypes2['default'].shape({
values: _propTypes2['default'].array.isRequired,
rowKey: _propTypes2['default'].string.isRequired
}).isRequired
})]),
rowsCount: _propTypes2['default'].number,
onRows: _propTypes2['default'].func,
sortColumn: _propTypes2['default'].string,
sortDirection: _propTypes2['default'].oneOf(['ASC', 'DESC', 'NONE']),
rowOffsetHeight: _propTypes2['default'].number.isRequired,
onViewportKeydown: _propTypes2['default'].func.isRequired,
onViewportKeyup: _propTypes2['default'].func,
onViewportDragStart: _propTypes2['default'].func.isRequired,
onViewportDragEnd: _propTypes2['default'].func.isRequired,
onViewportClick: _propTypes2['default'].func.isRequired,
onViewportDoubleClick: _propTypes2['default'].func.isRequired,
onColumnResize: _propTypes2['default'].func,
onSort: _propTypes2['default'].func,
onHeaderDrop: _propTypes2['default'].func,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape),
rowKey: _propTypes2['default'].string.isRequired,
rowScrollTimeout: _propTypes2['default'].number,
scrollToRowIndex: _propTypes2['default'].number,
contextMenu: _propTypes2['default'].element,
getSubRowDetails: _propTypes2['default'].func,
draggableHeaderCell: _propTypes2['default'].func,
getValidFilterValues: _propTypes2['default'].func,
rowGroupRenderer: _propTypes2['default'].func,
overScan: _propTypes2['default'].object
};
Grid.defaultProps = {
rowHeight: 35,
minHeight: 350,
tabIndex: 0
};
module.exports = Grid;
/***/ }),
/* 198 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var ReactDOM = __webpack_require__(6);
var joinClasses = __webpack_require__(7);
var shallowCloneObject = __webpack_require__(70);
var ColumnMetrics = __webpack_require__(32);
var ColumnUtils = __webpack_require__(8);
var HeaderRow = __webpack_require__(200);
var getScrollbarSize = __webpack_require__(33);
var createObjectWithProperties = __webpack_require__(18);
var cellMetaDataShape = __webpack_require__(12);
__webpack_require__(20);
// The list of the propTypes that we want to include in the Header div
var knownDivPropertyKeys = ['height', 'onScroll'];
var Header = function (_React$Component) {
_inherits(Header, _React$Component);
function Header() {
var _temp, _this, _ret;
_classCallCheck(this, Header);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = { resizing: null }, _this.onColumnResize = function (column, width) {
var state = _this.state.resizing || _this.props;
var pos = _this.getColumnPosition(column);
if (pos != null) {
var _resizing = {
columnMetrics: shallowCloneObject(state.columnMetrics)
};
_resizing.columnMetrics = ColumnMetrics.resizeColumn(_resizing.columnMetrics, pos, width);
// we don't want to influence scrollLeft while resizing
if (_resizing.columnMetrics.totalWidth < state.columnMetrics.totalWidth) {
_resizing.columnMetrics.totalWidth = state.columnMetrics.totalWidth;
}
_resizing.column = ColumnUtils.getColumn(_resizing.columnMetrics.columns, pos);
_this.setState({ resizing: _resizing });
}
}, _this.onColumnResizeEnd = function (column, width) {
var pos = _this.getColumnPosition(column);
if (pos !== null && _this.props.onColumnResize) {
_this.props.onColumnResize(pos, width || column.width);
}
}, _this.getHeaderRows = function () {
var columnMetrics = _this.getColumnMetrics();
var resizeColumn = void 0;
if (_this.state.resizing) {
resizeColumn = _this.state.resizing.column;
}
var headerRows = [];
_this.props.headerRows.forEach(function (row, index) {
// To allow header filters to be visible
var rowHeight = 'auto';
if (row.rowType === 'filter') {
rowHeight = '500px';
}
var scrollbarSize = getScrollbarSize() > 0 ? getScrollbarSize() : 0;
var updatedWidth = isNaN(_this.props.totalWidth - scrollbarSize) ? _this.props.totalWidth : _this.props.totalWidth - scrollbarSize;
var headerRowStyle = {
position: 'absolute',
top: _this.getCombinedHeaderHeights(index),
left: 0,
width: updatedWidth,
overflowX: 'hidden',
minHeight: rowHeight
};
headerRows.push(React.createElement(HeaderRow, {
key: row.ref,
ref: function ref(node) {
return row.rowType === 'filter' ? _this.filterRow = node : _this.row = node;
},
rowType: row.rowType,
style: headerRowStyle,
onColumnResize: _this.onColumnResize,
onColumnResizeEnd: _this.onColumnResizeEnd,
width: columnMetrics.width,
height: row.height || _this.props.height,
columns: columnMetrics.columns,
resizing: resizeColumn,
draggableHeaderCell: _this.props.draggableHeaderCell,
filterable: row.filterable,
onFilterChange: row.onFilterChange,
onHeaderDrop: _this.props.onHeaderDrop,
sortColumn: _this.props.sortColumn,
sortDirection: _this.props.sortDirection,
onSort: _this.props.onSort,
onScroll: _this.props.onScroll,
getValidFilterValues: _this.props.getValidFilterValues
}));
});
return headerRows;
}, _this.getColumnMetrics = function () {
var columnMetrics = void 0;
if (_this.state.resizing) {
columnMetrics = _this.state.resizing.columnMetrics;
} else {
columnMetrics = _this.props.columnMetrics;
}
return columnMetrics;
}, _this.getColumnPosition = function (column) {
var columnMetrics = _this.getColumnMetrics();
var pos = -1;
columnMetrics.columns.forEach(function (c, idx) {
if (c.key === column.key) {
pos = idx;
}
});
return pos === -1 ? null : pos;
}, _this.getCombinedHeaderHeights = function (until) {
var stopAt = _this.props.headerRows.length;
if (typeof until !== 'undefined') {
stopAt = until;
}
var height = 0;
for (var index = 0; index < stopAt; index++) {
height += _this.props.headerRows[index].height || _this.props.height;
}
return height;
}, _this.getStyle = function () {
return {
position: 'relative',
height: _this.getCombinedHeaderHeights()
};
}, _this.setScrollLeft = function (scrollLeft) {
var node = ReactDOM.findDOMNode(_this.row);
node.scrollLeft = scrollLeft;
_this.row.setScrollLeft(scrollLeft);
if (_this.filterRow) {
var nodeFilters = ReactDOM.findDOMNode(_this.filterRow);
nodeFilters.scrollLeft = scrollLeft;
_this.filterRow.setScrollLeft(scrollLeft);
}
}, _this.getKnownDivProps = function () {
return createObjectWithProperties(_this.props, knownDivPropertyKeys);
}, _this.onHeaderClick = function () {
_this.props.cellMetaData.onCellClick({ rowIdx: -1, idx: -1 });
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Header.prototype.componentWillReceiveProps = function componentWillReceiveProps() {
this.setState({ resizing: null });
};
Header.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps, nextState) {
var update = !ColumnMetrics.sameColumns(this.props.columnMetrics.columns, nextProps.columnMetrics.columns, ColumnMetrics.sameColumn) || this.props.totalWidth !== nextProps.totalWidth || this.props.headerRows.length !== nextProps.headerRows.length || this.state.resizing !== nextState.resizing || this.props.sortColumn !== nextProps.sortColumn || this.props.sortDirection !== nextProps.sortDirection;
return update;
};
// Set the cell selection to -1 x -1 when clicking on the header
Header.prototype.render = function render() {
var className = joinClasses({
'react-grid-Header': true,
'react-grid-Header--resizing': !!this.state.resizing
});
var headerRows = this.getHeaderRows();
return React.createElement(
'div',
_extends({}, this.getKnownDivProps(), { style: this.getStyle(), className: className, onClick: this.onHeaderClick }),
headerRows
);
};
return Header;
}(React.Component);
Header.propTypes = {
columnMetrics: _propTypes2['default'].shape({ width: _propTypes2['default'].number.isRequired, columns: _propTypes2['default'].any }).isRequired,
totalWidth: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
height: _propTypes2['default'].number.isRequired,
headerRows: _propTypes2['default'].array.isRequired,
sortColumn: _propTypes2['default'].string,
sortDirection: _propTypes2['default'].oneOf(['ASC', 'DESC', 'NONE']),
onSort: _propTypes2['default'].func,
onColumnResize: _propTypes2['default'].func,
onScroll: _propTypes2['default'].func,
onHeaderDrop: _propTypes2['default'].func,
draggableHeaderCell: _propTypes2['default'].func,
getValidFilterValues: _propTypes2['default'].func,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape)
};
module.exports = Header;
/***/ }),
/* 199 */
/***/ (function(module, exports) {
"use strict";
var HeaderCellType = {
SORTABLE: 0,
FILTERABLE: 1,
NONE: 2,
CHECKBOX: 3
};
module.exports = HeaderCellType;
/***/ }),
/* 200 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var shallowEqual = __webpack_require__(75);
var BaseHeaderCell = __webpack_require__(60);
var getScrollbarSize = __webpack_require__(33);
var ExcelColumn = __webpack_require__(15);
var columnUtils = __webpack_require__(8);
var SortableHeaderCell = __webpack_require__(210);
var FilterableHeaderCell = __webpack_require__(209);
var HeaderCellType = __webpack_require__(199);
var createObjectWithProperties = __webpack_require__(18);
__webpack_require__(20);
var HeaderRowStyle = {
overflow: _propTypes2['default'].string,
width: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
height: _propTypes2['default'].number,
position: _propTypes2['default'].string
};
// The list of the propTypes that we want to include in the HeaderRow div
var knownDivPropertyKeys = ['width', 'height', 'style', 'onScroll'];
var HeaderRow = function (_React$Component) {
_inherits(HeaderRow, _React$Component);
function HeaderRow() {
var _temp, _this, _ret;
_classCallCheck(this, HeaderRow);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.getHeaderCellType = function (column) {
if (column.filterable) {
if (_this.props.filterable) return HeaderCellType.FILTERABLE;
}
if (column.sortable && column.rowType !== 'filter') return HeaderCellType.SORTABLE;
return HeaderCellType.NONE;
}, _this.getFilterableHeaderCell = function (column) {
var FilterRenderer = FilterableHeaderCell;
if (column.filterRenderer !== undefined) {
FilterRenderer = column.filterRenderer;
}
return React.createElement(FilterRenderer, _extends({}, _this.props, { onChange: _this.props.onFilterChange }));
}, _this.getSortableHeaderCell = function (column) {
var sortDirection = _this.props.sortColumn === column.key ? _this.props.sortDirection : SortableHeaderCell.DEFINE_SORT.NONE;
var sortDescendingFirst = column.sortDescendingFirst === undefined ? false : column.sortDescendingFirst;
return React.createElement(SortableHeaderCell, { columnKey: column.key, onSort: _this.props.onSort, sortDirection: sortDirection, sortDescendingFirst: sortDescendingFirst });
}, _this.getHeaderRenderer = function (column) {
var renderer = void 0;
if (column.headerRenderer && !_this.props.filterable) {
renderer = column.headerRenderer;
} else {
var headerCellType = _this.getHeaderCellType(column);
switch (headerCellType) {
case HeaderCellType.SORTABLE:
renderer = _this.getSortableHeaderCell(column);
break;
case HeaderCellType.FILTERABLE:
renderer = _this.getFilterableHeaderCell(column);
break;
default:
break;
}
}
return renderer;
}, _this.getStyle = function () {
return {
overflow: 'hidden',
width: '100%',
height: _this.props.height,
position: 'absolute'
};
}, _this.getCells = function () {
var cells = [];
var lockedCells = [];
var _loop = function _loop(i, len) {
var column = Object.assign({ rowType: _this.props.rowType }, columnUtils.getColumn(_this.props.columns, i));
var _renderer = _this.getHeaderRenderer(column);
if (column.key === 'select-row' && _this.props.rowType === 'filter') {
_renderer = React.createElement('div', null);
}
var HeaderCell = column.draggable ? _this.props.draggableHeaderCell : BaseHeaderCell;
var cell = React.createElement(HeaderCell, {
ref: function ref(node) {
return _this.cells[i] = node;
},
key: i,
height: _this.props.height,
column: column,
renderer: _renderer,
resizing: _this.props.resizing === column,
onResize: _this.props.onColumnResize,
onResizeEnd: _this.props.onColumnResizeEnd,
onHeaderDrop: _this.props.onHeaderDrop
});
if (column.locked) {
lockedCells.push(cell);
} else {
cells.push(cell);
}
};
for (var i = 0, len = columnUtils.getSize(_this.props.columns); i < len; i++) {
_loop(i, len);
}
return cells.concat(lockedCells);
}, _this.setScrollLeft = function (scrollLeft) {
_this.props.columns.forEach(function (column, i) {
if (column.locked) {
_this.cells[i].setScrollLeft(scrollLeft);
} else {
if (_this.cells[i] && _this.cells[i].removeScroll) {
_this.cells[i].removeScroll();
}
}
});
}, _this.getKnownDivProps = function () {
return createObjectWithProperties(_this.props, knownDivPropertyKeys);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
HeaderRow.prototype.componentWillMount = function componentWillMount() {
this.cells = [];
};
HeaderRow.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return nextProps.width !== this.props.width || nextProps.height !== this.props.height || nextProps.columns !== this.props.columns || !shallowEqual(nextProps.style, this.props.style) || this.props.sortColumn !== nextProps.sortColumn || this.props.sortDirection !== nextProps.sortDirection;
};
HeaderRow.prototype.render = function render() {
var cellsStyle = {
width: this.props.width ? this.props.width + getScrollbarSize() : '100%',
height: this.props.height,
whiteSpace: 'nowrap',
overflowX: 'hidden',
overflowY: 'hidden'
};
var cells = this.getCells();
return React.createElement(
'div',
_extends({}, this.getKnownDivProps(), { className: 'react-grid-HeaderRow' }),
React.createElement(
'div',
{ style: cellsStyle },
cells
)
);
};
return HeaderRow;
}(React.Component);
HeaderRow.displayName = 'HeaderRow';
HeaderRow.propTypes = {
width: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]),
height: _propTypes2['default'].number.isRequired,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].object]).isRequired,
onColumnResize: _propTypes2['default'].func,
onSort: _propTypes2['default'].func.isRequired,
onColumnResizeEnd: _propTypes2['default'].func,
style: _propTypes2['default'].shape(HeaderRowStyle),
sortColumn: _propTypes2['default'].string,
sortDirection: _propTypes2['default'].oneOf(Object.keys(SortableHeaderCell.DEFINE_SORT)),
cellRenderer: _propTypes2['default'].func,
headerCellRenderer: _propTypes2['default'].func,
filterable: _propTypes2['default'].bool,
onFilterChange: _propTypes2['default'].func,
resizing: _propTypes2['default'].object,
onScroll: _propTypes2['default'].func,
rowType: _propTypes2['default'].string,
draggableHeaderCell: _propTypes2['default'].func,
onHeaderDrop: _propTypes2['default'].func
};
module.exports = HeaderRow;
/***/ }),
/* 201 */
/***/ (function(module, exports) {
"use strict";
module.exports = {
Backspace: 8,
Tab: 9,
Enter: 13,
Shift: 16,
Ctrl: 17,
Alt: 18,
PauseBreak: 19,
CapsLock: 20,
Escape: 27,
PageUp: 33,
PageDown: 34,
End: 35,
Home: 36,
LeftArrow: 37,
UpArrow: 38,
RightArrow: 39,
DownArrow: 40,
Insert: 45,
Delete: 46,
0: 48,
1: 49,
2: 50,
3: 51,
4: 52,
5: 53,
6: 54,
7: 55,
8: 56,
9: 57,
a: 65,
b: 66,
c: 67,
d: 68,
e: 69,
f: 70,
g: 71,
h: 72,
i: 73,
j: 74,
k: 75,
l: 76,
m: 77,
n: 78,
o: 79,
p: 80,
q: 81,
r: 82,
s: 83,
t: 84,
u: 85,
v: 86,
w: 87,
x: 88,
y: 89,
z: 90,
LeftWindowKey: 91,
RightWindowKey: 92,
SelectKey: 93,
NumPad0: 96,
NumPad1: 97,
NumPad2: 98,
NumPad3: 99,
NumPad4: 100,
NumPad5: 101,
NumPad6: 102,
NumPad7: 103,
NumPad8: 104,
NumPad9: 105,
Multiply: 106,
Add: 107,
Subtract: 109,
DecimalPoint: 110,
Divide: 111,
F1: 112,
F2: 113,
F3: 114,
F4: 115,
F5: 116,
F6: 117,
F7: 118,
F8: 119,
F9: 120,
F10: 121,
F12: 123,
NumLock: 144,
ScrollLock: 145,
SemiColon: 186,
EqualSign: 187,
Comma: 188,
Dash: 189,
Period: 190,
ForwardSlash: 191,
GraveAccent: 192,
OpenBracket: 219,
BackSlash: 220,
CloseBracket: 221,
SingleQuote: 222
};
/***/ }),
/* 202 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.OverflowCellComponent = undefined;
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _focusableComponentWrapper = __webpack_require__(213);
var _focusableComponentWrapper2 = _interopRequireDefault(_focusableComponentWrapper);
__webpack_require__(34);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var OverflowCell = function (_React$Component) {
_inherits(OverflowCell, _React$Component);
function OverflowCell() {
_classCallCheck(this, OverflowCell);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
OverflowCell.prototype.getStyle = function getStyle() {
var style = {
position: 'absolute',
width: this.props.column.width,
height: this.props.height,
left: this.props.column.left,
border: '1px solid #eee'
};
return style;
};
OverflowCell.prototype.render = function render() {
return _react2['default'].createElement('div', { tabIndex: '-1', style: this.getStyle(), width: '100%', className: 'react-grid-Cell' });
};
return OverflowCell;
}(_react2['default'].Component);
OverflowCell.isSelected = function (props) {
var cellMetaData = props.cellMetaData,
rowIdx = props.rowIdx,
idx = props.idx;
if (cellMetaData == null) {
return false;
}
var selected = cellMetaData.selected;
return selected && selected.rowIdx === rowIdx && selected.idx === idx;
};
OverflowCell.isScrolling = function (props) {
return props.cellMetaData.isScrollingHorizontallyWithKeyboard;
};
OverflowCell.propTypes = {
rowIdx: _propTypes2['default'].number,
idx: _propTypes2['default'].number,
height: _propTypes2['default'].number,
column: _propTypes2['default'].object,
cellMetaData: _propTypes2['default'].object
};
OverflowCell.displayName = 'Cell';
var OverflowCellComponent = OverflowCell;
exports['default'] = (0, _focusableComponentWrapper2['default'])(OverflowCell);
exports.OverflowCellComponent = OverflowCellComponent;
/***/ }),
/* 203 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var CellActionShape = {
icon: _propTypes2['default'].string.isRequired,
callback: _propTypes2['default'].func,
actions: _propTypes2['default'].arrayOf(_propTypes2['default'].shape({
text: _propTypes2['default'].string,
callback: _propTypes2['default'].func
}))
};
exports['default'] = CellActionShape;
/***/ }),
/* 204 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _ExcelColumn = __webpack_require__(15);
var _ExcelColumn2 = _interopRequireDefault(_ExcelColumn);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
exports['default'] = { ExcelColumn: _ExcelColumn2['default'] };
/***/ }),
/* 205 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _SelectAll = __webpack_require__(68);
var _SelectAll2 = _interopRequireDefault(_SelectAll);
var _AppConstants = __webpack_require__(31);
var _AppConstants2 = _interopRequireDefault(_AppConstants);
var _keyboardUtils = __webpack_require__(73);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var BaseGrid = __webpack_require__(197);
var CheckboxEditor = __webpack_require__(65);
var RowUtils = __webpack_require__(63);
var ColumnUtils = __webpack_require__(8);
var KeyCodes = __webpack_require__(201);
var isFunction = __webpack_require__(23);
var ColumnMetrics = __webpack_require__(32);
__webpack_require__(26);
__webpack_require__(76);
if (!Object.assign) {
Object.assign = __webpack_require__(232);
}
var ReactDataGrid = function (_React$Component) {
_inherits(ReactDataGrid, _React$Component);
function ReactDataGrid(props, context) {
_classCallCheck(this, ReactDataGrid);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props, context));
_initialiseProps.call(_this);
var columnMetrics = _this.createColumnMetrics();
var initialState = { columnMetrics: columnMetrics, selectedRows: [], copied: null, expandedRows: [], canFilter: false, columnFilters: {}, sortDirection: null, sortColumn: null, dragged: null, scrollOffset: 0, lastRowIdxUiSelected: -1 };
if (props.enableCellSelect) {
initialState.selected = { rowIdx: 0, idx: 0 };
} else {
initialState.selected = { rowIdx: -1, idx: -1 };
}
_this.state = initialState;
return _this;
}
ReactDataGrid.prototype.componentWillMount = function componentWillMount() {
this._mounted = true;
};
ReactDataGrid.prototype.componentDidMount = function componentDidMount() {
if (window.addEventListener) {
window.addEventListener('resize', this.metricsUpdated);
} else {
window.attachEvent('resize', this.metricsUpdated);
}
this.metricsUpdated();
};
ReactDataGrid.prototype.componentWillUnmount = function componentWillUnmount() {
this._mounted = false;
window.removeEventListener('resize', this.metricsUpdated);
};
ReactDataGrid.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (nextProps.columns) {
if (!ColumnMetrics.sameColumns(this.props.columns, nextProps.columns, this.props.columnEquality) || nextProps.minWidth !== this.props.minWidth) {
var columnMetrics = this.createColumnMetrics(nextProps);
this.setState({ columnMetrics: columnMetrics });
}
}
};
// return false if not a shift select so can be handled as normal row selection
// columnKey not used here as this function will select the whole row,
// but needed to match the function signature in the CheckboxEditor
ReactDataGrid.prototype.render = function render() {
var _this2 = this;
var cellMetaData = {
rowKey: this.props.rowKey,
selected: this.state.selected,
dragged: this.state.dragged,
hoveredRowIdx: this.state.hoveredRowIdx,
onCellClick: this.onCellClick,
onCellFocus: this.onCellFocus,
onCellContextMenu: this.onCellContextMenu,
onCellDoubleClick: this.onCellDoubleClick,
onCommit: this.onCellCommit,
onCommitCancel: this.setInactive,
copied: this.state.copied,
handleDragEnterRow: this.handleDragEnter,
handleTerminateDrag: this.handleTerminateDrag,
enableCellSelect: this.props.enableCellSelect,
onColumnEvent: this.onColumnEvent,
openCellEditor: this.openCellEditor,
onDragHandleDoubleClick: this.onDragHandleDoubleClick,
onCellExpand: this.onCellExpand,
onRowExpandToggle: this.onRowExpandToggle,
onRowHover: this.onRowHover,
getDataGridDOMNode: this.getDataGridDOMNode,
getCellActions: this.props.getCellActions,
onDeleteSubRow: this.props.onDeleteSubRow,
onAddSubRow: this.props.onAddSubRow,
isScrollingVerticallyWithKeyboard: this.isKeyDown(KeyCodes.DownArrow) || this.isKeyDown(KeyCodes.UpArrow),
isScrollingHorizontallyWithKeyboard: this.isKeyDown(KeyCodes.LeftArrow) || this.isKeyDown(KeyCodes.RightArrow) || this.isKeyDown(KeyCodes.Tab),
enableCellAutoFocus: this.props.enableCellAutoFocus
};
var toolbar = this.renderToolbar();
var containerWidth = this.props.minWidth || this.gridWidth();
var gridWidth = containerWidth - this.state.scrollOffset;
// depending on the current lifecycle stage, gridWidth() may not initialize correctly
// this also handles cases where it always returns undefined -- such as when inside a div with display:none
// eg Bootstrap tabs and collapses
if (typeof containerWidth === 'undefined' || isNaN(containerWidth) || containerWidth === 0) {
containerWidth = '100%';
}
if (typeof gridWidth === 'undefined' || isNaN(gridWidth) || gridWidth === 0) {
gridWidth = '100%';
}
return React.createElement(
'div',
{ className: 'react-grid-Container', style: { width: containerWidth },
ref: function ref(node) {
_this2.grid = node;
} },
toolbar,
React.createElement(
'div',
{ className: 'react-grid-Main' },
React.createElement(BaseGrid, _extends({
ref: function ref(node) {
return _this2.base = node;
}
}, this.props, {
rowKey: this.props.rowKey,
headerRows: this.getHeaderRows(),
columnMetrics: this.state.columnMetrics,
rowGetter: this.props.rowGetter,
rowsCount: this.props.rowsCount,
rowHeight: this.props.rowHeight,
cellMetaData: cellMetaData,
selectedRows: this.getSelectedRows(),
rowSelection: this.getRowSelectionProps(),
expandedRows: this.state.expandedRows,
rowOffsetHeight: this.getRowOffsetHeight(),
sortColumn: this.state.sortColumn,
sortDirection: this.state.sortDirection,
onSort: this.handleSort,
minHeight: this.props.minHeight,
totalWidth: gridWidth,
onViewportKeydown: this.onKeyDown,
onViewportKeyup: this.onKeyUp,
onViewportDragStart: this.onDragStart,
onViewportDragEnd: this.handleDragEnd,
onViewportClick: this.deselect,
onViewportDoubleClick: this.deselect,
onColumnResize: this.onColumnResize,
rowScrollTimeout: this.props.rowScrollTimeout,
scrollToRowIndex: this.props.scrollToRowIndex,
contextMenu: this.props.contextMenu,
overScan: this.props.overScan }))
)
);
};
return ReactDataGrid;
}(React.Component);
ReactDataGrid.displayName = 'ReactDataGrid';
ReactDataGrid.propTypes = {
rowHeight: _propTypes2['default'].number.isRequired,
headerRowHeight: _propTypes2['default'].number,
headerFiltersHeight: _propTypes2['default'].number,
minHeight: _propTypes2['default'].number.isRequired,
minWidth: _propTypes2['default'].number,
enableRowSelect: _propTypes2['default'].oneOfType([_propTypes2['default'].bool, _propTypes2['default'].string]),
onRowUpdated: _propTypes2['default'].func,
rowGetter: _propTypes2['default'].func.isRequired,
rowsCount: _propTypes2['default'].number.isRequired,
toolbar: _propTypes2['default'].element,
enableCellSelect: _propTypes2['default'].bool,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].array]).isRequired,
onFilter: _propTypes2['default'].func,
onCellCopyPaste: _propTypes2['default'].func,
onCellsDragged: _propTypes2['default'].func,
getCellActions: _propTypes2['default'].func,
onAddFilter: _propTypes2['default'].func,
onGridSort: _propTypes2['default'].func,
onDragHandleDoubleClick: _propTypes2['default'].func,
onGridRowsUpdated: _propTypes2['default'].func,
onRowSelect: _propTypes2['default'].func,
rowKey: _propTypes2['default'].string,
rowScrollTimeout: _propTypes2['default'].number,
scrollToRowIndex: _propTypes2['default'].number,
onClearFilters: _propTypes2['default'].func,
contextMenu: _propTypes2['default'].element,
cellNavigationMode: _propTypes2['default'].oneOf(['none', 'loopOverRow', 'changeRow']),
onCellSelected: _propTypes2['default'].func,
onCellDeSelected: _propTypes2['default'].func,
onCellExpand: _propTypes2['default'].func,
enableDragAndDrop: _propTypes2['default'].bool,
tabIndex: _propTypes2['default'].number,
onRowExpandToggle: _propTypes2['default'].func,
draggableHeaderCell: _propTypes2['default'].func,
getValidFilterValues: _propTypes2['default'].func,
rowSelection: _propTypes2['default'].shape({
enableShiftSelect: _propTypes2['default'].bool,
onRowsSelected: _propTypes2['default'].func,
onRowsDeselected: _propTypes2['default'].func,
showCheckbox: _propTypes2['default'].bool,
selectBy: _propTypes2['default'].oneOfType([_propTypes2['default'].shape({
indexes: _propTypes2['default'].arrayOf(_propTypes2['default'].number).isRequired
}), _propTypes2['default'].shape({
isSelectedKey: _propTypes2['default'].string.isRequired
}), _propTypes2['default'].shape({
keys: _propTypes2['default'].shape({
values: _propTypes2['default'].array.isRequired,
rowKey: _propTypes2['default'].string.isRequired
}).isRequired
})]).isRequired
}),
onRowClick: _propTypes2['default'].func,
onRowDoubleClick: _propTypes2['default'].func,
onGridKeyUp: _propTypes2['default'].func,
onGridKeyDown: _propTypes2['default'].func,
rowGroupRenderer: _propTypes2['default'].func,
rowActionsCell: _propTypes2['default'].func,
onCheckCellIsEditable: _propTypes2['default'].func,
/* called before cell is set active, returns a boolean to determine whether cell is editable */
overScan: _propTypes2['default'].object,
onDeleteSubRow: _propTypes2['default'].func,
onAddSubRow: _propTypes2['default'].func,
enableCellAutoFocus: _propTypes2['default'].bool,
onBeforeEdit: _propTypes2['default'].func,
selectAllRenderer: _propTypes2['default'].object,
minColumnWidth: _propTypes2['default'].number,
columnEquality: _propTypes2['default'].func,
onColumnResize: _propTypes2['default'].func
};
ReactDataGrid.defaultProps = {
enableCellSelect: false,
tabIndex: -1,
rowHeight: 35,
headerFiltersHeight: 45,
enableRowSelect: false,
minHeight: 350,
rowKey: 'id',
rowScrollTimeout: 0,
scrollToRowIndex: 0,
cellNavigationMode: 'none',
overScan: {
colsStart: 5,
colsEnd: 5,
rowsStart: 5,
rowsEnd: 5
},
enableCellAutoFocus: true,
onBeforeEdit: function onBeforeEdit() {},
minColumnWidth: 80,
columnEquality: ColumnMetrics.sameColumn
};
var _initialiseProps = function _initialiseProps() {
var _this3 = this;
this.gridWidth = function () {
return _this3.grid ? _this3.grid.parentElement.offsetWidth : 0;
};
this.getTotalWidth = function () {
var totalWidth = 0;
if (_this3._mounted) {
totalWidth = _this3.gridWidth();
} else {
totalWidth = ColumnUtils.getSize(_this3.props.columns) * _this3.props.minColumnWidth;
}
return totalWidth;
};
this.getColumnMetricsType = function (metrics) {
var totalWidth = metrics.totalWidth || _this3.getTotalWidth();
var currentMetrics = {
columns: metrics.columns,
totalWidth: totalWidth,
minColumnWidth: metrics.minColumnWidth
};
var updatedMetrics = ColumnMetrics.recalculate(currentMetrics);
return updatedMetrics;
};
this.getColumn = function (idx) {
var columns = _this3.state.columnMetrics.columns;
if (Array.isArray(columns)) {
return columns[idx];
} else if (typeof Immutable !== 'undefined') {
return columns.get(idx);
}
};
this.getSize = function () {
var columns = _this3.state.columnMetrics.columns;
if (Array.isArray(columns)) {
return columns.length;
} else if (typeof Immutable !== 'undefined') {
return columns.size;
}
};
this.metricsUpdated = function () {
var columnMetrics = _this3.createColumnMetrics();
_this3.setState({ columnMetrics: columnMetrics });
};
this.createColumnMetrics = function () {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this3.props;
var gridColumns = _this3.setupGridColumns(props);
return _this3.getColumnMetricsType({
columns: gridColumns,
minColumnWidth: _this3.props.minColumnWidth,
totalWidth: props.minWidth
});
};
this.onColumnResize = function (index, width) {
var columnMetrics = ColumnMetrics.resizeColumn(_this3.state.columnMetrics, index, width);
_this3.setState({ columnMetrics: columnMetrics });
if (_this3.props.onColumnResize) {
_this3.props.onColumnResize(index, width);
}
};
this.onKeyDown = function (e) {
if ((0, _keyboardUtils.isCtrlKeyHeldDown)(e)) {
_this3.checkAndCall('onPressKeyWithCtrl', e);
} else if (_this3.isKeyExplicitlyHandled(e.key)) {
// break up individual keyPress events to have their own specific callbacks
var callBack = 'onPress' + e.key;
_this3.checkAndCall(callBack, e);
} else if ((0, _keyboardUtils.isKeyPrintable)(e.keyCode)) {
_this3.checkAndCall('onPressChar', e);
}
// Track which keys are currently down for shift clicking etc
_this3._keysDown = _this3._keysDown || {};
_this3._keysDown[e.keyCode] = true;
if (isFunction(_this3.props.onGridKeyDown)) {
_this3.props.onGridKeyDown(e);
}
};
this.onKeyUp = function (e) {
// Track which keys are currently down for shift clicking etc
_this3._keysDown = _this3._keysDown || {};
delete _this3._keysDown[e.keyCode];
if (isFunction(_this3.props.onGridKeyUp)) {
_this3.props.onGridKeyUp(e);
}
};
this.isKeyDown = function (keyCode) {
if (!_this3._keysDown) return false;
return keyCode in _this3._keysDown;
};
this.isSingleKeyDown = function (keyCode) {
if (!_this3._keysDown) return false;
return keyCode in _this3._keysDown && Object.keys(_this3._keysDown).length === 1;
};
this.checkAndCall = function (methodName, args) {
if (typeof _this3[methodName] === 'function') {
_this3[methodName](args);
}
};
this.isKeyExplicitlyHandled = function (key) {
return typeof _this3['onPress' + key] === 'function';
};
this.hasSelectedCellChanged = function (selected) {
var previouslySelected = Object.assign({}, _this3.state.selected);
return previouslySelected.rowIdx !== selected.rowIdx || previouslySelected.idx !== selected.idx || previouslySelected.active === false;
};
this.onContextMenuHide = function () {
document.removeEventListener('click', _this3.onContextMenuHide);
var newSelected = Object.assign({}, _this3.state.selected, { contextMenuDisplayed: false });
_this3.setState({ selected: newSelected });
};
this.onColumnEvent = function (ev, columnEvent) {
var idx = columnEvent.idx,
name = columnEvent.name;
if (name && typeof idx !== 'undefined') {
var column = _this3.getColumn(idx);
if (column && column.events && column.events[name] && typeof column.events[name] === 'function') {
var eventArgs = {
idx: idx,
rowIdx: columnEvent.rowIdx,
rowId: columnEvent.rowId,
column: column
};
column.events[name](ev, eventArgs);
}
}
};
this.onSelect = function (selected) {
if (_this3.state.selected.rowIdx !== selected.rowIdx || _this3.state.selected.idx !== selected.idx || _this3.state.selected.active === false) {
var _idx = selected.idx;
var _rowIdx = selected.rowIdx;
if (_this3.isCellWithinBounds(selected)) {
var oldSelection = _this3.state.selected;
_this3.setState({ selected: selected }, function () {
if (typeof _this3.props.onCellDeSelected === 'function') {
_this3.props.onCellDeSelected(oldSelection);
}
if (typeof _this3.props.onCellSelected === 'function') {
_this3.props.onCellSelected(selected);
}
});
} else if (_rowIdx === -1 && _idx === -1) {
// When it's outside of the grid, set rowIdx anyway
_this3.setState({ selected: { idx: _idx, rowIdx: _rowIdx } });
}
}
};
this.onCellClick = function (cell, e) {
_this3.onSelect({ rowIdx: cell.rowIdx, idx: cell.idx });
if (_this3.props.onRowClick && typeof _this3.props.onRowClick === 'function') {
_this3.props.onRowClick(cell.rowIdx, _this3.props.rowGetter(cell.rowIdx), _this3.getColumn(cell.idx));
}
if (e) {
e.stopPropagation();
}
};
this.onCellFocus = function (cell) {
_this3.onSelect(cell);
};
this.onCellContextMenu = function (cell) {
_this3.onSelect({ rowIdx: cell.rowIdx, idx: cell.idx, contextMenuDisplayed: _this3.props.contextMenu });
if (_this3.props.contextMenu) {
document.addEventListener('click', _this3.onContextMenuHide);
}
};
this.onCellDoubleClick = function (cell, e) {
_this3.onSelect({ rowIdx: cell.rowIdx, idx: cell.idx });
if (_this3.props.onRowDoubleClick && typeof _this3.props.onRowDoubleClick === 'function') {
_this3.props.onRowDoubleClick(cell.rowIdx, _this3.props.rowGetter(cell.rowIdx), _this3.getColumn(cell.idx));
}
_this3.setActive();
if (e) {
e.stopPropagation();
}
};
this.onPressArrowUp = function (e) {
_this3.moveSelectedCell(e, -1, 0);
};
this.onPressArrowDown = function (e) {
_this3.moveSelectedCell(e, 1, 0);
};
this.onPressArrowLeft = function (e) {
_this3.moveSelectedCell(e, 0, -1);
};
this.onPressArrowRight = function (e) {
_this3.moveSelectedCell(e, 0, 1);
};
this.isFocusedOnCell = function () {
return document.activeElement && document.activeElement.classList && document.activeElement.classList.contains('react-grid-Cell');
};
this.isFocusedOnTable = function () {
var domNode = _this3.getDataGridDOMNode();
return domNode && domNode.contains(document.activeElement);
};
this.exitGrid = function (oldSelectedCell, newSelectedValue) {
_this3.setState({ selected: newSelectedValue }, function () {
if (typeof _this3.props.onCellDeSelected === 'function') {
_this3.props.onCellDeSelected(oldSelectedCell);
}
});
};
this.enterGrid = function (newSelectedValue) {
_this3.setState({ selected: newSelectedValue }, function () {
if (typeof _this3.props.onCellSelected === 'function') {
_this3.props.onCellSelected(newSelectedValue);
}
});
};
this.onPressTab = function (e) {
// Scenario 0a: When there are no rows in the grid, pressing tab needs to allow the browser to handle it
if (_this3.props.rowsCount === 0) {
return;
}
// Scenario 0b: When we're editing a cell
var idx = _this3.state.selected.idx;
var rowIdx = _this3.state.selected.rowIdx;
if (_this3.state.selected.active === true) {
// if we are in a position to leave the grid, stop editing but stay in that cell
if (_this3.canExitGrid(e)) {
_this3.moveSelectedCell(e, 0, 0);
return;
}
// otherwise move left or right as appropriate
_this3.moveSelectedCell(e, 0, e.shiftKey ? -1 : 1);
return;
}
var shift = e.shiftKey === true;
// Scenario 1: we're at a cell where we can exit the grid
if (_this3.canExitGrid(e) && _this3.isFocusedOnCell()) {
if (shift && idx >= 0) {
_this3.exitGrid({ idx: idx, rowIdx: rowIdx }, { idx: -1, rowIdx: rowIdx, exitedLeft: true });
return;
} else if (!shift && idx >= 0) {
_this3.exitGrid({ idx: idx, rowIdx: rowIdx }, { idx: -1, rowIdx: rowIdx });
return;
}
}
// Scenario 2: we're on the div surrounding the grid and press shift+Tab
// and we just exited left, so we want to let the browser handle it
// KNOWN ISSUE: Focus on the table can come from either side and at this point we can't know how
// they user arrived, so it is possible that exitLeft gets set and then the user clicks out of the table
// and they won't be able to Shift+Tab around the site to re-enter the table from the right.
if (_this3.isFocusedOnTable() && !_this3.isFocusedOnCell() && shift && _this3.state.selected.exitedLeft) {
_this3.enterGrid({ idx: idx, rowIdx: rowIdx });
return;
}
// Scenario 3: we're on the div surrounding the grid and we want to enter the grid
if (!_this3.isFocusedOnCell()) {
// Scenario 3A: idx has been set to -1 (eg can happen when clicking into the filter box)
// we want to go to the first cell in the row if we press Tab
// we want to go to the last cell in the row if we press Shift+Tab
if (idx === -1) {
_this3.moveSelectedCell(e, rowIdx === -1 ? 1 : 0, shift ? _this3.getNbrColumns() : 1);
return;
}
// otherwise, there is a selected cell in the table already, and
// we want to trigger it to focus - setting selected in state will update
// the cell props, and checkFocus will be called
_this3.enterGrid({ idx: idx, rowIdx: rowIdx, changeSomething: true });
// make sure the browser doesn't handle it
e.preventDefault();
return;
}
_this3.moveSelectedCell(e, 0, e.shiftKey ? -1 : 1);
};
this.onPressEnter = function (e) {
_this3.setActive(e.key);
};
this.onPressDelete = function (e) {
_this3.setActive(e.key);
};
this.onPressEscape = function (e) {
_this3.setInactive(e.key);
_this3.handleCancelCopy();
};
this.onPressBackspace = function (e) {
_this3.setActive(e.key);
};
this.onPressChar = function (e) {
if ((0, _keyboardUtils.isKeyPrintable)(e.keyCode)) {
_this3.setActive(e.keyCode);
}
};
this.onPressKeyWithCtrl = function (e) {
var keys = {
KeyCode_c: 99,
KeyCode_C: 67,
KeyCode_V: 86,
KeyCode_v: 118
};
var rowIdx = _this3.state.selected.rowIdx;
var row = _this3.props.rowGetter(rowIdx);
var idx = _this3.state.selected.idx;
var col = _this3.getColumn(idx);
if (ColumnUtils.canEdit(col, row, _this3.props.enableCellSelect)) {
if (e.keyCode === keys.KeyCode_c || e.keyCode === keys.KeyCode_C) {
var _value = _this3.getSelectedValue();
_this3.handleCopy({ value: _value });
} else if (e.keyCode === keys.KeyCode_v || e.keyCode === keys.KeyCode_V) {
_this3.handlePaste();
}
}
};
this.onGridRowsUpdated = function (cellKey, fromRow, toRow, updated, action, originRow) {
var rowIds = [];
for (var i = fromRow; i <= toRow; i++) {
rowIds.push(_this3.props.rowGetter(i)[_this3.props.rowKey]);
}
var fromRowData = _this3.props.rowGetter(action === 'COPY_PASTE' ? originRow : fromRow);
var fromRowId = fromRowData[_this3.props.rowKey];
var toRowId = _this3.props.rowGetter(toRow)[_this3.props.rowKey];
_this3.props.onGridRowsUpdated({ cellKey: cellKey, fromRow: fromRow, toRow: toRow, fromRowId: fromRowId, toRowId: toRowId, rowIds: rowIds, updated: updated, action: action, fromRowData: fromRowData });
};
this.onCellCommit = function (commit) {
var selected = Object.assign({}, _this3.state.selected);
selected.active = false;
var expandedRows = _this3.state.expandedRows;
// if(commit.changed && commit.changed.expandedHeight){
// expandedRows = this.expandRow(commit.rowIdx, commit.changed.expandedHeight);
// }
_this3.setState({ selected: selected, expandedRows: expandedRows });
if (_this3.props.onRowUpdated) {
_this3.props.onRowUpdated(commit);
}
var targetRow = commit.rowIdx;
if (_this3.props.onGridRowsUpdated) {
_this3.onGridRowsUpdated(commit.cellKey, targetRow, targetRow, commit.updated, _AppConstants2['default'].UpdateActions.CELL_UPDATE);
}
};
this.onDragStart = function (e) {
var idx = _this3.state.selected.idx;
// To prevent dragging down/up when reordering rows.
var isViewportDragging = e && e.target && e.target.className;
if (idx > -1 && isViewportDragging) {
var _value2 = _this3.getSelectedValue();
_this3.handleDragStart({ idx: _this3.state.selected.idx, rowIdx: _this3.state.selected.rowIdx, value: _value2 });
// need to set dummy data for FF
if (e && e.dataTransfer) {
if (e.dataTransfer.setData) {
e.dataTransfer.dropEffect = 'move';
e.dataTransfer.effectAllowed = 'move';
e.dataTransfer.setData('text/plain', '');
}
}
}
};
this.onToggleFilter = function () {
// setState() does not immediately mutate this.state but creates a pending state transition.
// Therefore if you want to do something after the state change occurs, pass it in as a callback function.
_this3.setState({ canFilter: !_this3.state.canFilter }, function () {
if (_this3.state.canFilter === false && _this3.props.onClearFilters) {
_this3.props.onClearFilters();
}
});
};
this.onDragHandleDoubleClick = function (e) {
if (_this3.props.onDragHandleDoubleClick) {
_this3.props.onDragHandleDoubleClick(e);
}
if (_this3.props.onGridRowsUpdated) {
var _this3$onGridRowsUpda;
var cellKey = _this3.getColumn(e.idx).key;
_this3.onGridRowsUpdated(cellKey, e.rowIdx, _this3.props.rowsCount - 1, (_this3$onGridRowsUpda = {}, _this3$onGridRowsUpda[cellKey] = e.rowData[cellKey], _this3$onGridRowsUpda), _AppConstants2['default'].UpdateActions.COLUMN_FILL);
}
};
this.onCellExpand = function (args) {
if (_this3.props.onCellExpand) {
_this3.props.onCellExpand(args);
}
};
this.onRowExpandToggle = function (args) {
if (typeof _this3.props.onRowExpandToggle === 'function') {
_this3.props.onRowExpandToggle(args);
}
};
this.isCellWithinBounds = function (_ref) {
var idx = _ref.idx,
rowIdx = _ref.rowIdx;
return idx >= 0 && rowIdx >= 0 && idx < ColumnUtils.getSize(_this3.state.columnMetrics.columns) && rowIdx < _this3.props.rowsCount;
};
this.handleDragStart = function (dragged) {
if (!_this3.dragEnabled()) {
return;
}
if (_this3.isCellWithinBounds(dragged)) {
_this3.setState({ dragged: dragged });
}
};
this.handleDragEnd = function () {
if (!_this3.dragEnabled()) {
return;
}
var _state = _this3.state,
selected = _state.selected,
dragged = _state.dragged;
var column = _this3.getColumn(_this3.state.selected.idx);
if (selected && dragged && column) {
var cellKey = column.key;
var fromRow = selected.rowIdx < dragged.overRowIdx ? selected.rowIdx : dragged.overRowIdx;
var toRow = selected.rowIdx > dragged.overRowIdx ? selected.rowIdx : dragged.overRowIdx;
if (_this3.props.onCellsDragged) {
_this3.props.onCellsDragged({ cellKey: cellKey, fromRow: fromRow, toRow: toRow, value: dragged.value });
}
if (_this3.props.onGridRowsUpdated) {
var _this3$onGridRowsUpda2;
_this3.onGridRowsUpdated(cellKey, fromRow, toRow, (_this3$onGridRowsUpda2 = {}, _this3$onGridRowsUpda2[cellKey] = dragged.value, _this3$onGridRowsUpda2), _AppConstants2['default'].UpdateActions.CELL_DRAG);
}
}
_this3.setState({ dragged: { complete: true } });
};
this.handleDragEnter = function (row) {
if (!_this3.dragEnabled() || _this3.state.dragged == null) {
return;
}
var dragged = _this3.state.dragged;
dragged.overRowIdx = row;
_this3.setState({ dragged: dragged });
};
this.handleTerminateDrag = function () {
if (!_this3.dragEnabled()) {
return;
}
_this3.setState({ dragged: null });
};
this.handlePaste = function () {
if (!_this3.copyPasteEnabled() || !_this3.state.copied) {
return;
}
var selected = _this3.state.selected;
var cellKey = _this3.getColumn(_this3.state.selected.idx).key;
var textToCopy = _this3.state.textToCopy;
var fromRow = _this3.state.copied.rowIdx;
var toRow = selected.rowIdx;
if (_this3.props.onCellCopyPaste) {
_this3.props.onCellCopyPaste({ cellKey: cellKey, rowIdx: toRow, value: textToCopy, fromRow: fromRow, toRow: toRow });
}
if (_this3.props.onGridRowsUpdated) {
var _this3$onGridRowsUpda3;
_this3.onGridRowsUpdated(cellKey, toRow, toRow, (_this3$onGridRowsUpda3 = {}, _this3$onGridRowsUpda3[cellKey] = textToCopy, _this3$onGridRowsUpda3), _AppConstants2['default'].UpdateActions.COPY_PASTE, fromRow);
}
};
this.handleCancelCopy = function () {
_this3.setState({ copied: null });
};
this.handleCopy = function (args) {
if (!_this3.copyPasteEnabled()) {
return;
}
var textToCopy = args.value;
var selected = _this3.state.selected;
var copied = { idx: selected.idx, rowIdx: selected.rowIdx };
_this3.setState({ textToCopy: textToCopy, copied: copied });
};
this.handleSort = function (columnKey, direction) {
_this3.setState({ sortDirection: direction, sortColumn: columnKey }, function () {
this.props.onGridSort(columnKey, direction);
});
};
this.getSelectedRow = function (rows, key) {
var selectedRow = rows.filter(function (r) {
if (r[_this3.props.rowKey] === key) {
return true;
}
return false;
});
if (selectedRow.length > 0) {
return selectedRow[0];
}
};
this.useNewRowSelection = function () {
return _this3.props.rowSelection && _this3.props.rowSelection.selectBy;
};
this.handleShiftSelect = function (rowIdx) {
if (_this3.state.lastRowIdxUiSelected > -1 && _this3.isSingleKeyDown(KeyCodes.Shift)) {
var _props$rowSelection$s = _this3.props.rowSelection.selectBy,
keys = _props$rowSelection$s.keys,
indexes = _props$rowSelection$s.indexes,
isSelectedKey = _props$rowSelection$s.isSelectedKey;
var isPreviouslySelected = RowUtils.isRowSelected(keys, indexes, isSelectedKey, _this3.props.rowGetter(rowIdx), rowIdx);
if (isPreviouslySelected) return false;
var handled = false;
if (rowIdx > _this3.state.lastRowIdxUiSelected) {
var rowsSelected = [];
for (var i = _this3.state.lastRowIdxUiSelected + 1; i <= rowIdx; i++) {
rowsSelected.push({ rowIdx: i, row: _this3.props.rowGetter(i) });
}
if (typeof _this3.props.rowSelection.onRowsSelected === 'function') {
_this3.props.rowSelection.onRowsSelected(rowsSelected);
}
handled = true;
} else if (rowIdx < _this3.state.lastRowIdxUiSelected) {
var _rowsSelected = [];
for (var _i = rowIdx; _i <= _this3.state.lastRowIdxUiSelected - 1; _i++) {
_rowsSelected.push({ rowIdx: _i, row: _this3.props.rowGetter(_i) });
}
if (typeof _this3.props.rowSelection.onRowsSelected === 'function') {
_this3.props.rowSelection.onRowsSelected(_rowsSelected);
}
handled = true;
}
if (handled) {
_this3.setState({ lastRowIdxUiSelected: rowIdx });
}
return handled;
}
return false;
};
this.handleNewRowSelect = function (rowIdx, rowData) {
if (_this3.selectAllCheckbox && _this3.selectAllCheckbox.checked === true) {
_this3.selectAllCheckbox.checked = false;
}
var _props$rowSelection$s2 = _this3.props.rowSelection.selectBy,
keys = _props$rowSelection$s2.keys,
indexes = _props$rowSelection$s2.indexes,
isSelectedKey = _props$rowSelection$s2.isSelectedKey;
var isPreviouslySelected = RowUtils.isRowSelected(keys, indexes, isSelectedKey, rowData, rowIdx);
_this3.setState({ lastRowIdxUiSelected: isPreviouslySelected ? -1 : rowIdx, selected: { rowIdx: rowIdx, idx: 0 } });
if (isPreviouslySelected && typeof _this3.props.rowSelection.onRowsDeselected === 'function') {
_this3.props.rowSelection.onRowsDeselected([{ rowIdx: rowIdx, row: rowData }]);
} else if (!isPreviouslySelected && typeof _this3.props.rowSelection.onRowsSelected === 'function') {
_this3.props.rowSelection.onRowsSelected([{ rowIdx: rowIdx, row: rowData }]);
}
};
this.handleRowSelect = function (rowIdx, columnKey, rowData, e) {
e.stopPropagation();
if (_this3.useNewRowSelection()) {
if (_this3.props.rowSelection.enableShiftSelect === true) {
if (!_this3.handleShiftSelect(rowIdx)) {
_this3.handleNewRowSelect(rowIdx, rowData);
}
} else {
_this3.handleNewRowSelect(rowIdx, rowData);
}
} else {
// Fallback to old onRowSelect handler
var selectedRows = _this3.props.enableRowSelect === 'single' ? [] : _this3.state.selectedRows.slice(0);
var selectedRow = _this3.getSelectedRow(selectedRows, rowData[_this3.props.rowKey]);
if (selectedRow) {
selectedRow.isSelected = !selectedRow.isSelected;
} else {
rowData.isSelected = true;
selectedRows.push(rowData);
}
_this3.setState({ selectedRows: selectedRows, selected: { rowIdx: rowIdx, idx: 0 } });
if (_this3.props.onRowSelect) {
_this3.props.onRowSelect(selectedRows.filter(function (r) {
return r.isSelected === true;
}));
}
}
};
this.handleCheckboxChange = function (e) {
var allRowsSelected = void 0;
if (e.currentTarget instanceof HTMLInputElement && e.currentTarget.checked === true) {
allRowsSelected = true;
} else {
allRowsSelected = false;
}
if (_this3.useNewRowSelection()) {
var _props$rowSelection$s3 = _this3.props.rowSelection.selectBy,
keys = _props$rowSelection$s3.keys,
indexes = _props$rowSelection$s3.indexes,
isSelectedKey = _props$rowSelection$s3.isSelectedKey;
if (allRowsSelected && typeof _this3.props.rowSelection.onRowsSelected === 'function') {
var selectedRows = [];
for (var i = 0; i < _this3.props.rowsCount; i++) {
var rowData = _this3.props.rowGetter(i);
if (!RowUtils.isRowSelected(keys, indexes, isSelectedKey, rowData, i)) {
selectedRows.push({ rowIdx: i, row: rowData });
}
}
if (selectedRows.length > 0) {
_this3.props.rowSelection.onRowsSelected(selectedRows);
}
} else if (!allRowsSelected && typeof _this3.props.rowSelection.onRowsDeselected === 'function') {
var deselectedRows = [];
for (var _i2 = 0; _i2 < _this3.props.rowsCount; _i2++) {
var _rowData = _this3.props.rowGetter(_i2);
if (RowUtils.isRowSelected(keys, indexes, isSelectedKey, _rowData, _i2)) {
deselectedRows.push({ rowIdx: _i2, row: _rowData });
}
}
if (deselectedRows.length > 0) {
_this3.props.rowSelection.onRowsDeselected(deselectedRows);
}
}
} else {
var _selectedRows = [];
for (var _i3 = 0; _i3 < _this3.props.rowsCount; _i3++) {
var row = Object.assign({}, _this3.props.rowGetter(_i3), { isSelected: allRowsSelected });
_selectedRows.push(row);
}
_this3.setState({ selectedRows: _selectedRows });
if (typeof _this3.props.onRowSelect === 'function') {
_this3.props.onRowSelect(_selectedRows.filter(function (r) {
return r.isSelected === true;
}));
}
}
};
this.getScrollOffSet = function () {
var scrollOffset = 0;
if (_this3.grid) {
var canvas = _this3.grid.querySelector('.react-grid-Canvas');
if (canvas) {
scrollOffset = canvas.offsetWidth - canvas.clientWidth;
}
}
_this3.setState({ scrollOffset: scrollOffset });
};
this.getRowOffsetHeight = function () {
var offsetHeight = 0;
_this3.getHeaderRows().forEach(function (row) {
return offsetHeight += parseFloat(row.height, 10);
});
return offsetHeight;
};
this.getHeaderRows = function () {
var rows = [{ ref: function ref(node) {
return _this3.row = node;
}, height: _this3.props.headerRowHeight || _this3.props.rowHeight, rowType: 'header' }];
if (_this3.state.canFilter === true) {
rows.push({
ref: function ref(node) {
return _this3.filterRow = node;
},
filterable: true,
onFilterChange: _this3.props.onAddFilter,
height: _this3.props.headerFiltersHeight,
rowType: 'filter'
});
}
return rows;
};
this.getInitialSelectedRows = function () {
var selectedRows = [];
for (var i = 0; i < _this3.props.rowsCount; i++) {
selectedRows.push(false);
}
return selectedRows;
};
this.getRowSelectionProps = function () {
if (_this3.props.rowSelection) {
return _this3.props.rowSelection.selectBy;
}
return null;
};
this.getSelectedRows = function () {
if (_this3.props.rowSelection) {
return null;
}
return _this3.state.selectedRows.filter(function (r) {
return r.isSelected === true;
});
};
this.getSelectedValue = function () {
var rowIdx = _this3.state.selected.rowIdx;
var idx = _this3.state.selected.idx;
var cellKey = _this3.getColumn(idx).key;
var row = _this3.props.rowGetter(rowIdx);
return RowUtils.get(row, cellKey);
};
this.canExitGrid = function (e) {
// When the cellNavigationMode is 'none', you can exit the grid if you're at the start or end of the row
// When the cellNavigationMode is 'changeRow', you can exit the grid if you're at the first or last cell of the grid
// When the cellNavigationMode is 'loopOverRow', there is no logical exit point so you can't exit the grid
var atLastCellInRow = _this3.isAtLastCellInRow(_this3.getNbrColumns());
var atFirstCellInRow = _this3.isAtFirstCellInRow();
var atLastRow = _this3.isAtLastRow();
var atFirstRow = _this3.isAtFirstRow();
var shift = e.shiftKey === true;
var cellNavigationMode = _this3.props.cellNavigationMode;
if (shift) {
if (cellNavigationMode === 'none') {
if (atFirstCellInRow) {
return true;
}
} else if (cellNavigationMode === 'changeRow') {
if (atFirstCellInRow && atFirstRow) {
return true;
}
}
} else {
if (cellNavigationMode === 'none') {
if (atLastCellInRow) {
return true;
}
} else if (cellNavigationMode === 'changeRow') {
if (atLastCellInRow && atLastRow) {
return true;
}
}
}
return false;
};
this.moveSelectedCell = function (e, rowDelta, cellDelta) {
// we need to prevent default as we control grid scroll
// otherwise it moves every time you left/right which is janky
e.preventDefault();
var rowIdx = void 0;
var idx = void 0;
var cellNavigationMode = _this3.props.cellNavigationMode;
if (cellNavigationMode !== 'none') {
var _calculateNextSelecti = _this3.calculateNextSelectionPosition(cellNavigationMode, cellDelta, rowDelta);
idx = _calculateNextSelecti.idx;
rowIdx = _calculateNextSelecti.rowIdx;
} else {
rowIdx = _this3.state.selected.rowIdx + rowDelta;
idx = _this3.state.selected.idx + cellDelta;
}
_this3.scrollToColumn(idx);
_this3.onSelect({ idx: idx, rowIdx: rowIdx });
};
this.getNbrColumns = function () {
var _props = _this3.props,
columns = _props.columns,
enableRowSelect = _props.enableRowSelect;
return enableRowSelect ? columns.length + 1 : columns.length;
};
this.getDataGridDOMNode = function () {
return _this3.grid;
};
this.calculateNextSelectionPosition = function (cellNavigationMode, cellDelta, rowDelta) {
var _rowDelta = rowDelta;
var idx = _this3.state.selected.idx + cellDelta;
var nbrColumns = _this3.getNbrColumns();
if (cellDelta > 0) {
if (_this3.isAtLastCellInRow(nbrColumns)) {
if (cellNavigationMode === 'changeRow') {
_rowDelta = _this3.isAtLastRow() ? rowDelta : rowDelta + 1;
idx = _this3.isAtLastRow() ? idx : 0;
} else {
idx = 0;
}
}
} else if (cellDelta < 0) {
if (_this3.isAtFirstCellInRow()) {
if (cellNavigationMode === 'changeRow') {
_rowDelta = _this3.isAtFirstRow() ? rowDelta : rowDelta - 1;
idx = _this3.isAtFirstRow() ? 0 : nbrColumns - 1;
} else {
idx = nbrColumns - 1;
}
}
}
var rowIdx = _this3.state.selected.rowIdx + _rowDelta;
return { idx: idx, rowIdx: rowIdx };
};
this.isAtLastCellInRow = function (nbrColumns) {
return _this3.state.selected.idx === nbrColumns - 1;
};
this.isAtLastRow = function () {
return _this3.state.selected.rowIdx === _this3.props.rowsCount - 1;
};
this.isAtFirstCellInRow = function () {
return _this3.state.selected.idx === 0;
};
this.isAtFirstRow = function () {
return _this3.state.selected.rowIdx === 0;
};
this.openCellEditor = function (rowIdx, idx) {
var row = _this3.props.rowGetter(rowIdx);
var col = _this3.getColumn(idx);
if (!ColumnUtils.canEdit(col, row, _this3.props.enableCellSelect)) {
return;
}
var selected = { rowIdx: rowIdx, idx: idx };
if (_this3.hasSelectedCellChanged(selected)) {
_this3.setState({ selected: selected }, function () {
_this3.setActive('Enter');
});
} else {
_this3.setActive('Enter');
}
};
this.scrollToColumn = function (colIdx) {
if (_this3.grid) {
var canvas = _this3.grid.querySelector('.react-grid-Canvas');
if (canvas) {
var left = 0;
var locked = 0;
for (var i = 0; i < colIdx; i++) {
var column = _this3.getColumn(i);
if (column) {
if (column.width) {
left += column.width;
}
if (column.locked) {
locked += column.width;
}
}
}
var selectedColumn = _this3.getColumn(colIdx);
if (selectedColumn) {
var scrollLeft = left - locked - canvas.scrollLeft;
var scrollRight = left + selectedColumn.width - canvas.scrollLeft;
if (scrollLeft < 0) {
canvas.scrollLeft += scrollLeft;
} else if (scrollRight > canvas.clientWidth) {
var scrollAmount = scrollRight - canvas.clientWidth;
canvas.scrollLeft += scrollAmount;
}
}
}
}
};
this.deselect = function () {
var selected = { rowIdx: -1, idx: -1 };
_this3.setState({ selected: selected });
};
this.setActive = function (keyPressed) {
var rowIdx = _this3.state.selected.rowIdx;
var row = _this3.props.rowGetter(rowIdx);
var idx = _this3.state.selected.idx;
var column = _this3.getColumn(idx);
if (ColumnUtils.canEdit(column, row, _this3.props.enableCellSelect) && !_this3.isActive()) {
var selected = Object.assign({}, _this3.state.selected, { idx: idx, rowIdx: rowIdx, active: true, initialKeyCode: keyPressed });
var showEditor = true;
if (typeof _this3.props.onCheckCellIsEditable === 'function') {
var args = Object.assign({}, { row: row, column: column }, selected);
showEditor = _this3.props.onCheckCellIsEditable(args);
}
if (showEditor !== false) {
if (column.locked) {
_this3.setState({ selected: selected });
} else {
_this3.setState({ selected: selected }, function () {
_this3.scrollToColumn(idx);
});
}
_this3.props.onBeforeEdit();
_this3.handleCancelCopy();
}
}
};
this.setInactive = function () {
var rowIdx = _this3.state.selected.rowIdx;
var row = _this3.props.rowGetter(rowIdx);
var idx = _this3.state.selected.idx;
var col = _this3.getColumn(idx);
if (ColumnUtils.canEdit(col, row, _this3.props.enableCellSelect) && _this3.isActive()) {
var selected = Object.assign({}, _this3.state.selected, { idx: idx, rowIdx: rowIdx, active: false });
_this3.setState({ selected: selected });
}
};
this.isActive = function () {
return _this3.state.selected.active === true;
};
this.setupGridColumns = function () {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this3.props;
var columns = props.columns;
if (_this3._cachedColumns === columns) {
return _this3._cachedComputedColumns;
}
_this3._cachedColumns = columns;
var cols = columns.slice(0);
var unshiftedCols = {};
if (_this3.props.rowActionsCell || props.enableRowSelect && !_this3.props.rowSelection || props.rowSelection && props.rowSelection.showCheckbox !== false) {
var SelectAllComponent = _this3.props.selectAllRenderer || _SelectAll2['default'];
var SelectAllRenderer = React.createElement(SelectAllComponent, { onChange: _this3.handleCheckboxChange, inputRef: function inputRef(grid) {
return _this3.selectAllCheckbox = grid;
} });
var headerRenderer = props.enableRowSelect === 'single' ? null : SelectAllRenderer;
var Formatter = _this3.props.rowActionsCell ? _this3.props.rowActionsCell : CheckboxEditor;
var selectColumn = {
key: 'select-row',
name: '',
formatter: React.createElement(Formatter, { rowSelection: _this3.props.rowSelection }),
onCellChange: _this3.handleRowSelect,
filterable: false,
headerRenderer: headerRenderer,
width: 60,
locked: true,
getRowMetaData: function getRowMetaData(rowData) {
return rowData;
},
cellClass: _this3.props.rowActionsCell ? 'rdg-row-actions-cell' : ''
};
unshiftedCols = cols.unshift(selectColumn);
cols = unshiftedCols > 0 ? cols : unshiftedCols;
}
_this3._cachedComputedColumns = cols;
return _this3._cachedComputedColumns;
};
this.copyPasteEnabled = function () {
return _this3.props.onCellCopyPaste !== null;
};
this.dragEnabled = function () {
return _this3.props.onGridRowsUpdated !== undefined || _this3.props.onCellsDragged !== undefined;
};
this.renderToolbar = function () {
var Toolbar = _this3.props.toolbar;
var toolBarProps = { columns: _this3.props.columns, onToggleFilter: _this3.onToggleFilter, numberOfRows: _this3.props.rowsCount };
if (React.isValidElement(Toolbar)) {
return React.cloneElement(Toolbar, toolBarProps);
} else if (isFunction(Toolbar)) {
return React.createElement(Toolbar, toolBarProps);
}
};
};
module.exports = ReactDataGrid;
/***/ }),
/* 206 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var Draggable = __webpack_require__(195);
__webpack_require__(20);
var style = {
position: 'absolute',
top: 0,
right: 0,
width: 6,
height: '100%'
};
var ResizeHandle = function (_React$Component) {
_inherits(ResizeHandle, _React$Component);
function ResizeHandle() {
_classCallCheck(this, ResizeHandle);
return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
ResizeHandle.prototype.render = function render() {
return React.createElement(Draggable, _extends({}, this.props, {
className: 'react-grid-HeaderCell__resizeHandle',
style: style
}));
};
return ResizeHandle;
}(React.Component);
module.exports = ResizeHandle;
/***/ }),
/* 207 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _utils = __webpack_require__(71);
var _utils2 = _interopRequireDefault(_utils);
__webpack_require__(27);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var cellMetaDataShape = __webpack_require__(12);
var RowGroup = function (_Component) {
_inherits(RowGroup, _Component);
function RowGroup(props) {
_classCallCheck(this, RowGroup);
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
_this.onRowExpandToggle = _this.onRowExpandToggle.bind(_this);
_this.onRowExpandClick = _this.onRowExpandClick.bind(_this);
_this.setScrollLeft = _this.setScrollLeft.bind(_this);
return _this;
}
RowGroup.prototype.onRowExpandToggle = function onRowExpandToggle(expand) {
var shouldExpand = expand == null ? !this.props.isExpanded : expand;
var meta = this.props.cellMetaData;
if (meta != null && meta.onRowExpandToggle && typeof meta.onRowExpandToggle === 'function') {
meta.onRowExpandToggle({ rowIdx: this.props.idx, shouldExpand: shouldExpand, columnGroupName: this.props.columnGroupName, name: this.props.name });
}
};
RowGroup.prototype.onRowExpandClick = function onRowExpandClick() {
this.onRowExpandToggle(!this.props.isExpanded);
};
RowGroup.prototype.setScrollLeft = function setScrollLeft(scrollLeft) {
if (this.rowGroupRenderer) {
this.rowGroupRenderer.setScrollLeft ? this.rowGroupRenderer.setScrollLeft(scrollLeft) : null;
}
};
RowGroup.prototype.render = function render() {
var _this2 = this;
var lastColumn = _utils2['default'].last(this.props.columns);
var style = { width: lastColumn.left + lastColumn.width };
return _react2['default'].createElement(
'div',
{ style: style, className: 'react-grid-row-group' },
_react2['default'].createElement(this.props.renderer, _extends({ ref: function ref(node) {
_this2.rowGroupRenderer = node;
} }, this.props, { onRowExpandClick: this.onRowExpandClick, onRowExpandToggle: this.onRowExpandToggle }))
);
};
return RowGroup;
}(_react.Component);
RowGroup.propTypes = {
height: _propTypes2['default'].number.isRequired,
columns: _propTypes2['default'].oneOfType([_propTypes2['default'].object, _propTypes2['default'].array]).isRequired,
row: _propTypes2['default'].any.isRequired,
cellRenderer: _propTypes2['default'].func,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape),
isSelected: _propTypes2['default'].bool,
idx: _propTypes2['default'].number.isRequired,
expandedRows: _propTypes2['default'].arrayOf(_propTypes2['default'].object),
extraClasses: _propTypes2['default'].string,
forceUpdate: _propTypes2['default'].bool,
subRowDetails: _propTypes2['default'].object,
isRowHovered: _propTypes2['default'].bool,
colVisibleStart: _propTypes2['default'].number.isRequired,
colVisibleEnd: _propTypes2['default'].number.isRequired,
colDisplayStart: _propTypes2['default'].number.isRequired,
colDisplayEnd: _propTypes2['default'].number.isRequired,
isScrolling: _propTypes2['default'].bool.isRequired,
columnGroupName: _propTypes2['default'].string.isRequired,
isExpanded: _propTypes2['default'].bool.isRequired,
treeDepth: _propTypes2['default'].number.isRequired,
name: _propTypes2['default'].string.isRequired,
renderer: _propTypes2['default'].func
};
var DefaultRowGroupRenderer = function DefaultRowGroupRenderer(props) {
var treeDepth = props.treeDepth || 0;
var marginLeft = treeDepth * 20;
var style = {
height: '50px',
border: '1px solid #dddddd',
paddingTop: '15px',
paddingLeft: '5px'
};
var onKeyDown = function onKeyDown(e) {
if (e.key === 'ArrowLeft') {
props.onRowExpandToggle(false);
}
if (e.key === 'ArrowRight') {
props.onRowExpandToggle(true);
}
if (e.key === 'Enter') {
props.onRowExpandToggle(!props.isExpanded);
}
};
return _react2['default'].createElement(
'div',
{ style: style, onKeyDown: onKeyDown, tabIndex: 0 },
_react2['default'].createElement(
'span',
{ className: 'row-expand-icon', style: { float: 'left', marginLeft: marginLeft, cursor: 'pointer' }, onClick: props.onRowExpandClick },
props.isExpanded ? String.fromCharCode('9660') : String.fromCharCode('9658')
),
_react2['default'].createElement(
'strong',
null,
props.columnGroupName,
': ',
props.name
)
);
};
DefaultRowGroupRenderer.propTypes = {
onRowExpandClick: _propTypes2['default'].func.isRequired,
onRowExpandToggle: _propTypes2['default'].func.isRequired,
isExpanded: _propTypes2['default'].bool.isRequired,
treeDepth: _propTypes2['default'].number.isRequired,
name: _propTypes2['default'].string.isRequired,
columnGroupName: _propTypes2['default'].string.isRequired,
hideColumnName: _propTypes2['default'].bool
};
RowGroup.defaultProps = {
renderer: DefaultRowGroupRenderer
};
exports['default'] = RowGroup;
/***/ }),
/* 208 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _ColumnUtils = __webpack_require__(8);
var _ColumnUtils2 = _interopRequireDefault(_ColumnUtils);
var _viewportUtils = __webpack_require__(224);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var Canvas = __webpack_require__(190);
var cellMetaDataShape = __webpack_require__(12);
var Viewport = function (_React$Component) {
_inherits(Viewport, _React$Component);
function Viewport() {
var _temp, _this, _ret;
_classCallCheck(this, Viewport);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = (0, _viewportUtils.getGridState)(_this.props), _this.onScroll = function (scroll) {
_this.updateScroll(scroll.scrollTop, scroll.scrollLeft, _this.state.height, _this.props.rowHeight, _this.props.rowsCount);
if (_this.props.onScroll) {
_this.props.onScroll({ scrollTop: scroll.scrollTop, scrollLeft: scroll.scrollLeft });
}
}, _this.getScroll = function () {
return _this.canvas.getScroll();
}, _this.setScrollLeft = function (scrollLeft) {
_this.canvas.setScrollLeft(scrollLeft);
}, _this.getDOMNodeOffsetWidth = function () {
return _this.viewport ? _this.viewport.offsetWidth : 0;
}, _this.clearScrollTimer = function () {
if (_this.resetScrollStateTimeoutId) {
clearTimeout(_this.resetScrollStateTimeoutId);
}
}, _this.resetScrollStateAfterDelay = function () {
_this.clearScrollTimer();
_this.resetScrollStateTimeoutId = setTimeout(_this.resetScrollStateAfterDelayCallback, 500);
}, _this.resetScrollStateAfterDelayCallback = function () {
_this.resetScrollStateTimeoutId = null;
_this.setState({
isScrolling: false
});
}, _this.updateScroll = function (scrollTop, scrollLeft, height, rowHeight, length, width) {
_this.resetScrollStateAfterDelay();
var nextScrollState = (0, _viewportUtils.getNextScrollState)(_this.props, _this.getDOMNodeOffsetWidth, scrollTop, scrollLeft, height, rowHeight, length, width);
_this.setState(nextScrollState);
}, _this.metricsUpdated = function () {
var height = _this.viewportHeight();
var width = _this.viewportWidth();
if (height) {
_this.updateScroll(_this.state.scrollTop, _this.state.scrollLeft, height, _this.props.rowHeight, _this.props.rowsCount, width);
}
}, _this.viewportHeight = function () {
return _this.viewport ? _this.viewport.offsetHeight : 0;
}, _this.viewportWidth = function () {
return _this.viewport ? _this.viewport.offsetWidth : 0;
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Viewport.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (this.props.rowHeight !== nextProps.rowHeight || this.props.minHeight !== nextProps.minHeight) {
var newState = (0, _viewportUtils.getGridState)(nextProps);
this.updateScroll(newState.scrollTop, newState.scrollLeft, newState.height, nextProps.rowHeight, nextProps.rowsCount);
} else if (_ColumnUtils2['default'].getSize(this.props.columnMetrics.columns) !== _ColumnUtils2['default'].getSize(nextProps.columnMetrics.columns)) {
this.setState((0, _viewportUtils.getGridState)(nextProps));
} else if (this.props.rowsCount !== nextProps.rowsCount) {
this.updateScroll(this.state.scrollTop, this.state.scrollLeft, this.state.height, nextProps.rowHeight, nextProps.rowsCount);
// Added to fix the hiding of the bottom scrollbar when showing the filters.
} else if (this.props.rowOffsetHeight !== nextProps.rowOffsetHeight) {
// The value of height can be positive or negative and will be added to the current height to cater for changes in the header height (due to the filer)
var height = this.props.rowOffsetHeight - nextProps.rowOffsetHeight;
this.updateScroll(this.state.scrollTop, this.state.scrollLeft, this.state.height + height, nextProps.rowHeight, nextProps.rowsCount);
}
};
Viewport.prototype.componentDidMount = function componentDidMount() {
if (window.addEventListener) {
window.addEventListener('resize', this.metricsUpdated);
} else {
window.attachEvent('resize', this.metricsUpdated);
}
this.metricsUpdated();
};
Viewport.prototype.componentWillUnmount = function componentWillUnmount() {
window.removeEventListener('resize', this.metricsUpdated);
this.clearScrollTimer();
};
Viewport.prototype.render = function render() {
var _this2 = this;
var style = {
padding: 0,
bottom: 0,
left: 0,
right: 0,
overflow: 'hidden',
position: 'absolute',
top: this.props.rowOffsetHeight
};
return React.createElement(
'div',
{
className: 'react-grid-Viewport',
style: style,
ref: function ref(node) {
_this2.viewport = node;
} },
React.createElement(Canvas, {
ref: function ref(node) {
return _this2.canvas = node;
},
rowKey: this.props.rowKey,
totalWidth: this.props.totalWidth,
width: this.props.columnMetrics.width,
rowGetter: this.props.rowGetter,
rowsCount: this.props.rowsCount,
selectedRows: this.props.selectedRows,
expandedRows: this.props.expandedRows,
columns: this.props.columnMetrics.columns,
rowRenderer: this.props.rowRenderer,
displayStart: this.state.displayStart,
displayEnd: this.state.displayEnd,
visibleStart: this.state.visibleStart,
visibleEnd: this.state.visibleEnd,
colVisibleStart: this.state.colVisibleStart,
colVisibleEnd: this.state.colVisibleEnd,
colDisplayStart: this.state.colDisplayStart,
colDisplayEnd: this.state.colDisplayEnd,
cellMetaData: this.props.cellMetaData,
height: this.state.height,
rowHeight: this.props.rowHeight,
onScroll: this.onScroll,
onRows: this.props.onRows,
rowScrollTimeout: this.props.rowScrollTimeout,
scrollToRowIndex: this.props.scrollToRowIndex,
contextMenu: this.props.contextMenu,
rowSelection: this.props.rowSelection,
getSubRowDetails: this.props.getSubRowDetails,
rowGroupRenderer: this.props.rowGroupRenderer,
isScrolling: this.state.isScrolling || false
})
);
};
return Viewport;
}(React.Component);
Viewport.displayName = 'Viewport';
Viewport.propTypes = {
rowOffsetHeight: _propTypes2['default'].number.isRequired,
totalWidth: _propTypes2['default'].oneOfType([_propTypes2['default'].number, _propTypes2['default'].string]).isRequired,
columnMetrics: _propTypes2['default'].object.isRequired,
rowGetter: _propTypes2['default'].oneOfType([_propTypes2['default'].array, _propTypes2['default'].func]).isRequired,
selectedRows: _propTypes2['default'].array,
rowSelection: _propTypes2['default'].oneOfType([_propTypes2['default'].shape({
indexes: _propTypes2['default'].arrayOf(_propTypes2['default'].number).isRequired
}), _propTypes2['default'].shape({
isSelectedKey: _propTypes2['default'].string.isRequired
}), _propTypes2['default'].shape({
keys: _propTypes2['default'].shape({
values: _propTypes2['default'].array.isRequired,
rowKey: _propTypes2['default'].string.isRequired
}).isRequired
})]),
expandedRows: _propTypes2['default'].array,
rowRenderer: _propTypes2['default'].oneOfType([_propTypes2['default'].element, _propTypes2['default'].func]),
rowsCount: _propTypes2['default'].number.isRequired,
rowHeight: _propTypes2['default'].number.isRequired,
onRows: _propTypes2['default'].func,
onScroll: _propTypes2['default'].func,
minHeight: _propTypes2['default'].number,
cellMetaData: _propTypes2['default'].shape(cellMetaDataShape),
rowKey: _propTypes2['default'].string.isRequired,
rowScrollTimeout: _propTypes2['default'].number,
scrollToRowIndex: _propTypes2['default'].number,
contextMenu: _propTypes2['default'].element,
getSubRowDetails: _propTypes2['default'].func,
rowGroupRenderer: _propTypes2['default'].func
};
Viewport.defaultProps = {
rowHeight: 30
};
module.exports = Viewport;
/***/ }),
/* 209 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var ExcelColumn = __webpack_require__(15);
var FilterableHeaderCell = function (_React$Component) {
_inherits(FilterableHeaderCell, _React$Component);
function FilterableHeaderCell() {
var _temp, _this, _ret;
_classCallCheck(this, FilterableHeaderCell);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.state = { filterTerm: '' }, _this.handleChange = function (e) {
var val = e.target.value;
_this.setState({ filterTerm: val });
_this.props.onChange({ filterTerm: val, column: _this.props.column });
}, _this.renderInput = function () {
if (_this.props.column.filterable === false) {
return React.createElement('span', null);
}
var inputKey = 'header-filter-' + _this.props.column.key;
return React.createElement('input', { key: inputKey, type: 'text', className: 'form-control input-sm', placeholder: 'Search', value: _this.state.filterTerm, onChange: _this.handleChange });
}, _temp), _possibleConstructorReturn(_this, _ret);
}
FilterableHeaderCell.prototype.render = function render() {
return React.createElement(
'div',
null,
React.createElement(
'div',
{ className: 'form-group' },
this.renderInput()
)
);
};
return FilterableHeaderCell;
}(React.Component);
FilterableHeaderCell.propTypes = {
onChange: _propTypes2['default'].func.isRequired,
column: _propTypes2['default'].shape(ExcelColumn)
};
module.exports = FilterableHeaderCell;
/***/ }),
/* 210 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var joinClasses = __webpack_require__(7);
var DEFINE_SORT = {
ASC: 'ASC',
DESC: 'DESC',
NONE: 'NONE'
};
var SortableHeaderCell = function (_React$Component) {
_inherits(SortableHeaderCell, _React$Component);
function SortableHeaderCell() {
var _temp, _this, _ret;
_classCallCheck(this, SortableHeaderCell);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.onClick = function () {
var direction = void 0;
var _this$props = _this.props,
sortDirection = _this$props.sortDirection,
sortDescendingFirst = _this$props.sortDescendingFirst;
switch (sortDirection) {
default:
case null:
case undefined:
case DEFINE_SORT.NONE:
direction = sortDescendingFirst ? DEFINE_SORT.DESC : DEFINE_SORT.ASC;
break;
case DEFINE_SORT.ASC:
direction = sortDescendingFirst ? DEFINE_SORT.NONE : DEFINE_SORT.DESC;
break;
case DEFINE_SORT.DESC:
direction = sortDescendingFirst ? DEFINE_SORT.ASC : DEFINE_SORT.NONE;
break;
}
_this.props.onSort(_this.props.columnKey, direction);
}, _this.getSortByText = function () {
var unicodeKeys = {
ASC: '9650',
DESC: '9660'
};
return _this.props.sortDirection === 'NONE' ? '' : String.fromCharCode(unicodeKeys[_this.props.sortDirection]);
}, _temp), _possibleConstructorReturn(_this, _ret);
}
SortableHeaderCell.prototype.render = function render() {
var className = joinClasses({
'react-grid-HeaderCell-sortable': true,
'react-grid-HeaderCell-sortable--ascending': this.props.sortDirection === 'ASC',
'react-grid-HeaderCell-sortable--descending': this.props.sortDirection === 'DESC'
});
return React.createElement(
'div',
{ className: className,
onClick: this.onClick,
style: { cursor: 'pointer' } },
React.createElement(
'span',
{ className: 'pull-right' },
this.getSortByText()
),
this.props.column.name
);
};
return SortableHeaderCell;
}(React.Component);
SortableHeaderCell.propTypes = {
columnKey: _propTypes2['default'].string.isRequired,
column: _propTypes2['default'].shape({ name: _propTypes2['default'].node }),
onSort: _propTypes2['default'].func.isRequired,
sortDirection: _propTypes2['default'].oneOf(Object.keys(DEFINE_SORT)),
sortDescendingFirst: _propTypes2['default'].bool
};
module.exports = SortableHeaderCell;
module.exports.DEFINE_SORT = DEFINE_SORT;
/***/ }),
/* 211 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _propTypes = __webpack_require__(3);
var _propTypes2 = _interopRequireDefault(_propTypes);
var _keyboardUtils = __webpack_require__(73);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = __webpack_require__(2);
var joinClasses = __webpack_require__(7);
var SimpleTextEditor = __webpack_require__(67);
var isFunction = __webpack_require__(23);
__webpack_require__(26);
var EditorContainer = function (_React$Component) {
_inherits(EditorContainer, _React$Component);
function EditorContainer() {
var _temp, _this, _ret;
_classCallCheck(this, EditorContainer);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _initialiseProps.call(_this), _temp), _possibleConstructorReturn(_this, _ret);
}
EditorContainer.prototype.componentDidMount = function componentDidMount() {
var inputNode = this.getInputNode();
if (inputNode !== undefined) {
this.setTextInputFocus();
if (!this.getEditor().disableContainerStyles) {
inputNode.className += ' editor-main';
inputNode.style.height = this.props.height - 1 + 'px';
}
}
};
EditorContainer.prototype.componentWillUnmount = function componentWillUnmount() {
if (!this.changeCommitted && !this.changeCanceled) {
this.commit({ key: 'Enter' });
}
};
EditorContainer.prototype.render = function render() {
return React.createElement(
'div',
{ className: this.getContainerClass(), onBlur: this.handleBlur, onKeyDown: this.onKeyDown, onContextMenu: this.handleRightClick },
this.createEditor(),
this.renderStatusIcon()
);
};
return EditorContainer;
}(React.Component);
EditorContainer.displayName = 'EditorContainer';
EditorContainer.propTypes = {
rowIdx: _propTypes2['default'].number,
rowData: _propTypes2['default'].object.isRequired,
value: _propTypes2['default'].oneOfType([_propTypes2['default'].string, _propTypes2['default'].number, _propTypes2['default'].object, _propTypes2['default'].bool]).isRequired,
cellMetaData: _propTypes2['default'].shape({
selected: _propTypes2['default'].object.isRequired,
copied: _propTypes2['default'].object,
dragged: _propTypes2['default'].object,
onCellClick: _propTypes2['default'].func,
onCellDoubleClick: _propTypes2['default'].func,
onCommitCancel: _propTypes2['default'].func,
onCommit: _propTypes2['default'].func
}).isRequired,
column: _propTypes2['default'].object.isRequired,
height: _propTypes2['default'].number.isRequired,
onGridKeyDown: _propTypes2['default'].func
};
var _initialiseProps = function _initialiseProps() {
var _this2 = this;
this.state = { isInvalid: false };
this.changeCommitted = false;
this.changeCanceled = false;
this.isKeyExplicitlyHandled = function (key) {
return isFunction(_this2['onPress' + key]);
};
this.checkAndCall = function (methodName, args) {
if (isFunction(_this2[methodName])) {
_this2[methodName](args);
}
};
this.onKeyDown = function (e) {
if ((0, _keyboardUtils.isCtrlKeyHeldDown)(e)) {
_this2.checkAndCall('onPressKeyWithCtrl', e);
} else if (_this2.isKeyExplicitlyHandled(e.key)) {
// break up individual keyPress events to have their own specific callbacks
var callBack = 'onPress' + e.key;
_this2.checkAndCall(callBack, e);
} else if ((0, _keyboardUtils.isKeyPrintable)(e.keyCode)) {
_this2.checkAndCall('onPressChar', e);
}
// Track which keys are currently down for shift clicking etc
_this2._keysDown = _this2._keysDown || {};
_this2._keysDown[e.keyCode] = true;
if (isFunction(_this2.props.onGridKeyDown)) {
_this2.props.onGridKeyDown(e);
}
};
this.createEditor = function () {
var editorRef = function editorRef(c) {
return _this2.editor = c;
};
var editorProps = {
ref: editorRef,
column: _this2.props.column,
value: _this2.getInitialValue(),
onCommit: _this2.commit,
onCommitCancel: _this2.commitCancel,
rowMetaData: _this2.getRowMetaData(),
rowData: _this2.props.rowData,
height: _this2.props.height,
onBlur: _this2.commit,
onOverrideKeyDown: _this2.onKeyDown
};
var CustomEditor = _this2.props.column.editor;
// return custom column editor or SimpleEditor if none specified
if (React.isValidElement(CustomEditor)) {
return React.cloneElement(CustomEditor, editorProps);
}
if (isFunction(CustomEditor)) {
return React.createElement(CustomEditor, _extends({ ref: editorRef }, editorProps));
}
return React.createElement(SimpleTextEditor, { ref: editorRef, column: _this2.props.column, value: _this2.getInitialValue(), onBlur: _this2.commit, rowMetaData: _this2.getRowMetaData(), onKeyDown: function onKeyDown() {}, commit: function commit() {} });
};
this.onPressEnter = function () {
_this2.commit({ key: 'Enter' });
};
this.onPressTab = function () {
_this2.commit({ key: 'Tab' });
};
this.onPressEscape = function (e) {
if (!_this2.editorIsSelectOpen()) {
_this2.commitCancel();
} else {
// prevent event from bubbling if editor has results to select
e.stopPropagation();
}
};
this.onPressArrowDown = function (e) {
if (_this2.editorHasResults()) {
// dont want to propogate as that then moves us round the grid
e.stopPropagation();
} else {
_this2.commit(e);
}
};
this.onPressArrowUp = function (e) {
if (_this2.editorHasResults()) {
// dont want to propogate as that then moves us round the grid
e.stopPropagation();
} else {
_this2.commit(e);
}
};
this.onPressArrowLeft = function (e) {
// prevent event propogation. this disables left cell navigation
if (!_this2.isCaretAtBeginningOfInput()) {
e.stopPropagation();
} else {
_this2.commit(e);
}
};
this.onPressArrowRight = function (e) {
// prevent event propogation. this disables right cell navigation
if (!_this2.isCaretAtEndOfInput()) {
e.stopPropagation();
} else {
_this2.commit(e);
}
};
this.editorHasResults = function () {
if (isFunction(_this2.getEditor().hasResults)) {
return _this2.getEditor().hasResults();
}
return false;
};
this.editorIsSelectOpen = function () {
if (isFunction(_this2.getEditor().isSelectOpen)) {
return _this2.getEditor().isSelectOpen();
}
return false;
};
this.getRowMetaData = function () {
// clone row data so editor cannot actually change this
// convention based method to get corresponding Id or Name of any Name or Id property
if (typeof _this2.props.column.getRowMetaData === 'function') {
return _this2.props.column.getRowMetaData(_this2.props.rowData, _this2.props.column);
}
};
this.getEditor = function () {
return _this2.editor;
};
this.getInputNode = function () {
return _this2.getEditor().getInputNode();
};
this.getInitialValue = function () {
var selected = _this2.props.cellMetaData.selected;
var keyCode = selected.initialKeyCode;
if (keyCode === 'Delete' || keyCode === 'Backspace') {
return '';
} else if (keyCode === 'Enter') {
return _this2.props.value;
}
var text = keyCode ? String.fromCharCode(keyCode) : _this2.props.value;
return text;
};
this.getContainerClass = function () {
return joinClasses({
'has-error': _this2.state.isInvalid === true
});
};
this.commit = function (args) {
var opts = args || {};
var updated = _this2.getEditor().getValue();
if (_this2.isNewValueValid(updated)) {
_this2.changeCommitted = true;
var cellKey = _this2.props.column.key;
_this2.props.cellMetaData.onCommit({ cellKey: cellKey, rowIdx: _this2.props.rowIdx, updated: updated, key: opts.key });
}
};
this.commitCancel = function () {
_this2.changeCanceled = true;
_this2.props.cellMetaData.onCommitCancel();
};
this.isNewValueValid = function (value) {
if (isFunction(_this2.getEditor().validate)) {
var isValid = _this2.getEditor().validate(value);
_this2.setState({ isInvalid: !isValid });
return isValid;
}
return true;
};
this.setCaretAtEndOfInput = function () {
var input = _this2.getInputNode();
// taken from http://stackoverflow.com/questions/511088/use-javascript-to-place-cursor-at-end-of-text-in-text-input-element
var txtLength = input.value.length;
if (input.setSelectionRange) {
input.setSelectionRange(txtLength, txtLength);
} else if (input.createTextRange) {
var fieldRange = input.createTextRange();
fieldRange.moveStart('character', txtLength);
fieldRange.collapse();
fieldRange.select();
}
};
this.isCaretAtBeginningOfInput = function () {
var inputNode = _this2.getInputNode();
return inputNode.selectionStart === inputNode.selectionEnd && inputNode.selectionStart === 0;
};
this.isCaretAtEndOfInput = function () {
var inputNode = _this2.getInputNode();
return inputNode.selectionStart === inputNode.value.length;
};
this.isBodyClicked = function (e) {
var relatedTarget = _this2.getRelatedTarget(e);
return relatedTarget === null;
};
this.isViewportClicked = function (e) {
var relatedTarget = _this2.getRelatedTarget(e);
return relatedTarget.className.indexOf('react-grid-Viewport') > -1;
};
this.isClickInsideEditor = function (e) {
var relatedTarget = _this2.getRelatedTarget(e);
return e.currentTarget.contains(relatedTarget) || relatedTarget.className.indexOf('editing') > -1 || relatedTarget.className.indexOf('react-grid-Cell') > -1;
};
this.getRelatedTarget = function (e) {
return e.relatedTarget || e.explicitOriginalTarget || document.activeElement; // IE11
};
this.handleRightClick = function (e) {
e.stopPropagation();
};
this.handleBlur = function (e) {
e.stopPropagation();
if (_this2.isBodyClicked(e)) {
_this2.commit(e);
}
if (!_this2.isBodyClicked(e)) {
// prevent null reference
if (_this2.isViewportClicked(e) || !_this2.isClickInsideEditor(e)) {
_this2.commit(e);
}
}
};
this.setTextInputFocus = function () {
var selected = _this2.props.cellMetaData.selected;
var keyCode = selected.initialKeyCode;
var inputNode = _this2.getInputNode();
inputNode.focus();
if (inputNode.tagName === 'INPUT') {
if (!(0, _keyboardUtils.isKeyPrintable)(keyCode)) {
inputNode.focus();
inputNode.select();
} else {
inputNode.select();
}
}
};
this.renderStatusIcon = function () {
if (_this2.state.isInvalid === true) {
return React.createElement('span', { className: 'glyphicon glyphicon-remove form-control-feedback' });
}
};
};
module.exports = EditorContainer;
/***/ }),
/* 212 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
module.exports = {
CheckboxEditor: __webpack_require__(65),
EditorBase: __webpack_require__(66),
SimpleTextEditor: __webpack_require__(67)
};
/***/ }),
/* 213 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
var _reactDom = __webpack_require__(6);
var _reactDom2 = _interopRequireDefault(_reactDom);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { 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: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /* eslint-disable react/prop-types */
var focusableComponentWrapper = function focusableComponentWrapper(WrappedComponent) {
return function (_Component) {
_inherits(ComponentWrapper, _Component);
function ComponentWrapper() {
_classCallCheck(this, ComponentWrapper);
var _this = _possibleConstructorReturn(this, _Component.call(this));
_this.checkFocus = _this.checkFocus.bind(_this);
_this.state = { isScrolling: false };
return _this;
}
ComponentWrapper.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return WrappedComponent.isSelected(this.props) !== WrappedComponent.isSelected(nextProps);
};
ComponentWrapper.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
var isScrolling = WrappedComponent.isScrolling(nextProps);
if (isScrolling && !this.state.isScrolling) {
this.setState({ isScrolling: isScrolling });
}
};
ComponentWrapper.prototype.componentDidMount = function componentDidMount() {
this.checkFocus();
};
ComponentWrapper.prototype.componentDidUpdate = function componentDidUpdate() {
this.checkFocus();
};
ComponentWrapper.prototype.checkFocus = function checkFocus() {
if (WrappedComponent.isSelected(this.props) && this.state.isScrolling) {
this.focus();
this.setState({ isScrolling: false });
}
};
ComponentWrapper.prototype.focus = function focus() {
_reactDom2['default'].findDOMNode(this).focus();
};
ComponentWrapper.prototype.render = function render() {
return _react2['default'].createElement(WrappedComponent, _extends({}, this.props, this.state));
};
return ComponentWrapper;
}(_react.Component);
};
exports['default'] = focusableComponentWrapper;
/***/ }),
/* 214 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
module.exports = {
SimpleCellFormatter: __webpack_require__(69),
SelectAll: __webpack_require__(68)
};
/***/ }),
/* 215 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _GridPropHelpers = __webpack_require__(216);
var _GridPropHelpers2 = _interopRequireDefault(_GridPropHelpers);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
module.exports = {
test: { GridPropHelpers: _GridPropHelpers2['default'] }
};
/***/ }),
/* 216 */
/***/ (function(module, exports) {
'use strict';
var _rows = [];
for (var i = 0; i < 1000; i++) {
_rows.push({
id: i,
title: 'Title ' + i,
count: i * 1000
});
}
module.exports = {
columns: [{
key: 'id',
name: 'ID',
width: 100
}, {
key: 'title',
name: 'Title',
width: 100
}, {
key: 'count',
name: 'Count',
width: 100
}],
rowGetter: function rowGetter(i) {
return _rows[i];
},
rowsCount: function rowsCount() {
return _rows.length;
},
cellMetaData: {
selected: { idx: 2, rowIdx: 3 },
dragged: null,
copied: null
}
};
/***/ }),
/* 217 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _RowComparer = __webpack_require__(62);
var _RowComparer2 = _interopRequireDefault(_RowComparer);
var _RowsContainer = __webpack_require__(64);
var _RowsContainer2 = _interopRequireDefault(_RowsContainer);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var Grid = __webpack_require__(205);
module.exports = Grid;
module.exports.Row = __webpack_require__(61);
module.exports.Cell = __webpack_require__(59);
module.exports.HeaderCell = __webpack_require__(60);
module.exports.RowComparer = _RowComparer2['default'];
module.exports.EmptyChildRow = __webpack_require__(196);
module.exports.RowsContainer = _RowsContainer2['default'];
module.exports.editors = __webpack_require__(212);
module.exports.formatters = __webpack_require__(214);
module.exports.utils = __webpack_require__(71);
module.exports.shapes = __webpack_require__(204);
module.exports._constants = __webpack_require__(31);
module.exports._helpers = __webpack_require__(215);
/***/ }),
/* 218 */
/***/ (function(module, exports) {
"use strict";
var isEmptyArray = function isEmptyArray(obj) {
return Array.isArray(obj) && obj.length === 0;
};
module.exports = isEmptyArray;
/***/ }),
/* 219 */
/***/ (function(module, exports) {
"use strict";
function isEmpty(obj) {
return Object.keys(obj).length === 0 && obj.constructor === Object;
}
module.exports = isEmpty;
/***/ }),
/* 220 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _immutable = __webpack_require__(19);
var isImmutableCollection = function isImmutableCollection(objToVerify) {
return _immutable.Iterable.isIterable(objToVerify);
};
module.exports = isImmutableCollection;
/***/ }),
/* 221 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _immutable = __webpack_require__(19);
module.exports = _immutable.Map.isMap;
/***/ }),
/* 222 */
/***/ (function(module, exports) {
"use strict";
var getMixedTypeValueRetriever = function getMixedTypeValueRetriever(isImmutable) {
var retObj = {};
var retriever = function retriever(item, key) {
return item[key];
};
var immutableRetriever = function immutableRetriever(immutable, key) {
return immutable.get(key);
};
retObj.getValue = isImmutable ? immutableRetriever : retriever;
return retObj;
};
module.exports = getMixedTypeValueRetriever;
/***/ }),
/* 223 */
/***/ (function(module, exports) {
'use strict';
exports.__esModule = true;
function createScrollShim(size) {
var shim = document.createElement('div');
if (shim.classList) {
shim.classList.add('react-grid-ScrollShim'); // flow - not compatible with HTMLElement
} else {
shim.className += ' react-grid-ScrollShim';
}
shim.style.position = 'absolute';
shim.style.top = 0;
shim.style.left = 0;
shim.style.width = size.width + 'px';
shim.style.height = size.height + 'px';
return shim;
}
exports.createScrollShim = createScrollShim;
/***/ }),
/* 224 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
exports.__esModule = true;
exports.getRenderedColumnCount = exports.getNextScrollState = exports.getGridState = undefined;
var _ColumnUtils = __webpack_require__(8);
var _ColumnUtils2 = _interopRequireDefault(_ColumnUtils);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var min = Math.min;
var max = Math.max;
var floor = Math.floor;
var ceil = Math.ceil;
function getGridState(props) {
var totalNumberColumns = _ColumnUtils2['default'].getSize(props.columnMetrics.columns);
var canvasHeight = props.minHeight - props.rowOffsetHeight;
var renderedRowsCount = ceil((props.minHeight - props.rowHeight) / props.rowHeight);
var totalRowCount = min(renderedRowsCount * 4, props.rowsCount);
return {
displayStart: 0,
displayEnd: totalRowCount,
visibleStart: 0,
visibleEnd: totalRowCount,
height: canvasHeight,
scrollTop: 0,
scrollLeft: 0,
colVisibleStart: 0,
colVisibleEnd: totalNumberColumns,
colDisplayStart: 0,
colDisplayEnd: totalNumberColumns
};
}
function getRenderedColumnCount(props, getDOMNodeOffsetWidth, displayStart, width) {
var remainingWidth = width && width > 0 ? width : props.columnMetrics.totalWidth;
if (remainingWidth === 0) {
remainingWidth = getDOMNodeOffsetWidth();
}
var columnIndex = displayStart;
var columnCount = 0;
while (remainingWidth > 0) {
var column = _ColumnUtils2['default'].getColumn(props.columnMetrics.columns, columnIndex);
if (!column) {
break;
}
columnCount++;
columnIndex++;
remainingWidth -= column.width;
}
return columnCount;
}
function getVisibleColStart(props, scrollLeft) {
var remainingScroll = scrollLeft;
var columnIndex = -1;
while (remainingScroll >= 0) {
columnIndex++;
remainingScroll -= _ColumnUtils2['default'].getColumn(props.columnMetrics.columns, columnIndex).width;
}
return columnIndex;
}
function getNextScrollState(props, getDOMNodeOffsetWidth, scrollTop, scrollLeft, height, rowHeight, length, width) {
var isScrolling = true;
var renderedRowsCount = ceil(height / rowHeight);
var visibleStart = max(0, floor(scrollTop / rowHeight));
var visibleEnd = min(visibleStart + renderedRowsCount, length);
var displayStart = max(0, visibleStart - props.overScan.rowsStart);
var displayEnd = min(visibleEnd + props.overScan.rowsEnd, length);
var totalNumberColumns = _ColumnUtils2['default'].getSize(props.columnMetrics.columns);
var colVisibleStart = totalNumberColumns > 0 ? max(0, getVisibleColStart(props, scrollLeft)) : 0;
var renderedColumnCount = getRenderedColumnCount(props, getDOMNodeOffsetWidth, colVisibleStart, width);
var colVisibleEnd = renderedColumnCount !== 0 ? colVisibleStart + renderedColumnCount : totalNumberColumns;
var colDisplayStart = max(0, colVisibleStart - props.overScan.colsStart);
var colDisplayEnd = min(colVisibleEnd + props.overScan.colsEnd, totalNumberColumns);
var nextScrollState = {
visibleStart: visibleStart,
visibleEnd: visibleEnd,
displayStart: displayStart,
displayEnd: displayEnd,
height: height,
scrollTop: scrollTop,
scrollLeft: scrollLeft,
colVisibleStart: colVisibleStart,
colVisibleEnd: colVisibleEnd,
colDisplayStart: colDisplayStart,
colDisplayEnd: colDisplayEnd,
isScrolling: isScrolling
};
return nextScrollState;
}
exports.getGridState = getGridState;
exports.getNextScrollState = getNextScrollState;
exports.getRenderedColumnCount = getRenderedColumnCount;
/***/ }),
/* 225 */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(9)();
// imports
// module
exports.push([module.id, ".react-grid-Cell{background-color:#fff;padding-left:8px;padding-right:8px;border-right:1px solid #eee;border-bottom:1px solid #ddd}.react-grid-Cell:focus{outline:2px solid #66afe9;outline-offset:-2px}.react-grid-Cell--locked:focus{z-index:100}.react-grid-Cell:focus .drag-handle{position:absolute;bottom:-5px;right:-4px;background:#66afe9;width:8px;height:8px;border:1px solid #fff;border-right:0;border-bottom:0;z-index:8;cursor:crosshair;cursor:-webkit-grab}.react-grid-Cell:not(.editing) .react-grid-Cell__value{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.react-grid-Cell:not(.editing):not(.rdg-child-cell) .react-grid-Cell__value{position:relative;top:50%;transform:translateY(-50%)}.rdg-child-cell .react-grid-Cell__value{line-height:35px}.react-grid-Cell.readonly{background-color:#000}.react-grid-Cell.copied{background:rgba(0,0,255,.2)!important}.react-grid-Cell--locked:last-of-type{border-right:1px solid #ddd;box-shadow:none}.react-grid-Cell:hover:focus .drag-handle .glyphicon-arrow-down{display:\"block\"}.react-grid-Cell.is-dragged-over-down{border-right:1px dashed #000;border-left:1px dashed #000;border-bottom:1px dashed #000}.react-grid-Cell.is-dragged-over-up{border-right:1px dashed #000;border-left:1px dashed #000;border-top:1px dashed #000}.react-grid-Cell.is-dragged-over-up .drag-handle{top:-5px}.react-grid-Cell:hover{background:#eee}.react-grid-cell .form-control-feedback{color:#a94442;position:absolute;top:0;right:10px;z-index:1000000;display:block;width:34px;height:34px}.react-grid-Cell.was-dragged-over{border-right:1px dashed #000;border-left:1px dashed #000}.react-grid-Cell:hover:focus .drag-handle{position:absolute;bottom:-8px;right:-7px;background:#fff;width:16px;height:16px;border:1px solid #66afe9;z-index:8;cursor:crosshair;cursor:-webkit-grab}.react-grid-Row.row-selected .react-grid-Cell{background-color:#dbecfa}.react-grid-Cell.editing{padding:0;overflow:visible!important}.react-grid-Cell--locked.editing{z-index:100}.react-grid-Cell.editing .has-error input{border:2px solid red!important;border-radius:2px!important}.react-grid-Cell__value ul{margin-top:0;margin-bottom:0;display:inline-block}.react-grid-Cell__value .btn-sm{padding:0}.cell-tooltip{position:relative;display:inline-block}.cell-tooltip .cell-tooltip-text{visibility:hidden;width:150px;background-color:#000;color:#fff;text-align:center;border-radius:6px;padding:5px 0;position:absolute;z-index:1;bottom:-150%;left:50%;margin-left:-60px;opacity:1s}.cell-tooltip:hover .cell-tooltip-text{visibility:visible;opacity:.8}.cell-tooltip .cell-tooltip-text:after{content:\" \";position:absolute;bottom:100%;left:50%;margin-left:-5px;border-width:5px;border-style:solid;border-color:transparent transparent #000}.react-grid-Canvas.opaque .react-grid-Cell.cell-tooltip:hover .cell-tooltip-text{visibility:hidden}.rdg-cell-expand{top:0;right:20px;position:absolute;cursor:pointer}.rdg-child-row-action-cross-last:before,.rdg-child-row-action-cross:before,rdg-child-row-action-cross-last:after,rdg-child-row-action-cross:after{content:\"\";position:absolute;background:grey;height:50%}.rdg-child-row-action-cross:before{left:21px;width:1px;height:35px}.rdg-child-row-action-cross-last:before{left:21px;width:1px}.rdg-child-row-action-cross-last:after,.rdg-child-row-action-cross:after{top:50%;left:20px;height:1px;width:15px;content:\"\";position:absolute;background:grey}.rdg-child-row-action-cross:hover{background:red}.rdg-child-row-btn{position:absolute;cursor:pointer;border:1px solid grey;border-radius:14px;z-index:3;background:#fff}.rdg-child-row-btn div{font-size:12px;text-align:center;line-height:19px;color:grey;height:20px;width:20px;position:absolute;top:60%;left:53%;margin-top:-10px;margin-left:-10px}.rdg-empty-child-row:hover .glyphicon-plus-sign,.rdg-empty-child-row:hover a{color:green}.rdg-child-row-btn .glyphicon-remove-sign:hover{color:red}.last-column .cell-tooltip-text{right:100%;left:0!important}.rdg-cell-action{float:right;height:100%}.rdg-cell-action-last{margin-right:-8px}.rdg-cell-action-button{width:35px;height:100%;text-align:center;position:relative;display:table}.rdg-cell-action-button>span{display:table-cell;vertical-align:middle}.rdg-cell-action-button:hover{background-color:#fff}.rdg-cell-action-button-toggled{background-color:#fff;border-right:1px solid #ccc;border-left:1px solid #ccc}.rdg-cell-action-button-toggled:after{content:\"\";height:1px;position:absolute;bottom:-1px;left:0;right:0;background:inherit;z-index:10001}.rdg-cell-action-menu{position:absolute;top:100%;right:0;z-index:1000;float:left;min-width:160px;padding:5px 0;font-size:14px;text-align:left;list-style:none;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc}.rdg-cell-action-menu>span{display:block;padding:3px 20px;clear:both;font-weight:400;line-height:1.42857143;color:#333;white-space:nowrap}.rdg-cell-action-menu>span:hover{color:#262626;text-decoration:none;background-color:#f5f5f5}", ""]);
// exports
/***/ }),
/* 226 */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(9)();
// imports
// module
exports.push([module.id, ".radio-custom,.react-grid-checkbox{opacity:0;position:absolute}.radio-custom,.radio-custom-label,.react-grid-checkbox,.react-grid-checkbox-label{display:inline-block;vertical-align:middle;cursor:pointer}.radio-custom-label,.react-grid-checkbox-label{position:relative}.radio-custom+.radio-custom-label:before,.react-grid-checkbox+.react-grid-checkbox-label:before{content:\"\";background:#fff;border:2px solid #ddd;display:inline-block;vertical-align:middle;width:20px;height:20px;text-align:center}.react-grid-checkbox:checked+.react-grid-checkbox-label:before{background:#005295;box-shadow:inset 0 0 0 4px #fff}.radio-custom:focus+.radio-custom-label,.react-grid-checkbox:focus+.react-grid-checkbox-label{outline:1px solid #ddd}.react-grid-HeaderCell input[type=checkbox]{z-index:99999}.react-grid-HeaderCell>.react-grid-checkbox-container{padding:0 10px;height:100%}.react-grid-HeaderCell>.react-grid-checkbox-container>.react-grid-checkbox-label{margin:0;position:relative;top:50%;transform:translateY(-50%)}.radio-custom+.radio-custom-label:before{border-radius:50%}.radio-custom:checked+.radio-custom-label:before{background:#ccc;box-shadow:inset 0 0 0 4px #fff}.checkbox-align{text-align:center}", ""]);
// exports
/***/ }),
/* 227 */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(9)();
// imports
// module
exports.push([module.id, ".react-grid-Container{clear:both;margin-top:0;padding:0}.react-grid-Main{background-color:#fff;color:inherit;padding:0;outline:1px solid #e7eaec;clear:both}.react-grid-Grid{border:1px solid #ddd}.react-grid-Canvas,.react-grid-Grid{background-color:#fff}.react-grid-Cell input.editor-main,select.editor-main{display:block;width:100%;height:34px;padding:6px 12px;font-size:14px;line-height:1.42857143;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075);box-shadow:inset 0 1px 1px rgba(0,0,0,.075)}input.editor-main:focus,select.editor-main:focus{border-color:#66afe9;border:2px solid #66afe9;background:#eee;border-radius:4px}.react-grid-Cell input.editor-main::-moz-placeholder,select.editor-main::-moz-placeholder{color:#999;opacity:1}.react-grid-Cell input.editor-main:-ms-input-placeholder,select.editor-main:-ms-input-placeholder{color:#999}.react-grid-Cell input.editor-main::-webkit-input-placeholder,select.editor-main::-webkit-input-placeholder{color:#999}.react-grid-Cell input.editor-main[disabled],.react-grid-Cell input.editor-main[readonly],fieldset[disabled] .react-grid-Cell input.editor-main,fieldset[disabled] select.editor-main,select.editor-main[disabled],select.editor-main[readonly]{cursor:not-allowed;background-color:#eee;opacity:1}textarea.react-grid-Cell input.editor-main,textareaselect.editor-main{height:auto}.react-grid-ScrollShim{z-index:10002}", ""]);
// exports
/***/ }),
/* 228 */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(9)();
// imports
// module
exports.push([module.id, ".react-grid-Header{box-shadow:0 0 4px 0 #ddd;background:#f9f9f9}.react-grid-Header--resizing{cursor:ew-resize}.react-grid-HeaderCell,.react-grid-HeaderRow{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.react-grid-HeaderCell{background:#f9f9f9;padding:8px;font-weight:700;border-right:1px solid #ddd;border-bottom:1px solid #ddd}.react-grid-HeaderCell__value{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;position:relative;top:50%;transform:translateY(-50%)}.react-grid-HeaderCell__resizeHandle:hover{cursor:ew-resize;background:#ddd}.react-grid-HeaderCell--locked:last-of-type{box-shadow:none}.react-grid-HeaderCell--resizing .react-grid-HeaderCell__resizeHandle{background:#ddd}.react-grid-HeaderCell__draggable{cursor:col-resize}.rdg-can-drop>.react-grid-HeaderCell{background:#ececec}.react-grid-HeaderCell .Select{max-height:30px;font-size:12px;font-weight:400}.react-grid-HeaderCell .Select-control{max-height:30px;border:1px solid #ccc;color:#555;border-radius:3px}.react-grid-HeaderCell .is-focused:not(.is-open)>.Select-control{border-color:#66afe9;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6)}.react-grid-HeaderCell .Select-control .Select-placeholder{line-height:20px;color:#999;padding:4px}.react-grid-HeaderCell .Select-control .Select-input{max-height:28px;padding:4px;margin-left:0}.react-grid-HeaderCell .Select-control .Select-input input{padding:0;height:100%}.react-grid-HeaderCell .Select-control .Select-arrow-zone .Select-arrow{border-color:gray transparent transparent;border-width:4px 4px 2.5px}.react-grid-HeaderCell .Select-control .Select-value{padding:4px;line-height:20px!important}.react-grid-HeaderCell .Select--multi .Select-control .Select-value{padding:0;line-height:16px!important;max-height:20px}.react-grid-HeaderCell .Select--multi .Select-control .Select-value .Select-value-icon,.react-grid-HeaderCell .Select--multi .Select-control .Select-value .Select-value-label{max-height:20px}.react-grid-HeaderCell .Select-control .Select-value .Select-value-label{color:#555!important}.react-grid-HeaderCell .Select-menu-outer .Select-option{padding:4px;line-height:20px}.react-grid-HeaderCell .Select-menu-outer .Select-menu .Select-option.is-focused,.react-grid-HeaderCell .Select-menu-outer .Select-menu .Select-option.is-selected{color:#555}", ""]);
// exports
/***/ }),
/* 229 */
/***/ (function(module, exports, __webpack_require__) {
exports = module.exports = __webpack_require__(9)();
// imports
// module
exports.push([module.id, ".react-grid-Row.row-context-menu .react-grid-Cell,.react-grid-Row:hover .react-grid-Cell{background-color:#f9f9f9}.react-grid-Row:hover .rdg-row-index{display:none}.react-grid-Row:hover .rdg-actions-checkbox{display:block}.react-grid-Row:hover .rdg-drag-row-handle{cursor:move;cursor:grab;cursor:-moz-grab;cursor:-webkit-grab;width:12px;height:30px;margin-left:0;background-image:url(\"data:image/svg+xml;base64, PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+Cjxzdmcgd2lkdGg9IjlweCIgaGVpZ2h0PSIyOXB4IiB2aWV3Qm94PSIwIDAgOSAyOSIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KICAgIDwhLS0gR2VuZXJhdG9yOiBTa2V0Y2ggMzkgKDMxNjY3KSAtIGh0dHA6Ly93d3cuYm9oZW1pYW5jb2RpbmcuY29tL3NrZXRjaCAtLT4KICAgIDx0aXRsZT5kcmFnIGljb248L3RpdGxlPgogICAgPGRlc2M+Q3JlYXRlZCB3aXRoIFNrZXRjaC48L2Rlc2M+CiAgICA8ZGVmcz48L2RlZnM+CiAgICA8ZyBpZD0iQWN0dWFsaXNhdGlvbi12MiIgc3Ryb2tlPSJub25lIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPGcgaWQ9IkRlc2t0b3AiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0xNS4wMDAwMDAsIC0yNjIuMDAwMDAwKSIgZmlsbD0iI0Q4RDhEOCI+CiAgICAgICAgICAgIDxnIGlkPSJJbnRlcmFjdGlvbnMiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDE1LjAwMDAwMCwgMjU4LjAwMDAwMCkiPgogICAgICAgICAgICAgICAgPGcgaWQ9IlJvdy1Db250cm9scyIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsIDIuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICAgICAgPGcgaWQ9ImRyYWctaWNvbiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMC4wMDAwMDAsIDIuMDAwMDAwKSI+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSIyIiBjeT0iMiIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSI3IiBjeT0iMiIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSIyIiBjeT0iNyIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSI3IiBjeT0iNyIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSIyIiBjeT0iMTIiIHI9IjIiPjwvY2lyY2xlPgogICAgICAgICAgICAgICAgICAgICAgICA8Y2lyY2xlIGlkPSJPdmFsLTMwIiBjeD0iNyIgY3k9IjEyIiByPSIyIj48L2NpcmNsZT4KICAgICAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBpZD0iT3ZhbC0zMCIgY3g9IjIiIGN5PSIxNyIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSI3IiBjeT0iMTciIHI9IjIiPjwvY2lyY2xlPgogICAgICAgICAgICAgICAgICAgICAgICA8Y2lyY2xlIGlkPSJPdmFsLTMwIiBjeD0iMiIgY3k9IjIyIiByPSIyIj48L2NpcmNsZT4KICAgICAgICAgICAgICAgICAgICAgICAgPGNpcmNsZSBpZD0iT3ZhbC0zMCIgY3g9IjciIGN5PSIyMiIgcj0iMiI+PC9jaXJjbGU+CiAgICAgICAgICAgICAgICAgICAgICAgIDxjaXJjbGUgaWQ9Ik92YWwtMzAiIGN4PSIyIiBjeT0iMjciIHI9IjIiPjwvY2lyY2xlPgogICAgICAgICAgICAgICAgICAgICAgICA8Y2lyY2xlIGlkPSJPdmFsLTMwIiBjeD0iNyIgY3k9IjI3IiByPSIyIj48L2NpcmNsZT4KICAgICAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgICAgICA8L2c+CiAgICAgICAgICAgIDwvZz4KICAgICAgICA8L2c+CiAgICA8L2c+Cjwvc3ZnPg==\");background-repeat:no-repeat}.react-grid-Row.row-selected,.react-grid-Row .row-selected{background-color:#dbecfa}.react-grid-row-group .row-expand-icon:hover{color:#777}.react-grid-row-index{padding:0 18px}.rdg-row-index{display:block;text-align:center}.rdg-row-actions-cell{padding:0}.rdg-actions-checkbox{display:none;text-align:center}.rdg-actions-checkbox.selected{display:block}.rdg-dragging{cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:grabbing}.rdg-dragged-row{border-bottom:1px solid #000}", ""]);
// exports
/***/ }),
/* 230 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule invariant
*/
'use strict';
/**
* 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.
*/
function invariant(condition, format, a, b, c, d, e, f) {
if (false) {
if (format === undefined) {
throw new Error('invariant requires an error message argument');
}
}
if (!condition) {
var error;
if (format === undefined) {
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];
var argIndex = 0;
error = new Error(format.replace(/%s/g, function () {
return args[argIndex++];
}));
error.name = 'Invariant Violation';
}
error.framesToPop = 1; // we don't care about invariant's own frame
throw error;
}
}
module.exports = invariant;
/***/ }),
/* 231 */
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule keyMirror
* @typechecks static-only
*/
'use strict';
var invariant = __webpack_require__(230);
/**
* Constructs an enumeration with keys equal to their value.
*
* For example:
*
* var COLORS = keyMirror({blue: null, red: null});
* var myColor = COLORS.blue;
* var isColorValid = !!COLORS[myColor];
*
* The last line could not be performed if the values of the generated enum were
* not equal to their keys.
*
* Input: {key1: val1, key2: val2}
* Output: {key1: key1, key2: key2}
*
* @param {object} obj
* @return {object}
*/
var keyMirror = function (obj) {
var ret = {};
var key;
!(obj instanceof Object && !Array.isArray(obj)) ? false ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : undefined;
for (key in obj) {
if (!obj.hasOwnProperty(key)) {
continue;
}
ret[key] = key;
}
return ret;
};
module.exports = keyMirror;
/***/ }),
/* 232 */
/***/ (function(module, exports) {
'use strict';
function ToObject(val) {
if (val == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
module.exports = Object.assign || function (target, source) {
var from;
var keys;
var to = ToObject(target);
for (var s = 1; s < arguments.length; s++) {
from = arguments[s];
keys = Object.keys(Object(from));
for (var i = 0; i < keys.length; i++) {
to[keys[i]] = from[keys[i]];
}
}
return to;
};
/***/ })
/******/ ])
});
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment