diff --git a/dist/frappe-datatable.cjs.js b/dist/frappe-datatable.cjs.js index 35ac48a..47a0d1e 100644 --- a/dist/frappe-datatable.cjs.js +++ b/dist/frappe-datatable.cjs.js @@ -2259,42 +2259,12 @@ class DataManager { } _sortRows(colIndex, sortOrder) { - - if (this.currentSort.colIndex === colIndex) { - // reverse the array if only sortOrder changed - if ( - (this.currentSort.sortOrder === 'asc' && sortOrder === 'desc') || - (this.currentSort.sortOrder === 'desc' && sortOrder === 'asc') - ) { - this.reverseArray(this.rowViewOrder); - this.currentSort.sortOrder = sortOrder; - return; - } + if (this.options.treeView) { + this.treeSort(colIndex, sortOrder); + } else { + this.rowViewOrder.sort((a, b) => this.compareContent(a, b, colIndex, sortOrder)); } - this.rowViewOrder.sort((a, b) => { - const aIndex = a; - const bIndex = b; - - let aContent = this.getCell(colIndex, a).content; - let bContent = this.getCell(colIndex, b).content; - aContent = aContent == null ? '' : aContent; - bContent = bContent == null ? '' : bContent; - - if (sortOrder === 'none') { - return aIndex - bIndex; - } else if (sortOrder === 'asc') { - if (aContent < bContent) return -1; - if (aContent > bContent) return 1; - if (aContent === bContent) return 0; - } else if (sortOrder === 'desc') { - if (aContent < bContent) return 1; - if (aContent > bContent) return -1; - if (aContent === bContent) return 0; - } - return 0; - }); - if (this.hasColumnById('_rowIndex')) { // update row index const srNoColIndex = this.getColumnIndexById('_rowIndex'); @@ -2306,6 +2276,82 @@ class DataManager { } } + treeSort(colIndex, sortOrder) { + let tree = []; + let rowMap = {}; + + // Build Tree + for (let i = 0; i < this.rows.length; i++) { + const rowIndex = this.rows[i].meta.rowIndex; + const currentIndent = this.rows[i].meta.indent; + + let currentNode = { parent: rowIndex, children: [] }; + rowMap[rowIndex] = currentNode; + + if (currentIndent === 0) { + tree.push(currentNode); + } else { + let parentIndex = rowIndex - 1; + + while (parentIndex >= 0 && this.rows[parentIndex].meta.indent >= currentIndent) { + parentIndex--; + } + + if (parentIndex >= 0) { + rowMap[parentIndex].children.push(currentNode); + } + } + } + + // Sort Tree + this._sortTree(tree, colIndex, sortOrder); + + // Row View Order + let flattenedTree = []; + + let traverseNode = (node) => { + flattenedTree.push(node.parent); + if (node.children) { + node.children.forEach(child => traverseNode(child)); + } + }; + + tree.forEach(node => traverseNode(node)); + this.rowViewOrder = flattenedTree; + } + + _sortTree(tree, colIndex, sortOrder) { + if (!tree || tree.length === 0) return; + + tree.sort((a, b) => this.compareContent(a.parent, b.parent, colIndex, sortOrder)); + tree.forEach(node => { + this._sortTree(node.children, colIndex, sortOrder); + }); + } + + compareContent(a, b, colIndex, sortOrder) { + const aIndex = a; + const bIndex = b; + + let aContent = this.getCell(colIndex, a).content; + let bContent = this.getCell(colIndex, b).content; + aContent = aContent == null ? '' : aContent; + bContent = bContent == null ? '' : bContent; + + if (sortOrder === 'none') { + return aIndex - bIndex; + } else if (sortOrder === 'asc') { + if (aContent < bContent) return -1; + if (aContent > bContent) return 1; + if (aContent === bContent) return 0; + } else if (sortOrder === 'desc') { + if (aContent < bContent) return 1; + if (aContent > bContent) return -1; + if (aContent === bContent) return 0; + } + return 0; + }; + reverseArray(array) { let left = null; let right = null; @@ -2952,7 +2998,11 @@ class CellManager { this.clearSelection(); this._selectedCells = cells.map(index => this.getCell$(...index)); requestAnimationFrame(() => { - this._selectedCells.map($cell => $cell.classList.add('dt-cell--highlight')); + this._selectedCells.forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.add('dt-cell--highlight'); + } + }); }); return true; } @@ -3011,8 +3061,11 @@ class CellManager { } clearSelection() { - (this._selectedCells || []) - .forEach($cell => $cell.classList.remove('dt-cell--highlight')); + (this._selectedCells || []).forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.remove('dt-cell--highlight'); + } + }); this._selectedCells = []; this.$selectionCursor = null; @@ -5965,7 +6018,7 @@ class DataTable { DataTable.instances = 0; var name = "@paralogic/frappe-datatable"; -var version = "1.17.4"; +var version = "1.17.5"; var description = "A modern datatable library for the web"; var main = "dist/frappe-datatable.cjs.js"; var unpkg = "dist/frappe-datatable.min.js"; diff --git a/dist/frappe-datatable.js b/dist/frappe-datatable.js index ff82c3c..1404983 100644 --- a/dist/frappe-datatable.js +++ b/dist/frappe-datatable.js @@ -302,18 +302,11 @@ var DataTable = (function (Sortable) { var _freeGlobal = freeGlobal; - var _freeGlobal$1 = /*#__PURE__*/Object.freeze({ - default: _freeGlobal, - __moduleExports: _freeGlobal - }); - - var freeGlobal$1 = ( _freeGlobal$1 && _freeGlobal ) || _freeGlobal$1; - /** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ - var root = freeGlobal$1 || freeSelf || Function('return this')(); + var root = _freeGlobal || freeSelf || Function('return this')(); var _root = root; @@ -473,6 +466,13 @@ var DataTable = (function (Sortable) { var isObjectLike_1 = isObjectLike; + var isObjectLike$1 = /*#__PURE__*/Object.freeze({ + default: isObjectLike_1, + __moduleExports: isObjectLike_1 + }); + + var isObjectLike$2 = ( isObjectLike$1 && isObjectLike_1 ) || isObjectLike$1; + /** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; @@ -495,7 +495,7 @@ var DataTable = (function (Sortable) { */ function isSymbol(value) { return typeof value == 'symbol' || - (isObjectLike_1(value) && _baseGetTag(value) == symbolTag); + (isObjectLike$2(value) && _baseGetTag(value) == symbolTag); } var isSymbol_1 = isSymbol; @@ -961,13 +961,6 @@ var DataTable = (function (Sortable) { var _getValue = getValue; - var _getValue$1 = /*#__PURE__*/Object.freeze({ - default: _getValue, - __moduleExports: _getValue - }); - - var getValue$1 = ( _getValue$1 && _getValue ) || _getValue$1; - /** * Gets the native function at `key` of `object`. * @@ -977,7 +970,7 @@ var DataTable = (function (Sortable) { * @returns {*} Returns the function if it's native, else `undefined`. */ function getNative(object, key) { - var value = getValue$1(object, key); + var value = _getValue(object, key); return _baseIsNative(value) ? value : undefined; } @@ -1350,6 +1343,13 @@ var DataTable = (function (Sortable) { var _isKeyable = isKeyable; + var _isKeyable$1 = /*#__PURE__*/Object.freeze({ + default: _isKeyable, + __moduleExports: _isKeyable + }); + + var isKeyable$1 = ( _isKeyable$1 && _isKeyable ) || _isKeyable$1; + /** * Gets the data for `map`. * @@ -1360,7 +1360,7 @@ var DataTable = (function (Sortable) { */ function getMapData(map, key) { var data = map.__data__; - return _isKeyable(key) + return isKeyable$1(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map; } @@ -1399,11 +1399,6 @@ var DataTable = (function (Sortable) { var _mapCacheGet = mapCacheGet; - var _mapCacheGet$1 = /*#__PURE__*/Object.freeze({ - default: _mapCacheGet, - __moduleExports: _mapCacheGet - }); - /** * Checks if a map value for `key` exists. * @@ -1440,8 +1435,6 @@ var DataTable = (function (Sortable) { var _mapCacheSet = mapCacheSet; - var mapCacheGet$1 = ( _mapCacheGet$1 && _mapCacheGet ) || _mapCacheGet$1; - /** * Creates a map cache object to store key-value pairs. * @@ -1463,7 +1456,7 @@ var DataTable = (function (Sortable) { // Add methods to `MapCache`. MapCache.prototype.clear = _mapCacheClear; MapCache.prototype['delete'] = _mapCacheDelete; - MapCache.prototype.get = mapCacheGet$1; + MapCache.prototype.get = _mapCacheGet; MapCache.prototype.has = _mapCacheHas; MapCache.prototype.set = _mapCacheSet; @@ -1553,11 +1546,6 @@ var DataTable = (function (Sortable) { var _baseFindIndex = baseFindIndex; - var _baseFindIndex$1 = /*#__PURE__*/Object.freeze({ - default: _baseFindIndex, - __moduleExports: _baseFindIndex - }); - /** * The base implementation of `_.isNaN` without support for number objects. * @@ -1595,8 +1583,6 @@ var DataTable = (function (Sortable) { var _strictIndexOf = strictIndexOf; - var baseFindIndex$1 = ( _baseFindIndex$1 && _baseFindIndex ) || _baseFindIndex$1; - /** * The base implementation of `_.indexOf` without `fromIndex` bounds checks. * @@ -1609,7 +1595,7 @@ var DataTable = (function (Sortable) { function baseIndexOf(array, value, fromIndex) { return value === value ? _strictIndexOf(array, value, fromIndex) - : baseFindIndex$1(array, _baseIsNaN, fromIndex); + : _baseFindIndex(array, _baseIsNaN, fromIndex); } var _baseIndexOf = baseIndexOf; @@ -1672,6 +1658,11 @@ var DataTable = (function (Sortable) { var _Set = Set; + var _Set$1 = /*#__PURE__*/Object.freeze({ + default: _Set, + __moduleExports: _Set + }); + /** * This method returns `undefined`. * @@ -1709,6 +1700,8 @@ var DataTable = (function (Sortable) { var _setToArray = setToArray; + var Set$1 = ( _Set$1 && _Set ) || _Set$1; + /** Used as references for various `Number` constants. */ var INFINITY = 1 / 0; @@ -1719,8 +1712,8 @@ var DataTable = (function (Sortable) { * @param {Array} values The values to add to the set. * @returns {Object} Returns the new set. */ - var createSet = !(_Set && (1 / _setToArray(new _Set([,-0]))[1]) == INFINITY) ? noop_1 : function(values) { - return new _Set(values); + var createSet = !(Set$1 && (1 / _setToArray(new Set$1([,-0]))[1]) == INFINITY) ? noop_1 : function(values) { + return new Set$1(values); }; var _createSet = createSet; @@ -2300,42 +2293,12 @@ var DataTable = (function (Sortable) { } _sortRows(colIndex, sortOrder) { - - if (this.currentSort.colIndex === colIndex) { - // reverse the array if only sortOrder changed - if ( - (this.currentSort.sortOrder === 'asc' && sortOrder === 'desc') || - (this.currentSort.sortOrder === 'desc' && sortOrder === 'asc') - ) { - this.reverseArray(this.rowViewOrder); - this.currentSort.sortOrder = sortOrder; - return; - } + if (this.options.treeView) { + this.treeSort(colIndex, sortOrder); + } else { + this.rowViewOrder.sort((a, b) => this.compareContent(a, b, colIndex, sortOrder)); } - this.rowViewOrder.sort((a, b) => { - const aIndex = a; - const bIndex = b; - - let aContent = this.getCell(colIndex, a).content; - let bContent = this.getCell(colIndex, b).content; - aContent = aContent == null ? '' : aContent; - bContent = bContent == null ? '' : bContent; - - if (sortOrder === 'none') { - return aIndex - bIndex; - } else if (sortOrder === 'asc') { - if (aContent < bContent) return -1; - if (aContent > bContent) return 1; - if (aContent === bContent) return 0; - } else if (sortOrder === 'desc') { - if (aContent < bContent) return 1; - if (aContent > bContent) return -1; - if (aContent === bContent) return 0; - } - return 0; - }); - if (this.hasColumnById('_rowIndex')) { // update row index const srNoColIndex = this.getColumnIndexById('_rowIndex'); @@ -2347,6 +2310,82 @@ var DataTable = (function (Sortable) { } } + treeSort(colIndex, sortOrder) { + let tree = []; + let rowMap = {}; + + // Build Tree + for (let i = 0; i < this.rows.length; i++) { + const rowIndex = this.rows[i].meta.rowIndex; + const currentIndent = this.rows[i].meta.indent; + + let currentNode = { parent: rowIndex, children: [] }; + rowMap[rowIndex] = currentNode; + + if (currentIndent === 0) { + tree.push(currentNode); + } else { + let parentIndex = rowIndex - 1; + + while (parentIndex >= 0 && this.rows[parentIndex].meta.indent >= currentIndent) { + parentIndex--; + } + + if (parentIndex >= 0) { + rowMap[parentIndex].children.push(currentNode); + } + } + } + + // Sort Tree + this._sortTree(tree, colIndex, sortOrder); + + // Row View Order + let flattenedTree = []; + + let traverseNode = (node) => { + flattenedTree.push(node.parent); + if (node.children) { + node.children.forEach(child => traverseNode(child)); + } + }; + + tree.forEach(node => traverseNode(node)); + this.rowViewOrder = flattenedTree; + } + + _sortTree(tree, colIndex, sortOrder) { + if (!tree || tree.length === 0) return; + + tree.sort((a, b) => this.compareContent(a.parent, b.parent, colIndex, sortOrder)); + tree.forEach(node => { + this._sortTree(node.children, colIndex, sortOrder); + }); + } + + compareContent(a, b, colIndex, sortOrder) { + const aIndex = a; + const bIndex = b; + + let aContent = this.getCell(colIndex, a).content; + let bContent = this.getCell(colIndex, b).content; + aContent = aContent == null ? '' : aContent; + bContent = bContent == null ? '' : bContent; + + if (sortOrder === 'none') { + return aIndex - bIndex; + } else if (sortOrder === 'asc') { + if (aContent < bContent) return -1; + if (aContent > bContent) return 1; + if (aContent === bContent) return 0; + } else if (sortOrder === 'desc') { + if (aContent < bContent) return 1; + if (aContent > bContent) return -1; + if (aContent === bContent) return 0; + } + return 0; + }; + reverseArray(array) { let left = null; let right = null; @@ -2993,7 +3032,11 @@ var DataTable = (function (Sortable) { this.clearSelection(); this._selectedCells = cells.map(index => this.getCell$(...index)); requestAnimationFrame(() => { - this._selectedCells.map($cell => $cell.classList.add('dt-cell--highlight')); + this._selectedCells.forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.add('dt-cell--highlight'); + } + }); }); return true; } @@ -3052,8 +3095,11 @@ var DataTable = (function (Sortable) { } clearSelection() { - (this._selectedCells || []) - .forEach($cell => $cell.classList.remove('dt-cell--highlight')); + (this._selectedCells || []).forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.remove('dt-cell--highlight'); + } + }); this._selectedCells = []; this.$selectionCursor = null; @@ -6006,7 +6052,7 @@ var DataTable = (function (Sortable) { DataTable.instances = 0; var name = "@paralogic/frappe-datatable"; - var version = "1.17.4"; + var version = "1.17.5"; var description = "A modern datatable library for the web"; var main = "dist/frappe-datatable.cjs.js"; var unpkg = "dist/frappe-datatable.min.js"; diff --git a/dist/frappe-datatable.min.js b/dist/frappe-datatable.min.js index 1699f1e..4cb3098 100644 --- a/dist/frappe-datatable.min.js +++ b/dist/frappe-datatable.min.js @@ -1 +1 @@ -var DataTable=function(t){"use strict";function e(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(){const t=document.createElement("div");e.style(t,{width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"}),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}function i(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function o(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function s(t){var e=Lt.call(t,jt),n=t[jt];try{t[jt]=void 0}catch(t){}var i=$t.call(t);return e?t[jt]=n:delete t[jt],i}function r(t){return zt.call(t)}function l(t){return null==t?void 0===t?Pt:Nt:Bt&&Bt in Object(t)?Wt(t):At(t)}function a(t){return null!=t&&"object"==typeof t}function c(t){return"symbol"==typeof t||Zt(t)&&Ut(t)==Xt}function u(t){if("number"==typeof t)return t;if(Yt(t))return Jt;if(vt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=vt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Qt,"");var n=ee.test(t);return n||ne.test(t)?ie(t.slice(2),n?2:8):te.test(t)?Jt:+t}function h(t,e,n){function i(e){var n=d,i=f;return d=f=void 0,y=e,m=t.apply(i,n)}function o(t){return y=t,g=setTimeout(l,e),b?i(t):m}function s(t){var n=t-y,i=e-(t-w);return C?le(i,p-n):i}function r(t){var n=t-w,i=t-y;return void 0===w||n>=e||n<0||C&&i>=p}function l(){var t=kt();if(r(t))return a(t);g=setTimeout(l,s(t))}function a(t){return g=void 0,v&&d?i(t):(d=f=void 0,m)}function c(){void 0!==g&&clearTimeout(g),y=0,d=w=f=g=void 0}function u(){return void 0===g?m:a(kt())}function h(){var t=kt(),n=r(t);if(d=arguments,f=this,w=t,n){if(void 0===g)return o(w);if(C)return g=setTimeout(l,e),i(w)}return void 0===g&&(g=setTimeout(l,e)),m}var d,f,p,m,g,w,y=0,b=!1,C=!1,v=!0;if("function"!=typeof t)throw new TypeError(se);return e=oe(e)||0,vt(n)&&(b=!!n.leading,p=(C="maxWait"in n)?re(oe(n.maxWait)||0,e):p,v="trailing"in n?!!n.trailing:v),h.cancel=c,h.flush=u,h}function d(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new TypeError(ce);return vt(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),ae(t,e,{leading:i,maxWait:e,trailing:o})}function f(t){if(!vt(t))return!1;var e=Ut(t);return e==de||e==fe||e==he||e==pe}function p(t){return!!ye&&ye in t}function m(t){if(null!=t){try{return Ce.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function g(t){return!(!vt(t)||be(t))&&(xe(t)?ke:Ie).test(Re(t))}function w(t,e){return null==t?void 0:t[e]}function y(t,e){var n=Me(t,e);return Oe(n)?n:void 0}function b(){this.__data__=$e?$e(null):{},this.size=0}function C(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function v(t){var e=this.__data__;if($e){var n=e[t];return n===De?void 0:n}return ze.call(e,t)?e[t]:void 0}function _(t){var e=this.__data__;return $e?void 0!==e[t]:We.call(e,t)}function x(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=$e&&void 0===e?Pe:e,this}function R(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}function O(t,e){var n=this.__data__,i=Ge(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}function M(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}function Z(t,e,n){for(var i=-1,o=null==t?0:t.length;++i=Ln){var c=e?null:On(t);if(c)return kn(c);r=!1,o=Tn,a=new Mn}else a=e?[]:l;t:for(;++i`-${t[0].toLowerCase()}`)}function nt(t){return Object.keys(t).map(e=>{const n=et(e);const i=t[e];if(void 0===i)return"";return`data-${n}="${i}" `}).join("").trim()}function it(t){var e=document.createElement("textarea");e.style.position="fixed",e.style.top=0,e.style.left=0,e.style.width="2em",e.style.height="2em",e.style.padding=0,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.value=t,document.body.appendChild(e),e.select();try{document.execCommand("copy")}catch(t){console.log("Oops, unable to copy")}document.body.removeChild(e)}function ot(t){return!isNaN(t)}function st(t,e=null){return(...n)=>new Promise(i=>{const o=()=>{const o=t.apply(e,n);i(o)};setTimeout(o)})}function rt(t,e,n){const i=n.reduce((t,n)=>{t[n]={get(){return e[n]}};return t},{});Object.defineProperties(t,i)}function lt(t){return void 0!==t||null!==t}function at(t){return!lt(t)}function ct(t){return!isNaN(t)}function ut(t){return Array.isArray(t)?t:[t]}function ht(t){return jn(t)}function dt(t,e){return t-e}function ft(t){return t.replace(/<[^>]*>/g,"")}function pt(t,e){return t?(Object.keys(e).forEach(n=>{let i=new RegExp(`{(${n})}`,"g");t=t.replace(i,e[n])}),t):t}function mt(t){if(!t)return"";let e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};return String(t).replace(/[&<>"'`=/]/g,t=>e[t]||t)}function gt(){return{en:Zn,de:Xn,fr:Yn,it:Jn}}function wt(t,e,n){let i=[];if(0===Object.keys(e).length)return t.map(t=>t.meta.rowIndex);for(let o in e){const s=e[o],r=i.length?i.map(e=>t[e]):t,l=r.map(t=>t[o]);let a=bt(s),c=yt(t,a,n);i=c?c(a.text,l):l.map(t=>t.rowIndex)}return i}function yt(t,e,n){const i=e=>{let i=Nn.getCustomCellFormatter(e);if(i&&e.content){const o=n.getData(e.rowIndex);return e.html=i(e.content,t[e.rowIndex],e.column,o,!0),ft(e.html)}return e.content||""},o=t=>String(ft(t.html||"")||i(t)).toLowerCase(),s=t=>parseFloat(t.content),r=(t,e)=>{if(t.column.compareValue){const n=t.column.compareValue(t,e);if(n&&Array.isArray(n))return n}const n=s(t);if(!isNaN(n))return[n,e];return[o(t),e]};return{contains(t,e){return e.filter(e=>{const n=o(e);const i=(t||"").toLowerCase();return!i||n.includes(i)}).map(t=>t.rowIndex)},greaterThan(t,e){return e.filter(e=>{const[n,i]=r(e,t);return n>i}).map(t=>t.rowIndex)},lessThan(t,e){return e.filter(e=>{const[n,i]=r(e,t);return nt.rowIndex)},equals(t,e){return e.filter(e=>{const n=parseFloat(e.content);return n===t}).map(t=>t.rowIndex)},notEquals(t,e){return e.filter(e=>{const n=parseFloat(e.content);return n!==t}).map(t=>t.rowIndex)},range(t,e){return e.filter(e=>{const n=r(e,t[0]);const i=r(e,t[1]);const o=n[0];return o>=n[1]&&o<=i[1]}).map(t=>t.rowIndex)},containsNumber(t,e){return e.filter(e=>{let n=parseFloat(t,10);let i=t;let r=s(e);let l=o(e);return n===r||l.includes(i)}).map(t=>t.rowIndex)}}[e.type]}function bt(t=""){if(0===t.length)return{};let e=t;return[">","<","="].includes(e[0])?e=t.slice(1):e.startsWith("!=")&&(e=t.slice(2)),t.startsWith(">")&&e?{type:"greaterThan",text:e.trim()}:t.startsWith("<")&&e?{type:"lessThan",text:e.trim()}:t.startsWith("=")&&ct(e)?{type:"equals",text:Number(t.slice(1).trim())}:ct(e)?{type:"containsNumber",text:e}:t.startsWith("!=")&&ct(e)?{type:"notEquals",text:Number(t.slice(2).trim())}:2===t.split(":").length?(e=t.split(":"),{type:"range",text:e.map(t=>t.trim())}):{type:"contains",text:e.toLowerCase()}}function Ct(t){return{columns:[],data:[],dropdownButton:Wn.chevronDown,headerDropdown:[{label:t.translate("Sort Ascending"),action:function(t){this.sortColumn(t.colIndex,"asc")}},{label:t.translate("Sort Descending"),action:function(t){this.sortColumn(t.colIndex,"desc")}},{label:t.translate("Reset sorting"),action:function(t){this.sortColumn(t.colIndex,"none")}},{label:t.translate("Remove column"),action:function(t){this.removeColumn(t.colIndex)}}],events:{onRemoveColumn(t){},onSwitchColumn(t,e){},onSortColumn(t){},onCheckRow(t){},onDestroy(){}},hooks:{columnTotal:null},sortIndicator:{asc:"↑",desc:"↓",none:""},overrideComponents:{},filterRows:wt,freezeMessage:"",getEditor:null,serialNoColumn:!0,checkboxColumn:!1,clusterize:!0,logs:!1,layout:"fixed",noDataMessage:t.translate("No Data"),cellHeight:40,minimumColumnWidth:30,inlineFilters:!1,treeView:!1,checkedRowStatus:!0,dynamicRowHeight:!1,pasteFromClipboard:!1,showTotalRow:!1,direction:"ltr",disableReorderColumn:!1}}t=t&&t.hasOwnProperty("default")?t.default:t,e.each=((t,e)=>"string"==typeof t?Array.from((e||document).querySelectorAll(t)):t||null),e.create=((t,n)=>{let i=document.createElement(t);for(let t in n){let o=n[t];if("inside"===t)e(o).appendChild(i);else if("around"===t){let t=e(o);t.parentNode.insertBefore(i,t),i.appendChild(t)}else"styles"===t?"object"==typeof o&&Object.keys(o).map(t=>{i.style[t]=o[t]}):t in i?i[t]=o:i.setAttribute(t,o)}return i}),e.on=((t,n,i,o)=>{o?e.delegate(t,n,i,o):(o=i,e.bind(t,n,o))}),e.off=((t,e,n)=>{t.removeEventListener(e,n)}),e.bind=((t,e,n)=>{e.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}),e.delegate=((t,e,n,i)=>{t.addEventListener(e,function(t){const e=t.target.closest(n);e&&(t.delegatedTarget=e,i.call(this,t,e))})}),e.unbind=((t,e)=>{if(t)for(let n in e){let i=e[n];n.split(/\s+/).forEach(function(e){t.removeEventListener(e,i)})}}),e.fire=((t,e,n)=>{let i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!0);for(let t in n)i[t]=n[t];return t.dispatchEvent(i)}),e.data=((t,e)=>{if(!e)return t.dataset;for(const n in e)t.dataset[n]=e[n]}),e.style=((t,n)=>{if("string"==typeof n)return e.getStyle(t,n);Array.isArray(t)||(t=[t]);t.map(t=>{for(const e in n)t.style[e]=n[e]})}),e.removeStyle=((t,e)=>{Array.isArray(t)||(t=[t]);Array.isArray(e)||(e=[e]);t.map(t=>{for(const n of e)t.style[n]=""})}),e.getStyle=((t,e)=>{if(!e)return getComputedStyle(t);let n=getComputedStyle(t)[e];["width","height"].includes(e)&&(n=parseFloat(n));return n}),e.closest=((t,n)=>{if(!n)return null;if(n.matches(t))return n;return e.closest(t,n.parentNode)}),e.inViewport=((t,e)=>{const{top:top,left:left,bottom:bottom,right:right}=t.getBoundingClientRect();const{top:pTop,left:pLeft,bottom:pBottom,right:pRight}=e.getBoundingClientRect();return top>=pTop&&left>=pLeft&&bottom<=pBottom&&right<=pRight}),e.inVerticalViewport=((t,e)=>{const{top:top,bottom:bottom}=t.getBoundingClientRect();const{top:pTop,bottom:pBottom}=e.getBoundingClientRect();return top>=pTop&&bottom<=pBottom}),e.scrollTop=function(t,e){t.scrollTop=e},e.scrollbarSize=function(){return e.scrollBarSizeValue||(e.scrollBarSizeValue=n()),e.scrollBarSizeValue},e.hasVerticalOverflow=function(t){return t.scrollHeight>t.offsetHeight+10},e.hasHorizontalOverflow=function(t){return t.scrollWidth>t.offsetWidth+10},e.measureTextWidth=function(t){const e=document.createElement("div");return e.style.position="absolute",e.style.visibility="hidden",e.style.height="auto",e.style.width="auto",e.style.whiteSpace="nowrap",e.style.top="-9999px",e.innerText=t,document.body.appendChild(e),e.clientWidth+1};var vt=i,_t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},xt="object"==typeof _t&&_t&&_t.Object===Object&&_t,Rt=Object.freeze({default:xt,__moduleExports:xt}),It=Rt&&xt||Rt,St="object"==typeof self&&self&&self.Object===Object&&self,Tt=It||St||Function("return this")(),Et=Object.freeze({default:Tt,__moduleExports:Tt}),Ht=Et&&Tt||Et,kt=function(){return Ht.Date.now()},Ot=Ht.Symbol,Mt=Object.prototype,Lt=Mt.hasOwnProperty,$t=Mt.toString,jt=Ot?Ot.toStringTag:void 0,Ft=s,Dt=Object.freeze({default:Ft,__moduleExports:Ft}),zt=Object.prototype.toString,At=r,Wt=Dt&&Ft||Dt,Nt="[object Null]",Pt="[object Undefined]",Bt=Ot?Ot.toStringTag:void 0,Vt=l,qt=Object.freeze({default:Vt,__moduleExports:Vt}),Kt=a,Gt=Object.freeze({default:Kt,__moduleExports:Kt}),Ut=qt&&Vt||qt,Zt=Gt&&Kt||Gt,Xt="[object Symbol]",Yt=c,Jt=NaN,Qt=/^\s+|\s+$/g,te=/^[-+]0x[0-9a-f]+$/i,ee=/^0b[01]+$/i,ne=/^0o[0-7]+$/i,ie=parseInt,oe=u,se="Expected a function",re=Math.max,le=Math.min,ae=h,ce="Expected a function",ue=d,he="[object AsyncFunction]",de="[object Function]",fe="[object GeneratorFunction]",pe="[object Proxy]",me=f,ge=Object.freeze({default:me,__moduleExports:me}),we=Ht["__core-js_shared__"],ye=function(){var t=/[^.]+$/.exec(we&&we.keys&&we.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),be=p,Ce=Function.prototype.toString,ve=m,_e=Object.freeze({default:ve,__moduleExports:ve}),xe=ge&&me||ge,Re=_e&&ve||_e,Ie=/^\[object .+?Constructor\]$/,Se=Function.prototype,Te=Object.prototype,Ee=Se.toString,He=Te.hasOwnProperty,ke=RegExp("^"+Ee.call(He).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Oe=g,Me=w,Le=y,$e=Le(Object,"create"),je=b,Fe=C,De="__lodash_hash_undefined__",ze=Object.prototype.hasOwnProperty,Ae=v,We=Object.prototype.hasOwnProperty,Ne=_,Pe="__lodash_hash_undefined__",Be=x;R.prototype.clear=je,R.prototype.delete=Fe,R.prototype.get=Ae,R.prototype.has=Ne,R.prototype.set=Be;var Ve=R,qe=I,Ke=S,Ge=T,Ue=Array.prototype.splice,Ze=E,Xe=H,Ye=k,Je=O;M.prototype.clear=qe,M.prototype.delete=Ze,M.prototype.get=Xe,M.prototype.has=Ye,M.prototype.set=Je;var Qe=M,tn=Le(Ht,"Map"),en=L,nn=$,on=j,sn=F,rn=D,ln=z,an=A;W.prototype.clear=en,W.prototype.delete=sn,W.prototype.get=rn,W.prototype.has=ln,W.prototype.set=an;var cn=W,un="__lodash_hash_undefined__",hn=N,dn=Object.freeze({default:hn,__moduleExports:hn}),fn=P,pn=dn&&hn||dn;B.prototype.add=B.prototype.push=pn,B.prototype.has=fn;var mn=B,gn=Object.freeze({default:mn,__moduleExports:mn}),wn=V,yn=q,bn=Object.freeze({default:yn,__moduleExports:yn}),Cn=K,vn=Object.freeze({default:Cn,__moduleExports:Cn}),_n=bn&&yn||bn,xn=vn&&Cn||vn,Rn=G,In=U,Sn=Z,Tn=X,En=Le(Ht,"Set"),Hn=Y,kn=J,On=En&&1/kn(new En([,-0]))[1]==1/0?function(t){return new En(t)}:Hn,Mn=gn&&mn||gn,Ln=200,$n=Q,jn=tt;let Fn=ue,Dn=ae;class zn{constructor(t){this.options=t,this.sortRows=st(this.sortRows,this),this.switchColumn=st(this.switchColumn,this),this.removeColumn=st(this.removeColumn,this),this.options.filterRows=st(this.options.filterRows,this)}init(t,e){t||(t=this.options.data),e&&(this.options.columns=e),this.data=t,this.rowCount=0,this.columns=[],this.rows=[],this.flatData=[],this.prepareColumns(),this.prepareRows(),this.prepareTreeRows(),this.prepareRowView(),this.prepareNumericColumns()}get currentSort(){return this.columns.find(t=>"none"!==t.sortOrder)||{colIndex:-1,sortOrder:"none"}}prepareColumns(){this.columns=[],this.validateColumns(),this.prepareDefaultColumns(),this.prepareHeader()}prepareDefaultColumns(){if(this.options.checkboxColumn&&!this.hasColumnById("_checkbox")){const t={id:"_checkbox",content:this.getCheckboxHTML(),editable:!1,resizable:!1,sortable:!1,focusable:!1,dropdown:!1,width:32};this.columns.push(t)}if(this.options.serialNoColumn&&!this.hasColumnById("_rowIndex")){let t={id:"_rowIndex",content:"",align:"center",editable:!1,resizable:!1,focusable:!1,dropdown:!1};this.columns.push(t)}}prepareHeader(){let t=this.columns.concat(this.options.columns);const e={isHeader:1,editable:!0,sortable:!0,resizable:!0,focusable:!0,dropdown:!0,width:null,format:t=>{if(null===t||void 0===t)return"";return t+""}};this.columns=t.map((t,e)=>this.prepareCell(t,e)).map(t=>Object.assign({},e,t)).map(t=>{t.content=t.content||t.name||"";t.id=t.id||t.content;return t})}prepareCell(t,e){const n={content:"",sortOrder:"none",colIndex:e,column:this.columns[e]};return null!==t&&"object"==typeof t?Object.assign(n,t):n.content=t,n}prepareNumericColumns(){const t=this.getRow(0);t&&(this.columns=this.columns.map((e,n)=>{const i=t[n].content;!e.align&&ot(i)&&(e.align="right");return e}))}prepareRows(){this.validateData(this.data),this.rows=[];for(let t of this.data)this.addRow(t)}addRow(t){Array.isArray(t)?this.addArrayRow(t):t._isGroup?this.addGroupObject(t):this.addObjectRow(t)}addArrayRow(t){const e=this._getNextRowCount();let n=[],i={rowIndex:e};for(this.options.checkboxColumn&&n.push(this.getCheckboxHTML()),this.options.serialNoColumn&&n.push(e+1+""),n=n.concat(t);n.length{if(ct(t.meta.indent)){const n=this.getRow(e+1);t.meta.isLeaf=!n||at(n.meta.indent)||n.meta.indent<=t.meta.indent,t.meta.isTreeNodeClose=!1}})}prepareRowView(){this.rowViewOrder=this.rows.map(t=>t.meta.rowIndex)}prepareRow(t,e){const n={rowIndex:e.rowIndex,indent:e.indent};return t=t.map((t,e)=>this.prepareCell(t,e)).map(t=>Object.assign({},n,t)),t.meta=e,t}validateColumns(){const t=this.options.columns;if(!Array.isArray(t))throw new An("`columns` must be an array");t.forEach((t,e)=>{if("string"!=typeof t&&"object"!=typeof t)throw new An(`column "${e}" must be a string or an object`)})}validateData(t){if(Array.isArray(t)&&(0===t.length||Array.isArray(t[0])||"object"==typeof t[0]))return!0;throw new An("`data` must be an array of arrays or objects")}appendRows(t){this.validateData(t),this.rows.push(...this.prepareRows(t)),this.flatData.push(...t)}sortRows(t,e="none"){t=+t,this.getColumns().map(n=>{n.colIndex===t?n.sortOrder=e:n.sortOrder="none"}),this._sortRows(t,e)}_sortRows(t,e){if(this.currentSort.colIndex===t&&("asc"===this.currentSort.sortOrder&&"desc"===e||"desc"===this.currentSort.sortOrder&&"asc"===e))return this.reverseArray(this.rowViewOrder),void(this.currentSort.sortOrder=e);if(this.rowViewOrder.sort((n,i)=>{const o=n;const s=i;let r=this.getCell(t,n).content;let l=this.getCell(t,i).content;r=null==r?"":r;l=null==l?"":l;if("none"===e)return o-s;if("asc"===e){if(rl)return 1;if(r===l)return 0}else if("desc"===e){if(rl)return-1;if(r===l)return 0}return 0}),this.hasColumnById("_rowIndex")){const t=this.getColumnIndexById("_rowIndex");this.rows.forEach((e,n)=>{const i=this.rowViewOrder.indexOf(n);const o=e[t];o.content=i+1+""})}}reverseArray(t){let e=null,n=null;for(e=0,n=t.length-1;e{const i=Object.assign({},n[t],{colIndex:e});const o=Object.assign({},n[e],{colIndex:t});n[e]=i;n[t]=o})}removeColumn(t){t=+t;const e=e=>e.colIndex!==t,n=(t,e)=>Object.assign({},t,{colIndex:e});this.columns=this.columns.filter(e).map(n),this.rows.forEach(e=>{e.splice(t,1);e.forEach((t,e)=>{t.colIndex=e})})}updateRow(t,e){if(t.lengtht[0].rowIndex===e);return this.rows[i]=n,n}updateCell(t,e,n){let i;"object"==typeof t&&(t=(i=t).colIndex,e=i.rowIndex,n=i),i=this.getCell(t,e);for(let t in n){const e=n[t];void 0!==e&&(i[t]=e)}return i}updateColumn(t,e){const n=this.getColumn(t);for(let t in e){const i=e[t];void 0!==i&&(n[t]=i)}return n}filterRows(t){return this.options.filterRows(this.rows,t,this).then(t=>{t||(t=this.getAllRowIndices());t.then||(t=Promise.resolve(t));return t.then(t=>{this._filteredRows=t;const e=this.getAllRowIndices().filter(e=>!t.includes(e));return{rowsToHide:e,rowsToShow:t}})})}getFilteredRowIndices(){return this._filteredRows||this.getAllRowIndices()}getAllRowIndices(){return this.rows.map(t=>t.meta.rowIndex)}getRowCount(){return this.rowCount}_getNextRowCount(){const t=this.rowCount;return this.rowCount++,t}getRows(t,e){return this.rows.slice(t,e)}getRowsForView(t,e){return this.rowViewOrder.map(t=>this.rows[t]).slice(t,e)}getColumns(t){let e=this.columns;return t&&(e=e.slice(this.getStandardColumnCount())),e}getStandardColumnCount(){return this.options.checkboxColumn&&this.options.serialNoColumn?2:this.options.checkboxColumn||this.options.serialNoColumn?1:0}getColumnCount(t){let e=this.columns.length;return t&&(e-=this.getStandardColumnCount()),e}getColumn(t){return(t=+t)<0&&(t=this.columns.length+t),this.columns.find(e=>e.colIndex===t)}getColumnById(t){return this.columns.find(e=>e.id===t)}getRow(t){return t=+t,this.rows[t]}getCell(t,e){return e=+e,t=+t,this.getRow(e)[t]}getChildren(t){t=+t;const e=this.getRow(t).meta.indent,n=[];for(let i=t+1;ie&&n.push(i),t.meta.indent===e))break}return n}getImmediateChildren(t){t=+t;const e=this.getRow(t).meta.indent,n=[],i=e+1;for(let o=t+1;oi)&&(t.meta.indent===i&&n.push(o),t.meta.indent===e))break}return n}get(){return{columns:this.columns,rows:this.rows}}getData(t){return this.flatData[t]}hasColumn(t){return Boolean(this.columns.find(e=>e.content===t))}hasColumnById(t){return Boolean(this.columns.find(e=>e.id===t))}getColumnIndex(t){return this.columns.findIndex(e=>e.content===t)}getColumnIndexById(t){return this.columns.findIndex(e=>e.id===t)}getCheckboxHTML(){return''}}class An extends TypeError{}let Wn={chevronDown:'',chevronRight:''};class Nn{constructor(t){this.instance=t,rt(this,this.instance,["wrapper","options","style","header","bodyScrollable","columnmanager","rowmanager","datamanager","keyboard"]),this.bindEvents()}bindEvents(){this.bindFocusCell(),this.bindEditCell(),this.bindKeyboardSelection(),this.bindCopyCellContents(),this.bindMouseEvents(),this.bindTreeEvents()}bindFocusCell(){this.bindKeyboardNav()}bindEditCell(){this.$editingCell=null,e.on(this.bodyScrollable,"dblclick",".dt-cell",(t,e)=>{this.activateEditing(e)}),this.keyboard.on("enter",()=>{this.$focusedCell&&!this.$editingCell?this.activateEditing(this.$focusedCell):this.$editingCell&&this.deactivateEditing()})}bindKeyboardNav(){const t=t=>{if(!this.$focusedCell||this.$editingCell)return!1;let n=this.$focusedCell;const{rowIndex:rowIndex,colIndex:colIndex}=e.data(n);"left"===t?n=this.getLeftMostCell$(rowIndex):"right"===t?n=this.getRightMostCell$(rowIndex):"up"===t?n=this.getTopMostCell$(colIndex):"down"===t&&(n=this.getBottomMostCell$(colIndex));this.focusCell(n);return!0};["left","right","up","down","tab","shift+tab"].map(t=>this.keyboard.on(t,()=>this.focusCellInDirection(t))),["left","right","up","down"].map(e=>this.keyboard.on(`ctrl+${e}`,()=>t(e))),this.keyboard.on("esc",()=>{this.deactivateEditing(!1);this.columnmanager.toggleFilter(!1)}),this.options.inlineFilters&&(this.keyboard.on("ctrl+f",t=>{const n=e.closest(".dt-cell",t.target);const{colIndex:colIndex}=e.data(n);this.activateFilter(colIndex);return!0}),e.on(this.header,"focusin",".dt-filter",()=>{this.unfocusCell(this.$focusedCell)}))}bindKeyboardSelection(){const t=t=>{let e=this.getSelectionCursor();"left"===t?e=this.getLeftCell$(e):"right"===t?e=this.getRightCell$(e):"up"===t?e=this.getAboveCell$(e):"down"===t&&(e=this.getBelowCell$(e));return e};["left","right","up","down"].map(e=>this.keyboard.on(`shift+${e}`,()=>this.selectArea(t(e))))}bindCopyCellContents(){this.keyboard.on("ctrl+c",()=>{const t=this.copyCellContents(this.$focusedCell,this.$selectionCursor);const e=this.instance.translate("{count} cells copied",{count:t});t&&this.instance.showToastMessage(e,2)}),this.options.pasteFromClipboard&&this.keyboard.on("ctrl+v",t=>{this.instance.pasteTarget.focus();setTimeout(()=>{const t=this.instance.pasteTarget.value;this.instance.pasteTarget.value="";this.pasteContentInCell(t)},10);return!1})}bindMouseEvents(){let t=null;e.on(this.bodyScrollable,"mousedown",".dt-cell",n=>{t=!0;this.focusCell(e(n.delegatedTarget))}),e.on(this.bodyScrollable,"mouseup",()=>{t=!1});const n=n=>{if(!t)return;this.selectArea(e(n.delegatedTarget))};e.on(this.bodyScrollable,"mousemove",".dt-cell",Fn(n,50))}bindTreeEvents(){e.on(this.bodyScrollable,"click",".dt-tree-node__toggle",(t,n)=>{const i=e.closest(".dt-cell",n);const{rowIndex:rowIndex}=e.data(i);i.classList.contains("dt-cell--tree-close")?this.rowmanager.openSingleNode(rowIndex):this.rowmanager.closeSingleNode(rowIndex)})}focusCell(t,{skipClearSelection:skipClearSelection=0,skipDOMFocus:skipDOMFocus=0,skipScrollToCell:skipScrollToCell=0}={}){if(t&&t!==this.$editingCell){const{colIndex:colIndex,isHeader:isHeader}=e.data(t);isHeader||!1!==this.columnmanager.getColumn(colIndex).focusable&&(skipScrollToCell||this.scrollToCell(t),this.deactivateEditing(),skipClearSelection||this.clearSelection(),this.$focusedCell&&this.$focusedCell.classList.remove("dt-cell--focus"),this.$focusedCell=t,t.classList.add("dt-cell--focus"),skipDOMFocus?this.wrapper.focus():t.focus(),this.highlightRowColumnHeader(t))}}unfocusCell(t){t&&(t.classList.remove("dt-cell--focus"),this.$focusedCell=null,this.lastHeaders&&this.lastHeaders.forEach(t=>t&&t.classList.remove("dt-cell--highlight")))}highlightRowColumnHeader(t){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(t),n=`.dt-cell--header-${colIndex}`,i=`.dt-cell--${this.datamanager.getColumnIndexById("_rowIndex")}-${rowIndex}`;this.lastHeaders&&this.lastHeaders.forEach(t=>t&&t.classList.remove("dt-cell--highlight"));const o=e(n,this.wrapper),s=e(i,this.wrapper);this.lastHeaders=[o,s],this.lastHeaders.forEach(t=>t&&t.classList.add("dt-cell--highlight"))}selectAreaOnClusterChanged(){if(this.$focusedCell&&this.$selectionCursor){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$selectionCursor),t=this.getCell$(colIndex,rowIndex);if(t&&t!==this.$selectionCursor){const n=e.data(this.$focusedCell);this.$focusedCell=this.getCell$(n.colIndex,n.rowIndex),this.selectArea(t)}}}focusCellOnClusterChanged(){if(this.$focusedCell){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$focusedCell),t=this.getCell$(colIndex,rowIndex);t&&this.focusCell(t,{skipClearSelection:1,skipDOMFocus:1,skipScrollToCell:1})}}selectArea(t){this.$focusedCell&&(this.$editingCell||this._selectArea(this.$focusedCell,t)&&(this.$selectionCursor=t))}_selectArea(t,e){if(t===e)return!1;const n=this.getCellsInRange(t,e);return!!n&&(this.clearSelection(),this._selectedCells=n.map(t=>this.getCell$(...t)),requestAnimationFrame(()=>{this._selectedCells.map(t=>t.classList.add("dt-cell--highlight"))}),!0)}getCellsInRange(t,n){let i,o,s,r;if("number"==typeof t)[i,o,s,r]=arguments;else if("object"==typeof t){if(!t||!n)return!1;const l=e.data(t),a=e.data(n);i=+l.colIndex,o=+l.rowIndex,s=+a.colIndex,r=+a.rowIndex}if(o>r&&([o,r]=[r,o]),i>s&&([i,s]=[s,i]),this.isStandardCell(i)||this.isStandardCell(s))return!1;const l=[];let a=i,c=o;const u=[];for(;c<=r;)u.push(c),c+=1;return u.map(t=>{for(;a<=s;)l.push([a,t]),a++;a=i}),l}clearSelection(){(this._selectedCells||[]).forEach(t=>t.classList.remove("dt-cell--highlight")),this._selectedCells=[],this.$selectionCursor=null}getSelectionCursor(){return this.$selectionCursor||this.$focusedCell}activateEditing(t){this.focusCell(t);const{rowIndex:rowIndex,colIndex:colIndex}=e.data(t),n=this.columnmanager.getColumn(colIndex);if(!n||!1!==n.editable&&!1!==n.focusable){const i=this.getCell(colIndex,rowIndex);if(!i||!1!==i.editable){if(this.$editingCell){const{_rowIndex:_rowIndex,_colIndex:_colIndex}=e.data(this.$editingCell);if(rowIndex===_rowIndex&&colIndex===_colIndex)return}this.$editingCell=t,t.classList.add("dt-cell--editing");const o=e(".dt-cell__edit",t);o.innerHTML="";const s=this.getEditor(colIndex,rowIndex,i.content,o);s&&(this.currentCellEditor=s,s.initValue(i.content,rowIndex,n))}}}deactivateEditing(t=!0){t&&this.submitEditing(),this.$focusedCell&&this.$focusedCell.focus(),this.$editingCell&&(this.$editingCell.classList.remove("dt-cell--editing"),this.$editingCell=null)}getEditor(t,e,n,i){const o=this.datamanager.getColumn(t),s=this.datamanager.getRow(e),r=this.datamanager.getData(e);let l=this.options.getEditor?this.options.getEditor(t,e,n,i,o,s,r):this.getDefaultEditor(i);return!1!==l&&(void 0===l&&(l=this.getDefaultEditor(i)),l)}getDefaultEditor(t){const n=e.create("input",{class:"dt-input",type:"text",inside:t});return{initValue(t){n.focus(),n.value=t},getValue(){return n.value},setValue(t){n.value=t}}}submitEditing(){let t=Promise.resolve();if(!this.$editingCell)return t;const n=this.$editingCell,{rowIndex:rowIndex,colIndex:colIndex}=e.data(n),i=this.datamanager.getColumn(colIndex);if(n){const e=this.currentCellEditor;if(e){let o=e.getValue();o&&o.then||(o=Promise.resolve(o)),t=o.then(t=>{const o=this.getCell(colIndex,rowIndex).content;if(o===t)return!1;const s=e.setValue(t,rowIndex,i);this.updateCell(colIndex,rowIndex,t,!0);n.focus();s&&s.then&&s.catch(t=>{console.log(t);this.updateCell(colIndex,rowIndex,o)});return s})}}return this.currentCellEditor=null,t}copyCellContents(t,n){if(!n&&t){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(t),n=this.getCell(colIndex,rowIndex);return it(n.content),1}const i=this.getCellsInRange(t,n);if(!i)return 0;const o=i.map(t=>this.getCell(...t)).reduce((t,e)=>{const n=e.rowIndex;t[n]=t[n]||[];t[n].push(e.content);return t},[]);return it(o.map(t=>t.join("\t")).join("\n")),o.reduce((t,e)=>t+e.length,0)}pasteContentInCell(t){if(this.$focusedCell){const n=t.split("\n").map(t=>t.split("\t")).filter(t=>t.length&&t.every(t=>t));let{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$focusedCell),i={colIndex:+colIndex,rowIndex:+rowIndex};n.forEach((t,e)=>{let n=e+i.rowIndex;t.forEach((t,e)=>{let o=e+i.colIndex;this.updateCell(o,n,t,!0)})})}}activateFilter(t){this.columnmanager.toggleFilter(),this.columnmanager.focusFilter(t),this.columnmanager.isFilterShown||this.$focusedCell&&this.$focusedCell.focus()}updateCell(t,e,n,i=!1){const o=this.datamanager.updateCell(t,e,{content:n});this.refreshCell(o,i)}refreshCell(t,n=!1){e(this.selector(t.colIndex,t.rowIndex),this.bodyScrollable).innerHTML=this.getCellContent(t,n)}toggleTreeButton(t,e){const n=this.columnmanager.getFirstColumnIndex(),i=this.getCell$(n,t);i&&i.classList[e?"remove":"add"]("dt-cell--tree-close")}isStandardCell(t){return t\n ${this.getCellContent(t)}\n \n `}getCellContent(t,e=!1){const{isHeader:isHeader,isFilter:isFilter,colIndex:colIndex}=t,n=!isHeader&&!1!==t.editable?this.getEditCellHTML(colIndex):"",i=isHeader&&!1!==t.sortable?`\n ${this.options.sortIndicator[t.sortOrder]}\n `:"",o=isHeader&&!1!==t.resizable?'':"",s=isHeader&&!1!==t.dropdown?this.columnmanager.getDropdownHTML():"";let r,l=Nn.getCustomCellFormatter(t);if(isHeader||isFilter||!l)r=t.content;else if(!t.html||e){const e=this.datamanager.getRow(t.rowIndex),n=this.datamanager.getData(t.rowIndex);r=l(t.content,e,t.column,n)}else r=t.html;if(t.html=r,this.options.treeView&&!isHeader&&!isFilter&&void 0!==t.indent){const e=this.datamanager.getRow(t.rowIndex+1),n=e&&e.meta.indent>t.indent,i=this.datamanager.getColumnIndexById("_rowIndex")+1;if(i===t.colIndex){const e=20*(t.indent||0),i=n?`\n ${Wn.chevronDown}\n ${Wn.chevronRight}\n `:"";r=`\n ${i}\n ${r}\n `}}let a=`\n
\n ${r}\n ${i}\n ${o}\n ${s}\n
\n ${n}\n `,c=document.createElement("div");c.innerHTML=r;let u=c.textContent;return u=u.replace(/\s+/g," ").trim(),a=a.replace(">",` title="${mt(u)}">`)}getEditCellHTML(t){return`
`}selector(t,e){return`.dt-cell--${t}-${e}`}static getCustomCellFormatter(t){return t.format||t.column&&t.column.format||null}}class Pn{constructor(t){this.instance=t,rt(this,this.instance,["options","fireEvent","header","datamanager","cellmanager","style","wrapper","rowmanager","bodyScrollable","bodyRenderer"]),this.bindEvents()}renderHeader(){this.header.innerHTML="
",this.refreshHeader()}refreshHeader(){const t=this.datamanager.getColumns();e("div",this.header).innerHTML=this.getHeaderHTML(t),this.$filterRow=e(".dt-row-filter",this.header),this.$filterRow&&e.style(this.$filterRow,{display:"none"}),this.$columnMap=[],this.bindMoveColumn()}getHeaderHTML(t){let e=this.rowmanager.getRowHTML(t,{isHeader:1});return this.options.inlineFilters&&(e+=this.rowmanager.getRowHTML(t,{isFilter:1})),e}bindEvents(){this.bindDropdown(),this.bindResizeColumn(),this.bindPerfectColumnWidth(),this.bindFilter()}bindDropdown(){function t(t){i.hideDropdown()}this.instance.dropdownContainer.innerHTML=this.getDropdownListHTML(),this.$dropdownList=this.instance.dropdownContainer.firstElementChild,e.on(this.header,"click",".dt-dropdown__toggle",t=>{this.openDropdown(t)});const n=e=>{const n=[".dt-dropdown__toggle",".dt-dropdown__toggle *",".dt-dropdown__list",".dt-dropdown__list *"].join(",");if(e.target.matches(n))return;t()};e.on(document.body,"click",n),document.addEventListener("scroll",t,!0),this.instance.on("onDestroy",()=>{e.off(document.body,"click",n);e.off(document,"scroll",t)}),e.on(this.$dropdownList,"click",".dt-dropdown__list-item",(t,n)=>{if(!this._dropdownActiveColIndex)return;const i=this.options.headerDropdown;const{index:index}=e.data(n);const o=this._dropdownActiveColIndex;let s=i[index].action;s&&s.call(this.instance,this.getColumn(o));this.hideDropdown()});const i=this;this.hideDropdown()}openDropdown(t){this._dropdownWidth||(e.style(this.$dropdownList,{display:""}),this._dropdownWidth=e.style(this.$dropdownList,"width")),e.style(this.$dropdownList,{display:"",left:t.clientX-this._dropdownWidth+4+"px",top:t.clientY+4+"px"});const n=e.closest(".dt-cell",t.target),{colIndex:colIndex}=e.data(n);this._dropdownActiveColIndex=colIndex}hideDropdown(){e.style(this.$dropdownList,{display:"none"}),this._dropdownActiveColIndex=null}bindResizeColumn(){let t,n,i,o=!1;e.on(this.header,"mousedown",".dt-cell .dt-cell__resize-handle",(s,r)=>{document.body.classList.add("dt-resize");const l=r.parentNode.parentNode;t=l;const{colIndex:colIndex}=e.data(t);const a=this.getColumn(colIndex);if(a&&!1===a.resizable)return;o=!0;n=e.style(e(".dt-cell__content",t),"width");i=s.pageX});const s=n=>{document.body.classList.remove("dt-resize");if(!t)return;o=!1;const{colIndex:colIndex}=e.data(t);this.setColumnWidth(colIndex);this.style.setBodyStyle();t=null};e.on(document.body,"mouseup",s),this.instance.on("onDestroy",()=>{e.off(document.body,"mouseup",s)});const r=s=>{if(!o)return;let r=s.pageX-i;"rtl"===this.options.direction&&(r*=-1);const l=n+r;const{colIndex:colIndex}=e.data(t);let a=this.options.minimumColumnWidth;if(a>l)return;this.datamanager.updateColumn(colIndex,{width:l});this.setColumnHeaderWidth(colIndex)};e.on(document.body,"mousemove",r),this.instance.on("onDestroy",()=>{e.off(document.body,"mousemove",r)})}bindPerfectColumnWidth(){e.on(this.header,"dblclick",".dt-cell .dt-cell__resize-handle",(t,n)=>{const i=n.parentNode.parentNode;const{colIndex:colIndex}=e.data(i);let o=this.bodyRenderer.visibleRows.map(t=>t[colIndex]).reduce((t,e)=>t.content.length>e.content.length?t:e);let s=this.cellmanager.getCellHTML(o);let r=document.createElement("div");r.innerHTML=s;let l=r.querySelector(".dt-cell__content").textContent;let{borderLeftWidth:borderLeftWidth,borderRightWidth:borderRightWidth,paddingLeft:paddingLeft,paddingRight:paddingRight}=e.getStyle(this.bodyScrollable.querySelector(".dt-cell__content"));let a=[borderLeftWidth,borderRightWidth,paddingLeft,paddingRight].map(parseFloat).reduce((t,e)=>t+e);let c=e.measureTextWidth(l)+a;this.datamanager.updateColumn(colIndex,{width:c});this.setColumnHeaderWidth(colIndex);this.setColumnWidth(colIndex)})}bindMoveColumn(){if(!this.options.disableReorderColumn){const n=e(".dt-row",this.header);this.sortable=t.create(n,{onEnd:t=>{const{oldIndex:oldIndex,newIndex:newIndex}=t;const n=t.item;const{colIndex:colIndex}=e.data(n);if(+colIndex===newIndex)return;this.switchColumn(oldIndex,newIndex)},preventOnFilter:!1,filter:".dt-cell__resize-handle, .dt-dropdown",chosenClass:"dt-cell--dragging",animation:150})}}sortColumn(t,e){this.instance.freeze(),this.sortRows(t,e).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>this.instance.unfreeze()).then(()=>{this.fireEvent("onSortColumn",this.getColumn(t))})}removeColumn(t){const e=this.getColumn(t);this.instance.freeze(),this.datamanager.removeColumn(t).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>this.instance.unfreeze()).then(()=>{this.fireEvent("onRemoveColumn",e)})}switchColumn(t,e){this.instance.freeze(),this.datamanager.switchColumn(t,e).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>{this.setColumnWidth(t);this.setColumnWidth(e);this.instance.unfreeze()}).then(()=>{this.fireEvent("onSwitchColumn",this.getColumn(t),this.getColumn(e))})}toggleFilter(t){if(this.options.inlineFilters){let n;(n=void 0===t?!this.isFilterShown:t)?e.style(this.$filterRow,{display:""}):e.style(this.$filterRow,{display:"none"}),this.isFilterShown=n,this.style.setBodyStyle()}}focusFilter(t){this.isFilterShown&&e(`.dt-cell--col-${t} .dt-filter`,this.$filterRow).focus()}bindFilter(){if(this.options.inlineFilters){const t=t=>{this.applyFilter(this.getAppliedFilters())};e.on(this.header,"keydown",".dt-filter",Dn(t,300))}}applyFilter(t){this.datamanager.filterRows(t).then(({rowsToShow:rowsToShow})=>{this.rowmanager.showRows(rowsToShow)})}getAppliedFilters(){const t={};return e.each(".dt-filter",this.header).map(e=>{const n=e.value;n&&(t[e.dataset.colIndex]=n)}),t}applyDefaultSortOrder(){const t=this.getColumns().filter(t=>"none"!==t.sortOrder);if(1===t.length){const e=t[0];this.sortColumn(e.colIndex,e.sortOrder)}}sortRows(t,e){return this.datamanager.sortRows(t,e)}getColumn(t){return this.datamanager.getColumn(t)}getColumns(){return this.datamanager.getColumns()}setColumnWidth(t,e){t=+t;let n=e||this.getColumn(t).width;const i=[`.dt-cell__content--col-${t}`,`.dt-cell__edit--col-${t}`].join(", "),o={width:n+"px"};this.style.setStyle(i,o)}setColumnHeaderWidth(t){t=+t,this.$columnMap=this.$columnMap||[];const e=`.dt-cell__content--header-${t}`,{width:width}=this.getColumn(t);let n=this.$columnMap[t];n||(n=this.header.querySelector(e),this.$columnMap[t]=n),n.style.width=width+"px"}getColumnMinWidth(t){return t=+t,this.getColumn(t).minWidth||24}getFirstColumnIndex(){return this.datamanager.getColumnIndexById("_rowIndex")+1}getHeaderCell$(t){return e(`.dt-cell--header-${t}`,this.header)}getLastColumnIndex(){return this.datamanager.getColumnCount()-1}getDropdownHTML(){const{dropdownButton:dropdownButton}=this.options;return`\n
\n
${dropdownButton}
\n
\n `}getDropdownListHTML(){const{headerDropdown:dropdownItems}=this.options;return`\n
\n ${dropdownItems.map((t,e)=>`\n
${t.label}
\n `).join("")}\n
\n `}}class Bn{constructor(t){this.instance=t,rt(this,this.instance,["options","fireEvent","wrapper","bodyScrollable","bodyRenderer","style"]),this.bindEvents(),this.refreshRows=st(this.refreshRows,this)}get datamanager(){return this.instance.datamanager}get cellmanager(){return this.instance.cellmanager}bindEvents(){this.bindCheckbox()}bindCheckbox(){this.options.checkboxColumn&&(this.checkMap=[],e.on(this.wrapper,"click",'.dt-cell--col-0 [type="checkbox"]',(t,n)=>{const i=n.closest(".dt-cell");const{rowIndex:rowIndex,isHeader:isHeader}=e.data(i);const o=n.checked;isHeader?this.checkAll(o):this.checkRow(rowIndex,o)}))}refreshRows(){this.instance.renderBody(),this.instance.setDimensions()}refreshRow(t,e){this.datamanager.updateRow(t,e).forEach(t=>{this.cellmanager.refreshCell(t,!0)})}getCheckedRows(){if(!this.checkMap)return[];let t=[];for(let e in this.checkMap){const n=this.checkMap[e];1===n&&t.push(e)}return t}highlightCheckedRows(){this.getCheckedRows().map(t=>this.checkRow(t,!0))}checkRow(t,n){const i=n?1:0,o=t=>`.dt-cell--0-${t} [type="checkbox"]`;this.checkMap[t]=i,e.each(o(t),this.bodyScrollable).map(t=>{t.checked=n}),this.highlightRow(t,n),this.showCheckStatus(),this.fireEvent("onCheckRow",this.datamanager.getRow(t))}checkAll(t){const n=t?1:0;t?this.datamanager._filteredRows?this.datamanager._filteredRows.forEach(e=>{this.checkRow(e,t)}):this.checkMap=Array.from(Array(this.getTotalRows())).map(t=>n):this.checkMap=[],e.each('.dt-cell--col-0 [type="checkbox"]',this.bodyScrollable).map(e=>{e.checked=t}),this.highlightAll(t),this.showCheckStatus(),this.fireEvent("onCheckRow")}showCheckStatus(){if(this.options.checkedRowStatus){const t=this.getCheckedRows().length;if(t>0){let e=this.instance.translate("{count} rows selected",{count:t});this.bodyRenderer.showToastMessage(e)}else this.bodyRenderer.clearToastMessage()}}highlightRow(t,e=!0){const n=this.getRow$(t);if(n){if(!e&&this.bodyScrollable.classList.contains("dt-scrollable--highlight-all"))return void n.classList.add("dt-row--unhighlight");e&&n.classList.contains("dt-row--unhighlight")&&n.classList.remove("dt-row--unhighlight"),this._highlightedRows=this._highlightedRows||{},e?(n.classList.add("dt-row--highlight"),this._highlightedRows[t]=n):(n.classList.remove("dt-row--highlight"),delete this._highlightedRows[t])}}highlightAll(t=!0){if(t)this.bodyScrollable.classList.add("dt-scrollable--highlight-all");else{this.bodyScrollable.classList.remove("dt-scrollable--highlight-all");for(const t in this._highlightedRows){const e=this._highlightedRows[t];e.classList.remove("dt-row--highlight")}this._highlightedRows={}}}showRows(t){const e=(t=ut(t)).map(t=>this.datamanager.getRow(t));this.bodyRenderer.renderRows(e)}showAllRows(){const t=this.datamanager.getAllRowIndices();this.showRows(t)}getChildrenToShowForNode(t){return this.datamanager.getRow(t).meta.isTreeNodeClose=!1,this.datamanager.getImmediateChildren(t)}openSingleNode(t){const e=ht([...this.getChildrenToShowForNode(t),...this.bodyRenderer.visibleRowIndices]).sort(dt);this.showRows(e)}getChildrenToHideForNode(t){this.datamanager.getRow(t).meta.isTreeNodeClose=!0;const e=this.datamanager.getChildren(t);return e.forEach(t=>{const e=this.datamanager.getRow(t);e.meta.isLeaf||(e.meta.isTreeNodeClose=!0)}),e}closeSingleNode(t){const e=this.getChildrenToHideForNode(t),n=this.bodyRenderer.visibleRowIndices.filter(t=>!e.includes(t)).sort(dt);this.showRows(n)}expandAllNodes(){const t=ht([...this.datamanager.getRows().filter(t=>!t.meta.isLeaf).map(t=>this.getChildrenToShowForNode(t.meta.rowIndex)).flat(),...this.bodyRenderer.visibleRowIndices]).sort(dt);this.showRows(t)}collapseAllNodes(){const t=this.datamanager.getRows().filter(t=>0===t.meta.indent).map(t=>this.getChildrenToHideForNode(t.meta.rowIndex)).flat(),e=this.bodyRenderer.visibleRowIndices.filter(e=>!t.includes(e)).sort(dt);this.showRows(e)}setTreeDepth(t){let e=this.datamanager.getRows();const n=e.filter(e=>e.meta.indente.meta.indent>=t),o=i.filter(e=>e.meta.indent>t);i.forEach(t=>{t.meta.isLeaf||(t.meta.isTreeNodeClose=!0)}),n.forEach(t=>{t.meta.isLeaf||(t.meta.isTreeNodeClose=!1)});const s=e.filter(t=>!o.includes(t)).map(t=>t.meta.rowIndex).sort(dt);this.showRows(s)}getRow$(t){return e(this.selector(t),this.bodyScrollable)}getTotalRows(){return this.datamanager.getRowCount()}getFirstRowIndex(){return 0}getLastRowIndex(){return this.datamanager.getRowCount()-1}scrollToRow(t){t=+t,this._lastScrollTo=this._lastScrollTo||0;const n=this.getRow$(t);if(n&&!e.inVerticalViewport(n,this.bodyScrollable)){const i=n.getBoundingClientRect().height,o=this.bodyScrollable.clientHeight,s=this.bodyScrollable.scrollTop;let r=0;const l=n.getBoundingClientRect().top-this.bodyScrollable.getBoundingClientRect().top+s,a=l+i;r=t>this._lastScrollTo?a-o:l,r=Math.max(0,Math.min(r,this.bodyScrollable.scrollHeight-o)),this._lastScrollTo=t,e.scrollTop(this.bodyScrollable,r)}}getRowHTML(t,e){const n=nt(e);let i=e.rowIndex;return e.isFilter&&(t=t.map(t=>Object.assign({},t,{content:this.getFilterInput({colIndex:t.colIndex,name:t.name}),isFilter:1,isHeader:void 0,editable:!1})),i="filter"),e.isHeader&&(i="header"),`\n
\n ${t.map(t=>this.cellmanager.getCellHTML(t)).join("")}\n
\n `}getFilterInput(t){let e=`title="Filter based on ${t.name||"Index"}"`;return``}selector(t){return`.dt-row-${t}`}}var Vn=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e){t.exports=function(){return function t(e,n,i){function s(l,a){if(!n[l]){if(!e[l]){var c="function"==typeof o&&o;if(!a&&c)return c(l,!0);if(r)return r(l,!0);var u=new Error("Cannot find module '"+l+"'");throw u.code="MODULE_NOT_FOUND",u}var h=n[l]={exports:{}};e[l][0].call(h.exports,function(t){var n=e[l][1][t];return s(n||t)},h,h.exports,t,e,n,i)}return n[l].exports}for(var r="function"==typeof o&&o,l=0;lo._averageHeight)){var i=o._renderChunk();o._lastRepaint=e,!1!==i&&"function"==typeof s.afterRender&&s.afterRender()}}()}return o(t,null,[{key:"create",value:function(e,n){return new t(e,n)}},{key:"mergeStyle",value:function(t,e){for(var n in e)t.style[n]!==e[n]&&(t.style[n]=e[n])}},{key:"getMaxBrowserHeight",value:function(){var e=document.createElement("div"),n=document.createElement("div");t.mergeStyle(e,{position:"absolute",height:"1px",opacity:0}),t.mergeStyle(n,{height:"1e7px"}),e.appendChild(n),document.body.appendChild(e);var i=n.offsetHeight;return document.body.removeChild(e),i}}]),o(t,[{key:"destroy",value:function(){window.cancelAnimationFrame(this._renderAnimationFrame)}},{key:"refresh",value:function(e,n){var i=this;if(Object.assign(this._config,s,n),!e||1!==e.nodeType)throw new Error("HyperList requires a valid DOM Node container");this._element=e;var o=this._config,l=this._scroller||o.scroller||document.createElement(o.scrollerTagName||"tr");if("boolean"!=typeof o.useFragment&&(this._config.useFragment=!0),!o.generate)throw new Error("Missing required `generate` function");if(!r(o.total))throw new Error("Invalid required `total` value, expected number");if(!Array.isArray(o.itemHeight)&&!r(o.itemHeight))throw new Error("\n Invalid required `itemHeight` value, expected number or array\n ".trim());r(o.itemHeight)?this._itemHeights=Array(o.total).fill(o.itemHeight):this._itemHeights=o.itemHeight,Object.keys(s).filter(function(t){return t in o}).forEach(function(t){var e=o[t],n=r(e),s=!n&&"%"===e.slice(-1);if(e&&"string"!=typeof e&&"number"!=typeof e){var l="Invalid optional `"+t+"`, expected string or number";throw new Error(l)}if(n&&(o[t]=e+"px"),"height"===t){var a=n?e:parseInt(e.replace(/px|%/,""),10);i._containerHeight=s?window.innerHeight*a/100:r(e)?e:a}});var a={width:""+o.width,height:""+o.height,overflow:"auto",position:"relative"};t.mergeStyle(e,a);var c=o.itemHeight*o.total,u=this._maxElementHeight;c>u&&console.warn(["HyperList: The maximum element height",u+"px has","been exceeded; please reduce your item height."].join(" "));var h={opacity:"0",position:"absolute",width:"1px",height:c+"px"};t.mergeStyle(l,h),this._scroller||e.appendChild(l),this._scroller=l,this._scrollHeight=this._computeScrollHeight(),this._itemPositions=this._itemPositions||Array(o.total).fill(0),this._computePositions(0),this._renderChunk(null!==this._lastRepaint),"function"==typeof o.afterRender&&o.afterRender()}},{key:"_getRow",value:function(e){var n=this._config,i=n.generate(e),o=i.height;if(void 0!==o&&r(o)?(i=i.element,o!==this._itemHeights&&(this._itemHeights[e]=o,this._computePositions(e),this._scrollHeight=this._computeScrollHeight(e))):o=this._itemHeights[e],!i||1!==i.nodeType)throw new Error("Generator did not return a DOM Node for index: "+e);var s=i.getAttribute("class")||"";i.setAttribute("class",s+" "+(n.rowClassName||"vrow"));var l=this._itemPositions[e];return t.mergeStyle(i,{position:"absolute",top:l+"px"}),i}},{key:"_getScrollPosition",value:function(){var t=this._config;return"function"==typeof t.overrideScrollPosition?t.overrideScrollPosition():this._element.scrollTop}},{key:"_renderChunk",value:function(t){var e=this._config,n=this._element,i=this._getScrollPosition(),o=e.total,s=e.reverse?this._getReverseFrom(i):this._getFrom(i)-1;if((s<0||s-this._screenItemsLen<0)&&(s=0),!t&&this._lastFrom===s)return!1;this._lastFrom=s;var r=s+this._cachedItemsLen;(r>o||r+this._cachedItemsLen>o)&&(r=o);var l=e.useFragment?document.createDocumentFragment():[],a=this._scroller;l[e.useFragment?"appendChild":"push"](a);for(var c=s;c0&&this._itemPositions[e]t.meta.rowIndex),0===t.length)return void(this.bodyScrollable.innerHTML=this.getNoDataHTML());const e=this.datamanager.rowViewOrder.map(t=>{if(this.visibleRowIndices.includes(t))return t;return null}).filter(t=>null!==t),n=getComputedStyle(this.bodyScrollable);let i={width:n.width,height:n.height,itemHeight:this.options.cellHeight,total:t.length,generate:t=>{const n=document.createElement("div");const i=e[t];const o=this.datamanager.getRow(i);const s=this.rowmanager.getRowHTML(o,o.meta);n.innerHTML=s;return n.children[0]},afterRender:()=>{this.restoreState()}};this.hyperlist?this.hyperlist.refresh(this.bodyScrollable,i):this.hyperlist=new Vn(this.bodyScrollable,i),this.renderFooter()}render(){const t=this.datamanager.getRowsForView();this.renderRows(t),this.instance.setDimensions()}renderFooter(){if(this.options.showTotalRow){const t=this.getTotalRow();let e=this.rowmanager.getRowHTML(t,{isTotalRow:1,rowIndex:"totalRow"});this.footer.innerHTML=e}}getTotalRow(){return this.datamanager.getColumns().map(t=>{let e=null;["_rowIndex","_checkbox"].includes(t.id)&&(e="");return{content:e,isTotalRow:1,colIndex:t.colIndex,column:t}}).map((t,e)=>{if(""===t.content)return t;if(this.options.hooks.columnTotal){const n=this.visibleRows.filter(t=>!t.meta||!t.meta.excludeFromTotal).map(t=>t[e].content),i=this.options.hooks.columnTotal.call(this.instance,n,t);if(null!=i)return t.content=i,t}t.content=this.visibleRows.filter(t=>!t.meta.excludeFromTotal).reduce((t,n)=>{const i=n[e];if("number"==typeof i.content)return null==t&&(t=0),t+i.content;return t},t.content);return t})}restoreState(){this.rowmanager.highlightCheckedRows(),this.cellmanager.selectAreaOnClusterChanged(),this.cellmanager.focusCellOnClusterChanged()}showToastMessage(t,e){this.instance.toastMessage.innerHTML=this.getToastMessageHTML(t),e&&setTimeout(()=>{this.clearToastMessage()},1e3*e)}clearToastMessage(){this.instance.toastMessage.innerHTML=""}getNoDataHTML(){return`
${this.options.noDataMessage}
`}getToastMessageHTML(t){return`${t}`}}class Kn{constructor(t){this.instance=t,rt(this,this.instance,["options","datamanager","columnmanager","header","footer","bodyScrollable","datatableWrapper","getColumn","bodyRenderer"]),this.scopeClass="dt-instance-"+t.constructor.instances,t.datatableWrapper.classList.add(this.scopeClass);const e=document.createElement("style");t.wrapper.insertBefore(e,t.datatableWrapper),this.styleEl=e,this.bindResizeWindow(),this.bindScrollHeader()}get stylesheet(){return this.styleEl.sheet}bindResizeWindow(){this.onWindowResize=this.onWindowResize.bind(this),this.onWindowResize=Fn(this.onWindowResize,300),e.on(window,"resize",this.onWindowResize)}bindScrollHeader(){this._settingHeaderPosition=!1,e.on(this.bodyScrollable,"scroll",t=>{if(this._settingHeaderPosition)return;this._settingHeaderPosition=!0;requestAnimationFrame(()=>{const n=-t.target.scrollLeft;e.style(this.header,{transform:`translateX(${n}px)`});e.style(this.footer,{transform:`translateX(${n}px)`});this._settingHeaderPosition=!1})})}onWindowResize(){this.distributeRemainingWidth(),this.refreshColumnWidth(),this.setBodyStyle()}destroy(){this.styleEl.remove(),e.off(window,"resize",this.onWindowResize)}setStyle(t,e){if(t.includes(","))return void t.split(",").map(t=>t.trim()).forEach(t=>{this.setStyle(t,e)});if(t=t.trim()){this._styleRulesMap=this._styleRulesMap||{};const n=this._getPrefixedSelector(t);this._styleRulesMap[n]&&(this.removeStyle(t),e=Object.assign({},this._styleRulesMap[n],e));const i=`${n} { ${this._getRuleString(e)} }`;this._styleRulesMap[n]=e,this.stylesheet.insertRule(i)}}removeStyle(t){if(t.includes(","))return void t.split(",").map(t=>t.trim()).forEach(t=>{this.removeStyle(t)});if(t=t.trim()){const e=this._getPrefixedSelector(t),n=Array.from(this.stylesheet.cssRules||[]).findIndex(t=>t.selectorText===e);-1!==n&&this.stylesheet.deleteRule(n)}}_getPrefixedSelector(t){return`.${this.scopeClass} ${t}`}_getRuleString(t){return Object.keys(t).map(e=>{let n=e;e.includes("-")||(n=et(e));return`${n}:${t[e]};`}).join("")}setDimensions(){this.setCellHeight(),this.setupMinWidth(),this.setupNaturalColumnWidth(),this.setupColumnWidth(),this.distributeRemainingWidth(),this.setColumnStyle(),this.setBodyStyle()}setCellHeight(){this.setStyle(".dt-cell",{height:this.options.cellHeight+"px"})}setupMinWidth(){e.each(".dt-cell--header",this.header).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.getColumn(colIndex);if(!n.minWidth){const i=e.style(e(".dt-cell__content",t),"width");n.minWidth=i}})}setupNaturalColumnWidth(){e(".dt-row")&&(e.each(".dt-row-header .dt-cell",this.header).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.datamanager.getColumn(colIndex);let i=e.style(e(".dt-cell__content",t),"width");"number"==typeof i&&i>=this.options.minimumColumnWidth?n.naturalWidth=i:n.naturalWidth=this.options.minimumColumnWidth}),e.each(".dt-row-0 .dt-cell",this.bodyScrollable).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.datamanager.getColumn(colIndex);let i=e.style(e(".dt-cell__content",t),"width");"number"==typeof i&&i>=n.naturalWidth?n.naturalWidth=i:n.naturalWidth=n.naturalWidth}))}setupColumnWidth(){if("ratio"===this.options.layout){let t=e.style(this.datatableWrapper,"width");if(this.options.serialNoColumn){const e=this.datamanager.getColumnById("_rowIndex");t=t-e.width-1}if(this.options.checkboxColumn){const e=this.datamanager.getColumnById("_checkbox");t=t-e.width-1}const n=this.datamanager.getColumns().map(t=>{if("_rowIndex"===t.id||"_checkbox"===t.id)return 0;t.width||(t.width=1);t.ratioWidth=parseInt(t.width,10);return t.ratioWidth}).reduce((t,e)=>t+e),i=t/n;this.datamanager.getColumns().map(t=>{if("_rowIndex"===t.id||"_checkbox"===t.id)return;t.width=Math.floor(i*t.ratioWidth)-1})}else this.datamanager.getColumns().map(t=>{t.width||(t.width=t.naturalWidth);"_rowIndex"===t.id&&(t.width=this.getRowIndexColumnWidth());t.widtht.offsetWidth);i=n.reduce((t,e)=>t+e,0)}const o=this.datamanager.getColumns().filter(t=>t.resizable),s=(t-i)/o.length;o.map(t=>{const n=e.style(this.getColumnHeaderElement(t.colIndex),"width");let i=Math.floor(n+s)-2;this.datamanager.updateColumn(t.colIndex,{width:i})})}}setColumnStyle(){this.datamanager.getColumns().map(t=>{t.align||(t.align="left");["left","center","right"].includes(t.align)||(t.align="left");this.setStyle(`.dt-cell--col-${t.colIndex}`,{"text-align":t.align});this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)})}refreshColumnWidth(){this.datamanager.getColumns().map(t=>{this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)})}setBodyStyle(){const t=e.style(this.datatableWrapper,"width"),n=e(".dt-row",this.bodyScrollable);if(n){const i=e.style(n,"width");let o=t>i?i:t;e.style(this.bodyScrollable,{width:o+"px"}),e.removeStyle(this.bodyScrollable,"height");let s=e.getStyle(this.bodyScrollable,"height");const r=(this.bodyRenderer.hyperlist||{})._scrollHeight||1/0,l=e.hasHorizontalOverflow(this.bodyScrollable);let a;r0)for(let e of n){const n=e(t);void 0!==n&&!0!==n||t.preventDefault()}}on(t,e){t.split(",").map(t=>t.trim()).map(t=>{this.listeners[t]=this.listeners[t]||[];this.listeners[t].push(e)})}}var Zn={"Sort Ascending":"Sort Ascending","Sort Descending":"Sort Descending","Reset sorting":"Reset sorting","Remove column":"Remove column","No Data":"No Data","{count} cells copied":{1:"{count} cell copied",default:"{count} cells copied"},"{count} rows selected":{1:"{count} row selected",default:"{count} rows selected"}},Xn={"Sort Ascending":"Aufsteigend sortieren","Sort Descending":"Absteigend sortieren","Reset sorting":"Sortierung zurücksetzen","Remove column":"Spalte entfernen","No Data":"Keine Daten","{count} cells copied":{1:"{count} Zelle kopiert",default:"{count} Zellen kopiert"},"{count} rows selected":{1:"{count} Zeile ausgewählt",default:"{count} Zeilen ausgewählt"}},Yn={"Sort Ascending":"Trier par ordre croissant","Sort Descending":"Trier par ordre décroissant","Reset sorting":"Réinitialiser le tri","Remove column":"Supprimer colonne","No Data":"Pas de données","{count} cells copied":{1:"{count} cellule copiée",default:"{count} cellules copiées"},"{count} rows selected":{1:"{count} ligne sélectionnée",default:"{count} lignes sélectionnées"}},Jn={"Sort Ascending":"Ordinamento ascendente","Sort Descending":"Ordinamento decrescente","Reset sorting":"Azzeramento ordinamento","Remove column":"Rimuovi colonna","No Data":"Nessun dato","{count} cells copied":{1:"Copiato {count} cella",default:"{count} celle copiate"},"{count} rows selected":{1:"{count} linea selezionata",default:"{count} linee selezionate"}};class Qn{constructor(t){this.language=t,this.translations=gt()}addTranslations(t){this.translations=Object.assign(this.translations,t)}translate(t,e){let n=this.translations[this.language]&&this.translations[this.language][t]||t;return"object"==typeof n&&(n=e&&e.count?this.getPluralizedTranslation(n,e.count):t),pt(n,e||{})}getPluralizedTranslation(t,e){return t[e]||t.default}}let ti={DataManager:zn,CellManager:Nn,ColumnManager:Pn,RowManager:Bn,BodyRenderer:qn,Style:Kn,Keyboard:Un};class ei{constructor(t,e){if(ei.instances++,"string"==typeof t&&(t=document.querySelector(t)),this.wrapper=t,!(this.wrapper instanceof HTMLElement))throw new Error("Invalid argument given for `wrapper`");this.initializeTranslations(e),this.setDefaultOptions(),this.buildOptions(e),this.prepare(),this.initializeComponents(),this.options.data&&(this.refresh(),this.columnmanager.applyDefaultSortOrder())}initializeTranslations(t){this.language=t.language||"en",this.translationManager=new Qn(this.language),t.translations&&this.translationManager.addTranslations(t.translations)}setDefaultOptions(){this.DEFAULT_OPTIONS=Ct(this)}buildOptions(t){this.options=this.options||{},this.options=Object.assign({},this.DEFAULT_OPTIONS,this.options||{},t),t.headerDropdown=t.headerDropdown||[],this.options.headerDropdown=[...this.DEFAULT_OPTIONS.headerDropdown,...t.headerDropdown],this.events=Object.assign({},this.DEFAULT_OPTIONS.events,this.options.events||{},t.events||{}),this.fireEvent=this.fireEvent.bind(this),this.hooks=Object.assign({},this.options.hooks||{},t.events||{})}prepare(){this.prepareDom(),this.unfreeze()}initializeComponents(){let t=Object.assign({},ti,this.options.overrideComponents),{Style:Style$$1,Keyboard:Keyboard$$1,DataManager:DataManager$$1,RowManager:RowManager$$1,ColumnManager:ColumnManager$$1,CellManager:CellManager$$1,BodyRenderer:BodyRenderer$$1}=t;this.style=new Style$$1(this),this.keyboard=new Keyboard$$1(this.wrapper),this.datamanager=new DataManager$$1(this.options),this.rowmanager=new RowManager$$1(this),this.columnmanager=new ColumnManager$$1(this),this.cellmanager=new CellManager$$1(this),this.bodyRenderer=new BodyRenderer$$1(this)}prepareDom(){this.wrapper.tabIndex=0,this.wrapper.innerHTML=`\n
\n
\n
\n \n
\n \n ${this.options.freezeMessage}\n \n
\n
\n
\n \n
\n `,this.datatableWrapper=e(".datatable",this.wrapper),this.header=e(".dt-header",this.wrapper),this.footer=e(".dt-footer",this.wrapper),this.bodyScrollable=e(".dt-scrollable",this.wrapper),this.freezeContainer=e(".dt-freeze",this.wrapper),this.toastMessage=e(".dt-toast",this.wrapper),this.pasteTarget=e(".dt-paste-target",this.wrapper),this.dropdownContainer=e(".dt-dropdown-container",this.wrapper)}refresh(t,e){this.datamanager.init(t,e),this.render(),this.setDimensions()}destroy(){this.wrapper.innerHTML="",this.style.destroy(),this.fireEvent("onDestroy")}appendRows(t){this.datamanager.appendRows(t),this.rowmanager.refreshRows()}refreshRow(t,e){this.rowmanager.refreshRow(t,e)}render(){this.renderHeader(),this.renderBody()}renderHeader(){this.columnmanager.renderHeader()}renderBody(){this.bodyRenderer.render()}setDimensions(){this.style.setDimensions()}showToastMessage(t,e){this.bodyRenderer.showToastMessage(t,e)}clearToastMessage(){this.bodyRenderer.clearToastMessage()}getColumn(t){return this.datamanager.getColumn(t)}getColumns(){return this.datamanager.getColumns()}getRows(){return this.datamanager.getRows()}getCell(t,e){return this.datamanager.getCell(t,e)}getColumnHeaderElement(t){return this.columnmanager.getColumnHeaderElement(t)}getViewportHeight(){return this.viewportHeight||(this.viewportHeight=e.style(this.bodyScrollable,"height")),this.viewportHeight}sortColumn(t,e){this.columnmanager.sortColumn(t,e)}removeColumn(t){this.columnmanager.removeColumn(t)}scrollToLastColumn(){this.datatableWrapper.scrollLeft=9999}freeze(){e.style(this.freezeContainer,{display:""})}unfreeze(){e.style(this.freezeContainer,{display:"none"})}updateOptions(t){this.buildOptions(t)}fireEvent(t,...e){const n=[...this._internalEventHandlers[t]||[],this.events[t]].filter(Boolean);for(let t of n)t.apply(this,e)}on(t,e){this._internalEventHandlers=this._internalEventHandlers||{},this._internalEventHandlers[t]=this._internalEventHandlers[t]||[],this._internalEventHandlers[t].push(e)}log(){this.options.logs&&console.log.apply(console,arguments)}translate(t,e){return this.translationManager.translate(t,e)}}ei.instances=0;var ni={name:"@paralogic/frappe-datatable",version:"1.17.4",description:"A modern datatable library for the web",main:"dist/frappe-datatable.cjs.js",unpkg:"dist/frappe-datatable.min.js",jsdelivr:"dist/frappe-datatable.min.js",scripts:{start:"yarn run dev",build:"rollup -c && NODE_ENV=production rollup -c",dev:"rollup -c -w","cy:server":"http-server -p 8989","cy:open":"cypress open","cy:run":"cypress run",test:"start-server-and-test cy:server http://localhost:8989 cy:run","test-local":"start-server-and-test cy:server http://localhost:8989 cy:open","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release",lint:"eslint src","lint-and-build":"yarn lint && yarn build",commit:"npx git-cz"},files:["dist","src"],devDependencies:{autoprefixer:"^9.0.0",chai:"3.5.0",cypress:"^9.2.0","cz-conventional-changelog":"^2.1.0",deepmerge:"^2.0.1",eslint:"^5.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","http-server":"^0.11.1",mocha:"3.3.0","postcss-custom-properties":"^7.0.0","postcss-nested":"^3.0.0",rollup:"^0.59.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1","semantic-release":"^17.1.1","start-server-and-test":"^1.4.1","travis-deploy-once":"^5.0.1"},repository:{type:"git",url:"https://github.com/ParaLogicTech/datatable.git"},keywords:["datatable","data","grid","table"],author:"Faris Ansari",license:"MIT",bugs:{url:"https://github.com/ParaLogicTech/datatable/issues"},homepage:"https://frappe.io/datatable",dependencies:{hyperlist:"^1.0.0-beta",lodash:"^4.17.5",sortablejs:"^1.7.0"},config:{commitizen:{path:"cz-conventional-changelog"}}};return ei.__version__=ni.version,ei}(Sortable); +var DataTable=function(t){"use strict";function e(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(){const t=document.createElement("div");e.style(t,{width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"}),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}function i(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function o(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function s(t){var e=Et.call(t,Lt),n=t[Lt];try{t[Lt]=void 0}catch(t){}var i=kt.call(t);return e?t[Lt]=n:delete t[Lt],i}function r(t){return $t.call(t)}function l(t){return null==t?void 0===t?jt:Ft:Dt&&Dt in Object(t)?Mt(t):Ot(t)}function a(t){return null!=t&&"object"==typeof t}function c(t){return"symbol"==typeof t||Wt(t)&&At(t)==zt}function h(t){if("number"==typeof t)return t;if(Nt(t))return Pt;if(vt(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=vt(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(Bt,"");var n=qt.test(t);return n||Kt.test(t)?Gt(t.slice(2),n?2:8):Vt.test(t)?Pt:+t}function u(t,e,n){function i(e){var n=d,i=f;return d=f=void 0,y=e,m=t.apply(i,n)}function o(t){return y=t,g=setTimeout(l,e),b?i(t):m}function s(t){var n=t-y,i=e-(t-w);return C?Yt(i,p-n):i}function r(t){var n=t-w,i=t-y;return void 0===w||n>=e||n<0||C&&i>=p}function l(){var t=St();if(r(t))return a(t);g=setTimeout(l,s(t))}function a(t){return g=void 0,v&&d?i(t):(d=f=void 0,m)}function c(){void 0!==g&&clearTimeout(g),y=0,d=w=f=g=void 0}function h(){return void 0===g?m:a(St())}function u(){var t=St(),n=r(t);if(d=arguments,f=this,w=t,n){if(void 0===g)return o(w);if(C)return g=setTimeout(l,e),i(w)}return void 0===g&&(g=setTimeout(l,e)),m}var d,f,p,m,g,w,y=0,b=!1,C=!1,v=!0;if("function"!=typeof t)throw new TypeError(Zt);return e=Ut(e)||0,vt(n)&&(b=!!n.leading,p=(C="maxWait"in n)?Xt(Ut(n.maxWait)||0,e):p,v="trailing"in n?!!n.trailing:v),u.cancel=c,u.flush=h,u}function d(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new TypeError(Qt);return vt(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Jt(t,e,{leading:i,maxWait:e,trailing:o})}function f(t){if(!vt(t))return!1;var e=At(t);return e==ne||e==ie||e==ee||e==oe}function p(t){return!!le&&le in t}function m(t){if(null!=t){try{return ce.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function g(t){return!(!vt(t)||ae(t))&&(se(t)?ge:ue).test(he(t))}function w(t,e){return null==t?void 0:t[e]}function y(t,e){var n=ye(t,e);return we(n)?n:void 0}function b(){this.__data__=_e?_e(null):{},this.size=0}function C(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}function v(t){var e=this.__data__;if(_e){var n=e[t];return n===Ie?void 0:n}return Se.call(e,t)?e[t]:void 0}function _(t){var e=this.__data__;return _e?void 0!==e[t]:He.call(e,t)}function x(t,e){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=_e&&void 0===e?ke:e,this}function R(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}function L(t,e){var n=this.__data__,i=De(n,t);return i<0?(++this.size,n.push([t,e])):n[i][1]=e,this}function M(t){var e=-1,n=null==t?0:t.length;for(this.clear();++e-1}function Z(t,e,n){for(var i=-1,o=null==t?0:t.length;++i=mn){var c=e?null:pn(t);if(c)return fn(c);r=!1,o=hn,a=new nn}else a=e?[]:l;t:for(;++i`-${t[0].toLowerCase()}`)}function nt(t){return Object.keys(t).map(e=>{const n=et(e);const i=t[e];if(void 0===i)return"";return`data-${n}="${i}" `}).join("").trim()}function it(t){var e=document.createElement("textarea");e.style.position="fixed",e.style.top=0,e.style.left=0,e.style.width="2em",e.style.height="2em",e.style.padding=0,e.style.border="none",e.style.outline="none",e.style.boxShadow="none",e.style.background="transparent",e.value=t,document.body.appendChild(e),e.select();try{document.execCommand("copy")}catch(t){console.log("Oops, unable to copy")}document.body.removeChild(e)}function ot(t){return!isNaN(t)}function st(t,e=null){return(...n)=>new Promise(i=>{const o=()=>{const o=t.apply(e,n);i(o)};setTimeout(o)})}function rt(t,e,n){const i=n.reduce((t,n)=>{t[n]={get(){return e[n]}};return t},{});Object.defineProperties(t,i)}function lt(t){return void 0!==t||null!==t}function at(t){return!lt(t)}function ct(t){return!isNaN(t)}function ht(t){return Array.isArray(t)?t:[t]}function ut(t){return wn(t)}function dt(t,e){return t-e}function ft(t){return t.replace(/<[^>]*>/g,"")}function pt(t,e){return t?(Object.keys(e).forEach(n=>{let i=new RegExp(`{(${n})}`,"g");t=t.replace(i,e[n])}),t):t}function mt(t){if(!t)return"";let e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};return String(t).replace(/[&<>"'`=/]/g,t=>e[t]||t)}function gt(){return{en:Ln,de:Mn,fr:$n,it:On}}function wt(t,e,n){let i=[];if(0===Object.keys(e).length)return t.map(t=>t.meta.rowIndex);for(let o in e){const s=e[o],r=i.length?i.map(e=>t[e]):t,l=r.map(t=>t[o]);let a=bt(s),c=yt(t,a,n);i=c?c(a.text,l):l.map(t=>t.rowIndex)}return i}function yt(t,e,n){const i=e=>{let i=xn.getCustomCellFormatter(e);if(i&&e.content){const o=n.getData(e.rowIndex);return e.html=i(e.content,t[e.rowIndex],e.column,o,!0),ft(e.html)}return e.content||""},o=t=>String(ft(t.html||"")||i(t)).toLowerCase(),s=t=>parseFloat(t.content),r=(t,e)=>{if(t.column.compareValue){const n=t.column.compareValue(t,e);if(n&&Array.isArray(n))return n}const n=s(t);if(!isNaN(n))return[n,e];return[o(t),e]};return{contains(t,e){return e.filter(e=>{const n=o(e);const i=(t||"").toLowerCase();return!i||n.includes(i)}).map(t=>t.rowIndex)},greaterThan(t,e){return e.filter(e=>{const[n,i]=r(e,t);return n>i}).map(t=>t.rowIndex)},lessThan(t,e){return e.filter(e=>{const[n,i]=r(e,t);return nt.rowIndex)},equals(t,e){return e.filter(e=>{const n=parseFloat(e.content);return n===t}).map(t=>t.rowIndex)},notEquals(t,e){return e.filter(e=>{const n=parseFloat(e.content);return n!==t}).map(t=>t.rowIndex)},range(t,e){return e.filter(e=>{const n=r(e,t[0]);const i=r(e,t[1]);const o=n[0];return o>=n[1]&&o<=i[1]}).map(t=>t.rowIndex)},containsNumber(t,e){return e.filter(e=>{let n=parseFloat(t,10);let i=t;let r=s(e);let l=o(e);return n===r||l.includes(i)}).map(t=>t.rowIndex)}}[e.type]}function bt(t=""){if(0===t.length)return{};let e=t;return[">","<","="].includes(e[0])?e=t.slice(1):e.startsWith("!=")&&(e=t.slice(2)),t.startsWith(">")&&e?{type:"greaterThan",text:e.trim()}:t.startsWith("<")&&e?{type:"lessThan",text:e.trim()}:t.startsWith("=")&&ct(e)?{type:"equals",text:Number(t.slice(1).trim())}:ct(e)?{type:"containsNumber",text:e}:t.startsWith("!=")&&ct(e)?{type:"notEquals",text:Number(t.slice(2).trim())}:2===t.split(":").length?(e=t.split(":"),{type:"range",text:e.map(t=>t.trim())}):{type:"contains",text:e.toLowerCase()}}function Ct(t){return{columns:[],data:[],dropdownButton:_n.chevronDown,headerDropdown:[{label:t.translate("Sort Ascending"),action:function(t){this.sortColumn(t.colIndex,"asc")}},{label:t.translate("Sort Descending"),action:function(t){this.sortColumn(t.colIndex,"desc")}},{label:t.translate("Reset sorting"),action:function(t){this.sortColumn(t.colIndex,"none")}},{label:t.translate("Remove column"),action:function(t){this.removeColumn(t.colIndex)}}],events:{onRemoveColumn(t){},onSwitchColumn(t,e){},onSortColumn(t){},onCheckRow(t){},onDestroy(){}},hooks:{columnTotal:null},sortIndicator:{asc:"↑",desc:"↓",none:""},overrideComponents:{},filterRows:wt,freezeMessage:"",getEditor:null,serialNoColumn:!0,checkboxColumn:!1,clusterize:!0,logs:!1,layout:"fixed",noDataMessage:t.translate("No Data"),cellHeight:40,minimumColumnWidth:30,inlineFilters:!1,treeView:!1,checkedRowStatus:!0,dynamicRowHeight:!1,pasteFromClipboard:!1,showTotalRow:!1,direction:"ltr",disableReorderColumn:!1}}t=t&&t.hasOwnProperty("default")?t.default:t,e.each=((t,e)=>"string"==typeof t?Array.from((e||document).querySelectorAll(t)):t||null),e.create=((t,n)=>{let i=document.createElement(t);for(let t in n){let o=n[t];if("inside"===t)e(o).appendChild(i);else if("around"===t){let t=e(o);t.parentNode.insertBefore(i,t),i.appendChild(t)}else"styles"===t?"object"==typeof o&&Object.keys(o).map(t=>{i.style[t]=o[t]}):t in i?i[t]=o:i.setAttribute(t,o)}return i}),e.on=((t,n,i,o)=>{o?e.delegate(t,n,i,o):(o=i,e.bind(t,n,o))}),e.off=((t,e,n)=>{t.removeEventListener(e,n)}),e.bind=((t,e,n)=>{e.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}),e.delegate=((t,e,n,i)=>{t.addEventListener(e,function(t){const e=t.target.closest(n);e&&(t.delegatedTarget=e,i.call(this,t,e))})}),e.unbind=((t,e)=>{if(t)for(let n in e){let i=e[n];n.split(/\s+/).forEach(function(e){t.removeEventListener(e,i)})}}),e.fire=((t,e,n)=>{let i=document.createEvent("HTMLEvents");i.initEvent(e,!0,!0);for(let t in n)i[t]=n[t];return t.dispatchEvent(i)}),e.data=((t,e)=>{if(!e)return t.dataset;for(const n in e)t.dataset[n]=e[n]}),e.style=((t,n)=>{if("string"==typeof n)return e.getStyle(t,n);Array.isArray(t)||(t=[t]);t.map(t=>{for(const e in n)t.style[e]=n[e]})}),e.removeStyle=((t,e)=>{Array.isArray(t)||(t=[t]);Array.isArray(e)||(e=[e]);t.map(t=>{for(const n of e)t.style[n]=""})}),e.getStyle=((t,e)=>{if(!e)return getComputedStyle(t);let n=getComputedStyle(t)[e];["width","height"].includes(e)&&(n=parseFloat(n));return n}),e.closest=((t,n)=>{if(!n)return null;if(n.matches(t))return n;return e.closest(t,n.parentNode)}),e.inViewport=((t,e)=>{const{top:top,left:left,bottom:bottom,right:right}=t.getBoundingClientRect();const{top:pTop,left:pLeft,bottom:pBottom,right:pRight}=e.getBoundingClientRect();return top>=pTop&&left>=pLeft&&bottom<=pBottom&&right<=pRight}),e.inVerticalViewport=((t,e)=>{const{top:top,bottom:bottom}=t.getBoundingClientRect();const{top:pTop,bottom:pBottom}=e.getBoundingClientRect();return top>=pTop&&bottom<=pBottom}),e.scrollTop=function(t,e){t.scrollTop=e},e.scrollbarSize=function(){return e.scrollBarSizeValue||(e.scrollBarSizeValue=n()),e.scrollBarSizeValue},e.hasVerticalOverflow=function(t){return t.scrollHeight>t.offsetHeight+10},e.hasHorizontalOverflow=function(t){return t.scrollWidth>t.offsetWidth+10},e.measureTextWidth=function(t){const e=document.createElement("div");return e.style.position="absolute",e.style.visibility="hidden",e.style.height="auto",e.style.width="auto",e.style.whiteSpace="nowrap",e.style.top="-9999px",e.innerText=t,document.body.appendChild(e),e.clientWidth+1};var vt=i,_t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},xt="object"==typeof _t&&_t&&_t.Object===Object&&_t,Rt="object"==typeof self&&self&&self.Object===Object&&self,It=xt||Rt||Function("return this")(),St=function(){return It.Date.now()},Tt=It.Symbol,Ht=Object.prototype,Et=Ht.hasOwnProperty,kt=Ht.toString,Lt=Tt?Tt.toStringTag:void 0,Mt=s,$t=Object.prototype.toString,Ot=r,Ft="[object Null]",jt="[object Undefined]",Dt=Tt?Tt.toStringTag:void 0,At=l,Wt=a,zt="[object Symbol]",Nt=c,Pt=NaN,Bt=/^\s+|\s+$/g,Vt=/^[-+]0x[0-9a-f]+$/i,qt=/^0b[01]+$/i,Kt=/^0o[0-7]+$/i,Gt=parseInt,Ut=h,Zt="Expected a function",Xt=Math.max,Yt=Math.min,Jt=u,Qt="Expected a function",te=d,ee="[object AsyncFunction]",ne="[object Function]",ie="[object GeneratorFunction]",oe="[object Proxy]",se=f,re=It["__core-js_shared__"],le=function(){var t=/[^.]+$/.exec(re&&re.keys&&re.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),ae=p,ce=Function.prototype.toString,he=m,ue=/^\[object .+?Constructor\]$/,de=Function.prototype,fe=Object.prototype,pe=de.toString,me=fe.hasOwnProperty,ge=RegExp("^"+pe.call(me).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),we=g,ye=w,be=y,Ce=be(Object,"create"),ve=Object.freeze({default:Ce,__moduleExports:Ce}),_e=ve&&Ce||ve,xe=b,Re=C,Ie="__lodash_hash_undefined__",Se=Object.prototype.hasOwnProperty,Te=v,He=Object.prototype.hasOwnProperty,Ee=_,ke="__lodash_hash_undefined__",Le=x;R.prototype.clear=xe,R.prototype.delete=Re,R.prototype.get=Te,R.prototype.has=Ee,R.prototype.set=Le;var Me=R,$e=I,Oe=S,Fe=T,je=Object.freeze({default:Fe,__moduleExports:Fe}),De=je&&Fe||je,Ae=Array.prototype.splice,We=H,ze=E,Ne=k,Pe=L;M.prototype.clear=$e,M.prototype.delete=We,M.prototype.get=ze,M.prototype.has=Ne,M.prototype.set=Pe;var Be=M,Ve=be(It,"Map"),qe=$,Ke=O,Ge=F,Ue=j,Ze=D,Xe=A,Ye=W;z.prototype.clear=qe,z.prototype.delete=Ue,z.prototype.get=Ze,z.prototype.has=Xe,z.prototype.set=Ye;var Je=z,Qe="__lodash_hash_undefined__",tn=N,en=P;B.prototype.add=B.prototype.push=tn,B.prototype.has=en;var nn=B,on=V,sn=q,rn=K,ln=G,an=U,cn=Z,hn=X,un=be(It,"Set"),dn=Y,fn=J,pn=un&&1/fn(new un([,-0]))[1]==1/0?function(t){return new un(t)}:dn,mn=200,gn=Q,wn=tt;let yn=te,bn=Jt;class Cn{constructor(t){this.options=t,this.sortRows=st(this.sortRows,this),this.switchColumn=st(this.switchColumn,this),this.removeColumn=st(this.removeColumn,this),this.options.filterRows=st(this.options.filterRows,this)}init(t,e){t||(t=this.options.data),e&&(this.options.columns=e),this.data=t,this.rowCount=0,this.columns=[],this.rows=[],this.flatData=[],this.prepareColumns(),this.prepareRows(),this.prepareTreeRows(),this.prepareRowView(),this.prepareNumericColumns()}get currentSort(){return this.columns.find(t=>"none"!==t.sortOrder)||{colIndex:-1,sortOrder:"none"}}prepareColumns(){this.columns=[],this.validateColumns(),this.prepareDefaultColumns(),this.prepareHeader()}prepareDefaultColumns(){if(this.options.checkboxColumn&&!this.hasColumnById("_checkbox")){const t={id:"_checkbox",content:this.getCheckboxHTML(),editable:!1,resizable:!1,sortable:!1,focusable:!1,dropdown:!1,width:32};this.columns.push(t)}if(this.options.serialNoColumn&&!this.hasColumnById("_rowIndex")){let t={id:"_rowIndex",content:"",align:"center",editable:!1,resizable:!1,focusable:!1,dropdown:!1};this.columns.push(t)}}prepareHeader(){let t=this.columns.concat(this.options.columns);const e={isHeader:1,editable:!0,sortable:!0,resizable:!0,focusable:!0,dropdown:!0,width:null,format:t=>{if(null===t||void 0===t)return"";return t+""}};this.columns=t.map((t,e)=>this.prepareCell(t,e)).map(t=>Object.assign({},e,t)).map(t=>{t.content=t.content||t.name||"";t.id=t.id||t.content;return t})}prepareCell(t,e){const n={content:"",sortOrder:"none",colIndex:e,column:this.columns[e]};return null!==t&&"object"==typeof t?Object.assign(n,t):n.content=t,n}prepareNumericColumns(){const t=this.getRow(0);t&&(this.columns=this.columns.map((e,n)=>{const i=t[n].content;!e.align&&ot(i)&&(e.align="right");return e}))}prepareRows(){this.validateData(this.data),this.rows=[];for(let t of this.data)this.addRow(t)}addRow(t){Array.isArray(t)?this.addArrayRow(t):t._isGroup?this.addGroupObject(t):this.addObjectRow(t)}addArrayRow(t){const e=this._getNextRowCount();let n=[],i={rowIndex:e};for(this.options.checkboxColumn&&n.push(this.getCheckboxHTML()),this.options.serialNoColumn&&n.push(e+1+""),n=n.concat(t);n.length{if(ct(t.meta.indent)){const n=this.getRow(e+1);t.meta.isLeaf=!n||at(n.meta.indent)||n.meta.indent<=t.meta.indent,t.meta.isTreeNodeClose=!1}})}prepareRowView(){this.rowViewOrder=this.rows.map(t=>t.meta.rowIndex)}prepareRow(t,e){const n={rowIndex:e.rowIndex,indent:e.indent};return t=t.map((t,e)=>this.prepareCell(t,e)).map(t=>Object.assign({},n,t)),t.meta=e,t}validateColumns(){const t=this.options.columns;if(!Array.isArray(t))throw new vn("`columns` must be an array");t.forEach((t,e)=>{if("string"!=typeof t&&"object"!=typeof t)throw new vn(`column "${e}" must be a string or an object`)})}validateData(t){if(Array.isArray(t)&&(0===t.length||Array.isArray(t[0])||"object"==typeof t[0]))return!0;throw new vn("`data` must be an array of arrays or objects")}appendRows(t){this.validateData(t),this.rows.push(...this.prepareRows(t)),this.flatData.push(...t)}sortRows(t,e="none"){t=+t,this.getColumns().map(n=>{n.colIndex===t?n.sortOrder=e:n.sortOrder="none"}),this._sortRows(t,e)}_sortRows(t,e){if(this.options.treeView?this.treeSort(t,e):this.rowViewOrder.sort((n,i)=>this.compareContent(n,i,t,e)),this.hasColumnById("_rowIndex")){const t=this.getColumnIndexById("_rowIndex");this.rows.forEach((e,n)=>{const i=this.rowViewOrder.indexOf(n);const o=e[t];o.content=i+1+""})}}treeSort(t,e){let n=[],i={};for(let t=0;t=0&&this.rows[t].meta.indent>=o;)t--;t>=0&&i[t].children.push(s)}}this._sortTree(n,t,e);let o=[],s=t=>{o.push(t.parent);t.children&&t.children.forEach(t=>s(t))};n.forEach(t=>s(t)),this.rowViewOrder=o}_sortTree(t,e,n){t&&0!==t.length&&(t.sort((t,i)=>this.compareContent(t.parent,i.parent,e,n)),t.forEach(t=>{this._sortTree(t.children,e,n)}))}compareContent(t,e,n,i){const o=t,s=e;let r=this.getCell(n,t).content,l=this.getCell(n,e).content;if(r=null==r?"":r,l=null==l?"":l,"none"===i)return o-s;if("asc"===i){if(rl)return 1;if(r===l)return 0}else if("desc"===i){if(rl)return-1;if(r===l)return 0}return 0}reverseArray(t){let e=null,n=null;for(e=0,n=t.length-1;e{const i=Object.assign({},n[t],{colIndex:e});const o=Object.assign({},n[e],{colIndex:t});n[e]=i;n[t]=o})}removeColumn(t){t=+t;const e=e=>e.colIndex!==t,n=(t,e)=>Object.assign({},t,{colIndex:e});this.columns=this.columns.filter(e).map(n),this.rows.forEach(e=>{e.splice(t,1);e.forEach((t,e)=>{t.colIndex=e})})}updateRow(t,e){if(t.lengtht[0].rowIndex===e);return this.rows[i]=n,n}updateCell(t,e,n){let i;"object"==typeof t&&(t=(i=t).colIndex,e=i.rowIndex,n=i),i=this.getCell(t,e);for(let t in n){const e=n[t];void 0!==e&&(i[t]=e)}return i}updateColumn(t,e){const n=this.getColumn(t);for(let t in e){const i=e[t];void 0!==i&&(n[t]=i)}return n}filterRows(t){return this.options.filterRows(this.rows,t,this).then(t=>{t||(t=this.getAllRowIndices());t.then||(t=Promise.resolve(t));return t.then(t=>{this._filteredRows=t;const e=this.getAllRowIndices().filter(e=>!t.includes(e));return{rowsToHide:e,rowsToShow:t}})})}getFilteredRowIndices(){return this._filteredRows||this.getAllRowIndices()}getAllRowIndices(){return this.rows.map(t=>t.meta.rowIndex)}getRowCount(){return this.rowCount}_getNextRowCount(){const t=this.rowCount;return this.rowCount++,t}getRows(t,e){return this.rows.slice(t,e)}getRowsForView(t,e){return this.rowViewOrder.map(t=>this.rows[t]).slice(t,e)}getColumns(t){let e=this.columns;return t&&(e=e.slice(this.getStandardColumnCount())),e}getStandardColumnCount(){return this.options.checkboxColumn&&this.options.serialNoColumn?2:this.options.checkboxColumn||this.options.serialNoColumn?1:0}getColumnCount(t){let e=this.columns.length;return t&&(e-=this.getStandardColumnCount()),e}getColumn(t){return(t=+t)<0&&(t=this.columns.length+t),this.columns.find(e=>e.colIndex===t)}getColumnById(t){return this.columns.find(e=>e.id===t)}getRow(t){return t=+t,this.rows[t]}getCell(t,e){return e=+e,t=+t,this.getRow(e)[t]}getChildren(t){t=+t;const e=this.getRow(t).meta.indent,n=[];for(let i=t+1;ie&&n.push(i),t.meta.indent===e))break}return n}getImmediateChildren(t){t=+t;const e=this.getRow(t).meta.indent,n=[],i=e+1;for(let o=t+1;oi)&&(t.meta.indent===i&&n.push(o),t.meta.indent===e))break}return n}get(){return{columns:this.columns,rows:this.rows}}getData(t){return this.flatData[t]}hasColumn(t){return Boolean(this.columns.find(e=>e.content===t))}hasColumnById(t){return Boolean(this.columns.find(e=>e.id===t))}getColumnIndex(t){return this.columns.findIndex(e=>e.content===t)}getColumnIndexById(t){return this.columns.findIndex(e=>e.id===t)}getCheckboxHTML(){return''}}class vn extends TypeError{}let _n={chevronDown:'',chevronRight:''};class xn{constructor(t){this.instance=t,rt(this,this.instance,["wrapper","options","style","header","bodyScrollable","columnmanager","rowmanager","datamanager","keyboard"]),this.bindEvents()}bindEvents(){this.bindFocusCell(),this.bindEditCell(),this.bindKeyboardSelection(),this.bindCopyCellContents(),this.bindMouseEvents(),this.bindTreeEvents()}bindFocusCell(){this.bindKeyboardNav()}bindEditCell(){this.$editingCell=null,e.on(this.bodyScrollable,"dblclick",".dt-cell",(t,e)=>{this.activateEditing(e)}),this.keyboard.on("enter",()=>{this.$focusedCell&&!this.$editingCell?this.activateEditing(this.$focusedCell):this.$editingCell&&this.deactivateEditing()})}bindKeyboardNav(){const t=t=>{if(!this.$focusedCell||this.$editingCell)return!1;let n=this.$focusedCell;const{rowIndex:rowIndex,colIndex:colIndex}=e.data(n);"left"===t?n=this.getLeftMostCell$(rowIndex):"right"===t?n=this.getRightMostCell$(rowIndex):"up"===t?n=this.getTopMostCell$(colIndex):"down"===t&&(n=this.getBottomMostCell$(colIndex));this.focusCell(n);return!0};["left","right","up","down","tab","shift+tab"].map(t=>this.keyboard.on(t,()=>this.focusCellInDirection(t))),["left","right","up","down"].map(e=>this.keyboard.on(`ctrl+${e}`,()=>t(e))),this.keyboard.on("esc",()=>{this.deactivateEditing(!1);this.columnmanager.toggleFilter(!1)}),this.options.inlineFilters&&(this.keyboard.on("ctrl+f",t=>{const n=e.closest(".dt-cell",t.target);const{colIndex:colIndex}=e.data(n);this.activateFilter(colIndex);return!0}),e.on(this.header,"focusin",".dt-filter",()=>{this.unfocusCell(this.$focusedCell)}))}bindKeyboardSelection(){const t=t=>{let e=this.getSelectionCursor();"left"===t?e=this.getLeftCell$(e):"right"===t?e=this.getRightCell$(e):"up"===t?e=this.getAboveCell$(e):"down"===t&&(e=this.getBelowCell$(e));return e};["left","right","up","down"].map(e=>this.keyboard.on(`shift+${e}`,()=>this.selectArea(t(e))))}bindCopyCellContents(){this.keyboard.on("ctrl+c",()=>{const t=this.copyCellContents(this.$focusedCell,this.$selectionCursor);const e=this.instance.translate("{count} cells copied",{count:t});t&&this.instance.showToastMessage(e,2)}),this.options.pasteFromClipboard&&this.keyboard.on("ctrl+v",t=>{this.instance.pasteTarget.focus();setTimeout(()=>{const t=this.instance.pasteTarget.value;this.instance.pasteTarget.value="";this.pasteContentInCell(t)},10);return!1})}bindMouseEvents(){let t=null;e.on(this.bodyScrollable,"mousedown",".dt-cell",n=>{t=!0;this.focusCell(e(n.delegatedTarget))}),e.on(this.bodyScrollable,"mouseup",()=>{t=!1});const n=n=>{if(!t)return;this.selectArea(e(n.delegatedTarget))};e.on(this.bodyScrollable,"mousemove",".dt-cell",yn(n,50))}bindTreeEvents(){e.on(this.bodyScrollable,"click",".dt-tree-node__toggle",(t,n)=>{const i=e.closest(".dt-cell",n);const{rowIndex:rowIndex}=e.data(i);i.classList.contains("dt-cell--tree-close")?this.rowmanager.openSingleNode(rowIndex):this.rowmanager.closeSingleNode(rowIndex)})}focusCell(t,{skipClearSelection:skipClearSelection=0,skipDOMFocus:skipDOMFocus=0,skipScrollToCell:skipScrollToCell=0}={}){if(t&&t!==this.$editingCell){const{colIndex:colIndex,isHeader:isHeader}=e.data(t);isHeader||!1!==this.columnmanager.getColumn(colIndex).focusable&&(skipScrollToCell||this.scrollToCell(t),this.deactivateEditing(),skipClearSelection||this.clearSelection(),this.$focusedCell&&this.$focusedCell.classList.remove("dt-cell--focus"),this.$focusedCell=t,t.classList.add("dt-cell--focus"),skipDOMFocus?this.wrapper.focus():t.focus(),this.highlightRowColumnHeader(t))}}unfocusCell(t){t&&(t.classList.remove("dt-cell--focus"),this.$focusedCell=null,this.lastHeaders&&this.lastHeaders.forEach(t=>t&&t.classList.remove("dt-cell--highlight")))}highlightRowColumnHeader(t){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(t),n=`.dt-cell--header-${colIndex}`,i=`.dt-cell--${this.datamanager.getColumnIndexById("_rowIndex")}-${rowIndex}`;this.lastHeaders&&this.lastHeaders.forEach(t=>t&&t.classList.remove("dt-cell--highlight"));const o=e(n,this.wrapper),s=e(i,this.wrapper);this.lastHeaders=[o,s],this.lastHeaders.forEach(t=>t&&t.classList.add("dt-cell--highlight"))}selectAreaOnClusterChanged(){if(this.$focusedCell&&this.$selectionCursor){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$selectionCursor),t=this.getCell$(colIndex,rowIndex);if(t&&t!==this.$selectionCursor){const n=e.data(this.$focusedCell);this.$focusedCell=this.getCell$(n.colIndex,n.rowIndex),this.selectArea(t)}}}focusCellOnClusterChanged(){if(this.$focusedCell){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$focusedCell),t=this.getCell$(colIndex,rowIndex);t&&this.focusCell(t,{skipClearSelection:1,skipDOMFocus:1,skipScrollToCell:1})}}selectArea(t){this.$focusedCell&&(this.$editingCell||this._selectArea(this.$focusedCell,t)&&(this.$selectionCursor=t))}_selectArea(t,e){if(t===e)return!1;const n=this.getCellsInRange(t,e);return!!n&&(this.clearSelection(),this._selectedCells=n.map(t=>this.getCell$(...t)),requestAnimationFrame(()=>{this._selectedCells.forEach(t=>{t&&t.classList&&t.classList.add("dt-cell--highlight")})}),!0)}getCellsInRange(t,n){let i,o,s,r;if("number"==typeof t)[i,o,s,r]=arguments;else if("object"==typeof t){if(!t||!n)return!1;const l=e.data(t),a=e.data(n);i=+l.colIndex,o=+l.rowIndex,s=+a.colIndex,r=+a.rowIndex}if(o>r&&([o,r]=[r,o]),i>s&&([i,s]=[s,i]),this.isStandardCell(i)||this.isStandardCell(s))return!1;const l=[];let a=i,c=o;const h=[];for(;c<=r;)h.push(c),c+=1;return h.map(t=>{for(;a<=s;)l.push([a,t]),a++;a=i}),l}clearSelection(){(this._selectedCells||[]).forEach(t=>{t&&t.classList&&t.classList.remove("dt-cell--highlight")}),this._selectedCells=[],this.$selectionCursor=null}getSelectionCursor(){return this.$selectionCursor||this.$focusedCell}activateEditing(t){this.focusCell(t);const{rowIndex:rowIndex,colIndex:colIndex}=e.data(t),n=this.columnmanager.getColumn(colIndex);if(!n||!1!==n.editable&&!1!==n.focusable){const i=this.getCell(colIndex,rowIndex);if(!i||!1!==i.editable){if(this.$editingCell){const{_rowIndex:_rowIndex,_colIndex:_colIndex}=e.data(this.$editingCell);if(rowIndex===_rowIndex&&colIndex===_colIndex)return}this.$editingCell=t,t.classList.add("dt-cell--editing");const o=e(".dt-cell__edit",t);o.innerHTML="";const s=this.getEditor(colIndex,rowIndex,i.content,o);s&&(this.currentCellEditor=s,s.initValue(i.content,rowIndex,n))}}}deactivateEditing(t=!0){t&&this.submitEditing(),this.$focusedCell&&this.$focusedCell.focus(),this.$editingCell&&(this.$editingCell.classList.remove("dt-cell--editing"),this.$editingCell=null)}getEditor(t,e,n,i){const o=this.datamanager.getColumn(t),s=this.datamanager.getRow(e),r=this.datamanager.getData(e);let l=this.options.getEditor?this.options.getEditor(t,e,n,i,o,s,r):this.getDefaultEditor(i);return!1!==l&&(void 0===l&&(l=this.getDefaultEditor(i)),l)}getDefaultEditor(t){const n=e.create("input",{class:"dt-input",type:"text",inside:t});return{initValue(t){n.focus(),n.value=t},getValue(){return n.value},setValue(t){n.value=t}}}submitEditing(){let t=Promise.resolve();if(!this.$editingCell)return t;const n=this.$editingCell,{rowIndex:rowIndex,colIndex:colIndex}=e.data(n),i=this.datamanager.getColumn(colIndex);if(n){const e=this.currentCellEditor;if(e){let o=e.getValue();o&&o.then||(o=Promise.resolve(o)),t=o.then(t=>{const o=this.getCell(colIndex,rowIndex).content;if(o===t)return!1;const s=e.setValue(t,rowIndex,i);this.updateCell(colIndex,rowIndex,t,!0);n.focus();s&&s.then&&s.catch(t=>{console.log(t);this.updateCell(colIndex,rowIndex,o)});return s})}}return this.currentCellEditor=null,t}copyCellContents(t,n){if(!n&&t){const{colIndex:colIndex,rowIndex:rowIndex}=e.data(t),n=this.getCell(colIndex,rowIndex);return it(n.content),1}const i=this.getCellsInRange(t,n);if(!i)return 0;const o=i.map(t=>this.getCell(...t)).reduce((t,e)=>{const n=e.rowIndex;t[n]=t[n]||[];t[n].push(e.content);return t},[]);return it(o.map(t=>t.join("\t")).join("\n")),o.reduce((t,e)=>t+e.length,0)}pasteContentInCell(t){if(this.$focusedCell){const n=t.split("\n").map(t=>t.split("\t")).filter(t=>t.length&&t.every(t=>t));let{colIndex:colIndex,rowIndex:rowIndex}=e.data(this.$focusedCell),i={colIndex:+colIndex,rowIndex:+rowIndex};n.forEach((t,e)=>{let n=e+i.rowIndex;t.forEach((t,e)=>{let o=e+i.colIndex;this.updateCell(o,n,t,!0)})})}}activateFilter(t){this.columnmanager.toggleFilter(),this.columnmanager.focusFilter(t),this.columnmanager.isFilterShown||this.$focusedCell&&this.$focusedCell.focus()}updateCell(t,e,n,i=!1){const o=this.datamanager.updateCell(t,e,{content:n});this.refreshCell(o,i)}refreshCell(t,n=!1){e(this.selector(t.colIndex,t.rowIndex),this.bodyScrollable).innerHTML=this.getCellContent(t,n)}toggleTreeButton(t,e){const n=this.columnmanager.getFirstColumnIndex(),i=this.getCell$(n,t);i&&i.classList[e?"remove":"add"]("dt-cell--tree-close")}isStandardCell(t){return t\n ${this.getCellContent(t)}\n \n `}getCellContent(t,e=!1){const{isHeader:isHeader,isFilter:isFilter,colIndex:colIndex}=t,n=!isHeader&&!1!==t.editable?this.getEditCellHTML(colIndex):"",i=isHeader&&!1!==t.sortable?`\n ${this.options.sortIndicator[t.sortOrder]}\n `:"",o=isHeader&&!1!==t.resizable?'':"",s=isHeader&&!1!==t.dropdown?this.columnmanager.getDropdownHTML():"";let r,l=xn.getCustomCellFormatter(t);if(isHeader||isFilter||!l)r=t.content;else if(!t.html||e){const e=this.datamanager.getRow(t.rowIndex),n=this.datamanager.getData(t.rowIndex);r=l(t.content,e,t.column,n)}else r=t.html;if(t.html=r,this.options.treeView&&!isHeader&&!isFilter&&void 0!==t.indent){const e=this.datamanager.getRow(t.rowIndex+1),n=e&&e.meta.indent>t.indent,i=this.datamanager.getColumnIndexById("_rowIndex")+1;if(i===t.colIndex){const e=20*(t.indent||0),i=n?`\n ${_n.chevronDown}\n ${_n.chevronRight}\n `:"";r=`\n ${i}\n ${r}\n `}}let a=`\n
\n ${r}\n ${i}\n ${o}\n ${s}\n
\n ${n}\n `,c=document.createElement("div");c.innerHTML=r;let h=c.textContent;return h=h.replace(/\s+/g," ").trim(),a=a.replace(">",` title="${mt(h)}">`)}getEditCellHTML(t){return`
`}selector(t,e){return`.dt-cell--${t}-${e}`}static getCustomCellFormatter(t){return t.format||t.column&&t.column.format||null}}class Rn{constructor(t){this.instance=t,rt(this,this.instance,["options","fireEvent","header","datamanager","cellmanager","style","wrapper","rowmanager","bodyScrollable","bodyRenderer"]),this.bindEvents()}renderHeader(){this.header.innerHTML="
",this.refreshHeader()}refreshHeader(){const t=this.datamanager.getColumns();e("div",this.header).innerHTML=this.getHeaderHTML(t),this.$filterRow=e(".dt-row-filter",this.header),this.$filterRow&&e.style(this.$filterRow,{display:"none"}),this.$columnMap=[],this.bindMoveColumn()}getHeaderHTML(t){let e=this.rowmanager.getRowHTML(t,{isHeader:1});return this.options.inlineFilters&&(e+=this.rowmanager.getRowHTML(t,{isFilter:1})),e}bindEvents(){this.bindDropdown(),this.bindResizeColumn(),this.bindPerfectColumnWidth(),this.bindFilter()}bindDropdown(){function t(t){i.hideDropdown()}this.instance.dropdownContainer.innerHTML=this.getDropdownListHTML(),this.$dropdownList=this.instance.dropdownContainer.firstElementChild,e.on(this.header,"click",".dt-dropdown__toggle",t=>{this.openDropdown(t)});const n=e=>{const n=[".dt-dropdown__toggle",".dt-dropdown__toggle *",".dt-dropdown__list",".dt-dropdown__list *"].join(",");if(e.target.matches(n))return;t()};e.on(document.body,"click",n),document.addEventListener("scroll",t,!0),this.instance.on("onDestroy",()=>{e.off(document.body,"click",n);e.off(document,"scroll",t)}),e.on(this.$dropdownList,"click",".dt-dropdown__list-item",(t,n)=>{if(!this._dropdownActiveColIndex)return;const i=this.options.headerDropdown;const{index:index}=e.data(n);const o=this._dropdownActiveColIndex;let s=i[index].action;s&&s.call(this.instance,this.getColumn(o));this.hideDropdown()});const i=this;this.hideDropdown()}openDropdown(t){this._dropdownWidth||(e.style(this.$dropdownList,{display:""}),this._dropdownWidth=e.style(this.$dropdownList,"width")),e.style(this.$dropdownList,{display:"",left:t.clientX-this._dropdownWidth+4+"px",top:t.clientY+4+"px"});const n=e.closest(".dt-cell",t.target),{colIndex:colIndex}=e.data(n);this._dropdownActiveColIndex=colIndex}hideDropdown(){e.style(this.$dropdownList,{display:"none"}),this._dropdownActiveColIndex=null}bindResizeColumn(){let t,n,i,o=!1;e.on(this.header,"mousedown",".dt-cell .dt-cell__resize-handle",(s,r)=>{document.body.classList.add("dt-resize");const l=r.parentNode.parentNode;t=l;const{colIndex:colIndex}=e.data(t);const a=this.getColumn(colIndex);if(a&&!1===a.resizable)return;o=!0;n=e.style(e(".dt-cell__content",t),"width");i=s.pageX});const s=n=>{document.body.classList.remove("dt-resize");if(!t)return;o=!1;const{colIndex:colIndex}=e.data(t);this.setColumnWidth(colIndex);this.style.setBodyStyle();t=null};e.on(document.body,"mouseup",s),this.instance.on("onDestroy",()=>{e.off(document.body,"mouseup",s)});const r=s=>{if(!o)return;let r=s.pageX-i;"rtl"===this.options.direction&&(r*=-1);const l=n+r;const{colIndex:colIndex}=e.data(t);let a=this.options.minimumColumnWidth;if(a>l)return;this.datamanager.updateColumn(colIndex,{width:l});this.setColumnHeaderWidth(colIndex)};e.on(document.body,"mousemove",r),this.instance.on("onDestroy",()=>{e.off(document.body,"mousemove",r)})}bindPerfectColumnWidth(){e.on(this.header,"dblclick",".dt-cell .dt-cell__resize-handle",(t,n)=>{const i=n.parentNode.parentNode;const{colIndex:colIndex}=e.data(i);let o=this.bodyRenderer.visibleRows.map(t=>t[colIndex]).reduce((t,e)=>t.content.length>e.content.length?t:e);let s=this.cellmanager.getCellHTML(o);let r=document.createElement("div");r.innerHTML=s;let l=r.querySelector(".dt-cell__content").textContent;let{borderLeftWidth:borderLeftWidth,borderRightWidth:borderRightWidth,paddingLeft:paddingLeft,paddingRight:paddingRight}=e.getStyle(this.bodyScrollable.querySelector(".dt-cell__content"));let a=[borderLeftWidth,borderRightWidth,paddingLeft,paddingRight].map(parseFloat).reduce((t,e)=>t+e);let c=e.measureTextWidth(l)+a;this.datamanager.updateColumn(colIndex,{width:c});this.setColumnHeaderWidth(colIndex);this.setColumnWidth(colIndex)})}bindMoveColumn(){if(!this.options.disableReorderColumn){const n=e(".dt-row",this.header);this.sortable=t.create(n,{onEnd:t=>{const{oldIndex:oldIndex,newIndex:newIndex}=t;const n=t.item;const{colIndex:colIndex}=e.data(n);if(+colIndex===newIndex)return;this.switchColumn(oldIndex,newIndex)},preventOnFilter:!1,filter:".dt-cell__resize-handle, .dt-dropdown",chosenClass:"dt-cell--dragging",animation:150})}}sortColumn(t,e){this.instance.freeze(),this.sortRows(t,e).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>this.instance.unfreeze()).then(()=>{this.fireEvent("onSortColumn",this.getColumn(t))})}removeColumn(t){const e=this.getColumn(t);this.instance.freeze(),this.datamanager.removeColumn(t).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>this.instance.unfreeze()).then(()=>{this.fireEvent("onRemoveColumn",e)})}switchColumn(t,e){this.instance.freeze(),this.datamanager.switchColumn(t,e).then(()=>{this.refreshHeader();return this.rowmanager.refreshRows()}).then(()=>{this.setColumnWidth(t);this.setColumnWidth(e);this.instance.unfreeze()}).then(()=>{this.fireEvent("onSwitchColumn",this.getColumn(t),this.getColumn(e))})}toggleFilter(t){if(this.options.inlineFilters){let n;(n=void 0===t?!this.isFilterShown:t)?e.style(this.$filterRow,{display:""}):e.style(this.$filterRow,{display:"none"}),this.isFilterShown=n,this.style.setBodyStyle()}}focusFilter(t){this.isFilterShown&&e(`.dt-cell--col-${t} .dt-filter`,this.$filterRow).focus()}bindFilter(){if(this.options.inlineFilters){const t=t=>{this.applyFilter(this.getAppliedFilters())};e.on(this.header,"keydown",".dt-filter",bn(t,300))}}applyFilter(t){this.datamanager.filterRows(t).then(({rowsToShow:rowsToShow})=>{this.rowmanager.showRows(rowsToShow)})}getAppliedFilters(){const t={};return e.each(".dt-filter",this.header).map(e=>{const n=e.value;n&&(t[e.dataset.colIndex]=n)}),t}applyDefaultSortOrder(){const t=this.getColumns().filter(t=>"none"!==t.sortOrder);if(1===t.length){const e=t[0];this.sortColumn(e.colIndex,e.sortOrder)}}sortRows(t,e){return this.datamanager.sortRows(t,e)}getColumn(t){return this.datamanager.getColumn(t)}getColumns(){return this.datamanager.getColumns()}setColumnWidth(t,e){t=+t;let n=e||this.getColumn(t).width;const i=[`.dt-cell__content--col-${t}`,`.dt-cell__edit--col-${t}`].join(", "),o={width:n+"px"};this.style.setStyle(i,o)}setColumnHeaderWidth(t){t=+t,this.$columnMap=this.$columnMap||[];const e=`.dt-cell__content--header-${t}`,{width:width}=this.getColumn(t);let n=this.$columnMap[t];n||(n=this.header.querySelector(e),this.$columnMap[t]=n),n.style.width=width+"px"}getColumnMinWidth(t){return t=+t,this.getColumn(t).minWidth||24}getFirstColumnIndex(){return this.datamanager.getColumnIndexById("_rowIndex")+1}getHeaderCell$(t){return e(`.dt-cell--header-${t}`,this.header)}getLastColumnIndex(){return this.datamanager.getColumnCount()-1}getDropdownHTML(){const{dropdownButton:dropdownButton}=this.options;return`\n
\n
${dropdownButton}
\n
\n `}getDropdownListHTML(){const{headerDropdown:dropdownItems}=this.options;return`\n
\n ${dropdownItems.map((t,e)=>`\n
${t.label}
\n `).join("")}\n
\n `}}class In{constructor(t){this.instance=t,rt(this,this.instance,["options","fireEvent","wrapper","bodyScrollable","bodyRenderer","style"]),this.bindEvents(),this.refreshRows=st(this.refreshRows,this)}get datamanager(){return this.instance.datamanager}get cellmanager(){return this.instance.cellmanager}bindEvents(){this.bindCheckbox()}bindCheckbox(){this.options.checkboxColumn&&(this.checkMap=[],e.on(this.wrapper,"click",'.dt-cell--col-0 [type="checkbox"]',(t,n)=>{const i=n.closest(".dt-cell");const{rowIndex:rowIndex,isHeader:isHeader}=e.data(i);const o=n.checked;isHeader?this.checkAll(o):this.checkRow(rowIndex,o)}))}refreshRows(){this.instance.renderBody(),this.instance.setDimensions()}refreshRow(t,e){this.datamanager.updateRow(t,e).forEach(t=>{this.cellmanager.refreshCell(t,!0)})}getCheckedRows(){if(!this.checkMap)return[];let t=[];for(let e in this.checkMap){const n=this.checkMap[e];1===n&&t.push(e)}return t}highlightCheckedRows(){this.getCheckedRows().map(t=>this.checkRow(t,!0))}checkRow(t,n){const i=n?1:0,o=t=>`.dt-cell--0-${t} [type="checkbox"]`;this.checkMap[t]=i,e.each(o(t),this.bodyScrollable).map(t=>{t.checked=n}),this.highlightRow(t,n),this.showCheckStatus(),this.fireEvent("onCheckRow",this.datamanager.getRow(t))}checkAll(t){const n=t?1:0;t?this.datamanager._filteredRows?this.datamanager._filteredRows.forEach(e=>{this.checkRow(e,t)}):this.checkMap=Array.from(Array(this.getTotalRows())).map(t=>n):this.checkMap=[],e.each('.dt-cell--col-0 [type="checkbox"]',this.bodyScrollable).map(e=>{e.checked=t}),this.highlightAll(t),this.showCheckStatus(),this.fireEvent("onCheckRow")}showCheckStatus(){if(this.options.checkedRowStatus){const t=this.getCheckedRows().length;if(t>0){let e=this.instance.translate("{count} rows selected",{count:t});this.bodyRenderer.showToastMessage(e)}else this.bodyRenderer.clearToastMessage()}}highlightRow(t,e=!0){const n=this.getRow$(t);if(n){if(!e&&this.bodyScrollable.classList.contains("dt-scrollable--highlight-all"))return void n.classList.add("dt-row--unhighlight");e&&n.classList.contains("dt-row--unhighlight")&&n.classList.remove("dt-row--unhighlight"),this._highlightedRows=this._highlightedRows||{},e?(n.classList.add("dt-row--highlight"),this._highlightedRows[t]=n):(n.classList.remove("dt-row--highlight"),delete this._highlightedRows[t])}}highlightAll(t=!0){if(t)this.bodyScrollable.classList.add("dt-scrollable--highlight-all");else{this.bodyScrollable.classList.remove("dt-scrollable--highlight-all");for(const t in this._highlightedRows){const e=this._highlightedRows[t];e.classList.remove("dt-row--highlight")}this._highlightedRows={}}}showRows(t){const e=(t=ht(t)).map(t=>this.datamanager.getRow(t));this.bodyRenderer.renderRows(e)}showAllRows(){const t=this.datamanager.getAllRowIndices();this.showRows(t)}getChildrenToShowForNode(t){return this.datamanager.getRow(t).meta.isTreeNodeClose=!1,this.datamanager.getImmediateChildren(t)}openSingleNode(t){const e=ut([...this.getChildrenToShowForNode(t),...this.bodyRenderer.visibleRowIndices]).sort(dt);this.showRows(e)}getChildrenToHideForNode(t){this.datamanager.getRow(t).meta.isTreeNodeClose=!0;const e=this.datamanager.getChildren(t);return e.forEach(t=>{const e=this.datamanager.getRow(t);e.meta.isLeaf||(e.meta.isTreeNodeClose=!0)}),e}closeSingleNode(t){const e=this.getChildrenToHideForNode(t),n=this.bodyRenderer.visibleRowIndices.filter(t=>!e.includes(t)).sort(dt);this.showRows(n)}expandAllNodes(){const t=ut([...this.datamanager.getRows().filter(t=>!t.meta.isLeaf).map(t=>this.getChildrenToShowForNode(t.meta.rowIndex)).flat(),...this.bodyRenderer.visibleRowIndices]).sort(dt);this.showRows(t)}collapseAllNodes(){const t=this.datamanager.getRows().filter(t=>0===t.meta.indent).map(t=>this.getChildrenToHideForNode(t.meta.rowIndex)).flat(),e=this.bodyRenderer.visibleRowIndices.filter(e=>!t.includes(e)).sort(dt);this.showRows(e)}setTreeDepth(t){let e=this.datamanager.getRows();const n=e.filter(e=>e.meta.indente.meta.indent>=t),o=i.filter(e=>e.meta.indent>t);i.forEach(t=>{t.meta.isLeaf||(t.meta.isTreeNodeClose=!0)}),n.forEach(t=>{t.meta.isLeaf||(t.meta.isTreeNodeClose=!1)});const s=e.filter(t=>!o.includes(t)).map(t=>t.meta.rowIndex).sort(dt);this.showRows(s)}getRow$(t){return e(this.selector(t),this.bodyScrollable)}getTotalRows(){return this.datamanager.getRowCount()}getFirstRowIndex(){return 0}getLastRowIndex(){return this.datamanager.getRowCount()-1}scrollToRow(t){t=+t,this._lastScrollTo=this._lastScrollTo||0;const n=this.getRow$(t);if(n&&!e.inVerticalViewport(n,this.bodyScrollable)){const i=n.getBoundingClientRect().height,o=this.bodyScrollable.clientHeight,s=this.bodyScrollable.scrollTop;let r=0;const l=n.getBoundingClientRect().top-this.bodyScrollable.getBoundingClientRect().top+s,a=l+i;r=t>this._lastScrollTo?a-o:l,r=Math.max(0,Math.min(r,this.bodyScrollable.scrollHeight-o)),this._lastScrollTo=t,e.scrollTop(this.bodyScrollable,r)}}getRowHTML(t,e){const n=nt(e);let i=e.rowIndex;return e.isFilter&&(t=t.map(t=>Object.assign({},t,{content:this.getFilterInput({colIndex:t.colIndex,name:t.name}),isFilter:1,isHeader:void 0,editable:!1})),i="filter"),e.isHeader&&(i="header"),`\n
\n ${t.map(t=>this.cellmanager.getCellHTML(t)).join("")}\n
\n `}getFilterInput(t){let e=`title="Filter based on ${t.name||"Index"}"`;return``}selector(t){return`.dt-row-${t}`}}var Sn=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t,e){!function(e){t.exports=function(){return function t(e,n,i){function s(l,a){if(!n[l]){if(!e[l]){var c="function"==typeof o&&o;if(!a&&c)return c(l,!0);if(r)return r(l,!0);var h=new Error("Cannot find module '"+l+"'");throw h.code="MODULE_NOT_FOUND",h}var u=n[l]={exports:{}};e[l][0].call(u.exports,function(t){var n=e[l][1][t];return s(n||t)},u,u.exports,t,e,n,i)}return n[l].exports}for(var r="function"==typeof o&&o,l=0;lo._averageHeight)){var i=o._renderChunk();o._lastRepaint=e,!1!==i&&"function"==typeof s.afterRender&&s.afterRender()}}()}return o(t,null,[{key:"create",value:function(e,n){return new t(e,n)}},{key:"mergeStyle",value:function(t,e){for(var n in e)t.style[n]!==e[n]&&(t.style[n]=e[n])}},{key:"getMaxBrowserHeight",value:function(){var e=document.createElement("div"),n=document.createElement("div");t.mergeStyle(e,{position:"absolute",height:"1px",opacity:0}),t.mergeStyle(n,{height:"1e7px"}),e.appendChild(n),document.body.appendChild(e);var i=n.offsetHeight;return document.body.removeChild(e),i}}]),o(t,[{key:"destroy",value:function(){window.cancelAnimationFrame(this._renderAnimationFrame)}},{key:"refresh",value:function(e,n){var i=this;if(Object.assign(this._config,s,n),!e||1!==e.nodeType)throw new Error("HyperList requires a valid DOM Node container");this._element=e;var o=this._config,l=this._scroller||o.scroller||document.createElement(o.scrollerTagName||"tr");if("boolean"!=typeof o.useFragment&&(this._config.useFragment=!0),!o.generate)throw new Error("Missing required `generate` function");if(!r(o.total))throw new Error("Invalid required `total` value, expected number");if(!Array.isArray(o.itemHeight)&&!r(o.itemHeight))throw new Error("\n Invalid required `itemHeight` value, expected number or array\n ".trim());r(o.itemHeight)?this._itemHeights=Array(o.total).fill(o.itemHeight):this._itemHeights=o.itemHeight,Object.keys(s).filter(function(t){return t in o}).forEach(function(t){var e=o[t],n=r(e),s=!n&&"%"===e.slice(-1);if(e&&"string"!=typeof e&&"number"!=typeof e){var l="Invalid optional `"+t+"`, expected string or number";throw new Error(l)}if(n&&(o[t]=e+"px"),"height"===t){var a=n?e:parseInt(e.replace(/px|%/,""),10);i._containerHeight=s?window.innerHeight*a/100:r(e)?e:a}});var a={width:""+o.width,height:""+o.height,overflow:"auto",position:"relative"};t.mergeStyle(e,a);var c=o.itemHeight*o.total,h=this._maxElementHeight;c>h&&console.warn(["HyperList: The maximum element height",h+"px has","been exceeded; please reduce your item height."].join(" "));var u={opacity:"0",position:"absolute",width:"1px",height:c+"px"};t.mergeStyle(l,u),this._scroller||e.appendChild(l),this._scroller=l,this._scrollHeight=this._computeScrollHeight(),this._itemPositions=this._itemPositions||Array(o.total).fill(0),this._computePositions(0),this._renderChunk(null!==this._lastRepaint),"function"==typeof o.afterRender&&o.afterRender()}},{key:"_getRow",value:function(e){var n=this._config,i=n.generate(e),o=i.height;if(void 0!==o&&r(o)?(i=i.element,o!==this._itemHeights&&(this._itemHeights[e]=o,this._computePositions(e),this._scrollHeight=this._computeScrollHeight(e))):o=this._itemHeights[e],!i||1!==i.nodeType)throw new Error("Generator did not return a DOM Node for index: "+e);var s=i.getAttribute("class")||"";i.setAttribute("class",s+" "+(n.rowClassName||"vrow"));var l=this._itemPositions[e];return t.mergeStyle(i,{position:"absolute",top:l+"px"}),i}},{key:"_getScrollPosition",value:function(){var t=this._config;return"function"==typeof t.overrideScrollPosition?t.overrideScrollPosition():this._element.scrollTop}},{key:"_renderChunk",value:function(t){var e=this._config,n=this._element,i=this._getScrollPosition(),o=e.total,s=e.reverse?this._getReverseFrom(i):this._getFrom(i)-1;if((s<0||s-this._screenItemsLen<0)&&(s=0),!t&&this._lastFrom===s)return!1;this._lastFrom=s;var r=s+this._cachedItemsLen;(r>o||r+this._cachedItemsLen>o)&&(r=o);var l=e.useFragment?document.createDocumentFragment():[],a=this._scroller;l[e.useFragment?"appendChild":"push"](a);for(var c=s;c0&&this._itemPositions[e]t.meta.rowIndex),0===t.length)return void(this.bodyScrollable.innerHTML=this.getNoDataHTML());const e=this.datamanager.rowViewOrder.map(t=>{if(this.visibleRowIndices.includes(t))return t;return null}).filter(t=>null!==t),n=getComputedStyle(this.bodyScrollable);let i={width:n.width,height:n.height,itemHeight:this.options.cellHeight,total:t.length,generate:t=>{const n=document.createElement("div");const i=e[t];const o=this.datamanager.getRow(i);const s=this.rowmanager.getRowHTML(o,o.meta);n.innerHTML=s;return n.children[0]},afterRender:()=>{this.restoreState()}};this.hyperlist?this.hyperlist.refresh(this.bodyScrollable,i):this.hyperlist=new Sn(this.bodyScrollable,i),this.renderFooter()}render(){const t=this.datamanager.getRowsForView();this.renderRows(t),this.instance.setDimensions()}renderFooter(){if(this.options.showTotalRow){const t=this.getTotalRow();let e=this.rowmanager.getRowHTML(t,{isTotalRow:1,rowIndex:"totalRow"});this.footer.innerHTML=e}}getTotalRow(){return this.datamanager.getColumns().map(t=>{let e=null;["_rowIndex","_checkbox"].includes(t.id)&&(e="");return{content:e,isTotalRow:1,colIndex:t.colIndex,column:t}}).map((t,e)=>{if(""===t.content)return t;if(this.options.hooks.columnTotal){const n=this.visibleRows.filter(t=>!t.meta||!t.meta.excludeFromTotal).map(t=>t[e].content),i=this.options.hooks.columnTotal.call(this.instance,n,t);if(null!=i)return t.content=i,t}t.content=this.visibleRows.filter(t=>!t.meta.excludeFromTotal).reduce((t,n)=>{const i=n[e];if("number"==typeof i.content)return null==t&&(t=0),t+i.content;return t},t.content);return t})}restoreState(){this.rowmanager.highlightCheckedRows(),this.cellmanager.selectAreaOnClusterChanged(),this.cellmanager.focusCellOnClusterChanged()}showToastMessage(t,e){this.instance.toastMessage.innerHTML=this.getToastMessageHTML(t),e&&setTimeout(()=>{this.clearToastMessage()},1e3*e)}clearToastMessage(){this.instance.toastMessage.innerHTML=""}getNoDataHTML(){return`
${this.options.noDataMessage}
`}getToastMessageHTML(t){return`${t}`}}class Hn{constructor(t){this.instance=t,rt(this,this.instance,["options","datamanager","columnmanager","header","footer","bodyScrollable","datatableWrapper","getColumn","bodyRenderer"]),this.scopeClass="dt-instance-"+t.constructor.instances,t.datatableWrapper.classList.add(this.scopeClass);const e=document.createElement("style");t.wrapper.insertBefore(e,t.datatableWrapper),this.styleEl=e,this.bindResizeWindow(),this.bindScrollHeader()}get stylesheet(){return this.styleEl.sheet}bindResizeWindow(){this.onWindowResize=this.onWindowResize.bind(this),this.onWindowResize=yn(this.onWindowResize,300),e.on(window,"resize",this.onWindowResize)}bindScrollHeader(){this._settingHeaderPosition=!1,e.on(this.bodyScrollable,"scroll",t=>{if(this._settingHeaderPosition)return;this._settingHeaderPosition=!0;requestAnimationFrame(()=>{const n=-t.target.scrollLeft;e.style(this.header,{transform:`translateX(${n}px)`});e.style(this.footer,{transform:`translateX(${n}px)`});this._settingHeaderPosition=!1})})}onWindowResize(){this.distributeRemainingWidth(),this.refreshColumnWidth(),this.setBodyStyle()}destroy(){this.styleEl.remove(),e.off(window,"resize",this.onWindowResize)}setStyle(t,e){if(t.includes(","))return void t.split(",").map(t=>t.trim()).forEach(t=>{this.setStyle(t,e)});if(t=t.trim()){this._styleRulesMap=this._styleRulesMap||{};const n=this._getPrefixedSelector(t);this._styleRulesMap[n]&&(this.removeStyle(t),e=Object.assign({},this._styleRulesMap[n],e));const i=`${n} { ${this._getRuleString(e)} }`;this._styleRulesMap[n]=e,this.stylesheet.insertRule(i)}}removeStyle(t){if(t.includes(","))return void t.split(",").map(t=>t.trim()).forEach(t=>{this.removeStyle(t)});if(t=t.trim()){const e=this._getPrefixedSelector(t),n=Array.from(this.stylesheet.cssRules||[]).findIndex(t=>t.selectorText===e);-1!==n&&this.stylesheet.deleteRule(n)}}_getPrefixedSelector(t){return`.${this.scopeClass} ${t}`}_getRuleString(t){return Object.keys(t).map(e=>{let n=e;e.includes("-")||(n=et(e));return`${n}:${t[e]};`}).join("")}setDimensions(){this.setCellHeight(),this.setupMinWidth(),this.setupNaturalColumnWidth(),this.setupColumnWidth(),this.distributeRemainingWidth(),this.setColumnStyle(),this.setBodyStyle()}setCellHeight(){this.setStyle(".dt-cell",{height:this.options.cellHeight+"px"})}setupMinWidth(){e.each(".dt-cell--header",this.header).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.getColumn(colIndex);if(!n.minWidth){const i=e.style(e(".dt-cell__content",t),"width");n.minWidth=i}})}setupNaturalColumnWidth(){e(".dt-row")&&(e.each(".dt-row-header .dt-cell",this.header).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.datamanager.getColumn(colIndex);let i=e.style(e(".dt-cell__content",t),"width");"number"==typeof i&&i>=this.options.minimumColumnWidth?n.naturalWidth=i:n.naturalWidth=this.options.minimumColumnWidth}),e.each(".dt-row-0 .dt-cell",this.bodyScrollable).map(t=>{const{colIndex:colIndex}=e.data(t);const n=this.datamanager.getColumn(colIndex);let i=e.style(e(".dt-cell__content",t),"width");"number"==typeof i&&i>=n.naturalWidth?n.naturalWidth=i:n.naturalWidth=n.naturalWidth}))}setupColumnWidth(){if("ratio"===this.options.layout){let t=e.style(this.datatableWrapper,"width");if(this.options.serialNoColumn){const e=this.datamanager.getColumnById("_rowIndex");t=t-e.width-1}if(this.options.checkboxColumn){const e=this.datamanager.getColumnById("_checkbox");t=t-e.width-1}const n=this.datamanager.getColumns().map(t=>{if("_rowIndex"===t.id||"_checkbox"===t.id)return 0;t.width||(t.width=1);t.ratioWidth=parseInt(t.width,10);return t.ratioWidth}).reduce((t,e)=>t+e),i=t/n;this.datamanager.getColumns().map(t=>{if("_rowIndex"===t.id||"_checkbox"===t.id)return;t.width=Math.floor(i*t.ratioWidth)-1})}else this.datamanager.getColumns().map(t=>{t.width||(t.width=t.naturalWidth);"_rowIndex"===t.id&&(t.width=this.getRowIndexColumnWidth());t.widtht.offsetWidth);i=n.reduce((t,e)=>t+e,0)}const o=this.datamanager.getColumns().filter(t=>t.resizable),s=(t-i)/o.length;o.map(t=>{const n=e.style(this.getColumnHeaderElement(t.colIndex),"width");let i=Math.floor(n+s)-2;this.datamanager.updateColumn(t.colIndex,{width:i})})}}setColumnStyle(){this.datamanager.getColumns().map(t=>{t.align||(t.align="left");["left","center","right"].includes(t.align)||(t.align="left");this.setStyle(`.dt-cell--col-${t.colIndex}`,{"text-align":t.align});this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)})}refreshColumnWidth(){this.datamanager.getColumns().map(t=>{this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)})}setBodyStyle(){const t=e.style(this.datatableWrapper,"width"),n=e(".dt-row",this.bodyScrollable);if(n){const i=e.style(n,"width");let o=t>i?i:t;e.style(this.bodyScrollable,{width:o+"px"}),e.removeStyle(this.bodyScrollable,"height");let s=e.getStyle(this.bodyScrollable,"height");const r=(this.bodyRenderer.hyperlist||{})._scrollHeight||1/0,l=e.hasHorizontalOverflow(this.bodyScrollable);let a;r0)for(let e of n){const n=e(t);void 0!==n&&!0!==n||t.preventDefault()}}on(t,e){t.split(",").map(t=>t.trim()).map(t=>{this.listeners[t]=this.listeners[t]||[];this.listeners[t].push(e)})}}var Ln={"Sort Ascending":"Sort Ascending","Sort Descending":"Sort Descending","Reset sorting":"Reset sorting","Remove column":"Remove column","No Data":"No Data","{count} cells copied":{1:"{count} cell copied",default:"{count} cells copied"},"{count} rows selected":{1:"{count} row selected",default:"{count} rows selected"}},Mn={"Sort Ascending":"Aufsteigend sortieren","Sort Descending":"Absteigend sortieren","Reset sorting":"Sortierung zurücksetzen","Remove column":"Spalte entfernen","No Data":"Keine Daten","{count} cells copied":{1:"{count} Zelle kopiert",default:"{count} Zellen kopiert"},"{count} rows selected":{1:"{count} Zeile ausgewählt",default:"{count} Zeilen ausgewählt"}},$n={"Sort Ascending":"Trier par ordre croissant","Sort Descending":"Trier par ordre décroissant","Reset sorting":"Réinitialiser le tri","Remove column":"Supprimer colonne","No Data":"Pas de données","{count} cells copied":{1:"{count} cellule copiée",default:"{count} cellules copiées"},"{count} rows selected":{1:"{count} ligne sélectionnée",default:"{count} lignes sélectionnées"}},On={"Sort Ascending":"Ordinamento ascendente","Sort Descending":"Ordinamento decrescente","Reset sorting":"Azzeramento ordinamento","Remove column":"Rimuovi colonna","No Data":"Nessun dato","{count} cells copied":{1:"Copiato {count} cella",default:"{count} celle copiate"},"{count} rows selected":{1:"{count} linea selezionata",default:"{count} linee selezionate"}};class Fn{constructor(t){this.language=t,this.translations=gt()}addTranslations(t){this.translations=Object.assign(this.translations,t)}translate(t,e){let n=this.translations[this.language]&&this.translations[this.language][t]||t;return"object"==typeof n&&(n=e&&e.count?this.getPluralizedTranslation(n,e.count):t),pt(n,e||{})}getPluralizedTranslation(t,e){return t[e]||t.default}}let jn={DataManager:Cn,CellManager:xn,ColumnManager:Rn,RowManager:In,BodyRenderer:Tn,Style:Hn,Keyboard:kn};class Dn{constructor(t,e){if(Dn.instances++,"string"==typeof t&&(t=document.querySelector(t)),this.wrapper=t,!(this.wrapper instanceof HTMLElement))throw new Error("Invalid argument given for `wrapper`");this.initializeTranslations(e),this.setDefaultOptions(),this.buildOptions(e),this.prepare(),this.initializeComponents(),this.options.data&&(this.refresh(),this.columnmanager.applyDefaultSortOrder())}initializeTranslations(t){this.language=t.language||"en",this.translationManager=new Fn(this.language),t.translations&&this.translationManager.addTranslations(t.translations)}setDefaultOptions(){this.DEFAULT_OPTIONS=Ct(this)}buildOptions(t){this.options=this.options||{},this.options=Object.assign({},this.DEFAULT_OPTIONS,this.options||{},t),t.headerDropdown=t.headerDropdown||[],this.options.headerDropdown=[...this.DEFAULT_OPTIONS.headerDropdown,...t.headerDropdown],this.events=Object.assign({},this.DEFAULT_OPTIONS.events,this.options.events||{},t.events||{}),this.fireEvent=this.fireEvent.bind(this),this.hooks=Object.assign({},this.options.hooks||{},t.events||{})}prepare(){this.prepareDom(),this.unfreeze()}initializeComponents(){let t=Object.assign({},jn,this.options.overrideComponents),{Style:Style$$1,Keyboard:Keyboard$$1,DataManager:DataManager$$1,RowManager:RowManager$$1,ColumnManager:ColumnManager$$1,CellManager:CellManager$$1,BodyRenderer:BodyRenderer$$1}=t;this.style=new Style$$1(this),this.keyboard=new Keyboard$$1(this.wrapper),this.datamanager=new DataManager$$1(this.options),this.rowmanager=new RowManager$$1(this),this.columnmanager=new ColumnManager$$1(this),this.cellmanager=new CellManager$$1(this),this.bodyRenderer=new BodyRenderer$$1(this)}prepareDom(){this.wrapper.tabIndex=0,this.wrapper.innerHTML=`\n
\n
\n
\n \n
\n \n ${this.options.freezeMessage}\n \n
\n
\n
\n \n
\n `,this.datatableWrapper=e(".datatable",this.wrapper),this.header=e(".dt-header",this.wrapper),this.footer=e(".dt-footer",this.wrapper),this.bodyScrollable=e(".dt-scrollable",this.wrapper),this.freezeContainer=e(".dt-freeze",this.wrapper),this.toastMessage=e(".dt-toast",this.wrapper),this.pasteTarget=e(".dt-paste-target",this.wrapper),this.dropdownContainer=e(".dt-dropdown-container",this.wrapper)}refresh(t,e){this.datamanager.init(t,e),this.render(),this.setDimensions()}destroy(){this.wrapper.innerHTML="",this.style.destroy(),this.fireEvent("onDestroy")}appendRows(t){this.datamanager.appendRows(t),this.rowmanager.refreshRows()}refreshRow(t,e){this.rowmanager.refreshRow(t,e)}render(){this.renderHeader(),this.renderBody()}renderHeader(){this.columnmanager.renderHeader()}renderBody(){this.bodyRenderer.render()}setDimensions(){this.style.setDimensions()}showToastMessage(t,e){this.bodyRenderer.showToastMessage(t,e)}clearToastMessage(){this.bodyRenderer.clearToastMessage()}getColumn(t){return this.datamanager.getColumn(t)}getColumns(){return this.datamanager.getColumns()}getRows(){return this.datamanager.getRows()}getCell(t,e){return this.datamanager.getCell(t,e)}getColumnHeaderElement(t){return this.columnmanager.getColumnHeaderElement(t)}getViewportHeight(){return this.viewportHeight||(this.viewportHeight=e.style(this.bodyScrollable,"height")),this.viewportHeight}sortColumn(t,e){this.columnmanager.sortColumn(t,e)}removeColumn(t){this.columnmanager.removeColumn(t)}scrollToLastColumn(){this.datatableWrapper.scrollLeft=9999}freeze(){e.style(this.freezeContainer,{display:""})}unfreeze(){e.style(this.freezeContainer,{display:"none"})}updateOptions(t){this.buildOptions(t)}fireEvent(t,...e){const n=[...this._internalEventHandlers[t]||[],this.events[t]].filter(Boolean);for(let t of n)t.apply(this,e)}on(t,e){this._internalEventHandlers=this._internalEventHandlers||{},this._internalEventHandlers[t]=this._internalEventHandlers[t]||[],this._internalEventHandlers[t].push(e)}log(){this.options.logs&&console.log.apply(console,arguments)}translate(t,e){return this.translationManager.translate(t,e)}}Dn.instances=0;var An={name:"@paralogic/frappe-datatable",version:"1.17.5",description:"A modern datatable library for the web",main:"dist/frappe-datatable.cjs.js",unpkg:"dist/frappe-datatable.min.js",jsdelivr:"dist/frappe-datatable.min.js",scripts:{start:"yarn run dev",build:"rollup -c && NODE_ENV=production rollup -c",dev:"rollup -c -w","cy:server":"http-server -p 8989","cy:open":"cypress open","cy:run":"cypress run",test:"start-server-and-test cy:server http://localhost:8989 cy:run","test-local":"start-server-and-test cy:server http://localhost:8989 cy:open","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release",lint:"eslint src","lint-and-build":"yarn lint && yarn build",commit:"npx git-cz"},files:["dist","src"],devDependencies:{autoprefixer:"^9.0.0",chai:"3.5.0",cypress:"^9.2.0","cz-conventional-changelog":"^2.1.0",deepmerge:"^2.0.1",eslint:"^5.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","http-server":"^0.11.1",mocha:"3.3.0","postcss-custom-properties":"^7.0.0","postcss-nested":"^3.0.0",rollup:"^0.59.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1","semantic-release":"^17.1.1","start-server-and-test":"^1.4.1","travis-deploy-once":"^5.0.1"},repository:{type:"git",url:"https://github.com/ParaLogicTech/datatable.git"},keywords:["datatable","data","grid","table"],author:"Faris Ansari",license:"MIT",bugs:{url:"https://github.com/ParaLogicTech/datatable/issues"},homepage:"https://frappe.io/datatable",dependencies:{hyperlist:"^1.0.0-beta",lodash:"^4.17.5",sortablejs:"^1.7.0"},config:{commitizen:{path:"cz-conventional-changelog"}}};return Dn.__version__=An.version,Dn}(Sortable); diff --git a/src/cellmanager.js b/src/cellmanager.js index 7ead7d6..e0119a6 100644 --- a/src/cellmanager.js +++ b/src/cellmanager.js @@ -334,7 +334,11 @@ export default class CellManager { this.clearSelection(); this._selectedCells = cells.map(index => this.getCell$(...index)); requestAnimationFrame(() => { - this._selectedCells.map($cell => $cell.classList.add('dt-cell--highlight')); + this._selectedCells.forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.add('dt-cell--highlight'); + } + }); }); return true; } @@ -393,8 +397,11 @@ export default class CellManager { } clearSelection() { - (this._selectedCells || []) - .forEach($cell => $cell.classList.remove('dt-cell--highlight')); + (this._selectedCells || []).forEach($cell => { + if ($cell && $cell.classList) { + $cell.classList.remove('dt-cell--highlight'); + } + }); this._selectedCells = []; this.$selectionCursor = null; diff --git a/src/datamanager.js b/src/datamanager.js index ca8304e..e217c7e 100644 --- a/src/datamanager.js +++ b/src/datamanager.js @@ -324,42 +324,12 @@ export default class DataManager { } _sortRows(colIndex, sortOrder) { - - if (this.currentSort.colIndex === colIndex) { - // reverse the array if only sortOrder changed - if ( - (this.currentSort.sortOrder === 'asc' && sortOrder === 'desc') || - (this.currentSort.sortOrder === 'desc' && sortOrder === 'asc') - ) { - this.reverseArray(this.rowViewOrder); - this.currentSort.sortOrder = sortOrder; - return; - } + if (this.options.treeView) { + this.treeSort(colIndex, sortOrder); + } else { + this.rowViewOrder.sort((a, b) => this.compareContent(a, b, colIndex, sortOrder)); } - this.rowViewOrder.sort((a, b) => { - const aIndex = a; - const bIndex = b; - - let aContent = this.getCell(colIndex, a).content; - let bContent = this.getCell(colIndex, b).content; - aContent = aContent == null ? '' : aContent; - bContent = bContent == null ? '' : bContent; - - if (sortOrder === 'none') { - return aIndex - bIndex; - } else if (sortOrder === 'asc') { - if (aContent < bContent) return -1; - if (aContent > bContent) return 1; - if (aContent === bContent) return 0; - } else if (sortOrder === 'desc') { - if (aContent < bContent) return 1; - if (aContent > bContent) return -1; - if (aContent === bContent) return 0; - } - return 0; - }); - if (this.hasColumnById('_rowIndex')) { // update row index const srNoColIndex = this.getColumnIndexById('_rowIndex'); @@ -371,6 +341,82 @@ export default class DataManager { } } + treeSort(colIndex, sortOrder) { + let tree = []; + let rowMap = {}; + + // Build Tree + for (let i = 0; i < this.rows.length; i++) { + const rowIndex = this.rows[i].meta.rowIndex; + const currentIndent = this.rows[i].meta.indent; + + let currentNode = { parent: rowIndex, children: [] }; + rowMap[rowIndex] = currentNode; + + if (currentIndent === 0) { + tree.push(currentNode); + } else { + let parentIndex = rowIndex - 1; + + while (parentIndex >= 0 && this.rows[parentIndex].meta.indent >= currentIndent) { + parentIndex--; + } + + if (parentIndex >= 0) { + rowMap[parentIndex].children.push(currentNode); + } + } + } + + // Sort Tree + this._sortTree(tree, colIndex, sortOrder); + + // Row View Order + let flattenedTree = []; + + let traverseNode = (node) => { + flattenedTree.push(node.parent); + if (node.children) { + node.children.forEach(child => traverseNode(child)); + } + }; + + tree.forEach(node => traverseNode(node)); + this.rowViewOrder = flattenedTree; + } + + _sortTree(tree, colIndex, sortOrder) { + if (!tree || tree.length === 0) return; + + tree.sort((a, b) => this.compareContent(a.parent, b.parent, colIndex, sortOrder)); + tree.forEach(node => { + this._sortTree(node.children, colIndex, sortOrder); + }); + } + + compareContent(a, b, colIndex, sortOrder) { + const aIndex = a; + const bIndex = b; + + let aContent = this.getCell(colIndex, a).content; + let bContent = this.getCell(colIndex, b).content; + aContent = aContent == null ? '' : aContent; + bContent = bContent == null ? '' : bContent; + + if (sortOrder === 'none') { + return aIndex - bIndex; + } else if (sortOrder === 'asc') { + if (aContent < bContent) return -1; + if (aContent > bContent) return 1; + if (aContent === bContent) return 0; + } else if (sortOrder === 'desc') { + if (aContent < bContent) return 1; + if (aContent > bContent) return -1; + if (aContent === bContent) return 0; + } + return 0; + }; + reverseArray(array) { let left = null; let right = null;