From 39b6b5702015ae7afb493db7afaf35790fc8a8d7 Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Sat, 12 Aug 2017 17:52:08 +0800 Subject: [PATCH] v1.12.4 --- dist/infinite-tree.js | 1480 +++++++++++++++++++------------------ dist/infinite-tree.min.js | 8 +- package.json | 39 +- 3 files changed, 768 insertions(+), 759 deletions(-) diff --git a/dist/infinite-tree.js b/dist/infinite-tree.js index 0ec26a2..1370ae7 100644 --- a/dist/infinite-tree.js +++ b/dist/infinite-tree.js @@ -1,4 +1,4 @@ -/*! infinite-tree v1.12.3 | (c) 2017 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ +/*! infinite-tree v1.12.4 | (c) 2017 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -17,9 +17,9 @@ return /******/ (function(modules) { // webpackBootstrap /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) +/******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; -/******/ +/******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, @@ -44,9 +44,6 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ -/******/ // identity function for calling harmony imports with the correct context -/******/ __webpack_require__.i = function(value) { return value; }; -/******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { @@ -74,7 +71,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 7); +/******/ return __webpack_require__(__webpack_require__.s = 4); /******/ }) /************************************************************************/ /******/ ([ @@ -136,91 +133,6 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! /* 1 */ /***/ (function(module, exports, __webpack_require__) { -"use strict"; -/*! - * escape-html - * Copyright(c) 2012-2013 TJ Holowaychuk - * Copyright(c) 2015 Andreas Lubbe - * Copyright(c) 2015 Tiancheng "Timothy" Gu - * MIT Licensed - */ - - - -/** - * Module variables. - * @private - */ - -var matchHtmlRegExp = /["'&<>]/; - -/** - * Module exports. - * @public - */ - -module.exports = escapeHtml; - -/** - * Escape special characters in the given string of html. - * - * @param {string} string The string to escape for inserting into HTML - * @return {string} - * @public - */ - -function escapeHtml(string) { - var str = '' + string; - var match = matchHtmlRegExp.exec(str); - - if (!match) { - return str; - } - - var escape; - var html = ''; - var index = 0; - var lastIndex = 0; - - for (index = match.index; index < str.length; index++) { - switch (str.charCodeAt(index)) { - case 34: // " - escape = '"'; - break; - case 38: // & - escape = '&'; - break; - case 39: // ' - escape = '''; - break; - case 60: // < - escape = '<'; - break; - case 62: // > - escape = '>'; - break; - default: - continue; - } - - if (lastIndex !== index) { - html += str.substring(lastIndex, index); - } - - lastIndex = index + 1; - html += escape; - } - - return lastIndex !== index - ? html + str.substring(lastIndex, index) - : html; -} - - -/***/ }), -/* 2 */ -/***/ (function(module, exports, __webpack_require__) { - "use strict"; @@ -252,7 +164,7 @@ var extend = function extend(target) { exports['default'] = extend; /***/ }), -/* 3 */ +/* 2 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -260,7 +172,7 @@ exports['default'] = extend; exports.__esModule = true; -var _extend = __webpack_require__(2); +var _extend = __webpack_require__(1); var _extend2 = _interopRequireDefault(_extend); @@ -392,6 +304,91 @@ var Node = function () { exports['default'] = Node; +/***/ }), +/* 3 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +/*! + * escape-html + * Copyright(c) 2012-2013 TJ Holowaychuk + * Copyright(c) 2015 Andreas Lubbe + * Copyright(c) 2015 Tiancheng "Timothy" Gu + * MIT Licensed + */ + + + +/** + * Module variables. + * @private + */ + +var matchHtmlRegExp = /["'&<>]/; + +/** + * Module exports. + * @public + */ + +module.exports = escapeHtml; + +/** + * Escape special characters in the given string of html. + * + * @param {string} string The string to escape for inserting into HTML + * @return {string} + * @public + */ + +function escapeHtml(string) { + var str = '' + string; + var match = matchHtmlRegExp.exec(str); + + if (!match) { + return str; + } + + var escape; + var html = ''; + var index = 0; + var lastIndex = 0; + + for (index = match.index; index < str.length; index++) { + switch (str.charCodeAt(index)) { + case 34: // " + escape = '"'; + break; + case 38: // & + escape = '&'; + break; + case 39: // ' + escape = '''; + break; + case 60: // < + escape = '<'; + break; + case 62: // > + escape = '>'; + break; + default: + continue; + } + + if (lastIndex !== index) { + html += str.substring(lastIndex, index); + } + + lastIndex = index + 1; + html += escape; + } + + return lastIndex !== index + ? html + str.substring(lastIndex, index) + : html; +} + + /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { @@ -399,13 +396,28 @@ exports['default'] = Node; "use strict"; +var _infiniteTree = __webpack_require__(5); + +var _infiniteTree2 = _interopRequireDefault(_infiniteTree); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + +module.exports = _infiniteTree2['default']; + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + exports.__esModule = true; 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 _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 _events = __webpack_require__(13); +var _events = __webpack_require__(6); var _events2 = _interopRequireDefault(_events); @@ -413,33 +425,33 @@ var _classnames = __webpack_require__(0); var _classnames2 = _interopRequireDefault(_classnames); -var _clusterize = __webpack_require__(11); +var _clusterize = __webpack_require__(7); var _clusterize2 = _interopRequireDefault(_clusterize); -var _elementClass = __webpack_require__(12); +var _elementClass = __webpack_require__(8); var _elementClass2 = _interopRequireDefault(_elementClass); -var _isDom = __webpack_require__(17); +var _isDom = __webpack_require__(9); var _isDom2 = _interopRequireDefault(_isDom); -var _flattree = __webpack_require__(15); +var _flattree = __webpack_require__(10); -var _ensureArray = __webpack_require__(6); +var _ensureArray = __webpack_require__(12); var _ensureArray2 = _interopRequireDefault(_ensureArray); -var _utilities = __webpack_require__(10); +var _utilities = __webpack_require__(13); -var _lookupTable = __webpack_require__(8); +var _lookupTable = __webpack_require__(14); var _lookupTable2 = _interopRequireDefault(_lookupTable); -var _renderer = __webpack_require__(9); +var _renderer = __webpack_require__(15); -var _domEvents = __webpack_require__(5); +var _domEvents = __webpack_require__(17); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } @@ -449,7 +461,6 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen 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 no-continue: 0 */ /* eslint operator-assignment: 0 */ -/* eslint prefer-spread: 0 */ var noop = function noop() {}; @@ -1492,6 +1503,8 @@ var InfiniteTree = function (_events$EventEmitter) { // Do a setTimeout to prevent the CPU intensive task setTimeout(function () { _this6.options.loadNodes(node, function (err, nodes) { + var done = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : noop; + nodes = (0, _ensureArray2['default'])(nodes); if (err || nodes.length === 0) { @@ -1501,6 +1514,10 @@ var InfiniteTree = function (_events$EventEmitter) { _this6.rows[nodeIndex] = _this6.options.rowRenderer(node, _this6.options); // Update list _this6.update(); + + if (typeof done === 'function') { + done(); + } return; } @@ -1518,6 +1535,10 @@ var InfiniteTree = function (_events$EventEmitter) { _this6.rows[nodeIndex] = _this6.options.rowRenderer(node, _this6.options); // Update list _this6.update(); + + if (typeof done === 'function') { + done(); + } } })); } else { @@ -1527,6 +1548,10 @@ var InfiniteTree = function (_events$EventEmitter) { _this6.rows[nodeIndex] = _this6.options.rowRenderer(node, _this6.options); // Update list _this6.update(); + + if (typeof done === 'function') { + done(); + } } }); }, 0); @@ -2170,300 +2195,315 @@ var InfiniteTree = function (_events$EventEmitter) { exports['default'] = InfiniteTree; /***/ }), -/* 5 */ -/***/ (function(module, exports, __webpack_require__) { +/* 6 */ +/***/ (function(module, exports) { -"use strict"; +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +function EventEmitter() { + this._events = this._events || {}; + this._maxListeners = this._maxListeners || undefined; +} +module.exports = EventEmitter; +// Backwards-compat with node 0.10.x +EventEmitter.EventEmitter = EventEmitter; -exports.__esModule = true; -var preventDefault = function preventDefault(e) { - if (typeof e.preventDefault !== 'undefined') { - e.preventDefault(); - } else { - e.returnValue = false; - } -}; +EventEmitter.prototype._events = undefined; +EventEmitter.prototype._maxListeners = undefined; -var stopPropagation = function stopPropagation(e) { - if (typeof e.stopPropagation !== 'undefined') { - e.stopPropagation(); - } else { - e.cancelBubble = true; - } +// By default EventEmitters will print a warning if more than 10 listeners are +// added to it. This is a useful default which helps finding memory leaks. +EventEmitter.defaultMaxListeners = 10; + +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +EventEmitter.prototype.setMaxListeners = function(n) { + if (!isNumber(n) || n < 0 || isNaN(n)) + throw TypeError('n must be a positive number'); + this._maxListeners = n; + return this; }; -// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Compatibility -var addEventListener = function addEventListener(target, type, listener) { - if (target.addEventListener) { - // Standard - target.addEventListener(type, listener, false); - } else if (target.attachEvent) { - // IE8 - // In Internet Explorer versions before IE 9, you have to use attachEvent rather than the standard addEventListener. - target.attachEvent('on' + type, listener); - } -}; - -// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener -var removeEventListener = function removeEventListener(target, type, listener) { - if (target.removeEventListener) { - // Standard - target.removeEventListener(type, listener, false); - } else if (target.detachEvent) { - // IE8 - // In Internet Explorer versions before IE 9, you have to use detachEvent rather than the standard removeEventListener. - target.detachEvent('on' + type, listener); - } -}; +EventEmitter.prototype.emit = function(type) { + var er, handler, len, args, i, listeners; -exports.preventDefault = preventDefault; -exports.stopPropagation = stopPropagation; -exports.addEventListener = addEventListener; -exports.removeEventListener = removeEventListener; + if (!this._events) + this._events = {}; -/***/ }), -/* 6 */ -/***/ (function(module, exports, __webpack_require__) { + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events.error || + (isObject(this._events.error) && !this._events.error.length)) { + er = arguments[1]; + if (er instanceof Error) { + throw er; // Unhandled 'error' event + } else { + // At least give some kind of context to the user + var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); + err.context = er; + throw err; + } + } + } -"use strict"; + handler = this._events[type]; + if (isUndefined(handler)) + return false; -exports.__esModule = true; -var ensureArray = function ensureArray() { - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; + if (isFunction(handler)) { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); } + } else if (isObject(handler)) { + args = Array.prototype.slice.call(arguments, 1); + listeners = handler.slice(); + len = listeners.length; + for (i = 0; i < len; i++) + listeners[i].apply(this, args); + } - if (args.length === 0 || args[0] === undefined || args[0] === null) { - return []; - } - if (args.length === 1) { - return [].concat(args[0]); - } - return [].concat(args); + return true; }; -exports["default"] = ensureArray; - -/***/ }), -/* 7 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; - - -var _infiniteTree = __webpack_require__(4); - -var _infiniteTree2 = _interopRequireDefault(_infiniteTree); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } - -module.exports = _infiniteTree2['default']; - -/***/ }), -/* 8 */ -/***/ (function(module, exports, __webpack_require__) { - -"use strict"; +EventEmitter.prototype.addListener = function(type, listener) { + var m; + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -exports.__esModule = true; + if (!this._events) + this._events = {}; -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + // To avoid recursion in the case that type === "newListener"! Before + // adding it to the listeners, first emit "newListener". + if (this._events.newListener) + this.emit('newListener', type, + isFunction(listener.listener) ? + listener.listener : listener); -var LookupTable = function () { - function LookupTable() { - _classCallCheck(this, LookupTable); + if (!this._events[type]) + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + else if (isObject(this._events[type])) + // If we've already got an array, just append. + this._events[type].push(listener); + else + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; - this.data = {}; + // Check for listener leak + if (isObject(this._events[type]) && !this._events[type].warned) { + if (!isUndefined(this._maxListeners)) { + m = this._maxListeners; + } else { + m = EventEmitter.defaultMaxListeners; } - LookupTable.prototype.clear = function clear() { - this.data = {}; - }; - - LookupTable.prototype.get = function get(key) { - return this.data[key]; - }; - - LookupTable.prototype.has = function has(key) { - return this.data[key] !== undefined; - }; - - LookupTable.prototype.set = function set(key, value) { - this.data[key] = value; - return value; - }; - - LookupTable.prototype.unset = function unset(key) { - if (this.data[key] !== undefined) { - delete this.data[key]; - } - }; - - return LookupTable; -}(); + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + if (typeof console.trace === 'function') { + // not supported in IE 10 + console.trace(); + } + } + } -exports["default"] = LookupTable; + return this; +}; -/***/ }), -/* 9 */ -/***/ (function(module, exports, __webpack_require__) { +EventEmitter.prototype.on = EventEmitter.prototype.addListener; -"use strict"; +EventEmitter.prototype.once = function(type, listener) { + if (!isFunction(listener)) + throw TypeError('listener must be a function'); + var fired = false; -exports.__esModule = true; -exports.defaultRowRenderer = undefined; + function g() { + this.removeListener(type, g); -var _classnames = __webpack_require__(0); + if (!fired) { + fired = true; + listener.apply(this, arguments); + } + } -var _classnames2 = _interopRequireDefault(_classnames); + g.listener = listener; + this.on(type, g); -var _escapeHtml = __webpack_require__(1); + return this; +}; -var _escapeHtml2 = _interopRequireDefault(_escapeHtml); +// emits a 'removeListener' event iff the listener was removed +EventEmitter.prototype.removeListener = function(type, listener) { + var list, position, length, i; -var _html5Tag = __webpack_require__(16); + if (!isFunction(listener)) + throw TypeError('listener must be a function'); -var _html5Tag2 = _interopRequireDefault(_html5Tag); + if (!this._events || !this._events[type]) + return this; -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } + list = this._events[type]; + length = list.length; + position = -1; -var defaultRowRenderer = function defaultRowRenderer(node, treeOptions) { - var id = node.id, - name = node.name, - _node$loadOnDemand = node.loadOnDemand, - loadOnDemand = _node$loadOnDemand === undefined ? false : _node$loadOnDemand, - children = node.children, - state = node.state; + if (list === listener || + (isFunction(list.listener) && list.listener === listener)) { + delete this._events[type]; + if (this._events.removeListener) + this.emit('removeListener', type, listener); - var droppable = treeOptions.droppable; - var depth = state.depth, - open = state.open, - path = state.path, - total = state.total, - _state$selected = state.selected, - selected = _state$selected === undefined ? false : _state$selected, - filtered = state.filtered; + } else if (isObject(list)) { + for (i = length; i-- > 0;) { + if (list[i] === listener || + (list[i].listener && list[i].listener === listener)) { + position = i; + break; + } + } - var childrenLength = Object.keys(children).length; - var more = node.hasChildren(); + if (position < 0) + return this; - if (filtered === false) { - return ''; + if (list.length === 1) { + list.length = 0; + delete this._events[type]; + } else { + list.splice(position, 1); } - var togglerContent = ''; - if (!more && loadOnDemand) { - togglerContent = '►'; - } - if (more && open) { - togglerContent = '▼'; - } - if (more && !open) { - togglerContent = '►'; - } - var toggler = (0, _html5Tag2['default'])('a', { - 'class': function () { - if (!more && loadOnDemand) { - return (0, _classnames2['default'])(treeOptions.togglerClass, 'infinite-tree-closed'); - } - if (more && open) { - return (0, _classnames2['default'])(treeOptions.togglerClass); - } - if (more && !open) { - return (0, _classnames2['default'])(treeOptions.togglerClass, 'infinite-tree-closed'); - } - return ''; - }() - }, togglerContent); - var title = (0, _html5Tag2['default'])('span', { - 'class': (0, _classnames2['default'])('infinite-tree-title') - }, (0, _escapeHtml2['default'])(name)); - var treeNode = (0, _html5Tag2['default'])('div', { - 'class': 'infinite-tree-node', - 'style': 'margin-left: ' + depth * 18 + 'px' - }, toggler + title); + if (this._events.removeListener) + this.emit('removeListener', type, listener); + } - return (0, _html5Tag2['default'])('div', { - 'data-id': id, - 'data-expanded': more && open, - 'data-depth': depth, - 'data-path': path, - 'data-selected': selected, - 'data-children': childrenLength, - 'data-total': total, - 'class': (0, _classnames2['default'])('infinite-tree-item', { 'infinite-tree-selected': selected }), - 'droppable': droppable - }, treeNode); -}; /* eslint import/prefer-default-export: 0 */ -exports.defaultRowRenderer = defaultRowRenderer; + return this; +}; -/***/ }), -/* 10 */ -/***/ (function(module, exports, __webpack_require__) { +EventEmitter.prototype.removeAllListeners = function(type) { + var key, listeners; -"use strict"; + if (!this._events) + return this; + // not listening for removeListener, no need to emit + if (!this._events.removeListener) { + if (arguments.length === 0) + this._events = {}; + else if (this._events[type]) + delete this._events[type]; + return this; + } -exports.__esModule = true; + // emit removeListener for all listeners on all events + if (arguments.length === 0) { + for (key in this._events) { + if (key === 'removeListener') continue; + this.removeAllListeners(key); + } + this.removeAllListeners('removeListener'); + this._events = {}; + return this; + } -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; }; + listeners = this._events[type]; -var trim = exports.trim = function trim(str) { - var chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' \f\n\r\t\v'; + if (isFunction(listeners)) { + this.removeListener(type, listeners); + } else if (listeners) { + // LIFO order + while (listeners.length) + this.removeListener(type, listeners[listeners.length - 1]); + } + delete this._events[type]; - while (chars.indexOf(str[0]) >= 0) { - str = str.slice(1); - } - while (chars.indexOf(str[str.length - 1]) >= 0) { - str = str.slice(0, -1); - } - return str; + return this; }; -var get = exports.get = function () { - var re = new RegExp(/[\w\-]+|\[[^\]]*\]+/g); +EventEmitter.prototype.listeners = function(type) { + var ret; + if (!this._events || !this._events[type]) + ret = []; + else if (isFunction(this._events[type])) + ret = [this._events[type]]; + else + ret = this._events[type].slice(); + return ret; +}; - return function (object, path, defaultValue) { - if (!object || (typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') { - return defaultValue; - } +EventEmitter.prototype.listenerCount = function(type) { + if (this._events) { + var evlistener = this._events[type]; - path = '' + path; + if (isFunction(evlistener)) + return 1; + else if (evlistener) + return evlistener.length; + } + return 0; +}; - var keys = path.match(re); - if (!keys) { - return defaultValue; - } +EventEmitter.listenerCount = function(emitter, type) { + return emitter.listenerCount(type); +}; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - key = trim(key, ' \f\n\r\t\v'); - if (key[0] === '[') { - key = trim(key.slice(1, -1), ' \f\n\r\t\v'); - } - key = trim(key, '\'"'); +function isFunction(arg) { + return typeof arg === 'function'; +} - if (object === undefined || object === null || (typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') { - break; - } +function isNumber(arg) { + return typeof arg === 'number'; +} - object = object[key]; +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} - if (object === undefined) { - break; - } - } +function isUndefined(arg) { + return arg === void 0; +} - return object !== undefined ? object : defaultValue; - }; -}(); /***/ }), -/* 11 */ +/* 7 */ /***/ (function(module, exports, __webpack_require__) { /*! Clusterize.js - v0.17.6 - 2017-03-05 @@ -2797,7 +2837,7 @@ var get = exports.get = function () { })); /***/ }), -/* 12 */ +/* 8 */ /***/ (function(module, exports) { module.exports = function(opts) { @@ -2862,315 +2902,47 @@ ElementClass.prototype.toggle = function(className) { /***/ }), -/* 13 */ +/* 9 */ /***/ (function(module, exports) { -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -function EventEmitter() { - this._events = this._events || {}; - this._maxListeners = this._maxListeners || undefined; -} -module.exports = EventEmitter; - -// Backwards-compat with node 0.10.x -EventEmitter.EventEmitter = EventEmitter; - -EventEmitter.prototype._events = undefined; -EventEmitter.prototype._maxListeners = undefined; - -// By default EventEmitters will print a warning if more than 10 listeners are -// added to it. This is a useful default which helps finding memory leaks. -EventEmitter.defaultMaxListeners = 10; - -// Obviously not all Emitters should be limited to 10. This function allows -// that to be increased. Set to zero for unlimited. -EventEmitter.prototype.setMaxListeners = function(n) { - if (!isNumber(n) || n < 0 || isNaN(n)) - throw TypeError('n must be a positive number'); - this._maxListeners = n; - return this; -}; - -EventEmitter.prototype.emit = function(type) { - var er, handler, len, args, i, listeners; - - if (!this._events) - this._events = {}; - - // If there is no 'error' event listener then throw. - if (type === 'error') { - if (!this._events.error || - (isObject(this._events.error) && !this._events.error.length)) { - er = arguments[1]; - if (er instanceof Error) { - throw er; // Unhandled 'error' event - } else { - // At least give some kind of context to the user - var err = new Error('Uncaught, unspecified "error" event. (' + er + ')'); - err.context = er; - throw err; - } - } - } - - handler = this._events[type]; - - if (isUndefined(handler)) - return false; - - if (isFunction(handler)) { - switch (arguments.length) { - // fast cases - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - // slower - default: - args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - } else if (isObject(handler)) { - args = Array.prototype.slice.call(arguments, 1); - listeners = handler.slice(); - len = listeners.length; - for (i = 0; i < len; i++) - listeners[i].apply(this, args); - } - - return true; -}; - -EventEmitter.prototype.addListener = function(type, listener) { - var m; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events) - this._events = {}; - - // To avoid recursion in the case that type === "newListener"! Before - // adding it to the listeners, first emit "newListener". - if (this._events.newListener) - this.emit('newListener', type, - isFunction(listener.listener) ? - listener.listener : listener); - - if (!this._events[type]) - // Optimize the case of one listener. Don't need the extra array object. - this._events[type] = listener; - else if (isObject(this._events[type])) - // If we've already got an array, just append. - this._events[type].push(listener); - else - // Adding the second element, need to change to array. - this._events[type] = [this._events[type], listener]; - - // Check for listener leak - if (isObject(this._events[type]) && !this._events[type].warned) { - if (!isUndefined(this._maxListeners)) { - m = this._maxListeners; - } else { - m = EventEmitter.defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - if (typeof console.trace === 'function') { - // not supported in IE 10 - console.trace(); - } - } - } - - return this; -}; - -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - var fired = false; - - function g() { - this.removeListener(type, g); - - if (!fired) { - fired = true; - listener.apply(this, arguments); - } - } - - g.listener = listener; - this.on(type, g); - - return this; -}; - -// emits a 'removeListener' event iff the listener was removed -EventEmitter.prototype.removeListener = function(type, listener) { - var list, position, length, i; - - if (!isFunction(listener)) - throw TypeError('listener must be a function'); - - if (!this._events || !this._events[type]) - return this; - - list = this._events[type]; - length = list.length; - position = -1; - - if (list === listener || - (isFunction(list.listener) && list.listener === listener)) { - delete this._events[type]; - if (this._events.removeListener) - this.emit('removeListener', type, listener); - - } else if (isObject(list)) { - for (i = length; i-- > 0;) { - if (list[i] === listener || - (list[i].listener && list[i].listener === listener)) { - position = i; - break; - } - } - - if (position < 0) - return this; - - if (list.length === 1) { - list.length = 0; - delete this._events[type]; - } else { - list.splice(position, 1); - } - - if (this._events.removeListener) - this.emit('removeListener', type, listener); - } - - return this; -}; - -EventEmitter.prototype.removeAllListeners = function(type) { - var key, listeners; - - if (!this._events) - return this; - - // not listening for removeListener, no need to emit - if (!this._events.removeListener) { - if (arguments.length === 0) - this._events = {}; - else if (this._events[type]) - delete this._events[type]; - return this; - } - - // emit removeListener for all listeners on all events - if (arguments.length === 0) { - for (key in this._events) { - if (key === 'removeListener') continue; - this.removeAllListeners(key); - } - this.removeAllListeners('removeListener'); - this._events = {}; - return this; - } +module.exports = isNode - listeners = this._events[type]; +function isNode (val) { + return (!val || typeof val !== 'object') + ? false + : (typeof window === 'object' && typeof window.Node === 'object') + ? (val instanceof window.Node) + : (typeof val.nodeType === 'number') && + (typeof val.nodeName === 'string') +} - if (isFunction(listeners)) { - this.removeListener(type, listeners); - } else if (listeners) { - // LIFO order - while (listeners.length) - this.removeListener(type, listeners[listeners.length - 1]); - } - delete this._events[type]; - return this; -}; +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { -EventEmitter.prototype.listeners = function(type) { - var ret; - if (!this._events || !this._events[type]) - ret = []; - else if (isFunction(this._events[type])) - ret = [this._events[type]]; - else - ret = this._events[type].slice(); - return ret; -}; +"use strict"; -EventEmitter.prototype.listenerCount = function(type) { - if (this._events) { - var evlistener = this._events[type]; - if (isFunction(evlistener)) - return 1; - else if (evlistener) - return evlistener.length; - } - return 0; -}; +exports.__esModule = true; +exports.Node = exports.flatten = undefined; -EventEmitter.listenerCount = function(emitter, type) { - return emitter.listenerCount(type); -}; +var _flatten = __webpack_require__(11); -function isFunction(arg) { - return typeof arg === 'function'; -} +var _flatten2 = _interopRequireDefault(_flatten); -function isNumber(arg) { - return typeof arg === 'number'; -} +var _node = __webpack_require__(2); -function isObject(arg) { - return typeof arg === 'object' && arg !== null; -} +var _node2 = _interopRequireDefault(_node); -function isUndefined(arg) { - return arg === void 0; -} +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } +// IE8 compatibility output +exports.flatten = _flatten2['default']; +exports.Node = _node2['default']; /***/ }), -/* 14 */ +/* 11 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -3178,11 +2950,11 @@ function isUndefined(arg) { exports.__esModule = true; -var _extend = __webpack_require__(2); +var _extend = __webpack_require__(1); var _extend2 = _interopRequireDefault(_extend); -var _node = __webpack_require__(3); +var _node = __webpack_require__(2); var _node2 = _interopRequireDefault(_node); @@ -3277,102 +3049,233 @@ var flatten = function flatten() { node.parent = current; node.children = node.children || []; - // Ensure parent.children[index] is equal to the current node - node.parent.children[index] = node; + // Ensure parent.children[index] is equal to the current node + node.parent.children[index] = node; + + var path = current.state.path + '.' + index; + var open = node.hasChildren() && function () { + var openAllNodes = options.openAllNodes, + openNodes = options.openNodes; + + if (openAllNodes) { + return true; + } + // determine by node object + if (openNodes.indexOf(node) >= 0) { + return true; + } + // determine by node id + if (openNodes.indexOf(node.id) >= 0) { + return true; + } + return false; + }(); + var prefixMask = function (prefix) { + var mask = ''; + while (prefix.length > 0) { + prefix = prefix.replace(/\.\d+$/, ''); + if (!prefix || pool.lastChild[prefix]) { + mask = '0' + mask; + } else { + mask = '1' + mask; + } + } + return mask; + }(path); + + if (node.isLastChild()) { + pool.lastChild[path] = true; + } + + // This allows you to put extra information to node.state + node.state = (0, _extend2['default'])({}, node.state, { + depth: depth + 1, + open: open, + path: path, + prefixMask: prefixMask, + total: 0 + }); + + var parentDidOpen = true; + + { + // Check the open state from its ancestors + var _p = node; + while (_p.parent !== null) { + if (_p.parent.state.open === false) { + parentDidOpen = false; + break; + } + _p = _p.parent; + } + } + + if (parentDidOpen) { + // Push the node to flatten list only if all of its parent nodes have the open state set to true + flatten.push(node); + + // Update the total number of visible child nodes + var _p2 = node; + while (_p2.parent !== null) { + _p2.parent.state.total++; + _p2 = _p2.parent; + } + } + + ++index; + + if (node.hasChildren()) { + // Push back parent node to the stack that will be able to continue + // the next iteration once all the child nodes of the current node + // have been completely explored. + stack.push([current, depth, index]); + + index = 0; + depth = depth + 1; + current = node; + } + }; + + while (index < current.children.length) { + _loop(); + } + } + + return flatten; +}; + +exports['default'] = flatten; + +/***/ }), +/* 12 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; +var ensureArray = function ensureArray() { + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (args.length === 0 || args[0] === undefined || args[0] === null) { + return []; + } + if (args.length === 1) { + return [].concat(args[0]); + } + return [].concat(args); +}; + +exports["default"] = ensureArray; + +/***/ }), +/* 13 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +exports.__esModule = true; + +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 trim = exports.trim = function trim(str) { + var chars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ' \f\n\r\t\v'; + + while (chars.indexOf(str[0]) >= 0) { + str = str.slice(1); + } + while (chars.indexOf(str[str.length - 1]) >= 0) { + str = str.slice(0, -1); + } + return str; +}; + +var get = exports.get = function () { + var re = new RegExp(/[\w\-]+|\[[^\]]*\]+/g); + + return function (object, path, defaultValue) { + if (!object || (typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') { + return defaultValue; + } + + path = '' + path; + + var keys = path.match(re); + if (!keys) { + return defaultValue; + } + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + key = trim(key, ' \f\n\r\t\v'); + if (key[0] === '[') { + key = trim(key.slice(1, -1), ' \f\n\r\t\v'); + } + key = trim(key, '\'"'); + + if (object === undefined || object === null || (typeof object === 'undefined' ? 'undefined' : _typeof(object)) !== 'object') { + break; + } + + object = object[key]; + + if (object === undefined) { + break; + } + } + + return object !== undefined ? object : defaultValue; + }; +}(); - var path = current.state.path + '.' + index; - var open = node.hasChildren() && function () { - var openAllNodes = options.openAllNodes, - openNodes = options.openNodes; +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { - if (openAllNodes) { - return true; - } - // determine by node object - if (openNodes.indexOf(node) >= 0) { - return true; - } - // determine by node id - if (openNodes.indexOf(node.id) >= 0) { - return true; - } - return false; - }(); - var prefixMask = function (prefix) { - var mask = ''; - while (prefix.length > 0) { - prefix = prefix.replace(/\.\d+$/, ''); - if (!prefix || pool.lastChild[prefix]) { - mask = '0' + mask; - } else { - mask = '1' + mask; - } - } - return mask; - }(path); +"use strict"; - if (node.isLastChild()) { - pool.lastChild[path] = true; - } - // This allows you to put extra information to node.state - node.state = (0, _extend2['default'])({}, node.state, { - depth: depth + 1, - open: open, - path: path, - prefixMask: prefixMask, - total: 0 - }); +exports.__esModule = true; - var parentDidOpen = true; +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - { - // Check the open state from its ancestors - var _p = node; - while (_p.parent !== null) { - if (_p.parent.state.open === false) { - parentDidOpen = false; - break; - } - _p = _p.parent; - } - } +var LookupTable = function () { + function LookupTable() { + _classCallCheck(this, LookupTable); - if (parentDidOpen) { - // Push the node to flatten list only if all of its parent nodes have the open state set to true - flatten.push(node); + this.data = {}; + } - // Update the total number of visible child nodes - var _p2 = node; - while (_p2.parent !== null) { - _p2.parent.state.total++; - _p2 = _p2.parent; - } - } + LookupTable.prototype.clear = function clear() { + this.data = {}; + }; - ++index; + LookupTable.prototype.get = function get(key) { + return this.data[key]; + }; - if (node.hasChildren()) { - // Push back parent node to the stack that will be able to continue - // the next iteration once all the child nodes of the current node - // have been completely explored. - stack.push([current, depth, index]); + LookupTable.prototype.has = function has(key) { + return this.data[key] !== undefined; + }; - index = 0; - depth = depth + 1; - current = node; - } - }; + LookupTable.prototype.set = function set(key, value) { + this.data[key] = value; + return value; + }; - while (index < current.children.length) { - _loop(); + LookupTable.prototype.unset = function unset(key) { + if (this.data[key] !== undefined) { + delete this.data[key]; } - } + }; - return flatten; -}; + return LookupTable; +}(); -exports['default'] = flatten; +exports["default"] = LookupTable; /***/ }), /* 15 */ @@ -3382,21 +3285,91 @@ exports['default'] = flatten; exports.__esModule = true; -exports.Node = exports.flatten = undefined; +exports.defaultRowRenderer = undefined; -var _flatten = __webpack_require__(14); +var _classnames = __webpack_require__(0); -var _flatten2 = _interopRequireDefault(_flatten); +var _classnames2 = _interopRequireDefault(_classnames); -var _node = __webpack_require__(3); +var _escapeHtml = __webpack_require__(3); -var _node2 = _interopRequireDefault(_node); +var _escapeHtml2 = _interopRequireDefault(_escapeHtml); + +var _html5Tag = __webpack_require__(16); + +var _html5Tag2 = _interopRequireDefault(_html5Tag); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } -// IE8 compatibility output -exports.flatten = _flatten2['default']; -exports.Node = _node2['default']; +var defaultRowRenderer = function defaultRowRenderer(node, treeOptions) { + var id = node.id, + name = node.name, + _node$loadOnDemand = node.loadOnDemand, + loadOnDemand = _node$loadOnDemand === undefined ? false : _node$loadOnDemand, + children = node.children, + state = node.state; + + var droppable = treeOptions.droppable; + var depth = state.depth, + open = state.open, + path = state.path, + total = state.total, + _state$selected = state.selected, + selected = _state$selected === undefined ? false : _state$selected, + filtered = state.filtered; + + var childrenLength = Object.keys(children).length; + var more = node.hasChildren(); + + if (filtered === false) { + return ''; + } + + var togglerContent = ''; + if (!more && loadOnDemand) { + togglerContent = '►'; + } + if (more && open) { + togglerContent = '▼'; + } + if (more && !open) { + togglerContent = '►'; + } + var toggler = (0, _html5Tag2['default'])('a', { + 'class': function () { + if (!more && loadOnDemand) { + return (0, _classnames2['default'])(treeOptions.togglerClass, 'infinite-tree-closed'); + } + if (more && open) { + return (0, _classnames2['default'])(treeOptions.togglerClass); + } + if (more && !open) { + return (0, _classnames2['default'])(treeOptions.togglerClass, 'infinite-tree-closed'); + } + return ''; + }() + }, togglerContent); + var title = (0, _html5Tag2['default'])('span', { + 'class': (0, _classnames2['default'])('infinite-tree-title') + }, (0, _escapeHtml2['default'])(name)); + var treeNode = (0, _html5Tag2['default'])('div', { + 'class': 'infinite-tree-node', + 'style': 'margin-left: ' + depth * 18 + 'px' + }, toggler + title); + + return (0, _html5Tag2['default'])('div', { + 'data-id': id, + 'data-expanded': more && open, + 'data-depth': depth, + 'data-path': path, + 'data-selected': selected, + 'data-children': childrenLength, + 'data-total': total, + 'class': (0, _classnames2['default'])('infinite-tree-item', { 'infinite-tree-selected': selected }), + 'droppable': droppable + }, treeNode); +}; /* eslint import/prefer-default-export: 0 */ +exports.defaultRowRenderer = defaultRowRenderer; /***/ }), /* 16 */ @@ -3409,7 +3382,7 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; -var _escapeHtml = __webpack_require__(1); +var _escapeHtml = __webpack_require__(3); var _escapeHtml2 = _interopRequireDefault(_escapeHtml); @@ -3456,19 +3429,56 @@ module.exports = function (tag, attrs, text) { /***/ }), /* 17 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { -module.exports = isNode +"use strict"; -function isNode (val) { - return (!val || typeof val !== 'object') - ? false - : (typeof window === 'object' && typeof window.Node === 'object') - ? (val instanceof window.Node) - : (typeof val.nodeType === 'number') && - (typeof val.nodeName === 'string') -} +exports.__esModule = true; +var preventDefault = function preventDefault(e) { + if (typeof e.preventDefault !== 'undefined') { + e.preventDefault(); + } else { + e.returnValue = false; + } +}; + +var stopPropagation = function stopPropagation(e) { + if (typeof e.stopPropagation !== 'undefined') { + e.stopPropagation(); + } else { + e.cancelBubble = true; + } +}; + +// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Compatibility +var addEventListener = function addEventListener(target, type, listener) { + if (target.addEventListener) { + // Standard + target.addEventListener(type, listener, false); + } else if (target.attachEvent) { + // IE8 + // In Internet Explorer versions before IE 9, you have to use attachEvent rather than the standard addEventListener. + target.attachEvent('on' + type, listener); + } +}; + +// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/removeEventListener +var removeEventListener = function removeEventListener(target, type, listener) { + if (target.removeEventListener) { + // Standard + target.removeEventListener(type, listener, false); + } else if (target.detachEvent) { + // IE8 + // In Internet Explorer versions before IE 9, you have to use detachEvent rather than the standard removeEventListener. + target.detachEvent('on' + type, listener); + } +}; + +exports.preventDefault = preventDefault; +exports.stopPropagation = stopPropagation; +exports.addEventListener = addEventListener; +exports.removeEventListener = removeEventListener; /***/ }) /******/ ]); diff --git a/dist/infinite-tree.min.js b/dist/infinite-tree.min.js index c3c8737..2ffd140 100644 --- a/dist/infinite-tree.min.js +++ b/dist/infinite-tree.min.js @@ -1,14 +1,14 @@ -/*! infinite-tree v1.12.3 | (c) 2017 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ -!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.InfiniteTree=factory():root.InfiniteTree=factory()}(this,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=7)}([function(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;/*! +/*! infinite-tree v1.12.4 | (c) 2017 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ +!function(root,factory){"object"==typeof exports&&"object"==typeof module?module.exports=factory():"function"==typeof define&&define.amd?define([],factory):"object"==typeof exports?exports.InfiniteTree=factory():root.InfiniteTree=factory()}(this,function(){return function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=4)}([function(module,exports,__webpack_require__){var __WEBPACK_AMD_DEFINE_ARRAY__,__WEBPACK_AMD_DEFINE_RESULT__;/*! Copyright (c) 2016 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ -!function(){"use strict";function classNames(){for(var classes=[],i=0;i1?_len-1:0),_key=1;_key<_len;_key++)sources[_key-1]=arguments[_key];if(void 0===target||null===target)throw new TypeError("Cannot convert undefined or null to object");for(var output=Object(target),index=0;index0&&index>=0&&index0&&(node=this.children[0]),node},Node.prototype.getLastChild=function(){var node=null;return this.children.length>0&&(node=this.children[this.children.length-1]),node},Node.prototype.getNextSibling=function(){var node=null;if(this.parent){var index=this.parent.children.indexOf(this);index>=0&&index0&&index0},Node.prototype.isLastChild=function(){return!this.getNextSibling()},Node}();exports.default=Node},function(module,exports,__webpack_require__){"use strict";function escapeHtml(string){var str=""+string,match=matchHtmlRegExp.exec(str);if(!match)return str;var escape,html="",index=0,lastIndex=0;for(index=match.index;index]/;module.exports=escapeHtml},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var extend=function(target){for(var _len=arguments.length,sources=Array(_len>1?_len-1:0),_key=1;_key<_len;_key++)sources[_key-1]=arguments[_key];if(void 0===target||null===target)throw new TypeError("Cannot convert undefined or null to object");for(var output=Object(target),index=0;index0&&index>=0&&index0&&(node=this.children[0]),node},Node.prototype.getLastChild=function(){var node=null;return this.children.length>0&&(node=this.children[this.children.length-1]),node},Node.prototype.getNextSibling=function(){var node=null;if(this.parent){var index=this.parent.children.indexOf(this);index>=0&&index0&&index0},Node.prototype.isLastChild=function(){return!this.getNextSibling()},Node}();exports.default=Node},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_extends=Object.assign||function(target){for(var i=1;i1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var argIndex=0,message="Error: "+format.replace(/%s/g,function(){return args[argIndex++]});console&&console.error&&console.error(message);try{throw new Error(message)}catch(e){}},ensureNodeInstance=function(node){return!!node&&(node instanceof _flattree.Node||(error("The node must be a Node object."),!1))},createRootNode=function(rootNode){return Object.assign(rootNode||new _flattree.Node,{parent:null,children:[],state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}})},InfiniteTree=function(_events$EventEmitter){function InfiniteTree(el,options){_classCallCheck(this,InfiniteTree);var _this=_possibleConstructorReturn(this,_events$EventEmitter.call(this));return _this.options={autoOpen:!1,droppable:!1,el:null,layout:"div",loadNodes:null,noDataClass:"infinite-tree-no-data",noDataText:"No data",nodeIdAttr:"data-id",rowRenderer:_renderer.defaultRowRenderer,selectable:!0,shouldSelectNode:null,togglerClass:"infinite-tree-toggler"},_this.state={openNodes:[],rootNode:createRootNode(),selectedNode:null},_this.clusterize=null,_this.nodeTable=new _lookupTable2.default,_this.nodes=[],_this.rows=[],_this.filtered=!1,_this.scrollElement=null,_this.contentElement=null,_this.draggableTarget=null,_this.droppableTarget=null,_this.contentListener={click:function(event){event=event||window.event;var stopPropagation=event.stopPropagation;event.stopPropagation=function(){event.cancelBubble=!0,stopPropagation&&stopPropagation.call(event)},setTimeout(function(){if(!0!==event.cancelBubble&&(_this.emit("click",event),!0!==event.cancelBubble)){var itemTarget=null,clickToggler=!1;for(event.target?itemTarget=event.target!==event.currentTarget?event.target:null:event.srcElement&&(itemTarget=event.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)(0,_elementClass2.default)(itemTarget).has(_this.options.togglerClass)&&(clickToggler=!0),itemTarget=itemTarget.parentElement;if(itemTarget&&!itemTarget.hasAttribute("disabled")){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);if(node)return clickToggler?void _this.toggleNode(node,{async:!0}):void _this.selectNode(node)}}},0)},dblclick:function(event){_this.emit("doubleClick",event)},keydown:function(event){_this.emit("keyDown",event)},keyup:function(event){_this.emit("keyUp",event)},dragstart:function(event){event=event||window.event,_this.draggableTarget=event.target||event.srcElement},dragend:function(event){event=event||window.event;var _this$options$droppab=_this.options.droppable.hoverClass,hoverClass=void 0===_this$options$droppab?"":_this$options$droppab;_this.draggableTarget=null,_this.droppableTarget&&((0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null)},dragenter:function(event){event=event||window.event;var itemTarget=null;for(event.target?itemTarget=event.target!==event.currentTarget?event.target:null:event.srcElement&&(itemTarget=event.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)itemTarget=itemTarget.parentElement;if(itemTarget&&_this.droppableTarget!==itemTarget){var _this$options$droppab2=_this.options.droppable,accept=_this$options$droppab2.accept,_this$options$droppab3=_this$options$droppab2.hoverClass,hoverClass=void 0===_this$options$droppab3?"":_this$options$droppab3;(0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null;var canDrop=!0;if("function"==typeof accept){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);canDrop=!!accept.call(_this,event,{type:"dragenter",draggableTarget:_this.draggableTarget,droppableTarget:itemTarget,node:node})}canDrop&&((0,_elementClass2.default)(itemTarget).add(hoverClass),_this.droppableTarget=itemTarget)}},dragover:function(event){event=event||window.event,(0,_domEvents.preventDefault)(event)},drop:function(event){if(event=event||window.event,(0,_domEvents.preventDefault)(event),_this.draggableTarget&&_this.droppableTarget){var _this$options$droppab4=_this.options.droppable,accept=_this$options$droppab4.accept,drop=_this$options$droppab4.drop,_this$options$droppab5=_this$options$droppab4.hoverClass,hoverClass=void 0===_this$options$droppab5?"":_this$options$droppab5,id=_this.droppableTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id),canDrop=!0;"function"==typeof accept&&(canDrop=!!accept.call(_this,event,{type:"drop",draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node})),canDrop&&"function"==typeof drop&&drop.call(_this,event,{draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node}),(0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null}}},options=(0,_isDom2.default)(el)?_extends({},options,{el:el}):el,_this.options=_extends({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),InfiniteTree.prototype.create=function(){var _this2=this;this.options.el||error("The element option is not specified.");var tag=null;if(this.scrollElement=document.createElement("div"),"table"===this.options.layout){var tableElement=document.createElement("table");tableElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-table");var contentElement=document.createElement("tbody");tableElement.appendChild(contentElement),this.scrollElement.appendChild(tableElement),this.contentElement=contentElement,tag="tr"}else{var _contentElement=document.createElement("div");this.scrollElement.appendChild(_contentElement),this.contentElement=_contentElement,tag="div"}this.scrollElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-scroll"),this.contentElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-content"),this.options.el.appendChild(this.scrollElement),this.clusterize=new _clusterize2.default({tag:tag,rows:[],scrollElem:this.scrollElement,contentElem:this.contentElement,no_data_text:this.options.noDataText,no_data_class:this.options.noDataClass,callbacks:{clusterWillChange:function(){_this2.emit("clusterWillChange")},clusterChanged:function(){_this2.emit("clusterDidChange")}}}),(0,_domEvents.addEventListener)(this.contentElement,"click",this.contentListener.click),(0,_domEvents.addEventListener)(this.contentElement,"dblclick",this.contentListener.dblclick),(0,_domEvents.addEventListener)(this.contentElement,"keydown",this.contentListener.keydown),(0,_domEvents.addEventListener)(this.contentElement,"keyup",this.contentListener.keyup),this.options.droppable&&((0,_domEvents.addEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_domEvents.addEventListener)(document,"dragend",this.contentListener.dragend),(0,_domEvents.addEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_domEvents.addEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_domEvents.addEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_domEvents.addEventListener)(this.contentElement,"drop",this.contentListener.drop))},InfiniteTree.prototype.destroy=function(){for((0,_domEvents.removeEventListener)(this.contentElement,"click",this.contentListener.click),(0,_domEvents.removeEventListener)(this.contentElement,"dblclick",this.contentListener.dblclick),(0,_domEvents.removeEventListener)(this.contentElement,"keydown",this.contentListener.keydown),(0,_domEvents.removeEventListener)(this.contentElement,"keyup",this.contentListener.keyup),this.options.droppable&&((0,_domEvents.removeEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_domEvents.removeEventListener)(document,"dragend",this.contentListener.dragend),(0,_domEvents.removeEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_domEvents.removeEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_domEvents.removeEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_domEvents.removeEventListener)(this.contentElement,"drop",this.contentListener.drop)),this.clear(),this.clusterize&&(this.clusterize.destroy(!0),this.clusterize=null);this.contentElement.firstChild;)this.contentElement.removeChild(this.contentElement.firstChild);for(;this.scrollElement.firstChild;)this.scrollElement.removeChild(this.scrollElement.firstChild);if(this.options.el)for(var containerElement=this.options.el;containerElement.firstChild;)containerElement.removeChild(containerElement.firstChild);this.contentElement=null,this.scrollElement=null},InfiniteTree.prototype.addChildNodes=function(newNodes,index,parentNode){var _this3=this;if(newNodes=[].concat(newNodes||[]),0===newNodes.length)return!1;if("object"===(void 0===index?"undefined":_typeof(index))?(parentNode=index||this.state.rootNode,index=parentNode.children.length):parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;"number"!=typeof index&&(index=parentNode.children.length),newNodes.forEach(function(newNode){newNode.parent=parentNode}),parentNode.children.splice.apply(parentNode.children,[index,0].concat(newNodes)),index=parentNode.children.indexOf(newNodes[0]);var deleteCount=parentNode.state.total,nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes}),rows=[];rows.length=nodes.length;for(var i=0;i=0&&(this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.rows[parentOffset]=this.options.rowRenderer(parentNode,this.options))}return parentNode.children.slice(index).forEach(function(childNode){_this3.flattenNode(childNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)})}),this.update(),!0},InfiniteTree.prototype.appendChildNode=function(newNode,parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;var index=parentNode.children.length,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.clear=function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=createRootNode(this.state.rootNode),this.state.selectedNode=null},InfiniteTree.prototype.closeNode=function(node,options){var _this4=this,_options=_extends({},options),_options$async=_options.async,async=void 0!==_options$async&&_options$async,_options$asyncCallbac=_options.asyncCallback,asyncCallback=void 0===_options$asyncCallbac?noop:_options$asyncCallbac,_options$silent=_options.silent,silent=void 0!==_options$silent&&_options$silent;if(!ensureNodeInstance(node))return!1;this.emit("willCloseNode",node);var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)<0)return!1;node.state.collapsing=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update();var fn=function(){if(_this4.state.selectedNode&&_this4.state.selectedNode!==node){var selectedIndex=_this4.nodes.indexOf(_this4.state.selectedNode),_total=node.state.total,rangeFrom=nodeIndex+1,rangeTo=nodeIndex+_total;rangeFrom<=selectedIndex&&selectedIndex<=rangeTo&&_this4.selectNode(node,options)}node.state.open=!1;var openNodes=_this4.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});_this4.state.openNodes=openNodes;for(var total=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-total;_this4.nodes.splice(nodeIndex+1,total),_this4.rows.splice(nodeIndex+1,total),node.state.collapsing=!1,_this4.rows[nodeIndex]=_this4.options.rowRenderer(node,_this4.options),_this4.update(),silent||_this4.emit("closeNode",node),"function"==typeof asyncCallback&&asyncCallback()};return async?setTimeout(fn,0):fn(),!0},InfiniteTree.prototype.filter=function(predicate,options){options=_extends({caseSensitive:!1,exactMatch:!1,filterPath:"name",includeAncestors:!0,includeDescendants:!0},options),this.filtered=!0;var rootNode=this.state.rootNode;!function traverse(node){var filterNode=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!node||!node.children)return!1;if(node===rootNode)node.state.filtered=!1;else if(filterNode)node.state.filtered=!0;else if("string"==typeof predicate){var filterText=(0,_utilities.get)(node,options.filterPath,""),keyword=predicate;options.caseSensitive||(filterText=filterText.toLowerCase(),keyword=keyword.toLowerCase()),node.state.filtered=options.exactMatch?filterText===keyword:filterText.indexOf(keyword)>=0}else if("function"==typeof predicate){var callback=predicate;node.state.filtered=!!callback(node)}else node.state.filtered=!1;options.includeDescendants&&(filterNode=filterNode||node.state.filtered);for(var filtered=!1,i=0;i0&&void 0!==arguments[0]?arguments[0]:[];this.nodes=(0,_flattree.flatten)(data,{openAllNodes:this.options.autoOpen}),this.nodeTable.clear(),this.state.openNodes=this.nodes.filter(function(node){return node.hasChildren()&&node.state.open}),this.state.selectedNode=null;var rootNode=function(){for(var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;node&&null!==node.parent;)node=node.parent;return node}(this.nodes.length>0?this.nodes[0]:null);this.state.rootNode=rootNode||createRootNode(this.state.rootNode),this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this5.nodeTable.set(node.id,node)}),this.rows.length=this.nodes.length;for(var i=0;i=0)return!1;if(!node.hasChildren()&&node.loadOnDemand)return"function"==typeof this.options.loadNodes&&(!0!==node.state.loading&&(node.state.loading=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update(),setTimeout(function(){_this6.options.loadNodes(node,function(err,nodes){if(nodes=(0,_ensureArray2.default)(nodes),err||0===nodes.length)return node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),void _this6.update();_this6.addChildNodes(nodes,node),node.hasChildren()?_this6.openNode(node,_extends({},options,{async:!0,asyncCallback:function(){node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update()}})):(node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update())})},0),!0));node.state.expanding=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update();var fn=function(){node.state.open=!0;var openNodes=[node].concat(_this6.state.openNodes);_this6.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:_this6.state.openNodes}),rows=[];rows.length=nodes.length;for(var i=0;i0&&!_this6.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this6.nodeTable.set(node.id,node)}),node.state.expanding=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update(),silent||_this6.emit("openNode",node),"function"==typeof asyncCallback&&asyncCallback()};return async?setTimeout(fn,0):fn(),!0},InfiniteTree.prototype.removeChildNodes=function(parentNode,options){var _this7=this;if(!ensureNodeInstance(parentNode))return!1;if(0===parentNode.children.length)return!1;if(parentNode===this.state.rootNode)return this.clear(),!0;var parentNodeIndex=this.nodes.indexOf(parentNode);if(parentNodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=parentNodeIndex+1,rangeTo=parentNodeIndex+parentNode.state.total;rangeFrom<=selectedIndex&&selectedIndex<=rangeTo&&(parentNode===this.state.rootNode?this.selectNode(null,options):this.selectNode(parentNode,options))}for(var removedNodes=this.flattenChildNodes(parentNode),deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0,parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),this.state.openNodes=this.state.openNodes.filter(function(node){return removedNodes.indexOf(node)<0&&node.hasChildren()&&node.state.open}),removedNodes.forEach(function(node){_this7.nodeTable.unset(node.id)}),this.update(),!0},InfiniteTree.prototype.removeNode=function(node,options){var _this8=this;if(!ensureNodeInstance(node))return!1;var parentNode=node.parent;if(!parentNode)return!1;var nodeIndex=this.nodes.indexOf(node),parentNodeIndex=this.nodes.indexOf(parentNode);if(nodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex,rangeTo=nodeIndex+node.state.total+1;if(rangeFrom<=selectedIndex&&selectedIndex<=rangeTo){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();selectedNode===this.state.rootNode?this.selectNode(null,options):this.selectNode(selectedNode,options)}}for(var removedNodes=this.flattenNode(node),deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0,nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),this.state.openNodes=this.state.openNodes.filter(function(node){return removedNodes.indexOf(node)<0&&node.hasChildren()&&node.state.open}),removedNodes.forEach(function(node){_this8.nodeTable.unset(node.id)}),this.update(),!0},InfiniteTree.prototype.scrollToNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return!1;if(!this.contentElement)return!1;for(var firstChild=this.contentElement.firstChild;firstChild;){if((firstChild.className||"").indexOf("clusterize-extra-row")<0&&firstChild.offsetHeight>0)break;firstChild=firstChild.nextSibling}var offsetHeight=firstChild&&firstChild.offsetHeight||0;offsetHeight>0&&this.scrollTop(nodeIndex*offsetHeight);var nodeSelector="["+this.options.nodeIdAttr+'="'+node.id+'"]',nodeEl=this.contentElement.querySelector(nodeSelector);return nodeEl&&this.scrollTop(nodeEl.offsetTop),!0},InfiniteTree.prototype.scrollTop=function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0},InfiniteTree.prototype.selectNode=function(){var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,options=arguments[1],_options3=this.options,selectable=_options3.selectable,shouldSelectNode=_options3.shouldSelectNode,_options4=_extends({},options),_options4$autoScroll=_options4.autoScroll,autoScroll=void 0===_options4$autoScroll||_options4$autoScroll,_options4$silent=_options4.silent,silent=void 0!==_options4$silent&&_options4$silent;if(this.emit("willSelectNode",node),!selectable)return!1;if("function"==typeof shouldSelectNode&&!shouldSelectNode(node))return!1;if(node===this.state.rootNode)return!1;if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(this.state.selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode,this.options),this.state.selectedNode=null,this.update(),silent||this.emit("selectNode",null),!0}return!1}if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return error("Invalid node index"),!1;if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(this.state.selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode,this.options)}if(this.state.selectedNode!==node){if(this.state.selectedNode=node,silent||this.emit("selectNode",node),autoScroll){var nodeSelector="["+this.options.nodeIdAttr+'="'+node.id+'"]',nodeEl=this.contentElement.querySelector(nodeSelector);if(nodeEl){var offsetTop=nodeEl.offsetTop||0,offsetHeight=nodeEl.offsetHeight||0;offsetTop=this.scrollElement.scrollTop+this.scrollElement.clientHeight&&(this.scrollElement.scrollTop+=offsetHeight)}}}else this.state.selectedNode=null,silent||this.emit("selectNode",null);return this.update(),!0},InfiniteTree.prototype.swapNodes=function(node1,node2){if(!ensureNodeInstance(node1)||!ensureNodeInstance(node1.parent))return!1;if(!ensureNodeInstance(node2)||!ensureNodeInstance(node2.parent))return!1;for(var parentNode1=node1.parent,parentNode2=node2.parent,p=parentNode1;null!==p;p=p.parent)if(p===node2)return error("Cannot swap two nodes with one being an ancestor of the other."),!1;for(var _p=parentNode2;null!==_p;_p=_p.parent)if(_p===node1)return error("Cannot swap two nodes with one being an ancestor of the other."),!1;var nodeIndex1=parentNode1.children.indexOf(node1),nodeIndex2=parentNode2.children.indexOf(node2);return this.moveNodeTo(node1,parentNode2,nodeIndex2)&&this.moveNodeTo(node2,parentNode1,nodeIndex1)},InfiniteTree.prototype.toggleNode=function(node,options){return!!ensureNodeInstance(node)&&(this.state.openNodes.indexOf(node)>=0?this.closeNode(node,options):this.openNode(node,options))},InfiniteTree.prototype.toString=function(){var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return node||(node=this.state.rootNode),function traverse(node){var s="[";if(node&&node.children)for(var i=0;i=0){var _options5=_extends({},options),_options5$shallowRend=_options5.shallowRendering,shallowRendering=void 0!==_options5$shallowRend&&_options5$shallowRend;if(this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),!shallowRendering)for(var total=node.state.total,rangeFrom=nodeIndex+1,rangeTo=nodeIndex+total,index=rangeFrom;index<=rangeTo;++index)this.rows[index]=this.options.rowRenderer(this.nodes[index],this.options);this.update()}}},InfiniteTree}(_events2.default.EventEmitter);exports.default=InfiniteTree},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var preventDefault=function(e){void 0!==e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation=function(e){void 0!==e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},addEventListener=function(target,type,listener){target.addEventListener?target.addEventListener(type,listener,!1):target.attachEvent&&target.attachEvent("on"+type,listener)},removeEventListener=function(target,type,listener){target.removeEventListener?target.removeEventListener(type,listener,!1):target.detachEvent&&target.detachEvent("on"+type,listener)};exports.preventDefault=preventDefault,exports.stopPropagation=stopPropagation,exports.addEventListener=addEventListener,exports.removeEventListener=removeEventListener},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var ensureArray=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];return 0===args.length||void 0===args[0]||null===args[0]?[]:1===args.length?[].concat(args[0]):[].concat(args)};exports.default=ensureArray},function(module,exports,__webpack_require__){"use strict";var _infiniteTree=__webpack_require__(4),_infiniteTree2=function(obj){return obj&&obj.__esModule?obj:{default:obj}}(_infiniteTree);module.exports=_infiniteTree2.default},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")}exports.__esModule=!0;var LookupTable=function(){function LookupTable(){_classCallCheck(this,LookupTable),this.data={}}return LookupTable.prototype.clear=function(){this.data={}},LookupTable.prototype.get=function(key){return this.data[key]},LookupTable.prototype.has=function(key){return void 0!==this.data[key]},LookupTable.prototype.set=function(key,value){return this.data[key]=value,value},LookupTable.prototype.unset=function(key){void 0!==this.data[key]&&delete this.data[key]},LookupTable}();exports.default=LookupTable},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.__esModule=!0,exports.defaultRowRenderer=void 0;var _classnames=__webpack_require__(0),_classnames2=_interopRequireDefault(_classnames),_escapeHtml=__webpack_require__(1),_escapeHtml2=_interopRequireDefault(_escapeHtml),_html5Tag=__webpack_require__(16),_html5Tag2=_interopRequireDefault(_html5Tag),defaultRowRenderer=function(node,treeOptions){var id=node.id,name=node.name,_node$loadOnDemand=node.loadOnDemand,loadOnDemand=void 0!==_node$loadOnDemand&&_node$loadOnDemand,children=node.children,state=node.state,droppable=treeOptions.droppable,depth=state.depth,open=state.open,path=state.path,total=state.total,_state$selected=state.selected,selected=void 0!==_state$selected&&_state$selected,filtered=state.filtered,childrenLength=Object.keys(children).length,more=node.hasChildren();if(!1===filtered)return"";var togglerContent="";!more&&loadOnDemand&&(togglerContent="►"),more&&open&&(togglerContent="▼"),more&&!open&&(togglerContent="►");var toggler=(0,_html5Tag2.default)("a",{class:function(){return!more&&loadOnDemand?(0,_classnames2.default)(treeOptions.togglerClass,"infinite-tree-closed"):more&&open?(0,_classnames2.default)(treeOptions.togglerClass):more&&!open?(0,_classnames2.default)(treeOptions.togglerClass,"infinite-tree-closed"):""}()},togglerContent),title=(0,_html5Tag2.default)("span",{class:(0,_classnames2.default)("infinite-tree-title")},(0,_escapeHtml2.default)(name)),treeNode=(0,_html5Tag2.default)("div",{class:"infinite-tree-node",style:"margin-left: "+18*depth+"px"},toggler+title);return(0,_html5Tag2.default)("div",{"data-id":id,"data-expanded":more&&open,"data-depth":depth,"data-path":path,"data-selected":selected,"data-children":childrenLength,"data-total":total,class:(0,_classnames2.default)("infinite-tree-item",{"infinite-tree-selected":selected}),droppable:droppable},treeNode)};exports.defaultRowRenderer=defaultRowRenderer},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},trim=exports.trim=function(str){for(var chars=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" \f\n\r\t\v";chars.indexOf(str[0])>=0;)str=str.slice(1);for(;chars.indexOf(str[str.length-1])>=0;)str=str.slice(0,-1);return str};exports.get=function(){var re=new RegExp(/[\w\-]+|\[[^\]]*\]+/g);return function(object,path,defaultValue){if(!object||"object"!==(void 0===object?"undefined":_typeof(object)))return defaultValue;path=""+path;var keys=path.match(re);if(!keys)return defaultValue;for(var i=0;i",all[0];);return v>4?v:document.documentMode}(),is_mac=navigator.platform.toLowerCase().indexOf("mac")+1,Clusterize=function(data){if(!(this instanceof Clusterize))return new Clusterize(data);var self=this,defaults={rows_in_block:50,blocks_in_cluster:4,tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{}};self.options={};for(var option,options=["rows_in_block","blocks_in_cluster","show_no_data_row","no_data_class","no_data_text","keep_parity","tag","callbacks"],i=0;option=options[i];i++)self.options[option]=void 0!==data[option]&&null!=data[option]?data[option]:defaults[option];for(var elem,elems=["scroll","content"],i=0;elem=elems[i];i++)if(self[elem+"_elem"]=data[elem+"Id"]?document.getElementById(data[elem+"Id"]):data[elem+"Elem"],!self[elem+"_elem"])throw new Error("Error! Could not find "+elem+" element");self.content_elem.hasAttribute("tabindex")||self.content_elem.setAttribute("tabindex",0);var rows=isArray(data.rows)?data.rows:self.fetchMarkup(),cache={},scroll_top=self.scroll_elem.scrollTop;self.insertToDOM(rows,cache),self.scroll_elem.scrollTop=scroll_top;var last_cluster=!1,scroll_debounce=0,pointer_events_set=!1,scrollEv=function(){is_mac&&(pointer_events_set||(self.content_elem.style.pointerEvents="none"),pointer_events_set=!0,clearTimeout(scroll_debounce),scroll_debounce=setTimeout(function(){self.content_elem.style.pointerEvents="auto",pointer_events_set=!1},50)),last_cluster!=(last_cluster=self.getClusterNum())&&self.insertToDOM(rows,cache),self.options.callbacks.scrollingProgress&&self.options.callbacks.scrollingProgress(self.getScrollProgress())},resize_debounce=0,resizeEv=function(){clearTimeout(resize_debounce),resize_debounce=setTimeout(self.refresh,100)};on("scroll",self.scroll_elem,scrollEv),on("resize",window,resizeEv),self.destroy=function(clean){off("scroll",self.scroll_elem,scrollEv),off("resize",window,resizeEv),self.html((clean?self.generateEmptyRow():rows).join(""))},self.refresh=function(force){(self.getRowsHeight(rows)||force)&&self.update(rows)},self.update=function(new_rows){rows=isArray(new_rows)?new_rows:[];var scroll_top=self.scroll_elem.scrollTop;rows.length*self.options.item_height\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&(cache.data=this.html(rows[0]+rows[0]+rows[0])),opts.tag||(opts.tag=this.content_elem.children[0].tagName.toLowerCase()),this.getRowsHeight(rows))},getRowsHeight:function(rows){var opts=this.options,prev_item_height=opts.item_height;if(opts.cluster_height=0,rows.length){var nodes=this.content_elem.children,node=nodes[Math.floor(nodes.length/2)];if(opts.item_height=node.offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem),10)||0),"tr"!=opts.tag){var marginTop=parseInt(getStyle("marginTop",node),10)||0,marginBottom=parseInt(getStyle("marginBottom",node),10)||0;opts.item_height+=Math.max(marginTop,marginBottom)}return opts.block_height=opts.item_height*opts.rows_in_block,opts.rows_in_cluster=opts.blocks_in_cluster*opts.rows_in_block,opts.cluster_height=opts.blocks_in_cluster*opts.block_height,prev_item_height!=opts.item_height}},getClusterNum:function(){return this.options.scroll_top=this.scroll_elem.scrollTop,Math.floor(this.options.scroll_top/(this.options.cluster_height-this.options.block_height))||0},generateEmptyRow:function(){var opts=this.options;if(!opts.tag||!opts.show_no_data_row)return[];var td,empty_row=document.createElement(opts.tag),no_data_content=document.createTextNode(opts.no_data_text);return empty_row.className=opts.no_data_class,"tr"==opts.tag&&(td=document.createElement("td"),td.colSpan=100,td.appendChild(no_data_content)),empty_row.appendChild(td||no_data_content),[empty_row.outerHTML]},generate:function(rows,cluster_num){var opts=this.options,rows_len=rows.length;if(rows_len"+data+"";last=content_elem.lastChild;)content_elem.removeChild(last);for(var rows_nodes=this.getChildNodes(div.firstChild.firstChild);rows_nodes.length;)content_elem.appendChild(rows_nodes.shift())}else content_elem.innerHTML=data},getChildNodes:function(tag){for(var child_nodes=tag.children,nodes=[],i=0,ii=child_nodes.length;i-1?classes:(classes.push(className),el.className=classes.join(" "),classes)}},ElementClass.prototype.remove=function(className){var el=this.el;if(el&&""!==el.className){var classes=el.className.split(" "),idx=indexOf(classes,className);return idx>-1&&classes.splice(idx,1),el.className=classes.join(" "),classes}},ElementClass.prototype.has=function(className){var el=this.el;if(el){return indexOf(el.className.split(" "),className)>-1}},ElementClass.prototype.toggle=function(className){this.el&&(this.has(className)?this.remove(className):this.add(className))}},function(module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if((er=arguments[1])instanceof Error)throw er;var err=new Error('Uncaught, unspecified "error" event. ('+er+")");throw err.context=er,err}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;i0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(position<0)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){return this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.__esModule=!0;var _extend=__webpack_require__(2),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(3),_node2=_interopRequireDefault(_node),flatten=function(){var nodes=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nodes=[].concat(nodes);var flatten=[],stack=[],pool={lastChild:{}};options.openAllNodes=!!options.openAllNodes,options.openNodes=options.openNodes||[],options.throwOnError=!!options.throwOnError;var firstNode=nodes.length>0?nodes[0]:null,parentNode=firstNode?firstNode.parent:null;!parentNode||parentNode instanceof _node2.default||(parentNode=new _node2.default(parentNode));var rootNode=parentNode||new _node2.default({parent:null,children:nodes,state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}});if(rootNode===parentNode)for(var subtotal=rootNode.state.total||0,p=rootNode;p;){var _p$state=p.state,path=_p$state.path,_p$state$total=_p$state.total,total=void 0===_p$state$total?0:_p$state$total;if(p.isLastChild()&&path&&(pool.lastChild[path]=!0),p.state.total=total-subtotal,p.state.total<0){if(options.throwOnError)throw new Error("The node might have been corrupted: id="+JSON.stringify(p.id)+", state="+JSON.stringify(p.state));console&&console.log("Error: The node might have been corrupted: id=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),p.parent,p.children,JSON.stringify(p.state))}p=p.parent}for(stack.push([rootNode,rootNode.state.depth,0]);stack.length>0;)for(var _stack$pop=stack.pop(),current=_stack$pop[0],depth=_stack$pop[1],index=_stack$pop[2];index=0||openNodes.indexOf(node.id)>=0)}(),prefixMask=function(prefix){for(var mask="";prefix.length>0;)prefix=prefix.replace(/\.\d+$/,""),mask=!prefix||pool.lastChild[prefix]?"0"+mask:"1"+mask;return mask}(path);node.isLastChild()&&(pool.lastChild[path]=!0),node.state=(0,_extend2.default)({},node.state,{depth:depth+1,open:open,path:path,prefixMask:prefixMask,total:0});for(var parentDidOpen=!0,_p=node;null!==_p.parent;){if(!1===_p.parent.state.open){parentDidOpen=!1;break}_p=_p.parent}if(parentDidOpen){flatten.push(node);for(var _p2=node;null!==_p2.parent;)_p2.parent.state.total++,_p2=_p2.parent}++index,node.hasChildren()&&(stack.push([current,depth,index]),index=0,depth+=1,current=node)}();return flatten};exports.default=flatten},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.__esModule=!0,exports.Node=exports.flatten=void 0;var _flatten=__webpack_require__(14),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(3),_node2=_interopRequireDefault(_node);exports.flatten=_flatten2.default,exports.Node=_node2.default},function(module,exports,__webpack_require__){"use strict";var _extends=Object.assign||function(target){for(var i=1;i=0,html="<"+tag;return attrs=_extends({},attrs),Object.keys(attrs).forEach(function(name){var value=attrs[name];"string"==typeof value?(value=(0,_escapeHtml2.default)(""+value),html+=" "+name+'="'+value+'"'):value&&(html+=" "+name)}),html+=voidElement?">":void 0!==text?">"+text+"":"/>"}},function(module,exports){function isNode(val){return!(!val||"object"!=typeof val)&&("object"==typeof window&&"object"==typeof window.Node?val instanceof window.Node:"number"==typeof val.nodeType&&"string"==typeof val.nodeName)}module.exports=isNode}])}); \ No newline at end of file +var matchHtmlRegExp=/["'&<>]/;module.exports=escapeHtml},function(module,exports,__webpack_require__){"use strict";var _infiniteTree=__webpack_require__(5),_infiniteTree2=function(obj){return obj&&obj.__esModule?obj:{default:obj}}(_infiniteTree);module.exports=_infiniteTree2.default},function(module,exports,__webpack_require__){"use strict";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||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},_extends=Object.assign||function(target){for(var i=1;i1?_len-1:0),_key=1;_key<_len;_key++)args[_key-1]=arguments[_key];var argIndex=0,message="Error: "+format.replace(/%s/g,function(){return args[argIndex++]});console&&console.error&&console.error(message);try{throw new Error(message)}catch(e){}},ensureNodeInstance=function(node){return!!node&&(node instanceof _flattree.Node||(error("The node must be a Node object."),!1))},createRootNode=function(rootNode){return Object.assign(rootNode||new _flattree.Node,{parent:null,children:[],state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}})},InfiniteTree=function(_events$EventEmitter){function InfiniteTree(el,options){_classCallCheck(this,InfiniteTree);var _this=_possibleConstructorReturn(this,_events$EventEmitter.call(this));return _this.options={autoOpen:!1,droppable:!1,el:null,layout:"div",loadNodes:null,noDataClass:"infinite-tree-no-data",noDataText:"No data",nodeIdAttr:"data-id",rowRenderer:_renderer.defaultRowRenderer,selectable:!0,shouldSelectNode:null,togglerClass:"infinite-tree-toggler"},_this.state={openNodes:[],rootNode:createRootNode(),selectedNode:null},_this.clusterize=null,_this.nodeTable=new _lookupTable2.default,_this.nodes=[],_this.rows=[],_this.filtered=!1,_this.scrollElement=null,_this.contentElement=null,_this.draggableTarget=null,_this.droppableTarget=null,_this.contentListener={click:function(event){event=event||window.event;var stopPropagation=event.stopPropagation;event.stopPropagation=function(){event.cancelBubble=!0,stopPropagation&&stopPropagation.call(event)},setTimeout(function(){if(!0!==event.cancelBubble&&(_this.emit("click",event),!0!==event.cancelBubble)){var itemTarget=null,clickToggler=!1;for(event.target?itemTarget=event.target!==event.currentTarget?event.target:null:event.srcElement&&(itemTarget=event.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)(0,_elementClass2.default)(itemTarget).has(_this.options.togglerClass)&&(clickToggler=!0),itemTarget=itemTarget.parentElement;if(itemTarget&&!itemTarget.hasAttribute("disabled")){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);if(node)return clickToggler?void _this.toggleNode(node,{async:!0}):void _this.selectNode(node)}}},0)},dblclick:function(event){_this.emit("doubleClick",event)},keydown:function(event){_this.emit("keyDown",event)},keyup:function(event){_this.emit("keyUp",event)},dragstart:function(event){event=event||window.event,_this.draggableTarget=event.target||event.srcElement},dragend:function(event){event=event||window.event;var _this$options$droppab=_this.options.droppable.hoverClass,hoverClass=void 0===_this$options$droppab?"":_this$options$droppab;_this.draggableTarget=null,_this.droppableTarget&&((0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null)},dragenter:function(event){event=event||window.event;var itemTarget=null;for(event.target?itemTarget=event.target!==event.currentTarget?event.target:null:event.srcElement&&(itemTarget=event.srcElement);itemTarget&&itemTarget.parentElement!==_this.contentElement;)itemTarget=itemTarget.parentElement;if(itemTarget&&_this.droppableTarget!==itemTarget){var _this$options$droppab2=_this.options.droppable,accept=_this$options$droppab2.accept,_this$options$droppab3=_this$options$droppab2.hoverClass,hoverClass=void 0===_this$options$droppab3?"":_this$options$droppab3;(0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null;var canDrop=!0;if("function"==typeof accept){var id=itemTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id);canDrop=!!accept.call(_this,event,{type:"dragenter",draggableTarget:_this.draggableTarget,droppableTarget:itemTarget,node:node})}canDrop&&((0,_elementClass2.default)(itemTarget).add(hoverClass),_this.droppableTarget=itemTarget)}},dragover:function(event){event=event||window.event,(0,_domEvents.preventDefault)(event)},drop:function(event){if(event=event||window.event,(0,_domEvents.preventDefault)(event),_this.draggableTarget&&_this.droppableTarget){var _this$options$droppab4=_this.options.droppable,accept=_this$options$droppab4.accept,drop=_this$options$droppab4.drop,_this$options$droppab5=_this$options$droppab4.hoverClass,hoverClass=void 0===_this$options$droppab5?"":_this$options$droppab5,id=_this.droppableTarget.getAttribute(_this.options.nodeIdAttr),node=_this.getNodeById(id),canDrop=!0;"function"==typeof accept&&(canDrop=!!accept.call(_this,event,{type:"drop",draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node})),canDrop&&"function"==typeof drop&&drop.call(_this,event,{draggableTarget:_this.draggableTarget,droppableTarget:_this.droppableTarget,node:node}),(0,_elementClass2.default)(_this.droppableTarget).remove(hoverClass),_this.droppableTarget=null}}},options=(0,_isDom2.default)(el)?_extends({},options,{el:el}):el,_this.options=_extends({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),InfiniteTree.prototype.create=function(){var _this2=this;this.options.el||error("The element option is not specified.");var tag=null;if(this.scrollElement=document.createElement("div"),"table"===this.options.layout){var tableElement=document.createElement("table");tableElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-table");var contentElement=document.createElement("tbody");tableElement.appendChild(contentElement),this.scrollElement.appendChild(tableElement),this.contentElement=contentElement,tag="tr"}else{var _contentElement=document.createElement("div");this.scrollElement.appendChild(_contentElement),this.contentElement=_contentElement,tag="div"}this.scrollElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-scroll"),this.contentElement.className=(0,_classnames2.default)("infinite-tree","infinite-tree-content"),this.options.el.appendChild(this.scrollElement),this.clusterize=new _clusterize2.default({tag:tag,rows:[],scrollElem:this.scrollElement,contentElem:this.contentElement,no_data_text:this.options.noDataText,no_data_class:this.options.noDataClass,callbacks:{clusterWillChange:function(){_this2.emit("clusterWillChange")},clusterChanged:function(){_this2.emit("clusterDidChange")}}}),(0,_domEvents.addEventListener)(this.contentElement,"click",this.contentListener.click),(0,_domEvents.addEventListener)(this.contentElement,"dblclick",this.contentListener.dblclick),(0,_domEvents.addEventListener)(this.contentElement,"keydown",this.contentListener.keydown),(0,_domEvents.addEventListener)(this.contentElement,"keyup",this.contentListener.keyup),this.options.droppable&&((0,_domEvents.addEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_domEvents.addEventListener)(document,"dragend",this.contentListener.dragend),(0,_domEvents.addEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_domEvents.addEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_domEvents.addEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_domEvents.addEventListener)(this.contentElement,"drop",this.contentListener.drop))},InfiniteTree.prototype.destroy=function(){for((0,_domEvents.removeEventListener)(this.contentElement,"click",this.contentListener.click),(0,_domEvents.removeEventListener)(this.contentElement,"dblclick",this.contentListener.dblclick),(0,_domEvents.removeEventListener)(this.contentElement,"keydown",this.contentListener.keydown),(0,_domEvents.removeEventListener)(this.contentElement,"keyup",this.contentListener.keyup),this.options.droppable&&((0,_domEvents.removeEventListener)(document,"dragstart",this.contentListener.dragstart),(0,_domEvents.removeEventListener)(document,"dragend",this.contentListener.dragend),(0,_domEvents.removeEventListener)(this.contentElement,"dragenter",this.contentListener.dragenter),(0,_domEvents.removeEventListener)(this.contentElement,"dragleave",this.contentListener.dragleave),(0,_domEvents.removeEventListener)(this.contentElement,"dragover",this.contentListener.dragover),(0,_domEvents.removeEventListener)(this.contentElement,"drop",this.contentListener.drop)),this.clear(),this.clusterize&&(this.clusterize.destroy(!0),this.clusterize=null);this.contentElement.firstChild;)this.contentElement.removeChild(this.contentElement.firstChild);for(;this.scrollElement.firstChild;)this.scrollElement.removeChild(this.scrollElement.firstChild);if(this.options.el)for(var containerElement=this.options.el;containerElement.firstChild;)containerElement.removeChild(containerElement.firstChild);this.contentElement=null,this.scrollElement=null},InfiniteTree.prototype.addChildNodes=function(newNodes,index,parentNode){var _this3=this;if(newNodes=[].concat(newNodes||[]),0===newNodes.length)return!1;if("object"===(void 0===index?"undefined":_typeof(index))?(parentNode=index||this.state.rootNode,index=parentNode.children.length):parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;"number"!=typeof index&&(index=parentNode.children.length),newNodes.forEach(function(newNode){newNode.parent=parentNode}),parentNode.children.splice.apply(parentNode.children,[index,0].concat(newNodes)),index=parentNode.children.indexOf(newNodes[0]);var deleteCount=parentNode.state.total,nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes}),rows=[];rows.length=nodes.length;for(var i=0;i=0&&(this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.rows[parentOffset]=this.options.rowRenderer(parentNode,this.options))}return parentNode.children.slice(index).forEach(function(childNode){_this3.flattenNode(childNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)})}),this.update(),!0},InfiniteTree.prototype.appendChildNode=function(newNode,parentNode){if(parentNode=parentNode||this.state.rootNode,!ensureNodeInstance(parentNode))return!1;var index=parentNode.children.length,newNodes=[].concat(newNode||[]);return this.addChildNodes(newNodes,index,parentNode)},InfiniteTree.prototype.clear=function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=createRootNode(this.state.rootNode),this.state.selectedNode=null},InfiniteTree.prototype.closeNode=function(node,options){var _this4=this,_options=_extends({},options),_options$async=_options.async,async=void 0!==_options$async&&_options$async,_options$asyncCallbac=_options.asyncCallback,asyncCallback=void 0===_options$asyncCallbac?noop:_options$asyncCallbac,_options$silent=_options.silent,silent=void 0!==_options$silent&&_options$silent;if(!ensureNodeInstance(node))return!1;this.emit("willCloseNode",node);var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return error("Invalid node index"),!1;if(this.state.openNodes.indexOf(node)<0)return!1;node.state.collapsing=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update();var fn=function(){if(_this4.state.selectedNode&&_this4.state.selectedNode!==node){var selectedIndex=_this4.nodes.indexOf(_this4.state.selectedNode),_total=node.state.total,rangeFrom=nodeIndex+1,rangeTo=nodeIndex+_total;rangeFrom<=selectedIndex&&selectedIndex<=rangeTo&&_this4.selectNode(node,options)}node.state.open=!1;var openNodes=_this4.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});_this4.state.openNodes=openNodes;for(var total=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-total;_this4.nodes.splice(nodeIndex+1,total),_this4.rows.splice(nodeIndex+1,total),node.state.collapsing=!1,_this4.rows[nodeIndex]=_this4.options.rowRenderer(node,_this4.options),_this4.update(),silent||_this4.emit("closeNode",node),"function"==typeof asyncCallback&&asyncCallback()};return async?setTimeout(fn,0):fn(),!0},InfiniteTree.prototype.filter=function(predicate,options){options=_extends({caseSensitive:!1,exactMatch:!1,filterPath:"name",includeAncestors:!0,includeDescendants:!0},options),this.filtered=!0;var rootNode=this.state.rootNode;!function traverse(node){var filterNode=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!node||!node.children)return!1;if(node===rootNode)node.state.filtered=!1;else if(filterNode)node.state.filtered=!0;else if("string"==typeof predicate){var filterText=(0,_utilities.get)(node,options.filterPath,""),keyword=predicate;options.caseSensitive||(filterText=filterText.toLowerCase(),keyword=keyword.toLowerCase()),node.state.filtered=options.exactMatch?filterText===keyword:filterText.indexOf(keyword)>=0}else if("function"==typeof predicate){var callback=predicate;node.state.filtered=!!callback(node)}else node.state.filtered=!1;options.includeDescendants&&(filterNode=filterNode||node.state.filtered);for(var filtered=!1,i=0;i0&&void 0!==arguments[0]?arguments[0]:[];this.nodes=(0,_flattree.flatten)(data,{openAllNodes:this.options.autoOpen}),this.nodeTable.clear(),this.state.openNodes=this.nodes.filter(function(node){return node.hasChildren()&&node.state.open}),this.state.selectedNode=null;var rootNode=function(){for(var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;node&&null!==node.parent;)node=node.parent;return node}(this.nodes.length>0?this.nodes[0]:null);this.state.rootNode=rootNode||createRootNode(this.state.rootNode),this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this5.nodeTable.set(node.id,node)}),this.rows.length=this.nodes.length;for(var i=0;i=0)return!1;if(!node.hasChildren()&&node.loadOnDemand)return"function"==typeof this.options.loadNodes&&(!0!==node.state.loading&&(node.state.loading=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update(),setTimeout(function(){_this6.options.loadNodes(node,function(err,nodes){var done=arguments.length>2&&void 0!==arguments[2]?arguments[2]:noop;if(nodes=(0,_ensureArray2.default)(nodes),err||0===nodes.length)return node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update(),void("function"==typeof done&&done());_this6.addChildNodes(nodes,node),node.hasChildren()?_this6.openNode(node,_extends({},options,{async:!0,asyncCallback:function(){node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update(),"function"==typeof done&&done()}})):(node.state.loading=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update(),"function"==typeof done&&done())})},0),!0));node.state.expanding=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),this.update();var fn=function(){node.state.open=!0;var openNodes=[node].concat(_this6.state.openNodes);_this6.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:_this6.state.openNodes}),rows=[];rows.length=nodes.length;for(var i=0;i0&&!_this6.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this6.nodeTable.set(node.id,node)}),node.state.expanding=!1,_this6.rows[nodeIndex]=_this6.options.rowRenderer(node,_this6.options),_this6.update(),silent||_this6.emit("openNode",node),"function"==typeof asyncCallback&&asyncCallback()};return async?setTimeout(fn,0):fn(),!0},InfiniteTree.prototype.removeChildNodes=function(parentNode,options){var _this7=this;if(!ensureNodeInstance(parentNode))return!1;if(0===parentNode.children.length)return!1;if(parentNode===this.state.rootNode)return this.clear(),!0;var parentNodeIndex=this.nodes.indexOf(parentNode);if(parentNodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=parentNodeIndex+1,rangeTo=parentNodeIndex+parentNode.state.total;rangeFrom<=selectedIndex&&selectedIndex<=rangeTo&&(parentNode===this.state.rootNode?this.selectNode(null,options):this.selectNode(parentNode,options))}for(var removedNodes=this.flattenChildNodes(parentNode),deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0,parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),this.state.openNodes=this.state.openNodes.filter(function(node){return removedNodes.indexOf(node)<0&&node.hasChildren()&&node.state.open}),removedNodes.forEach(function(node){_this7.nodeTable.unset(node.id)}),this.update(),!0},InfiniteTree.prototype.removeNode=function(node,options){var _this8=this;if(!ensureNodeInstance(node))return!1;var parentNode=node.parent;if(!parentNode)return!1;var nodeIndex=this.nodes.indexOf(node),parentNodeIndex=this.nodes.indexOf(parentNode);if(nodeIndex>=0&&this.state.selectedNode){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex,rangeTo=nodeIndex+node.state.total+1;if(rangeFrom<=selectedIndex&&selectedIndex<=rangeTo){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();selectedNode===this.state.rootNode?this.selectNode(null,options):this.selectNode(selectedNode,options)}}for(var removedNodes=this.flattenNode(node),deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0,nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode,this.options)),this.state.openNodes=this.state.openNodes.filter(function(node){return removedNodes.indexOf(node)<0&&node.hasChildren()&&node.state.open}),removedNodes.forEach(function(node){_this8.nodeTable.unset(node.id)}),this.update(),!0},InfiniteTree.prototype.scrollToNode=function(node){if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return!1;if(!this.contentElement)return!1;for(var firstChild=this.contentElement.firstChild;firstChild;){if((firstChild.className||"").indexOf("clusterize-extra-row")<0&&firstChild.offsetHeight>0)break;firstChild=firstChild.nextSibling}var offsetHeight=firstChild&&firstChild.offsetHeight||0;offsetHeight>0&&this.scrollTop(nodeIndex*offsetHeight);var nodeSelector="["+this.options.nodeIdAttr+'="'+node.id+'"]',nodeEl=this.contentElement.querySelector(nodeSelector);return nodeEl&&this.scrollTop(nodeEl.offsetTop),!0},InfiniteTree.prototype.scrollTop=function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0},InfiniteTree.prototype.selectNode=function(){var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,options=arguments[1],_options3=this.options,selectable=_options3.selectable,shouldSelectNode=_options3.shouldSelectNode,_options4=_extends({},options),_options4$autoScroll=_options4.autoScroll,autoScroll=void 0===_options4$autoScroll||_options4$autoScroll,_options4$silent=_options4.silent,silent=void 0!==_options4$silent&&_options4$silent;if(this.emit("willSelectNode",node),!selectable)return!1;if("function"==typeof shouldSelectNode&&!shouldSelectNode(node))return!1;if(node===this.state.rootNode)return!1;if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(this.state.selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode,this.options),this.state.selectedNode=null,this.update(),silent||this.emit("selectNode",null),!0}return!1}if(!ensureNodeInstance(node))return!1;var nodeIndex=this.nodes.indexOf(node);if(nodeIndex<0)return error("Invalid node index"),!1;if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node,this.options)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(this.state.selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode,this.options)}if(this.state.selectedNode!==node){if(this.state.selectedNode=node,silent||this.emit("selectNode",node),autoScroll){var nodeSelector="["+this.options.nodeIdAttr+'="'+node.id+'"]',nodeEl=this.contentElement.querySelector(nodeSelector);if(nodeEl){var offsetTop=nodeEl.offsetTop||0,offsetHeight=nodeEl.offsetHeight||0;offsetTop=this.scrollElement.scrollTop+this.scrollElement.clientHeight&&(this.scrollElement.scrollTop+=offsetHeight)}}}else this.state.selectedNode=null,silent||this.emit("selectNode",null);return this.update(),!0},InfiniteTree.prototype.swapNodes=function(node1,node2){if(!ensureNodeInstance(node1)||!ensureNodeInstance(node1.parent))return!1;if(!ensureNodeInstance(node2)||!ensureNodeInstance(node2.parent))return!1;for(var parentNode1=node1.parent,parentNode2=node2.parent,p=parentNode1;null!==p;p=p.parent)if(p===node2)return error("Cannot swap two nodes with one being an ancestor of the other."),!1;for(var _p=parentNode2;null!==_p;_p=_p.parent)if(_p===node1)return error("Cannot swap two nodes with one being an ancestor of the other."),!1;var nodeIndex1=parentNode1.children.indexOf(node1),nodeIndex2=parentNode2.children.indexOf(node2);return this.moveNodeTo(node1,parentNode2,nodeIndex2)&&this.moveNodeTo(node2,parentNode1,nodeIndex1)},InfiniteTree.prototype.toggleNode=function(node,options){return!!ensureNodeInstance(node)&&(this.state.openNodes.indexOf(node)>=0?this.closeNode(node,options):this.openNode(node,options))},InfiniteTree.prototype.toString=function(){var node=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return node||(node=this.state.rootNode),function traverse(node){var s="[";if(node&&node.children)for(var i=0;i=0){var _options5=_extends({},options),_options5$shallowRend=_options5.shallowRendering,shallowRendering=void 0!==_options5$shallowRend&&_options5$shallowRend;if(this.rows[nodeIndex]=this.options.rowRenderer(node,this.options),!shallowRendering)for(var total=node.state.total,rangeFrom=nodeIndex+1,rangeTo=nodeIndex+total,index=rangeFrom;index<=rangeTo;++index)this.rows[index]=this.options.rowRenderer(this.nodes[index],this.options);this.update()}}},InfiniteTree}(_events2.default.EventEmitter);exports.default=InfiniteTree},function(module,exports){function EventEmitter(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function isFunction(arg){return"function"==typeof arg}function isNumber(arg){return"number"==typeof arg}function isObject(arg){return"object"==typeof arg&&null!==arg}function isUndefined(arg){return void 0===arg}module.exports=EventEmitter,EventEmitter.EventEmitter=EventEmitter,EventEmitter.prototype._events=void 0,EventEmitter.prototype._maxListeners=void 0,EventEmitter.defaultMaxListeners=10,EventEmitter.prototype.setMaxListeners=function(n){if(!isNumber(n)||n<0||isNaN(n))throw TypeError("n must be a positive number");return this._maxListeners=n,this},EventEmitter.prototype.emit=function(type){var er,handler,len,args,i,listeners;if(this._events||(this._events={}),"error"===type&&(!this._events.error||isObject(this._events.error)&&!this._events.error.length)){if((er=arguments[1])instanceof Error)throw er;var err=new Error('Uncaught, unspecified "error" event. ('+er+")");throw err.context=er,err}if(handler=this._events[type],isUndefined(handler))return!1;if(isFunction(handler))switch(arguments.length){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:args=Array.prototype.slice.call(arguments,1),handler.apply(this,args)}else if(isObject(handler))for(args=Array.prototype.slice.call(arguments,1),listeners=handler.slice(),len=listeners.length,i=0;i0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),"function"==typeof console.trace&&console.trace()),this},EventEmitter.prototype.on=EventEmitter.prototype.addListener,EventEmitter.prototype.once=function(type,listener){function g(){this.removeListener(type,g),fired||(fired=!0,listener.apply(this,arguments))}if(!isFunction(listener))throw TypeError("listener must be a function");var fired=!1;return g.listener=listener,this.on(type,g),this},EventEmitter.prototype.removeListener=function(type,listener){var list,position,length,i;if(!isFunction(listener))throw TypeError("listener must be a function");if(!this._events||!this._events[type])return this;if(list=this._events[type],length=list.length,position=-1,list===listener||isFunction(list.listener)&&list.listener===listener)delete this._events[type],this._events.removeListener&&this.emit("removeListener",type,listener);else if(isObject(list)){for(i=length;i-- >0;)if(list[i]===listener||list[i].listener&&list[i].listener===listener){position=i;break}if(position<0)return this;1===list.length?(list.length=0,delete this._events[type]):list.splice(position,1),this._events.removeListener&&this.emit("removeListener",type,listener)}return this},EventEmitter.prototype.removeAllListeners=function(type){var key,listeners;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[type]&&delete this._events[type],this;if(0===arguments.length){for(key in this._events)"removeListener"!==key&&this.removeAllListeners(key);return this.removeAllListeners("removeListener"),this._events={},this}if(listeners=this._events[type],isFunction(listeners))this.removeListener(type,listeners);else if(listeners)for(;listeners.length;)this.removeListener(type,listeners[listeners.length-1]);return delete this._events[type],this},EventEmitter.prototype.listeners=function(type){return this._events&&this._events[type]?isFunction(this._events[type])?[this._events[type]]:this._events[type].slice():[]},EventEmitter.prototype.listenerCount=function(type){if(this._events){var evlistener=this._events[type];if(isFunction(evlistener))return 1;if(evlistener)return evlistener.length}return 0},EventEmitter.listenerCount=function(emitter,type){return emitter.listenerCount(type)}},function(module,exports,__webpack_require__){!function(name,definition){module.exports=definition()}(0,function(){"use strict";function on(evt,element,fnc){return element.addEventListener?element.addEventListener(evt,fnc,!1):element.attachEvent("on"+evt,fnc)}function off(evt,element,fnc){return element.removeEventListener?element.removeEventListener(evt,fnc,!1):element.detachEvent("on"+evt,fnc)}function isArray(arr){return"[object Array]"===Object.prototype.toString.call(arr)}function getStyle(prop,elem){return window.getComputedStyle?window.getComputedStyle(elem)[prop]:elem.currentStyle[prop]}var ie=function(){for(var v=3,el=document.createElement("b"),all=el.all||[];el.innerHTML="\x3c!--[if gt IE "+ ++v+"]>4?v:document.documentMode}(),is_mac=navigator.platform.toLowerCase().indexOf("mac")+1,Clusterize=function(data){if(!(this instanceof Clusterize))return new Clusterize(data);var self=this,defaults={rows_in_block:50,blocks_in_cluster:4,tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{}};self.options={};for(var option,options=["rows_in_block","blocks_in_cluster","show_no_data_row","no_data_class","no_data_text","keep_parity","tag","callbacks"],i=0;option=options[i];i++)self.options[option]=void 0!==data[option]&&null!=data[option]?data[option]:defaults[option];for(var elem,elems=["scroll","content"],i=0;elem=elems[i];i++)if(self[elem+"_elem"]=data[elem+"Id"]?document.getElementById(data[elem+"Id"]):data[elem+"Elem"],!self[elem+"_elem"])throw new Error("Error! Could not find "+elem+" element");self.content_elem.hasAttribute("tabindex")||self.content_elem.setAttribute("tabindex",0);var rows=isArray(data.rows)?data.rows:self.fetchMarkup(),cache={},scroll_top=self.scroll_elem.scrollTop;self.insertToDOM(rows,cache),self.scroll_elem.scrollTop=scroll_top;var last_cluster=!1,scroll_debounce=0,pointer_events_set=!1,scrollEv=function(){is_mac&&(pointer_events_set||(self.content_elem.style.pointerEvents="none"),pointer_events_set=!0,clearTimeout(scroll_debounce),scroll_debounce=setTimeout(function(){self.content_elem.style.pointerEvents="auto",pointer_events_set=!1},50)),last_cluster!=(last_cluster=self.getClusterNum())&&self.insertToDOM(rows,cache),self.options.callbacks.scrollingProgress&&self.options.callbacks.scrollingProgress(self.getScrollProgress())},resize_debounce=0,resizeEv=function(){clearTimeout(resize_debounce),resize_debounce=setTimeout(self.refresh,100)};on("scroll",self.scroll_elem,scrollEv),on("resize",window,resizeEv),self.destroy=function(clean){off("scroll",self.scroll_elem,scrollEv),off("resize",window,resizeEv),self.html((clean?self.generateEmptyRow():rows).join(""))},self.refresh=function(force){(self.getRowsHeight(rows)||force)&&self.update(rows)},self.update=function(new_rows){rows=isArray(new_rows)?new_rows:[];var scroll_top=self.scroll_elem.scrollTop;rows.length*self.options.item_height\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&(cache.data=this.html(rows[0]+rows[0]+rows[0])),opts.tag||(opts.tag=this.content_elem.children[0].tagName.toLowerCase()),this.getRowsHeight(rows))},getRowsHeight:function(rows){var opts=this.options,prev_item_height=opts.item_height;if(opts.cluster_height=0,rows.length){var nodes=this.content_elem.children,node=nodes[Math.floor(nodes.length/2)];if(opts.item_height=node.offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem),10)||0),"tr"!=opts.tag){var marginTop=parseInt(getStyle("marginTop",node),10)||0,marginBottom=parseInt(getStyle("marginBottom",node),10)||0;opts.item_height+=Math.max(marginTop,marginBottom)}return opts.block_height=opts.item_height*opts.rows_in_block,opts.rows_in_cluster=opts.blocks_in_cluster*opts.rows_in_block,opts.cluster_height=opts.blocks_in_cluster*opts.block_height,prev_item_height!=opts.item_height}},getClusterNum:function(){return this.options.scroll_top=this.scroll_elem.scrollTop,Math.floor(this.options.scroll_top/(this.options.cluster_height-this.options.block_height))||0},generateEmptyRow:function(){var opts=this.options;if(!opts.tag||!opts.show_no_data_row)return[];var td,empty_row=document.createElement(opts.tag),no_data_content=document.createTextNode(opts.no_data_text);return empty_row.className=opts.no_data_class,"tr"==opts.tag&&(td=document.createElement("td"),td.colSpan=100,td.appendChild(no_data_content)),empty_row.appendChild(td||no_data_content),[empty_row.outerHTML]},generate:function(rows,cluster_num){var opts=this.options,rows_len=rows.length;if(rows_len"+data+"";last=content_elem.lastChild;)content_elem.removeChild(last);for(var rows_nodes=this.getChildNodes(div.firstChild.firstChild);rows_nodes.length;)content_elem.appendChild(rows_nodes.shift())}else content_elem.innerHTML=data},getChildNodes:function(tag){for(var child_nodes=tag.children,nodes=[],i=0,ii=child_nodes.length;i-1?classes:(classes.push(className),el.className=classes.join(" "),classes)}},ElementClass.prototype.remove=function(className){var el=this.el;if(el&&""!==el.className){var classes=el.className.split(" "),idx=indexOf(classes,className);return idx>-1&&classes.splice(idx,1),el.className=classes.join(" "),classes}},ElementClass.prototype.has=function(className){var el=this.el;if(el){return indexOf(el.className.split(" "),className)>-1}},ElementClass.prototype.toggle=function(className){this.el&&(this.has(className)?this.remove(className):this.add(className))}},function(module,exports){function isNode(val){return!(!val||"object"!=typeof val)&&("object"==typeof window&&"object"==typeof window.Node?val instanceof window.Node:"number"==typeof val.nodeType&&"string"==typeof val.nodeName)}module.exports=isNode},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.__esModule=!0,exports.Node=exports.flatten=void 0;var _flatten=__webpack_require__(11),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(2),_node2=_interopRequireDefault(_node);exports.flatten=_flatten2.default,exports.Node=_node2.default},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.__esModule=!0;var _extend=__webpack_require__(1),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(2),_node2=_interopRequireDefault(_node),flatten=function(){var nodes=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};nodes=[].concat(nodes);var flatten=[],stack=[],pool={lastChild:{}};options.openAllNodes=!!options.openAllNodes,options.openNodes=options.openNodes||[],options.throwOnError=!!options.throwOnError;var firstNode=nodes.length>0?nodes[0]:null,parentNode=firstNode?firstNode.parent:null;!parentNode||parentNode instanceof _node2.default||(parentNode=new _node2.default(parentNode));var rootNode=parentNode||new _node2.default({parent:null,children:nodes,state:{depth:-1,open:!0,path:"",prefixMask:"",total:0}});if(rootNode===parentNode)for(var subtotal=rootNode.state.total||0,p=rootNode;p;){var _p$state=p.state,path=_p$state.path,_p$state$total=_p$state.total,total=void 0===_p$state$total?0:_p$state$total;if(p.isLastChild()&&path&&(pool.lastChild[path]=!0),p.state.total=total-subtotal,p.state.total<0){if(options.throwOnError)throw new Error("The node might have been corrupted: id="+JSON.stringify(p.id)+", state="+JSON.stringify(p.state));console&&console.log("Error: The node might have been corrupted: id=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),p.parent,p.children,JSON.stringify(p.state))}p=p.parent}for(stack.push([rootNode,rootNode.state.depth,0]);stack.length>0;)for(var _stack$pop=stack.pop(),current=_stack$pop[0],depth=_stack$pop[1],index=_stack$pop[2];index=0||openNodes.indexOf(node.id)>=0)}(),prefixMask=function(prefix){for(var mask="";prefix.length>0;)prefix=prefix.replace(/\.\d+$/,""),mask=!prefix||pool.lastChild[prefix]?"0"+mask:"1"+mask;return mask}(path);node.isLastChild()&&(pool.lastChild[path]=!0),node.state=(0,_extend2.default)({},node.state,{depth:depth+1,open:open,path:path,prefixMask:prefixMask,total:0});for(var parentDidOpen=!0,_p=node;null!==_p.parent;){if(!1===_p.parent.state.open){parentDidOpen=!1;break}_p=_p.parent}if(parentDidOpen){flatten.push(node);for(var _p2=node;null!==_p2.parent;)_p2.parent.state.total++,_p2=_p2.parent}++index,node.hasChildren()&&(stack.push([current,depth,index]),index=0,depth+=1,current=node)}();return flatten};exports.default=flatten},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var ensureArray=function(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++)args[_key]=arguments[_key];return 0===args.length||void 0===args[0]||null===args[0]?[]:[].concat(1===args.length?args[0]:args)};exports.default=ensureArray},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol&&obj!==Symbol.prototype?"symbol":typeof obj},trim=exports.trim=function(str){for(var chars=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" \f\n\r\t\v";chars.indexOf(str[0])>=0;)str=str.slice(1);for(;chars.indexOf(str[str.length-1])>=0;)str=str.slice(0,-1);return str};exports.get=function(){var re=new RegExp(/[\w\-]+|\[[^\]]*\]+/g);return function(object,path,defaultValue){if(!object||"object"!==(void 0===object?"undefined":_typeof(object)))return defaultValue;path=""+path;var keys=path.match(re);if(!keys)return defaultValue;for(var i=0;i=0,html="<"+tag;return attrs=_extends({},attrs),Object.keys(attrs).forEach(function(name){var value=attrs[name];"string"==typeof value?(value=(0,_escapeHtml2.default)(""+value),html+=" "+name+'="'+value+'"'):value&&(html+=" "+name)}),html+=voidElement?">":void 0!==text?">"+text+"":"/>"}},function(module,exports,__webpack_require__){"use strict";exports.__esModule=!0;var preventDefault=function(e){void 0!==e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation=function(e){void 0!==e.stopPropagation?e.stopPropagation():e.cancelBubble=!0},addEventListener=function(target,type,listener){target.addEventListener?target.addEventListener(type,listener,!1):target.attachEvent&&target.attachEvent("on"+type,listener)},removeEventListener=function(target,type,listener){target.removeEventListener?target.removeEventListener(type,listener,!1):target.detachEvent&&target.detachEvent("on"+type,listener)};exports.preventDefault=preventDefault,exports.stopPropagation=stopPropagation,exports.addEventListener=addEventListener,exports.removeEventListener=removeEventListener}])}); \ No newline at end of file diff --git a/package.json b/package.json index 3b189a1..da53260 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "infinite-tree", - "version": "1.12.3", + "version": "1.12.4", "description": "A browser-ready tree library that can efficiently display a large amount of data using infinite scrolling.", "homepage": "https://github.com/cheton/infinite-tree", "main": "lib/index.js", @@ -43,39 +43,38 @@ "is-dom": "^1.0.9" }, "devDependencies": { - "babel-cli": "^6.24.0", - "babel-core": "^6.24.0", - "babel-eslint": "^7.2.1", - "babel-loader": "^6.4.1", + "babel-cli": "^6.24.1", + "babel-core": "^6.25.0", + "babel-eslint": "^7.2.3", + "babel-loader": "^7.1.1", "babel-plugin-transform-es3-member-expression-literals": "^6.22.0", "babel-plugin-transform-es3-property-literals": "^6.22.0", - "babel-preset-es2015": "^6.24.0", + "babel-preset-es2015": "^6.24.1", "babel-preset-es2015-loose": "^8.0.0", - "babel-preset-stage-0": "^6.22.0", - "babel-runtime": "^6.23.0", + "babel-preset-stage-0": "^6.24.1", + "babel-runtime": "^6.25.0", "coveralls": "^2.13.1", - "css-loader": "^0.28.0", + "css-loader": "^0.28.4", "eslint": "^3.19.0", "eslint-config-trendmicro": "^0.5.1", - "eslint-import-resolver-webpack": "^0.8.1", - "eslint-loader": "^1.7.1", - "eslint-plugin-import": "^2.2.0", + "eslint-import-resolver-webpack": "^0.8.3", + "eslint-loader": "^1.9.0", + "eslint-plugin-import": "^2.7.0", "eslint-plugin-jsx-a11y": "^2.2.3", "eslint-plugin-react": "^6.10.3", - "file-loader": "^0.11.1", + "file-loader": "^0.11.2", "jsdom": "^9.12.0", - "json-loader": "^0.5.4", + "json-loader": "^0.5.7", "lodash": "^4.17.4", "nib": "^1.1.2", - "style-loader": "^0.16.1", + "style-loader": "^0.18.2", "stylint": "^1.5.9", "stylus": "^0.54.5", "stylus-loader": "^3.0.1", - "tap": "^10.3.1", - "url-loader": "^0.5.8", - "webpack": "^2.3.3", - "webpack-dev-server": "^2.4.2", - "which": "^1.2.14" + "tap": "^10.7.1", + "url-loader": "^0.5.9", + "webpack": "^3.5.4", + "webpack-dev-server": "^2.7.1" }, "nyc": { "exclude": []