From daa2db75457ec874d1fdc88f8f6305328ba838e6 Mon Sep 17 00:00:00 2001 From: Cheton Wu Date: Mon, 4 Apr 2016 23:28:00 +0800 Subject: [PATCH] v0.4.0 --- dist/infinite-tree.js | 108 ++++++++++++++++++++------------------ dist/infinite-tree.min.js | 4 +- 2 files changed, 59 insertions(+), 53 deletions(-) diff --git a/dist/infinite-tree.js b/dist/infinite-tree.js index eb5d9b6..8dfa67c 100644 --- a/dist/infinite-tree.js +++ b/dist/infinite-tree.js @@ -1,4 +1,4 @@ -/*! infinite-tree v0.3.0 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ +/*! infinite-tree v0.4.0 | (c) 2016 Cheton Wu | MIT | https://github.com/cheton/infinite-tree */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -240,17 +240,6 @@ return /******/ (function(modules) { // webpackBootstrap (0, _polyfill.addEventListener)(this.contentElement, 'click', this.contentListener); } - }, { - key: 'clear', - value: function clear() { - this.clusterize.clear(); - this.nodeTable.clear(); - this.nodes = []; - this.rows = []; - this.state.openNodes = []; - this.state.rootNode = null; - this.state.selectedNode = null; - } }, { key: 'destroy', value: function destroy() { @@ -284,9 +273,9 @@ return /******/ (function(modules) { // webpackBootstrap // * If the parent has children, the method adds the child to it at the specified index. // * If the parent does not have children, the method adds the child to the parent. // * If the index value is greater than or equal to the number of children in the parent, the method adds the child at the end of the children. - // @param {object} newNode The new child node. - // @param {number} [index] The 0-based index of where to insert the child node. Defaults to 0. - // @param {object} parentNode The parent Node object. + // @param {Object} newNode The new child node. + // @param {number} index The 0-based index of where to insert the child node. Defaults to 0 for negative index. + // @param {Node} parentNode The Node object that defines the parent node. // @return {boolean} Returns true on success, false otherwise. }, { @@ -349,8 +338,8 @@ return /******/ (function(modules) { // webpackBootstrap // * If the parent is null or undefined, inserts the child at the specified index in the top-level. // * If the parent has children, the method adds the child as the last child. // * If the parent does not have children, the method adds the child to the parent. - // @param {object} newNode The new child node. - // @param {object} parentNode The parent Node object. + // @param {Object} newNode The new child node. + // @param {Node} parentNode The Node object that defines the parent node. // @return {boolean} Returns true on success, false otherwise. }, { @@ -364,8 +353,21 @@ return /******/ (function(modules) { // webpackBootstrap var index = parentNode.children.length; return this.addChildNodeAt(newNode, index, parentNode); } + // Clears the tree. + + }, { + key: 'clear', + value: function clear() { + this.clusterize.clear(); + this.nodeTable.clear(); + this.nodes = []; + this.rows = []; + this.state.openNodes = []; + this.state.rootNode = null; + this.state.selectedNode = null; + } // Closes a node to hide its children. - // @param {object} node The Node object. + // @param {Node} node The Node object. // @return {boolean} Returns true on success, false otherwise. }, { @@ -430,8 +432,8 @@ return /******/ (function(modules) { // webpackBootstrap } // Flattens all child nodes of a parent node by performing full tree traversal using child-parent link. // No recursion or stack is involved. - // @param {object} parentNode The parent Node object. - // @return {array} Returns a flattened list of child nodes, not including the parent node. + // @param {Node} parentNode The Node object that defines the parent node. + // @return {array} Returns an array of Node objects containing all the child nodes of the parent node. }, { key: 'flattenChildNodes', @@ -465,8 +467,8 @@ return /******/ (function(modules) { // webpackBootstrap } // Flattens a node by performing full tree traversal using child-parent link. // No recursion or stack is involved. - // @param {object} node The Node object. - // @return {array} Returns a flattened list of nodes. + // @param {Node} node The Node object. + // @return {array} Returns a flattened list of Node objects. }, { key: 'flattenNode', @@ -474,8 +476,8 @@ return /******/ (function(modules) { // webpackBootstrap return [node].concat(this.flattenChildNodes(node)); } // Gets a list of child nodes. - // @param {object} [parentNode] The parent Node object. If null or undefined, returns a list of top level nodes. - // @return {array} Returns an array of child nodes. + // @param {Node} [parentNode] The Node object that defines the parent node. If null or undefined, returns a list of top level nodes. + // @return {array} Returns an array of Node objects containing all the child nodes of the parent node. }, { key: 'getChildNodes', @@ -489,7 +491,7 @@ return /******/ (function(modules) { // webpackBootstrap } // Gets a node by its unique id. This assumes that you have given the nodes in the data a unique id. // @param {string|number} id An unique node id. A null value will be returned if the id doesn't match. - // @return {object} Returns the node the matches the id, null otherwise. + // @return {Node} Returns a node the matches the id, null otherwise. }, { key: 'getNodeById', @@ -507,8 +509,17 @@ return /******/ (function(modules) { // webpackBootstrap } return node; } + // Gets an array of open nodes. + // @return {array} Returns an array of Node objects containing open nodes. + + }, { + key: 'getOpenNodes', + value: function getOpenNodes() { + // returns a shallow copy of an array into a new array object. + return this.state.openNodes.slice(); + } // Gets the root node. - // @return {object} Returns the root node, or null if empty. + // @return {Node} Returns the root node, or null if empty. }, { key: 'getRootNode', @@ -516,25 +527,17 @@ return /******/ (function(modules) { // webpackBootstrap return this.state.rootNode; } // Gets the selected node. - // @return {object} Returns the selected node, or null if not selected. + // @return {Node} Returns the selected node, or null if not selected. }, { key: 'getSelectedNode', value: function getSelectedNode() { return this.state.selectedNode; } - // Gets an array of open nodes. - // @return {array} Returns an array of open nodes. - - }, { - key: 'getOpenNodes', - value: function getOpenNodes() { - // returns a shallow copy of an array into a new array object. - return this.state.openNodes.slice(); - } // Inserts the specified node after the reference node. - // @param {object} newNode The new sibling node. - // @param {object} referenceNode The reference Node object. + // @param {Object} newNode The new sibling node. + // @param {Node} referenceNode The Node object that defines the reference node. + // @return {boolean} Returns true on success, false otherwise. }, { key: 'insertNodeAfter', @@ -545,8 +548,9 @@ return /******/ (function(modules) { // webpackBootstrap return this.addChildNodeAt(newNode, index, parentNode); } // Inserts the specified node before the reference node. - // @param {object} newNode The new sibling node. - // @param {object} referenceNode The reference Node object. + // @param {Object} newNode The new sibling node. + // @param {Node} referenceNode The Node object that defines the reference node. + // @return {boolean} Returns true on success, false otherwise. }, { key: 'insertNodeBefore', @@ -601,7 +605,7 @@ return /******/ (function(modules) { // webpackBootstrap this.update(); } // Opens a node to display its children. - // @param {object} node The Node object. + // @param {Node} node The Node object. // @return {boolean} Returns true on success, false otherwise. }, { @@ -655,8 +659,8 @@ return /******/ (function(modules) { // webpackBootstrap return true; } - // Removes all child nodes from a parent node - // @param {object} parentNode The parent Node object. + // Removes all child nodes from a parent node. + // @param {Node} parentNode The Node object that defines the parent node. // @return {boolean} Returns true on success, false otherwise. }, { @@ -730,7 +734,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; } // Removes a node and all of its child nodes. - // @param {object} node The Node object. + // @param {Node} node The Node object. // @return {boolean} Returns true on success, false otherwise. }, { @@ -814,7 +818,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; } // Sets the current scroll position to this node. - // @param {object} node The Node object. + // @param {Node} node The Node object. // @return {number} Returns the vertical scroll position, or -1 on error. }, { @@ -851,7 +855,7 @@ return /******/ (function(modules) { // webpackBootstrap return this.scrollElement.scrollTop; } // Selects a node. - // @param {object} node The Node object. If null or undefined, deselects the current node. + // @param {Node} node The Node object. If null or undefined, deselects the current node. // @return {boolean} Returns true on success, false otherwise. }, { @@ -923,7 +927,7 @@ return /******/ (function(modules) { // webpackBootstrap return true; } // Toggles a node to display or hide its children. - // @param {object} node The Node object. + // @param {Node} node The Node object. }, { key: 'toggleNode', @@ -937,7 +941,8 @@ return /******/ (function(modules) { // webpackBootstrap } } // Serializes the current state of a node to a JSON string. - // @param {object} node The Node object. If null, returns the whole tree. + // @param {Node} node The Node object. If null, returns the whole tree. + // @return {string} Returns a JSON string represented the tree. }, { key: 'toString', @@ -986,19 +991,20 @@ return /******/ (function(modules) { // webpackBootstrap return traverse(node); } - // Updates list with new data + // Updates the tree. }, { key: 'update', value: function update() { + // Update the list with new data this.clusterize.update(this.rows); // Emit the 'update' event this.emit('update'); } // Updates the data of a node. - // @param {object} node - // @param {object} data The data object. + // @param {Node} node The Node object. + // @param {Object} data The data object. }, { key: 'updateNode', diff --git a/dist/infinite-tree.min.js b/dist/infinite-tree.min.js index d0f76b5..9aa35e1 100644 --- a/dist/infinite-tree.min.js +++ b/dist/infinite-tree.min.js @@ -1,3 +1,3 @@ -/*! infinite-tree v0.3.0 | (c) 2016 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]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([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)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},_createClass=function(){function defineProperties(target,props){for(var i=0;i1?_len-1:0),_key=1;_len>_key;_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;index=0&&(handleToggler=!0),itemTarget=itemTarget.parentElement;var id=itemTarget.getAttribute("aria-id"),node=_this.getNodeById(id);if(!node)return;handleToggler?_this.toggleNode(node):_this.selectNode(node)}},_this.options=extend({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(console.error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),_createClass(InfiniteTree,[{key:"create",value:function(){var _this2=this;if(!this.options.el)throw new Error("The element option is not specified.");var scrollElement=document.createElement("div");scrollElement.className=(0,_utils.classNames)("infinite-tree","infinite-tree-scroll");var contentElement=document.createElement("div");contentElement.className=(0,_utils.classNames)("infinite-tree","infinite-tree-content"),scrollElement.appendChild(contentElement),this.options.el.appendChild(scrollElement),this.clusterize=new _clusterize2["default"]({tag:"div",rows:[],scrollElem:scrollElement,contentElem:contentElement,no_data_class:"infinite-tree-no-data",callbacks:{clusterWillChange:function(){},clusterChanged:function(){},scrollingProgress:function(progress){_this2.emit("scrollProgress",progress)}}}),this.scrollElement=scrollElement,this.contentElement=contentElement,(0,_polyfill.addEventListener)(this.contentElement,"click",this.contentListener)}},{key:"clear",value:function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=null,this.state.selectedNode=null}},{key:"destroy",value:function(){for((0,_polyfill.removeEventListener)(this.contentElement,"click",this.contentListener),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}},{key:"addChildNodeAt",value:function(newNode,index,parentNode){var _this3=this;if(parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode),!newNode)return!1;index=Number(index)||0,0>index&&(index=0),newNode.parent=parentNode,parentNode.children.splice(index,0,newNode);var deleteCount=parentNode.state.total;index=parentNode.children.indexOf(newNode);var nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes});newNode=parentNode.getChildAt(index);var rows=nodes.map(function(node){return _this3.options.rowRenderer(node)}),parentOffset=this.nodes.indexOf(parentNode);return this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.flattenNode(newNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)}),this.rows[parentOffset]=this.options.rowRenderer(parentNode),this.update(),!0}},{key:"appendChildNode",value:function(newNode,parentNode){parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode);var index=parentNode.children.length;return this.addChildNodeAt(newNode,index,parentNode)}},{key:"closeNode",value:function(node){ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.openNodes.indexOf(node)<0)return!1;if(this.state.selectedNode&&this.state.selectedNode!==node){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex+1,rangeTo=nodeIndex+node.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(node)}node.state.open=!1;var openNodes=this.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});this.state.openNodes=openNodes;for(var deleteCount=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return this.nodes.splice(nodeIndex+1,deleteCount),this.rows.splice(nodeIndex+1,deleteCount),this.rows[nodeIndex]=this.options.rowRenderer(node),this.emit("closeNode",node),this.update(),!0}},{key:"flattenChildNodes",value:function(parentNode){parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode);for(var list=[],node=parentNode.getFirstChild();node;)if(list.push(node),node.hasChildren())node=node.getFirstChild();else{for(;null===node.getNextSibling()&&node.parent!==parentNode;)node=node.getParent();node=node.getNextSibling()}return list}},{key:"flattenNode",value:function(node){return[node].concat(this.flattenChildNodes(node))}},{key:"getChildNodes",value:function(parentNode){return parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode),parentNode.children}},{key:"getNodeById",value:function(id){var node=this.nodeTable.get(id);if(!node){if(node=this.nodes.filter(function(node){return node.id===id})[0],!node)return null;this.nodeTable.set(node.id,node)}return node}},{key:"getRootNode",value:function(){return this.state.rootNode}},{key:"getSelectedNode",value:function(){return this.state.selectedNode}},{key:"getOpenNodes",value:function(){return this.state.openNodes.slice()}},{key:"insertNodeAfter",value:function(newNode,referenceNode){ensureNodeInstance(referenceNode);var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode)+1;return this.addChildNodeAt(newNode,index,parentNode)}},{key:"insertNodeBefore",value:function(newNode,referenceNode){ensureNodeInstance(referenceNode);var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode);return this.addChildNodeAt(newNode,index,parentNode)}},{key:"loadData",value:function(){var _this4=this,data=arguments.length<=0||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.rootNode=function(){for(var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];node&&null!==node.parent;)node=node.parent;return node}(this.nodes[0]),this.state.selectedNode=null,this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this4.nodeTable.set(node.id,node)}),this.rows=this.nodes.map(function(node){return _this4.options.rowRenderer(node)}),this.update()}},{key:"openNode",value:function(node){var _this5=this;ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.openNodes.indexOf(node)>=0)return!1;node.state.open=!0;var openNodes=[node].concat(this.state.openNodes);this.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this5.options.rowRenderer(node)});return this.nodes.splice.apply(this.nodes,[nodeIndex+1,0].concat(nodes)),this.rows.splice.apply(this.rows,[nodeIndex+1,0].concat(rows)),this.rows[nodeIndex]=this.options.rowRenderer(node),nodes.length>0&&!this.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this5.nodeTable.set(node.id,node)}),this.emit("openNode",node),this.update(),!0}},{key:"removeChildNodes",value:function(parentNode){var _this6=this;if(ensureNodeInstance(parentNode),0===parentNode.children.length)return!1;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;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(parentNode)}parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode)),!function(){var childNodes=_this6.flattenChildNodes(parentNode);_this6.state.openNodes=_this6.state.openNodes.filter(function(node){return childNodes.indexOf(node)<0}),childNodes.forEach(function(node){_this6.nodeTable.unset(node.id)})}(),this.update(),!0}},{key:"removeNode",value:function(node){var _this7=this;ensureNodeInstance(node);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(selectedIndex>=rangeFrom&&rangeTo>=selectedIndex){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();this.selectNode(selectedNode)}}parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode)),!function(){var nodes=_this7.flattenNode(node);_this7.state.openNodes=_this7.state.openNodes.filter(function(node){return nodes.indexOf(node)<0}),nodes.forEach(function(node){_this7.nodeTable.unset(node.id)})}(),this.update(),!0}},{key:"scrollToNode",value:function(node){ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return-1;if(!this.contentElement)return-1;var firstChild=this.contentElement.querySelectorAll(".tree-item")[0],rowHeight=firstChild&&firstChild.offsetHeight||0;return this.scrollTop(nodeIndex*rowHeight)}},{key:"scrollTop",value:function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0}},{key:"selectNode",value:function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode),this.state.selectedNode=null,this.emit("selectNode",null),this.update(),!0}return!1}ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(_selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode)}return this.state.selectedNode!==node?(this.state.selectedNode=node,this.emit("selectNode",node)):(this.state.selectedNode=null,this.emit("selectNode",null)),this.update(),!0}},{key:"toggleNode",value:function(node){this.state.openNodes.indexOf(node)>=0?this.closeNode(node):this.openNode(node)}},{key:"toString",value:function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],traverse=function traverse(node){var s="[";if(node&&node.children)for(var _loop=function(i){var list=[];s+="{",Object.keys(node).forEach(function(key){var value=node[key];if("parent"!==key)return"children"===key?void list.push('"'+key+'":'+traverse(node.children[i])):void("string"==typeof value||"object"===("undefined"==typeof value?"undefined":_typeof(value))?list.push('"'+key+'":'+JSON.stringify(value)):list.push('"'+key+'":'+value))}),s+=list.join(","),s=s+"}"+(i===node.children.length-1?"":",")},i=0;i=0&&(this.rows[nodeIndex]=this.options.rowRenderer(node),this.update())}}]),InfiniteTree}(_events2["default"].EventEmitter);module.exports=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)||0>n||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],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified "error" event.')}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;len>i;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&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(0>position)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){var ret;return ret=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()}("Clusterize",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="",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={item_height:0,block_height:0,rows_in_block:50,rows_in_cluster:0,cluster_height:0,blocks_in_cluster:4,tag:null,content_tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{},scroll_top:0};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]="undefined"!=typeof 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={data:"",bottom:0},scroll_top=self.scroll_elem.scrollTop;self.exploreEnvironment(rows),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(){self.getRowsHeight(rows)&&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=ie&&!opts.tag&&(opts.tag=rows[0].match(/<([^>\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&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;return opts.item_height=nodes[Math.floor(nodes.length/2)].offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem))||0),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.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_lentop_offset&&rows_above++;for(var i=items_start;items_end>i;i++)rows[i]&&this_cluster_rows.push(rows[i]);return{top_offset:top_offset,bottom_offset:bottom_offset,rows_above:rows_above,rows:this_cluster_rows}},renderExtraTag:function(class_name,height){var tag=document.createElement(this.options.tag),clusterize_prefix="clusterize-";return tag.className=[clusterize_prefix+"extra-row",clusterize_prefix+class_name].join(" "),height&&(tag.style.height=height+"px"),tag.outerHTML},insertToDOM:function(rows,cache){var data=this.generate(rows,this.getClusterNum()),this_cluster_rows=data.rows.join(""),this_cluster_content_changed=this.checkChanges("data",this_cluster_rows,cache),only_bottom_offset_changed=this.checkChanges("bottom",data.bottom_offset,cache),callbacks=this.options.callbacks,layout=[];this_cluster_content_changed?(data.top_offset&&(this.options.keep_parity&&layout.push(this.renderExtraTag("keep-parity")),layout.push(this.renderExtraTag("top-space",data.top_offset))),layout.push(this_cluster_rows),data.bottom_offset&&layout.push(this.renderExtraTag("bottom-space",data.bottom_offset)),callbacks.clusterWillChange&&callbacks.clusterWillChange(),this.html(layout.join("")),"ol"==this.options.content_tag&&this.content_elem.setAttribute("start",data.rows_above),callbacks.clusterChanged&&callbacks.clusterChanged()):only_bottom_offset_changed&&(this.content_elem.lastChild.style.height=data.bottom_offset+"px")},html:function(data){var content_elem=this.content_elem;if(ie&&9>=ie&&"tr"==this.options.tag){var last,div=document.createElement("div");for(div.innerHTML=""+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;ii>i;i++)nodes.push(child_nodes[i]);return nodes},checkChanges:function(type,value,cache){var changed=value!=cache[type];return cache[type]=value,changed}},Clusterize})},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _flatten=__webpack_require__(4),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(6),_node2=_interopRequireDefault(_node);module.exports={flatten:_flatten2["default"],Node:_node2["default"]}},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_extend=__webpack_require__(5),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(6),_node2=_interopRequireDefault(_node),flatten=function flatten(){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"]({label:"",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, label=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),JSON.stringify(p.label),p.parent,p.children,JSON.stringify(p.state))}p=p.parent; +/*! infinite-tree v0.4.0 | (c) 2016 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]={exports:{},id:moduleId,loaded:!1};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.loaded=!0,module.exports}var installedModules={};return __webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.p="",__webpack_require__(0)}([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)}var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(obj){return typeof obj}:function(obj){return obj&&"function"==typeof Symbol&&obj.constructor===Symbol?"symbol":typeof obj},_createClass=function(){function defineProperties(target,props){for(var i=0;i1?_len-1:0),_key=1;_len>_key;_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;index=0&&(handleToggler=!0),itemTarget=itemTarget.parentElement;var id=itemTarget.getAttribute("aria-id"),node=_this.getNodeById(id);if(!node)return;handleToggler?_this.toggleNode(node):_this.selectNode(node)}},_this.options=extend({},_this.options,options),_this.options.el?(_this.create(),options.data&&_this.loadData(options.data),_this):(console.error("Failed to initialize infinite-tree: el is not specified.",options),_possibleConstructorReturn(_this))}return _inherits(InfiniteTree,_events$EventEmitter),_createClass(InfiniteTree,[{key:"create",value:function(){var _this2=this;if(!this.options.el)throw new Error("The element option is not specified.");var scrollElement=document.createElement("div");scrollElement.className=(0,_utils.classNames)("infinite-tree","infinite-tree-scroll");var contentElement=document.createElement("div");contentElement.className=(0,_utils.classNames)("infinite-tree","infinite-tree-content"),scrollElement.appendChild(contentElement),this.options.el.appendChild(scrollElement),this.clusterize=new _clusterize2["default"]({tag:"div",rows:[],scrollElem:scrollElement,contentElem:contentElement,no_data_class:"infinite-tree-no-data",callbacks:{clusterWillChange:function(){},clusterChanged:function(){},scrollingProgress:function(progress){_this2.emit("scrollProgress",progress)}}}),this.scrollElement=scrollElement,this.contentElement=contentElement,(0,_polyfill.addEventListener)(this.contentElement,"click",this.contentListener)}},{key:"destroy",value:function(){for((0,_polyfill.removeEventListener)(this.contentElement,"click",this.contentListener),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}},{key:"addChildNodeAt",value:function(newNode,index,parentNode){var _this3=this;if(parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode),!newNode)return!1;index=Number(index)||0,0>index&&(index=0),newNode.parent=parentNode,parentNode.children.splice(index,0,newNode);var deleteCount=parentNode.state.total;index=parentNode.children.indexOf(newNode);var nodes=(0,_flattree.flatten)(parentNode.children,{openNodes:this.state.openNodes});newNode=parentNode.getChildAt(index);var rows=nodes.map(function(node){return _this3.options.rowRenderer(node)}),parentOffset=this.nodes.indexOf(parentNode);return this.nodes.splice.apply(this.nodes,[parentOffset+1,deleteCount].concat(nodes)),this.rows.splice.apply(this.rows,[parentOffset+1,deleteCount].concat(rows)),this.flattenNode(newNode).forEach(function(node){void 0!==node.id&&_this3.nodeTable.set(node.id,node)}),this.rows[parentOffset]=this.options.rowRenderer(parentNode),this.update(),!0}},{key:"appendChildNode",value:function(newNode,parentNode){parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode);var index=parentNode.children.length;return this.addChildNodeAt(newNode,index,parentNode)}},{key:"clear",value:function(){this.clusterize.clear(),this.nodeTable.clear(),this.nodes=[],this.rows=[],this.state.openNodes=[],this.state.rootNode=null,this.state.selectedNode=null}},{key:"closeNode",value:function(node){ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.openNodes.indexOf(node)<0)return!1;if(this.state.selectedNode&&this.state.selectedNode!==node){var selectedIndex=this.nodes.indexOf(this.state.selectedNode),rangeFrom=nodeIndex+1,rangeTo=nodeIndex+node.state.total;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(node)}node.state.open=!1;var openNodes=this.state.openNodes.filter(function(node){return node.hasChildren()&&node.state.open});this.state.openNodes=openNodes;for(var deleteCount=node.state.total,p=node;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return this.nodes.splice(nodeIndex+1,deleteCount),this.rows.splice(nodeIndex+1,deleteCount),this.rows[nodeIndex]=this.options.rowRenderer(node),this.emit("closeNode",node),this.update(),!0}},{key:"flattenChildNodes",value:function(parentNode){parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode);for(var list=[],node=parentNode.getFirstChild();node;)if(list.push(node),node.hasChildren())node=node.getFirstChild();else{for(;null===node.getNextSibling()&&node.parent!==parentNode;)node=node.getParent();node=node.getNextSibling()}return list}},{key:"flattenNode",value:function(node){return[node].concat(this.flattenChildNodes(node))}},{key:"getChildNodes",value:function(parentNode){return parentNode=parentNode||this.state.rootNode,ensureNodeInstance(parentNode),parentNode.children}},{key:"getNodeById",value:function(id){var node=this.nodeTable.get(id);if(!node){if(node=this.nodes.filter(function(node){return node.id===id})[0],!node)return null;this.nodeTable.set(node.id,node)}return node}},{key:"getOpenNodes",value:function(){return this.state.openNodes.slice()}},{key:"getRootNode",value:function(){return this.state.rootNode}},{key:"getSelectedNode",value:function(){return this.state.selectedNode}},{key:"insertNodeAfter",value:function(newNode,referenceNode){ensureNodeInstance(referenceNode);var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode)+1;return this.addChildNodeAt(newNode,index,parentNode)}},{key:"insertNodeBefore",value:function(newNode,referenceNode){ensureNodeInstance(referenceNode);var parentNode=referenceNode.getParent(),index=parentNode.children.indexOf(referenceNode);return this.addChildNodeAt(newNode,index,parentNode)}},{key:"loadData",value:function(){var _this4=this,data=arguments.length<=0||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.rootNode=function(){for(var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];node&&null!==node.parent;)node=node.parent;return node}(this.nodes[0]),this.state.selectedNode=null,this.flattenChildNodes(this.state.rootNode).forEach(function(node){void 0!==node.id&&_this4.nodeTable.set(node.id,node)}),this.rows=this.nodes.map(function(node){return _this4.options.rowRenderer(node)}),this.update()}},{key:"openNode",value:function(node){var _this5=this;ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.openNodes.indexOf(node)>=0)return!1;node.state.open=!0;var openNodes=[node].concat(this.state.openNodes);this.state.openNodes=openNodes;var nodes=(0,_flattree.flatten)(node.children,{openNodes:this.state.openNodes}),rows=nodes.map(function(node){return _this5.options.rowRenderer(node)});return this.nodes.splice.apply(this.nodes,[nodeIndex+1,0].concat(nodes)),this.rows.splice.apply(this.rows,[nodeIndex+1,0].concat(rows)),this.rows[nodeIndex]=this.options.rowRenderer(node),nodes.length>0&&!this.nodeTable.get(nodes[0])&&nodes.forEach(function(node){void 0!==node.id&&_this5.nodeTable.set(node.id,node)}),this.emit("openNode",node),this.update(),!0}},{key:"removeChildNodes",value:function(parentNode){var _this6=this;if(ensureNodeInstance(parentNode),0===parentNode.children.length)return!1;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;selectedIndex>=rangeFrom&&rangeTo>=selectedIndex&&this.selectNode(parentNode)}parentNode.children=[],parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=parentNode.state.total,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return parentNodeIndex>=0&&(this.nodes.splice(parentNodeIndex+1,deleteCount),this.rows.splice(parentNodeIndex+1,deleteCount),this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode)),!function(){var childNodes=_this6.flattenChildNodes(parentNode);_this6.state.openNodes=_this6.state.openNodes.filter(function(node){return childNodes.indexOf(node)<0}),childNodes.forEach(function(node){_this6.nodeTable.unset(node.id)})}(),this.update(),!0}},{key:"removeNode",value:function(node){var _this7=this;ensureNodeInstance(node);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(selectedIndex>=rangeFrom&&rangeTo>=selectedIndex){var selectedNode=node.getNextSibling()||node.getPreviousSibling()||node.getParent();this.selectNode(selectedNode)}}parentNode.children.splice(parentNode.children.indexOf(node),1),parentNode.state.open=parentNode.state.open&&parentNode.children.length>0;for(var deleteCount=node.state.total+1,p=parentNode;null!==p;p=p.parent)p.state.total=p.state.total-deleteCount;return nodeIndex>=0&&(this.nodes.splice(nodeIndex,deleteCount),this.rows.splice(nodeIndex,deleteCount)),parentNodeIndex>=0&&(this.rows[parentNodeIndex]=this.options.rowRenderer(parentNode)),!function(){var nodes=_this7.flattenNode(node);_this7.state.openNodes=_this7.state.openNodes.filter(function(node){return nodes.indexOf(node)<0}),nodes.forEach(function(node){_this7.nodeTable.unset(node.id)})}(),this.update(),!0}},{key:"scrollToNode",value:function(node){ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)return-1;if(!this.contentElement)return-1;var firstChild=this.contentElement.querySelectorAll(".tree-item")[0],rowHeight=firstChild&&firstChild.offsetHeight||0;return this.scrollTop(nodeIndex*rowHeight)}},{key:"scrollTop",value:function(value){return this.scrollElement?(void 0!==value&&(this.scrollElement.scrollTop=Number(value)),this.scrollElement.scrollTop):0}},{key:"selectNode",value:function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0];if(null===node){if(this.state.selectedNode){var selectedNode=this.state.selectedNode,selectedIndex=this.nodes.indexOf(selectedNode);return selectedNode.state.selected=!1,this.rows[selectedIndex]=this.options.rowRenderer(selectedNode),this.state.selectedNode=null,this.emit("selectNode",null),this.update(),!0}return!1}ensureNodeInstance(node);var nodeIndex=this.nodes.indexOf(node);if(0>nodeIndex)throw new Error("Invalid node index");if(this.state.selectedNode!==node&&(node.state.selected=!0,this.rows[nodeIndex]=this.options.rowRenderer(node)),this.state.selectedNode){var _selectedNode=this.state.selectedNode,_selectedIndex=this.nodes.indexOf(_selectedNode);_selectedNode.state.selected=!1,this.rows[_selectedIndex]=this.options.rowRenderer(_selectedNode)}return this.state.selectedNode!==node?(this.state.selectedNode=node,this.emit("selectNode",node)):(this.state.selectedNode=null,this.emit("selectNode",null)),this.update(),!0}},{key:"toggleNode",value:function(node){this.state.openNodes.indexOf(node)>=0?this.closeNode(node):this.openNode(node)}},{key:"toString",value:function(){var node=arguments.length<=0||void 0===arguments[0]?null:arguments[0],traverse=function traverse(node){var s="[";if(node&&node.children)for(var _loop=function(i){var list=[];s+="{",Object.keys(node).forEach(function(key){var value=node[key];if("parent"!==key)return"children"===key?void list.push('"'+key+'":'+traverse(node.children[i])):void("string"==typeof value||"object"===("undefined"==typeof value?"undefined":_typeof(value))?list.push('"'+key+'":'+JSON.stringify(value)):list.push('"'+key+'":'+value))}),s+=list.join(","),s=s+"}"+(i===node.children.length-1?"":",")},i=0;i=0&&(this.rows[nodeIndex]=this.options.rowRenderer(node),this.update())}}]),InfiniteTree}(_events2["default"].EventEmitter);module.exports=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)||0>n||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],er instanceof Error)throw er;throw TypeError('Uncaught, unspecified "error" event.')}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;len>i;i++)listeners[i].apply(this,args);return!0},EventEmitter.prototype.addListener=function(type,listener){var m;if(!isFunction(listener))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",type,isFunction(listener.listener)?listener.listener:listener),this._events[type]?isObject(this._events[type])?this._events[type].push(listener):this._events[type]=[this._events[type],listener]:this._events[type]=listener,isObject(this._events[type])&&!this._events[type].warned&&(m=isUndefined(this._maxListeners)?EventEmitter.defaultMaxListeners:this._maxListeners,m&&m>0&&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(0>position)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){var ret;return ret=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()}("Clusterize",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="",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={item_height:0,block_height:0,rows_in_block:50,rows_in_cluster:0,cluster_height:0,blocks_in_cluster:4,tag:null,content_tag:null,show_no_data_row:!0,no_data_class:"clusterize-no-data",no_data_text:"No data",keep_parity:!0,callbacks:{},scroll_top:0};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]="undefined"!=typeof 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={data:"",bottom:0},scroll_top=self.scroll_elem.scrollTop;self.exploreEnvironment(rows),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(){self.getRowsHeight(rows)&&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=ie&&!opts.tag&&(opts.tag=rows[0].match(/<([^>\s\/]*)/)[1].toLowerCase()),this.content_elem.children.length<=1&&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;return opts.item_height=nodes[Math.floor(nodes.length/2)].offsetHeight,"tr"==opts.tag&&"collapse"!=getStyle("borderCollapse",this.content_elem)&&(opts.item_height+=parseInt(getStyle("borderSpacing",this.content_elem))||0),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.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_lentop_offset&&rows_above++;for(var i=items_start;items_end>i;i++)rows[i]&&this_cluster_rows.push(rows[i]);return{top_offset:top_offset,bottom_offset:bottom_offset,rows_above:rows_above,rows:this_cluster_rows}},renderExtraTag:function(class_name,height){var tag=document.createElement(this.options.tag),clusterize_prefix="clusterize-";return tag.className=[clusterize_prefix+"extra-row",clusterize_prefix+class_name].join(" "),height&&(tag.style.height=height+"px"),tag.outerHTML},insertToDOM:function(rows,cache){var data=this.generate(rows,this.getClusterNum()),this_cluster_rows=data.rows.join(""),this_cluster_content_changed=this.checkChanges("data",this_cluster_rows,cache),only_bottom_offset_changed=this.checkChanges("bottom",data.bottom_offset,cache),callbacks=this.options.callbacks,layout=[];this_cluster_content_changed?(data.top_offset&&(this.options.keep_parity&&layout.push(this.renderExtraTag("keep-parity")),layout.push(this.renderExtraTag("top-space",data.top_offset))),layout.push(this_cluster_rows),data.bottom_offset&&layout.push(this.renderExtraTag("bottom-space",data.bottom_offset)),callbacks.clusterWillChange&&callbacks.clusterWillChange(),this.html(layout.join("")),"ol"==this.options.content_tag&&this.content_elem.setAttribute("start",data.rows_above),callbacks.clusterChanged&&callbacks.clusterChanged()):only_bottom_offset_changed&&(this.content_elem.lastChild.style.height=data.bottom_offset+"px")},html:function(data){var content_elem=this.content_elem;if(ie&&9>=ie&&"tr"==this.options.tag){var last,div=document.createElement("div");for(div.innerHTML=""+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;ii>i;i++)nodes.push(child_nodes[i]);return nodes},checkChanges:function(type,value,cache){var changed=value!=cache[type];return cache[type]=value,changed}},Clusterize})},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _flatten=__webpack_require__(4),_flatten2=_interopRequireDefault(_flatten),_node=__webpack_require__(6),_node2=_interopRequireDefault(_node);module.exports={flatten:_flatten2["default"],Node:_node2["default"]}},function(module,exports,__webpack_require__){"use strict";function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj}}var _slicedToArray=function(){function sliceIterator(arr,i){var _arr=[],_n=!0,_d=!1,_e=void 0;try{for(var _s,_i=arr[Symbol.iterator]();!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{!_n&&_i["return"]&&_i["return"]()}finally{if(_d)throw _e}}return _arr}return function(arr,i){if(Array.isArray(arr))return arr;if(Symbol.iterator in Object(arr))return sliceIterator(arr,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),_extend=__webpack_require__(5),_extend2=_interopRequireDefault(_extend),_node=__webpack_require__(6),_node2=_interopRequireDefault(_node),flatten=function flatten(){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"]({label:"",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, label=%s, parent=%s, children=%s, state=%s",JSON.stringify(p.id),JSON.stringify(p.label),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(),_stack$pop2=_slicedToArray(_stack$pop,3),current=_stack$pop2[0],depth=_stack$pop2[1],index=_stack$pop2[2],_loop=function(){var node=current.children[index];node instanceof _node2["default"]||(node=new _node2["default"](node)),node.parent=current,node.children=node.children||[],node.parent.children[index]=node;var path=current.state.path+"."+index,open=node.hasChildren()&&function(){var openAllNodes=options.openAllNodes,openNodes=options.openNodes;return openAllNodes?!0:openNodes.indexOf(node)>=0?!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(_p.parent.state.open===!1){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)};index1?_len-1:0),_key=1;_len>_key;_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}},{key:"getLastChild",value:function(){var node=null;return this.children.length>0&&(node=this.children[this.children.length-1]),node}},{key:"getNextSibling",value:function(){var node=null;if(this.parent){var index=this.parent.children.indexOf(this);index>=0&&index0&&index0}},{key:"isLastChild",value:function(){var hasNextSibling=this.getNextSibling();return!hasNextSibling}}]),Node}();module.exports=Node},function(module,exports){"use strict";function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function defineProperties(target,props){for(var i=0;i"+html+"":"/>"},classNames=function classNames(){for(var _len=arguments.length,args=Array(_len),_key=0;_len>_key;_key++)args[_key]=arguments[_key];var classNames=[];return args.forEach(function(arg){Array.isArray(arg)?classNames=classNames.concat(arg):"object"===("undefined"==typeof arg?"undefined":_typeof(arg))?Object.keys(arg).forEach(function(className){var ok=arg[className];ok&&classNames.push(className)}):classNames.push(arg)}),classNames.join(" ")},quoteattr=function(s,preserveCR){return preserveCR=preserveCR?" ":"\n",(""+s).replace(/&/g,"&").replace(/'/g,"'").replace(/"/g,""").replace(//g,">").replace(/\r\n/g,preserveCR).replace(/[\r\n]/g,preserveCR)};module.exports={buildHTML:buildHTML,classNames:classNames,quoteattr:quoteattr}},function(module,exports){"use strict";var preventDefault=function(e){"undefined"!=typeof e.preventDefault?e.preventDefault():e.returnValue=!1},stopPropagation=function(e){"undefined"!=typeof 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)};module.exports={preventDefault:preventDefault,stopPropagation:stopPropagation,addEventListener:addEventListener,removeEventListener:removeEventListener}}])}); \ No newline at end of file