diff --git a/dist/frappe-datatable.cjs.js b/dist/frappe-datatable.cjs.js index 5ab0446..bf2308b 100644 --- a/dist/frappe-datatable.cjs.js +++ b/dist/frappe-datatable.cjs.js @@ -242,10 +242,12 @@ var isObject_1 = isObject; var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +/** Detect free variable `global` from Node.js. */ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var _freeGlobal = freeGlobal; +/** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ @@ -253,16 +255,34 @@ var root = _freeGlobal || freeSelf || Function('return this')(); var _root = root; +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ var now = function() { return _root.Date.now(); }; var now_1 = now; +/** Built-in value references. */ var Symbol = _root.Symbol; var _Symbol = Symbol; +/** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ @@ -330,6 +350,7 @@ function objectToString(value) { var _objectToString = objectToString; +/** `Object#toString` result references. */ var nullTag = '[object Null]'; var undefinedTag = '[object Undefined]'; @@ -384,6 +405,7 @@ function isObjectLike(value) { var isObjectLike_1 = isObjectLike; +/** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** @@ -410,6 +432,7 @@ function isSymbol(value) { var isSymbol_1 = isSymbol; +/** Used as references for various `Number` constants. */ var NAN = 0 / 0; /** Used to match leading and trailing whitespace. */ @@ -473,6 +496,7 @@ function toNumber(value) { var toNumber_1 = toNumber; +/** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -659,6 +683,7 @@ function debounce(func, wait, options) { var debounce_1 = debounce; +/** Error message constants. */ var FUNC_ERROR_TEXT$1 = 'Expected a function'; /** @@ -965,7 +990,6 @@ class DataManager { prepareCell(content, i) { const cell = { content: '', - align: 'left', sortOrder: 'none', colIndex: i, column: this.columns[i] @@ -1934,7 +1958,7 @@ class CellManager { this.activateEditing(cell); }); - this.keyboard.on('enter', (e) => { + this.keyboard.on('enter', () => { if (this.$focusedCell && !this.$editingCell) { // enter keypress on focused cell this.activateEditing(this.$focusedCell); @@ -1993,13 +2017,11 @@ class CellManager { return true; }; - ['left', 'right', 'up', 'down', 'tab', 'shift+tab'].map( - direction => this.keyboard.on(direction, () => focusCell(direction)) - ); + ['left', 'right', 'up', 'down', 'tab', 'shift+tab'] + .map(direction => this.keyboard.on(direction, () => focusCell(direction))); - ['left', 'right', 'up', 'down'].map( - direction => this.keyboard.on('ctrl+' + direction, () => focusLastCell(direction)) - ); + ['left', 'right', 'up', 'down'] + .map(direction => this.keyboard.on(`ctrl+${direction}`, () => focusLastCell(direction))); this.keyboard.on('esc', () => { this.deactivateEditing(); @@ -2008,9 +2030,7 @@ class CellManager { if (this.options.inlineFilters) { this.keyboard.on('ctrl+f', (e) => { const $cell = $.closest('.data-table-cell', e.target); - let { - colIndex - } = $.data($cell); + const { colIndex } = $.data($cell); this.activateFilter(colIndex); return true; @@ -2035,10 +2055,9 @@ class CellManager { return $selectionCursor; }; - ['left', 'right', 'up', 'down'].map( - direction => this.keyboard.on('shift+' + direction, - () => this.selectArea(getNextSelectionCursor(direction))) - ); + ['left', 'right', 'up', 'down'] + .map(direction => + this.keyboard.on(`shift+${direction}`, () => this.selectArea(getNextSelectionCursor(direction)))); } bindCopyCellContents() { @@ -2186,7 +2205,7 @@ class CellManager { // valid selection this.$selectionCursor = $selectionCursor; } - }; + } _selectArea($cell1, $cell2) { if ($cell1 === $cell2) return false; @@ -2200,13 +2219,15 @@ class CellManager { } getCellsInRange($cell1, $cell2) { - let colIndex1, rowIndex1, colIndex2, rowIndex2; + let colIndex1; + let rowIndex1; + let colIndex2; + let rowIndex2; if (typeof $cell1 === 'number') { - [colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments; + [colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments; // eslint-disable-line } else if (typeof $cell1 === 'object') { - if (!($cell1 && $cell2)) { return false; } @@ -2232,17 +2253,17 @@ class CellManager { return false; } - let cells = []; + const cells = []; let colIndex = colIndex1; let rowIndex = rowIndex1; - let rowIndices = []; + const rowIndices = []; while (rowIndex <= rowIndex2) { rowIndices.push(rowIndex); - rowIndex++; + rowIndex += 1; } - rowIndices.map(rowIndex => { + rowIndices.map((rowIndex) => { while (colIndex <= colIndex2) { cells.push([colIndex, rowIndex]); colIndex++; @@ -2964,9 +2985,7 @@ class BodyRenderer { scrollElem: this.bodyScrollable, contentElem: $('tbody', this.bodyScrollable), callbacks: { - clusterChanged: () => { - this.restoreState(); - } + clusterChanged: () => this.restoreState() }, /* eslint-disable */ show_no_data_row: false, @@ -3003,7 +3022,7 @@ class BodyRenderer { } getDataForClusterize(rows) { - return rows.map((row) => this.rowmanager.getRowHTML(row, row.meta)); + return rows.map(row => this.rowmanager.getRowHTML(row, row.meta)); } getBodyHTML(rows) { @@ -3627,8 +3646,8 @@ var name = "frappe-datatable"; var version = "0.0.4"; var description = "A modern datatable library for the web"; var main = "dist/frappe-datatable.cjs.js"; -var scripts = {"start":"yarn run dev","build":"rollup -c","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"}; -var devDependencies = {"chai":"3.5.0","cssnano":"^3.10.0","deepmerge":"^2.0.1","eslint":"3.19.0","eslint-loader":"1.7.1","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","precss":"^3.1.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify":"^3.0.0"}; +var scripts = {"start":"yarn run dev","build":"rollup -c","production":"rollup -c --production","build:docs":"rollup -c --docs","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js"}; +var devDependencies = {"chai":"3.5.0","deepmerge":"^2.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","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"}; var repository = {"type":"git","url":"https://github.com/frappe/datatable.git"}; var keywords = ["datatable","data","grid","table"]; var author = "Faris Ansari"; diff --git a/dist/frappe-datatable.css b/dist/frappe-datatable.css index 195b393..dd6fcf3 100644 --- a/dist/frappe-datatable.css +++ b/dist/frappe-datatable.css @@ -222,7 +222,7 @@ display: none; padding: 8px; padding: 0.5rem; - background: #fff; + background-color: #fff; z-index: 1; height: 100%; } @@ -236,7 +236,7 @@ } .data-table-cell.editing .edit-cell { - border: 2px solid rgb(82, 146, 247); + border: 2px solid rgb(255, 160, 10); display: block; } diff --git a/dist/frappe-datatable.js b/dist/frappe-datatable.js index 79057ec..ca718cf 100644 --- a/dist/frappe-datatable.js +++ b/dist/frappe-datatable.js @@ -241,10 +241,12 @@ var isObject_1 = isObject; var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +/** Detect free variable `global` from Node.js. */ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var _freeGlobal = freeGlobal; +/** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ @@ -252,16 +254,34 @@ var root = _freeGlobal || freeSelf || Function('return this')(); var _root = root; +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ var now = function() { return _root.Date.now(); }; var now_1 = now; +/** Built-in value references. */ var Symbol = _root.Symbol; var _Symbol = Symbol; +/** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ @@ -329,6 +349,7 @@ function objectToString(value) { var _objectToString = objectToString; +/** `Object#toString` result references. */ var nullTag = '[object Null]'; var undefinedTag = '[object Undefined]'; @@ -383,6 +404,7 @@ function isObjectLike(value) { var isObjectLike_1 = isObjectLike; +/** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** @@ -409,6 +431,7 @@ function isSymbol(value) { var isSymbol_1 = isSymbol; +/** Used as references for various `Number` constants. */ var NAN = 0 / 0; /** Used to match leading and trailing whitespace. */ @@ -472,6 +495,7 @@ function toNumber(value) { var toNumber_1 = toNumber; +/** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -658,6 +682,7 @@ function debounce(func, wait, options) { var debounce_1 = debounce; +/** Error message constants. */ var FUNC_ERROR_TEXT$1 = 'Expected a function'; /** @@ -964,7 +989,6 @@ class DataManager { prepareCell(content, i) { const cell = { content: '', - align: 'left', sortOrder: 'none', colIndex: i, column: this.columns[i] @@ -1933,7 +1957,7 @@ class CellManager { this.activateEditing(cell); }); - this.keyboard.on('enter', (e) => { + this.keyboard.on('enter', () => { if (this.$focusedCell && !this.$editingCell) { // enter keypress on focused cell this.activateEditing(this.$focusedCell); @@ -1992,13 +2016,11 @@ class CellManager { return true; }; - ['left', 'right', 'up', 'down', 'tab', 'shift+tab'].map( - direction => this.keyboard.on(direction, () => focusCell(direction)) - ); + ['left', 'right', 'up', 'down', 'tab', 'shift+tab'] + .map(direction => this.keyboard.on(direction, () => focusCell(direction))); - ['left', 'right', 'up', 'down'].map( - direction => this.keyboard.on('ctrl+' + direction, () => focusLastCell(direction)) - ); + ['left', 'right', 'up', 'down'] + .map(direction => this.keyboard.on(`ctrl+${direction}`, () => focusLastCell(direction))); this.keyboard.on('esc', () => { this.deactivateEditing(); @@ -2007,9 +2029,7 @@ class CellManager { if (this.options.inlineFilters) { this.keyboard.on('ctrl+f', (e) => { const $cell = $.closest('.data-table-cell', e.target); - let { - colIndex - } = $.data($cell); + const { colIndex } = $.data($cell); this.activateFilter(colIndex); return true; @@ -2034,10 +2054,9 @@ class CellManager { return $selectionCursor; }; - ['left', 'right', 'up', 'down'].map( - direction => this.keyboard.on('shift+' + direction, - () => this.selectArea(getNextSelectionCursor(direction))) - ); + ['left', 'right', 'up', 'down'] + .map(direction => + this.keyboard.on(`shift+${direction}`, () => this.selectArea(getNextSelectionCursor(direction)))); } bindCopyCellContents() { @@ -2185,7 +2204,7 @@ class CellManager { // valid selection this.$selectionCursor = $selectionCursor; } - }; + } _selectArea($cell1, $cell2) { if ($cell1 === $cell2) return false; @@ -2199,13 +2218,15 @@ class CellManager { } getCellsInRange($cell1, $cell2) { - let colIndex1, rowIndex1, colIndex2, rowIndex2; + let colIndex1; + let rowIndex1; + let colIndex2; + let rowIndex2; if (typeof $cell1 === 'number') { - [colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments; + [colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments; // eslint-disable-line } else if (typeof $cell1 === 'object') { - if (!($cell1 && $cell2)) { return false; } @@ -2231,17 +2252,17 @@ class CellManager { return false; } - let cells = []; + const cells = []; let colIndex = colIndex1; let rowIndex = rowIndex1; - let rowIndices = []; + const rowIndices = []; while (rowIndex <= rowIndex2) { rowIndices.push(rowIndex); - rowIndex++; + rowIndex += 1; } - rowIndices.map(rowIndex => { + rowIndices.map((rowIndex) => { while (colIndex <= colIndex2) { cells.push([colIndex, rowIndex]); colIndex++; @@ -2963,9 +2984,7 @@ class BodyRenderer { scrollElem: this.bodyScrollable, contentElem: $('tbody', this.bodyScrollable), callbacks: { - clusterChanged: () => { - this.restoreState(); - } + clusterChanged: () => this.restoreState() }, /* eslint-disable */ show_no_data_row: false, @@ -3002,7 +3021,7 @@ class BodyRenderer { } getDataForClusterize(rows) { - return rows.map((row) => this.rowmanager.getRowHTML(row, row.meta)); + return rows.map(row => this.rowmanager.getRowHTML(row, row.meta)); } getBodyHTML(rows) { @@ -3626,8 +3645,8 @@ var name = "frappe-datatable"; var version = "0.0.4"; var description = "A modern datatable library for the web"; var main = "dist/frappe-datatable.cjs.js"; -var scripts = {"start":"yarn run dev","build":"rollup -c","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"}; -var devDependencies = {"chai":"3.5.0","cssnano":"^3.10.0","deepmerge":"^2.0.1","eslint":"3.19.0","eslint-loader":"1.7.1","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","precss":"^3.1.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify":"^3.0.0"}; +var scripts = {"start":"yarn run dev","build":"rollup -c","production":"rollup -c --production","build:docs":"rollup -c --docs","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js"}; +var devDependencies = {"chai":"3.5.0","deepmerge":"^2.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","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"}; var repository = {"type":"git","url":"https://github.com/frappe/datatable.git"}; var keywords = ["datatable","data","grid","table"]; var author = "Faris Ansari"; diff --git a/dist/frappe-datatable.min.css b/dist/frappe-datatable.min.css new file mode 100644 index 0000000..d87dd06 --- /dev/null +++ b/dist/frappe-datatable.min.css @@ -0,0 +1 @@ +.data-table{position:relative;overflow:auto}.data-table *,.data-table :after,.data-table :before{-webkit-box-sizing:border-box;box-sizing:border-box}.data-table button,.data-table input{overflow:visible;font-family:inherit;font-size:inherit;line-height:inherit;margin:0;padding:0}.data-table .input-style{outline:none;width:100%;border:none}.data-table *,.data-table :focus{outline:none;border-radius:0;-webkit-box-shadow:none;box-shadow:none}.data-table table{border-collapse:collapse}.data-table table td{padding:0;border:1px solid #d1d8dd}.data-table thead td{border-bottom-width:1px}.data-table .freeze-container{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;-ms-flex-line-pack:center;align-content:center;position:absolute;left:0;right:0;top:0;bottom:0;background-color:#f5f7fa;opacity:.5;font-size:2em}.data-table .freeze-container span{position:absolute;top:50%;-webkit-transform:translateY(-50%);transform:translateY(-50%)}.data-table .hide{display:none}.data-table .toast-message{position:absolute;bottom:16px;bottom:1rem;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%)}.data-table .toast-message span{display:inline-block;background-color:rgba(0,0,0,.8);color:#dfe2e5;border-radius:3px;padding:8px 16px;padding:.5rem 1rem}.body-scrollable{max-height:500px;overflow:auto;border-bottom:1px solid #d1d8dd}.body-scrollable.row-highlight-all .data-table-row:not(.row-unhighlight){background-color:#f5f7fa}.body-scrollable .no-data td{text-align:center;padding:8px;padding:.5rem}.data-table-header{position:absolute;top:0;left:0;background-color:#fff;font-weight:700}.data-table-header .content span:not(.column-resizer){cursor:pointer}.data-table-header .column-resizer{display:none;position:absolute;right:0;top:0;width:4px;width:.25rem;height:100%;background-color:#5292f7;cursor:col-resize}.data-table-header .data-table-dropdown{position:absolute;right:10px;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;vertical-align:top;text-align:left}.data-table-header .data-table-dropdown.is-active .data-table-dropdown-list,.data-table-header .data-table-dropdown.is-active .data-table-dropdown-toggle{display:block}.data-table-header .data-table-dropdown-toggle{display:none;background-color:transparent;border:none}.data-table-header .data-table-dropdown-list{display:none;font-weight:400;position:absolute;min-width:128px;min-width:8rem;top:100%;right:0;z-index:1;background-color:#fff;border-radius:3px;-webkit-box-shadow:0 2px 3px hsla(0,0%,4%,.1),0 0 0 1px hsla(0,0%,4%,.1);box-shadow:0 2px 3px hsla(0,0%,4%,.1),0 0 0 1px hsla(0,0%,4%,.1);padding-bottom:8px;padding-bottom:.5rem;padding-top:8px;padding-top:.5rem}.data-table-header .data-table-dropdown-list>div{padding:8px 16px;padding:.5rem 1rem}.data-table-header .data-table-dropdown-list>div:hover{background-color:#f5f7fa}.data-table-header .data-table-cell.remove-column{background-color:#fd8b8b;-webkit-transition:background-color .3s ease-in-out;transition:background-color .3s ease-in-out}.data-table-header .data-table-cell.sortable-chosen{background-color:#f5f7fa}.data-table-cell{position:relative}.data-table-cell .content{padding:8px;padding:.5rem;border:2px solid transparent;height:100%}.data-table-cell .content.ellipsis{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.data-table-cell .edit-cell{display:none;padding:8px;padding:.5rem;background-color:#fff;z-index:1;height:100%}.data-table-cell.selected .content{border:2px solid #5292f7}.data-table-cell.editing .content{display:none}.data-table-cell.editing .edit-cell{border:2px solid #ffa00a;border-style:dashed;display:block}.data-table-cell.highlight{background-color:#f5f7fa}.data-table-cell:hover .column-resizer{display:inline-block}.data-table-cell:hover .data-table-dropdown-toggle{display:block}.data-table-cell .tree-node{display:inline-block;position:relative}.data-table-cell .toggle{display:inline-block;position:absolute;padding:0 4px;cursor:pointer}.data-table-cell .toggle:before{content:"▼"}.data-table-cell.tree-close .toggle:before{content:"►"}.data-table-row.row-highlight{background-color:#f5f7fa}.noselect{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}body.data-table-resize{cursor:col-resize} \ No newline at end of file diff --git a/dist/frappe-datatable.min.js b/dist/frappe-datatable.min.js new file mode 100644 index 0000000..f821db2 --- /dev/null +++ b/dist/frappe-datatable.min.js @@ -0,0 +1 @@ +var DataTable=function(t,e){"use strict";function n(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function i(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function o(t){var e=T.call(t,L),n=t[L];try{t[L]=void 0;var i=!0}catch(t){}var o=H.call(t);return i&&(e?t[L]=n:delete t[L]),o}function s(t){return W.call(t)}function r(t){return null==t?void 0===t?z:O:A&&A in Object(t)?_(t):j(t)}function a(t){return null!=t&&"object"==typeof t}function l(t){return"symbol"==typeof t||F(t)&&B(t)==D}function c(t){if("number"==typeof t)return t;if(N(t))return V;if(I(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=I(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(q,"");var n=P.test(t);return n||X.test(t)?U(t.slice(2),n?2:8):K.test(t)?V:+t}function h(t,e,n){function i(e){var n=d,i=f;return d=f=void 0,b=e,g=t.apply(i,n)}function o(t){return b=t,p=setTimeout(a,e),C?i(t):g}function s(t){var n=t-b,i=e-(t-w);return y?Q(i,m-n):i}function r(t){var n=t-w,i=t-b;return void 0===w||n>=e||n<0||y&&i>=m}function a(){var t=E();if(r(t))return l(t);p=setTimeout(a,s(t))}function l(t){return p=void 0,x&&d?i(t):(d=f=void 0,g)}function c(){void 0!==p&&clearTimeout(p),b=0,d=w=f=p=void 0}function h(){return void 0===p?g:l(E())}function u(){var t=E(),n=r(t);if(d=arguments,f=this,w=t,n){if(void 0===p)return o(w);if(y)return p=setTimeout(a,e),i(w)}return void 0===p&&(p=setTimeout(a,e)),g}var d,f,m,g,p,w,b=0,C=!1,y=!1,x=!0;if("function"!=typeof t)throw new TypeError(G);return e=Z(e)||0,I(n)&&(C=!!n.leading,m=(y="maxWait"in n)?J(Z(n.maxWait)||0,e):m,x="trailing"in n?!!n.trailing:x),u.cancel=c,u.flush=h,u}function u(t,e,n){var i=!0,o=!0;if("function"!=typeof t)throw new TypeError(tt);return I(n)&&(i="leading"in n?!!n.leading:i,o="trailing"in n?!!n.trailing:o),Y(t,e,{leading:i,maxWait:e,trailing:o})}function d(t){return t.replace(/([A-Z])/g,t=>`-${t[0].toLowerCase()}`)}function f(t){return Object.keys(t).map(e=>{const n=d(e);const i=t[e];if(void 0===i)return"";return`data-${n}="${i}" `}).join("").trim()}function m(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 g(t){return!isNaN(t)}function p(t,e=null){return(...n)=>new Promise(i=>{const o=()=>{const o=t.apply(e,n);i(o)};window.setImmediate?setImmediate(o):window.requestAnimationFrame?requestAnimationFrame(o):setTimeout(o)})}function w(t,e,n){const i=n.reduce((t,n)=>{t[n]={get(){return e[n]}};return t},{});Object.defineProperties(t,i)}function b(t){return void 0!==t||null!==t}function C(t){return!b(t)}function y(t){return!isNaN(t)}function x(t){return Array.isArray(t)?t:[t]}t=t&&t.hasOwnProperty("default")?t.default:t,e=e&&e.hasOwnProperty("default")?e.default:e,n.each=((t,e)=>"string"==typeof t?Array.from((e||document).querySelectorAll(t)):t||null),n.create=((t,e)=>{let i=document.createElement(t);for(let t in e){let o=e[t];if("inside"===t)n(o).appendChild(i);else if("around"===t){let t=n(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}),n.on=((t,e,i,o)=>{o?n.delegate(t,e,i,o):(o=i,n.bind(t,e,o))}),n.off=((t,e,n)=>{t.removeEventListener(e,n)}),n.bind=((t,e,n)=>{e.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}),n.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))})}),n.unbind=((t,e)=>{if(t)for(let n in e){let i=e[n];n.split(/\s+/).forEach(function(e){t.removeEventListener(e,i)})}}),n.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)}),n.data=((t,e)=>{if(!e)return t.dataset;for(const n in e)t.dataset[n]=e[n]}),n.style=((t,e)=>{if("string"==typeof e)return n.getStyle(t,e);Array.isArray(t)||(t=[t]);t.map(t=>{for(const n in e)t.style[n]=e[n]})}),n.removeStyle=((t,e)=>{Array.isArray(t)||(t=[t]);Array.isArray(e)||(e=[e]);t.map(t=>{for(const n of e)t.style[n]=""})}),n.getStyle=((t,e)=>{let n=getComputedStyle(t)[e];["width","height"].includes(e)&&(n=parseFloat(n));return n}),n.closest=((t,e)=>{if(!e)return null;if(e.matches(t))return e;return n.closest(t,e.parentNode)}),n.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}),n.scrollTop=function(t,e){requestAnimationFrame(()=>{t.scrollTop=e})},n.scrollbarWidth=function(){const t=document.createElement("div");n.style(t,{width:"100px",height:"100px",overflow:"scroll",position:"absolute",top:"-9999px"}),document.body.appendChild(t);const e=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),e};var I=i,v="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},R="object"==typeof v&&v&&v.Object===Object&&v,S="object"==typeof self&&self&&self.Object===Object&&self,$=R||S||Function("return this")(),E=function(){return $.Date.now()},k=$.Symbol,M=Object.prototype,T=M.hasOwnProperty,H=M.toString,L=k?k.toStringTag:void 0,_=o,W=Object.prototype.toString,j=s,O="[object Null]",z="[object Undefined]",A=k?k.toStringTag:void 0,B=r,F=a,D="[object Symbol]",N=l,V=NaN,q=/^\s+|\s+$/g,K=/^[-+]0x[0-9a-f]+$/i,P=/^0b[01]+$/i,X=/^0o[0-7]+$/i,U=parseInt,Z=c,G="Expected a function",J=Math.max,Q=Math.min,Y=h,tt="Expected a function";let et=u,nt=Y;class it{constructor(t){this.options=t,this.sortRows=p(this.sortRows,this),this.switchColumn=p(this.switchColumn,this),this.removeColumn=p(this.removeColumn,this),this.filterRows=p(this.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.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&&i&&g(i)&&(e.align="right");return e}))}prepareRows(){this.validateData(this.data),this.rows=this.data.map((t,e)=>{const n=this._getNextRowCount();let i=[];let o={rowIndex:n};if(Array.isArray(t))for(this.options.checkboxColumn&&i.push(this.getCheckboxHTML()),this.options.serialNoColumn&&i.push(n+1+""),i=i.concat(t);i.length{if(y(t.meta.indent)){const n=this.getRow(e+1);t.meta.isLeaf=!n||C(n.meta.indent)||n.meta.indent<=t.meta.indent}})}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 ot("`columns` must be an array");t.forEach((t,e)=>{if("string"!=typeof t&&"object"!=typeof t)throw new ot(`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 ot("`data` must be an array of arrays or objects")}appendRows(t){this.validateData(t),this.rows.push(...this.prepareRows(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;const r=this.getCell(t,n).content;const a=this.getCell(t,i).content;if("none"===e)return o-s;if("asc"===e){if(ra)return 1;if(r===a)return 0}else if("desc"===e){if(ra)return-1;if(r===a)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,e){let n=[],i=[];return this.rows.map(t=>t[e]).forEach(e=>{const o=String(e.content||"").toLowerCase();const s=(t||"").toLowerCase();!s||o.includes(s)?i.push(e.rowIndex):n.push(e.rowIndex)}),this._filteredRows=i,{rowsToHide:n,rowsToShow:i}}getFilteredRowIndices(){return this._filteredRows||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.data[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 ot extends TypeError{}class st{constructor(t){this.instance=t,w(this,this.instance,["options","fireEvent","header","datamanager","style","wrapper","rowmanager","bodyScrollable"]),this.bindEvents(),rt=rt.bind(this,this.options.dropdownButton)}renderHeader(){this.header.innerHTML="",this.refreshHeader()}refreshHeader(){const t=this.datamanager.getColumns(),e=n.each(".data-table-cell[data-is-header]",this.header);!n(".data-table-cell",this.header)||t.length{const o=t[i];n.data(e,{colIndex:o.colIndex});const s=n(".sort-indicator",e);s&&(s.innerHTML=this.options.sortIndicator[o.sortOrder])}),this.$columnMap=[]}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.bindMoveColumn(),this.bindFilter()}bindDropdown(){function t(t){e&&e.classList.remove("is-active"),e=null}let e;n.on(this.header,"click",".data-table-dropdown-toggle",(i,o)=>{const s=n.closest(".data-table-dropdown",o);s.classList.contains("is-active")?t():(t(),s.classList.add("is-active"),e=s)}),n.on(document.body,"click",e=>{if(e.target.matches(".data-table-dropdown-toggle"))return;t()});const i=this.options.headerDropdown;n.on(this.header,"click",".data-table-dropdown-list > div",(t,e)=>{const o=n.closest(".data-table-cell",e);const{index:index}=n.data(e);const{colIndex:colIndex}=n.data(o);let s=i[index].action;s&&s.call(this.instance,this.getColumn(colIndex))})}bindResizeColumn(){let t,e,i,o=!1;n.on(this.header,"mousedown",".data-table-cell .column-resizer",(s,r)=>{document.body.classList.add("data-table-resize");const a=r.parentNode.parentNode;t=a;const{colIndex:colIndex}=n.data(t);const l=this.getColumn(colIndex);if(l&&!1===l.resizable)return;o=!0;e=n.style(n(".content",t),"width");i=s.pageX}),n.on(document.body,"mouseup",e=>{document.body.classList.remove("data-table-resize");if(!t)return;o=!1;const{colIndex:colIndex}=n.data(t);this.setColumnWidth(colIndex);this.style.setBodyStyle();t=null}),n.on(document.body,"mousemove",s=>{if(!o)return;const r=e+(s.pageX-i);const{colIndex:colIndex}=n.data(t);if(this.getColumnMinWidth(colIndex)>r)return;this.datamanager.updateColumn(colIndex,{width:r});this.setColumnHeaderWidth(colIndex)})}bindMoveColumn(){const e=()=>{const e=n(".data-table-cell",this.header);if(!e)return;const i=n(".data-table-row",this.header);this.sortable=t.create(i,{onEnd:t=>{const{oldIndex:oldIndex,newIndex:newIndex}=t;const e=t.item;const{colIndex:colIndex}=n.data(e);if(+colIndex===newIndex)return;this.switchColumn(oldIndex,newIndex)},preventOnFilter:!1,filter:".column-resizer, .data-table-dropdown",animation:150})};n.on(document.body,"mousemove",e)}bindSortColumn(){n.on(this.header,"click",".data-table-cell .column-title",(t,e)=>{const i=e.closest(".data-table-cell");let{colIndex:colIndex,sortOrder:sortOrder="none"}=n.data(i);const o=this.getColumn(colIndex);if(o&&!1===o.sortable)return;n(".sort-indicator",this.header).textContent="";n.each(".data-table-cell",this.header).map(t=>{n.data(t,{sortOrder:"none"})});let s,r;"none"===sortOrder?(s="asc",r="▲"):"asc"===sortOrder?(s="desc",r="▼"):"desc"===sortOrder&&(s="none",r="");n.data(i,{sortOrder:s});n(".sort-indicator",i).textContent=r;this.sortColumn(colIndex,s)})}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){let e;(e=void 0===t?!this.isFilterShown:t)?n.style(this.$filterRow,{display:""}):n.style(this.$filterRow,{display:"none"}),this.isFilterShown=e,this.style.setBodyStyle()}focusFilter(t){this.isFilterShown&&n(`[data-col-index="${t}"] .data-table-filter`,this.$filterRow).focus()}bindFilter(){if(this.options.inlineFilters){const t=t=>{const e=n.closest(".data-table-cell",t.target);const{colIndex:colIndex}=n.data(e);const i=t.target.value;this.datamanager.filterRows(i,colIndex).then(({rowsToHide:rowsToHide,rowsToShow:rowsToShow})=>{this.rowmanager.hideRows(rowsToHide);this.rowmanager.showRows(rowsToShow)})};n.on(this.header,"keydown",".data-table-filter",nt(t,300))}}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,this._columnWidthMap=this._columnWidthMap||[];let n=e||this.getColumn(t).width,i=this._columnWidthMap[t];const o=`[data-col-index="${t}"] .content, [data-col-index="${t}"] .edit-cell`,s={width:n+"px"};void 0!==(i=this.style.setStyle(o,s,i))&&(this._columnWidthMap[t]=i)}setColumnHeaderWidth(t){t=+t,this.$columnMap=this.$columnMap||[];const e=`.data-table-header [data-col-index="${t}"] .content`,{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 n(`.data-table-cell[data-col-index="${t}"]`,this.header)}getLastColumnIndex(){return this.datamanager.getColumnCount()-1}getSerialColumnIndex(){return this.datamanager.getColumns().findIndex(t=>t.content.includes("Sr. No"))}}var rt=function(t="v"){return`
${t}
\n
\n ${this.options.headerDropdown.map((t,e)=>`
${t.label}
`).join("")}\n
\n `};class at{constructor(t){this.instance=t,w(this,this.instance,["wrapper","options","style","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,n.on(this.bodyScrollable,"dblclick",".data-table-cell",(t,e)=>{this.activateEditing(e)}),this.keyboard.on("enter",t=>{this.$focusedCell&&!this.$editingCell?this.activateEditing(this.$focusedCell):this.$editingCell&&(this.submitEditing(),this.deactivateEditing())})}bindKeyboardNav(){const t=t=>{if(!this.$focusedCell||this.$editingCell)return!1;let e=this.$focusedCell;"left"===t||"shift+tab"===t?e=this.getLeftCell$(e):"right"===t||"tab"===t?e=this.getRightCell$(e):"up"===t?e=this.getAboveCell$(e):"down"===t&&(e=this.getBelowCell$(e));this.focusCell(e);return!0},e=t=>{if(!this.$focusedCell||this.$editingCell)return!1;let e=this.$focusedCell;const{rowIndex:rowIndex,colIndex:colIndex}=n.data(e);"left"===t?e=this.getLeftMostCell$(rowIndex):"right"===t?e=this.getRightMostCell$(rowIndex):"up"===t?e=this.getTopMostCell$(colIndex):"down"===t&&(e=this.getBottomMostCell$(colIndex));this.focusCell(e);return!0};["left","right","up","down","tab","shift+tab"].map(e=>this.keyboard.on(e,()=>t(e))),["left","right","up","down"].map(t=>this.keyboard.on("ctrl+"+t,()=>e(t))),this.keyboard.on("esc",()=>{this.deactivateEditing()}),this.options.inlineFilters&&this.keyboard.on("ctrl+f",t=>{const e=n.closest(".data-table-cell",t.target);let{colIndex:colIndex}=n.data(e);this.activateFilter(colIndex);return!0})}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",()=>{this.copyCellContents(this.$focusedCell,this.$selectionCursor)})}bindMouseEvents(){let t=null;n.on(this.bodyScrollable,"mousedown",".data-table-cell",e=>{t=!0;this.focusCell(n(e.delegatedTarget))}),n.on(this.bodyScrollable,"mouseup",()=>{t=!1});const e=e=>{if(!t)return;this.selectArea(n(e.delegatedTarget))};n.on(this.bodyScrollable,"mousemove",".data-table-cell",et(e,50))}bindTreeEvents(){n.on(this.bodyScrollable,"click",".toggle",(t,e)=>{const i=n.closest(".data-table-cell",e);const{rowIndex:rowIndex}=n.data(i);i.classList.contains("tree-close")?this.rowmanager.openSingleNode(rowIndex):this.rowmanager.closeSingleNode(rowIndex)})}focusCell(t,{skipClearSelection:skipClearSelection=0}={}){if(t&&t!==this.$editingCell){const{colIndex:colIndex,isHeader:isHeader}=n.data(t);isHeader||!1!==this.columnmanager.getColumn(colIndex).focusable&&(this.scrollToCell(t),this.deactivateEditing(),skipClearSelection||this.clearSelection(),this.$focusedCell&&this.$focusedCell.classList.remove("selected"),this.$focusedCell=t,t.classList.add("selected"),t.focus(),this.highlightRowColumnHeader(t))}}highlightRowColumnHeader(t){const{colIndex:colIndex,rowIndex:rowIndex}=n.data(t),e=`.data-table-header .data-table-cell[data-col-index="${colIndex}"]`,i=`.data-table-cell[data-row-index="${rowIndex}"][data-col-index="${this.datamanager.getColumnIndexById("_rowIndex")}"]`;this.lastHeaders&&n.removeStyle(this.lastHeaders,"backgroundColor");const o=n(e,this.wrapper),s=n(i,this.wrapper);n.style([o,s],{backgroundColor:"#f5f7fa"}),this.lastHeaders=[o,s]}selectAreaOnClusterChanged(){if(this.$focusedCell&&this.$selectionCursor){const{colIndex:colIndex,rowIndex:rowIndex}=n.data(this.$selectionCursor),t=this.getCell$(colIndex,rowIndex);if(t&&t!==this.$selectionCursor){const e=n.data(this.$focusedCell);this.$focusedCell=this.getCell$(e.colIndex,e.rowIndex),this.selectArea(t)}}}focusCellOnClusterChanged(){if(this.$focusedCell){const{colIndex:colIndex,rowIndex:rowIndex}=n.data(this.$focusedCell),t=this.getCell$(colIndex,rowIndex);t&&this.focusCell(t,{skipClearSelection:1})}}selectArea(t){this.$focusedCell&&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(),n.map(t=>this.getCell$(...t)).map(t=>t.classList.add("highlight")),!0)}getCellsInRange(t,e){let i,o,s,r;if("number"==typeof t)[i,o,s,r]=arguments;else if("object"==typeof t){if(!t||!e)return!1;const a=n.data(t),l=n.data(e);i=a.colIndex,o=a.rowIndex,s=l.colIndex,r=l.rowIndex}if(o>r&&([o,r]=[r,o]),i>s&&([i,s]=[s,i]),this.isStandardCell(i)||this.isStandardCell(s))return!1;let a=[],l=i,c=o,h=[];for(;c<=r;)h.push(c),c++;return h.map(t=>{for(;l<=s;)a.push([l,t]),l++;l=i}),a}clearSelection(){n.each(".data-table-cell.highlight",this.bodyScrollable).map(t=>t.classList.remove("highlight")),this.$selectionCursor=null}getSelectionCursor(){return this.$selectionCursor||this.$focusedCell}activateEditing(t){this.focusCell(t);const{rowIndex:rowIndex,colIndex:colIndex}=n.data(t),e=this.columnmanager.getColumn(colIndex);if(!e||!1!==e.editable&&!1!==e.focusable){const i=this.getCell(colIndex,rowIndex);if(!i||!1!==i.editable){if(this.$editingCell){const{_rowIndex:_rowIndex,_colIndex:_colIndex}=n.data(this.$editingCell);if(rowIndex===_rowIndex&&colIndex===_colIndex)return}this.$editingCell=t,t.classList.add("editing");const o=n(".edit-cell",t);o.innerHTML="";const s=this.getEditor(colIndex,rowIndex,i.content,o);s&&(this.currentCellEditor=s,s.initValue(i.content,rowIndex,e))}}}deactivateEditing(){this.$focusedCell&&this.$focusedCell.focus(),this.$editingCell&&(this.$editingCell.classList.remove("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 a=this.options.getEditor?this.options.getEditor(t,e,n,i,o,s,r):this.getDefaultEditor(i);return!1!==a&&(void 0===a&&(a=this.getDefaultEditor(i)),a)}getDefaultEditor(t){const e=n.create("input",{class:"input-style",type:"text",inside:t});return{initValue(t){e.focus(),e.value=t},getValue(){return e.value},setValue(t){e.value=t}}}submitEditing(){if(this.$editingCell){const t=this.$editingCell,{rowIndex:rowIndex,colIndex:colIndex}=n.data(t),e=this.datamanager.getColumn(colIndex);if(t){const n=this.currentCellEditor;if(n){const i=n.getValue(),o=n.setValue(i,rowIndex,e),s=this.getCell(colIndex,rowIndex).content;this.updateCell(colIndex,rowIndex,i),t.focus(),o&&o.then&&o.catch(t=>{console.log(t);this.updateCell(colIndex,rowIndex,s)})}}this.currentCellEditor=null}}copyCellContents(t,e){if(!e&&t){const{colIndex:colIndex,rowIndex:rowIndex}=n.data(t),e=this.getCell(colIndex,rowIndex);return void m(e.content)}const i=this.getCellsInRange(t,e);i&&m(i.map(t=>this.getCell(...t)).reduce((t,e)=>{const n=e.rowIndex;t[n]=t[n]||[];t[n].push(e.content);return t},[]).map(t=>t.join("\t")).join("\n"))}activateFilter(t){this.columnmanager.toggleFilter(),this.columnmanager.focusFilter(t),this.columnmanager.isFilterShown||this.$focusedCell.focus()}updateCell(t,e,n){const i=this.datamanager.updateCell(t,e,{content:n});this.refreshCell(i)}refreshCell(t){n(this.selector(t.colIndex,t.rowIndex),this.bodyScrollable).innerHTML=this.getCellContent(t)}toggleTreeButton(t,e){const n=this.columnmanager.getFirstColumnIndex(),i=this.getCell$(n,t);i&&i.classList[e?"remove":"add"]("tree-close")}isStandardCell(t){return t\n ${this.getCellContent(t)}\n \n `}getCellContent(t){const{isHeader:isHeader,isFilter:isFilter}=t,e=!isHeader&&!1!==t.editable?this.getEditCellHTML():"",n=isHeader&&!1!==t.sortable?'':"",i=isHeader&&!1!==t.resizable?'':"",o=isHeader&&!1!==t.dropdown?`
${rt()}
`:"",s=t.format||t.column&&t.column.format||null;let r;if(isHeader||isFilter||!s)r=t.content;else{const e=this.datamanager.getRow(t.rowIndex),n=this.datamanager.getData(t.rowIndex);r=s(t.content,e,t.column,n)}if(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=1.5*((t.indent||0)+1),i=n?``:"";r=`\n ${i}${r}`}}return`\n
\n ${r}\n ${n}\n ${i}\n ${o}\n
\n ${e}\n `}getEditCellHTML(){return`\n
\n `}selector(t,e){return`.data-table-cell[data-col-index="${t}"][data-row-index="${e}"]`}}class lt{constructor(t){this.instance=t,w(this,this.instance,["options","fireEvent","wrapper","bodyScrollable","bodyRenderer"]),this.bindEvents(),this.refreshRows=p(this.refreshRows,this)}get datamanager(){return this.instance.datamanager}get cellmanager(){return this.instance.cellmanager}bindEvents(){this.bindCheckbox()}bindCheckbox(){this.options.checkboxColumn&&(this.checkMap=[],n.on(this.wrapper,"click",'.data-table-cell[data-col-index="0"] [type="checkbox"]',(t,e)=>{const i=e.closest(".data-table-cell");const{rowIndex:rowIndex,isHeader:isHeader}=n.data(i);const o=e.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)})}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,e){const i=e?1:0,o=t=>`.data-table-cell[data-row-index="${t}"][data-col-index="0"] [type="checkbox"]`;this.checkMap[t]=i,n.each(o(t),this.bodyScrollable).map(t=>{t.checked=e}),this.highlightRow(t,e),this.showCheckStatus(),this.fireEvent("onCheckRow",this.datamanager.getRow(t))}checkAll(t){const e=t?1:0;this.checkMap=t?Array.from(Array(this.getTotalRows())).map(t=>e):[],n.each('.data-table-cell[data-col-index="0"] [type="checkbox"]',this.bodyScrollable).map(e=>{e.checked=t}),this.highlightAll(t),this.showCheckStatus()}showCheckStatus(){if(this.options.checkedRowStatus){const t=this.getCheckedRows().length;t>0?this.bodyRenderer.showToastMessage(`${t} row${t>1?"s":""} selected`):this.bodyRenderer.clearToastMessage()}}highlightRow(t,e=!0){const n=this.getRow$(t);if(n){if(!e&&this.bodyScrollable.classList.contains("row-highlight-all"))return void n.classList.add("row-unhighlight");e&&n.classList.contains("row-unhighlight")&&n.classList.remove("row-unhighlight"),this._highlightedRows=this._highlightedRows||{},e?(n.classList.add("row-highlight"),this._highlightedRows[t]=n):(n.classList.remove("row-highlight"),delete this._highlightedRows[t])}}highlightAll(t=!0){if(t)this.bodyScrollable.classList.add("row-highlight-all");else{this.bodyScrollable.classList.remove("row-highlight-all");for(const t in this._highlightedRows){const e=this._highlightedRows[t];e.classList.remove("row-highlight")}this._highlightedRows={}}}hideRows(t){(t=x(t)).map(t=>{const e=this.getRow$(t);e.classList.add("hide")})}showRows(t){(t=x(t)).map(t=>{const e=this.getRow$(t);e.classList.remove("hide")})}openSingleNode(t){const e=this.datamanager.getImmediateChildren(t);this.showRows(e),this.cellmanager.toggleTreeButton(t,!0)}closeSingleNode(t){this.datamanager.getImmediateChildren(t).forEach(t=>{const e=this.datamanager.getRow(t);e.meta.isLeaf?(this.hideRows(t),this.cellmanager.toggleTreeButton(t,!1)):(this.closeSingleNode(t),this.hideRows(t))}),this.cellmanager.toggleTreeButton(t,!1)}getRow$(t){return n(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 e=this.getRow$(t);if(!n.inViewport(e,this.bodyScrollable)){const{height:height}=e.getBoundingClientRect(),{top:top,bottom:bottom}=this.bodyScrollable.getBoundingClientRect(),i=Math.floor((bottom-top)/height);let o=0;o=t>this._lastScrollTo?height*(t+1-i):height*(t+1-1),this._lastScrollTo=t,n.scrollTop(this.bodyScrollable,o)}}getRowHTML(t,e){const n=f(e);return e.isFilter&&(t=t.map(t=>Object.assign({},t,{content:this.getFilterInput({colIndex:t.colIndex}),isFilter:1,isHeader:void 0,editable:!1}))),`\n \n ${t.map(t=>this.cellmanager.getCellHTML(t)).join("")}\n \n `}getFilterInput(t){return``}selector(t){return`.data-table-row[data-row-index="${t}"]`}}class ct{constructor(t){this.instance=t,this.options=t.options,this.datamanager=t.datamanager,this.rowmanager=t.rowmanager,this.cellmanager=t.cellmanager,this.bodyScrollable=t.bodyScrollable,this.log=t.log,this.appendRemainingData=p(this.appendRemainingData,this)}render(){this.options.clusterize?this.renderBodyWithClusterize():this.renderBodyHTML()}renderBodyHTML(){const t=this.datamanager.getRowsForView();this.bodyScrollable.innerHTML=`\n \n ${this.getBodyHTML(t)}\n
\n `,this.instance.setDimensions(),this.restoreState()}renderBodyWithClusterize(){const t=this.datamanager.getRowsForView(0,20);let i=this.getDataForClusterize(t);0===i.length&&(i=[`${this.options.noDataMessage}`]),this.clusterize?this.clusterize.update(i):(this.bodyScrollable.innerHTML=`\n \n ${this.getBodyHTML([])}\n
\n `,this.clusterize=new e({rows:i,scrollElem:this.bodyScrollable,contentElem:n("tbody",this.bodyScrollable),callbacks:{clusterChanged:()=>{this.restoreState()}},show_no_data_row:!1}),this.instance.setDimensions()),this.appendRemainingData()}restoreState(){this.rowmanager.highlightCheckedRows(),this.cellmanager.selectAreaOnClusterChanged(),this.cellmanager.focusCellOnClusterChanged()}appendRemainingData(){const t=this.datamanager.getRowsForView(20),e=this.getDataForClusterize(t);this.clusterize.append(e)}showToastMessage(t){this.instance.toastMessage.innerHTML=`${t}`}clearToastMessage(){this.instance.toastMessage.innerHTML=""}getDataForClusterize(t){return t.map(t=>this.rowmanager.getRowHTML(t,t.meta))}getBodyHTML(t){return`\n \n ${t.map(t=>this.rowmanager.getRowHTML(t,t.meta)).join("")}\n \n `}}class ht{constructor(t){this.instance=t,w(this,this.instance,["options","datamanager","columnmanager","header","bodyScrollable","datatableWrapper","getColumn"]),this.scopeClass="datatable-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()}get stylesheet(){return this.styleEl.sheet}bindResizeWindow(){"fluid"===this.options.layout&&n.on(window,"resize",et(()=>{this.distributeRemainingWidth();this.refreshColumnWidth();this.compensateScrollbarWidth();this.setBodyStyle()},300))}destroy(){this.styleEl.remove()}setStyle(t,e,n=-1){const i=Object.keys(e).map(t=>{t.includes("-")||(t=d(t));return`${t}:${e[t]};`}).join("");let o=`${t.split(",").map(t=>`.${this.scopeClass} ${t}`).join(",")} { ${i} }`;if(this.stylesheet){let t=this.stylesheet.cssRules.length;return-1!==n&&(this.stylesheet.deleteRule(n),t=n),this.stylesheet.insertRule(o,t),t}}setDimensions(){this.setHeaderStyle(),this.setupMinWidth(),this.setupNaturalColumnWidth(),this.setupColumnWidth(),this.distributeRemainingWidth(),this.setColumnStyle(),this.compensateScrollbarWidth(),this.setDefaultCellHeight(),this.setBodyStyle()}setHeaderStyle(){"fluid"===this.options.layout&&n.style(this.header,{width:0}),n.style(this.header,{margin:0});const t=this.datamanager.getColumns().filter(t=>!1===t.resizable).map(t=>t.colIndex).map(t=>`.data-table-header [data-col-index="${t}"]`).join();this.setStyle(t,{cursor:"pointer"})}setupMinWidth(){n.each(".data-table-cell[data-is-header]",this.header).map(t=>{const e=n.style(n(".content",t),"width");const{colIndex:colIndex}=n.data(t);const i=this.getColumn(colIndex);i.minWidth||(i.minWidth=e)})}setupNaturalColumnWidth(){n(".data-table-row")&&n.each('.data-table-row[data-row-index="0"] .data-table-cell',this.bodyScrollable).map(t=>{const{colIndex:colIndex}=n.data(t);const e=this.datamanager.getColumn(colIndex);let i=n.style(n(".content",t),"width");"_rowIndex"===e.id&&(i=this.getRowIndexColumnWidth(i),e.width=i);e.naturalWidth=i})}setupColumnWidth(){if("ratio"===this.options.layout){let t=n.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 e=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/e;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);t.widtht.resizable),o=(t-e)/i.length;i.map(t=>{const e=n.style(this.getColumnHeaderElement(t.colIndex),"width");let i=Math.floor(e+o)-2;this.datamanager.updateColumn(t.colIndex,{width:i})})}}setDefaultCellHeight(){if(!this.options.dynamicRowHeight&&!this.__cellHeightSet){const t=n(".data-table-cell[data-is-header]",this.instance.header);if(t){const e=this.options.cellHeight||n.style(t,"height");e&&(this.setCellHeight(e),this.__cellHeightSet=!0)}}}setCellHeight(t){this.setStyle(".data-table-cell .content",{height:t+"px"}),this.setStyle(".data-table-cell .edit-cell",{height:t+"px"})}setColumnStyle(){this.datamanager.getColumns().map(t=>{["left","center","right"].includes(t.align)&&this.setStyle(`[data-col-index="${t.colIndex}"]`,{"text-align":t.align});this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)}),this.setBodyStyle()}refreshColumnWidth(){this.datamanager.getColumns().map(t=>{this.columnmanager.setColumnHeaderWidth(t.colIndex);this.columnmanager.setColumnWidth(t.colIndex)})}setBodyStyle(){const t=n.style(this.header,"width");n.style(this.bodyScrollable,{width:t+"px"});const e=n(".data-table-body",this.bodyScrollable);e&&n.style(e,{height:"0px"}),n.style(this.bodyScrollable,{marginTop:n.style(this.header,"height")+"px"}),n.style(n("table",this.bodyScrollable),{margin:0,width:"100%"})}getColumnHeaderElement(t){return t=+t,t<0?null:n(`.data-table-cell[data-col-index="${t}"]`,this.header)}getRowIndexColumnWidth(t){this._rowIndexColumnWidthMap=this._rowIndexColumnWidthMap||{};const e=(this.datamanager.getRowCount()+"").length;return this._rowIndexColumnWidthMap[e]||(this._rowIndexColumnWidthMap[e]=t+8*(e-1)),this._rowIndexColumnWidthMap[e]}}const ut={13:"enter",91:"meta",16:"shift",17:"ctrl",18:"alt",37:"left",38:"up",39:"right",40:"down",9:"tab",27:"esc",67:"c",70:"f"};class dt{constructor(t){this.listeners={},n.on(t,"keydown",this.handler.bind(this))}handler(t){let e=ut[t.keyCode];t.shiftKey&&"shift"!==e&&(e="shift+"+e),(t.ctrlKey&&"ctrl"!==e||t.metaKey&&"meta"!==e)&&(e="ctrl+"+e);const n=this.listeners[e];if(n&&n.length>0)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 ft={columns:[],data:[],dropdownButton:"▼",headerDropdown:[{label:"Sort Ascending",action:function(t){this.sortColumn(t.colIndex,"asc")}},{label:"Sort Descending",action:function(t){this.sortColumn(t.colIndex,"desc")}},{label:"Reset sorting",action:function(t){this.sortColumn(t.colIndex,"none")}},{label:"Remove column",action:function(t){this.removeColumn(t.colIndex)}}],events:{onRemoveColumn(t){},onSwitchColumn(t,e){},onSortColumn(t){},onCheckRow(t){}},sortIndicator:{asc:"↑",desc:"↓",none:""},freezeMessage:"",getEditor:null,serialNoColumn:!0,checkboxColumn:!1,clusterize:!0,logs:!1,layout:"fixed",noDataMessage:"No Data",cellHeight:null,inlineFilters:!1,treeView:!1,checkedRowStatus:!0,dynamicRowHeight:!1};class mt{constructor(t,e){if(mt.instances++,"string"==typeof t&&(t=document.querySelector(t)),this.wrapper=t,!(this.wrapper instanceof HTMLElement))throw new Error("Invalid argument given for `wrapper`");this.buildOptions(e),this.prepare(),this.style=new ht(this),this.keyboard=new dt(this.wrapper),this.datamanager=new it(this.options),this.rowmanager=new lt(this),this.columnmanager=new st(this),this.cellmanager=new at(this),this.bodyRenderer=new ct(this),this.options.data&&this.refresh()}buildOptions(t){this.options=this.options||{},this.options=Object.assign({},ft,this.options||{},t),this.options.headerDropdown.push(...t.headerDropdown||[]),this.events=Object.assign({},ft.events,this.options.events||{},t.events||{}),this.fireEvent=this.fireEvent.bind(this)}prepare(){this.prepareDom(),this.unfreeze()}prepareDom(){this.wrapper.innerHTML=`\n
\n \n
\n
\n
\n
\n ${this.options.freezeMessage}\n
\n \n
\n
\n `,this.datatableWrapper=n(".data-table",this.wrapper),this.header=n(".data-table-header",this.wrapper),this.bodyScrollable=n(".body-scrollable",this.wrapper),this.freezeContainer=n(".freeze-container",this.wrapper),this.toastMessage=n(".toast-message",this.wrapper)}refresh(t,e){this.datamanager.init(t,e),this.render(),this.setDimensions()}destroy(){this.wrapper.innerHTML="",this.style.destroy()}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){this.bodyRenderer.showToastMessage(t)}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=n.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(){n.style(this.freezeContainer,{display:""})}unfreeze(){n.style(this.freezeContainer,{display:"none"})}updateOptions(t){this.buildOptions(t)}fireEvent(t,...e){this.events[t].apply(this,e)}log(){this.options.logs&&console.log.apply(console,arguments)}}mt.instances=0;var gt={name:"frappe-datatable",version:"0.0.4",description:"A modern datatable library for the web",main:"dist/frappe-datatable.cjs.js",scripts:{start:"yarn run dev",build:"rollup -c",production:"rollup -c --production","build:docs":"rollup -c --docs",dev:"rollup -c -w",test:"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"},devDependencies:{chai:"3.5.0",cssnano:"^3.10.0",deepmerge:"^2.0.1",eslint:"3.19.0","eslint-loader":"1.7.1",mocha:"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0",precss:"^3.1.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify":"^3.0.0","rollup-plugin-uglify-es":"^0.0.1"},repository:{type:"git",url:"https://github.com/frappe/datatable.git"},keywords:["datatable","data","grid","table"],author:"Faris Ansari",license:"MIT",bugs:{url:"https://github.com/frappe/datatable/issues"},homepage:"https://frappe.github.io/datatable",dependencies:{"clusterize.js":"^0.18.0",lodash:"^4.17.5",sortablejs:"^1.7.0"}};return mt.__version__=gt.version,mt}(Sortable,Clusterize); diff --git a/docs/assets/frappe-datatable.css b/docs/assets/frappe-datatable.css index 8ce9ace..dd6fcf3 100644 --- a/docs/assets/frappe-datatable.css +++ b/docs/assets/frappe-datatable.css @@ -108,6 +108,12 @@ background-color: #f5f7fa; } +.body-scrollable .no-data td { + text-align: center; + padding: 8px; + padding: 0.5rem; + } + .data-table-header { position: absolute; top: 0; @@ -203,6 +209,7 @@ padding: 8px; padding: 0.5rem; border: 2px solid transparent; + height: 100%; } .data-table-cell .content.ellipsis { @@ -215,7 +222,7 @@ display: none; padding: 8px; padding: 0.5rem; - background: #fff; + background-color: #fff; z-index: 1; height: 100%; } @@ -229,7 +236,7 @@ } .data-table-cell.editing .edit-cell { - border: 2px solid rgb(82, 146, 247); + border: 2px solid rgb(255, 160, 10); display: block; } diff --git a/docs/assets/frappe-datatable.js b/docs/assets/frappe-datatable.js index a32aca1..c0a4056 100644 --- a/docs/assets/frappe-datatable.js +++ b/docs/assets/frappe-datatable.js @@ -241,10 +241,12 @@ var isObject_1 = isObject; var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; +/** Detect free variable `global` from Node.js. */ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal; var _freeGlobal = freeGlobal; +/** Detect free variable `self`. */ var freeSelf = typeof self == 'object' && self && self.Object === Object && self; /** Used as a reference to the global object. */ @@ -252,16 +254,34 @@ var root = _freeGlobal || freeSelf || Function('return this')(); var _root = root; +/** + * Gets the timestamp of the number of milliseconds that have elapsed since + * the Unix epoch (1 January 1970 00:00:00 UTC). + * + * @static + * @memberOf _ + * @since 2.4.0 + * @category Date + * @returns {number} Returns the timestamp. + * @example + * + * _.defer(function(stamp) { + * console.log(_.now() - stamp); + * }, _.now()); + * // => Logs the number of milliseconds it took for the deferred invocation. + */ var now = function() { return _root.Date.now(); }; var now_1 = now; +/** Built-in value references. */ var Symbol = _root.Symbol; var _Symbol = Symbol; +/** Used for built-in method references. */ var objectProto = Object.prototype; /** Used to check objects for own properties. */ @@ -329,6 +349,7 @@ function objectToString(value) { var _objectToString = objectToString; +/** `Object#toString` result references. */ var nullTag = '[object Null]'; var undefinedTag = '[object Undefined]'; @@ -383,6 +404,7 @@ function isObjectLike(value) { var isObjectLike_1 = isObjectLike; +/** `Object#toString` result references. */ var symbolTag = '[object Symbol]'; /** @@ -409,6 +431,7 @@ function isSymbol(value) { var isSymbol_1 = isSymbol; +/** Used as references for various `Number` constants. */ var NAN = 0 / 0; /** Used to match leading and trailing whitespace. */ @@ -472,6 +495,7 @@ function toNumber(value) { var toNumber_1 = toNumber; +/** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /* Built-in method references for those with the same name as other `lodash` methods. */ @@ -658,6 +682,7 @@ function debounce(func, wait, options) { var debounce_1 = debounce; +/** Error message constants. */ var FUNC_ERROR_TEXT$1 = 'Expected a function'; /** @@ -964,7 +989,6 @@ class DataManager { prepareCell(content, i) { const cell = { content: '', - align: 'left', sortOrder: 'none', colIndex: i, column: this.columns[i] @@ -3229,8 +3253,9 @@ class Style { } setDefaultCellHeight() { + if (this.options.dynamicRowHeight) return; if (this.__cellHeightSet) return; - const $firstCell = $('.data-table-cell', this.instance.bodyScrollable); + const $firstCell = $('.data-table-cell[data-is-header]', this.instance.header); if (!$firstCell) return; const height = this.options.cellHeight || $.style($firstCell, 'height'); @@ -3281,6 +3306,14 @@ class Style { width: width + 'px' }); + const $body = $('.data-table-body', this.bodyScrollable); + + if ($body) { + $.style($body, { + height: '0px' + }); + } + $.style(this.bodyScrollable, { marginTop: $.style(this.header, 'height') + 'px' }); @@ -3418,7 +3451,8 @@ var DEFAULT_OPTIONS = { cellHeight: null, inlineFilters: false, treeView: false, - checkedRowStatus: true + checkedRowStatus: true, + dynamicRowHeight: false }; class DataTable { @@ -3613,11 +3647,11 @@ class DataTable { DataTable.instances = 0; var name = "frappe-datatable"; -var version = "0.0.3"; +var version = "0.0.4"; var description = "A modern datatable library for the web"; var main = "dist/frappe-datatable.cjs.js"; -var scripts = {"start":"yarn run dev","build":"rollup -c","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js","test:watch":"mocha --compilers js:babel-core/register --colors -w ./test/*.spec.js"}; -var devDependencies = {"chai":"3.5.0","cssnano":"^3.10.0","deepmerge":"^2.0.1","eslint":"3.19.0","eslint-loader":"1.7.1","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","precss":"^3.1.0","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify":"^3.0.0"}; +var scripts = {"start":"yarn run dev","build":"rollup -c","production":"rollup -c --production","build:docs":"rollup -c --docs","dev":"rollup -c -w","test":"mocha --compilers js:babel-core/register --colors ./test/*.spec.js"}; +var devDependencies = {"chai":"3.5.0","deepmerge":"^2.0.1","mocha":"3.3.0","postcss-cssnext":"^3.1.0","postcss-nested":"^3.0.0","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"}; var repository = {"type":"git","url":"https://github.com/frappe/datatable.git"}; var keywords = ["datatable","data","grid","table"]; var author = "Faris Ansari"; diff --git a/docs/assets/index.css b/docs/assets/index.css index fbf9def..198eb94 100644 --- a/docs/assets/index.css +++ b/docs/assets/index.css @@ -6,7 +6,7 @@ html, body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; - font-size: 14px; + font-size: 12px; } code { @@ -35,7 +35,6 @@ h2 { flex-direction: column; align-items: center; padding: 4rem; - text-align: center; } .showcase p { @@ -62,4 +61,9 @@ h2 { footer { border-top: 1px solid #d1d8dd; +} + +.data-table-header { + background: #f7fafc; + color: #8d99a6; } \ No newline at end of file diff --git a/docs/assets/index.js b/docs/assets/index.js index 9dacbff..0703010 100644 --- a/docs/assets/index.js +++ b/docs/assets/index.js @@ -9,7 +9,8 @@ const { // Hero let datatable1 = new DataTable('.example-1 .target', { columns, - data + data, + checkboxColumn: true }); // Formatted Cells @@ -39,65 +40,65 @@ let datatable5 = new DataTable('.example-5', getTreeData()); datatable5.showToastMessage('Expand/Collapse tree nodes'); function getSampleData(multiplier) { - let columns = ['Name', 'Position', 'Office', 'Extn.', 'Start Date', 'Salary']; + let columns = ['Name', 'Position', 'Office', {name: 'Extn.', width: 75}, 'Start Date', 'Salary']; let data = [ - ['Tiger Nixon', 'System Architect', 'Edinburgh', '5421', '2011/04/25', '320,800'], - ['Garrett Winters', 'Accountant', 'Tokyo', '8422', '2011/07/25', '170,750'], - ['Ashton Cox', 'Junior Technical Author', 'San Francisco', '1562', '2009/01/12', '86,000'], - ['Cedric Kelly', 'Senior Javascript Developer', 'Edinburgh', '6224', '2012/03/29', '433,060'], - ['Airi Satou', 'Accountant', 'Tokyo', '5407', '2008/11/28', '162,700'], - ['Brielle Williamson', 'Integration Specialist', 'New York', '4804', '2012/12/02', '372,000'], - ['Herrod Chandler', 'Sales Assistant', 'San Francisco', '9608', '2012/08/06', '137,500'], - ['Rhona Davidson', 'Integration Specialist', 'Tokyo', '6200', '2010/10/14', '327,900'], - ['Colleen Hurst', 'Javascript Developer', 'San Francisco', '2360', '2009/09/15', '205,500'], - ['Sonya Frost', 'Software Engineer', 'Edinburgh', '1667', '2008/12/13', '103,600'], - ['Jena Gaines', 'Office Manager', 'London', '3814', '2008/12/19', '90,560'], - ['Quinn Flynn', 'Support Lead', 'Edinburgh', '9497', '2013/03/03', '342,000'], - ['Charde Marshall', 'Regional Director', 'San Francisco', '6741', '2008/10/16', '470,600'], - ['Haley Kennedy', 'Senior Marketing Designer', 'London', '3597', '2012/12/18', '313,500'], - ['Tatyana Fitzpatrick', 'Regional Director', 'London', '1965', '2010/03/17', '385,750'], - ['Michael Silva', 'Marketing Designer', 'London', '1581', '2012/11/27', '198,500'], - ['Paul Byrd', 'Chief Financial Officer (CFO)', 'New York', '3059', '2010/06/09', '725,000'], - ['Gloria Little', 'Systems Administrator', 'New York', '1721', '2009/04/10', '237,500'], - ['Bradley Greer', 'Software Engineer', 'London', '2558', '2012/10/13', '132,000'], - ['Dai Rios', 'Personnel Lead', 'Edinburgh', '2290', '2012/09/26', '217,500'], - ['Jenette Caldwell', 'Development Lead', 'New York', '1937', '2011/09/03', '345,000'], - ['Yuri Berry', 'Chief Marketing Officer (CMO)', 'New York', '6154', '2009/06/25', '675,000'], - ['Caesar Vance', 'Pre-Sales Support', 'New York', '8330', '2011/12/12', '106,450'], - ['Doris Wilder', 'Sales Assistant', 'Sidney', '3023', '2010/09/20', '85,600'], - ['Angelica Ramos', 'Chief Executive Officer (CEO)', 'London', '5797', '2009/10/09', '1,200,000'], - ['Gavin Joyce', 'Developer', 'Edinburgh', '8822', '2010/12/22', '92,575'], - ['Jennifer Chang', 'Regional Director', 'Singapore', '9239', '2010/11/14', '357,650'], - ['Brenden Wagner', 'Software Engineer', 'San Francisco', '1314', '2011/06/07', '206,850'], - ['Fiona Green', 'Chief Operating Officer (COO)', 'San Francisco', '2947', '2010/03/11', '850,000'], - ['Shou Itou', 'Regional Marketing', 'Tokyo', '8899', '2011/08/14', '163,000'], - ['Michelle House', 'Integration Specialist', 'Sidney', '2769', '2011/06/02', '95,400'], - ['Suki Burks', 'Developer', 'London', '6832', '2009/10/22', '114,500'], - ['Prescott Bartlett', 'Technical Author', 'London', '3606', '2011/05/07', '145,000'], - ['Gavin Cortez', 'Team Leader', 'San Francisco', '2860', '2008/10/26', '235,500'], - ['Martena Mccray', 'Post-Sales support', 'Edinburgh', '8240', '2011/03/09', '324,050'], - ['Unity Butler', 'Marketing Designer', 'San Francisco', '5384', '2009/12/09', '85,675'], - ['Howard Hatfield', 'Office Manager', 'San Francisco', '7031', '2008/12/16', '164,500'], - ['Hope Fuentes', 'Secretary', 'San Francisco', '6318', '2010/02/12', '109,850'], - ['Vivian Harrell', 'Financial Controller', 'San Francisco', '9422', '2009/02/14', '452,500'], - ['Timothy Mooney', 'Office Manager', 'London', '7580', '2008/12/11', '136,200'], - ['Jackson Bradshaw', 'Director', 'New York', '1042', '2008/09/26', '645,750'], - ['Olivia Liang', 'Support Engineer', 'Singapore', '2120', '2011/02/03', '234,500'], - ['Bruno Nash', 'Software Engineer', 'London', '6222', '2011/05/03', '163,500'], - ['Sakura Yamamoto', 'Support Engineer', 'Tokyo', '9383', '2009/08/19', '139,575'], - ['Thor Walton', 'Developer', 'New York', '8327', '2013/08/11', '98,540'], - ['Finn Camacho', 'Support Engineer', 'San Francisco', '2927', '2009/07/07', '87,500'], - ['Serge Baldwin', 'Data Coordinator', 'Singapore', '8352', '2012/04/09', '138,575'], - ['Zenaida Frank', 'Software Engineer', 'New York', '7439', '2010/01/04', '125,250'], - ['Zorita Serrano', 'Software Engineer', 'San Francisco', '4389', '2012/06/01', '115,000'], - ['Jennifer Acosta', 'Junior Javascript Developer', 'Edinburgh', '3431', '2013/02/01', '75,650'], - ['Cara Stevens', 'Sales Assistant', 'New York', '3990', '2011/12/06', '145,600'], - ['Hermione Butler', 'Regional Director', 'London', '1016', '2011/03/21', '356,250'], - ['Lael Greer', 'Systems Administrator', 'London', '6733', '2009/02/27', '103,500'], - ['Jonas Alexander', 'Developer', 'San Francisco', '8196', '2010/07/14', '86,500'], - ['Shad Decker', 'Regional Director', 'Edinburgh', '6373', '2008/11/13', '183,000'], - ['Michael Bruce', 'Javascript Developer', 'Singapore', '5384', '2011/06/27', '183,000'], - ['Donna Snider', 'Customer Support', 'New York', '4226', '2011/01/25', '112,000'] + ['Tiger Nixon', 'System Architect', 'Edinburgh', 5421, '2011/04/25', '320,800'], + ['Garrett Winters', 'Accountant', 'Tokyo', 8422, '2011/07/25', '170,750'], + ['Ashton Cox', 'Junior Technical Author', 'San Francisco', 1562, '2009/01/12', '86,000'], + ['Cedric Kelly', 'Senior Javascript Developer', 'Edinburgh', 6224, '2012/03/29', '433,060'], + ['Airi Satou', 'Accountant', 'Tokyo', 5407, '2008/11/28', '162,700'], + ['Brielle Williamson', 'Integration Specialist', 'New York', 4804, '2012/12/02', '372,000'], + ['Herrod Chandler', 'Sales Assistant', 'San Francisco', 9608, '2012/08/06', '137,500'], + ['Rhona Davidson', 'Integration Specialist', 'Tokyo', 6200, '2010/10/14', '327,900'], + ['Colleen Hurst', 'Javascript Developer', 'San Francisco', 2360, '2009/09/15', '205,500'], + ['Sonya Frost', 'Software Engineer', 'Edinburgh', 1667, '2008/12/13', '103,600'], + ['Jena Gaines', 'Office Manager', 'London', 3814, '2008/12/19', '90,560'], + ['Quinn Flynn', 'Support Lead', 'Edinburgh', 9497, '2013/03/03', '342,000'], + ['Charde Marshall', 'Regional Director', 'San Francisco', 6741, '2008/10/16', '470,600'], + ['Haley Kennedy', 'Senior Marketing Designer', 'London', 3597, '2012/12/18', '313,500'], + ['Tatyana Fitzpatrick', 'Regional Director', 'London', 1965, '2010/03/17', '385,750'], + ['Michael Silva', 'Marketing Designer', 'London', 1581, '2012/11/27', '198,500'], + ['Paul Byrd', 'Chief Financial Officer (CFO)', 'New York', 3059, '2010/06/09', '725,000'], + ['Gloria Little', 'Systems Administrator', 'New York', 1721, '2009/04/10', '237,500'], + ['Bradley Greer', 'Software Engineer', 'London', 2558, '2012/10/13', '132,000'], + ['Dai Rios', 'Personnel Lead', 'Edinburgh', 2290, '2012/09/26', '217,500'], + ['Jenette Caldwell', 'Development Lead', 'New York', 1937, '2011/09/03', '345,000'], + ['Yuri Berry', 'Chief Marketing Officer (CMO)', 'New York', 6154, '2009/06/25', '675,000'], + ['Caesar Vance', 'Pre-Sales Support', 'New York', 8330, '2011/12/12', '106,450'], + ['Doris Wilder', 'Sales Assistant', 'Sidney', 3023, '2010/09/20', '85,600'], + ['Angelica Ramos', 'Chief Executive Officer (CEO)', 'London', 5797, '2009/10/09', '1,200,000'], + ['Gavin Joyce', 'Developer', 'Edinburgh', 8822, '2010/12/22', '92,575'], + ['Jennifer Chang', 'Regional Director', 'Singapore', 9239, '2010/11/14', '357,650'], + ['Brenden Wagner', 'Software Engineer', 'San Francisco', 1314, '2011/06/07', '206,850'], + ['Fiona Green', 'Chief Operating Officer (COO)', 'San Francisco', 2947, '2010/03/11', '850,000'], + ['Shou Itou', 'Regional Marketing', 'Tokyo', 8899, '2011/08/14', '163,000'], + ['Michelle House', 'Integration Specialist', 'Sidney', 2769, '2011/06/02', '95,400'], + ['Suki Burks', 'Developer', 'London', 6832, '2009/10/22', '114,500'], + ['Prescott Bartlett', 'Technical Author', 'London', 3606, '2011/05/07', '145,000'], + ['Gavin Cortez', 'Team Leader', 'San Francisco', 2860, '2008/10/26', '235,500'], + ['Martena Mccray', 'Post-Sales support', 'Edinburgh', 8240, '2011/03/09', '324,050'], + ['Unity Butler', 'Marketing Designer', 'San Francisco', 5384, '2009/12/09', '85,675'], + ['Howard Hatfield', 'Office Manager', 'San Francisco', 7031, '2008/12/16', '164,500'], + ['Hope Fuentes', 'Secretary', 'San Francisco', 6318, '2010/02/12', '109,850'], + ['Vivian Harrell', 'Financial Controller', 'San Francisco', 9422, '2009/02/14', '452,500'], + ['Timothy Mooney', 'Office Manager', 'London', 7580, '2008/12/11', '136,200'], + ['Jackson Bradshaw', 'Director', 'New York', 1042, '2008/09/26', '645,750'], + ['Olivia Liang', 'Support Engineer', 'Singapore', 2120, '2011/02/03', '234,500'], + ['Bruno Nash', 'Software Engineer', 'London', 6222, '2011/05/03', '163,500'], + ['Sakura Yamamoto', 'Support Engineer', 'Tokyo', 9383, '2009/08/19', '139,575'], + ['Thor Walton', 'Developer', 'New York', 8327, '2013/08/11', '98,540'], + ['Finn Camacho', 'Support Engineer', 'San Francisco', 2927, '2009/07/07', '87,500'], + ['Serge Baldwin', 'Data Coordinator', 'Singapore', 8352, '2012/04/09', '138,575'], + ['Zenaida Frank', 'Software Engineer', 'New York', 7439, '2010/01/04', '125,250'], + ['Zorita Serrano', 'Software Engineer', 'San Francisco', 4389, '2012/06/01', '115,000'], + ['Jennifer Acosta', 'Junior Javascript Developer', 'Edinburgh', 3431, '2013/02/01', '75,650'], + ['Cara Stevens', 'Sales Assistant', 'New York', 3990, '2011/12/06', '145,600'], + ['Hermione Butler', 'Regional Director', 'London', 1016, '2011/03/21', '356,250'], + ['Lael Greer', 'Systems Administrator', 'London', 6733, '2009/02/27', '103,500'], + ['Jonas Alexander', 'Developer', 'San Francisco', 8196, '2010/07/14', '86,500'], + ['Shad Decker', 'Regional Director', 'Edinburgh', 6373, '2008/11/13', '183,000'], + ['Michael Bruce', 'Javascript Developer', 'Singapore', 5384, '2011/06/27', '183,000'], + ['Donna Snider', 'Customer Support', 'New York', 4226, '2011/01/25', '112,000'] ]; if (multiplier) {