1 line
57 KiB
JavaScript
1 line
57 KiB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("sortablejs"),require("clusterize.js")):"function"==typeof define&&define.amd?define("DataTable",[,],t):"object"==typeof exports?exports.DataTable=t(require("sortablejs"),require("clusterize.js")):e.DataTable=t(e.Sortable,e.Clusterize)}("undefined"!=typeof self?self:this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";function o(e,t){return"string"==typeof e?(t||document).querySelector(e):e||null}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=o,o.each=function(e,t){return"string"==typeof e?Array.from((t||document).querySelectorAll(e)):e||null},o.create=function(e,t){var n=document.createElement(e);for(var r in t)!function(e){var r=t[e];if("inside"===e)o(r).appendChild(n);else if("around"===e){var i=o(r);i.parentNode.insertBefore(n,i),n.appendChild(i)}else"styles"===e?"object"===(void 0===r?"undefined":a(r))&&Object.keys(r).map(function(e){n.style[e]=r[e]}):e in n?n[e]=r:n.setAttribute(e,r)}(r);return n},o.on=function(e,t,n,a){a?o.delegate(e,t,n,a):(a=n,o.bind(e,t,a))},o.off=function(e,t,n){e.removeEventListener(t,n)},o.bind=function(e,t,n){t.split(/\s+/).forEach(function(t){e.addEventListener(t,n)})},o.delegate=function(e,t,n,o){e.addEventListener(t,function(e){var t=e.target.closest(n);t&&(e.delegatedTarget=t,o.call(this,e,t))})},o.unbind=function(e,t){if(e){for(var n in t)!function(n){var o=t[n];n.split(/\s+/).forEach(function(t){e.removeEventListener(t,o)})}(n)}},o.fire=function(e,t,n){var o=document.createEvent("HTMLEvents");o.initEvent(t,!0,!0);for(var a in n)o[a]=n[a];return e.dispatchEvent(o)},o.data=function(e,t){if(!t)return e.dataset;for(var n in t)e.dataset[n]=t[n]},o.style=function(e,t){if("string"==typeof t)return o.getStyle(e,t);Array.isArray(e)||(e=[e]),e.map(function(e){for(var n in t)e.style[n]=t[n]})},o.removeStyle=function(e,t){Array.isArray(e)||(e=[e]),Array.isArray(t)||(t=[t]),e.map(function(e){var n=!0,o=!1,a=void 0;try{for(var r,i=t[Symbol.iterator]();!(n=(r=i.next()).done);n=!0){var l=r.value;e.style[l]=""}}catch(e){o=!0,a=e}finally{try{!n&&i.return&&i.return()}finally{if(o)throw a}}})},o.getStyle=function(e,t){var n=getComputedStyle(e)[t];return["width","height"].includes(t)&&(n=parseFloat(n)),n},o.closest=function(e,t){return t?t.matches(e)?t:o.closest(e,t.parentNode):null},o.inViewport=function(e,t){var n=e.getBoundingClientRect(),o=n.top,a=n.left,r=n.bottom,i=n.right,l=t.getBoundingClientRect(),s=l.top,u=l.left,c=l.bottom,d=l.right;return o>=s&&a>=u&&r<=c&&i<=d},o.scrollTop=function(e,t){requestAnimationFrame(function(){e.scrollTop=t})},e.exports=t.default},function(e,t,n){"use strict";function o(e){return e.replace(/([A-Z])/g,function(e){return"-"+e[0].toLowerCase()})}function a(e){return Object.keys(e).map(function(t){var n=o(t),a=e[t];return void 0===a?"":"data-"+n+'="'+a+'" '}).join("").trim()}function r(e,t){return void 0!==e?e:t}function i(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function l(e){var t="";for(var n in e)e.hasOwnProperty(n)&&(t+=n+": "+e[n]+"; ");return t.trim()}function s(e,t){return e+" { "+l(t)+" }"}function u(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",o=i(e)+" {([^}]*)}",a=new RegExp(o,"g");if(n&&n.match(a)){for(var r in t)!function(o){var r=t[o],l=new RegExp(i(o)+":([^;]*);");n=n.replace(a,function(t,n){return n.match(l)&&(n=n.replace(l,function(e,t){return o+": "+r+";"})),n=n.trim(),e+" { "+n+" }"})}(r);return n}return""+n+s(e,t)}function c(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=i(e)+" {([^}]*)}",o=new RegExp(n,"g"),a=t;return t&&t.match(o)&&(a=t.replace(o,"")),a.trim()}function d(e){var t=document.createElement("textarea");t.style.position="fixed",t.style.top=0,t.style.left=0,t.style.width="2em",t.style.height="2em",t.style.padding=0,t.style.border="none",t.style.outline="none",t.style.boxShadow="none",t.style.background="transparent",t.value=e,document.body.appendChild(t),t.select();try{document.execCommand("copy")}catch(e){console.log("Oops, unable to copy")}document.body.removeChild(t)}function f(e){return!isNaN(e)}function h(e,t,n){var o,a,r,i=null,l=0;n||(n={});var s=function(){l=!1===n.leading?0:Date.now(),i=null,r=e.apply(o,a),i||(o=a=null)};return function(){var u=Date.now();l||!1!==n.leading||(l=u);var c=t-(u-l);return o=this,a=arguments,c<=0||c>t?(i&&(clearTimeout(i),i=null),l=u,r=e.apply(o,a),i||(o=a=null)):i||!1===n.trailing||(i=setTimeout(s,c)),r}}function p(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return function(){for(var n=arguments.length,o=Array(n),a=0;a<n;a++)o[a]=arguments[a];return new Promise(function(n){setTimeout(function(){e.apply(t,o),n("done",e.name)},0)})}}function v(e){return e.reduce(function(e,t){return e.then(t)},Promise.resolve())}Object.defineProperty(t,"__esModule",{value:!0}),t.camelCaseToDash=o,t.makeDataAttributeString=a,t.getDefault=r,t.escapeRegExp=i,t.getCSSString=l,t.getCSSRuleBlock=s,t.buildCSSRule=u,t.removeCSSRule=c,t.copyTextToClipboard=d,t.isNumeric=f,t.throttle=h,t.promisify=p,t.chainPromises=v},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){return'\n <tr class="data-table-row" '+(0,s.makeDataAttributeString)(t)+">\n "+e.map(u.getCellHTML).join("")+"\n </tr>\n "}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();t.getRowHTML=a;var i=n(0),l=function(e){return e&&e.__esModule?e:{default:e}}(i),s=n(1),u=n(3),c=function(){function e(t){o(this,e),this.instance=t,this.options=this.instance.options,this.wrapper=this.instance.wrapper,this.bodyScrollable=this.instance.bodyScrollable,this.bindEvents(),this.refreshRows=(0,s.promisify)(this.refreshRows,this)}return r(e,[{key:"bindEvents",value:function(){this.bindCheckbox()}},{key:"bindCheckbox",value:function(){var e=this;this.options.addCheckboxColumn&&(this.checkMap=[],l.default.on(this.wrapper,"click",'.data-table-col[data-col-index="0"] [type="checkbox"]',function(t,n){var o=n.closest(".data-table-col"),a=l.default.data(o),r=a.rowIndex,i=a.isHeader,s=n.checked;i?e.checkAll(s):e.checkRow(r,s)}))}},{key:"refreshRows",value:function(){this.instance.renderBody(),this.instance.setDimensions()}},{key:"refreshRow",value:function(e,t){var n=this;this.datamanager.updateRow(e,t).forEach(function(e){n.cellmanager.refreshCell(e)})}},{key:"getCheckedRows",value:function(){return this.checkMap.map(function(e,t){return e?t:null}).filter(function(e){return null!==e||void 0!==e})}},{key:"highlightCheckedRows",value:function(){var e=this;this.getCheckedRows().map(function(t){return e.checkRow(t,!0)})}},{key:"checkRow",value:function(e,t){var n=t?1:0;this.checkMap[e]=n,l.default.each('.data-table-col[data-row-index="'+e+'"][data-col-index="0"] [type="checkbox"]',this.bodyScrollable).map(function(e){e.checked=t}),this.highlightRow(e,t)}},{key:"checkAll",value:function(e){var t=e?1:0;this.checkMap=e?Array.from(Array(this.getTotalRows())).map(function(e){return t}):[],l.default.each('.data-table-col[data-col-index="0"] [type="checkbox"]',this.bodyScrollable).map(function(t){t.checked=e}),this.highlightAll(e)}},{key:"highlightRow",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=this.getRow$(e);if(n){if(!t&&this.bodyScrollable.classList.contains("row-highlight-all"))return void n.classList.add("row-unhighlight");t&&n.classList.contains("row-unhighlight")&&n.classList.remove("row-unhighlight"),this._highlightedRows=this._highlightedRows||{},t?(n.classList.add("row-highlight"),this._highlightedRows[e]=n):(n.classList.remove("row-highlight"),delete this._highlightedRows[e])}}},{key:"highlightAll",value:function(){if(arguments.length>0&&void 0!==arguments[0]&&!arguments[0]){this.bodyScrollable.classList.remove("row-highlight-all");for(var e in this._highlightedRows)this._highlightedRows[e].classList.remove("row-highlight");this._highlightedRows={}}else this.bodyScrollable.classList.add("row-highlight-all")}},{key:"getRow$",value:function(e){return(0,l.default)('.data-table-row[data-row-index="'+e+'"]',this.bodyScrollable)}},{key:"getTotalRows",value:function(){return this.datamanager.getRowCount()}},{key:"getFirstRowIndex",value:function(){return 0}},{key:"getLastRowIndex",value:function(){return this.datamanager.getRowCount()-1}},{key:"scrollToRow",value:function(e){e=+e,this._lastScrollTo=this._lastScrollTo||0;var t=this.getRow$(e);if(!l.default.inViewport(t,this.bodyScrollable)){var n=t.getBoundingClientRect(),o=n.height,a=this.bodyScrollable.getBoundingClientRect(),r=a.top,i=a.bottom,s=Math.floor((i-r)/o),u=0;u=e>this._lastScrollTo?o*(e+1-s):o*(e+1-1),this._lastScrollTo=e,l.default.scrollTop(this.bodyScrollable,u)}}},{key:"datamanager",get:function(){return this.instance.datamanager}},{key:"cellmanager",get:function(){return this.instance.cellmanager}}]),e}();t.default=c},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e){var t=e.rowIndex,n=e.colIndex,o=e.isHeader;return'\n <td class="data-table-col noselect" '+(0,f.makeDataAttributeString)({rowIndex:t,colIndex:n,isHeader:o})+' tabindex="0">\n '+l(e)+"\n </td>\n "}function l(e){var t=e.isHeader,n=!t&&!1!==e.editable,o=n?'\n <div class="edit-cell"></div>\n ':"",a=t&&!1!==e.sortable,r=a?'<span class="sort-indicator"></span>':"",i=t&&!1!==e.resizable,l=i?'<span class="column-resizer"></span>':"",s=t&&!1!==e.dropdown,u=s?'<div class="data-table-dropdown">'+(0,m.getDropdownHTML)()+"</div>":"";return'\n <div class="content ellipsis">\n '+(e.format?e.format(e.content):e.content)+"\n "+r+"\n "+l+"\n "+u+"\n </div>\n "+o+"\n "}function s(){return'\n <div class="edit-cell"></div>\n '}function u(e,t){return'.data-table-col[data-col-index="'+e+'"][data-row-index="'+t+'"]'}Object.defineProperty(t,"__esModule",{value:!0});var c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();t.getCellHTML=i,t.getCellContent=l,t.getEditCellHTML=s;var f=n(1),h=n(4),p=o(h),v=n(0),g=o(v),m=n(5),b=function(){function e(t){r(this,e),this.instance=t,this.wrapper=this.instance.wrapper,this.options=this.instance.options,this.style=this.instance.style,this.bodyScrollable=this.instance.bodyScrollable,this.columnmanager=this.instance.columnmanager,this.rowmanager=this.instance.rowmanager,this.datamanager=this.instance.datamanager,this.bindEvents()}return d(e,[{key:"bindEvents",value:function(){this.bindFocusCell(),this.bindEditCell(),this.bindKeyboardSelection(),this.bindCopyCellContents(),this.bindMouseEvents()}},{key:"bindFocusCell",value:function(){this.bindKeyboardNav()}},{key:"bindEditCell",value:function(){var e=this;this.$editingCell=null,g.default.on(this.bodyScrollable,"dblclick",".data-table-col",function(t,n){e.activateEditing(n)}),p.default.on("enter",function(t){e.$focusedCell&&!e.$editingCell?e.activateEditing(e.$focusedCell):e.$editingCell&&(e.submitEditing(),e.deactivateEditing())})}},{key:"bindKeyboardNav",value:function(){var e=this,t=function(t){if(!e.$focusedCell||e.$editingCell)return!1;var n=e.$focusedCell;return"left"===t?n=e.getLeftCell$(n):"right"===t?n=e.getRightCell$(n):"up"===t?n=e.getAboveCell$(n):"down"===t&&(n=e.getBelowCell$(n)),e.focusCell(n),!0},n=function(t){if(!e.$focusedCell||e.$editingCell)return!1;var n=e.$focusedCell,o=g.default.data(n),a=o.rowIndex,r=o.colIndex;return"left"===t?n=e.getLeftMostCell$(a):"right"===t?n=e.getRightMostCell$(a):"up"===t?n=e.getTopMostCell$(r):"down"===t&&(n=e.getBottomMostCell$(r)),e.focusCell(n),!0};["left","right","up","down"].map(function(e){return p.default.on(e,function(){return t(e)})}),["left","right","up","down"].map(function(e){return p.default.on("ctrl+"+e,function(){return n(e)})}),p.default.on("esc",function(){e.deactivateEditing()})}},{key:"bindKeyboardSelection",value:function(){var e=this,t=function(t){var n=e.getSelectionCursor();return"left"===t?n=e.getLeftCell$(n):"right"===t?n=e.getRightCell$(n):"up"===t?n=e.getAboveCell$(n):"down"===t&&(n=e.getBelowCell$(n)),n};["left","right","up","down"].map(function(n){return p.default.on("shift+"+n,function(){return e.selectArea(t(n))})})}},{key:"bindCopyCellContents",value:function(){var e=this;p.default.on("ctrl+c",function(){e.copyCellContents(e.$focusedCell,e.$selectionCursor)})}},{key:"bindMouseEvents",value:function(){var e=this,t=null;g.default.on(this.bodyScrollable,"mousedown",".data-table-col",function(n){t=!0,e.focusCell((0,g.default)(n.delegatedTarget))}),g.default.on(this.bodyScrollable,"mouseup",function(){t=!1});var n=function(n){t&&e.selectArea((0,g.default)(n.delegatedTarget))};g.default.on(this.bodyScrollable,"mousemove",".data-table-col",(0,f.throttle)(n,50))}},{key:"focusCell",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.skipClearSelection,o=void 0===n?0:n;if(e&&e!==this.$editingCell){var a=g.default.data(e),r=a.colIndex;if(!a.isHeader){!1!==this.columnmanager.getColumn(r).focusable&&(this.deactivateEditing(),o||this.clearSelection(),this.$focusedCell&&this.$focusedCell.classList.remove("selected"),this.$focusedCell=e,e.classList.add("selected"),this.highlightRowColumnHeader(e),this.scrollToCell(e))}}}},{key:"highlightRowColumnHeader",value:function(e){var t=g.default.data(e),n=t.colIndex,o=t.rowIndex,a=this.columnmanager.getSerialColumnIndex(),r='.data-table-header .data-table-col[data-col-index="'+n+'"]',i='.data-table-col[data-row-index="'+o+'"][data-col-index="'+a+'"]';this.lastHeaders&&g.default.removeStyle(this.lastHeaders,"backgroundColor");var l=(0,g.default)(r,this.wrapper),s=(0,g.default)(i,this.wrapper);g.default.style([l,s],{backgroundColor:"#f5f7fa"}),this.lastHeaders=[l,s]}},{key:"selectAreaOnClusterChanged",value:function(){if(this.$focusedCell&&this.$selectionCursor){var e=g.default.data(this.$selectionCursor),t=e.colIndex,n=e.rowIndex,o=this.getCell$(t,n);if(o&&o!==this.$selectionCursor){var a=g.default.data(this.$focusedCell);this.$focusedCell=this.getCell$(a.colIndex,a.rowIndex),this.selectArea(o)}}}},{key:"focusCellOnClusterChanged",value:function(){if(this.$focusedCell){var e=g.default.data(this.$focusedCell),t=e.colIndex,n=e.rowIndex,o=this.getCell$(t,n);o&&this.focusCell(o,{skipClearSelection:1})}}},{key:"selectArea",value:function(e){this.$focusedCell&&this._selectArea(this.$focusedCell,e)&&(this.$selectionCursor=e)}},{key:"_selectArea",value:function(e,t){var n=this;if(e===t)return!1;var o=this.getCellsInRange(e,t);return!!o&&(this.clearSelection(),o.map(function(e){return n.getCell$.apply(n,a(e))}).map(function(e){return e.classList.add("highlight")}),!0)}},{key:"getCellsInRange",value:function(e,t){var n=void 0,o=void 0,a=void 0,r=void 0;if("number"==typeof e){var i=Array.prototype.slice.call(arguments);n=i[0],o=i[1],a=i[2],r=i[3]}else if("object"===(void 0===e?"undefined":c(e))){if(!e||!t)return!1;var l=g.default.data(e),s=g.default.data(t);n=l.colIndex,o=l.rowIndex,a=s.colIndex,r=s.rowIndex}if(o>r){var u=[r,o];o=u[0],r=u[1]}if(n>a){var d=[a,n];n=d[0],a=d[1]}if(this.isStandardCell(n)||this.isStandardCell(a))return!1;for(var f=[],h=n,p=o,v=[];p<=r;)v.push(p),p++;return v.map(function(e){for(;h<=a;)f.push([h,e]),h++;h=n}),f}},{key:"clearSelection",value:function(){g.default.each(".data-table-col.highlight",this.bodyScrollable).map(function(e){return e.classList.remove("highlight")}),this.$selectionCursor=null}},{key:"getSelectionCursor",value:function(){return this.$selectionCursor||this.$focusedCell}},{key:"activateEditing",value:function(e){var t=g.default.data(e),n=t.rowIndex,o=t.colIndex,a=this.columnmanager.getColumn(o);if(!a||!1!==a.editable&&!1!==a.focusable){var r=this.getCell(o,n);if(!r||!1!==r.editable){if(this.$editingCell){var i=g.default.data(this.$editingCell),l=i._rowIndex,s=i._colIndex;if(n===l&&o===s)return}this.$editingCell=e,e.classList.add("editing");var u=(0,g.default)(".edit-cell",e);u.innerHTML="";var c=this.getEditingObject(o,n,r.content,u);c&&(this.currentCellEditing=c,c.initValue(r.content))}}}},{key:"deactivateEditing",value:function(){this.$editingCell&&(this.$editingCell.classList.remove("editing"),this.$editingCell=null)}},{key:"getEditingObject",value:function(e,t,n,o){var a=this.options.editing(e,t,n,o);if(a&&a.setValue)return a;var r=g.default.create("input",{type:"text",inside:o});return{initValue:function(e){r.focus(),r.value=e},getValue:function(){return r.value},setValue:function(e){r.value=e}}}},{key:"submitEditing",value:function(){var e=this;if(this.$editingCell){var t=this.$editingCell,n=g.default.data(t),o=n.rowIndex,a=n.colIndex;if(t){var r=this.currentCellEditing;if(r){var i=r.getValue(),l=r.setValue(i),s=this.getCell(a,o).content;this.updateCell(a,o,i),t.focus(),l&&l.then&&l.catch(function(t){console.log(t),e.updateCell(a,o,s)})}}this.currentCellEditing=null}}},{key:"copyCellContents",value:function(e,t){var n=this;if(!t&&e){var o=g.default.data(e),r=o.colIndex,i=o.rowIndex,l=this.getCell(r,i);return void(0,f.copyTextToClipboard)(l.content)}var s=this.getCellsInRange(e,t);if(s){var u=s.map(function(e){return n.getCell.apply(n,a(e))}).reduce(function(e,t){var n=t.rowIndex;return e[n]=e[n]||[],e[n].push(t.content),e},[]).map(function(e){return e.join("\t")}).join("\n");(0,f.copyTextToClipboard)(u)}}},{key:"updateCell",value:function(e,t,n){var o=this.datamanager.updateCell(e,t,{content:n});this.refreshCell(o)}},{key:"refreshCell",value:function(e){(0,g.default)(u(e.colIndex,e.rowIndex),this.bodyScrollable).innerHTML=l(e)}},{key:"isStandardCell",value:function(e){return e<this.columnmanager.getFirstColumnIndex()}},{key:"getCell$",value:function(e,t){return(0,g.default)(u(e,t),this.bodyScrollable)}},{key:"getAboveCell$",value:function(e){var t=g.default.data(e),n=t.colIndex,o=e.parentElement.previousElementSibling;return(0,g.default)('[data-col-index="'+n+'"]',o)}},{key:"getBelowCell$",value:function(e){var t=g.default.data(e),n=t.colIndex,o=e.parentElement.nextElementSibling;return(0,g.default)('[data-col-index="'+n+'"]',o)}},{key:"getLeftCell$",value:function(e){return e.previousElementSibling}},{key:"getRightCell$",value:function(e){return e.nextElementSibling}},{key:"getLeftMostCell$",value:function(e){return this.getCell$(this.columnmanager.getFirstColumnIndex(),e)}},{key:"getRightMostCell$",value:function(e){return this.getCell$(this.columnmanager.getLastColumnIndex(),e)}},{key:"getTopMostCell$",value:function(e){return this.getCell$(e,this.rowmanager.getFirstRowIndex())}},{key:"getBottomMostCell$",value:function(e){return this.getCell$(e,this.rowmanager.getLastRowIndex())}},{key:"getCell",value:function(e,t){return this.instance.datamanager.getCell(e,t)}},{key:"getCellAttr",value:function(e){return this.instance.getCellAttr(e)}},{key:"getRowHeight",value:function(){return g.default.style((0,g.default)(".data-table-row",this.bodyScrollable),"height")}},{key:"scrollToCell",value:function(e){if(g.default.inViewport(e,this.bodyScrollable))return!1;var t=g.default.data(e),n=t.rowIndex;return this.rowmanager.scrollToRow(n),!1}},{key:"getRowCountPerPage",value:function(){return Math.ceil(this.instance.getViewportHeight()/this.getRowHeight())}}]),e}();t.default=b},function(e,t,n){"use strict";function o(e){s||(i.default.on(e,"keydown",a),s=!0)}function a(e){var t=l[e.keyCode];e.shiftKey&&"shift"!==t&&(t="shift+"+t),(e.ctrlKey&&"ctrl"!==t||e.metaKey&&"meta"!==t)&&(t="ctrl+"+t);var n=u[t];n&&n.length>0&&n.map(function(t){var n=t();void 0!==n&&!0!==n||e.preventDefault()})}Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=function(e){return e&&e.__esModule?e:{default:e}}(r),l={13:"enter",91:"meta",16:"shift",17:"ctrl",18:"alt",37:"left",38:"up",39:"right",40:"down",9:"tab",27:"esc",67:"c"},s=!1,u={};t.default={init:function(e){o(e)},on:function(e,t){e.split(",").map(function(e){return e.trim()}).map(function(e){u[e]=u[e]||[],u[e].push(t)})}},e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0}),t.getDropdownHTML=void 0;var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(0),l=o(i),s=n(9),u=o(s),c=n(2),d=n(1),f=function(){function e(n){a(this,e),this.instance=n,this.options=this.instance.options,this.fireEvent=this.instance.fireEvent,this.header=this.instance.header,this.datamanager=this.instance.datamanager,this.style=this.instance.style,this.wrapper=this.instance.wrapper,this.rowmanager=this.instance.rowmanager,this.bindEvents(),t.getDropdownHTML=h=h.bind(this,this.options.dropdownButton)}return r(e,[{key:"renderHeader",value:function(){this.header.innerHTML="<thead></thead>",this.refreshHeader()}},{key:"refreshHeader",value:function(){var e=this,t=this.datamanager.getColumns();if((0,l.default)(".data-table-col",this.header)){var n=l.default.each(".data-table-col",this.header);if(t.length<n.length)return void((0,l.default)("thead",this.header).innerHTML=(0,c.getRowHTML)(t,{isHeader:1}));n.map(function(n,o){var a=t[o];l.default.data(n,{colIndex:a.colIndex});var r=(0,l.default)(".sort-indicator",n);r&&(r.innerHTML=e.options.sortIndicator[a.sortOrder])})}else(0,l.default)("thead",this.header).innerHTML=(0,c.getRowHTML)(t,{isHeader:1});this.$columnMap=[]}},{key:"bindEvents",value:function(){this.bindDropdown(),this.bindResizeColumn(),this.bindMoveColumn()}},{key:"bindDropdown",value:function(){function e(e){n&&n.classList.remove("is-active"),n=null}var t=this,n=void 0;l.default.on(this.header,"click",".data-table-dropdown-toggle",function(t,o){var a=l.default.closest(".data-table-dropdown",o);a.classList.contains("is-active")?e():(e(),a.classList.add("is-active"),n=a)}),l.default.on(document.body,"click",function(t){t.target.matches(".data-table-dropdown-toggle")||e()});var o=this.options.headerDropdown;l.default.on(this.header,"click",".data-table-dropdown-list > div",function(e,n){var a=l.default.closest(".data-table-col",n),r=l.default.data(n),i=r.index,s=l.default.data(a),u=s.colIndex,c=o[i].action;c&&c.call(t.instance,t.getColumn(u))})}},{key:"bindResizeColumn",value:function(){var e=this,t=!1,n=void 0,o=void 0,a=void 0;l.default.on(this.header,"mousedown",".data-table-col .column-resizer",function(r,i){document.body.classList.add("data-table-resize");var s=i.parentNode.parentNode;n=s;var u=l.default.data(n),c=u.colIndex,d=e.getColumn(c);d&&!1===d.resizable||(t=!0,o=l.default.style((0,l.default)(".content",n),"width"),a=r.pageX)}),l.default.on(document.body,"mouseup",function(o){if(document.body.classList.remove("data-table-resize"),n){t=!1;var a=l.default.data(n),r=a.colIndex,i=l.default.style((0,l.default)(".content",n),"width");e.setColumnWidth(r,i),e.instance.setBodyWidth(),n=null}}),l.default.on(document.body,"mousemove",function(r){if(t){var i=o+(r.pageX-a),s=l.default.data(n),u=s.colIndex;e.getColumnMinWidth(u)>i||e.setColumnHeaderWidth(u,i)}})}},{key:"bindMoveColumn",value:function(){var e=this,t=function(){if((0,l.default)(".data-table-col",e.header)){var t=(0,l.default)(".data-table-row",e.header);l.default.on(document,"drag",".data-table-col",(0,d.throttle)(function(e,t){e.offsetY>200?t.classList.add("remove-column"):setTimeout(function(){t.classList.remove("remove-column")},10)})),e.sortable=u.default.create(t,{onEnd:function(t){var n=t.oldIndex,o=t.newIndex,a=t.item;+l.default.data(a).colIndex!==o&&e.switchColumn(n,o)},preventOnFilter:!1,filter:".column-resizer, .data-table-dropdown",animation:150})}};l.default.on(document.body,"mousemove",t)}},{key:"bindSortColumn",value:function(){var e=this;l.default.on(this.header,"click",".data-table-col .column-title",function(t,n){var o=n.closest(".data-table-col"),a=l.default.data(o),r=a.colIndex,i=a.sortOrder;i=(0,d.getDefault)(i,"none");var s=e.getColumn(r);if(!s||!1!==s.sortable){(0,l.default)(".sort-indicator",e.header).textContent="",l.default.each(".data-table-col",e.header).map(function(e){l.default.data(e,{sortOrder:"none"})});var u=void 0,c=void 0;"none"===i?(u="asc",c="▲"):"asc"===i?(u="desc",c="▼"):"desc"===i&&(u="none",c=""),l.default.data(o,{sortOrder:u}),(0,l.default)(".sort-indicator",o).textContent=c,e.sortColumn(r,u)}})}},{key:"sortColumn",value:function(e,t){var n=this;this.instance.freeze(),this.sortRows(e,t).then(function(){return n.refreshHeader(),n.rowmanager.refreshRows()}).then(function(){return n.instance.unfreeze()}).then(function(){n.fireEvent("onSortColumn",n.getColumn(e))})}},{key:"removeColumn",value:function(e){var t=this,n=this.getColumn(e);this.instance.freeze(),this.datamanager.removeColumn(e).then(function(){return t.refreshHeader(),t.rowmanager.refreshRows()}).then(function(){return t.instance.unfreeze()}).then(function(){t.fireEvent("onRemoveColumn",n)})}},{key:"switchColumn",value:function(e,t){var n=this;this.instance.freeze(),this.datamanager.switchColumn(e,t).then(function(){return n.refreshHeader(),n.rowmanager.refreshRows()}).then(function(){n.setColumnWidth(e),n.setColumnWidth(t),n.instance.unfreeze()}).then(function(){n.fireEvent("onSwitchColumn",n.getColumn(e),n.getColumn(t))})}},{key:"setDimensions",value:function(){this.setHeaderStyle(),this.setupMinWidth(),this.setNaturalColumnWidth(),this.distributeRemainingWidth(),this.setColumnAlignments()}},{key:"setHeaderStyle",value:function(){this.options.takeAvailableSpace||l.default.style(this.header,{width:0}),l.default.style(this.header,{margin:0});var e=this.datamanager.getColumns().filter(function(e){return void 0!==e.resizable&&!e.resizable}).map(function(e){return e.colIndex}).map(function(e){return'.data-table-header [data-col-index="'+e+'"]'}).join();this.style.setStyle(e,{cursor:"pointer"})}},{key:"setupMinWidth",value:function(){var e=this;this.minWidthMap=(0,d.getDefault)(this.minWidthMap,[]),l.default.each(".data-table-col",this.header).map(function(t){var n=l.default.style((0,l.default)(".content",t),"width"),o=l.default.data(t),a=o.colIndex;e.minWidthMap[a]||(e.minWidthMap[a]=n,e.datamanager.updateColumn(a,{minWidth:n}))})}},{key:"setNaturalColumnWidth",value:function(){var e=this;l.default.each('.data-table-row[data-row-index="0"] .data-table-col',this.bodyScrollable).map(function(t){var n=l.default.style((0,l.default)(".content",t),"width"),o=l.default.style((0,l.default)(".content",t),"height"),a=l.default.data(t),r=a.colIndex,i=e.getColumnMinWidth(r);n<i&&(n=i),e.datamanager.updateColumn(r,{width:n}),e.setColumnWidth(r,n),e.setDefaultCellHeight(o)})}},{key:"distributeRemainingWidth",value:function(){var e=this;if(this.options.takeAvailableSpace){var t=l.default.style(this.instance.datatableWrapper,"width"),n=l.default.style(this.header,"width");if(!(n>=t)){var o=this.datamanager.getColumns().filter(function(e){return void 0===e.resizable||e.resizable}),a=(t-n)/o.length;o.map(function(t){var n=l.default.style(e.getColumnHeaderElement(t.colIndex),"width"),o=Math.min(n+a)-2;e.datamanager.updateColumn(t.colIndex,{width:o}),e.setColumnHeaderWidth(t.colIndex,o),e.setColumnWidth(t.colIndex,o)}),this.instance.setBodyWidth()}}}},{key:"setDefaultCellHeight",value:function(e){this.style.setStyle(".data-table-col .content",{height:e+"px"})}},{key:"setColumnAlignments",value:function(){var e=this;this.getColumns().map(function(t){["left","center","right"].includes(t.align)&&e.style.setStyle('[data-col-index="'+t.colIndex+'"]',{"text-align":t.align})})}},{key:"sortRows",value:function(e,t){return this.datamanager.sortRows(e,t)}},{key:"getColumn",value:function(e){return this.datamanager.getColumn(e)}},{key:"getColumns",value:function(){return this.datamanager.getColumns()}},{key:"setColumnWidth",value:function(e,t){if(this._columnWidthMap=this._columnWidthMap||[],!t){var n=(0,l.default)('.data-table-col[data-col-index="'+e+'"] .content',this.header);t=l.default.style(n,"width")}var o=this._columnWidthMap[e],a='[data-col-index="'+e+'"] .content, [data-col-index="'+e+'"] .edit-cell',r={width:t+"px"};o=this.style.setStyle(a,r,o),this._columnWidthMap[e]=o}},{key:"setColumnHeaderWidth",value:function(e,t){this.$columnMap=this.$columnMap||[];var n='[data-col-index="'+e+'"][data-is-header] .content',o=this.$columnMap[e];o||(o=this.header.querySelector(n),this.$columnMap[e]=o),o.style.width=t+"px"}},{key:"getColumnMinWidth",value:function(e){return e=+e,this.minWidthMap&&this.minWidthMap[e]}},{key:"getFirstColumnIndex",value:function(){return this.options.addCheckboxColumn&&this.options.addSerialNoColumn?2:this.options.addCheckboxColumn||this.options.addSerialNoColumn?1:0}},{key:"getHeaderCell$",value:function(e){return(0,l.default)('.data-table-col[data-col-index="'+e+'"]',this.header)}},{key:"getLastColumnIndex",value:function(){return this.datamanager.getColumnCount()-1}},{key:"getColumnHeaderElement",value:function(e){return e=+e,e<0?null:(0,l.default)('.data-table-col[data-is-header][data-col-index="'+e+'"]',this.wrapper)}},{key:"getSerialColumnIndex",value:function(){return this.datamanager.getColumns().findIndex(function(e){return e.content.includes("Sr. No")})}}]),e}();t.default=f;var h=function(){return'<div class="data-table-dropdown-toggle">'+(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"v")+'</div>\n <div class="data-table-dropdown-list">\n '+this.options.headerDropdown.map(function(e,t){return'<div data-index="'+t+'">'+e.label+"</div>"}).join("")+"\n </div>\n "};t.getDropdownHTML=h},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),r=o(a),i=n(19),l=o(i);r.default.__version__=l.default.version,t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(0),l=o(i),s=n(8),u=o(s),c=n(3),d=o(c),f=n(5),h=o(f),p=n(2),v=o(p),g=n(10),m=o(g),b=n(12),y=o(b),w=n(4),C=o(w),k=n(13),x=o(k);n(14);var S=function(){function e(t,n){if(a(this,e),e.instances++,"string"==typeof t&&(t=document.querySelector(t)),this.wrapper=t,!this.wrapper)throw new Error("Invalid argument given for `wrapper`");this.options=Object.assign({},x.default,n),this.options.headerDropdown=x.default.headerDropdown.concat(n.headerDropdown||[]),this.events=Object.assign({},x.default.events,n.events||{}),this.fireEvent=this.fireEvent.bind(this),this.prepare(),this.style=new y.default(this),this.datamanager=new u.default(this.options),this.rowmanager=new v.default(this),this.columnmanager=new h.default(this),this.cellmanager=new d.default(this),this.bodyRenderer=new m.default(this),C.default.init(this.wrapper),this.options.data&&this.refresh(this.options.data)}return r(e,[{key:"prepare",value:function(){this.prepareDom(),this.unfreeze()}},{key:"prepareDom",value:function(){this.wrapper.innerHTML='\n <div class="data-table">\n <table class="data-table-header">\n </table>\n <div class="body-scrollable">\n </div>\n <div class="freeze-container">\n <span>'+this.options.freezeMessage+'</span>\n </div>\n <div class="data-table-footer">\n </div>\n </div>\n ',this.datatableWrapper=(0,l.default)(".data-table",this.wrapper),this.header=(0,l.default)(".data-table-header",this.wrapper),this.bodyScrollable=(0,l.default)(".body-scrollable",this.wrapper),this.freezeContainer=(0,l.default)(".freeze-container",this.wrapper)}},{key:"refresh",value:function(e){this.datamanager.init(e),this.render()}},{key:"destroy",value:function(){this.wrapper.innerHTML="",this.style.destroy()}},{key:"appendRows",value:function(e){this.datamanager.appendRows(e),this.rowmanager.refreshRows()}},{key:"refreshRow",value:function(e,t){this.rowmanager.refreshRow(e,t)}},{key:"render",value:function(){this.renderHeader(),this.renderBody()}},{key:"renderHeader",value:function(){this.columnmanager.renderHeader()}},{key:"renderBody",value:function(){this.bodyRenderer.render()}},{key:"setDimensions",value:function(){this.columnmanager.setDimensions(),this.setBodyWidth(),l.default.style(this.bodyScrollable,{marginTop:l.default.style(this.header,"height")+"px"}),l.default.style((0,l.default)("table",this.bodyScrollable),{margin:0})}},{key:"setBodyWidth",value:function(){var e=l.default.style(this.header,"width");l.default.style(this.bodyScrollable,{width:e+"px"})}},{key:"getColumn",value:function(e){return this.datamanager.getColumn(e)}},{key:"getCell",value:function(e,t){return this.datamanager.getCell(e,t)}},{key:"getColumnHeaderElement",value:function(e){return this.columnmanager.getColumnHeaderElement(e)}},{key:"getViewportHeight",value:function(){return this.viewportHeight||(this.viewportHeight=l.default.style(this.bodyScrollable,"height")),this.viewportHeight}},{key:"sortColumn",value:function(e,t){this.columnmanager.sortColumn(e,t)}},{key:"removeColumn",value:function(e){this.columnmanager.removeColumn(e)}},{key:"scrollToLastColumn",value:function(){this.datatableWrapper.scrollLeft=9999}},{key:"freeze",value:function(){l.default.style(this.freezeContainer,{display:""})}},{key:"unfreeze",value:function(){l.default.style(this.freezeContainer,{display:"none"})}},{key:"fireEvent",value:function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];this.events[e].apply(this,n)}},{key:"log",value:function(){this.options.enableLogs&&console.log.apply(console,arguments)}}]),e}();S.instances=0,t.default=S,e.exports=t.default},function(e,t,n){"use strict";function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function i(e,t){var n={rowIndex:t};return e.map(s).map(function(e){return Object.assign({},n,e)})}function l(e){var t=(arguments.length>1&&void 0!==arguments[1]&&arguments[1],{isHeader:1,editable:!0,sortable:!0,resizable:!0,focusable:!0,dropdown:!0,format:function(e){return'<span class="column-title">'+e+"</span>"}});return e.map(s).map(function(e){return Object.assign({},t,e)})}function s(e,t){var n={content:"",align:"left",sortOrder:"none",colIndex:0,width:40};return"string"==typeof e&&(e={content:e}),Object.assign({},n,e,{colIndex:t})}Object.defineProperty(t,"__esModule",{value:!0}),t.DataError=void 0;var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),d=n(1),f=function(){function e(t){r(this,e),this.options=t,this.sortRows=(0,d.promisify)(this.sortRows,this),this.switchColumn=(0,d.promisify)(this.switchColumn,this),this.removeColumn=(0,d.promisify)(this.removeColumn,this)}return c(e,[{key:"init",value:function(e){e||(e=this.options.data);var t=e,n=t.columns,o=t.rows;this.rowCount=0,this.columns=[],this.rows=[],this.columns=this.prepareColumns(n),this.rows=this.prepareRows(o),this.prepareNumericColumns()}},{key:"prepareColumns",value:function(e){if(this.validateColumns(e),this.options.addSerialNoColumn&&!this.hasColumn("Sr. No")){e=[{content:"Sr. No",align:"center",editable:!1,resizable:!1,focusable:!1,dropdown:!1}].concat(e)}if(this.options.addCheckboxColumn&&!this.hasColumn("Checkbox")){e=[{content:"Checkbox",editable:!1,resizable:!1,sortable:!1,focusable:!1,dropdown:!1,format:function(e){return'<input type="checkbox" />'}}].concat(e)}return l(e)}},{key:"prepareNumericColumns",value:function(){var e=this.getRow(0);this.columns=this.columns.map(function(t,n){var o=e[n].content;return!t.align&&o&&(0,d.isNumeric)(o)&&(t.align="right"),t})}},{key:"prepareRows",value:function(e){var t=this;return this.validateRows(e),e=e.map(function(e,n){var o=t._getNextRowCount();if(e.length<t.columns.length){if(t.hasColumn("Sr. No")){e=[o+1+""].concat(e)}if(t.hasColumn("Checkbox")){e=['<input type="checkbox" />'].concat(e)}}return i(e,o)})}},{key:"validateColumns",value:function(e){if(!Array.isArray(e))throw new h("`columns` must be an array");e.forEach(function(e,t){if("string"!=typeof e&&"object"!==(void 0===e?"undefined":u(e)))throw new h('column "'+t+'" must be a string or an object')})}},{key:"validateRows",value:function(e){var t=this;if(!Array.isArray(e))throw new h("`rows` must be an array");e.forEach(function(e,n){if(!Array.isArray(e))throw new h("`row` must be an array");if(e.length!==t.getColumnCount(!0))throw new h('Row index "'+n+"\" doesn't match column length")})}},{key:"appendRows",value:function(e){this.validateRows(e),this.rows=this.rows.concat(this.prepareRows(e))}},{key:"sortRows",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none";e=+e,this.getColumns().map(function(n){n.colIndex===e?n.sortOrder=t:n.sortOrder="none"}),this._sortRows(e,t)}},{key:"_sortRows",value:function(e,t){if(this.currentSort.colIndex===e&&("asc"===this.currentSort.sortOrder&&"desc"===t||"desc"===this.currentSort.sortOrder&&"asc"===t))return this.reverseArray(this.rows),void(this.currentSort.sortOrder=t);if(this.rows.sort(function(n,o){var a=n[0].rowIndex,r=o[0].rowIndex,i=n[e].content,l=o[e].content;if("none"===t)return a-r;if("asc"===t){if(i<l)return-1;if(i>l)return 1;if(i===l)return 0}else if("desc"===t){if(i<l)return 1;if(i>l)return-1;if(i===l)return 0}return 0}),this.hasColumn("Sr. No")){var n=this.getColumnIndex("Sr. No");this.rows=this.rows.map(function(e,t){return e.map(function(e){return e.colIndex===n&&(e.content=t+1+""),e})})}}},{key:"reverseArray",value:function(e){var t=null,n=null,o=e.length;for(t=0,n=o-1;t<n;t+=1,n-=1){var a=e[t];e[t]=e[n],e[n]=a}}},{key:"switchColumn",value:function(e,t){var n=this.columns[e];this.columns[e]=this.columns[t],this.columns[t]=n,this.columns[e].colIndex=e,this.columns[t].colIndex=t,this.rows=this.rows.map(function(n){var o=Object.assign({},n[e],{colIndex:t}),a=Object.assign({},n[t],{colIndex:e}),r=n.map(function(e){return Object.assign({},e)});return r[t]=o,r[e]=a,r})}},{key:"removeColumn",value:function(e){e=+e;var t=function(t){return t.colIndex!==e},n=function(e,t){return Object.assign({},e,{colIndex:t})};this.columns=this.columns.filter(t).map(n),this.rows=this.rows.map(function(e){return e.filter(t).map(n)})}},{key:"updateRow",value:function(e,t){if(e.length<this.columns.length){if(this.hasColumn("Sr. No")){e=[t+1+""].concat(e)}if(this.hasColumn("Checkbox")){e=['<input type="checkbox" />'].concat(e)}}var n=i(e,t),o=this.rows.findIndex(function(e){return e[0].rowIndex===t});return this.rows[o]=n,n}},{key:"updateCell",value:function(e,t,n){var o=void 0;"object"===(void 0===e?"undefined":u(e))&&(o=e,e=o.colIndex,t=o.rowIndex,n=o),o=this.getCell(e,t);for(var a in n){var r=n[a];void 0!==r&&(o[a]=r)}return o}},{key:"updateColumn",value:function(e,t){var n=this.getColumn(e);for(var o in t){var a=t[o];void 0!==a&&(n[o]=a)}return n}},{key:"getRowCount",value:function(){return this.rowCount}},{key:"_getNextRowCount",value:function(){var e=this.rowCount;return this.rowCount++,e}},{key:"getRows",value:function(e,t){return this.rows.slice(e,t)}},{key:"getColumns",value:function(e){var t=this.columns;return e&&(t=t.slice(this.getStandardColumnCount())),t}},{key:"getStandardColumnCount",value:function(){return this.options.addCheckboxColumn&&this.options.addSerialNoColumn?2:this.options.addCheckboxColumn||this.options.addSerialNoColumn?1:0}},{key:"getColumnCount",value:function(e){var t=this.columns.length;return e&&(t-=this.getStandardColumnCount()),t}},{key:"getColumn",value:function(e){return e=+e,this.columns.find(function(t){return t.colIndex===e})}},{key:"getRow",value:function(e){return e=+e,this.rows.find(function(t){return t[0].rowIndex===e})}},{key:"getCell",value:function(e,t){return t=+t,e=+e,this.rows.find(function(e){return e[0].rowIndex===t})[e]}},{key:"get",value:function(){return{columns:this.columns,rows:this.rows}}},{key:"hasColumn",value:function(e){return Boolean(this.columns.find(function(t){return t.content===e}))}},{key:"getColumnIndex",value:function(e){return this.columns.findIndex(function(t){return t.content===e})}},{key:"currentSort",get:function(){return this.columns.find(function(e){return"none"!==e.sortOrder})||{colIndex:-1,sortOrder:"none"}}}]),e}();t.default=f;var h=t.DataError=function(e){function t(){return r(this,t),o(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return a(t,e),t}(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(TypeError))},function(t,n){t.exports=e},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){return"\n <tbody>\n "+e.map(function(e){return(0,d.getRowHTML)(e,{rowIndex:e[0].rowIndex})}).join("")+"\n </tbody>\n "}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();t.getBodyHTML=r;var l=n(0),s=o(l),u=n(11),c=o(u),d=n(2),f=n(1),h=function(){function e(t){a(this,e),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=(0,f.promisify)(this.appendRemainingData,this)}return i(e,[{key:"render",value:function(){this.options.enableClusterize?this.renderBodyWithClusterize():this.renderBodyHTML()}},{key:"renderBodyHTML",value:function(){var e=this.datamanager.getRows();this.bodyScrollable.innerHTML='\n <table class="data-table-body">\n '+r(e)+"\n </table>\n "}},{key:"renderBodyWithClusterize",value:function(){var e=this,t=this.datamanager.getRows(0,20),n=this.getDataForClusterize(t);this.clusterize?this.clusterize.update(n):(this.bodyScrollable.innerHTML='\n <table class="data-table-body">\n '+r([])+"\n </table>\n ",this.clusterize=new c.default({rows:n,scrollElem:this.bodyScrollable,contentElem:(0,s.default)("tbody",this.bodyScrollable),callbacks:{clusterChanged:function(){e.rowmanager.highlightCheckedRows(),e.cellmanager.selectAreaOnClusterChanged(),e.cellmanager.focusCellOnClusterChanged()}},no_data_text:this.options.loadingText,no_data_class:"empty-state"}),this.instance.setDimensions()),this.appendRemainingData()}},{key:"appendRemainingData",value:function(){var e=this.datamanager.getRows(20),t=this.getDataForClusterize(e);this.clusterize.append(t)}},{key:"getDataForClusterize",value:function(e){return e.map(function(e){return(0,d.getRowHTML)(e,{rowIndex:e[0].rowIndex})})}}]),e}();t.default=h},function(e,n){e.exports=t},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),r=n(1),i=function(){function e(t){o(this,e),this.datatable=t,this.scopeClass="datatable-instance-"+t.constructor.instances,t.datatableWrapper.classList.add(this.scopeClass);var n=document.createElement("style");t.wrapper.insertBefore(n,t.datatableWrapper),this.styleEl=n,this.styleSheet=n.sheet}return a(e,[{key:"destroy",value:function(){this.styleEl.remove()}},{key:"setStyle",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1,o=Object.keys(t).map(function(e){return e.includes("-")||(e=(0,r.camelCaseToDash)(e)),e+":"+t[e]+";"}).join(""),a="."+this.scopeClass+" "+e+" { "+o+" }",i=this.styleSheet.cssRules.length;return-1!==n&&(this.styleSheet.deleteRule(n),i=n),this.styleSheet.insertRule(a,i),i}}]),e}();t.default=i,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={data:{columns:[],rows:[]},dropdownButton:"▼",headerDropdown:[{label:"Sort Ascending",action:function(e){this.sortColumn(e.colIndex,"asc")}},{label:"Sort Descending",action:function(e){this.sortColumn(e.colIndex,"desc")}},{label:"Reset sorting",action:function(e){this.sortColumn(e.colIndex,"none")}},{label:"Remove column",action:function(e){this.removeColumn(e.colIndex)}}],events:{onRemoveColumn:function(e){},onSwitchColumn:function(e,t){},onSortColumn:function(e){}},sortIndicator:{asc:"↑",desc:"↓",none:""},freezeMessage:"Loading...",editing:function(){},addSerialNoColumn:!0,addCheckboxColumn:!0,enableClusterize:!0,enableLogs:!1,takeAvailableSpace:!1,loadingText:"Loading..."},e.exports=t.default},function(e,t,n){var o=n(15);"string"==typeof o&&(o=[[e.i,o,""]]);var a={};a.transform=void 0;n(17)(o,a);o.locals&&(e.exports=o.locals)},function(e,t,n){t=e.exports=n(16)(void 0),t.push([e.i,"/* variables */\n/* resets */\n*, *::after, *::before {\n box-sizing: border-box; }\n\nbutton, input {\n overflow: visible;\n font-family: inherit;\n font-size: inherit;\n line-height: inherit;\n margin: 0; }\n\n/* styling */\n.data-table * {\n outline: none; }\n\n.data-table {\n width: 100%;\n position: relative;\n overflow: auto; }\n .data-table table {\n border-collapse: collapse; }\n .data-table table td {\n padding: 0;\n border: 1px solid #d1d8dd; }\n .data-table thead td {\n border-bottom-width: 2px; }\n .data-table .freeze-container {\n display: flex;\n justify-content: center;\n align-content: center;\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n background-color: #f5f7fa;\n opacity: 0.5;\n font-size: 2em; }\n .data-table .freeze-container span {\n position: absolute;\n top: 50%;\n transform: translateY(-50%); }\n .data-table .trash-container {\n position: absolute;\n bottom: 0;\n left: 30%;\n right: 30%;\n height: 70px;\n background: palevioletred;\n opacity: 0.5; }\n\n.body-scrollable {\n max-height: 500px;\n overflow: auto;\n border-bottom: 1px solid #d1d8dd; }\n .body-scrollable.row-highlight-all .data-table-row:not(.row-unhighlight) {\n background-color: #f5f7fa; }\n\n.data-table-header {\n position: absolute;\n top: 0;\n left: 0;\n background-color: white;\n font-weight: bold; }\n .data-table-header .content span:not(.column-resizer) {\n cursor: pointer; }\n .data-table-header .column-resizer {\n display: none;\n position: absolute;\n right: 0;\n top: 0;\n width: 4px;\n height: 100%;\n background-color: #5292f7;\n cursor: col-resize; }\n .data-table-header .data-table-dropdown {\n position: absolute;\n right: 10px;\n display: inline-flex;\n vertical-align: top;\n text-align: left; }\n .data-table-header .data-table-dropdown.is-active .data-table-dropdown-list {\n display: block; }\n .data-table-header .data-table-dropdown.is-active .data-table-dropdown-toggle {\n display: block; }\n .data-table-header .data-table-dropdown-toggle {\n display: none;\n background-color: transparent;\n border: none; }\n .data-table-header .data-table-dropdown-list {\n display: none;\n font-weight: normal;\n position: absolute;\n min-width: 8rem;\n top: 100%;\n right: 0;\n z-index: 1;\n background-color: white;\n border-radius: 3px;\n box-shadow: 0 2px 3px rgba(10, 10, 10, 0.1), 0 0 0 1px rgba(10, 10, 10, 0.1);\n padding-bottom: 0.5rem;\n padding-top: 0.5rem; }\n .data-table-header .data-table-dropdown-list > div {\n padding: 5px 10px; }\n .data-table-header .data-table-dropdown-list > div:hover {\n background-color: #f5f7fa; }\n .data-table-header .data-table-col.remove-column {\n background-color: #FD8B8B;\n transition: 300ms background-color ease-in-out; }\n .data-table-header .data-table-col.sortable-chosen {\n background-color: #f5f7fa; }\n\n.data-table-col {\n position: relative; }\n .data-table-col .content {\n padding: 8px;\n border: 2px solid transparent; }\n .data-table-col .content.ellipsis {\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden; }\n .data-table-col .edit-cell {\n display: none;\n padding: 8px;\n background: #fff;\n z-index: 1;\n height: 100%; }\n .data-table-col .edit-cell input {\n outline: none;\n width: 100%;\n border: none;\n height: 1em; }\n .data-table-col.selected .content {\n border: 2px solid #5292f7; }\n .data-table-col.editing .content {\n display: none; }\n .data-table-col.editing .edit-cell {\n border: 2px solid #5292f7;\n display: block; }\n .data-table-col.highlight {\n background-color: #f5f7fa; }\n .data-table-col:hover .column-resizer {\n display: inline-block; }\n .data-table-col:hover .data-table-dropdown-toggle {\n display: block; }\n\n.data-table-row.row-highlight {\n background-color: #f5f7fa; }\n\n.noselect {\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -khtml-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none; }\n\nbody.data-table-resize {\n cursor: col-resize; }\n",""])},function(e,t){function n(e,t){var n=e[1]||"",a=e[3];if(!a)return n;if(t&&"function"==typeof btoa){var r=o(a);return[n].concat(a.sources.map(function(e){return"/*# sourceURL="+a.sourceRoot+e+" */"})).concat([r]).join("\n")}return[n].join("\n")}function o(e){return"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(e))))+" */"}e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var o=n(t,e);return t[2]?"@media "+t[2]+"{"+o+"}":o}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var o={},a=0;a<this.length;a++){var r=this[a][0];"number"==typeof r&&(o[r]=!0)}for(a=0;a<e.length;a++){var i=e[a];"number"==typeof i[0]&&o[i[0]]||(n&&!i[2]?i[2]=n:n&&(i[2]="("+i[2]+") and ("+n+")"),t.push(i))}},t}},function(e,t,n){function o(e,t){for(var n=0;n<e.length;n++){var o=e[n],a=p[o.id];if(a){a.refs++;for(var r=0;r<a.parts.length;r++)a.parts[r](o.parts[r]);for(;r<o.parts.length;r++)a.parts.push(c(o.parts[r],t))}else{for(var i=[],r=0;r<o.parts.length;r++)i.push(c(o.parts[r],t));p[o.id]={id:o.id,refs:1,parts:i}}}}function a(e,t){for(var n=[],o={},a=0;a<e.length;a++){var r=e[a],i=t.base?r[0]+t.base:r[0],l=r[1],s=r[2],u=r[3],c={css:l,media:s,sourceMap:u};o[i]?o[i].parts.push(c):n.push(o[i]={id:i,parts:[c]})}return n}function r(e,t){var n=g(e.insertInto);if(!n)throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");var o=y[y.length-1];if("top"===e.insertAt)o?o.nextSibling?n.insertBefore(t,o.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),y.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function i(e){if(null===e.parentNode)return!1;e.parentNode.removeChild(e);var t=y.indexOf(e);t>=0&&y.splice(t,1)}function l(e){var t=document.createElement("style");return e.attrs.type="text/css",u(t,e.attrs),r(e,t),t}function s(e){var t=document.createElement("link");return e.attrs.type="text/css",e.attrs.rel="stylesheet",u(t,e.attrs),r(e,t),t}function u(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function c(e,t){var n,o,a,r;if(t.transform&&e.css){if(!(r=t.transform(e.css)))return function(){};e.css=r}if(t.singleton){var u=b++;n=m||(m=l(t)),o=d.bind(null,n,u,!1),a=d.bind(null,n,u,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=s(t),o=h.bind(null,n,t),a=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=l(t),o=f.bind(null,n),a=function(){i(n)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else a()}}function d(e,t,n,o){var a=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=C(t,a);else{var r=document.createTextNode(a),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(r,i[t]):e.appendChild(r)}}function f(e,t){var n=t.css,o=t.media;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function h(e,t,n){var o=n.css,a=n.sourceMap,r=void 0===t.convertToAbsoluteUrls&&a;(t.convertToAbsoluteUrls||r)&&(o=w(o)),a&&(o+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(a))))+" */");var i=new Blob([o],{type:"text/css"}),l=e.href;e.href=URL.createObjectURL(i),l&&URL.revokeObjectURL(l)}var p={},v=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}}(function(){return window&&document&&document.all&&!window.atob}),g=function(e){var t={};return function(n){return void 0===t[n]&&(t[n]=e.call(this,n)),t[n]}}(function(e){return document.querySelector(e)}),m=null,b=0,y=[],w=n(18);e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},t.attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||(t.singleton=v()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=a(e,t);return o(n,t),function(e){for(var r=[],i=0;i<n.length;i++){var l=n[i],s=p[l.id];s.refs--,r.push(s)}if(e){o(a(e,t),t)}for(var i=0;i<r.length;i++){var s=r[i];if(0===s.refs){for(var u=0;u<s.parts.length;u++)s.parts[u]();delete p[s.id]}}}};var C=function(){var e=[];return function(t,n){return e[t]=n,e.filter(Boolean).join("\n")}}()},function(e,t){e.exports=function(e){var t="undefined"!=typeof window&&window.location;if(!t)throw new Error("fixUrls requires window.location");if(!e||"string"!=typeof e)return e;var n=t.protocol+"//"+t.host,o=n+t.pathname.replace(/\/[^\/]*$/,"/");return e.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi,function(e,t){var a=t.trim().replace(/^"(.*)"$/,function(e,t){return t}).replace(/^'(.*)'$/,function(e,t){return t});if(/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/)/i.test(a))return e;var r;return r=0===a.indexOf("//")?a:0===a.indexOf("/")?n+a:o+a.replace(/^\.\//,""),"url("+JSON.stringify(r)+")"})}},function(e,t){e.exports={name:"frappe-datatable",version:"0.0.1",description:"A modern datatable library for the web",main:"lib/frappe-datatable.js",scripts:{build:"webpack --env build",dev:"webpack --progress --colors --watch --env dev",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:{"babel-cli":"6.24.1","babel-core":"6.24.1","babel-eslint":"7.2.3","babel-loader":"7.0.0","babel-plugin-add-module-exports":"0.2.1","babel-plugin-transform-builtin-extend":"^1.1.2","babel-preset-env":"^1.6.1",chai:"3.5.0","css-loader":"^0.28.7",eslint:"3.19.0","eslint-loader":"1.7.1",mocha:"3.3.0","node-sass":"^4.5.3","sass-loader":"^6.0.6","style-loader":"^0.18.2",webpack:"^3.1.0",yargs:"7.1.0"},repository:{type:"git",url:"https://github.com/frappe/datatable.git"},keywords:["webpack","es6","starter","library","universal","umd","commonjs"],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",sortablejs:"^1.7.0"}}}])}); |