12 lines
347 KiB
JavaScript
12 lines
347 KiB
JavaScript
|
var _typeof="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};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Tabulator=t()}(this,function(){"use strict";Array.prototype.findIndex||Object.defineProperty(Array.prototype,"findIndex",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<o;){var s=t[n];if(e.call(i,s,n,t))return n;n++}return-1}}),Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var i=arguments[1],n=0;n<o;){var s=t[n];if(e.call(i,s,n,t))return s;n++}}}),String.prototype.includes||(String.prototype.includes=function(e,t){if(e instanceof RegExp)throw TypeError("first argument must not be a RegExp");return void 0===t&&(t=0),-1!==this.indexOf(e,t)}),Array.prototype.includes||Object.defineProperty(Array.prototype,"includes",{value:function(e,t){if(null==this)throw new TypeError('"this" is null or not defined');var o=Object(this),i=o.length>>>0;if(0===i)return!1;for(var n=0|t,s=Math.max(n>=0?n:i-Math.abs(n),0);s<i;){if(function(e,t){return e===t||"number"==typeof e&&"number"==typeof t&&isNaN(e)&&isNaN(t)}(o[s],e))return!0;s++}return!1}}),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null===e||void 0===e)throw new TypeError("Cannot convert undefined or null to object");for(var o=Object(e),i=1;i<arguments.length;i++){var n=arguments[i];if(null!==n&&void 0!==n)for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])}return o},writable:!0,configurable:!0});var t=function(e){this.table=e,this.blockHozScrollEvent=!1,this.headersElement=this.createHeadersElement(),this.element=this.createHeaderElement(),this.rowManager=null,this.columns=[],this.columnsByIndex=[],this.columnsByField={},this.scrollLeft=0,this.element.insertBefore(this.headersElement,this.element.firstChild)};t.prototype.createHeadersElement=function(){var e=document.createElement("div");return e.classList.add("tabulator-headers"),e},t.prototype.createHeaderElement=function(){var e=document.createElement("div");return e.classList.add("tabulator-header"),this.table.options.headerVisible||e.classList.add("tabulator-header-hidden"),e},t.prototype.initialize=function(){},t.prototype.setRowManager=function(e){this.rowManager=e},t.prototype.getElement=function(){return this.element},t.prototype.getHeadersElement=function(){return this.headersElement},t.prototype.scrollHorizontal=function(e){var t=0,o=this.element.scrollWidth-this.table.element.clientWidth;this.element.scrollLeft=e,e>o?(t=e-o,this.element.style.marginLeft=-t+"px"):this.element.style.marginLeft=0,this.scrollLeft=e,this.table.modExists("frozenColumns")&&this.table.modules.frozenColumns.scrollHorizontal()},t.prototype.generateColumnsFromRowData=function(e){var t,o,i=[],n=this.table.options.autoColumnsDefinitions;if(e&&e.length){t=e[0];for(var s in t){var a={field:s,title:s},r=t[s];switch(void 0===r?"undefined":_typeof(r)){case"undefined":o="string";break;case"boolean":o="boolean";break;case"object":o=Array.isArray(r)?"array":"string";break;default:o=isNaN(r)||""===r?r.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)?"alphanum":"string":"number"}a.sorter=o,i.push(a)}if(n)switch(void 0===n?"undefined":_typeof(n)){case"function":this.table.options.columns=n.call(this.table,i);break;case"object":Array.isArray(n)?i.forEach(function(e){var t=n.find(function(t){return t.field===e.field});t&&Object.assign(e,t)}):i.forEach(function(e){n[e.field]&&Object.assign(e,n[e.field])}),this.table.op
|
||
|
n.prototype.delete=function(){var e=this;return new Promise(function(t,o){e.isGroup&&e.columns.forEach(function(e){e.delete()}),e.table.modExists("edit")&&e.table.modules.edit.currentCell.column===e&&e.table.modules.edit.cancelEdit();for(var i=e.cells.length,n=0;n<i;n++)e.cells[0].delete();e.element.parentNode&&e.element.parentNode.removeChild(e.element),e.element=!1,e.contentElement=!1,e.titleElement=!1,e.groupElement=!1,e.table.columnManager.deregisterColumn(e),e.table.options.virtualDomHoz&&e.table.vdomHoz.reinitialize(!0),t()})},n.prototype.columnRendered=function(){this.titleFormatterRendered&&this.titleFormatterRendered()},n.prototype.validate=function(){var e=[];return this.cells.forEach(function(t){t.validate()||e.push(t.getComponent())}),!e.length||e},n.prototype.generateCell=function(e){var t=this,o=new u(t,e);return this.cells.push(o),o},n.prototype.nextColumn=function(){var e=this.table.columnManager.findColumnIndex(this);return e>-1&&this._nextVisibleColumn(e+1)},n.prototype._nextVisibleColumn=function(e){var t=this.table.columnManager.getColumnByIndex(e);return!t||t.visible?t:this._nextVisibleColumn(e+1)},n.prototype.prevColumn=function(){var e=this.table.columnManager.findColumnIndex(this);return e>-1&&this._prevVisibleColumn(e-1)},n.prototype._prevVisibleColumn=function(e){var t=this.table.columnManager.getColumnByIndex(e);return!t||t.visible?t:this._prevVisibleColumn(e-1)},n.prototype.reinitializeWidth=function(e){this.widthFixed=!1,void 0===this.definition.width||e||this.setWidth(this.definition.width),this.table.modExists("filter")&&this.table.modules.filter.hideHeaderFilterElements(),this.fitToData(),this.table.modExists("filter")&&this.table.modules.filter.showHeaderFilterElements()},n.prototype.fitToData=function(){var e=this;this.widthFixed||(this.element.style.width="",e.cells.forEach(function(e){e.clearWidth()}));var t=this.element.offsetWidth;e.width&&this.widthFixed||(e.cells.forEach(function(e){var o=e.getWidth();o>t&&(t=o)}),t&&e.setWidthActual(t+1))},n.prototype.updateDefinition=function(e){var t=this;return new Promise(function(o,i){var n;t.isGroup?(console.warn("Column Update Error - The updateDefinition function is only available on columns, not column groups"),i("Column Update Error - The updateDefinition function is only available on columns, not column groups")):(n=Object.assign({},t.getDefinition()),n=Object.assign(n,e),t.table.columnManager.addColumn(n,!1,t).then(function(e){n.field==t.field&&(t.field=!1),t.delete().then(function(){o(e.getComponent())}).catch(function(e){i(e)})}).catch(function(e){i(e)}))})},n.prototype.deleteCell=function(e){var t=this.cells.indexOf(e);t>-1&&this.cells.splice(t,1)},n.prototype.defaultOptionList=["title","field","columns","visible","align","hozAlign","vertAlign","width","minWidth","widthGrow","widthShrink","resizable","frozen","responsive","tooltip","cssClass","rowHandle","hideInHtml","print","htmlOutput","sorter","sorterParams","formatter","formatterParams","variableHeight","editable","editor","editorParams","validator","mutator","mutatorParams","mutatorData","mutatorDataParams","mutatorEdit","mutatorEditParams","mutatorClipboard","mutatorClipboardParams","accessor","accessorParams","accessorData","accessorDataParams","accessorDownload","accessorDownloadParams","accessorClipboard","accessorClipboardParams","accessorPrint","accessorPrintParams","accessorHtmlOutput","accessorHtmlOutputParams","clipboard","download","downloadTitle","topCalc","topCalcParams","topCalcFormatter","topCalcFormatterParams","bottomCalc","bottomCalcParams","bottomCalcFormatter","bottomCalcFormatterParams","cellClick","cellDblClick","cellContext","cellTap","cellDblTap","cellTapHold","cellMouseEnter","cellMouseLeave","cellMouseOver","cellMouseOut","cellMouseMove","cellEditing","cellEdited","cellEditCancelled","headerSort","headerSortStartingDir","headerSortTristate","headerClick","headerDblClick","headerContext","headerTap","headerDblTap","headerTapHold","headerTooltip","headerVertical","headerHozAlign","editableTitle","titleFormatter","titleFormatterParams","headerFilter","hea
|
||
|
this.redrawBlockRestoreConfig?(this.refreshActiveData(this.redrawBlockRestoreConfig.stage,this.redrawBlockRestoreConfig.skipStage,this.redrawBlockRestoreConfig.renderInPosition),this.redrawBlockRestoreConfig=!1):this.redrawBlockRederInPosition&&this.reRenderInPosition(),this.redrawBlockRederInPosition=!1},s.prototype.redraw=function(e){var t=this.scrollLeft;this.adjustTableSize(),this.table.tableWidth=this.table.element.clientWidth,e?this.renderTable():("classic"==this.renderMode?this.table.options.groupBy?this.refreshActiveData("group",!1,!1):this._simpleRender():(this.reRenderInPosition(),this.scrollHorizontal(t)),this.displayRowsCount||this.table.options.placeholder&&this.getElement().appendChild(this.table.options.placeholder))},s.prototype.resetScroll=function(){if(this.element.scrollLeft=0,this.element.scrollTop=0,"ie"===this.table.browser){var e=document.createEvent("Event");e.initEvent("scroll",!1,!0),this.element.dispatchEvent(e)}else this.element.dispatchEvent(new Event("scroll"))};var a=function(e){this.table=e,this.element=this.table.rowManager.tableElement,this.holderEl=this.table.rowManager.element,this.leftCol=0,this.rightCol=0,this.scrollLeft=0,this.vDomScrollPosLeft=0,this.vDomScrollPosRight=0,this.vDomPadLeft=0,this.vDomPadRight=0,this.fitDataColAvg=0,this.window=200,this.initialized=!1,this.columns=[],this.compatabilityCheck()&&this.initialize()};a.prototype.compatabilityCheck=function(){var e=this.table.options,t=!0;return"fitDataTable"==e.layout&&(console.warn("Horizontal Vitrual DOM is not compatible with fitDataTable layout mode"),t=!1),e.responsiveLayout&&(console.warn("Horizontal Vitrual DOM is not compatible with responsive columns"),t=!1),this.table.rtl&&(console.warn("Horizontal Vitrual DOM is not currently compatible with RTL text direction"),t=!1),e.columns&&e.columns.find(function(e){return e.frozen})&&(console.warn("Horizontal Vitrual DOM is not compatible with frozen columns"),t=!1),t||(e.virtualDomHoz=!1),t},a.prototype.initialize=function(){var e=this;this.holderEl.addEventListener("scroll",function(){var t=e.holderEl.scrollLeft;e.scrollLeft!=t&&(e.scrollLeft=t,e.scroll(t-(e.vDomScrollPosLeft+e.window)))})},a.prototype.deinitialize=function(){this.initialized=!1},a.prototype.clear=function(){this.columns=[],this.leftCol=-1,this.rightCol=0,this.vDomScrollPosLeft=0,this.vDomScrollPosRight=0,this.vDomPadLeft=0,this.vDomPadRight=0},a.prototype.dataChange=function(){var e,t,o,i=!1,n=0,s=0;if("fitData"===this.table.options.layout){if(this.table.columnManager.columnsByIndex.forEach(function(e){!e.definition.width&&e.visible&&(i=!0)}),i&&i&&this.table.rowManager.getDisplayRows().length&&(this.vDomScrollPosRight=this.scrollLeft+this.holderEl.clientWidth+this.window,this.table.options.groupBy?(e=this.table.modules.groupRows.getGroups(!1)[0],t=e.getRows(!1)[0]):t=this.table.rowManager.getDisplayRows()[0],t)){o=t.getElement(),t.generateCells(),this.element.appendChild(o);for(var s=0;s<t.cells.length;s++){var a=t.cells[s];if(o.appendChild(a.getElement()),a.column.reinitializeWidth(),(n+=a.column.getWidth())>this.vDomScrollPosRight)break}for(o.parentNode.removeChild(o),this.fitDataColAvg=Math.floor(n/(s+1)),s;s<this.table.columnManager.columnsByIndex.length;s++)this.table.columnManager.columnsByIndex[s].setWidth(this.fitDataColAvg);this.reinitialize(!1,!0)}}else"fitColumns"===this.table.options.layout&&(this.table.modules.layout.layout(),this.table.vdomHoz.reinitialize(!1,!0))},a.prototype.fitDataLayoutOverride=function(){for(var e=this.leftCol;e<=this.rightCol;e++)this.columns[e].reinitializeWidth()},a.prototype.reinitialize=function(e,t){var o=this,i={cols:this.columns,leftCol:this.leftCol,rightCol:this.rightCol};if(!e||this.initialized){this.clear(),this.scrollLeft=this.holderEl.scrollLeft,this.vDomScrollPosLeft=this.scrollLeft-this.window,this.vDomScrollPosRight=this.scrollLeft+this.holderEl.clientWidth+this.window;var n=0;this.table.columnManager.columnsByIndex.forEach(function(e){var t={};if(e.visible){var i=e.getWidth();t.leftPos=n,t.rightPos=n+i,n+i>o.vDomScrollPosLeft&&n<o.vDomScrollPosRigh
|
||
|
this.table.options.resizableColumns&&this.table.modExists("resizeColumns")&&"row"===this.row.type&&this.table.modules.resizeColumns.initializeColumn("cell",this.column,this.element),(this.column.definition.contextMenu||this.column.definition.clickMenu)&&this.table.modExists("menu")&&this.table.modules.menu.initializeCell(this),this.table.modExists("frozenColumns")&&this.table.modules.frozenColumns.layoutElement(this.element,this.column)},u.prototype.setWidth=function(){this.width=this.column.width,this.element.style.width=this.column.widthStyled},u.prototype.clearWidth=function(){this.width="",this.element.style.width=""},u.prototype.getWidth=function(){return this.width||this.element.offsetWidth},u.prototype.setMinWidth=function(){this.minWidth=this.column.minWidth,this.element.style.minWidth=this.column.minWidthStyled},u.prototype.checkHeight=function(){this.row.reinitializeHeight()},u.prototype.clearHeight=function(){this.element.style.height="",this.height=null},u.prototype.setHeight=function(){this.height=this.row.height,this.element.style.height=this.row.heightStyled},u.prototype.getHeight=function(){return this.height||this.element.offsetHeight},u.prototype.show=function(){this.element.style.display=""},u.prototype.hide=function(){this.element.style.display="none"},u.prototype.edit=function(e){if(this.table.modExists("edit",!0))return this.table.modules.edit.editCell(this,e)},u.prototype.cancelEdit=function(){if(this.table.modExists("edit",!0)){var e=this.table.modules.edit.getCurrentCell();e&&e._getSelf()===this?this.table.modules.edit.cancelEdit():console.warn("Cancel Editor Error - This cell is not currently being edited ")}},u.prototype.validate=function(){if(this.column.modules.validate&&this.table.modExists("validate",!0)){return!0===this.table.modules.validate.validate(this.column.modules.validate,this,this.getValue())}return!0},u.prototype.delete=function(){!this.table.rowManager.redrawBlock&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.modules.validate&&this.modules.validate.invalid&&this.table.modules.validate.clearValidation(this),this.modules.edit&&this.modules.edit.edited&&this.table.modules.edit.clearEdited(this),this.table.options.history&&this.table.modules.history.clearComponentHistory(this),this.element=!1,this.column.deleteCell(this),this.row.deleteCell(this),this.calcs={}},u.prototype.nav=function(){var e=this,t=!1,o=this.row.getCellIndex(this);return{next:function(){var t,o=this.right();return!!o||!(!(t=e.table.rowManager.nextDisplayRow(e.row,!0))||!(o=t.findNextEditableCell(-1)))&&(o.edit(),!0)},prev:function(){var t,o=this.left();return!!o||!(!(t=e.table.rowManager.prevDisplayRow(e.row,!0))||!(o=t.findPrevEditableCell(t.cells.length)))&&(o.edit(),!0)},left:function(){return!!(t=e.row.findPrevEditableCell(o))&&(t.edit(),!0)},right:function(){return!!(t=e.row.findNextEditableCell(o))&&(t.edit(),!0)},up:function(){var t=e.table.rowManager.prevDisplayRow(e.row,!0);t&&t.cells[o].edit()},down:function(){var t=e.table.rowManager.nextDisplayRow(e.row,!0);t&&t.cells[o].edit()}}},u.prototype.getIndex=function(){this.row.getCellIndex(this)},u.prototype.getComponent=function(){return this.component||(this.component=new c(this)),this.component};var d=function(e){this.table=e,this.active=!1,this.element=this.createElement(),this.external=!1,this.links=[],this._initialize()};d.prototype.createElement=function(){var e=document.createElement("div");return e.classList.add("tabulator-footer"),e},d.prototype._initialize=function(e){if(this.table.options.footerElement)switch(_typeof(this.table.options.footerElement)){case"string":"<"===this.table.options.footerElement[0]?this.element.innerHTML=this.table.options.footerElement:(this.external=!0,this.element=document.querySelector(this.table.options.footerElement));break;default:this.element=this.table.options.footerElement}},d.prototype.getElement=function(){return this.element},d.prototype.append=function(e,t){this.activate(t),this.element.appendChild(e),this.table.rowManager.adjustTableSize()},d.prototype.prepend=function(e,t
|
||
|
this.rowManager.redraw()):console.warn("setHeight function is not available in classic render mode")},h.prototype.setSort=function(e,t){this.modExists("sort",!0)&&(this.modules.sort.setSort(e,t),this.rowManager.sorterRefresh())},h.prototype.getSorters=function(){if(this.modExists("sort",!0))return this.modules.sort.getSort()},h.prototype.clearSort=function(){this.modExists("sort",!0)&&(this.modules.sort.clear(),this.rowManager.sorterRefresh())},h.prototype.setFilter=function(e,t,o,i){this.modExists("filter",!0)&&(this.modules.filter.setFilter(e,t,o,i),this.rowManager.filterRefresh())},h.prototype.addFilter=function(e,t,o,i){this.modExists("filter",!0)&&(this.modules.filter.addFilter(e,t,o,i),this.rowManager.filterRefresh())},h.prototype.getFilters=function(e){if(this.modExists("filter",!0))return this.modules.filter.getFilters(e)},h.prototype.setHeaderFilterFocus=function(e){if(this.modExists("filter",!0)){var t=this.columnManager.findColumn(e);if(!t)return console.warn("Column Filter Focus Error - No matching column found:",e),!1;this.modules.filter.setHeaderFilterFocus(t)}},h.prototype.getHeaderFilterValue=function(e){if(this.modExists("filter",!0)){var t=this.columnManager.findColumn(e);if(t)return this.modules.filter.getHeaderFilterValue(t);console.warn("Column Filter Error - No matching column found:",e)}},h.prototype.setHeaderFilterValue=function(e,t){if(this.modExists("filter",!0)){var o=this.columnManager.findColumn(e);if(!o)return console.warn("Column Filter Error - No matching column found:",e),!1;this.modules.filter.setHeaderFilterValue(o,t)}},h.prototype.getHeaderFilters=function(){if(this.modExists("filter",!0))return this.modules.filter.getHeaderFilters()},h.prototype.removeFilter=function(e,t,o){this.modExists("filter",!0)&&(this.modules.filter.removeFilter(e,t,o),this.rowManager.filterRefresh())},h.prototype.clearFilter=function(e){this.modExists("filter",!0)&&(this.modules.filter.clearFilter(e),this.rowManager.filterRefresh())},h.prototype.clearHeaderFilter=function(){this.modExists("filter",!0)&&(this.modules.filter.clearHeaderFilter(),this.rowManager.filterRefresh())},h.prototype.selectRow=function(e){this.modExists("selectRow",!0)&&(!0===e&&(console.warn("passing a boolean to the selectRowselectRow function is deprecated, you should now pass the string 'active'"),e="active"),this.modules.selectRow.selectRows(e))},h.prototype.deselectRow=function(e){this.modExists("selectRow",!0)&&this.modules.selectRow.deselectRows(e)},h.prototype.toggleSelectRow=function(e){this.modExists("selectRow",!0)&&this.modules.selectRow.toggleRow(e)},h.prototype.getSelectedRows=function(){if(this.modExists("selectRow",!0))return this.modules.selectRow.getSelectedRows()},h.prototype.getSelectedData=function(){if(this.modExists("selectRow",!0))return this.modules.selectRow.getSelectedData()},h.prototype.getInvalidCells=function(){if(this.modExists("validate",!0))return this.modules.validate.getInvalidCells()},h.prototype.clearCellValidation=function(e){var t=this;this.modExists("validate",!0)&&(e||(e=this.modules.validate.getInvalidCells()),Array.isArray(e)||(e=[e]),e.forEach(function(e){t.modules.validate.clearValidation(e._getSelf())}))},h.prototype.validate=function(e){var t=[];return this.rowManager.rows.forEach(function(e){var o=e.validate();!0!==o&&(t=t.concat(o))}),!t.length||t},h.prototype.setMaxPage=function(e){if(!this.options.pagination||!this.modExists("page"))return!1;this.modules.page.setMaxPage(e)},h.prototype.setPage=function(e){return this.options.pagination&&this.modExists("page")?this.modules.page.setPage(e):new Promise(function(e,t){t()})},h.prototype.setPageToRow=function(e){var t=this;return new Promise(function(o,i){t.options.pagination&&t.modExists("page")?(e=t.rowManager.findRow(e),e?t.modules.page.setPageToRow(e).then(function(){o()}).catch(function(){i()}):i()):i()})},h.prototype.setPageSize=function(e){if(!this.options.pagination||!this.modExists("page"))return!1;this.modules.page.setPageSize(e),this.modules.page.setPage(1).then(function(){}).catch(function(){})},h.prototype.getPageSize=function(){i
|
||
|
;var s=new u(i.genColumn,o);s.column=n,s.setWidth(),n.cells.push(s),t.push(s),n.visible||s.hide()}),this.cells=t},o},y.prototype.generateRowData=function(e,t){var o,i,n={},s="top"==e?this.topCalcs:this.botCalcs,a="top"==e?"topCalc":"botCalc";return s.forEach(function(e){var s=[];e.modules.columnCalcs&&e.modules.columnCalcs[a]&&(t.forEach(function(t){s.push(e.getFieldValue(t))}),i=a+"Params",o="function"==typeof e.modules.columnCalcs[i]?e.modules.columnCalcs[i](s,t):e.modules.columnCalcs[i],e.setFieldValue(n,e.modules.columnCalcs[a](s,t,o)))}),n},y.prototype.hasTopCalcs=function(){return!!this.topCalcs.length},y.prototype.hasBottomCalcs=function(){return!!this.botCalcs.length},y.prototype.redraw=function(){this.topRow&&this.topRow.normalizeHeight(!0),this.botRow&&this.botRow.normalizeHeight(!0)},y.prototype.getResults=function(){var e,t=this,o={};return this.table.options.groupBy&&this.table.modExists("groupRows")?(e=this.table.modules.groupRows.getGroups(!0),e.forEach(function(e){o[e.getKey()]=t.getGroupResults(e)})):o={top:this.topRow?this.topRow.getData():{},bottom:this.botRow?this.botRow.getData():{}},o},y.prototype.getGroupResults=function(e){var t=this,o=e._getSelf(),i=e.getSubGroups(),n={};return i.forEach(function(e){n[e.getKey()]=t.getGroupResults(e)}),{top:o.calcs.top?o.calcs.top.getData():{},bottom:o.calcs.bottom?o.calcs.bottom.getData():{},groups:n}},y.prototype.calculations={avg:function(e,t,o){var i=0,n=void 0!==o.precision?o.precision:2;return e.length&&(i=e.reduce(function(e,t){return t=Number(t),e+t}),i/=e.length,i=!1!==n?i.toFixed(n):i),parseFloat(i).toString()},max:function(e,t,o){var i=null,n=void 0!==o.precision&&o.precision;return e.forEach(function(e){((e=Number(e))>i||null===i)&&(i=e)}),null!==i?!1!==n?i.toFixed(n):i:""},min:function(e,t,o){var i=null,n=void 0!==o.precision&&o.precision;return e.forEach(function(e){((e=Number(e))<i||null===i)&&(i=e)}),null!==i?!1!==n?i.toFixed(n):i:""},sum:function(e,t,o){var i=0,n=void 0!==o.precision&&o.precision;return e.length&&e.forEach(function(e){e=Number(e),i+=isNaN(e)?0:Number(e)}),!1!==n?i.toFixed(n):i},concat:function(e,t,o){var i=0;return e.length&&(i=e.reduce(function(e,t){return String(e)+String(t)})),i},count:function(e,t,o){var i=0;return e.length&&e.forEach(function(e){e&&i++}),i}},h.prototype.registerModule("columnCalcs",y);var w=function(e){this.table=e,this.mode=!0,this.pasteParser=function(){},this.pasteAction=function(){},this.customSelection=!1,this.rowRange=!1,this.blocked=!0};w.prototype.initialize=function(){var e=this;this.mode=this.table.options.clipboard,this.rowRange=this.table.options.clipboardCopyRowRange,!0!==this.mode&&"copy"!==this.mode||this.table.element.addEventListener("copy",function(t){var o,i,n;if(!e.blocked){if(t.preventDefault(),e.customSelection)o=e.customSelection,e.table.options.clipboardCopyFormatter&&(o=e.table.options.clipboardCopyFormatter("plain",o));else{var n=e.table.modules.export.generateExportList(e.rowRange,e.table.options.clipboardCopyStyled,e.table.options.clipboardCopyConfig,"clipboard");i=e.table.modules.export.genereateHTMLTable(n),o=i?e.generatePlainContent(n):"",e.table.options.clipboardCopyFormatter&&(o=e.table.options.clipboardCopyFormatter("plain",o),i=e.table.options.clipboardCopyFormatter("html",i))}window.clipboardData&&window.clipboardData.setData?window.clipboardData.setData("Text",o):t.clipboardData&&t.clipboardData.setData?(t.clipboardData.setData("text/plain",o),i&&t.clipboardData.setData("text/html",i)):t.originalEvent&&t.originalEvent.clipboardData.setData&&(t.originalEvent.clipboardData.setData("text/plain",o),i&&t.originalEvent.clipboardData.setData("text/html",i)),e.table.options.clipboardCopied.call(e.table,o,i),e.reset()}}),!0!==this.mode&&"paste"!==this.mode||this.table.element.addEventListener("paste",function(t){e.paste(t)}),this.setPasteParser(this.table.options.clipboardPasteParser),this.setPasteAction(this.table.options.clipboardPasteAction)},w.prototype.reset=function(){this.blocked=!1,this.originalSelectionText=""},w.prototype.generatePlainContent=function(e){var t=[];return
|
||
|
void 0!==n.max&&r.setAttribute("max",n.max),void 0!==n.min&&r.setAttribute("min",n.min),void 0!==n.step&&r.setAttribute("step",n.step),r.style.padding="4px",r.style.width="100%",r.style.boxSizing="border-box",n.elementAttributes&&"object"==_typeof(n.elementAttributes))for(var l in n.elementAttributes)"+"==l.charAt(0)?(l=l.slice(1),r.setAttribute(l,r.getAttribute(l)+n.elementAttributes["+"+l])):r.setAttribute(l,n.elementAttributes[l]);return r.value=a,t(function(){r.focus({preventScroll:!0}),r.style.height="100%"}),r.addEventListener("blur",function(e){s()}),r.addEventListener("keydown",function(e){switch(e.keyCode){case 13:s();break;case 27:i()}}),r},select:function(e,t,o,i,n){function s(t){var o,i={},s=C.table.getData();return o=t?C.table.columnManager.getColumnByField(t):e.getColumn()._getSelf(),o?(s.forEach(function(e){var t=o.getFieldValue(e);null!==t&&void 0!==t&&""!==t&&(i[t]=!0)}),i=n.sortValuesList?"asc"==n.sortValuesList?Object.keys(i).sort():Object.keys(i).sort().reverse():Object.keys(i)):console.warn("unable to find matching column to create select lookup list:",t),i}function a(t,o){function i(e){var e={label:e.label,value:e.value,itemParams:e.itemParams,elementAttributes:e.elementAttributes,element:!1};return o.indexOf(e.value)>-1&&c(e),n.push(e),s.push(e),e}var n=[],s=[];if("function"==typeof t&&(t=t(e)),Array.isArray(t))t.forEach(function(e){var t;"object"===(void 0===e?"undefined":_typeof(e))?e.options?(t={label:e.label,group:!0,itemParams:e.itemParams,elementAttributes:e.elementAttributes,element:!1},s.push(t),e.options.forEach(function(e){i(e)})):i(e):(t={label:e,value:e,element:!1},o.indexOf(t.value)>-1&&c(t),n.push(t),s.push(t))});else for(var a in t){var l={label:t[a],value:a,element:!1};o.indexOf(l.value)>-1&&c(l),n.push(l),s.push(l)}z=n,H=s,r()}function r(){for(;D.firstChild;)D.removeChild(D.firstChild);H.forEach(function(t){var o=t.element;if(!o){if(o=document.createElement("div"),t.label=n.listItemFormatter?n.listItemFormatter(t.value,t.label,e,o,t.itemParams):t.label,t.group?(o.classList.add("tabulator-edit-select-list-group"),o.tabIndex=0,o.innerHTML=""===t.label?" ":t.label):(o.classList.add("tabulator-edit-select-list-item"),o.tabIndex=0,o.innerHTML=""===t.label?" ":t.label,o.addEventListener("click",function(){_=!0,setTimeout(function(){_=!1},10),k?(d(t),T.focus()):p(t)}),P.indexOf(t)>-1&&o.classList.add("active")),t.elementAttributes&&"object"==_typeof(t.elementAttributes))for(var i in t.elementAttributes)"+"==i.charAt(0)?(i=i.slice(1),o.setAttribute(i,T.getAttribute(i)+t.elementAttributes["+"+i])):o.setAttribute(i,t.elementAttributes[i]);o.addEventListener("mousedown",function(){A=!1,setTimeout(function(){A=!0},10)}),t.element=o}D.appendChild(o)})}function l(e,t){!k&&S&&S.element&&S.element.classList.remove("active"),S&&S.element&&S.element.classList.remove("focused"),S=e,e.element&&(e.element.classList.add("focused"),t&&e.element.classList.add("active"))}function c(e){-1==P.indexOf(e)&&(P.push(e),l(e,!0)),f()}function u(e){var t=P[e];e>-1&&(P.splice(e,1),t.element&&t.element.classList.remove("active"))}function d(e){e||(e=S);var t=P.indexOf(e);t>-1?u(t):(!0!==k&&P.length>=k&&u(0),c(e)),f()}function p(e){y(),e||(e=S),e&&(T.value=e.label,o(e.value)),L=T.value}function m(e){e||y();var t=[];P.forEach(function(e){t.push(e.value)}),L=T.value,o(t)}function f(){var e=[];P.forEach(function(t){e.push(t.label)}),T.value=e.join(", "),!1===C.currentCell&&m(!0)}function g(){for(var e=P.length,t=0;t<e;t++)u(0)}function b(){y(),i()}function v(){if(P=[],!D.parentNode){!0===n.values?a(s(),L):"string"==typeof n.values?a(s(n.values),L):a(n.values||[],L);var e=h.prototype.helpers.elOffset(x);D.style.minWidth=x.offsetWidth+"px",D.style.top=e.top+x.offsetHeight+"px",D.style.left=e.left+"px",D.addEventListener("mousedown",function(e){A=!1,setTimeout(function(){A=!0},10)}),document.body.appendChild(D)}}function y(){D.parentNode&&D.parentNode.removeChild(D),w()}function w(){C.table.rowManager.element.removeEventListener("scroll",b)}var E=this,C=this,x=e.getElement(),R=e.getValue(),M=n.verticalNavigation|
|
||
|
c=function(e){l&&clearTimeout(l),l=setTimeout(function(){p(a.value)},h.table.options.headerFilterLiveFilterDelay)},e.modules.filter.headerElement=a,e.modules.filter.attrType=a.hasAttribute("type")?a.getAttribute("type").toLowerCase():"",e.modules.filter.tagType=a.tagName.toLowerCase(),!1!==e.definition.headerFilterLiveFilter&&("autocomplete"!==e.definition.headerFilter&&"tickCross"!==e.definition.headerFilter&&("autocomplete"!==e.definition.editor&&"tickCross"!==e.definition.editor||!0!==e.definition.headerFilter)&&(a.addEventListener("keyup",c),a.addEventListener("search",c),"number"==e.modules.filter.attrType&&a.addEventListener("change",function(e){p(a.value)}),"text"==e.modules.filter.attrType&&"ie"!==this.table.browser&&a.setAttribute("type","search")),"input"!=e.modules.filter.tagType&&"select"!=e.modules.filter.tagType&&"textarea"!=e.modules.filter.tagType||a.addEventListener("mousedown",function(e){e.stopPropagation()})),n.appendChild(a),e.contentElement.appendChild(n),o||h.headerFilterColumns.push(e)}}else console.warn("Filter Error - Cannot add header filter, column has no field set:",e.definition.title)},T.prototype.hideHeaderFilterElements=function(){this.headerFilterColumns.forEach(function(e){e.modules.filter&&e.modules.filter.headerElement&&(e.modules.filter.headerElement.style.display="none")})},T.prototype.showHeaderFilterElements=function(){this.headerFilterColumns.forEach(function(e){e.modules.filter&&e.modules.filter.headerElement&&(e.modules.filter.headerElement.style.display="")})},T.prototype.setHeaderFilterFocus=function(e){e.modules.filter&&e.modules.filter.headerElement?e.modules.filter.headerElement.focus():console.warn("Column Filter Focus Error - No header filter set on column:",e.getField())},T.prototype.getHeaderFilterValue=function(e){if(e.modules.filter&&e.modules.filter.headerElement)return e.modules.filter.headerElement.value;console.warn("Column Filter Error - No header filter set on column:",e.getField())},T.prototype.setHeaderFilterValue=function(e,t){e&&(e.modules.filter&&e.modules.filter.headerElement?(this.generateHeaderFilterElement(e,t,!0),e.modules.filter.success(t)):console.warn("Column Filter Error - No header filter set on column:",e.getField()))},T.prototype.reloadHeaderFilter=function(e){e&&(e.modules.filter&&e.modules.filter.headerElement?this.generateHeaderFilterElement(e,e.modules.filter.value,!0):console.warn("Column Filter Error - No header filter set on column:",e.getField()))},T.prototype.hasChanged=function(){var e=this.changed;return this.changed=!1,e},T.prototype.setFilter=function(e,t,o,i){var n=this;n.filterList=[],Array.isArray(e)||(e=[{field:e,type:t,value:o,params:i}]),n.addFilter(e)},T.prototype.addFilter=function(e,t,o,i){var n=this;Array.isArray(e)||(e=[{field:e,type:t,value:o,params:i}]),e.forEach(function(e){(e=n.findFilter(e))&&(n.filterList.push(e),n.changed=!0)}),this.table.options.persistence&&this.table.modExists("persistence",!0)&&this.table.modules.persistence.config.filter&&this.table.modules.persistence.save("filter")},T.prototype.findFilter=function(e){var t,o=this;if(Array.isArray(e))return this.findSubFilters(e);var i=!1;return"function"==typeof e.field?i=function(t){return e.field(t,e.type||{})}:o.filters[e.type]?(t=o.table.columnManager.getColumnByField(e.field),i=t?function(i){return o.filters[e.type](e.value,t.getFieldValue(i),i,e.params||{})}:function(t){return o.filters[e.type](e.value,t[e.field],t,e.params||{})}):console.warn("Filter Error - No such filter type found, ignoring: ",e.type),e.func=i,!!e.func&&e},T.prototype.findSubFilters=function(e){var t=this,o=[];return e.forEach(function(e){(e=t.findFilter(e))&&o.push(e)}),!!o.length&&o},T.prototype.getFilters=function(e,t){var o=[];return e&&(o=this.getHeaderFilters()),t&&o.forEach(function(e){"function"==typeof e.type&&(e.type="function")}),o=o.concat(this.filtersToArray(this.filterList,t))},T.prototype.filtersToArray=function(e,t){var o=this,i=[];return e.forEach(function(e){var n;Array.isArray(e)?i.push(o.filtersToArray(e,t)):(n={field:e.field,type:e.type,value:e.value},t&&"func
|
||
|
;this.groupManager.allowedValues&&this.groupManager.allowedValues[t]?this.groups[i]&&this.groups[i].addRow(e):(this.groups[i]||this._createGroup(o,t),this.groups[i].addRow(e))}},H.prototype._addRow=function(e){this.rows.push(e),e.modules.group=this},H.prototype.insertRow=function(e,t,o){var i=this.conformRowData({});e.updateData(i);var n=this.rows.indexOf(t);n>-1?o?this.rows.splice(n+1,0,e):this.rows.splice(n,0,e):o?this.rows.push(e):this.rows.unshift(e),e.modules.group=this,this.generateGroupHeaderContents(),this.groupManager.table.modExists("columnCalcs")&&"table"!=this.groupManager.table.options.columnCalcs&&this.groupManager.table.modules.columnCalcs.recalcGroup(this),this.groupManager.updateGroupRows(!0)},H.prototype.scrollHeader=function(e){this.arrowElement.style.marginLeft=e,this.groupList.forEach(function(t){t.scrollHeader(e)})},H.prototype.getRowIndex=function(e){},H.prototype.conformRowData=function(e){return this.field?e[this.field]=this.key:console.warn("Data Conforming Error - Cannot conform row data to match new group as groupBy is a function"),this.parent&&(e=this.parent.conformRowData(e)),e},H.prototype.removeRow=function(e){var t=this.rows.indexOf(e),o=e.getElement();t>-1&&this.rows.splice(t,1),this.groupManager.table.options.groupValues||this.rows.length?(o.parentNode&&o.parentNode.removeChild(o),this.generateGroupHeaderContents(),this.groupManager.table.modExists("columnCalcs")&&"table"!=this.groupManager.table.options.columnCalcs&&this.groupManager.table.modules.columnCalcs.recalcGroup(this)):(this.parent?this.parent.removeGroup(this):this.groupManager.removeGroup(this),this.groupManager.updateGroupRows(!0))},H.prototype.removeGroup=function(e){var t,o=e.level+"_"+e.key;this.groups[o]&&(delete this.groups[o],t=this.groupList.indexOf(e),t>-1&&this.groupList.splice(t,1),this.groupList.length||(this.parent?this.parent.removeGroup(this):this.groupManager.removeGroup(this)))},H.prototype.getHeadersAndRows=function(e){var t=[];return t.push(this),this._visSet(),this.visible?this.groupList.length?this.groupList.forEach(function(o){t=t.concat(o.getHeadersAndRows(e))}):(!e&&"table"!=this.groupManager.table.options.columnCalcs&&this.groupManager.table.modExists("columnCalcs")&&this.groupManager.table.modules.columnCalcs.hasTopCalcs()&&(this.calcs.top&&(this.calcs.top.detachElement(),this.calcs.top.deleteCells()),this.calcs.top=this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows),t.push(this.calcs.top)),t=t.concat(this.rows),!e&&"table"!=this.groupManager.table.options.columnCalcs&&this.groupManager.table.modExists("columnCalcs")&&this.groupManager.table.modules.columnCalcs.hasBottomCalcs()&&(this.calcs.bottom&&(this.calcs.bottom.detachElement(),this.calcs.bottom.deleteCells()),this.calcs.bottom=this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows),t.push(this.calcs.bottom))):this.groupList.length||"table"==this.groupManager.table.options.columnCalcs||this.groupManager.table.modExists("columnCalcs")&&(!e&&this.groupManager.table.modules.columnCalcs.hasTopCalcs()&&(this.calcs.top&&(this.calcs.top.detachElement(),this.calcs.top.deleteCells()),this.groupManager.table.options.groupClosedShowCalcs&&(this.calcs.top=this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows),t.push(this.calcs.top))),!e&&this.groupManager.table.modules.columnCalcs.hasBottomCalcs()&&(this.calcs.bottom&&(this.calcs.bottom.detachElement(),this.calcs.bottom.deleteCells()),this.groupManager.table.options.groupClosedShowCalcs&&(this.calcs.bottom=this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows),t.push(this.calcs.bottom)))),t},H.prototype.getData=function(e,t){var o=[];return this._visSet(),(!e||e&&this.visible)&&this.rows.forEach(function(e){o.push(e.getData(t||"data"))}),o},H.prototype.getRowCount=function(){var e=0;return this.groupList.length?this.groupList.forEach(function(t){e+=t.getRowCount()}):e=this.rows.length,e},H.prototype.toggleVisibility=function(){this.visible?this.hide():this.show()},H.prototype.hide=function(){this.visible=!1,"classic"!=this.groupManager.ta
|
||
|
var t,o=this,i=o.table.columnManager.getElement(),n=i.scrollLeft,s=(o.touchMove?e.touches[0].pageX:e.pageX)-h.prototype.helpers.elOffset(i).left+n;o.hoverElement.style.left=s-o.startX+"px",s-n<o.autoScrollMargin&&(o.autoScrollTimeout||(o.autoScrollTimeout=setTimeout(function(){t=Math.max(0,n-5),o.table.rowManager.getElement().scrollLeft=t,o.autoScrollTimeout=!1},1))),n+i.clientWidth-s<o.autoScrollMargin&&(o.autoScrollTimeout||(o.autoScrollTimeout=setTimeout(function(){t=Math.min(i.clientWidth,n+5),o.table.rowManager.getElement().scrollLeft=t,o.autoScrollTimeout=!1},1)))},h.prototype.registerModule("moveColumn",B);var O=function(e){this.table=e,this.placeholderElement=this.createPlaceholderElement(),this.hoverElement=!1,this.checkTimeout=!1,this.checkPeriod=150,this.moving=!1,this.toRow=!1,this.toRowAfter=!1,this.hasHandle=!1,this.startY=0,this.startX=0,this.moveHover=this.moveHover.bind(this),this.endMove=this.endMove.bind(this),this.tableRowDropEvent=!1,this.touchMove=!1,this.connection=!1,this.connectionSelectorsTables=!1,this.connectionSelectorsElements=!1,this.connectionElements=[],this.connections=[],this.connectedTable=!1,this.connectedRow=!1};O.prototype.createPlaceholderElement=function(){var e=document.createElement("div");return e.classList.add("tabulator-row"),e.classList.add("tabulator-row-placeholder"),e},O.prototype.initialize=function(e){this.connectionSelectorsTables=this.table.options.movableRowsConnectedTables,this.connectionSelectorsElements=this.table.options.movableRowsConnectedElements,this.connection=this.connectionSelectorsTables||this.connectionSelectorsElements},O.prototype.setHandle=function(e){this.hasHandle=e},O.prototype.initializeGroupHeader=function(e){var t=this,o={};o.mouseup=function(e){t.tableRowDrop(e,row)}.bind(t),o.mousemove=function(o){if(o.pageY-h.prototype.helpers.elOffset(e.element).top+t.table.rowManager.element.scrollTop>e.getHeight()/2){if(t.toRow!==e||!t.toRowAfter){var i=e.getElement();i.parentNode.insertBefore(t.placeholderElement,i.nextSibling),t.moveRow(e,!0)}}else if(t.toRow!==e||t.toRowAfter){var i=e.getElement();i.previousSibling&&(i.parentNode.insertBefore(t.placeholderElement,i),t.moveRow(e,!1))}}.bind(t),e.modules.moveRow=o},O.prototype.initializeRow=function(e){var t,o=this,i={};i.mouseup=function(t){o.tableRowDrop(t,e)}.bind(o),i.mousemove=function(t){if(t.pageY-h.prototype.helpers.elOffset(e.element).top+o.table.rowManager.element.scrollTop>e.getHeight()/2){if(o.toRow!==e||!o.toRowAfter){var i=e.getElement();i.parentNode.insertBefore(o.placeholderElement,i.nextSibling),o.moveRow(e,!0)}}else if(o.toRow!==e||o.toRowAfter){var i=e.getElement();i.parentNode.insertBefore(o.placeholderElement,i),o.moveRow(e,!1)}}.bind(o),this.hasHandle||(t=e.getElement(),t.addEventListener("mousedown",function(t){1===t.which&&(o.checkTimeout=setTimeout(function(){o.startMove(t,e)},o.checkPeriod))}),t.addEventListener("mouseup",function(e){1===e.which&&o.checkTimeout&&clearTimeout(o.checkTimeout)}),this.bindTouchEvents(e,e.getElement())),e.modules.moveRow=i},O.prototype.initializeCell=function(e){var t=this,o=e.getElement();o.addEventListener("mousedown",function(o){1===o.which&&(t.checkTimeout=setTimeout(function(){t.startMove(o,e.row)},t.checkPeriod))}),o.addEventListener("mouseup",function(e){1===e.which&&t.checkTimeout&&clearTimeout(t.checkTimeout)}),this.bindTouchEvents(e.row,e.getElement())},O.prototype.bindTouchEvents=function(e,t){var o,i,n,s,a,r,l,c=this,u=!1;t.addEventListener("touchstart",function(t){c.checkTimeout=setTimeout(function(){c.touchMove=!0,o=e,i=e.nextRow(),s=i?i.getHeight()/2:0,n=e.prevRow(),a=n?n.getHeight()/2:0,r=0,l=0,u=!1,c.startMove(t,e)},c.checkPeriod)},{passive:!0}),this.moving,this.toRow,this.toRowAfter,t.addEventListener("touchmove",function(t){var d,h;c.moving&&(t.preventDefault(),c.moveHover(t),u||(u=t.touches[0].pageY),d=t.touches[0].pageY-u,d>0?i&&d-r>s&&(h=i)!==e&&(u=t.touches[0].pageY,h.getElement().parentNode.insertBefore(c.placeholderElement,h.getElement().nextSibling),c.moveRow(h,!0)):n&&-d-l>a&&(h=n)!==e&&(u=t.touches[0].pageY,h.getElement().
|
||
|
(!0===this.config.page||this.config.page.page)&&(e.paginationInitialPage=this.table.modules.page.getPage())),e},V.prototype.parseColumns=function(e){var t=this,o=[],i=["headerContextMenu","headerMenu","contextMenu","clickMenu"];return e.forEach(function(e){var n,s={},a=e.getDefinition();e.isGroup?(s.title=a.title,s.columns=t.parseColumns(e.getColumns())):(s.field=e.getField(),!0===t.config.columns||void 0==t.config.columns?(n=Object.keys(a),n.push("width")):n=t.config.columns,n.forEach(function(t){switch(t){case"width":s.width=e.getWidth();break;case"visible":s.visible=e.visible;break;default:"function"!=typeof a[t]&&-1===i.indexOf(t)&&(s[t]=a[t])}})),o.push(s)}),o},V.prototype.readers={local:function(e,t){var o=localStorage.getItem(e+"-"+t);return!!o&&JSON.parse(o)},cookie:function(e,t){var o,i,n=document.cookie,s=e+"-"+t,a=n.indexOf(s+"=");return a>-1&&(n=n.substr(a),o=n.indexOf(";"),o>-1&&(n=n.substr(0,o)),i=n.replace(s+"=","")),!!i&&JSON.parse(i)}},V.prototype.writers={local:function(e,t,o){localStorage.setItem(e+"-"+t,JSON.stringify(o))},cookie:function(e,t,o){var i=new Date;i.setDate(i.getDate()+1e4),document.cookie=e+"-"+t+"="+JSON.stringify(o)+"; expires="+i.toUTCString()}},h.prototype.registerModule("persistence",V);var W=function(e){this.table=e,this.element=!1,this.manualBlock=!1};W.prototype.initialize=function(){window.addEventListener("beforeprint",this.replaceTable.bind(this)),window.addEventListener("afterprint",this.cleanup.bind(this))},W.prototype.replaceTable=function(){this.manualBlock||(this.element=document.createElement("div"),this.element.classList.add("tabulator-print-table"),this.element.appendChild(this.table.modules.export.genereateTable(this.table.options.printConfig,this.table.options.printStyled,this.table.options.printRowRange,"print")),this.table.element.style.display="none",this.table.element.parentNode.insertBefore(this.element,this.table.element))},W.prototype.cleanup=function(){document.body.classList.remove("tabulator-print-fullscreen-hide"),this.element&&this.element.parentNode&&(this.element.parentNode.removeChild(this.element),this.table.element.style.display="")},W.prototype.printFullscreen=function(e,t,o){var i,n,s=window.scrollX,a=window.scrollY,r=document.createElement("div"),l=document.createElement("div"),c=this.table.modules.export.genereateTable(void 0!==o?o:this.table.options.printConfig,void 0!==t?t:this.table.options.printStyled,e,"print");this.manualBlock=!0,this.element=document.createElement("div"),this.element.classList.add("tabulator-print-fullscreen"),this.table.options.printHeader&&(r.classList.add("tabulator-print-header"),i="function"==typeof this.table.options.printHeader?this.table.options.printHeader.call(this.table):this.table.options.printHeader,"string"==typeof i?r.innerHTML=i:r.appendChild(i),this.element.appendChild(r)),this.element.appendChild(c),this.table.options.printFooter&&(l.classList.add("tabulator-print-footer"),n="function"==typeof this.table.options.printFooter?this.table.options.printFooter.call(this.table):this.table.options.printFooter,"string"==typeof n?l.innerHTML=n:l.appendChild(n),this.element.appendChild(l)),document.body.classList.add("tabulator-print-fullscreen-hide"),document.body.appendChild(this.element),this.table.options.printFormatter&&this.table.options.printFormatter(this.element,c),window.print(),this.cleanup(),window.scrollTo(s,a),this.manualBlock=!1},h.prototype.registerModule("print",W);var G=function(e){this.table=e,this.data=!1,this.blocked=!1,this.origFuncs={},this.currentVersion=0};G.prototype.watchData=function(e){var t,o=this;this.currentVersion++,t=this.currentVersion,o.unwatchData(),o.data=e,o.origFuncs.push=e.push,Object.defineProperty(o.data,"push",{enumerable:!1,configurable:!0,value:function(){var i=Array.from(arguments);return o.blocked||t!==o.currentVersion||i.forEach(function(e){o.table.rowManager.addRowActual(e,!1)}),o.origFuncs.push.apply(e,arguments)}}),o.origFuncs.unshift=e.unshift,Object.defineProperty(o.data,"unshift",{enumerable:!1,configurable:!0,value:function(){var i=Array.from(arguments);return
|
||
|
r===l)return 0;if(!m.test(r)||!m.test(l))return r>l?1:-1;for(r=r.match(p),l=l.match(p),d=r.length>l.length?l.length:r.length;h<d;)if(c=r[h],u=l[h++],c!==u)return isFinite(c)&&isFinite(u)?("0"===c.charAt(0)&&(c="."+c),"0"===u.charAt(0)&&(u="."+u),c-u):c>u?1:-1;return r.length>l.length}g=1}else g=t||0===t?-1:0;return("top"===f&&"desc"===s||"bottom"===f&&"asc"===s)&&(g*=-1),g}},h.prototype.registerModule("sort",J);var $=function(e){this.table=e,this.invalidCells=[]};return $.prototype.initializeColumn=function(e){var t,o=this,i=[];e.definition.validator&&(Array.isArray(e.definition.validator)?e.definition.validator.forEach(function(e){(t=o._extractValidator(e))&&i.push(t)}):(t=this._extractValidator(e.definition.validator))&&i.push(t),e.modules.validate=!!i.length&&i)},$.prototype._extractValidator=function(e){var t,o,i;switch(void 0===e?"undefined":_typeof(e)){case"string":return i=e.indexOf(":"),i>-1?(t=e.substring(0,i),o=e.substring(i+1)):t=e,this._buildValidator(t,o);case"function":return this._buildValidator(e);case"object":return this._buildValidator(e.type,e.parameters)}},$.prototype._buildValidator=function(e,t){var o="function"==typeof e?e:this.validators[e];return o?{type:"function"==typeof e?"function":e,func:o,params:t}:(console.warn("Validator Setup Error - No matching validator found:",e),!1)},$.prototype.validate=function(e,t,o){var i=this,n=[],s=this.invalidCells.indexOf(t);return e&&e.forEach(function(e){e.func.call(i,t.getComponent(),o,e.params)||n.push({type:e.type,parameters:e.params})}),n=!n.length||n,t.modules.validate||(t.modules.validate={}),!0===n?(t.modules.validate.invalid=!1,t.getElement().classList.remove("tabulator-validation-fail"),s>-1&&this.invalidCells.splice(s,1)):(t.modules.validate.invalid=!0,"manual"!==this.table.options.validationMode&&t.getElement().classList.add("tabulator-validation-fail"),-1==s&&this.invalidCells.push(t)),n},$.prototype.getInvalidCells=function(){var e=[];return this.invalidCells.forEach(function(t){e.push(t.getComponent())}),e},$.prototype.clearValidation=function(e){var t;e.modules.validate&&e.modules.validate.invalid&&(e.getElement().classList.remove("tabulator-validation-fail"),e.modules.validate.invalid=!1,(t=this.invalidCells.indexOf(e))>-1&&this.invalidCells.splice(t,1))},$.prototype.validators={integer:function(e,t,o){return""===t||null===t||void 0===t||"number"==typeof(t=Number(t))&&isFinite(t)&&Math.floor(t)===t},float:function(e,t,o){return""===t||null===t||void 0===t||"number"==typeof(t=Number(t))&&isFinite(t)&&t%1!=0},numeric:function(e,t,o){return""===t||null===t||void 0===t||!isNaN(t)},string:function(e,t,o){return""===t||null===t||void 0===t||isNaN(t)},max:function(e,t,o){return""===t||null===t||void 0===t||parseFloat(t)<=o},min:function(e,t,o){return""===t||null===t||void 0===t||parseFloat(t)>=o},starts:function(e,t,o){return""===t||null===t||void 0===t||String(t).toLowerCase().startsWith(String(o).toLowerCase())},ends:function(e,t,o){return""===t||null===t||void 0===t||String(t).toLowerCase().endsWith(String(o).toLowerCase())},minLength:function(e,t,o){return""===t||null===t||void 0===t||String(t).length>=o},maxLength:function(e,t,o){return""===t||null===t||void 0===t||String(t).length<=o},in:function(e,t,o){return""===t||null===t||void 0===t||("string"==typeof o&&(o=o.split("|")),""===t||o.indexOf(t)>-1)},regex:function(e,t,o){return""===t||null===t||void 0===t||new RegExp(o).test(t)},unique:function(e,t,o){if(""===t||null===t||void 0===t)return!0;var i=!0,n=e.getData(),s=e.getColumn()._getSelf();return this.table.rowManager.rows.forEach(function(e){var o=e.getData();o!==n&&t==s.getFieldValue(o)&&(i=!1)}),i},required:function(e,t,o){return""!==t&&null!==t&&void 0!==t}},h.prototype.registerModule("validate",$),h});
|