diff --git a/build/rollup.js b/build/rollup.js index 8e4c5910e..75b4f7a1d 100644 --- a/build/rollup.js +++ b/build/rollup.js @@ -1,5 +1,5 @@ import Bundler from "./Bundler.js"; -var bundler = new Bundler("4.9.3", process.env.TARGET); +var bundler = new Bundler("5.0.0-alpha.0", process.env.TARGET); module.exports = bundler.bundle(); diff --git a/dist/js/tabulator.js b/dist/js/tabulator.js index 14149fb6e..e4eb992c5 100644 --- a/dist/js/tabulator.js +++ b/dist/js/tabulator.js @@ -1,4 +1,4 @@ -/* Tabulator v4.9.3 (c) Oliver Folkerd 2021 */ +/* Tabulator v5.0.0-alpha.0 (c) Oliver Folkerd 2021 */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : @@ -122,6 +122,18 @@ }; } + function _toConsumableArray(arr) { + return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); + } + + function _arrayWithoutHoles(arr) { + if (Array.isArray(arr)) return _arrayLikeToArray(arr); + } + + function _iterableToArray(iter) { + if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); + } + function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); @@ -139,6 +151,10 @@ return arr2; } + function _nonIterableSpread() { + throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); + } + function _createForOfIteratorHelper(o, allowArrayLike) { var it; @@ -197,274 +213,48 @@ } var defaultOptions = { + debugEventsExternal: false, + //flag to console log events + debugEventsInternal: false, + //flag to console log events + debugInvalidOptions: true, + //allow toggling of invalid option warnings height: false, //height of tabulator minHeight: false, //minimum height of tabulator maxHeight: false, //maximum height of tabulator - layout: "fitData", - ///layout type "fitColumns" | "fitData" - layoutColumnsOnNewData: false, - //update column widths on setData - columnMinWidth: 40, - //minimum global width for a column columnMaxWidth: false, //minimum global width for a column columnHeaderVertAlign: "top", //vertical alignment of column headers - resizableColumns: true, - //resizable columns - resizableRows: false, - //resizable rows - autoResize: true, - //auto resize table columns: [], //store for colum header info - columnDefaults: false, + columnDefaults: {}, //store column default props - cellHozAlign: "", - //horizontal align columns - cellVertAlign: "", - //vertical align columns - headerHozAlign: "", - //horizontal header alignment - data: [], + data: false, //default starting data autoColumns: false, //build columns from data row structure autoColumnsDefinitions: false, - reactiveData: false, - //enable data reactivity nestedFieldSeparator: ".", //seperatpr for nested data - tooltips: false, - //Tool tip value - tooltipsHeader: false, - //Tool tip for headers tooltipGenerationMode: "load", //when to generate tooltips - initialSort: false, - //initial sorting criteria - initialFilter: false, - //initial filtering criteria - initialHeaderFilter: false, - //initial header filtering criteria - columnHeaderSortMulti: true, - //multiple or single column sorting - sortOrderReverse: false, - //reverse internal sort ordering - headerSort: true, - //set default global header sort - headerSortTristate: false, - //set default tristate header sorting - headerSortElement: "
", - //header sort element footerElement: false, //hold footer element index: "id", //filed for row index textDirection: "auto", - keybindings: [], - //array for keybindings - tabEndNewRow: false, - //create new row when tab to end of table - invalidOptionWarnings: true, - //allow toggling of invalid option warnings - clipboard: false, - //enable clipboard - clipboardCopyStyled: true, - //formatted table data - clipboardCopyConfig: false, - //clipboard config - clipboardCopyFormatter: false, - //DEPRICATED - REMOVE in 5.0 - clipboardCopyRowRange: "active", - //restrict clipboard to visible rows only - clipboardPasteParser: "table", - //convert pasted clipboard data to rows - clipboardPasteAction: "insert", - //how to insert pasted data into the table - clipboardCopied: function clipboardCopied() {}, - //data has been copied to the clipboard - clipboardPasted: function clipboardPasted() {}, - //data has been pasted into the table - clipboardPasteError: function clipboardPasteError() {}, - //data has not successfully been pasted into the table - downloadReady: function downloadReady(data, blob) { - return blob; - }, - //function to manipulate download data - downloadComplete: false, - //function to manipulate download data - downloadConfig: {}, - //download config - downloadRowRange: "active", - //restrict download to active rows only - dataTree: false, - //enable data tree - dataTreeFilter: true, - //filter child rows - dataTreeSort: true, - //sort child rows - dataTreeElementColumn: false, - dataTreeBranchElement: true, - //show data tree branch element - dataTreeChildIndent: 9, - //data tree child indent in px - dataTreeChildField: "_children", - //data tre column field to look for child rows - dataTreeCollapseElement: false, - //data tree row collapse element - dataTreeExpandElement: false, - //data tree row expand element - dataTreeStartExpanded: false, - dataTreeRowExpanded: function dataTreeRowExpanded() {}, - //row has been expanded - dataTreeRowCollapsed: function dataTreeRowCollapsed() {}, - //row has been collapsed - dataTreeChildColumnCalcs: false, - //include visible data tree rows in column calculations - dataTreeSelectPropagate: false, - //seleccting a parent row selects its children - printAsHtml: false, - //enable print as html - printFormatter: false, - //printing page formatter - printHeader: false, - //page header contents - printFooter: false, - //page footer contents - printStyled: true, - //enable print as html styling - printRowRange: "visible", - //restrict print to visible rows only - printConfig: {}, - //print config options addRowPos: "bottom", //position to insert blank rows, top|bottom - selectable: "highlight", - //highlight rows on hover - selectableRangeMode: "drag", - //highlight rows on hover - selectableRollingSelection: true, - //roll selection once maximum number of selectable rows is reached - selectablePersistence: true, - // maintain selection when table view is updated - selectableCheck: function selectableCheck(data, row) { - return true; - }, - //check wheather row is selectable - headerFilterLiveFilterDelay: 300, - //delay before updating column after user types in header filter - headerFilterPlaceholder: false, - //placeholder text to display in header filters headerVisible: true, //hide header - history: false, - //enable edit history - locale: false, - //current system language - langs: {}, - virtualDom: true, - //enable DOM virtualization - virtualDomBuffer: 0, + renderVertical: "virtual", + renderHorizontal: "basic", + renderVerticalBuffer: 0, // set virtual DOM buffer size - virtualDomHoz: false, - //enable horizontal DOM virtualization - persistence: false, - persistenceID: "", - //key for persistent storage - persistenceMode: true, - //mode for storing persistence information - persistenceReaderFunc: false, - //function for handling persistence data reading - persistenceWriterFunc: false, - //function for handling persistence data writing - responsiveLayout: false, - //responsive layout flags - responsiveLayoutCollapseStartOpen: true, - //start showing collapsed data - responsiveLayoutCollapseUseFormatters: true, - //responsive layout collapse formatter - responsiveLayoutCollapseFormatter: false, - //responsive layout collapse formatter - pagination: false, - //set pagination type - paginationSize: false, - //set number of rows to a page - paginationInitialPage: 1, - //initail page to show on load - paginationButtonCount: 5, - // set count of page button - paginationSizeSelector: false, - //add pagination size selector element - paginationElement: false, - //element to hold pagination numbers - paginationDataSent: {}, - //pagination data sent to the server - paginationDataReceived: {}, - //pagination data received from the server - paginationAddRow: "page", - //add rows on table or page - ajaxURL: false, - //url for ajax loading - ajaxURLGenerator: false, - ajaxParams: {}, - //params for ajax loading - ajaxConfig: "get", - //ajax request type - ajaxContentType: "form", - //ajax request type - ajaxRequestFunc: false, - //promise function - ajaxLoader: true, - //show loader - ajaxLoaderLoading: false, - //loader element - ajaxLoaderError: false, - //loader element - ajaxFiltering: false, - ajaxSorting: false, - ajaxProgressiveLoad: false, - //progressive loading - ajaxProgressiveLoadDelay: 0, - //delay between requests - ajaxProgressiveLoadScrollMargin: 0, - //margin before scroll begins - groupBy: false, - //enable table grouping and set field to group by - groupStartOpen: true, - //starting state of group - groupValues: false, - groupUpdateOnCellEdit: false, - groupHeader: false, - //header generation function - groupHeaderPrint: null, - groupHeaderClipboard: null, - groupHeaderHtmlOutput: null, - groupHeaderDownload: null, - htmlOutputConfig: false, - //html outypu config - movableColumns: false, - //enable movable columns - movableRows: false, - //enable movable rows - movableRowsConnectedTables: false, - //tables for movable rows to be connected to - movableRowsConnectedElements: false, - //other elements for movable rows to be connected to - movableRowsSender: false, - movableRowsReceiver: "insert", - movableRowsSendingStart: function movableRowsSendingStart() {}, - movableRowsSent: function movableRowsSent() {}, - movableRowsSentFailed: function movableRowsSentFailed() {}, - movableRowsSendingStop: function movableRowsSendingStop() {}, - movableRowsReceivingStart: function movableRowsReceivingStart() {}, - movableRowsReceived: function movableRowsReceived() {}, - movableRowsReceivedFailed: function movableRowsReceivedFailed() {}, - movableRowsReceivingStop: function movableRowsReceivingStop() {}, - movableRowsElementDrop: function movableRowsElementDrop() {}, scrollToRowPosition: "top", scrollToRowIfVisible: true, scrollToColumnPosition: "left", @@ -474,109 +264,201 @@ rowFormatterClipboard: null, rowFormatterHtmlOutput: null, placeholder: false, - //table building callbacks - tableBuilding: function tableBuilding() {}, - tableBuilt: function tableBuilt() {}, - //render callbacks - renderStarted: function renderStarted() {}, - renderComplete: function renderComplete() {}, - //row callbacks - rowClick: false, - rowDblClick: false, - rowContext: false, - rowTap: false, - rowDblTap: false, - rowTapHold: false, - rowMouseEnter: false, - rowMouseLeave: false, - rowMouseOver: false, - rowMouseOut: false, - rowMouseMove: false, - rowContextMenu: false, - rowClickMenu: false, - rowAdded: function rowAdded() {}, - rowDeleted: function rowDeleted() {}, - rowMoved: function rowMoved() {}, - rowUpdated: function rowUpdated() {}, - rowSelectionChanged: function rowSelectionChanged() {}, - rowSelected: function rowSelected() {}, - rowDeselected: function rowDeselected() {}, - rowResized: function rowResized() {}, - //cell callbacks - //row callbacks - cellClick: false, - cellDblClick: false, - cellContext: false, - cellTap: false, - cellDblTap: false, - cellTapHold: false, - cellMouseEnter: false, - cellMouseLeave: false, - cellMouseOver: false, - cellMouseOut: false, - cellMouseMove: false, - cellEditing: function cellEditing() {}, - cellEdited: function cellEdited() {}, - cellEditCancelled: function cellEditCancelled() {}, - //column callbacks - columnMoved: false, - columnResized: function columnResized() {}, - columnTitleChanged: function columnTitleChanged() {}, - columnVisibilityChanged: function columnVisibilityChanged() {}, - //HTML iport callbacks - htmlImporting: function htmlImporting() {}, - htmlImported: function htmlImported() {}, - //data callbacks - dataLoading: function dataLoading() {}, - dataLoaded: function dataLoaded() {}, - dataChanged: false, - //ajax callbacks - ajaxRequesting: function ajaxRequesting() {}, - ajaxResponse: false, - ajaxError: function ajaxError() {}, - //filtering callbacks - dataFiltering: false, - dataFiltered: false, - //sorting callbacks - dataSorting: function dataSorting() {}, - dataSorted: function dataSorted() {}, - //grouping callbacks - groupToggleElement: "arrow", - groupClosedShowCalcs: false, - dataGrouping: function dataGrouping() {}, - dataGrouped: false, - groupVisibilityChanged: function groupVisibilityChanged() {}, - groupClick: false, - groupDblClick: false, - groupContext: false, - groupContextMenu: false, - groupClickMenu: false, - groupTap: false, - groupDblTap: false, - groupTapHold: false, - columnCalcs: true, - //pagination callbacks - pageLoaded: function pageLoaded() {}, - //localization callbacks - localized: function localized() {}, - //validation callbacks - validationMode: "blocking", - validationFailed: function validationFailed() {}, - //history callbacks - historyUndo: function historyUndo() {}, - historyRedo: function historyRedo() {}, - //scroll callbacks - scrollHorizontal: function scrollHorizontal() {}, - scrollVertical: function scrollVertical() {} + dataLoader: true, + dataLoaderLoading: false, + dataLoaderError: false, + dataSendParams: {}, + dataReceiveParams: {} }; + var CoreFeature = /*#__PURE__*/function () { + function CoreFeature(table) { + _classCallCheck(this, CoreFeature); + + this.table = table; + } ////////////////////////////////////////// + /////////////// DataLoad ///////////////// + ////////////////////////////////////////// + + + _createClass(CoreFeature, [{ + key: "reloadData", + value: function reloadData(data, silent) { + return this.table.dataLoader.load(data, undefined, undefined, undefined, silent); + } ////////////////////////////////////////// + ///////////// Localization /////////////// + ////////////////////////////////////////// + + }, { + key: "langText", + value: function langText() { + var _this$table$modules$l; + + return (_this$table$modules$l = this.table.modules.localize).getText.apply(_this$table$modules$l, arguments); + } + }, { + key: "langBind", + value: function langBind() { + var _this$table$modules$l2; + + return (_this$table$modules$l2 = this.table.modules.localize).bind.apply(_this$table$modules$l2, arguments); + } + }, { + key: "langLocale", + value: function langLocale() { + var _this$table$modules$l3; + + return (_this$table$modules$l3 = this.table.modules.localize).getLocale.apply(_this$table$modules$l3, arguments); + } ////////////////////////////////////////// + ////////// Inter Table Comms ///////////// + ////////////////////////////////////////// + + }, { + key: "commsConnections", + value: function commsConnections() { + var _this$table$modules$c; + + return (_this$table$modules$c = this.table.modules.comms).getConnections.apply(_this$table$modules$c, arguments); + } + }, { + key: "commsSend", + value: function commsSend() { + var _this$table$modules$c2; + + return (_this$table$modules$c2 = this.table.modules.comms).send.apply(_this$table$modules$c2, arguments); + } ////////////////////////////////////////// + //////////////// Layout ///////////////// + ////////////////////////////////////////// + + }, { + key: "layoutMode", + value: function layoutMode() { + return this.table.modules.layout.getMode(); + } + }, { + key: "layoutRefresh", + value: function layoutRefresh() { + return this.table.modules.layout.layout(); + } ////////////////////////////////////////// + /////////////// Event Bus //////////////// + ////////////////////////////////////////// + + }, { + key: "subscribe", + value: function subscribe() { + var _this$table$eventBus; + + (_this$table$eventBus = this.table.eventBus).subscribe.apply(_this$table$eventBus, arguments); + } + }, { + key: "unsubscribe", + value: function unsubscribe() { + var _this$table$eventBus2; + + (_this$table$eventBus2 = this.table.eventBus).unsubscribe.apply(_this$table$eventBus2, arguments); + } + }, { + key: "subscribed", + value: function subscribed(key) { + this.table.eventBus.subscribed(key); + } + }, { + key: "subscriptionChange", + value: function subscriptionChange() { + var _this$table$eventBus3; + + (_this$table$eventBus3 = this.table.eventBus).subscriptionChange.apply(_this$table$eventBus3, arguments); + } + }, { + key: "dispatch", + value: function dispatch() { + var _this$table$eventBus4; + + (_this$table$eventBus4 = this.table.eventBus).dispatch.apply(_this$table$eventBus4, arguments); + } + }, { + key: "chain", + value: function chain() { + var _this$table$eventBus5; + + return (_this$table$eventBus5 = this.table.eventBus).chain.apply(_this$table$eventBus5, arguments); + } + }, { + key: "confirm", + value: function confirm() { + var _this$table$eventBus6; + + return (_this$table$eventBus6 = this.table.eventBus).confirm.apply(_this$table$eventBus6, arguments); + } + }, { + key: "dispatchExternal", + value: function dispatchExternal() { + var _this$table$externalE; + + (_this$table$externalE = this.table.externalEvents).dispatch.apply(_this$table$externalE, arguments); + } + }, { + key: "subscribedExternal", + value: function subscribedExternal(key) { + this.table.externalEvents.subscribed(key); + } + }, { + key: "subscriptionChangeExternal", + value: function subscriptionChangeExternal() { + var _this$table$externalE2; + + (_this$table$externalE2 = this.table.externalEvents).subscriptionChange.apply(_this$table$externalE2, arguments); + } ////////////////////////////////////////// + //////////////// Options ///////////////// + ////////////////////////////////////////// + + }, { + key: "options", + value: function options(key, value) { + if (typeof value !== "undefined") { + this.table.options[key] = value; + } + + return this.table.options[key]; + } + }, { + key: "setOption", + value: function setOption(key, value) { + if (typeof value !== "undefined") { + this.table.options[key] = value; + } + + return this.table.options[key]; + } ////////////////////////////////////////// + //////////////// Modules ///////////////// + ////////////////////////////////////////// + + }, { + key: "module", + value: function module(key) { + return this.table.module(key); + } + }]); + + return CoreFeature; + }(); + //public column object - var ColumnComponent$1 = /*#__PURE__*/function () { + var ColumnComponent = /*#__PURE__*/function () { function ColumnComponent(column) { _classCallCheck(this, ColumnComponent); this._column = column; this.type = "ColumnComponent"; + return new Proxy(this, { + get: function get(target, name, receiver) { + if (typeof target[name] !== "undefined") { + return target[name]; + } else { + return target._column.table.componentFunctionBinder.handle("column", target._column, name); + } + } + }); } _createClass(ColumnComponent, [{ @@ -679,34 +561,6 @@ value: function getTable() { return this._column.table; } - }, { - key: "headerFilterFocus", - value: function headerFilterFocus() { - if (this._column.table.modExists("filter", true)) { - this._column.table.modules.filter.setHeaderFilterFocus(this._column); - } - } - }, { - key: "reloadHeaderFilter", - value: function reloadHeaderFilter() { - if (this._column.table.modExists("filter", true)) { - this._column.table.modules.filter.reloadHeaderFilter(this._column); - } - } - }, { - key: "getHeaderFilterValue", - value: function getHeaderFilterValue() { - if (this._column.table.modExists("filter", true)) { - return this._column.table.modules.filter.getHeaderFilterValue(this._column); - } - } - }, { - key: "setHeaderFilterValue", - value: function setHeaderFilterValue(value) { - if (this._column.table.modExists("filter", true)) { - this._column.table.modules.filter.setHeaderFilterValue(this._column, value); - } - } }, { key: "move", value: function move(to, after) { @@ -753,31 +607,49 @@ result = this._column.setWidth(width); } - if (this._column.table.options.virtualDomHoz) { - this._column.table.vdomHoz.reinitialize(true); - } + this._column.table.columnManager.renderer.rerenderColumns(true); return result; } - }, { - key: "validate", - value: function validate() { - return this._column.validate(); - } }]); return ColumnComponent; }(); - var defaultOptions$1 = ["title", "field", "columns", "visible", "hozAlign", "vertAlign", "width", "minWidth", "maxWidth", "widthGrow", "widthShrink", "resizable", "frozen", "responsive", "tooltip", "cssClass", "rowHandle", "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", "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", "headerFilterPlaceholder", "headerFilterParams", "headerFilterEmptyCheck", "headerFilterFunc", "headerFilterFuncParams", "headerFilterLiveFilter", "print", "headerContextMenu", "headerMenu", "contextMenu", // "headerClickMenu", - "clickMenu", "formatterPrint", "formatterPrintParams", "formatterClipboard", "formatterClipboardParams", "formatterHtmlOutput", "formatterHtmlOutputParams", "titlePrint", "titleClipboard", "titleHtmlOutput", "titleDownload"]; + var defaultOptions$1 = { + "title": undefined, + "field": undefined, + "columns": undefined, + "visible": undefined, + "hozAlign": undefined, + "vertAlign": undefined, + "width": undefined, + "minWidth": 40, + "maxWidth": undefined, + "tooltip": undefined, + "cssClass": undefined, + "variableHeight": undefined, + "headerTooltip": undefined, + "headerVertical": undefined, + "headerHozAlign": undefined, + "editableTitle": undefined + }; //public cell object - var CellComponent$1 = /*#__PURE__*/function () { + var CellComponent = /*#__PURE__*/function () { function CellComponent(cell) { _classCallCheck(this, CellComponent); this._cell = cell; + return new Proxy(this, { + get: function get(target, name, receiver) { + if (typeof target[name] !== "undefined") { + return target[name]; + } else { + return target._cell.table.componentFunctionBinder.handle("cell", target._cell, name); + } + } + }); } _createClass(CellComponent, [{ @@ -839,50 +711,6 @@ value: function restoreInitialValue() { this._cell.setValueActual(this._cell.initialValue); } - }, { - key: "edit", - value: function edit(force) { - return this._cell.edit(force); - } - }, { - key: "cancelEdit", - value: function cancelEdit() { - this._cell.cancelEdit(); - } - }, { - key: "isEdited", - value: function isEdited() { - return !!this._cell.modules.edit && this._cell.modules.edit.edited; - } - }, { - key: "clearEdited", - value: function clearEdited() { - if (this._cell.table.modExists("edit", true)) { - this._cell.table.modules.edit.clearEdited(this._cell); - } - } - }, { - key: "isValid", - value: function isValid() { - return this._cell.modules.validate ? !this._cell.modules.validate.invalid : true; - } - }, { - key: "validate", - value: function validate() { - return this._cell.validate(); - } - }, { - key: "clearValidation", - value: function clearValidation() { - if (this._cell.table.modExists("validate", true)) { - this._cell.table.modules.validate.clearValidation(this._cell); - } - } - }, { - key: "nav", - value: function nav() { - return this._cell.nav(); - } }, { key: "checkHeight", value: function checkHeight() { @@ -903,25 +731,34 @@ return CellComponent; }(); - var Cell$1 = /*#__PURE__*/function () { + var Cell$1 = /*#__PURE__*/function (_CoreFeature) { + _inherits(Cell, _CoreFeature); + + var _super = _createSuper(Cell); + function Cell(column, row) { + var _this; + _classCallCheck(this, Cell); - this.table = column.table; - this.column = column; - this.row = row; - this.element = null; - this.value = null; - this.initialValue; - this.oldValue = null; - this.modules = {}; - this.height = null; - this.width = null; - this.minWidth = null; - this.component = null; - this.loaded = false; //track if the cell has been added to the DOM yet + _this = _super.call(this, column.table); + _this.table = column.table; + _this.column = column; + _this.row = row; + _this.element = null; + _this.value = null; + _this.initialValue; + _this.oldValue = null; + _this.modules = {}; + _this.height = null; + _this.width = null; + _this.minWidth = null; + _this.component = null; + _this.loaded = false; //track if the cell has been added to the DOM yet + + _this.build(); - this.build(); + return _this; } //////////////// Setup Functions ///////////////// //generate element @@ -948,10 +785,9 @@ }, { key: "_configureCell", value: function _configureCell() { - var _this = this; + var _this2 = this; - var cellEvents = this.column.cellEvents, - element = this.element, + var element = this.element, field = this.column.getField(), vertAligns = { top: "flex-start", @@ -990,393 +826,123 @@ if (this.table.options.tooltipGenerationMode === "hover") { element.addEventListener("mouseenter", function (e) { - _this._generateTooltip(); + _this2._generateTooltip(); }); } - this._bindClickEvents(cellEvents); - - this._bindTouchEvents(cellEvents); - - this._bindMouseEvents(cellEvents); - - if (this.column.modules.edit) { - this.table.modules.edit.bindEditor(this); - } - - if (this.column.definition.rowHandle && this.table.options.movableRows !== false && this.table.modExists("moveRow")) { - this.table.modules.moveRow.initializeCell(this); - } //hide cell if not visible - + this.dispatch("cell-init", this); //hide cell if not visible if (!this.column.visible) { this.hide(); } - } - }, { - key: "_bindClickEvents", - value: function _bindClickEvents(cellEvents) { - var _this2 = this; - - var element = this.element; //set event bindings - - if (cellEvents.cellClick || this.table.options.cellClick) { - element.addEventListener("click", function (e) { - var component = _this2.getComponent(); - - if (cellEvents.cellClick) { - cellEvents.cellClick.call(_this2.table, e, component); - } - - if (_this2.table.options.cellClick) { - _this2.table.options.cellClick.call(_this2.table, e, component); - } - }); - } + } //generate cell contents - if (cellEvents.cellDblClick || this.table.options.cellDblClick) { - element.addEventListener("dblclick", function (e) { - var component = _this2.getComponent(); + }, { + key: "_generateContents", + value: function _generateContents() { + var _this3 = this; - if (cellEvents.cellDblClick) { - cellEvents.cellDblClick.call(_this2.table, e, component); - } + var val; + val = this.chain("cell-format", this, null, function () { + return _this3.element.innerHTML = _this3.value; + }); - if (_this2.table.options.cellDblClick) { - _this2.table.options.cellDblClick.call(_this2.table, e, component); - } - }); - } else { - element.addEventListener("dblclick", function (e) { - if (_this2.table.modExists("edit")) { - if (_this2.table.modules.edit.currentCell === _this2) { - return; //prevent instant selection of editor content + switch (_typeof(val)) { + case "object": + if (val instanceof Node) { + //clear previous cell contents + while (this.element.firstChild) { + this.element.removeChild(this.element.firstChild); } - } - e.preventDefault(); + this.element.appendChild(val); + } else { + this.element.innerHTML = ""; - try { - if (document.selection) { - // IE - var range = document.body.createTextRange(); - range.moveToElementText(_this2.element); - range.select(); - } else if (window.getSelection) { - var range = document.createRange(); - range.selectNode(_this2.element); - window.getSelection().removeAllRanges(); - window.getSelection().addRange(range); + if (val != null) { + console.warn("Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", val); } - } catch (e) {} - }); - } + } - if (cellEvents.cellContext || this.table.options.cellContext) { - element.addEventListener("contextmenu", function (e) { - var component = _this2.getComponent(); + break; - if (cellEvents.cellContext) { - cellEvents.cellContext.call(_this2.table, e, component); - } + case "undefined": + case "null": + this.element.innerHTML = ""; + break; - if (_this2.table.options.cellContext) { - _this2.table.options.cellContext.call(_this2.table, e, component); - } - }); + default: + this.element.innerHTML = val; } } }, { - key: "_bindMouseEvents", - value: function _bindMouseEvents(cellEvents) { - var _this3 = this; - - var element = this.element; + key: "cellRendered", + value: function cellRendered() { + this.dispatch("cell-rendered", this); + } //generate tooltip text - if (cellEvents.cellMouseEnter || this.table.options.cellMouseEnter) { - element.addEventListener("mouseenter", function (e) { - var component = _this3.getComponent(); + }, { + key: "_generateTooltip", + value: function _generateTooltip() { + var tooltip = this.column.tooltip; - if (cellEvents.cellMouseEnter) { - cellEvents.cellMouseEnter.call(_this3.table, e, component); - } + if (tooltip) { + if (tooltip === true) { + tooltip = this.value; + } else if (typeof tooltip == "function") { + tooltip = tooltip(this.getComponent()); - if (_this3.table.options.cellMouseEnter) { - _this3.table.options.cellMouseEnter.call(_this3.table, e, component); + if (tooltip === false) { + tooltip = ""; } - }); - } - - if (cellEvents.cellMouseLeave || this.table.options.cellMouseLeave) { - element.addEventListener("mouseleave", function (e) { - var component = _this3.getComponent(); + } - if (cellEvents.cellMouseLeave) { - cellEvents.cellMouseLeave.call(_this3.table, e, component); - } + if (typeof tooltip === "undefined") { + tooltip = ""; + } - if (_this3.table.options.cellMouseLeave) { - _this3.table.options.cellMouseLeave.call(_this3.table, e, component); - } - }); + this.element.setAttribute("title", tooltip); + } else { + this.element.setAttribute("title", ""); } + } //////////////////// Getters //////////////////// - if (cellEvents.cellMouseOver || this.table.options.cellMouseOver) { - element.addEventListener("mouseover", function (e) { - var component = _this3.getComponent(); - - if (cellEvents.cellMouseOver) { - cellEvents.cellMouseOver.call(_this3.table, e, component); - } + }, { + key: "getElement", + value: function getElement(containerOnly) { + if (!this.loaded) { + this.loaded = true; - if (_this3.table.options.cellMouseOver) { - _this3.table.options.cellMouseOver.call(_this3.table, e, component); - } - }); + if (!containerOnly) { + this.layoutElement(); + } } - if (cellEvents.cellMouseOut || this.table.options.cellMouseOut) { - element.addEventListener("mouseout", function (e) { - var component = _this3.getComponent(); - - if (cellEvents.cellMouseOut) { - cellEvents.cellMouseOut.call(_this3.table, e, component); - } - - if (_this3.table.options.cellMouseOut) { - _this3.table.options.cellMouseOut.call(_this3.table, e, component); - } - }); - } - - if (cellEvents.cellMouseMove || this.table.options.cellMouseMove) { - element.addEventListener("mousemove", function (e) { - var component = _this3.getComponent(); - - if (cellEvents.cellMouseMove) { - cellEvents.cellMouseMove.call(_this3.table, e, component); - } - - if (_this3.table.options.cellMouseMove) { - _this3.table.options.cellMouseMove.call(_this3.table, e, component); - } - }); - } - } - }, { - key: "_bindTouchEvents", - value: function _bindTouchEvents(cellEvents) { - var _this4 = this; - - var element = this.element, - dblTap, - tapHold, - tap; - - if (cellEvents.cellTap || this.table.options.cellTap) { - tap = false; - element.addEventListener("touchstart", function (e) { - tap = true; - }, { - passive: true - }); - element.addEventListener("touchend", function (e) { - if (tap) { - var component = _this4.getComponent(); - - if (cellEvents.cellTap) { - cellEvents.cellTap.call(_this4.table, e, component); - } - - if (_this4.table.options.cellTap) { - _this4.table.options.cellTap.call(_this4.table, e, component); - } - } - - tap = false; - }); - } - - if (cellEvents.cellDblTap || this.table.options.cellDblTap) { - dblTap = null; - element.addEventListener("touchend", function (e) { - if (dblTap) { - clearTimeout(dblTap); - dblTap = null; - - var component = _this4.getComponent(); - - if (cellEvents.cellDblTap) { - cellEvents.cellDblTap.call(_this4.table, e, component); - } - - if (_this4.table.options.cellDblTap) { - _this4.table.options.cellDblTap.call(_this4.table, e, component); - } - } else { - dblTap = setTimeout(function () { - clearTimeout(dblTap); - dblTap = null; - }, 300); - } - }); - } - - if (cellEvents.cellTapHold || this.table.options.cellTapHold) { - tapHold = null; - element.addEventListener("touchstart", function (e) { - clearTimeout(tapHold); - tapHold = setTimeout(function () { - clearTimeout(tapHold); - tapHold = null; - tap = false; - - var component = _this4.getComponent(); - - if (cellEvents.cellTapHold) { - cellEvents.cellTapHold.call(_this4.table, e, component); - } - - if (_this4.table.options.cellTapHold) { - _this4.table.options.cellTapHold.call(_this4.table, e, component); - } - }, 1000); - }, { - passive: true - }); - element.addEventListener("touchend", function (e) { - clearTimeout(tapHold); - tapHold = null; - }); - } - } //generate cell contents - - }, { - key: "_generateContents", - value: function _generateContents() { - var val; - - if (this.table.modExists("format")) { - val = this.table.modules.format.formatValue(this); - } else { - val = this.element.innerHTML = this.value; - } - - switch (_typeof(val)) { - case "object": - if (val instanceof Node) { - //clear previous cell contents - while (this.element.firstChild) { - this.element.removeChild(this.element.firstChild); - } - - this.element.appendChild(val); - } else { - this.element.innerHTML = ""; - - if (val != null) { - console.warn("Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", val); - } - } - - break; - - case "undefined": - case "null": - this.element.innerHTML = ""; - break; - - default: - this.element.innerHTML = val; - } - } - }, { - key: "cellRendered", - value: function cellRendered() { - if (this.table.modExists("format") && this.table.modules.format.cellRendered) { - this.table.modules.format.cellRendered(this); - } - } //generate tooltip text - - }, { - key: "_generateTooltip", - value: function _generateTooltip() { - var tooltip = this.column.tooltip; - - if (tooltip) { - if (tooltip === true) { - tooltip = this.value; - } else if (typeof tooltip == "function") { - tooltip = tooltip(this.getComponent()); - - if (tooltip === false) { - tooltip = ""; - } - } - - if (typeof tooltip === "undefined") { - tooltip = ""; - } - - this.element.setAttribute("title", tooltip); - } else { - this.element.setAttribute("title", ""); - } - } //////////////////// Getters //////////////////// - - }, { - key: "getElement", - value: function getElement(containerOnly) { - if (!this.loaded) { - this.loaded = true; - - if (!containerOnly) { - this.layoutElement(); - } - } - - return this.element; - } - }, { - key: "getValue", - value: function getValue() { - return this.value; - } - }, { - key: "getOldValue", - value: function getOldValue() { - return this.oldValue; - } //////////////////// Actions //////////////////// + return this.element; + } + }, { + key: "getValue", + value: function getValue() { + return this.value; + } + }, { + key: "getOldValue", + value: function getOldValue() { + return this.oldValue; + } //////////////////// Actions //////////////////// }, { key: "setValue", value: function setValue(value, mutate) { - var changed = this.setValueProcessData(value, mutate), - component; + var changed = this.setValueProcessData(value, mutate); if (changed) { - if (this.table.options.history && this.table.modExists("history")) { - this.table.modules.history.action("cellEdit", this, { - oldValue: this.oldValue, - newValue: this.value - }); - } - - component = this.getComponent(); - - if (this.column.cellEvents.cellEdited) { - this.column.cellEvents.cellEdited.call(this.table, component); - } - - if (this.table.options.groupUpdateOnCellEdit && this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.groupRows.reassignRowToGroup(this.row); - } - + this.dispatch("cell-value-updated", this); this.cellRendered(); - this.table.options.cellEdited.call(this.table, component); + this.dispatchExternal("cellEdited", this.getComponent()); - if (this.table.options.dataChanged) { - this.table.options.dataChanged.call(this.table, this.table.rowManager.getData()); + if (this.subscribedExternal("dataChanged")) { + this.dispatchExternal("dataChanged", this.table.rowManager.getData()); } } } @@ -1389,28 +955,14 @@ changed = true; if (mutate) { - if (this.column.modules.mutate) { - value = this.table.modules.mutator.transformCell(this, value); - } + value = this.chain("cell-value-changing", [this, value], null, value); } } this.setValueActual(value); - if (changed && this.table.modExists("columnCalcs")) { - if (this.column.definition.topCalc || this.column.definition.bottomCalc) { - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - if (this.table.options.columnCalcs == "table" || this.table.options.columnCalcs == "both") { - this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows); - } - - if (this.table.options.columnCalcs != "table") { - this.table.modules.columnCalcs.recalcRowGroup(this.row); - } - } else { - this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows); - } - } + if (changed) { + this.dispatch("cell-value-changed", this); } return changed; @@ -1420,16 +972,9 @@ value: function setValueActual(value) { this.oldValue = this.value; this.value = value; - - if (this.table.options.reactiveData && this.table.modExists("reactiveData")) { - this.table.modules.reactiveData.block(); - } - + this.dispatch("cell-value-save-before", this); this.column.setFieldValue(this.row.data, value); - - if (this.table.options.reactiveData && this.table.modExists("reactiveData")) { - this.table.modules.reactiveData.unblock(); - } + this.dispatch("cell-value-save-after", this); if (this.loaded) { this.layoutElement(); @@ -1440,21 +985,9 @@ value: function layoutElement() { this._generateContents(); - this._generateTooltip(); //set resizable handles - - - if (this.table.options.resizableColumns && this.table.modExists("resizeColumns") && this.row.type === "row") { - this.table.modules.resizeColumns.initializeColumn("cell", this.column, this.element); - } - - if ((this.column.definition.contextMenu || this.column.definition.clickMenu) && this.table.modExists("menu")) { - this.table.modules.menu.initializeCell(this); - } //handle frozen cells - + this._generateTooltip(); - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.layoutElement(this.element, this.column); - } + this.dispatch("cell-layout", this); } }, { key: "setWidth", @@ -1518,265 +1051,125 @@ value: function hide() { this.element.style.display = "none"; } - }, { - key: "edit", - value: function edit(force) { - if (this.table.modExists("edit", true)) { - return this.table.modules.edit.editCell(this, force); - } - } - }, { - key: "cancelEdit", - value: function cancelEdit() { - if (this.table.modExists("edit", true)) { - var editing = this.table.modules.edit.getCurrentCell(); - - if (editing && editing._getSelf() === this) { - this.table.modules.edit.cancelEdit(); - } else { - console.warn("Cancel Editor Error - This cell is not currently being edited "); - } - } - } - }, { - key: "validate", - value: function validate() { - if (this.column.modules.validate && this.table.modExists("validate", true)) { - var valid = this.table.modules.validate.validate(this.column.modules.validate, this, this.getValue()); - return valid === true; - } else { - return true; - } - } }, { key: "delete", value: function _delete() { + this.dispatch("cell-delete", this); + if (!this.table.rowManager.redrawBlock && this.element.parentNode) { this.element.parentNode.removeChild(this.element); } - if (this.modules.validate && this.modules.validate.invalid) { - this.table.modules.validate.clearValidation(this); - } - - if (this.modules.edit && this.modules.edit.edited) { - this.table.modules.edit.clearEdited(this); - } - - if (this.table.options.history) { - this.table.modules.history.clearComponentHistory(this); - } - this.element = false; this.column.deleteCell(this); this.row.deleteCell(this); this.calcs = {}; - } //////////////// Navigation ///////////////// + } + }, { + key: "getIndex", + value: function getIndex() { + return this.row.getCellIndex(this); + } //////////////// Object Generation ///////////////// }, { - key: "nav", - value: function nav() { - var self = this, - nextCell = false, - index = this.row.getCellIndex(this); - return { - next: function next() { - var nextCell = this.right(), - nextRow; + key: "getComponent", + value: function getComponent() { + if (!this.component) { + this.component = new CellComponent(this); + } - if (!nextCell) { - nextRow = self.table.rowManager.nextDisplayRow(self.row, true); + return this.component; + } + }]); - if (nextRow) { - nextCell = nextRow.findNextEditableCell(-1); + return Cell; + }(CoreFeature); - if (nextCell) { - nextCell.edit(); - return true; - } - } - } else { - return true; - } + var Column$1 = /*#__PURE__*/function (_CoreFeature) { + _inherits(Column, _CoreFeature); - return false; - }, - prev: function prev() { - var nextCell = this.left(), - prevRow; + var _super = _createSuper(Column); - if (!nextCell) { - prevRow = self.table.rowManager.prevDisplayRow(self.row, true); + function Column(def, parent) { + var _this; - if (prevRow) { - nextCell = prevRow.findPrevEditableCell(prevRow.cells.length); + _classCallCheck(this, Column); - if (nextCell) { - nextCell.edit(); - return true; - } - } - } else { - return true; - } + _this = _super.call(this, parent.table); + _this.definition = def; //column definition - return false; - }, - left: function left() { - nextCell = self.row.findPrevEditableCell(index); + _this.parent = parent; //hold parent object - if (nextCell) { - nextCell.edit(); - return true; - } else { - return false; - } - }, - right: function right() { - nextCell = self.row.findNextEditableCell(index); + _this.type = "column"; //type of element - if (nextCell) { - nextCell.edit(); - return true; - } else { - return false; - } - }, - up: function up() { - var nextRow = self.table.rowManager.prevDisplayRow(self.row, true); - - if (nextRow) { - nextRow.cells[index].edit(); - } - }, - down: function down() { - var nextRow = self.table.rowManager.nextDisplayRow(self.row, true); - - if (nextRow) { - nextRow.cells[index].edit(); - } - } - }; - } - }, { - key: "getIndex", - value: function getIndex() { - this.row.getCellIndex(this); - } //////////////// Object Generation ///////////////// - - }, { - key: "getComponent", - value: function getComponent() { - if (!this.component) { - this.component = new CellComponent$1(this); - } - - return this.component; - } - }]); - - return Cell; - }(); + _this.columns = []; //child columns - var Column$1 = /*#__PURE__*/function () { - function Column(def, parent) { - var _this = this; - - _classCallCheck(this, Column); + _this.cells = []; //cells bound to this column - this.table = parent.table; - this.definition = def; //column definition + _this.element = _this.createElement(); //column header element - this.parent = parent; //hold parent object + _this.contentElement = false; + _this.titleHolderElement = false; + _this.titleElement = false; + _this.groupElement = _this.createGroupElement(); //column group holder element - this.type = "column"; //type of element + _this.isGroup = false; + _this.tooltip = false; //hold column tooltip - this.columns = []; //child columns + _this.hozAlign = ""; //horizontal text alignment - this.cells = []; //cells bound to this column - - this.element = this.createElement(); //column header element - - this.contentElement = false; - this.titleHolderElement = false; - this.titleElement = false; - this.groupElement = this.createGroupElement(); //column group holder element + _this.vertAlign = ""; //vert text alignment + //multi dimensional filed handling - this.isGroup = false; - this.tooltip = false; //hold column tooltip + _this.field = ""; + _this.fieldStructure = ""; + _this.getFieldValue = ""; + _this.setFieldValue = ""; + _this.titleFormatterRendered = false; - this.hozAlign = ""; //horizontal text alignment + _this.mapDefinitions(); - this.vertAlign = ""; //vert text alignment - //multi dimensional filed handling + _this.setField(_this.definition.field); - this.field = ""; - this.fieldStructure = ""; - this.getFieldValue = ""; - this.setFieldValue = ""; - this.titleFormatterRendered = false; - this.mapDefinitionDefaults(); - this.setField(this.definition.field); - - if (this.table.options.invalidOptionWarnings) { - this.checkDefinition(); - } - - this.modules = {}; //hold module variables; - - this.cellEvents = { - cellClick: false, - cellDblClick: false, - cellContext: false, - cellTap: false, - cellDblTap: false, - cellTapHold: false, - cellMouseEnter: false, - cellMouseLeave: false, - cellMouseOver: false, - cellMouseOut: false, - cellMouseMove: false - }; - this.width = null; //column width + _this.modules = {}; //hold module variables; - this.widthStyled = ""; //column width prestyled to improve render efficiency + _this.width = null; //column width - this.maxWidth = null; //column maximum width + _this.widthStyled = ""; //column width prestyled to improve render efficiency - this.maxWidthStyled = ""; //column maximum prestyled to improve render efficiency + _this.maxWidth = null; //column maximum width - this.minWidth = null; //column minimum width + _this.maxWidthStyled = ""; //column maximum prestyled to improve render efficiency - this.minWidthStyled = ""; //column minimum prestyled to improve render efficiency + _this.minWidth = null; //column minimum width - this.widthFixed = false; //user has specified a width for this column + _this.minWidthStyled = ""; //column minimum prestyled to improve render efficiency - this.visible = true; //default visible state + _this.widthFixed = false; //user has specified a width for this column - this.component = null; + _this.visible = true; //default visible state - this._mapDepricatedFunctionality(); //initialize column + _this.component = null; //initialize column + if (_this.definition.columns) { + _this.isGroup = true; - if (def.columns) { - this.isGroup = true; - def.columns.forEach(function (def, i) { - var newCol = new Column(def, _this); + _this.definition.columns.forEach(function (def, i) { + var newCol = new Column(def, _assertThisInitialized(_this)); _this.attachColumn(newCol); }); - this.checkColumnVisibility(); + + _this.checkColumnVisibility(); } else { - parent.registerColumnField(this); + parent.registerColumnField(_assertThisInitialized(_this)); } - if (def.rowHandle && this.table.options.movableRows !== false && this.table.modExists("moveRow")) { - this.table.modules.moveRow.setHandle(true); - } + _this._initialize(); - this._buildHeader(); + _this.bindModuleColumns(); - this.bindModuleColumns(); + return _this; } _createClass(Column, [{ @@ -1796,9 +1189,9 @@ return el; } }, { - key: "mapDefinitionDefaults", - value: function mapDefinitionDefaults() { - var defaults = this.table.options.columnDefaults; + key: "mapDefinitions", + value: function mapDefinitions() { + var defaults = this.table.options.columnDefaults; //map columnDefaults onto column definitions if (defaults) { for (var key in defaults) { @@ -1807,6 +1200,8 @@ } } } + + this.definition = this.table.columnManager.optionsList.generate(Column.defaultOptionList, this.definition); } }, { key: "checkDefinition", @@ -1862,12 +1257,12 @@ var def = this.definition; //set header tooltips - var tooltip = def.headerTooltip || def.tooltip === false ? def.headerTooltip : this.table.options.tooltipsHeader; + var tooltip = typeof def.headerTooltip === "undefined" ? def.tooltip : def.headerTooltip; if (tooltip) { if (tooltip === true) { if (def.field) { - this.table.modules.localize.bind("columns|" + def.field, function (value) { + this.langBind("columns|" + def.field, function (value) { _this3.element.setAttribute("title", value || def.title); }); } else { @@ -1890,8 +1285,8 @@ } //build header element }, { - key: "_buildHeader", - value: function _buildHeader() { + key: "_initialize", + value: function _initialize() { var _this4 = this; var def = this.definition; @@ -1918,41 +1313,8 @@ this._buildColumnHeader(); } - this.setTooltip(); //set resizable handles - - if (this.table.options.resizableColumns && this.table.modExists("resizeColumns")) { - this.table.modules.resizeColumns.initializeColumn("header", this, this.element); - } //set resizable handles - - - if (def.headerFilter && this.table.modExists("filter") && this.table.modExists("edit")) { - if (typeof def.headerFilterPlaceholder !== "undefined" && def.field) { - this.table.modules.localize.setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder); - } - - this.table.modules.filter.initializeColumn(this); - } //set resizable handles - - - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.initializeColumn(this); - } //set movable column - - - if (this.table.options.movableColumns && !this.isGroup && this.table.modExists("moveColumn")) { - this.table.modules.moveColumn.initializeColumn(this); - } //set calcs column - - - if ((def.topCalc || def.bottomCalc) && this.table.modExists("columnCalcs")) { - this.table.modules.columnCalcs.initializeColumn(this); - } //handle persistence - - - if (this.table.modExists("persistence") && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.initializeColumn(this); - } //update header tooltip on mouse enter - + this.setTooltip(); + this.dispatch("column-init", this); //update header tooltip on mouse enter this.element.addEventListener("mouseenter", function (e) { _this4.setTooltip(); @@ -2036,66 +1398,6 @@ clearTimeout(tapHold); tapHold = null; }); - } //store column cell click event bindings - - - if (typeof def.cellClick == "function") { - this.cellEvents.cellClick = def.cellClick; - } - - if (typeof def.cellDblClick == "function") { - this.cellEvents.cellDblClick = def.cellDblClick; - } - - if (typeof def.cellContext == "function") { - this.cellEvents.cellContext = def.cellContext; - } //store column mouse event bindings - - - if (typeof def.cellMouseEnter == "function") { - this.cellEvents.cellMouseEnter = def.cellMouseEnter; - } - - if (typeof def.cellMouseLeave == "function") { - this.cellEvents.cellMouseLeave = def.cellMouseLeave; - } - - if (typeof def.cellMouseOver == "function") { - this.cellEvents.cellMouseOver = def.cellMouseOver; - } - - if (typeof def.cellMouseOut == "function") { - this.cellEvents.cellMouseOut = def.cellMouseOut; - } - - if (typeof def.cellMouseMove == "function") { - this.cellEvents.cellMouseMove = def.cellMouseMove; - } //setup column cell tap event bindings - - - if (typeof def.cellTap == "function") { - this.cellEvents.cellTap = def.cellTap; - } - - if (typeof def.cellDblTap == "function") { - this.cellEvents.cellDblTap = def.cellDblTap; - } - - if (typeof def.cellTapHold == "function") { - this.cellEvents.cellTapHold = def.cellTapHold; - } //setup column cell edit callbacks - - - if (typeof def.cellEdited == "function") { - this.cellEvents.cellEdited = def.cellEdited; - } - - if (typeof def.cellEditing == "function") { - this.cellEvents.cellEditing = def.cellEditing; - } - - if (typeof def.cellEditCancelled == "function") { - this.cellEvents.cellEditCancelled = def.cellEditCancelled; } } //build header element for header @@ -2106,47 +1408,7 @@ var def = this.definition, table = this.table; - //set column sorter - - if (table.modExists("sort")) { - table.modules.sort.initializeColumn(this, this.titleHolderElement); - } //set column header context menu - - - if ((def.headerContextMenu || def.headerClickMenu || def.headerMenu) && table.modExists("menu")) { - table.modules.menu.initializeColumnHeader(this); - } //set column formatter - - - if (table.modExists("format")) { - table.modules.format.initializeColumn(this); - } //set column editor - - - if (typeof def.editor != "undefined" && table.modExists("edit")) { - table.modules.edit.initializeColumn(this); - } //set colum validator - - - if (typeof def.validator != "undefined" && table.modExists("validate")) { - table.modules.validate.initializeColumn(this); - } //set column mutator - - - if (table.modExists("mutator")) { - table.modules.mutator.initializeColumn(this); - } //set column accessor - - - if (table.modExists("accessor")) { - table.modules.accessor.initializeColumn(this); - } //set respoviveLayout - - - if (_typeof(table.options.responsiveLayout) && table.modExists("responsiveLayout")) { - table.modules.responsiveLayout.initializeColumn(this); - } //set column visibility - + this.dispatch("column-layout", this); //set column visibility if (typeof def.visible != "undefined") { if (def.visible) { @@ -2169,21 +1431,19 @@ } //set min width if present - this.setMinWidth(typeof def.minWidth == "undefined" ? this.table.options.columnMinWidth : parseInt(def.minWidth)); + this.setMinWidth(parseInt(def.minWidth)); - if (def.maxWidth || this.table.options.columnMaxWidth) { - if (def.maxWidth !== false) { - this.setMaxWidth(typeof def.maxWidth == "undefined" ? this.table.options.columnMaxWidth : parseInt(def.maxWidth)); - } + if (def.maxWidth) { + this.setMaxWidth(parseInt(def.maxWidth)); } this.reinitializeWidth(); //set tooltip if present - this.tooltip = this.definition.tooltip || this.definition.tooltip === false ? this.definition.tooltip : this.table.options.tooltips; //set orizontal text alignment + this.tooltip = this.definition.tooltip; //set orizontal text alignment - this.hozAlign = typeof this.definition.hozAlign == "undefined" ? this.table.options.cellHozAlign : this.definition.hozAlign; - this.vertAlign = typeof this.definition.vertAlign == "undefined" ? this.table.options.cellVertAlign : this.definition.vertAlign; - this.titleElement.style.textAlign = this.definition.headerHozAlign || this.table.options.headerHozAlign; + this.hozAlign = this.definition.hozAlign; + this.vertAlign = this.definition.vertAlign; + this.titleElement.style.textAlign = this.definition.headerHozAlign; } }, { key: "_buildColumnHeaderContent", @@ -2205,8 +1465,7 @@ value: function _buildColumnHeaderTitle() { var _this7 = this; - var def = this.definition, - table = this.table; + var def = this.definition; var titleHolderElement = document.createElement("div"); titleHolderElement.classList.add("tabulator-col-title"); @@ -2219,12 +1478,13 @@ }); titleElement.addEventListener("change", function () { def.title = titleElement.value; - table.options.columnTitleChanged.call(_this7.table, _this7.getComponent()); + + _this7.dispatchExternal("columnTitleChanged", _this7.getComponent()); }); titleHolderElement.appendChild(titleElement); if (def.field) { - table.modules.localize.bind("columns|" + def.field, function (text) { + this.langBind("columns|" + def.field, function (text) { titleElement.value = text || def.title || " "; }); } else { @@ -2232,7 +1492,7 @@ } } else { if (def.field) { - table.modules.localize.bind("columns|" + def.field, function (text) { + this.langBind("columns|" + def.field, function (text) { _this7._formatColumnHeaderTitle(titleHolderElement, text || def.title || " "); }); } else { @@ -2245,57 +1505,35 @@ }, { key: "_formatColumnHeaderTitle", value: function _formatColumnHeaderTitle(el, title) { - var _this8 = this; - - var formatter, contents, params, mockCell, onRendered; - - if (this.definition.titleFormatter && this.table.modExists("format")) { - formatter = this.table.modules.format.getFormatter(this.definition.titleFormatter); - - onRendered = function onRendered(callback) { - _this8.titleFormatterRendered = callback; - }; + var contents = this.chain("column-format", [this, title, el], null, function () { + return title; + }); - mockCell = { - getValue: function getValue() { - return title; - }, - getElement: function getElement() { - return el; + switch (_typeof(contents)) { + case "object": + if (contents instanceof Node) { + el.appendChild(contents); + } else { + el.innerHTML = ""; + console.warn("Format Error - Title formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", contents); } - }; - params = this.definition.titleFormatterParams || {}; - params = typeof params === "function" ? params() : params; - contents = formatter.call(this.table.modules.format, mockCell, params, onRendered); - - switch (_typeof(contents)) { - case "object": - if (contents instanceof Node) { - el.appendChild(contents); - } else { - el.innerHTML = ""; - console.warn("Format Error - Title formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:", contents); - } - break; + break; - case "undefined": - case "null": - el.innerHTML = ""; - break; + case "undefined": + case "null": + el.innerHTML = ""; + break; - default: - el.innerHTML = contents; - } - } else { - el.innerHTML = title; + default: + el.innerHTML = contents; } } //build header element for column group }, { key: "_buildGroupHeader", value: function _buildGroupHeader() { - var _this9 = this; + var _this8 = this; this.element.classList.add("tabulator-col-group"); this.element.setAttribute("role", "columngroup"); @@ -2304,16 +1542,11 @@ if (this.definition.cssClass) { var classeNames = this.definition.cssClass.split(" "); classeNames.forEach(function (className) { - _this9.element.classList.add(className); + _this8.element.classList.add(className); }); - } //set column header context menu - - - if ((this.definition.headerContextMenu || this.definition.headerMenu) && this.table.modExists("menu")) { - this.table.modules.menu.initializeColumnHeader(this); } - this.titleElement.style.textAlign = this.definition.headerHozAlign || this.table.options.headerHozAlign; + this.titleElement.style.textAlign = this.definition.headerHozAlign; this.element.appendChild(this.groupElement); } //flat field lookup @@ -2528,7 +1761,7 @@ if (visible) { this.show(); - this.parent.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), false); + this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false); } else { this.hide(); } @@ -2555,24 +1788,18 @@ this.table.columnManager._verticalAlignHeaders(); - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.save("columns"); - } - - if (!responsiveToggle && this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.updateColumnVisibility(this, this.visible); - } + this.dispatch("column-show", this, responsiveToggle); if (!silent) { - this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), true); + this.dispatchExternal("columnVisibilityChanged", this.getComponent(), true); } if (this.parent.isGroup) { this.parent.matchChildWidths(); } - if (!this.silent && this.table.options.virtualDomHoz) { - this.table.vdomHoz.reinitialize(); + if (!this.silent) { + this.table.columnManager.renderer.rerenderColumns(); } } } //hide column @@ -2593,25 +1820,18 @@ this.cells.forEach(function (cell) { cell.hide(); }); - - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.save("columns"); - } - - if (!responsiveToggle && this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.updateColumnVisibility(this, this.visible); - } + this.dispatch("column-hide", this); if (!silent) { - this.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), false); + this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false); } if (this.parent.isGroup) { this.parent.matchChildWidths(); } - if (!this.silent && this.table.options.virtualDomHoz) { - this.table.vdomHoz.reinitialize(); + if (!this.silent) { + this.table.columnManager.renderer.rerenderColumns(); } } } @@ -2677,12 +1897,9 @@ if (this.parent.isGroup) { this.parent.matchChildWidths(); - } //set resizable handles - - - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.layout(); } + + this.dispatch("column-width", this); } }, { key: "checkCellHeights", @@ -2750,47 +1967,40 @@ }, { key: "delete", value: function _delete() { - var _this10 = this; + var _this9 = this; return new Promise(function (resolve, reject) { - if (_this10.isGroup) { - _this10.columns.forEach(function (column) { + if (_this9.isGroup) { + _this9.columns.forEach(function (column) { column["delete"](); }); - } //cancel edit if column is currently being edited - - - if (_this10.table.modExists("edit")) { - if (_this10.table.modules.edit.currentCell.column === _this10) { - _this10.table.modules.edit.cancelEdit(); - } } - var cellCount = _this10.cells.length; + _this9.dispatch("column-delete", _this9); + + var cellCount = _this9.cells.length; for (var i = 0; i < cellCount; i++) { - _this10.cells[0]["delete"](); + _this9.cells[0]["delete"](); } - if (_this10.element.parentNode) { - _this10.element.parentNode.removeChild(_this10.element); + if (_this9.element.parentNode) { + _this9.element.parentNode.removeChild(_this9.element); } - _this10.element = false; - _this10.contentElement = false; - _this10.titleElement = false; - _this10.groupElement = false; + _this9.element = false; + _this9.contentElement = false; + _this9.titleElement = false; + _this9.groupElement = false; - if (_this10.parent.isGroup) { - _this10.parent.removeChild(_this10); + if (_this9.parent.isGroup) { + _this9.parent.removeChild(_this9); } - _this10.table.columnManager.deregisterColumn(_this10); + _this9.table.columnManager.deregisterColumn(_this9); - if (_this10.table.options.virtualDomHoz) { - _this10.table.vdomHoz.reinitialize(true); - } + _this9.table.columnManager.renderer.rerenderColumns(true); resolve(); }); @@ -2801,17 +2011,6 @@ if (this.titleFormatterRendered) { this.titleFormatterRendered(); } - } - }, { - key: "validate", - value: function validate() { - var invalid = []; - this.cells.forEach(function (cell) { - if (!cell.validate()) { - invalid.push(cell.getComponent()); - } - }); - return invalid.length ? invalid : true; } //////////////// Cell Management ///////////////// //generate cell for this column @@ -2853,18 +2052,11 @@ if (typeof this.definition.width !== "undefined" && !force) { this.setWidth(this.definition.width); - } //hide header filters to prevent them altering column width - - - if (this.table.modExists("filter")) { - this.table.modules.filter.hideHeaderFilterElements(); } - this.fitToData(); //show header filters again after layout is complete - - if (this.table.modExists("filter")) { - this.table.modules.filter.showHeaderFilterElements(); - } + this.dispatch("column-width-fit-before", this); + this.fitToData(); + this.dispatch("column-width-fit-after", this); } //set column width to maximum cell width }, { @@ -2896,22 +2088,22 @@ }, { key: "updateDefinition", value: function updateDefinition(updates) { - var _this11 = this; + var _this10 = this; return new Promise(function (resolve, reject) { var definition; - if (!_this11.isGroup) { - if (!_this11.parent.isGroup) { - definition = Object.assign({}, _this11.getDefinition()); + if (!_this10.isGroup) { + if (!_this10.parent.isGroup) { + definition = Object.assign({}, _this10.getDefinition()); definition = Object.assign(definition, updates); - _this11.table.columnManager.addColumn(definition, false, _this11).then(function (column) { - if (definition.field == _this11.field) { - _this11.field = false; //cleair field name to prevent deletion of duplicate column from arrays + _this10.table.columnManager.addColumn(definition, false, _this10).then(function (column) { + if (definition.field == _this10.field) { + _this10.field = false; //cleair field name to prevent deletion of duplicate column from arrays } - _this11["delete"]().then(function () { + _this10["delete"]().then(function () { resolve(column.getComponent()); })["catch"](function (err) { reject(err); @@ -2943,7 +2135,7 @@ key: "getComponent", value: function getComponent() { if (!this.component) { - this.component = new ColumnComponent$1(this); + this.component = new ColumnComponent(this); } return this.component; @@ -2951,11 +2143,11 @@ }]); return Column; - }(); + }(CoreFeature); Column$1.defaultOptionList = defaultOptions$1; - var Helpers = /*#__PURE__*/function () { + var Helpers$1 = /*#__PURE__*/function () { function Helpers() { _classCallCheck(this, Helpers); } @@ -2996,2824 +2188,2276 @@ return Helpers; }(); - var ColumnManager = /*#__PURE__*/function () { - function ColumnManager(table) { - _classCallCheck(this, ColumnManager); - - this.table = table; //hold parent table - - this.blockHozScrollEvent = false; - this.headersElement = this.createHeadersElement(); - this.element = this.createHeaderElement(); //containing element - - this.rowManager = null; //hold row manager object - - this.columns = []; // column definition object - - this.columnsByIndex = []; //columns by index - - this.columnsByField = {}; //columns by field - - this.scrollLeft = 0; - this.element.insertBefore(this.headersElement, this.element.firstChild); - } ////////////// Setup Functions ///////////////// + var OptionsList = /*#__PURE__*/function () { + function OptionsList(table, msgType) { + _classCallCheck(this, OptionsList); + this.table = table; + this.msgType = msgType; + this.registeredDefaults = {}; + } - _createClass(ColumnManager, [{ - key: "createHeadersElement", - value: function createHeadersElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-headers"); - return el; + _createClass(OptionsList, [{ + key: "register", + value: function register(option, value) { + this.registeredDefaults[option] = value; } }, { - key: "createHeaderElement", - value: function createHeaderElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-header"); + key: "generate", + value: function generate(defaultOptions) { + var userOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + var output = Object.assign({}, this.registeredDefaults); + Object.assign(output, defaultOptions); - if (!this.table.options.headerVisible) { - el.classList.add("tabulator-header-hidden"); + if (userOptions.debugInvalidOptions !== false || this.table.options.debugInvalidOptions) { + for (var key in userOptions) { + if (!output.hasOwnProperty(key)) { + console.warn("Invalid " + this.msgType + " option:", key); + } + } } - return el; - } - }, { - key: "initialize", - value: function initialize() {//scroll body along with header - // this.element.addEventListener("scroll", (e) => { - // if(!this.blockHozScrollEvent){ - // this.table.rowManager.scrollHorizontal(this.element.scrollLeft); - // } - // }); - } //link to row manager + for (var key in output) { + if (key in userOptions) { + output[key] = userOptions[key]; + } else { + if (Array.isArray(output[key])) { + output[key] = Object.assign([], output[key]); + } else if (_typeof(output[key]) === "object" && output[key] !== null) { + output[key] = Object.assign({}, output[key]); + } else if (typeof output[key] === "undefined") { + delete output[key]; + } + } + } - }, { - key: "setRowManager", - value: function setRowManager(manager) { - this.rowManager = manager; - } //return containing element + return output; + } + }]); - }, { - key: "getElement", - value: function getElement() { - return this.element; - } //return header containing element + return OptionsList; + }(); - }, { - key: "getHeadersElement", - value: function getHeadersElement() { - return this.headersElement; - } //scroll horizontally to match table body + var Renderer = /*#__PURE__*/function (_CoreFeature) { + _inherits(Renderer, _CoreFeature); - }, { - key: "scrollHorizontal", - value: function scrollHorizontal(left) { - var hozAdjust = 0, - scrollWidth = this.element.scrollWidth - this.table.element.clientWidth; // this.tempScrollBlock(); + var _super = _createSuper(Renderer); - this.element.scrollLeft = left; //adjust for vertical scrollbar moving table when present + function Renderer(table) { + var _this; - if (left > scrollWidth) { - hozAdjust = left - scrollWidth; - this.element.style.marginLeft = -hozAdjust + "px"; - } else { - this.element.style.marginLeft = 0; - } //keep frozen columns fixed in position - //this._calcFrozenColumnsPos(hozAdjust + 3); + _classCallCheck(this, Renderer); + _this = _super.call(this, table); + _this.elementVertical = table.rowManager.element; + _this.elementHorizontal = table.columnManager.element; + _this.tableElement = table.rowManager.tableElement; + _this.verticalFillMode = "fit"; // used by row manager to determin how to size the render area ("fit" - fits container to the contents, "fill" - fills the contianer without resizing it) - this.scrollLeft = left; + return _this; + } /////////////////////////////////// + /////// Internal Bindings ///////// + /////////////////////////////////// - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.scrollHorizontal(); - } - } ///////////// Column Setup Functions ///////////// + _createClass(Renderer, [{ + key: "initialize", + value: function initialize() {//initialize core functionality + } }, { - key: "generateColumnsFromRowData", - value: function generateColumnsFromRowData(data) { - var cols = [], - definitions = this.table.options.autoColumnsDefinitions, - row, - sorter; + key: "clearRows", + value: function clearRows() {//clear down existing rows layout + } + }, { + key: "clearColumns", + value: function clearColumns() {//clear down existing columns layout + } + }, { + key: "reinitializeColumnWidths", + value: function reinitializeColumnWidths(columns) {//resize columns to fit data + } + }, { + key: "renderRows", + value: function renderRows() {//render rows from a clean slate + } + }, { + key: "renderColumns", + value: function renderColumns() {//render columns from a clean slate + } + }, { + key: "rerenderRows", + value: function rerenderRows(callback) { + // rerender rows and keep position + if (callback) { + callback(); + } + } + }, { + key: "rerenderColumns", + value: function rerenderColumns(update, blockRedraw) {//rerender columns + } + }, { + key: "renderRowCells", + value: function renderRowCells(row) {//render the cells in a row + } + }, { + key: "rerenderRowCells", + value: function rerenderRowCells(row, force) {//rerender the cells in a row + } + }, { + key: "scrollColumns", + value: function scrollColumns(left, dir) {//handle horizontal scrolling + } + }, { + key: "scrollRows", + value: function scrollRows(top, dir) {//handle vertical scolling + } + }, { + key: "resize", + value: function resize() {//container has rezied, carry out any needed recalculations (DO NOT RERENDER IN THIS FUNCTION) + } + }, { + key: "scrollToRow", + value: function scrollToRow(row) {//scroll to a specific row + } + }, { + key: "scrollToRowNearestTop", + value: function scrollToRowNearestTop(row) {//determin weather the row is nearest the top or bottom of the table, retur true for top or false for bottom + } + }, { + key: "visibleRows", + value: function visibleRows(includingBuffer) { + //return the visible rows + return []; + } /////////////////////////////////// + //////// Helper Functions ///////// + /////////////////////////////////// - if (data && data.length) { - row = data[0]; + }, { + key: "rows", + value: function rows() { + return this.table.rowManager.getDisplayRows(); + } + }, { + key: "styleRow", + value: function styleRow(row, index) { + var rowEl = row.getElement(); - for (var key in row) { - var col = { - field: key, - title: key - }; - var value = row[key]; + if (index % 2) { + rowEl.classList.add("tabulator-row-even"); + rowEl.classList.remove("tabulator-row-odd"); + } else { + rowEl.classList.add("tabulator-row-odd"); + rowEl.classList.remove("tabulator-row-even"); + } + } /////////////////////////////////// + /////// External Triggers ///////// + /////// (DO NOT OVERRIDE) ///////// + /////////////////////////////////// - switch (_typeof(value)) { - case "undefined": - sorter = "string"; - break; + }, { + key: "clear", + value: function clear() { + //clear down existing layout + this.clearRows(); + this.clearColumns(); + } + }, { + key: "render", + value: function render() { + //render from a clean slate + this.renderRows(); + this.renderColumns(); + } + }, { + key: "rerender", + value: function rerender(callback) { + // rerender and keep position + this.rerenderRows(); + this.rerenderColumns(); + } + }, { + key: "scrollToRowPosition", + value: function scrollToRowPosition(row, position, ifVisible) { + var _this2 = this; - case "boolean": - sorter = "boolean"; - break; + var rowIndex = this.rows().indexOf(row), + rowEl = row.getElement(), + offset = 0; + return new Promise(function (resolve, reject) { + if (rowIndex > -1) { + if (typeof ifVisible === "undefined") { + ifVisible = _this2.table.options.scrollToRowIfVisible; + } //check row visibility - case "object": - if (Array.isArray(value)) { - sorter = "array"; - } else { - sorter = "string"; - } - break; + if (!ifVisible) { + if (Helpers$1.elVisible(rowEl)) { + offset = Helpers$1.elOffset(rowEl).top - Helpers$1.elOffset(_this2.elementVertical).top; - default: - if (!isNaN(value) && value !== "") { - sorter = "number"; - } else { - if (value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)) { - sorter = "alphanum"; - } else { - sorter = "string"; - } + if (offset > 0 && offset < _this2.elementVertical.clientHeight - rowEl.offsetHeight) { + return false; } + } + } - break; + if (typeof position === "undefined") { + position = _this2.table.options.scrollToRowPosition; } - col.sorter = sorter; - cols.push(col); - } + if (position === "nearest") { + position = _this2.scrollToRowNearestTop(row) ? "top" : "bottom"; + } //scroll to row - if (definitions) { - switch (_typeof(definitions)) { - case "function": - this.table.options.columns = definitions.call(this.table, cols); - break; - case "object": - if (Array.isArray(definitions)) { - cols.forEach(function (col) { - var match = definitions.find(function (def) { - return def.field === col.field; - }); + _this2.scrollToRow(row); //align to correct position - if (match) { - Object.assign(col, match); - } - }); + + switch (position) { + case "middle": + case "center": + if (_this2.elementVertical.scrollHeight - _this2.elementVertical.scrollTop == _this2.elementVertical.clientHeight) { + _this2.elementVertical.scrollTop = _this2.elementVertical.scrollTop + (rowEl.offsetTop - _this2.elementVertical.scrollTop) - (_this2.elementVertical.scrollHeight - rowEl.offsetTop) / 2; } else { - cols.forEach(function (col) { - if (definitions[col.field]) { - Object.assign(col, definitions[col.field]); - } - }); + _this2.elementVertical.scrollTop = _this2.elementVertical.scrollTop - _this2.elementVertical.clientHeight / 2; + } + + break; + + case "bottom": + if (_this2.elementVertical.scrollHeight - _this2.elementVertical.scrollTop == _this2.elementVertical.clientHeight) { + _this2.elementVertical.scrollTop = _this2.elementVertical.scrollTop - (_this2.elementVertical.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight; + } else { + _this2.elementVertical.scrollTop = _this2.elementVertical.scrollTop - _this2.elementVertical.clientHeight + rowEl.offsetHeight; } - this.table.options.columns = cols; break; } + + resolve(); } else { - this.table.options.columns = cols; + console.warn("Scroll Error - Row not visible"); + reject("Scroll Error - Row not visible"); } + }); + } + }]); - this.setColumns(this.table.options.columns); - } + return Renderer; + }(CoreFeature); + + var BaiscHorizontal = /*#__PURE__*/function (_Renderer) { + _inherits(BaiscHorizontal, _Renderer); + + var _super = _createSuper(BaiscHorizontal); + + function BaiscHorizontal(table) { + _classCallCheck(this, BaiscHorizontal); + + return _super.call(this, table); + } + + _createClass(BaiscHorizontal, [{ + key: "renderRowCells", + value: function renderRowCells(row) { + row.cells.forEach(function (cell) { + row.element.appendChild(cell.getElement()); + cell.cellRendered(); + }); } }, { - key: "setColumns", - value: function setColumns(cols, row) { - var _this = this; + key: "reinitializeColumnWidths", + value: function reinitializeColumnWidths(columns) { + columns.forEach(function (column) { + column.reinitializeWidth(); + }); + } + }]); - while (this.headersElement.firstChild) { - this.headersElement.removeChild(this.headersElement.firstChild); - } + return BaiscHorizontal; + }(Renderer); - this.columns = []; - this.columnsByIndex = []; - this.columnsByField = {}; //reset frozen columns + var VirtualDomHorizontal = /*#__PURE__*/function (_Renderer) { + _inherits(VirtualDomHorizontal, _Renderer); - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.reset(); - } + var _super = _createSuper(VirtualDomHorizontal); - cols.forEach(function (def, i) { - _this._addColumn(def); - }); + function VirtualDomHorizontal(table) { + var _this; - this._reIndexColumns(); + _classCallCheck(this, VirtualDomHorizontal); - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.initialize(); + _this = _super.call(this, table); + _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; //pixel margin to make column visible before it is shown on screen + + _this.initialized = false; + _this.columns = []; + return _this; + } + + _createClass(VirtualDomHorizontal, [{ + key: "initialize", + value: function initialize() { + this.compatabilityCheck(); + } + }, { + key: "compatabilityCheck", + value: function compatabilityCheck() { + var columns = this.options("columns"), + frozen = false, + ok = true; + + if (this.options("layout") == "fitDataTable") { + console.warn("Horizontal Vitrual DOM is not compatible with fitDataTable layout mode"); + ok = false; } - if (this.table.options.virtualDomHoz) { - this.table.vdomHoz.reinitialize(false, true); + if (this.options("responsiveLayout")) { + console.warn("Horizontal Vitrual DOM is not compatible with responsive columns"); + ok = false; } - this.redraw(true); - } - }, { - key: "_addColumn", - value: function _addColumn(definition, before, nextToColumn) { - var column = new Column$1(definition, this), - colEl = column.getElement(), - index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn; + if (this.options("rtl")) { + console.warn("Horizontal Vitrual DOM is not currently compatible with RTL text direction"); + ok = false; + } - if (nextToColumn && index > -1) { - var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn()); - var nextEl = nextToColumn.getElement(); + if (columns) { + frozen = columns.find(function (col) { + return col.frozen; + }); - if (before) { - this.columns.splice(parentIndex, 0, column); - nextEl.parentNode.insertBefore(colEl, nextEl); - } else { - this.columns.splice(parentIndex + 1, 0, column); - nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling); - } - } else { - if (before) { - this.columns.unshift(column); - this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild); - } else { - this.columns.push(column); - this.headersElement.appendChild(column.getElement()); + if (frozen) { + console.warn("Horizontal Vitrual DOM is not compatible with frozen columns"); + ok = false; } + } - column.columnRendered(); + if (!ok) { + options.virtualDomHoz = false; } - return column; - } + return ok; + } ////////////////////////////////////// + ///////// Public Functions /////////// + ////////////////////////////////////// + }, { - key: "registerColumnField", - value: function registerColumnField(col) { - if (col.definition.field) { - this.columnsByField[col.definition.field] = col; - } + key: "renderColumns", + value: function renderColumns(row, force) { + this.dataChange(); } }, { - key: "registerColumnPosition", - value: function registerColumnPosition(col) { - this.columnsByIndex.push(col); + key: "scrollColumns", + value: function scrollColumns(left, dir) { + if (this.scrollLeft != left) { + this.scrollLeft = left; + this.scroll(left - (this.vDomScrollPosLeft + this.window)); + } } }, { - key: "_reIndexColumns", - value: function _reIndexColumns() { - this.columnsByIndex = []; - this.columns.forEach(function (column) { - column.reRegisterPosition(); - }); - } //ensure column headers take up the correct amount of space in column groups - - }, { - key: "_verticalAlignHeaders", - value: function _verticalAlignHeaders() { + key: "rerenderColumns", + value: function rerenderColumns(update, blockRedraw) { var _this2 = this; - var minHeight = 0; - this.columns.forEach(function (column) { - var height; - column.clearVerticalAlign(); - height = column.getHeight(); + var old = { + cols: this.columns, + leftCol: this.leftCol, + rightCol: this.rightCol + }; - if (height > minHeight) { - minHeight = height; - } - }); - this.columns.forEach(function (column) { - column.verticalAlign(_this2.table.options.columnHeaderVertAlign, minHeight); - }); - this.rowManager.adjustTableSize(); - } //////////////// Column Details ///////////////// + if (update && !this.initialized) { + return; + } - }, { - key: "findColumn", - value: function findColumn(subject) { - if (_typeof(subject) == "object") { - if (subject instanceof Column$1) { - //subject is column element - return subject; - } else if (subject instanceof ColumnComponent) { - //subject is public column component - return subject._getSelf() || false; - } else if (typeof HTMLElement !== "undefined" && subject instanceof HTMLElement) { - //subject is a HTML element of the column header - var match = this.columns.find(function (column) { - return column.element === subject; - }); - return match || false; - } - } else { - //subject should be treated as the field name of the column - return this.columnsByField[subject] || false; - } //catch all for any other type of input + this.clear(); + this.scrollLeft = this.elementVertical.scrollLeft; + this.vDomScrollPosLeft = this.scrollLeft - this.window; + this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window; + var colPos = 0; + this.table.columnManager.columnsByIndex.forEach(function (column) { + var config = {}; + if (column.visible) { + var width = column.getWidth(); + config.leftPos = colPos; + config.rightPos = colPos + width; + config.width = width; - return false; - } - }, { - key: "getColumnByField", - value: function getColumnByField(field) { - return this.columnsByField[field]; - } - }, { - key: "getColumnsByFieldRoot", - value: function getColumnsByFieldRoot(root) { - var _this3 = this; + if (_this2.options("layout") === "fitData") { + config.fitDataCheck = true; + } - var matches = []; - Object.keys(this.columnsByField).forEach(function (field) { - var fieldRoot = field.split(".")[0]; + if (colPos + width > _this2.vDomScrollPosLeft && colPos < _this2.vDomScrollPosRight) { + //column is visible + if (_this2.leftCol == -1) { + _this2.leftCol = _this2.columns.length; + _this2.vDomPadLeft = colPos; + } - if (fieldRoot === root) { - matches.push(_this3.columnsByField[field]); - } - }); - return matches; - } - }, { - key: "getColumnByIndex", - value: function getColumnByIndex(index) { - return this.columnsByIndex[index]; - } - }, { - key: "getFirstVisibileColumn", - value: function getFirstVisibileColumn(index) { - var index = this.columnsByIndex.findIndex(function (col) { - return col.visible; - }); - return index > -1 ? this.columnsByIndex[index] : false; - } - }, { - key: "getColumns", - value: function getColumns() { - return this.columns; - } - }, { - key: "findColumnIndex", - value: function findColumnIndex(column) { - return this.columnsByIndex.findIndex(function (col) { - return column === col; - }); - } //return all columns that are not groups + _this2.rightCol = _this2.columns.length; + } else { + // column is hidden + if (_this2.leftCol !== -1) { + _this2.vDomPadRight += width; + } + } - }, { - key: "getRealColumns", - value: function getRealColumns() { - return this.columnsByIndex; - } //travers across columns and call action + _this2.columns.push(column); - }, { - key: "traverse", - value: function traverse(callback) { - this.columnsByIndex.forEach(function (column, i) { - callback(column, i); + column.modules.vdomHoz = config; + colPos += width; + } }); - } //get defintions of actual columns + this.tableElement.style.paddingLeft = this.vDomPadLeft + "px"; + this.tableElement.style.paddingRight = this.vDomPadRight + "px"; + this.initialized = true; - }, { - key: "getDefinitions", - value: function getDefinitions(active) { - var output = []; - this.columnsByIndex.forEach(function (column) { - if (!active || active && column.visible) { - output.push(column.getDefinition()); + if (!blockRedraw) { + if (!update || this.reinitChanged(old)) { + this.renitializeRows(); } - }); - return output; - } //get full nested definition tree + } - }, { - key: "getDefinitionTree", - value: function getDefinitionTree() { - var output = []; - this.columns.forEach(function (column) { - output.push(column.getDefinition(true)); - }); - return output; + this.elementVertical.scrollLeft = this.scrollLeft; } }, { - key: "getComponents", - value: function getComponents(structured) { - var output = [], - columns = structured ? this.columns : this.columnsByIndex; - columns.forEach(function (column) { - output.push(column.getComponent()); - }); - return output; + key: "renderRowCells", + value: function renderRowCells(row) { + if (this.initialized) { + this.initializeRow(row); + } else { + row.cells.forEach(function (cell) { + row.element.appendChild(cell.getElement()); + cell.cellRendered(); + }); + } } }, { - key: "getWidth", - value: function getWidth() { - var width = 0; - this.columnsByIndex.forEach(function (column) { - if (column.visible) { - width += column.getWidth(); - } - }); - return width; + key: "rerenderRowCells", + value: function rerenderRowCells(row, force) { + this.reinitializeRow(row, force); } }, { - key: "moveColumn", - value: function moveColumn(from, to, after) { - this.moveColumnActual(from, to, after); - - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.initialize(); + key: "reinitializeColumnWidths", + value: function reinitializeColumnWidths(columns) { + for (var i = this.leftCol; i <= this.rightCol; i++) { + this.columns[i].reinitializeWidth(); } + } ////////////////////////////////////// + //////// Internal Rendering ////////// + ////////////////////////////////////// - if (this.table.modExists("columnCalcs")) { - this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows); - } + }, { + key: "deinitialize", + value: function deinitialize() { + this.initialized = false; + } + }, { + key: "clear", + value: function clear() { + this.columns = []; + this.leftCol = -1; + this.rightCol = 0; + this.vDomScrollPosLeft = 0; + this.vDomScrollPosRight = 0; + this.vDomPadLeft = 0; + this.vDomPadRight = 0; + } + }, { + key: "dataChange", + value: function dataChange() { + var _this3 = this; - to.element.parentNode.insertBefore(from.element, to.element); + var change = false, + collsWidth = 0, + colEnd = 0, + row, + rowEl; - if (after) { - to.element.parentNode.insertBefore(to.element, from.element); - } + if (this.options("layout") === "fitData") { + this.table.columnManager.columnsByIndex.forEach(function (column) { + if (!column.definition.width && column.visible) { + change = true; + } + }); - this._verticalAlignHeaders(); + if (change) { + if (change && this.table.rowManager.getDisplayRows().length) { + this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.window; + var row = this.chain("rows-sample", [1], [], function () { + return _this3.table.rowManager.getDisplayRows()[0]; + })[0]; - this.table.rowManager.reinitialize(); - } - }, { - key: "moveColumnActual", - value: function moveColumnActual(from, to, after) { - if (from.parent.isGroup) { - this._moveColumnInArray(from.parent.columns, from, to, after); - } else { - this._moveColumnInArray(this.columns, from, to, after); - } + if (row) { + rowEl = row.getElement(); + row.generateCells(); + this.tableElement.appendChild(rowEl); - this._moveColumnInArray(this.columnsByIndex, from, to, after, true); + for (var colEnd = 0; colEnd < row.cells.length; colEnd++) { + var cell = row.cells[colEnd]; + rowEl.appendChild(cell.getElement()); + cell.column.reinitializeWidth(); + collsWidth += cell.column.getWidth(); - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.initialize(); - } + if (collsWidth > this.vDomScrollPosRight) { + break; + } + } - if (this.table.options.virtualDomHoz) { - this.table.vdomHoz.reinitialize(true); - } + rowEl.parentNode.removeChild(rowEl); + this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1)); - if (this.table.options.columnMoved) { - this.table.options.columnMoved.call(this.table, from.getComponent(), this.table.columnManager.getComponents()); - } + for (colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++) { + this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg); + } - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.save("columns"); + this.rerenderColumns(false, true); + } + } + } + } else { + if (this.options("layout") === "fitColumns") { + this.layoutRefresh(); + this.rerenderColumns(false, true); + } } } }, { - key: "_moveColumnInArray", - value: function _moveColumnInArray(columns, from, to, after, updateRows) { + key: "reinitChanged", + value: function reinitChanged(old) { var _this4 = this; - var fromIndex = columns.indexOf(from), - toIndex, - rows = []; - - if (fromIndex > -1) { - columns.splice(fromIndex, 1); - toIndex = columns.indexOf(to); - - if (toIndex > -1) { - if (after) { - toIndex = toIndex + 1; - } - } else { - toIndex = fromIndex; - } - - columns.splice(toIndex, 0, from); - - if (updateRows) { - if (this.table.options.dataTree && this.table.modExists("dataTree", true)) { - this.table.rowManager.rows.forEach(function (row) { - rows = rows.concat(_this4.table.modules.dataTree.getTreeChildren(row, false, true)); - }); - } - - rows = rows.concat(this.table.rowManager.rows); - rows.forEach(function (row) { - if (row.cells.length) { - var cell = row.cells.splice(fromIndex, 1)[0]; - row.cells.splice(toIndex, 0, cell); - } - }); - } - } - } - }, { - key: "scrollToColumn", - value: function scrollToColumn(column, position, ifVisible) { - var _this5 = this; - - var left = 0, - offset = 0, - adjust = 0, - colEl = column.getElement(); - return new Promise(function (resolve, reject) { - if (typeof position === "undefined") { - position = _this5.table.options.scrollToColumnPosition; - } - - if (typeof ifVisible === "undefined") { - ifVisible = _this5.table.options.scrollToColumnIfVisible; - } - - if (column.visible) { - //align to correct position - switch (position) { - case "middle": - case "center": - adjust = -_this5.element.clientWidth / 2; - break; - - case "right": - adjust = colEl.clientWidth - _this5.headersElement.clientWidth; - break; - } //check column visibility - - - if (!ifVisible) { - offset = colEl.offsetLeft; - - if (offset > 0 && offset + colEl.offsetWidth < _this5.element.clientWidth) { - return false; - } - } //calculate scroll position - - - left = colEl.offsetLeft + adjust; - left = Math.max(Math.min(left, _this5.table.rowManager.element.scrollWidth - _this5.table.rowManager.element.clientWidth), 0); - - _this5.table.rowManager.scrollHorizontal(left); - - _this5.scrollHorizontal(left); - - resolve(); - } else { - console.warn("Scroll Error - Column not visible"); - reject("Scroll Error - Column not visible"); - } - }); - } //////////////// Cell Management ///////////////// - - }, { - key: "generateCells", - value: function generateCells(row) { - var cells = []; - this.columnsByIndex.forEach(function (column) { - cells.push(column.generateCell(row)); - }); - return cells; - } //////////////// Column Management ///////////////// - - }, { - key: "getFlexBaseWidth", - value: function getFlexBaseWidth() { - var totalWidth = this.table.element.clientWidth, - //table element width - fixedWidth = 0; //adjust for vertical scrollbar if present + var match = true; - if (this.rowManager.element.scrollHeight > this.rowManager.element.clientHeight) { - totalWidth -= this.rowManager.element.offsetWidth - this.rowManager.element.clientWidth; + if (old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol) { + return true; } - this.columnsByIndex.forEach(function (column) { - var width, minWidth, colWidth; - - if (column.visible) { - width = column.definition.width || 0; - minWidth = typeof column.minWidth == "undefined" ? this.table.options.columnMinWidth : parseInt(column.minWidth); - - if (typeof width == "string") { - if (width.indexOf("%") > -1) { - colWidth = totalWidth / 100 * parseInt(width); - } else { - colWidth = parseInt(width); - } - } else { - colWidth = width; - } - - fixedWidth += colWidth > minWidth ? colWidth : minWidth; + old.cols.forEach(function (col, i) { + if (col !== _this4.columns[i]) { + match = false; } }); - return fixedWidth; + return !match; } }, { - key: "addColumn", - value: function addColumn(definition, before, nextToColumn) { - var _this6 = this; - - return new Promise(function (resolve, reject) { - var column = _this6._addColumn(definition, before, nextToColumn); - - _this6._reIndexColumns(); - - if (_this6.table.options.responsiveLayout && _this6.table.modExists("responsiveLayout", true)) { - _this6.table.modules.responsiveLayout.initialize(); - } - - if (_this6.table.modExists("columnCalcs")) { - _this6.table.modules.columnCalcs.recalc(_this6.table.rowManager.activeRows); - } - - _this6.redraw(true); - - if (_this6.table.modules.layout.getMode() != "fitColumns") { - column.reinitializeWidth(); - } - - _this6._verticalAlignHeaders(); - - _this6.table.rowManager.reinitialize(); - - if (_this6.table.options.virtualDomHoz) { - _this6.table.vdomHoz.reinitialize(); - } + key: "renitializeRows", + value: function renitializeRows() { + var _this5 = this; - resolve(column); + var rows = this.table.rowManager.getVisibleRows(); + rows.forEach(function (row) { + _this5.reinitializeRow(row, true); }); - } //remove column from system - - }, { - key: "deregisterColumn", - value: function deregisterColumn(column) { - var field = column.getField(), - index; //remove from field list - - if (field) { - delete this.columnsByField[field]; - } //remove from index list - - - index = this.columnsByIndex.indexOf(column); - - if (index > -1) { - this.columnsByIndex.splice(index, 1); - } //remove from column list - - - index = this.columns.indexOf(column); - - if (index > -1) { - this.columns.splice(index, 1); - } - - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.initialize(); - } - - this._verticalAlignHeaders(); - - this.redraw(); - } //redraw columns - + } }, { - key: "redraw", - value: function redraw(force) { - if (force) { - if (Helpers.elVisible(this.element)) { - this._verticalAlignHeaders(); - } - - this.table.rowManager.resetScroll(); - this.table.rowManager.reinitialize(); - } + key: "scroll", + value: function scroll(diff) { + this.vDomScrollPosLeft += diff; + this.vDomScrollPosRight += diff; - if (["fitColumns", "fitDataStretch"].indexOf(this.table.modules.layout.getMode()) > -1) { - this.table.modules.layout.layout(); + if (diff > this.elementVertical.clientWidth * .8) { + this.rerenderColumns(); } else { - if (force) { - this.table.modules.layout.layout(); + if (diff > 0) { + //scroll right + this.addColRight(); + this.removeColLeft(); } else { - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.update(); - } - } - } - - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.layout(); - } - - if (this.table.modExists("columnCalcs")) { - this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows); - } - - if (force) { - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.save("columns"); - } - - if (this.table.modExists("columnCalcs")) { - this.table.modules.columnCalcs.redraw(); + //scroll left + this.addColLeft(); + this.removeColRight(); } } - - this.table.footerManager.redraw(); - } - }]); - - return ColumnManager; - }(); - - //public row object - var RowComponent$1 = /*#__PURE__*/function () { - function RowComponent(row) { - _classCallCheck(this, RowComponent); - - this._row = row; - } - - _createClass(RowComponent, [{ - key: "getData", - value: function getData(transform) { - return this._row.getData(transform); } }, { - key: "getElement", - value: function getElement() { - return this._row.getElement(); + key: "colPositionAdjust", + value: function colPositionAdjust(start, end, diff) { + for (var i = start; i < end; i++) { + var column = this.columns[i]; + column.modules.vdomHoz.leftPos += diff; + column.modules.vdomHoz.rightPos += diff; + } } }, { - key: "getCells", - value: function getCells() { - var cells = []; - - this._row.getCells().forEach(function (cell) { - cells.push(cell.getComponent()); - }); - - return cells; - } - }, { - key: "getCell", - value: function getCell(column) { - var cell = this._row.getCell(column); - - return cell ? cell.getComponent() : false; - } - }, { - key: "getIndex", - value: function getIndex() { - return this._row.getData("data")[this._row.table.options.index]; - } - }, { - key: "getPosition", - value: function getPosition(active) { - return this._row.table.rowManager.getRowPosition(this._row, active); - } - }, { - key: "delete", - value: function _delete() { - return this._row["delete"](); - } - }, { - key: "scrollTo", - value: function scrollTo() { - return this._row.table.rowManager.scrollToRow(this._row); - } - }, { - key: "pageTo", - value: function pageTo() { - if (this._row.table.modExists("page", true)) { - return this._row.table.modules.page.setPageToRow(this._row); - } - } - }, { - key: "move", - value: function move(to, after) { - this._row.moveToRow(to, after); - } - }, { - key: "update", - value: function update(data) { - return this._row.updateData(data); - } - }, { - key: "normalizeHeight", - value: function normalizeHeight() { - this._row.normalizeHeight(true); - } - }, { - key: "select", - value: function select() { - this._row.table.modules.selectRow.selectRows(this._row); - } - }, { - key: "deselect", - value: function deselect() { - this._row.table.modules.selectRow.deselectRows(this._row); - } - }, { - key: "toggleSelect", - value: function toggleSelect() { - this._row.table.modules.selectRow.toggleRow(this._row); - } - }, { - key: "isSelected", - value: function isSelected() { - return this._row.table.modules.selectRow.isRowSelected(this._row); - } - }, { - key: "_getSelf", - value: function _getSelf() { - return this._row; - } - }, { - key: "validate", - value: function validate() { - return this._row.validate(); - } - }, { - key: "freeze", - value: function freeze() { - if (this._row.table.modExists("frozenRows", true)) { - this._row.table.modules.frozenRows.freezeRow(this._row); - } - } - }, { - key: "unfreeze", - value: function unfreeze() { - if (this._row.table.modExists("frozenRows", true)) { - this._row.table.modules.frozenRows.unfreezeRow(this._row); - } - } - }, { - key: "isFrozen", - value: function isFrozen() { - if (this._row.table.modExists("frozenRows", true)) { - var index = this._row.table.modules.frozenRows.rows.indexOf(this._row); - - return index > -1; - } - - return false; - } - }, { - key: "treeCollapse", - value: function treeCollapse() { - if (this._row.table.modExists("dataTree", true)) { - this._row.table.modules.dataTree.collapseRow(this._row); - } - } - }, { - key: "treeExpand", - value: function treeExpand() { - if (this._row.table.modExists("dataTree", true)) { - this._row.table.modules.dataTree.expandRow(this._row); - } - } - }, { - key: "treeToggle", - value: function treeToggle() { - if (this._row.table.modExists("dataTree", true)) { - this._row.table.modules.dataTree.toggleRow(this._row); - } - } - }, { - key: "getTreeParent", - value: function getTreeParent() { - if (this._row.table.modExists("dataTree", true)) { - return this._row.table.modules.dataTree.getTreeParent(this._row); - } - - return false; - } - }, { - key: "getTreeChildren", - value: function getTreeChildren() { - if (this._row.table.modExists("dataTree", true)) { - return this._row.table.modules.dataTree.getTreeChildren(this._row, true); - } - - return false; - } - }, { - key: "addTreeChild", - value: function addTreeChild(data, pos, index) { - if (this._row.table.modExists("dataTree", true)) { - return this._row.table.modules.dataTree.addTreeChildRow(this._row, data, pos, index); - } - - return false; - } - }, { - key: "reformat", - value: function reformat() { - return this._row.reinitialize(); - } - }, { - key: "getGroup", - value: function getGroup() { - return this._row.getGroup().getComponent(); - } - }, { - key: "getTable", - value: function getTable() { - return this._row.table; - } - }, { - key: "getNextRow", - value: function getNextRow() { - var row = this._row.nextRow(); - - return row ? row.getComponent() : row; - } - }, { - key: "getPrevRow", - value: function getPrevRow() { - var row = this._row.prevRow(); - - return row ? row.getComponent() : row; - } - }]); - - return RowComponent; - }(); - - var Row$1 = /*#__PURE__*/function () { - function Row(data, parent) { - var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "row"; - - _classCallCheck(this, Row); - - this.table = parent.table; - this.parent = parent; - this.data = {}; - this.type = type; //type of element - - this.element = false; - this.modules = {}; //hold module variables; - - this.cells = []; - this.height = 0; //hold element height - - this.heightStyled = ""; //hold element height prestyled to improve render efficiency - - this.manualHeight = false; //user has manually set row height - - this.outerHeight = 0; //holde lements outer height - - this.initialized = false; //element has been rendered - - this.heightInitialized = false; //element has resized cells to fit - - this.component = null; - this.created = false; - this.setData(data); - } - - _createClass(Row, [{ - key: "create", - value: function create() { - if (!this.created) { - this.created = true; - this.generateElement(); - } - } - }, { - key: "createElement", - value: function createElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-row"); - el.setAttribute("role", "row"); - this.element = el; - } - }, { - key: "getElement", - value: function getElement() { - this.create(); - return this.element; - } - }, { - key: "detachElement", - value: function detachElement() { - if (this.element && this.element.parentNode) { - this.element.parentNode.removeChild(this.element); - } - } - }, { - key: "generateElement", - value: function generateElement() { - var _this = this; - - var dblTap, tapHold, tap; - this.createElement(); //set row selection characteristics - - if (this.table.options.selectable !== false && this.table.modExists("selectRow")) { - this.table.modules.selectRow.initializeRow(this); - } //setup movable rows - - - if (this.table.options.movableRows !== false && this.table.modExists("moveRow")) { - this.table.modules.moveRow.initializeRow(this); - } //setup data tree - - - if (this.table.options.dataTree !== false && this.table.modExists("dataTree")) { - this.table.modules.dataTree.initializeRow(this); - } //setup column colapse container - - - if (this.table.options.responsiveLayout === "collapse" && this.table.modExists("responsiveLayout")) { - this.table.modules.responsiveLayout.initializeRow(this); - } //set column menu - - - if ((this.table.options.rowContextMenu || this.table.options.rowClickMenu) && this.table.modExists("menu")) { - this.table.modules.menu.initializeRow(this); - } //handle row click events - - - if (this.table.options.rowClick) { - this.element.addEventListener("click", function (e) { - _this.table.options.rowClick(e, _this.getComponent()); - }); - } - - if (this.table.options.rowDblClick) { - this.element.addEventListener("dblclick", function (e) { - _this.table.options.rowDblClick(e, _this.getComponent()); - }); - } - - if (this.table.options.rowContext) { - this.element.addEventListener("contextmenu", function (e) { - _this.table.options.rowContext(e, _this.getComponent()); - }); - } //handle mouse events - - - if (this.table.options.rowMouseEnter) { - this.element.addEventListener("mouseenter", function (e) { - _this.table.options.rowMouseEnter(e, _this.getComponent()); - }); - } - - if (this.table.options.rowMouseLeave) { - this.element.addEventListener("mouseleave", function (e) { - _this.table.options.rowMouseLeave(e, _this.getComponent()); - }); - } - - if (this.table.options.rowMouseOver) { - this.element.addEventListener("mouseover", function (e) { - _this.table.options.rowMouseOver(e, _this.getComponent()); - }); - } - - if (this.table.options.rowMouseOut) { - this.element.addEventListener("mouseout", function (e) { - _this.table.options.rowMouseOut(e, _this.getComponent()); - }); - } - - if (this.table.options.rowMouseMove) { - this.element.addEventListener("mousemove", function (e) { - _this.table.options.rowMouseMove(e, _this.getComponent()); - }); - } - - if (this.table.options.rowTap) { - tap = false; - this.element.addEventListener("touchstart", function (e) { - tap = true; - }, { - passive: true - }); - this.element.addEventListener("touchend", function (e) { - if (tap) { - _this.table.options.rowTap(e, _this.getComponent()); - } - - tap = false; - }); - } - - if (this.table.options.rowDblTap) { - dblTap = null; - this.element.addEventListener("touchend", function (e) { - if (dblTap) { - clearTimeout(dblTap); - dblTap = null; - - _this.table.options.rowDblTap(e, _this.getComponent()); - } else { - dblTap = setTimeout(function () { - clearTimeout(dblTap); - dblTap = null; - }, 300); - } - }); - } - - if (this.table.options.rowTapHold) { - tapHold = null; - this.element.addEventListener("touchstart", function (e) { - clearTimeout(tapHold); - tapHold = setTimeout(function () { - clearTimeout(tapHold); - tapHold = null; - tap = false; - - _this.table.options.rowTapHold(e, _this.getComponent()); - }, 1000); - }, { - passive: true - }); - this.element.addEventListener("touchend", function (e) { - clearTimeout(tapHold); - tapHold = null; - }); - } - } - }, { - key: "generateCells", - value: function generateCells() { - this.cells = this.table.columnManager.generateCells(this); - } //functions to setup on first render - - }, { - key: "initialize", - value: function initialize(force) { - var _this2 = this; - - this.create(); - - if (!this.initialized || force) { - this.deleteCells(); - - while (this.element.firstChild) { - this.element.removeChild(this.element.firstChild); - } //handle frozen cells - - - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.layoutRow(this); - } - - this.generateCells(); - - if (this.table.options.virtualDomHoz && this.table.vdomHoz.initialized) { - this.table.vdomHoz.initializeRow(this); - } else { - this.cells.forEach(function (cell) { - _this2.element.appendChild(cell.getElement()); + key: "addColRight", + value: function addColRight() { + var column = this.columns[this.rightCol + 1], + rows; + if (column && column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight) { + rows = this.table.rowManager.getVisibleRows(); + rows.forEach(function (row) { + if (row.type !== "group") { + var cell = row.getCell(column); + row.getElement().appendChild(cell.getElement()); cell.cellRendered(); - }); - } - - if (force) { - this.normalizeHeight(); - } //setup movable rows - - - if (this.table.options.dataTree && this.table.modExists("dataTree")) { - this.table.modules.dataTree.layoutRow(this); - } //setup column colapse container - + } + }); + this.fitDataColActualWidthCheck(column); + this.rightCol++; - if (this.table.options.responsiveLayout === "collapse" && this.table.modExists("responsiveLayout")) { - this.table.modules.responsiveLayout.layoutRow(this); + if (this.rightCol >= this.columns.length - 1) { + this.vDomPadRight = 0; + } else { + this.vDomPadRight -= column.getWidth(); } - if (this.table.options.rowFormatter) { - this.table.options.rowFormatter(this.getComponent()); - } //set resizable handles + this.tableElement.style.paddingRight = this.vDomPadRight + "px"; + this.addColRight(); + } + } + }, { + key: "addColLeft", + value: function addColLeft() { + var column = this.columns[this.leftCol - 1], + rows; + if (column && column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft) { + var rows = this.table.rowManager.getVisibleRows(); + rows.forEach(function (row) { + if (row.type !== "group") { + var cell = row.getCell(column); + row.getElement().prepend(cell.getElement()); + cell.cellRendered(); + } + }); + this.fitDataColActualWidthCheck(column); - if (this.table.options.resizableRows && this.table.modExists("resizeRows")) { - this.table.modules.resizeRows.initializeRow(this); + if (!this.leftCol) { + this.vDomPadLeft = 0; + } else { + this.vDomPadLeft -= column.getWidth(); } - this.initialized = true; - } else { - if (this.table.options.virtualDomHoz) { - this.table.vdomHoz.reinitializeRow(this); - } + this.tableElement.style.paddingLeft = this.vDomPadLeft + "px"; + this.leftCol--; + this.addColLeft(); } } }, { - key: "reinitializeHeight", - value: function reinitializeHeight() { - this.heightInitialized = false; + key: "removeColRight", + value: function removeColRight(column) { + var column = this.columns[this.rightCol], + rows; - if (this.element && this.element.offsetParent !== null) { - this.normalizeHeight(true); + if (column && column.modules.vdomHoz.leftPos > this.vDomScrollPosRight) { + rows = this.table.rowManager.getVisibleRows(); + column.modules.vdomHoz.visible = false; + rows.forEach(function (row) { + if (row.type !== "group") { + var cell = row.getCell(column); + row.getElement().removeChild(cell.getElement()); + } + }); + this.vDomPadRight += column.getWidth(); + this.tableElement.style.paddingRight = this.vDomPadRight + "px"; + this.rightCol--; + this.removeColRight(); } } }, { - key: "reinitialize", - value: function reinitialize(children) { - this.initialized = false; - this.heightInitialized = false; - - if (!this.manualHeight) { - this.height = 0; - this.heightStyled = ""; - } - - if (this.element && this.element.offsetParent !== null) { - this.initialize(true); - } + key: "removeColLeft", + value: function removeColLeft() { + var column = this.columns[this.leftCol], + rows; - if (this.table.options.dataTree && this.table.modExists("dataTree", true)) { - this.table.modules.dataTree.getTreeChildren(this, false, true).forEach(function (child) { - child.reinitialize(true); + if (column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft) { + rows = this.table.rowManager.getVisibleRows(); + rows.forEach(function (row) { + if (row.type !== "group") { + var cell = row.getCell(column); + row.getElement().removeChild(cell.getElement()); + } }); + this.vDomPadLeft += column.getWidth(); + this.tableElement.style.paddingLeft = this.vDomPadLeft + "px"; + this.leftCol++; + this.removeColLeft(); } - } //get heights when doing bulk row style calcs in virtual DOM - + } }, { - key: "calcHeight", - value: function calcHeight(force) { - var maxHeight = 0, - minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0; - this.cells.forEach(function (cell) { - var height = cell.getHeight(); + key: "fitDataColActualWidthCheck", + value: function fitDataColActualWidthCheck(column) { + var newWidth, widthDiff; - if (height > maxHeight) { - maxHeight = height; + if (column.modules.vdomHoz.fitDataCheck) { + column.reinitializeWidth(); + newWidth = column.getWidth(); + widthDiff = newWidth - column.modules.vdomHoz.width; + + if (widthDiff) { + column.modules.vdomHoz.rightPos += widthDiff; + column.modules.vdomHoz.width = newWidth; + this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff); } - }); - if (force) { - this.height = Math.max(maxHeight, minHeight); - } else { - this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight); + column.modules.vdomHoz.fitDataCheck = false; } + } + }, { + key: "initializeRow", + value: function initializeRow(row) { + if (row.type !== "group") { + row.modules.vdomHoz = { + leftCol: this.leftCol, + rightCol: this.rightCol + }; - this.heightStyled = this.height ? this.height + "px" : ""; - this.outerHeight = this.element.offsetHeight; - } //set of cells + for (var i = this.leftCol; i <= this.rightCol; i++) { + var column = this.columns[i]; - }, { - key: "setCellHeight", - value: function setCellHeight() { - this.cells.forEach(function (cell) { - cell.setHeight(); - }); - this.heightInitialized = true; + if (column && column.visible) { + var cell = row.getCell(column); + row.getElement().appendChild(cell.getElement()); + cell.cellRendered(); + } + } + } } }, { - key: "clearCellHeight", - value: function clearCellHeight() { - this.cells.forEach(function (cell) { - cell.clearHeight(); - }); - } //normalize the height of elements in the row + key: "reinitializeRow", + value: function reinitializeRow(row, force) { + if (row.type !== "group") { + if (force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol) { + var rowEl = row.getElement(); - }, { - key: "normalizeHeight", - value: function normalizeHeight(force) { - if (force) { - this.clearCellHeight(); + while (rowEl.firstChild) { + rowEl.removeChild(rowEl.firstChild); + } + + this.initializeRow(row); + } } + } + }]); - this.calcHeight(force); - this.setCellHeight(); - } //set height of rows + return VirtualDomHorizontal; + }(Renderer); - }, { - key: "setHeight", - value: function setHeight(height, force) { - if (this.height != height || force) { - this.manualHeight = true; - this.height = height; - this.heightStyled = height ? height + "px" : ""; - this.setCellHeight(); // this.outerHeight = this.element.outerHeight(); + var ColumnManager = /*#__PURE__*/function (_CoreFeature) { + _inherits(ColumnManager, _CoreFeature); - this.outerHeight = this.element.offsetHeight; - } - } //return rows outer height + var _super = _createSuper(ColumnManager); - }, { - key: "getHeight", - value: function getHeight() { - return this.outerHeight; - } //return rows outer Width + function ColumnManager(table) { + var _this; - }, { - key: "getWidth", - value: function getWidth() { - return this.element.offsetWidth; - } //////////////// Cell Management ///////////////// + _classCallCheck(this, ColumnManager); - }, { - key: "deleteCell", - value: function deleteCell(cell) { - var index = this.cells.indexOf(cell); + _this = _super.call(this, table); + _this.blockHozScrollEvent = false; + _this.headersElement = null; + _this.element = null; //containing element - if (index > -1) { - this.cells.splice(index, 1); - } - } //////////////// Data Management ///////////////// + _this.columns = []; // column definition object - }, { - key: "setData", - value: function setData(data) { - if (this.table.modExists("mutator")) { - data = this.table.modules.mutator.transformRow(data, "data"); + _this.columnsByIndex = []; //columns by index + + _this.columnsByField = {}; //columns by field + + _this.scrollLeft = 0; + _this.optionsList = new OptionsList(_this.table, "column definition"); + _this.renderer = null; + return _this; + } ////////////// Setup Functions ///////////////// + + + _createClass(ColumnManager, [{ + key: "initialize", + value: function initialize() { + this.initializeRenderer(); + this.headersElement = this.createHeadersElement(); + this.element = this.createHeaderElement(); + this.element.insertBefore(this.headersElement, this.element.firstChild); + this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this)); + } + }, { + key: "initializeRenderer", + value: function initializeRenderer() { + var renderClass; + var renderers = { + "virtual": VirtualDomHorizontal, + "basic": BaiscHorizontal + }; + + if (typeof this.table.options.renderVertical === "string") { + renderClass = renderers[this.table.options.renderVertical]; + } else { + renderClass = this.table.options.renderVertical; } - this.data = data; + if (renderClass) { + this.renderer = new renderClass(this.table, this.element, this.tableElement); + this.renderer.initialize(); + } else { + console.error("Unable to find matching renderer:", table.options.renderVertical); + } + } + }, { + key: "createHeadersElement", + value: function createHeadersElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-headers"); + return el; + } + }, { + key: "createHeaderElement", + value: function createHeaderElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-header"); - if (this.table.options.reactiveData && this.table.modExists("reactiveData", true)) { - this.table.modules.reactiveData.watchRow(this); + if (!this.table.options.headerVisible) { + el.classList.add("tabulator-header-hidden"); } - } //update the rows data + + return el; + } //return containing element }, { - key: "updateData", - value: function updateData(updatedData) { - var _this3 = this; + key: "getElement", + value: function getElement() { + return this.element; + } //return header containing element - var visible = this.element && Helpers.elVisible(this.element), - tempData = {}, - newRowData; - return new Promise(function (resolve, reject) { - if (typeof updatedData === "string") { - updatedData = JSON.parse(updatedData); - } + }, { + key: "getHeadersElement", + value: function getHeadersElement() { + return this.headersElement; + } //scroll horizontally to match table body - if (_this3.table.options.reactiveData && _this3.table.modExists("reactiveData", true)) { - _this3.table.modules.reactiveData.block(); - } //mutate incomming data if needed + }, { + key: "scrollHorizontal", + value: function scrollHorizontal(left) { + var hozAdjust = 0, + scrollWidth = this.element.scrollWidth - this.table.element.clientWidth; // this.tempScrollBlock(); + this.element.scrollLeft = left; //adjust for vertical scrollbar moving table when present - if (_this3.table.modExists("mutator")) { - tempData = Object.assign(tempData, _this3.data); - tempData = Object.assign(tempData, updatedData); - newRowData = _this3.table.modules.mutator.transformRow(tempData, "data", updatedData); - } else { - newRowData = updatedData; - } //set data + if (left > scrollWidth) { + hozAdjust = left - scrollWidth; + this.element.style.marginLeft = -hozAdjust + "px"; + } else { + this.element.style.marginLeft = 0; + } + this.scrollLeft = left; + this.renderer.scrollColumns(left); + } ///////////// Column Setup Functions ///////////// - for (var attrname in newRowData) { - _this3.data[attrname] = newRowData[attrname]; - } + }, { + key: "generateColumnsFromRowData", + value: function generateColumnsFromRowData(data) { + var cols = [], + definitions = this.table.options.autoColumnsDefinitions, + row, + sorter; - if (_this3.table.options.reactiveData && _this3.table.modExists("reactiveData", true)) { - _this3.table.modules.reactiveData.unblock(); - } //update affected cells only + if (data && data.length) { + row = data[0]; + for (var key in row) { + var col = { + field: key, + title: key + }; + var value = row[key]; - for (var attrname in updatedData) { - var columns = _this3.table.columnManager.getColumnsByFieldRoot(attrname); + switch (_typeof(value)) { + case "undefined": + sorter = "string"; + break; - columns.forEach(function (column) { - var cell = _this3.getCell(column.getField()); + case "boolean": + sorter = "boolean"; + break; - if (cell) { - var value = column.getFieldValue(newRowData); + case "object": + if (Array.isArray(value)) { + sorter = "array"; + } else { + sorter = "string"; + } - if (cell.getValue() != value) { - cell.setValueProcessData(value); + break; - if (visible) { - cell.cellRendered(); + default: + if (!isNaN(value) && value !== "") { + sorter = "number"; + } else { + if (value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)) { + sorter = "alphanum"; + } else { + sorter = "string"; } } - } - }); + + break; + } + + col.sorter = sorter; + cols.push(col); } - if (_this3.table.options.groupUpdateOnCellEdit && _this3.table.options.groupBy && _this3.table.modExists("groupRows")) { - _this3.table.modules.groupRows.reassignRowToGroup(_this3.row); - } //Partial reinitialization if visible + if (definitions) { + switch (_typeof(definitions)) { + case "function": + this.table.options.columns = definitions.call(this.table, cols); + break; + case "object": + if (Array.isArray(definitions)) { + cols.forEach(function (col) { + var match = definitions.find(function (def) { + return def.field === col.field; + }); - if (visible) { - _this3.normalizeHeight(true); + if (match) { + Object.assign(col, match); + } + }); + } else { + cols.forEach(function (col) { + if (definitions[col.field]) { + Object.assign(col, definitions[col.field]); + } + }); + } - if (_this3.table.options.rowFormatter) { - _this3.table.options.rowFormatter(_this3.getComponent()); + this.table.options.columns = cols; + break; } } else { - _this3.initialized = false; - _this3.height = 0; - _this3.heightStyled = ""; + this.table.options.columns = cols; } - if (_this3.table.options.dataTree !== false && _this3.table.modExists("dataTree") && _this3.table.modules.dataTree.redrawNeeded(updatedData)) { - _this3.table.modules.dataTree.initializeRow(_this3); - - if (visible) { - _this3.table.modules.dataTree.layoutRow(_this3); - - _this3.table.rowManager.refreshActiveData("tree", false, true); - } - } //this.reinitialize(); + this.setColumns(this.table.options.columns); + } + } + }, { + key: "setColumns", + value: function setColumns(cols, row) { + var _this2 = this; + while (this.headersElement.firstChild) { + this.headersElement.removeChild(this.headersElement.firstChild); + } - _this3.table.options.rowUpdated.call(_this3.table, _this3.getComponent()); + this.columns = []; + this.columnsByIndex = []; + this.columnsByField = {}; + this.dispatch("columns-loading"); + cols.forEach(function (def, i) { + _this2._addColumn(def); + }); - if (_this3.table.options.dataChanged) { - _this3.table.options.dataChanged.call(_this3.table, _this3.table.rowManager.getData()); - } + this._reIndexColumns(); - resolve(); - }); + this.dispatch("columns-loaded"); + this.renderer.rerenderColumns(false, true); + this.redraw(true); } }, { - key: "getData", - value: function getData(transform) { - if (transform) { - if (this.table.modExists("accessor")) { - return this.table.modules.accessor.transformRow(this, transform); + key: "_addColumn", + value: function _addColumn(definition, before, nextToColumn) { + var column = new Column$1(definition, this), + colEl = column.getElement(), + index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn; + + if (nextToColumn && index > -1) { + var parentIndex = this.columns.indexOf(nextToColumn.getTopColumn()); + var nextEl = nextToColumn.getElement(); + + if (before) { + this.columns.splice(parentIndex, 0, column); + nextEl.parentNode.insertBefore(colEl, nextEl); + } else { + this.columns.splice(parentIndex + 1, 0, column); + nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling); + } + } else { + if (before) { + this.columns.unshift(column); + this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild); + } else { + this.columns.push(column); + this.headersElement.appendChild(column.getElement()); } + + column.columnRendered(); } - return this.data; + return column; } }, { - key: "getCell", - value: function getCell(column) { - var match = false; - column = this.table.columnManager.findColumn(column); - match = this.cells.find(function (cell) { - return cell.column === column; - }); - return match; + key: "registerColumnField", + value: function registerColumnField(col) { + if (col.definition.field) { + this.columnsByField[col.definition.field] = col; + } } }, { - key: "getCellIndex", - value: function getCellIndex(findCell) { - return this.cells.findIndex(function (cell) { - return cell === findCell; - }); + key: "registerColumnPosition", + value: function registerColumnPosition(col) { + this.columnsByIndex.push(col); } }, { - key: "findNextEditableCell", - value: function findNextEditableCell(index) { - var nextCell = false; + key: "_reIndexColumns", + value: function _reIndexColumns() { + this.columnsByIndex = []; + this.columns.forEach(function (column) { + column.reRegisterPosition(); + }); + } //ensure column headers take up the correct amount of space in column groups - if (index < this.cells.length - 1) { - for (var i = index + 1; i < this.cells.length; i++) { - var cell = this.cells[i]; + }, { + key: "_verticalAlignHeaders", + value: function _verticalAlignHeaders() { + var _this3 = this; - if (cell.column.modules.edit && Helpers.elVisible(cell.getElement())) { - var allowEdit = true; + var minHeight = 0; + this.columns.forEach(function (column) { + var height; + column.clearVerticalAlign(); + height = column.getHeight(); - if (typeof cell.column.modules.edit.check == "function") { - allowEdit = cell.column.modules.edit.check(cell.getComponent()); - } + if (height > minHeight) { + minHeight = height; + } + }); + this.columns.forEach(function (column) { + column.verticalAlign(_this3.table.options.columnHeaderVertAlign, minHeight); + }); + this.table.rowManager.adjustTableSize(); + } //////////////// Column Details ///////////////// - if (allowEdit) { - nextCell = cell; - break; - } - } + }, { + key: "findColumn", + value: function findColumn(subject) { + if (_typeof(subject) == "object") { + if (subject instanceof Column$1) { + //subject is column element + return subject; + } else if (subject instanceof ColumnComponent) { + //subject is public column component + return subject._getSelf() || false; + } else if (typeof HTMLElement !== "undefined" && subject instanceof HTMLElement) { + //subject is a HTML element of the column header + var match = this.columns.find(function (column) { + return column.element === subject; + }); + return match || false; } - } + } else { + //subject should be treated as the field name of the column + return this.columnsByField[subject] || false; + } //catch all for any other type of input - return nextCell; + + return false; + } + }, { + key: "getColumnByField", + value: function getColumnByField(field) { + return this.columnsByField[field]; } }, { - key: "findPrevEditableCell", - value: function findPrevEditableCell(index) { - var prevCell = false; - - if (index > 0) { - for (var i = index - 1; i >= 0; i--) { - var cell = this.cells[i], - allowEdit = true; + key: "getColumnsByFieldRoot", + value: function getColumnsByFieldRoot(root) { + var _this4 = this; - if (cell.column.modules.edit && Helpers.elVisible(cell.getElement())) { - if (typeof cell.column.modules.edit.check == "function") { - allowEdit = cell.column.modules.edit.check(cell.getComponent()); - } + var matches = []; + Object.keys(this.columnsByField).forEach(function (field) { + var fieldRoot = field.split(".")[0]; - if (allowEdit) { - prevCell = cell; - break; - } - } + if (fieldRoot === root) { + matches.push(_this4.columnsByField[field]); } - } - - return prevCell; - } - }, { - key: "getCells", - value: function getCells() { - return this.cells; + }); + return matches; } }, { - key: "nextRow", - value: function nextRow() { - var row = this.table.rowManager.nextDisplayRow(this, true); - return row || false; + key: "getColumnByIndex", + value: function getColumnByIndex(index) { + return this.columnsByIndex[index]; } }, { - key: "prevRow", - value: function prevRow() { - var row = this.table.rowManager.prevDisplayRow(this, true); - return row || false; + key: "getFirstVisibileColumn", + value: function getFirstVisibileColumn(index) { + var index = this.columnsByIndex.findIndex(function (col) { + return col.visible; + }); + return index > -1 ? this.columnsByIndex[index] : false; } }, { - key: "moveToRow", - value: function moveToRow(to, before) { - var toRow = this.table.rowManager.findRow(to); - - if (toRow) { - this.table.rowManager.moveRowActual(this, toRow, !before); - this.table.rowManager.refreshActiveData("display", false, true); - } else { - console.warn("Move Error - No matching row found:", to); - } + key: "getColumns", + value: function getColumns() { + return this.columns; } }, { - key: "validate", - value: function validate() { - var invalid = []; - this.cells.forEach(function (cell) { - if (!cell.validate()) { - invalid.push(cell.getComponent()); - } + key: "findColumnIndex", + value: function findColumnIndex(column) { + return this.columnsByIndex.findIndex(function (col) { + return column === col; }); - return invalid.length ? invalid : true; - } ///////////////////// Actions ///////////////////// + } //return all columns that are not groups }, { - key: "delete", - value: function _delete() { - var _this4 = this; - - return new Promise(function (resolve, reject) { - var index, rows; - - if (_this4.table.options.history && _this4.table.modExists("history")) { - if (_this4.table.options.groupBy && _this4.table.modExists("groupRows")) { - rows = _this4.getGroup().rows; - index = rows.indexOf(_this4); - - if (index) { - index = rows[index - 1]; - } - } else { - index = _this4.table.rowManager.getRowIndex(_this4); + key: "getRealColumns", + value: function getRealColumns() { + return this.columnsByIndex; + } //travers across columns and call action - if (index) { - index = _this4.table.rowManager.rows[index - 1]; - } - } + }, { + key: "traverse", + value: function traverse(callback) { + this.columnsByIndex.forEach(function (column, i) { + callback(column, i); + }); + } //get defintions of actual columns - _this4.table.modules.history.action("rowDelete", _this4, { - data: _this4.getData(), - pos: !index, - index: index - }); + }, { + key: "getDefinitions", + value: function getDefinitions(active) { + var output = []; + this.columnsByIndex.forEach(function (column) { + if (!active || active && column.visible) { + output.push(column.getDefinition()); } + }); + return output; + } //get full nested definition tree - _this4.deleteActual(); - - resolve(); + }, { + key: "getDefinitionTree", + value: function getDefinitionTree() { + var output = []; + this.columns.forEach(function (column) { + output.push(column.getDefinition(true)); }); + return output; } }, { - key: "deleteActual", - value: function deleteActual(blockRedraw) { - var index = this.table.rowManager.getRowIndex(this); - this.detatchModules(); // if(this.table.options.dataTree && this.table.modExists("dataTree")){ - // this.table.modules.dataTree.collapseRow(this, true); - // } - //remove any reactive data watchers from row object - - if (this.table.options.reactiveData && this.table.modExists("reactiveData", true)) ; //remove from group - + key: "getComponents", + value: function getComponents(structured) { + var output = [], + columns = structured ? this.columns : this.columnsByIndex; + columns.forEach(function (column) { + output.push(column.getComponent()); + }); + return output; + } + }, { + key: "getWidth", + value: function getWidth() { + var width = 0; + this.columnsByIndex.forEach(function (column) { + if (column.visible) { + width += column.getWidth(); + } + }); + return width; + } + }, { + key: "moveColumn", + value: function moveColumn(from, to, after) { + this.moveColumnActual(from, to, after); + to.element.parentNode.insertBefore(from.element, to.element); - if (this.modules.group) { - this.modules.group.removeRow(this); + if (after) { + to.element.parentNode.insertBefore(to.element, from.element); } - this.table.rowManager.deleteRow(this, blockRedraw); - this.deleteCells(); - this.initialized = false; - this.heightInitialized = false; - this.element = false; - - if (this.table.options.dataTree && this.table.modExists("dataTree", true)) { - this.table.modules.dataTree.rowDelete(this); - } //recalc column calculations if present - + this._verticalAlignHeaders(); - if (this.table.modExists("columnCalcs")) { - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.columnCalcs.recalcRowGroup(this); - } else { - this.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows); - } - } + this.table.rowManager.reinitialize(); } }, { - key: "detatchModules", - value: function detatchModules() { - //deselect row if it is selected - if (this.table.modExists("selectRow")) { - this.table.modules.selectRow._deselectRow(this, true); - } //cancel edit if row is currently being edited + key: "moveColumnActual", + value: function moveColumnActual(from, to, after) { + if (from.parent.isGroup) { + this._moveColumnInArray(from.parent.columns, from, to, after); + } else { + this._moveColumnInArray(this.columns, from, to, after); + } + this._moveColumnInArray(this.columnsByIndex, from, to, after, true); - if (this.table.modExists("edit")) { - if (this.table.modules.edit.currentCell.row === this) { - this.table.modules.edit.cancelEdit(); - } - } + this.renderer.rerenderColumns(true); + this.dispatch("column-moved", from, to, after); - if (this.table.modExists("frozenRows")) { - this.table.modules.frozenRows.detachRow(this); + if (this.subscribedExternal("columnMoved")) { + this.dispatchExternal("columnMoved", from.getComponent(), this.table.columnManager.getComponents()); } } }, { - key: "deleteCells", - value: function deleteCells() { - var cellCount = this.cells.length; + key: "_moveColumnInArray", + value: function _moveColumnInArray(columns, from, to, after, updateRows) { + var fromIndex = columns.indexOf(from), + toIndex, + rows = []; - for (var i = 0; i < cellCount; i++) { - this.cells[0]["delete"](); - } - } - }, { - key: "wipe", - value: function wipe() { - this.detatchModules(); - this.deleteCells(); + if (fromIndex > -1) { + columns.splice(fromIndex, 1); + toIndex = columns.indexOf(to); - if (this.element) { - while (this.element.firstChild) { - this.element.removeChild(this.element.firstChild); + if (toIndex > -1) { + if (after) { + toIndex = toIndex + 1; + } + } else { + toIndex = fromIndex; } - if (this.element.parentNode) { - this.element.parentNode.removeChild(this.element); + columns.splice(toIndex, 0, from); + + if (updateRows) { + rows = this.chain("column-moving-rows", [from, to, after], null, []) || []; + rows = rows.concat(this.table.rowManager.rows); + rows.forEach(function (row) { + if (row.cells.length) { + var cell = row.cells.splice(fromIndex, 1)[0]; + row.cells.splice(toIndex, 0, cell); + } + }); } } - - this.element = false; - this.modules = {}; } }, { - key: "getGroup", - value: function getGroup() { - return this.modules.group || false; - } //////////////// Object Generation ///////////////// - - }, { - key: "getComponent", - value: function getComponent() { - if (!this.component) { - this.component = new RowComponent$1(this); - } - - return this.component; - } - }]); - - return Row; - }(); - - var RowManager = /*#__PURE__*/function () { - function RowManager(table) { - _classCallCheck(this, RowManager); - - this.table = table; - this.element = this.createHolderElement(); //containing element - - this.tableElement = this.createTableElement(); //table element - - this.heightFixer = this.createTableElement(); //table element - - this.columnManager = null; //hold column manager object + key: "scrollToColumn", + value: function scrollToColumn(column, position, ifVisible) { + var _this5 = this; - this.height = 0; //hold height of table element + var left = 0, + offset = 0, + adjust = 0, + colEl = column.getElement(); + return new Promise(function (resolve, reject) { + if (typeof position === "undefined") { + position = _this5.table.options.scrollToColumnPosition; + } - this.firstRender = false; //handle first render + if (typeof ifVisible === "undefined") { + ifVisible = _this5.table.options.scrollToColumnIfVisible; + } - this.renderMode = "virtual"; //current rendering mode + if (column.visible) { + //align to correct position + switch (position) { + case "middle": + case "center": + adjust = -_this5.element.clientWidth / 2; + break; - this.fixedHeight = false; //current rendering mode + case "right": + adjust = colEl.clientWidth - _this5.headersElement.clientWidth; + break; + } //check column visibility - this.rows = []; //hold row data objects - this.activeRows = []; //rows currently available to on display in the table + if (!ifVisible) { + offset = colEl.offsetLeft; - this.activeRowsCount = 0; //count of active rows + if (offset > 0 && offset + colEl.offsetWidth < _this5.element.clientWidth) { + return false; + } + } //calculate scroll position - this.displayRows = []; //rows currently on display in the table - this.displayRowsCount = 0; //count of display rows + left = colEl.offsetLeft + adjust; + left = Math.max(Math.min(left, _this5.table.rowManager.element.scrollWidth - _this5.table.rowManager.element.clientWidth), 0); - this.scrollTop = 0; - this.scrollLeft = 0; - this.vDomRowHeight = 20; //approximation of row heights for padding + _this5.table.rowManager.scrollHorizontal(left); - this.vDomTop = 0; //hold position for first rendered row in the virtual DOM + _this5.scrollHorizontal(left); - this.vDomBottom = 0; //hold possition for last rendered row in the virtual DOM + resolve(); + } else { + console.warn("Scroll Error - Column not visible"); + reject("Scroll Error - Column not visible"); + } + }); + } //////////////// Cell Management ///////////////// - this.vDomScrollPosTop = 0; //last scroll position of the vDom top; + }, { + key: "generateCells", + value: function generateCells(row) { + var cells = []; + this.columnsByIndex.forEach(function (column) { + cells.push(column.generateCell(row)); + }); + return cells; + } //////////////// Column Management ///////////////// - this.vDomScrollPosBottom = 0; //last scroll position of the vDom bottom; + }, { + key: "getFlexBaseWidth", + value: function getFlexBaseWidth() { + var totalWidth = this.table.element.clientWidth, + //table element width + fixedWidth = 0; //adjust for vertical scrollbar if present - this.vDomTopPad = 0; //hold value of padding for top of virtual DOM + if (this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight) { + totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth; + } - this.vDomBottomPad = 0; //hold value of padding for bottom of virtual DOM + this.columnsByIndex.forEach(function (column) { + var width, minWidth, colWidth; - this.vDomMaxRenderChain = 90; //the maximum number of dom elements that can be rendered in 1 go + if (column.visible) { + width = column.definition.width || 0; + minWidth = parseInt(column.minWidth); - this.vDomWindowBuffer = 0; //window row buffer before removing elements, to smooth scrolling + if (typeof width == "string") { + if (width.indexOf("%") > -1) { + colWidth = totalWidth / 100 * parseInt(width); + } else { + colWidth = parseInt(width); + } + } else { + colWidth = width; + } - this.vDomWindowMinTotalRows = 20; //minimum number of rows to be generated in virtual dom (prevent buffering issues on tables with tall rows) + fixedWidth += colWidth > minWidth ? colWidth : minWidth; + } + }); + return fixedWidth; + } + }, { + key: "addColumn", + value: function addColumn(definition, before, nextToColumn) { + var _this6 = this; - this.vDomWindowMinMarginRows = 5; //minimum number of rows to be generated in virtual dom margin + return new Promise(function (resolve, reject) { + var column = _this6._addColumn(definition, before, nextToColumn); - this.vDomTopNewRows = []; //rows to normalize after appending to optimize render speed + _this6._reIndexColumns(); - this.vDomBottomNewRows = []; //rows to normalize after appending to optimize render speed + _this6.dispatch("column-add", definition, before, nextToColumn); - this.rowNumColumn = false; //hold column component for row number column + _this6.redraw(true); - this.redrawBlock = false; //prevent redraws to allow multiple data manipulations becore continuing + if (_this6.layoutMode() != "fitColumns") { + column.reinitializeWidth(); + } - this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed + _this6._verticalAlignHeaders(); - this.redrawBlockRederInPosition = false; //store latest redraw function calls for when redraw is needed - } //////////////// Setup Functions ///////////////// + _this6.table.rowManager.reinitialize(); + _this6.renderer.rerenderColumns(); - _createClass(RowManager, [{ - key: "createHolderElement", - value: function createHolderElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-tableHolder"); - el.setAttribute("tabindex", 0); - return el; - } - }, { - key: "createTableElement", - value: function createTableElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-table"); - return el; - } //return containing element + resolve(column); + }); + } //remove column from system }, { - key: "getElement", - value: function getElement() { - return this.element; - } //return table element + key: "deregisterColumn", + value: function deregisterColumn(column) { + var field = column.getField(), + index; //remove from field list - }, { - key: "getTableElement", - value: function getTableElement() { - return this.tableElement; - } //return position of row in table + if (field) { + delete this.columnsByField[field]; + } //remove from index list - }, { - key: "getRowPosition", - value: function getRowPosition(row, active) { - if (active) { - return this.activeRows.indexOf(row); - } else { - return this.rows.indexOf(row); - } - } //link to column manager - }, { - key: "setColumnManager", - value: function setColumnManager(manager) { - this.columnManager = manager; - } - }, { - key: "initialize", - value: function initialize() { - var _this = this; + index = this.columnsByIndex.indexOf(column); - this.setRenderMode(); //initialize manager + if (index > -1) { + this.columnsByIndex.splice(index, 1); + } //remove from column list - this.element.appendChild(this.tableElement); - this.firstRender = true; //scroll header along with table body - this.element.addEventListener("scroll", function () { - var left = _this.element.scrollLeft; //handle horizontal scrolling + index = this.columns.indexOf(column); - if (_this.scrollLeft != left) { - _this.columnManager.scrollHorizontal(left); + if (index > -1) { + this.columns.splice(index, 1); + } - if (_this.table.options.groupBy) { - _this.table.modules.groupRows.scrollHeaders(left); - } + this._verticalAlignHeaders(); - if (_this.table.modExists("columnCalcs")) { - _this.table.modules.columnCalcs.scrollHorizontal(left); - } + this.redraw(); + } //redraw columns - _this.table.options.scrollHorizontal(left); + }, { + key: "redraw", + value: function redraw(force) { + if (force) { + if (Helpers$1.elVisible(this.element)) { + this._verticalAlignHeaders(); } - _this.scrollLeft = left; - }); //handle virtual dom scrolling + this.table.rowManager.resetScroll(); + this.table.rowManager.reinitialize(); + } - if (this.renderMode === "virtual") { - this.element.addEventListener("scroll", function () { - var top = _this.element.scrollTop; - var dir = _this.scrollTop > top; //handle verical scrolling + if (!this.confirm("table-redrawing", force)) { + this.layoutRefresh(); + } - if (_this.scrollTop != top) { - _this.scrollTop = top; + this.dispatch("table-redraw", force); + this.table.footerManager.redraw(); + } + }]); - _this.scrollVertical(dir); + return ColumnManager; + }(CoreFeature); - if (_this.table.options.ajaxProgressiveLoad == "scroll") { - _this.table.modules.ajax.nextPage(_this.element.scrollHeight - _this.element.clientHeight - top); - } + //public row object + var RowComponent$1 = /*#__PURE__*/function () { + function RowComponent(row) { + _classCallCheck(this, RowComponent); - _this.table.options.scrollVertical(top); - } else { - _this.scrollTop = top; - } - }); + this._row = row; + return new Proxy(this, { + get: function get(target, name, receiver) { + if (typeof target[name] !== "undefined") { + return target[name]; + } else { + return target._row.table.componentFunctionBinder.handle("row", target._row, name); + } } - } ////////////////// Row Manipulation ////////////////// + }); + } + _createClass(RowComponent, [{ + key: "getData", + value: function getData(transform) { + return this._row.getData(transform); + } }, { - key: "findRow", - value: function findRow(subject) { - var _this2 = this; - - if (_typeof(subject) == "object") { - if (subject instanceof Row$1) { - //subject is row element - return subject; - } else if (subject instanceof RowComponent) { - //subject is public row component - return subject._getSelf() || false; - } else if (typeof HTMLElement !== "undefined" && subject instanceof HTMLElement) { - //subject is a HTML element of the row - var match = this.rows.find(function (row) { - return row.getElement() === subject; - }); - return match || false; - } - } else if (typeof subject == "undefined" || subject === null) { - return false; - } else { - //subject should be treated as the index of the row - var _match = this.rows.find(function (row) { - return row.data[_this2.table.options.index] == subject; - }); + key: "getElement", + value: function getElement() { + return this._row.getElement(); + } + }, { + key: "getCells", + value: function getCells() { + var cells = []; - return _match || false; - } //catch all for any other type of input + this._row.getCells().forEach(function (cell) { + cells.push(cell.getComponent()); + }); + return cells; + } + }, { + key: "getCell", + value: function getCell(column) { + var cell = this._row.getCell(column); - return false; + return cell ? cell.getComponent() : false; + } + }, { + key: "getIndex", + value: function getIndex() { + return this._row.getData("data")[this._row.table.options.index]; + } + }, { + key: "getPosition", + value: function getPosition(active) { + return this._row.table.rowManager.getRowPosition(this._row, active); + } + }, { + key: "delete", + value: function _delete() { + return this._row["delete"](); + } + }, { + key: "scrollTo", + value: function scrollTo() { + return this._row.table.rowManager.scrollToRow(this._row); + } + }, { + key: "move", + value: function move(to, after) { + this._row.moveToRow(to, after); + } + }, { + key: "update", + value: function update(data) { + return this._row.updateData(data); + } + }, { + key: "normalizeHeight", + value: function normalizeHeight() { + this._row.normalizeHeight(true); } }, { - key: "getRowFromDataObject", - value: function getRowFromDataObject(data) { - var match = this.rows.find(function (row) { - return row.data === data; - }); - return match || false; + key: "_getSelf", + value: function _getSelf() { + return this._row; } }, { - key: "getRowFromPosition", - value: function getRowFromPosition(position, active) { - if (active) { - return this.activeRows[position]; - } else { - return this.rows[position]; - } + key: "reformat", + value: function reformat() { + return this._row.reinitialize(); } }, { - key: "scrollToRow", - value: function scrollToRow(row, position, ifVisible) { - var _this3 = this; - - var rowIndex = this.getDisplayRows().indexOf(row), - rowEl = row.getElement(), - rowTop, - offset = 0; - return new Promise(function (resolve, reject) { - if (rowIndex > -1) { - if (typeof position === "undefined") { - position = _this3.table.options.scrollToRowPosition; - } - - if (typeof ifVisible === "undefined") { - ifVisible = _this3.table.options.scrollToRowIfVisible; - } + key: "getTable", + value: function getTable() { + return this._row.table; + } + }, { + key: "getNextRow", + value: function getNextRow() { + var row = this._row.nextRow(); - if (position === "nearest") { - switch (_this3.renderMode) { - case "classic": - rowTop = Helpers.elOffset(rowEl).top; - position = Math.abs(_this3.element.scrollTop - rowTop) > Math.abs(_this3.element.scrollTop + _this3.element.clientHeight - rowTop) ? "bottom" : "top"; - break; + return row ? row.getComponent() : row; + } + }, { + key: "getPrevRow", + value: function getPrevRow() { + var row = this._row.prevRow(); - case "virtual": - position = Math.abs(_this3.vDomTop - rowIndex) > Math.abs(_this3.vDomBottom - rowIndex) ? "bottom" : "top"; - break; - } - } //check row visibility + return row ? row.getComponent() : row; + } + }]); + return RowComponent; + }(); - if (!ifVisible) { - if (Helpers.elVisible(rowEl)) { - offset = Helpers.elOffset(rowEl).top - Helpers.elOffset(_this3.element).top; + var Row$1 = /*#__PURE__*/function (_CoreFeature) { + _inherits(Row, _CoreFeature); - if (offset > 0 && offset < _this3.element.clientHeight - rowEl.offsetHeight) { - return false; - } - } - } //scroll to row + var _super = _createSuper(Row); + function Row(data, parent) { + var _this; - switch (_this3.renderMode) { - case "classic": - _this3.element.scrollTop = Helpers.elOffset(rowEl).top - Helpers.elOffset(_this3.element).top + _this3.element.scrollTop; - break; + var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "row"; - case "virtual": - _this3._virtualRenderFill(rowIndex, true); + _classCallCheck(this, Row); - break; - } //align to correct position + _this = _super.call(this, parent.table); + _this.parent = parent; + _this.data = {}; + _this.type = type; //type of element + _this.element = false; + _this.modules = {}; //hold module variables; - switch (position) { - case "middle": - case "center": - if (_this3.element.scrollHeight - _this3.element.scrollTop == _this3.element.clientHeight) { - _this3.element.scrollTop = _this3.element.scrollTop + (rowEl.offsetTop - _this3.element.scrollTop) - (_this3.element.scrollHeight - rowEl.offsetTop) / 2; - } else { - _this3.element.scrollTop = _this3.element.scrollTop - _this3.element.clientHeight / 2; - } + _this.cells = []; + _this.height = 0; //hold element height - break; + _this.heightStyled = ""; //hold element height prestyled to improve render efficiency - case "bottom": - if (_this3.element.scrollHeight - _this3.element.scrollTop == _this3.element.clientHeight) { - _this3.element.scrollTop = _this3.element.scrollTop - (_this3.element.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight; - } else { - _this3.element.scrollTop = _this3.element.scrollTop - _this3.element.clientHeight + rowEl.offsetHeight; - } + _this.manualHeight = false; //user has manually set row height - break; - } + _this.outerHeight = 0; //holde lements outer height - resolve(); - } else { - console.warn("Scroll Error - Row not visible"); - reject("Scroll Error - Row not visible"); - } - }); - } ////////////////// Data Handling ////////////////// + _this.initialized = false; //element has been rendered - }, { - key: "setData", - value: function setData(data, renderInPosition, columnsChanged) { - var _this4 = this; + _this.heightInitialized = false; //element has resized cells to fit - return new Promise(function (resolve, reject) { - if (renderInPosition && _this4.getDisplayRows().length) { - if (_this4.table.options.pagination) { - _this4._setDataActual(data, true); - } else { - _this4.reRenderInPosition(function () { - _this4._setDataActual(data); - }); - } - } else { - if (_this4.table.options.autoColumns && columnsChanged) { - _this4.table.columnManager.generateColumnsFromRowData(data); - } + _this.component = null; + _this.created = false; - _this4.resetScroll(); + _this.setData(data); - _this4._setDataActual(data); - } + return _this; + } - resolve(); - }); + _createClass(Row, [{ + key: "create", + value: function create() { + if (!this.created) { + this.created = true; + this.generateElement(); + } } }, { - key: "_setDataActual", - value: function _setDataActual(data, renderInPosition) { - var _this5 = this; - - this.table.options.dataLoading.call(this.table, data); + key: "createElement", + value: function createElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-row"); + el.setAttribute("role", "row"); + this.element = el; + } + }, { + key: "getElement", + value: function getElement() { + this.create(); + return this.element; + } + }, { + key: "detachElement", + value: function detachElement() { + if (this.element && this.element.parentNode) { + this.element.parentNode.removeChild(this.element); + } + } + }, { + key: "generateElement", + value: function generateElement() { + this.createElement(); + this.dispatch("row-init", this); + } + }, { + key: "generateCells", + value: function generateCells() { + this.cells = this.table.columnManager.generateCells(this); + } //functions to setup on first render - this._wipeElements(); + }, { + key: "initialize", + value: function initialize(force) { + this.create(); - if (this.table.options.history && this.table.modExists("history")) { - this.table.modules.history.clear(); - } + if (!this.initialized || force) { + this.deleteCells(); - if (Array.isArray(data)) { - if (this.table.modExists("selectRow")) { - this.table.modules.selectRow.clearSelectionData(); + while (this.element.firstChild) { + this.element.removeChild(this.element.firstChild); } - if (this.table.options.reactiveData && this.table.modExists("reactiveData", true)) { - this.table.modules.reactiveData.watchData(data); + this.dispatch("row-layout-before", this); + this.generateCells(); + this.table.columnManager.renderer.renderRowCells(this); + + if (force) { + this.normalizeHeight(); } - data.forEach(function (def, i) { - if (def && _typeof(def) === "object") { - var row = new Row$1(def, _this5); + this.dispatch("row-layout", this); - _this5.rows.push(row); - } else { - console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def); - } - }); - this.refreshActiveData(false, false, renderInPosition); - this.table.options.dataLoaded.call(this.table, data); + if (this.table.options.rowFormatter) { + this.table.options.rowFormatter(this.getComponent()); + } + + this.dispatch("row-layout-after", this); + this.initialized = true; } else { - console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", _typeof(data), "\nData: ", data); + this.table.columnManager.renderer.rerenderRowCells(this); } } }, { - key: "_wipeElements", - value: function _wipeElements() { - this.rows.forEach(function (row) { - row.wipe(); - }); + key: "reinitializeHeight", + value: function reinitializeHeight() { + this.heightInitialized = false; - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.groupRows.wipe(); + if (this.element && this.element.offsetParent !== null) { + this.normalizeHeight(true); } - - this.rows = []; - this.activeRows = []; - this.activeRowsCount = 0; - this.displayRows = []; - this.displayRowsCount = 0; - this.adjustTableSize(); } }, { - key: "deleteRow", - value: function deleteRow(row, blockRedraw) { - var allIndex = this.rows.indexOf(row), - activeIndex = this.activeRows.indexOf(row); + key: "reinitialize", + value: function reinitialize(children) { + this.initialized = false; + this.heightInitialized = false; - if (activeIndex > -1) { - this.activeRows.splice(activeIndex, 1); + if (!this.manualHeight) { + this.height = 0; + this.heightStyled = ""; + } + + if (this.element && this.element.offsetParent !== null) { + this.initialize(true); + } + + this.dispatch("row-relayout", this); + } //get heights when doing bulk row style calcs in virtual DOM + + }, { + key: "calcHeight", + value: function calcHeight(force) { + var maxHeight = 0, + minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0; + this.cells.forEach(function (cell) { + var height = cell.getHeight(); + + if (height > maxHeight) { + maxHeight = height; + } + }); + + if (force) { + this.height = Math.max(maxHeight, minHeight); + } else { + this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight); } - if (allIndex > -1) { - this.rows.splice(allIndex, 1); + this.heightStyled = this.height ? this.height + "px" : ""; + this.outerHeight = this.element.offsetHeight; + } //set of cells + + }, { + key: "setCellHeight", + value: function setCellHeight() { + this.cells.forEach(function (cell) { + cell.setHeight(); + }); + this.heightInitialized = true; + } + }, { + key: "clearCellHeight", + value: function clearCellHeight() { + this.cells.forEach(function (cell) { + cell.clearHeight(); + }); + } //normalize the height of elements in the row + + }, { + key: "normalizeHeight", + value: function normalizeHeight(force) { + if (force) { + this.clearCellHeight(); } - this.setActiveRows(this.activeRows); - this.displayRowIterator(function (rows) { - var displayIndex = rows.indexOf(row); + this.calcHeight(force); + this.setCellHeight(); + } //set height of rows - if (displayIndex > -1) { - rows.splice(displayIndex, 1); - } - }); + }, { + key: "setHeight", + value: function setHeight(height, force) { + if (this.height != height || force) { + this.manualHeight = true; + this.height = height; + this.heightStyled = height ? height + "px" : ""; + this.setCellHeight(); // this.outerHeight = this.element.outerHeight(); - if (!blockRedraw) { - this.reRenderInPosition(); + this.outerHeight = this.element.offsetHeight; } + } //return rows outer height - this.regenerateRowNumbers(); - this.table.options.rowDeleted.call(this.table, row.getComponent()); + }, { + key: "getHeight", + value: function getHeight() { + return this.outerHeight; + } //return rows outer Width - if (this.table.options.dataChanged) { - this.table.options.dataChanged.call(this.table, this.getData()); - } + }, { + key: "getWidth", + value: function getWidth() { + return this.element.offsetWidth; + } //////////////// Cell Management ///////////////// - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.groupRows.updateGroupRows(true); - } else if (this.table.options.pagination && this.table.modExists("page")) { - this.refreshActiveData(false, false, true); - } else { - if (this.table.options.pagination && this.table.modExists("page")) { - this.refreshActiveData("page"); - } - } - } }, { - key: "addRow", - value: function addRow(data, pos, index, blockRedraw) { - var row = this.addRowActual(data, pos, index, blockRedraw); + key: "deleteCell", + value: function deleteCell(cell) { + var index = this.cells.indexOf(cell); - if (this.table.options.history && this.table.modExists("history")) { - this.table.modules.history.action("rowAdd", row, { - data: data, - pos: pos, - index: index - }); + if (index > -1) { + this.cells.splice(index, 1); } + } //////////////// Data Management ///////////////// - return row; - } //add multiple rows + }, { + key: "setData", + value: function setData(data) { + this.data = this.chain("row-data-init-before", [this, data], null, data); + this.dispatch("row-data-init-after", this); + } //update the rows data }, { - key: "addRows", - value: function addRows(data, pos, index) { - var _this6 = this; + key: "updateData", + value: function updateData(updatedData) { + var _this2 = this; - var rows = []; + var visible = this.element && Helpers$1.elVisible(this.element), + tempData = {}, + newRowData; return new Promise(function (resolve, reject) { - pos = _this6.findAddRowPos(pos); - - if (!Array.isArray(data)) { - data = [data]; + if (typeof updatedData === "string") { + updatedData = JSON.parse(updatedData); } - data.length - 1; + _this2.dispatch("row-data-save-before", _this2); - if (typeof index == "undefined" && pos || typeof index !== "undefined" && !pos) { - data.reverse(); + if (_this2.subscribed("row-data-changing")) { + tempData = Object.assign(tempData, _this2.data); + tempData = Object.assign(tempData, updatedData); } - data.forEach(function (item, i) { - var row = _this6.addRow(item, pos, index, true); - - rows.push(row); - }); - - if (_this6.table.options.groupBy && _this6.table.modExists("groupRows")) { - _this6.table.modules.groupRows.updateGroupRows(true); - } else if (_this6.table.options.pagination && _this6.table.modExists("page")) { - _this6.refreshActiveData(false, false, true); - } else { - _this6.reRenderInPosition(); - } //recalc column calculations if present - + newRowData = _this2.chain("row-data-changing", [_this2, tempData, updatedData], null, updatedData); //set data - if (_this6.table.modExists("columnCalcs")) { - _this6.table.modules.columnCalcs.recalc(_this6.table.rowManager.activeRows); + for (var attrname in newRowData) { + _this2.data[attrname] = newRowData[attrname]; } - _this6.regenerateRowNumbers(); - - resolve(rows); - }); - } - }, { - key: "findAddRowPos", - value: function findAddRowPos(pos) { - if (typeof pos === "undefined") { - pos = this.table.options.addRowPos; - } - - if (pos === "pos") { - pos = true; - } - - if (pos === "bottom") { - pos = false; - } - - return pos; - } - }, { - key: "addRowActual", - value: function addRowActual(data, pos, index, blockRedraw) { - var row = data instanceof Row$1 ? data : new Row$1(data || {}, this), - top = this.findAddRowPos(pos), - allIndex = -1, - activeIndex, - dispRows; - - if (!index && this.table.options.pagination && this.table.options.paginationAddRow == "page") { - dispRows = this.getDisplayRows(); + _this2.dispatch("row-data-save-after", _this2); //update affected cells only - if (top) { - if (dispRows.length) { - index = dispRows[0]; - } else { - if (this.activeRows.length) { - index = this.activeRows[this.activeRows.length - 1]; - top = false; - } - } - } else { - if (dispRows.length) { - index = dispRows[dispRows.length - 1]; - top = dispRows.length < this.table.modules.page.getPageSize() ? false : true; - } - } - } - if (typeof index !== "undefined") { - index = this.findRow(index); - } + for (var attrname in updatedData) { + var columns = _this2.table.columnManager.getColumnsByFieldRoot(attrname); - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.groupRows.assignRowToGroup(row); - var groupRows = row.getGroup().rows; + columns.forEach(function (column) { + var cell = _this2.getCell(column.getField()); - if (groupRows.length > 1) { - if (!index || index && groupRows.indexOf(index) == -1) { - if (top) { - if (groupRows[0] !== row) { - index = groupRows[0]; + if (cell) { + var value = column.getFieldValue(newRowData); - this._moveRowInArray(row.getGroup().rows, row, index, !top); - } - } else { - if (groupRows[groupRows.length - 1] !== row) { - index = groupRows[groupRows.length - 1]; + if (cell.getValue() != value) { + cell.setValueProcessData(value); - this._moveRowInArray(row.getGroup().rows, row, index, !top); + if (visible) { + cell.cellRendered(); + } } } - } else { - this._moveRowInArray(row.getGroup().rows, row, index, !top); - } - } - } + }); + } //Partial reinitialization if visible - if (index) { - allIndex = this.rows.indexOf(index); - } - if (index && allIndex > -1) { - activeIndex = this.activeRows.indexOf(index); - this.displayRowIterator(function (rows) { - var displayIndex = rows.indexOf(index); + if (visible) { + _this2.normalizeHeight(true); - if (displayIndex > -1) { - rows.splice(top ? displayIndex : displayIndex + 1, 0, row); + if (_this2.table.options.rowFormatter) { + _this2.table.options.rowFormatter(_this2.getComponent()); } - }); - - if (activeIndex > -1) { - this.activeRows.splice(top ? activeIndex : activeIndex + 1, 0, row); - } - - this.rows.splice(top ? allIndex : allIndex + 1, 0, row); - } else { - if (top) { - this.displayRowIterator(function (rows) { - rows.unshift(row); - }); - this.activeRows.unshift(row); - this.rows.unshift(row); } else { - this.displayRowIterator(function (rows) { - rows.push(row); - }); - this.activeRows.push(row); - this.rows.push(row); + _this2.initialized = false; + _this2.height = 0; + _this2.heightStyled = ""; } - } - this.setActiveRows(this.activeRows); - this.table.options.rowAdded.call(this.table, row.getComponent()); + _this2.dispatch("row-data-changed", _this2, visible, updatedData); //this.reinitialize(); - if (this.table.options.dataChanged) { - this.table.options.dataChanged.call(this.table, this.getData()); - } - if (!blockRedraw) { - this.reRenderInPosition(); - } + _this2.dispatchExternal("rowUpdated", _this2.getComponent()); - return row; + if (_this2.subscribedExternal.subscribed("dataChanged")) { + _this2.dispatchExternal("dataChanged", _this2.table.rowManager.getData()); + } + + resolve(); + }); } }, { - key: "moveRow", - value: function moveRow(from, to, after) { - if (this.table.options.history && this.table.modExists("history")) { - this.table.modules.history.action("rowMove", from, { - posFrom: this.getRowPosition(from), - posTo: this.getRowPosition(to), - to: to, - after: after - }); + key: "getData", + value: function getData(transform) { + if (transform) { + return this.chain("row-data-retrieve", [this, transform], null, this.data); } - this.moveRowActual(from, to, after); - this.regenerateRowNumbers(); - this.table.options.rowMoved.call(this.table, from.getComponent()); + return this.data; } }, { - key: "moveRowActual", - value: function moveRowActual(from, to, after) { - var _this7 = this; - - this._moveRowInArray(this.rows, from, to, after); - - this._moveRowInArray(this.activeRows, from, to, after); - - this.displayRowIterator(function (rows) { - _this7._moveRowInArray(rows, from, to, after); + key: "getCell", + value: function getCell(column) { + var match = false; + column = this.table.columnManager.findColumn(column); + match = this.cells.find(function (cell) { + return cell.column === column; }); - - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - if (!after && to instanceof Group) { - to = this.table.rowManager.prevDisplayRow(from) || to; - } - - var toGroup = to.getGroup(); - var fromGroup = from.getGroup(); - - if (toGroup === fromGroup) { - this._moveRowInArray(toGroup.rows, from, to, after); - } else { - if (fromGroup) { - fromGroup.removeRow(from); - } - - toGroup.insertRow(from, to, after); - } - } + return match; } }, { - key: "_moveRowInArray", - value: function _moveRowInArray(rows, from, to, after) { - var fromIndex, toIndex, start, end; - - if (from !== to) { - fromIndex = rows.indexOf(from); - - if (fromIndex > -1) { - rows.splice(fromIndex, 1); - toIndex = rows.indexOf(to); - - if (toIndex > -1) { - if (after) { - rows.splice(toIndex + 1, 0, from); - } else { - rows.splice(toIndex, 0, from); - } - } else { - rows.splice(fromIndex, 0, from); - } - } //restyle rows - - - if (rows === this.getDisplayRows()) { - start = fromIndex < toIndex ? fromIndex : toIndex; - end = toIndex > fromIndex ? toIndex : fromIndex + 1; - - for (var i = start; i <= end; i++) { - if (rows[i]) { - this.styleRow(rows[i], i); - } - } - } - } + key: "getCellIndex", + value: function getCellIndex(findCell) { + return this.cells.findIndex(function (cell) { + return cell === findCell; + }); } }, { - key: "clearData", - value: function clearData() { - this.setData([]); + key: "findCell", + value: function findCell(subject) { + return this.cells.find(function (cell) { + return cell.element === subject; + }); } }, { - key: "getRowIndex", - value: function getRowIndex(row) { - return this.findRowIndex(row, this.rows); + key: "getCells", + value: function getCells() { + return this.cells; } }, { - key: "getDisplayRowIndex", - value: function getDisplayRowIndex(row) { - var index = this.getDisplayRows().indexOf(row); - return index > -1 ? index : false; + key: "nextRow", + value: function nextRow() { + var row = this.table.rowManager.nextDisplayRow(this, true); + return row || false; } }, { - key: "nextDisplayRow", - value: function nextDisplayRow(row, rowOnly) { - var index = this.getDisplayRowIndex(row), - nextRow = false; - - if (index !== false && index < this.displayRowsCount - 1) { - nextRow = this.getDisplayRows()[index + 1]; - } - - if (nextRow && (!(nextRow instanceof Row$1) || nextRow.type != "row")) { - return this.nextDisplayRow(nextRow, rowOnly); - } - - return nextRow; + key: "prevRow", + value: function prevRow() { + var row = this.table.rowManager.prevDisplayRow(this, true); + return row || false; } }, { - key: "prevDisplayRow", - value: function prevDisplayRow(row, rowOnly) { - var index = this.getDisplayRowIndex(row), - prevRow = false; - - if (index) { - prevRow = this.getDisplayRows()[index - 1]; - } + key: "moveToRow", + value: function moveToRow(to, before) { + var toRow = this.table.rowManager.findRow(to); - if (rowOnly && prevRow && (!(prevRow instanceof Row$1) || prevRow.type != "row")) { - return this.prevDisplayRow(prevRow, rowOnly); + if (toRow) { + this.table.rowManager.moveRowActual(this, toRow, !before); + this.table.rowManager.refreshActiveData("display", false, true); + } else { + console.warn("Move Error - No matching row found:", to); } + } ///////////////////// Actions ///////////////////// - return prevRow; - } }, { - key: "findRowIndex", - value: function findRowIndex(row, list) { - var rowIndex; - row = this.findRow(row); + key: "delete", + value: function _delete() { + var _this3 = this; - if (row) { - rowIndex = list.indexOf(row); + return new Promise(function (resolve, reject) { + _this3.dispatch("row-delete", _this3); - if (rowIndex > -1) { - return rowIndex; - } - } + _this3.deleteActual(); - return false; - } - }, { - key: "getData", - value: function getData(active, transform) { - var output = [], - rows = this.getRows(active); - rows.forEach(function (row) { - if (row.type == "row") { - output.push(row.getData(transform || "data")); - } + resolve(); }); - return output; } }, { - key: "getComponents", - value: function getComponents(active) { - var output = [], - rows = this.getRows(active); - rows.forEach(function (row) { - output.push(row.getComponent()); - }); - return output; + key: "deleteActual", + value: function deleteActual(blockRedraw) { + var index = this.table.rowManager.getRowIndex(this); + this.detatchModules(); + this.table.rowManager.deleteRow(this, blockRedraw); + this.deleteCells(); + this.initialized = false; + this.heightInitialized = false; + this.element = false; + this.dispatch("row-deleted", this); } }, { - key: "getDataCount", - value: function getDataCount(active) { - var rows = this.getRows(active); - return rows.length; + key: "detatchModules", + value: function detatchModules() { + this.dispatch("row-deleting", this); } }, { - key: "_genRemoteRequest", - value: function _genRemoteRequest() { - var _this8 = this; - - var table = this.table, - options = table.options, - params = {}; - - if (table.modExists("page")) { - //set sort data if defined - if (options.ajaxSorting) { - var sorters = this.table.modules.sort.getSort(); - sorters.forEach(function (item) { - delete item.column; - }); - params[this.table.modules.page.paginationDataSentNames.sorters] = sorters; - } //set filter data if defined - - - if (options.ajaxFiltering) { - var filters = this.table.modules.filter.getFilters(true, true); - params[this.table.modules.page.paginationDataSentNames.filters] = filters; - } + key: "deleteCells", + value: function deleteCells() { + var cellCount = this.cells.length; - this.table.modules.ajax.setParams(params, true); + for (var i = 0; i < cellCount; i++) { + this.cells[0]["delete"](); } - - table.modules.ajax.sendRequest().then(function (data) { - _this8._setDataActual(data, true); - })["catch"](function (e) {}); - } //choose the path to refresh data after a filter update - + } }, { - key: "filterRefresh", - value: function filterRefresh() { - var table = this.table, - options = table.options, - left = this.scrollLeft; - - if (options.ajaxFiltering) { - if (options.pagination == "remote" && table.modExists("page")) { - table.modules.page.reset(true); - table.modules.page.setPage(1).then(function () {})["catch"](function () {}); - } else if (options.ajaxProgressiveLoad) { - table.modules.ajax.loadData().then(function () {})["catch"](function () {}); - } else { - //assume data is url, make ajax call to url to get data - this._genRemoteRequest(); - } - } else { - this.refreshActiveData("filter"); - } + key: "wipe", + value: function wipe() { + this.detatchModules(); + this.deleteCells(); - this.scrollHorizontal(left); - } //choose the path to refresh data after a sorter update + if (this.element) { + while (this.element.firstChild) { + this.element.removeChild(this.element.firstChild); + } - }, { - key: "sorterRefresh", - value: function sorterRefresh(loadOrignalData) { - var table = this.table, - options = this.table.options, - left = this.scrollLeft; - - if (options.ajaxSorting) { - if ((options.pagination == "remote" || options.progressiveLoad) && table.modExists("page")) { - table.modules.page.reset(true); - table.modules.page.setPage(1).then(function () {})["catch"](function () {}); - } else if (options.ajaxProgressiveLoad) { - table.modules.ajax.loadData().then(function () {})["catch"](function () {}); - } else { - //assume data is url, make ajax call to url to get data - this._genRemoteRequest(); + if (this.element.parentNode) { + this.element.parentNode.removeChild(this.element); } - } else { - this.refreshActiveData(loadOrignalData ? "filter" : "sort"); } - this.scrollHorizontal(left); + this.element = false; + this.modules = {}; } }, { - key: "scrollHorizontal", - value: function scrollHorizontal(left) { - this.scrollLeft = left; - this.element.scrollLeft = left; + key: "getGroup", + value: function getGroup() { + return this.modules.group || false; + } //////////////// Object Generation ///////////////// - if (this.table.options.groupBy) { - this.table.modules.groupRows.scrollHeaders(left); + }, { + key: "getComponent", + value: function getComponent() { + if (!this.component) { + this.component = new RowComponent$1(this); } - if (this.table.modExists("columnCalcs")) { - this.table.modules.columnCalcs.scrollHorizontal(left); - } - } //set active data set + return this.component; + } + }]); - }, { - key: "refreshActiveData", - value: function refreshActiveData(stage, skipStage, renderInPosition) { - var table = this.table, - cascadeOrder = ["all", "filter", "sort", "display", "freeze", "group", "tree", "page"], - displayIndex; + return Row; + }(CoreFeature); - if (this.redrawBlock) { - if (!this.redrawBlockRestoreConfig || cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage)) { - this.redrawBlockRestoreConfig = { - stage: stage, - skipStage: skipStage, - renderInPosition: renderInPosition - }; - } + var BaiscVertical = /*#__PURE__*/function (_Renderer) { + _inherits(BaiscVertical, _Renderer); - return; - } else { - if (this.table.modExists("edit")) { - this.table.modules.edit.cancelEdit(); - } + var _super = _createSuper(BaiscVertical); - if (!stage) { - stage = "all"; - } + function BaiscVertical(table) { + var _this; - if (table.options.selectable && !table.options.selectablePersistence && table.modExists("selectRow")) { - table.modules.selectRow.deselectRows(); - } //cascade through data refresh stages + _classCallCheck(this, BaiscVertical); + _this = _super.call(this, table); + _this.verticalFillMode = "fill"; + _this.scrollTop = 0; + _this.scrollLeft = 0; + _this.scrollTop = 0; + _this.scrollLeft = 0; + return _this; + } - switch (stage) { - case "all": - case "filter": - if (!skipStage) { - if (table.modExists("filter")) { - this.setActiveRows(table.modules.filter.filter(this.rows)); - } else { - this.setActiveRows(this.rows.slice(0)); - } - } else { - skipStage = false; - } + _createClass(BaiscVertical, [{ + key: "clearRows", + value: function clearRows() { + var element = this.tableElement; // element.children.detach(); - case "sort": - if (!skipStage) { - if (table.modExists("sort")) { - table.modules.sort.sort(this.activeRows); - } - } else { - skipStage = false; - } //regenerate row numbers for row number formatter if in use + while (element.firstChild) { + element.removeChild(element.firstChild); + } + element.scrollTop = 0; + element.scrollLeft = 0; + element.style.minWidth = ""; + element.style.minHeight = ""; + element.style.display = ""; + element.style.visibility = ""; + } + }, { + key: "renderRows", + value: function renderRows() { + var _this2 = this; - this.regenerateRowNumbers(); - //generic stage to allow for pipeline trigger after the data manipulation stage + var element = this.tableElement, + onlyGroupHeaders = true; + this.rows().forEach(function (row, index) { + _this2.styleRow(row, index); - case "display": - this.resetDisplayRows(); + element.appendChild(row.getElement()); + row.initialize(true); - case "freeze": - if (!skipStage) { - if (this.table.modExists("frozenRows")) { - if (table.modules.frozenRows.isFrozen()) { - if (!table.modules.frozenRows.getDisplayIndex()) { - table.modules.frozenRows.setDisplayIndex(this.getNextDisplayIndex()); - } + if (row.type !== "group") { + onlyGroupHeaders = false; + } + }); + + if (onlyGroupHeaders) { + element.style.minWidth = this.table.columnManager.getWidth() + "px"; + } else { + element.style.minWidth = ""; + } + } + }, { + key: "rerenderRows", + value: function rerenderRows(callback) { + this.render(); - displayIndex = table.modules.frozenRows.getDisplayIndex(); - displayIndex = this.setDisplayRows(table.modules.frozenRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex); + if (callback) { + callback(); + } + } + }, { + key: "scrollToRowNearestTop", + value: function scrollToRowNearestTop(row) { + var rowTop = Helpers$1.elOffset(row.getElement()).top; + return !(Math.abs(this.elementVertical.scrollTop - rowTop) > Math.abs(this.elementVertical.scrollTop + this.elementVertical.clientHeight - rowTop)); + } + }, { + key: "scrollToRow", + value: function scrollToRow(row) { + var rowEl = row.getElement(); + this.elementVertical.scrollTop = Helpers$1.elOffset(rowEl).top - Helpers$1.elOffset(this.elementVertical).top + this.elementVertical.scrollTop; + } + }, { + key: "visibleRows", + value: function visibleRows(includingBuffer) { + return this.rows(); + } + }]); - if (displayIndex !== true) { - table.modules.frozenRows.setDisplayIndex(displayIndex); - } - } - } - } else { - skipStage = false; - } + return BaiscVertical; + }(Renderer); - case "group": - if (!skipStage) { - if (table.options.groupBy && table.modExists("groupRows")) { - if (!table.modules.groupRows.getDisplayIndex()) { - table.modules.groupRows.setDisplayIndex(this.getNextDisplayIndex()); - } + var VirtualDomVertical = /*#__PURE__*/function (_Renderer) { + _inherits(VirtualDomVertical, _Renderer); - displayIndex = table.modules.groupRows.getDisplayIndex(); - displayIndex = this.setDisplayRows(table.modules.groupRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex); + var _super = _createSuper(VirtualDomVertical); - if (displayIndex !== true) { - table.modules.groupRows.setDisplayIndex(displayIndex); - } - } - } else { - skipStage = false; - } + function VirtualDomVertical(table) { + var _this; - case "tree": - if (!skipStage) { - if (table.options.dataTree && table.modExists("dataTree")) { - if (!table.modules.dataTree.getDisplayIndex()) { - table.modules.dataTree.setDisplayIndex(this.getNextDisplayIndex()); - } + _classCallCheck(this, VirtualDomVertical); - displayIndex = table.modules.dataTree.getDisplayIndex(); - displayIndex = this.setDisplayRows(table.modules.dataTree.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex); + _this = _super.call(this, table); + _this.verticalFillMode = "fill"; + _this.scrollTop = 0; + _this.scrollLeft = 0; + _this.vDomRowHeight = 20; //approximation of row heights for padding - if (displayIndex !== true) { - table.modules.dataTree.setDisplayIndex(displayIndex); - } - } - } else { - skipStage = false; - } + _this.vDomTop = 0; //hold position for first rendered row in the virtual DOM - if (table.options.pagination && table.modExists("page") && !renderInPosition) { - if (table.modules.page.getMode() == "local") { - table.modules.page.reset(); - } - } + _this.vDomBottom = 0; //hold possition for last rendered row in the virtual DOM - case "page": - if (!skipStage) { - if (table.options.pagination && table.modExists("page")) { - if (!table.modules.page.getDisplayIndex()) { - table.modules.page.setDisplayIndex(this.getNextDisplayIndex()); - } + _this.vDomScrollPosTop = 0; //last scroll position of the vDom top; - displayIndex = table.modules.page.getDisplayIndex(); + _this.vDomScrollPosBottom = 0; //last scroll position of the vDom bottom; - if (table.modules.page.getMode() == "local") { - table.modules.page.setMaxRows(this.getDisplayRows(displayIndex - 1).length); - } + _this.vDomTopPad = 0; //hold value of padding for top of virtual DOM - displayIndex = this.setDisplayRows(table.modules.page.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex); + _this.vDomBottomPad = 0; //hold value of padding for bottom of virtual DOM - if (displayIndex !== true) { - table.modules.page.setDisplayIndex(displayIndex); - } - } - } else { - skipStage = false; - } + _this.vDomMaxRenderChain = 90; //the maximum number of dom elements that can be rendered in 1 go - } + _this.vDomWindowBuffer = 0; //window row buffer before removing elements, to smooth scrolling - if (Helpers.elVisible(this.element)) { - if (renderInPosition) { - this.reRenderInPosition(); - } else { - if (stage === "all" && this.table.options.virtualDomHoz) { - this.table.vdomHoz.dataChange(); - } + _this.vDomWindowMinTotalRows = 20; //minimum number of rows to be generated in virtual dom (prevent buffering issues on tables with tall rows) - this.renderTable(); + _this.vDomWindowMinMarginRows = 5; //minimum number of rows to be generated in virtual dom margin - if (table.options.layoutColumnsOnNewData) { - this.table.columnManager.redraw(true); - } - } - } + _this.vDomTopNewRows = []; //rows to normalize after appending to optimize render speed - if (table.modExists("columnCalcs")) { - table.modules.columnCalcs.recalc(this.activeRows); - } - } - } //regenerate row numbers for row number formatter if in use + _this.vDomBottomNewRows = []; //rows to normalize after appending to optimize render speed - }, { - key: "regenerateRowNumbers", - value: function regenerateRowNumbers() { - var _this9 = this; + return _this; + } ////////////////////////////////////// + ///////// Public Functions /////////// + ////////////////////////////////////// - if (this.rowNumColumn) { - this.activeRows.forEach(function (row) { - var cell = row.getCell(_this9.rowNumColumn); - if (cell) { - cell._generateContents(); - } - }); + _createClass(VirtualDomVertical, [{ + key: "clearRows", + value: function clearRows() { + var element = this.tableElement; // element.children.detach(); + + while (element.firstChild) { + element.removeChild(element.firstChild); } + + element.style.paddingTop = ""; + element.style.paddingBottom = ""; + element.style.minWidth = ""; + element.style.minHeight = ""; + element.style.display = ""; + element.style.visibility = ""; + this.elementVertical.scrollTop = 0; + this.elementVertical.scrollLeft = 0; + this.scrollTop = 0; + this.scrollLeft = 0; + this.vDomTop = 0; + this.vDomBottom = 0; + this.vDomTopPad = 0; + this.vDomBottomPad = 0; + this.vDomScrollPosTop = 0; + this.vDomScrollPosBottom = 0; } }, { - key: "setActiveRows", - value: function setActiveRows(activeRows) { - this.activeRows = activeRows; - this.activeRowsCount = this.activeRows.length; - } //reset display rows array - + key: "renderRows", + value: function renderRows() { + this._virtualRenderFill(); + } }, { - key: "resetDisplayRows", - value: function resetDisplayRows() { - this.displayRows = []; - this.displayRows.push(this.activeRows.slice(0)); - this.displayRowsCount = this.displayRows[0].length; + key: "rerenderRows", + value: function rerenderRows(callback) { + var scrollTop = this.elementVertical.scrollTop; + var topRow = false; + var topOffset = false; + var left = this.table.rowManager.scrollLeft; + var rows = this.rows(); - if (this.table.modExists("frozenRows")) { - this.table.modules.frozenRows.setDisplayIndex(0); - } + for (var i = this.vDomTop; i <= this.vDomBottom; i++) { + if (rows[i]) { + var diff = scrollTop - rows[i].getElement().offsetTop; - if (this.table.options.groupBy && this.table.modExists("groupRows")) { - this.table.modules.groupRows.setDisplayIndex(0); + if (topOffset === false || Math.abs(diff) < topOffset) { + topOffset = diff; + topRow = i; + } else { + break; + } + } } - if (this.table.options.pagination && this.table.modExists("page")) { - this.table.modules.page.setDisplayIndex(0); + if (callback) { + callback(); } + + this._virtualRenderFill(topRow === false ? this.rows.length - 1 : topRow, true, topOffset || 0); + + this.scrollColumns(left); } }, { - key: "getNextDisplayIndex", - value: function getNextDisplayIndex() { - return this.displayRows.length; - } //set display row pipeline data - + key: "scrollColumns", + value: function scrollColumns(left) { + this.table.rowManager.scrollHorizontal(left); + } }, { - key: "setDisplayRows", - value: function setDisplayRows(displayRows, index) { - var output = true; + key: "scrollRows", + value: function scrollRows(top, dir) { + var topDiff = top - this.vDomScrollPosTop; + var bottomDiff = top - this.vDomScrollPosBottom; + var margin = this.vDomWindowBuffer * 2; + var rows = this.rows(); + this.scrollTop = top; - if (index && typeof this.displayRows[index] != "undefined") { - this.displayRows[index] = displayRows; - output = true; + if (-topDiff > margin || bottomDiff > margin) { + //if big scroll redraw table; + var left = this.table.rowManager.scrollLeft; + + this._virtualRenderFill(Math.floor(this.elementVertical.scrollTop / this.elementVertical.scrollHeight * rows.length)); + + this.scrollColumns(left); } else { - this.displayRows.push(displayRows); - output = index = this.displayRows.length - 1; - } + if (dir) { + //scrolling up + if (topDiff < 0) { + this._addTopRow(rows, -topDiff); + } - if (index == this.displayRows.length - 1) { - this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length; - } + if (bottomDiff < 0) { + //hide bottom row if needed + if (this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer) { + this._removeBottomRow(rows, -bottomDiff); + } else { + this.vDomScrollPosBottom = this.scrollTop; + } + } + } else { + if (bottomDiff >= 0) { + this._addBottomRow(rows, bottomDiff); + } //scrolling down - return output; + + if (topDiff >= 0) { + //hide top row if needed + if (this.scrollTop > this.vDomWindowBuffer) { + this._removeTopRow(rows, topDiff); + } else { + this.vDomScrollPosTop = this.scrollTop; + } + } + } + } } }, { - key: "getDisplayRows", - value: function getDisplayRows(index) { - if (typeof index == "undefined") { - return this.displayRows.length ? this.displayRows[this.displayRows.length - 1] : []; - } else { - return this.displayRows[index] || []; + key: "resize", + value: function resize() { + this.vDomWindowBuffer = this.table.options.renderVerticalBuffer || this.elementVertical.clientHeight; + } + }, { + key: "scrollToRowNearestTop", + value: function scrollToRowNearestTop(row) { + var rowIndex = this.rows().indexOf(row); + return !(Math.abs(this.vDomTop - rowIndex) > Math.abs(this.vDomBottom - rowIndex)); + } + }, { + key: "scrollToRow", + value: function scrollToRow(row) { + var index = this.rows().indexOf(row); + + if (index > -1) { + this._virtualRenderFill(index, true); } } }, { - key: "getVisibleRows", - value: function getVisibleRows(viewable) { - var topEdge = this.element.scrollTop, - bottomEdge = this.element.clientHeight + topEdge, + key: "visibleRows", + value: function visibleRows(includingBuffer) { + var topEdge = this.elementVertical.scrollTop, + bottomEdge = this.elementVertical.clientHeight + topEdge, topFound = false, topRow = 0, bottomRow = 0, - rows = this.getDisplayRows(); - - if (viewable) { - this.getDisplayRows(); + rows = this.rows(); + if (includingBuffer) { + topRow = this.vDomTop; + bottomRow = this.vDomBottom; + } else { for (var i = this.vDomTop; i <= this.vDomBottom; i++) { if (rows[i]) { if (!topFound) { @@ -5837,3773 +4481,4044 @@ } } } - } else { - topRow = this.vDomTop; - bottomRow = this.vDomBottom; } - return rows.slice(topRow, bottomRow + 1); - } //repeat action accross display rows + return rows.slice(topRow, bottomRow + 1); + } ////////////////////////////////////// + //////// Internal Rendering ////////// + ////////////////////////////////////// + //full virtual render + + }, { + key: "_virtualRenderFill", + value: function _virtualRenderFill(position, forceMove, offset) { + var element = this.tableElement, + holder = this.elementVertical, + topPad = 0, + rowsHeight = 0, + heightOccupied = 0, + topPadHeight = 0, + i = 0, + rows = this.rows(), + rowsCount = rows.length, + containerHeight = this.elementVertical.clientHeight; + position = position || 0; + offset = offset || 0; + + if (!position) { + this.clear(); + } else { + while (element.firstChild) { + element.removeChild(element.firstChild); + } //check if position is too close to bottom of table + + + heightOccupied = (rowsCount - position + 1) * this.vDomRowHeight; + + if (heightOccupied < containerHeight) { + position -= Math.ceil((containerHeight - heightOccupied) / this.vDomRowHeight); + + if (position < 0) { + position = 0; + } + } //calculate initial pad + + + topPad = Math.min(Math.max(Math.floor(this.vDomWindowBuffer / this.vDomRowHeight), this.vDomWindowMinMarginRows), position); + position -= topPad; + } + + if (rowsCount && Helpers$1.elVisible(this.elementVertical)) { + this.vDomTop = position; + this.vDomBottom = position - 1; + + while ((rowsHeight <= containerHeight + this.vDomWindowBuffer || i < this.vDomWindowMinTotalRows) && this.vDomBottom < rowsCount - 1) { + var index = this.vDomBottom + 1, + row = rows[index], + rowHeight = 0; + this.styleRow(row, index); + element.appendChild(row.getElement()); + row.initialize(); + + if (!row.heightInitialized) { + row.normalizeHeight(true); + } + + rowHeight = row.getHeight(); + + if (i < topPad) { + topPadHeight += rowHeight; + } else { + rowsHeight += rowHeight; + } + + if (rowHeight > this.vDomWindowBuffer) { + this.vDomWindowBuffer = rowHeight * 2; + } + + this.vDomBottom++; + i++; + } + + if (!position) { + this.vDomTopPad = 0; //adjust rowheight to match average of rendered elements + + this.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / i); + this.vDomBottomPad = this.vDomRowHeight * (rowsCount - this.vDomBottom - 1); + this.vDomScrollHeight = topPadHeight + rowsHeight + this.vDomBottomPad - containerHeight; + } else { + this.vDomTopPad = !forceMove ? this.scrollTop - topPadHeight : this.vDomRowHeight * this.vDomTop + offset; + this.vDomBottomPad = this.vDomBottom == rowsCount - 1 ? 0 : Math.max(this.vDomScrollHeight - this.vDomTopPad - rowsHeight - topPadHeight, 0); + } + + element.style.paddingTop = this.vDomTopPad + "px"; + element.style.paddingBottom = this.vDomBottomPad + "px"; + + if (forceMove) { + this.scrollTop = this.vDomTopPad + topPadHeight + offset - (this.elementVertical.scrollWidth > this.elementVertical.clientWidth ? this.elementVertical.offsetHeight - containerHeight : 0); + } + + this.scrollTop = Math.min(this.scrollTop, this.elementVertical.scrollHeight - containerHeight); //adjust for horizontal scrollbar if present (and not at top of table) + + if (this.elementVertical.scrollWidth > this.elementVertical.offsetWidth && forceMove) { + this.scrollTop += this.elementVertical.offsetHeight - containerHeight; + } + + this.vDomScrollPosTop = this.scrollTop; + this.vDomScrollPosBottom = this.scrollTop; + holder.scrollTop = this.scrollTop; + this.dispatch("render-virtual-fill"); + } + } + }, { + key: "_addTopRow", + value: function _addTopRow(rows, fillableSpace) { + var table = this.tableElement, + addedRows = [], + paddingAdjust = 0, + index = this.vDomTop - 1, + i = 0; + + while (true) { + if (this.vDomTop) { + var row = rows[index], + rowHeight = void 0, + initialized = void 0; + + if (row && i < this.vDomMaxRenderChain) { + rowHeight = row.getHeight() || this.vDomRowHeight; + initialized = row.initialized; + + if (fillableSpace >= rowHeight) { + this.styleRow(row, index); + table.insertBefore(row.getElement(), table.firstChild); + + if (!row.initialized || !row.heightInitialized) { + addedRows.push(row); + } + + row.initialize(); + + if (!initialized) { + rowHeight = row.getElement().offsetHeight; + + if (rowHeight > this.vDomWindowBuffer) { + this.vDomWindowBuffer = rowHeight * 2; + } + } + + fillableSpace -= rowHeight; + paddingAdjust += rowHeight; + this.vDomTop--; + index--; + i++; + } else { + break; + } + } else { + break; + } + } else { + break; + } + } + + for (var _i = 0, _addedRows = addedRows; _i < _addedRows.length; _i++) { + var _row = _addedRows[_i]; + + _row.clearCellHeight(); + } + + this._quickNormalizeRowHeight(addedRows); + + if (paddingAdjust) { + this.vDomTopPad -= paddingAdjust; + + if (this.vDomTopPad < 0) { + this.vDomTopPad = index * this.vDomRowHeight; + } + + if (index < 1) { + this.vDomTopPad = 0; + } + + table.style.paddingTop = this.vDomTopPad + "px"; + this.vDomScrollPosTop -= paddingAdjust; + } + } + }, { + key: "_removeTopRow", + value: function _removeTopRow(rows, fillableSpace) { + var removableRows = [], + paddingAdjust = 0, + i = 0; + + while (true) { + var row = rows[this.vDomTop], + rowHeight = void 0; + + if (row && i < this.vDomMaxRenderChain) { + rowHeight = row.getHeight() || this.vDomRowHeight; + + if (fillableSpace >= rowHeight) { + this.vDomTop++; + fillableSpace -= rowHeight; + paddingAdjust += rowHeight; + removableRows.push(row); + i++; + } else { + break; + } + } else { + break; + } + } + + for (var _i2 = 0, _removableRows = removableRows; _i2 < _removableRows.length; _i2++) { + var _row2 = _removableRows[_i2]; - }, { - key: "displayRowIterator", - value: function displayRowIterator(callback) { - this.displayRows.forEach(callback); - this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length; - } //return only actual rows (not group headers etc) + var rowEl = _row2.getElement(); + if (rowEl.parentNode) { + rowEl.parentNode.removeChild(rowEl); + } + } + + if (paddingAdjust) { + this.vDomTopPad += paddingAdjust; + this.tableElement.style.paddingTop = this.vDomTopPad + "px"; + this.vDomScrollPosTop += this.vDomTop ? paddingAdjust : paddingAdjust + this.vDomWindowBuffer; + } + } }, { - key: "getRows", - value: function getRows(active) { - var rows; + key: "_addBottomRow", + value: function _addBottomRow(rows, fillableSpace) { + var table = this.tableElement, + addedRows = [], + paddingAdjust = 0, + index = this.vDomBottom + 1, + i = 0; - switch (active) { - case "active": - rows = this.activeRows; - break; + while (true) { + var row = rows[index], + rowHeight = void 0, + initialized = void 0; - case "display": - rows = this.table.rowManager.getDisplayRows(); - break; + if (row && i < this.vDomMaxRenderChain) { + rowHeight = row.getHeight() || this.vDomRowHeight; + initialized = row.initialized; - case "visible": - rows = this.getVisibleRows(true); - break; + if (fillableSpace >= rowHeight) { + this.styleRow(row, index); + table.appendChild(row.getElement()); - case "selected": - rows = this.table.modules.selectRow.selectedRows; - break; + if (!row.initialized || !row.heightInitialized) { + addedRows.push(row); + } - default: - rows = this.rows; - } + row.initialize(); - return rows; - } ///////////////// Table Rendering ///////////////// - //trigger rerender of table in current position + if (!initialized) { + rowHeight = row.getElement().offsetHeight; - }, { - key: "reRenderInPosition", - value: function reRenderInPosition(callback) { - if (this.getRenderMode() == "virtual") { - if (this.redrawBlock) { - if (callback) { - callback(); + if (rowHeight > this.vDomWindowBuffer) { + this.vDomWindowBuffer = rowHeight * 2; + } + } + + fillableSpace -= rowHeight; + paddingAdjust += rowHeight; + this.vDomBottom++; + index++; + i++; } else { - this.redrawBlockRederInPosition = true; + break; } } else { - var scrollTop = this.element.scrollTop; - var topRow = false; - var topOffset = false; - var left = this.scrollLeft; - var rows = this.getDisplayRows(); + break; + } + } - for (var i = this.vDomTop; i <= this.vDomBottom; i++) { - if (rows[i]) { - var diff = scrollTop - rows[i].getElement().offsetTop; + for (var _i3 = 0, _addedRows2 = addedRows; _i3 < _addedRows2.length; _i3++) { + var _row3 = _addedRows2[_i3]; - if (topOffset === false || Math.abs(diff) < topOffset) { - topOffset = diff; - topRow = i; - } else { - break; - } - } - } + _row3.clearCellHeight(); + } - if (callback) { - callback(); - } + this._quickNormalizeRowHeight(addedRows); - this._virtualRenderFill(topRow === false ? this.displayRowsCount - 1 : topRow, true, topOffset || 0); + if (paddingAdjust) { + this.vDomBottomPad -= paddingAdjust; - this.scrollHorizontal(left); + if (this.vDomBottomPad < 0 || index == rows.length - 1) { + this.vDomBottomPad = 0; } - } else { - this.renderTable(); - if (callback) { - callback(); - } + table.style.paddingBottom = this.vDomBottomPad + "px"; + this.vDomScrollPosBottom += paddingAdjust; } } }, { - key: "setRenderMode", - value: function setRenderMode() { - if (this.table.options.virtualDom) { - this.renderMode = "virtual"; - - if (this.table.element.clientHeight || this.table.options.height) { - this.fixedHeight = true; + key: "_removeBottomRow", + value: function _removeBottomRow(rows, fillableSpace) { + var removableRows = [], + paddingAdjust = 0, + i = 0; + + while (true) { + var row = rows[this.vDomBottom], + rowHeight = void 0; + + if (row && i < this.vDomMaxRenderChain) { + rowHeight = row.getHeight() || this.vDomRowHeight; + + if (fillableSpace >= rowHeight) { + this.vDomBottom--; + fillableSpace -= rowHeight; + paddingAdjust += rowHeight; + removableRows.push(row); + i++; + } else { + break; + } } else { - this.fixedHeight = false; + break; } - } else { - this.renderMode = "classic"; } - } - }, { - key: "getRenderMode", - value: function getRenderMode() { - return this.renderMode; - } - }, { - key: "renderTable", - value: function renderTable() { - this.table.options.renderStarted.call(this.table); - this.element.scrollTop = 0; - switch (this.renderMode) { - case "classic": - this._simpleRender(); + for (var _i4 = 0, _removableRows2 = removableRows; _i4 < _removableRows2.length; _i4++) { + var _row4 = _removableRows2[_i4]; - break; - - case "virtual": - this._virtualRenderFill(); + var rowEl = _row4.getElement(); - break; + if (rowEl.parentNode) { + rowEl.parentNode.removeChild(rowEl); + } } - if (this.firstRender) { - if (this.displayRowsCount) { - this.firstRender = false; - this.table.modules.layout.layout(); - } else { - this.renderEmptyScroll(); + if (paddingAdjust) { + this.vDomBottomPad += paddingAdjust; + + if (this.vDomBottomPad < 0) { + this.vDomBottomPad = 0; } - } - if (this.table.modExists("frozenColumns")) { - this.table.modules.frozenColumns.layout(); + this.tableElement.style.paddingBottom = this.vDomBottomPad + "px"; + this.vDomScrollPosBottom -= paddingAdjust; } + } + }, { + key: "_quickNormalizeRowHeight", + value: function _quickNormalizeRowHeight(rows) { + var _iterator = _createForOfIteratorHelper(rows), + _step; - if (!this.displayRowsCount) { - if (this.table.options.placeholder) { - this.table.options.placeholder.setAttribute("tabulator-render-mode", this.renderMode); - this.getElement().appendChild(this.table.options.placeholder); - this.table.options.placeholder.style.width = this.table.columnManager.getWidth() + "px"; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var row = _step.value; + row.calcHeight(); } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); } - this.table.options.renderComplete.call(this.table); - } //simple render on heightless table + var _iterator2 = _createForOfIteratorHelper(rows), + _step2; - }, { - key: "_simpleRender", - value: function _simpleRender() { - this._clearVirtualDom(); + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var _row5 = _step2.value; - if (this.displayRowsCount) { - this.checkClassicModeGroupHeaderWidth(); - } else { - this.renderEmptyScroll(); + _row5.setCellHeight(); + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } } - }, { - key: "checkClassicModeGroupHeaderWidth", - value: function checkClassicModeGroupHeaderWidth() { - var _this10 = this; + }]); - var element = this.tableElement, - onlyGroupHeaders = true; - this.getDisplayRows().forEach(function (row, index) { - _this10.styleRow(row, index); + return VirtualDomVertical; + }(Renderer); - element.appendChild(row.getElement()); - row.initialize(true); + var RowManager = /*#__PURE__*/function (_CoreFeature) { + _inherits(RowManager, _CoreFeature); - if (row.type !== "group") { - onlyGroupHeaders = false; - } - }); + var _super = _createSuper(RowManager); - if (onlyGroupHeaders) { - element.style.minWidth = this.table.columnManager.getWidth() + "px"; - } else { - element.style.minWidth = ""; - } - } //show scrollbars on empty table div + function RowManager(table) { + var _this; - }, { - key: "renderEmptyScroll", - value: function renderEmptyScroll() { - if (this.table.options.placeholder) { - this.tableElement.style.display = "none"; - } else { - this.tableElement.style.minWidth = this.table.columnManager.getWidth() + "px"; // this.tableElement.style.minHeight = "1px"; - // this.tableElement.style.visibility = "hidden"; - } - } - }, { - key: "_clearVirtualDom", - value: function _clearVirtualDom() { - var element = this.tableElement; + _classCallCheck(this, RowManager); - if (this.table.options.placeholder && this.table.options.placeholder.parentNode) { - this.table.options.placeholder.parentNode.removeChild(this.table.options.placeholder); - } // element.children.detach(); + _this = _super.call(this, table); + _this.element = _this.createHolderElement(); //containing element + _this.tableElement = _this.createTableElement(); //table element - while (element.firstChild) { - element.removeChild(element.firstChild); - } + _this.heightFixer = _this.createTableElement(); //table element - element.style.paddingTop = ""; - element.style.paddingBottom = ""; - element.style.minWidth = ""; - element.style.minHeight = ""; - element.style.display = ""; - element.style.visibility = ""; - this.scrollTop = 0; - this.scrollLeft = 0; - this.vDomTop = 0; - this.vDomBottom = 0; - this.vDomTopPad = 0; - this.vDomBottomPad = 0; + _this.firstRender = false; //handle first render + + _this.renderMode = "virtual"; //current rendering mode + + _this.fixedHeight = false; //current rendering mode + + _this.rows = []; //hold row data objects + + _this.activeRowsPipeline = []; //hold caluclation of active rows + + _this.activeRows = []; //rows currently available to on display in the table + + _this.activeRowsCount = 0; //count of active rows + + _this.displayRows = []; //rows currently on display in the table + + _this.displayRowsCount = 0; //count of display rows + + _this.scrollTop = 0; + _this.scrollLeft = 0; + _this.rowNumColumn = false; //hold column component for row number column + + _this.redrawBlock = false; //prevent redraws to allow multiple data manipulations becore continuing + + _this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed + + _this.redrawBlockRederInPosition = false; //store latest redraw function calls for when redraw is needed + + _this.dataPipeline = []; //hold data pipeline tasks + + _this.displayPipeline = []; //hold data display pipeline tasks + + _this.renderer = null; + return _this; + } //////////////// Setup Functions ///////////////// + + + _createClass(RowManager, [{ + key: "createHolderElement", + value: function createHolderElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-tableHolder"); + el.setAttribute("tabindex", 0); + return el; } }, { - key: "styleRow", - value: function styleRow(row, index) { - var rowEl = row.getElement(); + key: "createTableElement", + value: function createTableElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-table"); + return el; + } //return containing element - if (index % 2) { - rowEl.classList.add("tabulator-row-even"); - rowEl.classList.remove("tabulator-row-odd"); - } else { - rowEl.classList.add("tabulator-row-odd"); - rowEl.classList.remove("tabulator-row-even"); - } - } //full virtual render + }, { + key: "getElement", + value: function getElement() { + return this.element; + } //return table element }, { - key: "_virtualRenderFill", - value: function _virtualRenderFill(position, forceMove, offset) { - var element = this.tableElement, - holder = this.element, - topPad = 0, - rowsHeight = 0, - topPadHeight = 0, - i = 0, - onlyGroupHeaders = true, - rows = this.getDisplayRows(); - position = position || 0; - offset = offset || 0; + key: "getTableElement", + value: function getTableElement() { + return this.tableElement; + } //return position of row in table - if (!position) { - this._clearVirtualDom(); + }, { + key: "getRowPosition", + value: function getRowPosition(row, active) { + if (active) { + return this.activeRows.indexOf(row); } else { - while (element.firstChild) { - element.removeChild(element.firstChild); - } //check if position is too close to bottom of table + return this.rows.indexOf(row); + } + } + }, { + key: "initialize", + value: function initialize() { + var _this2 = this; + + this.initializeRenderer(); //initialize manager + + this.element.appendChild(this.tableElement); + this.firstRender = true; //scroll header along with table body + this.element.addEventListener("scroll", function () { + var left = _this2.element.scrollLeft, + leftDir = _this2.scrollLeft > left, + top = _this2.element.scrollTop, + topDir = _this2.scrollTop > top; //handle horizontal scrolling - var heightOccupied = (this.displayRowsCount - position + 1) * this.vDomRowHeight; + if (_this2.scrollLeft != left) { + _this2.scrollLeft = left; - if (heightOccupied < this.height) { - position -= Math.ceil((this.height - heightOccupied) / this.vDomRowHeight); + _this2.dispatch("scroll-horizontal", left, leftDir); - if (position < 0) { - position = 0; - } - } //calculate initial pad + _this2.dispatchExternal("scrollHorizontal", left, leftDir); + } //handle verical scrolling - topPad = Math.min(Math.max(Math.floor(this.vDomWindowBuffer / this.vDomRowHeight), this.vDomWindowMinMarginRows), position); - position -= topPad; - } + if (_this2.scrollTop != top) { + _this2.scrollTop = top; - if (this.displayRowsCount && Helpers.elVisible(this.element)) { - this.vDomTop = position; - this.vDomBottom = position - 1; + _this2.renderer.scrollRows(top, topDir); - while ((rowsHeight <= this.height + this.vDomWindowBuffer || i < this.vDomWindowMinTotalRows) && this.vDomBottom < this.displayRowsCount - 1) { - var index = this.vDomBottom + 1, - row = rows[index], - rowHeight = 0; - this.styleRow(row, index); - element.appendChild(row.getElement()); - row.initialize(); + _this2.dispatch("scroll-vertical", top, topDir); - if (!row.heightInitialized) { - row.normalizeHeight(true); - } + _this2.dispatchExternal("scrollVertical", top, topDir); + } + }); + } ////////////////// Row Manipulation ////////////////// - rowHeight = row.getHeight(); + }, { + key: "findRow", + value: function findRow(subject) { + var _this3 = this; - if (i < topPad) { - topPadHeight += rowHeight; - } else { - rowsHeight += rowHeight; - } + if (_typeof(subject) == "object") { + if (subject instanceof Row$1) { + //subject is row element + return subject; + } else if (subject instanceof RowComponent$1) { + //subject is public row component + return subject._getSelf() || false; + } else if (typeof HTMLElement !== "undefined" && subject instanceof HTMLElement) { + //subject is a HTML element of the row + var match = this.rows.find(function (row) { + return row.getElement() === subject; + }); + return match || false; + } + } else if (typeof subject == "undefined" || subject === null) { + return false; + } else { + //subject should be treated as the index of the row + var _match = this.rows.find(function (row) { + return row.data[_this3.table.options.index] == subject; + }); - if (rowHeight > this.vDomWindowBuffer) { - this.vDomWindowBuffer = rowHeight * 2; - } + return _match || false; + } //catch all for any other type of input - if (row.type !== "group") { - onlyGroupHeaders = false; - } - this.vDomBottom++; - i++; - } + return false; + } + }, { + key: "getRowFromDataObject", + value: function getRowFromDataObject(data) { + var match = this.rows.find(function (row) { + return row.data === data; + }); + return match || false; + } + }, { + key: "getRowFromPosition", + value: function getRowFromPosition(position, active) { + if (active) { + return this.activeRows[position]; + } else { + return this.rows[position]; + } + } + }, { + key: "scrollToRow", + value: function scrollToRow(row, position, ifVisible) { + return this.renderer.scrollToRowPosition(row, position, ifVisible); + } ////////////////// Data Handling ////////////////// - if (!position) { - this.vDomTopPad = 0; //adjust rowheight to match average of rendered elements + }, { + key: "setData", + value: function setData(data, renderInPosition, columnsChanged) { + var _this4 = this; - this.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / i); - this.vDomBottomPad = this.vDomRowHeight * (this.displayRowsCount - this.vDomBottom - 1); - this.vDomScrollHeight = topPadHeight + rowsHeight + this.vDomBottomPad - this.height; + return new Promise(function (resolve, reject) { + if (renderInPosition && _this4.getDisplayRows().length) { + if (_this4.table.options.pagination) { + _this4._setDataActual(data, true); + } else { + _this4.reRenderInPosition(function () { + _this4._setDataActual(data); + }); + } } else { - this.vDomTopPad = !forceMove ? this.scrollTop - topPadHeight : this.vDomRowHeight * this.vDomTop + offset; - this.vDomBottomPad = this.vDomBottom == this.displayRowsCount - 1 ? 0 : Math.max(this.vDomScrollHeight - this.vDomTopPad - rowsHeight - topPadHeight, 0); - } + if (_this4.table.options.autoColumns && columnsChanged) { + _this4.table.columnManager.generateColumnsFromRowData(data); + } - element.style.paddingTop = this.vDomTopPad + "px"; - element.style.paddingBottom = this.vDomBottomPad + "px"; + _this4.resetScroll(); - if (forceMove) { - this.scrollTop = this.vDomTopPad + topPadHeight + offset - (this.element.scrollWidth > this.element.clientWidth ? this.element.offsetHeight - this.element.clientHeight : 0); + _this4._setDataActual(data); } - this.scrollTop = Math.min(this.scrollTop, this.element.scrollHeight - this.height); //adjust for horizontal scrollbar if present (and not at top of table) + resolve(); + }); + } + }, { + key: "_setDataActual", + value: function _setDataActual(data, renderInPosition) { + var _this5 = this; - if (this.element.scrollWidth > this.element.offsetWidth && forceMove) { - this.scrollTop += this.element.offsetHeight - this.element.clientHeight; - } + this.dispatchExternal("dataProcessing", data); - this.vDomScrollPosTop = this.scrollTop; - this.vDomScrollPosBottom = this.scrollTop; - holder.scrollTop = this.scrollTop; - element.style.minWidth = onlyGroupHeaders ? this.table.columnManager.getWidth() + "px" : ""; + this._wipeElements(); - if (this.table.options.groupBy) { - if (this.table.modules.layout.getMode() != "fitDataFill" && this.displayRowsCount == this.table.modules.groupRows.countGroups()) { - this.tableElement.style.minWidth = this.table.columnManager.getWidth(); + if (Array.isArray(data)) { + this.dispatch("data-processing", data); + data.forEach(function (def, i) { + if (def && _typeof(def) === "object") { + var row = new Row$1(def, _this5); + + _this5.rows.push(row); + } else { + console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def); } - } + }); + this.refreshActiveData(false, false, renderInPosition); + this.dispatch("data-processed", data); + this.dispatchExternal("dataProcesed", data); } else { - this.renderEmptyScroll(); + console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", _typeof(data), "\nData: ", data); } + } + }, { + key: "_wipeElements", + value: function _wipeElements() { + this.dispatch("rows-wipe"); + this.rows.forEach(function (row) { + row.wipe(); + }); + this.rows = []; + this.activeRows = []; + this.activeRowsPipeline = []; + this.activeRowsCount = 0; + this.displayRows = []; + this.displayRowsCount = 0; + this.adjustTableSize(); + } + }, { + key: "deleteRow", + value: function deleteRow(row, blockRedraw) { + var allIndex = this.rows.indexOf(row), + activeIndex = this.activeRows.indexOf(row); - if (!this.fixedHeight) { - this.adjustTableSize(); + if (activeIndex > -1) { + this.activeRows.splice(activeIndex, 1); } - } //handle vertical scrolling - }, { - key: "scrollVertical", - value: function scrollVertical(dir) { - var topDiff = this.scrollTop - this.vDomScrollPosTop; - var bottomDiff = this.scrollTop - this.vDomScrollPosBottom; - var margin = this.vDomWindowBuffer * 2; + if (allIndex > -1) { + this.rows.splice(allIndex, 1); + } - if (-topDiff > margin || bottomDiff > margin) { - //if big scroll redraw table; - var left = this.scrollLeft; + this.setActiveRows(this.activeRows); + this.displayRowIterator(function (rows) { + var displayIndex = rows.indexOf(row); - this._virtualRenderFill(Math.floor(this.element.scrollTop / this.element.scrollHeight * this.displayRowsCount)); + if (displayIndex > -1) { + rows.splice(displayIndex, 1); + } + }); - this.scrollHorizontal(left); - } else { - if (dir) { - //scrolling up - if (topDiff < 0) { - this._addTopRow(-topDiff); - } + if (!blockRedraw) { + this.reRenderInPosition(); + } - if (bottomDiff < 0) { - //hide bottom row if needed - if (this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer) { - this._removeBottomRow(-bottomDiff); - } else { - this.vDomScrollPosBottom = this.scrollTop; - } - } - } else { - //scrolling down - if (topDiff >= 0) { - //hide top row if needed - if (this.scrollTop > this.vDomWindowBuffer) { - this._removeTopRow(topDiff); - } else { - this.vDomScrollPosTop = this.scrollTop; - } - } + this.regenerateRowNumbers(); + this.dispatchExternal("rowDeleted", row.getComponent()); - if (bottomDiff >= 0) { - this._addBottomRow(bottomDiff); - } - } + if (this.subscribedExternal("dataChanged")) { + this.dispatchExternal("dataChanged", this.getData()); } } }, { - key: "_addTopRow", - value: function _addTopRow(topDiff) { - var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var table = this.tableElement, - rows = this.getDisplayRows(); - - if (this.vDomTop) { - var index = this.vDomTop - 1, - topRow = rows[index], - topRowHeight = topRow.getHeight() || this.vDomRowHeight; //hide top row if needed - - if (topDiff >= topRowHeight) { - this.styleRow(topRow, index); - table.insertBefore(topRow.getElement(), table.firstChild); - - if (!topRow.initialized || !topRow.heightInitialized) { - this.vDomTopNewRows.push(topRow); + key: "addRow", + value: function addRow(data, pos, index, blockRedraw) { + var row = this.addRowActual(data, pos, index, blockRedraw); + this.dispatch("row-added", row, data, pos, index); + return row; + } //add multiple rows - if (!topRow.heightInitialized) { - topRow.clearCellHeight(); - } - } + }, { + key: "addRows", + value: function addRows(data, pos, index) { + var _this6 = this; - topRow.initialize(); - this.vDomTopPad -= topRowHeight; + var rows = []; + return new Promise(function (resolve, reject) { + pos = _this6.findAddRowPos(pos); - if (this.vDomTopPad < 0) { - this.vDomTopPad = index * this.vDomRowHeight; - } + if (!Array.isArray(data)) { + data = [data]; + } - if (!index) { - this.vDomTopPad = 0; - } + data.length - 1; - table.style.paddingTop = this.vDomTopPad + "px"; - this.vDomScrollPosTop -= topRowHeight; - this.vDomTop--; + if (typeof index == "undefined" && pos || typeof index !== "undefined" && !pos) { + data.reverse(); } - topDiff = -(this.scrollTop - this.vDomScrollPosTop); + data.forEach(function (item, i) { + var row = _this6.addRow(item, pos, index, true); - if (topRow.getHeight() > this.vDomWindowBuffer) { - this.vDomWindowBuffer = topRow.getHeight() * 2; - } + rows.push(row); + }); - if (i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (rows[this.vDomTop - 1].getHeight() || this.vDomRowHeight)) { - this._addTopRow(topDiff, i + 1); + if (_this6.subscribed("row-added")) { + _this6.dispatch("row-added", row, data, pos, index); } else { - this._quickNormalizeRowHeight(this.vDomTopNewRows); + _this6.reRenderInPosition(); } - } + + _this6.regenerateRowNumbers(); + + resolve(rows); + }); } }, { - key: "_removeTopRow", - value: function _removeTopRow(topDiff) { - var table = this.tableElement, - topRow = this.getDisplayRows()[this.vDomTop], - topRowHeight = topRow.getHeight() || this.vDomRowHeight; + key: "findAddRowPos", + value: function findAddRowPos(pos) { + if (typeof pos === "undefined") { + pos = this.table.options.addRowPos; + } - if (topDiff >= topRowHeight) { - var rowEl = topRow.getElement(); - rowEl.parentNode.removeChild(rowEl); - this.vDomTopPad += topRowHeight; - table.style.paddingTop = this.vDomTopPad + "px"; - this.vDomScrollPosTop += this.vDomTop ? topRowHeight : topRowHeight + this.vDomWindowBuffer; - this.vDomTop++; - topDiff = this.scrollTop - this.vDomScrollPosTop; + if (pos === "pos") { + pos = true; + } - this._removeTopRow(topDiff); + if (pos === "bottom") { + pos = false; } + + return pos; } }, { - key: "_addBottomRow", - value: function _addBottomRow(bottomDiff) { - var i = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; - var table = this.tableElement, - rows = this.getDisplayRows(); + key: "addRowActual", + value: function addRowActual(data, pos, index, blockRedraw) { + var row = data instanceof Row$1 ? data : new Row$1(data || {}, this), + top = this.findAddRowPos(pos), + allIndex = -1, + activeIndex, + chainResult; - if (this.vDomBottom < this.displayRowsCount - 1) { - var index = this.vDomBottom + 1, - bottomRow = rows[index], - bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight; //hide bottom row if needed + if (!index) { + chainResult = this.chain("row-adding-position", [row, top], null, { + index: index, + top: top + }); + index = chainResult.index; + top = chainResult.top; + } - if (bottomDiff >= bottomRowHeight) { - this.styleRow(bottomRow, index); - table.appendChild(bottomRow.getElement()); + if (typeof index !== "undefined") { + index = this.findRow(index); + } - if (!bottomRow.initialized || !bottomRow.heightInitialized) { - this.vDomBottomNewRows.push(bottomRow); + index = this.chain("row-adding-index", [row, index, top], null, index); - if (!bottomRow.heightInitialized) { - bottomRow.clearCellHeight(); - } - } + if (index) { + allIndex = this.rows.indexOf(index); + } - bottomRow.initialize(); - this.vDomBottomPad -= bottomRowHeight; + if (index && allIndex > -1) { + activeIndex = this.activeRows.indexOf(index); + this.displayRowIterator(function (rows) { + var displayIndex = rows.indexOf(index); - if (this.vDomBottomPad < 0 || index == this.displayRowsCount - 1) { - this.vDomBottomPad = 0; + if (displayIndex > -1) { + rows.splice(top ? displayIndex : displayIndex + 1, 0, row); } + }); - table.style.paddingBottom = this.vDomBottomPad + "px"; - this.vDomScrollPosBottom += bottomRowHeight; - this.vDomBottom++; - } - - bottomDiff = this.scrollTop - this.vDomScrollPosBottom; - - if (bottomRow.getHeight() > this.vDomWindowBuffer) { - this.vDomWindowBuffer = bottomRow.getHeight() * 2; + if (activeIndex > -1) { + this.activeRows.splice(top ? activeIndex : activeIndex + 1, 0, row); } - if (i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount - 1 && bottomDiff >= (rows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)) { - this._addBottomRow(bottomDiff, i + 1); + this.rows.splice(top ? allIndex : allIndex + 1, 0, row); + } else { + if (top) { + this.displayRowIterator(function (rows) { + rows.unshift(row); + }); + this.activeRows.unshift(row); + this.rows.unshift(row); } else { - this._quickNormalizeRowHeight(this.vDomBottomNewRows); + this.displayRowIterator(function (rows) { + rows.push(row); + }); + this.activeRows.push(row); + this.rows.push(row); } } - } - }, { - key: "_removeBottomRow", - value: function _removeBottomRow(bottomDiff) { - var table = this.tableElement, - bottomRow = this.getDisplayRows()[this.vDomBottom], - bottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight; - - if (bottomDiff >= bottomRowHeight) { - var rowEl = bottomRow.getElement(); - - if (rowEl.parentNode) { - rowEl.parentNode.removeChild(rowEl); - } - this.vDomBottomPad += bottomRowHeight; - - if (this.vDomBottomPad < 0) { - this.vDomBottomPad = 0; - } + this.setActiveRows(this.activeRows); + this.dispatchExternal("rowAdded", row.getComponent()); - table.style.paddingBottom = this.vDomBottomPad + "px"; - this.vDomScrollPosBottom -= bottomRowHeight; - this.vDomBottom--; - bottomDiff = -(this.scrollTop - this.vDomScrollPosBottom); + if (this.subscribedExternal("dataChanged")) { + this.dispatchExternal("dataChanged", this.table.rowManager.getData()); + } - this._removeBottomRow(bottomDiff); + if (!blockRedraw) { + this.reRenderInPosition(); } + + return row; } }, { - key: "_quickNormalizeRowHeight", - value: function _quickNormalizeRowHeight(rows) { - rows.forEach(function (row) { - row.calcHeight(); - }); - rows.forEach(function (row) { - row.setCellHeight(); - }); - rows.length = 0; - } //normalize height of active rows - + key: "moveRow", + value: function moveRow(from, to, after) { + this.dispatch("row-move", from, to, after); + this.moveRowActual(from, to, after); + this.regenerateRowNumbers(); + this.dispatch("row-moved", from, to, after); + this.dispatchExternal("rowMoved", from.getComponent()); + } }, { - key: "normalizeHeight", - value: function normalizeHeight() { - this.activeRows.forEach(function (row) { - row.normalizeHeight(); - }); - } //adjust the height of the table holder to fit in the Tabulator element + key: "moveRowActual", + value: function moveRowActual(from, to, after) { + var _this7 = this; + this.moveRowInArray(this.rows, from, to, after); + this.moveRowInArray(this.activeRows, from, to, after); + this.displayRowIterator(function (rows) { + _this7.moveRowInArray(rows, from, to, after); + }); + this.dispatch("row-moving", from, to, after); + } }, { - key: "adjustTableSize", - value: function adjustTableSize() { - var initialHeight = this.element.clientHeight, - modExists; + key: "moveRowInArray", + value: function moveRowInArray(rows, from, to, after) { + var fromIndex, toIndex, start, end; - if (this.renderMode === "virtual") { - var otherHeight = Math.floor(this.columnManager.getElement().getBoundingClientRect().height + (this.table.footerManager && this.table.footerManager.active && !this.table.footerManager.external ? this.table.footerManager.getElement().getBoundingClientRect().height : 0)); + if (from !== to) { + fromIndex = rows.indexOf(from); - if (this.fixedHeight) { - this.element.style.minHeight = "calc(100% - " + otherHeight + "px)"; - this.element.style.height = "calc(100% - " + otherHeight + "px)"; - this.element.style.maxHeight = "calc(100% - " + otherHeight + "px)"; - } else { - this.element.style.height = ""; - this.element.style.height = this.table.element.clientHeight - otherHeight + "px"; - this.element.scrollTop = this.scrollTop; - } + if (fromIndex > -1) { + rows.splice(fromIndex, 1); + toIndex = rows.indexOf(to); + + if (toIndex > -1) { + if (after) { + rows.splice(toIndex + 1, 0, from); + } else { + rows.splice(toIndex, 0, from); + } + } else { + rows.splice(fromIndex, 0, from); + } + } //restyle rows - this.height = this.element.clientHeight; - this.vDomWindowBuffer = this.table.options.virtualDomBuffer || this.height; //check if the table has changed size when dealing with variable height tables - if (!this.fixedHeight && initialHeight != this.element.clientHeight) { - modExists = this.table.modExists("resizeTable"); + if (rows === this.getDisplayRows()) { + start = fromIndex < toIndex ? fromIndex : toIndex; + end = toIndex > fromIndex ? toIndex : fromIndex + 1; - if (modExists && !this.table.modules.resizeTable.autoResize || !modExists) { - this.redraw(); + for (var i = start; i <= end; i++) { + if (rows[i]) { + this.styleRow(rows[i], i); + } } } } - } //renitialize all rows - + } }, { - key: "reinitialize", - value: function reinitialize() { - this.rows.forEach(function (row) { - row.reinitialize(true); - }); - } //prevent table from being redrawn - + key: "clearData", + value: function clearData() { + this.setData([]); + } }, { - key: "blockRedraw", - value: function blockRedraw() { - this.redrawBlock = true; - this.redrawBlockRestoreConfig = false; - } //restore table redrawing - + key: "getRowIndex", + value: function getRowIndex(row) { + return this.findRowIndex(row, this.rows); + } }, { - key: "restoreRedraw", - value: function restoreRedraw() { - this.redrawBlock = false; - - if (this.redrawBlockRestoreConfig) { - this.refreshActiveData(this.redrawBlockRestoreConfig.stage, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition); - this.redrawBlockRestoreConfig = false; - } else { - if (this.redrawBlockRederInPosition) { - this.reRenderInPosition(); - } - } - - this.redrawBlockRederInPosition = false; - } //redraw table - + key: "getDisplayRowIndex", + value: function getDisplayRowIndex(row) { + var index = this.getDisplayRows().indexOf(row); + return index > -1 ? index : false; + } }, { - key: "redraw", - value: function redraw(force) { - var left = this.scrollLeft; - this.adjustTableSize(); - this.table.tableWidth = this.table.element.clientWidth; + key: "nextDisplayRow", + value: function nextDisplayRow(row, rowOnly) { + var index = this.getDisplayRowIndex(row), + nextRow = false; - if (!force) { - if (this.renderMode == "classic") { - if (this.table.options.groupBy) { - this.refreshActiveData("group", false, false); - } else { - this._simpleRender(); - } - } else { - this.reRenderInPosition(); - this.scrollHorizontal(left); - } + if (index !== false && index < this.displayRowsCount - 1) { + nextRow = this.getDisplayRows()[index + 1]; + } - if (!this.displayRowsCount) { - if (this.table.options.placeholder) { - this.getElement().appendChild(this.table.options.placeholder); - } - } - } else { - this.renderTable(); + if (nextRow && (!(nextRow instanceof Row$1) || nextRow.type != "row")) { + return this.nextDisplayRow(nextRow, rowOnly); } + + return nextRow; } }, { - key: "resetScroll", - value: function resetScroll() { - this.element.scrollLeft = 0; - this.element.scrollTop = 0; + key: "prevDisplayRow", + value: function prevDisplayRow(row, rowOnly) { + var index = this.getDisplayRowIndex(row), + prevRow = false; - if (this.table.browser === "ie") { - var event = document.createEvent("Event"); - event.initEvent("scroll", false, true); - this.element.dispatchEvent(event); - } else { - this.element.dispatchEvent(new Event('scroll')); + if (index) { + prevRow = this.getDisplayRows()[index - 1]; } - } - }]); - - return RowManager; - }(); - - var FooterManager = /*#__PURE__*/function () { - function FooterManager(table) { - _classCallCheck(this, FooterManager); - this.table = table; - this.active = false; - this.element = this.createElement(); //containing element - - this.external = false; - this.links = []; - - this._initialize(); - } + if (rowOnly && prevRow && (!(prevRow instanceof Row$1) || prevRow.type != "row")) { + return this.prevDisplayRow(prevRow, rowOnly); + } - _createClass(FooterManager, [{ - key: "createElement", - value: function createElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-footer"); - return el; + return prevRow; } }, { - key: "_initialize", - value: function _initialize(element) { - if (this.table.options.footerElement) { - switch (_typeof(this.table.options.footerElement)) { - case "string": - if (this.table.options.footerElement[0] === "<") { - this.element.innerHTML = this.table.options.footerElement; - } else { - this.external = true; - this.element = document.querySelector(this.table.options.footerElement); - } + key: "findRowIndex", + value: function findRowIndex(row, list) { + var rowIndex; + row = this.findRow(row); - break; + if (row) { + rowIndex = list.indexOf(row); - default: - this.element = this.table.options.footerElement; - break; + if (rowIndex > -1) { + return rowIndex; } } + + return false; } }, { - key: "getElement", - value: function getElement() { - return this.element; + key: "getData", + value: function getData(active, transform) { + var output = [], + rows = this.getRows(active); + rows.forEach(function (row) { + if (row.type == "row") { + output.push(row.getData(transform || "data")); + } + }); + return output; } }, { - key: "append", - value: function append(element, parent) { - this.activate(parent); - this.element.appendChild(element); - this.table.rowManager.adjustTableSize(); + key: "getComponents", + value: function getComponents(active) { + var output = [], + rows = this.getRows(active); + rows.forEach(function (row) { + output.push(row.getComponent()); + }); + return output; } }, { - key: "prepend", - value: function prepend(element, parent) { - this.activate(parent); - this.element.insertBefore(element, this.element.firstChild); - this.table.rowManager.adjustTableSize(); + key: "getDataCount", + value: function getDataCount(active) { + var rows = this.getRows(active); + return rows.length; } }, { - key: "remove", - value: function remove(element) { - element.parentNode.removeChild(element); - this.deactivate(); + key: "scrollHorizontal", + value: function scrollHorizontal(left) { + this.scrollLeft = left; + this.element.scrollLeft = left; + this.dispatch("scroll-horizontal", left); } }, { - key: "deactivate", - value: function deactivate(force) { - if (!this.element.firstChild || force) { - if (!this.external) { - this.element.parentNode.removeChild(this.element); - } - - this.active = false; + key: "registerDataPipelineHandler", + value: function registerDataPipelineHandler(handler, priority) { + if (typeof priority !== "undefined") { + this.dataPipeline.push({ + handler: handler, + priority: priority + }); + this.dataPipeline.sort(function (a, b) { + return a.priority - b.priority; + }); + } else { + console.error("Data pipeline handlers must have a priority in order to be registered"); } } }, { - key: "activate", - value: function activate(parent) { - if (!this.active) { - this.active = true; - - if (!this.external) { - this.table.element.appendChild(this.getElement()); - this.table.element.style.display = ''; - } + key: "registerDisplayPipelineHandler", + value: function registerDisplayPipelineHandler(handler, priority) { + if (typeof priority !== "undefined") { + this.displayPipeline.push({ + handler: handler, + priority: priority + }); + this.displayPipeline.sort(function (a, b) { + return a.priority - b.priority; + }); + } else { + console.error("Display pipeline handlers must have a priority in order to be registered"); } + } //set active data set - if (parent) { - this.links.push(parent); - } - } }, { - key: "redraw", - value: function redraw() { - this.links.forEach(function (link) { - link.footerRedraw(); - }); - } - }]); - - return FooterManager; - }(); - - var TableRegistry = /*#__PURE__*/function () { - function TableRegistry() { - _classCallCheck(this, TableRegistry); - } + key: "refreshActiveData", + value: function refreshActiveData(handler, skipStage, renderInPosition) { + var table = this.table, + stage = "", + index = 0, + cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"]; - _createClass(TableRegistry, null, [{ - key: "register", - value: function register(table) { - TableRegistry.tables.push(table); - } - }, { - key: "deregister", - value: function deregister(table) { - var index = TableRegistry.tables.indexOf(table); + if (typeof handler === "function") { + index = this.dataPipeline.findIndex(function (item) { + return item.handler === handler; + }); - if (index > -1) { - TableRegistry.tables.splice(index, 1); - } - } - }, { - key: "lookupTable", - value: function lookupTable(query, silent) { - var results = [], - matches, - match; + if (index > -1) { + stage = "dataPipeline"; - if (typeof query === "string") { - matches = document.querySelectorAll(query); + if (skipStage) { + if (index == this.dataPipeline.length - 1) { + stage = "display"; + } else { + index++; + } + } + } else { + index = this.displayPipeline.findIndex(function (item) { + return item.handler === handler; + }); - if (matches.length) { - for (var i = 0; i < matches.length; i++) { - match = TableRegistry.matchElement(matches[i]); + if (index > -1) { + stage = "displayPipeline"; - if (match) { - results.push(match); + if (skipStage) { + if (index == this.displayPipeline.length - 1) { + stage = "end"; + } else { + index++; + } } + } else { + console.error("Unable to refresh data, invalid handler provided", handler); + return; } } - } else if (typeof HTMLElement !== "undefined" && query instanceof HTMLElement || query instanceof Tabulator$1) { - match = TableRegistry.matchElement(query); + } else { + stage = handler || "all"; + index = 0; + } - if (match) { - results.push(match); + if (this.redrawBlock) { + if (!this.redrawBlockRestoreConfig || this.redrawBlockRestoreConfig && (this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index || cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))) { + this.redrawBlockRestoreConfig = { + handler: handler, + skipStage: skipStage, + renderInPosition: renderInPosition, + stage: stage, + index: index + }; } - } else if (Array.isArray(query)) { - query.forEach(function (item) { - results = results.concat(TableRegistry.lookupTable(item)); - }); + + return; } else { - if (!silent) { - console.warn("Table Connection Error - Invalid Selector", query); + this.dispatch("data-refeshing"); + + if (!handler) { + this.activeRowsPipeline[0] = this.rows.slice(0); + } //cascade through data refresh stages + + + switch (stage) { + case "all": //handle case where alldata needs refreshing + + case "dataPipeline": + for (var i = index; i < this.dataPipeline.length; i++) { + var result = this.dataPipeline[i].handler(this.activeRowsPipeline[i].slice(0)); + this.activeRowsPipeline[i + 1] = result || this.activeRowsPipeline[i].slice(0); + } + + this.setActiveRows(this.activeRowsPipeline[this.dataPipeline.length]); + this.regenerateRowNumbers(); + + case "display": + index = 0; + this.resetDisplayRows(); + + case "displayPipeline": + for (var _i = index; _i < this.displayPipeline.length; _i++) { + var _result = this.displayPipeline[_i].handler((_i ? this.getDisplayRows(_i - 1) : this.activeRows).slice(0), renderInPosition); + + this.setDisplayRows(_result || this.getDisplayRows(_i - 1).slice(0), _i); + } + } - } - return results; - } - }, { - key: "matchElement", - value: function matchElement(element) { - return TableRegistry.tables.find(function (table) { - return element instanceof Tabulator$1 ? table === element : table.element === element; - }); - } - }]); + if (Helpers$1.elVisible(this.element)) { + if (renderInPosition) { + this.reRenderInPosition(); + } else { + if (!handler) { + this.table.columnManager.renderer.renderColumns(); + } - return TableRegistry; - }(); + this.renderTable(); - TableRegistry.tables = []; + if (table.options.layoutColumnsOnNewData) { + this.table.columnManager.redraw(true); + } + } + } - var Module = /*#__PURE__*/function () { - function Module(table, name) { - _classCallCheck(this, Module); + this.dispatch("data-refeshed"); + } + } //regenerate row numbers for row number formatter if in use - this.table = table; - } + }, { + key: "regenerateRowNumbers", + value: function regenerateRowNumbers() { + var _this8 = this; - _createClass(Module, [{ - key: "register", - value: function register() {} - }]); + if (this.rowNumColumn) { + this.activeRows.forEach(function (row) { + var cell = row.getCell(_this8.rowNumColumn); - return Module; - }(); + if (cell) { + cell._generateContents(); + } + }); + } + } + }, { + key: "setActiveRows", + value: function setActiveRows(activeRows) { + this.activeRows = activeRows; + this.activeRowsCount = this.activeRows.length; + } //reset display rows array - //resize columns to fit data they contain - function fitData (columns) { - if (this.table.options.virtualDomHoz) { - this.table.vdomHoz.fitDataLayoutOverride(); - } else { - columns.forEach(function (column) { - column.reinitializeWidth(); - }); - } + }, { + key: "resetDisplayRows", + value: function resetDisplayRows() { + this.displayRows = []; + this.displayRows.push(this.activeRows.slice(0)); + this.displayRowsCount = this.displayRows[0].length; + } + }, { + key: "getNextDisplayIndex", + value: function getNextDisplayIndex() { + return this.displayRows.length; + } //set display row pipeline data + + }, { + key: "setDisplayRows", + value: function setDisplayRows(displayRows, index) { + var output = true; + + if (index && typeof this.displayRows[index] != "undefined") { + this.displayRows[index] = displayRows; + output = true; + } else { + this.displayRows.push(displayRows); + output = index = this.displayRows.length - 1; + } - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.update(); - } - } + if (index == this.displayRows.length - 1) { + this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length; + } - //resize columns to fit data they contain and stretch row to fill table, also used for fitDataTable - function fitDataGeneral (columns) { - columns.forEach(function (column) { - column.reinitializeWidth(); - }); + return output; + } + }, { + key: "getDisplayRows", + value: function getDisplayRows(index) { + if (typeof index == "undefined") { + return this.displayRows.length ? this.displayRows[this.displayRows.length - 1] : []; + } else { + return this.displayRows[index] || []; + } + } + }, { + key: "getVisibleRows", + value: function getVisibleRows(viewable) { + return this.renderer.visibleRows(!viewable); + } //repeat action accross display rows - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.update(); - } - } + }, { + key: "displayRowIterator", + value: function displayRowIterator(callback) { + this.activeRowsPipeline.forEach(callback); + this.displayRows.forEach(callback); + this.displayRowsCount = this.displayRows[this.displayRows.length - 1].length; + } //return only actual rows (not group headers etc) - //resize columns to fit data the contain and stretch last column to fill table - function fitDataStretch (columns) { - var _this = this; + }, { + key: "getRows", + value: function getRows(type) { + var rows; - var colsWidth = 0, - tableWidth = this.table.rowManager.element.clientWidth, - gap = 0, - lastCol = false; - columns.forEach(function (column, i) { - if (!column.widthFixed) { - column.reinitializeWidth(); - } + switch (type) { + case "active": + rows = this.activeRows; + break; - if (_this.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible) { - lastCol = column; - } + case "display": + rows = this.table.rowManager.getDisplayRows(); + break; - if (column.visible) { - colsWidth += column.getWidth(); - } - }); + case "visible": + rows = this.getVisibleRows(true); + break; - if (lastCol) { - gap = tableWidth - colsWidth + lastCol.getWidth(); + default: + rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows; + } - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - lastCol.setWidth(0); - this.table.modules.responsiveLayout.update(); - } + return rows; + } ///////////////// Table Rendering ///////////////// + //trigger rerender of table in current position - if (gap > 0) { - lastCol.setWidth(gap); - } else { - lastCol.reinitializeWidth(); - } - } else { - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.update(); + }, { + key: "reRenderInPosition", + value: function reRenderInPosition(callback) { + if (this.redrawBlock) { + if (callback) { + callback(); + } else { + this.redrawBlockRederInPosition = true; + } + } else { + this.renderer.rerenderRows(callback); + } } - } - } - - //resize columns to fit - function fitColumns (columns) { - var totalWidth = this.table.element.clientWidth; //table element width + }, { + key: "initializeRenderer", + value: function initializeRenderer() { + var renderClass; + var renderers = { + "virtual": VirtualDomVertical, + "basic": BaiscVertical + }; - var fixedWidth = 0; //total width of columns with a defined width + if (typeof this.table.options.renderVertical === "string") { + renderClass = renderers[this.table.options.renderVertical]; + } else { + renderClass = this.table.options.renderVertical; + } - var flexWidth = 0; //total width available to flexible columns + if (renderClass) { + this.renderer = new renderClass(this.table, this.element, this.tableElement); + this.renderer.initialize(); - var flexGrowUnits = 0; //total number of widthGrow blocks accross all columns + if (this.table.element.clientHeight || this.table.options.height) { + this.fixedHeight = true; + } else { + this.fixedHeight = false; + } + } else { + console.error("Unable to find matching renderer:", table.options.renderVertical); + } + } + }, { + key: "getRenderMode", + value: function getRenderMode() { + return this.renderMode; + } + }, { + key: "renderTable", + value: function renderTable() { + this.dispatchExternal("renderStarted"); + this.element.scrollTop = 0; - var flexColWidth = 0; //desired width of flexible columns + if (this.displayRowsCount) { + this._clearTable(); - var flexColumns = []; //array of flexible width columns + this.renderer.renderRows(); - var fixedShrinkColumns = []; //array of fixed width columns that can shrink + if (this.firstRender) { + this.firstRender = false; + this.layoutRefresh(); + } + } else { + this.renderEmptyScroll(); + } - var flexShrinkUnits = 0; //total number of widthShrink blocks accross all columns + if (!this.fixedHeight) { + this.adjustTableSize(); + } - var overflowWidth = 0; //horizontal overflow width + this.dispatch("table-layout"); - var gapFill = 0; //number of pixels to be added to final column to close and half pixel gaps + if (!this.displayRowsCount) { + if (this.table.options.placeholder) { + this.table.options.placeholder.setAttribute("tabulator-render-mode", this.renderMode); + this.getElement().appendChild(this.table.options.placeholder); + this.table.options.placeholder.style.width = this.table.columnManager.getWidth() + "px"; + } + } - function calcWidth(width) { - var colWidth; + this.dispatchExternal("renderComplete"); + } //show scrollbars on empty table div - if (typeof width == "string") { - if (width.indexOf("%") > -1) { - colWidth = totalWidth / 100 * parseInt(width); + }, { + key: "renderEmptyScroll", + value: function renderEmptyScroll() { + if (this.table.options.placeholder) { + this.tableElement.style.display = "none"; } else { - colWidth = parseInt(width); + this.tableElement.style.minWidth = this.table.columnManager.getWidth() + "px"; // this.tableElement.style.minHeight = "1px"; + // this.tableElement.style.visibility = "hidden"; } - } else { - colWidth = width; } + }, { + key: "_clearTable", + value: function _clearTable() { + var element = this.tableElement; - return colWidth; - } //ensure columns resize to take up the correct amount of space + if (this.table.options.placeholder && this.table.options.placeholder.parentNode) { + this.table.options.placeholder.parentNode.removeChild(this.table.options.placeholder); + } + this.scrollTop = 0; + this.scrollLeft = 0; + this.renderer.clearRows(); + } + }, { + key: "styleRow", + value: function styleRow(row, index) { + var rowEl = row.getElement(); - function scaleColumns(columns, freeSpace, colWidth, shrinkCols) { - var oversizeCols = [], - oversizeSpace = 0, - remainingSpace = 0, - nextColWidth = 0, - remainingFlexGrowUnits = flexGrowUnits, - gap = 0, - changeUnits = 0, - undersizeCols = []; + if (index % 2) { + rowEl.classList.add("tabulator-row-even"); + rowEl.classList.remove("tabulator-row-odd"); + } else { + rowEl.classList.add("tabulator-row-odd"); + rowEl.classList.remove("tabulator-row-even"); + } + } //normalize height of active rows - function calcGrow(col) { - return colWidth * (col.column.definition.widthGrow || 1); - } + }, { + key: "normalizeHeight", + value: function normalizeHeight() { + this.activeRows.forEach(function (row) { + row.normalizeHeight(); + }); + } //adjust the height of the table holder to fit in the Tabulator element - function calcShrink(col) { - return calcWidth(col.width) - colWidth * (col.column.definition.widthShrink || 0); - } + }, { + key: "adjustTableSize", + value: function adjustTableSize() { + var initialHeight = this.element.clientHeight; - columns.forEach(function (col, i) { - var width = shrinkCols ? calcShrink(col) : calcGrow(col); + if (this.renderer.verticalFillMode === "fill") { + var otherHeight = Math.floor(this.table.columnManager.getElement().getBoundingClientRect().height + (this.table.footerManager && this.table.footerManager.active && !this.table.footerManager.external ? this.table.footerManager.getElement().getBoundingClientRect().height : 0)); - if (col.column.minWidth >= width) { - oversizeCols.push(col); - } else { - if (col.column.maxWidth && col.column.maxWidth < width) { - col.width = col.column.maxWidth; - freeSpace -= col.column.maxWidth; - remainingFlexGrowUnits -= shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1; + if (this.fixedHeight) { + this.element.style.minHeight = "calc(100% - " + otherHeight + "px)"; + this.element.style.height = "calc(100% - " + otherHeight + "px)"; + this.element.style.maxHeight = "calc(100% - " + otherHeight + "px)"; + } else { + this.element.style.height = ""; + this.element.style.height = this.table.element.clientHeight - otherHeight + "px"; + this.element.scrollTop = this.scrollTop; + } - if (remainingFlexGrowUnits) { - colWidth = Math.floor(freeSpace / remainingFlexGrowUnits); + this.renderer.resize(); //check if the table has changed size when dealing with variable height tables + + if (!this.fixedHeight && initialHeight != this.element.clientHeight) { + if (this.subscribed("table-resize")) { + this.dispatch("table-resize"); + } else { + this.redraw(); } - } else { - undersizeCols.push(col); - changeUnits += shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1; } } - }); - - if (oversizeCols.length) { - oversizeCols.forEach(function (col) { - oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth; - col.width = col.column.minWidth; - }); - remainingSpace = freeSpace - oversizeSpace; - nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace; - gap = remainingSpace - nextColWidth * changeUnits; - gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols); - } else { - gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace; - undersizeCols.forEach(function (column) { - column.width = shrinkCols ? calcShrink(column) : calcGrow(column); - }); - } + } //renitialize all rows - return gap; - } + }, { + key: "reinitialize", + value: function reinitialize() { + this.rows.forEach(function (row) { + row.reinitialize(true); + }); + } //prevent table from being redrawn - if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { - this.table.modules.responsiveLayout.update(); - } //adjust for vertical scrollbar if present + }, { + key: "blockRedraw", + value: function blockRedraw() { + this.redrawBlock = true; + this.redrawBlockRestoreConfig = false; + } //restore table redrawing + }, { + key: "restoreRedraw", + value: function restoreRedraw() { + this.redrawBlock = false; - if (this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight) { - totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth; - } + if (this.redrawBlockRestoreConfig) { + this.refreshActiveData(this.redrawBlockRestoreConfig.handler, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition); + this.redrawBlockRestoreConfig = false; + } else { + if (this.redrawBlockRederInPosition) { + this.reRenderInPosition(); + } + } - columns.forEach(function (column) { - var width, minWidth, colWidth; + this.redrawBlockRederInPosition = false; + } //redraw table - if (column.visible) { - width = column.definition.width; - minWidth = parseInt(column.minWidth); + }, { + key: "redraw", + value: function redraw(force) { + var left = this.scrollLeft; + this.adjustTableSize(); + this.table.tableWidth = this.table.element.clientWidth; - if (width) { - colWidth = calcWidth(width); - fixedWidth += colWidth > minWidth ? colWidth : minWidth; + if (!force) { + this.reRenderInPosition(); + this.scrollHorizontal(left); - if (column.definition.widthShrink) { - fixedShrinkColumns.push({ - column: column, - width: colWidth > minWidth ? colWidth : minWidth - }); - flexShrinkUnits += column.definition.widthShrink; + if (!this.displayRowsCount) { + if (this.table.options.placeholder) { + this.getElement().appendChild(this.table.options.placeholder); + } } } else { - flexColumns.push({ - column: column, - width: 0 - }); - flexGrowUnits += column.definition.widthGrow || 1; + this.renderTable(); } } - }); //calculate available space - - flexWidth = totalWidth - fixedWidth; //calculate correct column size - - flexColWidth = Math.floor(flexWidth / flexGrowUnits); //generate column widths - - var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false); //increase width of last column to account for rounding errors - - if (flexColumns.length && gapFill > 0) { - flexColumns[flexColumns.length - 1].width += +gapFill; - } //caculate space for columns to be shrunk into - - - flexColumns.forEach(function (col) { - flexWidth -= col.width; - }); - overflowWidth = Math.abs(gapFill) + flexWidth; //shrink oversize columns if there is no available space + }, { + key: "resetScroll", + value: function resetScroll() { + this.element.scrollLeft = 0; + this.element.scrollTop = 0; - if (overflowWidth > 0 && flexShrinkUnits) { - gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true); - } //decrease width of last column to account for rounding errors + if (this.table.browser === "ie") { + var event = document.createEvent("Event"); + event.initEvent("scroll", false, true); + this.element.dispatchEvent(event); + } else { + this.element.dispatchEvent(new Event('scroll')); + } + } + }]); + return RowManager; + }(CoreFeature); - if (fixedShrinkColumns.length) { - fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill; - } + var FooterManager = /*#__PURE__*/function (_CoreFeature) { + _inherits(FooterManager, _CoreFeature); - flexColumns.forEach(function (col) { - col.column.setWidth(col.width); - }); - fixedShrinkColumns.forEach(function (col) { - col.column.setWidth(col.width); - }); - } + var _super = _createSuper(FooterManager); - var defaultModes = { - fitData: fitData, - fitDataFill: fitDataGeneral, - fitDataTable: fitDataGeneral, - fitDataStretch: fitDataStretch, - fitColumns: fitColumns - }; + function FooterManager(table) { + var _this; - var Layout = /*#__PURE__*/function (_Module) { - _inherits(Layout, _Module); + _classCallCheck(this, FooterManager); - var _super = _createSuper(Layout); + _this = _super.call(this, table); + _this.active = false; + _this.element = _this.createElement(); //containing element - function Layout(table) { - var _this; + _this.external = false; + _this.links = []; - _classCallCheck(this, Layout); + _this.initializeElement(); - _this = _super.call(this, table, "layout"); - _this.mode = null; return _this; - } //initialize layout system - + } - _createClass(Layout, [{ + _createClass(FooterManager, [{ key: "initialize", - value: function initialize(layout) { - if (Layout.modes[layout]) { - this.mode = layout; - } else { - console.warn("Layout Error - invalid mode set, defaulting to 'fitData' : " + layout); - this.mode = 'fitData'; - } - - this.table.element.setAttribute("tabulator-layout", this.mode); + value: function initialize() {} + }, { + key: "createElement", + value: function createElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-footer"); + return el; } }, { - key: "getMode", - value: function getMode() { - return this.mode; - } //trigger table layout + key: "initializeElement", + value: function initializeElement(element) { + if (this.table.options.footerElement) { + switch (_typeof(this.table.options.footerElement)) { + case "string": + if (this.table.options.footerElement[0] === "<") { + this.element.innerHTML = this.table.options.footerElement; + } else { + this.external = true; + this.element = document.querySelector(this.table.options.footerElement); + } - }, { - key: "layout", - value: function layout() { - Layout.modes[this.mode].call(this, this.table.columnManager.columnsByIndex); + break; - if (this.mode.indexOf("fitData") === 0 && this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.columns) { - this.table.modules.persistence.save("columns"); + default: + this.element = this.table.options.footerElement; + break; + } } } - }]); - - return Layout; - }(Module); + }, { + key: "getElement", + value: function getElement() { + return this.element; + } + }, { + key: "append", + value: function append(element, parent) { + this.activate(parent); + this.element.appendChild(element); + this.table.rowManager.adjustTableSize(); + } + }, { + key: "prepend", + value: function prepend(element, parent) { + this.activate(parent); + this.element.insertBefore(element, this.element.firstChild); + this.table.rowManager.adjustTableSize(); + } + }, { + key: "remove", + value: function remove(element) { + element.parentNode.removeChild(element); + this.deactivate(); + } + }, { + key: "deactivate", + value: function deactivate(force) { + if (!this.element.firstChild || force) { + if (!this.external) { + this.element.parentNode.removeChild(this.element); + } - Layout.moduleName = "layout"; //load defaults + this.active = false; + } + } + }, { + key: "activate", + value: function activate(parent) { + if (!this.active) { + this.active = true; - Layout.modes = defaultModes; + if (!this.external) { + this.table.element.appendChild(this.getElement()); + this.table.element.style.display = ''; + } + } - var defaultLangs = { - "default": { - //hold default locale text - "groups": { - "item": "item", - "items": "items" - }, - "columns": {}, - "ajax": { - "loading": "Loading", - "error": "Error" - }, - "pagination": { - "page_size": "Page Size", - "page_title": "Show Page", - "first": "First", - "first_title": "First Page", - "last": "Last", - "last_title": "Last Page", - "prev": "Prev", - "prev_title": "Prev Page", - "next": "Next", - "next_title": "Next Page", - "all": "All" - }, - "headerFilters": { - "default": "filter column...", - "columns": {} + if (parent) { + this.links.push(parent); + } } - } - }; + }, { + key: "redraw", + value: function redraw() { + this.links.forEach(function (link) { + link.footerRedraw(); + }); + } + }]); - var Localize = /*#__PURE__*/function (_Module) { - _inherits(Localize, _Module); + return FooterManager; + }(CoreFeature); - var _super = _createSuper(Localize); + var InteractionManager = /*#__PURE__*/function (_CoreFeature) { + _inherits(InteractionManager, _CoreFeature); - function Localize(table) { + var _super = _createSuper(InteractionManager); + + function InteractionManager(table) { var _this; - _classCallCheck(this, Localize); + _classCallCheck(this, InteractionManager); _this = _super.call(this, table); - _this.locale = "default"; //current locale + _this.el = _this.table.element; + _this.abortClasses = ["tabulator-headers", "tabulator-table"]; + _this.previousTargets = {}; + _this.listeners = ["click", "dblclick", "contextmenu", "mouseenter", "mouseleave", "mouseover", "mouseout", "mousemove", "touchstart", "touchend"]; + _this.componentMap = { + "tabulator-cell": "cell", + "tabulator-row": "row", + "tabulator-group": "group", + "tabulator-col": "column" + }; - _this.lang = false; //current language + _this.buildListenerMap(); - _this.bindings = {}; //update events to call when locale is changed + _this.bindSubscriptionWatchers(); - _this.langList = {}; return _this; } - _createClass(Localize, [{ - key: "initialize", - value: function initialize() { - this.langList = Helpers.deepClone(Localize.langs); - } //set header placehoder - + _createClass(InteractionManager, [{ + key: "buildListenerMap", + value: function buildListenerMap() { + var listenerMap = {}; + this.listeners.forEach(function (listener) { + listenerMap[listener] = { + handler: null, + components: [] + }; + }); + this.listeners = listenerMap; + } }, { - key: "setHeaderFilterPlaceholder", - value: function setHeaderFilterPlaceholder(placeholder) { - this.langList["default"].headerFilters["default"] = placeholder; - } //set header filter placeholder by column + key: "bindSubscriptionWatchers", + value: function bindSubscriptionWatchers() { + var listeners = Object.keys(this.listeners), + components = Object.values(this.componentMap); - }, { - key: "setHeaderFilterColumnPlaceholder", - value: function setHeaderFilterColumnPlaceholder(column, placeholder) { - this.langList["default"].headerFilters.columns[column] = placeholder; + for (var _i = 0, _components = components; _i < _components.length; _i++) { + var comp = _components[_i]; - if (this.lang && !this.lang.headerFilters.columns[column]) { - this.lang.headerFilters.columns[column] = placeholder; - } - } //setup a lang description object + var _iterator = _createForOfIteratorHelper(listeners), + _step; + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var listener = _step.value; + var key = comp + "-" + listener; + this.subscriptionChange(key, this.subscriptionChanged.bind(this, comp, listener)); + } + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + } }, { - key: "installLang", - value: function installLang(locale, lang) { - if (this.langList[locale]) { - this._setLangProp(this.langList[locale], lang); + key: "subscriptionChanged", + value: function subscriptionChanged(component, key, added) { + var listener = this.listeners[key].components, + index = listener.indexOf(component), + changed = false; + + if (added) { + if (index === -1) { + listener.push(component); + changed = true; + } } else { - this.langList[locale] = lang; + if (!this.subscribed(component + "-" + key)) { + if (index > -1) { + listener.splice(index, 1); + changed = true; + } + } + } + + if (changed) { + this.updateEventListeners(); } } }, { - key: "_setLangProp", - value: function _setLangProp(lang, values) { - for (var key in values) { - if (lang[key] && _typeof(lang[key]) == "object") { - this._setLangProp(lang[key], values[key]); + key: "updateEventListeners", + value: function updateEventListeners() { + for (var key in this.listeners) { + var listener = this.listeners[key]; + + if (listener.components.length) { + if (!listener.handler) { + listener.handler = this.track.bind(this, key); + this.el.addEventListener(key, listener.handler); // this.el.addEventListener(key, listener.handler, {passive: true}) + } } else { - lang[key] = values[key]; + if (listener.handler) { + this.el.removeEventListener(key, listener.handler); + listener.handler = null; + } } } - } //set current locale - + } }, { - key: "setLocale", - value: function setLocale(desiredLocale) { - desiredLocale = desiredLocale || "default"; //fill in any matching languge values + key: "track", + value: function track(type, e) { + var targets = this.findTargets(e.path); + targets = this.bindComponents(type, targets); + this.triggerEvents(type, e, targets); + } + }, { + key: "findTargets", + value: function findTargets(path) { + var _this2 = this; - function traverseLang(trans, path) { - for (var prop in trans) { - if (_typeof(trans[prop]) == "object") { - if (!path[prop]) { - path[prop] = {}; - } + var targets = {}; + var componentMap = Object.keys(this.componentMap); - traverseLang(trans[prop], path[prop]); - } else { - path[prop] = trans[prop]; - } - } - } //determing correct locale to load + var _iterator2 = _createForOfIteratorHelper(path), + _step2; + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var el = _step2.value; + var classList = el.classList ? _toConsumableArray(el.classList) : []; + var abort = classList.filter(function (item) { + return _this2.abortClasses.includes(item); + }); - if (desiredLocale === true && navigator.language) { - //get local from system - desiredLocale = navigator.language.toLowerCase(); - } + if (abort.length) { + break; + } - if (desiredLocale) { - //if locale is not set, check for matching top level locale else use default - if (!this.langList[desiredLocale]) { - var prefix = desiredLocale.split("-")[0]; + var elTargets = classList.filter(function (item) { + return componentMap.includes(item); + }); - if (this.langList[prefix]) { - console.warn("Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix); - desiredLocale = prefix; - } else { - console.warn("Localization Error - Matching locale not found, using default: ", desiredLocale); - desiredLocale = "default"; + var _iterator3 = _createForOfIteratorHelper(elTargets), + _step3; + + try { + for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { + var target = _step3.value; + targets[this.componentMap[target]] = el; + } + } catch (err) { + _iterator3.e(err); + } finally { + _iterator3.f(); } } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); } - this.locale = desiredLocale; //load default lang template - - this.lang = Helpers.deepClone(this.langList["default"] || {}); - - if (desiredLocale != "default") { - traverseLang(this.langList[desiredLocale], this.lang); + if (targets.group && targets.group === targets.row) { + delete targets.row; } - this.table.options.localized.call(this.table, this.locale, this.lang); + return targets; + } + }, { + key: "bindComponents", + value: function bindComponents(type, targets) { + var _this3 = this; + + //ensure row component is looked up before cell + var keys = Object.keys(targets).reverse(), + listener = this.listeners[type], + targetMatches = {}; - this._executeBindings(); - } //get current locale + var _iterator4 = _createForOfIteratorHelper(keys), + _step4; - }, { - key: "getLocale", - value: function getLocale(locale) { - return this.locale; - } //get lang object for given local or current if none provided + try { + var _loop = function _loop() { + var key = _step4.value; + var component = void 0; + var target = targets[key]; + var previousTarget = _this3.previousTargets[key]; + + if (previousTarget && previousTarget.target === target) { + component = previousTarget.component; + } else { + switch (key) { + case "row": + case "group": + if (listener.components.includes("row") || listener.components.includes("cell")) { + var rows = _this3.table.rowManager.getVisibleRows(); - }, { - key: "getLang", - value: function getLang(locale) { - return locale ? this.langList[locale] : this.lang; - } //get text for current locale + component = rows.find(function (row) { + return row.getElement() === target; + }); + } - }, { - key: "getText", - value: function getText(path, value) { - var path = value ? path + "|" + value : path, - pathArray = path.split("|"), - text = this._getLangElement(pathArray, this.locale); // if(text === false){ - // console.warn("Localization Error - Matching localized text not found for given path: ", path); - // } + break; + case "column": + if (listener.components.includes("column")) { + component = _this3.table.columnManager.findColumn(target); + } - return text || ""; - } //traverse langs object and find localized copy + break; - }, { - key: "_getLangElement", - value: function _getLangElement(path, locale) { - var root = this.lang; - path.forEach(function (level) { - var rootPath; + case "cell": + if (listener.components.includes("cell")) { + component = targets["row"].findCell(target); + } - if (root) { - rootPath = root[level]; + break; + } + } - if (typeof rootPath != "undefined") { - root = rootPath; - } else { - root = false; + if (component) { + targets[key] = component; + targetMatches[key] = { + target: target, + component: component + }; } - } - }); - return root; - } //set update binding + }; - }, { - key: "bind", - value: function bind(path, callback) { - if (!this.bindings[path]) { - this.bindings[path] = []; + for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) { + _loop(); + } + } catch (err) { + _iterator4.e(err); + } finally { + _iterator4.f(); } - this.bindings[path].push(callback); - callback(this.getText(path), this.lang); - } //itterate through bindings and trigger updates - + this.previousTargets = targetMatches; + return targets; + } }, { - key: "_executeBindings", - value: function _executeBindings() { - var _this2 = this; - - var _loop = function _loop(path) { - _this2.bindings[path].forEach(function (binding) { - binding(_this2.getText(path), _this2.lang); - }); - }; + key: "triggerEvents", + value: function triggerEvents(type, e, targets) { + var listener = this.listeners[type]; - for (var path in this.bindings) { - _loop(path); + for (var key in targets) { + if (targets[key] && listener.components.includes(key)) { + this.dispatch(key + "-" + type, e, targets[key]); + } } } }]); - return Localize; - }(Module); - - Localize.moduleName = "localize"; //load defaults - - Localize.langs = defaultLangs; - - var Comms = /*#__PURE__*/function (_Module) { - _inherits(Comms, _Module); - - var _super = _createSuper(Comms); + return InteractionManager; + }(CoreFeature); - function Comms() { - _classCallCheck(this, Comms); + var ComponentFuctionBinder = /*#__PURE__*/function () { + function ComponentFuctionBinder(table) { + _classCallCheck(this, ComponentFuctionBinder); - return _super.apply(this, arguments); + this.table = table; + this.bindings = {}; } - _createClass(Comms, [{ - key: "getConnections", - value: function getConnections(selectors) { - var _this = this; - - var connections = [], - connection; - connection = Tabulator.comms.lookupTable(selectors); - connection.forEach(function (con) { - if (_this.table !== con) { - connections.push(con); - } - }); - return connections; - } - }, { - key: "send", - value: function send(selectors, module, action, data) { - var _this2 = this; - - var connections = this.getConnections(selectors); - connections.forEach(function (connection) { - connection.tableComms(_this2.table.element, module, action, data); - }); + _createClass(ComponentFuctionBinder, [{ + key: "bind", + value: function bind(type, funcName, handler) { + if (!this.bindings[type]) { + this.bindings[type] = {}; + } - if (!connections.length && selectors) { - console.warn("Table Connection Error - No tables matching selector found", selectors); + if (this.bindings[type][funcName]) { + console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, hanlder); + } else { + this.bindings[type][funcName] = handler; } - } - }, { - key: "receive", - value: function receive(table, module, action, data) { - if (this.table.modExists(module)) { - return this.table.modules[module].commsReceived(table, action, data); + } + }, { + key: "handle", + value: function handle(type, component, name) { + if (this.bindings[type] && this.bindings[type][name]) { + return this.bindings[type][name].bind(null, component); } else { - console.warn("Inter-table Comms Error - no such module:", module); + console.error("The " + type + " component does not have a " + name + " function, have you checked that you have the correct Tabulator module installed?"); } } }]); - return Comms; - }(Module); + return ComponentFuctionBinder; + }(); - Comms.moduleName = "comms"; + var DataLoader = /*#__PURE__*/function (_CoreFeature) { + _inherits(DataLoader, _CoreFeature); - var coreModules = /*#__PURE__*/Object.freeze({ - __proto__: null, - LayoutModule: Layout, - LocalizeModule: Localize, - CommsModule: Comms - }); + var _super = _createSuper(DataLoader); - var ModuleBinder = /*#__PURE__*/function () { - function ModuleBinder(tabulator, modules) { - _classCallCheck(this, ModuleBinder); + function DataLoader(table) { + var _this; - this.bindStaticFuctionality(tabulator); - this.bindModules(tabulator, coreModules); + _classCallCheck(this, DataLoader); - if (modules) { - this.bindModules(tabulator, modules); - } - } + _this = _super.call(this, table); + _this.loaderElement = _this.createLoaderElement(); //loader message div - _createClass(ModuleBinder, [{ - key: "bindStaticFuctionality", - value: function bindStaticFuctionality(tabulator) { - tabulator.moduleBindings = {}; + _this.msgElement = _this.createMsgElement(); //message element - tabulator.extendModule = function (name, property, values) { - if (tabulator.moduleBindings[name]) { - var source = tabulator.moduleBindings[name].prototype[property]; + _this.loadingElement = null; + _this.errorElement = null; + _this.requestOrder = 0; //prevent requests comming out of sequence if overridden by another load request - if (source) { - if (_typeof(values) == "object") { - for (var key in values) { - source[key] = values[key]; - } - } else { - console.warn("Module Error - Invalid value type, it must be an object"); - } - } else { - console.warn("Module Error - property does not exist:", property); - } + _this.loading = false; + return _this; + } + + _createClass(DataLoader, [{ + key: "initialize", + value: function initialize() { + var template; + this.loaderElement.appendChild(this.msgElement); + + if (this.table.options.dataLoaderLoading) { + if (typeof this.table.options.dataLoaderLoading == "string") { + template = document.createElement('template'); + template.innerHTML = this.table.options.dataLoaderLoading.trim(); + this.loadingElement = template.content.firstChild; } else { - console.warn("Module Error - module does not exist:", name); + this.loadingElement = this.table.options.dataLoaderLoading; } - }; + } - tabulator.registerModule = function (modules) { - if (!Array.isArray(modules)) { - modules = [modules]; + if (this.table.options.dataLoaderError) { + if (typeof this.table.options.dataLoaderError == "string") { + template = document.createElement('template'); + template.innerHTML = this.table.options.dataLoaderError.trim(); + this.errorElement = template.content.firstChild; + } else { + this.errorElement = this.table.options.dataLoaderError; } + } + } + }, { + key: "createLoaderElement", + value: function createLoaderElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-loader"); + return el; + } + }, { + key: "createMsgElement", + value: function createMsgElement() { + var el = document.createElement("div"); + el.classList.add("tabulator-loader-msg"); + el.setAttribute("role", "alert"); + return el; + } + }, { + key: "load", + value: function load(data, params, config, replace, silent) { + var _this2 = this; - modules.forEach(function (mod) { - tabulator.registerModuleBinding(mod); - }); - }; - - tabulator.registerModuleBinding = function (mod) { - tabulator.moduleBindings[mod.moduleName] = mod; - }; + var requestNo = ++this.requestOrder; + this.dispatchExternal("dataLoading", data); //parse json data to array - tabulator.findTable = function (query) { - var results = TableRegistry.lookupTable(query, true); - return Array.isArray(results) && !results.length ? false : results; - }; //ensure that module are bound to instantiated function + if (data && (data.indexOf("{") == 0 || data.indexOf("[") == 0)) { + data = JSON.parse(data); + } + if (this.confirm("data-loading", data, params, config, silent)) { + this.loading = true; - tabulator.prototype.bindModules = function () { - this.modules = {}; + if (!silent) { + this.showLoader(); + } //get params for request - for (var name in tabulator.moduleBindings) { - this.modules[name] = new tabulator.moduleBindings[name](this); - } - }; - } - }, { - key: "bindModules", - value: function bindModules(tabulator, modules) { - var mods = Object.values(modules); - tabulator.registerModule(mods); - } - }]); - return ModuleBinder; - }(); + var params = this.chain("data-params", [data, config, silent], params || {}, {}); + params = this.mapParams(params, this.table.options.dataSendParams); + var result = this.chain("data-load", [data, params, config, silent], Promise.resolve([])); + return result.then(function (response) { + if (!Array.isArray(response) && _typeof(response) == "object") { + response = _this2.mapParams(response, _this2.objectInvert(_this2.table.options.dataReceiveParams)); + } - var VirtualDomHorizontal = /*#__PURE__*/function () { - function VirtualDomHorizontal(table) { - _classCallCheck(this, VirtualDomHorizontal); + var rowData = _this2.chain("data-loaded", response, null, response); - this.table = table; - 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; //pixel margin to make column visible before it is shown on screen + if (requestNo == _this2.requestOrder) { + _this2.hideLoader(); - this.initialized = false; - this.columns = []; + if (rowData !== false) { + _this2.dispatchExternal("dataLoaded", data); - if (this.compatabilityCheck()) { - this.initialize(); - } - } + _this2.table.rowManager.setData(rowData, replace, !replace); + } + } else { + console.warn("Data Load Response Blocked - An active data load request was blocked by an attempt to change table data while the request was being made"); + } + })["catch"](function (error) { + console.error("Data Load Error: ", error); - _createClass(VirtualDomHorizontal, [{ - key: "compatabilityCheck", - value: function compatabilityCheck() { - var options = this.table.options, - frozen = false, - ok = true; + _this2.dispatchExternal("dataLoadError", error); - if (options.layout == "fitDataTable") { - console.warn("Horizontal Vitrual DOM is not compatible with fitDataTable layout mode"); - ok = false; - } + if (!silent) { + _this2.showError(); + } - if (options.responsiveLayout) { - console.warn("Horizontal Vitrual DOM is not compatible with responsive columns"); - ok = false; + setTimeout(function () { + _this2.hideLoader(); + }, 3000); + })["finally"](function () { + _this2.loading = false; + }); + } else { + this.dispatchExternal("dataLoaded", data); + this.table.rowManager.setData(data, replace, !replace); + return Promise.resolve(); } + } + }, { + key: "mapParams", + value: function mapParams(params, map) { + var output = {}; - if (this.table.rtl) { - console.warn("Horizontal Vitrual DOM is not currently compatible with RTL text direction"); - ok = false; + for (var key in params) { + output[map.hasOwnProperty(key) ? map[key] : key] = params[key]; } - if (options.columns) { - frozen = options.columns.find(function (col) { - return col.frozen; - }); - - if (frozen) { - console.warn("Horizontal Vitrual DOM is not compatible with frozen columns"); - ok = false; - } - } + return output; + } + }, { + key: "objectInvert", + value: function objectInvert(obj) { + var output = {}; - if (!ok) { - options.virtualDomHoz = false; + for (var key in obj) { + output[obj[key]] = key; } - return ok; + return output; } }, { - key: "initialize", - value: function initialize() { - var _this = this; + key: "blockActiveLoad", + value: function blockActiveLoad() { + this.requestOrder++; + } + }, { + key: "showLoader", + value: function showLoader() { + var shouldLoad = typeof this.table.options.dataLoader === "function" ? this.table.options.dataLoader() : this.table.options.dataLoader; + + if (shouldLoad) { + this.hideLoader(); - this.holderEl.addEventListener("scroll", function () { - var left = _this.holderEl.scrollLeft; + while (this.msgElement.firstChild) { + this.msgElement.removeChild(this.msgElement.firstChild); + } - if (_this.scrollLeft != left) { - _this.scrollLeft = left; + this.msgElement.classList.remove("tabulator-error"); + this.msgElement.classList.add("tabulator-loading"); - _this.scroll(left - (_this.vDomScrollPosLeft + _this.window)); + if (this.loadingElement) { + this.msgElement.appendChild(this.loadingElement); + } else { + this.msgElement.innerHTML = this.langText("data|loading"); } - }); + + this.table.element.appendChild(this.loaderElement); + } } }, { - key: "deinitialize", - value: function deinitialize() { - this.initialized = false; + key: "showError", + value: function showError() { + this.hideLoader(); + + while (this.msgElement.firstChild) { + this.msgElement.removeChild(this.msgElement.firstChild); + } + + this.msgElement.classList.remove("tabulator-loading"); + this.msgElement.classList.add("tabulator-error"); + + if (this.errorElement) { + this.msgElement.appendChild(this.errorElement); + } else { + this.msgElement.innerHTML = this.langText("data|error"); + } + + this.table.element.appendChild(this.loaderElement); } }, { - key: "clear", - value: function clear() { - this.columns = []; - this.leftCol = -1; - this.rightCol = 0; - this.vDomScrollPosLeft = 0; - this.vDomScrollPosRight = 0; - this.vDomPadLeft = 0; - this.vDomPadRight = 0; + key: "hideLoader", + value: function hideLoader() { + if (this.loaderElement.parentNode) { + this.loaderElement.parentNode.removeChild(this.loaderElement); + } } - }, { - key: "dataChange", - value: function dataChange() { - var change = false, - collsWidth = 0, - colEnd = 0, - group, - row, - rowEl; + }]); - if (this.table.options.layout === "fitData") { - this.table.columnManager.columnsByIndex.forEach(function (column) { - if (!column.definition.width && column.visible) { - change = true; - } - }); + return DataLoader; + }(CoreFeature); - if (change) { - if (change && this.table.rowManager.getDisplayRows().length) { - this.vDomScrollPosRight = this.scrollLeft + this.holderEl.clientWidth + this.window; + var ExternalEventBus = /*#__PURE__*/function () { + function ExternalEventBus(optionsList, debug) { + _classCallCheck(this, ExternalEventBus); - if (this.table.options.groupBy) { - group = this.table.modules.groupRows.getGroups(false)[0]; - row = group.getRows(false)[0]; - } else { - row = this.table.rowManager.getDisplayRows()[0]; - } + this.events = {}; + this.optionsList = optionsList || {}; + this.subscriptionNotifiers = {}; + this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this); + this.debug = debug; + } - if (row) { - rowEl = row.getElement(); - row.generateCells(); - this.element.appendChild(rowEl); + _createClass(ExternalEventBus, [{ + key: "subscriptionChange", + value: function subscriptionChange(key, callback) { + if (!this.subscriptionNotifiers[key]) { + this.subscriptionNotifiers[key] = []; + } - for (var colEnd = 0; colEnd < row.cells.length; colEnd++) { - var cell = row.cells[colEnd]; - rowEl.appendChild(cell.getElement()); - cell.column.reinitializeWidth(); - collsWidth += cell.column.getWidth(); + this.subscriptionNotifiers[key].push(callback); - if (collsWidth > this.vDomScrollPosRight) { - break; - } - } + if (this.subscribed(key)) { + this._notifiySubscriptionChange(key, true); + } + } + }, { + key: "subscribe", + value: function subscribe(key, callback) { + if (!this.events[key]) { + this.events[key] = []; + } - rowEl.parentNode.removeChild(rowEl); - this.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1)); + this.events[key].push(callback); + + this._notifiySubscriptionChange(key, true); + } + }, { + key: "unsubscribe", + value: function unsubscribe(key, callback) { + var index; - for (colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++) { - this.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg); - } + if (this.events[key]) { + if (callback) { + index = this.events[key].findIndex(function (item) { + return item === callback; + }); - this.reinitialize(false, true); - } + if (index > -1) { + this.events[key].splice(index, 1); + } else { + console.warn("Cannot remove event, no matching event found:", key, callback); + return; } + } else { + delete this.events[key]; } } else { - if (this.table.options.layout === "fitColumns") { - this.table.modules.layout.layout(); - this.table.vdomHoz.reinitialize(false, true); - } + console.warn("Cannot remove event, no events set on:", key); + return; } + + this._notifiySubscriptionChange(key, false); } }, { - key: "fitDataLayoutOverride", - value: function fitDataLayoutOverride() { - for (var i = this.leftCol; i <= this.rightCol; i++) { - this.columns[i].reinitializeWidth(); + key: "subscribed", + value: function subscribed(key) { + return this.events[key] && this.events[key].length; + } + }, { + key: "_notifiySubscriptionChange", + value: function _notifiySubscriptionChange(key, subscribed) { + var notifiers = this.subscriptionNotifiers[key]; + + if (notifiers) { + notifiers.forEach(function (callback) { + callback(subscribed); + }); } } }, { - key: "reinitialize", - value: function reinitialize(update, blockRedraw) { - var _this2 = this; + key: "_dispatch", + value: function _dispatch() { + var _this = this; - var old = { - cols: this.columns, - leftCol: this.leftCol, - rightCol: this.rightCol - }; + var args = Array.from(arguments), + key = args.shift(), + result; - if (update && !this.initialized) { - return; + if (this.events[key]) { + this.events[key].forEach(function (callback, i) { + var callResult = callback.apply(_this, args); + + if (!i) { + result = callResult; + } + }); } - this.clear(); - this.scrollLeft = this.holderEl.scrollLeft; - this.vDomScrollPosLeft = this.scrollLeft - this.window; - this.vDomScrollPosRight = this.scrollLeft + this.holderEl.clientWidth + this.window; - var colPos = 0; - this.table.columnManager.columnsByIndex.forEach(function (column) { - var config = {}; + return result; + } + }, { + key: "_debugDispatch", + value: function _debugDispatch() { + var args = Array.from(arguments), + key = args[0]; + args[0] = "ExternalEvent:" + args[0]; - if (column.visible) { - var width = column.getWidth(); - config.leftPos = colPos; - config.rightPos = colPos + width; - config.width = width; + if (this.debug === true || this.debug.includes(key)) { + var _console; - if (_this18.table.options.layout === "fitData") { - config.fitDataCheck = true; - } + (_console = console).log.apply(_console, _toConsumableArray(args)); + } - if (colPos + width > _this2.vDomScrollPosLeft && colPos < _this2.vDomScrollPosRight) { - //column is visible - if (_this2.leftCol == -1) { - _this2.leftCol = _this2.columns.length; - _this2.vDomPadLeft = colPos; - } + return this._dispatch.apply(this, arguments); + } + }]); - _this2.rightCol = _this2.columns.length; - } else { - // column is hidden - if (_this2.leftCol !== -1) { - _this2.vDomPadRight += width; - } - } + return ExternalEventBus; + }(); - _this2.columns.push(column); + var InternalEventBus = /*#__PURE__*/function () { + function InternalEventBus(debug) { + _classCallCheck(this, InternalEventBus); - column.modules.vdomHoz = config; - colPos += width; - } - }); - this.element.style.paddingLeft = this.vDomPadLeft + "px"; - this.element.style.paddingRight = this.vDomPadRight + "px"; - this.initialized = true; + this.events = {}; + this.subscriptionNotifiers = {}; + this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this); + this.chain = debug ? this._debugChain.bind(this) : this._chain.bind(this); + this.confirm = debug ? this._debugConfirm.bind(this) : this._confirm.bind(this); + this.debug = debug; + } - if (!blockRedraw) { - if (!update || this.reinitChanged(old)) { - this.renitializeRows(); - } + _createClass(InternalEventBus, [{ + key: "subscriptionChange", + value: function subscriptionChange(key, callback) { + if (!this.subscriptionNotifiers[key]) { + this.subscriptionNotifiers[key] = []; } - this.holderEl.scrollLeft = this.scrollLeft; + this.subscriptionNotifiers[key].push(callback); + + if (this.subscribed(key)) { + this._notifiySubscriptionChange(key, true); + } } }, { - key: "reinitChanged", - value: function reinitChanged(old) { - var _this3 = this; - - var match = true; + key: "subscribe", + value: function subscribe(key, callback) { + var priority = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 10000; - if (old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol) { - return true; + if (!this.events[key]) { + this.events[key] = []; } - old.cols.forEach(function (col, i) { - if (col !== _this3.columns[i]) { - match = false; - } + this.events[key].push({ + callback: callback, + priority: priority }); - return !match; - } - }, { - key: "renitializeRows", - value: function renitializeRows() { - var _this4 = this; - - var rows = this.table.rowManager.getVisibleRows(); - rows.forEach(function (row) { - _this4.reinitializeRow(row, true); + this.events[key].sort(function (a, b) { + return a.priority - b.priority; }); + + this._notifiySubscriptionChange(key, true); } }, { - key: "scroll", - value: function scroll(diff) { - this.vDomScrollPosLeft += diff; - this.vDomScrollPosRight += diff; + key: "unsubscribe", + value: function unsubscribe(key, callback) { + var index; - if (diff > this.holderEl.clientWidth * .8) { - this.reinitialize(); - } else { - if (diff > 0) { - //scroll right - this.addColRight(); - this.removeColLeft(); - } else { - //scroll left - this.addColLeft(); - this.removeColRight(); + if (this.events[key]) { + if (callback) { + index = this.events[key].findIndex(function (item) { + return item.callback === callback; + }); + + if (index > -1) { + this.events[key].splice(index, 1); + } else { + console.warn("Cannot remove event, no matching event found:", key, callback); + return; + } } + } else { + console.warn("Cannot remove event, no events set on:", key); + return; } + + this._notifiySubscriptionChange(key, false); } }, { - key: "colPositionAdjust", - value: function colPositionAdjust(start, end, diff) { - for (var i = start; i < end; i++) { - var column = this.columns[i]; - column.modules.vdomHoz.leftPos += diff; - column.modules.vdomHoz.rightPos += diff; + key: "subscribed", + value: function subscribed(key) { + return this.events[key] && this.events[key].length; + } + }, { + key: "_chain", + value: function _chain(key, args, initialValue, fallback) { + var _this = this; + + var value = initialValue; + + if (!Array.isArray(args)) { + args = [args]; + } + + if (this.subscribed(key)) { + this.events[key].forEach(function (subscriber, i) { + value = subscriber.callback.apply(_this, args.concat([value])); + }); + return value; + } else { + return typeof fallback === "function" ? fallback() : fallback; } } }, { - key: "addColRight", - value: function addColRight() { - var column = this.columns[this.rightCol + 1], - rows; + key: "_confirm", + value: function _confirm(key, args) { + var _this2 = this; - if (column && column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight) { - rows = this.table.rowManager.getVisibleRows(); - rows.forEach(function (row) { - if (row.type !== "group") { - var cell = row.getCell(column); - row.getElement().appendChild(cell.getElement()); - cell.cellRendered(); + var confirmed = false; + + if (!Array.isArray(args)) { + args = [args]; + } + + if (this.subscribed(key)) { + this.events[key].forEach(function (subscriber, i) { + if (subscriber.callback.apply(_this2, args)) { + confirmed = true; } }); - this.fitDataColActualWidthCheck(column); - this.rightCol++; + } - if (this.rightCol >= this.columns.length - 1) { - this.vDomPadRight = 0; - } else { - this.vDomPadRight -= column.getWidth(); - } + return confirmed; + } + }, { + key: "_notifiySubscriptionChange", + value: function _notifiySubscriptionChange(key, subscribed) { + var notifiers = this.subscriptionNotifiers[key]; - this.element.style.paddingRight = this.vDomPadRight + "px"; - this.addColRight(); + if (notifiers) { + notifiers.forEach(function (callback) { + callback(subscribed); + }); } } }, { - key: "addColLeft", - value: function addColLeft() { - var column = this.columns[this.leftCol - 1], - rows; + key: "_dispatch", + value: function _dispatch() { + var _this3 = this; - if (column && column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft) { - var rows = this.table.rowManager.getVisibleRows(); - rows.forEach(function (row) { - if (row.type !== "group") { - var cell = row.getCell(column); - row.getElement().prepend(cell.getElement()); - cell.cellRendered(); - } + var args = Array.from(arguments), + key = args.shift(); + + if (this.events[key]) { + this.events[key].forEach(function (subscriber) { + var callResult = subscriber.callback.apply(_this3, args); }); - this.fitDataColActualWidthCheck(column); + } + } + }, { + key: "_debugDispatch", + value: function _debugDispatch() { + var args = Array.from(arguments), + key = args[0]; + args[0] = "InternalEvent:" + key; - if (!this.leftCol) { - this.vDomPadLeft = 0; - } else { - this.vDomPadLeft -= column.getWidth(); - } + if (this.debug === true || this.debug.includes(key)) { + var _console; - this.element.style.paddingLeft = this.vDomPadLeft + "px"; - this.leftCol--; - this.addColLeft(); + (_console = console).log.apply(_console, _toConsumableArray(args)); + } + + return this._dispatch.apply(this, arguments); + } + }, { + key: "_debugChain", + value: function _debugChain() { + var args = Array.from(arguments), + key = args[0]; + args[0] = "InternalEvent:" + key; + + if (this.debug === true || this.debug.includes(key)) { + var _console2; + + (_console2 = console).log.apply(_console2, _toConsumableArray(args)); } + + return this._chain.apply(this, arguments); } }, { - key: "removeColRight", - value: function removeColRight(column) { - var column = this.columns[this.rightCol], - rows; + key: "_debugConfirm", + value: function _debugConfirm() { + var args = Array.from(arguments), + key = args[0]; + args[0] = "InternalEvent:" + key; - if (column && column.modules.vdomHoz.leftPos > this.vDomScrollPosRight) { - rows = this.table.rowManager.getVisibleRows(); - column.modules.vdomHoz.visible = false; - rows.forEach(function (row) { - if (row.type !== "group") { - var cell = row.getCell(column); - row.getElement().removeChild(cell.getElement()); - } - }); - this.vDomPadRight += column.getWidth(); - this.element.style.paddingRight = this.vDomPadRight + "px"; - this.rightCol--; - this.removeColRight(); + if (this.debug === true || this.debug.includes(key)) { + var _console3; + + (_console3 = console).log.apply(_console3, _toConsumableArray(args)); + } + + return this._confirm.apply(this, arguments); + } + }]); + + return InternalEventBus; + }(); + + var TableRegistry = /*#__PURE__*/function () { + function TableRegistry() { + _classCallCheck(this, TableRegistry); + } + + _createClass(TableRegistry, null, [{ + key: "register", + value: function register(table) { + TableRegistry.tables.push(table); + } + }, { + key: "deregister", + value: function deregister(table) { + var index = TableRegistry.tables.indexOf(table); + + if (index > -1) { + TableRegistry.tables.splice(index, 1); } } }, { - key: "removeColLeft", - value: function removeColLeft() { - var column = this.columns[this.leftCol], - rows; + key: "lookupTable", + value: function lookupTable(query, silent) { + var results = [], + matches, + match; - if (column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft) { - rows = this.table.rowManager.getVisibleRows(); - rows.forEach(function (row) { - if (row.type !== "group") { - var cell = row.getCell(column); - row.getElement().removeChild(cell.getElement()); + if (typeof query === "string") { + matches = document.querySelectorAll(query); + + if (matches.length) { + for (var i = 0; i < matches.length; i++) { + match = TableRegistry.matchElement(matches[i]); + + if (match) { + results.push(match); + } } + } + } else if (typeof HTMLElement !== "undefined" && query instanceof HTMLElement || query instanceof Tabulator$1) { + match = TableRegistry.matchElement(query); + + if (match) { + results.push(match); + } + } else if (Array.isArray(query)) { + query.forEach(function (item) { + results = results.concat(TableRegistry.lookupTable(item)); }); - this.vDomPadLeft += column.getWidth(); - this.element.style.paddingLeft = this.vDomPadLeft + "px"; - this.leftCol++; - this.removeColLeft(); + } else { + if (!silent) { + console.warn("Table Connection Error - Invalid Selector", query); + } } + + return results; } }, { - key: "fitDataColActualWidthCheck", - value: function fitDataColActualWidthCheck(column) { - var newWidth, widthDiff; + key: "matchElement", + value: function matchElement(element) { + return TableRegistry.tables.find(function (table) { + return element instanceof Tabulator$1 ? table === element : table.element === element; + }); + } + }]); - if (column.modules.vdomHoz.fitDataCheck) { - column.reinitializeWidth(); - newWidth = column.getWidth(); - widthDiff = newWidth - column.modules.vdomHoz.width; + return TableRegistry; + }(); - if (widthDiff) { - column.modules.vdomHoz.rightPos += widthDiff; - column.modules.vdomHoz.width = newWidth; - this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff); - } + TableRegistry.tables = []; - column.modules.vdomHoz.fitDataCheck = false; - } + var Module = /*#__PURE__*/function (_CoreFeature) { + _inherits(Module, _CoreFeature); + + var _super = _createSuper(Module); + + function Module(table, name) { + var _this; + + _classCallCheck(this, Module); + + _this = _super.call(this, table); + _this._handler = null; + return _this; + } + + _createClass(Module, [{ + key: "initialize", + value: function initialize() {// setup module when table is initialized, to be overriden in module + } /////////////////////////////////// + ////// Options Registration /////// + /////////////////////////////////// + + }, { + key: "registerTableOption", + value: function registerTableOption(key, value) { + this.table.optionsList.register(key, value); } }, { - key: "initializeRow", - value: function initializeRow(row) { - if (row.type !== "group") { - row.modules.vdomHoz = { - leftCol: this.leftCol, - rightCol: this.rightCol - }; - - for (var i = this.leftCol; i <= this.rightCol; i++) { - var column = this.columns[i]; + key: "registerColumnOption", + value: function registerColumnOption(key, value) { + this.table.columnManager.optionsList.register(key, value); + } /////////////////////////////////// + /// Public Function Registation /// + /////////////////////////////////// - if (column && column.visible) { - var cell = row.getCell(column); - row.getElement().appendChild(cell.getElement()); - cell.cellRendered(); - } - } + }, { + key: "registerTableFunction", + value: function registerTableFunction(name, func) { + if (typeof this.table[name] === "undefined") { + this.table[name] = func; + } else { + console.warn("Unable to bind table function, name already in use", name); } } }, { - key: "reinitializeRow", - value: function reinitializeRow(row, force) { - if (row.type !== "group") { - if (force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol) { - var rowEl = row.getElement(); + key: "registerComponentFunction", + value: function registerComponentFunction(component, func, handler) { + return this.table.componentFunctionBinder.bind(component, func, handler); + } /////////////////////////////////// + ////////// Data Pipeline ////////// + /////////////////////////////////// - while (rowEl.firstChild) { - rowEl.removeChild(rowEl.firstChild); - } + }, { + key: "registerDataHandler", + value: function registerDataHandler(handler, priority) { + this.table.rowManager.registerDataPipelineHandler(handler, priority); + this._handler = handler; + } + }, { + key: "registerDisplayHandler", + value: function registerDisplayHandler(handler, priority) { + this.table.rowManager.registerDisplayPipelineHandler(handler, priority); + this._handler = handler; + } + }, { + key: "refreshData", + value: function refreshData(renderInPosition, handler) { + if (!handler) { + handler = this._handler; + } - this.initializeRow(row); - } + if (handler) { + this.table.rowManager.refreshActiveData(handler, false, renderInPosition); } } }]); - return VirtualDomHorizontal; - }(); - - var Tabulator$1 = /*#__PURE__*/function () { - function Tabulator(element, options) { - _classCallCheck(this, Tabulator); - - this.options = {}; - this.columnManager = null; // hold Column Manager + return Module; + }(CoreFeature); - this.rowManager = null; //hold Row Manager + //resize columns to fit data they contain + function fitData (columns) { + this.table.columnManager.renderer.reinitializeColumnWidths(columns); - this.footerManager = null; //holder Footer Manager + if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { + this.table.modules.responsiveLayout.update(); + } + } - this.vdomHoz = null; //holder horizontal virtual dom + //resize columns to fit data they contain and stretch row to fill table, also used for fitDataTable + function fitDataGeneral (columns) { + columns.forEach(function (column) { + column.reinitializeWidth(); + }); - this.browser = ""; //hold current browser type + if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { + this.table.modules.responsiveLayout.update(); + } + } - this.browserSlow = false; //handle reduced functionality for slower browsers + //resize columns to fit data the contain and stretch last column to fill table + function fitDataStretch (columns) { + var _this = this; - this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence + var colsWidth = 0, + tableWidth = this.table.rowManager.element.clientWidth, + gap = 0, + lastCol = false; + columns.forEach(function (column, i) { + if (!column.widthFixed) { + column.reinitializeWidth(); + } - this.rtl = false; //check if the table is in RTL mode + if (_this.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible) { + lastCol = column; + } - this.modules = {}; //hold all modules bound to this table + if (column.visible) { + colsWidth += column.getWidth(); + } + }); - if (this.initializeElement(element)) { - this.initializeOptions(options || {}); + if (lastCol) { + gap = tableWidth - colsWidth + lastCol.getWidth(); - this._create(); + if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { + lastCol.setWidth(0); + this.table.modules.responsiveLayout.update(); } - TableRegistry.register(this); //register table for inderdevice communication + if (gap > 0) { + lastCol.setWidth(gap); + } else { + lastCol.reinitializeWidth(); + } + } else { + if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { + this.table.modules.responsiveLayout.update(); + } } + } - _createClass(Tabulator, [{ - key: "initializeOptions", - value: function initializeOptions(options) { - var defaults = Tabulator.defaultOptions; //warn user if option is not available + //resize columns to fit + function fitColumns (columns) { + var totalWidth = this.table.element.clientWidth; //table element width - if (options.invalidOptionWarnings !== false) { - for (var key in options) { - if (typeof defaults[key] === "undefined") { - console.warn("Invalid table constructor option:", key); - } - } - } //assign options to table + var fixedWidth = 0; //total width of columns with a defined width + var flexWidth = 0; //total width available to flexible columns - for (var key in defaults) { - if (key in options) { - this.options[key] = options[key]; - } else { - if (Array.isArray(defaults[key])) { - this.options[key] = Object.assign([], defaults[key]); - } else if (_typeof(defaults[key]) === "object" && defaults[key] !== null) { - this.options[key] = Object.assign({}, defaults[key]); - } else { - this.options[key] = defaults[key]; - } - } - } - } - }, { - key: "initializeElement", - value: function initializeElement(element) { - if (typeof HTMLElement !== "undefined" && element instanceof HTMLElement) { - this.element = element; - return true; - } else if (typeof element === "string") { - this.element = document.querySelector(element); + var flexGrowUnits = 0; //total number of widthGrow blocks accross all columns - if (this.element) { - return true; - } else { - console.error("Tabulator Creation Error - no element found matching selector: ", element); - return false; - } + var flexColWidth = 0; //desired width of flexible columns + + var flexColumns = []; //array of flexible width columns + + var fixedShrinkColumns = []; //array of fixed width columns that can shrink + + var flexShrinkUnits = 0; //total number of widthShrink blocks accross all columns + + var overflowWidth = 0; //horizontal overflow width + + var gapFill = 0; //number of pixels to be added to final column to close and half pixel gaps + + function calcWidth(width) { + var colWidth; + + if (typeof width == "string") { + if (width.indexOf("%") > -1) { + colWidth = totalWidth / 100 * parseInt(width); } else { - console.error("Tabulator Creation Error - Invalid element provided:", element); - return false; + colWidth = parseInt(width); } + } else { + colWidth = width; } - }, { - key: "rtlCheck", - value: function rtlCheck() { - var style = window.getComputedStyle(this.element); - switch (this.options.textDirection) { - case "auto": - if (style.direction !== "rtl") { - break; - } + return colWidth; + } //ensure columns resize to take up the correct amount of space - case "rtl": - this.element.classList.add("tabulator-rtl"); - this.rtl = true; - break; - case "ltr": - this.element.classList.add("tabulator-ltr"); + function scaleColumns(columns, freeSpace, colWidth, shrinkCols) { + var oversizeCols = [], + oversizeSpace = 0, + remainingSpace = 0, + nextColWidth = 0, + remainingFlexGrowUnits = flexGrowUnits, + gap = 0, + changeUnits = 0, + undersizeCols = []; - default: - this.rtl = false; - } - } //convert depricated functionality to new functions + function calcGrow(col) { + return colWidth * (col.column.definition.widthGrow || 1); + } - }, { - key: "_mapDepricatedFunctionality", - value: function _mapDepricatedFunctionality() {//all previously deprecated functionality removed in the 5.0 release + function calcShrink(col) { + return calcWidth(col.width) - colWidth * (col.column.definition.widthShrink || 0); } - }, { - key: "_clearSelection", - value: function _clearSelection() { - this.element.classList.add("tabulator-block-select"); - if (window.getSelection) { - if (window.getSelection().empty) { - // Chrome - window.getSelection().empty(); - } else if (window.getSelection().removeAllRanges) { - // Firefox - window.getSelection().removeAllRanges(); + columns.forEach(function (col, i) { + var width = shrinkCols ? calcShrink(col) : calcGrow(col); + + if (col.column.minWidth >= width) { + oversizeCols.push(col); + } else { + if (col.column.maxWidth && col.column.maxWidth < width) { + col.width = col.column.maxWidth; + freeSpace -= col.column.maxWidth; + remainingFlexGrowUnits -= shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1; + + if (remainingFlexGrowUnits) { + colWidth = Math.floor(freeSpace / remainingFlexGrowUnits); + } + } else { + undersizeCols.push(col); + changeUnits += shrinkCols ? col.column.definition.widthShrink || 1 : col.column.definition.widthGrow || 1; } - } else if (document.selection) { - // IE? - document.selection.empty(); } + }); - this.element.classList.remove("tabulator-block-select"); - } //concreate table + if (oversizeCols.length) { + oversizeCols.forEach(function (col) { + oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth; + col.width = col.column.minWidth; + }); + remainingSpace = freeSpace - oversizeSpace; + nextColWidth = changeUnits ? Math.floor(remainingSpace / changeUnits) : remainingSpace; + gap = remainingSpace - nextColWidth * changeUnits; + gap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols); + } else { + gap = changeUnits ? freeSpace - Math.floor(freeSpace / changeUnits) * changeUnits : freeSpace; + undersizeCols.forEach(function (column) { + column.width = shrinkCols ? calcShrink(column) : calcGrow(column); + }); + } - }, { - key: "_create", - value: function _create() { - this._clearObjectPointers(); + return gap; + } - this._mapDepricatedFunctionality(); + if (this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)) { + this.table.modules.responsiveLayout.update(); + } //adjust for vertical scrollbar if present - this.bindModules(); - this.rtlCheck(); - if (this.element.tagName === "TABLE") { - if (this.modExists("htmlTableImport", true)) { - this.modules.htmlTableImport.parseTable(); - } - } + if (this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight) { + totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth; + } - this.columnManager = new ColumnManager(this); - this.rowManager = new RowManager(this); - this.footerManager = new FooterManager(this); - this.columnManager.setRowManager(this.rowManager); - this.rowManager.setColumnManager(this.columnManager); + columns.forEach(function (column) { + var width, minWidth, colWidth; - if (this.options.virtualDomHoz) { - this.vdomHoz = new VirtualDomHorizontal(this); - } + if (column.visible) { + width = column.definition.width; + minWidth = parseInt(column.minWidth); - this._buildElement(); + if (width) { + colWidth = calcWidth(width); + fixedWidth += colWidth > minWidth ? colWidth : minWidth; - this._loadInitialData(); - } //clear pointers to objects in default config object + if (column.definition.widthShrink) { + fixedShrinkColumns.push({ + column: column, + width: colWidth > minWidth ? colWidth : minWidth + }); + flexShrinkUnits += column.definition.widthShrink; + } + } else { + flexColumns.push({ + column: column, + width: 0 + }); + flexGrowUnits += column.definition.widthGrow || 1; + } + } + }); //calculate available space - }, { - key: "_clearObjectPointers", - value: function _clearObjectPointers() { - this.options.columns = this.options.columns.slice(0); + flexWidth = totalWidth - fixedWidth; //calculate correct column size - if (!this.options.reactiveData) { - this.options.data = this.options.data.slice(0); - } - } //build tabulator element + flexColWidth = Math.floor(flexWidth / flexGrowUnits); //generate column widths - }, { - key: "_buildElement", - value: function _buildElement() { - var _this = this; + var gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false); //increase width of last column to account for rounding errors - var element = this.element, - mod = this.modules, - options = this.options; - options.tableBuilding.call(this); - element.classList.add("tabulator"); - element.setAttribute("role", "grid"); //empty element + if (flexColumns.length && gapFill > 0) { + flexColumns[flexColumns.length - 1].width += +gapFill; + } //caculate space for columns to be shrunk into - while (element.firstChild) { - element.removeChild(element.firstChild); - } //set table height + flexColumns.forEach(function (col) { + flexWidth -= col.width; + }); + overflowWidth = Math.abs(gapFill) + flexWidth; //shrink oversize columns if there is no available space - if (options.height) { - options.height = isNaN(options.height) ? options.height : options.height + "px"; - element.style.height = options.height; - } //set table min height + if (overflowWidth > 0 && flexShrinkUnits) { + gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true); + } //decrease width of last column to account for rounding errors - if (options.minHeight !== false) { - options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px"; - element.style.minHeight = options.minHeight; - } //set table maxHeight + if (fixedShrinkColumns.length) { + fixedShrinkColumns[fixedShrinkColumns.length - 1].width -= gapFill; + } + flexColumns.forEach(function (col) { + col.column.setWidth(col.width); + }); + fixedShrinkColumns.forEach(function (col) { + col.column.setWidth(col.width); + }); + } - if (options.maxHeight !== false) { - options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px"; - element.style.maxHeight = options.maxHeight; - } + var defaultModes = { + fitData: fitData, + fitDataFill: fitDataGeneral, + fitDataTable: fitDataGeneral, + fitDataStretch: fitDataStretch, + fitColumns: fitColumns + }; - this.columnManager.initialize(); - this.rowManager.initialize(); + var Layout = /*#__PURE__*/function (_Module) { + _inherits(Layout, _Module); - this._detectBrowser(); + var _super = _createSuper(Layout); - if (this.modExists("layout", true)) { - mod.layout.initialize(options.layout); - } //set localization + function Layout(table) { + var _this; + _classCallCheck(this, Layout); - mod.localize.initialize(); + _this = _super.call(this, table, "layout"); + _this.mode = null; - if (options.headerFilterPlaceholder !== false) { - mod.localize.setHeaderFilterPlaceholder(options.headerFilterPlaceholder); - } + _this.registerTableOption("layout", "fitData"); //layout type - for (var locale in options.langs) { - mod.localize.installLang(locale, options.langs[locale]); - } - mod.localize.setLocale(options.locale); //configure placeholder element + _this.registerTableOption("layoutColumnsOnNewData", false); //update column widths on setData - if (typeof options.placeholder == "string") { - var el = document.createElement("div"); - el.classList.add("tabulator-placeholder"); - var span = document.createElement("span"); - span.innerHTML = options.placeholder; - el.appendChild(span); - options.placeholder = el; - } //build table elements + _this.registerColumnOption("widthGrow"); - element.appendChild(this.columnManager.getElement()); - element.appendChild(this.rowManager.getElement()); + _this.registerColumnOption("widthShrink"); - if (options.footerElement) { - this.footerManager.activate(); - } + return _this; + } //initialize layout system - if (options.persistence && this.modExists("persistence", true)) { - mod.persistence.initialize(); - } - if (options.movableRows && this.modExists("moveRow")) { - mod.moveRow.initialize(); - } + _createClass(Layout, [{ + key: "initialize", + value: function initialize() { + var layout = this.table.options.layout; - if (options.autoColumns && this.options.data) { - this.columnManager.generateColumnsFromRowData(this.options.data); + if (Layout.modes[layout]) { + this.mode = layout; + } else { + console.warn("Layout Error - invalid mode set, defaulting to 'fitData' : " + layout); + this.mode = 'fitData'; } - if (this.modExists("columnCalcs")) { - mod.columnCalcs.initialize(); - } + this.table.element.setAttribute("tabulator-layout", this.mode); + } + }, { + key: "getMode", + value: function getMode() { + return this.mode; + } //trigger table layout - this.columnManager.setColumns(options.columns); + }, { + key: "layout", + value: function layout() { + Layout.modes[this.mode].call(this, this.table.columnManager.columnsByIndex); + this.dispatch("layout-refreshed"); + } + }]); - if (options.dataTree && this.modExists("dataTree", true)) { - mod.dataTree.initialize(); - } + return Layout; + }(Module); - if (this.modExists("frozenRows")) { - this.modules.frozenRows.initialize(); - } + Layout.moduleName = "layout"; //load defaults - if ((options.persistence && this.modExists("persistence", true) && mod.persistence.config.sort || options.initialSort) && this.modExists("sort", true)) { - var sorters = []; + Layout.modes = defaultModes; - if (options.persistence && this.modExists("persistence", true) && mod.persistence.config.sort) { - sorters = mod.persistence.load("sort"); + var defaultLangs = { + "default": { + //hold default locale text + "groups": { + "item": "item", + "items": "items" + }, + "columns": {}, + "data": { + "loading": "Loading", + "error": "Error" + }, + "pagination": { + "page_size": "Page Size", + "page_title": "Show Page", + "first": "First", + "first_title": "First Page", + "last": "Last", + "last_title": "Last Page", + "prev": "Prev", + "prev_title": "Prev Page", + "next": "Next", + "next_title": "Next Page", + "all": "All" + }, + "headerFilters": { + "default": "filter column...", + "columns": {} + } + } + }; - if (sorters === false && options.initialSort) { - sorters = options.initialSort; - } - } else if (options.initialSort) { - sorters = options.initialSort; - } + var Localize = /*#__PURE__*/function (_Module) { + _inherits(Localize, _Module); - mod.sort.setSort(sorters); - } + var _super = _createSuper(Localize); - if ((options.persistence && this.modExists("persistence", true) && mod.persistence.config.filter || options.initialFilter) && this.modExists("filter", true)) { - var filters = []; + function Localize(table) { + var _this; - if (options.persistence && this.modExists("persistence", true) && mod.persistence.config.filter) { - filters = mod.persistence.load("filter"); + _classCallCheck(this, Localize); - if (filters === false && options.initialFilter) { - filters = options.initialFilter; - } - } else if (options.initialFilter) { - filters = options.initialFilter; - } + _this = _super.call(this, table); + _this.locale = "default"; //current locale - mod.filter.setFilter(filters); - } + _this.lang = false; //current language - if (options.initialHeaderFilter && this.modExists("filter", true)) { - options.initialHeaderFilter.forEach(function (item) { - var column = _this.columnManager.findColumn(item.field); + _this.bindings = {}; //update events to call when locale is changed - if (column) { - mod.filter.setHeaderFilterValue(column, item.value); - } else { - console.warn("Column Filter Error - No matching column found:", item.field); - return false; - } - }); - } + _this.langList = {}; - if (this.modExists("ajax")) { - mod.ajax.initialize(); - } + _this.registerTableOption("locale", false); //current system language - if (options.pagination && this.modExists("page", true)) { - mod.page.initialize(); - } - if (options.groupBy && this.modExists("groupRows", true)) { - mod.groupRows.initialize(); - } + _this.registerTableOption("langs", {}); - if (this.modExists("keybindings")) { - mod.keybindings.initialize(); - } + return _this; + } - if (this.modExists("selectRow")) { - mod.selectRow.clearSelectionData(true); - } + _createClass(Localize, [{ + key: "initialize", + value: function initialize() { + this.langList = Helpers$1.deepClone(Localize.langs); - if (options.autoResize && this.modExists("resizeTable")) { - mod.resizeTable.initialize(); + if (this.table.options.columnDefaults.headerFilterPlaceholder !== false) { + this.setHeaderFilterPlaceholder(this.table.options.columnDefaults.headerFilterPlaceholder); } - if (this.modExists("clipboard")) { - mod.clipboard.initialize(); + for (var locale in this.table.options.langs) { + this.installLang(locale, this.table.options.langs[locale]); } - if (options.printAsHtml && this.modExists("print")) { - mod.print.initialize(); - } + this.setLocale(this.table.options.locale); + this.registerTableFunction("setLocale", this.setLocale.bind(this)); + this.registerTableFunction("getLocale", this.getLocale.bind(this)); + this.registerTableFunction("getLang", this.getLang.bind(this)); + } //set header placehoder - options.tableBuilt.call(this); - } }, { - key: "_loadInitialData", - value: function _loadInitialData() { - var _this2 = this; + key: "setHeaderFilterPlaceholder", + value: function setHeaderFilterPlaceholder(placeholder) { + this.langList["default"].headerFilters["default"] = placeholder; + } //set header filter placeholder by column - if (this.options.pagination && this.modExists("page")) { - this.modules.page.reset(true, true); + }, { + key: "setHeaderFilterColumnPlaceholder", + value: function setHeaderFilterColumnPlaceholder(column, placeholder) { + this.langList["default"].headerFilters.columns[column] = placeholder; - if (this.options.pagination == "local") { - if (this.options.data.length) { - this.rowManager.setData(this.options.data, false, true); - } else { - if ((this.options.ajaxURL || this.options.ajaxURLGenerator) && this.modExists("ajax")) { - this.modules.ajax.loadData(false, true).then(function () {})["catch"](function () { - if (_this2.options.paginationInitialPage) { - _this2.modules.page.setPage(_this2.options.paginationInitialPage); - } - }); - return; - } else { - this.rowManager.setData(this.options.data, false, true); - } - } + if (this.lang && !this.lang.headerFilters.columns[column]) { + this.lang.headerFilters.columns[column] = placeholder; + } + } //setup a lang description object - if (this.options.paginationInitialPage) { - this.modules.page.setPage(this.options.paginationInitialPage); - } - } else { - if (this.options.ajaxURL) { - this.modules.page.setPage(this.options.paginationInitialPage).then(function () {})["catch"](function () {}); - } else { - this.rowManager.setData([], false, true); - } - } + }, { + key: "installLang", + value: function installLang(locale, lang) { + if (this.langList[locale]) { + this._setLangProp(this.langList[locale], lang); } else { - if (this.options.data.length) { - this.rowManager.setData(this.options.data); + this.langList[locale] = lang; + } + } + }, { + key: "_setLangProp", + value: function _setLangProp(lang, values) { + for (var key in values) { + if (lang[key] && _typeof(lang[key]) == "object") { + this._setLangProp(lang[key], values[key]); } else { - if ((this.options.ajaxURL || this.options.ajaxURLGenerator) && this.modExists("ajax")) { - this.modules.ajax.loadData(false, true).then(function () {})["catch"](function () {}); - } else { - this.rowManager.setData(this.options.data, false, true); - } + lang[key] = values[key]; } } - } //deconstructor + } //set current locale }, { - key: "destroy", - value: function destroy() { - var element = this.element; - comms(this); //deregister table from inderdevice communication + key: "setLocale", + value: function setLocale(desiredLocale) { + desiredLocale = desiredLocale || "default"; //fill in any matching languge values - if (this.options.reactiveData && this.modExists("reactiveData", true)) { - this.modules.reactiveData.unwatchData(); - } //clear row data + function traverseLang(trans, path) { + for (var prop in trans) { + if (_typeof(trans[prop]) == "object") { + if (!path[prop]) { + path[prop] = {}; + } + traverseLang(trans[prop], path[prop]); + } else { + path[prop] = trans[prop]; + } + } + } //determing correct locale to load - this.rowManager.rows.forEach(function (row) { - row.wipe(); - }); - this.rowManager.rows = []; - this.rowManager.activeRows = []; - this.rowManager.displayRows = []; //clear event bindings - if (this.options.autoResize && this.modExists("resizeTable")) { - this.modules.resizeTable.clearBindings(); + if (desiredLocale === true && navigator.language) { + //get local from system + desiredLocale = navigator.language.toLowerCase(); } - if (this.modExists("keybindings")) { - this.modules.keybindings.clearBindings(); - } //clear DOM - + if (desiredLocale) { + //if locale is not set, check for matching top level locale else use default + if (!this.langList[desiredLocale]) { + var prefix = desiredLocale.split("-")[0]; - while (element.firstChild) { - element.removeChild(element.firstChild); + if (this.langList[prefix]) { + console.warn("Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix); + desiredLocale = prefix; + } else { + console.warn("Localization Error - Matching locale not found, using default: ", desiredLocale); + desiredLocale = "default"; + } + } } - element.classList.remove("tabulator"); - } - }, { - key: "_detectBrowser", - value: function _detectBrowser() { - var ua = navigator.userAgent || navigator.vendor || window.opera; + this.locale = desiredLocale; //load default lang template - if (ua.indexOf("Trident") > -1) { - this.browser = "ie"; - this.browserSlow = true; - } else if (ua.indexOf("Edge") > -1) { - this.browser = "edge"; - this.browserSlow = true; - } else if (ua.indexOf("Firefox") > -1) { - this.browser = "firefox"; - this.browserSlow = false; - } else { - this.browser = "other"; - this.browserSlow = false; - } + this.lang = Helpers$1.deepClone(this.langList["default"] || {}); - this.browserMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(ua) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(ua.substr(0, 4)); - } ////////////////// Data Handling ////////////////// - //block table redrawing + if (desiredLocale != "default") { + traverseLang(this.langList[desiredLocale], this.lang); + } - }, { - key: "blockRedraw", - value: function blockRedraw() { - return this.rowManager.blockRedraw(); - } //restore table redrawing + this.dispatchExternal("localized", this.locale, this.lang); - }, { - key: "restoreRedraw", - value: function restoreRedraw() { - return this.rowManager.restoreRedraw(); - } //local data from local file + this._executeBindings(); + } //get current locale }, { - key: "setDataFromLocalFile", - value: function setDataFromLocalFile(extensions) { - var _this3 = this; - - return new Promise(function (resolve, reject) { - var input = document.createElement("input"); - input.type = "file"; - input.accept = extensions || ".json,application/json"; - input.addEventListener("change", function (e) { - var file = input.files[0], - reader = new FileReader(), - data; - reader.readAsText(file); - - reader.onload = function (e) { - try { - data = JSON.parse(reader.result); - } catch (e) { - console.warn("File Load Error - File contents is invalid JSON", e); - reject(e); - return; - } - - _this3.setData(data).then(function (data) { - resolve(data); - })["catch"](function (err) { - resolve(err); - }); - }; - - reader.onerror = function (e) { - console.warn("File Load Error - Unable to read file"); - reject(); - }; - }); - input.click(); - }); - } //load data + key: "getLocale", + value: function getLocale(locale) { + return this.locale; + } //get lang object for given local or current if none provided }, { - key: "setData", - value: function setData(data, params, config) { - if (this.modExists("ajax")) { - this.modules.ajax.blockActiveRequest(); - } + key: "getLang", + value: function getLang(locale) { + return locale ? this.langList[locale] : this.lang; + } //get text for current locale - return this._setData(data, params, config, false, true); - } }, { - key: "_setData", - value: function _setData(data, params, config, inPosition, columnsChanged) { - if (typeof data === "string") { - if (data.indexOf("{") == 0 || data.indexOf("[") == 0) { - //data is a json encoded string - return this.rowManager.setData(JSON.parse(data), inPosition, columnsChanged); - } else { - if (this.modExists("ajax", true)) { - if (params) { - this.modules.ajax.setParams(params); - } - - if (config) { - this.modules.ajax.setConfig(config); - } + key: "getText", + value: function getText(path, value) { + var path = value ? path + "|" + value : path, + pathArray = path.split("|"), + text = this._getLangElement(pathArray, this.locale); // if(text === false){ + // console.warn("Localization Error - Matching localized text not found for given path: ", path); + // } - this.modules.ajax.setUrl(data); - if (this.options.pagination == "remote" && this.modExists("page", true)) { - this.modules.page.reset(true, true); - return this.modules.page.setPage(1); - } else { - //assume data is url, make ajax call to url to get data - return this.modules.ajax.loadData(inPosition, columnsChanged); - } - } - } - } else { - if (data) { - //asume data is already an object - return this.rowManager.setData(data, inPosition, columnsChanged); - } else { - //no data provided, check if ajaxURL is present; - if (this.modExists("ajax") && (this.modules.ajax.getUrl || this.options.ajaxURLGenerator)) { - if (this.options.pagination == "remote" && this.modExists("page", true)) { - this.modules.page.reset(true, true); - return this.modules.page.setPage(1); - } else { - return this.modules.ajax.loadData(inPosition, columnsChanged); - } - } else { - //empty data - return this.rowManager.setData([], inPosition, columnsChanged); - } - } - } - } //clear data + return text || ""; + } //traverse langs object and find localized copy }, { - key: "clearData", - value: function clearData() { - if (this.modExists("ajax")) { - this.modules.ajax.blockActiveRequest(); - } - - this.rowManager.clearData(); - } //get table data array + key: "_getLangElement", + value: function _getLangElement(path, locale) { + var root = this.lang; + path.forEach(function (level) { + var rootPath; - }, { - key: "getData", - value: function getData(active) { - return this.rowManager.getData(active); - } //get table data array count + if (root) { + rootPath = root[level]; - }, { - key: "getDataCount", - value: function getDataCount(active) { - return this.rowManager.getDataCount(active); - } //search for specific row components + if (typeof rootPath != "undefined") { + root = rootPath; + } else { + root = false; + } + } + }); + return root; + } //set update binding }, { - key: "searchRows", - value: function searchRows(field, type, value) { - if (this.modExists("filter", true)) { - return this.modules.filter.search("rows", field, type, value); + key: "bind", + value: function bind(path, callback) { + if (!this.bindings[path]) { + this.bindings[path] = []; } - } //search for specific data - }, { - key: "searchData", - value: function searchData(field, type, value) { - if (this.modExists("filter", true)) { - return this.modules.filter.search("data", field, type, value); - } - } //get table html + this.bindings[path].push(callback); + callback(this.getText(path), this.lang); + } //itterate through bindings and trigger updates }, { - key: "getHtml", - value: function getHtml(visible, style, config) { - if (this.modExists("export", true)) { - return this.modules["export"].getHtml(visible, style, config); - } - } //get print html + key: "_executeBindings", + value: function _executeBindings() { + var _this2 = this; - }, { - key: "print", - value: function print(visible, style, config) { - if (this.modExists("print", true)) { - return this.modules.print.printFullscreen(visible, style, config); - } - } //retrieve Ajax URL + var _loop = function _loop(path) { + _this2.bindings[path].forEach(function (binding) { + binding(_this2.getText(path), _this2.lang); + }); + }; - }, { - key: "getAjaxUrl", - value: function getAjaxUrl() { - if (this.modExists("ajax", true)) { - return this.modules.ajax.getUrl(); + for (var path in this.bindings) { + _loop(path); } - } //replace data, keeping table in position with same sort + } + }]); - }, { - key: "replaceData", - value: function replaceData(data, params, config) { - if (this.modExists("ajax")) { - this.modules.ajax.blockActiveRequest(); - } + return Localize; + }(Module); - return this._setData(data, params, config, true); - } //update table data + Localize.moduleName = "localize"; //load defaults - }, { - key: "updateData", - value: function updateData(data) { - var _this4 = this; + Localize.langs = defaultLangs; - var responses = 0; - return new Promise(function (resolve, reject) { - if (_this4.modExists("ajax")) { - _this4.modules.ajax.blockActiveRequest(); - } + var Comms = /*#__PURE__*/function (_Module) { + _inherits(Comms, _Module); - if (typeof data === "string") { - data = JSON.parse(data); - } + var _super = _createSuper(Comms); - if (data) { - data.forEach(function (item) { - var row = _this4.rowManager.findRow(item[_this4.options.index]); + function Comms(table) { + _classCallCheck(this, Comms); - if (row) { - responses++; - row.updateData(item).then(function () { - responses--; + return _super.call(this, table); + } - if (!responses) { - resolve(); - } - }); - } - }); - } else { - console.warn("Update Error - No data provided"); - reject("Update Error - No data provided"); - } - }); + _createClass(Comms, [{ + key: "initialize", + value: function initialize() { + this.registerTableFunction("tableComms", this.receive.bind(this)); } }, { - key: "addData", - value: function addData(data, pos, index) { - var _this5 = this; - - return new Promise(function (resolve, reject) { - if (_this5.modExists("ajax")) { - _this5.modules.ajax.blockActiveRequest(); - } + key: "getConnections", + value: function getConnections(selectors) { + var _this = this; - if (typeof data === "string") { - data = JSON.parse(data); + var connections = [], + connection; + connection = Tabulator.comms.lookupTable(selectors); + connection.forEach(function (con) { + if (_this.table !== con) { + connections.push(con); } + }); + return connections; + } + }, { + key: "send", + value: function send(selectors, module, action, data) { + var _this2 = this; - if (data) { - _this5.rowManager.addRows(data, pos, index).then(function (rows) { - var output = []; - rows.forEach(function (row) { - output.push(row.getComponent()); - }); - resolve(output); - }); - } else { - console.warn("Update Error - No data provided"); - reject("Update Error - No data provided"); - } + var connections = this.getConnections(selectors); + connections.forEach(function (connection) { + connection.tableComms(_this2.table.element, module, action, data); }); - } //update table data + if (!connections.length && selectors) { + console.warn("Table Connection Error - No tables matching selector found", selectors); + } + } }, { - key: "updateOrAddData", - value: function updateOrAddData(data) { - var _this6 = this; + key: "receive", + value: function receive(table, module, action, data) { + if (this.table.modExists(module)) { + return this.table.modules[module].commsReceived(table, action, data); + } else { + console.warn("Inter-table Comms Error - no such module:", module); + } + } + }]); - var rows = [], - responses = 0; - return new Promise(function (resolve, reject) { - if (_this6.modExists("ajax")) { - _this6.modules.ajax.blockActiveRequest(); - } + return Comms; + }(Module); - if (typeof data === "string") { - data = JSON.parse(data); - } + Comms.moduleName = "comms"; - if (data) { - data.forEach(function (item) { - var row = _this6.rowManager.findRow(item[_this6.options.index]); + var coreModules = /*#__PURE__*/Object.freeze({ + __proto__: null, + LayoutModule: Layout, + LocalizeModule: Localize, + CommsModule: Comms + }); - responses++; + var ModuleBinder = /*#__PURE__*/function () { + function ModuleBinder(tabulator, modules) { + _classCallCheck(this, ModuleBinder); - if (row) { - row.updateData(item).then(function () { - responses--; - rows.push(row.getComponent()); + this.bindStaticFuctionality(tabulator); + this.bindModules(tabulator, coreModules, true); - if (!responses) { - resolve(rows); - } - }); - } else { - _this6.rowManager.addRows(item).then(function (newRows) { - responses--; - rows.push(newRows[0].getComponent()); + if (modules) { + this.bindModules(tabulator, modules); + } + } - if (!responses) { - resolve(rows); - } - }); + _createClass(ModuleBinder, [{ + key: "bindStaticFuctionality", + value: function bindStaticFuctionality(tabulator) { + tabulator.moduleBindings = {}; + + tabulator.extendModule = function (name, property, values) { + if (tabulator.moduleBindings[name]) { + var source = tabulator.moduleBindings[name].prototype[property]; + + if (source) { + if (_typeof(values) == "object") { + for (var key in values) { + source[key] = values[key]; + } + } else { + console.warn("Module Error - Invalid value type, it must be an object"); } - }); + } else { + console.warn("Module Error - property does not exist:", property); + } } else { - console.warn("Update Error - No data provided"); - reject("Update Error - No data provided"); + console.warn("Module Error - module does not exist:", name); } - }); - } //get row object + }; - }, { - key: "getRow", - value: function getRow(index) { - var row = this.rowManager.findRow(index); + tabulator.registerModule = function (modules) { + if (!Array.isArray(modules)) { + modules = [modules]; + } - if (row) { - return row.getComponent(); - } else { - console.warn("Find Error - No matching row found:", index); - return false; - } - } //get row object + modules.forEach(function (mod) { + tabulator.registerModuleBinding(mod); + }); + }; - }, { - key: "getRowFromPosition", - value: function getRowFromPosition(position, active) { - var row = this.rowManager.getRowFromPosition(position, active); + tabulator.registerModuleBinding = function (mod) { + tabulator.moduleBindings[mod.moduleName] = mod; + }; - if (row) { - return row.getComponent(); - } else { - console.warn("Find Error - No matching row found:", position); - return false; + tabulator.findTable = function (query) { + var results = TableRegistry.lookupTable(query, true); + return Array.isArray(results) && !results.length ? false : results; + }; //ensure that module are bound to instantiated function + + + tabulator.prototype.bindModules = function () { + this.modules = {}; + + for (var name in tabulator.moduleBindings) { + var mod = tabulator.moduleBindings[name]; + this.modules[name] = new mod(this); + + if (mod.prototype.moduleCore) { + this.modulesCore[name] = this.modules[name]; + } else { + this.modulesRegular[name] = this.modules[name]; + } + } + }; + } + }, { + key: "bindModules", + value: function bindModules(tabulator, modules, core) { + var mods = Object.values(modules); + + if (core) { + mods.forEach(function (mod) { + mod.prototype.moduleCore = true; + }); } - } //delete row from table - }, { - key: "deleteRow", - value: function deleteRow(index) { - var _this7 = this; + tabulator.registerModule(mods); + } + }]); - return new Promise(function (resolve, reject) { - var count = 0, - successCount = 0, - foundRows = []; + return ModuleBinder; + }(); - function doneCheck() { - count++; + var Tabulator$1 = /*#__PURE__*/function () { + function Tabulator(element, options) { + var _this = this; - if (count == index.length) { - if (successCount) { - this.rowManager.reRenderInPosition(); - resolve(); - } - } - } + _classCallCheck(this, Tabulator); - if (!Array.isArray(index)) { - index = [index]; - } //find matching rows + this.options = {}; + this.columnManager = null; // hold Column Manager + this.rowManager = null; //hold Row Manager - index.forEach(function (item) { - var row = _this7.rowManager.findRow(item, true); + this.footerManager = null; //holder Footer Manager - if (row) { - foundRows.push(row); - } else { - console.warn("Delete Error - No matching row found:", item); - reject("Delete Error - No matching row found"); - doneCheck(); - } - }); //sort rows into correct order to ensure smooth delete from table + this.vdomHoz = null; //holder horizontal virtual dom - foundRows.sort(function (a, b) { - return _this7.rowManager.rows.indexOf(a) > _this7.rowManager.rows.indexOf(b) ? 1 : -1; - }); - foundRows.forEach(function (row) { - row["delete"]().then(function () { - successCount++; - doneCheck(); - })["catch"](function (err) { - doneCheck(); - reject(err); - }); - }); - }); - } //add row to table + this.externalEvents = null; //handle external event messaging - }, { - key: "addRow", - value: function addRow(data, pos, index) { - var _this8 = this; + this.eventBus = null; //handle internal event messaging - return new Promise(function (resolve, reject) { - if (typeof data === "string") { - data = JSON.parse(data); - } + this.interactionMonitor = false; //track user interaction - _this8.rowManager.addRows(data, pos, index).then(function (rows) { - //recalc column calculations if present - if (_this8.modExists("columnCalcs")) { - _this8.modules.columnCalcs.recalc(_this8.rowManager.activeRows); - } + this.browser = ""; //hold current browser type - resolve(rows[0].getComponent()); - }); - }); - } //update a row if it exitsts otherwise create it + this.browserSlow = false; //handle reduced functionality for slower browsers - }, { - key: "updateOrAddRow", - value: function updateOrAddRow(index, data) { - var _this9 = this; + this.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence - return new Promise(function (resolve, reject) { - var row = _this9.rowManager.findRow(index); + this.rtl = false; //check if the table is in RTL mode - if (typeof data === "string") { - data = JSON.parse(data); - } + this.componentFunctionBinder = new ComponentFuctionBinder(this); //bind component functions - if (row) { - row.updateData(data).then(function () { - //recalc column calculations if present - if (_this9.modExists("columnCalcs")) { - _this9.modules.columnCalcs.recalc(_this9.rowManager.activeRows); - } + this.dataLoader = false; //bind component functions - resolve(row.getComponent()); - })["catch"](function (err) { - reject(err); - }); - } else { - row = _this9.rowManager.addRows(data).then(function (rows) { - //recalc column calculations if present - if (_this9.modExists("columnCalcs")) { - _this9.modules.columnCalcs.recalc(_this9.rowManager.activeRows); - } + this.modules = {}; //hold all modules bound to this table - resolve(rows[0].getComponent()); - })["catch"](function (err) { - reject(err); - }); - } - }); - } //update row data + this.modulesCore = {}; //hold core modules bound to this table (for initialization purposes) - }, { - key: "updateRow", - value: function updateRow(index, data) { - var _this10 = this; + this.modulesRegular = {}; //hold regular modules bound to this table (for initialization purposes) - return new Promise(function (resolve, reject) { - var row = _this10.rowManager.findRow(index); + this.optionsList = new OptionsList(this, "table constructor"); - if (typeof data === "string") { - data = JSON.parse(data); - } + if (this.initializeElement(element)) { + this.initialzeCoreSystems(options); //delay table creation to allow event bindings immediatly after the constructor - if (row) { - row.updateData(data).then(function () { - resolve(row.getComponent()); - })["catch"](function (err) { - reject(err); - }); - } else { - console.warn("Update Error - No matching row found:", index); - reject("Update Error - No matching row found"); - } + setTimeout(function () { + _this._create(); }); - } //scroll to row in DOM + } - }, { - key: "scrollToRow", - value: function scrollToRow(index, position, ifVisible) { - var _this11 = this; + TableRegistry.register(this); //register table for inderdevice communication + } - return new Promise(function (resolve, reject) { - var row = _this11.rowManager.findRow(index); + _createClass(Tabulator, [{ + key: "initializeElement", + value: function initializeElement(element) { + if (typeof HTMLElement !== "undefined" && element instanceof HTMLElement) { + this.element = element; + return true; + } else if (typeof element === "string") { + this.element = document.querySelector(element); - if (row) { - _this11.rowManager.scrollToRow(row, position, ifVisible).then(function () { - resolve(); - })["catch"](function (err) { - reject(err); - }); + if (this.element) { + return true; } else { - console.warn("Scroll Error - No matching row found:", index); - reject("Scroll Error - No matching row found"); + console.error("Tabulator Creation Error - no element found matching selector: ", element); + return false; } - }); - } - }, { - key: "moveRow", - value: function moveRow(from, to, after) { - var fromRow = this.rowManager.findRow(from); - - if (fromRow) { - fromRow.moveToRow(to, after); } else { - console.warn("Move Error - No matching row found:", from); + console.error("Tabulator Creation Error - Invalid element provided:", element); + return false; } } }, { - key: "getRows", - value: function getRows(active) { - return this.rowManager.getComponents(active); - } //get position of row in table + key: "initialzeCoreSystems", + value: function initialzeCoreSystems(options) { + this.columnManager = new ColumnManager(this); + this.rowManager = new RowManager(this); + this.footerManager = new FooterManager(this); + this.dataLoader = new DataLoader(this); + this.bindModules(); + this.options = this.optionsList.generate(Tabulator.defaultOptions, options); - }, { - key: "getRowPosition", - value: function getRowPosition(index, active) { - var row = this.rowManager.findRow(index); + this._clearObjectPointers(); - if (row) { - return this.rowManager.getRowPosition(row, active); - } else { - console.warn("Position Error - No matching row found:", index); - return false; - } - } //copy table data to clipboard + this._mapDepricatedFunctionality(); + this.externalEvents = new ExternalEventBus(this.options, this.options.debugEventsExternal); + this.eventBus = new InternalEventBus(this.options.debugEventsInternal); + this.interactionMonitor = new InteractionManager(this); + this.dataLoader.initialize(); + this.columnManager.initialize(); + this.rowManager.initialize(); + this.footerManager.initialize(); + } }, { - key: "copyToClipboard", - value: function copyToClipboard(selector) { - if (this.modExists("clipboard", true)) { - this.modules.clipboard.copy(selector); + key: "rtlCheck", + value: function rtlCheck() { + var style = window.getComputedStyle(this.element); + + switch (this.options.textDirection) { + case "auto": + if (style.direction !== "rtl") { + break; + } + + case "rtl": + this.element.classList.add("tabulator-rtl"); + this.rtl = true; + break; + + case "ltr": + this.element.classList.add("tabulator-ltr"); + + default: + this.rtl = false; } - } /////////////// Column Functions /////////////// + } //convert depricated functionality to new functions }, { - key: "setColumns", - value: function setColumns(definition) { - this.columnManager.setColumns(definition); - } - }, { - key: "getColumns", - value: function getColumns(structured) { - return this.columnManager.getComponents(structured); + key: "_mapDepricatedFunctionality", + value: function _mapDepricatedFunctionality() {//all previously deprecated functionality removed in the 5.0 release } }, { - key: "getColumn", - value: function getColumn(field) { - var col = this.columnManager.findColumn(field); + key: "_clearSelection", + value: function _clearSelection() { + this.element.classList.add("tabulator-block-select"); - if (col) { - return col.getComponent(); - } else { - console.warn("Find Error - No matching column found:", field); - return false; + if (window.getSelection) { + if (window.getSelection().empty) { + // Chrome + window.getSelection().empty(); + } else if (window.getSelection().removeAllRanges) { + // Firefox + window.getSelection().removeAllRanges(); + } + } else if (document.selection) { + // IE? + document.selection.empty(); } - } - }, { - key: "getColumnDefinitions", - value: function getColumnDefinitions() { - return this.columnManager.getDefinitionTree(); - } + + this.element.classList.remove("tabulator-block-select"); + } //concreate table + }, { - key: "getColumnLayout", - value: function getColumnLayout() { - if (this.modExists("persistence", true)) { - return this.modules.persistence.parseColumns(this.columnManager.getColumns()); - } - } + key: "_create", + value: function _create() { + this.externalEvents.dispatch("tableBuilding"); + this.eventBus.dispatch("table-building"); + this.rtlCheck(); + + this._buildElement(); + + this._loadInitialData(); + } //clear pointers to objects in default config object + }, { - key: "setColumnLayout", - value: function setColumnLayout(layout) { - if (this.modExists("persistence", true)) { - this.columnManager.setColumns(this.modules.persistence.mergeDefinition(this.options.columns, layout)); - return true; + key: "_clearObjectPointers", + value: function _clearObjectPointers() { + this.options.columns = this.options.columns.slice(0); + + if (this.options.data && !this.options.reactiveData) { + this.options.data = this.options.data.slice(0); } + } //build tabulator element - return false; - } }, { - key: "showColumn", - value: function showColumn(field) { - var column = this.columnManager.findColumn(field); + key: "_buildElement", + value: function _buildElement() { + var element = this.element, + options = this.options; + element.classList.add("tabulator"); + element.setAttribute("role", "grid"); //empty element - if (column) { - column.show(); + while (element.firstChild) { + element.removeChild(element.firstChild); + } //set table height - if (this.options.responsiveLayout && this.modExists("responsiveLayout", true)) { - this.modules.responsiveLayout.update(); - } - } else { - console.warn("Column Show Error - No matching column found:", field); - return false; - } - } - }, { - key: "hideColumn", - value: function hideColumn(field) { - var column = this.columnManager.findColumn(field); - if (column) { - column.hide(); + if (options.height) { + options.height = isNaN(options.height) ? options.height : options.height + "px"; + element.style.height = options.height; + } //set table min height - if (this.options.responsiveLayout && this.modExists("responsiveLayout", true)) { - this.modules.responsiveLayout.update(); - } - } else { - console.warn("Column Hide Error - No matching column found:", field); - return false; - } - } - }, { - key: "toggleColumn", - value: function toggleColumn(field) { - var column = this.columnManager.findColumn(field); - if (column) { - if (column.visible) { - column.hide(); - } else { - column.show(); - } - } else { - console.warn("Column Visibility Toggle Error - No matching column found:", field); - return false; + if (options.minHeight !== false) { + options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px"; + element.style.minHeight = options.minHeight; + } //set table maxHeight + + + if (options.maxHeight !== false) { + options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px"; + element.style.maxHeight = options.maxHeight; } - } - }, { - key: "addColumn", - value: function addColumn(definition, before, field) { - var _this12 = this; - return new Promise(function (resolve, reject) { - var column = _this12.columnManager.findColumn(field); + this.columnManager.initialize(); + this.rowManager.initialize(); - _this12.columnManager.addColumn(definition, before, column).then(function (column) { - resolve(column.getComponent()); - })["catch"](function (err) { - reject(err); - }); - }); - } - }, { - key: "deleteColumn", - value: function deleteColumn(field) { - var _this13 = this; + this._detectBrowser(); //initialize core modules - return new Promise(function (resolve, reject) { - var column = _this13.columnManager.findColumn(field); - if (column) { - column["delete"]().then(function () { - resolve(); - })["catch"](function (err) { - reject(err); - }); - } else { - console.warn("Column Delete Error - No matching column found:", field); - reject(); - } - }); - } - }, { - key: "updateColumnDefinition", - value: function updateColumnDefinition(field, definition) { - var _this14 = this; + for (var key in this.modulesCore) { + var mod = this.modulesCore[key]; + mod.initialize(); + } //configure placeholder element - return new Promise(function (resolve, reject) { - var column = _this14.columnManager.findColumn(field); - if (column) { - column.updateDefinition(definition).then(function (col) { - resolve(col); - })["catch"](function (err) { - reject(err); - }); - } else { - console.warn("Column Update Error - No matching column found:", field); - reject(); - } - }); - } - }, { - key: "moveColumn", - value: function moveColumn(from, to, after) { - var fromColumn = this.columnManager.findColumn(from); - var toColumn = this.columnManager.findColumn(to); + if (typeof options.placeholder == "string") { + var el = document.createElement("div"); + el.classList.add("tabulator-placeholder"); + var span = document.createElement("span"); + span.innerHTML = options.placeholder; + el.appendChild(span); + options.placeholder = el; + } //build table elements - if (fromColumn) { - if (toColumn) { - this.columnManager.moveColumn(fromColumn, toColumn, after); - } else { - console.warn("Move Error - No matching column found:", toColumn); - } - } else { - console.warn("Move Error - No matching column found:", from); + + element.appendChild(this.columnManager.getElement()); + element.appendChild(this.rowManager.getElement()); + + if (options.footerElement) { + this.footerManager.activate(); } - } //scroll to column in DOM - }, { - key: "scrollToColumn", - value: function scrollToColumn(field, position, ifVisible) { - var _this15 = this; + if (options.autoColumns && this.options.data) { + this.columnManager.generateColumnsFromRowData(this.options.data); + } //initialize regular modules - return new Promise(function (resolve, reject) { - var column = _this15.columnManager.findColumn(field); - if (column) { - _this15.columnManager.scrollToColumn(column, position, ifVisible).then(function () { - resolve(); - })["catch"](function (err) { - reject(err); - }); - } else { - console.warn("Scroll Error - No matching column found:", field); - reject("Scroll Error - No matching column found"); - } - }); - } //////////// Localization Functions //////////// + for (var _key in this.modulesRegular) { + var _mod = this.modulesRegular[_key]; - }, { - key: "setLocale", - value: function setLocale(locale) { - this.modules.localize.setLocale(locale); - } - }, { - key: "getLocale", - value: function getLocale() { - return this.modules.localize.getLocale(); + _mod.initialize(); + } + + this.columnManager.setColumns(options.columns); + this.eventBus.dispatch("table-built"); + this.externalEvents.dispatch("tableBuilt"); } }, { - key: "getLang", - value: function getLang(locale) { - return this.modules.localize.getLang(locale); - } //////////// General Public Functions //////////// - //redraw list without updating data + key: "_loadInitialData", + value: function _loadInitialData() { + this.dataLoader.load(this.options.data); + } //deconstructor }, { - key: "redraw", - value: function redraw(force) { - this.columnManager.redraw(force); - this.rowManager.redraw(force); + key: "destroy", + value: function destroy() { + var element = this.element; + TableRegistry.deregister(this); //deregister table from inderdevice communication + + this.eventBus.dispatch("table-destroy"); //clear row data + + this.rowManager.rows.forEach(function (row) { + row.wipe(); + }); + this.rowManager.rows = []; + this.rowManager.activeRows = []; + this.rowManager.displayRows = []; //clear DOM + + while (element.firstChild) { + element.removeChild(element.firstChild); + } + + element.classList.remove("tabulator"); } }, { - key: "setHeight", - value: function setHeight(height) { - if (this.rowManager.renderMode !== "classic") { - this.options.height = isNaN(height) ? height : height + "px"; - this.element.style.height = this.options.height; - this.rowManager.setRenderMode(); - this.rowManager.redraw(); + key: "_detectBrowser", + value: function _detectBrowser() { + var ua = navigator.userAgent || navigator.vendor || window.opera; + + if (ua.indexOf("Trident") > -1) { + this.browser = "ie"; + this.browserSlow = true; + } else if (ua.indexOf("Edge") > -1) { + this.browser = "edge"; + this.browserSlow = true; + } else if (ua.indexOf("Firefox") > -1) { + this.browser = "firefox"; + this.browserSlow = false; } else { - console.warn("setHeight function is not available in classic render mode"); + this.browser = "other"; + this.browserSlow = false; } - } ///////////////////// Sorting //////////////////// + + this.browserMobile = /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(ua) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(ua.substr(0, 4)); + } ////////////////// Data Handling ////////////////// + //block table redrawing }, { - key: "setSort", - value: function setSort(sortList, dir) { - if (this.modExists("sort", true)) { - this.modules.sort.setSort(sortList, dir); - this.rowManager.sorterRefresh(); - } - } + key: "blockRedraw", + value: function blockRedraw() { + return this.rowManager.blockRedraw(); + } //restore table redrawing + }, { - key: "getSorters", - value: function getSorters() { - if (this.modExists("sort", true)) { - return this.modules.sort.getSort(); - } - } + key: "restoreRedraw", + value: function restoreRedraw() { + return this.rowManager.restoreRedraw(); + } //local data from local file + }, { - key: "clearSort", - value: function clearSort() { - if (this.modExists("sort", true)) { - this.modules.sort.clear(); - this.rowManager.sorterRefresh(); - } - } ///////////////////// Filtering //////////////////// - //set standard filters + key: "setDataFromLocalFile", + value: function setDataFromLocalFile(extensions) { + var _this2 = this; + + return new Promise(function (resolve, reject) { + var input = document.createElement("input"); + input.type = "file"; + input.accept = extensions || ".json,application/json"; + input.addEventListener("change", function (e) { + var file = input.files[0], + reader = new FileReader(), + data; + reader.readAsText(file); + + reader.onload = function (e) { + try { + data = JSON.parse(reader.result); + } catch (e) { + console.warn("File Load Error - File contents is invalid JSON", e); + reject(e); + return; + } + + _this2.setData(data).then(function (data) { + resolve(data); + })["catch"](function (err) { + resolve(err); + }); + }; + + reader.onerror = function (e) { + console.warn("File Load Error - Unable to read file"); + reject(); + }; + }); + input.click(); + }); + } //load data }, { - key: "setFilter", - value: function setFilter(field, type, value, params) { - if (this.modExists("filter", true)) { - this.modules.filter.setFilter(field, type, value, params); - this.rowManager.filterRefresh(); - } - } //set standard filters + key: "setData", + value: function setData(data, params, config) { + return this.dataLoader.load(data, params, config, false); + } //clear data }, { - key: "refreshFilter", - value: function refreshFilter() { - if (this.modExists("filter", true)) { - this.rowManager.filterRefresh(); - } - } //add filter to array + key: "clearData", + value: function clearData() { + this.dataLoader.blockActiveLoad(); + this.rowManager.clearData(); + } //get table data array }, { - key: "addFilter", - value: function addFilter(field, type, value, params) { - if (this.modExists("filter", true)) { - this.modules.filter.addFilter(field, type, value, params); - this.rowManager.filterRefresh(); - } - } //get all filters + key: "getData", + value: function getData(active) { + return this.rowManager.getData(active); + } //get table data array count }, { - key: "getFilters", - value: function getFilters(all) { - if (this.modExists("filter", true)) { - return this.modules.filter.getFilters(all); - } - } + key: "getDataCount", + value: function getDataCount(active) { + return this.rowManager.getDataCount(active); + } //replace data, keeping table in position with same sort + }, { - key: "setHeaderFilterFocus", - value: function setHeaderFilterFocus(field) { - if (this.modExists("filter", true)) { - var column = this.columnManager.findColumn(field); + key: "replaceData", + value: function replaceData(data, params, config) { + return this.dataLoader.load(data, params, config, true, true); + } //update table data - if (column) { - this.modules.filter.setHeaderFilterFocus(column); - } else { - console.warn("Column Filter Focus Error - No matching column found:", field); - return false; - } - } - } }, { - key: "getHeaderFilterValue", - value: function getHeaderFilterValue(field) { - if (this.modExists("filter", true)) { - var column = this.columnManager.findColumn(field); + key: "updateData", + value: function updateData(data) { + var _this3 = this; - if (column) { - return this.modules.filter.getHeaderFilterValue(column); - } else { - console.warn("Column Filter Error - No matching column found:", field); + var responses = 0; + return new Promise(function (resolve, reject) { + _this3.dataLoader.blockActiveLoad(); + + if (typeof data === "string") { + data = JSON.parse(data); } - } - } - }, { - key: "setHeaderFilterValue", - value: function setHeaderFilterValue(field, value) { - if (this.modExists("filter", true)) { - var column = this.columnManager.findColumn(field); - if (column) { - this.modules.filter.setHeaderFilterValue(column, value); + if (data) { + data.forEach(function (item) { + var row = _this3.rowManager.findRow(item[_this3.options.index]); + + if (row) { + responses++; + row.updateData(item).then(function () { + responses--; + + if (!responses) { + resolve(); + } + }); + } + }); } else { - console.warn("Column Filter Error - No matching column found:", field); - return false; + console.warn("Update Error - No data provided"); + reject("Update Error - No data provided"); } - } + }); } }, { - key: "getHeaderFilters", - value: function getHeaderFilters() { - if (this.modExists("filter", true)) { - return this.modules.filter.getHeaderFilters(); - } - } //remove filter from array + key: "addData", + value: function addData(data, pos, index) { + var _this4 = this; - }, { - key: "removeFilter", - value: function removeFilter(field, type, value) { - if (this.modExists("filter", true)) { - this.modules.filter.removeFilter(field, type, value); - this.rowManager.filterRefresh(); - } - } //clear filters + return new Promise(function (resolve, reject) { + _this4.dataLoader.blockActiveLoad(); - }, { - key: "clearFilter", - value: function clearFilter(all) { - if (this.modExists("filter", true)) { - this.modules.filter.clearFilter(all); - this.rowManager.filterRefresh(); - } - } //clear header filters + if (typeof data === "string") { + data = JSON.parse(data); + } - }, { - key: "clearHeaderFilter", - value: function clearHeaderFilter() { - if (this.modExists("filter", true)) { - this.modules.filter.clearHeaderFilter(); - this.rowManager.filterRefresh(); - } - } ///////////////////// select //////////////////// + if (data) { + _this4.rowManager.addRows(data, pos, index).then(function (rows) { + var output = []; + rows.forEach(function (row) { + output.push(row.getComponent()); + }); + resolve(output); + }); + } else { + console.warn("Update Error - No data provided"); + reject("Update Error - No data provided"); + } + }); + } //update table data }, { - key: "selectRow", - value: function selectRow(rows) { - if (this.modExists("selectRow", true)) { - this.modules.selectRow.selectRows(rows); - } - } - }, { - key: "deselectRow", - value: function deselectRow(rows) { - if (this.modExists("selectRow", true)) { - this.modules.selectRow.deselectRows(rows); - } - } - }, { - key: "toggleSelectRow", - value: function toggleSelectRow(row) { - if (this.modExists("selectRow", true)) { - this.modules.selectRow.toggleRow(row); - } - } - }, { - key: "getSelectedRows", - value: function getSelectedRows() { - if (this.modExists("selectRow", true)) { - return this.modules.selectRow.getSelectedRows(); - } - } - }, { - key: "getSelectedData", - value: function getSelectedData() { - if (this.modExists("selectRow", true)) { - return this.modules.selectRow.getSelectedData(); - } - } ///////////////////// validation //////////////////// + key: "updateOrAddData", + value: function updateOrAddData(data) { + var _this5 = this; - }, { - key: "getInvalidCells", - value: function getInvalidCells() { - if (this.modExists("validate", true)) { - return this.modules.validate.getInvalidCells(); - } - } - }, { - key: "clearCellValidation", - value: function clearCellValidation(cells) { - var _this16 = this; + var rows = [], + responses = 0; + return new Promise(function (resolve, reject) { + _this5.dataLoader.blockActiveLoad(); - if (this.modExists("validate", true)) { - if (!cells) { - cells = this.modules.validate.getInvalidCells(); + if (typeof data === "string") { + data = JSON.parse(data); } - if (!Array.isArray(cells)) { - cells = [cells]; - } + if (data) { + data.forEach(function (item) { + var row = _this5.rowManager.findRow(item[_this5.options.index]); - cells.forEach(function (cell) { - _this16.modules.validate.clearValidation(cell._getSelf()); - }); - } - } - }, { - key: "validate", - value: function validate(cells) { - var output = []; //clear row data + responses++; - this.rowManager.rows.forEach(function (row) { - var valid = row.validate(); + if (row) { + row.updateData(item).then(function () { + responses--; + rows.push(row.getComponent()); - if (valid !== true) { - output = output.concat(valid); + if (!responses) { + resolve(rows); + } + }); + } else { + _this5.rowManager.addRows(item).then(function (newRows) { + responses--; + rows.push(newRows[0].getComponent()); + + if (!responses) { + resolve(rows); + } + }); + } + }); + } else { + console.warn("Update Error - No data provided"); + reject("Update Error - No data provided"); } }); - return output.length ? output : true; - } //////////// Pagination Functions //////////// + } //get row object }, { - key: "setMaxPage", - value: function setMaxPage(max) { - if (this.options.pagination && this.modExists("page")) { - this.modules.page.setMaxPage(max); + key: "getRow", + value: function getRow(index) { + var row = this.rowManager.findRow(index); + + if (row) { + return row.getComponent(); } else { + console.warn("Find Error - No matching row found:", index); return false; } - } + } //get row object + }, { - key: "setPage", - value: function setPage(page) { - if (this.options.pagination && this.modExists("page")) { - return this.modules.page.setPage(page); + key: "getRowFromPosition", + value: function getRowFromPosition(position, active) { + var row = this.rowManager.getRowFromPosition(position, active); + + if (row) { + return row.getComponent(); } else { - return new Promise(function (resolve, reject) { - reject(); - }); + console.warn("Find Error - No matching row found:", position); + return false; } - } + } //delete row from table + }, { - key: "setPageToRow", - value: function setPageToRow(row) { - var _this17 = this; + key: "deleteRow", + value: function deleteRow(index) { + var _this6 = this; + + return new Promise(function (resolve, reject) { + var count = 0, + successCount = 0, + foundRows = []; + + function doneCheck() { + count++; + + if (count == index.length) { + if (successCount) { + this.rowManager.reRenderInPosition(); + resolve(); + } + } + } + + if (!Array.isArray(index)) { + index = [index]; + } //find matching rows + + + index.forEach(function (item) { + var row = _this6.rowManager.findRow(item, true); + + if (row) { + foundRows.push(row); + } else { + console.warn("Delete Error - No matching row found:", item); + reject("Delete Error - No matching row found"); + doneCheck(); + } + }); //sort rows into correct order to ensure smooth delete from table + + foundRows.sort(function (a, b) { + return _this6.rowManager.rows.indexOf(a) > _this6.rowManager.rows.indexOf(b) ? 1 : -1; + }); + foundRows.forEach(function (row) { + row["delete"]().then(function () { + successCount++; + doneCheck(); + })["catch"](function (err) { + doneCheck(); + reject(err); + }); + }); + }); + } //add row to table - return new Promise(function (resolve, reject) { - if (_this17.options.pagination && _this17.modExists("page")) { - row = _this17.rowManager.findRow(row); + }, { + key: "addRow", + value: function addRow(data, pos, index) { + if (typeof data === "string") { + data = JSON.parse(data); + } - if (row) { - _this17.modules.page.setPageToRow(row).then(function () { - resolve(); - })["catch"](function () { - reject(); - }); - } else { - reject(); - } - } else { - reject(); - } + return this.rowManager.addRows(data, pos, index).then(function (rows) { + return rows[0].getComponent(); }); - } + } //update a row if it exitsts otherwise create it + }, { - key: "setPageSize", - value: function setPageSize(size) { - if (this.options.pagination && this.modExists("page")) { - this.modules.page.setPageSize(size); - this.modules.page.setPage(1).then(function () {})["catch"](function () {}); + key: "updateOrAddRow", + value: function updateOrAddRow(index, data) { + var row = this.rowManager.findRow(index); + + if (typeof data === "string") { + data = JSON.parse(data); + } + + if (row) { + return row.updateData(data).then(function () { + return row.getComponent(); + }); } else { - return false; + return this.rowManager.addRows(data).then(function (rows) { + return rows[0].getComponent(); + }); } - } + } //update row data + }, { - key: "getPageSize", - value: function getPageSize() { - if (this.options.pagination && this.modExists("page", true)) { - return this.modules.page.getPageSize(); + key: "updateRow", + value: function updateRow(index, data) { + var row = this.rowManager.findRow(index); + + if (typeof data === "string") { + data = JSON.parse(data); } - } - }, { - key: "previousPage", - value: function previousPage() { - if (this.options.pagination && this.modExists("page")) { - this.modules.page.previousPage(); + + if (row) { + return row.updateData(data).then(function () { + resolve(row.getComponent()); + }); } else { - return false; + console.warn("Update Error - No matching row found:", index); + return Promise.reject("Update Error - No matching row found"); } - } + } //scroll to row in DOM + }, { - key: "nextPage", - value: function nextPage() { - if (this.options.pagination && this.modExists("page")) { - this.modules.page.nextPage(); + key: "scrollToRow", + value: function scrollToRow(index, position, ifVisible) { + var row = this.rowManager.findRow(index); + + if (row) { + return this.rowManager.scrollToRow(row, position, ifVisible); } else { - return false; + console.warn("Scroll Error - No matching row found:", index); + return Promise.reject("Scroll Error - No matching row found"); } } }, { - key: "getPage", - value: function getPage() { - if (this.options.pagination && this.modExists("page")) { - return this.modules.page.getPage(); + key: "moveRow", + value: function moveRow(from, to, after) { + var fromRow = this.rowManager.findRow(from); + + if (fromRow) { + fromRow.moveToRow(to, after); } else { - return false; + console.warn("Move Error - No matching row found:", from); } } }, { - key: "getPageMax", - value: function getPageMax() { - if (this.options.pagination && this.modExists("page")) { - return this.modules.page.getPageMax(); - } else { - return false; - } - } ///////////////// Grouping Functions /////////////// + key: "getRows", + value: function getRows(active) { + return this.rowManager.getComponents(active); + } //get position of row in table }, { - key: "setGroupBy", - value: function setGroupBy(groups) { - if (this.modExists("groupRows", true)) { - this.options.groupBy = groups; - this.modules.groupRows.initialize(); - this.rowManager.refreshActiveData("display"); + key: "getRowPosition", + value: function getRowPosition(index, active) { + var row = this.rowManager.findRow(index); - if (this.options.persistence && this.modExists("persistence", true) && this.modules.persistence.config.group) { - this.modules.persistence.save("group"); - } + if (row) { + return this.rowManager.getRowPosition(row, active); } else { + console.warn("Position Error - No matching row found:", index); return false; } + } /////////////// Column Functions /////////////// + + }, { + key: "setColumns", + value: function setColumns(definition) { + this.columnManager.setColumns(definition); } }, { - key: "setGroupValues", - value: function setGroupValues(groupValues) { - if (this.modExists("groupRows", true)) { - this.options.groupValues = groupValues; - this.modules.groupRows.initialize(); - this.rowManager.refreshActiveData("display"); - - if (this.options.persistence && this.modExists("persistence", true) && this.modules.persistence.config.group) { - this.modules.persistence.save("group"); - } - } else { - return false; - } + key: "getColumns", + value: function getColumns(structured) { + return this.columnManager.getComponents(structured); } }, { - key: "setGroupStartOpen", - value: function setGroupStartOpen(values) { - if (this.modExists("groupRows", true)) { - this.options.groupStartOpen = values; - this.modules.groupRows.initialize(); - - if (this.options.groupBy) { - this.rowManager.refreshActiveData("group"); + key: "getColumn", + value: function getColumn(field) { + var col = this.columnManager.findColumn(field); - if (this.options.persistence && this.modExists("persistence", true) && this.modules.persistence.config.group) { - this.modules.persistence.save("group"); - } - } else { - console.warn("Grouping Update - cant refresh view, no groups have been set"); - } + if (col) { + return col.getComponent(); } else { + console.warn("Find Error - No matching column found:", field); return false; } } }, { - key: "setGroupHeader", - value: function setGroupHeader(values) { - if (this.modExists("groupRows", true)) { - this.options.groupHeader = values; - this.modules.groupRows.initialize(); - - if (this.options.groupBy) { - this.rowManager.refreshActiveData("group"); - - if (this.options.persistence && this.modExists("persistence", true) && this.modules.persistence.config.group) { - this.modules.persistence.save("group"); - } - } else { - console.warn("Grouping Update - cant refresh view, no groups have been set"); - } - } else { - return false; - } + key: "getColumnDefinitions", + value: function getColumnDefinitions() { + return this.columnManager.getDefinitionTree(); } }, { - key: "getGroups", - value: function getGroups(values) { - if (this.modExists("groupRows", true)) { - return this.modules.groupRows.getGroups(true); + key: "showColumn", + value: function showColumn(field) { + var column = this.columnManager.findColumn(field); + + if (column) { + column.show(); } else { + console.warn("Column Show Error - No matching column found:", field); return false; } - } // get grouped table data in the same format as getData() - - }, { - key: "getGroupedData", - value: function getGroupedData() { - if (this.modExists("groupRows", true)) { - return this.options.groupBy ? this.modules.groupRows.getGroupedData() : this.getData(); - } - } - }, { - key: "getEditedCells", - value: function getEditedCells() { - if (this.modExists("edit", true)) { - return this.modules.edit.getEditedCells(); - } } }, { - key: "clearCellEdited", - value: function clearCellEdited(cells) { - var _this18 = this; - - if (this.modExists("edit", true)) { - if (!cells) { - cells = this.modules.edit.getEditedCells(); - } - - if (!Array.isArray(cells)) { - cells = [cells]; - } - - cells.forEach(function (cell) { - _this18.modules.edit.clearEdited(cell._getSelf()); - }); - } - } ///////////////// Column Calculation Functions /////////////// + key: "hideColumn", + value: function hideColumn(field) { + var column = this.columnManager.findColumn(field); - }, { - key: "getCalcResults", - value: function getCalcResults() { - if (this.modExists("columnCalcs", true)) { - return this.modules.columnCalcs.getResults(); + if (column) { + column.hide(); } else { + console.warn("Column Hide Error - No matching column found:", field); return false; } } }, { - key: "recalc", - value: function recalc() { - if (this.modExists("columnCalcs", true)) { - this.modules.columnCalcs.recalcAll(this.rowManager.activeRows); - } - } /////////////// Navigation Management ////////////// - - }, { - key: "navigatePrev", - value: function navigatePrev() { - var cell = false; - - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; + key: "toggleColumn", + value: function toggleColumn(field) { + var column = this.columnManager.findColumn(field); - if (cell) { - return cell.nav().prev(); + if (column) { + if (column.visible) { + column.hide(); + } else { + column.show(); } + } else { + console.warn("Column Visibility Toggle Error - No matching column found:", field); + return false; } - - return false; } }, { - key: "navigateNext", - value: function navigateNext() { - var cell = false; - - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; - - if (cell) { - return cell.nav().next(); - } - } - - return false; + key: "addColumn", + value: function addColumn(definition, before, field) { + var column = this.columnManager.findColumn(field); + return this.columnManager.addColumn(definition, before, column).then(function (column) { + returncolumn.getComponent(); + }); } }, { - key: "navigateLeft", - value: function navigateLeft() { - var cell = false; - - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; + key: "deleteColumn", + value: function deleteColumn(field) { + var column = this.columnManager.findColumn(field); - if (cell) { - e.preventDefault(); - return cell.nav().left(); - } + if (column) { + return column["delete"](); + } else { + console.warn("Column Delete Error - No matching column found:", field); + return Promise.reject(); } - - return false; } }, { - key: "navigateRight", - value: function navigateRight() { - var cell = false; - - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; + key: "updateColumnDefinition", + value: function updateColumnDefinition(field, definition) { + var column = this.columnManager.findColumn(field); - if (cell) { - e.preventDefault(); - return cell.nav().right(); - } + if (column) { + return column.updateDefinition(definition); + } else { + console.warn("Column Update Error - No matching column found:", field); + return Promise.reject(); } - - return false; } }, { - key: "navigateUp", - value: function navigateUp() { - var cell = false; - - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; + key: "moveColumn", + value: function moveColumn(from, to, after) { + var fromColumn = this.columnManager.findColumn(from); + var toColumn = this.columnManager.findColumn(to); - if (cell) { - e.preventDefault(); - return cell.nav().up(); + if (fromColumn) { + if (toColumn) { + this.columnManager.moveColumn(fromColumn, toColumn, after); + } else { + console.warn("Move Error - No matching column found:", toColumn); } + } else { + console.warn("Move Error - No matching column found:", from); } + } //scroll to column in DOM - return false; - } }, { - key: "navigateDown", - value: function navigateDown() { - var cell = false; + key: "scrollToColumn", + value: function scrollToColumn(field, position, ifVisible) { + var _this7 = this; - if (this.modExists("edit", true)) { - cell = this.modules.edit.currentCell; + return new Promise(function (resolve, reject) { + var column = _this7.columnManager.findColumn(field); - if (cell) { - e.preventDefault(); - return cell.nav().down(); + if (column) { + return _this7.columnManager.scrollToColumn(column, position, ifVisible); + } else { + console.warn("Scroll Error - No matching column found:", field); + return Promise.reject("Scroll Error - No matching column found"); } - } - - return false; - } /////////////// History Management ////////////// + }); + } //////////// General Public Functions //////////// + //redraw list without updating data }, { - key: "undo", - value: function undo() { - if (this.options.history && this.modExists("history", true)) { - return this.modules.history.undo(); - } else { - return false; - } + key: "redraw", + value: function redraw(force) { + this.columnManager.redraw(force); + this.rowManager.redraw(force); } }, { - key: "redo", - value: function redo() { - if (this.options.history && this.modExists("history", true)) { - return this.modules.history.redo(); - } else { - return false; - } - } + key: "setHeight", + value: function setHeight(height) { + this.options.height = isNaN(height) ? height : height + "px"; + this.element.style.height = this.options.height; + this.rowManager.initializeRenderer(); + this.rowManager.redraw(); + } //////////////////// Event Bus /////////////////// + }, { - key: "getHistoryUndoSize", - value: function getHistoryUndoSize() { - if (this.options.history && this.modExists("history", true)) { - return this.modules.history.getHistoryUndoSize(); - } else { - return false; - } + key: "on", + value: function on(key, callback) { + this.externalEvents.subscribe(key, callback); } }, { - key: "getHistoryRedoSize", - value: function getHistoryRedoSize() { - if (this.options.history && this.modExists("history", true)) { - return this.modules.history.getHistoryRedoSize(); - } else { - return false; - } + key: "off", + value: function off(key, callback) { + this.externalEvents.unsubscribe(key, callback); } }, { - key: "clearHistory", - value: function clearHistory() { - if (this.options.history && this.modExists("history", true)) { - return this.modules.history.clear(); - } else { - return false; - } - } /////////////// Download Management ////////////// + key: "dispatchEvent", + value: function dispatchEvent() { + var _this$externalEvents; - }, { - key: "download", - value: function download(type, filename, options, active) { - if (this.modExists("download", true)) { - this.modules.download.download(type, filename, options, active); - } - } - }, { - key: "downloadToTab", - value: function downloadToTab(type, filename, options, active) { - if (this.modExists("download", true)) { - this.modules.download.download(type, filename, options, active, true); - } - } /////////// Inter Table Communications /////////// + var args = Array.from(arguments), + key = args.shift(); - }, { - key: "tableComms", - value: function tableComms(table, module, action, data) { - this.modules.comms.receive(table, module, action, data); + (_this$externalEvents = this.externalEvents).dispatch.apply(_this$externalEvents, arguments); } ////////////// Extension Management ////////////// }, { @@ -9619,6 +8534,17 @@ return false; } } + }, { + key: "module", + value: function module(key) { + var mod = this.modules[key]; + + if (!mod) { + console.error("Tabulator module not installed: " + key); + } + + return mod; + } }]); return Tabulator; @@ -9644,11 +8570,41 @@ _this = _super.call(this, table); _this.allowedTypes = ["", "data", "download", "clipboard", "print", "htmlOutput"]; //list of accessor types - return _this; - } //initialize column accessor + _this.registerColumnOption("accessor"); + _this.registerColumnOption("accessorParams"); + + _this.registerColumnOption("accessorData"); + + _this.registerColumnOption("accessorDataParams"); + + _this.registerColumnOption("accessorDownload"); + + _this.registerColumnOption("accessorDownloadParams"); + + _this.registerColumnOption("accessorClipboard"); + + _this.registerColumnOption("accessorClipboardParams"); + + _this.registerColumnOption("accessorPrint"); + + _this.registerColumnOption("accessorPrintParams"); + + _this.registerColumnOption("accessorHtmlOutput"); + + _this.registerColumnOption("accessorHtmlOutputParams"); + + return _this; + } _createClass(Accessor, [{ + key: "initialize", + value: function initialize() { + this.subscribe("column-layout", this.initializeColumn.bind(this)); + this.subscribe("row-data-retrieve", this.transformRow.bind(this)); + } //initialize column accessor + + }, { key: "initializeColumn", value: function initializeColumn(column) { var match = false, @@ -9703,7 +8659,7 @@ var key = "accessor" + (type.charAt(0).toUpperCase() + type.slice(1)), rowComponent = row.getComponent(); //clone data object with deep copy to isolate internal data from returned result - var data = Helpers.deepClone(row.data || {}); + var data = Helpers$1.deepClone(row.data || {}); this.table.columnManager.traverse(function (column) { var value, accessor, params, colCompnent; @@ -9736,12 +8692,43 @@ method: "GET" }; + function generateParamsList(data, prefix) { + var output = []; + prefix = prefix || ""; + + if (Array.isArray(data)) { + data.forEach(function (item, i) { + output = output.concat(generateParamsList(item, prefix ? prefix + "[" + i + "]" : i)); + }); + } else if (_typeof(data) === "object") { + for (var key in data) { + output = output.concat(generateParamsList(data[key], prefix ? prefix + "[" + key + "]" : key)); + } + } else { + output.push({ + key: prefix, + value: data + }); + } + + return output; + } + + function serializeParams(params) { + var output = generateParamsList(params), + encoded = []; + output.forEach(function (item) { + encoded.push(encodeURIComponent(item.key) + "=" + encodeURIComponent(item.value)); + }); + return encoded.join("&"); + } + function defaultURLGenerator (url, config, params) { if (url) { if (params && Object.keys(params).length) { if (!config.method || config.method.toLowerCase() == "get") { config.method = "get"; - url += (url.includes("?") ? "&" : "?") + this.modules.ajax.serializeParams(params); + url += (url.includes("?") ? "&" : "?") + serializeParams(params); } } } @@ -9873,17 +8860,30 @@ _this.urlGenerator = false; _this.params = false; //request parameters - _this.loaderElement = _this.createLoaderElement(); //loader message div + _this.loaderPromise = false; - _this.msgElement = _this.createMsgElement(); //message element + _this.registerTableOption("ajaxURL", false); //url for ajax loading - _this.loadingElement = false; - _this.errorElement = false; - _this.loaderPromise = false; - _this.progressiveLoad = false; - _this.loading = false; - _this.requestOrder = 0; //prevent requests comming out of sequence if overridden by another load request + _this.registerTableOption("ajaxURLGenerator", false); + + _this.registerTableOption("ajaxParams", {}); //params for ajax loading + + + _this.registerTableOption("ajaxConfig", "get"); //ajax request type + + + _this.registerTableOption("ajaxContentType", "form"); //ajax request type + + + _this.registerTableOption("ajaxRequestFunc", false); //promise function + + + _this.registerTableOption("ajaxRequesting", function () {}); + + _this.registerTableOption("ajaxResponse", false); + + _this.contentTypeFormatters = Ajax.contentTypeFormatters; return _this; } //initialize setup options @@ -9891,32 +8891,9 @@ _createClass(Ajax, [{ key: "initialize", value: function initialize() { - var template; - this.loaderElement.appendChild(this.msgElement); - - if (this.table.options.ajaxLoaderLoading) { - if (typeof this.table.options.ajaxLoaderLoading == "string") { - template = document.createElement('template'); - template.innerHTML = this.table.options.ajaxLoaderLoading.trim(); - this.loadingElement = template.content.firstChild; - } else { - this.loadingElement = this.table.options.ajaxLoaderLoading; - } - } - this.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise; this.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator; - if (this.table.options.ajaxLoaderError) { - if (typeof this.table.options.ajaxLoaderError == "string") { - template = document.createElement('template'); - template.innerHTML = this.table.options.ajaxLoaderError.trim(); - this.errorElement = template.content.firstChild; - } else { - this.errorElement = this.table.options.ajaxLoaderError; - } - } - if (this.table.options.ajaxParams) { this.setParams(this.table.options.ajaxParams); } @@ -9929,280 +8906,113 @@ this.setUrl(this.table.options.ajaxURL); } - if (this.table.options.ajaxProgressiveLoad) { - if (this.table.options.pagination) { - this.progressiveLoad = false; - console.error("Progressive Load Error - Pagination and progressive load cannot be used at the same time"); - } else { - if (this.table.modExists("page")) { - this.progressiveLoad = this.table.options.ajaxProgressiveLoad; - this.table.modules.page.initializeProgressive(this.progressiveLoad); - } else { - console.error("Pagination plugin is required for progressive ajax loading"); - } - } - } - } - }, { - key: "createLoaderElement", - value: function createLoaderElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-loader"); - return el; + this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this)); + this.subscribe("data-loading", this.requestDataCheck.bind(this)); + this.subscribe("data-load", this.requestData.bind(this)); } }, { - key: "createMsgElement", - value: function createMsgElement() { - var el = document.createElement("div"); - el.classList.add("tabulator-loader-msg"); - el.setAttribute("role", "alert"); - return el; - } //set ajax params - - }, { - key: "setParams", - value: function setParams(params, update) { - if (update) { - this.params = this.params || {}; - - for (var key in params) { - this.params[key] = params[key]; - } - } else { - this.params = params; - } + key: "requestDataCheck", + value: function requestDataCheck(data, params, config, silent) { + return !!(!data && this.url || typeof data === "string"); } }, { - key: "getParams", - value: function getParams() { - return this.params || {}; - } //load config object - - }, { - key: "setConfig", - value: function setConfig(config) { - this._loadDefaultConfig(); - - if (typeof config == "string") { - this.config.method = config; - } else { - for (var key in config) { - this.config[key] = config[key]; + key: "requestData", + value: function requestData(data, params, config, silent, previousData) { + if (this.requestDataCheck(data)) { + if (data) { + this.setUrl(data); } - } - } //create config object from default - - }, { - key: "_loadDefaultConfig", - value: function _loadDefaultConfig(force) { - if (!this.config || force) { - this.config = {}; //load base config from defaults - for (var key in Ajax.defaultConfig) { - this.config[key] = Ajax.defaultConfig[key]; + if (params) { + this.setParams(params, true); } - } - } //set request url - - }, { - key: "setUrl", - value: function setUrl(url) { - this.url = url; - } //get request url - - }, { - key: "getUrl", - value: function getUrl() { - return this.url; - } //lstandard loading function - - }, { - key: "loadData", - value: function loadData(inPosition, columnsChanged) { - if (this.progressiveLoad) { - return this._loadDataProgressive(); - } else { - return this._loadDataStandard(inPosition, columnsChanged); - } - } - }, { - key: "nextPage", - value: function nextPage(diff) { - var margin; - - if (!this.loading) { - margin = this.table.options.ajaxProgressiveLoadScrollMargin || this.table.rowManager.getElement().clientHeight * 2; - if (diff < margin) { - this.table.modules.page.nextPage().then(function () {})["catch"](function () {}); + if (config) { + this.setConfig(config); } - } - } - }, { - key: "blockActiveRequest", - value: function blockActiveRequest() { - this.requestOrder++; - } - }, { - key: "_loadDataProgressive", - value: function _loadDataProgressive() { - this.table.rowManager.setData([]); - return this.table.modules.page.setPage(1); - } - }, { - key: "_loadDataStandard", - value: function _loadDataStandard(inPosition, columnsChanged) { - var _this2 = this; - - return new Promise(function (resolve, reject) { - _this2.sendRequest(inPosition).then(function (data) { - _this2.table.rowManager.setData(data, inPosition, columnsChanged).then(function () { - resolve(); - })["catch"](function (e) { - reject(e); - }); - })["catch"](function (e) { - reject(e); - }); - }); - } - }, { - key: "generateParamsList", - value: function generateParamsList(data, prefix) { - var _this3 = this; - var output = []; - prefix = prefix || ""; - - if (Array.isArray(data)) { - data.forEach(function (item, i) { - output = output.concat(_this3.generateParamsList(item, prefix ? prefix + "[" + i + "]" : i)); - }); - } else if (_typeof(data) === "object") { - for (var key in data) { - output = output.concat(this.generateParamsList(data[key], prefix ? prefix + "[" + key + "]" : key)); - } + return this.sendRequest(); } else { - output.push({ - key: prefix, - value: data - }); + return previousData; } - - return output; - } - }, { - key: "serializeParams", - value: function serializeParams(params) { - var output = this.generateParamsList(params), - encoded = []; - output.forEach(function (item) { - encoded.push(encodeURIComponent(item.key) + "=" + encodeURIComponent(item.value)); - }); - return encoded.join("&"); - } //send ajax request + } //set ajax params }, { - key: "sendRequest", - value: function sendRequest(silent) { - var _this4 = this; - - var url = this.url, - requestNo; - this.requestOrder++; - requestNo = this.requestOrder; - - this._loadDefaultConfig(); - - return new Promise(function (resolve, reject) { - if (_this4.table.options.ajaxRequesting.call(_this4.table, _this4.url, _this4.params) !== false) { - _this4.loading = true; - - if (!silent) { - _this4.showLoader(); - } - - _this4.loaderPromise(url, _this4.config, _this4.params).then(function (data) { - if (requestNo === _this4.requestOrder) { - if (_this4.table.options.ajaxResponse) { - data = _this4.table.options.ajaxResponse.call(_this4.table, _this4.url, _this4.params, data); - } - - resolve(data); - - _this4.hideLoader(); - - _this4.loading = false; - } else { - console.warn("Ajax Response Blocked - An active ajax request was blocked by an attempt to change table data while the request was being made"); - } - })["catch"](function (error) { - console.error("Ajax Load Error: ", error); - - _this4.table.options.ajaxError.call(_this4.table, error); - - _this4.showError(); - - setTimeout(function () { - _this4.hideLoader(); - }, 3000); - _this4.loading = false; - reject(error); - }); - } else { - reject(); + key: "setParams", + value: function setParams(params, update) { + if (update) { + this.params = this.params || {}; + + for (var key in params) { + this.params[key] = params[key]; } - }); + } else { + this.params = params; + } } }, { - key: "showLoader", - value: function showLoader() { - var shouldLoad = typeof this.table.options.ajaxLoader === "function" ? this.table.options.ajaxLoader() : this.table.options.ajaxLoader; + key: "getParams", + value: function getParams() { + return this.params || {}; + } //load config object - if (shouldLoad) { - this.hideLoader(); + }, { + key: "setConfig", + value: function setConfig(config) { + this._loadDefaultConfig(); - while (this.msgElement.firstChild) { - this.msgElement.removeChild(this.msgElement.firstChild); + if (typeof config == "string") { + this.config.method = config; + } else { + for (var key in config) { + this.config[key] = config[key]; } + } + } //create config object from default - this.msgElement.classList.remove("tabulator-error"); - this.msgElement.classList.add("tabulator-loading"); + }, { + key: "_loadDefaultConfig", + value: function _loadDefaultConfig(force) { + if (!this.config || force) { + this.config = {}; //load base config from defaults - if (this.loadingElement) { - this.msgElement.appendChild(this.loadingElement); - } else { - this.msgElement.innerHTML = this.table.modules.localize.getText("ajax|loading"); + for (var key in Ajax.defaultConfig) { + this.config[key] = Ajax.defaultConfig[key]; } - - this.table.element.appendChild(this.loaderElement); } - } + } //set request url + }, { - key: "showError", - value: function showError() { - this.hideLoader(); + key: "setUrl", + value: function setUrl(url) { + this.url = url; + } //get request url - while (this.msgElement.firstChild) { - this.msgElement.removeChild(this.msgElement.firstChild); - } + }, { + key: "getUrl", + value: function getUrl() { + return this.url; + } //send ajax request - this.msgElement.classList.remove("tabulator-loading"); - this.msgElement.classList.add("tabulator-error"); + }, { + key: "sendRequest", + value: function sendRequest(silent) { + var _this2 = this; - if (this.errorElement) { - this.msgElement.appendChild(this.errorElement); - } else { - this.msgElement.innerHTML = this.table.modules.localize.getText("ajax|error"); - } + var url = this.url; - this.table.element.appendChild(this.loaderElement); - } - }, { - key: "hideLoader", - value: function hideLoader() { - if (this.loaderElement.parentNode) { - this.loaderElement.parentNode.removeChild(this.loaderElement); + this._loadDefaultConfig(); + + if (this.table.options.ajaxRequesting.call(this.table, this.url, this.params) !== false) { + return this.loaderPromise(url, this.config, this.params).then(function (data) { + if (_this2.table.options.ajaxResponse) { + data = _this2.table.options.ajaxResponse.call(_this2.table, _this2.url, _this2.params, data); + } + + return data; + }); + } else { + return Promise.reject(); } } }]); @@ -10318,6 +9128,31 @@ _this.rowRange = false; _this.blocked = true; //block copy actions not originating from this command + _this.registerTableOption("clipboard", false); //enable clipboard + + + _this.registerTableOption("clipboardCopyStyled", true); //formatted table data + + + _this.registerTableOption("clipboardCopyConfig", false); //clipboard config + + + _this.registerTableOption("clipboardCopyFormatter", false); //DEPRICATED - REMOVE in 5.0 + + + _this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only + + + _this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows + + + _this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table + + + _this.registerColumnOption("clipboard"); + + _this.registerColumnOption("titleClipboard"); + return _this; } @@ -10370,7 +9205,7 @@ } } - _this2.table.options.clipboardCopied.call(_this2.table, plain, html); + _this2.dispatchExternal("clipboardCopied", plain, html); _this2.reset(); } @@ -10385,6 +9220,7 @@ this.setPasteParser(this.table.options.clipboardPasteParser); this.setPasteAction(this.table.options.clipboardPasteAction); + this.registerTableFunction("copyToClipboard", this.copy.bind(this)); } }, { key: "reset", @@ -10518,9 +9354,9 @@ } rows = this.pasteAction.call(this, rowData); - this.table.options.clipboardPasted.call(this.table, data, rowData, rows); + this.dispatchExternal("clipboardPasted", data, rowData, rows); } else { - this.table.options.clipboardPasteError.call(this.table, data); + this.dispatchExternal("clipboardPasteError", data); } } } @@ -10582,6 +9418,15 @@ _classCallCheck(this, CalcComponent); this._row = row; + return new Proxy(this, { + get: function get(target, name, receiver) { + if (typeof target[name] !== "undefined") { + return target[name]; + } else { + return target._row.table.componentFunctionBinder.handle("row", target._row, name); + } + } + }); } _createClass(CalcComponent, [{ @@ -10726,7 +9571,23 @@ _this.topInitialized = false; _this.botInitialized = false; - _this.initialize(); + _this.registerTableOption("columnCalcs", true); + + _this.registerColumnOption("topCalc"); + + _this.registerColumnOption("topCalcParams"); + + _this.registerColumnOption("topCalcFormatter"); + + _this.registerColumnOption("topCalcFormatterParams"); + + _this.registerColumnOption("bottomCalc"); + + _this.registerColumnOption("bottomCalcParams"); + + _this.registerColumnOption("bottomCalcFormatter"); + + _this.registerColumnOption("bottomCalcFormatterParams"); return _this; } @@ -10744,14 +9605,79 @@ this.genColumn = new Column$1({ field: "value" }, this); - } //dummy functions to handle being mock column manager + this.subscribe("cell-value-changed", this.cellValueChanged.bind(this)); + this.subscribe("column-init", this.initializeColumnCheck.bind(this)); + this.subscribe("row-deleted", this.rowsUpdated.bind(this)); + this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this)); + this.subscribe("row-added", this.rowsUpdated.bind(this)); + this.subscribe("column-moved", this.recalcActiveRows.bind(this)); + this.subscribe("column-add", this.recalcActiveRows.bind(this)); + this.subscribe("data-refeshed", this.recalcActiveRows.bind(this)); + this.subscribe("table-redraw", this.tableRedraw.bind(this)); + this.registerTableFunction("getCalcResults", this.getResults.bind(this)); + this.registerTableFunction("recalc", this.userRecalc.bind(this)); + } + }, { + key: "tableRedraw", + value: function tableRedraw(force) { + this.recalc(this.table.rowManager.activeRows); + + if (force) { + this.redraw(); + } + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// }, { - key: "registerColumnField", - value: function registerColumnField() {} + key: "userRecalc", + value: function userRecalc() { + this.recalc(this.table.rowManager.activeRows); + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + + }, { + key: "rowsUpdated", + value: function rowsUpdated(row) { + if (this.table.options.groupBy) { + this.recalcRowGroup(this); + } else { + this.recalcActiveRows(); + } + } + }, { + key: "recalcActiveRows", + value: function recalcActiveRows() { + this.recalc(this.table.rowManager.activeRows); + } + }, { + key: "cellValueChanged", + value: function cellValueChanged(cell) { + if (cell.column.definition.topCalc || cell.column.definition.bottomCalc) { + if (this.table.options.groupBy) { + if (this.table.options.columnCalcs == "table" || this.table.options.columnCalcs == "both") { + this.recalcActiveRows(); + } + + if (this.table.options.columnCalcs != "table") { + this.recalcRowGroup(cell.row); + } + } else { + this.recalcActiveRows(); + } + } + } + }, { + key: "initializeColumnCheck", + value: function initializeColumnCheck(column) { + if (column.definition.topCalc || column.definition.bottomCalc) { + this.initializeColumn(column); + } + } //initialize column calcs + }, { key: "initializeColumn", - //initialize column calcs value: function initializeColumn(column) { var def = column.definition; var config = { @@ -10810,7 +9736,11 @@ } } } - } + } //dummy functions to handle being mock column manager + + }, { + key: "registerColumnField", + value: function registerColumnField() {} }, { key: "removeCalcs", value: function removeCalcs() { @@ -10914,7 +9844,7 @@ if (this.topCalcs.length || this.botCalcs.length) { if (this.table.options.columnCalcs !== "group") { - this.recalc(this.table.rowManager.activeRows); + this.recalcActiveRows(); } if (this.table.options.groupBy && this.table.options.columnCalcs !== "table") { @@ -11002,11 +9932,11 @@ row.component = false; row.getComponent = function () { - if (!_this4.component) { - _this4.component = new CalcComponent(_this4); + if (!row.component) { + row.component = new CalcComponent(_this4); } - return _this4.component; + return row.component; }; row.generateCells = function () { @@ -11045,7 +9975,7 @@ } }); - _this4.cells = cells; + row.cells = cells; }; return row; @@ -11169,82 +10099,168 @@ _this.startOpen = function () {}; _this.displayIndex = 0; + + _this.registerTableOption("dataTree", false); //enable data tree + + + _this.registerTableOption("dataTreeFilter", true); //filter child rows + + + _this.registerTableOption("dataTreeSort", true); //sort child rows + + + _this.registerTableOption("dataTreeElementColumn", false); + + _this.registerTableOption("dataTreeBranchElement", true); //show data tree branch element + + + _this.registerTableOption("dataTreeChildIndent", 9); //data tree child indent in px + + + _this.registerTableOption("dataTreeChildField", "_children"); //data tre column field to look for child rows + + + _this.registerTableOption("dataTreeCollapseElement", false); //data tree row collapse element + + + _this.registerTableOption("dataTreeExpandElement", false); //data tree row expand element + + + _this.registerTableOption("dataTreeStartExpanded", false); + + _this.registerTableOption("dataTreeChildColumnCalcs", false); //include visible data tree rows in column calculations + + + _this.registerTableOption("dataTreeSelectPropagate", false); //seleccting a parent row selects its children + //register component functions + + + _this.registerComponentFunction("row", "treeCollapse", _this.collapseRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "treeExpand", _this.expandRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "treeToggle", _this.toggleRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "getTreeParent", _this.getTreeParent.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "getTreeChildren", _this.getRowChildren.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "addTreeChild", _this.addTreeChildRow.bind(_assertThisInitialized(_this))); + return _this; } _createClass(DataTree, [{ key: "initialize", value: function initialize() { - var dummyEl = null, - firstCol = this.table.columnManager.getFirstVisibileColumn(), - options = this.table.options; - this.field = options.dataTreeChildField; - this.indent = options.dataTreeChildIndent; - this.elementField = options.dataTreeElementColumn || (firstCol ? firstCol.field : false); - - if (options.dataTreeBranchElement) { - if (options.dataTreeBranchElement === true) { - this.branchEl = document.createElement("div"); - this.branchEl.classList.add("tabulator-data-tree-branch"); - } else { - if (typeof options.dataTreeBranchElement === "string") { - dummyEl = document.createElement("div"); - dummyEl.innerHTML = options.dataTreeBranchElement; - this.branchEl = dummyEl.firstChild; + if (this.table.options.dataTree) { + var dummyEl = null, + firstCol = this.table.columnManager.getFirstVisibileColumn(), + options = this.table.options; + this.field = options.dataTreeChildField; + this.indent = options.dataTreeChildIndent; + this.elementField = options.dataTreeElementColumn || (firstCol ? firstCol.field : false); + + if (options.dataTreeBranchElement) { + if (options.dataTreeBranchElement === true) { + this.branchEl = document.createElement("div"); + this.branchEl.classList.add("tabulator-data-tree-branch"); } else { - this.branchEl = options.dataTreeBranchElement; + if (typeof options.dataTreeBranchElement === "string") { + dummyEl = document.createElement("div"); + dummyEl.innerHTML = options.dataTreeBranchElement; + this.branchEl = dummyEl.firstChild; + } else { + this.branchEl = options.dataTreeBranchElement; + } } } - } - if (options.dataTreeCollapseElement) { - if (typeof options.dataTreeCollapseElement === "string") { - dummyEl = document.createElement("div"); - dummyEl.innerHTML = options.dataTreeCollapseElement; - this.collapseEl = dummyEl.firstChild; + if (options.dataTreeCollapseElement) { + if (typeof options.dataTreeCollapseElement === "string") { + dummyEl = document.createElement("div"); + dummyEl.innerHTML = options.dataTreeCollapseElement; + this.collapseEl = dummyEl.firstChild; + } else { + this.collapseEl = options.dataTreeCollapseElement; + } } else { - this.collapseEl = options.dataTreeCollapseElement; + this.collapseEl = document.createElement("div"); + this.collapseEl.classList.add("tabulator-data-tree-control"); + this.collapseEl.tabIndex = 0; + this.collapseEl.innerHTML = ""; } - } else { - this.collapseEl = document.createElement("div"); - this.collapseEl.classList.add("tabulator-data-tree-control"); - this.collapseEl.tabIndex = 0; - this.collapseEl.innerHTML = ""; - } - if (options.dataTreeExpandElement) { - if (typeof options.dataTreeExpandElement === "string") { - dummyEl = document.createElement("div"); - dummyEl.innerHTML = options.dataTreeExpandElement; - this.expandEl = dummyEl.firstChild; + if (options.dataTreeExpandElement) { + if (typeof options.dataTreeExpandElement === "string") { + dummyEl = document.createElement("div"); + dummyEl.innerHTML = options.dataTreeExpandElement; + this.expandEl = dummyEl.firstChild; + } else { + this.expandEl = options.dataTreeExpandElement; + } } else { - this.expandEl = options.dataTreeExpandElement; + this.expandEl = document.createElement("div"); + this.expandEl.classList.add("tabulator-data-tree-control"); + this.expandEl.tabIndex = 0; + this.expandEl.innerHTML = ""; } - } else { - this.expandEl = document.createElement("div"); - this.expandEl.classList.add("tabulator-data-tree-control"); - this.expandEl.tabIndex = 0; - this.expandEl.innerHTML = ""; - } - switch (_typeof(options.dataTreeStartExpanded)) { - case "boolean": - this.startOpen = function (row, index) { - return options.dataTreeStartExpanded; - }; + switch (_typeof(options.dataTreeStartExpanded)) { + case "boolean": + this.startOpen = function (row, index) { + return options.dataTreeStartExpanded; + }; - break; + break; - case "function": - this.startOpen = options.dataTreeStartExpanded; - break; + case "function": + this.startOpen = options.dataTreeStartExpanded; + break; - default: - this.startOpen = function (row, index) { - return options.dataTreeStartExpanded[index]; - }; + default: + this.startOpen = function (row, index) { + return options.dataTreeStartExpanded[index]; + }; - break; + break; + } + + this.subscribe("row-init", this.initializeRow.bind(this)); + this.subscribe("row-layout", this.layoutRow.bind(this)); + this.subscribe("row-relayout", this.layoutRow.bind(this)); + this.subscribe("row-deleted", this.rowDelete.bind(this), 0); + this.subscribe("row-data-changed", this.rowDataChanged.bind(this), 10); + this.subscribe("column-moving-rows", this.columnMoving.bind(this)); + this.registerDisplayHandler(this.getRows.bind(this), 30); + } + } + }, { + key: "getRowChildren", + value: function getRowChildren(row) { + return this.getTreeChildren(row, true); + } + }, { + key: "columnMoving", + value: function columnMoving() { + var _this2 = this; + + var rows = []; + this.table.rowManager.rows.forEach(function (row) { + rows = rows.concat(_this2.getTreeChildren(row, false, true)); + }); + return rows; + } + }, { + key: "rowDataChanged", + value: function rowDataChanged(row, visible, updatedData) { + if (this.redrawNeeded(updatedData)) { + this.initializeRow(row); + + if (visible) { + this.layoutRow(row); + this.refreshData(true); + } } } }, { @@ -11271,6 +10287,14 @@ children: children }; } + }, { + key: "reinitializeRowChildren", + value: function reinitializeRowChildren(row) { + var children = this.getTreeChildren(row, false, true); + children.forEach(function (child) { + child.reinitialize(true); + }); + } }, { key: "layoutRow", value: function layoutRow(row) { @@ -11319,7 +10343,7 @@ }, { key: "generateControlElement", value: function generateControlElement(row, el) { - var _this2 = this; + var _this3 = this; var config = row.modules.dataTree, el = el || row.getCells()[0].getElement(), @@ -11331,14 +10355,14 @@ config.controlEl.addEventListener("click", function (e) { e.stopPropagation(); - _this2.collapseRow(row); + _this3.collapseRow(row); }); } else { config.controlEl = this.expandEl.cloneNode(true); config.controlEl.addEventListener("click", function (e) { e.stopPropagation(); - _this2.expandRow(row); + _this3.expandRow(row); }); } @@ -11366,7 +10390,7 @@ }, { key: "getRows", value: function getRows(rows) { - var _this3 = this; + var _this4 = this; var output = []; rows.forEach(function (row, i) { @@ -11378,7 +10402,7 @@ config = row.modules.dataTree.children; if (!config.index && config.children !== false) { - children = _this3.getChildren(row); + children = _this4.getChildren(row); children.forEach(function (child) { child.create(); output.push(child); @@ -11391,7 +10415,7 @@ }, { key: "getChildren", value: function getChildren(row, allChildren) { - var _this4 = this; + var _this5 = this; var config = row.modules.dataTree, children = [], @@ -11415,7 +10439,7 @@ children.forEach(function (child) { output.push(child); - var subChildren = _this4.getChildren(child); + var subChildren = _this5.getChildren(child); subChildren.forEach(function (sub) { output.push(sub); @@ -11428,7 +10452,7 @@ }, { key: "generateChildren", value: function generateChildren(row) { - var _this5 = this; + var _this6 = this; var children = []; var childArray = row.getData()[this.field]; @@ -11438,13 +10462,13 @@ } childArray.forEach(function (childData) { - var childRow = new Row$1(childData || {}, _this5.table.rowManager); + var childRow = new Row$1(childData || {}, _this6.table.rowManager); childRow.create(); childRow.modules.dataTree.index = row.modules.dataTree.index + 1; childRow.modules.dataTree.parent = row; if (childRow.modules.dataTree.children) { - childRow.modules.dataTree.open = _this5.startOpen(childRow.getComponent(), childRow.modules.dataTree.index); + childRow.modules.dataTree.open = _this6.startOpen(childRow.getComponent(), childRow.modules.dataTree.index); } children.push(childRow); @@ -11459,8 +10483,8 @@ if (config.children !== false) { config.open = true; row.reinitialize(); - this.table.rowManager.refreshActiveData("tree", false, true); - this.table.options.dataTreeRowExpanded(row.getComponent(), row.modules.dataTree.index); + this.refreshData(true); + this.dispatchExternal("dataTreeRowExpanded", row.getComponent(), row.modules.dataTree.index); } } }, { @@ -11471,8 +10495,8 @@ if (config.children !== false) { config.open = false; row.reinitialize(); - this.table.rowManager.refreshActiveData("tree", false, true); - this.table.options.dataTreeRowCollapsed(row.getComponent(), row.modules.dataTree.index); + this.refreshData(true); + this.dispatchExternal("dataTreeRowCollapsed", getComponent(), row.modules.dataTree.index); } } }, { @@ -11541,7 +10565,7 @@ this.layoutRow(parent); } - this.table.rowManager.refreshActiveData("tree", false, true); + this.refreshData(true); } }, { key: "addTreeChildRow", @@ -11575,12 +10599,12 @@ this.initializeRow(row); this.layoutRow(row); - this.table.rowManager.refreshActiveData("tree", false, true); + this.refreshData(true); } }, { key: "findChildIndex", value: function findChildIndex(subject, parent) { - var _this6 = this; + var _this7 = this; var match = false; @@ -11607,7 +10631,7 @@ } else { //subject should be treated as the index of the row match = parent.data[this.field].find(function (row) { - return row.data[_this6.table.options.index] == subject; + return row.data[_this7.table.options.index] == subject; }); } @@ -11627,7 +10651,7 @@ }, { key: "getTreeChildren", value: function getTreeChildren(row, component, recurse) { - var _this7 = this; + var _this8 = this; var config = row.modules.dataTree, output = []; @@ -11642,7 +10666,7 @@ output.push(component ? childRow.getComponent() : childRow); if (recurse) { - output = output.concat(_this7.getTreeChildren(childRow, component, recurse)); + output = output.concat(_this8.getTreeChildren(childRow, component, recurse)); } } }); @@ -11880,7 +10904,8 @@ var self = this, sheetName = options.sheetName || "Sheet1", workbook = XLSX.utils.book_new(), - output; + tableFeatures = new CoreFeature(this); + output; workbook.SheetNames = []; workbook.Sheets = {}; @@ -11948,7 +10973,7 @@ workbook.Sheets[sheet] = generateSheet(); } else { workbook.SheetNames.push(sheet); - this.modules.comms.send(options.sheets[sheet], "download", "intercept", { + tableFeatures.commsSend(options.sheets[sheet], "download", "intercept", { type: "xlsx", options: { sheetOnly: true @@ -12009,13 +11034,49 @@ var _super = _createSuper(Download); function Download(table) { + var _this; + _classCallCheck(this, Download); - return _super.call(this, table); - } //trigger file download + _this = _super.call(this, table); + + _this.registerTableOption("downloadReady", function (data, blob) { + return blob; + }); //function to manipulate download data + + + _this.registerTableOption("downloadConfig", {}); //download config + + + _this.registerTableOption("downloadRowRange", "active"); //restrict download to active rows only + + + _this.registerColumnOption("download"); + + _this.registerColumnOption("titleDownload"); + + return _this; + } + + _createClass(Download, [{ + key: "initialize", + value: function initialize() { + this.registerTableFunction("download", this.download.bind(this)); + this.registerTableFunction("downloadToTab", this.downloadToTab.bind(this)); + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + }, { + key: "downloadToTab", + value: function downloadToTab(type, filename, options, active) { + this.download(type, filename, options, active, true); + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + //trigger file download - _createClass(Download, [{ + }, { key: "download", value: function download(type, filename, options, range, interceptCallback) { var downloadFunc = false; @@ -12079,7 +11140,7 @@ type: mime }), filename = filename || "Tabulator." + (typeof type === "function" ? "txt" : type); - blob = this.table.options.downloadReady.call(this.table, data, blob); + blob = this.table.options.downloadReady(data, blob); if (blob) { if (newTab) { @@ -12100,9 +11161,7 @@ } } - if (this.table.options.downloadComplete) { - this.table.options.downloadComplete(); - } + this.dispatchExternal("downloadComplete"); } } }, { @@ -12123,7 +11182,83 @@ Download.downloaders = defaultDownloaders; - //input element + function maskInput(el, options) { + var mask = options.mask, + maskLetter = typeof options.maskLetterChar !== "undefined" ? options.maskLetterChar : "A", + maskNumber = typeof options.maskNumberChar !== "undefined" ? options.maskNumberChar : "9", + maskWildcard = typeof options.maskWildcardChar !== "undefined" ? options.maskWildcardChar : "*"; + + function fillSymbols(index) { + var symbol = mask[index]; + + if (typeof symbol !== "undefined" && symbol !== maskWildcard && symbol !== maskLetter && symbol !== maskNumber) { + el.value = el.value + "" + symbol; + fillSymbols(index + 1); + } + } + + el.addEventListener("keydown", function (e) { + var index = el.value.length, + _char = e.key; + + if (e.keyCode > 46) { + if (index >= mask.length) { + e.preventDefault(); + e.stopPropagation(); + return false; + } else { + switch (mask[index]) { + case maskLetter: + if (_char.toUpperCase() == _char.toLowerCase()) { + e.preventDefault(); + e.stopPropagation(); + return false; + } + + break; + + case maskNumber: + if (isNaN(_char)) { + e.preventDefault(); + e.stopPropagation(); + return false; + } + + break; + + case maskWildcard: + break; + + default: + if (_char !== mask[index]) { + e.preventDefault(); + e.stopPropagation(); + return false; + } + + } + } + } + + return; + }); + el.addEventListener("keyup", function (e) { + if (e.keyCode > 46) { + if (options.maskAutoFill) { + fillSymbols(el.value.length); + } + } + }); + + if (!el.placeholder) { + el.placeholder = mask; + } + + if (options.maskAutoFill) { + fillSymbols(el.value.length); + } + } + function input (cell, onRendered, success, cancel, editorParams) { //create and style input var cellValue = cell.getValue(), @@ -12185,13 +11320,12 @@ }); if (editorParams.mask) { - this.table.modules.edit.maskInput(input, editorParams); + maskInput(input, editorParams); } return input; } - //resizable text area element function textarea (cell, onRendered, success, cancel, editorParams) { var cellValue = cell.getValue(), vertNav = editorParams.verticalNavigation || "hybrid", @@ -12289,13 +11423,12 @@ }); if (editorParams.mask) { - this.table.modules.edit.maskInput(input, editorParams); + maskInput(input, editorParams); } return input; } - //input element with type of number function number (cell, onRendered, success, cancel, editorParams) { var cellValue = cell.getValue(), vertNav = editorParams.verticalNavigation || "editor", @@ -12394,7 +11527,7 @@ }); if (editorParams.mask) { - this.table.modules.edit.maskInput(input, editorParams); + maskInput(input, editorParams); } return input; @@ -12845,7 +11978,7 @@ parseItems(editorParams.values || [], initialDisplayValue); } - var offset = Helpers.elOffset(cellEl); + var offset = Helpers$1.elOffset(cellEl); listEl.style.minWidth = cellEl.offsetWidth + "px"; listEl.style.top = offset.top + cellEl.offsetHeight + "px"; listEl.style.left = offset.left + "px"; @@ -13297,13 +12430,11 @@ function showList() { if (!listEl.parentNode) { - console.log("show", initialDisplayValue); - while (listEl.firstChild) { listEl.removeChild(listEl.firstChild); } - var offset = Helpers.elOffset(cellEl); + var offset = Helpers$1.elOffset(cellEl); listEl.style.minWidth = cellEl.offsetWidth + "px"; listEl.style.top = offset.top + cellEl.offsetHeight + "px"; listEl.style.left = offset.left + "px"; @@ -13462,7 +12593,7 @@ }); if (editorParams.mask) { - this.table.modules.edit.maskInput(input, editorParams); + maskInput(input, editorParams); } setTimeout(function () { @@ -13824,30 +12955,397 @@ tickCross: tickCross }; - var Edit = /*#__PURE__*/function (_Module) { - _inherits(Edit, _Module); + var Edit = /*#__PURE__*/function (_Module) { + _inherits(Edit, _Module); + + var _super = _createSuper(Edit); + + function Edit(table) { + var _this; + + _classCallCheck(this, Edit); + + _this = _super.call(this, table); + _this.currentCell = false; //hold currently editing cell + + _this.mouseClick = false; //hold mousedown state to prevent click binding being overriden by editor opening + + _this.recursionBlock = false; //prevent focus recursion + + _this.invalidEdit = false; + _this.editedCells = []; + _this.editors = Edit.editors; + + _this.registerColumnOption("editable"); + + _this.registerColumnOption("editor"); + + _this.registerColumnOption("editorParams"); + + _this.registerColumnOption("cellEditing"); + + _this.registerColumnOption("cellEdited"); + + _this.registerColumnOption("cellEditCancelled"); + + _this.registerTableFunction("getEditedCells", _this.getEditedCells.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("clearCellEdited", _this.clearCellEdited.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigatePrev", _this.navigatePrev.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigateNext", _this.navigateNext.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigateLeft", _this.navigateLeft.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigateRight", _this.navigateRight.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigateUp", _this.navigateUp.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("navigateDown", _this.navigateDown.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "isEdited", _this.cellisEdited.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "clearEdited", _this.clearEdited.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "edit", _this.editCell.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "cancelEdit", _this.cellCancelEdit.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigatePrev", _this.navigatePrev.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigateNext", _this.navigateNext.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigateLeft", _this.navigateLeft.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigateRight", _this.navigateRight.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigateUp", _this.navigateUp.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "navigateDown", _this.navigateDown.bind(_assertThisInitialized(_this))); + + return _this; + } + + _createClass(Edit, [{ + key: "initialize", + value: function initialize() { + this.subscribe("cell-init", this.bindEditor.bind(this)); + this.subscribe("cell-delete", this.clearEdited.bind(this)); + this.subscribe("column-layout", this.initializeColumnCheck.bind(this)); + this.subscribe("column-delete", this.columnDeleteCheck.bind(this)); + this.subscribe("row-deleting", this.rowDeleteCheck.bind(this)); + this.subscribe("data-refeshing", this.cancelEdit.bind(this)); + this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this)); + this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this)); + this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this)); + this.subscribe("keybinding-nav-right", this.navigateRight.bind(this)); + this.subscribe("keybinding-nav-up", this.navigateUp.bind(this)); + this.subscribe("keybinding-nav-down", this.navigateDown.bind(this)); + } /////////////////////////////////// + ////// Keybinding Functions /////// + /////////////////////////////////// + + }, { + key: "keybindingNavigateNext", + value: function keybindingNavigateNext(e) { + var cell = this.currentCell, + newRow = this.options("tabEndNewRow"); + + if (cell) { + if (!this.navigateNext(e)) { + if (newRow) { + cell.getElement().firstChild.blur(); + + if (newRow === true) { + newRow = this.table.addRow({}); + } else { + if (typeof newRow == "function") { + newRow = this.table.addRow(newRow(cell.row.getComponent())); + } else { + newRow = this.table.addRow(Object.assign({}, newRow)); + } + } + + newRow.then(function () { + setTimeout(function () { + nav.next(); + }); + }); + } + } + } + } /////////////////////////////////// + ///////// Cell Functions ////////// + /////////////////////////////////// + + }, { + key: "cellisEdited", + value: function cellisEdited(cell) { + return !!cell.modules.edit && cell.modules.edit.edited; + } + }, { + key: "cellCancelEdit", + value: function cellCancelEdit(cell) { + if (cell === this.currentCell) { + this.table.modules.edit.cancelEdit(); + } else { + console.warn("Cancel Editor Error - This cell is not currently being edited "); + } + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "clearCellEdited", + value: function clearCellEdited(cells) { + var _this2 = this; + + if (!cells) { + cells = this.modules.edit.getEditedCells(); + } + + if (!Array.isArray(cells)) { + cells = [cells]; + } + + cells.forEach(function (cell) { + _this2.modules.edit.clearEdited(cell._getSelf()); + }); + } + }, { + key: "navigatePrev", + value: function navigatePrev(e) { + var cell = this.currentCell, + nextCell, + prevRow; + + if (cell) { + if (e) { + e.preventDefault(); + } + + nextCell = this.navigateLeft(); + + if (nextCell) { + return true; + } else { + prevRow = this.table.rowManager.prevDisplayRow(cell.row, true); + + if (prevRow) { + nextCell = this.findNextEditableCell(prevRow, prevRow.cells.length); + + if (nextCell) { + nextCell.edit(); + return true; + } + } + } + } + + return false; + } + }, { + key: "navigateNext", + value: function navigateNext(e) { + var cell = this.currentCell, + nextCell, + nextRow; + + if (cell) { + if (e) { + e.preventDefault(); + } + + nextCell = this.navigateRight(); + + if (nextCell) { + return true; + } else { + nextRow = this.table.rowManager.nextDisplayRow(cell.row, true); + + if (nextRow) { + nextCell = this.findNextEditableCell(nextRow, -1); + + if (nextCell) { + nextCell.edit(); + return true; + } + } + } + } + + return false; + } + }, { + key: "navigateLeft", + value: function navigateLeft(e) { + var cell = this.currentCell, + index, + nextCell; + + if (cell) { + if (e) { + e.preventDefault(); + } + + index = cell.getIndex(); + nextCell = this.findPrevEditableCell(cell.row, index); + + if (nextCell) { + nextCell.edit(); + return true; + } + } + + return false; + } + }, { + key: "navigateRight", + value: function navigateRight(e) { + var cell = this.currentCell, + index, + nextCell; + + if (cell) { + if (e) { + e.preventDefault(); + } + + index = cell.getIndex(); + nextCell = this.findNextEditableCell(cell.row, index); + + if (nextCell) { + nextCell.edit(); + return true; + } + } + + return false; + } + }, { + key: "navigateUp", + value: function navigateUp(e) { + var cell = this.currentCell, + index, + nextRow; + + if (cell) { + if (e) { + e.preventDefault(); + } + + index = cell.getIndex(); + nextRow = this.table.rowManager.prevDisplayRow(cell.row, true); + + if (nextRow) { + nextRow.cells[index].edit(); + return true; + } + } + + return false; + } + }, { + key: "navigateDown", + value: function navigateDown(e) { + var cell = this.currentCell, + index, + nextRow; + + if (cell) { + if (e) { + e.preventDefault(); + } + + index = cell.getIndex(); + nextRow = this.table.rowManager.nextDisplayRow(cell.row, true); + + if (nextRow) { + nextRow.cells[index].edit(); + return true; + } + } + + return false; + } + }, { + key: "findNextEditableCell", + value: function findNextEditableCell(row, index) { + var nextCell = false; + + if (index < row.cells.length - 1) { + for (var i = index + 1; i < row.cells.length; i++) { + var cell = row.cells[i]; - var _super = _createSuper(Edit); + if (cell.column.modules.edit && Helpers.elVisible(cell.getElement())) { + var allowEdit = true; - function Edit(table) { - var _this; + if (typeof cell.column.modules.edit.check == "function") { + allowEdit = cell.column.modules.edit.check(cell.getComponent()); + } - _classCallCheck(this, Edit); + if (allowEdit) { + nextCell = cell; + break; + } + } + } + } - _this = _super.call(this, table); - _this.currentCell = false; //hold currently editing cell + return nextCell; + } + }, { + key: "findPrevEditableCell", + value: function findPrevEditableCell(row, index) { + var prevCell = false; - _this.mouseClick = false; //hold mousedown state to prevent click binding being overriden by editor opening + if (index > 0) { + for (var i = index - 1; i >= 0; i--) { + var cell = row.cells[i], + allowEdit = true; - _this.recursionBlock = false; //prevent focus recursion + if (cell.column.modules.edit && Helpers.elVisible(cell.getElement())) { + if (typeof cell.column.modules.edit.check == "function") { + allowEdit = cell.column.modules.edit.check(cell.getComponent()); + } - _this.invalidEdit = false; - _this.editedCells = []; - return _this; - } //initialize column editor + if (allowEdit) { + prevCell = cell; + break; + } + } + } + } + return prevCell; + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// - _createClass(Edit, [{ + }, { + key: "initializeColumnCheck", + value: function initializeColumnCheck(column) { + if (typeof column.definition.editor !== "undefined") { + this.initializeColumn(column); + } + } + }, { + key: "columnDeleteCheck", + value: function columnDeleteCheck(column) { + if (this.currentCell && this.currentCell.column === column) { + this.cancelEdit(); + } + } + }, { + key: "rowDeleteCheck", + value: function rowDeleteCheck(row) { + if (this.currentCell && this.currentCell.row === row) { + this.cancelEdit(); + } + } //initialize column editor + + }, { key: "initializeColumn", value: function initializeColumn(column) { var config = { @@ -13859,8 +13357,8 @@ switch (_typeof(column.definition.editor)) { case "string": - if (Edit.editors[column.definition.editor]) { - config.editor = Edit.editors[column.definition.editor]; + if (this.editors[column.definition.editor]) { + config.editor = this.editors[column.definition.editor]; } else { console.warn("Editor Error - No such editor found: ", column.definition.editor); } @@ -13874,10 +13372,10 @@ case "boolean": if (column.definition.editor === true) { if (typeof column.definition.formatter !== "function") { - if (Edit.editors[column.definition.formatter]) { - config.editor = Edit.editors[column.definition.formatter]; + if (this.editors[column.definition.formatter]) { + config.editor = this.editors[column.definition.formatter]; } else { - config.editor = Edit.editors["input"]; + config.editor = this.editors["input"]; } } else { console.warn("Editor Error - Cannot auto lookup editor for a custom formatter: ", column.definition.formatter); @@ -13936,39 +13434,41 @@ cell.row.normalizeHeight(true); } - if (cell.column.cellEvents.cellEditCancelled) { - cell.column.cellEvents.cellEditCancelled.call(this.table, component); + if (cell.column.definition.cellEditCancelled) { + cell.column.definition.cellEditCancelled.call(this.table, component); } - this.table.options.cellEditCancelled.call(this.table, component); + this.dispatchExternal("cellEditCancelled", component); } } //return a formatted value for a cell }, { key: "bindEditor", value: function bindEditor(cell) { - var self = this, - element = cell.getElement(true); - element.setAttribute("tabindex", 0); - element.addEventListener("click", function (e) { - if (!element.classList.contains("tabulator-editing")) { - element.focus({ - preventScroll: true - }); - } - }); - element.addEventListener("mousedown", function (e) { - if (e.button === 2) { - e.preventDefault(); - } else { - self.mouseClick = true; - } - }); - element.addEventListener("focus", function (e) { - if (!self.recursionBlock) { - self.edit(cell, e, false); - } - }); + if (cell.column.modules.edit) { + var self = this, + element = cell.getElement(true); + element.setAttribute("tabindex", 0); + element.addEventListener("click", function (e) { + if (!element.classList.contains("tabulator-editing")) { + element.focus({ + preventScroll: true + }); + } + }); + element.addEventListener("mousedown", function (e) { + if (e.button === 2) { + e.preventDefault(); + } else { + self.mouseClick = true; + } + }); + element.addEventListener("focus", function (e) { + if (!self.recursionBlock) { + self.edit(cell, e, false); + } + }); + } } }, { key: "focusCellNoEvent", @@ -14016,9 +13516,9 @@ rightEdge -= parseInt(this.table.modules.frozenColumns.rightMargin); } - if (this.table.options.virtualDomHoz) { - leftEdge -= parseInt(this.table.vdomHoz.vDomPadLeft); - rightEdge -= parseInt(this.table.vdomHoz.vDomPadLeft); + if (this.table.options.renderHorizontal === "virtual") { + leftEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft); + rightEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft); } if (cellEl.offsetLeft < leftEdge) { @@ -14080,7 +13580,7 @@ if (valid !== true) { element.classList.add("tabulator-validation-fail"); - self.table.options.validationFailed.call(self.table, cell.getComponent(), value, valid); + self.table.externalEvents.dispatch("validationFailed", cell.getComponent(), value, valid); return false; } @@ -14090,7 +13590,7 @@ element.classList.add("tabulator-validation-fail"); self.focusCellNoEvent(cell, true); rendered(); - self.table.options.validationFailed.call(self.table, cell.getComponent(), value, valid); + self.table.externalEvents.dispatch("validationFailed", cell.getComponent(), value, valid); return false; } } @@ -14135,16 +13635,16 @@ if (this.mouseClick) { this.mouseClick = false; - if (cell.column.cellEvents.cellClick) { - cell.column.cellEvents.cellClick.call(this.table, e, component); + if (cell.column.definition.cellClick) { + cell.column.definition.cellClick.call(this.table, e, component); } } - if (cell.column.cellEvents.cellEditing) { - cell.column.cellEvents.cellEditing.call(this.table, component); + if (cell.column.definition.cellEditing) { + cell.column.definition.cellEditing.call(this.table, component); } - self.table.options.cellEditing.call(this.table, component); + this.dispatchExternal("cellEditing", component); params = typeof cell.column.modules.edit.params === "function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params; cellEditor = cell.column.modules.edit.editor.call(self, component, onRendered, success, cancel, params); //if editor returned, add to DOM, if false, abort edit @@ -14190,84 +13690,6 @@ return false; } } - }, { - key: "maskInput", - value: function maskInput(el, options) { - var mask = options.mask, - maskLetter = typeof options.maskLetterChar !== "undefined" ? options.maskLetterChar : "A", - maskNumber = typeof options.maskNumberChar !== "undefined" ? options.maskNumberChar : "9", - maskWildcard = typeof options.maskWildcardChar !== "undefined" ? options.maskWildcardChar : "*"; - - function fillSymbols(index) { - var symbol = mask[index]; - - if (typeof symbol !== "undefined" && symbol !== maskWildcard && symbol !== maskLetter && symbol !== maskNumber) { - el.value = el.value + "" + symbol; - fillSymbols(index + 1); - } - } - - el.addEventListener("keydown", function (e) { - var index = el.value.length, - _char = e.key; - - if (e.keyCode > 46) { - if (index >= mask.length) { - e.preventDefault(); - e.stopPropagation(); - return false; - } else { - switch (mask[index]) { - case maskLetter: - if (_char.toUpperCase() == _char.toLowerCase()) { - e.preventDefault(); - e.stopPropagation(); - return false; - } - - break; - - case maskNumber: - if (isNaN(_char)) { - e.preventDefault(); - e.stopPropagation(); - return false; - } - - break; - - case maskWildcard: - break; - - default: - if (_char !== mask[index]) { - e.preventDefault(); - e.stopPropagation(); - return false; - } - - } - } - } - - return; - }); - el.addEventListener("keyup", function (e) { - if (e.keyCode > 46) { - if (options.maskAutoFill) { - fillSymbols(el.value.length); - } - } - }); - - if (!el.placeholder) { - el.placeholder = mask; - } - - if (options.maskAutoFill) { - fillSymbols(el.value.length); - } - } }, { key: "getEditedCells", value: function getEditedCells() { @@ -14338,10 +13760,29 @@ _this.config = {}; _this.cloneTableStyle = true; _this.colVisProp = ""; + + _this.registerTableOption("htmlOutputConfig", false); //html outypu config + + + _this.registerColumnOption("htmlOutput"); + + _this.registerColumnOption("titleHtmlOutput"); + return _this; } _createClass(Export, [{ + key: "initialize", + value: function initialize() { + this.registerTableFunction("getHtml", this.getHtml.bind(this)); + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + + }, { key: "generateExportList", value: function generateExportList(config, style, range, colVisProp) { this.cloneTableStyle = style; @@ -15020,11 +14461,220 @@ _this.prevHeaderFilterChangeCheck = "{}"; _this.changed = false; //has filtering changed since last render - return _this; - } //initialize column header filter + _this.registerTableOption("filterMode", "local"); //local or remote filtering + + + _this.registerTableOption("initialFilter", false); //initial filtering criteria + + + _this.registerTableOption("initialHeaderFilter", false); //initial header filtering criteria + + + _this.registerTableOption("headerFilterLiveFilterDelay", 300); //delay before updating column after user types in header filter + + + _this.registerColumnOption("headerFilter"); + + _this.registerColumnOption("headerFilterPlaceholder"); + + _this.registerColumnOption("headerFilterParams"); + + _this.registerColumnOption("headerFilterEmptyCheck"); + + _this.registerColumnOption("headerFilterFunc"); + + _this.registerColumnOption("headerFilterFuncParams"); + + _this.registerColumnOption("headerFilterLiveFilter"); + + _this.registerTableFunction("searchRows", _this.searchRows.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("searchData", _this.searchData.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setFilter", _this.userSetFilter.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("refreshFilter", _this.userRefreshFilter.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("addFilter", _this.userAddFilter.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getFilters", _this.getFilters.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setHeaderFilterFocus", _this.userSetHeaderFilterFocus.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getHeaderFilterValue", _this.userGetHeaderFilterValue.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setHeaderFilterValue", _this.userSetHeaderFilterValue.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getHeaderFilters", _this.getHeaderFilters.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("removeFilter", _this.userRemoveFilter.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("clearFilter", _this.userClearFilter.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("clearHeaderFilter", _this.userClearHeaderFilter.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("column", "headerFilterFocus", _this.setHeaderFilterFocus.bind(_assertThisInitialized(_this))); + _this.registerComponentFunction("column", "reloadHeaderFilter", _this.reloadHeaderFilter.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("column", "getHeaderFilterValue", _this.getHeaderFilterValue.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("column", "setHeaderFilterValue", _this.setHeaderFilterValue.bind(_assertThisInitialized(_this))); + + return _this; + } _createClass(Filter, [{ + key: "initialize", + value: function initialize() { + this.subscribe("column-init", this.initializeColumnHeaderFilter.bind(this)); + this.subscribe("column-width-fit-before", this.hideHeaderFilterElements.bind(this)); + this.subscribe("column-width-fit-after", this.showHeaderFilterElements.bind(this)); + this.subscribe("table-built", this.tableBuilt.bind(this)); + + if (this.table.options.filterMode === "remote") { + this.subscribe("data-params", this.remoteFilterParams.bind(this)); + } + + this.registerDataHandler(this.filter.bind(this), 10); + } + }, { + key: "tableBuilt", + value: function tableBuilt() { + var _this2 = this; + + if (this.table.options.initialFilter) { + this.setFilter(this.table.options.initialFilter); + } + + if (this.table.options.initialHeaderFilter) { + this.table.options.initialHeaderFilter.forEach(function (item) { + var column = _this2.table.columnManager.findColumn(item.field); + + if (column) { + _this2.setHeaderFilterValue(column, item.value); + } else { + console.warn("Column Filter Error - No matching column found:", item.field); + return false; + } + }); + } + } + }, { + key: "remoteFilterParams", + value: function remoteFilterParams(data, config, silent, params) { + params.filter = this.getFilters(true, true); + return params; + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + //set standard filters + + }, { + key: "userSetFilter", + value: function userSetFilter(field, type, value, params) { + this.setFilter(field, type, value, params); + this.refreshFilter(); + } //set standard filters + + }, { + key: "userRefreshFilter", + value: function userRefreshFilter() { + this.refreshFilter(); + } //add filter to array + + }, { + key: "userAddFilter", + value: function userAddFilter(field, type, value, params) { + this.addFilter(field, type, value, params); + this.refreshFilter(); + } + }, { + key: "userSetHeaderFilterFocus", + value: function userSetHeaderFilterFocus(field) { + var column = this.table.columnManager.findColumn(field); + + if (column) { + this.setHeaderFilterFocus(column); + } else { + console.warn("Column Filter Focus Error - No matching column found:", field); + return false; + } + } + }, { + key: "userGetHeaderFilterValue", + value: function userGetHeaderFilterValue(field) { + var column = this.table.columnManager.findColumn(field); + + if (column) { + return this.getHeaderFilterValue(column); + } else { + console.warn("Column Filter Error - No matching column found:", field); + } + } + }, { + key: "userSetHeaderFilterValue", + value: function userSetHeaderFilterValue(field, value) { + var column = this.table.columnManager.findColumn(field); + + if (column) { + this.setHeaderFilterValue(column, value); + } else { + console.warn("Column Filter Error - No matching column found:", field); + return false; + } + } //remove filter from array + + }, { + key: "userRemoveFilter", + value: function userRemoveFilter(field, type, value) { + this.removeFilter(field, type, value); + this.refreshFilter(); + } //clear filters + + }, { + key: "userClearFilter", + value: function userClearFilter(all) { + this.clearFilter(all); + this.refreshFilter(); + } //clear header filters + + }, { + key: "userClearHeaderFilter", + value: function userClearHeaderFilter() { + this.clearHeaderFilter(); + this.refreshFilter(); + } //search for specific row components + + }, { + key: "searchRows", + value: function searchRows(field, type, value) { + return this.search("rows", field, type, value); + } //search for specific data + + }, { + key: "searchData", + value: function searchData(field, type, value) { + return this.search("data", field, type, value); + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + + }, { + key: "initializeColumnHeaderFilter", + value: function initializeColumnHeaderFilter(column) { + var def = column.definition; + + if (def.headerFilter) { + if (typeof def.headerFilterPlaceholder !== "undefined" && def.field) { + this.module("localize").setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder); + } + + this.initializeColumn(column); + } + } //initialize column header filter + + }, { key: "initializeColumn", value: function initializeColumn(column, value) { var self = this, @@ -15111,8 +14761,8 @@ if (self.prevHeaderFilterChangeCheck !== filterChangeCheck) { self.prevHeaderFilterChangeCheck = filterChangeCheck; - self.changed = true; - self.table.rowManager.filterRefresh(); + self.trackChanges(); + self.refreshFilter(); } } @@ -15130,7 +14780,7 @@ }, { key: "generateHeaderFilterElement", value: function generateHeaderFilterElement(column, initialValue, reinitialize) { - var _this2 = this; + var _this3 = this; var self = this, success = column.modules.filter.success, @@ -15234,12 +14884,12 @@ if (field) { - self.table.modules.localize.bind("headerFilters|columns|" + column.definition.field, function (value) { - editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : self.table.modules.localize.getText("headerFilters|default")); + self.langBind("headerFilters|columns|" + column.definition.field, function (value) { + editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : self.langText("headerFilters|default")); }); } else { - self.table.modules.localize.bind("headerFilters|default", function (value) { - editorElement.setAttribute("placeholder", typeof self.column.definition.headerFilterPlaceholder !== "undefined" && self.column.definition.headerFilterPlaceholder ? self.column.definition.headerFilterPlaceholder : value); + self.langBind("headerFilters|default", function (value) { + editorElement.setAttribute("placeholder", value); }); } //focus on element on click @@ -15249,12 +14899,12 @@ editorElement.focus(); }); editorElement.addEventListener("focus", function (e) { - var left = _this2.table.columnManager.element.scrollLeft; + var left = _this3.table.columnManager.element.scrollLeft; - if (left !== _this2.table.rowManager.element.scrollLeft) { - _this2.table.rowManager.scrollHorizontal(left); + if (left !== _this3.table.rowManager.element.scrollLeft) { + _this3.table.rowManager.scrollHorizontal(left); - _this2.table.columnManager.scrollHorizontal(left); + _this3.table.columnManager.scrollHorizontal(left); } }); //live update filters as user types @@ -15373,6 +15023,25 @@ console.warn("Column Filter Error - No header filter set on column:", column.getField()); } } + } + }, { + key: "refreshFilter", + value: function refreshFilter() { + if (this.table.options.filterMode === "remote") { + this.reloadData(); + } else { + this.refreshData(); + } //TODO - Persist left position of row manager + // left = this.scrollLeft; + // this.scrollHorizontal(left); + + } //check if the filters has changed since last use + + }, { + key: "trackChanges", + value: function trackChanges() { + this.changed = true; + this.dispatch("filter-changed"); } //check if the filters has changed since last use }, { @@ -15386,8 +15055,7 @@ }, { key: "setFilter", value: function setFilter(field, type, value, params) { - var self = this; - self.filterList = []; + this.filterList = []; if (!Array.isArray(field)) { field = [{ @@ -15398,13 +15066,13 @@ }]; } - self.addFilter(field); + this.addFilter(field); } //add filter to array }, { key: "addFilter", value: function addFilter(field, type, value, params) { - var self = this; + var _this4 = this; if (!Array.isArray(field)) { field = [{ @@ -15416,23 +15084,19 @@ } field.forEach(function (filter) { - filter = self.findFilter(filter); + filter = _this4.findFilter(filter); if (filter) { - self.filterList.push(filter); - self.changed = true; + _this4.filterList.push(filter); + + _this4.changed = true; } }); - - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.filter) { - this.table.modules.persistence.save("filter"); - } } }, { key: "findFilter", value: function findFilter(filter) { - var self = this, - column; + var column; if (Array.isArray(filter)) { return this.findSubFilters(filter); @@ -15446,7 +15110,7 @@ }; } else { if (Filter.filters[filter.type]) { - column = self.table.columnManager.getColumnByField(filter.field); + column = this.table.columnManager.getColumnByField(filter.field); if (column) { filterFunc = function filterFunc(data) { @@ -15468,10 +15132,11 @@ }, { key: "findSubFilters", value: function findSubFilters(filters) { - var self = this, - output = []; + var _this5 = this; + + var output = []; filters.forEach(function (filter) { - filter = self.findFilter(filter); + filter = _this5.findFilter(filter); if (filter) { output.push(filter); @@ -15504,14 +15169,14 @@ }, { key: "filtersToArray", value: function filtersToArray(filterList, ajax) { - var _this3 = this; + var _this6 = this; var output = []; filterList.forEach(function (filter) { var item; if (Array.isArray(filter)) { - output.push(_this3.filtersToArray(filter, ajax)); + output.push(_this6.filtersToArray(filter, ajax)); } else { item = { field: filter.field, @@ -15550,7 +15215,7 @@ }, { key: "removeFilter", value: function removeFilter(field, type, value) { - var self = this; + var _this7 = this; if (!Array.isArray(field)) { field = [{ @@ -15564,26 +15229,22 @@ var index = -1; if (_typeof(filter.field) == "object") { - index = self.filterList.findIndex(function (element) { + index = _this7.filterList.findIndex(function (element) { return filter === element; }); } else { - index = self.filterList.findIndex(function (element) { + index = _this7.filterList.findIndex(function (element) { return filter.field === element.field && filter.type === element.type && filter.value === element.value; }); } if (index > -1) { - self.filterList.splice(index, 1); - self.changed = true; + _this7.filterList.splice(index, 1); } else { console.warn("Filter Error - No matching filter type found, ignoring: ", filter.type); } }); - - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.filter) { - this.table.modules.persistence.save("filter"); - } + this.trackChanges(); } //clear filters }, { @@ -15595,35 +15256,34 @@ this.clearHeaderFilter(); } - this.changed = true; - - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.filter) { - this.table.modules.persistence.save("filter"); - } + this.trackChanges(); } //clear header filters }, { key: "clearHeaderFilter", value: function clearHeaderFilter() { - var self = this; + var _this8 = this; + this.headerFilters = {}; - self.prevHeaderFilterChangeCheck = "{}"; + this.prevHeaderFilterChangeCheck = "{}"; this.headerFilterColumns.forEach(function (column) { if (typeof column.modules.filter.value !== "undefined") { delete column.modules.filter.value; } column.modules.filter.prevSuccess = undefined; - self.reloadHeaderFilter(column); + + _this8.reloadHeaderFilter(column); }); - this.changed = true; + this.trackChanges(); } //search data and return matching rows }, { key: "search", value: function search(searchType, field, type, value) { - var self = this, - activeRows = [], + var _this9 = this; + + var activeRows = [], filterList = []; if (!Array.isArray(field)) { @@ -15635,7 +15295,7 @@ } field.forEach(function (filter) { - filter = self.findFilter(filter); + filter = _this9.findFilter(filter); if (filter) { filterList.push(filter); @@ -15644,7 +15304,7 @@ this.table.rowManager.rows.forEach(function (row) { var match = true; filterList.forEach(function (filter) { - if (!self.filterRecurse(filter, row.getData())) { + if (!_this9.filterRecurse(filter, row.getData())) { match = false; } }); @@ -15659,17 +15319,18 @@ }, { key: "filter", value: function filter(rowList, filters) { - var self = this, - activeRows = [], + var _this10 = this; + + var activeRows = [], activeRowComponents = []; - if (self.table.options.dataFiltering) { - self.table.options.dataFiltering.call(self.table, self.getFilters()); + if (this.subscribedExternal("dataFiltering")) { + this.dispatchExternal("dataFiltering", this.getFilters()); } - if (!self.table.options.ajaxFiltering && (self.filterList.length || Object.keys(self.headerFilters).length)) { + if (this.table.options.filterMode !== "remote" && (this.filterList.length || Object.keys(this.headerFilters).length)) { rowList.forEach(function (row) { - if (self.filterRow(row)) { + if (_this10.filterRow(row)) { activeRows.push(row); } }); @@ -15677,11 +15338,11 @@ activeRows = rowList.slice(0); } - if (self.table.options.dataFiltered) { + if (this.subscribedExternal("dataFiltered")) { activeRows.forEach(function (row) { activeRowComponents.push(row.getComponent()); }); - self.table.options.dataFiltered.call(self.table, self.getFilters(), activeRowComponents); + this.dispatchExternal("dataFiltered", this.getFilters(), activeRowComponents); } return activeRows; @@ -15690,17 +15351,18 @@ }, { key: "filterRow", value: function filterRow(row, filters) { - var self = this, - match = true, + var _this11 = this; + + var match = true, data = row.getData(); - self.filterList.forEach(function (filter) { - if (!self.filterRecurse(filter, data)) { + this.filterList.forEach(function (filter) { + if (!_this11.filterRecurse(filter, data)) { match = false; } }); - for (var field in self.headerFilters) { - if (!self.headerFilters[field].func(data)) { + for (var field in this.headerFilters) { + if (!this.headerFilters[field].func(data)) { match = false; } } @@ -15710,12 +15372,13 @@ }, { key: "filterRecurse", value: function filterRecurse(filter, data) { - var self = this, - match = false; + var _this12 = this; + + var match = false; if (Array.isArray(filter)) { filter.forEach(function (subFilter) { - if (self.filterRecurse(subFilter, data)) { + if (_this12.filterRecurse(subFilter, data)) { match = true; } }); @@ -16291,15 +15954,47 @@ var _super = _createSuper(Format); - function Format() { + function Format(table) { + var _this; + _classCallCheck(this, Format); - return _super.apply(this, arguments); + _this = _super.call(this, table); + + _this.registerColumnOption("formatter"); + + _this.registerColumnOption("formatterParams"); + + _this.registerColumnOption("formatterPrint"); + + _this.registerColumnOption("formatterPrintParams"); + + _this.registerColumnOption("formatterClipboard"); + + _this.registerColumnOption("formatterClipboardParams"); + + _this.registerColumnOption("formatterHtmlOutput"); + + _this.registerColumnOption("formatterHtmlOutputParams"); + + _this.registerColumnOption("titleFormatter"); + + _this.registerColumnOption("titleFormatterParams"); + + return _this; } _createClass(Format, [{ + key: "initialize", + value: function initialize() { + this.subscribe("cell-format", this.formatValue.bind(this)); + this.subscribe("cell-rendered", this.cellRendered.bind(this)); + this.subscribe("column-layout", this.initializeColumn.bind(this)); + this.subscribe("column-format", this.formatHeader.bind(this)); + } //initialize column formatter + + }, { key: "initializeColumn", - //initialize column formatter value: function initializeColumn(column) { column.modules.format = this.lookupFormatter(column, ""); @@ -16352,6 +16047,34 @@ cell.modules.format.renderedCallback(); cell.modules.format.rendered = true; } + } //return a formatted value for a column header + + }, { + key: "formatHeader", + value: function formatHeader(column, title, el) { + var formatter, params, onRendered, mockCell; + + if (column.definition.titleFormatter) { + formatter = this.getFormatter(column.definition.titleFormatter); + + onRendered = function onRendered(callback) { + column.titleFormatterRendered = callback; + }; + + mockCell = { + getValue: function getValue() { + return title; + }, + getElement: function getElement() { + return el; + } + }; + params = column.definition.titleFormatterParams || {}; + params = typeof params === "function" ? params() : params; + return formatter.call(this, mockCell, params, onRendered); + } else { + return title; + } } //return a formatted value for a cell }, { @@ -16475,6 +16198,9 @@ _this.initializationMode = "left"; _this.active = false; _this.scrollEndTimer = false; + + _this.registerColumnOption("frozen"); + return _this; } //reset initial state @@ -16491,6 +16217,23 @@ this.active = false; this.table.columnManager.headersElement.style.marginLeft = 0; this.table.columnManager.element.style.paddingRight = 0; + } + }, { + key: "initialize", + value: function initialize() { + this.subscribe("cell-layout", this.layoutCell.bind(this)); + this.subscribe("column-init", this.initializeColumn.bind(this)); + this.subscribe("column-width", this.layout.bind(this)); + this.subscribe("row-layout-before", this.layoutRow.bind(this)); + this.subscribe("table-layout", this.layout.bind(this)); + this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this)); + this.subscribe("columns-loading", this.reset.bind(this)); + this.subscribe("table-redraw", this.layout.bind(this)); + } + }, { + key: "layoutCell", + value: function layoutCell(cell) { + this.layoutElement(cell.element, cell.column); } //initialize specific column }, { @@ -16735,8 +16478,13 @@ _this = _super.call(this, table); _this.topElement = document.createElement("div"); - _this.rows = []; - _this.displayIndex = 0; //index in display pipeline + _this.rows = []; //register component functions + + _this.registerComponentFunction("row", "freeze", _this.freezeRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "unfreeze", _this.unfreezeRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "isFrozen", _this.isRowFrozen.bind(_assertThisInitialized(_this))); return _this; } @@ -16748,16 +16496,14 @@ this.topElement.classList.add("tabulator-frozen-rows-holder"); // this.table.columnManager.element.append(this.topElement); this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling); + this.subscribe("row-deleting", this.detachRow.bind(this)); + this.registerDisplayHandler(this.getRows.bind(this), 10); } }, { - key: "setDisplayIndex", - value: function setDisplayIndex(index) { - this.displayIndex = index; - } - }, { - key: "getDisplayIndex", - value: function getDisplayIndex() { - return this.displayIndex; + key: "isRowFrozen", + value: function isRowFrozen(row) { + var index = this.rows.indexOf(row); + return index > -1; } }, { key: "isFrozen", @@ -16839,7 +16585,90 @@ FrozenRows.moduleName = "frozenRows"; - var Group$1 = /*#__PURE__*/function () { + //public group object + var GroupComponent = /*#__PURE__*/function () { + function GroupComponent(group) { + _classCallCheck(this, GroupComponent); + + this._group = group; + this.type = "GroupComponent"; + return new Proxy(this, { + get: function get(target, name, receiver) { + if (typeof target[name] !== "undefined") { + return target[name]; + } else { + return target._group.table.componentFunctionBinder.handle("row", target._group, name); + } + } + }); + } + + _createClass(GroupComponent, [{ + key: "getKey", + value: function getKey() { + return this._group.key; + } + }, { + key: "getField", + value: function getField() { + return this._group.field; + } + }, { + key: "getElement", + value: function getElement() { + return this._group.element; + } + }, { + key: "getRows", + value: function getRows() { + return this._group.getRows(true); + } + }, { + key: "getSubGroups", + value: function getSubGroups() { + return this._group.getSubGroups(true); + } + }, { + key: "getParentGroup", + value: function getParentGroup() { + return this._group.parent ? this._group.parent.getComponent() : false; + } + }, { + key: "isVisible", + value: function isVisible() { + return this._group.visible; + } + }, { + key: "show", + value: function show() { + this._group.show(); + } + }, { + key: "hide", + value: function hide() { + this._group.hide(); + } + }, { + key: "toggle", + value: function toggle() { + this._group.toggleVisibility(); + } + }, { + key: "_getSelf", + value: function _getSelf() { + return this._group; + } + }, { + key: "getTable", + value: function getTable() { + return this._group.groupManager.table; + } + }]); + + return GroupComponent; + }(); + + var Group = /*#__PURE__*/function () { function Group(groupManager, parent, level, key, field, generator, oldGroup) { _classCallCheck(this, Group); @@ -16921,25 +16750,7 @@ value: function addBindings() { var _this2 = this; - var dblTap, tapHold, tap, toggleElement; //handle group click events - - if (this.groupManager.table.options.groupClick) { - this.element.addEventListener("click", function (e) { - _this2.groupManager.table.options.groupClick.call(_this2.groupManager.table, e, _this2.getComponent()); - }); - } - - if (this.groupManager.table.options.groupDblClick) { - this.element.addEventListener("dblclick", function (e) { - _this2.groupManager.table.options.groupDblClick.call(_this2.groupManager.table, e, _this2.getComponent()); - }); - } - - if (this.groupManager.table.options.groupContext) { - this.element.addEventListener("contextmenu", function (e) { - _this2.groupManager.table.options.groupContext.call(_this2.groupManager.table, e, _this2.getComponent()); - }); - } + var dblTap, tapHold, tap, toggleElement; if ((this.groupManager.table.options.groupContextMenu || this.groupManager.table.options.groupClickMenu) && this.groupManager.table.modExists("menu")) { this.groupManager.table.modules.menu.initializeGroup.call(this.groupManager.table.modules.menu, this); @@ -17289,7 +17100,7 @@ this.groupManager.updateGroupRows(true); } - this.groupManager.table.options.groupVisibilityChanged.call(this.table, this.getComponent(), false); + this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), false); } }, { key: "show", @@ -17325,7 +17136,7 @@ this.groupManager.updateGroupRows(true); } - this.groupManager.table.options.groupVisibilityChanged.call(this.table, this.getComponent(), true); + this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), true); } }, { key: "_visSet", @@ -17462,7 +17273,7 @@ this.initialized = false; this.height = 0; - if (Helpers.elVisible(this.element)) { + if (Helpers$1.elVisible(this.element)) { this.initialize(true); } } @@ -17538,6 +17349,48 @@ _this.groups = {}; //hold row groups _this.displayIndex = 0; //index in display pipeline + //register table options + + _this.registerTableOption("groupBy", false); //enable table grouping and set field to group by + + + _this.registerTableOption("groupStartOpen", true); //starting state of group + + + _this.registerTableOption("groupValues", false); + + _this.registerTableOption("groupUpdateOnCellEdit", false); + + _this.registerTableOption("groupHeader", false); //header generation function + + + _this.registerTableOption("groupHeaderPrint", null); + + _this.registerTableOption("groupHeaderClipboard", null); + + _this.registerTableOption("groupHeaderHtmlOutput", null); + + _this.registerTableOption("groupHeaderDownload", null); + + _this.registerTableOption("groupToggleElement", "arrow"); + + _this.registerTableOption("groupClosedShowCalcs", false); //register table functions + + + _this.registerTableFunction("setGroupBy", _this.setGroupBy.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setGroupValues", _this.setGroupValues.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setGroupStartOpen", _this.setGroupStartOpen.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setGroupHeader", _this.setGroupHeader.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getGroups", _this.userGetGroups.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getGroupedData", _this.userGetGroupedData.bind(_assertThisInitialized(_this))); //register component functions + + + _this.registerComponentFunction("row", "getGroup", _this.rowGetGroup.bind(_assertThisInitialized(_this))); return _this; } //initialize group configuration @@ -17548,94 +17401,268 @@ value: function initialize() { var _this2 = this; - var groupBy = this.table.options.groupBy, - startOpen = this.table.options.groupStartOpen, - groupHeader = this.table.options.groupHeader; - this.allowedValues = this.table.options.groupValues; + if (this.table.options.groupBy) { + var groupBy = this.table.options.groupBy, + startOpen = this.table.options.groupStartOpen, + groupHeader = this.table.options.groupHeader; + this.allowedValues = this.table.options.groupValues; - if (Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length) { - console.warn("Error creating group headers, groupHeader array is shorter than groupBy array"); - } + if (Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length) { + console.warn("Error creating group headers, groupHeader array is shorter than groupBy array"); + } - this.headerGenerator = [function () { - return ""; - }]; - this.startOpen = [function () { - return false; - }]; //starting state of group + this.headerGenerator = [function () { + return ""; + }]; + this.startOpen = [function () { + return false; + }]; //starting state of group - this.table.modules.localize.bind("groups|item", function (langValue, lang) { - _this2.headerGenerator[0] = function (value, count, data) { - //header layout function - return (typeof value === "undefined" ? "" : value) + "(" + count + " " + (count === 1 ? langValue : lang.groups.items) + ")"; - }; + this.langBind("groups|item", function (langValue, lang) { + _this2.headerGenerator[0] = function (value, count, data) { + //header layout function + return (typeof value === "undefined" ? "" : value) + "(" + count + " " + (count === 1 ? langValue : lang.groups.items) + ")"; + }; + }); + this.groupIDLookups = []; + + if (Array.isArray(groupBy) || groupBy) { + if (this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "table" && this.table.options.columnCalcs != "both") { + this.table.modules.columnCalcs.removeCalcs(); + } + } else { + if (this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "group") { + var cols = this.table.columnManager.getRealColumns(); + cols.forEach(function (col) { + if (col.definition.topCalc) { + _this2.table.modules.columnCalcs.initializeTopRow(); + } + + if (col.definition.bottomCalc) { + _this2.table.modules.columnCalcs.initializeBottomRow(); + } + }); + } + } + + if (!Array.isArray(groupBy)) { + groupBy = [groupBy]; + } + + groupBy.forEach(function (group, i) { + var lookupFunc, column; + + if (typeof group == "function") { + lookupFunc = group; + } else { + column = _this2.table.columnManager.getColumnByField(group); + + if (column) { + lookupFunc = function lookupFunc(data) { + return column.getFieldValue(data); + }; + } else { + lookupFunc = function lookupFunc(data) { + return data[group]; + }; + } + } + + _this2.groupIDLookups.push({ + field: typeof group === "function" ? false : group, + func: lookupFunc, + values: _this2.allowedValues ? _this2.allowedValues[i] : false + }); + }); + + if (startOpen) { + if (!Array.isArray(startOpen)) { + startOpen = [startOpen]; + } + + startOpen.forEach(function (level) { + }); + this.startOpen = startOpen; + } + + if (groupHeader) { + this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader]; + } + + if (this.table.options.groupUpdateOnCellEdit) { + this.subscribe("cell-value-updated", this.cellUpdated.bind(this)); + this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0); + } + + this.subscribe("row-deleting", this.rowDeleting.bind(this)); + this.subscribe("row-deleted", this.rowsUpdated.bind(this)); + this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this)); + this.subscribe("rows-wipe", this.wipe.bind(this)); + this.subscribe("rows-added", this.rowsUpdated.bind(this)); + this.subscribe("row-moving", this.rowMoving.bind(this)); + this.subscribe("row-adding-index", this.rowAddingIndex.bind(this)); + this.subscribe("rows-sample", this.rowSample.bind(this)); + this.subscribe("render-virtual-fill", this.rowAddingIndex.bind(this)); + this.registerDisplayHandler(this.getRows.bind(this), 20); + this.initialized = true; + } + } + }, { + key: "rowSample", + value: function rowSample(rows, prevValue) { + var group = this.getGroups(false)[0]; + prevValue.push(group.getRows(false)[0]); + return prevValue; + } + }, { + key: "virtualRenderFill", + value: function virtualRenderFill() { + var el = this.table.rowManager.tableElement; + rows = this.table.rowManager.getVisibleRows(); + rows = rows.filter(function (row) { + return row.type !== "group"; }); - this.groupIDLookups = []; + el.style.minWidth = !rows.length ? this.table.columnManager.getWidth() + "px" : ""; // if(this.table.options.groupBy){ + // if(this.layoutMode() != "fitDataFill" && rowsCount == this.table.modules.groupRows.countGroups()){ + // el.style.minWidth = this.table.columnManager.getWidth() + "px"; + // } + // } + } + }, { + key: "rowAddingIndex", + value: function rowAddingIndex(row, index, top) { + this.assignRowToGroup(row); + var groupRows = row.modules.group.rows; + + if (groupRows.length > 1) { + if (!index || index && groupRows.indexOf(index) == -1) { + if (top) { + if (groupRows[0] !== row) { + index = groupRows[0]; + this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top); + } + } else { + if (groupRows[groupRows.length - 1] !== row) { + index = groupRows[groupRows.length - 1]; + this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top); + } + } + } else { + this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top); + } + } + + return index; + } + }, { + key: "trackChanges", + value: function trackChanges() { + this.dispatch("group-changed"); + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "setGroupBy", + value: function setGroupBy(groups) { + this.table.options.groupBy = groups; + this.initialize(); + this.refreshData(false, "display"); + this.trackChanges(); + } + }, { + key: "setGroupValues", + value: function setGroupValues(groupValues) { + this.table.options.groupValues = groupValues; + this.initialize(); + this.refreshData(false, "display"); + this.trackChanges(); + } + }, { + key: "setGroupStartOpen", + value: function setGroupStartOpen(values) { + this.table.options.groupStartOpen = values; + this.initialize(); - if (Array.isArray(groupBy) || groupBy) { - if (this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "table" && this.table.options.columnCalcs != "both") { - this.table.modules.columnCalcs.removeCalcs(); - } + if (this.table.options.groupBy) { + this.refreshData(); + this.trackChanges(); } else { - if (this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "group") { - var cols = this.table.columnManager.getRealColumns(); - cols.forEach(function (col) { - if (col.definition.topCalc) { - _this2.table.modules.columnCalcs.initializeTopRow(); - } - - if (col.definition.bottomCalc) { - _this2.table.modules.columnCalcs.initializeBottomRow(); - } - }); - } + console.warn("Grouping Update - cant refresh view, no groups have been set"); } + } + }, { + key: "setGroupHeader", + value: function setGroupHeader(values) { + this.table.options.groupHeader = values; + this.initialize(); - if (!Array.isArray(groupBy)) { - groupBy = [groupBy]; + if (this.table.options.groupBy) { + this.refreshData(); + this.trackChanges(); + } else { + console.warn("Grouping Update - cant refresh view, no groups have been set"); } + } + }, { + key: "userGetGroups", + value: function userGetGroups(values) { + return this.getGroups(true); + } // get grouped table data in the same format as getData() - groupBy.forEach(function (group, i) { - var lookupFunc, column; + }, { + key: "userGetGroupedData", + value: function userGetGroupedData() { + return this.table.options.groupBy ? this.getGroupedData() : this.getData(); + } /////////////////////////////////////// + ///////// Component Functions ///////// + /////////////////////////////////////// - if (typeof group == "function") { - lookupFunc = group; - } else { - column = _this2.table.columnManager.getColumnByField(group); + }, { + key: "rowGetGroup", + value: function rowGetGroup(row) { + return row.modules.group ? row.modules.group.getComponent() : false; + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// - if (column) { - lookupFunc = function lookupFunc(data) { - return column.getFieldValue(data); - }; - } else { - lookupFunc = function lookupFunc(data) { - return data[group]; - }; - } - } + }, { + key: "rowMoving", + value: function rowMoving(from, to, after) { + if (!after && to instanceof Group) { + to = this.table.rowManager.prevDisplayRow(from) || to; + } - _this2.groupIDLookups.push({ - field: typeof group === "function" ? false : group, - func: lookupFunc, - values: _this2.allowedValues ? _this2.allowedValues[i] : false - }); - }); + var toGroup = to.modules.group; + var fromGroup = from.modules.group; - if (startOpen) { - if (!Array.isArray(startOpen)) { - startOpen = [startOpen]; + if (toGroup === fromGroup) { + this.table.rowManager.moveRowInArray(toGroup.rows, from, to, after); + } else { + if (fromGroup) { + fromGroup.removeRow(from); } - startOpen.forEach(function (level) { - }); - this.startOpen = startOpen; + toGroup.insertRow(from, to, after); } - - if (groupHeader) { - this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader]; + } + }, { + key: "rowDeleting", + value: function rowDeleting(row) { + //remove from group + if (row.modules.group) { + row.modules.group.removeRow(row); } - - this.initialized = true; + } + }, { + key: "rowsUpdated", + value: function rowsUpdated(row) { + this.updateGroupRows(true); + } + }, { + key: "cellUpdated", + value: function cellUpdated(cell) { + this.reassignRowToGroup(cell.row); } }, { key: "setDisplayIndex", @@ -17652,11 +17679,11 @@ key: "getRows", value: function getRows(rows) { if (this.groupIDLookups.length) { - this.table.options.dataGrouping.call(this.table); + this.dispatchExternal("dataGrouping"); this.generateGroups(rows); - if (this.table.options.dataGrouped) { - this.table.options.dataGrouped.call(this.table, this.getGroups(true)); + if (this.subscribedExternal("dataGrouped")) { + this.dispatchExternal("dataGrouped", this.getGroups(true)); } return this.updateGroupRows(); @@ -17666,10 +17693,10 @@ } }, { key: "getGroups", - value: function getGroups(compoment) { + value: function getGroups(component) { var groupComponents = []; this.groupList.forEach(function (group) { - groupComponents.push(compoment ? group.getComponent() : group); + groupComponents.push(component ? group.getComponent() : group); }); return groupComponents; } @@ -17784,7 +17811,7 @@ var groupKey = level + "_" + groupID, group; oldGroups = oldGroups || []; - group = new Group$1(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]); + group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]); this.groups[groupKey] = group; this.groupList.push(group); } @@ -17814,19 +17841,21 @@ }, { key: "reassignRowToGroup", value: function reassignRowToGroup(row) { - var oldRowGroup = row.getGroup(), - oldGroupPath = oldRowGroup.getPath(), - newGroupPath = this.getExpectedPath(row), - samePath = true; // figure out if new group path is the same as old group path + if (row.type === "row") { + var oldRowGroup = row.modules.group, + oldGroupPath = oldRowGroup.getPath(), + newGroupPath = this.getExpectedPath(row), + samePath = true; // figure out if new group path is the same as old group path - var samePath = oldGroupPath.length == newGroupPath.length && oldGroupPath.every(function (element, index) { - return element === newGroupPath[index]; - }); // refresh if they new path and old path aren't the same (aka the row's groupings have changed) + var samePath = oldGroupPath.length == newGroupPath.length && oldGroupPath.every(function (element, index) { + return element === newGroupPath[index]; + }); // refresh if they new path and old path aren't the same (aka the row's groupings have changed) - if (!samePath) { - oldRowGroup.removeRow(row); - this.assignRowToGroup(row, this.groups); - this.table.rowManager.refreshActiveData("group", false, true); + if (!samePath) { + oldRowGroup.removeRow(row); + this.assignRowToGroup(row, this.groups); + this.refreshData(true); + } } } }, { @@ -17854,7 +17883,7 @@ this.setDisplayIndex(displayIndex); } - this.table.rowManager.refreshActiveData("group", true, true); + this.refreshData(true); } return output; @@ -17862,8 +17891,8 @@ }, { key: "scrollHeaders", value: function scrollHeaders(left) { - if (this.table.options.virtualDomHoz) { - left -= this.table.vdomHoz.vDomPadLeft; + if (this.table.options.renderHorizontal === "virtual") { + left -= this.table.columnManager.renderer.vDomPadLeft; } left = left + "px"; @@ -17950,10 +17979,85 @@ _this = _super.call(this, table); _this.history = []; _this.index = -1; + + _this.registerTableOption("history", false); //enable edit history + + return _this; } _createClass(History, [{ + key: "initialize", + value: function initialize() { + if (this.table.options.history) { + this.subscribe("cell-value-updated", this.layoutCell.bind(this)); + this.subscribe("cell-delete", this.clearComponentHistory.bind(this)); + this.subscribe("row-delete", this.rowDeleted.bind(this)); + this.subscribe("rows-wipe", this.clear.bind(this)); + this.subscribe("row-added", this.clear.bind(this)); + this.subscribe("row-move", this.rowMoved.bind(this)); + } + + this.registerTableFunction("undo", this.undo.bind(this)); + this.registerTableFunction("redo", this.redo.bind(this)); + this.registerTableFunction("getHistoryUndoSize", this.getHistoryUndoSize.bind(this)); + this.registerTableFunction("getHistoryRedoSize", this.getHistoryRedoSize.bind(this)); + this.registerTableFunction("clearHistory", this.clear.bind(this)); + } + }, { + key: "rowMoved", + value: function rowMoved(from, to, after) { + this.action("rowMove", from, { + posFrom: this.table.rowManager.getRowPosition(from), + posTo: this.table.rowManager.getRowPosition(to), + to: to, + after: after + }); + } + }, { + key: "rowAdded", + value: function rowAdded(row, data, pos, index) { + this.action("rowAdd", row, { + data: data, + pos: pos, + index: index + }); + } + }, { + key: "rowDeleted", + value: function rowDeleted(row) { + var index, rows; + + if (this.table.options.groupBy) { + rows = row.getComponent().getGroup().rows; + index = rows.indexOf(row); + + if (index) { + index = rows[index - 1]; + } + } else { + index = row.table.rowManager.getRowIndex(row); + + if (index) { + index = row.table.rowManager.rows[index - 1]; + } + } + + this.history.action("rowDelete", row, { + data: row.getData(), + pos: !index, + index: index + }); + } + }, { + key: "cellUpdated", + value: function cellUpdated(cell) { + this.action("cellEdit", cell, { + oldValue: cell.oldValue, + newValue: cell.value + }); + } + }, { key: "clear", value: function clear() { this.history = []; @@ -18004,7 +18108,7 @@ var action = this.history[this.index]; History.undoers[action.type].call(this, action); this.index--; - this.table.options.historyUndo.call(this.table, action.type, action.component.getComponent(), action.data); + this.dispatchExternal("historyUndo", action.type, action.component.getComponent(), action.data); return true; } else { console.warn("History Undo Error - No more history to undo"); @@ -18018,7 +18122,7 @@ this.index++; var action = this.history[this.index]; History.redoers[action.type].call(this, action); - this.table.options.historyRedo.call(this.table, action.type, action.component.getComponent(), action.data); + this.dispatchExternal("historyRedo", action.type, action.component.getComponent(), action.data); return true; } else { console.warn("History Redo Error - No more history to redo"); @@ -18072,6 +18176,18 @@ } _createClass(HtmlTableImport, [{ + key: "initialize", + value: function initialize() { + this.subscribe("table-building", this.tableElementCheck.bind(this)); + } + }, { + key: "tableElementCheck", + value: function tableElementCheck() { + if (this.table.element.tagName === "TABLE") { + this.parseTable(); + } + } + }, { key: "parseTable", value: function parseTable() { var element = this.table.element, @@ -18081,7 +18197,7 @@ rows = element.getElementsByTagName("tbody")[0], data = []; this.hasIndex = false; - this.table.options.htmlImporting.call(this.table); + this.dispatchExternal("htmlImporting"); rows = rows ? rows.getElementsByTagName("tr") : []; //check for tablator inline options this._extractOptions(element, options); @@ -18128,7 +18244,7 @@ element.parentNode.replaceChild(newElement, element); options.data = data; - this.table.options.htmlImported.call(this.table); + this.dispatchExternal("htmlImported"); this.table.element = newElement; } //extract tabulator attribute options @@ -18249,6 +18365,334 @@ HtmlTableImport.moduleName = "htmlTableImport"; + var Interaction = /*#__PURE__*/function (_Module) { + _inherits(Interaction, _Module); + + var _super = _createSuper(Interaction); + + function Interaction(table) { + var _this; + + _classCallCheck(this, Interaction); + + _this = _super.call(this, table); + _this.eventMap = { + //row events + rowClick: "row-click", + rowDblClick: "row-dblclick", + rowContext: "row-contextmenu", + rowMouseEnter: "row-mouseenter", + rowMouseLeave: "row-mouseleave", + rowMouseOver: "row-mouseover", + rowMouseOut: "row-mouseout", + rowMouseMove: "row-mousemove", + rowTap: "row", + rowDblTap: "row", + rowTapHold: "row", + //cell events + cellClick: "cell-click", + cellDblClick: "cell-dblclick", + cellContext: "cell-contextmenu", + cellMouseEnter: "cell-mouseenter", + cellMouseLeave: "cell-mouseleave", + cellMouseOver: "cell-mouseover", + cellMouseOut: "cell-mouseout", + cellMouseMove: "cell-mousemove", + cellTap: "cell", + cellDblTap: "cell", + cellTapHold: "cell", + //column header events + headerClick: "column-click", + headerDblClick: "column-dblclick", + headerContext: "column-contextmenu", + headerMouseEnter: "column-mouseenter", + headerMouseLeave: "column-mouseleave", + headerMouseOver: "column-mouseover", + headerMouseOut: "column-mouseout", + headerMouseMove: "column-mousemove", + headerTap: "column", + headerDblTap: "column", + headerTapHold: "column", + //group header + groupClick: "group-click", + groupDblClick: "group-dblclick", + groupContext: "group-contextmenu", + groupMouseEnter: "group-mouseenter", + groupMouseLeave: "group-mouseleave", + groupMouseOver: "group-mouseover", + groupMouseOut: "group-mouseout", + groupMouseMove: "group-mousemove", + groupTap: "group", + groupDblTap: "group", + groupTapHold: "group" + }; + _this.subscribers = {}; + _this.touchSubscribers = {}; + _this.columnSubscribers = {}; + _this.touchWatchers = { + row: { + tap: null, + tapDbl: null, + tapHold: null + }, + cell: { + tap: null, + tapDbl: null, + tapHold: null + }, + column: { + tap: null, + tapDbl: null, + tapHold: null + } + }; + + _this.registerColumnOption("headerClick"); + + _this.registerColumnOption("headerDblClick"); + + _this.registerColumnOption("headerContext"); + + _this.registerColumnOption("headerMouseEnter"); + + _this.registerColumnOption("headerMouseLeave"); + + _this.registerColumnOption("headerMouseOver"); + + _this.registerColumnOption("headerMouseOut"); + + _this.registerColumnOption("headerMouseMove"); + + _this.registerColumnOption("headerTap"); + + _this.registerColumnOption("headerDblTap"); + + _this.registerColumnOption("headerTapHold"); + + _this.registerColumnOption("cellClick"); + + _this.registerColumnOption("cellDblClick"); + + _this.registerColumnOption("cellContext"); + + _this.registerColumnOption("cellMouseEnter"); + + _this.registerColumnOption("cellMouseLeave"); + + _this.registerColumnOption("cellMouseOver"); + + _this.registerColumnOption("cellMouseOut"); + + _this.registerColumnOption("cellMouseMove"); + + _this.registerColumnOption("cellTap"); + + _this.registerColumnOption("cellDblTap"); + + _this.registerColumnOption("cellTapHold"); + + return _this; + } + + _createClass(Interaction, [{ + key: "initialize", + value: function initialize() { + this.initializeExternalEvents(); + this.subscribe("column-init", this.initializeColumn.bind(this)); + this.subscribe("cell-dblclick", this.cellContentsSelectionFixer.bind(this)); + } + }, { + key: "cellContentsSelectionFixer", + value: function cellContentsSelectionFixer(e, cell) { + if (this.table.modExists("edit")) { + if (this.table.modules.edit.currentCell === this) { + return; //prevent instant selection of editor content + } + } + + e.preventDefault(); + + try { + if (document.selection) { + // IE + var range = document.body.createTextRange(); + range.moveToElementText(this.element); + range.select(); + } else if (window.getSelection) { + var range = document.createRange(); + range.selectNode(this.element); + window.getSelection().removeAllRanges(); + window.getSelection().addRange(range); + } + } catch (e) {} + } + }, { + key: "initializeExternalEvents", + value: function initializeExternalEvents() { + for (var key in this.eventMap) { + this.subscriptionChangeExternal(key, this.subscriptionChanged.bind(this, key)); + } + } + }, { + key: "subscriptionChanged", + value: function subscriptionChanged(key, added) { + + if (added) { + if (!this.subscribers[key]) { + if (this.eventMap[key].includes("-")) { + this.subscribers[key] = this.handle.bind(this, key); + this.subscribe(this.eventMap[key], this.subscribers[key]); + } else { + this.subscribeTouchEvents(key); + } + } + } else { + if (this.eventMap[key].includes("-")) { + if (this.subscribers[key] && !this.columnSubscribers[key] && !this.subscribedExternal(key)) { + this.unsubscribe(this.eventMap[key], this.subscribers[key]); + delete this.subscribers[key]; + } + } else { + this.unsubscribeTouchEvents(key); + } + } + } + }, { + key: "subscribeTouchEvents", + value: function subscribeTouchEvents(key) { + var type = this.eventMap[key]; + + if (!this.touchSubscribers[type + "-touchstart"]) { + this.touchSubscribers[type + "-touchstart"] = this.handleTouch.bind(this, type, "start"); + this.touchSubscribers[type + "-touchend"] = this.handleTouch.bind(this, type, "end"); + this.subscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]); + this.subscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]); + } + + this.subscribers[key] = true; + } + }, { + key: "unsubscribeTouchEvents", + value: function unsubscribeTouchEvents(key) { + var notouch = true, + type = this.eventMap[key]; + + if (this.subscribers[key] && !this.subscribedExternal(key)) { + delete this.subscribers[key]; + + for (var i in this.eventMap) { + if (this.eventMap[i] === type) { + if (this.subscribers[i]) { + notouch = false; + } + } + } + + if (notouch) { + this.unsubscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]); + this.unsubscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]); + delete this.touchSubscribers[type + "-touchstart"]; + delete this.touchSubscribers[type + "-touchend"]; + } + } + } + }, { + key: "initializeColumn", + value: function initializeColumn(column) { + var def = column.definition; + + for (var key in this.eventMap) { + if (def[key]) { + this.subscriptionChanged(key, true); + + if (!this.columnSubscribers[key]) { + this.columnSubscribers[key] = []; + } + + this.columnSubscribers[key].push(column); + } + } + } + }, { + key: "handle", + value: function handle(action, e, component) { + this.dispatchEvent(action, e, component); + } + }, { + key: "handleTouch", + value: function handleTouch(type, action, e, component) { + var _this2 = this; + + var watchers = this.touchWatchers[type]; + + if (type === "column") { + type = "header"; + } + + switch (action) { + case "start": + watchers.tap = true; + clearTimeout(watchers.tapHold); + watchers.tapHold = setTimeout(function () { + clearTimeout(watchers.tapHold); + watchers.tapHold = null; + watchers.tap = null; + clearTimeout(watchers.tapDbl); + watchers.tapDbl = null; + + _this2.dispatchEvent(type + "TapHold", e, component); + }, 1000); + break; + + case "end": + if (watchers.tap) { + watchers.tap = null; + this.dispatchEvent(type + "Tap", e, component); + } + + if (watchers.tapDbl) { + clearTimeout(watchers.tapDbl); + watchers.tapDbl = null; + this.dispatchEvent(type + "DblTap", e, component); + } else { + watchers.tapDbl = setTimeout(function () { + clearTimeout(watchers.tapDbl); + watchers.tapDbl = null; + }, 300); + } + + clearTimeout(watchers.tapHold); + watchers.tapHold = null; + break; + } + } + }, { + key: "dispatchEvent", + value: function dispatchEvent(action, e, component) { + var componentObj = component.getComponent(), + callback; + + if (this.columnSubscribers[action]) { + if (component instanceof Cell$1) { + callback = component.column.definition[action]; + } else if (component instanceof Column$1) { + callback = component.definition[action]; + } + + if (callback) { + callback(e, componentObj); + } + } + + this.dispatchExternal(action, e, componentObj); + } + }]); + + return Interaction; + }(Module); + + Interaction.moduleName = "interaction"; + var defaultBindings = { navPrev: "shift + 9", navNext: 9, @@ -18270,7 +18714,7 @@ }, scrollPageUp: function scrollPageUp(e) { var rowManager = this.table.rowManager, - newPos = rowManager.scrollTop - rowManager.height, + newPos = rowManager.scrollTop - rowManager.element.clientHeight, scrollMax = rowManager.element.scrollHeight; e.preventDefault(); @@ -18286,7 +18730,7 @@ }, scrollPageDown: function scrollPageDown(e) { var rowManager = this.table.rowManager, - newPos = rowManager.scrollTop + rowManager.height, + newPos = rowManager.scrollTop + rowManager.element.clientHeight, scrollMax = rowManager.element.scrollHeight; e.preventDefault(); @@ -18321,100 +18765,22 @@ this.table.element.focus(); }, navPrev: function navPrev(e) { - var cell = false; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - cell.nav().prev(); - } - } + this.dispatch("keybinding-nav-prev", e); }, navNext: function navNext(e) { - var cell = false; - var newRow = this.table.options.tabEndNewRow; - var nav; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - nav = cell.nav(); - - if (!nav.next()) { - if (newRow) { - cell.getElement().firstChild.blur(); - - if (newRow === true) { - newRow = this.table.addRow({}); - } else { - if (typeof newRow == "function") { - newRow = this.table.addRow(newRow(cell.row.getComponent())); - } else { - newRow = this.table.addRow(Object.assign({}, newRow)); - } - } - - newRow.then(function () { - setTimeout(function () { - nav.next(); - }); - }); - } - } - } - } + this.dispatch("keybinding-nav-next", e); }, - navLeft: function navLeft(e) { - var cell = false; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - cell.nav().left(); - } - } + navLeft: function navLeft(e) { + this.dispatch("keybinding-nav-left", e); }, navRight: function navRight(e) { - var cell = false; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - cell.nav().right(); - } - } + this.dispatch("keybinding-nav-right", e); }, navUp: function navUp(e) { - var cell = false; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - cell.nav().up(); - } - } + this.dispatch("keybinding-nav-up", e); }, navDown: function navDown(e) { - var cell = false; - - if (this.table.modExists("edit")) { - cell = this.table.modules.edit.currentCell; - - if (cell) { - e.preventDefault(); - cell.nav().down(); - } - } + this.dispatch("keybinding-nav-down", e); }, undo: function undo(e) { var cell = false; @@ -18464,6 +18830,13 @@ _this.pressedKeys = null; _this.keyupBinding = false; _this.keydownBinding = false; + + _this.registerTableOption("keybindings", []); //array for keybindings + + + _this.registerTableOption("tabEndNewRow", false); //create new row when tab to end of table + + return _this; } @@ -18489,6 +18862,8 @@ this.mapBindings(mergedBindings); this.bindEvents(); } + + this.subscribe("table-destroy", this.clearBindings.bind(this)); } }, { key: "mapBindings", @@ -18650,10 +19025,50 @@ _this.escEvent = _this.escMenu.bind(_assertThisInitialized(_this)); _this.nestedMenuBlock = false; _this.positionReversedX = false; + + _this.registerTableOption("rowContextMenu", false); + + _this.registerTableOption("rowClickMenu", false); + + _this.registerTableOption("groupContextMenu", false); + + _this.registerTableOption("groupClickMenu", false); + + _this.registerColumnOption("headerContextMenu"); + + _this.registerColumnOption("headerMenu"); + + _this.registerColumnOption("contextMenu"); + + _this.registerColumnOption("clickMenu"); + return _this; } _createClass(Menu, [{ + key: "initialize", + value: function initialize() { + this.subscribe("cell-layout", this.layoutCell.bind(this)); + this.subscribe("column-init", this.initializeColumn.bind(this)); + this.subscribe("row-init", this.initializeRow.bind(this)); + } + }, { + key: "layoutCell", + value: function layoutCell(cell) { + if (cell.column.definition.contextMenu || cell.column.definition.clickMenu) { + this.initializeCell(cell); + } + } + }, { + key: "initializeColumn", + value: function initializeColumn(column) { + var def = column.definition; + + if (def.headerContextMenu || def.headerClickMenu || def.headerMenu) { + this.initializeColumnHeader(this); + } + } + }, { key: "initializeColumnHeader", value: function initializeColumnHeader(column) { var _this2 = this; @@ -18882,7 +19297,7 @@ y = touch ? e.touches[0].pageY : e.pageY; this.positionReversedX = false; } else { - parentOffset = Helpers.elOffset(parentEl); + parentOffset = Helpers$1.elOffset(parentEl); x = parentOffset.left + parentEl.offsetWidth; y = parentOffset.top - 1; } @@ -18990,6 +19405,10 @@ _this.touchMove = false; _this.moveHover = _this.moveHover.bind(_assertThisInitialized(_this)); _this.endMove = _this.endMove.bind(_assertThisInitialized(_this)); + + _this.registerTableOption("movableColumns", false); //enable movable columns + + return _this; } @@ -19001,6 +19420,11 @@ el.classList.add("tabulator-col-placeholder"); return el; } + }, { + key: "initialize", + value: function initialize() { + this.subscribe("column-init", this.initializeColumn.bind(this)); + } }, { key: "initializeColumn", value: function initializeColumn(column) { @@ -19013,7 +19437,7 @@ config.mousemove = function (e) { if (column.parent === self.moving.parent) { - if ((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(colEl).left + self.table.columnManager.element.scrollLeft > column.getWidth() / 2) { + if ((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(colEl).left + self.table.columnManager.element.scrollLeft > column.getWidth() / 2) { if (self.toCol !== column || !self.toColAfter) { colEl.parentNode.insertBefore(self.placeholderElement, colEl.nextSibling); self.moveColumn(column, true); @@ -19140,7 +19564,7 @@ value: function startMove(e, column) { var element = column.getElement(); this.moving = column; - this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left; + this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(element).left; this.table.element.classList.add("tabulator-block-select"); //create placeholder this.placeholderElement.style.width = column.getWidth() + "px"; @@ -19232,7 +19656,7 @@ var columnHolder = this.table.columnManager.getElement(), scrollLeft = columnHolder.scrollLeft, - xPos = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(columnHolder).left + scrollLeft, + xPos = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers$1.elOffset(columnHolder).left + scrollLeft, scrollPos; this.hoverElement.style.left = xPos - this.startX + "px"; @@ -19304,6 +19728,22 @@ _this.connections = []; _this.connectedTable = false; _this.connectedRow = false; + + _this.registerTableOption("movableRows", false); //enable movable rows + + + _this.registerTableOption("movableRowsConnectedTables", false); //tables for movable rows to be connected to + + + _this.registerTableOption("movableRowsConnectedElements", false); //other elements for movable rows to be connected to + + + _this.registerTableOption("movableRowsSender", false); + + _this.registerTableOption("movableRowsReceiver", "insert"); + + _this.registerColumnOption("rowHandle"); + return _this; } @@ -19317,15 +19757,15 @@ } }, { key: "initialize", - value: function initialize(handle) { - this.connectionSelectorsTables = this.table.options.movableRowsConnectedTables; - this.connectionSelectorsElements = this.table.options.movableRowsConnectedElements; - this.connection = this.connectionSelectorsTables || this.connectionSelectorsElements; - } - }, { - key: "setHandle", - value: function setHandle(handle) { - this.hasHandle = handle; + value: function initialize() { + if (this.table.options.movableRows) { + this.connectionSelectorsTables = this.table.options.movableRowsConnectedTables; + this.connectionSelectorsElements = this.table.options.movableRowsConnectedElements; + this.connection = this.connectionSelectorsTables || this.connectionSelectorsElements; + this.subscribe("cell-init", this.initializeCell.bind(this)); + this.subscribe("column-init", this.initializeColumn.bind(this)); + this.subscribe("row-init", this.initializeRow.bind(this)); + } } }, { key: "initializeGroupHeader", @@ -19340,7 +19780,7 @@ config.mousemove = function (e) { - if (e.pageY - Helpers.elOffset(group.element).top + self.table.rowManager.element.scrollTop > group.getHeight() / 2) { + if (e.pageY - Helpers$1.elOffset(group.element).top + self.table.rowManager.element.scrollTop > group.getHeight() / 2) { if (self.toRow !== group || !self.toRowAfter) { var rowEl = group.getElement(); rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling); @@ -19375,7 +19815,7 @@ config.mousemove = function (e) { var rowEl = row.getElement(); - if (e.pageY - Helpers.elOffset(rowEl).top + self.table.rowManager.element.scrollTop > row.getHeight() / 2) { + if (e.pageY - Helpers$1.elOffset(rowEl).top + self.table.rowManager.element.scrollTop > row.getHeight() / 2) { if (self.toRow !== row || !self.toRowAfter) { rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling); self.moveRow(row, true); @@ -19409,26 +19849,35 @@ row.modules.moveRow = config; } + }, { + key: "initializeColumn", + value: function initializeColumn(column) { + if (column.definition.rowHandle && this.table.options.movableRows !== false) { + this.hasHandle = true; + } + } }, { key: "initializeCell", value: function initializeCell(cell) { - var self = this, - cellEl = cell.getElement(true); - cellEl.addEventListener("mousedown", function (e) { - if (e.which === 1) { - self.checkTimeout = setTimeout(function () { - self.startMove(e, cell.row); - }, self.checkPeriod); - } - }); - cellEl.addEventListener("mouseup", function (e) { - if (e.which === 1) { - if (self.checkTimeout) { - clearTimeout(self.checkTimeout); + if (cell.column.definition.rowHandle && this.table.options.movableRows !== false) { + var self = this, + cellEl = cell.getElement(true); + cellEl.addEventListener("mousedown", function (e) { + if (e.which === 1) { + self.checkTimeout = setTimeout(function () { + self.startMove(e, cell.row); + }, self.checkPeriod); } - } - }); - this.bindTouchEvents(cell.row, cellEl); + }); + cellEl.addEventListener("mouseup", function (e) { + if (e.which === 1) { + if (self.checkTimeout) { + clearTimeout(self.checkTimeout); + } + } + }); + this.bindTouchEvents(cell.row, cellEl); + } } }, { key: "bindTouchEvents", @@ -19660,7 +20109,7 @@ key: "elementRowDrop", value: function elementRowDrop(e, element, row) { if (this.table.options.movableRowsElementDrop) { - this.table.options.movableRowsElementDrop(e, element, row ? row.getComponent() : false); + this.dispatchExternal("movableRowsElementDrop", e, element, row ? row.getComponent() : false); } } //establish connection with other tables @@ -19672,9 +20121,9 @@ var connectionTables; if (this.connectionSelectorsTables) { - connectionTables = this.table.modules.comms.getConnections(this.connectionSelectorsTables); - this.table.options.movableRowsSendingStart.call(this.table, connectionTables); - this.table.modules.comms.send(this.connectionSelectorsTables, "moveRow", "connect", { + connectionTables = this.commsConnections(this.connectionSelectorsTables); + this.dispatchExternal("movableRowsSendingStart", connectionTables); + this.commsSend(this.connectionSelectorsTables, "moveRow", "connect", { row: row }); } @@ -19711,9 +20160,9 @@ var connectionTables; if (this.connectionSelectorsTables) { - connectionTables = this.table.modules.comms.getConnections(this.connectionSelectorsTables); - this.table.options.movableRowsSendingStop.call(this.table, connectionTables); - this.table.modules.comms.send(this.connectionSelectorsTables, "moveRow", "disconnect"); + connectionTables = this.commsConnections(this.connectionSelectorsTables); + this.dispatchExternal("movableRowsSendingStop", connectionTables); + this.commsSend(this.connectionSelectorsTables, "moveRow", "disconnect"); } this.connectionElements.forEach(function (element) { @@ -19737,7 +20186,7 @@ }); this.tableRowDropEvent = this.tableRowDrop.bind(this); this.table.element.addEventListener("mouseup", this.tableRowDropEvent); - this.table.options.movableRowsReceivingStart.call(this.table, row, table); + this.dispatchExternal("movableRowsReceivingStart", row, table); return true; } else { console.warn("Move Row Error - Table cannot accept connection, already connected to table:", this.connectedTable); @@ -19758,7 +20207,7 @@ } }); this.table.element.removeEventListener("mouseup", this.tableRowDropEvent); - this.table.options.movableRowsReceivingStop.call(this.table, table); + this.dispatchExternal("movableRowsReceivingStop", table); } else { console.warn("Move Row Error - trying to disconnect from non connected table"); } @@ -19787,9 +20236,9 @@ } } - this.table.options.movableRowsSent.call(this.table, this.moving.getComponent(), row ? row.getComponent() : undefined, table); + this.dispatchExternal("movableRowsSent", this.moving.getComponent(), row ? row.getComponent() : undefined, table); } else { - this.table.options.movableRowsSentFailed.call(this.table, this.moving.getComponent(), row ? row.getComponent() : undefined, table); + this.dispatchExternal("movableRowsSentFailed", this.moving.getComponent(), row ? row.getComponent() : undefined, table); } this.endMove(); @@ -19818,12 +20267,12 @@ } if (success) { - this.table.options.movableRowsReceived.call(this.table, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable); + this.dispatchExternal("movableRowsReceived", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable); } else { - this.table.options.movableRowsReceivedFailed.call(this.table, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable); + this.dispatchExternal("movableRowsReceivedFailed", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable); } - this.table.modules.comms.send(this.connectedTable, "moveRow", "dropcomplete", { + this.commsSend(this.connectedTable, "moveRow", "dropcomplete", { row: row, success: success }); @@ -19897,11 +20346,41 @@ _this.allowedTypes = ["", "data", "edit", "clipboard"]; //list of muatation types _this.enabled = true; - return _this; - } //initialize column mutator + _this.registerColumnOption("mutator"); + + _this.registerColumnOption("mutatorParams"); + + _this.registerColumnOption("mutatorData"); + + _this.registerColumnOption("mutatorDataParams"); + + _this.registerColumnOption("mutatorEdit"); + + _this.registerColumnOption("mutatorEditParams"); + + _this.registerColumnOption("mutatorClipboard"); + + _this.registerColumnOption("mutatorClipboardParams"); + + return _this; + } _createClass(Mutator, [{ + key: "initialize", + value: function initialize() { + this.subscribe("cell-value-changing", this.transformCell.bind(this)); + this.subscribe("column-layout", this.initializeColumn.bind(this)); + this.subscribe("row-data-init-before", this.rowDataChanged.bind(this)); + this.subscribe("row-data-changing", this.rowDataChanged.bind(this)); + } + }, { + key: "rowDataChanged", + value: function rowDataChanged(row, tempData, updatedData) { + return this.transformRow(tempData, "data", updatedData); + } //initialize column mutator + + }, { key: "initializeColumn", value: function initializeColumn(column) { var _this2 = this; @@ -19984,16 +20463,18 @@ }, { key: "transformCell", value: function transformCell(cell, value) { - var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator || false, - tempData = {}; + if (cell.column.modules.mutate) { + var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator || false, + tempData = {}; - if (mutator) { - tempData = Object.assign(tempData, cell.row.getData()); - cell.column.setFieldValue(tempData, value); - return mutator.mutator(value, tempData, "edit", mutator.params, cell.getComponent()); - } else { - return value; + if (mutator) { + tempData = Object.assign(tempData, cell.row.getData()); + cell.column.setFieldValue(tempData, value); + return mutator.mutator(value, tempData, "edit", mutator.params, cell.getComponent()); + } } + + return value; } }, { key: "enable", @@ -20014,19 +20495,6 @@ Mutator.mutators = defaultMutators; - var defaultDataSentNames = { - "page": "page", - "size": "size", - "sorters": "sorters", - "filters": "filters" - }; - - var defaultDataReceivedNames = { - "current_page": "current_page", - "last_page": "last_page", - "data": "data" - }; - var Page = /*#__PURE__*/function (_Module) { _inherits(Page, _Module); @@ -20047,16 +20515,237 @@ _this.displayIndex = 0; //index in display pipeline _this.initialLoad = true; + _this.dataChanging = false; //flag to check if data is being changed by this module + _this.pageSizes = []; - _this.dataReceivedNames = {}; - _this.dataSentNames = {}; + _this.dataReceivedNames = {}; //TODO - remove once pagimation update is complete + + _this.dataSentNames = {}; //TODO - remove once pagimation update is complete + + _this.registerTableOption("pagination", false); //set pagination type + + + _this.registerTableOption("paginationMode", "local"); //local or remote pagination + - _this.createElements(); + _this.registerTableOption("paginationSize", false); //set number of rows to a page + + + _this.registerTableOption("paginationInitialPage", 1); //initail page to show on load + + + _this.registerTableOption("paginationButtonCount", 5); // set count of page button + + + _this.registerTableOption("paginationSizeSelector", false); //add pagination size selector element + + + _this.registerTableOption("paginationElement", false); //element to hold pagination numbers + // this.registerTableOption("paginationDataSent", {}); //pagination data sent to the server + // this.registerTableOption("paginationDataReceived", {}); //pagination data received from the server + + + _this.registerTableOption("paginationAddRow", "page"); //add rows on table or page + + + _this.registerTableOption("progressiveLoad", false); //progressive loading + + + _this.registerTableOption("progressiveLoadDelay", 0); //delay between requests + + + _this.registerTableOption("progressiveLoadScrollMargin", 0); //margin before scroll begins + + + _this.registerTableFunction("setMaxPage", _this.setMaxPage.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setPage", _this.setPage.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setPageToRow", _this.userSetPageToRow.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("setPageSize", _this.userSetPageSize.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getPageSize", _this.getPageSize.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("previousPage", _this.previousPage.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("nextPage", _this.nextPage.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getPage", _this.getPage.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getPageMax", _this.getPageMax.bind(_assertThisInitialized(_this))); //register component functions + + + _this.registerComponentFunction("row", "pageTo", _this.setPageToRow.bind(_assertThisInitialized(_this))); return _this; } _createClass(Page, [{ + key: "initialize", + value: function initialize() { + if (this.table.options.pagination) { + this.subscribe("row-deleted", this.rowsUpdated.bind(this)); + this.subscribe("row-adding-position", this.rowAddingPosition.bind(this)); + this.subscribe("row-added", this.rowsUpdated.bind(this)); + this.subscribe("data-processed", this.initialLoadComplete.bind(this)); + this.subscribe("table-built", this.calculatePageSizes.bind(this)); + + if (this.table.options.paginationMode === "remote") { + this.subscribe("data-params", this.remotePageParams.bind(this)); + this.subscribe("data-loaded", this._parseRemoteData.bind(this)); + } + + if (this.table.options.progressiveLoad) { + console.error("Progressive Load Error - Pagination and progressive load cannot be used at the same time"); + } + + this.registerDisplayHandler(this.restOnRenderBefore.bind(this), 40); + this.registerDisplayHandler(this.getRows.bind(this), 50); + this.createElements(); + this.initializePaginator(); + } else if (this.table.options.progressiveLoad) { + this.subscribe("data-params", this.remotePageParams.bind(this)); + this.subscribe("data-loaded", this._parseRemoteData.bind(this)); + this.initializeProgressive(this.table.options.progressiveLoad); + + if (this.table.options.progressiveLoad === "scroll") { + this.subscribe("scroll-vertical", this.scrollVertical.bind(this)); + } + } + } + }, { + key: "rowAddingPosition", + value: function rowAddingPosition(row, top) { + var rowManager = this.table.rowManager, + dispRows = rowManager.getDisplayRows(), + index; + + if (top) { + if (dispRows.length) { + index = dispRows[0]; + } else { + if (rowManager.activeRows.length) { + index = rowManager.activeRows[rowManager.activeRows.length - 1]; + top = false; + } + } + } else { + if (dispRows.length) { + index = dispRows[dispRows.length - 1]; + top = dispRows.length < this.size ? false : true; + } + } + + return { + index: index, + top: top + }; + } + }, { + key: "calculatePageSizes", + value: function calculatePageSizes() { + var testElRow, testElCell; + + if (this.table.options.paginationSize) { + this.size = this.table.options.paginationSize; + } else { + testElRow = document.createElement("div"); + testElRow.classList.add("tabulator-row"); + testElRow.style.visibility = "hidden"; + testElCell = document.createElement("div"); + testElCell.classList.add("tabulator-cell"); + testElCell.innerHTML = "Page Row Test"; + testElRow.appendChild(testElCell); + this.table.rowManager.getTableElement().appendChild(testElRow); + this.size = Math.floor(this.table.rowManager.getElement().clientHeight / testElRow.offsetHeight); + this.table.rowManager.getTableElement().removeChild(testElRow); + } + } + }, { + key: "initialLoadComplete", + value: function initialLoadComplete() { + this.initialLoad = false; + } + }, { + key: "remotePageParams", + value: function remotePageParams(data, config, silent, params) { + if (!this.initialLoad) { + if (this.progressiveLoad && !silent || !this.progressiveLoad && !this.dataChanging) { + this.reset(true); + } + } //configure request params + + + params.page = this.page; //set page size if defined + + if (this.size) { + params.size = this.size; + } + + return params; + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "userSetPageToRow", + value: function userSetPageToRow(row) { + if (this.table.options.pagination) { + row = this.rowManager.findRow(row); + + if (row) { + return this.setPageToRow(row); + } + } + + return Promise.reject(); + } + }, { + key: "userSetPageSize", + value: function userSetPageSize(size) { + if (this.table.options.pagination) { + this.setPageSize(size); + return this.setPage(1); + } else { + return false; + } + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + + }, { + key: "scrollVertical", + value: function scrollVertical(top, dir) { + var element, diff, margin; + + if (!dir && !this.table.dataLoader.loading) { + element = this.table.rowManager.getElement(); + diff = element.scrollHeight - element.clientHeight - top; + margin = this.table.options.progressiveLoadScrollMargin || element.clientHeight * 2; + + if (diff < margin) { + this.nextPage(); + } + } + } + }, { + key: "restOnRenderBefore", + value: function restOnRenderBefore(rows, renderInPosition) { + if (!renderInPosition) { + if (this.mode === "local") { + this.reset(); + } + } + + return rows; + } + }, { + key: "rowsUpdated", + value: function rowsUpdated() { + this.refreshData(true, "all"); + } + }, { key: "createElements", value: function createElements() { var button; @@ -20122,7 +20811,7 @@ itemEl.value = item; if (item === true) { - _this2.table.modules.localize.bind("pagination|all", function (value) { + _this2.langBind("pagination|all", function (value) { itemEl.innerHTML = value; }); } else { @@ -20131,131 +20820,119 @@ _this2.pageSizeSelect.appendChild(itemEl); }); - this.pageSizeSelect.value = this.size; - } - } //setup pageination - - }, { - key: "initialize", - value: function initialize(hidden) { - var _this3 = this; - - var pageSelectLabel, testElRow, testElCell; //update param names - - this.dataSentNames = Object.assign({}, Page.defaultDataSentNames); - this.dataSentNames = Object.assign(this.dataSentNames, this.table.options.paginationDataSent); - this.dataReceivedNames = Object.assign({}, Page.defaultDataReceivedNames); - this.dataReceivedNames = Object.assign(this.dataReceivedNames, this.table.options.paginationDataReceived); //build pagination element - //bind localizations - - this.table.modules.localize.bind("pagination|first", function (value) { - _this3.firstBut.innerHTML = value; - }); - this.table.modules.localize.bind("pagination|first_title", function (value) { - _this3.firstBut.setAttribute("aria-label", value); - - _this3.firstBut.setAttribute("title", value); - }); - this.table.modules.localize.bind("pagination|prev", function (value) { - _this3.prevBut.innerHTML = value; - }); - this.table.modules.localize.bind("pagination|prev_title", function (value) { - _this3.prevBut.setAttribute("aria-label", value); - - _this3.prevBut.setAttribute("title", value); - }); - this.table.modules.localize.bind("pagination|next", function (value) { - _this3.nextBut.innerHTML = value; - }); - this.table.modules.localize.bind("pagination|next_title", function (value) { - _this3.nextBut.setAttribute("aria-label", value); - - _this3.nextBut.setAttribute("title", value); - }); - this.table.modules.localize.bind("pagination|last", function (value) { - _this3.lastBut.innerHTML = value; - }); - this.table.modules.localize.bind("pagination|last_title", function (value) { - _this3.lastBut.setAttribute("aria-label", value); + this.pageSizeSelect.value = this.size; + } + } //setup pageination - _this3.lastBut.setAttribute("title", value); - }); //click bindings + }, { + key: "initializePaginator", + value: function initializePaginator(hidden) { + var _this3 = this; - this.firstBut.addEventListener("click", function () { - _this3.setPage(1).then(function () {})["catch"](function () {}); - }); - this.prevBut.addEventListener("click", function () { - _this3.previousPage().then(function () {})["catch"](function () {}); - }); - this.nextBut.addEventListener("click", function () { - _this3.nextPage().then(function () {})["catch"](function () {}); - }); - this.lastBut.addEventListener("click", function () { - _this3.setPage(_this3.max).then(function () {})["catch"](function () {}); - }); + var pageSelectLabel; - if (this.table.options.paginationElement) { - this.element = this.table.options.paginationElement; - } + if (!hidden) { + //build pagination element + //bind localizations + this.langBind("pagination|first", function (value) { + _this3.firstBut.innerHTML = value; + }); + this.langBind("pagination|first_title", function (value) { + _this3.firstBut.setAttribute("aria-label", value); - if (this.pageSizeSelect) { - pageSelectLabel = document.createElement("label"); - this.table.modules.localize.bind("pagination|page_size", function (value) { - _this3.pageSizeSelect.setAttribute("aria-label", value); + _this3.firstBut.setAttribute("title", value); + }); + this.langBind("pagination|prev", function (value) { + _this3.prevBut.innerHTML = value; + }); + this.langBind("pagination|prev_title", function (value) { + _this3.prevBut.setAttribute("aria-label", value); - _this3.pageSizeSelect.setAttribute("title", value); + _this3.prevBut.setAttribute("title", value); + }); + this.langBind("pagination|next", function (value) { + _this3.nextBut.innerHTML = value; + }); + this.langBind("pagination|next_title", function (value) { + _this3.nextBut.setAttribute("aria-label", value); - pageSelectLabel.innerHTML = value; + _this3.nextBut.setAttribute("title", value); }); - this.element.appendChild(pageSelectLabel); - this.element.appendChild(this.pageSizeSelect); - this.pageSizeSelect.addEventListener("change", function (e) { - _this3.setPageSize(_this3.pageSizeSelect.value == "true" ? true : _this3.pageSizeSelect.value); + this.langBind("pagination|last", function (value) { + _this3.lastBut.innerHTML = value; + }); + this.langBind("pagination|last_title", function (value) { + _this3.lastBut.setAttribute("aria-label", value); + + _this3.lastBut.setAttribute("title", value); + }); //click bindings - _this3.setPage(1).then(function () {})["catch"](function () {}); + this.firstBut.addEventListener("click", function () { + _this3.setPage(1); + }); + this.prevBut.addEventListener("click", function () { + _this3.previousPage(); + }); + this.nextBut.addEventListener("click", function () { + _this3.nextPage(); + }); + this.lastBut.addEventListener("click", function () { + _this3.setPage(_this3.max); }); - } //append to DOM + if (this.table.options.paginationElement) { + this.element = this.table.options.paginationElement; + } - this.element.appendChild(this.firstBut); - this.element.appendChild(this.prevBut); - this.element.appendChild(this.pagesElement); - this.element.appendChild(this.nextBut); - this.element.appendChild(this.lastBut); + if (this.pageSizeSelect) { + pageSelectLabel = document.createElement("label"); + this.langBind("pagination|page_size", function (value) { + _this3.pageSizeSelect.setAttribute("aria-label", value); - if (!this.table.options.paginationElement && !hidden) { - this.table.footerManager.append(this.element, this); - } //set default values + _this3.pageSizeSelect.setAttribute("title", value); + pageSelectLabel.innerHTML = value; + }); + this.element.appendChild(pageSelectLabel); + this.element.appendChild(this.pageSizeSelect); + this.pageSizeSelect.addEventListener("change", function (e) { + _this3.setPageSize(_this3.pageSizeSelect.value == "true" ? true : _this3.pageSizeSelect.value); - this.mode = this.table.options.pagination; + _this3.setPage(1); + }); + } //append to DOM - if (this.table.options.paginationSize) { - this.size = this.table.options.paginationSize; - } else { - testElRow = document.createElement("div"); - testElRow.classList.add("tabulator-row"); - testElRow.style.visibility = hidden; - testElCell = document.createElement("div"); - testElCell.classList.add("tabulator-cell"); - testElCell.innerHTML = "Page Row Test"; - testElRow.appendChild(testElCell); - this.table.rowManager.getTableElement().appendChild(testElRow); - this.size = Math.floor(this.table.rowManager.getElement().clientHeight / testElRow.offsetHeight); - this.table.rowManager.getTableElement().removeChild(testElRow); - } // this.page = this.table.options.paginationInitialPage || 1; + this.element.appendChild(this.firstBut); + this.element.appendChild(this.prevBut); + this.element.appendChild(this.pagesElement); + this.element.appendChild(this.nextBut); + this.element.appendChild(this.lastBut); + + if (!this.table.options.paginationElement && !hidden) { + this.table.footerManager.append(this.element, this); + } + + this.page = this.table.options.paginationInitialPage; + this.count = this.table.options.paginationButtonCount; + this.generatePageSizeSelectList(); + } //set default values - this.count = this.table.options.paginationButtonCount; - this.generatePageSizeSelectList(); + + this.mode = this.table.options.paginationMode; } }, { key: "initializeProgressive", value: function initializeProgressive(mode) { - this.initialize(true); + this.initializePaginator(true); this.mode = "progressive_" + mode; this.progressiveLoad = true; } + }, { + key: "trackChanges", + value: function trackChanges() { + this.dispatch("page-changed"); + } }, { key: "setDisplayIndex", value: function setDisplayIndex(index) { @@ -20283,16 +20960,12 @@ }, { key: "reset", - value: function reset(force, columnsChanged) { - if (this.mode == "local" || force) { - this.page = 1; - } - - if (columnsChanged) { - this.initialLoad = true; + value: function reset(force) { + if (!this.initialLoad) { + if (this.mode == "local" || force) { + this.page = 1; + } } - - return true; } //set the maxmum page }, { @@ -20310,8 +20983,6 @@ }, { key: "setPage", value: function setPage(page) { - var _this4 = this; - switch (page) { case "first": return this.setPage(1); @@ -20326,50 +20997,30 @@ return this.setPage(this.max); } - return new Promise(function (resolve, reject) { - page = parseInt(page); - - if (page > 0 && page <= _this4.max || _this4.mode !== "local") { - _this4.page = page; - - _this4.trigger().then(function () { - resolve(); - })["catch"](function () { - reject(); - }); + page = parseInt(page); - if (_this4.table.options.persistence && _this4.table.modExists("persistence", true) && _this4.table.modules.persistence.config.page) { - _this4.table.modules.persistence.save("page"); - } - } else { - console.warn("Pagination Error - Requested page is out of range of 1 - " + _this4.max + ":", page); - reject(); - } - }); + if (page > 0 && page <= this.max || this.mode !== "local") { + this.page = page; + this.trackChanges(); + return this.trigger(); + } else { + console.warn("Pagination Error - Requested page is out of range of 1 - " + this.max + ":", page); + return Promise.reject(); + } } }, { key: "setPageToRow", value: function setPageToRow(row) { - var _this5 = this; + var rows = this.table.rowManager.getDisplayRows(this.displayIndex - 1); + var index = rows.indexOf(row); - return new Promise(function (resolve, reject) { - var rows = _this5.table.rowManager.getDisplayRows(_this5.displayIndex - 1); - - var index = rows.indexOf(row); - - if (index > -1) { - var page = _this5.size === true ? 1 : Math.ceil((index + 1) / _this5.size); - - _this5.setPage(page).then(function () { - resolve(); - })["catch"](function () { - reject(); - }); - } else { - console.warn("Pagination Error - Requested row is not visible"); - reject(); - } - }); + if (index > -1) { + var page = this.size === true ? 1 : Math.ceil((index + 1) / this.size); + return this.setPage(page); + } else { + console.warn("Pagination Error - Requested row is not visible"); + return Promise.reject(); + } } }, { key: "setPageSize", @@ -20387,9 +21038,7 @@ this.generatePageSizeSelectList(); } - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.page) { - this.table.modules.persistence.save("page"); - } + this.trackChanges(); } //setup the pagination buttons }, { @@ -20431,7 +21080,7 @@ }, { key: "_generatePageButton", value: function _generatePageButton(page) { - var _this6 = this; + var _this4 = this; var button = document.createElement("button"); button.classList.add("tabulator-page"); @@ -20442,14 +21091,14 @@ button.setAttribute("type", "button"); button.setAttribute("role", "button"); - this.table.modules.localize.bind("pagination|page_title", function (value) { + this.langBind("pagination|page_title", function (value) { button.setAttribute("aria-label", value + " " + page); button.setAttribute("title", value + " " + page); }); button.setAttribute("data-page", page); button.textContent = page; button.addEventListener("click", function (e) { - _this6.setPage(page).then(function () {})["catch"](function () {}); + _this4.setPage(page); }); return button; } //previous page @@ -20457,54 +21106,30 @@ }, { key: "previousPage", value: function previousPage() { - var _this7 = this; - - return new Promise(function (resolve, reject) { - if (_this7.page > 1) { - _this7.page--; - - _this7.trigger().then(function () { - resolve(); - })["catch"](function () { - reject(); - }); - - if (_this7.table.options.persistence && _this7.table.modExists("persistence", true) && _this7.table.modules.persistence.config.page) { - _this7.table.modules.persistence.save("page"); - } - } else { - console.warn("Pagination Error - Previous page would be less than page 1:", 0); - reject(); - } - }); + if (this.page > 1) { + this.page--; + this.trackChanges(); + return this.trigger(); + } else { + console.warn("Pagination Error - Previous page would be less than page 1:", 0); + return Promise.reject(); + } } //next page }, { key: "nextPage", value: function nextPage() { - var _this8 = this; - - return new Promise(function (resolve, reject) { - if (_this8.page < _this8.max) { - _this8.page++; - - _this8.trigger().then(function () { - resolve(); - })["catch"](function () { - reject(); - }); - - if (_this8.table.options.persistence && _this8.table.modExists("persistence", true) && _this8.table.modules.persistence.config.page) { - _this8.table.modules.persistence.save("page"); - } - } else { - if (!_this8.progressiveLoad) { - console.warn("Pagination Error - Next page would be greater than maximum page of " + _this8.max + ":", _this8.max + 1); - } - - reject(); + if (this.page < this.max) { + this.page++; + this.trackChanges(); + return this.trigger(); + } else { + if (!this.progressiveLoad) { + console.warn("Pagination Error - Next page would be greater than maximum page of " + this.max + ":", this.max + 1); } - }); + + return Promise.reject(); + } } //return current page number }, { @@ -20536,6 +21161,7 @@ if (this.mode == "local") { output = []; + this.setMaxRows(data.length); if (this.size === true) { start = 0; @@ -20563,147 +21189,89 @@ }, { key: "trigger", value: function trigger() { - var _this9 = this; + var _this5 = this; var left; - return new Promise(function (resolve, reject) { - switch (_this9.mode) { - case "local": - left = _this9.table.rowManager.scrollLeft; - - _this9.table.rowManager.refreshActiveData("page"); - - _this9.table.rowManager.scrollHorizontal(left); - - _this9.table.options.pageLoaded.call(_this9.table, _this9.getPage()); - - resolve(); - break; - - case "remote": - case "progressive_load": - case "progressive_scroll": - _this9.table.modules.ajax.blockActiveRequest(); - - _this9._getRemotePage().then(function () { - resolve(); - })["catch"](function () { - reject(); - }); - - break; - - default: - console.warn("Pagination Error - no such pagination mode:", _this9.mode); - reject(); - } - }); - } - }, { - key: "_getRemotePage", - value: function _getRemotePage() { - var _this10 = this; - - var oldParams, pageParams; - return new Promise(function (resolve, reject) { - if (!_this10.table.modExists("ajax", true)) { - reject(); - } //record old params and restore after request has been made - - - oldParams = Helpers.deepClone(_this10.table.modules.ajax.getParams() || {}); - pageParams = _this10.table.modules.ajax.getParams(); //configure request params - - pageParams[_this10.dataSentNames.page] = _this10.page; //set page size if defined - - if (_this10.size) { - pageParams[_this10.dataSentNames.size] = _this10.size; - } //set sort data if defined + switch (this.mode) { + case "local": + left = this.table.rowManager.scrollLeft; + this.refreshData(); + this.table.rowManager.scrollHorizontal(left); + this.dispatchExternal("pageLoaded", this.getPage()); + return Promise.resolve(); - if (_this10.table.options.ajaxSorting && _this10.table.modExists("sort")) { - var sorters = _this10.table.modules.sort.getSort(); - - sorters.forEach(function (item) { - delete item.column; + case "remote": + this.dataChanging = true; + return this.reloadData(null)["finally"](function () { + _this5.dataChanging = false; }); - pageParams[_this10.dataSentNames.sorters] = sorters; - } //set filter data if defined - - - if (_this10.table.options.ajaxFiltering && _this10.table.modExists("filter")) { - var filters = _this10.table.modules.filter.getFilters(true, true); - - pageParams[_this10.dataSentNames.filters] = filters; - } - - _this10.table.modules.ajax.setParams(pageParams); - _this10.table.modules.ajax.sendRequest(_this10.progressiveLoad).then(function (data) { - _this10._parseRemoteData(data); + case "progressive_load": + case "progressive_scroll": + return this.reloadData(null, true); - resolve(); - })["catch"](function (e) { - reject(); - }); - - _this10.table.modules.ajax.setParams(oldParams); - }); + default: + console.warn("Pagination Error - no such pagination mode:", this.mode); + return Promise.reject(); + } } }, { key: "_parseRemoteData", value: function _parseRemoteData(data) { - var _this11 = this; + var _this6 = this; - var left, data, margin; + var data, margin; - if (typeof data[this.dataReceivedNames.last_page] === "undefined") { + if (typeof data.last_page === "undefined") { console.warn("Remote Pagination Error - Server response missing '" + this.dataReceivedNames.last_page + "' property"); } - if (data[this.dataReceivedNames.data]) { - this.max = parseInt(data[this.dataReceivedNames.last_page]) || 1; + if (data.data) { + this.max = parseInt(data.last_page) || 1; if (this.progressiveLoad) { switch (this.mode) { case "progressive_load": if (this.page == 1) { - this.table.rowManager.setData(data[this.dataReceivedNames.data], false, this.initialLoad && this.page == 1); + this.table.rowManager.setData(data.data, false, this.page == 1); } else { - this.table.rowManager.addRows(data[this.dataReceivedNames.data]); + this.table.rowManager.addRows(data.data); } if (this.page < this.max) { setTimeout(function () { - _this11.nextPage().then(function () {})["catch"](function () {}); - }, this.table.options.ajaxProgressiveLoadDelay); + _this6.nextPage(); + }, this.table.options.progressiveLoadDelay); } break; case "progressive_scroll": - data = this.table.rowManager.getData().concat(data[this.dataReceivedNames.data]); - this.table.rowManager.setData(data, true, this.initialLoad && this.page == 1); - margin = this.table.options.ajaxProgressiveLoadScrollMargin || this.table.rowManager.element.clientHeight * 2; + data = this.table.rowManager.getData().concat(data.data); + this.table.rowManager.setData(data, this.page !== 1, this.page == 1); + margin = this.table.options.progressiveLoadScrollMargin || this.table.rowManager.element.clientHeight * 2; if (this.table.rowManager.element.scrollHeight <= this.table.rowManager.element.clientHeight + margin) { - this.nextPage().then(function () {})["catch"](function () {}); + setTimeout(function () { + _this6.nextPage(); + }); } break; } + + return false; } else { - left = this.table.rowManager.scrollLeft; - this.table.rowManager.setData(data[this.dataReceivedNames.data], false, this.initialLoad && this.page == 1); - this.table.rowManager.scrollHorizontal(left); - this.table.columnManager.scrollHorizontal(left); - this.table.options.pageLoaded.call(this.table, this.getPage()); + // left = this.table.rowManager.scrollLeft; + this.dispatchExternal("pageLoaded", this.getPage()); // this.table.rowManager.scrollHorizontal(left); + // this.table.columnManager.scrollHorizontal(left); } - - this.initialLoad = false; } else { console.warn("Remote Pagination Error - Server response missing '" + this.dataReceivedNames.data + "' property"); } + + return data.data; } //handle the footer element being redrawn }, { @@ -20726,10 +21294,7 @@ return Page; }(Module); - Page.moduleName = "page"; //load defaults - - Page.defaultDataSentNames = defaultDataSentNames; - Page.defaultDataReceivedNames = defaultDataReceivedNames; + Page.moduleName = "page"; // read peristence information from storage var defaultReaders = { @@ -20789,6 +21354,21 @@ _this.config = {}; _this.readFunc = false; _this.writeFunc = false; + + _this.registerTableOption("persistence", false); + + _this.registerTableOption("persistenceID", ""); //key for persistent storage + + + _this.registerTableOption("persistenceMode", true); //mode for storing persistence information + + + _this.registerTableOption("persistenceReaderFunc", false); //function for handling persistence data reading + + + _this.registerTableOption("persistenceWriterFunc", false); //function for handling persistence data writing + + return _this; } // Test for whether localStorage is available for use. @@ -20810,95 +21390,167 @@ }, { key: "initialize", value: function initialize() { - //determine persistent layout storage type - var mode = this.table.options.persistenceMode, - id = this.table.options.persistenceID, - retreivedData; - this.mode = mode !== true ? mode : this.localStorageTest() ? "local" : "cookie"; - - if (this.table.options.persistenceReaderFunc) { - if (typeof this.table.options.persistenceReaderFunc === "function") { - this.readFunc = this.table.options.persistenceReaderFunc; - } else { - if (Persistence.readers[this.table.options.persistenceReaderFunc]) { - this.readFunc = Persistence.readers[this.table.options.persistenceReaderFunc]; + if (this.table.options.persistence) { + //determine persistent layout storage type + var mode = this.table.options.persistenceMode, + id = this.table.options.persistenceID, + retreivedData; + this.mode = mode !== true ? mode : this.localStorageTest() ? "local" : "cookie"; + + if (this.table.options.persistenceReaderFunc) { + if (typeof this.table.options.persistenceReaderFunc === "function") { + this.readFunc = this.table.options.persistenceReaderFunc; } else { - console.warn("Persistence Read Error - invalid reader set", this.table.options.persistenceReaderFunc); + if (Persistence.readers[this.table.options.persistenceReaderFunc]) { + this.readFunc = Persistence.readers[this.table.options.persistenceReaderFunc]; + } else { + console.warn("Persistence Read Error - invalid reader set", this.table.options.persistenceReaderFunc); + } } - } - } else { - if (Persistence.readers[this.mode]) { - this.readFunc = Persistence.readers[this.mode]; } else { - console.warn("Persistence Read Error - invalid reader set", this.mode); + if (Persistence.readers[this.mode]) { + this.readFunc = Persistence.readers[this.mode]; + } else { + console.warn("Persistence Read Error - invalid reader set", this.mode); + } } - } - if (this.table.options.persistenceWriterFunc) { - if (typeof this.table.options.persistenceWriterFunc === "function") { - this.writeFunc = this.table.options.persistenceWriterFunc; - } else { - if (Persistence.writers[this.table.options.persistenceWriterFunc]) { - this.writeFunc = Persistence.writers[this.table.options.persistenceWriterFunc]; + if (this.table.options.persistenceWriterFunc) { + if (typeof this.table.options.persistenceWriterFunc === "function") { + this.writeFunc = this.table.options.persistenceWriterFunc; } else { - console.warn("Persistence Write Error - invalid reader set", this.table.options.persistenceWriterFunc); + if (Persistence.writers[this.table.options.persistenceWriterFunc]) { + this.writeFunc = Persistence.writers[this.table.options.persistenceWriterFunc]; + } else { + console.warn("Persistence Write Error - invalid reader set", this.table.options.persistenceWriterFunc); + } } - } - } else { - if (Persistence.writers[this.mode]) { - this.writeFunc = Persistence.writers[this.mode]; } else { - console.warn("Persistence Write Error - invalid writer set", this.mode); - } - } //set storage tag + if (Persistence.writers[this.mode]) { + this.writeFunc = Persistence.writers[this.mode]; + } else { + console.warn("Persistence Write Error - invalid writer set", this.mode); + } + } //set storage tag - this.id = "tabulator-" + (id || this.table.element.getAttribute("id") || ""); - this.config = { - sort: this.table.options.persistence === true || this.table.options.persistence.sort, - filter: this.table.options.persistence === true || this.table.options.persistence.filter, - group: this.table.options.persistence === true || this.table.options.persistence.group, - page: this.table.options.persistence === true || this.table.options.persistence.page, - columns: this.table.options.persistence === true ? ["title", "width", "visible"] : this.table.options.persistence.columns - }; //load pagination data if needed + this.id = "tabulator-" + (id || this.table.element.getAttribute("id") || ""); + this.config = { + sort: this.table.options.persistence === true || this.table.options.persistence.sort, + filter: this.table.options.persistence === true || this.table.options.persistence.filter, + group: this.table.options.persistence === true || this.table.options.persistence.group, + page: this.table.options.persistence === true || this.table.options.persistence.page, + columns: this.table.options.persistence === true ? ["title", "width", "visible"] : this.table.options.persistence.columns + }; //load pagination data if needed - if (this.config.page) { - retreivedData = this.retreiveData("page"); + if (this.config.page) { + retreivedData = this.retreiveData("page"); - if (retreivedData) { - if (typeof retreivedData.paginationSize !== "undefined" && (this.config.page === true || this.config.page.size)) { - this.table.options.paginationSize = retreivedData.paginationSize; + if (retreivedData) { + if (typeof retreivedData.paginationSize !== "undefined" && (this.config.page === true || this.config.page.size)) { + this.table.options.paginationSize = retreivedData.paginationSize; + } + + if (typeof retreivedData.paginationInitialPage !== "undefined" && (this.config.page === true || this.config.page.page)) { + this.table.options.paginationInitialPage = retreivedData.paginationInitialPage; + } } + } //load group data if needed + - if (typeof retreivedData.paginationInitialPage !== "undefined" && (this.config.page === true || this.config.page.page)) { - this.table.options.paginationInitialPage = retreivedData.paginationInitialPage; + if (this.config.group) { + retreivedData = this.retreiveData("group"); + + if (retreivedData) { + if (typeof retreivedData.groupBy !== "undefined" && (this.config.group === true || this.config.group.groupBy)) { + this.table.options.groupBy = retreivedData.groupBy; + } + + if (typeof retreivedData.groupStartOpen !== "undefined" && (this.config.group === true || this.config.group.groupStartOpen)) { + this.table.options.groupStartOpen = retreivedData.groupStartOpen; + } + + if (typeof retreivedData.groupHeader !== "undefined" && (this.config.group === true || this.config.group.groupHeader)) { + this.table.options.groupHeader = retreivedData.groupHeader; + } } } - } //load group data if needed + if (this.config.columns) { + this.table.options.columns = this.load("columns", this.table.options.columns); + this.subscribe("column-init", this.initializeColumn.bind(this)); + this.subscribe("column-show", this.save.bind(this, "columns")); + this.subscribe("column-hide", this.save.bind(this, "columns")); + this.subscribe("column-moved", this.save.bind(this, "columns")); + this.subscribe("table-built", this.tableBuilt.bind(this), 0); + } - if (this.config.group) { - retreivedData = this.retreiveData("group"); + this.subscribe("table-redraw", this.tableRedraw.bind(this)); + this.subscribe("filter-changed", this.eventSave.bind(this, "filter")); + this.subscribe("sort-changed", this.eventSave.bind(this, "sort")); + this.subscribe("group-changed", this.eventSave.bind(this, "group")); + this.subscribe("page-changed", this.eventSave.bind(this, "page")); + this.subscribe("column-resized", this.eventSave.bind(this, "columns")); + this.subscribe("layout-refreshed", this.eventSave.bind(this, "columns")); + } - if (retreivedData) { - if (typeof retreivedData.groupBy !== "undefined" && (this.config.group === true || this.config.group.groupBy)) { - this.table.options.groupBy = retreivedData.groupBy; - } + this.registerTableFunction("getColumnLayout", this.getColumnLayout.bind(this)); + this.registerTableFunction("setColumnLayout", this.setColumnLayout.bind(this)); + } + }, { + key: "eventSave", + value: function eventSave(type) { + if (this.config[type]) { + this.save(type); + } + } + }, { + key: "tableBuilt", + value: function tableBuilt() { + var options = this.table.options, + sorters, + filters; - if (typeof retreivedData.groupStartOpen !== "undefined" && (this.config.group === true || this.config.group.groupStartOpen)) { - this.table.options.groupStartOpen = retreivedData.groupStartOpen; - } + if (this.config.sort) { + sorters = this.load("sort"); - if (typeof retreivedData.groupHeader !== "undefined" && (this.config.group === true || this.config.group.groupHeader)) { - this.table.options.groupHeader = retreivedData.groupHeader; - } + if (!sorters === false) { + this.table.initialSort = sorters; } } - if (this.config.columns) { - this.table.options.columns = this.load("columns", this.table.options.columns); + if (this.config.filter) { + filters = this.load("filter"); + + if (!filters === false) { + this.table.initialFilter = filters; + } + } + } + }, { + key: "tableRedraw", + value: function tableRedraw(force) { + if (force && this.config.columns) { + this.save("columns"); } + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "getColumnLayout", + value: function getColumnLayout() { + return this.parseColumns(this.table.columnManager.getColumns()); } + }, { + key: "setColumnLayout", + value: function setColumnLayout(layout) { + this.table.columnManager.setColumns(this.mergeDefinition(this.table.options.columns, layout)); + return true; + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + }, { key: "initializeColumn", value: function initializeColumn(column) { @@ -21151,36 +21803,72 @@ } }]); - return Persistence; - }(Module); + return Persistence; + }(Module); + + Persistence.moduleName = "persistence"; //load defaults + + Persistence.readers = defaultReaders; + Persistence.writers = defaultWriters; + + var Print = /*#__PURE__*/function (_Module) { + _inherits(Print, _Module); + + var _super = _createSuper(Print); + + function Print(table) { + var _this; + + _classCallCheck(this, Print); + + _this = _super.call(this, table); + _this.element = false; + _this.manualBlock = false; + + _this.registerTableOption("printAsHtml", false); //enable print as html + + + _this.registerTableOption("printFormatter", false); //printing page formatter + + + _this.registerTableOption("printHeader", false); //page header contents + + + _this.registerTableOption("printFooter", false); //page footer contents + + + _this.registerTableOption("printStyled", true); //enable print as html styling + - Persistence.moduleName = "persistence"; //load defaults + _this.registerTableOption("printRowRange", "visible"); //restrict print to visible rows only - Persistence.readers = defaultReaders; - Persistence.writers = defaultWriters; - var Print = /*#__PURE__*/function (_Module) { - _inherits(Print, _Module); + _this.registerTableOption("printConfig", {}); //print config options - var _super = _createSuper(Print); - function Print(table) { - var _this; + _this.registerColumnOption("print"); - _classCallCheck(this, Print); + _this.registerColumnOption("titlePrint"); - _this = _super.call(this, table); - _this.element = false; - _this.manualBlock = false; return _this; } _createClass(Print, [{ key: "initialize", value: function initialize() { - window.addEventListener("beforeprint", this.replaceTable.bind(this)); - window.addEventListener("afterprint", this.cleanup.bind(this)); - } + if (this.table.options.printAsHtml) { + window.addEventListener("beforeprint", this.replaceTable.bind(this)); + window.addEventListener("afterprint", this.cleanup.bind(this)); + } + + this.registerTableFunction("print", this.printFullscreen.bind(this)); + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + }, { key: "replaceTable", value: function replaceTable() { @@ -21280,10 +21968,28 @@ _this.origFuncs = {}; // hold original data array functions to allow replacement after data is done with _this.currentVersion = 0; + + _this.registerTableOption("reactiveData", false); //enable data reactivity + + return _this; } _createClass(ReactiveData, [{ + key: "initialize", + value: function initialize() { + if (this.table.options.reactiveData) { + this.subscribe("cell-value-save-before", this.block.bind(this)); + this.subscribe("cell-value-save-after", this.unblock.bind(this)); + this.subscribe("row-data-save-before", this.block.bind(this)); + this.subscribe("row-data-save-after", this.unblock.bind(this)); + this.subscribe("row-data-init-after", this.watchRow.bind(this)); + this.subscribe("data-processing", this.watchData.bind(this)); + this.subscribe("data-processing", this.watchData.bind(this)); + this.subscribe("table-destroy", this.unwatchData.bind(this)); + } + } + }, { key: "watchData", value: function watchData(data) { var self = this, @@ -21588,15 +22294,37 @@ _this.startWidth = false; _this.handle = null; _this.prevHandle = null; + + _this.registerColumnOption("resizable", true); + return _this; } _createClass(ResizeColumns, [{ + key: "initialize", + value: function initialize() { + // if(this.table.options.resizableColumns){ + this.subscribe("cell-layout", this.layoutCellHandles.bind(this)); + this.subscribe("column-init", this.layoutColumnHeader.bind(this)); // } + } + }, { + key: "layoutCellHandles", + value: function layoutCellHandles(cell) { + if (cell.row.type === "row") { + this.initializeColumn("cell", cell.column, cell.element); + } + } + }, { + key: "layoutColumnHeader", + value: function layoutColumnHeader(column) { + this.initializeColumn("header", column, column.element); + } + }, { key: "initializeColumn", value: function initializeColumn(type, column, element) { var self = this, variableHeight = false, - mode = this.table.options.resizableColumns; //set column resize mode + mode = column.definition.resizable; //set column resize mode if (type === "header") { variableHeight = column.definition.formatter == "textarea" || column.definition.variableHeight; @@ -21683,7 +22411,7 @@ }, { key: "_checkResizability", value: function _checkResizability(column) { - return typeof column.definition.resizable != "undefined" ? column.definition.resizable : this.table.options.resizableColumns; + return column.definition.resizable; } }, { key: "_mouseDown", @@ -21699,9 +22427,7 @@ column.setWidth(self.startWidth + ((typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX) - self.startX)); } - if (self.table.options.virtualDomHoz) { - self.table.vdomHoz.reinitialize(true); - } + self.table.columnManager.renderer.rerenderColumns(true); if (!self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight) { column.checkCellHeights(); @@ -21723,12 +22449,8 @@ handle.removeEventListener("touchmove", mouseMove); handle.removeEventListener("touchend", mouseUp); self.table.element.classList.remove("tabulator-block-select"); - - if (self.table.options.persistence && self.table.modExists("persistence", true) && self.table.modules.persistence.config.columns) { - self.table.modules.persistence.save("columns"); - } - - self.table.options.columnResized.call(self.table, column.getComponent()); + self.dispatch("column-resized", column); + self.table.externalEvents.dispatch("columnResized", column.getComponent()); } e.stopPropagation(); //prevent resize from interfereing with movable columns @@ -21770,10 +22492,21 @@ _this.startHeight = false; _this.handle = null; _this.prevHandle = null; + + _this.registerTableOption("resizableRows", false); //resizable rows + + return _this; } _createClass(ResizeRows, [{ + key: "initialize", + value: function initialize() { + if (this.table.options.resizableRows) { + this.subscribe("row-layout-after", this.initializeRow.bind(this)); + } + } + }, { key: "initializeRow", value: function initializeRow(row) { var self = this, @@ -21837,7 +22570,7 @@ handle.removeEventListener("touchmove", mouseMove); handle.removeEventListener("touchend", mouseUp); self.table.element.classList.remove("tabulator-block-select"); - self.table.options.rowResized.call(this.table, row.getComponent()); + this.dispatchExternal("rowResized", row.getComponent()); } e.stopPropagation(); //prevent resize from interfereing with movable columns @@ -21881,90 +22614,97 @@ _this.containerHeight = 0; _this.containerWidth = 0; _this.autoResize = false; + + _this.registerTableOption("autoResize", true); //auto resize table + + return _this; } _createClass(ResizeTable, [{ key: "initialize", - value: function initialize(row) { + value: function initialize() { var _this2 = this; - var table = this.table, - tableStyle; - this.tableHeight = table.element.clientHeight; - this.tableWidth = table.element.clientWidth; - - if (table.element.parentNode) { - this.containerHeight = table.element.parentNode.clientHeight; - this.containerWidth = table.element.parentNode.clientWidth; - } - - if (typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual") { - this.autoResize = true; - this.observer = new ResizeObserver(function (entry) { - if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) { - var nodeHeight = Math.floor(entry[0].contentRect.height); - var nodeWidth = Math.floor(entry[0].contentRect.width); - - if (_this2.tableHeight != nodeHeight || _this2.tableWidth != nodeWidth) { - _this2.tableHeight = nodeHeight; - _this2.tableWidth = nodeWidth; - - if (table.element.parentNode) { - _this2.containerHeight = table.element.parentNode.clientHeight; - _this2.containerWidth = table.element.parentNode.clientWidth; - } - - if (table.options.virtualDomHoz) { - table.vdomHoz.reinitialize(true); - } + if (this.table.options.autoResize) { + var table = this.table, + tableStyle; + this.tableHeight = table.element.clientHeight; + this.tableWidth = table.element.clientWidth; - table.redraw(); - } - } - }); - this.observer.observe(table.element); - tableStyle = window.getComputedStyle(table.element); + if (table.element.parentNode) { + this.containerHeight = table.element.parentNode.clientHeight; + this.containerWidth = table.element.parentNode.clientWidth; + } - if (this.table.element.parentNode && !this.table.rowManager.fixedHeight && (tableStyle.getPropertyValue("max-height") || tableStyle.getPropertyValue("min-height"))) { - this.containerObserver = new ResizeObserver(function (entry) { + if (typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual") { + this.autoResize = true; + this.observer = new ResizeObserver(function (entry) { if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) { var nodeHeight = Math.floor(entry[0].contentRect.height); var nodeWidth = Math.floor(entry[0].contentRect.width); - if (_this2.containerHeight != nodeHeight || _this2.containerWidth != nodeWidth) { - _this2.containerHeight = nodeHeight; - _this2.containerWidth = nodeWidth; - _this2.tableHeight = table.element.clientHeight; - _this2.tableWidth = table.element.clientWidth; + if (_this2.tableHeight != nodeHeight || _this2.tableWidth != nodeWidth) { + _this2.tableHeight = nodeHeight; + _this2.tableWidth = nodeWidth; + + if (table.element.parentNode) { + _this2.containerHeight = table.element.parentNode.clientHeight; + _this2.containerWidth = table.element.parentNode.clientWidth; + } + + _this2.table.columnManager.renderer.rerenderColumns(true); + + table.redraw(); } + } + }); + this.observer.observe(table.element); + tableStyle = window.getComputedStyle(table.element); + + if (this.table.element.parentNode && !this.table.rowManager.fixedHeight && (tableStyle.getPropertyValue("max-height") || tableStyle.getPropertyValue("min-height"))) { + this.containerObserver = new ResizeObserver(function (entry) { + if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) { + var nodeHeight = Math.floor(entry[0].contentRect.height); + var nodeWidth = Math.floor(entry[0].contentRect.width); + + if (_this2.containerHeight != nodeHeight || _this2.containerWidth != nodeWidth) { + _this2.containerHeight = nodeHeight; + _this2.containerWidth = nodeWidth; + _this2.tableHeight = table.element.clientHeight; + _this2.tableWidth = table.element.clientWidth; + } - if (table.options.virtualDomHoz) { - table.vdomHoz.reinitialize(true); + table.columnManager.renderer.rerenderColumns(true); + table.redraw(); } + }); + this.containerObserver.observe(this.table.element.parentNode); + } + this.subscribe("table-resize", this.tableResized.bind(this)); + } else { + this.binding = function () { + if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) { + table.columnManager.renderer.rerenderColumns(true); table.redraw(); } - }); - this.containerObserver.observe(this.table.element.parentNode); - } - } else { - this.binding = function () { - if (!table.browserMobile || table.browserMobile && !table.modules.edit.currentCell) { - if (table.options.virtualDomHoz) { - table.vdomHoz.reinitialize(true); - } + }; - table.redraw(); - } - }; + window.addEventListener("resize", this.binding); + } - window.addEventListener("resize", this.binding); + this.subscribe("table-destroy", this.clearBindings.bind(this)); } } + }, { + key: "tableResized", + value: function tableResized() { + this.table.rowManager.redraw(); + } }, { key: "clearBindings", - value: function clearBindings(row) { + value: function clearBindings() { if (this.binding) { window.removeEventListener("resize", this.binding); } @@ -22002,6 +22742,21 @@ _this.collapseFormatter = []; _this.collapseStartOpen = true; _this.collapseHandleColumn = false; + + _this.registerTableOption("responsiveLayout", false); //responsive layout flags + + + _this.registerTableOption("responsiveLayoutCollapseStartOpen", true); //start showing collapsed data + + + _this.registerTableOption("responsiveLayoutCollapseUseFormatters", true); //responsive layout collapse formatter + + + _this.registerTableOption("responsiveLayoutCollapseFormatter", false); //responsive layout collapse formatter + + + _this.registerColumnOption("responsive"); + return _this; } //generate resposive columns list @@ -22009,8 +22764,35 @@ _createClass(ResponsiveLayout, [{ key: "initialize", value: function initialize() { - var self = this, - columns = []; + + if (this.table.options.responsiveLayout) { + this.subscribe("column-layout", this.initializeColumn.bind(this)); + this.subscribe("column-show", this.updateColumnVisibility.bind(this)); + this.subscribe("column-hide", this.updateColumnVisibility.bind(this)); + this.subscribe("columns-loaded", this.initializeResponsivity.bind(this)); + this.subscribe("column-moved", this.initializeResponsivity.bind(this)); + this.subscribe("column-add", this.initializeResponsivity.bind(this)); + this.subscribe("column-delete", this.initializeResponsivity.bind(this)); + this.subscribe("table-redrawing", this.tableRedraw.bind(this)); + + if (this.table.options.responsiveLayout === "collapse") { + this.subscribe("row-init", this.initializeRow.bind(this)); + this.subscribe("row-layout", this.layoutRow.bind(this)); + } + } + } + }, { + key: "tableRedraw", + value: function tableRedraw(force) { + if (["fitColumns", "fitDataStretch"].indexOf(this.layoutMode()) === -1) { + if (!force) { + this.update(); + } + } + } + }, { + key: "initializeResponsivity", + value: function initializeResponsivity() { this.mode = this.table.options.responsiveLayout; this.collapseFormatter = this.table.options.responsiveLayoutCollapseFormatter || this.formatCollapsedData; this.collapseStartOpen = this.table.options.responsiveLayoutCollapseStartOpen; @@ -22108,12 +22890,12 @@ }, { key: "updateColumnVisibility", - value: function updateColumnVisibility(column, visible) { - - if (column.modules.responsive) { - column.modules.responsive.visible = visible; + value: function updateColumnVisibility(column, responsiveToggle) { + if (!responsiveToggle && column.modules.responsive) { + column.modules.responsive.visible = column.visible; this.initialize(); - } + } //this.update(); + } }, { key: "hideColumn", @@ -22284,7 +23066,7 @@ var node_content; var titleHighlight = document.createElement("strong"); titleData.appendChild(titleHighlight); - this.table.modules.localize.bind("columns|" + item.field, function (text) { + this.langBind("columns|" + item.field, function (text) { titleHighlight.innerText = text || item.title; }); @@ -22330,10 +23112,70 @@ _this.headerCheckboxElement = null; // hold header select element + _this.registerTableOption("selectable", "highlight"); //highlight rows on hover + + + _this.registerTableOption("selectableRangeMode", "drag"); //highlight rows on hover + + + _this.registerTableOption("selectableRollingSelection", true); //roll selection once maximum number of selectable rows is reached + + + _this.registerTableOption("selectablePersistence", true); // maintain selection when table view is updated + + + _this.registerTableOption("selectableCheck", function (data, row) { + return true; + }); //check wheather row is selectable + + + _this.registerTableFunction("selectRow", _this.selectRows.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("deselectRow", _this.deselectRows.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("toggleSelectRow", _this.toggleRow.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getSelectedRows", _this.getSelectedRows.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("getSelectedData", _this.getSelectedData.bind(_assertThisInitialized(_this))); //register component functions + + + _this.registerComponentFunction("row", "select", _this.selectRows.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "deselect", _this.deselectRows.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "toggleSelect", _this.toggleRow.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "isSelected", _this.isRowSelected.bind(_assertThisInitialized(_this))); + return _this; } _createClass(SelectRow, [{ + key: "initialize", + value: function initialize() { + if (this.table.options.selectable !== false) { + this.subscribe("row-init", this.initializeRow.bind(this)); + this.subscribe("row-deleting", this.rowDeleted.bind(this)); + this.subscribe("rows-wipe", this.clearSelectionData.bind(this)); + this.subscribe("rows-retrieve", this.clearSelectionData.bind(this)); + + if (this.table.options.selectable && this.table.options.selectablePersistence) { + this.subscribe("data-refeshing", this.deselectRows.bind(this)); + } + } + } + }, { + key: "rowRetrieve", + value: function rowRetrieve(type, prevValue) { + return type === "selected" ? this.selectedRows : prevValue; + } + }, { + key: "rowDeleted", + value: function rowDeleted(row) { + this._deselectRow(row, true); + } + }, { key: "clearSelectionData", value: function clearSelectionData(silent) { this.selecting = false; @@ -22341,7 +23183,7 @@ this.selectPrev = []; this.selectedRows = []; - if (!silent) { + if (silent !== true) { this._rowSelectionChanged(); } } @@ -22559,7 +23401,7 @@ } if (!silent) { - this.table.options.rowSelected.call(this.table, row.getComponent()); + this.dispatchExternal("rowSelected", row.getComponent()); } this._rowSelectionChanged(silent); @@ -22635,7 +23477,7 @@ } if (!silent) { - self.table.options.rowDeselected.call(this.table, row.getComponent()); + this.dispatchExternal("rowDeselected", row.getComponent()); } self._rowSelectionChanged(silent); @@ -22681,7 +23523,7 @@ } if (!silent) { - this.table.options.rowSelectionChanged.call(this.table, this.getSelectedData(), this.getSelectedRows()); + this.dispatchExternal("rowSelectionChanged", this.getSelectedData(), this.getSelectedRows()); } } }, { @@ -22796,7 +23638,7 @@ switch (_typeof(params.locale)) { case "boolean": if (params.locale) { - locale = this.table.modules.localize.getLocale(); + locale = this.langLocale(); } break; @@ -23006,15 +23848,92 @@ _this.changed = false; //has the sort changed since last render - return _this; - } //initialize column header for sorting + _this.registerTableOption("sortMode", "local"); //local or remote sorting + + + _this.registerTableOption("initialSort", false); //initial sorting criteria + + + _this.registerTableOption("columnHeaderSortMulti", true); //multiple or single column sorting + + + _this.registerTableOption("sortOrderReverse", false); //reverse internal sort ordering + + + _this.registerTableOption("headerSortElement", ""); //header sort element + + + _this.registerColumnOption("sorter"); + + _this.registerColumnOption("sorterParams"); + + _this.registerColumnOption("headerSort", true); + + _this.registerColumnOption("headerSortStartingDir"); + _this.registerColumnOption("headerSortTristate"); + + return _this; + } _createClass(Sort, [{ + key: "initialize", + value: function initialize() { + this.subscribe("column-layout", this.initializeColumn.bind(this)); + this.subscribe("table-built", this.tableBuilt.bind(this)); + this.registerDataHandler(this.sort.bind(this), 20); + this.registerTableFunction("setSort", this.userSetSort.bind(this)); + this.registerTableFunction("getSorters", this.getSort.bind(this)); + this.registerTableFunction("clearSort", this.clearSort.bind(this)); + + if (this.table.options.sortMode === "remote") { + this.subscribe("data-params", this.remoteSortParams.bind(this)); + } + } + }, { + key: "tableBuilt", + value: function tableBuilt() { + if (this.table.options.initialSort) { + this.setSort(this.table.options.initialSort); + } + } + }, { + key: "remoteSortParams", + value: function remoteSortParams(data, config, silent, params) { + var sorters = this.getSort(); + sorters.forEach(function (item) { + delete item.column; + }); + params.sort = sorters; + return params; + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "userSetSort", + value: function userSetSort(sortList, dir) { + this.setSort(sortList, dir); // this.table.rowManager.sorterRefresh(); + + this.refreshSort(); + } + }, { + key: "clearSort", + value: function clearSort() { + this.clear(); // this.table.rowManager.sorterRefresh(); + + this.refreshSort(); + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + //initialize column header for sorting + + }, { key: "initializeColumn", - value: function initializeColumn(column, content) { - var self = this, - sorter = false, + value: function initializeColumn(column) { + var _this2 = this; + + var sorter = false, colEl, arrowEl; @@ -23038,10 +23957,10 @@ dir: "none", params: column.definition.sorterParams || {}, startingDir: column.definition.headerSortStartingDir || "asc", - tristate: typeof column.definition.headerSortTristate !== "undefined" ? column.definition.headerSortTristate : this.table.options.headerSortTristate + tristate: column.definition.headerSortTristate }; - if (typeof column.definition.headerSort === "undefined" ? this.table.options.headerSort !== false : column.definition.headerSort !== false) { + if (column.definition.headerSort !== false) { colEl = column.getElement(); colEl.classList.add("tabulator-sortable"); arrowEl = document.createElement("div"); @@ -23054,7 +23973,7 @@ } //create sorter arrow - content.appendChild(arrowEl); + column.titleHolderElement.appendChild(arrowEl); column.modules.sort.element = arrowEl; //sort on click colEl.addEventListener("click", function (e) { @@ -23088,8 +24007,8 @@ } } - if (self.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) { - sorters = self.getSort(); + if (_this2.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) { + sorters = _this2.getSort(); match = sorters.findIndex(function (sorter) { return sorter.field === column.getField(); }); @@ -23114,20 +24033,33 @@ } //add to existing sort - self.setSort(sorters); + _this2.setSort(sorters); } else { if (dir == "none") { - self.clear(); + _this2.clear(); } else { //sort by column only - self.setSort(column, dir); + _this2.setSort(column, dir); } - } + } // this.table.rowManager.sorterRefresh(!this.sortList.length); - self.table.rowManager.sorterRefresh(!self.sortList.length); + + _this2.refreshSort(); } }); } + } + }, { + key: "refreshSort", + value: function refreshSort() { + if (this.table.options.sortMode === "remote") { + this.reloadData(); + } else { + this.refreshData(); + } //TODO - Persist left position of row manager + // left = this.scrollLeft; + // this.scrollHorizontal(left); + } //check if the sorters have changed since last use }, { @@ -23181,10 +24113,7 @@ } }); self.sortList = newSortList; - - if (this.table.options.persistence && this.table.modExists("persistence", true) && this.table.modules.persistence.config.sort) { - this.table.modules.persistence.save("sort"); - } + this.dispatch("sort-changed"); } //clear sorters }, { @@ -23242,13 +24171,13 @@ sortListActual = [], rowComponents = []; - if (self.table.options.dataSorting) { - self.table.options.dataSorting.call(self.table, self.getSort()); + if (this.subscribedExternal("dataSorting")) { + this.dispatchExternal("dataSorting", self.getSort()); } self.clearColumnHeaders(); - if (!self.table.options.ajaxSorting) { + if (this.table.options.sortMode !== "remote") { //build list of valid sorters and trigger column specific callbacks before sort begins sortList.forEach(function (item, i) { var sortObj = item.column.modules.sort; @@ -23275,11 +24204,11 @@ }); } - if (self.table.options.dataSorted) { + if (this.subscribedExternal("dataSorted")) { data.forEach(function (row) { rowComponents.push(row.getComponent()); }); - self.table.options.dataSorted.call(self.table, self.getSort(), rowComponents); + this.dispatchExternal("dataSorted", self.getSort(), rowComponents); } } //clear sort arrows on columns @@ -23304,7 +24233,7 @@ }, { key: "_sortItems", value: function _sortItems(data, sortList) { - var _this2 = this; + var _this3 = this; var sorterCount = sortList.length - 1; data.sort(function (a, b) { @@ -23312,7 +24241,7 @@ for (var i = sorterCount; i >= 0; i--) { var sortItem = sortList[i]; - result = _this2._sortRow(a, b, sortItem.column, sortItem.dir, sortItem.params); + result = _this3._sortRow(a, b, sortItem.column, sortItem.dir, sortItem.params); if (result !== 0) { break; @@ -23491,11 +24420,123 @@ _this = _super.call(this, table); _this.invalidCells = []; - return _this; - } //validate + _this.registerTableOption("validationMode", "blocking"); + + _this.registerColumnOption("validator"); + + _this.registerTableFunction("getInvalidCells", _this.getInvalidCells.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("clearCellValidation", _this.userClearCellValidation.bind(_assertThisInitialized(_this))); + + _this.registerTableFunction("validate", _this.userValidate.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "isValid", _this.cellIsValid.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "clearValidation", _this.clearValidation.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("cell", "validate", _this.cellValidate.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("column", "validate", _this.columnValidate.bind(_assertThisInitialized(_this))); + + _this.registerComponentFunction("row", "validate", _this.rowValidate.bind(_assertThisInitialized(_this))); + + return _this; + } _createClass(Validate, [{ + key: "initialize", + value: function initialize() { + this.subscribe("cell-delete", this.clearValidation.bind(this)); + this.subscribe("column-layout", this.initializeColumnCheck.bind(this)); + } /////////////////////////////////// + ////////// Cell Functions ///////// + /////////////////////////////////// + + }, { + key: "cellIsValid", + value: function cellIsValid(cell) { + return cell.modules.validate ? !cell.modules.validate.invalid : true; + } + }, { + key: "cellValidate", + value: function cellValidate(cell) { + return this.validate(cell.column.modules.validate, cell, cell.getValue()); + } /////////////////////////////////// + ///////// Column Functions //////// + /////////////////////////////////// + + }, { + key: "columnValidate", + value: function columnValidate(column) { + var invalid = []; + column.cells.forEach(function (cell) { + if (!this.cellValidate(cell)) { + invalid.push(cell.getComponent()); + } + }); + return invalid.length ? invalid : true; + } /////////////////////////////////// + ////////// Row Functions ////////// + /////////////////////////////////// + + }, { + key: "rowValidate", + value: function rowValidate(row) { + var invalid = []; + row.cells.forEach(function (cell) { + if (!this.cellValidate(cell)) { + invalid.push(cell.getComponent()); + } + }); + return invalid.length ? invalid : true; + } /////////////////////////////////// + ///////// Table Functions ///////// + /////////////////////////////////// + + }, { + key: "userClearCellValidation", + value: function userClearCellValidation(cells) { + var _this2 = this; + + if (!cells) { + cells = this.getInvalidCells(); + } + + if (!Array.isArray(cells)) { + cells = [cells]; + } + + cells.forEach(function (cell) { + _this2.clearValidation(cell._getSelf()); + }); + } + }, { + key: "userValidate", + value: function userValidate(cells) { + var output = []; //clear row data + + this.table.rowManager.rows.forEach(function (row) { + var valid = row.validate(); + + if (valid !== true) { + output = output.concat(valid); + } + }); + return output.length ? output : true; + } /////////////////////////////////// + ///////// Internal Logic ////////// + /////////////////////////////////// + + }, { + key: "initializeColumnCheck", + value: function initializeColumnCheck(column) { + if (typeof column.definition.validator !== "undefined") { + this.initializeColumn(column); + } + } //validate + + }, { key: "initializeColumn", value: function initializeColumn(column) { var self = this, @@ -23658,6 +24699,7 @@ GroupRowsModule: GroupRows, HistoryModule: History, HtmlTableImportModule: HtmlTableImport, + InteractionModule: Interaction, KeybindingsModule: Keybindings, MenuModule: Menu, MoveColumnsModule: MoveColumns, diff --git a/dist/js/tabulator.js.map b/dist/js/tabulator.js.map index a11d844fc..aa99b0db4 100644 --- a/dist/js/tabulator.js.map +++ b/dist/js/tabulator.js.map @@ -1 +1 @@ -{"version":3,"file":"tabulator.js","sources":["../../src/js/core/defaults/options.js","../../src/js/core/column/ColumnComponent.js","../../src/js/core/column/defaults/options.js","../../src/js/core/cell/CellComponent.js","../../src/js/core/cell/Cell.js","../../src/js/core/column/Column.js","../../src/js/core/Helpers.js","../../src/js/core/ColumnManager.js","../../src/js/core/row/RowComponent.js","../../src/js/core/row/Row.js","../../src/js/core/RowManager.js","../../src/js/core/FooterManager.js","../../src/js/core/TableRegistry.js","../../src/js/core/Module.js","../../src/js/modules/Layout/defaults/modes/fitData.js","../../src/js/modules/Layout/defaults/modes/fitDataGeneral.js","../../src/js/modules/Layout/defaults/modes/fitDataStretch.js","../../src/js/modules/Layout/defaults/modes/fitColumns.js","../../src/js/modules/Layout/defaults/modes.js","../../src/js/modules/Layout/Layout.js","../../src/js/modules/Localize/defaults/langs.js","../../src/js/modules/Localize/Localize.js","../../src/js/modules/Comms/Comms.js","../../src/js/core/ModuleBinder.js","../../src/js/core/renderers/VirtualDomHorizontal.js","../../src/js/core/Tabulator.js","../../src/js/modules/Accessor/defaults/accessors.js","../../src/js/modules/Accessor/Accessor.js","../../src/js/modules/Ajax/defaults/config.js","../../src/js/modules/Ajax/defaults/urlGenerator.js","../../src/js/modules/Ajax/defaults/loaderPromise.js","../../src/js/modules/Ajax/defaults/contentTypeFormatters.js","../../src/js/modules/Ajax/Ajax.js","../../src/js/modules/Clipboard/defaults/pasteActions.js","../../src/js/modules/Clipboard/defaults/pasteParsers.js","../../src/js/modules/Clipboard/Clipboard.js","../../src/js/modules/ColumnCalcs/CalcComponent.js","../../src/js/modules/ColumnCalcs/defaults/calculations.js","../../src/js/modules/ColumnCalcs/ColumnCalcs.js","../../src/js/modules/DataTree/DataTree.js","../../src/js/modules/Download/defaults/downloaders/csv.js","../../src/js/modules/Download/defaults/downloaders/json.js","../../src/js/modules/Download/defaults/downloaders/pdf.js","../../src/js/modules/Download/defaults/downloaders/xlsx.js","../../src/js/modules/Download/defaults/downloaders/html.js","../../src/js/modules/Download/defaults/downloaders.js","../../src/js/modules/Download/Download.js","../../src/js/modules/Edit/defaults/editors/input.js","../../src/js/modules/Edit/defaults/editors/textarea.js","../../src/js/modules/Edit/defaults/editors/number.js","../../src/js/modules/Edit/defaults/editors/range.js","../../src/js/modules/Edit/defaults/editors/select.js","../../src/js/modules/Edit/defaults/editors/autocomplete.js","../../src/js/modules/Edit/defaults/editors/star.js","../../src/js/modules/Edit/defaults/editors/progress.js","../../src/js/modules/Edit/defaults/editors/tickCross.js","../../src/js/modules/Edit/defaults/editors.js","../../src/js/modules/Edit/Edit.js","../../src/js/modules/Export/ExportRow.js","../../src/js/modules/Export/ExportColumn.js","../../src/js/modules/Export/Export.js","../../src/js/modules/Filter/defaults/filters.js","../../src/js/modules/Filter/Filter.js","../../src/js/modules/Format/defaults/formatters/plaintext.js","../../src/js/modules/Format/defaults/formatters/html.js","../../src/js/modules/Format/defaults/formatters/textarea.js","../../src/js/modules/Format/defaults/formatters/money.js","../../src/js/modules/Format/defaults/formatters/link.js","../../src/js/modules/Format/defaults/formatters/image.js","../../src/js/modules/Format/defaults/formatters/tickCross.js","../../src/js/modules/Format/defaults/formatters/datetime.js","../../src/js/modules/Format/defaults/formatters/datetimediff.js","../../src/js/modules/Format/defaults/formatters/lookup.js","../../src/js/modules/Format/defaults/formatters/star.js","../../src/js/modules/Format/defaults/formatters/traffic.js","../../src/js/modules/Format/defaults/formatters/progress.js","../../src/js/modules/Format/defaults/formatters/color.js","../../src/js/modules/Format/defaults/formatters/buttonTick.js","../../src/js/modules/Format/defaults/formatters/buttonCross.js","../../src/js/modules/Format/defaults/formatters/rownum.js","../../src/js/modules/Format/defaults/formatters/handle.js","../../src/js/modules/Format/defaults/formatters/responsiveCollapse.js","../../src/js/modules/Format/defaults/formatters/rowSelection.js","../../src/js/modules/Format/defaults/formatters.js","../../src/js/modules/Format/Format.js","../../src/js/modules/FrozenColumns/FrozenColumns.js","../../src/js/modules/FrozenRows/FrozenRows.js","../../src/js/modules/GroupRows/Group.js","../../src/js/modules/GroupRows/GroupRows.js","../../src/js/modules/History/defaults/undoers.js","../../src/js/modules/History/defaults/redoers.js","../../src/js/modules/History/History.js","../../src/js/modules/HtmlTableImport/HtmlTableImport.js","../../src/js/modules/Keybindings/defaults/bindings.js","../../src/js/modules/Keybindings/defaults/actions.js","../../src/js/modules/Keybindings/Keybindings.js","../../src/js/modules/Menu/Menu.js","../../src/js/modules/MoveColumns/MoveColumns.js","../../src/js/modules/MoveRows/MoveRows.js","../../src/js/modules/Mutator/defaults/mutators.js","../../src/js/modules/Mutator/Mutator.js","../../src/js/modules/Page/defaults/dataSentNames.js","../../src/js/modules/Page/defaults/dataReceivedNames.js","../../src/js/modules/Page/Page.js","../../src/js/modules/Persistence/defaults/readers.js","../../src/js/modules/Persistence/defaults/writers.js","../../src/js/modules/Persistence/Persistence.js","../../src/js/modules/Print/Print.js","../../src/js/modules/ReactiveData/ReactiveData.js","../../src/js/modules/ResizeColumns/ResizeColumns.js","../../src/js/modules/ResizeRows/ResizeRows.js","../../src/js/modules/ResizeTable/ResizeTable.js","../../src/js/modules/ResponsiveLayout/ResponsiveLayout.js","../../src/js/modules/SelectRow/SelectRow.js","../../src/js/modules/Sort/defaults/sorters/number.js","../../src/js/modules/Sort/defaults/sorters/string.js","../../src/js/modules/Sort/defaults/sorters/datetime.js","../../src/js/modules/Sort/defaults/sorters/date.js","../../src/js/modules/Sort/defaults/sorters/time.js","../../src/js/modules/Sort/defaults/sorters/boolean.js","../../src/js/modules/Sort/defaults/sorters/array.js","../../src/js/modules/Sort/defaults/sorters/exists.js","../../src/js/modules/Sort/defaults/sorters/alphanum.js","../../src/js/modules/Sort/defaults/sorters.js","../../src/js/modules/Sort/Sort.js","../../src/js/modules/Validate/defaults/validators.js","../../src/js/modules/Validate/Validate.js","../../src/js/core/TabulatorFull.js"],"sourcesContent":["export default {\r\n\theight:false, //height of tabulator\r\n\tminHeight:false, //minimum height of tabulator\r\n\tmaxHeight:false, //maximum height of tabulator\r\n\r\n\tlayout:\"fitData\", ///layout type \"fitColumns\" | \"fitData\"\r\n\tlayoutColumnsOnNewData:false, //update column widths on setData\r\n\r\n\tcolumnMinWidth:40, //minimum global width for a column\r\n\tcolumnMaxWidth:false, //minimum global width for a column\r\n\tcolumnHeaderVertAlign:\"top\", //vertical alignment of column headers\r\n\r\n\tresizableColumns:true, //resizable columns\r\n\tresizableRows:false, //resizable rows\r\n\tautoResize:true, //auto resize table\r\n\r\n\tcolumns:[],//store for colum header info\r\n\tcolumnDefaults:false, //store column default props\r\n\r\n\tcellHozAlign:\"\", //horizontal align columns\r\n\tcellVertAlign:\"\", //vertical align columns\r\n\theaderHozAlign:\"\", //horizontal header alignment\r\n\r\n\tdata:[], //default starting data\r\n\r\n\tautoColumns:false, //build columns from data row structure\r\n\tautoColumnsDefinitions:false,\r\n\r\n\treactiveData:false, //enable data reactivity\r\n\r\n\tnestedFieldSeparator:\".\", //seperatpr for nested data\r\n\r\n\ttooltips: false, //Tool tip value\r\n\ttooltipsHeader: false, //Tool tip for headers\r\n\ttooltipGenerationMode:\"load\", //when to generate tooltips\r\n\r\n\tinitialSort:false, //initial sorting criteria\r\n\tinitialFilter:false, //initial filtering criteria\r\n\tinitialHeaderFilter:false, //initial header filtering criteria\r\n\r\n\tcolumnHeaderSortMulti: true, //multiple or single column sorting\r\n\r\n\tsortOrderReverse:false, //reverse internal sort ordering\r\n\r\n\theaderSort:true, //set default global header sort\r\n\theaderSortTristate:false, //set default tristate header sorting\r\n\theaderSortElement:\"\", //header sort element\r\n\r\n\tfooterElement:false, //hold footer element\r\n\r\n\tindex:\"id\", //filed for row index\r\n\r\n\ttextDirection:\"auto\",\r\n\r\n\tkeybindings:[], //array for keybindings\r\n\r\n\ttabEndNewRow:false, //create new row when tab to end of table\r\n\r\n\tinvalidOptionWarnings:true, //allow toggling of invalid option warnings\r\n\r\n\tclipboard:false, //enable clipboard\r\n\tclipboardCopyStyled:true, //formatted table data\r\n\tclipboardCopyConfig:false, //clipboard config\r\n\tclipboardCopyFormatter:false, //DEPRICATED - REMOVE in 5.0\r\n\tclipboardCopyRowRange:\"active\", //restrict clipboard to visible rows only\r\n\tclipboardPasteParser:\"table\", //convert pasted clipboard data to rows\r\n\tclipboardPasteAction:\"insert\", //how to insert pasted data into the table\r\n\r\n\tclipboardCopied:function(){}, //data has been copied to the clipboard\r\n\tclipboardPasted:function(){}, //data has been pasted into the table\r\n\tclipboardPasteError:function(){}, //data has not successfully been pasted into the table\r\n\r\n\tdownloadReady:function(data, blob){return blob;}, //function to manipulate download data\r\n\tdownloadComplete:false, //function to manipulate download data\r\n\tdownloadConfig:{},\t//download config\r\n\tdownloadRowRange:\"active\", //restrict download to active rows only\r\n\r\n\tdataTree:false, //enable data tree\r\n\tdataTreeFilter:true, //filter child rows\r\n\tdataTreeSort:true, //sort child rows\r\n\tdataTreeElementColumn:false,\r\n\tdataTreeBranchElement: true, //show data tree branch element\r\n\tdataTreeChildIndent:9, //data tree child indent in px\r\n\tdataTreeChildField:\"_children\", //data tre column field to look for child rows\r\n\tdataTreeCollapseElement:false, //data tree row collapse element\r\n\tdataTreeExpandElement:false, //data tree row expand element\r\n\tdataTreeStartExpanded:false,\r\n\tdataTreeRowExpanded:function(){}, //row has been expanded\r\n\tdataTreeRowCollapsed:function(){}, //row has been collapsed\r\n\tdataTreeChildColumnCalcs:false, //include visible data tree rows in column calculations\r\n\tdataTreeSelectPropagate:false, //seleccting a parent row selects its children\r\n\r\n\tprintAsHtml:false, //enable print as html\r\n\tprintFormatter:false, //printing page formatter\r\n\tprintHeader:false, //page header contents\r\n\tprintFooter:false, //page footer contents\r\n\tprintStyled:true, //enable print as html styling\r\n\tprintRowRange:\"visible\", //restrict print to visible rows only\r\n\tprintConfig:{}, //print config options\r\n\r\n\taddRowPos:\"bottom\", //position to insert blank rows, top|bottom\r\n\r\n\tselectable:\"highlight\", //highlight rows on hover\r\n\tselectableRangeMode: \"drag\", //highlight rows on hover\r\n\tselectableRollingSelection:true, //roll selection once maximum number of selectable rows is reached\r\n\tselectablePersistence:true, // maintain selection when table view is updated\r\n\tselectableCheck:function(data, row){return true;}, //check wheather row is selectable\r\n\r\n\theaderFilterLiveFilterDelay: 300, //delay before updating column after user types in header filter\r\n\theaderFilterPlaceholder: false, //placeholder text to display in header filters\r\n\r\n\theaderVisible:true, //hide header\r\n\r\n\thistory:false, //enable edit history\r\n\r\n\tlocale:false, //current system language\r\n\tlangs:{},\r\n\r\n\tvirtualDom:true, //enable DOM virtualization\r\n virtualDomBuffer:0, // set virtual DOM buffer size\r\n\tvirtualDomHoz:false, //enable horizontal DOM virtualization\r\n\r\n\tpersistence:false,\r\n\tpersistenceID:\"\", //key for persistent storage\r\n\tpersistenceMode:true, //mode for storing persistence information\r\n\tpersistenceReaderFunc:false, //function for handling persistence data reading\r\n\tpersistenceWriterFunc:false, //function for handling persistence data writing\r\n\r\n\r\n\tresponsiveLayout:false, //responsive layout flags\r\n\tresponsiveLayoutCollapseStartOpen:true, //start showing collapsed data\r\n\tresponsiveLayoutCollapseUseFormatters:true, //responsive layout collapse formatter\r\n\tresponsiveLayoutCollapseFormatter:false, //responsive layout collapse formatter\r\n\r\n\tpagination:false, //set pagination type\r\n\tpaginationSize:false, //set number of rows to a page\r\n\tpaginationInitialPage:1, //initail page to show on load\r\n\tpaginationButtonCount: 5, // set count of page button\r\n\tpaginationSizeSelector:false, //add pagination size selector element\r\n\tpaginationElement:false, //element to hold pagination numbers\r\n\tpaginationDataSent:{}, //pagination data sent to the server\r\n\tpaginationDataReceived:{}, //pagination data received from the server\r\n\tpaginationAddRow: \"page\", //add rows on table or page\r\n\r\n\tajaxURL:false, //url for ajax loading\r\n\tajaxURLGenerator:false,\r\n\tajaxParams:{}, //params for ajax loading\r\n\tajaxConfig:\"get\", //ajax request type\r\n\tajaxContentType:\"form\", //ajax request type\r\n\tajaxRequestFunc:false, //promise function\r\n\tajaxLoader:true, //show loader\r\n\tajaxLoaderLoading:false, //loader element\r\n\tajaxLoaderError:false, //loader element\r\n\tajaxFiltering:false,\r\n\tajaxSorting:false,\r\n\tajaxProgressiveLoad:false, //progressive loading\r\n\tajaxProgressiveLoadDelay:0, //delay between requests\r\n\tajaxProgressiveLoadScrollMargin:0, //margin before scroll begins\r\n\r\n\tgroupBy:false, //enable table grouping and set field to group by\r\n\tgroupStartOpen:true, //starting state of group\r\n\tgroupValues:false,\r\n\tgroupUpdateOnCellEdit:false,\r\n\r\n\tgroupHeader:false, //header generation function\r\n\tgroupHeaderPrint:null,\r\n\tgroupHeaderClipboard:null,\r\n\tgroupHeaderHtmlOutput:null,\r\n\tgroupHeaderDownload:null,\r\n\r\n\thtmlOutputConfig:false, //html outypu config\r\n\r\n\tmovableColumns:false, //enable movable columns\r\n\r\n\tmovableRows:false, //enable movable rows\r\n\tmovableRowsConnectedTables:false, //tables for movable rows to be connected to\r\n\tmovableRowsConnectedElements:false, //other elements for movable rows to be connected to\r\n\tmovableRowsSender:false,\r\n\tmovableRowsReceiver:\"insert\",\r\n\tmovableRowsSendingStart:function(){},\r\n\tmovableRowsSent:function(){},\r\n\tmovableRowsSentFailed:function(){},\r\n\tmovableRowsSendingStop:function(){},\r\n\tmovableRowsReceivingStart:function(){},\r\n\tmovableRowsReceived:function(){},\r\n\tmovableRowsReceivedFailed:function(){},\r\n\tmovableRowsReceivingStop:function(){},\r\n\tmovableRowsElementDrop:function(){},\r\n\r\n\tscrollToRowPosition:\"top\",\r\n\tscrollToRowIfVisible:true,\r\n\r\n\tscrollToColumnPosition:\"left\",\r\n\tscrollToColumnIfVisible:true,\r\n\r\n\trowFormatter:false,\r\n\trowFormatterPrint:null,\r\n\trowFormatterClipboard:null,\r\n\trowFormatterHtmlOutput:null,\r\n\r\n\tplaceholder:false,\r\n\r\n\t//table building callbacks\r\n\ttableBuilding:function(){},\r\n\ttableBuilt:function(){},\r\n\r\n\t//render callbacks\r\n\trenderStarted:function(){},\r\n\trenderComplete:function(){},\r\n\r\n\t//row callbacks\r\n\trowClick:false,\r\n\trowDblClick:false,\r\n\trowContext:false,\r\n\trowTap:false,\r\n\trowDblTap:false,\r\n\trowTapHold:false,\r\n\trowMouseEnter:false,\r\n\trowMouseLeave:false,\r\n\trowMouseOver:false,\r\n\trowMouseOut:false,\r\n\trowMouseMove:false,\r\n\trowContextMenu:false,\r\n\trowClickMenu:false,\r\n\trowAdded:function(){},\r\n\trowDeleted:function(){},\r\n\trowMoved:function(){},\r\n\trowUpdated:function(){},\r\n\trowSelectionChanged:function(){},\r\n\trowSelected:function(){},\r\n\trowDeselected:function(){},\r\n\trowResized:function(){},\r\n\r\n\t//cell callbacks\r\n\t//row callbacks\r\n\tcellClick:false,\r\n\tcellDblClick:false,\r\n\tcellContext:false,\r\n\tcellTap:false,\r\n\tcellDblTap:false,\r\n\tcellTapHold:false,\r\n\tcellMouseEnter:false,\r\n\tcellMouseLeave:false,\r\n\tcellMouseOver:false,\r\n\tcellMouseOut:false,\r\n\tcellMouseMove:false,\r\n\tcellEditing:function(){},\r\n\tcellEdited:function(){},\r\n\tcellEditCancelled:function(){},\r\n\r\n\t//column callbacks\r\n\tcolumnMoved:false,\r\n\tcolumnResized:function(){},\r\n\tcolumnTitleChanged:function(){},\r\n\tcolumnVisibilityChanged:function(){},\r\n\r\n\t//HTML iport callbacks\r\n\thtmlImporting:function(){},\r\n\thtmlImported:function(){},\r\n\r\n\t//data callbacks\r\n\tdataLoading:function(){},\r\n\tdataLoaded:function(){},\r\n\tdataChanged:false,\r\n\r\n\t//ajax callbacks\r\n\tajaxRequesting:function(){},\r\n\tajaxResponse:false,\r\n\tajaxError:function(){},\r\n\r\n\t//filtering callbacks\r\n\tdataFiltering:false,\r\n\tdataFiltered:false,\r\n\r\n\t//sorting callbacks\r\n\tdataSorting:function(){},\r\n\tdataSorted:function(){},\r\n\r\n\t//grouping callbacks\r\n\tgroupToggleElement:\"arrow\",\r\n\tgroupClosedShowCalcs:false,\r\n\tdataGrouping:function(){},\r\n\tdataGrouped:false,\r\n\tgroupVisibilityChanged:function(){},\r\n\tgroupClick:false,\r\n\tgroupDblClick:false,\r\n\tgroupContext:false,\r\n\tgroupContextMenu:false,\r\n\tgroupClickMenu:false,\r\n\tgroupTap:false,\r\n\tgroupDblTap:false,\r\n\tgroupTapHold:false,\r\n\r\n\tcolumnCalcs:true,\r\n\r\n\t//pagination callbacks\r\n\tpageLoaded:function(){},\r\n\r\n\t//localization callbacks\r\n\tlocalized:function(){},\r\n\r\n\t//validation callbacks\r\n\tvalidationMode:\"blocking\",\r\n\tvalidationFailed:function(){},\r\n\r\n\t//history callbacks\r\n\thistoryUndo:function(){},\r\n\thistoryRedo:function(){},\r\n\r\n\t//scroll callbacks\r\n\tscrollHorizontal:function(){},\r\n\tscrollVertical:function(){},\r\n};","//public column object\r\nexport default class ColumnComponent {\r\n\tconstructor (column){\r\n\t\tthis._column = column;\r\n\t\tthis.type = \"ColumnComponent\";\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\treturn this._column.getElement();\r\n\t}\r\n\r\n\tgetDefinition(){\r\n\t\treturn this._column.getDefinition();\r\n\t}\r\n\r\n\tgetField(){\r\n\t\treturn this._column.getField();\r\n\t}\r\n\r\n\tgetCells(){\r\n\t\tvar cells = [];\r\n\r\n\t\tthis._column.cells.forEach(function(cell){\r\n\t\t\tcells.push(cell.getComponent());\r\n\t\t});\r\n\r\n\t\treturn cells;\r\n\t}\r\n\r\n\tisVisible(){\r\n\t\treturn this._column.visible;\r\n\t}\r\n\r\n\tshow(){\r\n\t\tif(this._column.isGroup){\r\n\t\t\tthis._column.columns.forEach(function(column){\r\n\t\t\t\tcolumn.show();\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tthis._column.show();\r\n\t\t}\r\n\t}\r\n\r\n\thide(){\r\n\t\tif(this._column.isGroup){\r\n\t\t\tthis._column.columns.forEach(function(column){\r\n\t\t\t\tcolumn.hide();\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tthis._column.hide();\r\n\t\t}\r\n\t}\r\n\r\n\ttoggle(){\r\n\t\tif(this._column.visible){\r\n\t\t\tthis.hide();\r\n\t\t}else{\r\n\t\t\tthis.show();\r\n\t\t}\r\n\t}\r\n\r\n\tdelete(){\r\n\t\treturn this._column.delete();\r\n\t}\r\n\r\n\tgetSubColumns(){\r\n\t\tvar output = [];\r\n\r\n\t\tif(this._column.columns.length){\r\n\t\t\tthis._column.columns.forEach(function(column){\r\n\t\t\t\toutput.push(column.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetParentColumn(){\r\n\t\treturn this._column.parent instanceof Column ? this._column.parent.getComponent() : false;\r\n\t}\r\n\r\n\t_getSelf(){\r\n\t\treturn this._column;\r\n\t}\r\n\r\n\tscrollTo(){\r\n\t\treturn this._column.table.columnManager.scrollToColumn(this._column);\r\n\t}\r\n\r\n\tgetTable(){\r\n\t\treturn this._column.table;\r\n\t}\r\n\r\n\theaderFilterFocus(){\r\n\t\tif(this._column.table.modExists(\"filter\", true)){\r\n\t\t\tthis._column.table.modules.filter.setHeaderFilterFocus(this._column);\r\n\t\t}\r\n\t}\r\n\r\n\treloadHeaderFilter(){\r\n\t\tif(this._column.table.modExists(\"filter\", true)){\r\n\t\t\tthis._column.table.modules.filter.reloadHeaderFilter(this._column);\r\n\t\t}\r\n\t}\r\n\r\n\tgetHeaderFilterValue(){\r\n\t\tif(this._column.table.modExists(\"filter\", true)){\r\n\t\t\treturn this._column.table.modules.filter.getHeaderFilterValue(this._column);\r\n\t\t}\r\n\t}\r\n\r\n\tsetHeaderFilterValue(value){\r\n\t\tif(this._column.table.modExists(\"filter\", true)){\r\n\t\t\tthis._column.table.modules.filter.setHeaderFilterValue(this._column, value);\r\n\t\t}\r\n\t}\r\n\r\n\tmove(to, after){\r\n\t\tvar toColumn = this._column.table.columnManager.findColumn(to);\r\n\r\n\t\tif(toColumn){\r\n\t\t\tthis._column.table.columnManager.moveColumn(this._column, toColumn, after)\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Move Error - No matching column found:\", toColumn);\r\n\t\t}\r\n\t}\r\n\r\n\tgetNextColumn(){\r\n\t\tvar nextCol = this._column.nextColumn();\r\n\r\n\t\treturn nextCol ? nextCol.getComponent() : false;\r\n\t}\r\n\r\n\tgetPrevColumn(){\r\n\t\tvar prevCol = this._column.prevColumn();\r\n\r\n\t\treturn prevCol ? prevCol.getComponent() : false;\r\n\t}\r\n\r\n\tupdateDefinition(updates){\r\n\t\treturn this._column.updateDefinition(updates);\r\n\t}\r\n\r\n\tgetWidth(){\r\n\t\treturn this._column.getWidth();\r\n\t}\r\n\r\n\tsetWidth(width){\r\n\t\tvar result;\r\n\r\n\t\tif(width === true){\r\n\t\t\tresult = this._column.reinitializeWidth(true);\r\n\t\t}else{\r\n\t\t\tresult = this._column.setWidth(width);\r\n\t\t}\r\n\r\n\t\tif(this._column.table.options.virtualDomHoz){\r\n\t\t\tthis._column.table.vdomHoz.reinitialize(true);\r\n\t\t}\r\n\r\n\t\treturn result;\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\treturn this._column.validate();\r\n\t}\r\n}","export default [\r\n\t\"title\",\r\n\t\"field\",\r\n\t\"columns\",\r\n\t\"visible\",\r\n\t\"hozAlign\",\r\n\t\"vertAlign\",\r\n\t\"width\",\r\n\t\"minWidth\",\r\n\t\"maxWidth\",\r\n\t\"widthGrow\",\r\n\t\"widthShrink\",\r\n\t\"resizable\",\r\n\t\"frozen\",\r\n\t\"responsive\",\r\n\t\"tooltip\",\r\n\t\"cssClass\",\r\n\t\"rowHandle\",\r\n\t\"print\",\r\n\t\"htmlOutput\",\r\n\t\"sorter\",\r\n\t\"sorterParams\",\r\n\t\"formatter\",\r\n\t\"formatterParams\",\r\n\t\"variableHeight\",\r\n\t\"editable\",\r\n\t\"editor\",\r\n\t\"editorParams\",\r\n\t\"validator\",\r\n\t\"mutator\",\r\n\t\"mutatorParams\",\r\n\t\"mutatorData\",\r\n\t\"mutatorDataParams\",\r\n\t\"mutatorEdit\",\r\n\t\"mutatorEditParams\",\r\n\t\"mutatorClipboard\",\r\n\t\"mutatorClipboardParams\",\r\n\t\"accessor\",\r\n\t\"accessorParams\",\r\n\t\"accessorData\",\r\n\t\"accessorDataParams\",\r\n\t\"accessorDownload\",\r\n\t\"accessorDownloadParams\",\r\n\t\"accessorClipboard\",\r\n\t\"accessorClipboardParams\",\r\n\t\"accessorPrint\",\r\n\t\"accessorPrintParams\",\r\n\t\"accessorHtmlOutput\",\r\n\t\"accessorHtmlOutputParams\",\r\n\t\"clipboard\",\r\n\t\"download\",\r\n\t\"topCalc\",\r\n\t\"topCalcParams\",\r\n\t\"topCalcFormatter\",\r\n\t\"topCalcFormatterParams\",\r\n\t\"bottomCalc\",\r\n\t\"bottomCalcParams\",\r\n\t\"bottomCalcFormatter\",\r\n\t\"bottomCalcFormatterParams\",\r\n\t\"cellClick\",\r\n\t\"cellDblClick\",\r\n\t\"cellContext\",\r\n\t\"cellTap\",\r\n\t\"cellDblTap\",\r\n\t\"cellTapHold\",\r\n\t\"cellMouseEnter\",\r\n\t\"cellMouseLeave\",\r\n\t\"cellMouseOver\",\r\n\t\"cellMouseOut\",\r\n\t\"cellMouseMove\",\r\n\t\"cellEditing\",\r\n\t\"cellEdited\",\r\n\t\"cellEditCancelled\",\r\n\t\"headerSort\",\r\n\t\"headerSortStartingDir\",\r\n\t\"headerSortTristate\",\r\n\t\"headerClick\",\r\n\t\"headerDblClick\",\r\n\t\"headerContext\",\r\n\t\"headerTap\",\r\n\t\"headerDblTap\",\r\n\t\"headerTapHold\",\r\n\t\"headerTooltip\",\r\n\t\"headerVertical\",\r\n\t\"headerHozAlign\",\r\n\t\"editableTitle\",\r\n\t\"titleFormatter\",\r\n\t\"titleFormatterParams\",\r\n\t\"headerFilter\",\r\n\t\"headerFilterPlaceholder\",\r\n\t\"headerFilterParams\",\r\n\t\"headerFilterEmptyCheck\",\r\n\t\"headerFilterFunc\",\r\n\t\"headerFilterFuncParams\",\r\n\t\"headerFilterLiveFilter\",\r\n\t\"print\",\r\n\t\"headerContextMenu\",\r\n\t\"headerMenu\",\r\n\t\"contextMenu\",\r\n\t// \"headerClickMenu\",\r\n\t\"clickMenu\",\r\n\t\"formatterPrint\",\r\n\t\"formatterPrintParams\",\r\n\t\"formatterClipboard\",\r\n\t\"formatterClipboardParams\",\r\n\t\"formatterHtmlOutput\",\r\n\t\"formatterHtmlOutputParams\",\r\n\t\"titlePrint\",\r\n\t\"titleClipboard\",\r\n\t\"titleHtmlOutput\",\r\n\t\"titleDownload\",\r\n];","//public cell object\r\nexport default class CellComponent {\r\n\r\n\tconstructor (cell){\r\n\t\tthis._cell = cell;\r\n\t}\r\n\r\n\tgetValue(){\r\n\t\treturn this._cell.getValue();\r\n\t}\r\n\r\n\tgetOldValue(){\r\n\t\treturn this._cell.getOldValue();\r\n\t}\r\n\r\n\tgetInitialValue(){\r\n\t\treturn this._cell.initialValue;\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\treturn this._cell.getElement();\r\n\t}\r\n\r\n\tgetRow(){\r\n\t\treturn this._cell.row.getComponent();\r\n\t}\r\n\r\n\tgetData(){\r\n\t\treturn this._cell.row.getData();\r\n\t}\r\n\r\n\tgetField(){\r\n\t\treturn this._cell.column.getField();\r\n\t}\r\n\r\n\tgetColumn(){\r\n\t\treturn this._cell.column.getComponent();\r\n\t}\r\n\r\n\tsetValue(value, mutate){\r\n\t\tif(typeof mutate == \"undefined\"){\r\n\t\t\tmutate = true;\r\n\t\t}\r\n\r\n\t\tthis._cell.setValue(value, mutate);\r\n\t}\r\n\r\n\trestoreOldValue(){\r\n\t\tthis._cell.setValueActual(this._cell.getOldValue());\r\n\t}\r\n\r\n\trestoreInitialValue(){\r\n\t\tthis._cell.setValueActual(this._cell.initialValue);\r\n\t}\r\n\r\n\tedit(force){\r\n\t\treturn this._cell.edit(force);\r\n\t}\r\n\r\n\tcancelEdit(){\r\n\t\tthis._cell.cancelEdit();\r\n\t}\r\n\r\n\tisEdited(){\r\n\t\treturn !! this._cell.modules.edit && this._cell.modules.edit.edited;\r\n\t}\r\n\r\n\tclearEdited(){\r\n\t\tif(this._cell.table.modExists(\"edit\", true)){\r\n\t\t\tthis._cell.table.modules.edit.clearEdited(this._cell);\r\n\t\t}\r\n\t}\r\n\r\n\tisValid(){\r\n\t\treturn this._cell.modules.validate ? !this._cell.modules.validate.invalid : true;\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\treturn this._cell.validate();\r\n\t}\r\n\r\n\tclearValidation(){\r\n\t\tif(this._cell.table.modExists(\"validate\", true)){\r\n\t\t\tthis._cell.table.modules.validate.clearValidation(this._cell);\r\n\t\t}\r\n\t}\r\n\r\n\tnav(){\r\n\t\treturn this._cell.nav();\r\n\t}\r\n\r\n\tcheckHeight(){\r\n\t\tthis._cell.checkHeight();\r\n\t}\r\n\r\n\tgetTable(){\r\n\t\treturn this._cell.table;\r\n\t}\r\n\r\n\t_getSelf(){\r\n\t\treturn this._cell;\r\n\t}\r\n}","import CellComponent from './CellComponent.js';\r\n\r\nexport default class Cell {\r\n\tconstructor(column, row){\r\n\t\tthis.table = column.table;\r\n\t\tthis.column = column;\r\n\t\tthis.row = row;\r\n\t\tthis.element = null;\r\n\t\tthis.value = null;\r\n\t\tthis.initialValue;\r\n\t\tthis.oldValue = null;\r\n\t\tthis.modules = {};\r\n\r\n\t\tthis.height = null;\r\n\t\tthis.width = null;\r\n\t\tthis.minWidth = null;\r\n\r\n\t\tthis.component = null;\r\n\r\n\t\tthis.loaded = false; //track if the cell has been added to the DOM yet\r\n\r\n\t\tthis.build();\r\n\t}\r\n\r\n\t//////////////// Setup Functions /////////////////\r\n\t//generate element\r\n\tbuild(){\r\n\t\tthis.generateElement();\r\n\r\n\t\tthis.setWidth();\r\n\r\n\t\tthis._configureCell();\r\n\r\n\t\tthis.setValueActual(this.column.getFieldValue(this.row.data));\r\n\r\n\t\tthis.initialValue = this.value;\r\n\t}\r\n\r\n\tgenerateElement(){\r\n\t\tthis.element = document.createElement('div');\r\n\t\tthis.element.className = \"tabulator-cell\";\r\n\t\tthis.element.setAttribute(\"role\", \"gridcell\");\r\n\t\tthis.element = this.element;\r\n\t}\r\n\r\n\t_configureCell(){\r\n\t\tvar cellEvents = this.column.cellEvents,\r\n\t\telement = this.element,\r\n\t\tfield = this.column.getField(),\r\n\t\tvertAligns = {\r\n\t\t\ttop:\"flex-start\",\r\n\t\t\tbottom:\"flex-end\",\r\n\t\t\tmiddle:\"center\",\r\n\t\t},\r\n\t\thozAligns = {\r\n\t\t\tleft:\"flex-start\",\r\n\t\t\tright:\"flex-end\",\r\n\t\t\tcenter:\"center\",\r\n\t\t};\r\n\r\n\t\t//set text alignment\r\n\t\telement.style.textAlign = this.column.hozAlign;\r\n\r\n\t\tif(this.column.vertAlign){\r\n\t\t\telement.style.display = \"inline-flex\";\r\n\r\n\t\t\telement.style.alignItems = vertAligns[this.column.vertAlign] || \"\";\r\n\r\n\t\t\tif(this.column.hozAlign){\r\n\t\t\t\telement.style.justifyContent = hozAligns[this.column.hozAlign] || \"\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(field){\r\n\t\t\telement.setAttribute(\"tabulator-field\", field);\r\n\t\t}\r\n\r\n\t\t//add class to cell if needed\r\n\t\tif(this.column.definition.cssClass){\r\n\t\t\tvar classNames = this.column.definition.cssClass.split(\" \")\r\n\t\t\tclassNames.forEach((className) => {\r\n\t\t\t\telement.classList.add(className)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//update tooltip on mouse enter\r\n\t\tif (this.table.options.tooltipGenerationMode === \"hover\"){\r\n\t\t\telement.addEventListener(\"mouseenter\", (e) => {\r\n\t\t\t\tthis._generateTooltip();\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis._bindClickEvents(cellEvents);\r\n\r\n\t\tthis._bindTouchEvents(cellEvents);\r\n\r\n\t\tthis._bindMouseEvents(cellEvents);\r\n\r\n\t\tif(this.column.modules.edit){\r\n\t\t\tthis.table.modules.edit.bindEditor(this);\r\n\t\t}\r\n\r\n\t\tif(this.column.definition.rowHandle && this.table.options.movableRows !== false && this.table.modExists(\"moveRow\")){\r\n\t\t\tthis.table.modules.moveRow.initializeCell(this);\r\n\t\t}\r\n\r\n\t\t//hide cell if not visible\r\n\t\tif(!this.column.visible){\r\n\t\t\tthis.hide();\r\n\t\t}\r\n\t}\r\n\r\n\t_bindClickEvents(cellEvents){\r\n\t\tvar element = this.element;\r\n\r\n\t\t//set event bindings\r\n\t\tif (cellEvents.cellClick || this.table.options.cellClick){\r\n\t\t\telement.addEventListener(\"click\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellClick){\r\n\t\t\t\t\tcellEvents.cellClick.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellClick){\r\n\t\t\t\t\tthis.table.options.cellClick.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellDblClick || this.table.options.cellDblClick){\r\n\t\t\telement.addEventListener(\"dblclick\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellDblClick){\r\n\t\t\t\t\tcellEvents.cellDblClick.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellDblClick){\r\n\t\t\t\t\tthis.table.options.cellDblClick.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\telement.addEventListener(\"dblclick\", (e) => {\r\n\t\t\t\tif(this.table.modExists(\"edit\")){\r\n\t\t\t\t\tif (this.table.modules.edit.currentCell === this){\r\n\t\t\t\t\t\treturn; //prevent instant selection of editor content\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\ttry{\r\n\t\t\t\t\tif (document.selection) { // IE\r\n\t\t\t\t\t\tvar range = document.body.createTextRange();\r\n\t\t\t\t\t\trange.moveToElementText(this.element);\r\n\t\t\t\t\t\trange.select();\r\n\t\t\t\t\t} else if (window.getSelection) {\r\n\t\t\t\t\t\tvar range = document.createRange();\r\n\t\t\t\t\t\trange.selectNode(this.element);\r\n\t\t\t\t\t\twindow.getSelection().removeAllRanges();\r\n\t\t\t\t\t\twindow.getSelection().addRange(range);\r\n\t\t\t\t\t}\r\n\t\t\t\t}catch(e){}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellContext || this.table.options.cellContext){\r\n\t\t\telement.addEventListener(\"contextmenu\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellContext){\r\n\t\t\t\t\tcellEvents.cellContext.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellContext){\r\n\t\t\t\t\tthis.table.options.cellContext.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t_bindMouseEvents(cellEvents){\r\n\t\tvar element = this.element;\r\n\r\n\t\tif (cellEvents.cellMouseEnter || this.table.options.cellMouseEnter){\r\n\t\t\telement.addEventListener(\"mouseenter\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellMouseEnter){\r\n\t\t\t\t\tcellEvents.cellMouseEnter.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellMouseEnter){\r\n\t\t\t\t\tthis.table.options.cellMouseEnter.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellMouseLeave || this.table.options.cellMouseLeave){\r\n\t\t\telement.addEventListener(\"mouseleave\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellMouseLeave){\r\n\t\t\t\t\tcellEvents.cellMouseLeave.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellMouseLeave){\r\n\t\t\t\t\tthis.table.options.cellMouseLeave.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellMouseOver || this.table.options.cellMouseOver){\r\n\t\t\telement.addEventListener(\"mouseover\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellMouseOver){\r\n\t\t\t\t\tcellEvents.cellMouseOver.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellMouseOver){\r\n\t\t\t\t\tthis.table.options.cellMouseOver.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellMouseOut || this.table.options.cellMouseOut){\r\n\t\t\telement.addEventListener(\"mouseout\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellMouseOut){\r\n\t\t\t\t\tcellEvents.cellMouseOut.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellMouseOut){\r\n\t\t\t\t\tthis.table.options.cellMouseOut.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellMouseMove || this.table.options.cellMouseMove){\r\n\t\t\telement.addEventListener(\"mousemove\", (e) => {\r\n\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\tif(cellEvents.cellMouseMove){\r\n\t\t\t\t\tcellEvents.cellMouseMove.call(this.table, e, component);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.options.cellMouseMove){\r\n\t\t\t\t\tthis.table.options.cellMouseMove.call(this.table, e, component);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t_bindTouchEvents(cellEvents){\r\n\t\tvar element = this.element,\r\n\t\tdblTap,\ttapHold, tap;\r\n\r\n\t\tif (cellEvents.cellTap || this.table.options.cellTap){\r\n\t\t\ttap = false;\r\n\r\n\t\t\telement.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\ttap = true;\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\telement.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tif(tap){\r\n\t\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\t\tif(cellEvents.cellTap){\r\n\t\t\t\t\t\tcellEvents.cellTap.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(this.table.options.cellTap){\r\n\t\t\t\t\t\tthis.table.options.cellTap.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttap = false;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellDblTap || this.table.options.cellDblTap){\r\n\t\t\tdblTap = null;\r\n\r\n\t\t\telement.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tif(dblTap){\r\n\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\tdblTap = null;\r\n\r\n\t\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\t\tif(cellEvents.cellDblTap){\r\n\t\t\t\t\t\tcellEvents.cellDblTap.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(this.table.options.cellDblTap){\r\n\t\t\t\t\t\tthis.table.options.cellDblTap.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\r\n\t\t\t\t\tdblTap = setTimeout(() => {\r\n\t\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\t\tdblTap = null;\r\n\t\t\t\t\t}, 300);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (cellEvents.cellTapHold || this.table.options.cellTapHold){\r\n\t\t\ttapHold = null;\r\n\r\n\t\t\telement.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\r\n\t\t\t\ttapHold = setTimeout(() => {\r\n\t\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\t\ttapHold = null;\r\n\t\t\t\t\ttap = false;\r\n\t\t\t\t\tvar component = this.getComponent();\r\n\r\n\t\t\t\t\tif(cellEvents.cellTapHold){\r\n\t\t\t\t\t\tcellEvents.cellTapHold.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(this.table.options.cellTapHold){\r\n\t\t\t\t\t\tthis.table.options.cellTapHold.call(this.table, e, component);\r\n\t\t\t\t\t}\r\n\t\t\t\t}, 1000);\r\n\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\telement.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\ttapHold = null;\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t//generate cell contents\r\n\t_generateContents(){\r\n\t\tvar val;\r\n\r\n\t\tif(this.table.modExists(\"format\")){\r\n\t\t\tval = this.table.modules.format.formatValue(this);\r\n\t\t}else{\r\n\t\t\tval = this.element.innerHTML = this.value;\r\n\t\t}\r\n\r\n\t\tswitch(typeof val){\r\n\t\t\tcase \"object\":\r\n\t\t\tif(val instanceof Node){\r\n\r\n\t\t\t\t//clear previous cell contents\r\n\t\t\t\twhile(this.element.firstChild) this.element.removeChild(this.element.firstChild);\r\n\r\n\t\t\t\tthis.element.appendChild(val);\r\n\t\t\t}else{\r\n\t\t\t\tthis.element.innerHTML = \"\";\r\n\r\n\t\t\t\tif(val != null){\r\n\t\t\t\t\tconsole.warn(\"Format Error - Formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:\", val);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\t\t\tcase \"undefined\":\r\n\t\t\tcase \"null\":\r\n\t\t\tthis.element.innerHTML = \"\";\r\n\t\t\tbreak;\r\n\t\t\tdefault:\r\n\t\t\tthis.element.innerHTML = val;\r\n\t\t}\r\n\t}\r\n\r\n\tcellRendered(){\r\n\t\tif(this.table.modExists(\"format\") && this.table.modules.format.cellRendered){\r\n\t\t\tthis.table.modules.format.cellRendered(this);\r\n\t\t}\r\n\t}\r\n\r\n\t//generate tooltip text\r\n\t_generateTooltip(){\r\n\t\tvar tooltip = this.column.tooltip;\r\n\r\n\t\tif(tooltip){\r\n\t\t\tif(tooltip === true){\r\n\t\t\t\ttooltip = this.value;\r\n\t\t\t}else if(typeof(tooltip) == \"function\"){\r\n\t\t\t\ttooltip = tooltip(this.getComponent());\r\n\r\n\t\t\t\tif(tooltip === false){\r\n\t\t\t\t\ttooltip = \"\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof tooltip === \"undefined\"){\r\n\t\t\t\ttooltip = \"\";\r\n\t\t\t}\r\n\r\n\t\t\tthis.element.setAttribute(\"title\", tooltip);\r\n\t\t}else{\r\n\t\t\tthis.element.setAttribute(\"title\", \"\");\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////////// Getters ////////////////////\r\n\tgetElement(containerOnly){\r\n\t\tif(!this.loaded){\r\n\t\t\tthis.loaded = true;\r\n\t\t\tif(!containerOnly){\r\n\t\t\t\tthis.layoutElement();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\tgetValue(){\r\n\t\treturn this.value;\r\n\t}\r\n\r\n\tgetOldValue(){\r\n\t\treturn this.oldValue;\r\n\t}\r\n\r\n\t//////////////////// Actions ////////////////////\r\n\tsetValue(value, mutate){\r\n\t\tvar changed = this.setValueProcessData(value, mutate),\r\n\t\tcomponent;\r\n\r\n\t\tif(changed){\r\n\t\t\tif(this.table.options.history && this.table.modExists(\"history\")){\r\n\t\t\t\tthis.table.modules.history.action(\"cellEdit\", this, {oldValue:this.oldValue, newValue:this.value});\r\n\t\t\t}\r\n\r\n\t\t\tcomponent = this.getComponent();\r\n\r\n\t\t\tif(this.column.cellEvents.cellEdited){\r\n\t\t\t\tthis.column.cellEvents.cellEdited.call(this.table, component);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.groupUpdateOnCellEdit && this.table.options.groupBy && this.table.modExists(\"groupRows\")) {\r\n\t\t\t\tthis.table.modules.groupRows.reassignRowToGroup(this.row);\r\n\t\t\t}\r\n\r\n\t\t\tthis.cellRendered();\r\n\r\n\t\t\tthis.table.options.cellEdited.call(this.table, component);\r\n\r\n\t\t\tif(this.table.options.dataChanged){\r\n\t\t\t\tthis.table.options.dataChanged.call(this.table, this.table.rowManager.getData());\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tsetValueProcessData(value, mutate){\r\n\t\tvar changed = false;\r\n\r\n\t\tif(this.value != value){\r\n\r\n\t\t\tchanged = true;\r\n\r\n\t\t\tif(mutate){\r\n\t\t\t\tif(this.column.modules.mutate){\r\n\t\t\t\t\tvalue = this.table.modules.mutator.transformCell(this, value);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.setValueActual(value);\r\n\r\n\t\tif(changed && this.table.modExists(\"columnCalcs\")){\r\n\t\t\tif(this.column.definition.topCalc || this.column.definition.bottomCalc){\r\n\t\t\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\r\n\t\t\t\t\tif(this.table.options.columnCalcs == \"table\" || this.table.options.columnCalcs == \"both\"){\r\n\t\t\t\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(this.table.options.columnCalcs != \"table\"){\r\n\t\t\t\t\t\tthis.table.modules.columnCalcs.recalcRowGroup(this.row);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn changed;\r\n\t}\r\n\r\n\tsetValueActual(value){\r\n\t\tthis.oldValue = this.value;\r\n\r\n\t\tthis.value = value;\r\n\r\n\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\")){\r\n\t\t\tthis.table.modules.reactiveData.block();\r\n\t\t}\r\n\r\n\t\tthis.column.setFieldValue(this.row.data, value);\r\n\r\n\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\")){\r\n\t\t\tthis.table.modules.reactiveData.unblock();\r\n\t\t}\r\n\r\n\t\tif(this.loaded){\r\n\t\t\tthis.layoutElement();\r\n\t\t}\r\n\t}\r\n\r\n\tlayoutElement(){\r\n\t\tthis._generateContents();\r\n\t\tthis._generateTooltip();\r\n\r\n\t\t//set resizable handles\r\n\t\tif(this.table.options.resizableColumns && this.table.modExists(\"resizeColumns\") && this.row.type === \"row\"){\r\n\t\t\tthis.table.modules.resizeColumns.initializeColumn(\"cell\", this.column, this.element);\r\n\t\t}\r\n\r\n\r\n\t\tif((this.column.definition.contextMenu || this.column.definition.clickMenu) && this.table.modExists(\"menu\")){\r\n\t\t\tthis.table.modules.menu.initializeCell(this);\r\n\t\t}\r\n\r\n\t\t//handle frozen cells\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.layoutElement(this.element, this.column);\r\n\t\t}\r\n\t}\r\n\r\n\tsetWidth(){\r\n\t\tthis.width = this.column.width;\r\n\t\tthis.element.style.width = this.column.widthStyled;\r\n\t}\r\n\r\n\tclearWidth(){\r\n\t\tthis.width = \"\";\r\n\t\tthis.element.style.width = \"\";\r\n\t}\r\n\r\n\tgetWidth(){\r\n\t\treturn this.width || this.element.offsetWidth;\r\n\t}\r\n\r\n\tsetMinWidth(){\r\n\t\tthis.minWidth = this.column.minWidth;\r\n\t\tthis.element.style.minWidth = this.column.minWidthStyled;\r\n\t}\r\n\r\n\tsetMaxWidth(){\r\n\t\tthis.maxWidth = this.column.maxWidth;\r\n\t\tthis.element.style.maxWidth = this.column.maxWidthStyled;\r\n\t}\r\n\r\n\tcheckHeight(){\r\n\t\t// var height = this.element.css(\"height\");\r\n\t\tthis.row.reinitializeHeight();\r\n\t}\r\n\r\n\tclearHeight(){\r\n\t\tthis.element.style.height = \"\";\r\n\t\tthis.height = null;\r\n\t}\r\n\r\n\tsetHeight(){\r\n\t\tthis.height = this.row.height;\r\n\t\tthis.element.style.height = this.row.heightStyled;\r\n\t}\r\n\r\n\tgetHeight(){\r\n\t\treturn this.height || this.element.offsetHeight;\r\n\t}\r\n\r\n\tshow(){\r\n\t\tthis.element.style.display = this.column.vertAlign ? \"inline-flex\" : \"\";\r\n\t}\r\n\r\n\thide(){\r\n\t\tthis.element.style.display = \"none\";\r\n\t}\r\n\r\n\tedit(force){\r\n\t\tif(this.table.modExists(\"edit\", true)){\r\n\t\t\treturn this.table.modules.edit.editCell(this, force);\r\n\t\t}\r\n\t}\r\n\r\n\tcancelEdit(){\r\n\t\tif(this.table.modExists(\"edit\", true)){\r\n\t\t\tvar editing = this.table.modules.edit.getCurrentCell();\r\n\r\n\t\t\tif(editing && editing._getSelf() === this){\r\n\t\t\t\tthis.table.modules.edit.cancelEdit();\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Cancel Editor Error - This cell is not currently being edited \");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\tif(this.column.modules.validate && this.table.modExists(\"validate\", true)){\r\n\t\t\tvar valid = this.table.modules.validate.validate(this.column.modules.validate, this, this.getValue());\r\n\r\n\t\t\treturn valid === true;\r\n\t\t}else{\r\n\t\t\treturn true;\r\n\t\t}\r\n\t}\r\n\r\n\tdelete(){\r\n\t\tif(!this.table.rowManager.redrawBlock && this.element.parentNode){\r\n\t\t\tthis.element.parentNode.removeChild(this.element);\r\n\t\t}\r\n\r\n\t\tif(this.modules.validate && this.modules.validate.invalid){\r\n\t\t\tthis.table.modules.validate.clearValidation(this);\r\n\t\t}\r\n\r\n\t\tif(this.modules.edit && this.modules.edit.edited){\r\n\t\t\tthis.table.modules.edit.clearEdited(this);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.history){\r\n\t\t\tthis.table.modules.history.clearComponentHistory(this);\r\n\t\t}\r\n\r\n\t\tthis.element = false;\r\n\t\tthis.column.deleteCell(this);\r\n\t\tthis.row.deleteCell(this);\r\n\t\tthis.calcs = {};\r\n\t}\r\n\r\n\t//////////////// Navigation /////////////////\r\n\tnav(){\r\n\t\tvar self = this,\r\n\t\tnextCell = false,\r\n\t\tindex = this.row.getCellIndex(this);\r\n\r\n\t\treturn {\r\n\t\t\tnext:function(){\r\n\t\t\t\tvar nextCell = this.right(),\r\n\t\t\t\tnextRow;\r\n\r\n\t\t\t\tif(!nextCell){\r\n\t\t\t\t\tnextRow = self.table.rowManager.nextDisplayRow(self.row, true);\r\n\r\n\t\t\t\t\tif(nextRow){\r\n\t\t\t\t\t\tnextCell = nextRow.findNextEditableCell(-1);\r\n\r\n\t\t\t\t\t\tif(nextCell){\r\n\t\t\t\t\t\t\tnextCell.edit();\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn false;\r\n\t\t\t},\r\n\t\t\tprev:function(){\r\n\t\t\t\tvar nextCell = this.left(),\r\n\t\t\t\tprevRow;\r\n\r\n\t\t\t\tif(!nextCell){\r\n\t\t\t\t\tprevRow = self.table.rowManager.prevDisplayRow(self.row, true);\r\n\r\n\t\t\t\t\tif(prevRow){\r\n\t\t\t\t\t\tnextCell = prevRow.findPrevEditableCell(prevRow.cells.length);\r\n\r\n\t\t\t\t\t\tif(nextCell){\r\n\t\t\t\t\t\t\tnextCell.edit();\r\n\t\t\t\t\t\t\treturn true;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn false;\r\n\t\t\t},\r\n\t\t\tleft:function(){\r\n\r\n\t\t\t\tnextCell = self.row.findPrevEditableCell(index);\r\n\r\n\t\t\t\tif(nextCell){\r\n\t\t\t\t\tnextCell.edit();\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tright:function(){\r\n\t\t\t\tnextCell = self.row.findNextEditableCell(index);\r\n\r\n\t\t\t\tif(nextCell){\r\n\t\t\t\t\tnextCell.edit();\r\n\t\t\t\t\treturn true;\r\n\t\t\t\t}else{\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tup:function(){\r\n\t\t\t\tvar nextRow = self.table.rowManager.prevDisplayRow(self.row, true);\r\n\r\n\t\t\t\tif(nextRow){\r\n\t\t\t\t\tnextRow.cells[index].edit();\r\n\t\t\t\t}\r\n\t\t\t},\r\n\t\t\tdown:function(){\r\n\t\t\t\tvar nextRow = self.table.rowManager.nextDisplayRow(self.row, true);\r\n\r\n\t\t\t\tif(nextRow){\r\n\t\t\t\t\tnextRow.cells[index].edit();\r\n\t\t\t\t}\r\n\t\t\t},\r\n\r\n\t\t};\r\n\t}\r\n\r\n\tgetIndex(){\r\n\t\tthis.row.getCellIndex(this);\r\n\t}\r\n\r\n\t//////////////// Object Generation /////////////////\r\n\tgetComponent(){\r\n\t\tif(!this.component){\r\n\t\t\tthis.component = new CellComponent(this);\r\n\t\t}\r\n\r\n\t\treturn this.component;\r\n\t}\r\n}","import ColumnComponent from './ColumnComponent.js';\r\nimport defaultOptions from './defaults/options.js';\r\n\r\nimport Cell from '../cell/Cell.js';\r\n\r\nclass Column {\r\n\r\n\tconstructor(def, parent){\r\n\t\tthis.table = parent.table;\r\n\t\tthis.definition = def; //column definition\r\n\t\tthis.parent = parent; //hold parent object\r\n\t\tthis.type = \"column\"; //type of element\r\n\t\tthis.columns = []; //child columns\r\n\t\tthis.cells = []; //cells bound to this column\r\n\t\tthis.element = this.createElement(); //column header element\r\n\t\tthis.contentElement = false;\r\n\t\tthis.titleHolderElement = false;\r\n\t\tthis.titleElement = false;\r\n\t\tthis.groupElement = this.createGroupElement(); //column group holder element\r\n\t\tthis.isGroup = false;\r\n\t\tthis.tooltip = false; //hold column tooltip\r\n\t\tthis.hozAlign = \"\"; //horizontal text alignment\r\n\t\tthis.vertAlign = \"\"; //vert text alignment\r\n\r\n\t\t//multi dimensional filed handling\r\n\t\tthis.field =\"\";\r\n\t\tthis.fieldStructure = \"\";\r\n\t\tthis.getFieldValue = \"\";\r\n\t\tthis.setFieldValue = \"\";\r\n\r\n\t\tthis.titleFormatterRendered = false;\r\n\r\n\t\tthis.mapDefinitionDefaults();\r\n\r\n\t\tthis.setField(this.definition.field);\r\n\r\n\t\tif(this.table.options.invalidOptionWarnings){\r\n\t\t\tthis.checkDefinition();\r\n\t\t}\r\n\r\n\t\tthis.modules = {}; //hold module variables;\r\n\r\n\t\tthis.cellEvents = {\r\n\t\t\tcellClick:false,\r\n\t\t\tcellDblClick:false,\r\n\t\t\tcellContext:false,\r\n\t\t\tcellTap:false,\r\n\t\t\tcellDblTap:false,\r\n\t\t\tcellTapHold:false,\r\n\t\t\tcellMouseEnter:false,\r\n\t\t\tcellMouseLeave:false,\r\n\t\t\tcellMouseOver:false,\r\n\t\t\tcellMouseOut:false,\r\n\t\t\tcellMouseMove:false,\r\n\t\t};\r\n\r\n\t\tthis.width = null; //column width\r\n\t\tthis.widthStyled = \"\"; //column width prestyled to improve render efficiency\r\n\t\tthis.maxWidth = null; //column maximum width\r\n\t\tthis.maxWidthStyled = \"\"; //column maximum prestyled to improve render efficiency\r\n\t\tthis.minWidth = null; //column minimum width\r\n\t\tthis.minWidthStyled = \"\"; //column minimum prestyled to improve render efficiency\r\n\t\tthis.widthFixed = false; //user has specified a width for this column\r\n\r\n\t\tthis.visible = true; //default visible state\r\n\r\n\t\tthis.component = null;\r\n\r\n\t\tthis._mapDepricatedFunctionality();\r\n\r\n\t\t//initialize column\r\n\t\tif(def.columns){\r\n\r\n\t\t\tthis.isGroup = true;\r\n\r\n\t\t\tdef.columns.forEach((def, i) => {\r\n\t\t\t\tvar newCol = new Column(def, this);\r\n\t\t\t\tthis.attachColumn(newCol);\r\n\t\t\t});\r\n\r\n\t\t\tthis.checkColumnVisibility();\r\n\t\t}else{\r\n\t\t\tparent.registerColumnField(this);\r\n\t\t}\r\n\r\n\t\tif(def.rowHandle && this.table.options.movableRows !== false && this.table.modExists(\"moveRow\")){\r\n\t\t\tthis.table.modules.moveRow.setHandle(true);\r\n\t\t}\r\n\r\n\t\tthis._buildHeader();\r\n\r\n\t\tthis.bindModuleColumns();\r\n\t}\r\n\r\n\tcreateElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-col\");\r\n\t\tel.setAttribute(\"role\", \"columnheader\");\r\n\t\tel.setAttribute(\"aria-sort\", \"none\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\tcreateGroupElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-col-group-cols\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\tmapDefinitionDefaults(){\r\n\t\tvar defaults = this.table.options.columnDefaults;\r\n\r\n\t\tif(defaults){\r\n\t\t\tfor(let key in defaults){\r\n\t\t\t\tif(typeof this.definition[key] === \"undefined\"){\r\n\t\t\t\t\tthis.definition[key] = defaults[key];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tcheckDefinition(){\r\n\t\tObject.keys(this.definition).forEach((key) => {\r\n\t\t\tif(Column.defaultOptionList.indexOf(key) === -1){\r\n\t\t\t\tconsole.warn(\"Invalid column definition option in '\" + (this.field || this.definition.title) + \"' column:\", key)\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tsetField(field){\r\n\t\tthis.field = field;\r\n\t\tthis.fieldStructure = field ? (this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field]) : [];\r\n\t\tthis.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;\r\n\t\tthis.setFieldValue = this.fieldStructure.length > 1 ? this._setNestedData : this._setFlatData;\r\n\t}\r\n\r\n\t//register column position with column manager\r\n\tregisterColumnPosition(column){\r\n\t\tthis.parent.registerColumnPosition(column);\r\n\t}\r\n\r\n\t//register column position with column manager\r\n\tregisterColumnField(column){\r\n\t\tthis.parent.registerColumnField(column);\r\n\t}\r\n\r\n\t//trigger position registration\r\n\treRegisterPosition(){\r\n\t\tif(this.isGroup){\r\n\t\t\tthis.columns.forEach(function(column){\r\n\t\t\t\tcolumn.reRegisterPosition();\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tthis.registerColumnPosition(this);\r\n\t\t}\r\n\t}\r\n\r\n\t_mapDepricatedFunctionality(){\r\n\t\t//all previously deprecated functionality removed in the 5.0 release\r\n\t}\r\n\r\n\tsetTooltip(){\r\n\t\tvar def = this.definition;\r\n\r\n\t\t//set header tooltips\r\n\t\tvar tooltip = def.headerTooltip || def.tooltip === false ? def.headerTooltip : this.table.options.tooltipsHeader;\r\n\r\n\t\tif(tooltip){\r\n\t\t\tif(tooltip === true){\r\n\t\t\t\tif(def.field){\r\n\t\t\t\t\tthis.table.modules.localize.bind(\"columns|\" + def.field, (value) => {\r\n\t\t\t\t\t\tthis.element.setAttribute(\"title\", value || def.title);\r\n\t\t\t\t\t});\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.element.setAttribute(\"title\", def.title);\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\tif(typeof(tooltip) == \"function\"){\r\n\t\t\t\t\ttooltip = tooltip(this.getComponent());\r\n\r\n\t\t\t\t\tif(tooltip === false){\r\n\t\t\t\t\t\ttooltip = \"\";\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.element.setAttribute(\"title\", tooltip);\r\n\t\t\t}\r\n\r\n\t\t}else{\r\n\t\t\tthis.element.setAttribute(\"title\", \"\");\r\n\t\t}\r\n\t}\r\n\r\n\t//build header element\r\n\t_buildHeader(){\r\n\t\tvar def = this.definition;\r\n\r\n\t\twhile(this.element.firstChild) this.element.removeChild(this.element.firstChild);\r\n\r\n\t\tif(def.headerVertical){\r\n\t\t\tthis.element.classList.add(\"tabulator-col-vertical\");\r\n\r\n\t\t\tif(def.headerVertical === \"flip\"){\r\n\t\t\t\tthis.element.classList.add(\"tabulator-col-vertical-flip\");\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.contentElement = this._bindEvents();\r\n\r\n\t\tthis.contentElement = this._buildColumnHeaderContent();\r\n\r\n\t\tthis.element.appendChild(this.contentElement);\r\n\r\n\t\tif(this.isGroup){\r\n\t\t\tthis._buildGroupHeader();\r\n\t\t}else{\r\n\t\t\tthis._buildColumnHeader();\r\n\t\t}\r\n\r\n\t\tthis.setTooltip();\r\n\r\n\t\t//set resizable handles\r\n\t\tif(this.table.options.resizableColumns && this.table.modExists(\"resizeColumns\")){\r\n\t\t\tthis.table.modules.resizeColumns.initializeColumn(\"header\", this, this.element);\r\n\t\t}\r\n\r\n\t\t//set resizable handles\r\n\t\tif(def.headerFilter && this.table.modExists(\"filter\") && this.table.modExists(\"edit\")){\r\n\t\t\tif(typeof def.headerFilterPlaceholder !== \"undefined\" && def.field){\r\n\t\t\t\tthis.table.modules.localize.setHeaderFilterColumnPlaceholder(def.field, def.headerFilterPlaceholder);\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.modules.filter.initializeColumn(this);\r\n\t\t}\r\n\r\n\r\n\t\t//set resizable handles\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set movable column\r\n\t\tif(this.table.options.movableColumns && !this.isGroup && this.table.modExists(\"moveColumn\")){\r\n\t\t\tthis.table.modules.moveColumn.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set calcs column\r\n\t\tif((def.topCalc || def.bottomCalc) && this.table.modExists(\"columnCalcs\")){\r\n\t\t\tthis.table.modules.columnCalcs.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//handle persistence\r\n\t\tif(this.table.modExists(\"persistence\") && this.table.modules.persistence.config.columns){\r\n\t\t\tthis.table.modules.persistence.initializeColumn(this);\r\n\t\t}\r\n\r\n\r\n\t\t//update header tooltip on mouse enter\r\n\t\tthis.element.addEventListener(\"mouseenter\", (e) => {\r\n\t\t\tthis.setTooltip();\r\n\t\t});\r\n\t}\r\n\r\n\t_bindEvents(){\r\n\t\tvar def = this.definition,\r\n\t\tdblTap,\ttapHold, tap;\r\n\r\n\t\t//setup header click event bindings\r\n\t\tif(typeof(def.headerClick) == \"function\"){\r\n\t\t\tthis.element.addEventListener(\"click\", (e) => {def.headerClick(e, this.getComponent());});\r\n\t\t}\r\n\r\n\t\tif(typeof(def.headerDblClick) == \"function\"){\r\n\t\t\tthis.element.addEventListener(\"dblclick\", (e) => {def.headerDblClick(e, this.getComponent());});\r\n\t\t}\r\n\r\n\t\tif(typeof(def.headerContext) == \"function\"){\r\n\t\t\tthis.element.addEventListener(\"contextmenu\", (e) => {def.headerContext(e, this.getComponent());});\r\n\t\t}\r\n\r\n\t\t//setup header tap event bindings\r\n\t\tif(typeof(def.headerTap) == \"function\"){\r\n\t\t\ttap = false;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\ttap = true;\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tif(tap){\r\n\t\t\t\t\tdef.headerTap(e, this.getComponent());\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttap = false;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(typeof(def.headerDblTap) == \"function\"){\r\n\t\t\tdblTap = null;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\r\n\t\t\t\tif(dblTap){\r\n\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\tdblTap = null;\r\n\r\n\t\t\t\t\tdef.headerDblTap(e, this.getComponent());\r\n\t\t\t\t}else{\r\n\r\n\t\t\t\t\tdblTap = setTimeout(() => {\r\n\t\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\t\tdblTap = null;\r\n\t\t\t\t\t}, 300);\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(typeof(def.headerTapHold) == \"function\"){\r\n\t\t\ttapHold = null;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\r\n\t\t\t\ttapHold = setTimeout(function(){\r\n\t\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\t\ttapHold = null;\r\n\t\t\t\t\ttap = false;\r\n\t\t\t\t\tdef.headerTapHold(e, this.getComponent());\r\n\t\t\t\t}, 1000);\r\n\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\ttapHold = null;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//store column cell click event bindings\r\n\t\tif(typeof(def.cellClick) == \"function\"){\r\n\t\t\tthis.cellEvents.cellClick = def.cellClick;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellDblClick) == \"function\"){\r\n\t\t\tthis.cellEvents.cellDblClick = def.cellDblClick;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellContext) == \"function\"){\r\n\t\t\tthis.cellEvents.cellContext = def.cellContext;\r\n\t\t}\r\n\r\n\t\t//store column mouse event bindings\r\n\t\tif(typeof(def.cellMouseEnter) == \"function\"){\r\n\t\t\tthis.cellEvents.cellMouseEnter = def.cellMouseEnter;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellMouseLeave) == \"function\"){\r\n\t\t\tthis.cellEvents.cellMouseLeave = def.cellMouseLeave;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellMouseOver) == \"function\"){\r\n\t\t\tthis.cellEvents.cellMouseOver = def.cellMouseOver;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellMouseOut) == \"function\"){\r\n\t\t\tthis.cellEvents.cellMouseOut = def.cellMouseOut;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellMouseMove) == \"function\"){\r\n\t\t\tthis.cellEvents.cellMouseMove = def.cellMouseMove;\r\n\t\t}\r\n\r\n\t\t//setup column cell tap event bindings\r\n\t\tif(typeof(def.cellTap) == \"function\"){\r\n\t\t\tthis.cellEvents.cellTap = def.cellTap;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellDblTap) == \"function\"){\r\n\t\t\tthis.cellEvents.cellDblTap = def.cellDblTap;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellTapHold) == \"function\"){\r\n\t\t\tthis.cellEvents.cellTapHold = def.cellTapHold;\r\n\t\t}\r\n\r\n\t\t//setup column cell edit callbacks\r\n\t\tif(typeof(def.cellEdited) == \"function\"){\r\n\t\t\tthis.cellEvents.cellEdited = def.cellEdited;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellEditing) == \"function\"){\r\n\t\t\tthis.cellEvents.cellEditing = def.cellEditing;\r\n\t\t}\r\n\r\n\t\tif(typeof(def.cellEditCancelled) == \"function\"){\r\n\t\t\tthis.cellEvents.cellEditCancelled = def.cellEditCancelled;\r\n\t\t}\r\n\t}\r\n\r\n\t//build header element for header\r\n\t_buildColumnHeader(){\r\n\t\tvar def = this.definition,\r\n\t\ttable = this.table,\r\n\t\tsortable;\r\n\r\n\t\t//set column sorter\r\n\t\tif(table.modExists(\"sort\")){\r\n\t\t\ttable.modules.sort.initializeColumn(this, this.titleHolderElement);\r\n\t\t}\r\n\r\n\t\t//set column header context menu\r\n\t\tif((def.headerContextMenu || def.headerClickMenu || def.headerMenu) && table.modExists(\"menu\")){\r\n\t\t\ttable.modules.menu.initializeColumnHeader(this);\r\n\t\t}\r\n\r\n\t\t//set column formatter\r\n\t\tif(table.modExists(\"format\")){\r\n\t\t\ttable.modules.format.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set column editor\r\n\t\tif(typeof def.editor != \"undefined\" && table.modExists(\"edit\")){\r\n\t\t\ttable.modules.edit.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set colum validator\r\n\t\tif(typeof def.validator != \"undefined\" && table.modExists(\"validate\")){\r\n\t\t\ttable.modules.validate.initializeColumn(this);\r\n\t\t}\r\n\r\n\r\n\t\t//set column mutator\r\n\t\tif(table.modExists(\"mutator\")){\r\n\t\t\ttable.modules.mutator.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set column accessor\r\n\t\tif(table.modExists(\"accessor\")){\r\n\t\t\ttable.modules.accessor.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set respoviveLayout\r\n\t\tif(typeof table.options.responsiveLayout && table.modExists(\"responsiveLayout\")){\r\n\t\t\ttable.modules.responsiveLayout.initializeColumn(this);\r\n\t\t}\r\n\r\n\t\t//set column visibility\r\n\t\tif(typeof def.visible != \"undefined\"){\r\n\t\t\tif(def.visible){\r\n\t\t\t\tthis.show(true);\r\n\t\t\t}else{\r\n\t\t\t\tthis.hide(true);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//asign additional css classes to column header\r\n\t\tif(def.cssClass){\r\n\t\t\tvar classeNames = def.cssClass.split(\" \");\r\n\t\t\tclasseNames.forEach((className) => {\r\n\t\t\t\tthis.element.classList.add(className);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(def.field){\r\n\t\t\tthis.element.setAttribute(\"tabulator-field\", def.field);\r\n\t\t}\r\n\r\n\t\t//set min width if present\r\n\t\tthis.setMinWidth(typeof def.minWidth == \"undefined\" ? this.table.options.columnMinWidth : parseInt(def.minWidth));\r\n\r\n\t\tif(def.maxWidth || this.table.options.columnMaxWidth){\r\n\t\t\tif(def.maxWidth !== false){\r\n\t\t\t\tthis.setMaxWidth(typeof def.maxWidth == \"undefined\" ? this.table.options.columnMaxWidth : parseInt(def.maxWidth));\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.reinitializeWidth();\r\n\r\n\t\t//set tooltip if present\r\n\t\tthis.tooltip = this.definition.tooltip || this.definition.tooltip === false ? this.definition.tooltip : this.table.options.tooltips;\r\n\r\n\t\t//set orizontal text alignment\r\n\t\tthis.hozAlign = typeof(this.definition.hozAlign) == \"undefined\" ? this.table.options.cellHozAlign : this.definition.hozAlign;\r\n\t\tthis.vertAlign = typeof(this.definition.vertAlign) == \"undefined\" ? this.table.options.cellVertAlign : this.definition.vertAlign;\r\n\r\n\t\tthis.titleElement.style.textAlign = this.definition.headerHozAlign || this.table.options.headerHozAlign;\r\n\t}\r\n\r\n\t_buildColumnHeaderContent(){\r\n\t\tvar def = this.definition,\r\n\t\ttable = this.table;\r\n\r\n\t\tvar contentElement = document.createElement(\"div\");\r\n\t\tcontentElement.classList.add(\"tabulator-col-content\");\r\n\r\n\t\tthis.titleHolderElement = document.createElement(\"div\");\r\n\t\tthis.titleHolderElement.classList.add(\"tabulator-col-title-holder\");\r\n\r\n\t\tcontentElement.appendChild(this.titleHolderElement);\r\n\r\n\t\tthis.titleElement = this._buildColumnHeaderTitle();\r\n\r\n\t\tthis.titleHolderElement.appendChild(this.titleElement);\r\n\r\n\t\treturn contentElement;\r\n\t}\r\n\r\n\t//build title element of column\r\n\t_buildColumnHeaderTitle(){\r\n\t\tvar def = this.definition,\r\n\t\ttable = this.table,\r\n\t\ttitle;\r\n\r\n\t\tvar titleHolderElement = document.createElement(\"div\");\r\n\t\ttitleHolderElement.classList.add(\"tabulator-col-title\");\r\n\r\n\t\tif(def.editableTitle){\r\n\t\t\tvar titleElement = document.createElement(\"input\");\r\n\t\t\ttitleElement.classList.add(\"tabulator-title-editor\");\r\n\r\n\t\t\ttitleElement.addEventListener(\"click\", (e) => {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\ttitleElement.focus();\r\n\t\t\t});\r\n\r\n\t\t\ttitleElement.addEventListener(\"change\", () => {\r\n\t\t\t\tdef.title = titleElement.value;\r\n\t\t\t\ttable.options.columnTitleChanged.call(this.table, this.getComponent());\r\n\t\t\t});\r\n\r\n\t\t\ttitleHolderElement.appendChild(titleElement);\r\n\r\n\t\t\tif(def.field){\r\n\t\t\t\ttable.modules.localize.bind(\"columns|\" + def.field, (text) => {\r\n\t\t\t\t\ttitleElement.value = text || (def.title || \" \");\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\ttitleElement.value = def.title || \" \";\r\n\t\t\t}\r\n\r\n\t\t}else{\r\n\t\t\tif(def.field){\r\n\t\t\t\ttable.modules.localize.bind(\"columns|\" + def.field, (text) => {\r\n\t\t\t\t\tthis._formatColumnHeaderTitle(titleHolderElement, text || (def.title || \" \"));\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tthis._formatColumnHeaderTitle(titleHolderElement, def.title || \" \");\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn titleHolderElement;\r\n\t}\r\n\r\n\t_formatColumnHeaderTitle(el, title){\r\n\t\tvar formatter, contents, params, mockCell, onRendered;\r\n\r\n\t\tif(this.definition.titleFormatter && this.table.modExists(\"format\")){\r\n\r\n\t\t\tformatter = this.table.modules.format.getFormatter(this.definition.titleFormatter);\r\n\r\n\t\t\tonRendered = (callback) => {\r\n\t\t\t\tthis.titleFormatterRendered = callback;\r\n\t\t\t};\r\n\r\n\t\t\tmockCell = {\r\n\t\t\t\tgetValue:function(){\r\n\t\t\t\t\treturn title;\r\n\t\t\t\t},\r\n\t\t\t\tgetElement:function(){\r\n\t\t\t\t\treturn el;\r\n\t\t\t\t}\r\n\t\t\t};\r\n\r\n\t\t\tparams = this.definition.titleFormatterParams || {};\r\n\r\n\t\t\tparams = typeof params === \"function\" ? params() : params;\r\n\r\n\t\t\tcontents = formatter.call(this.table.modules.format, mockCell, params, onRendered);\r\n\r\n\t\t\tswitch(typeof contents){\r\n\t\t\t\tcase \"object\":\r\n\t\t\t\tif(contents instanceof Node){\r\n\t\t\t\t\tel.appendChild(contents);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tel.innerHTML = \"\";\r\n\t\t\t\t\tconsole.warn(\"Format Error - Title formatter has returned a type of object, the only valid formatter object return is an instance of Node, the formatter returned:\", contents);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\t\t\t\tcase \"undefined\":\r\n\t\t\t\tcase \"null\":\r\n\t\t\t\tel.innerHTML = \"\";\r\n\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\tel.innerHTML = contents;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tel.innerHTML = title;\r\n\t\t}\r\n\t}\r\n\r\n\t//build header element for column group\r\n\t_buildGroupHeader(){\r\n\t\tthis.element.classList.add(\"tabulator-col-group\");\r\n\t\tthis.element.setAttribute(\"role\", \"columngroup\");\r\n\t\tthis.element.setAttribute(\"aria-title\", this.definition.title);\r\n\r\n\t\t//asign additional css classes to column header\r\n\t\tif(this.definition.cssClass){\r\n\t\t\tvar classeNames = this.definition.cssClass.split(\" \");\r\n\t\t\tclasseNames.forEach((className) => {\r\n\t\t\t\tthis.element.classList.add(className);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//set column header context menu\r\n\t\tif ((this.definition.headerContextMenu || this.definition.headerMenu) && this.table.modExists(\"menu\")) {\r\n\t\t\tthis.table.modules.menu.initializeColumnHeader(this);\r\n\t\t}\r\n\r\n\t\tthis.titleElement.style.textAlign = this.definition.headerHozAlign || this.table.options.headerHozAlign;\r\n\r\n\t\tthis.element.appendChild(this.groupElement);\r\n\t}\r\n\r\n\t//flat field lookup\r\n\t_getFlatData(data){\r\n\t\treturn data[this.field];\r\n\t}\r\n\r\n\t//nested field lookup\r\n\t_getNestedData(data){\r\n\t\tvar dataObj = data,\r\n\t\tstructure = this.fieldStructure,\r\n\t\tlength = structure.length,\r\n\t\toutput;\r\n\r\n\t\tfor(let i = 0; i < length; i++){\r\n\r\n\t\t\tdataObj = dataObj[structure[i]];\r\n\r\n\t\t\toutput = dataObj;\r\n\r\n\t\t\tif(!dataObj){\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\t//flat field set\r\n\t_setFlatData(data, value){\r\n\t\tif(this.field){\r\n\t\t\tdata[this.field] = value;\r\n\t\t}\r\n\t}\r\n\r\n\t//nested field set\r\n\t_setNestedData(data, value){\r\n\t\tvar dataObj = data,\r\n\t\tstructure = this.fieldStructure,\r\n\t\tlength = structure.length;\r\n\r\n\t\tfor(let i = 0; i < length; i++){\r\n\r\n\t\t\tif(i == length -1){\r\n\t\t\t\tdataObj[structure[i]] = value;\r\n\t\t\t}else{\r\n\t\t\t\tif(!dataObj[structure[i]]){\r\n\t\t\t\t\tif(typeof value !== \"undefined\"){\r\n\t\t\t\t\t\tdataObj[structure[i]] = {};\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdataObj = dataObj[structure[i]];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//attach column to this group\r\n\tattachColumn(column){\r\n\t\tif(this.groupElement){\r\n\t\t\tthis.columns.push(column);\r\n\t\t\tthis.groupElement.appendChild(column.getElement());\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Column Warning - Column being attached to another column instead of column group\");\r\n\t\t}\r\n\t}\r\n\r\n\t//vertically align header in column\r\n\tverticalAlign(alignment, height){\r\n\r\n\t\t//calculate height of column header and group holder element\r\n\t\tvar parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : (height || this.parent.getHeadersElement().clientHeight);\r\n\t\t// var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : this.parent.getHeadersElement().clientHeight;\r\n\r\n\t\tthis.element.style.height = parentHeight + \"px\";\r\n\r\n\t\tif(this.isGroup){\r\n\t\t\tthis.groupElement.style.minHeight = (parentHeight - this.contentElement.offsetHeight) + \"px\";\r\n\t\t}\r\n\r\n\t\t//vertically align cell contents\r\n\t\tif(!this.isGroup && alignment !== \"top\"){\r\n\t\t\tif(alignment === \"bottom\"){\r\n\t\t\t\tthis.element.style.paddingTop = (this.element.clientHeight - this.contentElement.offsetHeight) + \"px\";\r\n\t\t\t}else{\r\n\t\t\t\tthis.element.style.paddingTop = ((this.element.clientHeight - this.contentElement.offsetHeight) / 2) + \"px\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.columns.forEach(function(column){\r\n\t\t\tcolumn.verticalAlign(alignment);\r\n\t\t});\r\n\t}\r\n\r\n\t//clear vertical alignmenet\r\n\tclearVerticalAlign(){\r\n\t\tthis.element.style.paddingTop = \"\";\r\n\t\tthis.element.style.height = \"\";\r\n\t\tthis.element.style.minHeight = \"\";\r\n\t\tthis.groupElement.style.minHeight = \"\";\r\n\r\n\t\tthis.columns.forEach(function(column){\r\n\t\t\tcolumn.clearVerticalAlign();\r\n\t\t});\r\n\t}\r\n\r\n\tbindModuleColumns (){\r\n\t\t//check if rownum formatter is being used on a column\r\n\t\tif(this.definition.formatter == \"rownum\"){\r\n\t\t\tthis.table.rowManager.rowNumColumn = this;\r\n\t\t}\r\n\t}\r\n\r\n\t//// Retreive Column Information ////\r\n\t//return column header element\r\n\tgetElement(){\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\t//return colunm group element\r\n\tgetGroupElement(){\r\n\t\treturn this.groupElement;\r\n\t}\r\n\r\n\t//return field name\r\n\tgetField(){\r\n\t\treturn this.field;\r\n\t}\r\n\r\n\t//return the first column in a group\r\n\tgetFirstColumn(){\r\n\t\tif(!this.isGroup){\r\n\t\t\treturn this;\r\n\t\t}else{\r\n\t\t\tif(this.columns.length){\r\n\t\t\t\treturn this.columns[0].getFirstColumn();\r\n\t\t\t}else{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//return the last column in a group\r\n\tgetLastColumn(){\r\n\t\tif(!this.isGroup){\r\n\t\t\treturn this;\r\n\t\t}else{\r\n\t\t\tif(this.columns.length){\r\n\t\t\t\treturn this.columns[this.columns.length -1].getLastColumn();\r\n\t\t\t}else{\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//return all columns in a group\r\n\tgetColumns(){\r\n\t\treturn this.columns;\r\n\t}\r\n\r\n\t//return all columns in a group\r\n\tgetCells(){\r\n\t\treturn this.cells;\r\n\t}\r\n\r\n\t//retreive the top column in a group of columns\r\n\tgetTopColumn(){\r\n\t\tif(this.parent.isGroup){\r\n\t\t\treturn this.parent.getTopColumn();\r\n\t\t}else{\r\n\t\t\treturn this;\r\n\t\t}\r\n\t}\r\n\r\n\t//return column definition object\r\n\tgetDefinition(updateBranches){\r\n\t\tvar colDefs = [];\r\n\r\n\t\tif(this.isGroup && updateBranches){\r\n\t\t\tthis.columns.forEach(function(column){\r\n\t\t\t\tcolDefs.push(column.getDefinition(true));\r\n\t\t\t});\r\n\r\n\t\t\tthis.definition.columns = colDefs;\r\n\t\t}\r\n\r\n\t\treturn this.definition;\r\n\t}\r\n\r\n\t//////////////////// Actions ////////////////////\r\n\tcheckColumnVisibility(){\r\n\t\tvar visible = false;\r\n\r\n\t\tthis.columns.forEach(function(column){\r\n\t\t\tif(column.visible){\r\n\t\t\t\tvisible = true;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(visible){\r\n\t\t\tthis.show();\r\n\t\t\tthis.parent.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), false);\r\n\t\t}else{\r\n\t\t\tthis.hide();\r\n\t\t}\r\n\t}\r\n\r\n\t//show column\r\n\tshow(silent, responsiveToggle){\r\n\t\tif(!this.visible){\r\n\t\t\tthis.visible = true;\r\n\r\n\t\t\tthis.element.style.display = \"\";\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.checkColumnVisibility();\r\n\t\t\t}\r\n\r\n\t\t\tthis.cells.forEach(function(cell){\r\n\t\t\t\tcell.show();\r\n\t\t\t});\r\n\r\n\t\t\tif(!this.isGroup && this.width === null){\r\n\t\t\t\tthis.reinitializeWidth();\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.columnManager._verticalAlignHeaders();\r\n\r\n\t\t\tif(this.table.options.persistence && this.table.modExists(\"persistence\", true) && this.table.modules.persistence.config.columns){\r\n\t\t\t\tthis.table.modules.persistence.save(\"columns\");\r\n\t\t\t}\r\n\r\n\t\t\tif(!responsiveToggle && this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\tthis.table.modules.responsiveLayout.updateColumnVisibility(this, this.visible);\r\n\t\t\t}\r\n\r\n\t\t\tif(!silent){\r\n\t\t\t\tthis.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), true);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.matchChildWidths();\r\n\t\t\t}\r\n\r\n\t\t\tif(!this.silent && this.table.options.virtualDomHoz){\r\n\t\t\t\tthis.table.vdomHoz.reinitialize();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//hide column\r\n\thide(silent, responsiveToggle){\r\n\t\tif(this.visible){\r\n\t\t\tthis.visible = false;\r\n\r\n\t\t\tthis.element.style.display = \"none\";\r\n\r\n\t\t\tthis.table.columnManager._verticalAlignHeaders();\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.checkColumnVisibility();\r\n\t\t\t}\r\n\r\n\t\t\tthis.cells.forEach(function(cell){\r\n\t\t\t\tcell.hide();\r\n\t\t\t});\r\n\r\n\t\t\tif(this.table.options.persistence && this.table.modExists(\"persistence\", true) && this.table.modules.persistence.config.columns){\r\n\t\t\t\tthis.table.modules.persistence.save(\"columns\");\r\n\t\t\t}\r\n\r\n\t\t\tif(!responsiveToggle && this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\tthis.table.modules.responsiveLayout.updateColumnVisibility(this, this.visible);\r\n\t\t\t}\r\n\r\n\t\t\tif(!silent){\r\n\t\t\t\tthis.table.options.columnVisibilityChanged.call(this.table, this.getComponent(), false);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.matchChildWidths();\r\n\t\t\t}\r\n\r\n\t\t\tif(!this.silent && this.table.options.virtualDomHoz){\r\n\t\t\t\tthis.table.vdomHoz.reinitialize();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tmatchChildWidths(){\r\n\t\tvar childWidth = 0;\r\n\r\n\t\tif(this.contentElement && this.columns.length){\r\n\t\t\tthis.columns.forEach(function(column){\r\n\t\t\t\tif(column.visible){\r\n\t\t\t\t\tchildWidth += column.getWidth();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.contentElement.style.maxWidth = (childWidth - 1) + \"px\";\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.matchChildWidths();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tremoveChild(child){\r\n\t\tvar index = this.columns.indexOf(child);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tthis.columns.splice(index, 1);\r\n\t\t}\r\n\r\n\t\tif(!this.columns.length){\r\n\t\t\tthis.delete();\r\n\t\t}\r\n\t}\r\n\r\n\tsetWidth(width){\r\n\t\tthis.widthFixed = true;\r\n\t\tthis.setWidthActual(width);\r\n\t}\r\n\r\n\tsetWidthActual(width){\r\n\t\tif(isNaN(width)){\r\n\t\t\twidth = Math.floor((this.table.element.clientWidth/100) * parseInt(width));\r\n\t\t}\r\n\r\n\t\twidth = Math.max(this.minWidth, width);\r\n\r\n\t\tif(this.maxWidth){\r\n\t\t\twidth = Math.min(this.maxWidth, width);\r\n\t\t}\r\n\r\n\t\tthis.width = width;\r\n\t\tthis.widthStyled = width ? width + \"px\" : \"\";\r\n\r\n\t\tthis.element.style.width = this.widthStyled;\r\n\r\n\t\tif(!this.isGroup){\r\n\t\t\tthis.cells.forEach(function(cell){\r\n\t\t\t\tcell.setWidth();\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(this.parent.isGroup){\r\n\t\t\tthis.parent.matchChildWidths();\r\n\t\t}\r\n\r\n\t\t//set resizable handles\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.layout();\r\n\t\t}\r\n\t}\r\n\r\n\tcheckCellHeights(){\r\n\t\tvar rows = [];\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tif(cell.row.heightInitialized){\r\n\t\t\t\tif(cell.row.getElement().offsetParent !== null){\r\n\t\t\t\t\trows.push(cell.row);\r\n\t\t\t\t\tcell.row.clearCellHeight();\r\n\t\t\t\t}else{\r\n\t\t\t\t\tcell.row.heightInitialized = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\trows.forEach(function(row){\r\n\t\t\trow.calcHeight();\r\n\t\t});\r\n\r\n\t\trows.forEach(function(row){\r\n\t\t\trow.setCellHeight();\r\n\t\t});\r\n\t}\r\n\r\n\tgetWidth(){\r\n\t\tvar width = 0;\r\n\r\n\t\tif(this.isGroup){\r\n\t\t\tthis.columns.forEach(function(column){\r\n\t\t\t\tif(column.visible){\r\n\t\t\t\t\twidth += column.getWidth();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\twidth = this.width;\r\n\t\t}\r\n\r\n\t\treturn width;\r\n\t}\r\n\r\n\tgetHeight(){\r\n\t\treturn this.element.offsetHeight;\r\n\t}\r\n\r\n\tsetMinWidth(minWidth){\r\n\t\tthis.minWidth = minWidth;\r\n\t\tthis.minWidthStyled = minWidth ? minWidth + \"px\" : \"\";\r\n\r\n\t\tthis.element.style.minWidth = this.minWidthStyled;\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tcell.setMinWidth();\r\n\t\t});\r\n\t}\r\n\r\n\tsetMaxWidth(maxWidth){\r\n\t\tthis.maxWidth = maxWidth;\r\n\t\tthis.maxWidthStyled = maxWidth ? maxWidth + \"px\" : \"\";\r\n\r\n\t\tthis.element.style.maxWidth = this.maxWidthStyled;\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tcell.setMaxWidth();\r\n\t\t});\r\n\t}\r\n\r\n\tdelete(){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar index;\r\n\r\n\t\t\tif(this.isGroup){\r\n\t\t\t\tthis.columns.forEach(function(column){\r\n\t\t\t\t\tcolumn.delete();\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\t//cancel edit if column is currently being edited\r\n\t\t\tif(this.table.modExists(\"edit\")){\r\n\t\t\t\tif(this.table.modules.edit.currentCell.column === this){\r\n\t\t\t\t\tthis.table.modules.edit.cancelEdit();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tvar cellCount = this.cells.length;\r\n\r\n\t\t\tfor(let i = 0; i < cellCount; i++){\r\n\t\t\t\tthis.cells[0].delete();\r\n\t\t\t}\r\n\r\n\t\t\tif(this.element.parentNode){\r\n\t\t\t\tthis.element.parentNode.removeChild(this.element);\r\n\t\t\t}\r\n\r\n\t\t\tthis.element = false;\r\n\t\t\tthis.contentElement = false;\r\n\t\t\tthis.titleElement = false;\r\n\t\t\tthis.groupElement = false;\r\n\r\n\t\t\tif(this.parent.isGroup){\r\n\t\t\t\tthis.parent.removeChild(this);\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.columnManager.deregisterColumn(this);\r\n\r\n\t\t\tif(this.table.options.virtualDomHoz){\r\n\t\t\t\tthis.table.vdomHoz.reinitialize(true);\r\n\t\t\t}\r\n\r\n\t\t\tresolve();\r\n\t\t});\r\n\t}\r\n\r\n\tcolumnRendered(){\r\n\t\tif(this.titleFormatterRendered){\r\n\t\t\tthis.titleFormatterRendered();\r\n\t\t}\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\tvar invalid = [];\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tif(!cell.validate()){\r\n\t\t\t\tinvalid.push(cell.getComponent());\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn invalid.length ? invalid : true;\r\n\t}\r\n\r\n\t//////////////// Cell Management /////////////////\r\n\t//generate cell for this column\r\n\tgenerateCell(row){\r\n\t\tvar cell = new Cell(this, row);\r\n\r\n\t\tthis.cells.push(cell);\r\n\r\n\t\treturn cell;\r\n\t}\r\n\r\n\tnextColumn(){\r\n\t\tvar index = this.table.columnManager.findColumnIndex(this);\r\n\t\treturn index > -1 ? this._nextVisibleColumn(index + 1) : false;\r\n\t}\r\n\r\n\t_nextVisibleColumn(index){\r\n\t\tvar column = this.table.columnManager.getColumnByIndex(index);\r\n\t\treturn !column || column.visible ? column : this._nextVisibleColumn(index + 1);\r\n\t}\r\n\r\n\tprevColumn(){\r\n\t\tvar index = this.table.columnManager.findColumnIndex(this);\r\n\t\treturn index > -1 ? this._prevVisibleColumn(index - 1) : false;\r\n\t}\r\n\r\n\t_prevVisibleColumn(index){\r\n\t\tvar column = this.table.columnManager.getColumnByIndex(index);\r\n\t\treturn !column || column.visible ? column : this._prevVisibleColumn(index - 1);\r\n\t}\r\n\r\n\treinitializeWidth(force){\r\n\t\tthis.widthFixed = false;\r\n\r\n\t\t//set width if present\r\n\t\tif(typeof this.definition.width !== \"undefined\" && !force){\r\n\t\t\tthis.setWidth(this.definition.width);\r\n\t\t}\r\n\r\n\t\t//hide header filters to prevent them altering column width\r\n\t\tif(this.table.modExists(\"filter\")){\r\n\t\t\tthis.table.modules.filter.hideHeaderFilterElements();\r\n\t\t}\r\n\r\n\t\tthis.fitToData();\r\n\r\n\t\t//show header filters again after layout is complete\r\n\t\tif(this.table.modExists(\"filter\")){\r\n\t\t\tthis.table.modules.filter.showHeaderFilterElements();\r\n\t\t}\r\n\t}\r\n\r\n\t//set column width to maximum cell width\r\n\tfitToData(){\r\n\t\tif(!this.widthFixed){\r\n\t\t\tthis.element.style.width = \"\";\r\n\r\n\t\t\tthis.cells.forEach((cell) => {\r\n\t\t\t\tcell.clearWidth();\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tvar maxWidth = this.element.offsetWidth;\r\n\r\n\t\tif(!this.width || !this.widthFixed){\r\n\t\t\tthis.cells.forEach((cell) => {\r\n\t\t\t\tvar width = cell.getWidth();\r\n\r\n\t\t\t\tif(width > maxWidth){\r\n\t\t\t\t\tmaxWidth = width;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif(maxWidth){\r\n\t\t\t\tthis.setWidthActual(maxWidth + 1);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tupdateDefinition(updates){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar definition;\r\n\r\n\t\t\tif(!this.isGroup){\r\n\t\t\t\tif(!this.parent.isGroup){\r\n\t\t\t\t\tdefinition = Object.assign({}, this.getDefinition());\r\n\t\t\t\t\tdefinition = Object.assign(definition, updates);\r\n\r\n\t\t\t\t\tthis.table.columnManager.addColumn(definition, false, this)\r\n\t\t\t\t\t.then((column) => {\r\n\r\n\t\t\t\t\t\tif(definition.field == this.field){\r\n\t\t\t\t\t\t\tthis.field = false; //cleair field name to prevent deletion of duplicate column from arrays\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tthis.delete()\r\n\t\t\t\t\t\t.then(() => {\r\n\t\t\t\t\t\t\tresolve(column.getComponent());\r\n\t\t\t\t\t\t}).catch((err) => {\r\n\t\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t}).catch((err) => {\r\n\t\t\t\t\t\treject(err);\r\n\t\t\t\t\t});\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Column Update Error - The updateDefinition function is only available on ungrouped columns\");\r\n\t\t\t\t\treject(\"Column Update Error - The updateDefinition function is only available on columns, not column groups\");\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Update Error - The updateDefinition function is only available on ungrouped columns\");\r\n\t\t\t\treject(\"Column Update Error - The updateDefinition function is only available on columns, not column groups\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tdeleteCell(cell){\r\n\t\tvar index = this.cells.indexOf(cell);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tthis.cells.splice(index, 1);\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////// Object Generation /////////////////\r\n\tgetComponent(){\r\n\t\tif(!this.component){\r\n\t\t\tthis.component = new ColumnComponent(this);\r\n\t\t}\r\n\r\n\t\treturn this.component;\r\n\t}\r\n}\r\n\r\nColumn.defaultOptionList = defaultOptions;\r\n\r\nexport default Column;","export default class Helpers{\r\n\r\n\tstatic elVisible(el){\r\n\t\treturn !(el.offsetWidth <= 0 && el.offsetHeight <= 0);\r\n\t}\r\n\r\n\tstatic elOffset(el){\r\n\t\tvar box = el.getBoundingClientRect();\r\n\r\n\t\treturn {\r\n\t\t\ttop: box.top + window.pageYOffset - document.documentElement.clientTop,\r\n\t\t\tleft: box.left + window.pageXOffset - document.documentElement.clientLeft\r\n\t\t};\r\n\t}\r\n\r\n\tstatic deepClone(obj){\r\n\t\tvar clone = Object.assign(Array.isArray(obj) ? [] : {}, obj);\r\n\r\n\t\tfor(var i in obj) {\r\n\t\t\tif(obj[i] != null && typeof(obj[i]) === \"object\"){\r\n\t\t\t\tif (obj[i] instanceof Date) {\r\n\t\t\t\t\tclone[i] = new Date(obj[i]);\r\n\t\t\t\t} else {\r\n\t\t\t\t\tclone[i] = this.deepClone(obj[i]);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn clone;\r\n\t}\r\n}","import Column from './column/Column.js';\r\nimport Helpers from './Helpers.js';\r\n\r\nexport default class ColumnManager {\r\n\r\n\tconstructor (table){\r\n\t\tthis.table = table; //hold parent table\r\n\t\tthis.blockHozScrollEvent = false;\r\n\t\tthis.headersElement = this.createHeadersElement();\r\n\t\tthis.element = this.createHeaderElement(); //containing element\r\n\t\tthis.rowManager = null; //hold row manager object\r\n\t\tthis.columns = []; // column definition object\r\n\t\tthis.columnsByIndex = []; //columns by index\r\n\t\tthis.columnsByField = {}; //columns by field\r\n\t\tthis.scrollLeft = 0;\r\n\r\n\t\tthis.element.insertBefore(this.headersElement, this.element.firstChild);\r\n\t}\r\n\r\n\t////////////// Setup Functions /////////////////\r\n\r\n\tcreateHeadersElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-headers\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\tcreateHeaderElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-header\");\r\n\r\n\t\tif(!this.table.options.headerVisible){\r\n\t\t\tel.classList.add(\"tabulator-header-hidden\");\r\n\t\t}\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\tinitialize (){\r\n\t\t//scroll body along with header\r\n\t\t// this.element.addEventListener(\"scroll\", (e) => {\r\n\t\t// \tif(!this.blockHozScrollEvent){\r\n\t\t// \t\tthis.table.rowManager.scrollHorizontal(this.element.scrollLeft);\r\n\t\t// \t}\r\n\t\t// });\r\n\t}\r\n\r\n\t//link to row manager\r\n\tsetRowManager(manager){\r\n\t\tthis.rowManager = manager;\r\n\t}\r\n\r\n\t//return containing element\r\n\tgetElement(){\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\t//return header containing element\r\n\tgetHeadersElement(){\r\n\t\treturn this.headersElement;\r\n\t}\r\n\r\n\t//scroll horizontally to match table body\r\n\tscrollHorizontal(left){\r\n\t\tvar hozAdjust = 0,\r\n\t\tscrollWidth = this.element.scrollWidth - this.table.element.clientWidth;\r\n\r\n\t\t// this.tempScrollBlock();\r\n\t\tthis.element.scrollLeft = left;\r\n\r\n\t\t//adjust for vertical scrollbar moving table when present\r\n\t\tif(left > scrollWidth){\r\n\t\t\thozAdjust = left - scrollWidth;\r\n\t\t\tthis.element.style.marginLeft = (-(hozAdjust)) + \"px\";\r\n\t\t}else{\r\n\t\t\tthis.element.style.marginLeft = 0;\r\n\t\t}\r\n\r\n\t\t//keep frozen columns fixed in position\r\n\t\t//this._calcFrozenColumnsPos(hozAdjust + 3);\r\n\r\n\t\tthis.scrollLeft = left;\r\n\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.scrollHorizontal();\r\n\t\t}\r\n\t}\r\n\r\n\t///////////// Column Setup Functions /////////////\r\n\tgenerateColumnsFromRowData(data){\r\n\t\tvar cols = [],\r\n\t\tdefinitions = this.table.options.autoColumnsDefinitions,\r\n\t\trow, sorter;\r\n\r\n\t\tif(data && data.length){\r\n\r\n\t\t\trow = data[0];\r\n\r\n\t\t\tfor(var key in row){\r\n\t\t\t\tlet col = {\r\n\t\t\t\t\tfield:key,\r\n\t\t\t\t\ttitle:key,\r\n\t\t\t\t};\r\n\r\n\t\t\t\tlet value = row[key];\r\n\r\n\t\t\t\tswitch(typeof value){\r\n\t\t\t\t\tcase \"undefined\":\r\n\t\t\t\t\tsorter = \"string\";\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"boolean\":\r\n\t\t\t\t\tsorter = \"boolean\";\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"object\":\r\n\t\t\t\t\tif(Array.isArray(value)){\r\n\t\t\t\t\t\tsorter = \"array\";\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tsorter = \"string\";\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\tif(!isNaN(value) && value !== \"\"){\r\n\t\t\t\t\t\tsorter = \"number\";\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tif(value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)){\r\n\t\t\t\t\t\t\tsorter = \"alphanum\";\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tsorter = \"string\";\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcol.sorter = sorter;\r\n\r\n\t\t\t\tcols.push(col);\r\n\t\t\t}\r\n\r\n\t\t\tif(definitions){\r\n\r\n\t\t\t\tswitch(typeof definitions){\r\n\t\t\t\t\tcase \"function\":\r\n\t\t\t\t\t\tthis.table.options.columns = definitions.call(this.table, cols);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"object\":\r\n\t\t\t\t\t\tif(Array.isArray(definitions)){\r\n\t\t\t\t\t\t\tcols.forEach((col) => {\r\n\t\t\t\t\t\t\t\tvar match = definitions.find((def) => {\r\n\t\t\t\t\t\t\t\t\treturn def.field === col.field;\r\n\t\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t\t\tif(match){\r\n\t\t\t\t\t\t\t\t\tObject.assign(col, match);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tcols.forEach((col) => {\r\n\t\t\t\t\t\t\t\tif(definitions[col.field]){\r\n\t\t\t\t\t\t\t\t\tObject.assign(col, definitions[col.field]);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tthis.table.options.columns = cols;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tthis.table.options.columns = cols;\r\n\t\t\t}\r\n\r\n\t\t\tthis.setColumns(this.table.options.columns);\r\n\t\t}\r\n\t}\r\n\r\n\tsetColumns(cols, row){\r\n\t\twhile(this.headersElement.firstChild) this.headersElement.removeChild(this.headersElement.firstChild);\r\n\r\n\t\tthis.columns = [];\r\n\t\tthis.columnsByIndex = [];\r\n\t\tthis.columnsByField = {};\r\n\r\n\t\t//reset frozen columns\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.reset();\r\n\t\t}\r\n\r\n\t\tcols.forEach((def, i) => {\r\n\t\t\tthis._addColumn(def);\r\n\t\t});\r\n\r\n\t\tthis._reIndexColumns();\r\n\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tthis.table.modules.responsiveLayout.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.table.options.virtualDomHoz){\r\n\t\t\tthis.table.vdomHoz.reinitialize(false, true);\r\n\t\t}\r\n\r\n\t\tthis.redraw(true);\r\n\t}\r\n\r\n\t_addColumn(definition, before, nextToColumn){\r\n\t\tvar column = new Column(definition, this),\r\n\t\tcolEl = column.getElement(),\r\n\t\tindex = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;\r\n\r\n\t\tif(nextToColumn && index > -1){\r\n\r\n\t\t\tvar parentIndex = this.columns.indexOf(nextToColumn.getTopColumn());\r\n\t\t\tvar nextEl = nextToColumn.getElement();\r\n\r\n\t\t\tif(before){\r\n\t\t\t\tthis.columns.splice(parentIndex, 0, column);\r\n\t\t\t\tnextEl.parentNode.insertBefore(colEl, nextEl);\r\n\t\t\t}else{\r\n\t\t\t\tthis.columns.splice(parentIndex + 1, 0, column);\r\n\t\t\t\tnextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);\r\n\t\t\t}\r\n\r\n\t\t}else{\r\n\t\t\tif(before){\r\n\t\t\t\tthis.columns.unshift(column);\r\n\t\t\t\tthis.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild);\r\n\t\t\t}else{\r\n\t\t\t\tthis.columns.push(column);\r\n\t\t\t\tthis.headersElement.appendChild(column.getElement());\r\n\t\t\t}\r\n\r\n\t\t\tcolumn.columnRendered();\r\n\t\t}\r\n\r\n\t\treturn column;\r\n\t}\r\n\r\n\tregisterColumnField(col){\r\n\t\tif(col.definition.field){\r\n\t\t\tthis.columnsByField[col.definition.field] = col;\r\n\t\t}\r\n\t}\r\n\r\n\tregisterColumnPosition(col){\r\n\t\tthis.columnsByIndex.push(col);\r\n\t}\r\n\r\n\t_reIndexColumns(){\r\n\t\tthis.columnsByIndex = [];\r\n\r\n\t\tthis.columns.forEach(function(column){\r\n\t\t\tcolumn.reRegisterPosition();\r\n\t\t});\r\n\t}\r\n\r\n\t//ensure column headers take up the correct amount of space in column groups\r\n\t_verticalAlignHeaders(){\r\n\t\tvar minHeight = 0;\r\n\r\n\t\tthis.columns.forEach((column) => {\r\n\t\t\tvar height;\r\n\r\n\t\t\tcolumn.clearVerticalAlign();\r\n\r\n\t\t\theight = column.getHeight();\r\n\r\n\t\t\tif(height > minHeight){\r\n\t\t\t\tminHeight = height;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tthis.columns.forEach((column) => {\r\n\t\t\tcolumn.verticalAlign(this.table.options.columnHeaderVertAlign, minHeight);\r\n\t\t});\r\n\r\n\t\tthis.rowManager.adjustTableSize();\r\n\t}\r\n\r\n\t//////////////// Column Details /////////////////\r\n\tfindColumn(subject){\r\n\t\tif(typeof subject == \"object\"){\r\n\r\n\t\t\tif(subject instanceof Column){\r\n\t\t\t\t//subject is column element\r\n\t\t\t\treturn subject;\r\n\t\t\t}else if(subject instanceof ColumnComponent){\r\n\t\t\t\t//subject is public column component\r\n\t\t\t\treturn subject._getSelf() || false;\r\n\t\t\t}else if(typeof HTMLElement !== \"undefined\" && subject instanceof HTMLElement){\r\n\t\t\t\t//subject is a HTML element of the column header\r\n\t\t\t\tlet match = this.columns.find((column) => {\r\n\t\t\t\t\treturn column.element === subject;\r\n\t\t\t\t});\r\n\r\n\t\t\t\treturn match || false;\r\n\t\t\t}\r\n\r\n\t\t}else{\r\n\t\t\t//subject should be treated as the field name of the column\r\n\t\t\treturn this.columnsByField[subject] || false;\r\n\t\t}\r\n\r\n\t\t//catch all for any other type of input\r\n\t\treturn false;\r\n\t}\r\n\r\n\tgetColumnByField(field){\r\n\t\treturn this.columnsByField[field];\r\n\t}\r\n\r\n\tgetColumnsByFieldRoot(root){\r\n\t\tvar matches = [];\r\n\r\n\t\tObject.keys(this.columnsByField).forEach((field) => {\r\n\t\t\tvar fieldRoot = field.split(\".\")[0];\r\n\t\t\tif(fieldRoot === root){\r\n\t\t\t\tmatches.push(this.columnsByField[field]);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn matches;\r\n\t}\r\n\r\n\tgetColumnByIndex(index){\r\n\t\treturn this.columnsByIndex[index];\r\n\t}\r\n\r\n\tgetFirstVisibileColumn(index){\r\n\t\tvar index = this.columnsByIndex.findIndex((col) => {\r\n\t\t\treturn col.visible;\r\n\t\t});\r\n\r\n\t\treturn index > -1 ? this.columnsByIndex[index] : false;\r\n\t}\r\n\r\n\tgetColumns(){\r\n\t\treturn this.columns;\r\n\t}\r\n\r\n\tfindColumnIndex(column){\r\n\t\treturn this.columnsByIndex.findIndex((col) => {\r\n\t\t\treturn column === col;\r\n\t\t});\r\n\t}\r\n\r\n\t//return all columns that are not groups\r\n\tgetRealColumns(){\r\n\t\treturn this.columnsByIndex;\r\n\t}\r\n\r\n\t//travers across columns and call action\r\n\ttraverse(callback){\r\n\t\tthis.columnsByIndex.forEach((column,i) =>{\r\n\t\t\tcallback(column, i);\r\n\t\t});\r\n\t}\r\n\r\n\t//get defintions of actual columns\r\n\tgetDefinitions(active){\r\n\t\tvar output = [];\r\n\r\n\t\tthis.columnsByIndex.forEach((column) => {\r\n\t\t\tif(!active || (active && column.visible)){\r\n\t\t\t\toutput.push(column.getDefinition());\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\t//get full nested definition tree\r\n\tgetDefinitionTree(){\r\n\t\tvar output = [];\r\n\r\n\t\tthis.columns.forEach((column) => {\r\n\t\t\toutput.push(column.getDefinition(true));\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetComponents(structured){\r\n\t\tvar output = [],\r\n\t\tcolumns = structured ? this.columns : this.columnsByIndex;\r\n\r\n\t\tcolumns.forEach((column) => {\r\n\t\t\toutput.push(column.getComponent());\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetWidth(){\r\n\t\tvar width = 0;\r\n\r\n\t\tthis.columnsByIndex.forEach((column) => {\r\n\t\t\tif(column.visible){\r\n\t\t\t\twidth += column.getWidth();\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn width;\r\n\t}\r\n\r\n\tmoveColumn(from, to, after){\r\n\t\tthis.moveColumnActual(from, to, after);\r\n\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tthis.table.modules.responsiveLayout.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t}\r\n\r\n\t\tto.element.parentNode.insertBefore(from.element, to.element);\r\n\r\n\t\tif(after){\r\n\t\t\tto.element.parentNode.insertBefore(to.element, from.element);\r\n\t\t}\r\n\r\n\t\tthis._verticalAlignHeaders();\r\n\r\n\t\tthis.table.rowManager.reinitialize();\r\n\t}\r\n\r\n\tmoveColumnActual(from, to, after){\r\n\r\n\t\tif(from.parent.isGroup){\r\n\t\t\tthis._moveColumnInArray(from.parent.columns, from, to, after);\r\n\t\t}else{\r\n\t\t\tthis._moveColumnInArray(this.columns, from, to, after);\r\n\t\t}\r\n\r\n\t\tthis._moveColumnInArray(this.columnsByIndex, from, to, after, true);\r\n\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tthis.table.modules.responsiveLayout.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.table.options.virtualDomHoz){\r\n\t\t\tthis.table.vdomHoz.reinitialize(true);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.columnMoved){\r\n\t\t\tthis.table.options.columnMoved.call(this.table, from.getComponent(), this.table.columnManager.getComponents());\r\n\t\t}\r\n\r\n\t\tif(this.table.options.persistence && this.table.modExists(\"persistence\", true) && this.table.modules.persistence.config.columns){\r\n\t\t\tthis.table.modules.persistence.save(\"columns\");\r\n\t\t}\r\n\t}\r\n\r\n\t_moveColumnInArray(columns, from, to, after, updateRows){\r\n\t\tvar\tfromIndex = columns.indexOf(from),\r\n\t\ttoIndex, rows = [];\r\n\r\n\t\tif (fromIndex > -1) {\r\n\r\n\t\t\tcolumns.splice(fromIndex, 1);\r\n\r\n\t\t\ttoIndex = columns.indexOf(to);\r\n\r\n\t\t\tif (toIndex > -1) {\r\n\r\n\t\t\t\tif(after){\r\n\t\t\t\t\ttoIndex = toIndex+1;\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\ttoIndex = fromIndex;\r\n\t\t\t}\r\n\r\n\t\t\tcolumns.splice(toIndex, 0, from);\r\n\r\n\t\t\tif(updateRows){\r\n\r\n\t\t\t\tif(this.table.options.dataTree && this.table.modExists(\"dataTree\", true)){\r\n\t\t\t\t\tthis.table.rowManager.rows.forEach((row) => {\r\n\t\t\t\t\t\trows = rows.concat(this.table.modules.dataTree.getTreeChildren(row, false, true));\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\r\n\t\t\t\trows = rows.concat(this.table.rowManager.rows);\r\n\r\n\t\t\t\trows.forEach(function(row){\r\n\t\t\t\t\tif(row.cells.length){\r\n\t\t\t\t\t\tvar cell = row.cells.splice(fromIndex, 1)[0];\r\n\t\t\t\t\t\trow.cells.splice(toIndex, 0, cell);\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tscrollToColumn(column, position, ifVisible){\r\n\t\tvar left = 0,\r\n\t\toffset = 0,\r\n\t\tadjust = 0,\r\n\t\tcolEl = column.getElement();\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\r\n\t\t\tif(typeof position === \"undefined\"){\r\n\t\t\t\tposition = this.table.options.scrollToColumnPosition;\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof ifVisible === \"undefined\"){\r\n\t\t\t\tifVisible = this.table.options.scrollToColumnIfVisible;\r\n\t\t\t}\r\n\r\n\t\t\tif(column.visible){\r\n\r\n\t\t\t\t//align to correct position\r\n\t\t\t\tswitch(position){\r\n\t\t\t\t\tcase \"middle\":\r\n\t\t\t\t\tcase \"center\":\r\n\t\t\t\t\tadjust = -this.element.clientWidth / 2;\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"right\":\r\n\t\t\t\t\tadjust = colEl.clientWidth - this.headersElement.clientWidth;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//check column visibility\r\n\t\t\t\tif(!ifVisible){\r\n\r\n\t\t\t\t\toffset = colEl.offsetLeft;\r\n\r\n\t\t\t\t\tif(offset > 0 && offset + colEl.offsetWidth < this.element.clientWidth){\r\n\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//calculate scroll position\r\n\t\t\t\tleft = colEl.offsetLeft + adjust;\r\n\r\n\t\t\t\tleft = Math.max(Math.min(left, this.table.rowManager.element.scrollWidth - this.table.rowManager.element.clientWidth),0);\r\n\r\n\t\t\t\tthis.table.rowManager.scrollHorizontal(left);\r\n\t\t\t\tthis.scrollHorizontal(left);\r\n\r\n\t\t\t\tresolve();\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Scroll Error - Column not visible\");\r\n\t\t\t\treject(\"Scroll Error - Column not visible\");\r\n\t\t\t}\r\n\r\n\t\t});\r\n\t}\r\n\r\n\t//////////////// Cell Management /////////////////\r\n\tgenerateCells(row){\r\n\t\tvar cells = [];\r\n\r\n\t\tthis.columnsByIndex.forEach((column) => {\r\n\t\t\tcells.push(column.generateCell(row));\r\n\t\t});\r\n\r\n\t\treturn cells;\r\n\t}\r\n\r\n\t//////////////// Column Management /////////////////\r\n\tgetFlexBaseWidth(){\r\n\t\tvar totalWidth = this.table.element.clientWidth, //table element width\r\n\t\tfixedWidth = 0;\r\n\r\n\t\t//adjust for vertical scrollbar if present\r\n\t\tif(this.rowManager.element.scrollHeight > this.rowManager.element.clientHeight){\r\n\t\t\ttotalWidth -= this.rowManager.element.offsetWidth - this.rowManager.element.clientWidth;\r\n\t\t}\r\n\r\n\t\tthis.columnsByIndex.forEach(function(column){\r\n\t\t\tvar width, minWidth, colWidth;\r\n\r\n\t\t\tif(column.visible){\r\n\r\n\t\t\t\twidth = column.definition.width || 0;\r\n\r\n\t\t\t\tminWidth = typeof column.minWidth == \"undefined\" ? this.table.options.columnMinWidth : parseInt(column.minWidth);\r\n\r\n\t\t\t\tif(typeof(width) == \"string\"){\r\n\t\t\t\t\tif(width.indexOf(\"%\") > -1){\r\n\t\t\t\t\t\tcolWidth = (totalWidth / 100) * parseInt(width) ;\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tcolWidth = parseInt(width);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tcolWidth = width;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tfixedWidth += colWidth > minWidth ? colWidth : minWidth;\r\n\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn fixedWidth;\r\n\t}\r\n\r\n\taddColumn(definition, before, nextToColumn){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar column = this._addColumn(definition, before, nextToColumn);\r\n\r\n\t\t\tthis._reIndexColumns();\r\n\r\n\t\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\tthis.table.modules.responsiveLayout.initialize();\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t\t}\r\n\r\n\t\t\tthis.redraw(true);\r\n\r\n\t\t\tif(this.table.modules.layout.getMode() != \"fitColumns\"){\r\n\t\t\t\tcolumn.reinitializeWidth();\r\n\t\t\t}\r\n\r\n\t\t\tthis._verticalAlignHeaders();\r\n\r\n\t\t\tthis.table.rowManager.reinitialize();\r\n\r\n\t\t\tif(this.table.options.virtualDomHoz){\r\n\t\t\t\tthis.table.vdomHoz.reinitialize();\r\n\t\t\t}\r\n\r\n\t\t\tresolve(column);\r\n\t\t});\r\n\t}\r\n\r\n\t//remove column from system\r\n\tderegisterColumn(column){\r\n\t\tvar field = column.getField(),\r\n\t\tindex;\r\n\r\n\t\t//remove from field list\r\n\t\tif(field){\r\n\t\t\tdelete this.columnsByField[field];\r\n\t\t}\r\n\r\n\t\t//remove from index list\r\n\t\tindex = this.columnsByIndex.indexOf(column);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tthis.columnsByIndex.splice(index, 1);\r\n\t\t}\r\n\r\n\t\t//remove from column list\r\n\t\tindex = this.columns.indexOf(column);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tthis.columns.splice(index, 1);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tthis.table.modules.responsiveLayout.initialize();\r\n\t\t}\r\n\r\n\t\tthis._verticalAlignHeaders();\r\n\r\n\t\tthis.redraw();\r\n\t}\r\n\r\n\t//redraw columns\r\n\tredraw(force){\r\n\t\tif(force){\r\n\t\t\tif(Helpers.elVisible(this.element)){\r\n\t\t\t\tthis._verticalAlignHeaders();\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.rowManager.resetScroll();\r\n\t\t\tthis.table.rowManager.reinitialize();\r\n\t\t}\r\n\r\n\t\tif([\"fitColumns\", \"fitDataStretch\"].indexOf(this.table.modules.layout.getMode()) > -1){\r\n\t\t\tthis.table.modules.layout.layout();\r\n\t\t}else{\r\n\t\t\tif(force){\r\n\t\t\t\tthis.table.modules.layout.layout();\r\n\t\t\t}else{\r\n\t\t\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\t\tthis.table.modules.responsiveLayout.update();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.layout();\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t}\r\n\r\n\t\tif(force){\r\n\t\t\tif(this.table.options.persistence && this.table.modExists(\"persistence\", true) && this.table.modules.persistence.config.columns){\r\n\t\t\t\tthis.table.modules.persistence.save(\"columns\");\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\t\tthis.table.modules.columnCalcs.redraw();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.table.footerManager.redraw();\r\n\t}\r\n}","//public row object\r\nexport default class RowComponent {\r\n\r\n\tconstructor (row){\r\n\t\tthis._row = row;\r\n\t}\r\n\r\n\tgetData(transform){\r\n\t\treturn this._row.getData(transform);\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\treturn this._row.getElement();\r\n\t}\r\n\r\n\tgetCells(){\r\n\t\tvar cells = [];\r\n\r\n\t\tthis._row.getCells().forEach(function(cell){\r\n\t\t\tcells.push(cell.getComponent());\r\n\t\t});\r\n\r\n\t\treturn cells;\r\n\t}\r\n\r\n\tgetCell(column){\r\n\t\tvar cell = this._row.getCell(column);\r\n\t\treturn cell ? cell.getComponent() : false;\r\n\t}\r\n\r\n\tgetIndex(){\r\n\t\treturn this._row.getData(\"data\")[this._row.table.options.index];\r\n\t}\r\n\r\n\tgetPosition(active){\r\n\t\treturn this._row.table.rowManager.getRowPosition(this._row, active);\r\n\t}\r\n\r\n\tdelete(){\r\n\t\treturn this._row.delete();\r\n\t}\r\n\r\n\tscrollTo(){\r\n\t\treturn this._row.table.rowManager.scrollToRow(this._row);\r\n\t}\r\n\r\n\tpageTo(){\r\n\t\tif(this._row.table.modExists(\"page\", true)){\r\n\t\t\treturn this._row.table.modules.page.setPageToRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\tmove(to, after){\r\n\t\tthis._row.moveToRow(to, after);\r\n\t}\r\n\r\n\tupdate(data){\r\n\t\treturn this._row.updateData(data);\r\n\t}\r\n\r\n\tnormalizeHeight(){\r\n\t\tthis._row.normalizeHeight(true);\r\n\t}\r\n\r\n\tselect(){\r\n\t\tthis._row.table.modules.selectRow.selectRows(this._row);\r\n\t}\r\n\r\n\tdeselect(){\r\n\t\tthis._row.table.modules.selectRow.deselectRows(this._row);\r\n\t}\r\n\r\n\ttoggleSelect(){\r\n\t\tthis._row.table.modules.selectRow.toggleRow(this._row);\r\n\t}\r\n\r\n\tisSelected(){\r\n\t\treturn this._row.table.modules.selectRow.isRowSelected(this._row);\r\n\t}\r\n\r\n\t_getSelf(){\r\n\t\treturn this._row;\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\treturn this._row.validate();\r\n\t}\r\n\r\n\tfreeze(){\r\n\t\tif(this._row.table.modExists(\"frozenRows\", true)){\r\n\t\t\tthis._row.table.modules.frozenRows.freezeRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\tunfreeze(){\r\n\t\tif(this._row.table.modExists(\"frozenRows\", true)){\r\n\t\t\tthis._row.table.modules.frozenRows.unfreezeRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\tisFrozen(){\r\n\t\tif(this._row.table.modExists(\"frozenRows\", true)){\r\n\t\t\tvar index = this._row.table.modules.frozenRows.rows.indexOf(this._row);\r\n\t\t\treturn index > -1;\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\ttreeCollapse(){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\tthis._row.table.modules.dataTree.collapseRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\ttreeExpand(){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\tthis._row.table.modules.dataTree.expandRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\ttreeToggle(){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\tthis._row.table.modules.dataTree.toggleRow(this._row);\r\n\t\t}\r\n\t}\r\n\r\n\tgetTreeParent(){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\treturn this._row.table.modules.dataTree.getTreeParent(this._row);\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tgetTreeChildren(){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\treturn this._row.table.modules.dataTree.getTreeChildren(this._row, true);\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\taddTreeChild(data, pos, index){\r\n\t\tif(this._row.table.modExists(\"dataTree\", true)){\r\n\t\t\treturn this._row.table.modules.dataTree.addTreeChildRow(this._row, data, pos, index);\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\treformat(){\r\n\t\treturn this._row.reinitialize();\r\n\t}\r\n\r\n\tgetGroup(){\r\n\t\treturn this._row.getGroup().getComponent();\r\n\t}\r\n\r\n\tgetTable(){\r\n\t\treturn this._row.table;\r\n\t}\r\n\r\n\tgetNextRow(){\r\n\t\tvar row = this._row.nextRow();\r\n\t\treturn row ? row.getComponent() : row;\r\n\t}\r\n\r\n\tgetPrevRow(){\r\n\t\tvar row = this._row.prevRow();\r\n\t\treturn row ? row.getComponent() : row;\r\n\t}\r\n}","import RowComponent from './RowComponent.js';\r\nimport Helpers from '../Helpers.js';\r\n\r\nexport default class Row {\r\n\tconstructor (data, parent, type = \"row\"){\r\n\t\tthis.table = parent.table;\r\n\t\tthis.parent = parent;\r\n\t\tthis.data = {};\r\n\t\tthis.type = type; //type of element\r\n\t\tthis.element = false;\r\n\t\tthis.modules = {}; //hold module variables;\r\n\t\tthis.cells = [];\r\n\t\tthis.height = 0; //hold element height\r\n\t\tthis.heightStyled = \"\"; //hold element height prestyled to improve render efficiency\r\n\t\tthis.manualHeight = false; //user has manually set row height\r\n\t\tthis.outerHeight = 0; //holde lements outer height\r\n\t\tthis.initialized = false; //element has been rendered\r\n\t\tthis.heightInitialized = false; //element has resized cells to fit\r\n\r\n\t\tthis.component = null;\r\n\r\n\t\tthis.created = false;\r\n\r\n\t\tthis.setData(data);\r\n\t}\r\n\r\n\tcreate(){\r\n\t\tif(!this.created){\r\n\t\t\tthis.created = true;\r\n\t\t\tthis.generateElement();\r\n\t\t}\r\n\t}\r\n\r\n\tcreateElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-row\");\r\n\t\tel.setAttribute(\"role\", \"row\");\r\n\r\n\t\tthis.element = el;\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\tthis.create();\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\tdetachElement(){\r\n\t\tif (this.element && this.element.parentNode){\r\n\t\t\tthis.element.parentNode.removeChild(this.element);\r\n\t\t}\r\n\t}\r\n\r\n\tgenerateElement(){\r\n\t\tvar dblTap,\ttapHold, tap;\r\n\r\n\t\tthis.createElement();\r\n\r\n\t\t//set row selection characteristics\r\n\t\tif(this.table.options.selectable !== false && this.table.modExists(\"selectRow\")){\r\n\t\t\tthis.table.modules.selectRow.initializeRow(this);\r\n\t\t}\r\n\r\n\t\t//setup movable rows\r\n\t\tif(this.table.options.movableRows !== false && this.table.modExists(\"moveRow\")){\r\n\t\t\tthis.table.modules.moveRow.initializeRow(this);\r\n\t\t}\r\n\r\n\t\t//setup data tree\r\n\t\tif(this.table.options.dataTree !== false && this.table.modExists(\"dataTree\")){\r\n\t\t\tthis.table.modules.dataTree.initializeRow(this);\r\n\t\t}\r\n\r\n\t\t//setup column colapse container\r\n\t\tif(this.table.options.responsiveLayout === \"collapse\" && this.table.modExists(\"responsiveLayout\")){\r\n\t\t\tthis.table.modules.responsiveLayout.initializeRow(this);\r\n\t\t}\r\n\r\n\t\t//set column menu\r\n\t\tif((this.table.options.rowContextMenu || this.table.options.rowClickMenu) && this.table.modExists(\"menu\")){\r\n\t\t\tthis.table.modules.menu.initializeRow(this);\r\n\t\t}\r\n\r\n\t\t//handle row click events\r\n\t\tif (this.table.options.rowClick){\r\n\t\t\tthis.element.addEventListener(\"click\", (e) => {\r\n\t\t\t\tthis.table.options.rowClick(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowDblClick){\r\n\t\t\tthis.element.addEventListener(\"dblclick\", (e) => {\r\n\t\t\t\tthis.table.options.rowDblClick(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowContext){\r\n\t\t\tthis.element.addEventListener(\"contextmenu\", (e) => {\r\n\t\t\t\tthis.table.options.rowContext(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\t//handle mouse events\r\n\t\tif (this.table.options.rowMouseEnter){\r\n\t\t\tthis.element.addEventListener(\"mouseenter\", (e) => {\r\n\t\t\t\tthis.table.options.rowMouseEnter(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowMouseLeave){\r\n\t\t\tthis.element.addEventListener(\"mouseleave\", (e) => {\r\n\t\t\t\tthis.table.options.rowMouseLeave(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowMouseOver){\r\n\t\t\tthis.element.addEventListener(\"mouseover\", (e) => {\r\n\t\t\t\tthis.table.options.rowMouseOver(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowMouseOut){\r\n\t\t\tthis.element.addEventListener(\"mouseout\", (e) => {\r\n\t\t\t\tthis.table.options.rowMouseOut(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowMouseMove){\r\n\t\t\tthis.element.addEventListener(\"mousemove\", (e) => {\r\n\t\t\t\tthis.table.options.rowMouseMove(e, this.getComponent());\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowTap){\r\n\r\n\t\t\ttap = false;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\ttap = true;\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tif(tap){\r\n\t\t\t\t\tthis.table.options.rowTap(e, this.getComponent());\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttap = false;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowDblTap){\r\n\r\n\t\t\tdblTap = null;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tif(dblTap){\r\n\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\tdblTap = null;\r\n\r\n\t\t\t\t\tthis.table.options.rowDblTap(e, this.getComponent());\r\n\t\t\t\t}else{\r\n\r\n\t\t\t\t\tdblTap = setTimeout(() => {\r\n\t\t\t\t\t\tclearTimeout(dblTap);\r\n\t\t\t\t\t\tdblTap = null;\r\n\t\t\t\t\t}, 300);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif (this.table.options.rowTapHold){\r\n\r\n\t\t\ttapHold = null;\r\n\r\n\t\t\tthis.element.addEventListener(\"touchstart\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\r\n\t\t\t\ttapHold = setTimeout(() => {\r\n\t\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\t\ttapHold = null;\r\n\t\t\t\t\ttap = false;\r\n\t\t\t\t\tthis.table.options.rowTapHold(e, this.getComponent());\r\n\t\t\t\t}, 1000);\r\n\r\n\t\t\t}, {passive: true});\r\n\r\n\t\t\tthis.element.addEventListener(\"touchend\", (e) => {\r\n\t\t\t\tclearTimeout(tapHold);\r\n\t\t\t\ttapHold = null;\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tgenerateCells(){\r\n\t\tthis.cells = this.table.columnManager.generateCells(this);\r\n\t}\r\n\r\n\t//functions to setup on first render\r\n\tinitialize(force){\r\n\t\tthis.create();\r\n\r\n\t\tif(!this.initialized || force){\r\n\r\n\t\t\tthis.deleteCells();\r\n\r\n\t\t\twhile(this.element.firstChild) this.element.removeChild(this.element.firstChild);\r\n\r\n\t\t\t//handle frozen cells\r\n\t\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\t\tthis.table.modules.frozenColumns.layoutRow(this);\r\n\t\t\t}\r\n\r\n\t\t\tthis.generateCells();\r\n\r\n\t\t\tif(this.table.options.virtualDomHoz && this.table.vdomHoz.initialized){\r\n\t\t\t\tthis.table.vdomHoz.initializeRow(this);\r\n\t\t\t}else{\r\n\t\t\t\tthis.cells.forEach((cell) => {\r\n\t\t\t\t\tthis.element.appendChild(cell.getElement());\r\n\t\t\t\t\tcell.cellRendered();\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tif(force){\r\n\t\t\t\tthis.normalizeHeight();\r\n\t\t\t}\r\n\r\n\t\t\t//setup movable rows\r\n\t\t\tif(this.table.options.dataTree && this.table.modExists(\"dataTree\")){\r\n\t\t\t\tthis.table.modules.dataTree.layoutRow(this);\r\n\t\t\t}\r\n\r\n\t\t\t//setup column colapse container\r\n\t\t\tif(this.table.options.responsiveLayout === \"collapse\" && this.table.modExists(\"responsiveLayout\")){\r\n\t\t\t\tthis.table.modules.responsiveLayout.layoutRow(this);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.rowFormatter){\r\n\t\t\t\tthis.table.options.rowFormatter(this.getComponent());\r\n\t\t\t}\r\n\r\n\t\t\t//set resizable handles\r\n\t\t\tif(this.table.options.resizableRows && this.table.modExists(\"resizeRows\")){\r\n\t\t\t\tthis.table.modules.resizeRows.initializeRow(this);\r\n\t\t\t}\r\n\r\n\t\t\tthis.initialized = true;\r\n\t\t}else{\r\n\t\t\tif(this.table.options.virtualDomHoz){\r\n\t\t\t\tthis.table.vdomHoz.reinitializeRow(this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treinitializeHeight(){\r\n\t\tthis.heightInitialized = false;\r\n\r\n\t\tif(this.element && this.element.offsetParent !== null){\r\n\t\t\tthis.normalizeHeight(true);\r\n\t\t}\r\n\t}\r\n\r\n\treinitialize(children){\r\n\t\tthis.initialized = false;\r\n\t\tthis.heightInitialized = false;\r\n\r\n\t\tif(!this.manualHeight){\r\n\t\t\tthis.height = 0;\r\n\t\t\tthis.heightStyled = \"\";\r\n\t\t}\r\n\r\n\t\tif(this.element && this.element.offsetParent !== null){\r\n\t\t\tthis.initialize(true);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.dataTree && this.table.modExists(\"dataTree\", true)){\r\n\t\t\tthis.table.modules.dataTree.getTreeChildren(this, false, true).forEach(function(child){\r\n\t\t\t\tchild.reinitialize(true);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t//get heights when doing bulk row style calcs in virtual DOM\r\n\tcalcHeight(force){\r\n\r\n\t\tvar maxHeight = 0,\r\n\t\tminHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tvar height = cell.getHeight();\r\n\t\t\tif(height > maxHeight){\r\n\t\t\t\tmaxHeight = height;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(force){\r\n\t\t\tthis.height = Math.max(maxHeight, minHeight);\r\n\t\t}else{\r\n\t\t\tthis.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);\r\n\t\t}\r\n\r\n\t\tthis.heightStyled = this.height ? this.height + \"px\" : \"\";\r\n\t\tthis.outerHeight = this.element.offsetHeight;\r\n\t}\r\n\r\n\t//set of cells\r\n\tsetCellHeight(){\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tcell.setHeight();\r\n\t\t});\r\n\r\n\t\tthis.heightInitialized = true;\r\n\t}\r\n\r\n\tclearCellHeight(){\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tcell.clearHeight();\r\n\t\t});\r\n\t}\r\n\r\n\t//normalize the height of elements in the row\r\n\tnormalizeHeight(force){\r\n\r\n\t\tif(force){\r\n\t\t\tthis.clearCellHeight();\r\n\t\t}\r\n\r\n\t\tthis.calcHeight(force);\r\n\r\n\t\tthis.setCellHeight();\r\n\t}\r\n\r\n\t//set height of rows\r\n\tsetHeight(height, force){\r\n\t\tif(this.height != height || force){\r\n\r\n\t\t\tthis.manualHeight = true;\r\n\r\n\t\t\tthis.height = height;\r\n\t\t\tthis.heightStyled = height ? height + \"px\" : \"\";\r\n\r\n\t\t\tthis.setCellHeight();\r\n\r\n\t\t\t// this.outerHeight = this.element.outerHeight();\r\n\t\t\tthis.outerHeight = this.element.offsetHeight;\r\n\t\t}\r\n\t}\r\n\r\n\t//return rows outer height\r\n\tgetHeight(){\r\n\t\treturn this.outerHeight;\r\n\t}\r\n\r\n\t//return rows outer Width\r\n\tgetWidth(){\r\n\t\treturn this.element.offsetWidth;\r\n\t}\r\n\r\n\t//////////////// Cell Management /////////////////\r\n\tdeleteCell(cell){\r\n\t\tvar index = this.cells.indexOf(cell);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tthis.cells.splice(index, 1);\r\n\t\t}\r\n\t}\r\n\r\n\t//////////////// Data Management /////////////////\r\n\tsetData(data){\r\n\t\tif(this.table.modExists(\"mutator\")){\r\n\t\t\tdata = this.table.modules.mutator.transformRow(data, \"data\");\r\n\t\t}\r\n\r\n\t\tthis.data = data;\r\n\r\n\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\", true)){\r\n\t\t\tthis.table.modules.reactiveData.watchRow(this);\r\n\t\t}\r\n\t}\r\n\r\n\t//update the rows data\r\n\tupdateData(updatedData){\r\n\t\tvar visible = this.element && Helpers.elVisible(this.element),\r\n\t\ttempData = {},\r\n\t\tnewRowData;\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\r\n\t\t\tif(typeof updatedData === \"string\"){\r\n\t\t\t\tupdatedData = JSON.parse(updatedData);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\", true)){\r\n\t\t\t\tthis.table.modules.reactiveData.block();\r\n\t\t\t}\r\n\r\n\t\t\t//mutate incomming data if needed\r\n\t\t\tif(this.table.modExists(\"mutator\")){\r\n\r\n\t\t\t\ttempData = Object.assign(tempData, this.data);\r\n\t\t\t\ttempData = Object.assign(tempData, updatedData);\r\n\r\n\t\t\t\tnewRowData = this.table.modules.mutator.transformRow(tempData, \"data\", updatedData);\r\n\t\t\t}else{\r\n\t\t\t\tnewRowData = updatedData;\r\n\t\t\t}\r\n\r\n\t\t\t//set data\r\n\t\t\tfor (var attrname in newRowData) {\r\n\t\t\t\tthis.data[attrname] = newRowData[attrname];\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\", true)){\r\n\t\t\t\tthis.table.modules.reactiveData.unblock();\r\n\t\t\t}\r\n\r\n\t\t\t//update affected cells only\r\n\t\t\tfor (var attrname in updatedData) {\r\n\r\n\t\t\t\tlet columns = this.table.columnManager.getColumnsByFieldRoot(attrname);\r\n\r\n\t\t\t\tcolumns.forEach((column) => {\r\n\t\t\t\t\tlet cell = this.getCell(column.getField());\r\n\r\n\t\t\t\t\tif(cell){\r\n\t\t\t\t\t\tlet value = column.getFieldValue(newRowData);\r\n\t\t\t\t\t\tif(cell.getValue() != value){\r\n\t\t\t\t\t\t\tcell.setValueProcessData(value);\r\n\r\n\t\t\t\t\t\t\tif(visible){\r\n\t\t\t\t\t\t\t\tcell.cellRendered();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.groupUpdateOnCellEdit && this.table.options.groupBy && this.table.modExists(\"groupRows\")) {\r\n\t\t\t\tthis.table.modules.groupRows.reassignRowToGroup(this.row);\r\n\t\t\t}\r\n\r\n\t\t\t//Partial reinitialization if visible\r\n\t\t\tif(visible){\r\n\t\t\t\tthis.normalizeHeight(true);\r\n\r\n\t\t\t\tif(this.table.options.rowFormatter){\r\n\t\t\t\t\tthis.table.options.rowFormatter(this.getComponent());\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tthis.initialized = false;\r\n\t\t\t\tthis.height = 0;\r\n\t\t\t\tthis.heightStyled = \"\";\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.dataTree !== false && this.table.modExists(\"dataTree\") && this.table.modules.dataTree.redrawNeeded(updatedData)){\r\n\t\t\t\tthis.table.modules.dataTree.initializeRow(this);\r\n\r\n\t\t\t\tif(visible){\r\n\t\t\t\t\tthis.table.modules.dataTree.layoutRow(this);\r\n\t\t\t\t\tthis.table.rowManager.refreshActiveData(\"tree\", false, true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\t//this.reinitialize();\r\n\r\n\t\t\tthis.table.options.rowUpdated.call(this.table, this.getComponent());\r\n\r\n\t\t\tif(this.table.options.dataChanged){\r\n\t\t\t\tthis.table.options.dataChanged.call(this.table, this.table.rowManager.getData());\r\n\t\t\t}\r\n\r\n\t\t\tresolve();\r\n\t\t});\r\n\t}\r\n\r\n\tgetData(transform){\r\n\t\tif(transform){\r\n\t\t\tif(this.table.modExists(\"accessor\")){\r\n\t\t\t\treturn this.table.modules.accessor.transformRow(this, transform);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn this.data;\r\n\t}\r\n\r\n\tgetCell(column){\r\n\t\tvar match = false;\r\n\r\n\t\tcolumn = this.table.columnManager.findColumn(column);\r\n\r\n\t\tmatch = this.cells.find(function(cell){\r\n\t\t\treturn cell.column === column;\r\n\t\t});\r\n\r\n\t\treturn match;\r\n\t}\r\n\r\n\tgetCellIndex(findCell){\r\n\t\treturn this.cells.findIndex(function(cell){\r\n\t\t\treturn cell === findCell;\r\n\t\t});\r\n\t}\r\n\r\n\tfindNextEditableCell(index){\r\n\t\tvar nextCell = false;\r\n\r\n\t\tif(index < this.cells.length-1){\r\n\t\t\tfor(var i = index+1; i < this.cells.length; i++){\r\n\t\t\t\tlet cell = this.cells[i];\r\n\r\n\t\t\t\tif(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){\r\n\t\t\t\t\tlet allowEdit = true;\r\n\r\n\t\t\t\t\tif(typeof cell.column.modules.edit.check == \"function\"){\r\n\t\t\t\t\t\tallowEdit = cell.column.modules.edit.check(cell.getComponent());\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(allowEdit){\r\n\t\t\t\t\t\tnextCell = cell;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn nextCell;\r\n\t}\r\n\r\n\tfindPrevEditableCell(index){\r\n\t\tvar prevCell = false;\r\n\r\n\t\tif(index > 0){\r\n\t\t\tfor(var i = index-1; i >= 0; i--){\r\n\t\t\t\tlet cell = this.cells[i],\r\n\t\t\t\tallowEdit = true;\r\n\r\n\t\t\t\tif(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){\r\n\t\t\t\t\tif(typeof cell.column.modules.edit.check == \"function\"){\r\n\t\t\t\t\t\tallowEdit = cell.column.modules.edit.check(cell.getComponent());\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(allowEdit){\r\n\t\t\t\t\t\tprevCell = cell;\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn prevCell;\r\n\t}\r\n\r\n\tgetCells(){\r\n\t\treturn this.cells;\r\n\t}\r\n\r\n\tnextRow(){\r\n\t\tvar row = this.table.rowManager.nextDisplayRow(this, true);\r\n\t\treturn row || false;\r\n\t}\r\n\r\n\tprevRow(){\r\n\t\tvar row = this.table.rowManager.prevDisplayRow(this, true);\r\n\t\treturn row || false;\r\n\t}\r\n\r\n\tmoveToRow(to, before){\r\n\t\tvar toRow = this.table.rowManager.findRow(to);\r\n\r\n\t\tif(toRow){\r\n\t\t\tthis.table.rowManager.moveRowActual(this, toRow, !before);\r\n\t\t\tthis.table.rowManager.refreshActiveData(\"display\", false, true);\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Move Error - No matching row found:\", to);\r\n\t\t}\r\n\t}\r\n\r\n\tvalidate(){\r\n\t\tvar invalid = [];\r\n\r\n\t\tthis.cells.forEach(function(cell){\r\n\t\t\tif(!cell.validate()){\r\n\t\t\t\tinvalid.push(cell.getComponent());\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn invalid.length ? invalid : true;\r\n\t}\r\n\r\n\t///////////////////// Actions /////////////////////\r\n\tdelete(){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar index, rows;\r\n\r\n\t\t\tif(this.table.options.history && this.table.modExists(\"history\")){\r\n\r\n\t\t\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\t\t\trows = this.getGroup().rows\r\n\t\t\t\t\tindex = rows.indexOf(this);\r\n\r\n\t\t\t\t\tif(index){\r\n\t\t\t\t\t\tindex = rows[index-1];\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tindex = this.table.rowManager.getRowIndex(this);\r\n\r\n\t\t\t\t\tif(index){\r\n\t\t\t\t\t\tindex = this.table.rowManager.rows[index-1];\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.table.modules.history.action(\"rowDelete\", this, {data:this.getData(), pos:!index, index:index});\r\n\t\t\t}\r\n\r\n\t\t\tthis.deleteActual();\r\n\r\n\t\t\tresolve();\r\n\t\t});\r\n\t}\r\n\r\n\tdeleteActual(blockRedraw){\r\n\t\tvar index = this.table.rowManager.getRowIndex(this);\r\n\r\n\t\tthis.detatchModules();\r\n\r\n\t\t// if(this.table.options.dataTree && this.table.modExists(\"dataTree\")){\r\n\t\t// \tthis.table.modules.dataTree.collapseRow(this, true);\r\n\t\t// }\r\n\r\n\t\t//remove any reactive data watchers from row object\r\n\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\", true)){\r\n\t\t\t// this.table.modules.reactiveData.unwatchRow(this);\r\n\t\t}\r\n\r\n\t\t//remove from group\r\n\t\tif(this.modules.group){\r\n\t\t\tthis.modules.group.removeRow(this);\r\n\t\t}\r\n\r\n\t\tthis.table.rowManager.deleteRow(this, blockRedraw);\r\n\r\n\t\tthis.deleteCells();\r\n\r\n\t\tthis.initialized = false;\r\n\t\tthis.heightInitialized = false;\r\n\t\tthis.element = false;\r\n\r\n\t\tif(this.table.options.dataTree && this.table.modExists(\"dataTree\", true)){\r\n\t\t\tthis.table.modules.dataTree.rowDelete(this);\r\n\t\t}\r\n\r\n\t\t//recalc column calculations if present\r\n\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\t\tthis.table.modules.columnCalcs.recalcRowGroup(this);\r\n\t\t\t}else{\r\n\t\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tdetatchModules(){\r\n\t\t//deselect row if it is selected\r\n\t\tif(this.table.modExists(\"selectRow\")){\r\n\t\t\tthis.table.modules.selectRow._deselectRow(this, true);\r\n\t\t}\r\n\r\n\t\t//cancel edit if row is currently being edited\r\n\t\tif(this.table.modExists(\"edit\")){\r\n\t\t\tif(this.table.modules.edit.currentCell.row === this){\r\n\t\t\t\tthis.table.modules.edit.cancelEdit();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"frozenRows\")){\r\n\t\t\tthis.table.modules.frozenRows.detachRow(this);\r\n\t\t}\r\n\t}\r\n\r\n\tdeleteCells(){\r\n\t\tvar cellCount = this.cells.length;\r\n\r\n\t\tfor(let i = 0; i < cellCount; i++){\r\n\t\t\tthis.cells[0].delete();\r\n\t\t}\r\n\t}\r\n\r\n\twipe(){\r\n\t\tthis.detatchModules();\r\n\t\tthis.deleteCells();\r\n\r\n\t\tif(this.element){\r\n\t\t\twhile(this.element.firstChild) this.element.removeChild(this.element.firstChild);\r\n\r\n\t\t\tif(this.element.parentNode){\r\n\t\t\t\tthis.element.parentNode.removeChild(this.element);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.element = false;\r\n\t\tthis.modules = {};\r\n\t}\r\n\r\n\tgetGroup(){\r\n\t\treturn this.modules.group || false;\r\n\t}\r\n\r\n\t//////////////// Object Generation /////////////////\r\n\tgetComponent(){\r\n\t\tif(!this.component){\r\n\t\t\tthis.component = new RowComponent(this);\r\n\t\t}\r\n\r\n\t\treturn this.component;\r\n\t}\r\n}","import Row from './row/Row.js';\r\nimport Helpers from './Helpers.js';\r\n\r\nexport default class RowManager {\r\n\r\n\tconstructor(table){\r\n\t\tthis.table = table;\r\n\t\tthis.element = this.createHolderElement(); //containing element\r\n\t\tthis.tableElement = this.createTableElement(); //table element\r\n\t\tthis.heightFixer = this.createTableElement(); //table element\r\n\t\tthis.columnManager = null; //hold column manager object\r\n\t\tthis.height = 0; //hold height of table element\r\n\r\n\t\tthis.firstRender = false; //handle first render\r\n\t\tthis.renderMode = \"virtual\"; //current rendering mode\r\n\t\tthis.fixedHeight = false; //current rendering mode\r\n\r\n\t\tthis.rows = []; //hold row data objects\r\n\t\tthis.activeRows = []; //rows currently available to on display in the table\r\n\t\tthis.activeRowsCount = 0; //count of active rows\r\n\r\n\t\tthis.displayRows = []; //rows currently on display in the table\r\n\t\tthis.displayRowsCount = 0; //count of display rows\r\n\r\n\t\tthis.scrollTop = 0;\r\n\t\tthis.scrollLeft = 0;\r\n\r\n\t\tthis.vDomRowHeight = 20; //approximation of row heights for padding\r\n\r\n\t\tthis.vDomTop = 0; //hold position for first rendered row in the virtual DOM\r\n\t\tthis.vDomBottom = 0; //hold possition for last rendered row in the virtual DOM\r\n\r\n\t\tthis.vDomScrollPosTop = 0; //last scroll position of the vDom top;\r\n\t\tthis.vDomScrollPosBottom = 0; //last scroll position of the vDom bottom;\r\n\r\n\t\tthis.vDomTopPad = 0; //hold value of padding for top of virtual DOM\r\n\t\tthis.vDomBottomPad = 0; //hold value of padding for bottom of virtual DOM\r\n\r\n\t\tthis.vDomMaxRenderChain = 90; //the maximum number of dom elements that can be rendered in 1 go\r\n\r\n\t\tthis.vDomWindowBuffer = 0; //window row buffer before removing elements, to smooth scrolling\r\n\r\n\t\tthis.vDomWindowMinTotalRows = 20; //minimum number of rows to be generated in virtual dom (prevent buffering issues on tables with tall rows)\r\n\t\tthis.vDomWindowMinMarginRows = 5; //minimum number of rows to be generated in virtual dom margin\r\n\r\n\t\tthis.vDomTopNewRows = []; //rows to normalize after appending to optimize render speed\r\n\t\tthis.vDomBottomNewRows = []; //rows to normalize after appending to optimize render speed\r\n\r\n\t\tthis.rowNumColumn = false; //hold column component for row number column\r\n\r\n\t\tthis.redrawBlock = false; //prevent redraws to allow multiple data manipulations becore continuing\r\n\t\tthis.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed\r\n\t\tthis.redrawBlockRederInPosition = false; //store latest redraw function calls for when redraw is needed\r\n\t}\r\n\r\n\t//////////////// Setup Functions /////////////////\r\n\r\n\tcreateHolderElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-tableHolder\");\r\n\t\tel.setAttribute(\"tabindex\", 0);\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\tcreateTableElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-table\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\t//return containing element\r\n\tgetElement(){\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\t//return table element\r\n\tgetTableElement(){\r\n\t\treturn this.tableElement;\r\n\t}\r\n\r\n\t//return position of row in table\r\n\tgetRowPosition(row, active){\r\n\t\tif(active){\r\n\t\t\treturn this.activeRows.indexOf(row);\r\n\t\t}else{\r\n\t\t\treturn this.rows.indexOf(row);\r\n\t\t}\r\n\t}\r\n\r\n\t//link to column manager\r\n\tsetColumnManager(manager){\r\n\t\tthis.columnManager = manager;\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tthis.setRenderMode();\r\n\r\n\t\t//initialize manager\r\n\t\tthis.element.appendChild(this.tableElement);\r\n\r\n\t\tthis.firstRender = true;\r\n\r\n\t\t//scroll header along with table body\r\n\t\tthis.element.addEventListener(\"scroll\", () => {\r\n\t\t\tvar left = this.element.scrollLeft;\r\n\r\n\t\t\t//handle horizontal scrolling\r\n\t\t\tif(this.scrollLeft != left){\r\n\t\t\t\tthis.columnManager.scrollHorizontal(left);\r\n\r\n\t\t\t\tif(this.table.options.groupBy){\r\n\t\t\t\t\tthis.table.modules.groupRows.scrollHeaders(left);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\t\t\tthis.table.modules.columnCalcs.scrollHorizontal(left);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.table.options.scrollHorizontal(left);\r\n\t\t\t}\r\n\r\n\t\t\tthis.scrollLeft = left;\r\n\t\t});\r\n\r\n\t\t//handle virtual dom scrolling\r\n\t\tif(this.renderMode === \"virtual\"){\r\n\t\t\tthis.element.addEventListener(\"scroll\", () => {\r\n\t\t\t\tvar top = this.element.scrollTop;\r\n\t\t\t\tvar dir = this.scrollTop > top;\r\n\r\n\t\t\t\t//handle verical scrolling\r\n\t\t\t\tif(this.scrollTop != top){\r\n\t\t\t\t\tthis.scrollTop = top;\r\n\t\t\t\t\tthis.scrollVertical(dir);\r\n\r\n\t\t\t\t\tif(this.table.options.ajaxProgressiveLoad == \"scroll\"){\r\n\t\t\t\t\t\tthis.table.modules.ajax.nextPage(this.element.scrollHeight - this.element.clientHeight - top);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.table.options.scrollVertical(top);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.scrollTop = top;\r\n\t\t\t\t}\r\n\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t////////////////// Row Manipulation //////////////////\r\n\tfindRow(subject){\r\n\t\tif(typeof subject == \"object\"){\r\n\t\t\tif(subject instanceof Row){\r\n\t\t\t\t//subject is row element\r\n\t\t\t\treturn subject;\r\n\t\t\t}else if(subject instanceof RowComponent){\r\n\t\t\t\t//subject is public row component\r\n\t\t\t\treturn subject._getSelf() || false;\r\n\t\t\t}else if(typeof HTMLElement !== \"undefined\" && subject instanceof HTMLElement){\r\n\t\t\t\t//subject is a HTML element of the row\r\n\t\t\t\tlet match = this.rows.find((row) => {\r\n\t\t\t\t\treturn row.getElement() === subject;\r\n\t\t\t\t});\r\n\r\n\t\t\t\treturn match || false;\r\n\t\t\t}\r\n\t\t}else if(typeof subject == \"undefined\" || subject === null){\r\n\t\t\treturn false;\r\n\t\t}else{\r\n\t\t\t//subject should be treated as the index of the row\r\n\t\t\tlet match = this.rows.find((row) => {\r\n\t\t\t\treturn row.data[this.table.options.index] == subject;\r\n\t\t\t});\r\n\r\n\t\t\treturn match || false;\r\n\t\t}\r\n\r\n\t\t//catch all for any other type of input\r\n\t\treturn false;\r\n\t}\r\n\r\n\tgetRowFromDataObject(data){\r\n\t\tvar match = this.rows.find((row) => {\r\n\t\t\treturn row.data === data;\r\n\t\t});\r\n\r\n\t\treturn match || false;\r\n\t}\r\n\r\n\tgetRowFromPosition(position, active){\r\n\t\tif(active){\r\n\t\t\treturn this.activeRows[position];\r\n\t\t}else{\r\n\t\t\treturn this.rows[position];\r\n\t\t}\r\n\t}\r\n\r\n\tscrollToRow(row, position, ifVisible){\r\n\t\tvar rowIndex = this.getDisplayRows().indexOf(row),\r\n\t\trowEl = row.getElement(),\r\n\t\trowTop,\r\n\t\toffset = 0;\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(rowIndex > -1){\r\n\r\n\t\t\t\tif(typeof position === \"undefined\"){\r\n\t\t\t\t\tposition = this.table.options.scrollToRowPosition;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(typeof ifVisible === \"undefined\"){\r\n\t\t\t\t\tifVisible = this.table.options.scrollToRowIfVisible;\r\n\t\t\t\t}\r\n\r\n\r\n\t\t\t\tif(position === \"nearest\"){\r\n\t\t\t\t\tswitch(this.renderMode){\r\n\t\t\t\t\t\tcase\"classic\":\r\n\t\t\t\t\t\trowTop = Helpers.elOffset(rowEl).top;\r\n\t\t\t\t\t\tposition = Math.abs(this.element.scrollTop - rowTop) > Math.abs(this.element.scrollTop + this.element.clientHeight - rowTop) ? \"bottom\" : \"top\";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\tcase\"virtual\":\r\n\t\t\t\t\t\tposition = Math.abs(this.vDomTop - rowIndex) > Math.abs(this.vDomBottom - rowIndex) ? \"bottom\" : \"top\";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//check row visibility\r\n\t\t\t\tif(!ifVisible){\r\n\t\t\t\t\tif(Helpers.elVisible(rowEl)){\r\n\t\t\t\t\t\toffset = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.element).top;\r\n\r\n\t\t\t\t\t\tif(offset > 0 && offset < this.element.clientHeight - rowEl.offsetHeight){\r\n\t\t\t\t\t\t\treturn false;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//scroll to row\r\n\t\t\t\tswitch(this.renderMode){\r\n\t\t\t\t\tcase\"classic\":\r\n\t\t\t\t\tthis.element.scrollTop = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.element).top + this.element.scrollTop;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t\tcase\"virtual\":\r\n\t\t\t\t\tthis._virtualRenderFill(rowIndex, true);\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//align to correct position\r\n\t\t\t\tswitch(position){\r\n\t\t\t\t\tcase \"middle\":\r\n\t\t\t\t\tcase \"center\":\r\n\r\n\t\t\t\t\tif(this.element.scrollHeight - this.element.scrollTop == this.element.clientHeight){\r\n\t\t\t\t\t\tthis.element.scrollTop = this.element.scrollTop + (rowEl.offsetTop - this.element.scrollTop) - ((this.element.scrollHeight - rowEl.offsetTop) / 2);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.element.scrollTop = this.element.scrollTop - (this.element.clientHeight / 2);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"bottom\":\r\n\r\n\t\t\t\t\tif(this.element.scrollHeight - this.element.scrollTop == this.element.clientHeight){\r\n\t\t\t\t\t\tthis.element.scrollTop = this.element.scrollTop - (this.element.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight;\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.element.scrollTop = this.element.scrollTop - this.element.clientHeight + rowEl.offsetHeight;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tresolve();\r\n\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Scroll Error - Row not visible\");\r\n\t\t\t\treject(\"Scroll Error - Row not visible\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t////////////////// Data Handling //////////////////\r\n\tsetData(data, renderInPosition, columnsChanged){\r\n\t\treturn new Promise((resolve, reject)=>{\r\n\t\t\tif(renderInPosition && this.getDisplayRows().length){\r\n\t\t\t\tif(this.table.options.pagination){\r\n\t\t\t\t\tthis._setDataActual(data, true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.reRenderInPosition(() => {\r\n\t\t\t\t\t\tthis._setDataActual(data);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tif(this.table.options.autoColumns && columnsChanged){\r\n\t\t\t\t\tthis.table.columnManager.generateColumnsFromRowData(data);\r\n\t\t\t\t}\r\n\t\t\t\tthis.resetScroll();\r\n\r\n\t\t\t\tthis._setDataActual(data);\r\n\r\n\t\t\t}\r\n\r\n\t\t\tresolve();\r\n\t\t});\r\n\t}\r\n\r\n\t_setDataActual(data, renderInPosition){\r\n\t\tthis.table.options.dataLoading.call(this.table, data);\r\n\r\n\t\tthis._wipeElements();\r\n\r\n\t\tif(this.table.options.history && this.table.modExists(\"history\")){\r\n\t\t\tthis.table.modules.history.clear();\r\n\t\t}\r\n\r\n\t\tif(Array.isArray(data)){\r\n\r\n\t\t\tif(this.table.modExists(\"selectRow\")){\r\n\t\t\t\tthis.table.modules.selectRow.clearSelectionData();\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.reactiveData && this.table.modExists(\"reactiveData\", true)){\r\n\t\t\t\tthis.table.modules.reactiveData.watchData(data);\r\n\t\t\t}\r\n\r\n\t\t\tdata.forEach((def, i) => {\r\n\t\t\t\tif(def && typeof def === \"object\"){\r\n\t\t\t\t\tvar row = new Row(def, this);\r\n\t\t\t\t\tthis.rows.push(row);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Data Loading Warning - Invalid row data detected and ignored, expecting object but received:\", def);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.refreshActiveData(false, false, renderInPosition);\r\n\r\n\t\t\tthis.table.options.dataLoaded.call(this.table, data);\r\n\t\t}else{\r\n\t\t\tconsole.error(\"Data Loading Error - Unable to process data due to invalid data type \\nExpecting: array \\nReceived: \", typeof data, \"\\nData: \", data);\r\n\t\t}\r\n\t}\r\n\r\n\t_wipeElements(){\r\n\t\tthis.rows.forEach((row) => {\r\n\t\t\trow.wipe();\r\n\t\t});\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\tthis.table.modules.groupRows.wipe();\r\n\t\t}\r\n\r\n\t\tthis.rows = [];\r\n\t\tthis.activeRows = [];\r\n\t\tthis.activeRowsCount = 0;\r\n\t\tthis.displayRows = [];\r\n\t\tthis.displayRowsCount = 0;\r\n\r\n\t\tthis.adjustTableSize();\r\n\t}\r\n\r\n\tdeleteRow(row, blockRedraw){\r\n\t\tvar allIndex = this.rows.indexOf(row),\r\n\t\tactiveIndex = this.activeRows.indexOf(row);\r\n\r\n\t\tif(activeIndex > -1){\r\n\t\t\tthis.activeRows.splice(activeIndex, 1);\r\n\t\t}\r\n\r\n\t\tif(allIndex > -1){\r\n\t\t\tthis.rows.splice(allIndex, 1);\r\n\t\t}\r\n\r\n\t\tthis.setActiveRows(this.activeRows);\r\n\r\n\t\tthis.displayRowIterator((rows) => {\r\n\t\t\tvar displayIndex = rows.indexOf(row);\r\n\r\n\t\t\tif(displayIndex > -1){\r\n\t\t\t\trows.splice(displayIndex, 1);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(!blockRedraw){\r\n\t\t\tthis.reRenderInPosition();\r\n\t\t}\r\n\r\n\t\tthis.regenerateRowNumbers();\r\n\r\n\t\tthis.table.options.rowDeleted.call(this.table, row.getComponent());\r\n\r\n\t\tif(this.table.options.dataChanged){\r\n\t\t\tthis.table.options.dataChanged.call(this.table, this.getData());\r\n\t\t}\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\tthis.table.modules.groupRows.updateGroupRows(true);\r\n\t\t}else if(this.table.options.pagination && this.table.modExists(\"page\")){\r\n\t\t\tthis.refreshActiveData(false, false, true);\r\n\t\t}else{\r\n\t\t\tif(this.table.options.pagination && this.table.modExists(\"page\")){\r\n\t\t\t\tthis.refreshActiveData(\"page\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\taddRow(data, pos, index, blockRedraw){\r\n\t\tvar row = this.addRowActual(data, pos, index, blockRedraw);\r\n\r\n\t\tif(this.table.options.history && this.table.modExists(\"history\")){\r\n\t\t\tthis.table.modules.history.action(\"rowAdd\", row, {data:data, pos:pos, index:index});\r\n\t\t}\r\n\r\n\t\treturn row;\r\n\t}\r\n\r\n\t//add multiple rows\r\n\taddRows(data, pos, index){\r\n\t\tvar length = 0,\r\n\t\trows = [];\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tpos = this.findAddRowPos(pos);\r\n\r\n\t\t\tif(!Array.isArray(data)){\r\n\t\t\t\tdata = [data];\r\n\t\t\t}\r\n\r\n\t\t\tlength = data.length - 1;\r\n\r\n\t\t\tif((typeof index == \"undefined\" && pos) || (typeof index !== \"undefined\" && !pos)){\r\n\t\t\t\tdata.reverse();\r\n\t\t\t}\r\n\r\n\t\t\tdata.forEach((item, i) => {\r\n\t\t\t\tvar row = this.addRow(item, pos, index, true);\r\n\t\t\t\trows.push(row);\r\n\t\t\t});\r\n\r\n\t\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\t\tthis.table.modules.groupRows.updateGroupRows(true);\r\n\t\t\t}else if(this.table.options.pagination && this.table.modExists(\"page\")){\r\n\t\t\t\tthis.refreshActiveData(false, false, true);\r\n\t\t\t}else{\r\n\t\t\t\tthis.reRenderInPosition();\r\n\t\t\t}\r\n\r\n\t\t\t//recalc column calculations if present\r\n\t\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\t\tthis.table.modules.columnCalcs.recalc(this.table.rowManager.activeRows);\r\n\t\t\t}\r\n\r\n\t\t\tthis.regenerateRowNumbers();\r\n\t\t\tresolve(rows);\r\n\t\t});\r\n\t}\r\n\r\n\tfindAddRowPos(pos){\r\n\t\tif(typeof pos === \"undefined\"){\r\n\t\t\tpos = this.table.options.addRowPos;\r\n\t\t}\r\n\r\n\t\tif(pos === \"pos\"){\r\n\t\t\tpos = true;\r\n\t\t}\r\n\r\n\t\tif(pos === \"bottom\"){\r\n\t\t\tpos = false;\r\n\t\t}\r\n\r\n\t\treturn pos;\r\n\t}\r\n\r\n\taddRowActual(data, pos, index, blockRedraw){\r\n\t\tvar row = data instanceof Row ? data : new Row(data || {}, this),\r\n\t\ttop = this.findAddRowPos(pos),\r\n\t\tallIndex = -1,\r\n\t\tactiveIndex, dispRows;\r\n\r\n\t\tif(!index && this.table.options.pagination && this.table.options.paginationAddRow == \"page\"){\r\n\t\t\tdispRows = this.getDisplayRows();\r\n\r\n\t\t\tif(top){\r\n\t\t\t\tif(dispRows.length){\r\n\t\t\t\t\tindex = dispRows[0];\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif(this.activeRows.length){\r\n\t\t\t\t\t\tindex = this.activeRows[this.activeRows.length-1];\r\n\t\t\t\t\t\ttop = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tif(dispRows.length){\r\n\t\t\t\t\tindex = dispRows[dispRows.length - 1];\r\n\t\t\t\t\ttop = dispRows.length < this.table.modules.page.getPageSize() ? false : true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(typeof index !== \"undefined\"){\r\n\t\t\tindex = this.findRow(index);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\tthis.table.modules.groupRows.assignRowToGroup(row);\r\n\r\n\t\t\tvar groupRows = row.getGroup().rows;\r\n\r\n\t\t\tif(groupRows.length > 1){\r\n\r\n\t\t\t\tif(!index || (index && groupRows.indexOf(index) == -1)){\r\n\t\t\t\t\tif(top){\r\n\t\t\t\t\t\tif(groupRows[0] !== row){\r\n\t\t\t\t\t\t\tindex = groupRows[0];\r\n\t\t\t\t\t\t\tthis._moveRowInArray(row.getGroup().rows, row, index, !top);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tif(groupRows[groupRows.length -1] !== row){\r\n\t\t\t\t\t\t\tindex = groupRows[groupRows.length -1];\r\n\t\t\t\t\t\t\tthis._moveRowInArray(row.getGroup().rows, row, index, !top);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis._moveRowInArray(row.getGroup().rows, row, index, !top);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(index){\r\n\t\t\tallIndex = this.rows.indexOf(index);\r\n\t\t}\r\n\r\n\t\tif(index && allIndex > -1){\r\n\t\t\tactiveIndex = this.activeRows.indexOf(index);\r\n\r\n\t\t\tthis.displayRowIterator(function(rows){\r\n\t\t\t\tvar displayIndex = rows.indexOf(index);\r\n\r\n\t\t\t\tif(displayIndex > -1){\r\n\t\t\t\t\trows.splice((top ? displayIndex : displayIndex + 1), 0, row);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif(activeIndex > -1){\r\n\t\t\t\tthis.activeRows.splice((top ? activeIndex : activeIndex + 1), 0, row);\r\n\t\t\t}\r\n\r\n\t\t\tthis.rows.splice((top ? allIndex : allIndex + 1), 0, row);\r\n\r\n\t\t}else{\r\n\r\n\t\t\tif(top){\r\n\r\n\t\t\t\tthis.displayRowIterator(function(rows){\r\n\t\t\t\t\trows.unshift(row);\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthis.activeRows.unshift(row);\r\n\t\t\t\tthis.rows.unshift(row);\r\n\t\t\t}else{\r\n\t\t\t\tthis.displayRowIterator(function(rows){\r\n\t\t\t\t\trows.push(row);\r\n\t\t\t\t});\r\n\r\n\t\t\t\tthis.activeRows.push(row);\r\n\t\t\t\tthis.rows.push(row);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.setActiveRows(this.activeRows);\r\n\r\n\t\tthis.table.options.rowAdded.call(this.table, row.getComponent());\r\n\r\n\t\tif(this.table.options.dataChanged){\r\n\t\t\tthis.table.options.dataChanged.call(this.table, this.getData());\r\n\t\t}\r\n\r\n\t\tif(!blockRedraw){\r\n\t\t\tthis.reRenderInPosition();\r\n\t\t}\r\n\r\n\t\treturn row;\r\n\t}\r\n\r\n\tmoveRow(from, to, after){\r\n\t\tif(this.table.options.history && this.table.modExists(\"history\")){\r\n\t\t\tthis.table.modules.history.action(\"rowMove\", from, {posFrom:this.getRowPosition(from), posTo:this.getRowPosition(to), to:to, after:after});\r\n\t\t}\r\n\r\n\t\tthis.moveRowActual(from, to, after);\r\n\r\n\t\tthis.regenerateRowNumbers();\r\n\r\n\t\tthis.table.options.rowMoved.call(this.table, from.getComponent());\r\n\t}\r\n\r\n\tmoveRowActual(from, to, after){\r\n\t\tthis._moveRowInArray(this.rows, from, to, after);\r\n\t\tthis._moveRowInArray(this.activeRows, from, to, after);\r\n\r\n\t\tthis.displayRowIterator((rows) => {\r\n\t\t\tthis._moveRowInArray(rows, from, to, after);\r\n\t\t});\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\r\n\t\t\tif(!after && to instanceof Group){\r\n\t\t\t\tto = this.table.rowManager.prevDisplayRow(from) || to;\r\n\t\t\t}\r\n\r\n\t\t\tvar toGroup = to.getGroup();\r\n\t\t\tvar fromGroup = from.getGroup();\r\n\r\n\t\t\tif(toGroup === fromGroup){\r\n\t\t\t\tthis._moveRowInArray(toGroup.rows, from, to, after);\r\n\t\t\t}else{\r\n\t\t\t\tif(fromGroup){\r\n\t\t\t\t\tfromGroup.removeRow(from);\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttoGroup.insertRow(from, to, after);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_moveRowInArray(rows, from, to, after){\r\n\t\tvar\tfromIndex, toIndex, start, end;\r\n\r\n\t\tif(from !== to){\r\n\r\n\t\t\tfromIndex = rows.indexOf(from);\r\n\r\n\t\t\tif (fromIndex > -1) {\r\n\r\n\t\t\t\trows.splice(fromIndex, 1);\r\n\r\n\t\t\t\ttoIndex = rows.indexOf(to);\r\n\r\n\t\t\t\tif (toIndex > -1) {\r\n\r\n\t\t\t\t\tif(after){\r\n\t\t\t\t\t\trows.splice(toIndex+1, 0, from);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\trows.splice(toIndex, 0, from);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}else{\r\n\t\t\t\t\trows.splice(fromIndex, 0, from);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//restyle rows\r\n\t\t\tif(rows === this.getDisplayRows()){\r\n\r\n\t\t\t\tstart = fromIndex < toIndex ? fromIndex : toIndex;\r\n\t\t\t\tend = toIndex > fromIndex ? toIndex : fromIndex +1;\r\n\r\n\t\t\t\tfor(let i = start; i <= end; i++){\r\n\t\t\t\t\tif(rows[i]){\r\n\t\t\t\t\t\tthis.styleRow(rows[i], i);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tclearData(){\r\n\t\tthis.setData([]);\r\n\t}\r\n\r\n\tgetRowIndex(row){\r\n\t\treturn this.findRowIndex(row, this.rows);\r\n\t}\r\n\r\n\tgetDisplayRowIndex(row){\r\n\t\tvar index = this.getDisplayRows().indexOf(row);\r\n\t\treturn index > -1 ? index : false;\r\n\t}\r\n\r\n\tnextDisplayRow(row, rowOnly){\r\n\t\tvar index = this.getDisplayRowIndex(row),\r\n\t\tnextRow = false;\r\n\r\n\r\n\t\tif(index !== false && index < this.displayRowsCount -1){\r\n\t\t\tnextRow = this.getDisplayRows()[index+1];\r\n\t\t}\r\n\r\n\t\tif(nextRow && (!(nextRow instanceof Row) || nextRow.type != \"row\")){\r\n\t\t\treturn this.nextDisplayRow(nextRow, rowOnly);\r\n\t\t}\r\n\r\n\t\treturn nextRow;\r\n\t}\r\n\r\n\tprevDisplayRow(row, rowOnly){\r\n\t\tvar index = this.getDisplayRowIndex(row),\r\n\t\tprevRow = false;\r\n\r\n\t\tif(index){\r\n\t\t\tprevRow = this.getDisplayRows()[index-1];\r\n\t\t}\r\n\r\n\t\tif(rowOnly && prevRow && (!(prevRow instanceof Row) || prevRow.type != \"row\")){\r\n\t\t\treturn this.prevDisplayRow(prevRow, rowOnly);\r\n\t\t}\r\n\r\n\t\treturn prevRow;\r\n\t}\r\n\r\n\tfindRowIndex(row, list){\r\n\t\tvar rowIndex;\r\n\r\n\t\trow = this.findRow(row);\r\n\r\n\t\tif(row){\r\n\t\t\trowIndex = list.indexOf(row);\r\n\r\n\t\t\tif(rowIndex > -1){\r\n\t\t\t\treturn rowIndex;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tgetData(active, transform){\r\n\t\tvar output = [],\r\n\t\trows = this.getRows(active);\r\n\r\n\t\trows.forEach(function(row){\r\n\t\t\tif(row.type == \"row\"){\r\n\t\t\t\toutput.push(row.getData(transform || \"data\"));\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetComponents(active){\r\n\t\tvar\toutput = [],\r\n\t\trows = this.getRows(active);\r\n\r\n\t\trows.forEach(function(row){\r\n\t\t\toutput.push(row.getComponent());\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetDataCount(active){\r\n\t\tvar rows = this.getRows(active);\r\n\r\n\t\treturn rows.length;\r\n\t}\r\n\r\n\t_genRemoteRequest(){\r\n\t\tvar table = this.table,\r\n\t\toptions = table.options,\r\n\t\tparams = {};\r\n\r\n\t\tif(table.modExists(\"page\")){\r\n\t\t\t//set sort data if defined\r\n\t\t\tif(options.ajaxSorting){\r\n\t\t\t\tlet sorters = this.table.modules.sort.getSort();\r\n\r\n\t\t\t\tsorters.forEach(function(item){\r\n\t\t\t\t\tdelete item.column;\r\n\t\t\t\t});\r\n\r\n\t\t\t\tparams[this.table.modules.page.paginationDataSentNames.sorters] = sorters;\r\n\t\t\t}\r\n\r\n\t\t\t//set filter data if defined\r\n\t\t\tif(options.ajaxFiltering){\r\n\t\t\t\tlet filters = this.table.modules.filter.getFilters(true, true);\r\n\r\n\t\t\t\tparams[this.table.modules.page.paginationDataSentNames.filters] = filters;\r\n\t\t\t}\r\n\r\n\r\n\t\t\tthis.table.modules.ajax.setParams(params, true);\r\n\t\t}\r\n\r\n\t\ttable.modules.ajax.sendRequest()\r\n\t\t.then((data)=>{\r\n\t\t\tthis._setDataActual(data, true);\r\n\t\t})\r\n\t\t.catch((e)=>{});\r\n\t}\r\n\r\n\t//choose the path to refresh data after a filter update\r\n\tfilterRefresh(){\r\n\t\tvar table = this.table,\r\n\t\toptions = table.options,\r\n\t\tleft = this.scrollLeft;\r\n\r\n\t\tif(options.ajaxFiltering){\r\n\t\t\tif(options.pagination == \"remote\" && table.modExists(\"page\")){\r\n\t\t\t\ttable.modules.page.reset(true);\r\n\t\t\t\ttable.modules.page.setPage(1).then(()=>{}).catch(()=>{});\r\n\t\t\t}else if(options.ajaxProgressiveLoad){\r\n\t\t\t\ttable.modules.ajax.loadData().then(()=>{}).catch(()=>{});\r\n\t\t\t}else{\r\n\t\t\t\t//assume data is url, make ajax call to url to get data\r\n\t\t\t\tthis._genRemoteRequest();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.refreshActiveData(\"filter\");\r\n\t\t}\r\n\r\n\t\tthis.scrollHorizontal(left);\r\n\t}\r\n\r\n\t//choose the path to refresh data after a sorter update\r\n\tsorterRefresh(loadOrignalData){\r\n\t\tvar table = this.table,\r\n\t\toptions = this.table.options,\r\n\t\tleft = this.scrollLeft;\r\n\r\n\t\tif(options.ajaxSorting){\r\n\t\t\tif((options.pagination == \"remote\" || options.progressiveLoad) && table.modExists(\"page\")){\r\n\t\t\t\ttable.modules.page.reset(true);\r\n\t\t\t\ttable.modules.page.setPage(1).then(()=>{}).catch(()=>{});\r\n\t\t\t}else if(options.ajaxProgressiveLoad){\r\n\t\t\t\ttable.modules.ajax.loadData().then(()=>{}).catch(()=>{});\r\n\t\t\t}else{\r\n\t\t\t\t//assume data is url, make ajax call to url to get data\r\n\t\t\t\tthis._genRemoteRequest();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.refreshActiveData(loadOrignalData ? \"filter\" : \"sort\");\r\n\t\t}\r\n\r\n\t\tthis.scrollHorizontal(left);\r\n\t}\r\n\r\n\tscrollHorizontal(left){\r\n\t\tthis.scrollLeft = left;\r\n\t\tthis.element.scrollLeft = left;\r\n\r\n\t\tif(this.table.options.groupBy){\r\n\t\t\tthis.table.modules.groupRows.scrollHeaders(left);\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"columnCalcs\")){\r\n\t\t\tthis.table.modules.columnCalcs.scrollHorizontal(left);\r\n\t\t}\r\n\t}\r\n\r\n\t//set active data set\r\n\trefreshActiveData(stage, skipStage, renderInPosition){\r\n\t\tvar table = this.table,\r\n\t\tcascadeOrder = [\"all\", \"filter\", \"sort\", \"display\", \"freeze\", \"group\", \"tree\", \"page\"],\r\n\t\tdisplayIndex;\r\n\r\n\t\tif(this.redrawBlock){\r\n\r\n\t\t\tif(!this.redrawBlockRestoreConfig || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))){\r\n\t\t\t\tthis.redrawBlockRestoreConfig = {\r\n\t\t\t\t\tstage: stage,\r\n\t\t\t\t\tskipStage: skipStage,\r\n\t\t\t\t\trenderInPosition: renderInPosition,\r\n\t\t\t\t};\r\n\t\t\t}\r\n\r\n\t\t\treturn;\r\n\t\t}else{\r\n\r\n\t\t\tif(this.table.modExists(\"edit\")){\r\n\t\t\t\tthis.table.modules.edit.cancelEdit();\r\n\t\t\t}\r\n\r\n\t\t\tif(!stage){\r\n\t\t\t\tstage = \"all\";\r\n\t\t\t}\r\n\r\n\t\t\tif(table.options.selectable && !table.options.selectablePersistence && table.modExists(\"selectRow\")){\r\n\t\t\t\ttable.modules.selectRow.deselectRows();\r\n\t\t\t}\r\n\r\n\t\t\t//cascade through data refresh stages\r\n\t\t\tswitch(stage){\r\n\t\t\t\tcase \"all\":\r\n\r\n\t\t\t\tcase \"filter\":\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(table.modExists(\"filter\")){\r\n\t\t\t\t\t\tthis.setActiveRows(table.modules.filter.filter(this.rows));\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.setActiveRows(this.rows.slice(0));\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase \"sort\":\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(table.modExists(\"sort\")){\r\n\t\t\t\t\t\ttable.modules.sort.sort(this.activeRows);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\t//regenerate row numbers for row number formatter if in use\r\n\t\t\t\tthis.regenerateRowNumbers();\r\n\r\n\t\t\t\t//generic stage to allow for pipeline trigger after the data manipulation stage\r\n\t\t\t\tcase \"display\":\r\n\t\t\t\tthis.resetDisplayRows();\r\n\r\n\t\t\t\tcase \"freeze\":\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(this.table.modExists(\"frozenRows\")){\r\n\t\t\t\t\t\tif(table.modules.frozenRows.isFrozen()){\r\n\t\t\t\t\t\t\tif(!table.modules.frozenRows.getDisplayIndex()){\r\n\t\t\t\t\t\t\t\ttable.modules.frozenRows.setDisplayIndex(this.getNextDisplayIndex());\r\n\t\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\t\tdisplayIndex = table.modules.frozenRows.getDisplayIndex();\r\n\r\n\t\t\t\t\t\t\tdisplayIndex = this.setDisplayRows(table.modules.frozenRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);\r\n\r\n\t\t\t\t\t\t\tif(displayIndex !== true){\r\n\t\t\t\t\t\t\t\ttable.modules.frozenRows.setDisplayIndex(displayIndex);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase \"group\":\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(table.options.groupBy && table.modExists(\"groupRows\")){\r\n\r\n\t\t\t\t\t\tif(!table.modules.groupRows.getDisplayIndex()){\r\n\t\t\t\t\t\t\ttable.modules.groupRows.setDisplayIndex(this.getNextDisplayIndex());\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tdisplayIndex = table.modules.groupRows.getDisplayIndex();\r\n\r\n\t\t\t\t\t\tdisplayIndex = this.setDisplayRows(table.modules.groupRows.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);\r\n\r\n\t\t\t\t\t\tif(displayIndex !== true){\r\n\t\t\t\t\t\t\ttable.modules.groupRows.setDisplayIndex(displayIndex);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase \"tree\":\r\n\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(table.options.dataTree && table.modExists(\"dataTree\")){\r\n\t\t\t\t\t\tif(!table.modules.dataTree.getDisplayIndex()){\r\n\t\t\t\t\t\t\ttable.modules.dataTree.setDisplayIndex(this.getNextDisplayIndex());\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tdisplayIndex = table.modules.dataTree.getDisplayIndex();\r\n\r\n\t\t\t\t\t\tdisplayIndex = this.setDisplayRows(table.modules.dataTree.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);\r\n\r\n\t\t\t\t\t\tif(displayIndex !== true){\r\n\t\t\t\t\t\t\ttable.modules.dataTree.setDisplayIndex(displayIndex);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(table.options.pagination && table.modExists(\"page\") && !renderInPosition){\r\n\t\t\t\t\tif(table.modules.page.getMode() == \"local\"){\r\n\t\t\t\t\t\ttable.modules.page.reset();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcase \"page\":\r\n\t\t\t\tif(!skipStage){\r\n\t\t\t\t\tif(table.options.pagination && table.modExists(\"page\")){\r\n\r\n\t\t\t\t\t\tif(!table.modules.page.getDisplayIndex()){\r\n\t\t\t\t\t\t\ttable.modules.page.setDisplayIndex(this.getNextDisplayIndex());\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tdisplayIndex = table.modules.page.getDisplayIndex();\r\n\r\n\t\t\t\t\t\tif(table.modules.page.getMode() == \"local\"){\r\n\t\t\t\t\t\t\ttable.modules.page.setMaxRows(this.getDisplayRows(displayIndex - 1).length);\r\n\t\t\t\t\t\t}\r\n\r\n\r\n\t\t\t\t\t\tdisplayIndex = this.setDisplayRows(table.modules.page.getRows(this.getDisplayRows(displayIndex - 1)), displayIndex);\r\n\r\n\t\t\t\t\t\tif(displayIndex !== true){\r\n\t\t\t\t\t\t\ttable.modules.page.setDisplayIndex(displayIndex);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tskipStage = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif(Helpers.elVisible(this.element)){\r\n\t\t\t\tif(renderInPosition){\r\n\t\t\t\t\tthis.reRenderInPosition();\r\n\t\t\t\t}else{\r\n\r\n\t\t\t\t\tif(stage === \"all\" && this.table.options.virtualDomHoz){\r\n\t\t\t\t\t\tthis.table.vdomHoz.dataChange();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.renderTable();\r\n\r\n\t\t\t\t\tif(table.options.layoutColumnsOnNewData){\r\n\t\t\t\t\t\tthis.table.columnManager.redraw(true);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(table.modExists(\"columnCalcs\")){\r\n\t\t\t\ttable.modules.columnCalcs.recalc(this.activeRows);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//regenerate row numbers for row number formatter if in use\r\n\tregenerateRowNumbers(){\r\n\t\tif(this.rowNumColumn){\r\n\t\t\tthis.activeRows.forEach((row) => {\r\n\t\t\t\tvar cell = row.getCell(this.rowNumColumn);\r\n\r\n\t\t\t\tif(cell){\r\n\t\t\t\t\tcell._generateContents();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tsetActiveRows(activeRows){\r\n\t\tthis.activeRows = activeRows;\r\n\t\tthis.activeRowsCount = this.activeRows.length;\r\n\t}\r\n\r\n\t//reset display rows array\r\n\tresetDisplayRows(){\r\n\t\tthis.displayRows = [];\r\n\r\n\t\tthis.displayRows.push(this.activeRows.slice(0));\r\n\r\n\t\tthis.displayRowsCount = this.displayRows[0].length;\r\n\r\n\t\tif(this.table.modExists(\"frozenRows\")){\r\n\t\t\tthis.table.modules.frozenRows.setDisplayIndex(0);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\tthis.table.modules.groupRows.setDisplayIndex(0);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.pagination && this.table.modExists(\"page\")){\r\n\t\t\tthis.table.modules.page.setDisplayIndex(0);\r\n\t\t}\r\n\t}\r\n\r\n\tgetNextDisplayIndex(){\r\n\t\treturn this.displayRows.length;\r\n\t}\r\n\r\n\t//set display row pipeline data\r\n\tsetDisplayRows(displayRows, index){\r\n\r\n\t\tvar output = true;\r\n\r\n\t\tif(index && typeof this.displayRows[index] != \"undefined\"){\r\n\t\t\tthis.displayRows[index] = displayRows;\r\n\t\t\toutput = true;\r\n\t\t}else{\r\n\t\t\tthis.displayRows.push(displayRows)\r\n\t\t\toutput = index = this.displayRows.length -1;\r\n\t\t}\r\n\r\n\t\tif(index == this.displayRows.length -1){\r\n\t\t\tthis.displayRowsCount = this.displayRows[this.displayRows.length -1].length;\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetDisplayRows(index){\r\n\t\tif(typeof index == \"undefined\"){\r\n\t\t\treturn this.displayRows.length ? this.displayRows[this.displayRows.length -1] : [];\r\n\t\t}else{\r\n\t\t\treturn this.displayRows[index] || [];\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tgetVisibleRows(viewable){\r\n\t\tvar topEdge = this.element.scrollTop,\r\n\t\tbottomEdge = this.element.clientHeight + topEdge,\r\n\t\ttopFound = false,\r\n\t\ttopRow = 0,\r\n\t\tbottomRow = 0,\r\n\t\trows = this.getDisplayRows();\r\n\r\n\t\tif(viewable){\r\n\r\n\t\t\tthis.getDisplayRows();\r\n\t\t\tfor(var i = this.vDomTop; i <= this.vDomBottom; i++){\r\n\t\t\t\tif(rows[i]){\r\n\t\t\t\t\tif(!topFound){\r\n\t\t\t\t\t\tif((topEdge - rows[i].getElement().offsetTop) >= 0){\r\n\t\t\t\t\t\t\ttopRow = i;\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\ttopFound = true;\r\n\r\n\t\t\t\t\t\t\tif(bottomEdge - rows[i].getElement().offsetTop >= 0){\r\n\t\t\t\t\t\t\t\tbottomRow = i;\r\n\t\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tif(bottomEdge - rows[i].getElement().offsetTop >= 0){\r\n\t\t\t\t\t\t\tbottomRow = i;\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\ttopRow = this.vDomTop;\r\n\t\t\tbottomRow = this.vDomBottom;\r\n\t\t}\r\n\r\n\t\treturn rows.slice(topRow, bottomRow + 1);\r\n\t}\r\n\r\n\t//repeat action accross display rows\r\n\tdisplayRowIterator(callback){\r\n\t\tthis.displayRows.forEach(callback);\r\n\r\n\t\tthis.displayRowsCount = this.displayRows[this.displayRows.length -1].length;\r\n\t}\r\n\r\n\t//return only actual rows (not group headers etc)\r\n\tgetRows(active){\r\n\t\tvar rows;\r\n\r\n\t\tswitch(active){\r\n\t\t\tcase \"active\":\r\n\t\t\trows = this.activeRows;\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"display\":\r\n\t\t\trows = this.table.rowManager.getDisplayRows();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"visible\":\r\n\t\t\trows = this.getVisibleRows(true);\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"selected\":\r\n\t\t\trows = this.table.modules.selectRow.selectedRows;\r\n\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\trows = this.rows;\r\n\t\t}\r\n\r\n\t\treturn rows;\r\n\t}\r\n\r\n\t///////////////// Table Rendering /////////////////\r\n\t//trigger rerender of table in current position\r\n\treRenderInPosition(callback){\r\n\t\tif(this.getRenderMode() == \"virtual\"){\r\n\r\n\t\t\tif(this.redrawBlock){\r\n\t\t\t\tif(callback){\r\n\t\t\t\t\tcallback();\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.redrawBlockRederInPosition = true;\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tvar scrollTop = this.element.scrollTop;\r\n\t\t\t\tvar topRow = false;\r\n\t\t\t\tvar topOffset = false;\r\n\r\n\t\t\t\tvar left = this.scrollLeft;\r\n\r\n\t\t\t\tvar rows = this.getDisplayRows();\r\n\r\n\t\t\t\tfor(var i = this.vDomTop; i <= this.vDomBottom; i++){\r\n\r\n\t\t\t\t\tif(rows[i]){\r\n\t\t\t\t\t\tvar diff = scrollTop - rows[i].getElement().offsetTop;\r\n\r\n\t\t\t\t\t\tif(topOffset === false || Math.abs(diff) < topOffset){\r\n\t\t\t\t\t\t\ttopOffset = diff;\r\n\t\t\t\t\t\t\ttopRow = i;\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(callback){\r\n\t\t\t\t\tcallback();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis._virtualRenderFill((topRow === false ? this.displayRowsCount - 1 : topRow), true, topOffset || 0);\r\n\r\n\t\t\t\tthis.scrollHorizontal(left);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.renderTable();\r\n\r\n\t\t\tif(callback){\r\n\t\t\t\tcallback();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tsetRenderMode(){\r\n\r\n\t\tif(this.table.options.virtualDom){\r\n\r\n\t\t\tthis.renderMode = \"virtual\";\r\n\r\n\t\t\tif((this.table.element.clientHeight || this.table.options.height)){\r\n\t\t\t\tthis.fixedHeight = true;\r\n\t\t\t}else{\r\n\t\t\t\tthis.fixedHeight = false;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.renderMode = \"classic\";\r\n\t\t}\r\n\t}\r\n\r\n\tgetRenderMode(){\r\n\t\treturn this.renderMode;\r\n\t}\r\n\r\n\trenderTable(){\r\n\r\n\t\tthis.table.options.renderStarted.call(this.table);\r\n\r\n\t\tthis.element.scrollTop = 0;\r\n\r\n\t\tswitch(this.renderMode){\r\n\t\t\tcase \"classic\":\r\n\t\t\tthis._simpleRender();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"virtual\":\r\n\t\t\tthis._virtualRenderFill();\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tif(this.firstRender){\r\n\t\t\tif(this.displayRowsCount){\r\n\t\t\t\tthis.firstRender = false;\r\n\t\t\t\tthis.table.modules.layout.layout();\r\n\t\t\t}else{\r\n\t\t\t\tthis.renderEmptyScroll();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\tthis.table.modules.frozenColumns.layout();\r\n\t\t}\r\n\r\n\t\tif(!this.displayRowsCount){\r\n\t\t\tif(this.table.options.placeholder){\r\n\r\n\t\t\t\tthis.table.options.placeholder.setAttribute(\"tabulator-render-mode\", this.renderMode);\r\n\r\n\t\t\t\tthis.getElement().appendChild(this.table.options.placeholder);\r\n\t\t\t\tthis.table.options.placeholder.style.width = this.table.columnManager.getWidth() + \"px\";\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.table.options.renderComplete.call(this.table);\r\n\t}\r\n\r\n\t//simple render on heightless table\r\n\t_simpleRender(){\r\n\t\tthis._clearVirtualDom();\r\n\r\n\t\tif(this.displayRowsCount){\r\n\t\t\tthis.checkClassicModeGroupHeaderWidth();\r\n\t\t}else{\r\n\t\t\tthis.renderEmptyScroll();\r\n\t\t}\r\n\t}\r\n\r\n\tcheckClassicModeGroupHeaderWidth(){\r\n\t\tvar element = this.tableElement,\r\n\t\tonlyGroupHeaders = true;\r\n\r\n\t\tthis.getDisplayRows().forEach((row, index) => {\r\n\t\t\tthis.styleRow(row, index);\r\n\t\t\telement.appendChild(row.getElement());\r\n\t\t\trow.initialize(true);\r\n\r\n\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\tonlyGroupHeaders = false;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(onlyGroupHeaders){\r\n\t\t\telement.style.minWidth = this.table.columnManager.getWidth() + \"px\";\r\n\t\t}else{\r\n\t\t\telement.style.minWidth = \"\";\r\n\t\t}\r\n\t}\r\n\r\n\t//show scrollbars on empty table div\r\n\trenderEmptyScroll(){\r\n\t\tif(this.table.options.placeholder){\r\n\t\t\tthis.tableElement.style.display = \"none\";\r\n\t\t}else{\r\n\t\t\tthis.tableElement.style.minWidth = this.table.columnManager.getWidth() + \"px\";\r\n\t\t\t// this.tableElement.style.minHeight = \"1px\";\r\n\t\t\t// this.tableElement.style.visibility = \"hidden\";\r\n\t\t}\r\n\t}\r\n\r\n\t_clearVirtualDom(){\r\n\t\tvar element = this.tableElement;\r\n\r\n\t\tif(this.table.options.placeholder && this.table.options.placeholder.parentNode){\r\n\t\t\tthis.table.options.placeholder.parentNode.removeChild(this.table.options.placeholder);\r\n\t\t}\r\n\r\n\t\t// element.children.detach();\r\n\t\twhile(element.firstChild) element.removeChild(element.firstChild);\r\n\r\n\t\telement.style.paddingTop = \"\";\r\n\t\telement.style.paddingBottom = \"\";\r\n\t\telement.style.minWidth = \"\";\r\n\t\telement.style.minHeight = \"\";\r\n\t\telement.style.display = \"\";\r\n\t\telement.style.visibility = \"\";\r\n\r\n\t\tthis.scrollTop = 0;\r\n\t\tthis.scrollLeft = 0;\r\n\t\tthis.vDomTop = 0;\r\n\t\tthis.vDomBottom = 0;\r\n\t\tthis.vDomTopPad = 0;\r\n\t\tthis.vDomBottomPad = 0;\r\n\t}\r\n\r\n\tstyleRow(row, index){\r\n\t\tvar rowEl = row.getElement();\r\n\r\n\t\tif(index % 2){\r\n\t\t\trowEl.classList.add(\"tabulator-row-even\");\r\n\t\t\trowEl.classList.remove(\"tabulator-row-odd\");\r\n\t\t}else{\r\n\t\t\trowEl.classList.add(\"tabulator-row-odd\");\r\n\t\t\trowEl.classList.remove(\"tabulator-row-even\");\r\n\t\t}\r\n\t}\r\n\r\n\t//full virtual render\r\n\t_virtualRenderFill(position, forceMove, offset){\r\n\t\tvar\telement = this.tableElement,\r\n\t\tholder = this.element,\r\n\t\ttopPad = 0,\r\n\t\trowsHeight = 0,\r\n\t\ttopPadHeight = 0,\r\n\t\ti = 0,\r\n\t\tonlyGroupHeaders = true,\r\n\t\trows = this.getDisplayRows();\r\n\r\n\t\tposition = position || 0;\r\n\r\n\t\toffset = offset || 0;\r\n\r\n\t\tif(!position){\r\n\t\t\tthis._clearVirtualDom();\r\n\t\t}else{\r\n\t\t\twhile(element.firstChild) element.removeChild(element.firstChild);\r\n\r\n\t\t\t//check if position is too close to bottom of table\r\n\t\t\tlet heightOccupied = (this.displayRowsCount - position + 1) * this.vDomRowHeight;\r\n\r\n\t\t\tif(heightOccupied < this.height){\r\n\t\t\t\tposition -= Math.ceil((this.height - heightOccupied ) / this.vDomRowHeight);\r\n\r\n\t\t\t\tif(position < 0){\r\n\t\t\t\t\tposition = 0;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//calculate initial pad\r\n\t\t\ttopPad = Math.min(Math.max(Math.floor(this.vDomWindowBuffer / this.vDomRowHeight), this.vDomWindowMinMarginRows), position);\r\n\t\t\tposition -= topPad;\r\n\t\t}\r\n\r\n\t\tif(this.displayRowsCount && Helpers.elVisible(this.element)){\r\n\t\t\tthis.vDomTop = position;\r\n\r\n\t\t\tthis.vDomBottom = position -1;\r\n\r\n\t\t\twhile ((rowsHeight <= this.height + this.vDomWindowBuffer || i < this.vDomWindowMinTotalRows) && this.vDomBottom < this.displayRowsCount -1){\r\n\t\t\t\tvar index = this.vDomBottom + 1,\r\n\t\t\t\trow = rows[index],\r\n\t\t\t\trowHeight = 0;\r\n\r\n\t\t\t\tthis.styleRow(row, index);\r\n\r\n\t\t\t\telement.appendChild(row.getElement());\r\n\r\n\t\t\t\trow.initialize();\r\n\r\n\t\t\t\tif(!row.heightInitialized){\r\n\t\t\t\t\trow.normalizeHeight(true);\r\n\t\t\t\t}\r\n\r\n\t\t\t\trowHeight = row.getHeight();\r\n\r\n\t\t\t\tif(i < topPad){\r\n\t\t\t\t\ttopPadHeight += rowHeight;\r\n\t\t\t\t}else{\r\n\t\t\t\t\trowsHeight += rowHeight;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(rowHeight > this.vDomWindowBuffer){\r\n\t\t\t\t\tthis.vDomWindowBuffer = rowHeight * 2;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\t\tonlyGroupHeaders = false;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.vDomBottom ++;\r\n\t\t\t\ti++;\r\n\t\t\t}\r\n\r\n\t\t\tif(!position){\r\n\t\t\t\tthis.vDomTopPad = 0;\r\n\t\t\t\t//adjust rowheight to match average of rendered elements\r\n\t\t\t\tthis.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / i);\r\n\t\t\t\tthis.vDomBottomPad = this.vDomRowHeight * (this.displayRowsCount - this.vDomBottom -1);\r\n\r\n\t\t\t\tthis.vDomScrollHeight = topPadHeight + rowsHeight + this.vDomBottomPad - this.height;\r\n\t\t\t}else{\r\n\t\t\t\tthis.vDomTopPad = !forceMove ? this.scrollTop - topPadHeight : (this.vDomRowHeight * this.vDomTop) + offset;\r\n\t\t\t\tthis.vDomBottomPad = this.vDomBottom == this.displayRowsCount-1 ? 0 : Math.max(this.vDomScrollHeight - this.vDomTopPad - rowsHeight - topPadHeight, 0);\r\n\t\t\t}\r\n\r\n\t\t\telement.style.paddingTop = this.vDomTopPad + \"px\";\r\n\t\t\telement.style.paddingBottom = this.vDomBottomPad + \"px\";\r\n\r\n\t\t\tif(forceMove){\r\n\t\t\t\tthis.scrollTop = this.vDomTopPad + (topPadHeight) + offset - (this.element.scrollWidth > this.element.clientWidth ? this.element.offsetHeight - this.element.clientHeight : 0);\r\n\t\t\t}\r\n\r\n\t\t\tthis.scrollTop = Math.min(this.scrollTop, this.element.scrollHeight - this.height);\r\n\r\n\t\t\t//adjust for horizontal scrollbar if present (and not at top of table)\r\n\t\t\tif(this.element.scrollWidth > this.element.offsetWidth && forceMove){\r\n\t\t\t\tthis.scrollTop += this.element.offsetHeight - this.element.clientHeight;\r\n\t\t\t}\r\n\r\n\t\t\tthis.vDomScrollPosTop = this.scrollTop;\r\n\t\t\tthis.vDomScrollPosBottom = this.scrollTop;\r\n\r\n\t\t\tholder.scrollTop = this.scrollTop;\r\n\r\n\t\t\telement.style.minWidth = onlyGroupHeaders ? this.table.columnManager.getWidth() + \"px\" : \"\";\r\n\r\n\t\t\tif(this.table.options.groupBy){\r\n\t\t\t\tif(this.table.modules.layout.getMode() != \"fitDataFill\" && this.displayRowsCount == this.table.modules.groupRows.countGroups()){\r\n\t\t\t\t\tthis.tableElement.style.minWidth = this.table.columnManager.getWidth();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.renderEmptyScroll();\r\n\t\t}\r\n\r\n\t\tif(!this.fixedHeight){\r\n\t\t\tthis.adjustTableSize();\r\n\t\t}\r\n\t}\r\n\r\n\t//handle vertical scrolling\r\n\tscrollVertical(dir){\r\n\t\tvar topDiff = this.scrollTop - this.vDomScrollPosTop;\r\n\t\tvar bottomDiff = this.scrollTop - this.vDomScrollPosBottom;\r\n\t\tvar margin = this.vDomWindowBuffer * 2;\r\n\r\n\t\tif(-topDiff > margin || bottomDiff > margin){\r\n\t\t\t//if big scroll redraw table;\r\n\t\t\tvar left = this.scrollLeft;\r\n\t\t\tthis._virtualRenderFill(Math.floor((this.element.scrollTop / this.element.scrollHeight) * this.displayRowsCount));\r\n\t\t\tthis.scrollHorizontal(left);\r\n\t\t}else{\r\n\r\n\t\t\tif(dir){\r\n\t\t\t\t//scrolling up\r\n\t\t\t\tif(topDiff < 0){\r\n\r\n\t\t\t\t\tthis._addTopRow(-topDiff);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(bottomDiff < 0){\r\n\r\n\t\t\t\t\t//hide bottom row if needed\r\n\t\t\t\t\tif(this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer){\r\n\t\t\t\t\t\tthis._removeBottomRow(-bottomDiff);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.vDomScrollPosBottom = this.scrollTop;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\t//scrolling down\r\n\t\t\t\tif(topDiff >= 0){\r\n\r\n\t\t\t\t\t//hide top row if needed\r\n\t\t\t\t\tif(this.scrollTop > this.vDomWindowBuffer){\r\n\r\n\t\t\t\t\t\tthis._removeTopRow(topDiff);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.vDomScrollPosTop = this.scrollTop;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(bottomDiff >= 0){\r\n\r\n\t\t\t\t\tthis._addBottomRow(bottomDiff);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_addTopRow(topDiff, i=0){\r\n\t\tvar table = this.tableElement,\r\n\t\trows = this.getDisplayRows();\r\n\r\n\t\tif(this.vDomTop){\r\n\t\t\tlet index = this.vDomTop -1,\r\n\t\t\ttopRow = rows[index],\r\n\t\t\ttopRowHeight = topRow.getHeight() || this.vDomRowHeight;\r\n\r\n\t\t\t//hide top row if needed\r\n\t\t\tif(topDiff >= topRowHeight){\r\n\t\t\t\tthis.styleRow(topRow, index);\r\n\t\t\t\ttable.insertBefore(topRow.getElement(), table.firstChild);\r\n\t\t\t\tif(!topRow.initialized || !topRow.heightInitialized){\r\n\t\t\t\t\tthis.vDomTopNewRows.push(topRow);\r\n\r\n\t\t\t\t\tif(!topRow.heightInitialized){\r\n\t\t\t\t\t\ttopRow.clearCellHeight();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\ttopRow.initialize();\r\n\r\n\t\t\t\tthis.vDomTopPad -= topRowHeight;\r\n\r\n\t\t\t\tif(this.vDomTopPad < 0){\r\n\t\t\t\t\tthis.vDomTopPad = index * this.vDomRowHeight;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(!index){\r\n\t\t\t\t\tthis.vDomTopPad = 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttable.style.paddingTop = this.vDomTopPad + \"px\";\r\n\t\t\t\tthis.vDomScrollPosTop -= topRowHeight;\r\n\t\t\t\tthis.vDomTop--;\r\n\t\t\t}\r\n\r\n\t\t\ttopDiff = -(this.scrollTop - this.vDomScrollPosTop);\r\n\r\n\t\t\tif(topRow.getHeight() > this.vDomWindowBuffer){\r\n\t\t\t\tthis.vDomWindowBuffer = topRow.getHeight() * 2;\r\n\t\t\t}\r\n\r\n\t\t\tif(i < this.vDomMaxRenderChain && this.vDomTop && topDiff >= (rows[this.vDomTop -1].getHeight() || this.vDomRowHeight)){\r\n\t\t\t\tthis._addTopRow(topDiff, i+1);\r\n\t\t\t}else{\r\n\t\t\t\tthis._quickNormalizeRowHeight(this.vDomTopNewRows);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_removeTopRow(topDiff){\r\n\t\tvar table = this.tableElement,\r\n\t\ttopRow = this.getDisplayRows()[this.vDomTop],\r\n\t\ttopRowHeight = topRow.getHeight() || this.vDomRowHeight;\r\n\r\n\t\tif(topDiff >= topRowHeight){\r\n\r\n\t\t\tvar rowEl = topRow.getElement();\r\n\t\t\trowEl.parentNode.removeChild(rowEl);\r\n\r\n\t\t\tthis.vDomTopPad += topRowHeight;\r\n\t\t\ttable.style.paddingTop = this.vDomTopPad + \"px\";\r\n\t\t\tthis.vDomScrollPosTop += this.vDomTop ? topRowHeight : topRowHeight + this.vDomWindowBuffer;\r\n\t\t\tthis.vDomTop++;\r\n\r\n\t\t\ttopDiff = this.scrollTop - this.vDomScrollPosTop;\r\n\r\n\t\t\tthis._removeTopRow(topDiff);\r\n\t\t}\r\n\t}\r\n\r\n\t_addBottomRow(bottomDiff, i=0){\r\n\t\tvar table = this.tableElement,\r\n\t\trows = this.getDisplayRows();\r\n\r\n\t\tif(this.vDomBottom < this.displayRowsCount -1){\r\n\t\t\tlet index = this.vDomBottom + 1,\r\n\t\t\tbottomRow = rows[index],\r\n\t\t\tbottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;\r\n\r\n\t\t\t//hide bottom row if needed\r\n\t\t\tif(bottomDiff >= bottomRowHeight){\r\n\t\t\t\tthis.styleRow(bottomRow, index);\r\n\t\t\t\ttable.appendChild(bottomRow.getElement());\r\n\r\n\t\t\t\tif(!bottomRow.initialized || !bottomRow.heightInitialized){\r\n\t\t\t\t\tthis.vDomBottomNewRows.push(bottomRow);\r\n\r\n\t\t\t\t\tif(!bottomRow.heightInitialized){\r\n\t\t\t\t\t\tbottomRow.clearCellHeight();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbottomRow.initialize();\r\n\r\n\t\t\t\tthis.vDomBottomPad -= bottomRowHeight;\r\n\r\n\t\t\t\tif(this.vDomBottomPad < 0 || index == this.displayRowsCount -1){\r\n\t\t\t\t\tthis.vDomBottomPad = 0;\r\n\t\t\t\t}\r\n\r\n\t\t\t\ttable.style.paddingBottom = this.vDomBottomPad + \"px\";\r\n\t\t\t\tthis.vDomScrollPosBottom += bottomRowHeight;\r\n\t\t\t\tthis.vDomBottom++;\r\n\t\t\t}\r\n\r\n\t\t\tbottomDiff = this.scrollTop - this.vDomScrollPosBottom;\r\n\r\n\t\t\tif(bottomRow.getHeight() > this.vDomWindowBuffer){\r\n\t\t\t\tthis.vDomWindowBuffer = bottomRow.getHeight() * 2;\r\n\t\t\t}\r\n\r\n\t\t\tif(i < this.vDomMaxRenderChain && this.vDomBottom < this.displayRowsCount -1 && bottomDiff >= (rows[this.vDomBottom + 1].getHeight() || this.vDomRowHeight)){\r\n\t\t\t\tthis._addBottomRow(bottomDiff, i+1);\r\n\t\t\t}else{\r\n\t\t\t\tthis._quickNormalizeRowHeight(this.vDomBottomNewRows);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t_removeBottomRow(bottomDiff){\r\n\t\tvar table = this.tableElement,\r\n\t\tbottomRow = this.getDisplayRows()[this.vDomBottom],\r\n\t\tbottomRowHeight = bottomRow.getHeight() || this.vDomRowHeight;\r\n\r\n\t\tif(bottomDiff >= bottomRowHeight){\r\n\r\n\t\t\tvar rowEl = bottomRow.getElement();\r\n\r\n\t\t\tif(rowEl.parentNode){\r\n\t\t\t\trowEl.parentNode.removeChild(rowEl);\r\n\t\t\t}\r\n\r\n\t\t\tthis.vDomBottomPad += bottomRowHeight;\r\n\r\n\t\t\tif(this.vDomBottomPad < 0){\r\n\t\t\t\tthis.vDomBottomPad = 0;\r\n\t\t\t}\r\n\r\n\t\t\ttable.style.paddingBottom = this.vDomBottomPad + \"px\";\r\n\t\t\tthis.vDomScrollPosBottom -= bottomRowHeight;\r\n\t\t\tthis.vDomBottom--;\r\n\r\n\t\t\tbottomDiff = -(this.scrollTop - this.vDomScrollPosBottom);\r\n\r\n\t\t\tthis._removeBottomRow(bottomDiff);\r\n\t\t}\r\n\t}\r\n\r\n\t_quickNormalizeRowHeight(rows){\r\n\t\trows.forEach(function(row){\r\n\t\t\trow.calcHeight();\r\n\t\t});\r\n\r\n\t\trows.forEach(function(row){\r\n\t\t\trow.setCellHeight();\r\n\t\t});\r\n\r\n\t\trows.length = 0;\r\n\t}\r\n\r\n\t//normalize height of active rows\r\n\tnormalizeHeight(){\r\n\t\tthis.activeRows.forEach(function(row){\r\n\t\t\trow.normalizeHeight();\r\n\t\t});\r\n\t}\r\n\r\n\t//adjust the height of the table holder to fit in the Tabulator element\r\n\tadjustTableSize(){\r\n\t\tvar initialHeight = this.element.clientHeight,\r\n\t\tmodExists;\r\n\r\n\t\tif(this.renderMode === \"virtual\"){\r\n\r\n\t\t\tlet otherHeight = Math.floor(this.columnManager.getElement().getBoundingClientRect().height + (this.table.footerManager && this.table.footerManager.active && !this.table.footerManager.external ? this.table.footerManager.getElement().getBoundingClientRect().height : 0));\r\n\r\n\t\t\tif(this.fixedHeight){\r\n\t\t\t\tthis.element.style.minHeight = \"calc(100% - \" + otherHeight + \"px)\";\r\n\t\t\t\tthis.element.style.height = \"calc(100% - \" + otherHeight + \"px)\";\r\n\t\t\t\tthis.element.style.maxHeight = \"calc(100% - \" + otherHeight + \"px)\";\r\n\t\t\t}else{\r\n\t\t\t\tthis.element.style.height = \"\";\r\n\t\t\t\tthis.element.style.height = (this.table.element.clientHeight - otherHeight) + \"px\";\r\n\t\t\t\tthis.element.scrollTop = this.scrollTop;\r\n\t\t\t}\r\n\r\n\t\t\tthis.height = this.element.clientHeight;\r\n\t\t\tthis.vDomWindowBuffer = this.table.options.virtualDomBuffer || this.height;\r\n\r\n\t\t\t//check if the table has changed size when dealing with variable height tables\r\n\t\t\tif(!this.fixedHeight && initialHeight != this.element.clientHeight){\r\n\t\t\t\tmodExists = this.table.modExists(\"resizeTable\");\r\n\r\n\t\t\t\tif((modExists && !this.table.modules.resizeTable.autoResize) || !modExists){\r\n\t\t\t\t\tthis.redraw();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\t}\r\n\r\n\t//renitialize all rows\r\n\treinitialize(){\r\n\t\tthis.rows.forEach(function(row){\r\n\t\t\trow.reinitialize(true);\r\n\t\t});\r\n\t}\r\n\r\n\t//prevent table from being redrawn\r\n\tblockRedraw (){\r\n\t\tthis.redrawBlock = true;\r\n\t\tthis.redrawBlockRestoreConfig = false;\r\n\t}\r\n\r\n\t//restore table redrawing\r\n\trestoreRedraw (){\r\n\t\tthis.redrawBlock = false;\r\n\r\n\t\tif(this.redrawBlockRestoreConfig){\r\n\t\t\tthis.refreshActiveData(this.redrawBlockRestoreConfig.stage, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition)\r\n\r\n\t\t\tthis.redrawBlockRestoreConfig = false;\r\n\t\t}else{\r\n\t\t\tif(this.redrawBlockRederInPosition){\r\n\t\t\t\tthis.reRenderInPosition();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.redrawBlockRederInPosition = false;\r\n\t}\r\n\r\n\t//redraw table\r\n\tredraw (force){\r\n\t\tvar pos = 0,\r\n\t\tleft = this.scrollLeft;\r\n\r\n\t\tthis.adjustTableSize();\r\n\r\n\t\tthis.table.tableWidth = this.table.element.clientWidth;\r\n\r\n\t\tif(!force){\r\n\t\t\tif(this.renderMode == \"classic\"){\r\n\r\n\t\t\t\tif(this.table.options.groupBy){\r\n\t\t\t\t\tthis.refreshActiveData(\"group\", false, false);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis._simpleRender();\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\tthis.reRenderInPosition();\r\n\t\t\t\tthis.scrollHorizontal(left);\r\n\t\t\t}\r\n\r\n\t\t\tif(!this.displayRowsCount){\r\n\t\t\t\tif(this.table.options.placeholder){\r\n\t\t\t\t\tthis.getElement().appendChild(this.table.options.placeholder);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}else{\r\n\t\t\tthis.renderTable();\r\n\t\t}\r\n\t}\r\n\r\n\tresetScroll(){\r\n\t\tthis.element.scrollLeft = 0;\r\n\t\tthis.element.scrollTop = 0;\r\n\r\n\t\tif(this.table.browser === \"ie\"){\r\n\t\t\tvar event = document.createEvent(\"Event\");\r\n\t\t\tevent.initEvent(\"scroll\", false, true);\r\n\t\t\tthis.element.dispatchEvent(event);\r\n\t\t}else{\r\n\t\t\tthis.element.dispatchEvent(new Event('scroll'));\r\n\t\t}\r\n\t}\r\n}","export default class FooterManager {\r\n\r\n\tconstructor(table){\r\n\t\tthis.table = table;\r\n\t\tthis.active = false;\r\n\t\tthis.element = this.createElement(); //containing element\r\n\t\tthis.external = false;\r\n\t\tthis.links = [];\r\n\r\n\t\tthis._initialize();\r\n\t}\r\n\r\n\tcreateElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-footer\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\t_initialize(element){\r\n\t\tif(this.table.options.footerElement){\r\n\r\n\t\t\tswitch(typeof this.table.options.footerElement){\r\n\t\t\t\tcase \"string\":\r\n\t\t\t\tif(this.table.options.footerElement[0] === \"<\"){\r\n\t\t\t\t\tthis.element.innerHTML = this.table.options.footerElement;\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.external = true;\r\n\t\t\t\t\tthis.element = document.querySelector(this.table.options.footerElement);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tdefault:\r\n\t\t\t\tthis.element = this.table.options.footerElement;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\treturn this.element;\r\n\t}\r\n\r\n\tappend(element, parent){\r\n\t\tthis.activate(parent);\r\n\r\n\t\tthis.element.appendChild(element);\r\n\t\tthis.table.rowManager.adjustTableSize();\r\n\t}\r\n\r\n\tprepend(element, parent){\r\n\t\tthis.activate(parent);\r\n\r\n\t\tthis.element.insertBefore(element, this.element.firstChild);\r\n\t\tthis.table.rowManager.adjustTableSize();\r\n\t}\r\n\r\n\tremove(element){\r\n\t\telement.parentNode.removeChild(element);\r\n\t\tthis.deactivate();\r\n\t}\r\n\r\n\tdeactivate(force){\r\n\t\tif(!this.element.firstChild || force){\r\n\t\t\tif(!this.external){\r\n\t\t\t\tthis.element.parentNode.removeChild(this.element);\r\n\t\t\t}\r\n\t\t\tthis.active = false;\r\n\t\t}\r\n\t}\r\n\r\n\tactivate(parent){\r\n\t\tif(!this.active){\r\n\t\t\tthis.active = true;\r\n\t\t\tif(!this.external){\r\n\t\t\t\tthis.table.element.appendChild(this.getElement());\r\n\t\t\t\tthis.table.element.style.display = '';\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(parent){\r\n\t\t\tthis.links.push(parent);\r\n\t\t}\r\n\t}\r\n\r\n\tredraw(){\r\n\t\tthis.links.forEach(function(link){\r\n\t\t\tlink.footerRedraw();\r\n\t\t});\r\n\t}\r\n}","import Tabulator from './Tabulator.js';\r\n\r\nclass TableRegistry {\r\n\r\n\tstatic register(table){\r\n\t\tTableRegistry.tables.push(table);\r\n\t}\r\n\r\n\tstatic deregister(table){\r\n\t\tvar index = TableRegistry.tables.indexOf(table);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tTableRegistry.tables.splice(index, 1);\r\n\t\t}\r\n\t}\r\n\r\n\tstatic lookupTable(query, silent){\r\n\t\tvar results = [],\r\n\t\tmatches, match;\r\n\r\n\t\tif(typeof query === \"string\"){\r\n\t\t\tmatches = document.querySelectorAll(query);\r\n\r\n\t\t\tif(matches.length){\r\n\t\t\t\tfor(var i = 0; i < matches.length; i++){\r\n\t\t\t\t\tmatch = TableRegistry.matchElement(matches[i]);\r\n\r\n\t\t\t\t\tif(match){\r\n\t\t\t\t\t\tresults.push(match);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}else if((typeof HTMLElement !== \"undefined\" && query instanceof HTMLElement) || query instanceof Tabulator){\r\n\t\t\tmatch = TableRegistry.matchElement(query);\r\n\r\n\t\t\tif(match){\r\n\t\t\t\tresults.push(match);\r\n\t\t\t}\r\n\t\t}else if(Array.isArray(query)){\r\n\t\t\tquery.forEach(function(item){\r\n\t\t\t\tresults = results.concat(TableRegistry.lookupTable(item));\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tif(!silent){\r\n\t\t\t\tconsole.warn(\"Table Connection Error - Invalid Selector\", query);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn results;\r\n\t}\r\n\r\n\tstatic matchElement(element){\r\n\t\treturn TableRegistry.tables.find(function(table){\r\n\t\t\treturn element instanceof Tabulator ? table === element : table.element === element;\r\n\t\t});\r\n\t}\r\n}\r\n\r\nTableRegistry.tables = [];\r\n\r\nexport default TableRegistry;","class Module{\r\n\r\n\tconstructor(table, name){\r\n\t\tthis.table = table;\r\n\t}\r\n\r\n\tregister(){\r\n\t}\r\n}\r\n\r\nexport default Module;","//resize columns to fit data they contain\r\nexport default function(columns){\r\n\tif(this.table.options.virtualDomHoz){\r\n\t\tthis.table.vdomHoz.fitDataLayoutOverride();\r\n\t}else{\r\n\t\tcolumns.forEach(function(column){\r\n\t\t\tcolumn.reinitializeWidth();\r\n\t\t});\r\n\t}\r\n\r\n\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\tthis.table.modules.responsiveLayout.update();\r\n\t}\r\n};","//resize columns to fit data they contain and stretch row to fill table, also used for fitDataTable\r\nexport default function(columns){\r\n\tcolumns.forEach(function(column){\r\n\t\tcolumn.reinitializeWidth();\r\n\t});\r\n\r\n\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\tthis.table.modules.responsiveLayout.update();\r\n\t}\r\n};","//resize columns to fit data the contain and stretch last column to fill table\r\nexport default function(columns){\r\n\tvar colsWidth = 0,\r\n\ttableWidth = this.table.rowManager.element.clientWidth,\r\n\tgap = 0,\r\n\tlastCol = false;\r\n\r\n\tcolumns.forEach((column, i) => {\r\n\t\tif(!column.widthFixed){\r\n\t\t\tcolumn.reinitializeWidth();\r\n\t\t}\r\n\r\n\t\tif(this.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible){\r\n\t\t\tlastCol = column;\r\n\t\t}\r\n\r\n\t\tif(column.visible){\r\n\t\t\tcolsWidth += column.getWidth();\r\n\t\t}\r\n\t});\r\n\r\n\tif(lastCol){\r\n\t\tgap = tableWidth - colsWidth + lastCol.getWidth();\r\n\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tlastCol.setWidth(0);\r\n\t\t\tthis.table.modules.responsiveLayout.update();\r\n\t\t}\r\n\r\n\t\tif(gap > 0){\r\n\t\t\tlastCol.setWidth(gap);\r\n\t\t}else{\r\n\t\t\tlastCol.reinitializeWidth();\r\n\t\t}\r\n\t}else{\r\n\t\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\t\tthis.table.modules.responsiveLayout.update();\r\n\t\t}\r\n\t}\r\n};","//resize columns to fit\r\nexport default function(columns){\r\n\tvar totalWidth = this.table.element.clientWidth; //table element width\r\n\tvar fixedWidth = 0; //total width of columns with a defined width\r\n\tvar flexWidth = 0; //total width available to flexible columns\r\n\tvar flexGrowUnits = 0; //total number of widthGrow blocks accross all columns\r\n\tvar flexColWidth = 0; //desired width of flexible columns\r\n\tvar flexColumns = []; //array of flexible width columns\r\n\tvar fixedShrinkColumns = []; //array of fixed width columns that can shrink\r\n\tvar flexShrinkUnits = 0; //total number of widthShrink blocks accross all columns\r\n\tvar overflowWidth = 0; //horizontal overflow width\r\n\tvar gapFill=0; //number of pixels to be added to final column to close and half pixel gaps\r\n\r\n\tfunction calcWidth(width){\r\n\t\tvar colWidth;\r\n\r\n\t\tif(typeof(width) == \"string\"){\r\n\t\t\tif(width.indexOf(\"%\") > -1){\r\n\t\t\t\tcolWidth = (totalWidth / 100) * parseInt(width);\r\n\t\t\t}else{\r\n\t\t\t\tcolWidth = parseInt(width);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tcolWidth = width;\r\n\t\t}\r\n\r\n\t\treturn colWidth;\r\n\t}\r\n\r\n\t//ensure columns resize to take up the correct amount of space\r\n\tfunction scaleColumns(columns, freeSpace, colWidth, shrinkCols){\r\n\r\n\t\tvar oversizeCols = [],\r\n\t\toversizeSpace = 0,\r\n\t\tremainingSpace = 0,\r\n\t\tnextColWidth = 0,\r\n\t\tremainingFlexGrowUnits = flexGrowUnits,\r\n\t\tgap = 0,\r\n\t\tchangeUnits = 0,\r\n\t\tundersizeCols = [];\r\n\r\n\t\tfunction calcGrow(col){\r\n\t\t\treturn (colWidth * (col.column.definition.widthGrow || 1));\r\n\t\t}\r\n\r\n\t\tfunction calcShrink(col){\r\n\t\t\treturn (calcWidth(col.width) - (colWidth * (col.column.definition.widthShrink || 0)))\r\n\t\t}\r\n\r\n\t\tcolumns.forEach(function(col, i){\r\n\t\t\tvar width = shrinkCols ? calcShrink(col) : calcGrow(col);\r\n\t\t\tif(col.column.minWidth >= width){\r\n\t\t\t\toversizeCols.push(col);\r\n\t\t\t}else{\r\n\t\t\t\tif(col.column.maxWidth && col.column.maxWidth < width){\r\n\t\t\t\t\tcol.width = col.column.maxWidth;\r\n\t\t\t\t\tfreeSpace -= col.column.maxWidth;\r\n\r\n\t\t\t\t\tremainingFlexGrowUnits -= shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);\r\n\r\n\t\t\t\t\tif(remainingFlexGrowUnits){\r\n\t\t\t\t\t\tcolWidth = Math.floor(freeSpace/remainingFlexGrowUnits);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tundersizeCols.push(col);\r\n\t\t\t\t\tchangeUnits += shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(oversizeCols.length){\r\n\t\t\toversizeCols.forEach(function(col){\r\n\t\t\t\toversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;\r\n\t\t\t\tcol.width = col.column.minWidth;\r\n\t\t\t});\r\n\r\n\t\t\tremainingSpace = freeSpace - oversizeSpace;\r\n\r\n\t\t\tnextColWidth = changeUnits ? Math.floor(remainingSpace/changeUnits) : remainingSpace;\r\n\r\n\t\t\tgap = remainingSpace - (nextColWidth * changeUnits);\r\n\r\n\t\t\tgap += scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);\r\n\t\t}else{\r\n\t\t\tgap = changeUnits ? freeSpace - (Math.floor(freeSpace/changeUnits) * changeUnits) : freeSpace;\r\n\r\n\t\t\tundersizeCols.forEach(function(column){\r\n\t\t\t\tcolumn.width = shrinkCols ? calcShrink(column) : calcGrow(column);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn gap;\r\n\t}\r\n\r\n\tif(this.table.options.responsiveLayout && this.table.modExists(\"responsiveLayout\", true)){\r\n\t\tthis.table.modules.responsiveLayout.update();\r\n\t}\r\n\r\n\t//adjust for vertical scrollbar if present\r\n\tif(this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight){\r\n\t\ttotalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;\r\n\t}\r\n\r\n\tcolumns.forEach(function(column){\r\n\t\tvar width, minWidth, colWidth;\r\n\r\n\t\tif(column.visible){\r\n\r\n\t\t\twidth = column.definition.width;\r\n\t\t\tminWidth = parseInt(column.minWidth);\r\n\r\n\t\t\tif(width){\r\n\r\n\t\t\t\tcolWidth = calcWidth(width);\r\n\r\n\t\t\t\tfixedWidth += colWidth > minWidth ? colWidth : minWidth;\r\n\r\n\t\t\t\tif(column.definition.widthShrink){\r\n\t\t\t\t\tfixedShrinkColumns.push({\r\n\t\t\t\t\t\tcolumn:column,\r\n\t\t\t\t\t\twidth:colWidth > minWidth ? colWidth : minWidth\r\n\t\t\t\t\t});\r\n\t\t\t\t\tflexShrinkUnits += column.definition.widthShrink;\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\tflexColumns.push({\r\n\t\t\t\t\tcolumn:column,\r\n\t\t\t\t\twidth:0,\r\n\t\t\t\t});\r\n\t\t\t\tflexGrowUnits += column.definition.widthGrow || 1;\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\r\n\t//calculate available space\r\n\tflexWidth = totalWidth - fixedWidth;\r\n\r\n\t//calculate correct column size\r\n\tflexColWidth = Math.floor(flexWidth / flexGrowUnits)\r\n\r\n\t//generate column widths\r\n\tvar gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false);\r\n\r\n\t//increase width of last column to account for rounding errors\r\n\tif(flexColumns.length && gapFill > 0){\r\n\t\tflexColumns[flexColumns.length-1].width += + gapFill;\r\n\t}\r\n\r\n\t//caculate space for columns to be shrunk into\r\n\tflexColumns.forEach(function(col){\r\n\t\tflexWidth -= col.width;\r\n\t});\r\n\r\n\toverflowWidth = Math.abs(gapFill) + flexWidth;\r\n\r\n\t//shrink oversize columns if there is no available space\r\n\tif(overflowWidth > 0 && flexShrinkUnits){\r\n\t\tgapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true);\r\n\t}\r\n\r\n\t//decrease width of last column to account for rounding errors\r\n\tif(fixedShrinkColumns.length){\r\n\t\tfixedShrinkColumns[fixedShrinkColumns.length-1].width -= gapFill;\r\n\t}\r\n\r\n\tflexColumns.forEach(function(col){\r\n\t\tcol.column.setWidth(col.width);\r\n\t});\r\n\r\n\tfixedShrinkColumns.forEach(function(col){\r\n\t\tcol.column.setWidth(col.width);\r\n\t});\r\n};","import fitData from './modes/fitData.js';\r\nimport fitDataGeneral from './modes/fitDataGeneral.js';\r\nimport fitDataStretch from './modes/fitDataStretch.js';\r\nimport fitColumns from './modes/fitColumns.js';\r\n\r\nexport default {\r\n\tfitData:fitData,\r\n\tfitDataFill:fitDataGeneral,\r\n\tfitDataTable:fitDataGeneral,\r\n\tfitDataStretch:fitDataStretch,\r\n\tfitColumns:fitColumns ,\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport defaultModes from './defaults/modes.js';\r\n\r\nclass Layout extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table, \"layout\");\r\n\r\n\t\tthis.mode = null;\r\n\t}\r\n\r\n\t//initialize layout system\r\n\tinitialize(layout){\r\n\t\tif(Layout.modes[layout]){\r\n\t\t\tthis.mode = layout;\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Layout Error - invalid mode set, defaulting to 'fitData' : \" + layout);\r\n\t\t\tthis.mode = 'fitData';\r\n\t\t}\r\n\r\n\t\tthis.table.element.setAttribute(\"tabulator-layout\", this.mode);\r\n\t}\r\n\r\n\tgetMode(){\r\n\t\treturn this.mode;\r\n\t}\r\n\r\n\t//trigger table layout\r\n\tlayout(){\r\n\t\tLayout.modes[this.mode].call(this, this.table.columnManager.columnsByIndex);\r\n\r\n\t\tif(this.mode.indexOf(\"fitData\") === 0 && this.table.options.persistence && this.table.modExists(\"persistence\", true) && this.table.modules.persistence.config.columns){\r\n\t\t\tthis.table.modules.persistence.save(\"columns\");\r\n\t\t}\r\n\t}\r\n}\r\n\r\nLayout.moduleName = \"layout\";\r\n\r\n//load defaults\r\nLayout.modes = defaultModes;\r\n\r\nexport default Layout;","export default {\r\n\t\"default\":{ //hold default locale text\r\n\t\t\"groups\":{\r\n\t\t\t\"item\":\"item\",\r\n\t\t\t\"items\":\"items\",\r\n\t\t},\r\n\t\t\"columns\":{\r\n\t\t},\r\n\t\t\"ajax\":{\r\n\t\t\t\"loading\":\"Loading\",\r\n\t\t\t\"error\":\"Error\",\r\n\t\t},\r\n\t\t\"pagination\":{\r\n\t\t\t\"page_size\":\"Page Size\",\r\n\t\t\t\"page_title\":\"Show Page\",\r\n\t\t\t\"first\":\"First\",\r\n\t\t\t\"first_title\":\"First Page\",\r\n\t\t\t\"last\":\"Last\",\r\n\t\t\t\"last_title\":\"Last Page\",\r\n\t\t\t\"prev\":\"Prev\",\r\n\t\t\t\"prev_title\":\"Prev Page\",\r\n\t\t\t\"next\":\"Next\",\r\n\t\t\t\"next_title\":\"Next Page\",\r\n\t\t\t\"all\":\"All\",\r\n\t\t},\r\n\t\t\"headerFilters\":{\r\n\t\t\t\"default\":\"filter column...\",\r\n\t\t\t\"columns\":{}\r\n\t\t}\r\n\t},\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport Helpers from '../../core/Helpers.js';\r\n\r\nimport defaultLangs from './defaults/langs.js';\r\n\r\nclass Localize extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.locale = \"default\"; //current locale\r\n\t\tthis.lang = false; //current language\r\n\t\tthis.bindings = {}; //update events to call when locale is changed\r\n\t\tthis.langList = {};\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tthis.langList = Helpers.deepClone(Localize.langs);\r\n\t}\r\n\r\n\t//set header placehoder\r\n\tsetHeaderFilterPlaceholder(placeholder){\r\n\t\tthis.langList.default.headerFilters.default = placeholder;\r\n\t}\r\n\r\n\t//set header filter placeholder by column\r\n\tsetHeaderFilterColumnPlaceholder(column, placeholder){\r\n\t\tthis.langList.default.headerFilters.columns[column] = placeholder;\r\n\r\n\t\tif(this.lang && !this.lang.headerFilters.columns[column]){\r\n\t\t\tthis.lang.headerFilters.columns[column] = placeholder;\r\n\t\t}\r\n\t}\r\n\r\n\t//setup a lang description object\r\n\tinstallLang(locale, lang){\r\n\t\tif(this.langList[locale]){\r\n\t\t\tthis._setLangProp(this.langList[locale], lang);\r\n\t\t}else{\r\n\t\t\tthis.langList[locale] = lang;\r\n\t\t}\r\n\t}\r\n\r\n\t_setLangProp(lang, values){\r\n\t\tfor(let key in values){\r\n\t\t\tif(lang[key] && typeof lang[key] == \"object\"){\r\n\t\t\t\tthis._setLangProp(lang[key], values[key])\r\n\t\t\t}else{\r\n\t\t\t\tlang[key] = values[key];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//set current locale\r\n\tsetLocale(desiredLocale){\r\n\t\tdesiredLocale = desiredLocale || \"default\";\r\n\r\n\t\t//fill in any matching languge values\r\n\t\tfunction traverseLang(trans, path){\r\n\t\t\tfor(var prop in trans){\r\n\t\t\t\tif(typeof trans[prop] == \"object\"){\r\n\t\t\t\t\tif(!path[prop]){\r\n\t\t\t\t\t\tpath[prop] = {};\r\n\t\t\t\t\t}\r\n\t\t\t\t\ttraverseLang(trans[prop], path[prop]);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tpath[prop] = trans[prop];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//determing correct locale to load\r\n\t\tif(desiredLocale === true && navigator.language){\r\n\t\t\t//get local from system\r\n\t\t\tdesiredLocale = navigator.language.toLowerCase();\r\n\t\t}\r\n\r\n\t\tif(desiredLocale){\r\n\t\t\t//if locale is not set, check for matching top level locale else use default\r\n\t\t\tif(!this.langList[desiredLocale]){\r\n\t\t\t\tlet prefix = desiredLocale.split(\"-\")[0];\r\n\r\n\t\t\t\tif(this.langList[prefix]){\r\n\t\t\t\t\tconsole.warn(\"Localization Error - Exact matching locale not found, using closest match: \", desiredLocale, prefix);\r\n\t\t\t\t\tdesiredLocale = prefix;\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Localization Error - Matching locale not found, using default: \", desiredLocale);\r\n\t\t\t\t\tdesiredLocale = \"default\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.locale = desiredLocale;\r\n\r\n\t\t//load default lang template\r\n\t\tthis.lang = Helpers.deepClone(this.langList.default || {});\r\n\r\n\t\tif(desiredLocale != \"default\"){\r\n\t\t\ttraverseLang(this.langList[desiredLocale], this.lang);\r\n\t\t}\r\n\r\n\t\tthis.table.options.localized.call(this.table, this.locale, this.lang);\r\n\r\n\t\tthis._executeBindings();\r\n\t}\r\n\r\n\t//get current locale\r\n\tgetLocale(locale){\r\n\t\treturn this.locale;\r\n\t}\r\n\r\n\t//get lang object for given local or current if none provided\r\n\tgetLang(locale){\r\n\t\treturn locale ? this.langList[locale] : this.lang;\r\n\t}\r\n\r\n\t//get text for current locale\r\n\tgetText(path, value){\r\n\t\tvar path = value ? path + \"|\" + value : path,\r\n\t\tpathArray = path.split(\"|\"),\r\n\t\ttext = this._getLangElement(pathArray, this.locale);\r\n\r\n\t\t// if(text === false){\r\n\t\t// \tconsole.warn(\"Localization Error - Matching localized text not found for given path: \", path);\r\n\t\t// }\r\n\r\n\t\treturn text || \"\";\r\n\t}\r\n\r\n\t//traverse langs object and find localized copy\r\n\t_getLangElement(path, locale){\r\n\t\tvar root = this.lang;\r\n\r\n\t\tpath.forEach(function(level){\r\n\t\t\tvar rootPath;\r\n\r\n\t\t\tif(root){\r\n\t\t\t\trootPath = root[level];\r\n\r\n\t\t\t\tif(typeof rootPath != \"undefined\"){\r\n\t\t\t\t\troot = rootPath;\r\n\t\t\t\t}else{\r\n\t\t\t\t\troot = false;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn root;\r\n\t}\r\n\r\n\t//set update binding\r\n\tbind(path, callback){\r\n\t\tif(!this.bindings[path]){\r\n\t\t\tthis.bindings[path] = [];\r\n\t\t}\r\n\r\n\t\tthis.bindings[path].push(callback);\r\n\r\n\t\tcallback(this.getText(path), this.lang);\r\n\t}\r\n\r\n\t//itterate through bindings and trigger updates\r\n\t_executeBindings(){\r\n\t\tfor(let path in this.bindings){\r\n\t\t\tthis.bindings[path].forEach((binding) => {\r\n\t\t\t\tbinding(this.getText(path), this.lang);\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n}\r\n\r\nLocalize.moduleName = \"localize\";\r\n\r\n//load defaults\r\nLocalize.langs = defaultLangs;\r\n\r\nexport default Localize;","import Module from '../../core/Module.js';\r\nimport TableRegistry from '../../core/TableRegistry.js';\r\n\r\nclass Comms extends Module{\r\n\r\n\tgetConnections(selectors){\r\n\t\tvar connections = [],\r\n\t\tconnection;\r\n\r\n\t\tconnection = Tabulator.comms.lookupTable(selectors);\r\n\r\n\t\tconnection.forEach((con) =>{\r\n\t\t\tif(this.table !== con){\r\n\t\t\t\tconnections.push(con);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn connections;\r\n\t}\r\n\r\n\tsend(selectors, module, action, data){\r\n\t\tvar connections = this.getConnections(selectors);\r\n\r\n\t\tconnections.forEach((connection) => {\r\n\t\t\tconnection.tableComms(this.table.element, module, action, data);\r\n\t\t});\r\n\r\n\t\tif(!connections.length && selectors){\r\n\t\t\tconsole.warn(\"Table Connection Error - No tables matching selector found\", selectors);\r\n\t\t}\r\n\t}\r\n\r\n\treceive(table, module, action, data){\r\n\t\tif(this.table.modExists(module)){\r\n\t\t\treturn this.table.modules[module].commsReceived(table, action, data);\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Inter-table Comms Error - no such module:\", module);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nComms.moduleName = \"comms\";\r\n\r\nexport default Comms;","import * as coreModules from './modules/core.js';\r\nimport TableRegistry from './TableRegistry.js';\r\n\r\nexport default class ModuleBinder {\r\n\r\n\tconstructor(tabulator, modules){\r\n\t\tthis.bindStaticFuctionality(tabulator);\r\n\t\tthis.bindModules(tabulator, coreModules);\r\n\r\n\t\tif(modules){\r\n\t\t\tthis.bindModules(tabulator, modules);\r\n\t\t}\r\n\t}\r\n\r\n\tbindStaticFuctionality(tabulator){\r\n\r\n\t\ttabulator.moduleBindings = {};\r\n\r\n\t\ttabulator.extendModule = function(name, property, values){\r\n\t\t\tif(tabulator.moduleBindings[name]){\r\n\t\t\t\tvar source = tabulator.moduleBindings[name].prototype[property];\r\n\r\n\t\t\t\tif(source){\r\n\t\t\t\t\tif(typeof values == \"object\"){\r\n\t\t\t\t\t\tfor(let key in values){\r\n\t\t\t\t\t\t\tsource[key] = values[key];\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tconsole.warn(\"Module Error - Invalid value type, it must be an object\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Module Error - property does not exist:\", property);\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Module Error - module does not exist:\", name);\r\n\t\t\t}\r\n\t\t};\r\n\r\n\t\ttabulator.registerModule = function(modules){\r\n\t\t\tif(!Array.isArray(modules)){\r\n\t\t\t\tmodules = [modules];\r\n\t\t\t}\r\n\r\n\t\t\tmodules.forEach((mod) => {\r\n\t\t\t\ttabulator.registerModuleBinding(mod)\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\ttabulator.registerModuleBinding = function(mod){\r\n\t\t\ttabulator.moduleBindings[mod.moduleName] = mod;\r\n\t\t};\r\n\r\n\t\ttabulator.findTable = function(query){\r\n\t\t\tvar results = TableRegistry.lookupTable(query, true);\r\n\t\t\treturn Array.isArray(results) && !results.length ? false : results;\r\n\t\t}\r\n\r\n\t\t//ensure that module are bound to instantiated function\r\n\t\ttabulator.prototype.bindModules = function(){\r\n\t\t\tthis.modules = {};\r\n\r\n\t\t\tfor(var name in tabulator.moduleBindings){\r\n\t\t\t\tthis.modules[name] = new tabulator.moduleBindings[name](this);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tbindModules(tabulator, modules){\r\n\t\tvar mods = Object.values(modules);\r\n\r\n\t\ttabulator.registerModule(mods);\r\n\t}\r\n}","export default class VirtualDomHorizontal {\r\n\tconstructor(table){\r\n\t\tthis.table = table;\r\n\r\n\t\tthis.element = this.table.rowManager.tableElement;\r\n\t\tthis.holderEl = this.table.rowManager.element;\r\n\r\n\t\tthis.leftCol = 0;\r\n\t\tthis.rightCol = 0;\r\n\t\tthis.scrollLeft = 0;\r\n\r\n\t\tthis.vDomScrollPosLeft = 0;\r\n\t\tthis.vDomScrollPosRight = 0;\r\n\r\n\t\tthis.vDomPadLeft = 0;\r\n\t\tthis.vDomPadRight = 0;\r\n\r\n\t\tthis.fitDataColAvg = 0;\r\n\r\n\t\tthis.window = 200; //pixel margin to make column visible before it is shown on screen\r\n\r\n\t\tthis.initialized = false;\r\n\r\n\t\tthis.columns = [];\r\n\r\n\t\tif(this.compatabilityCheck()){\r\n\t\t\tthis.initialize();\r\n\t\t}\r\n\t}\r\n\r\n\tcompatabilityCheck(){\r\n\t\tvar options = this.table.options,\r\n\t\tfrozen = false,\r\n\t\tok = true;\r\n\r\n\t\tif(options.layout == \"fitDataTable\"){\r\n\t\t\tconsole.warn(\"Horizontal Vitrual DOM is not compatible with fitDataTable layout mode\");\r\n\t\t\tok = false;\r\n\t\t}\r\n\r\n\t\tif(options.responsiveLayout){\r\n\t\t\tconsole.warn(\"Horizontal Vitrual DOM is not compatible with responsive columns\");\r\n\t\t\tok = false;\r\n\t\t}\r\n\r\n\t\tif(this.table.rtl){\r\n\t\t\tconsole.warn(\"Horizontal Vitrual DOM is not currently compatible with RTL text direction\");\r\n\t\t\tok = false;\r\n\t\t}\r\n\r\n\t\tif(options.columns){\r\n\t\t\tfrozen = options.columns.find((col) => {\r\n\t\t\t\treturn col.frozen;\r\n\t\t\t});\r\n\r\n\t\t\tif(frozen){\r\n\t\t\t\tconsole.warn(\"Horizontal Vitrual DOM is not compatible with frozen columns\");\r\n\t\t\t\tok = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(!ok){\r\n\t\t\toptions.virtualDomHoz = false;\r\n\t\t}\r\n\r\n\t\treturn ok;\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tthis.holderEl.addEventListener(\"scroll\", () => {\r\n\t\t\tvar left = this.holderEl.scrollLeft;\r\n\r\n\t\t\tif(this.scrollLeft != left){\r\n\t\t\t\tthis.scrollLeft = left;\r\n\t\t\t\tthis.scroll(left - (this.vDomScrollPosLeft + this.window));\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tdeinitialize(){\r\n\t\tthis.initialized = false;\r\n\t}\r\n\r\n\tclear(){\r\n\t\tthis.columns = [];\r\n\r\n\t\tthis.leftCol = -1;\r\n\t\tthis.rightCol = 0;\r\n\r\n\t\tthis.vDomScrollPosLeft = 0;\r\n\t\tthis.vDomScrollPosRight = 0;\r\n\t\tthis.vDomPadLeft = 0;\r\n\t\tthis.vDomPadRight = 0;\r\n\t}\r\n\r\n\tdataChange(){\r\n\t\tvar change = false,\r\n\t\tcollsWidth = 0,\r\n\t\tcolEnd = 0,\r\n\t\tgroup, row, rowEl;\r\n\r\n\t\tif(this.table.options.layout === \"fitData\"){\r\n\t\t\tthis.table.columnManager.columnsByIndex.forEach((column) => {\r\n\t\t\t\tif(!column.definition.width && column.visible){\r\n\t\t\t\t\tchange = true;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif(change){\r\n\t\t\t\tif(change && this.table.rowManager.getDisplayRows().length){\r\n\r\n\t\t\t\t\tthis.vDomScrollPosRight = this.scrollLeft + this.holderEl.clientWidth + this.window;\r\n\r\n\t\t\t\t\tif(this.table.options.groupBy){\r\n\t\t\t\t\t\tgroup = this.table.modules.groupRows.getGroups(false)[0];\r\n\r\n\t\t\t\t\t\trow = group.getRows(false)[0];\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\trow = this.table.rowManager.getDisplayRows()[0];\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(row){\r\n\r\n\t\t\t\t\t\trowEl = row.getElement();\r\n\r\n\t\t\t\t\t\trow.generateCells();\r\n\r\n\t\t\t\t\t\tthis.element.appendChild(rowEl);\r\n\r\n\t\t\t\t\t\tfor(var colEnd = 0; colEnd < row.cells.length; colEnd++){\r\n\t\t\t\t\t\t\tlet cell = row.cells[colEnd];\r\n\t\t\t\t\t\t\trowEl.appendChild(cell.getElement());\r\n\r\n\t\t\t\t\t\t\tcell.column.reinitializeWidth();\r\n\r\n\t\t\t\t\t\t\tcollsWidth += cell.column.getWidth();\r\n\r\n\t\t\t\t\t\t\tif(collsWidth > this.vDomScrollPosRight){\r\n\t\t\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\trowEl.parentNode.removeChild(rowEl);\r\n\r\n\t\t\t\t\t\tthis.fitDataColAvg = Math.floor(collsWidth / (colEnd + 1));\r\n\r\n\t\t\t\t\t\tfor(colEnd; colEnd < this.table.columnManager.columnsByIndex.length; colEnd++){\r\n\t\t\t\t\t\t\tthis.table.columnManager.columnsByIndex[colEnd].setWidth(this.fitDataColAvg);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t\tthis.reinitialize(false, true);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tif(this.table.options.layout === \"fitColumns\"){\r\n\t\t\t\tthis.table.modules.layout.layout();\r\n\t\t\t\tthis.table.vdomHoz.reinitialize(false, true);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfitDataLayoutOverride(){\r\n\t\tfor(let i = this.leftCol; i <= this.rightCol; i++){\r\n\t\t\tthis.columns[i].reinitializeWidth();\r\n\t\t}\r\n\t}\r\n\r\n\treinitialize(update, blockRedraw){\r\n\t\tvar old = {\r\n\t\t\tcols:this.columns,\r\n\t\t\tleftCol:this.leftCol,\r\n\t\t\trightCol:this.rightCol,\r\n\t\t};\r\n\r\n\t\tif(update && !this.initialized){\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\tthis.clear();\r\n\r\n\t\tthis.scrollLeft = this.holderEl.scrollLeft;\r\n\r\n\t\tthis.vDomScrollPosLeft = this.scrollLeft - this.window;\r\n\t\tthis.vDomScrollPosRight = this.scrollLeft + this.holderEl.clientWidth + this.window;\r\n\r\n\t\tvar colPos = 0;\r\n\r\n\t\tthis.table.columnManager.columnsByIndex.forEach((column) => {\r\n\t\t\tvar config = {};\r\n\r\n\t\t\tif(column.visible){\r\n\t\t\t\tvar width = column.getWidth();\r\n\r\n\t\t\t\tconfig.leftPos = colPos;\r\n\t\t\t\tconfig.rightPos = colPos + width;\r\n\r\n\t\t\t\tconfig.width = width;\r\n\r\n\t\t\t\tif (_this18.table.options.layout === \"fitData\") {\r\n\r\n\t\t\t\t config.fitDataCheck = true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif((colPos + width > this.vDomScrollPosLeft) && (colPos < this.vDomScrollPosRight)){\r\n\t \t\t//column is visible\r\n\r\n\t \t\tif(this.leftCol == -1){\r\n\t \t\t\tthis.leftCol = this.columns.length;\r\n\t \t\t\tthis.vDomPadLeft = colPos;\r\n\t \t\t}\r\n\r\n\t \t\tthis.rightCol = this.columns.length;\r\n\t \t}else{\r\n\t \t\t// column is hidden\r\n\t \t\tif(this.leftCol !== -1){\r\n\t \t\t\tthis.vDomPadRight += width;\r\n\t \t\t}\r\n\t \t}\r\n\r\n\t \tthis.columns.push(column);\r\n\r\n\t \tcolumn.modules.vdomHoz = config;\r\n\r\n\t \tcolPos += width;\r\n\t }\r\n\t });\r\n\r\n\t\tthis.element.style.paddingLeft = this.vDomPadLeft + \"px\";\r\n\t\tthis.element.style.paddingRight = this.vDomPadRight + \"px\";\r\n\r\n\t\tthis.initialized = true;\r\n\r\n\t\tif(!blockRedraw){\r\n\t\t\tif(!update || this.reinitChanged(old)){\r\n\t\t\t\tthis.renitializeRows();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.holderEl.scrollLeft = this.scrollLeft;\r\n\t}\r\n\r\n\treinitChanged(old){\r\n\t\tvar match = true;\r\n\r\n\t\tif(old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol){\r\n\t\t\treturn true;\r\n\t\t}\r\n\r\n\t\told.cols.forEach((col, i) => {\r\n\t\t\tif(col !== this.columns[i]){\r\n\t\t\t\tmatch = false;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn !match;\r\n\t}\r\n\r\n\trenitializeRows(){\r\n\t\tvar rows = this.table.rowManager.getVisibleRows();\r\n\t\trows.forEach((row) => {\r\n\t\t\tthis.reinitializeRow(row, true);\r\n\t\t});\r\n\t}\r\n\r\n\tscroll(diff){\r\n\t\tthis.vDomScrollPosLeft += diff;\r\n\t\tthis.vDomScrollPosRight += diff;\r\n\r\n\t\tif(diff > (this.holderEl.clientWidth * .8)){\r\n\t\t\tthis.reinitialize();\r\n\t\t}else{\r\n\t\t\tif(diff > 0){\r\n\t\t\t\t//scroll right\r\n\t\t\t\tthis.addColRight();\r\n\t\t\t\tthis.removeColLeft();\r\n\t\t\t}else{\r\n\t\t\t\t//scroll left\r\n\t\t\t\tthis.addColLeft();\r\n\t\t\t\tthis.removeColRight();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tcolPositionAdjust (start, end, diff){\r\n\t\tfor(let i = start; i < end; i++){\r\n\t\t\tlet column = this.columns[i];\r\n\r\n\t\t\tcolumn.modules.vdomHoz.leftPos += diff;\r\n\t\t\tcolumn.modules.vdomHoz.rightPos += diff;\r\n\t\t}\r\n\t}\r\n\r\n\taddColRight(){\r\n\t\tvar column = this.columns[this.rightCol + 1],\r\n\t\trows, newWidth, widthDiff;\r\n\r\n\t\tif(column && column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){\r\n\r\n\t\t\trows = this.table.rowManager.getVisibleRows();\r\n\r\n\t\t\trows.forEach((row) => {\r\n\t\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\t\tvar cell = row.getCell(column);\r\n\t\t\t\t\trow.getElement().appendChild(cell.getElement());\r\n\t\t\t\t\tcell.cellRendered();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.fitDataColActualWidthCheck(column);\r\n\r\n\t\t\tthis.rightCol++;\r\n\r\n\t\t\tif(this.rightCol >= (this.columns.length - 1)){\r\n\t\t\t\tthis.vDomPadRight = 0;\r\n\t\t\t}else{\r\n\t\t\t\tthis.vDomPadRight -= column.getWidth();\r\n\t\t\t}\r\n\r\n\t\t\tthis.element.style.paddingRight = this.vDomPadRight + \"px\";\r\n\r\n\t\t\tthis.addColRight();\r\n\t\t}\r\n\t}\r\n\r\n\taddColLeft(){\r\n\t\tvar column = this.columns[this.leftCol - 1],\r\n\t\trows;\r\n\r\n\t\tif(column && column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){\r\n\t\t\tvar rows = this.table.rowManager.getVisibleRows();\r\n\r\n\t\t\trows.forEach((row) => {\r\n\t\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\t\tvar cell = row.getCell(column);\r\n\t\t\t\t\trow.getElement().prepend(cell.getElement());\r\n\t\t\t\t\tcell.cellRendered();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.fitDataColActualWidthCheck(column);\r\n\r\n\t\t\tif(!this.leftCol){\r\n\t\t\t\tthis.vDomPadLeft = 0;\r\n\t\t\t}else{\r\n\t\t\t\tthis.vDomPadLeft -= column.getWidth();\r\n\t\t\t}\r\n\r\n\t\t\tthis.element.style.paddingLeft = this.vDomPadLeft + \"px\";\r\n\r\n\t\t\tthis.leftCol--;\r\n\r\n\t\t\tthis.addColLeft();\r\n\t\t}\r\n\t}\r\n\r\n\tremoveColRight(column){\r\n\t\tvar column = this.columns[this.rightCol],\r\n\t\trows;\r\n\r\n\t\tif(column && column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){\r\n\t\t\trows = this.table.rowManager.getVisibleRows();\r\n\r\n\t\t\tcolumn.modules.vdomHoz.visible = false;\r\n\r\n\t\t\trows.forEach((row) => {\r\n\t\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\t\tvar cell = row.getCell(column);\r\n\t\t\t\t\trow.getElement().removeChild(cell.getElement());\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.vDomPadRight += column.getWidth();\r\n\t\t\tthis.element.style.paddingRight = this.vDomPadRight + \"px\";\r\n\r\n\t\t\tthis.rightCol --;\r\n\r\n\t\t\tthis.removeColRight();\r\n\t\t}\r\n\t}\r\n\r\n\tremoveColLeft(){\r\n\t\tvar column = this.columns[this.leftCol],\r\n\t\trows;\r\n\r\n\t\tif(column && column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){\r\n\r\n\t\t\trows = this.table.rowManager.getVisibleRows();\r\n\r\n\t\t\trows.forEach((row) => {\r\n\t\t\t\tif(row.type !== \"group\"){\r\n\t\t\t\t\tvar cell = row.getCell(column);\r\n\t\t\t\t\trow.getElement().removeChild(cell.getElement());\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tthis.vDomPadLeft += column.getWidth();\r\n\t\t\tthis.element.style.paddingLeft = this.vDomPadLeft + \"px\";\r\n\r\n\t\t\tthis.leftCol ++;\r\n\r\n\t\t\tthis.removeColLeft();\r\n\t\t}\r\n\t}\r\n\r\n\tfitDataColActualWidthCheck(column){\r\n\t var newWidth, widthDiff;\r\n\r\n\t if(column.modules.vdomHoz.fitDataCheck){\r\n\t column.reinitializeWidth();\r\n\r\n\t newWidth = column.getWidth();\r\n\t widthDiff = newWidth - column.modules.vdomHoz.width;\r\n\r\n\t if(widthDiff){\r\n\t column.modules.vdomHoz.rightPos += widthDiff;\r\n\t column.modules.vdomHoz.width = newWidth;\r\n\t this.colPositionAdjust(this.rightCol + 2, this.columns.length, widthDiff);\r\n\t }\r\n\r\n\t column.modules.vdomHoz.fitDataCheck = false;\r\n\t }\r\n\t};\r\n\r\n\tinitializeRow(row){\r\n\t\tif(row.type !== \"group\"){\r\n\t\t\trow.modules.vdomHoz = {\r\n\t\t\t\tleftCol:this.leftCol,\r\n\t\t\t\trightCol:this.rightCol,\r\n\t\t\t};\r\n\r\n\t\t\tfor(let i = this.leftCol; i <= this.rightCol; i++){\r\n\t\t\t\tlet column = this.columns[i];\r\n\r\n\t\t\t\tif(column && column.visible){\r\n\t\t\t\t\tlet cell = row.getCell(column);\r\n\r\n\t\t\t\t\trow.getElement().appendChild(cell.getElement());\r\n\t\t\t\t\tcell.cellRendered();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treinitializeRow(row, force){\r\n\t\tif(row.type !== \"group\"){\r\n\t\t\tif(force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol){\r\n\t\t\t\tvar rowEl = row.getElement();\r\n\t\t\t\twhile(rowEl.firstChild) rowEl.removeChild(rowEl.firstChild);\r\n\r\n\t\t\t\tthis.initializeRow(row);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}","'use strict';\r\n\r\nimport defaultOptions from './defaults/options.js';\r\n\r\n\r\nimport ColumnManager from './ColumnManager.js';\r\nimport RowManager from './RowManager.js';\r\nimport FooterManager from './FooterManager.js';\r\n\r\nimport TableRegistry from './TableRegistry.js';\r\nimport ModuleBinder from './ModuleBinder.js';\r\n\r\nimport VirtualDomHorizontal from './renderers/VirtualDomHorizontal.js';\r\n\r\nclass Tabulator {\r\n\r\n\tconstructor(element, options){\r\n\r\n\t\tthis.options = {};\r\n\r\n\t\tthis.columnManager = null; // hold Column Manager\r\n\t\tthis.rowManager = null; //hold Row Manager\r\n\t\tthis.footerManager = null; //holder Footer Manager\r\n\t\tthis.vdomHoz = null; //holder horizontal virtual dom\r\n\r\n\t\tthis.browser = \"\"; //hold current browser type\r\n\t\tthis.browserSlow = false; //handle reduced functionality for slower browsers\r\n\t\tthis.browserMobile = false; //check if running on moble, prevent resize cancelling edit on keyboard appearence\r\n\t\tthis.rtl = false; //check if the table is in RTL mode\r\n\r\n\t\tthis.modules = {}; //hold all modules bound to this table\r\n\r\n\t\tif(this.initializeElement(element)){\r\n\t\t\tthis.initializeOptions(options || {});\r\n\t\t\tthis._create();\r\n\t\t}\r\n\r\n\t\tTableRegistry.register(this); //register table for inderdevice communication\r\n\t}\r\n\r\n\tinitializeOptions(options){\r\n\r\n\t\tvar defaults = Tabulator.defaultOptions;\r\n\r\n\t\t//warn user if option is not available\r\n\t\tif(options.invalidOptionWarnings !== false){\r\n\t\t\tfor (var key in options){\r\n\t\t\t\tif(typeof defaults[key] === \"undefined\"){\r\n\t\t\t\t\tconsole.warn(\"Invalid table constructor option:\", key)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//assign options to table\r\n\t\tfor (var key in defaults){\r\n\t\t\tif(key in options){\r\n\t\t\t\tthis.options[key] = options[key];\r\n\t\t\t}else{\r\n\t\t\t\tif(Array.isArray(defaults[key])){\r\n\t\t\t\t\tthis.options[key] = Object.assign([], defaults[key]);\r\n\t\t\t\t}else if(typeof defaults[key] === \"object\" && defaults[key] !== null){\r\n\t\t\t\t\tthis.options[key] = Object.assign({}, defaults[key]);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.options[key] = defaults[key];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinitializeElement(element){\r\n\t\tif(typeof HTMLElement !== \"undefined\" && element instanceof HTMLElement){\r\n\t\t\tthis.element = element;\r\n\t\t\treturn true;\r\n\t\t}else if(typeof element === \"string\"){\r\n\t\t\tthis.element = document.querySelector(element);\r\n\r\n\t\t\tif(this.element){\r\n\t\t\t\treturn true;\r\n\t\t\t}else{\r\n\t\t\t\tconsole.error(\"Tabulator Creation Error - no element found matching selector: \", element);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.error(\"Tabulator Creation Error - Invalid element provided:\", element);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\trtlCheck(){\r\n\t\tvar style = window.getComputedStyle(this.element);\r\n\r\n\t\tswitch(this.options.textDirection){\r\n\t\t\tcase\"auto\":\r\n\t\t\tif(style.direction !== \"rtl\"){\r\n\t\t\t\tbreak;\r\n\t\t\t};\r\n\r\n\t\t\tcase \"rtl\":\r\n\t\t\tthis.element.classList.add(\"tabulator-rtl\");\r\n\t\t\tthis.rtl = true;\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"ltr\":\r\n\t\t\tthis.element.classList.add(\"tabulator-ltr\");\r\n\r\n\t\t\tdefault:\r\n\t\t\tthis.rtl = false;\r\n\t\t}\r\n\t}\r\n\r\n\t//convert depricated functionality to new functions\r\n\t_mapDepricatedFunctionality(){\r\n\t\t//all previously deprecated functionality removed in the 5.0 release\r\n\t}\r\n\r\n\t_clearSelection(){\r\n\r\n\t\tthis.element.classList.add(\"tabulator-block-select\");\r\n\r\n\t\tif (window.getSelection) {\r\n\t\t if (window.getSelection().empty) { // Chrome\r\n\t\t \twindow.getSelection().empty();\r\n\t\t } else if (window.getSelection().removeAllRanges) { // Firefox\r\n\t\t \twindow.getSelection().removeAllRanges();\r\n\t\t }\r\n\t\t} else if (document.selection) { // IE?\r\n\t\t\tdocument.selection.empty();\r\n\t\t}\r\n\r\n\t\tthis.element.classList.remove(\"tabulator-block-select\");\r\n\t}\r\n\r\n\t//concreate table\r\n\t_create(){\r\n\t\tthis._clearObjectPointers();\r\n\r\n\t\tthis._mapDepricatedFunctionality();\r\n\r\n\t\tthis.bindModules();\r\n\r\n\t\tthis.rtlCheck();\r\n\r\n\t\tif(this.element.tagName === \"TABLE\"){\r\n\t\t\tif(this.modExists(\"htmlTableImport\", true)){\r\n\t\t\t\tthis.modules.htmlTableImport.parseTable();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.columnManager = new ColumnManager(this);\r\n\t\tthis.rowManager = new RowManager(this);\r\n\t\tthis.footerManager = new FooterManager(this);\r\n\r\n\t\tthis.columnManager.setRowManager(this.rowManager);\r\n\t\tthis.rowManager.setColumnManager(this.columnManager);\r\n\r\n\t\tif(this.options.virtualDomHoz){\r\n\t\t\tthis.vdomHoz = new VirtualDomHorizontal(this);\r\n\t\t}\r\n\r\n\t\tthis._buildElement();\r\n\r\n\t\tthis._loadInitialData();\r\n\t}\r\n\r\n\t//clear pointers to objects in default config object\r\n\t_clearObjectPointers(){\r\n\t\tthis.options.columns = this.options.columns.slice(0);\r\n\r\n\t\tif(!this.options.reactiveData){\r\n\t\t\tthis.options.data = this.options.data.slice(0);\r\n\t\t}\r\n\t}\r\n\r\n\t//build tabulator element\r\n\t_buildElement(){\r\n\t\tvar element = this.element,\r\n\t\tmod = this.modules,\r\n\t\toptions = this.options;\r\n\r\n\t\toptions.tableBuilding.call(this);\r\n\r\n\t\telement.classList.add(\"tabulator\");\r\n\t\telement.setAttribute(\"role\", \"grid\");\r\n\r\n\t\t//empty element\r\n\t\twhile(element.firstChild) element.removeChild(element.firstChild);\r\n\r\n\t\t//set table height\r\n\t\tif(options.height){\r\n\t\t\toptions.height = isNaN(options.height) ? options.height : options.height + \"px\";\r\n\t\t\telement.style.height = options.height;\r\n\t\t}\r\n\r\n\t\t//set table min height\r\n\t\tif(options.minHeight !== false){\r\n\t\t\toptions.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + \"px\";\r\n\t\t\telement.style.minHeight = options.minHeight;\r\n\t\t}\r\n\r\n\t\t//set table maxHeight\r\n\t\tif(options.maxHeight !== false){\r\n\t\t\toptions.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + \"px\";\r\n\t\t\telement.style.maxHeight = options.maxHeight;\r\n\t\t}\r\n\r\n\t\tthis.columnManager.initialize();\r\n\t\tthis.rowManager.initialize();\r\n\r\n\t\tthis._detectBrowser();\r\n\r\n\t\tif(this.modExists(\"layout\", true)){\r\n\t\t\tmod.layout.initialize(options.layout);\r\n\t\t}\r\n\r\n\t\t//set localization\r\n\t\tmod.localize.initialize();\r\n\r\n\t\tif(options.headerFilterPlaceholder !== false){\r\n\t\t\tmod.localize.setHeaderFilterPlaceholder(options.headerFilterPlaceholder);\r\n\t\t}\r\n\r\n\t\tfor(let locale in options.langs){\r\n\t\t\tmod.localize.installLang(locale, options.langs[locale]);\r\n\t\t}\r\n\r\n\t\tmod.localize.setLocale(options.locale);\r\n\r\n\t\t//configure placeholder element\r\n\t\tif(typeof options.placeholder == \"string\"){\r\n\r\n\t\t\tvar el = document.createElement(\"div\");\r\n\t\t\tel.classList.add(\"tabulator-placeholder\");\r\n\r\n\t\t\tvar span = document.createElement(\"span\");\r\n\t\t\tspan.innerHTML = options.placeholder;\r\n\r\n\t\t\tel.appendChild(span);\r\n\r\n\t\t\toptions.placeholder = el;\r\n\t\t}\r\n\r\n\t\t//build table elements\r\n\t\telement.appendChild(this.columnManager.getElement());\r\n\t\telement.appendChild(this.rowManager.getElement());\r\n\r\n\t\tif(options.footerElement){\r\n\t\t\tthis.footerManager.activate();\r\n\t\t}\r\n\r\n\t\tif(options.persistence && this.modExists(\"persistence\", true)){\r\n\t\t\tmod.persistence.initialize();\r\n\t\t}\r\n\r\n\t\tif(options.movableRows && this.modExists(\"moveRow\")){\r\n\t\t\tmod.moveRow.initialize();\r\n\t\t}\r\n\r\n\t\tif(options.autoColumns && this.options.data){\r\n\t\t\tthis.columnManager.generateColumnsFromRowData(this.options.data);\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"columnCalcs\")){\r\n\t\t\tmod.columnCalcs.initialize();\r\n\t\t}\r\n\r\n\t\tthis.columnManager.setColumns(options.columns);\r\n\r\n\t\tif(options.dataTree && this.modExists(\"dataTree\", true)){\r\n\t\t\tmod.dataTree.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"frozenRows\")){\r\n\t\t\tthis.modules.frozenRows.initialize();\r\n\t\t}\r\n\r\n\t\tif(((options.persistence && this.modExists(\"persistence\", true) && mod.persistence.config.sort) || options.initialSort) && this.modExists(\"sort\", true)){\r\n\t\t\tvar sorters = [];\r\n\r\n\t\t\tif(options.persistence && this.modExists(\"persistence\", true) && mod.persistence.config.sort){\r\n\t\t\t\tsorters = mod.persistence.load(\"sort\");\r\n\r\n\t\t\t\tif(sorters === false && options.initialSort){\r\n\t\t\t\t\tsorters = options.initialSort;\r\n\t\t\t\t}\r\n\t\t\t}else if(options.initialSort){\r\n\t\t\t\tsorters = options.initialSort;\r\n\t\t\t}\r\n\r\n\t\t\tmod.sort.setSort(sorters);\r\n\t\t}\r\n\r\n\t\tif(((options.persistence && this.modExists(\"persistence\", true) && mod.persistence.config.filter) || options.initialFilter) && this.modExists(\"filter\", true)){\r\n\t\t\tvar filters = [];\r\n\r\n\r\n\t\t\tif(options.persistence && this.modExists(\"persistence\", true) && mod.persistence.config.filter){\r\n\t\t\t\tfilters = mod.persistence.load(\"filter\");\r\n\r\n\t\t\t\tif(filters === false && options.initialFilter){\r\n\t\t\t\t\tfilters = options.initialFilter;\r\n\t\t\t\t}\r\n\t\t\t}else if(options.initialFilter){\r\n\t\t\t\tfilters = options.initialFilter;\r\n\t\t\t}\r\n\r\n\t\t\tmod.filter.setFilter(filters);\r\n\t\t}\r\n\r\n\t\tif(options.initialHeaderFilter && this.modExists(\"filter\", true)){\r\n\t\t\toptions.initialHeaderFilter.forEach((item) => {\r\n\r\n\t\t\t\tvar column = this.columnManager.findColumn(item.field);\r\n\r\n\t\t\t\tif(column){\r\n\t\t\t\t\tmod.filter.setHeaderFilterValue(column, item.value);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Column Filter Error - No matching column found:\", item.field);\r\n\t\t\t\t\treturn false;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\r\n\t\tif(this.modExists(\"ajax\")){\r\n\t\t\tmod.ajax.initialize();\r\n\t\t}\r\n\r\n\t\tif(options.pagination && this.modExists(\"page\", true)){\r\n\t\t\tmod.page.initialize();\r\n\t\t}\r\n\r\n\t\tif(options.groupBy && this.modExists(\"groupRows\", true)){\r\n\t\t\tmod.groupRows.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"keybindings\")){\r\n\t\t\tmod.keybindings.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"selectRow\")){\r\n\t\t\tmod.selectRow.clearSelectionData(true);\r\n\t\t}\r\n\r\n\t\tif(options.autoResize && this.modExists(\"resizeTable\")){\r\n\t\t\tmod.resizeTable.initialize();\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"clipboard\")){\r\n\t\t\tmod.clipboard.initialize();\r\n\t\t}\r\n\r\n\t\tif(options.printAsHtml && this.modExists(\"print\")){\r\n\t\t\tmod.print.initialize();\r\n\t\t}\r\n\r\n\t\toptions.tableBuilt.call(this);\r\n\t}\r\n\r\n\t_loadInitialData(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\tthis.modules.page.reset(true, true);\r\n\r\n\t\t\tif(this.options.pagination == \"local\"){\r\n\t\t\t\tif(this.options.data.length){\r\n\t\t\t\t\tthis.rowManager.setData(this.options.data, false, true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tif((this.options.ajaxURL || this.options.ajaxURLGenerator) && this.modExists(\"ajax\")){\r\n\t\t\t\t\t\tthis.modules.ajax.loadData(false, true).then(()=>{}).catch(()=>{\r\n\t\t\t\t\t\t\tif(this.options.paginationInitialPage){\r\n\t\t\t\t\t\t\t\tthis.modules.page.setPage(this.options.paginationInitialPage);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.rowManager.setData(this.options.data, false, true);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(this.options.paginationInitialPage){\r\n\t\t\t\t\tthis.modules.page.setPage(this.options.paginationInitialPage);\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tif(this.options.ajaxURL){\r\n\t\t\t\t\tthis.modules.page.setPage(this.options.paginationInitialPage).then(()=>{}).catch(()=>{});\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.rowManager.setData([], false, true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tif(this.options.data.length){\r\n\t\t\t\tthis.rowManager.setData(this.options.data);\r\n\t\t\t}else{\r\n\t\t\t\tif((this.options.ajaxURL || this.options.ajaxURLGenerator) && this.modExists(\"ajax\")){\r\n\t\t\t\t\tthis.modules.ajax.loadData(false, true).then(()=>{}).catch(()=>{});\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.rowManager.setData(this.options.data, false, true);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//deconstructor\r\n\tdestroy(){\r\n\t\tvar element = this.element;\r\n\r\n\t\tcomms(this); //deregister table from inderdevice communication\r\n\r\n\t\tif(this.options.reactiveData && this.modExists(\"reactiveData\", true)){\r\n\t\t\tthis.modules.reactiveData.unwatchData();\r\n\t\t}\r\n\r\n\t\t//clear row data\r\n\t\tthis.rowManager.rows.forEach(function(row){\r\n\t\t\trow.wipe();\r\n\t\t});\r\n\r\n\t\tthis.rowManager.rows = [];\r\n\t\tthis.rowManager.activeRows = [];\r\n\t\tthis.rowManager.displayRows = [];\r\n\r\n\t\t//clear event bindings\r\n\t\tif(this.options.autoResize && this.modExists(\"resizeTable\")){\r\n\t\t\tthis.modules.resizeTable.clearBindings();\r\n\t\t}\r\n\r\n\t\tif(this.modExists(\"keybindings\")){\r\n\t\t\tthis.modules.keybindings.clearBindings();\r\n\t\t}\r\n\r\n\t\t//clear DOM\r\n\t\twhile(element.firstChild) element.removeChild(element.firstChild);\r\n\t\telement.classList.remove(\"tabulator\");\r\n\t}\r\n\r\n\t_detectBrowser(){\r\n\t\tvar ua = navigator.userAgent||navigator.vendor||window.opera;\r\n\r\n\t\tif(ua.indexOf(\"Trident\") > -1){\r\n\t\t\tthis.browser = \"ie\";\r\n\t\t\tthis.browserSlow = true;\r\n\t\t}else if(ua.indexOf(\"Edge\") > -1){\r\n\t\t\tthis.browser = \"edge\";\r\n\t\t\tthis.browserSlow = true;\r\n\t\t}else if(ua.indexOf(\"Firefox\") > -1){\r\n\t\t\tthis.browser = \"firefox\";\r\n\t\t\tthis.browserSlow = false;\r\n\t\t}else{\r\n\t\t\tthis.browser = \"other\";\r\n\t\t\tthis.browserSlow = false;\r\n\t\t}\r\n\r\n\t\tthis.browserMobile = /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(ua)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\\-(n|u)|c55\\/|capi|ccwa|cdm\\-|cell|chtm|cldc|cmd\\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\\-s|devi|dica|dmob|do(c|p)o|ds(12|\\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\\-|_)|g1 u|g560|gene|gf\\-5|g\\-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd\\-(m|p|t)|hei\\-|hi(pt|ta)|hp( i|ip)|hs\\-c|ht(c(\\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\\-(20|go|ma)|i230|iac( |\\-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc\\-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|\\-[a-w])|libw|lynx|m1\\-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m\\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\\-2|po(ck|rt|se)|prox|psio|pt\\-g|qa\\-a|qc(07|12|21|32|60|\\-[2-7]|i\\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\\-|oo|p\\-)|sdk\\/|se(c(\\-|0|1)|47|mc|nd|ri)|sgh\\-|shar|sie(\\-|m)|sk\\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\\-|v\\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\\-|tdg\\-|tel(i|m)|tim\\-|t\\-mo|to(pl|sh)|ts(70|m\\-|m3|m5)|tx\\-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\\-|your|zeto|zte\\-/i.test(ua.substr(0,4));\r\n\t}\r\n\r\n\t////////////////// Data Handling //////////////////\r\n\t//block table redrawing\r\n\tblockRedraw(){\r\n\t\treturn this.rowManager.blockRedraw();\r\n\t}\r\n\r\n\t//restore table redrawing\r\n\trestoreRedraw(){\r\n\t\treturn this.rowManager.restoreRedraw();\r\n\t}\r\n\r\n\t//local data from local file\r\n\tsetDataFromLocalFile(extensions){\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar input = document.createElement(\"input\");\r\n\t\t\tinput.type = \"file\";\r\n\t\t\tinput.accept = extensions || \".json,application/json\";\r\n\r\n\t\t\tinput.addEventListener(\"change\", (e) => {\r\n\t\t\t\tvar file = input.files[0],\r\n\t\t\t\treader = new FileReader(),\r\n\t\t\t\tdata;\r\n\r\n\t\t\t\treader.readAsText(file);\r\n\r\n\t\t\t\treader.onload = (e) => {\r\n\r\n\t\t\t\t\ttry {\r\n\t\t\t\t\t\tdata = JSON.parse(reader.result);\r\n\t\t\t\t\t} catch(e) {\r\n\t\t\t\t\t\tconsole.warn(\"File Load Error - File contents is invalid JSON\", e);\r\n\t\t\t\t\t\treject(e);\r\n\t\t\t\t\t\treturn;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.setData(data)\r\n\t\t\t\t\t.then((data) => {\r\n\t\t\t\t\t\tresolve(data);\r\n\t\t\t\t\t})\r\n\t\t\t\t\t.catch((err) => {\r\n\t\t\t\t\t\tresolve(err);\r\n\t\t\t\t\t});\r\n\t\t\t\t};\r\n\r\n\t\t\t\treader.onerror = (e) => {\r\n\t\t\t\t\tconsole.warn(\"File Load Error - Unable to read file\");\r\n\t\t\t\t\treject();\r\n\t\t\t\t};\r\n\t\t\t});\r\n\r\n\t\t\tinput.click();\r\n\t\t});\r\n\t}\r\n\r\n\t//load data\r\n\tsetData(data, params, config){\r\n\t\tif(this.modExists(\"ajax\")){\r\n\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t}\r\n\r\n\t\treturn this._setData(data, params, config, false, true);\r\n\t}\r\n\r\n\t_setData(data, params, config, inPosition, columnsChanged){\r\n\t\tif(typeof(data) === \"string\"){\r\n\t\t\tif (data.indexOf(\"{\") == 0 || data.indexOf(\"[\") == 0){\r\n\t\t\t\t//data is a json encoded string\r\n\t\t\t\treturn this.rowManager.setData(JSON.parse(data), inPosition, columnsChanged);\r\n\t\t\t}else{\r\n\r\n\t\t\t\tif(this.modExists(\"ajax\", true)){\r\n\t\t\t\t\tif(params){\r\n\t\t\t\t\t\tthis.modules.ajax.setParams(params);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(config){\r\n\t\t\t\t\t\tthis.modules.ajax.setConfig(config);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.modules.ajax.setUrl(data);\r\n\r\n\t\t\t\t\tif(this.options.pagination == \"remote\" && this.modExists(\"page\", true)){\r\n\t\t\t\t\t\tthis.modules.page.reset(true, true);\r\n\t\t\t\t\t\treturn this.modules.page.setPage(1);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\t//assume data is url, make ajax call to url to get data\r\n\t\t\t\t\t\treturn this.modules.ajax.loadData(inPosition, columnsChanged);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tif(data){\r\n\t\t\t\t//asume data is already an object\r\n\t\t\t\treturn this.rowManager.setData(data, inPosition, columnsChanged);\r\n\t\t\t}else{\r\n\t\t\t\t//no data provided, check if ajaxURL is present;\r\n\t\t\t\tif(this.modExists(\"ajax\") && (this.modules.ajax.getUrl || this.options.ajaxURLGenerator)){\r\n\t\t\t\t\tif(this.options.pagination == \"remote\" && this.modExists(\"page\", true)){\r\n\t\t\t\t\t\tthis.modules.page.reset(true, true);\r\n\t\t\t\t\t\treturn this.modules.page.setPage(1);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\treturn this.modules.ajax.loadData(inPosition, columnsChanged);\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\t//empty data\r\n\t\t\t\t\treturn this.rowManager.setData([], inPosition, columnsChanged);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//clear data\r\n\tclearData(){\r\n\t\tif(this.modExists(\"ajax\")){\r\n\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t}\r\n\r\n\t\tthis.rowManager.clearData();\r\n\t}\r\n\r\n\t//get table data array\r\n\tgetData(active){\r\n\t\treturn this.rowManager.getData(active);\r\n\t}\r\n\r\n\t//get table data array count\r\n\tgetDataCount(active){\r\n\t\treturn this.rowManager.getDataCount(active);\r\n\t}\r\n\r\n\t//search for specific row components\r\n\tsearchRows(field, type, value){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\treturn this.modules.filter.search(\"rows\", field, type, value);\r\n\t\t}\r\n\t}\r\n\r\n\t//search for specific data\r\n\tsearchData(field, type, value){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\treturn this.modules.filter.search(\"data\", field, type, value);\r\n\t\t}\r\n\t}\r\n\r\n\t//get table html\r\n\tgetHtml(visible, style, config){\r\n\t\tif(this.modExists(\"export\", true)){\r\n\t\t\treturn this.modules.export.getHtml(visible, style, config);\r\n\t\t}\r\n\t}\r\n\r\n\t//get print html\r\n\tprint(visible, style, config){\r\n\t\tif(this.modExists(\"print\", true)){\r\n\t\t\treturn this.modules.print.printFullscreen(visible, style, config);\r\n\t\t}\r\n\t}\r\n\r\n\t//retrieve Ajax URL\r\n\tgetAjaxUrl(){\r\n\t\tif(this.modExists(\"ajax\", true)){\r\n\t\t\treturn this.modules.ajax.getUrl();\r\n\t\t}\r\n\t}\r\n\r\n\t//replace data, keeping table in position with same sort\r\n\treplaceData(data, params, config){\r\n\t\tif(this.modExists(\"ajax\")){\r\n\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t}\r\n\r\n\t\treturn this._setData(data, params, config, true);\r\n\t}\r\n\r\n\t//update table data\r\n\tupdateData(data){\r\n\t\tvar responses = 0;\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(this.modExists(\"ajax\")){\r\n\t\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tif(data){\r\n\t\t\t\tdata.forEach((item) => {\r\n\t\t\t\t\tvar row = this.rowManager.findRow(item[this.options.index]);\r\n\r\n\t\t\t\t\tif(row){\r\n\t\t\t\t\t\tresponses++;\r\n\r\n\t\t\t\t\t\trow.updateData(item)\r\n\t\t\t\t\t\t.then(()=>{\r\n\t\t\t\t\t\t\tresponses--;\r\n\r\n\t\t\t\t\t\t\tif(!responses){\r\n\t\t\t\t\t\t\t\tresolve();\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Update Error - No data provided\");\r\n\t\t\t\treject(\"Update Error - No data provided\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\taddData(data, pos, index){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(this.modExists(\"ajax\")){\r\n\t\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tif(data){\r\n\t\t\t\tthis.rowManager.addRows(data, pos, index)\r\n\t\t\t\t.then((rows) => {\r\n\t\t\t\t\tvar output = [];\r\n\r\n\t\t\t\t\trows.forEach(function(row){\r\n\t\t\t\t\t\toutput.push(row.getComponent());\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tresolve(output);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Update Error - No data provided\");\r\n\t\t\t\treject(\"Update Error - No data provided\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t//update table data\r\n\tupdateOrAddData(data){\r\n\t\tvar rows = [],\r\n\t\tresponses = 0;\r\n\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(this.modExists(\"ajax\")){\r\n\t\t\t\tthis.modules.ajax.blockActiveRequest();\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tif(data){\r\n\t\t\t\tdata.forEach((item) => {\r\n\t\t\t\t\tvar row = this.rowManager.findRow(item[this.options.index]);\r\n\r\n\t\t\t\t\tresponses++;\r\n\r\n\t\t\t\t\tif(row){\r\n\t\t\t\t\t\trow.updateData(item)\r\n\t\t\t\t\t\t.then(()=>{\r\n\t\t\t\t\t\t\tresponses--;\r\n\t\t\t\t\t\t\trows.push(row.getComponent());\r\n\r\n\t\t\t\t\t\t\tif(!responses){\r\n\t\t\t\t\t\t\t\tresolve(rows);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.rowManager.addRows(item)\r\n\t\t\t\t\t\t.then((newRows)=>{\r\n\t\t\t\t\t\t\tresponses--;\r\n\t\t\t\t\t\t\trows.push(newRows[0].getComponent());\r\n\r\n\t\t\t\t\t\t\tif(!responses){\r\n\t\t\t\t\t\t\t\tresolve(rows);\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Update Error - No data provided\");\r\n\t\t\t\treject(\"Update Error - No data provided\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t//get row object\r\n\tgetRow(index){\r\n\t\tvar row = this.rowManager.findRow(index);\r\n\r\n\t\tif(row){\r\n\t\t\treturn row.getComponent();\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Find Error - No matching row found:\", index);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t//get row object\r\n\tgetRowFromPosition(position, active){\r\n\t\tvar row = this.rowManager.getRowFromPosition(position, active);\r\n\r\n\t\tif(row){\r\n\t\t\treturn row.getComponent();\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Find Error - No matching row found:\", position);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t//delete row from table\r\n\tdeleteRow(index){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar count = 0,\r\n\t\t\tsuccessCount = 0,\r\n\t\t\tfoundRows = [];\r\n\r\n\t\t\tfunction doneCheck(){\r\n\t\t\t\tcount++;\r\n\r\n\t\t\t\tif(count == index.length){\r\n\t\t\t\t\tif(successCount){\r\n\t\t\t\t\t\tthis.rowManager.reRenderInPosition();\r\n\t\t\t\t\t\tresolve();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tif(!Array.isArray(index)){\r\n\t\t\t\tindex = [index];\r\n\t\t\t}\r\n\r\n\t\t\t//find matching rows\r\n\t\t\tindex.forEach((item) =>{\r\n\t\t\t\tvar row = this.rowManager.findRow(item, true);\r\n\r\n\t\t\t\tif(row){\r\n\t\t\t\t\tfoundRows.push(row);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Delete Error - No matching row found:\", item);\r\n\t\t\t\t\treject(\"Delete Error - No matching row found\")\r\n\t\t\t\t\tdoneCheck();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t//sort rows into correct order to ensure smooth delete from table\r\n\t\t\tfoundRows.sort((a, b) => {\r\n\t\t\t\treturn this.rowManager.rows.indexOf(a) > this.rowManager.rows.indexOf(b) ? 1 : -1;\r\n\t\t\t});\r\n\r\n\t\t\tfoundRows.forEach((row) =>{\r\n\t\t\t\trow.delete()\r\n\t\t\t\t.then(() => {\r\n\t\t\t\t\tsuccessCount++;\r\n\t\t\t\t\tdoneCheck();\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err) => {\r\n\t\t\t\t\tdoneCheck();\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\t//add row to table\r\n\taddRow(data, pos, index){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tthis.rowManager.addRows(data, pos, index)\r\n\t\t\t.then((rows)=>{\r\n\t\t\t\t//recalc column calculations if present\r\n\t\t\t\tif(this.modExists(\"columnCalcs\")){\r\n\t\t\t\t\tthis.modules.columnCalcs.recalc(this.rowManager.activeRows);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tresolve(rows[0].getComponent());\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\t//update a row if it exitsts otherwise create it\r\n\tupdateOrAddRow(index, data){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar row = this.rowManager.findRow(index);\r\n\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tif(row){\r\n\t\t\t\trow.updateData(data)\r\n\t\t\t\t.then(()=>{\r\n\t\t\t\t\t//recalc column calculations if present\r\n\t\t\t\t\tif(this.modExists(\"columnCalcs\")){\r\n\t\t\t\t\t\tthis.modules.columnCalcs.recalc(this.rowManager.activeRows);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tresolve(row.getComponent());\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err)=>{\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\trow = this.rowManager.addRows(data)\r\n\t\t\t\t.then((rows)=>{\r\n\t\t\t\t\t//recalc column calculations if present\r\n\t\t\t\t\tif(this.modExists(\"columnCalcs\")){\r\n\t\t\t\t\t\tthis.modules.columnCalcs.recalc(this.rowManager.activeRows);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tresolve(rows[0].getComponent());\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err)=>{\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t//update row data\r\n\tupdateRow(index, data){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar row = this.rowManager.findRow(index);\r\n\r\n\t\t\tif(typeof data === \"string\"){\r\n\t\t\t\tdata = JSON.parse(data);\r\n\t\t\t}\r\n\r\n\t\t\tif(row){\r\n\t\t\t\trow.updateData(data).then(()=>{\r\n\t\t\t\t\tresolve(row.getComponent());\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err)=>{\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Update Error - No matching row found:\", index);\r\n\t\t\t\treject(\"Update Error - No matching row found\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t//scroll to row in DOM\r\n\tscrollToRow(index, position, ifVisible){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar row = this.rowManager.findRow(index);\r\n\r\n\t\t\tif(row){\r\n\t\t\t\tthis.rowManager.scrollToRow(row, position, ifVisible)\r\n\t\t\t\t.then(()=>{\r\n\t\t\t\t\tresolve();\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err)=>{\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Scroll Error - No matching row found:\", index);\r\n\t\t\t\treject(\"Scroll Error - No matching row found\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tmoveRow(from, to, after){\r\n\t\tvar fromRow = this.rowManager.findRow(from);\r\n\r\n\t\tif(fromRow){\r\n\t\t\tfromRow.moveToRow(to, after);\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Move Error - No matching row found:\", from);\r\n\t\t}\r\n\t}\r\n\r\n\tgetRows(active){\r\n\t\treturn this.rowManager.getComponents(active);\r\n\t}\r\n\r\n\t//get position of row in table\r\n\tgetRowPosition(index, active){\r\n\t\tvar row = this.rowManager.findRow(index);\r\n\r\n\t\tif(row){\r\n\t\t\treturn this.rowManager.getRowPosition(row, active);\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Position Error - No matching row found:\", index);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t//copy table data to clipboard\r\n\tcopyToClipboard(selector){\r\n\t\tif(this.modExists(\"clipboard\", true)){\r\n\t\t\tthis.modules.clipboard.copy(selector);\r\n\t\t}\r\n\t}\r\n\r\n\t/////////////// Column Functions ///////////////\r\n\tsetColumns(definition){\r\n\t\tthis.columnManager.setColumns(definition);\r\n\t}\r\n\r\n\tgetColumns(structured){\r\n\t\treturn this.columnManager.getComponents(structured);\r\n\t}\r\n\r\n\tgetColumn(field){\r\n\t\tvar col = this.columnManager.findColumn(field);\r\n\r\n\t\tif(col){\r\n\t\t\treturn col.getComponent();\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Find Error - No matching column found:\", field);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetColumnDefinitions(){\r\n\t\treturn this.columnManager.getDefinitionTree();\r\n\t}\r\n\r\n\tgetColumnLayout(){\r\n\t\tif(this.modExists(\"persistence\", true)){\r\n\t\t\treturn this.modules.persistence.parseColumns(this.columnManager.getColumns());\r\n\t\t}\r\n\t}\r\n\r\n\tsetColumnLayout(layout){\r\n\t\tif(this.modExists(\"persistence\", true)){\r\n\t\t\tthis.columnManager.setColumns(this.modules.persistence.mergeDefinition(this.options.columns, layout))\r\n\t\t\treturn true;\r\n\t\t}\r\n\t\treturn false;\r\n\t}\r\n\r\n\tshowColumn(field){\r\n\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\tif(column){\r\n\t\t\tcolumn.show();\r\n\r\n\t\t\tif(this.options.responsiveLayout && this.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\tthis.modules.responsiveLayout.update();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Column Show Error - No matching column found:\", field);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\thideColumn(field){\r\n\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\tif(column){\r\n\t\t\tcolumn.hide();\r\n\r\n\t\t\tif(this.options.responsiveLayout && this.modExists(\"responsiveLayout\", true)){\r\n\t\t\t\tthis.modules.responsiveLayout.update();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Column Hide Error - No matching column found:\", field);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\ttoggleColumn(field){\r\n\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\tif(column){\r\n\t\t\tif(column.visible){\r\n\t\t\t\tcolumn.hide();\r\n\t\t\t}else{\r\n\t\t\t\tcolumn.show();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Column Visibility Toggle Error - No matching column found:\", field);\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\taddColumn(definition, before, field){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tthis.columnManager.addColumn(definition, before, column)\r\n\t\t\t.then((column) => {\r\n\t\t\t\tresolve(column.getComponent());\r\n\t\t\t}).catch((err) => {\r\n\t\t\t\treject(err);\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\tdeleteColumn(field){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\tcolumn.delete()\r\n\t\t\t\t.then(() => {\r\n\t\t\t\t\tresolve();\r\n\t\t\t\t}).catch((err) => {\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Delete Error - No matching column found:\", field);\r\n\t\t\t\treject();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tupdateColumnDefinition(field, definition){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\tcolumn.updateDefinition(definition)\r\n\t\t\t\t.then((col) => {\r\n\t\t\t\t\tresolve(col);\r\n\t\t\t\t}).catch((err) => {\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Update Error - No matching column found:\", field);\r\n\t\t\t\treject();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tmoveColumn(from, to, after){\r\n\t\tvar fromColumn = this.columnManager.findColumn(from);\r\n\t\tvar toColumn = this.columnManager.findColumn(to);\r\n\r\n\t\tif(fromColumn){\r\n\t\t\tif(toColumn){\r\n\t\t\t\tthis.columnManager.moveColumn(fromColumn, toColumn, after)\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Move Error - No matching column found:\", toColumn);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Move Error - No matching column found:\", from);\r\n\t\t}\r\n\t}\r\n\r\n\t//scroll to column in DOM\r\n\tscrollToColumn(field, position, ifVisible){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\tthis.columnManager.scrollToColumn(column, position, ifVisible)\r\n\t\t\t\t.then(()=>{\r\n\t\t\t\t\tresolve();\r\n\t\t\t\t})\r\n\t\t\t\t.catch((err)=>{\r\n\t\t\t\t\treject(err);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Scroll Error - No matching column found:\", field);\r\n\t\t\t\treject(\"Scroll Error - No matching column found\");\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\t//////////// Localization Functions ////////////\r\n\tsetLocale(locale){\r\n\t\tthis.modules.localize.setLocale(locale);\r\n\t}\r\n\r\n\tgetLocale(){\r\n\t\treturn this.modules.localize.getLocale();\r\n\t}\r\n\r\n\tgetLang(locale){\r\n\t\treturn this.modules.localize.getLang(locale);\r\n\t}\r\n\r\n\t//////////// General Public Functions ////////////\r\n\t//redraw list without updating data\r\n\tredraw(force){\r\n\t\tthis.columnManager.redraw(force);\r\n\t\tthis.rowManager.redraw(force);\r\n\t}\r\n\r\n\tsetHeight(height){\r\n\r\n\t\tif(this.rowManager.renderMode !== \"classic\"){\r\n\t\t\tthis.options.height = isNaN(height) ? height : height + \"px\";\r\n\t\t\tthis.element.style.height = this.options.height;\r\n\t\t\tthis.rowManager.setRenderMode();\r\n\t\t\tthis.rowManager.redraw();\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"setHeight function is not available in classic render mode\");\r\n\t\t}\r\n\t}\r\n\r\n\t///////////////////// Sorting ////////////////////\r\n\tsetSort(sortList, dir){\r\n\t\tif(this.modExists(\"sort\", true)){\r\n\t\t\tthis.modules.sort.setSort(sortList, dir);\r\n\t\t\tthis.rowManager.sorterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\tgetSorters(){\r\n\t\tif(this.modExists(\"sort\", true)){\r\n\t\t\treturn this.modules.sort.getSort();\r\n\t\t}\r\n\t}\r\n\r\n\tclearSort(){\r\n\t\tif(this.modExists(\"sort\", true)){\r\n\t\t\tthis.modules.sort.clear();\r\n\t\t\tthis.rowManager.sorterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t///////////////////// Filtering ////////////////////\r\n\r\n\t//set standard filters\r\n\tsetFilter(field, type, value, params){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.modules.filter.setFilter(field, type, value, params);\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t//set standard filters\r\n\trefreshFilter(){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t//add filter to array\r\n\taddFilter(field, type, value, params){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.modules.filter.addFilter(field, type, value, params);\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t//get all filters\r\n\tgetFilters(all){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\treturn this.modules.filter.getFilters(all);\r\n\t\t}\r\n\t}\r\n\r\n\tsetHeaderFilterFocus(field){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\tthis.modules.filter.setHeaderFilterFocus(column);\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Filter Focus Error - No matching column found:\", field);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetHeaderFilterValue(field) {\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\treturn this.modules.filter.getHeaderFilterValue(column);\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Filter Error - No matching column found:\", field);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tsetHeaderFilterValue(field, value){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tvar column = this.columnManager.findColumn(field);\r\n\r\n\t\t\tif(column){\r\n\t\t\t\tthis.modules.filter.setHeaderFilterValue(column, value);\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Column Filter Error - No matching column found:\", field);\r\n\t\t\t\treturn false;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetHeaderFilters(){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\treturn this.modules.filter.getHeaderFilters();\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t//remove filter from array\r\n\tremoveFilter(field, type, value){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.modules.filter.removeFilter(field, type, value);\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t//clear filters\r\n\tclearFilter(all){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.modules.filter.clearFilter(all);\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t//clear header filters\r\n\tclearHeaderFilter(){\r\n\t\tif(this.modExists(\"filter\", true)){\r\n\t\t\tthis.modules.filter.clearHeaderFilter();\r\n\t\t\tthis.rowManager.filterRefresh();\r\n\t\t}\r\n\t}\r\n\r\n\t///////////////////// select ////////////////////\r\n\tselectRow(rows){\r\n\t\tif(this.modExists(\"selectRow\", true)){\r\n\t\t\tthis.modules.selectRow.selectRows(rows);\r\n\t\t}\r\n\t}\r\n\r\n\tdeselectRow(rows){\r\n\t\tif(this.modExists(\"selectRow\", true)){\r\n\t\t\tthis.modules.selectRow.deselectRows(rows);\r\n\t\t}\r\n\t}\r\n\r\n\ttoggleSelectRow(row){\r\n\t\tif(this.modExists(\"selectRow\", true)){\r\n\t\t\tthis.modules.selectRow.toggleRow(row);\r\n\t\t}\r\n\t}\r\n\r\n\tgetSelectedRows(){\r\n\t\tif(this.modExists(\"selectRow\", true)){\r\n\t\t\treturn this.modules.selectRow.getSelectedRows();\r\n\t\t}\r\n\t}\r\n\r\n\tgetSelectedData(){\r\n\t\tif(this.modExists(\"selectRow\", true)){\r\n\t\t\treturn this.modules.selectRow.getSelectedData();\r\n\t\t}\r\n\t}\r\n\r\n\t///////////////////// validation ////////////////////\r\n\tgetInvalidCells(){\r\n\t\tif(this.modExists(\"validate\", true)){\r\n\t\t\treturn this.modules.validate.getInvalidCells();\r\n\t\t}\r\n\t}\r\n\r\n\tclearCellValidation(cells){\r\n\r\n\t\tif(this.modExists(\"validate\", true)){\r\n\r\n\t\t\tif(!cells){\r\n\t\t\t\tcells = this.modules.validate.getInvalidCells();\r\n\t\t\t}\r\n\r\n\t\t\tif(!Array.isArray(cells)){\r\n\t\t\t\tcells = [cells];\r\n\t\t\t}\r\n\r\n\t\t\tcells.forEach((cell) => {\r\n\t\t\t\tthis.modules.validate.clearValidation(cell._getSelf());\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\tvalidate(cells){\r\n\t\tvar output = [];\r\n\r\n\t\t//clear row data\r\n\t\tthis.rowManager.rows.forEach(function(row){\r\n\t\t\tvar valid = row.validate();\r\n\r\n\t\t\tif(valid !== true){\r\n\t\t\t\toutput = output.concat(valid);\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output.length ? output : true;\r\n\t}\r\n\r\n\t//////////// Pagination Functions ////////////\r\n\tsetMaxPage(max){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\tthis.modules.page.setMaxPage(max);\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tsetPage(page){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\treturn this.modules.page.setPage(page);\r\n\t\t}else{\r\n\t\t\treturn new Promise((resolve, reject) => { reject() });\r\n\t\t}\r\n\t}\r\n\r\n\tsetPageToRow(row){\r\n\t\treturn new Promise((resolve, reject) => {\r\n\t\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\t\trow = this.rowManager.findRow(row);\r\n\r\n\t\t\t\tif(row){\r\n\t\t\t\t\tthis.modules.page.setPageToRow(row)\r\n\t\t\t\t\t.then(()=>{\r\n\t\t\t\t\t\tresolve();\r\n\t\t\t\t\t})\r\n\t\t\t\t\t.catch(()=>{\r\n\t\t\t\t\t\treject();\r\n\t\t\t\t\t});\r\n\t\t\t\t}else{\r\n\t\t\t\t\treject();\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\treject();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tsetPageSize(size){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\tthis.modules.page.setPageSize(size);\r\n\t\t\tthis.modules.page.setPage(1).then(()=>{}).catch(()=>{});\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetPageSize(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\", true)){\r\n\t\t\treturn this.modules.page.getPageSize();\r\n\t\t}\r\n\t}\r\n\r\n\tpreviousPage(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\tthis.modules.page.previousPage();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tnextPage(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\tthis.modules.page.nextPage();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetPage(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\treturn this.modules.page.getPage();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetPageMax(){\r\n\t\tif(this.options.pagination && this.modExists(\"page\")){\r\n\t\t\treturn this.modules.page.getPageMax();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t///////////////// Grouping Functions ///////////////\r\n\tsetGroupBy(groups){\r\n\t\tif(this.modExists(\"groupRows\", true)){\r\n\t\t\tthis.options.groupBy = groups;\r\n\t\t\tthis.modules.groupRows.initialize();\r\n\t\t\tthis.rowManager.refreshActiveData(\"display\");\r\n\r\n\t\t\tif(this.options.persistence && this.modExists(\"persistence\", true) && this.modules.persistence.config.group){\r\n\t\t\t\tthis.modules.persistence.save(\"group\");\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tsetGroupValues(groupValues){\r\n\t\tif(this.modExists(\"groupRows\", true)){\r\n\t\t\tthis.options.groupValues = groupValues;\r\n\t\t\tthis.modules.groupRows.initialize();\r\n\t\t\tthis.rowManager.refreshActiveData(\"display\");\r\n\r\n\t\t\tif(this.options.persistence && this.modExists(\"persistence\", true) && this.modules.persistence.config.group){\r\n\t\t\t\tthis.modules.persistence.save(\"group\");\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tsetGroupStartOpen(values){\r\n\t\tif(this.modExists(\"groupRows\", true)){\r\n\t\t\tthis.options.groupStartOpen = values;\r\n\t\t\tthis.modules.groupRows.initialize();\r\n\t\t\tif(this.options.groupBy){\r\n\t\t\t\tthis.rowManager.refreshActiveData(\"group\");\r\n\r\n\t\t\t\tif(this.options.persistence && this.modExists(\"persistence\", true) && this.modules.persistence.config.group){\r\n\t\t\t\t\tthis.modules.persistence.save(\"group\");\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Grouping Update - cant refresh view, no groups have been set\");\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tsetGroupHeader(values){\r\n\t\tif(this.modExists(\"groupRows\", true)){\r\n\t\t\tthis.options.groupHeader = values;\r\n\t\t\tthis.modules.groupRows.initialize();\r\n\t\t\tif(this.options.groupBy){\r\n\t\t\t\tthis.rowManager.refreshActiveData(\"group\");\r\n\r\n\t\t\t\tif(this.options.persistence && this.modExists(\"persistence\", true) && this.modules.persistence.config.group){\r\n\t\t\t\t\tthis.modules.persistence.save(\"group\");\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Grouping Update - cant refresh view, no groups have been set\");\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetGroups(values){\r\n\t\tif(this.modExists(\"groupRows\", true)){\r\n\t\t\treturn this.modules.groupRows.getGroups(true);\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t// get grouped table data in the same format as getData()\r\n\tgetGroupedData(){\r\n\t\tif (this.modExists(\"groupRows\", true)){\r\n\t\t\treturn this.options.groupBy ?\r\n\t\t\tthis.modules.groupRows.getGroupedData() : this.getData()\r\n\t\t}\r\n\t}\r\n\r\n\tgetEditedCells(){\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\treturn this.modules.edit.getEditedCells();\r\n\t\t}\r\n\t}\r\n\r\n\tclearCellEdited(cells){\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\r\n\t\t\tif(!cells){\r\n\t\t\t\tcells = this.modules.edit.getEditedCells();\r\n\t\t\t}\r\n\r\n\t\t\tif(!Array.isArray(cells)){\r\n\t\t\t\tcells = [cells];\r\n\t\t\t}\r\n\r\n\t\t\tcells.forEach((cell) => {\r\n\t\t\t\tthis.modules.edit.clearEdited(cell._getSelf());\r\n\t\t\t});\r\n\t\t}\r\n\t}\r\n\r\n\t///////////////// Column Calculation Functions ///////////////\r\n\tgetCalcResults(){\r\n\t\tif(this.modExists(\"columnCalcs\", true)){\r\n\t\t\treturn this.modules.columnCalcs.getResults();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\trecalc(){\r\n\t\tif(this.modExists(\"columnCalcs\", true)){\r\n\t\t\tthis.modules.columnCalcs.recalcAll(this.rowManager.activeRows);\r\n\t\t}\r\n\t}\r\n\r\n\t/////////////// Navigation Management //////////////\r\n\tnavigatePrev(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\treturn cell.nav().prev();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tnavigateNext(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\treturn cell.nav().next();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tnavigateLeft(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\treturn cell.nav().left();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tnavigateRight(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\treturn cell.nav().right();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tnavigateUp(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\treturn cell.nav().up();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\tnavigateDown(){\r\n\t\tvar cell = false;\r\n\r\n\t\tif(this.modExists(\"edit\", true)){\r\n\t\t\tcell = this.modules.edit.currentCell;\r\n\r\n\t\t\tif(cell){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t\treturn cell.nav().down();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn false;\r\n\t}\r\n\r\n\t/////////////// History Management //////////////\r\n\tundo(){\r\n\t\tif(this.options.history && this.modExists(\"history\", true)){\r\n\t\t\treturn this.modules.history.undo();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tredo(){\r\n\t\tif(this.options.history && this.modExists(\"history\", true)){\r\n\t\t\treturn this.modules.history.redo();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetHistoryUndoSize(){\r\n\t\tif(this.options.history && this.modExists(\"history\", true)){\r\n\t\t\treturn this.modules.history.getHistoryUndoSize();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tgetHistoryRedoSize(){\r\n\t\tif(this.options.history && this.modExists(\"history\", true)){\r\n\t\t\treturn this.modules.history.getHistoryRedoSize();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\tclearHistory(){\r\n\t\tif(this.options.history && this.modExists(\"history\", true)){\r\n\t\t\treturn this.modules.history.clear();\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t/////////////// Download Management //////////////\r\n\tdownload(type, filename, options, active){\r\n\t\tif(this.modExists(\"download\", true)){\r\n\t\t\tthis.modules.download.download(type, filename, options, active);\r\n\t\t}\r\n\t}\r\n\r\n\tdownloadToTab(type, filename, options, active){\r\n\t\tif(this.modExists(\"download\", true)){\r\n\t\t\tthis.modules.download.download(type, filename, options, active, true);\r\n\t\t}\r\n\t}\r\n\r\n\t/////////// Inter Table Communications ///////////\r\n\ttableComms(table, module, action, data){\r\n\t\tthis.modules.comms.receive(table, module, action, data);\r\n\t}\r\n\r\n\t////////////// Extension Management //////////////\r\n\tmodExists(plugin, required){\r\n\t\tif(this.modules[plugin]){\r\n\t\t\treturn true;\r\n\t\t}else{\r\n\t\t\tif(required){\r\n\t\t\t\tconsole.error(\"Tabulator Module Not Installed: \" + plugin);\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n}\r\n\r\n//default setup options\r\nTabulator.defaultOptions = defaultOptions;\r\n\r\n//bind modules and static functionality\r\nnew ModuleBinder(Tabulator);\r\n\r\nexport default Tabulator;","export default {}","import Module from '../../core/Module.js';\r\nimport Helpers from '../../core/Helpers.js';\r\n\r\nimport defautlAccessors from './defaults/accessors.js';\r\n\r\nclass Accessor extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.allowedTypes = [\"\", \"data\", \"download\", \"clipboard\", \"print\", \"htmlOutput\"] //list of accessor types\r\n\t}\r\n\r\n\t//initialize column accessor\r\n\tinitializeColumn(column){\r\n\t\tvar match = false,\r\n\t\tconfig = {};\r\n\r\n\t\tthis.allowedTypes.forEach(function(type){\r\n\t\t\tvar key = \"accessor\" + (type.charAt(0).toUpperCase() + type.slice(1)),\r\n\t\t\taccessor;\r\n\r\n\t\t\tif(column.definition[key]){\r\n\t\t\t\taccessor = this.lookupAccessor(column.definition[key]);\r\n\r\n\t\t\t\tif(accessor){\r\n\t\t\t\t\tmatch = true;\r\n\r\n\t\t\t\t\tconfig[key] = {\r\n\t\t\t\t\t\taccessor:accessor,\r\n\t\t\t\t\t\tparams: column.definition[key + \"Params\"] || {},\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\tif(match){\r\n\t\t\tcolumn.modules.accessor = config;\r\n\t\t}\r\n\t}\r\n\r\n\tlookupAccessor(value){\r\n\t\tvar accessor = false;\r\n\r\n\t\t//set column accessor\r\n\t\tswitch(typeof value){\r\n\t\t\tcase \"string\":\r\n\t\t\tif(Accessor.accessors[value]){\r\n\t\t\t\taccessor = Accessor.accessors[value]\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Accessor Error - No such accessor found, ignoring: \", value);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"function\":\r\n\t\t\taccessor = value;\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\treturn accessor;\r\n\t}\r\n\r\n\t//apply accessor to row\r\n\ttransformRow(row, type){\r\n\t\tvar key = \"accessor\" + (type.charAt(0).toUpperCase() + type.slice(1)),\r\n\t\trowComponent = row.getComponent();\r\n\r\n\t\t//clone data object with deep copy to isolate internal data from returned result\r\n\t\tvar data = Helpers.deepClone(row.data || {});\r\n\r\n\t\tthis.table.columnManager.traverse(function(column){\r\n\t\t\tvar value, accessor, params, colCompnent;\r\n\r\n\t\t\tif(column.modules.accessor){\r\n\r\n\t\t\t\taccessor = column.modules.accessor[key] || column.modules.accessor.accessor || false;\r\n\r\n\t\t\t\tif(accessor){\r\n\t\t\t\t\tvalue = column.getFieldValue(data);\r\n\r\n\t\t\t\t\tif(value != \"undefined\"){\r\n\t\t\t\t\t\tcolCompnent = column.getComponent();\r\n\t\t\t\t\t\tparams = typeof accessor.params === \"function\" ? accessor.params(value, data, type, colCompnent, rowComponent) : accessor.params;\r\n\t\t\t\t\t\tcolumn.setFieldValue(data, accessor.accessor(value, data, type, params, colCompnent, rowComponent));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn data;\r\n\t}\r\n}\r\n\r\n//load defaults\r\nAccessor.moduleName = \"accessor\";\r\nAccessor.accessors = defautlAccessors;\r\n\r\nexport default Accessor;","export default {\r\n\tmethod: \"GET\",\r\n};","export default function(url, config, params){\r\n\tif(url){\r\n\t\tif(params && Object.keys(params).length){\r\n\t\t\tif(!config.method || config.method.toLowerCase() == \"get\"){\r\n\t\t\t\tconfig.method = \"get\";\r\n\r\n\t\t\t\turl += (url.includes(\"?\") ? \"&\" : \"?\") + this.modules.ajax.serializeParams(params);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn url;\r\n};","export default function(url, config, params){\r\n\tvar contentType;\r\n\r\n\treturn new Promise((resolve, reject) => {\r\n\t\t//set url\r\n\t\turl = this.urlGenerator.call(this.table, url, config, params);\r\n\r\n\t\t//set body content if not GET request\r\n\t\tif(config.method.toUpperCase() != \"GET\"){\r\n\t\t\tcontentType = typeof this.table.options.ajaxContentType === \"object\" ? this.table.options.ajaxContentType : this.contentTypeFormatters[this.table.options.ajaxContentType];\r\n\t\t\tif(contentType){\r\n\r\n\t\t\t\tfor(var key in contentType.headers){\r\n\t\t\t\t\tif(!config.headers){\r\n\t\t\t\t\t\tconfig.headers = {};\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(typeof config.headers[key] === \"undefined\"){\r\n\t\t\t\t\t\tconfig.headers[key] = contentType.headers[key];\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tconfig.body = contentType.body.call(this, url, config, params);\r\n\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Ajax Error - Invalid ajaxContentType value:\", this.table.options.ajaxContentType);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(url){\r\n\t\t\t//configure headers\r\n\t\t\tif(typeof config.headers === \"undefined\"){\r\n\t\t\t\tconfig.headers = {};\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof config.headers.Accept === \"undefined\"){\r\n\t\t\t\tconfig.headers.Accept = \"application/json\";\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof config.headers[\"X-Requested-With\"] === \"undefined\"){\r\n\t\t\t\tconfig.headers[\"X-Requested-With\"] = \"XMLHttpRequest\";\r\n\t\t\t}\r\n\r\n\t\t\tif(typeof config.mode === \"undefined\"){\r\n\t\t\t\tconfig.mode = \"cors\";\r\n\t\t\t}\r\n\r\n\t\t\tif(config.mode == \"cors\"){\r\n\r\n\t\t\t\tif(typeof config.headers[\"Access-Control-Allow-Origin\"] === \"undefined\"){\r\n\t\t\t\t\tconfig.headers[\"Access-Control-Allow-Origin\"] = window.location.origin;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(typeof config.credentials === \"undefined\"){\r\n\t\t\t\t\tconfig.credentials = 'same-origin';\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\tif(typeof config.credentials === \"undefined\"){\r\n\t\t\t\t\tconfig.credentials = 'include';\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//send request\r\n\t\t\tfetch(url, config)\r\n\t\t\t.then((response)=>{\r\n\t\t\t\tif(response.ok) {\r\n\t\t\t\t\tresponse.json()\r\n\t\t\t\t\t.then((data)=>{\r\n\t\t\t\t\t\tresolve(data);\r\n\t\t\t\t\t}).catch((error)=>{\r\n\t\t\t\t\t\treject(error);\r\n\t\t\t\t\t\tconsole.warn(\"Ajax Load Error - Invalid JSON returned\", error);\r\n\t\t\t\t\t});\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.error(\"Ajax Load Error - Connection Error: \" + response.status, response.statusText);\r\n\t\t\t\t\treject(response);\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t\t.catch((error)=>{\r\n\t\t\t\tconsole.error(\"Ajax Load Error - Connection Error: \", error);\r\n\t\t\t\treject(error);\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"Ajax Load Error - No URL Set\");\r\n\t\t\tresolve([]);\r\n\t\t}\r\n\t});\r\n};","export default {\r\n\t\"json\":{\r\n\t\theaders:{\r\n\t\t\t'Content-Type': 'application/json',\r\n\t\t},\r\n\t\tbody:function(url, config, params){\r\n\t\t\treturn JSON.stringify(params);\r\n\t\t},\r\n\t},\r\n\t\"form\":{\r\n\t\theaders:{\r\n\t\t},\r\n\t\tbody:function(url, config, params){\r\n\t\t\tvar output = this.generateParamsList(params),\r\n\t\t\tform = new FormData();\r\n\r\n\t\t\toutput.forEach(function(item){\r\n\t\t\t\tform.append(item.key, item.value);\r\n\t\t\t});\r\n\r\n\t\t\treturn form;\r\n\t\t},\r\n\t},\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport defaultConfig from './defaults/config.js';\r\nimport defaultURLGenerator from './defaults/urlGenerator.js';\r\nimport defaultLoaderPromise from './defaults/loaderPromise.js';\r\nimport defaultContentTypeFormatters from './defaults/contentTypeFormatters.js';\r\n\r\nclass Ajax extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.config = false; //hold config object for ajax request\r\n\t\tthis.url = \"\"; //request URL\r\n\t\tthis.urlGenerator = false;\r\n\t\tthis.params = false; //request parameters\r\n\r\n\t\tthis.loaderElement = this.createLoaderElement(); //loader message div\r\n\t\tthis.msgElement = this.createMsgElement(); //message element\r\n\t\tthis.loadingElement = false;\r\n\t\tthis.errorElement = false;\r\n\t\tthis.loaderPromise = false;\r\n\r\n\t\tthis.progressiveLoad = false;\r\n\t\tthis.loading = false;\r\n\r\n\t\tthis.requestOrder = 0; //prevent requests comming out of sequence if overridden by another load request\r\n\t}\r\n\r\n\t//initialize setup options\r\n\tinitialize(){\r\n\t\tvar template;\r\n\r\n\t\tthis.loaderElement.appendChild(this.msgElement);\r\n\r\n\t\tif(this.table.options.ajaxLoaderLoading){\r\n\t\t\tif(typeof this.table.options.ajaxLoaderLoading == \"string\"){\r\n\t\t\t\ttemplate = document.createElement('template');\r\n\t\t\t\ttemplate.innerHTML = this.table.options.ajaxLoaderLoading.trim();\r\n\t\t\t\tthis.loadingElement = template.content.firstChild;\r\n\t\t\t}else{\r\n\t\t\t\tthis.loadingElement = this.table.options.ajaxLoaderLoading;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise;\r\n\r\n\t\tthis.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator;\r\n\r\n\t\tif(this.table.options.ajaxLoaderError){\r\n\t\t\tif(typeof this.table.options.ajaxLoaderError == \"string\"){\r\n\t\t\t\ttemplate = document.createElement('template');\r\n\t\t\t\ttemplate.innerHTML = this.table.options.ajaxLoaderError.trim();\r\n\t\t\t\tthis.errorElement = template.content.firstChild;\r\n\t\t\t}else{\r\n\t\t\t\tthis.errorElement = this.table.options.ajaxLoaderError;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(this.table.options.ajaxParams){\r\n\t\t\tthis.setParams(this.table.options.ajaxParams);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.ajaxConfig){\r\n\t\t\tthis.setConfig(this.table.options.ajaxConfig);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.ajaxURL){\r\n\t\t\tthis.setUrl(this.table.options.ajaxURL);\r\n\t\t}\r\n\r\n\t\tif(this.table.options.ajaxProgressiveLoad){\r\n\t\t\tif(this.table.options.pagination){\r\n\t\t\t\tthis.progressiveLoad = false;\r\n\t\t\t\tconsole.error(\"Progressive Load Error - Pagination and progressive load cannot be used at the same time\");\r\n\t\t\t}else{\r\n\t\t\t\tif(this.table.modExists(\"page\")){\r\n\t\t\t\t\tthis.progressiveLoad = this.table.options.ajaxProgressiveLoad;\r\n\t\t\t\t\tthis.table.modules.page.initializeProgressive(this.progressiveLoad);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.error(\"Pagination plugin is required for progressive ajax loading\");\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tcreateLoaderElement(){\r\n\t\tvar el = document.createElement(\"div\");\r\n\t\tel.classList.add(\"tabulator-loader\");\r\n\t\treturn el;\r\n\t}\r\n\r\n\tcreateMsgElement(){\r\n\t\tvar el = document.createElement(\"div\");\r\n\r\n\t\tel.classList.add(\"tabulator-loader-msg\");\r\n\t\tel.setAttribute(\"role\", \"alert\");\r\n\r\n\t\treturn el;\r\n\t}\r\n\r\n\t//set ajax params\r\n\tsetParams(params, update){\r\n\t\tif(update){\r\n\t\t\tthis.params = this.params || {};\r\n\r\n\t\t\tfor(let key in params){\r\n\t\t\t\tthis.params[key] = params[key];\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.params = params;\r\n\t\t}\r\n\t}\r\n\r\n\tgetParams(){\r\n\t\treturn this.params || {};\r\n\t}\r\n\r\n\t//load config object\r\n\tsetConfig(config){\r\n\t\tthis._loadDefaultConfig();\r\n\r\n\t\tif(typeof config == \"string\"){\r\n\t\t\tthis.config.method = config;\r\n\t\t}else{\r\n\t\t\tfor(let key in config){\r\n\t\t\t\tthis.config[key] = config[key];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//create config object from default\r\n\t_loadDefaultConfig(force){\r\n\t\tif(!this.config || force){\r\n\r\n\t\t\tthis.config = {};\r\n\r\n\t\t\t//load base config from defaults\r\n\t\t\tfor(let key in Ajax.defaultConfig){\r\n\t\t\t\tthis.config[key] = Ajax.defaultConfig[key];\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//set request url\r\n\tsetUrl(url){\r\n\t\tthis.url = url;\r\n\t}\r\n\r\n\t//get request url\r\n\tgetUrl(){\r\n\t\treturn this.url;\r\n\t}\r\n\r\n\t//lstandard loading function\r\n\tloadData(inPosition, columnsChanged){\r\n\t\tif(this.progressiveLoad){\r\n\t\t\treturn this._loadDataProgressive();\r\n\t\t}else{\r\n\t\t\treturn this._loadDataStandard(inPosition, columnsChanged);\r\n\t\t}\r\n\t}\r\n\r\n\tnextPage(diff){\r\n\t\tvar margin;\r\n\r\n\t\tif(!this.loading){\r\n\r\n\t\t\tmargin = this.table.options.ajaxProgressiveLoadScrollMargin || (this.table.rowManager.getElement().clientHeight * 2);\r\n\r\n\t\t\tif(diff < margin){\r\n\t\t\t\tthis.table.modules.page.nextPage()\r\n\t\t\t\t.then(()=>{}).catch(()=>{});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tblockActiveRequest(){\r\n\t\tthis.requestOrder ++;\r\n\t}\r\n\r\n\t_loadDataProgressive(){\r\n\t\tthis.table.rowManager.setData([]);\r\n\t\treturn this.table.modules.page.setPage(1);\r\n\t}\r\n\r\n\t_loadDataStandard(inPosition, columnsChanged){\r\n\t\treturn new Promise((resolve, reject)=>{\r\n\t\t\tthis.sendRequest(inPosition)\r\n\t\t\t.then((data)=>{\r\n\t\t\t\tthis.table.rowManager.setData(data, inPosition, columnsChanged)\r\n\t\t\t\t.then(()=>{\r\n\t\t\t\t\tresolve();\r\n\t\t\t\t})\r\n\t\t\t\t.catch((e)=>{\r\n\t\t\t\t\treject(e)\r\n\t\t\t\t});\r\n\t\t\t})\r\n\t\t\t.catch((e)=>{\r\n\t\t\t\treject(e)\r\n\t\t\t});\r\n\t\t});\r\n\t}\r\n\r\n\tgenerateParamsList(data, prefix){\r\n\t\tvar output = [];\r\n\r\n\t\tprefix = prefix || \"\";\r\n\r\n\t\tif(Array.isArray(data)){\r\n\t\t\tdata.forEach((item, i) => {\r\n\t\t\t\toutput = output.concat(this.generateParamsList(item, prefix ? prefix + \"[\" + i + \"]\" : i));\r\n\t\t\t});\r\n\t\t}else if (typeof data === \"object\"){\r\n\t\t\tfor (var key in data){\r\n\t\t\t\toutput = output.concat(this.generateParamsList(data[key], prefix ? prefix + \"[\" + key + \"]\" : key));\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\toutput.push({key:prefix, value:data});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tserializeParams(params){\r\n\t\tvar output = this.generateParamsList(params),\r\n\t\tencoded = [];\r\n\r\n\t\toutput.forEach(function(item){\r\n\t\t\tencoded.push(encodeURIComponent(item.key) + \"=\" + encodeURIComponent(item.value));\r\n\t\t});\r\n\r\n\t\treturn encoded.join(\"&\");\r\n\t}\r\n\r\n\t//send ajax request\r\n\tsendRequest(silent){\r\n\t\tvar url = this.url,\r\n\t\trequestNo, esc, query;\r\n\r\n\t\tthis.requestOrder ++;\r\n\t\trequestNo = this.requestOrder;\r\n\r\n\t\tthis._loadDefaultConfig();\r\n\r\n\t\treturn new Promise((resolve, reject)=>{\r\n\t\t\tif(this.table.options.ajaxRequesting.call(this.table, this.url, this.params) !== false){\r\n\r\n\t\t\t\tthis.loading = true;\r\n\r\n\t\t\t\tif(!silent){\r\n\t\t\t\t\tthis.showLoader();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tthis.loaderPromise(url, this.config, this.params).then((data)=>{\r\n\t\t\t\t\tif(requestNo === this.requestOrder){\r\n\t\t\t\t\t\tif(this.table.options.ajaxResponse){\r\n\t\t\t\t\t\t\tdata = this.table.options.ajaxResponse.call(this.table, this.url, this.params, data);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\tresolve(data);\r\n\r\n\t\t\t\t\t\tthis.hideLoader();\r\n\t\t\t\t\t\tthis.loading = false;\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tconsole.warn(\"Ajax Response Blocked - An active ajax request was blocked by an attempt to change table data while the request was being made\");\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t})\r\n\t\t\t\t.catch((error)=>{\r\n\t\t\t\t\tconsole.error(\"Ajax Load Error: \", error);\r\n\t\t\t\t\tthis.table.options.ajaxError.call(this.table, error);\r\n\r\n\t\t\t\t\tthis.showError();\r\n\r\n\t\t\t\t\tsetTimeout(() => {\r\n\t\t\t\t\t\tthis.hideLoader();\r\n\t\t\t\t\t}, 3000);\r\n\r\n\t\t\t\t\tthis.loading = false;\r\n\r\n\t\t\t\t\treject(error);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\treject();\r\n\t\t\t}\r\n\t\t});\r\n\t}\r\n\r\n\tshowLoader(){\r\n\t\tvar shouldLoad = typeof this.table.options.ajaxLoader === \"function\" ? this.table.options.ajaxLoader() : this.table.options.ajaxLoader;\r\n\r\n\t\tif(shouldLoad){\r\n\r\n\t\t\tthis.hideLoader();\r\n\r\n\t\t\twhile(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);\r\n\t\t\tthis.msgElement.classList.remove(\"tabulator-error\");\r\n\t\t\tthis.msgElement.classList.add(\"tabulator-loading\");\r\n\r\n\t\t\tif(this.loadingElement){\r\n\t\t\t\tthis.msgElement.appendChild(this.loadingElement);\r\n\t\t\t}else{\r\n\t\t\t\tthis.msgElement.innerHTML = this.table.modules.localize.getText(\"ajax|loading\");\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.element.appendChild(this.loaderElement);\r\n\t\t}\r\n\t}\r\n\r\n\tshowError(){\r\n\t\tthis.hideLoader();\r\n\r\n\t\twhile(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);\r\n\t\tthis.msgElement.classList.remove(\"tabulator-loading\");\r\n\t\tthis.msgElement.classList.add(\"tabulator-error\");\r\n\r\n\t\tif(this.errorElement){\r\n\t\t\tthis.msgElement.appendChild(this.errorElement);\r\n\t\t}else{\r\n\t\t\tthis.msgElement.innerHTML = this.table.modules.localize.getText(\"ajax|error\");\r\n\t\t}\r\n\r\n\t\tthis.table.element.appendChild(this.loaderElement);\r\n\t}\r\n\r\n\thideLoader(){\r\n\t\tif(this.loaderElement.parentNode){\r\n\t\t\tthis.loaderElement.parentNode.removeChild(this.loaderElement);\r\n\t\t}\r\n\t}\r\n}\r\n\r\nAjax.moduleName = \"ajax\";\r\n\r\n//load defaults\r\nAjax.defaultConfig = defaultConfig;\r\nAjax.defaultURLGenerator = defaultURLGenerator;\r\nAjax.defaultLoaderPromise = defaultLoaderPromise;\r\nAjax.contentTypeFormatters = defaultContentTypeFormatters;\r\n\r\nexport default Ajax;","export default {\r\n\treplace:function(rows){\r\n\t\treturn this.table.setData(rows);\r\n\t},\r\n\tupdate:function(rows){\r\n\t\treturn this.table.updateOrAddData(rows);\r\n\t},\r\n\tinsert:function(rows){\r\n\t\treturn this.table.addData(rows);\r\n\t},\r\n};","export default {\r\n\ttable:function(clipboard){\r\n\t\tvar data = [],\r\n\t\tsuccess = false,\r\n\t\theaderFindSuccess = true,\r\n\t\tcolumns = this.table.columnManager.columns,\r\n\t\tcolumnMap = [],\r\n\t\trows = [];\r\n\r\n\t\t//get data from clipboard into array of columns and rows.\r\n\t\tclipboard = clipboard.split(\"\\n\");\r\n\r\n\t\tclipboard.forEach(function(row){\r\n\t\t\tdata.push(row.split(\"\\t\"));\r\n\t\t});\r\n\r\n\t\tif(data.length && !(data.length === 1 && data[0].length < 2)){\r\n\t\t\tsuccess = true;\r\n\r\n\t\t\t//check if headers are present by title\r\n\t\t\tdata[0].forEach(function(value){\r\n\t\t\t\tvar column = columns.find(function(column){\r\n\t\t\t\t\treturn value && column.definition.title && value.trim() && column.definition.title.trim() === value.trim();\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif(column){\r\n\t\t\t\t\tcolumnMap.push(column);\r\n\t\t\t\t}else{\r\n\t\t\t\t\theaderFindSuccess = false;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\t//check if column headers are present by field\r\n\t\t\tif(!headerFindSuccess){\r\n\t\t\t\theaderFindSuccess = true;\r\n\t\t\t\tcolumnMap = [];\r\n\r\n\t\t\t\tdata[0].forEach(function(value){\r\n\t\t\t\t\tvar column = columns.find(function(column){\r\n\t\t\t\t\t\treturn value && column.field && value.trim() && column.field.trim() === value.trim();\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif(column){\r\n\t\t\t\t\t\tcolumnMap.push(column);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\theaderFindSuccess = false;\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\tif(!headerFindSuccess){\r\n\t\t\t\t\tcolumnMap = this.table.columnManager.columnsByIndex;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t//remove header row if found\r\n\t\t\tif(headerFindSuccess){\r\n\t\t\t\tdata.shift();\r\n\t\t\t}\r\n\r\n\t\t\tdata.forEach(function(item){\r\n\t\t\t\tvar row = {};\r\n\r\n\t\t\t\titem.forEach(function(value, i){\r\n\t\t\t\t\tif(columnMap[i]){\r\n\t\t\t\t\t\trow[columnMap[i].field] = value;\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\t\trows.push(row);\r\n\t\t\t});\r\n\r\n\t\t\treturn rows;\r\n\t\t}else{\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport defaultPasteActions from './defaults/pasteActions.js';\r\nimport defaultPasteParsers from './defaults/pasteParsers.js';\r\n\r\nclass Clipboard extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.mode = true;\r\n\t\tthis.pasteParser = function(){};\r\n\t\tthis.pasteAction = function(){};\r\n\t\tthis.customSelection = false;\r\n\t\tthis.rowRange = false;\r\n\t\tthis.blocked = true; //block copy actions not originating from this command\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tthis.mode = this.table.options.clipboard;\r\n\r\n\t\tthis.rowRange = this.table.options.clipboardCopyRowRange;\r\n\r\n\t\tif(this.mode === true || this.mode === \"copy\"){\r\n\t\t\tthis.table.element.addEventListener(\"copy\", (e) => {\r\n\t\t\t\tvar plain, html, list;\r\n\r\n\t\t\t\tif(!this.blocked){\r\n\t\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\t\tif(this.customSelection){\r\n\t\t\t\t\t\tplain = this.customSelection;\r\n\r\n\t\t\t\t\t\tif(this.table.options.clipboardCopyFormatter){\r\n\t\t\t\t\t\t\tplain = this.table.options.clipboardCopyFormatter(\"plain\", plain);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}else{\r\n\r\n\t\t\t\t\t\tvar list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, \"clipboard\");\r\n\r\n\t\t\t\t\t\thtml = this.table.modules.export.genereateHTMLTable(list);\r\n\t\t\t\t\t\tplain = html ? this.generatePlainContent(list) : \"\";\r\n\r\n\t\t\t\t\t\tif(this.table.options.clipboardCopyFormatter){\r\n\t\t\t\t\t\t\tplain = this.table.options.clipboardCopyFormatter(\"plain\", plain);\r\n\t\t\t\t\t\t\thtml = this.table.options.clipboardCopyFormatter(\"html\", html);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif (window.clipboardData && window.clipboardData.setData) {\r\n\t\t\t\t\t\twindow.clipboardData.setData('Text', plain);\r\n\t\t\t\t\t} else if (e.clipboardData && e.clipboardData.setData) {\r\n\t\t\t\t\t\te.clipboardData.setData('text/plain', plain);\r\n\t\t\t\t\t\tif(html){\r\n\t\t\t\t\t\t\te.clipboardData.setData('text/html', html);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {\r\n\t\t\t\t\t\te.originalEvent.clipboardData.setData('text/plain', plain);\r\n\t\t\t\t\t\tif(html){\r\n\t\t\t\t\t\t\te.originalEvent.clipboardData.setData('text/html', html);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tthis.table.options.clipboardCopied.call(this.table, plain, html);\r\n\r\n\t\t\t\t\tthis.reset();\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(this.mode === true || this.mode === \"paste\"){\r\n\t\t\tthis.table.element.addEventListener(\"paste\", (e) => {\r\n\t\t\t\tthis.paste(e);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tthis.setPasteParser(this.table.options.clipboardPasteParser);\r\n\t\tthis.setPasteAction(this.table.options.clipboardPasteAction);\r\n\t}\r\n\r\n\treset(){\r\n\t\tthis.blocked = true;\r\n\t\tthis.customSelection = false;\r\n\t}\r\n\r\n\tgeneratePlainContent (list) {\r\n\t\tvar output = [];\r\n\r\n\t\tlist.forEach((row) => {\r\n\t\t\tvar rowData = [];\r\n\r\n\t\t\trow.columns.forEach((col) => {\r\n\t\t\t\tvar value = \"\";\r\n\r\n\t\t\t\tif(col){\r\n\r\n\t\t\t\t\tif(row.type === \"group\"){\r\n\t\t\t\t\t\tcol.value = col.component.getKey();\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tif(col.value === null){\r\n\t\t\t\t\t\tvalue = \"\";\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tswitch(typeof col.value){\r\n\t\t\t\t\t\t\tcase \"object\":\r\n\t\t\t\t\t\t\tvalue = JSON.stringify(col.value);\r\n\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\tcase \"undefined\":\r\n\t\t\t\t\t\t\tvalue = \"\";\r\n\t\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\t\tdefault:\r\n\t\t\t\t\t\t\tvalue = col.value;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\trowData.push(value);\r\n\t\t\t});\r\n\r\n\t\t\toutput.push(rowData.join(\"\\t\"));\r\n\t\t});\r\n\r\n\t\treturn output.join(\"\\n\");\r\n\t}\r\n\r\n\tcopy (range, internal) {\r\n\t\tvar range, sel, textRange;\r\n\t\tthis.blocked = false;\r\n\t\tthis.customSelection = false;\r\n\r\n\t\tif (this.mode === true || this.mode === \"copy\") {\r\n\r\n\t\t\tthis.rowRange = range || this.table.options.clipboardCopyRowRange;\r\n\r\n\t\t\tif (typeof window.getSelection != \"undefined\" && typeof document.createRange != \"undefined\") {\r\n\t\t\t\trange = document.createRange();\r\n\t\t\t\trange.selectNodeContents(this.table.element);\r\n\t\t\t\tsel = window.getSelection();\r\n\r\n\t\t\t\tif (sel.toString() && internal) {\r\n\t\t\t\t\tthis.customSelection = sel.toString();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tsel.removeAllRanges();\r\n\t\t\t\tsel.addRange(range);\r\n\t\t\t} else if (typeof document.selection != \"undefined\" && typeof document.body.createTextRange != \"undefined\") {\r\n\t\t\t\ttextRange = document.body.createTextRange();\r\n\t\t\t\ttextRange.moveToElementText(this.table.element);\r\n\t\t\t\ttextRange.select();\r\n\t\t\t}\r\n\r\n\t\t\tdocument.execCommand('copy');\r\n\r\n\t\t\tif (sel) {\r\n\t\t\t\tsel.removeAllRanges();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//PASTE EVENT HANDLING\r\n\tsetPasteAction(action){\r\n\r\n\t\tswitch(typeof action){\r\n\t\t\tcase \"string\":\r\n\t\t\tthis.pasteAction = Clipboard.pasteActions[action];\r\n\r\n\t\t\tif(!this.pasteAction){\r\n\t\t\t\tconsole.warn(\"Clipboard Error - No such paste action found:\", action);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"function\":\r\n\t\t\tthis.pasteAction = action;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tsetPasteParser(parser){\r\n\t\tswitch(typeof parser){\r\n\t\t\tcase \"string\":\r\n\t\t\tthis.pasteParser = Clipboard.pasteParsers[parser];\r\n\r\n\t\t\tif(!this.pasteParser){\r\n\t\t\t\tconsole.warn(\"Clipboard Error - No such paste parser found:\", parser);\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"function\":\r\n\t\t\tthis.pasteParser = parser;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tpaste(e){\r\n\t\tvar data, rowData, rows;\r\n\r\n\t\tif(this.checkPaseOrigin(e)){\r\n\r\n\t\t\tdata = this.getPasteData(e);\r\n\r\n\t\t\trowData = this.pasteParser.call(this, data);\r\n\r\n\t\t\tif(rowData){\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\tif(this.table.modExists(\"mutator\")){\r\n\t\t\t\t\trowData = this.mutateData(rowData);\r\n\t\t\t\t}\r\n\r\n\t\t\t\trows = this.pasteAction.call(this, rowData);\r\n\t\t\t\tthis.table.options.clipboardPasted.call(this.table, data, rowData, rows);\r\n\t\t\t}else{\r\n\t\t\t\tthis.table.options.clipboardPasteError.call(this.table, data);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tmutateData(data){\r\n\t\tvar output = [];\r\n\r\n\t\tif(Array.isArray(data)){\r\n\t\t\tdata.forEach((row) => {\r\n\t\t\t\toutput.push(this.table.modules.mutator.transformRow(row, \"clipboard\"));\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\toutput = data;\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\r\n\tcheckPaseOrigin(e){\r\n\t\tvar valid = true;\r\n\r\n\t\tif(e.target.tagName != \"DIV\" || this.table.modules.edit.currentCell){\r\n\t\t\tvalid = false;\r\n\t\t}\r\n\r\n\t\treturn valid;\r\n\t}\r\n\r\n\tgetPasteData(e){\r\n\t\tvar data;\r\n\r\n\t\tif (window.clipboardData && window.clipboardData.getData) {\r\n\t\t\tdata = window.clipboardData.getData('Text');\r\n\t\t} else if (e.clipboardData && e.clipboardData.getData) {\r\n\t\t\tdata = e.clipboardData.getData('text/plain');\r\n\t\t} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {\r\n\t\t\tdata = e.originalEvent.clipboardData.getData('text/plain');\r\n\t\t}\r\n\r\n\t\treturn data;\r\n\t}\r\n}\r\n\r\nClipboard.moduleName = \"clipboard\";\r\n\r\n//load defaults\r\nClipboard.pasteActions = defaultPasteActions;\r\nClipboard.pasteParsers = defaultPasteParsers;\r\n\r\nexport default Clipboard;","class CalcComponent{\r\n\tconstructor (row){\r\n\t\tthis._row = row;\r\n\t}\r\n\r\n\tgetData(transform){\r\n\t\treturn this._row.getData(transform);\r\n\t}\r\n\r\n\tgetElement(){\r\n\t\treturn this._row.getElement();\r\n\t}\r\n\r\n\tgetTable(){\r\n\t\treturn this._row.table;\r\n\t}\r\n\r\n\tgetCells(){\r\n\t\tvar cells = [];\r\n\r\n\t\tthis._row.getCells().forEach(function(cell){\r\n\t\t\tcells.push(cell.getComponent());\r\n\t\t});\r\n\r\n\t\treturn cells;\r\n\t}\r\n\r\n\tgetCell(column){\r\n\t\tvar cell = this._row.getCell(column);\r\n\t\treturn cell ? cell.getComponent() : false;\r\n\t}\r\n\r\n\t_getSelf(){\r\n\t\treturn this._row;\r\n\t}\r\n}\r\n\r\nexport default CalcComponent;","export default {\r\n\t\"avg\":function(values, data, calcParams){\r\n\t\tvar output = 0,\r\n\t\tprecision = typeof calcParams.precision !== \"undefined\" ? calcParams.precision : 2\r\n\r\n\t\tif(values.length){\r\n\t\t\toutput = values.reduce(function(sum, value){\r\n\t\t\t\treturn Number(sum) + Number(value);\r\n\t\t\t});\r\n\r\n\t\t\toutput = output / values.length;\r\n\r\n\t\t\toutput = precision !== false ? output.toFixed(precision) : output;\r\n\t\t}\r\n\r\n\t\treturn parseFloat(output).toString();\r\n\t},\r\n\t\"max\":function(values, data, calcParams){\r\n\t\tvar output = null,\r\n\t\tprecision = typeof calcParams.precision !== \"undefined\" ? calcParams.precision : false;\r\n\r\n\t\tvalues.forEach(function(value){\r\n\r\n\t\t\tvalue = Number(value);\r\n\r\n\t\t\tif(value > output || output === null){\r\n\t\t\t\toutput = value;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output !== null ? (precision !== false ? output.toFixed(precision) : output) : \"\";\r\n\t},\r\n\t\"min\":function(values, data, calcParams){\r\n\t\tvar output = null,\r\n\t\tprecision = typeof calcParams.precision !== \"undefined\" ? calcParams.precision : false;\r\n\r\n\t\tvalues.forEach(function(value){\r\n\r\n\t\t\tvalue = Number(value);\r\n\r\n\t\t\tif(value < output || output === null){\r\n\t\t\t\toutput = value;\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output !== null ? (precision !== false ? output.toFixed(precision) : output) : \"\";\r\n\t},\r\n\t\"sum\":function(values, data, calcParams){\r\n\t\tvar output = 0,\r\n\t\tprecision = typeof calcParams.precision !== \"undefined\" ? calcParams.precision : false;\r\n\r\n\t\tif(values.length){\r\n\t\t\tvalues.forEach(function(value){\r\n\t\t\t\tvalue = Number(value);\r\n\r\n\t\t\t\toutput += !isNaN(value) ? Number(value) : 0;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn precision !== false ? output.toFixed(precision) : output;\r\n\t},\r\n\t\"concat\":function(values, data, calcParams){\r\n\t\tvar output = 0;\r\n\r\n\t\tif(values.length){\r\n\t\t\toutput = values.reduce(function(sum, value){\r\n\t\t\t\treturn String(sum) + String(value);\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t},\r\n\t\"count\":function(values, data, calcParams){\r\n\t\tvar output = 0;\r\n\r\n\t\tif(values.length){\r\n\t\t\tvalues.forEach(function(value){\r\n\t\t\t\tif(value){\r\n\t\t\t\t\toutput ++;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t},\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport CalcComponent from './CalcComponent.js';\r\n\r\nimport Cell from '../../core/cell/Cell.js';\r\nimport Column from '../../core/column/Column.js';\r\nimport Row from '../../core/row/Row.js';\r\n\r\nimport defaultCalculations from './defaults/calculations.js';\r\n\r\nclass ColumnCalcs extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.topCalcs = [];\r\n\t\tthis.botCalcs = [];\r\n\t\tthis.genColumn = false;\r\n\t\tthis.topElement = this.createElement();\r\n\t\tthis.botElement = this.createElement();\r\n\t\tthis.topRow = false;\r\n\t\tthis.botRow = false;\r\n\t\tthis.topInitialized = false;\r\n\t\tthis.botInitialized = false;\r\n\r\n\t\tthis.initialize();\r\n\t}\r\n\r\n\tcreateElement (){\r\n\t\tvar el = document.createElement(\"div\");\r\n\t\tel.classList.add(\"tabulator-calcs-holder\");\r\n\t\treturn el;\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tthis.genColumn = new Column({field:\"value\"}, this);\r\n\t}\r\n\r\n\t//dummy functions to handle being mock column manager\r\n\tregisterColumnField(){};\r\n\r\n\t//initialize column calcs\r\n\tinitializeColumn(column){\r\n\t\tvar def = column.definition\r\n\r\n\t\tvar config = {\r\n\t\t\ttopCalcParams:def.topCalcParams || {},\r\n\t\t\tbotCalcParams:def.bottomCalcParams || {},\r\n\t\t};\r\n\r\n\t\tif(def.topCalc){\r\n\r\n\t\t\tswitch(typeof def.topCalc){\r\n\t\t\t\tcase \"string\":\r\n\t\t\t\tif(ColumnCalcs.calculations[def.topCalc]){\r\n\t\t\t\t\tconfig.topCalc = ColumnCalcs.calculations[def.topCalc]\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Column Calc Error - No such calculation found, ignoring: \", def.topCalc);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase \"function\":\r\n\t\t\t\tconfig.topCalc = def.topCalc;\r\n\t\t\t\tbreak\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif(config.topCalc){\r\n\t\t\t\tcolumn.modules.columnCalcs = config;\r\n\t\t\t\tthis.topCalcs.push(column);\r\n\r\n\t\t\t\tif(this.table.options.columnCalcs != \"group\"){\r\n\t\t\t\t\tthis.initializeTopRow();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}\r\n\r\n\t\tif(def.bottomCalc){\r\n\t\t\tswitch(typeof def.bottomCalc){\r\n\t\t\t\tcase \"string\":\r\n\t\t\t\tif(ColumnCalcs.calculations[def.bottomCalc]){\r\n\t\t\t\t\tconfig.botCalc = ColumnCalcs.calculations[def.bottomCalc]\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconsole.warn(\"Column Calc Error - No such calculation found, ignoring: \", def.bottomCalc);\r\n\t\t\t\t}\r\n\t\t\t\tbreak;\r\n\r\n\t\t\t\tcase \"function\":\r\n\t\t\t\tconfig.botCalc = def.bottomCalc;\r\n\t\t\t\tbreak\r\n\r\n\t\t\t}\r\n\r\n\t\t\tif(config.botCalc){\r\n\t\t\t\tcolumn.modules.columnCalcs = config;\r\n\t\t\t\tthis.botCalcs.push(column);\r\n\r\n\t\t\t\tif(this.table.options.columnCalcs != \"group\"){\r\n\t\t\t\t\tthis.initializeBottomRow();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t}\r\n\r\n\tremoveCalcs(){\r\n\t\tvar changed = false;\r\n\r\n\t\tif(this.topInitialized){\r\n\t\t\tthis.topInitialized = false;\r\n\t\t\tthis.topElement.parentNode.removeChild(this.topElement);\r\n\t\t\tchanged = true;\r\n\t\t}\r\n\r\n\t\tif(this.botInitialized){\r\n\t\t\tthis.botInitialized = false;\r\n\t\t\tthis.table.footerManager.remove(this.botElement);\r\n\t\t\tchanged = true;\r\n\t\t}\r\n\r\n\t\tif(changed){\r\n\t\t\tthis.table.rowManager.adjustTableSize();\r\n\t\t}\r\n\t}\r\n\r\n\tinitializeTopRow(){\r\n\t\tif(!this.topInitialized){\r\n\t\t\tthis.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);\r\n\t\t\tthis.topInitialized = true;\r\n\t\t}\r\n\t}\r\n\r\n\tinitializeBottomRow(){\r\n\t\tif(!this.botInitialized){\r\n\t\t\tthis.table.footerManager.prepend(this.botElement);\r\n\t\t\tthis.botInitialized = true;\r\n\t\t}\r\n\t}\r\n\r\n\tscrollHorizontal(left){\r\n\t\tif(this.botInitialized && this.botRow){\r\n\t\t\tthis.botRow.getElement().style.marginLeft = (-left) + \"px\";\r\n\t\t}\r\n\t}\r\n\r\n\trecalc(rows){\r\n\t\tvar data, row;\r\n\r\n\t\tif(this.topInitialized || this.botInitialized){\r\n\t\t\tdata = this.rowsToData(rows);\r\n\r\n\t\t\tif(this.topInitialized){\r\n\t\t\t\tif(this.topRow){\r\n\t\t\t\t\tthis.topRow.deleteCells();\r\n\t\t\t\t}\r\n\r\n\t\t\t\trow = this.generateRow(\"top\", this.rowsToData(rows))\r\n\t\t\t\tthis.topRow = row;\r\n\t\t\t\twhile(this.topElement.firstChild) this.topElement.removeChild(this.topElement.firstChild);\r\n\t\t\t\tthis.topElement.appendChild(row.getElement());\r\n\t\t\t\trow.initialize(true);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.botInitialized){\r\n\t\t\t\tif(this.botRow){\r\n\t\t\t\t\tthis.botRow.deleteCells();\r\n\t\t\t\t}\r\n\r\n\t\t\t\trow = this.generateRow(\"bottom\", this.rowsToData(rows))\r\n\t\t\t\tthis.botRow = row;\r\n\t\t\t\twhile(this.botElement.firstChild) this.botElement.removeChild(this.botElement.firstChild);\r\n\t\t\t\tthis.botElement.appendChild(row.getElement());\r\n\t\t\t\trow.initialize(true);\r\n\t\t\t}\r\n\r\n\t\t\tthis.table.rowManager.adjustTableSize();\r\n\r\n\t\t\t//set resizable handles\r\n\t\t\tif(this.table.modExists(\"frozenColumns\")){\r\n\t\t\t\tthis.table.modules.frozenColumns.layout();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\trecalcRowGroup(row){\r\n\t\tthis.recalcGroup(this.table.modules.groupRows.getRowGroup(row));\r\n\t}\r\n\r\n\trecalcAll(){\r\n\t\tif(this.topCalcs.length || this.botCalcs.length){\r\n\t\t\tif(this.table.options.columnCalcs !== \"group\"){\r\n\t\t\t\tthis.recalc(this.table.rowManager.activeRows);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.options.groupBy && this.table.options.columnCalcs !== \"table\"){\r\n\r\n\r\n\t\t\t\tvar groups = table.modules.groupRows.getChildGroups();\r\n\r\n\t\t\t\tgroups.forEach((group) => {\r\n\t\t\t\t\tthis.recalcGroup(group);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\trecalcGroup(group){\r\n\t\tvar data, rowData;\r\n\r\n\t\tif(group){\r\n\t\t\tif(group.calcs){\r\n\t\t\t\tif(group.calcs.bottom){\r\n\t\t\t\t\tdata = this.rowsToData(group.rows);\r\n\t\t\t\t\trowData = this.generateRowData(\"bottom\", data);\r\n\r\n\t\t\t\t\tgroup.calcs.bottom.updateData(rowData);\r\n\t\t\t\t\tgroup.calcs.bottom.reinitialize();\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(group.calcs.top){\r\n\t\t\t\t\tdata = this.rowsToData(group.rows);\r\n\t\t\t\t\trowData = this.generateRowData(\"top\", data);\r\n\r\n\t\t\t\t\tgroup.calcs.top.updateData(rowData);\r\n\t\t\t\t\tgroup.calcs.top.reinitialize();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//generate top stats row\r\n\tgenerateTopRow(rows){\r\n\t\treturn this.generateRow(\"top\", this.rowsToData(rows));\r\n\t}\r\n\t//generate bottom stats row\r\n\tgenerateBottomRow(rows){\r\n\t\treturn this.generateRow(\"bottom\", this.rowsToData(rows));\r\n\t}\r\n\r\n\trowsToData(rows){\r\n\t\tvar data = [];\r\n\r\n\t\trows.forEach((row) => {\r\n\t\t\tdata.push(row.getData());\r\n\r\n\t\t\tif(this.table.options.dataTree && this.table.options.dataTreeChildColumnCalcs){\r\n\t\t\t\tif(row.modules.dataTree.open){\r\n\t\t\t\t\tvar children = this.rowsToData(this.table.modules.dataTree.getFilteredTreeChildren(row));\r\n\t\t\t\t\tdata = data.concat(children);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn data;\r\n\t}\r\n\r\n\t//generate stats row\r\n\tgenerateRow(pos, data){\r\n\t\tvar rowData = this.generateRowData(pos, data),\r\n\t\trow;\r\n\r\n\t\tif(this.table.modExists(\"mutator\")){\r\n\t\t\tthis.table.modules.mutator.disable();\r\n\t\t}\r\n\r\n\t\trow = new Row(rowData, this, \"calc\");\r\n\r\n\t\tif(this.table.modExists(\"mutator\")){\r\n\t\t\tthis.table.modules.mutator.enable();\r\n\t\t}\r\n\r\n\t\trow.getElement().classList.add(\"tabulator-calcs\", \"tabulator-calcs-\" + pos);\r\n\r\n\t\trow.component = false;\r\n\r\n\t\trow.getComponent = () => {\r\n\t\t\tif(!this.component){\r\n\t\t\t\tthis.component = new CalcComponent(this);\r\n\t\t\t}\r\n\r\n\t\t\treturn this.component;\r\n\t\t};\r\n\r\n\t\trow.generateCells = () => {\r\n\r\n\t\t\tvar cells = [];\r\n\r\n\t\t\tthis.table.columnManager.columnsByIndex.forEach((column) => {\r\n\r\n\t\t\t\t\t//set field name of mock column\r\n\t\t\t\t\tthis.genColumn.setField(column.getField());\r\n\t\t\t\t\tthis.genColumn.hozAlign = column.hozAlign;\r\n\r\n\t\t\t\t\tif(column.definition[pos + \"CalcFormatter\"] && this.table.modExists(\"format\")){\r\n\t\t\t\t\t\tthis.genColumn.modules.format = {\r\n\t\t\t\t\t\t\tformatter: this.table.modules.format.getFormatter(column.definition[pos + \"CalcFormatter\"]),\r\n\t\t\t\t\t\t\tparams: column.definition[pos + \"CalcFormatterParams\"] || {},\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tthis.genColumn.modules.format = {\r\n\t\t\t\t\t\t\tformatter: this.table.modules.format.getFormatter(\"plaintext\"),\r\n\t\t\t\t\t\t\tparams:{}\r\n\t\t\t\t\t\t};\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\t//ensure css class defintion is replicated to calculation cell\r\n\t\t\t\t\tthis.genColumn.definition.cssClass = column.definition.cssClass;\r\n\r\n\t\t\t\t\t//generate cell and assign to correct column\r\n\t\t\t\t\tvar cell = new Cell(this.genColumn, row);\r\n\t\t\t\t\tcell.getElement();\r\n\t\t\t\t\tcell.column = column;\r\n\t\t\t\t\tcell.setWidth();\r\n\r\n\t\t\t\t\tcolumn.cells.push(cell);\r\n\t\t\t\t\tcells.push(cell);\r\n\r\n\t\t\t\t\tif(!column.visible){\r\n\t\t\t\t\t\tcell.hide();\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\r\n\t\t\tthis.cells = cells;\r\n\t\t};\r\n\r\n\t\treturn row;\r\n\t}\r\n\r\n\t//generate stats row\r\n\tgenerateRowData(pos, data){\r\n\t\tvar rowData = {},\r\n\t\tcalcs = pos == \"top\" ? this.topCalcs : this.botCalcs,\r\n\t\ttype = pos == \"top\" ? \"topCalc\" : \"botCalc\",\r\n\t\tparams, paramKey;\r\n\r\n\t\tcalcs.forEach(function(column){\r\n\t\t\tvar values = [];\r\n\r\n\t\t\tif(column.modules.columnCalcs && column.modules.columnCalcs[type]){\r\n\t\t\t\tdata.forEach(function(item){\r\n\t\t\t\t\tvalues.push(column.getFieldValue(item));\r\n\t\t\t\t});\r\n\r\n\t\t\t\tparamKey = type + \"Params\";\r\n\t\t\t\tparams = typeof column.modules.columnCalcs[paramKey] === \"function\" ? column.modules.columnCalcs[paramKey](values, data) : column.modules.columnCalcs[paramKey];\r\n\r\n\t\t\t\tcolumn.setFieldValue(rowData, column.modules.columnCalcs[type](values, data, params));\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn rowData;\r\n\t}\r\n\r\n\thasTopCalcs(){\r\n\t\treturn\t!!(this.topCalcs.length);\r\n\t}\r\n\r\n\thasBottomCalcs(){\r\n\t\treturn\t!!(this.botCalcs.length);\r\n\t}\r\n\r\n\t//handle table redraw\r\n\tredraw(){\r\n\t\tif(this.topRow){\r\n\t\t\tthis.topRow.normalizeHeight(true);\r\n\t\t}\r\n\t\tif(this.botRow){\r\n\t\t\tthis.botRow.normalizeHeight(true);\r\n\t\t}\r\n\t}\r\n\r\n\t//return the calculated\r\n\tgetResults(){\r\n\t\tvar results = {},\r\n\t\tgroups;\r\n\r\n\t\tif(this.table.options.groupBy && this.table.modExists(\"groupRows\")){\r\n\t\t\tgroups = this.table.modules.groupRows.getGroups(true);\r\n\r\n\t\t\tgroups.forEach((group) => {\r\n\t\t\t\tresults[group.getKey()] = this.getGroupResults(group);\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tresults = {\r\n\t\t\t\ttop: this.topRow ? this.topRow.getData() : {},\r\n\t\t\t\tbottom: this.botRow ? this.botRow.getData() : {},\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn results;\r\n\t}\r\n\r\n\t//get results from a group\r\n\tgetGroupResults(group){\r\n\t\tvar groupObj = group._getSelf(),\r\n\t\tsubGroups = group.getSubGroups(),\r\n\t\tsubGroupResults = {},\r\n\t\tresults = {};\r\n\r\n\t\tsubGroups.forEach((subgroup) => {\r\n\t\t\tsubGroupResults[subgroup.getKey()] = this.getGroupResults(subgroup);\r\n\t\t});\r\n\r\n\t\tresults = {\r\n\t\t\ttop: groupObj.calcs.top ? groupObj.calcs.top.getData() : {},\r\n\t\t\tbottom: groupObj.calcs.bottom ? groupObj.calcs.bottom.getData() : {},\r\n\t\t\tgroups: subGroupResults,\r\n\t\t}\r\n\r\n\t\treturn results;\r\n\t}\r\n}\r\n\r\nColumnCalcs.moduleName = \"columnCalcs\";\r\n\r\n//load defaults\r\nColumnCalcs.calculations = defaultCalculations;\r\n\r\nexport default ColumnCalcs;","import Module from '../../core/Module.js';\r\n\r\nimport Row from '../../core/row/Row.js';\r\n\r\nclass DataTree extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\r\n\t\tthis.indent = 10;\r\n\t\tthis.field = \"\";\r\n\t\tthis.collapseEl = null;\r\n\t\tthis.expandEl = null;\r\n\t\tthis.branchEl = null;\r\n\t\tthis.elementField = false;\r\n\r\n\t\tthis.startOpen = function(){};\r\n\r\n\t\tthis.displayIndex = 0;\r\n\t}\r\n\r\n\tinitialize(){\r\n\t\tvar dummyEl = null,\r\n\t\tfirstCol = this.table.columnManager.getFirstVisibileColumn(),\r\n\t\toptions = this.table.options;\r\n\r\n\t\tthis.field = options.dataTreeChildField;\r\n\t\tthis.indent = options.dataTreeChildIndent;\r\n\t\tthis.elementField = options.dataTreeElementColumn || (firstCol ? firstCol.field : false);\r\n\r\n\t\tif(options.dataTreeBranchElement){\r\n\r\n\t\t\tif(options.dataTreeBranchElement === true){\r\n\t\t\t\tthis.branchEl = document.createElement(\"div\");\r\n\t\t\t\tthis.branchEl.classList.add(\"tabulator-data-tree-branch\");\r\n\t\t\t}else{\r\n\t\t\t\tif(typeof options.dataTreeBranchElement === \"string\"){\r\n\t\t\t\t\tdummyEl = document.createElement(\"div\");\r\n\t\t\t\t\tdummyEl.innerHTML = options.dataTreeBranchElement;\r\n\t\t\t\t\tthis.branchEl = dummyEl.firstChild;\r\n\t\t\t\t}else{\r\n\t\t\t\t\tthis.branchEl = options.dataTreeBranchElement;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(options.dataTreeCollapseElement){\r\n\t\t\tif(typeof options.dataTreeCollapseElement === \"string\"){\r\n\t\t\t\tdummyEl = document.createElement(\"div\");\r\n\t\t\t\tdummyEl.innerHTML = options.dataTreeCollapseElement;\r\n\t\t\t\tthis.collapseEl = dummyEl.firstChild;\r\n\t\t\t}else{\r\n\t\t\t\tthis.collapseEl = options.dataTreeCollapseElement;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.collapseEl = document.createElement(\"div\");\r\n\t\t\tthis.collapseEl.classList.add(\"tabulator-data-tree-control\");\r\n\t\t\tthis.collapseEl.tabIndex = 0;\r\n\t\t\tthis.collapseEl.innerHTML = \"\";\r\n\t\t}\r\n\r\n\t\tif(options.dataTreeExpandElement){\r\n\t\t\tif(typeof options.dataTreeExpandElement === \"string\"){\r\n\t\t\t\tdummyEl = document.createElement(\"div\");\r\n\t\t\t\tdummyEl.innerHTML = options.dataTreeExpandElement;\r\n\t\t\t\tthis.expandEl = dummyEl.firstChild;\r\n\t\t\t}else{\r\n\t\t\t\tthis.expandEl = options.dataTreeExpandElement;\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tthis.expandEl = document.createElement(\"div\");\r\n\t\t\tthis.expandEl.classList.add(\"tabulator-data-tree-control\");\r\n\t\t\tthis.expandEl.tabIndex = 0;\r\n\t\t\tthis.expandEl.innerHTML = \"\";\r\n\t\t}\r\n\r\n\r\n\t\tswitch(typeof options.dataTreeStartExpanded){\r\n\t\t\tcase \"boolean\":\r\n\t\t\tthis.startOpen = function(row, index){\r\n\t\t\t\treturn options.dataTreeStartExpanded;\r\n\t\t\t};\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"function\":\r\n\t\t\tthis.startOpen = options.dataTreeStartExpanded;\r\n\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\tthis.startOpen = function(row, index){\r\n\t\t\t\treturn options.dataTreeStartExpanded[index];\r\n\t\t\t};\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\r\n\tinitializeRow(row){\r\n\t\tvar childArray = row.getData()[this.field];\r\n\t\tvar isArray = Array.isArray(childArray);\r\n\r\n\t\tvar children = isArray || (!isArray && typeof childArray === \"object\" && childArray !== null);\r\n\r\n\t\tif(!children && row.modules.dataTree && row.modules.dataTree.branchEl){\r\n\t\t\trow.modules.dataTree.branchEl.parentNode.removeChild(row.modules.dataTree.branchEl);\r\n\t\t}\r\n\r\n\t\tif(!children && row.modules.dataTree && row.modules.dataTree.controlEl){\r\n\t\t\trow.modules.dataTree.controlEl.parentNode.removeChild(row.modules.dataTree.controlEl);\r\n\t\t}\r\n\r\n\t\trow.modules.dataTree = {\r\n\t\t\tindex: row.modules.dataTree ? row.modules.dataTree.index : 0,\r\n\t\t\topen: children ? (row.modules.dataTree ? row.modules.dataTree.open : this.startOpen(row.getComponent(), 0)) : false,\r\n\t\t\tcontrolEl: row.modules.dataTree && children ? row.modules.dataTree.controlEl : false,\r\n\t\t\tbranchEl: row.modules.dataTree && children ? row.modules.dataTree.branchEl : false,\r\n\t\t\tparent: row.modules.dataTree ? row.modules.dataTree.parent : false,\r\n\t\t\tchildren:children,\r\n\t\t};\r\n\t}\r\n\r\n\tlayoutRow(row){\r\n\t\tvar cell = this.elementField ? row.getCell(this.elementField) : row.getCells()[0],\r\n\t\tel = cell.getElement(),\r\n\t\tconfig = row.modules.dataTree;\r\n\r\n\t\tif(config.branchEl){\r\n\t\t\tif(config.branchEl.parentNode){\r\n\t\t\t\tconfig.branchEl.parentNode.removeChild(config.branchEl);\r\n\t\t\t}\r\n\t\t\tconfig.branchEl = false;\r\n\t\t}\r\n\r\n\t\tif(config.controlEl){\r\n\t\t\tif(config.controlEl.parentNode){\r\n\t\t\t\tconfig.controlEl.parentNode.removeChild(config.controlEl);\r\n\t\t\t}\r\n\t\t\tconfig.controlEl = false;\r\n\t\t}\r\n\r\n\t\tthis.generateControlElement(row, el);\r\n\r\n\t\trow.getElement().classList.add(\"tabulator-tree-level-\" + config.index);\r\n\r\n\t\tif(config.index){\r\n\t\t\tif(this.branchEl){\r\n\t\t\t\tconfig.branchEl = this.branchEl.cloneNode(true);\r\n\t\t\t\tel.insertBefore(config.branchEl, el.firstChild);\r\n\r\n\t\t\t\tif(this.table.rtl){\r\n\t\t\t\t\tconfig.branchEl.style.marginRight = (((config.branchEl.offsetWidth + config.branchEl.style.marginLeft) * (config.index - 1)) + (config.index * this.indent)) + \"px\";\r\n\t\t\t\t}else{\r\n\t\t\t\t\tconfig.branchEl.style.marginLeft = (((config.branchEl.offsetWidth + config.branchEl.style.marginRight) * (config.index - 1)) + (config.index * this.indent)) + \"px\";\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\r\n\t\t\t\tif(this.table.rtl){\r\n\t\t\t\t\tel.style.paddingRight = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + (config.index * this.indent) + \"px\";\r\n\t\t\t\t}else{\r\n\t\t\t\t\tel.style.paddingLeft = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + (config.index * this.indent) + \"px\";\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgenerateControlElement(row, el){\r\n\t\tvar config = row.modules.dataTree,\r\n\t\tel = el || row.getCells()[0].getElement(),\r\n\t\toldControl = config.controlEl;\r\n\r\n\t\tif(config.children !== false){\r\n\r\n\t\t\tif(config.open){\r\n\t\t\t\tconfig.controlEl = this.collapseEl.cloneNode(true);\r\n\t\t\t\tconfig.controlEl.addEventListener(\"click\", (e) => {\r\n\t\t\t\t\te.stopPropagation();\r\n\t\t\t\t\tthis.collapseRow(row);\r\n\t\t\t\t});\r\n\t\t\t}else{\r\n\t\t\t\tconfig.controlEl = this.expandEl.cloneNode(true);\r\n\t\t\t\tconfig.controlEl.addEventListener(\"click\", (e) => {\r\n\t\t\t\t\te.stopPropagation();\r\n\t\t\t\t\tthis.expandRow(row);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tconfig.controlEl.addEventListener(\"mousedown\", (e) => {\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t});\r\n\r\n\t\t\tif(oldControl && oldControl.parentNode === el){\r\n\t\t\t\toldControl.parentNode.replaceChild(config.controlEl,oldControl);\r\n\t\t\t}else{\r\n\t\t\t\tel.insertBefore(config.controlEl, el.firstChild);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tsetDisplayIndex (index) {\r\n\t\tthis.displayIndex = index;\r\n\t}\r\n\r\n\tgetDisplayIndex () {\r\n\t\treturn this.displayIndex;\r\n\t}\r\n\r\n\tgetRows(rows){\r\n\t\tvar output = [];\r\n\r\n\t\trows.forEach((row, i) => {\r\n\t\t\tvar config, children;\r\n\r\n\t\t\toutput.push(row);\r\n\r\n\t\t\tif(row instanceof Row){\r\n\r\n\t\t\t\trow.create();\r\n\r\n\t\t\t\tconfig = row.modules.dataTree.children;\r\n\r\n\t\t\t\tif(!config.index && config.children !== false){\r\n\t\t\t\t\tchildren = this.getChildren(row);\r\n\r\n\t\t\t\t\tchildren.forEach((child) => {\r\n\t\t\t\t\t\tchild.create();\r\n\t\t\t\t\t\toutput.push(child);\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgetChildren(row, allChildren){\r\n\t\tvar config = row.modules.dataTree,\r\n\t\tchildren = [],\r\n\t\toutput = [];\r\n\r\n\t\tif(config.children !== false && (config.open || allChildren)){\r\n\t\t\tif(!Array.isArray(config.children)){\r\n\t\t\t\tconfig.children = this.generateChildren(row);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.modExists(\"filter\") && this.table.options.dataTreeFilter){\r\n\t\t\t\tchildren = this.table.modules.filter.filter(config.children);\r\n\t\t\t}else{\r\n\t\t\t\tchildren = config.children;\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.modExists(\"sort\") && this.table.options.dataTreeSort){\r\n\t\t\t\tthis.table.modules.sort.sort(children);\r\n\t\t\t}\r\n\r\n\t\t\tchildren.forEach((child) => {\r\n\t\t\t\toutput.push(child);\r\n\r\n\t\t\t\tvar subChildren = this.getChildren(child);\r\n\r\n\t\t\t\tsubChildren.forEach((sub) => {\r\n\t\t\t\t\toutput.push(sub);\r\n\t\t\t\t});\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tgenerateChildren(row){\r\n\t\tvar children = [];\r\n\r\n\t\tvar childArray = row.getData()[this.field];\r\n\r\n\t\tif(!Array.isArray(childArray)){\r\n\t\t\tchildArray = [childArray];\r\n\t\t}\r\n\r\n\t\tchildArray.forEach((childData) => {\r\n\t\t\tvar childRow = new Row(childData || {}, this.table.rowManager);\r\n\r\n\t\t\tchildRow.create();\r\n\r\n\t\t\tchildRow.modules.dataTree.index = row.modules.dataTree.index + 1;\r\n\t\t\tchildRow.modules.dataTree.parent = row;\r\n\r\n\t\t\tif(childRow.modules.dataTree.children){\r\n\t\t\t\tchildRow.modules.dataTree.open = this.startOpen(childRow.getComponent(), childRow.modules.dataTree.index);\r\n\t\t\t}\r\n\t\t\tchildren.push(childRow);\r\n\t\t});\r\n\r\n\t\treturn children;\r\n\t}\r\n\r\n\texpandRow(row, silent){\r\n\t\tvar config = row.modules.dataTree;\r\n\r\n\t\tif(config.children !== false){\r\n\t\t\tconfig.open = true;\r\n\r\n\t\t\trow.reinitialize();\r\n\r\n\t\t\tthis.table.rowManager.refreshActiveData(\"tree\", false, true);\r\n\r\n\t\t\tthis.table.options.dataTreeRowExpanded(row.getComponent(), row.modules.dataTree.index);\r\n\t\t}\r\n\t}\r\n\r\n\tcollapseRow(row){\r\n\t\tvar config = row.modules.dataTree;\r\n\r\n\t\tif(config.children !== false){\r\n\t\t\tconfig.open = false;\r\n\r\n\t\t\trow.reinitialize();\r\n\r\n\t\t\tthis.table.rowManager.refreshActiveData(\"tree\", false, true);\r\n\r\n\t\t\tthis.table.options.dataTreeRowCollapsed(row.getComponent(), row.modules.dataTree.index);\r\n\t\t}\r\n\t}\r\n\r\n\ttoggleRow(row){\r\n\t\tvar config = row.modules.dataTree;\r\n\r\n\t\tif(config.children !== false){\r\n\t\t\tif(config.open){\r\n\t\t\t\tthis.collapseRow(row);\r\n\t\t\t}else{\r\n\t\t\t\tthis.expandRow(row);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tgetTreeParent(row){\r\n\t\treturn row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() : false;\r\n\t}\r\n\r\n\tgetFilteredTreeChildren(row){\r\n\t\tvar config = row.modules.dataTree,\r\n\t\toutput = [], children;\r\n\r\n\t\tif(config.children){\r\n\r\n\t\t\tif(!Array.isArray(config.children)){\r\n\t\t\t\tconfig.children = this.generateChildren(row);\r\n\t\t\t}\r\n\r\n\t\t\tif(this.table.modExists(\"filter\") && this.table.options.dataTreeFilter){\r\n\t\t\t\tchildren = this.table.modules.filter.filter(config.children);\r\n\t\t\t}else{\r\n\t\t\t\tchildren = config.children;\r\n\t\t\t}\r\n\r\n\t\t\tchildren.forEach((childRow) => {\r\n\t\t\t\tif(childRow instanceof Row){\r\n\t\t\t\t\toutput.push(childRow);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\trowDelete(row){\r\n\t\tvar parent = row.modules.dataTree.parent,\r\n\t\tchildIndex;\r\n\r\n\t\tif(parent){\r\n\t\t\tchildIndex = this.findChildIndex(row, parent);\r\n\r\n\t\t\tif(childIndex !== false){\r\n\t\t\t\tparent.data[this.field].splice(childIndex, 1);\r\n\t\t\t}\r\n\r\n\t\t\tif(!parent.data[this.field].length){\r\n\t\t\t\tdelete parent.data[this.field];\r\n\t\t\t}\r\n\r\n\t\t\tthis.initializeRow(parent);\r\n\t\t\tthis.layoutRow(parent);\r\n\t\t}\r\n\r\n\t\tthis.table.rowManager.refreshActiveData(\"tree\", false, true);\r\n\t}\r\n\r\n\taddTreeChildRow(row, data, top, index){\r\n\t\tvar childIndex = false;\r\n\r\n\t\tif(typeof data === \"string\"){\r\n\t\t\tdata = JSON.parse(data);\r\n\t\t}\r\n\r\n\t\tif(!Array.isArray(row.data[this.field])){\r\n\t\t\trow.data[this.field] = [];\r\n\r\n\t\t\trow.modules.dataTree.open = this.startOpen(row.getComponent(), row.modules.dataTree.index);\r\n\t\t}\r\n\r\n\t\tif(typeof index !== \"undefined\"){\r\n\t\t\tchildIndex = this.findChildIndex(index, row);\r\n\r\n\t\t\tif(childIndex !== false){\r\n\t\t\t\trow.data[this.field].splice((top ? childIndex : childIndex + 1), 0, data);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(childIndex === false){\r\n\t\t\tif(top){\r\n\t\t\t\trow.data[this.field].unshift(data);\r\n\t\t\t}else{\r\n\t\t\t\trow.data[this.field].push(data);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tthis.initializeRow(row);\r\n\t\tthis.layoutRow(row);\r\n\r\n\t\tthis.table.rowManager.refreshActiveData(\"tree\", false, true);\r\n\t}\r\n\r\n\tfindChildIndex(subject, parent){\r\n\t\tvar match = false;\r\n\r\n\t\tif(typeof subject == \"object\"){\r\n\r\n\t\t\tif(subject instanceof Row){\r\n\t\t\t\t//subject is row element\r\n\t\t\t\tmatch = subject.data;\r\n\t\t\t}else if(subject instanceof RowComponent){\r\n\t\t\t\t//subject is public row component\r\n\t\t\t\tmatch = subject._getSelf().data;\r\n\t\t\t}else if(typeof HTMLElement !== \"undefined\" && subject instanceof HTMLElement){\r\n\t\t\t\tif(parent.modules.dataTree){\r\n\t\t\t\t\tmatch = parent.modules.dataTree.children.find((childRow) => {\r\n\t\t\t\t\t\treturn childRow instanceof Row ? childRow.element === subject : false;\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\tif(match){\r\n\t\t\t\t\t\tmatch = match.data;\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t}else if(typeof subject == \"undefined\" || subject === null){\r\n\t\t\tmatch = false\r\n\t\t}else{\r\n\t\t\t//subject should be treated as the index of the row\r\n\t\t\tmatch = parent.data[this.field].find((row) => {\r\n\t\t\t\treturn row.data[this.table.options.index] == subject;\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\tif(match){\r\n\r\n\t\t\tif(Array.isArray(parent.data[this.field])){\r\n\t\t\t\tmatch = parent.data[this.field].indexOf(match);\r\n\t\t\t}\r\n\r\n\t\t\tif(match == -1){\r\n\t\t\t\tmatch = false;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\t//catch all for any other type of input\r\n\r\n\t\treturn match;\r\n\t}\r\n\r\n\tgetTreeChildren(row, component, recurse){\r\n\t\tvar config = row.modules.dataTree,\r\n\t\toutput = [];\r\n\r\n\t\tif(config.children){\r\n\r\n\t\t\tif(!Array.isArray(config.children)){\r\n\t\t\t\tconfig.children = this.generateChildren(row);\r\n\t\t\t}\r\n\r\n\t\t\tconfig.children.forEach((childRow) => {\r\n\t\t\t\tif(childRow instanceof Row){\r\n\t\t\t\t\toutput.push(component ? childRow.getComponent() : childRow);\r\n\r\n\t\t\t\t\tif(recurse){\r\n\t\t\t\t\t\toutput = output.concat(this.getTreeChildren(childRow, component, recurse));\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tcheckForRestyle(cell){\r\n\t\tif(!cell.row.cells.indexOf(cell)){\r\n\t\t\tcell.row.reinitialize();\r\n\t\t}\r\n\t}\r\n\r\n\tgetChildField(){\r\n\t\treturn this.field;\r\n\t}\r\n\r\n\tredrawNeeded(data){\r\n\t\treturn (this.field ? typeof data[this.field] !== \"undefined\" : false) || (this.elementField ? typeof data[this.elementField] !== \"undefined\" : false);\r\n\t}\r\n}\r\n\r\nDataTree.moduleName = \"dataTree\";\r\n\r\nexport default DataTree;","export default function(list, options, setFileContents){\r\n\tvar delimiter = options && options.delimiter ? options.delimiter : \",\",\r\n\tfileContents = [],\r\n\theaders = [];\r\n\r\n\tlist.forEach((row) => {\r\n\t\tvar item = [];\r\n\r\n\t\tswitch(row.type){\r\n\t\t\tcase \"group\":\r\n\t\t\tconsole.warn(\"Download Warning - CSV downloader cannot process row groups\");\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"calc\":\r\n\t\t\tconsole.warn(\"Download Warning - CSV downloader cannot process column calculations\");\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"header\":\r\n\t\t\trow.columns.forEach((col, i) => {\r\n\t\t\t\tif(col && col.depth === 1){\r\n\t\t\t\t\theaders[i] = typeof col.value == \"undefined\" || col.value === null ? \"\" : ('\"' + String(col.value).split('\"').join('\"\"') + '\"');\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"row\":\r\n\t\t\trow.columns.forEach((col) => {\r\n\r\n\t\t\t\tif(col){\r\n\r\n\t\t\t\t\tswitch(typeof col.value){\r\n\t\t\t\t\t\tcase \"object\":\r\n\t\t\t\t\t\tcol.value = JSON.stringify(col.value);\r\n\t\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\t\tcase \"undefined\":\r\n\t\t\t\t\t\tcase \"null\":\r\n\t\t\t\t\t\tcol.value = \"\";\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\titem.push('\"' + String(col.value).split('\"').join('\"\"') + '\"');\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tfileContents.push(item.join(delimiter));\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tif(headers.length){\r\n\t\tfileContents.unshift(headers.join(delimiter));\r\n\t}\r\n\r\n\tfileContents = fileContents.join(\"\\n\");\r\n\r\n\tif(options.bom){\r\n\t\tfileContents = \"\\ufeff\" + fileContents;\r\n\t}\r\n\r\n\tsetFileContents(fileContents, \"text/csv\");\r\n};","export default function(list, options, setFileContents){\r\n\tvar fileContents = [];\r\n\r\n\tlist.forEach((row) => {\r\n\t\tvar item = {};\r\n\r\n\t\tswitch(row.type){\r\n\t\t\tcase \"header\":\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"group\":\r\n\t\t\tconsole.warn(\"Download Warning - JSON downloader cannot process row groups\");\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"calc\":\r\n\t\t\tconsole.warn(\"Download Warning - JSON downloader cannot process column calculations\");\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"row\":\r\n\t\t\trow.columns.forEach((col) => {\r\n\t\t\t\tif(col){\r\n\t\t\t\t\titem[col.component.getField()] = col.value;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tfileContents.push(item);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tfileContents = JSON.stringify(fileContents, null, '\\t');\r\n\r\n\tsetFileContents(fileContents, \"application/json\");\r\n};","export default function(list, options, setFileContents){\r\n\tvar header = [],\r\n\tbody = [],\r\n\tautoTableParams = {},\r\n\trowGroupStyles = options.rowGroupStyles || {\r\n\t\tfontStyle: \"bold\",\r\n\t\tfontSize: 12,\r\n\t\tcellPadding: 6,\r\n\t\tfillColor: 220,\r\n\t},\r\n\trowCalcStyles = options.rowCalcStyles || {\r\n\t\tfontStyle: \"bold\",\r\n\t\tfontSize: 10,\r\n\t\tcellPadding: 4,\r\n\t\tfillColor: 232,\r\n\t},\r\n\tjsPDFParams = options.jsPDF || {},\r\n\ttitle = options && options.title ? options.title : \"\";\r\n\r\n\tif(!jsPDFParams.orientation){\r\n\t\tjsPDFParams.orientation = options.orientation || \"landscape\";\r\n\t}\r\n\r\n\tif(!jsPDFParams.unit){\r\n\t\tjsPDFParams.unit = \"pt\";\r\n\t}\r\n\r\n\t//parse row list\r\n\tlist.forEach((row) => {\r\n\t\tvar item = {};\r\n\r\n\t\tswitch(row.type){\r\n\t\t\tcase \"header\":\r\n\t\t\theader.push(parseRow(row));\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"group\":\r\n\t\t\tbody.push(parseRow(row, rowGroupStyles));\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"calc\":\r\n\t\t\tbody.push(parseRow(row, rowCalcStyles));\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase \"row\":\r\n\t\t\tbody.push(parseRow(row));\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tfunction parseRow(row, styles){\r\n\t\tvar rowData = [];\r\n\r\n\t\trow.columns.forEach((col) =>{\r\n\t\t\tvar cell;\r\n\r\n\t\t\tif(col){\r\n\t\t\t\tswitch(typeof col.value){\r\n\t\t\t\t\tcase \"object\":\r\n\t\t\t\t\tcol.value = JSON.stringify(col.value);\r\n\t\t\t\t\tbreak;\r\n\r\n\t\t\t\t\tcase \"undefined\":\r\n\t\t\t\t\tcase \"null\":\r\n\t\t\t\t\tcol.value = \"\";\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tcell = {\r\n\t\t\t\t\tcontent:col.value,\r\n\t\t\t\t\tcolSpan:col.width,\r\n\t\t\t\t\trowSpan:col.height,\r\n\t\t\t\t};\r\n\r\n\t\t\t\tif(styles){\r\n\t\t\t\t\tcell.styles = styles;\r\n\t\t\t\t}\r\n\r\n\t\t\t\trowData.push(cell);\r\n\t\t\t}else{\r\n\t\t\t\trowData.push(\"\");\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn rowData;\r\n\t}\r\n\r\n\r\n\t//configure PDF\r\n\tvar doc = new jsPDF(jsPDFParams); //set document to landscape, better for most tables\r\n\r\n\tif(options && options.autoTable){\r\n\t\tif(typeof options.autoTable === \"function\"){\r\n\t\t\tautoTableParams = options.autoTable(doc) || {};\r\n\t\t}else{\r\n\t\t\tautoTableParams = options.autoTable;\r\n\t\t}\r\n\t}\r\n\r\n\tif(title){\r\n\t\tautoTableParams.addPageContent = function(data) {\r\n\t\t\tdoc.text(title, 40, 30);\r\n\t\t};\r\n\t}\r\n\r\n\tautoTableParams.head = header;\r\n\tautoTableParams.body = body;\r\n\r\n\tdoc.autoTable(autoTableParams);\r\n\r\n\tif(options && options.documentProcessing){\r\n\t\toptions.documentProcessing(doc);\r\n\t}\r\n\r\n\tsetFileContents(doc.output(\"arraybuffer\"), \"application/pdf\");\r\n};","export default function(list, options, setFileContents){\r\n\tvar self = this,\r\n\tsheetName = options.sheetName || \"Sheet1\",\r\n\tworkbook = XLSX.utils.book_new(),\r\n\toutput;\r\n\r\n\tworkbook.SheetNames = [];\r\n\tworkbook.Sheets = {};\r\n\r\n\tfunction generateSheet(){\r\n\t\tvar rows = [],\r\n\t\tmerges = [],\r\n\t\tworksheet = {},\r\n\t\trange = {s: {c:0, r:0}, e: {c:(list[0] ? list[0].columns.reduce((a, b) => a + (b && b.width ? b.width : 1), 0) : 0), r:list.length }};\r\n\r\n\t\t//parse row list\r\n\t\tlist.forEach((row, i) => {\r\n\t\t\tvar rowData = [];\r\n\r\n\t\t\trow.columns.forEach(function(col, j){\r\n\r\n\t\t\t\tif(col){\r\n\t\t\t\t\trowData.push(!(col.value instanceof Date) && typeof col.value === \"object\" ? JSON.stringify(col.value) : col.value);\r\n\r\n\t\t\t\t\tif(col.width > 1 || col.height > -1){\r\n\t\t\t\t\t\tmerges.push({s:{r:i,c:j},e:{r:i + col.height - 1,c:j + col.width - 1}});\r\n\t\t\t\t\t}\r\n\t\t\t\t}else{\r\n\t\t\t\t\trowData.push(\"\");\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\trows.push(rowData);\r\n\t\t});\r\n\r\n\r\n\t\t//convert rows to worksheet\r\n\t\tXLSX.utils.sheet_add_aoa(worksheet, rows);\r\n\r\n\t\tworksheet['!ref'] = XLSX.utils.encode_range(range);\r\n\r\n\t\tif(merges.length){\r\n\t\t\tworksheet[\"!merges\"] = merges;\r\n\t\t}\r\n\r\n\t\treturn worksheet;\r\n\t}\r\n\r\n\tif(options.sheetOnly){\r\n\t\tsetFileContents(generateSheet());\r\n\t\treturn;\r\n\t}\r\n\r\n\tif(options.sheets){\r\n\t\tfor(var sheet in options.sheets){\r\n\r\n\t\t\tif(options.sheets[sheet] === true){\r\n\t\t\t\tworkbook.SheetNames.push(sheet);\r\n\t\t\t\tworkbook.Sheets[sheet] = generateSheet();\r\n\t\t\t}else{\r\n\r\n\t\t\t\tworkbook.SheetNames.push(sheet);\r\n\r\n\t\t\t\tthis.modules.comms.send(options.sheets[sheet], \"download\", \"intercept\",{\r\n\t\t\t\t\ttype:\"xlsx\",\r\n\t\t\t\t\toptions:{sheetOnly:true},\r\n\t\t\t\t\tactive:self.active,\r\n\t\t\t\t\tintercept:function(data){\r\n\t\t\t\t\t\tworkbook.Sheets[sheet] = data;\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t}\r\n\t}else{\r\n\t\tworkbook.SheetNames.push(sheetName);\r\n\t\tworkbook.Sheets[sheetName] = generateSheet();\r\n\t}\r\n\r\n\tif(options.documentProcessing){\r\n\t\tworkbook = options.documentProcessing(workbook);\r\n\t}\r\n\r\n\t//convert workbook to binary array\r\n\tfunction s2ab(s) {\r\n\t\tvar buf = new ArrayBuffer(s.length);\r\n\t\tvar view = new Uint8Array(buf);\r\n\t\tfor (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;\r\n\t\t\treturn buf;\r\n\t}\r\n\r\n\toutput = XLSX.write(workbook, {bookType:'xlsx', bookSST:true, type: 'binary'});\r\n\r\n\tsetFileContents(s2ab(output), \"application/octet-stream\");\r\n};","export default function(list, options, setFileContents){\r\n\tif(this.modExists(\"export\", true)){\r\n\t\tsetFileContents(this.modules.export.genereateHTMLTable(list), \"text/html\");\r\n\t}\r\n};","import csv from './downloaders/csv.js';\r\nimport json from './downloaders/json.js';\r\nimport pdf from './downloaders/pdf.js';\r\nimport xlsx from './downloaders/xlsx.js';\r\nimport html from './downloaders/html.js';\r\n\r\nexport default {\r\n\tcsv:csv,\r\n\tjson:json,\r\n\tpdf:pdf,\r\n\txlsx:xlsx,\r\n\thtml:html,\r\n};","import Module from '../../core/Module.js';\r\n\r\nimport defaultDownloaders from './defaults/downloaders.js';\r\n\r\nclass Download extends Module{\r\n\r\n\tconstructor(table){\r\n\t\tsuper(table);\r\n\t}\r\n\r\n\t//trigger file download\r\n\tdownload(type, filename, options, range, interceptCallback){\r\n\t\tvar downloadFunc = false;\r\n\r\n\t\tfunction buildLink(data, mime){\r\n\t\t\tif(interceptCallback){\r\n\t\t\t\tif(interceptCallback === true){\r\n\t\t\t\t\tthis.triggerDownload(data, mime, type, filename, true);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tinterceptCallback(data);\r\n\t\t\t\t}\r\n\r\n\t\t\t}else{\r\n\t\t\t\tthis.triggerDownload(data, mime, type, filename);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(typeof type == \"function\"){\r\n\t\t\tdownloadFunc = type;\r\n\t\t}else{\r\n\t\t\tif(Download.downloaders[type]){\r\n\t\t\t\tdownloadFunc = Download.downloaders[type];\r\n\t\t\t}else{\r\n\t\t\t\tconsole.warn(\"Download Error - No such download type found: \", type);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(downloadFunc){\r\n\t\t\tvar list = this.generateExportList(range);\r\n\r\n\t\t\tdownloadFunc.call(this.table, list , options || {}, buildLink);\r\n\t\t}\r\n\t}\r\n\r\n\tgenerateExportList(range){\r\n\t\tvar list = this.table.modules.export.generateExportList(this.table.options.downloadConfig, false, range || this.table.options.downloadRowRange, \"download\");\r\n\r\n\t\t//assign group header formatter\r\n\t\tvar groupHeader = this.table.options.groupHeaderDownload;\r\n\r\n\t\tif(groupHeader && !Array.isArray(groupHeader)){\r\n\t\t\tgroupHeader = [groupHeader];\r\n\t\t}\r\n\r\n\t\tlist.forEach((row) => {\r\n\t\t\tvar group;\r\n\r\n\t\t\tif(row.type === \"group\"){\r\n\t\t\t\tgroup = row.columns[0];\r\n\r\n\t\t\t\tif(groupHeader && groupHeader[row.indent]){\r\n\t\t\t\t\tgroup.value = groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t});\r\n\r\n\t\treturn list;\r\n\t}\r\n\r\n\ttriggerDownload(data, mime, type, filename, newTab){\r\n\t\tvar element = document.createElement('a'),\r\n\t\tblob = new Blob([data],{type:mime}),\r\n\t\tfilename = filename || \"Tabulator.\" + (typeof type === \"function\" ? \"txt\" : type);\r\n\r\n\t\tblob = this.table.options.downloadReady.call(this.table, data, blob);\r\n\r\n\t\tif(blob){\r\n\r\n\t\t\tif(newTab){\r\n\t\t\t\twindow.open(window.URL.createObjectURL(blob));\r\n\t\t\t}else{\r\n\t\t\t\tif(navigator.msSaveOrOpenBlob){\r\n\t\t\t\t\tnavigator.msSaveOrOpenBlob(blob, filename);\r\n\t\t\t\t}else{\r\n\t\t\t\t\telement.setAttribute('href', window.URL.createObjectURL(blob));\r\n\r\n\t\t\t\t\t//set file title\r\n\t\t\t\t\telement.setAttribute('download', filename);\r\n\r\n\t\t\t\t\t//trigger download\r\n\t\t\t\t\telement.style.display = 'none';\r\n\t\t\t\t\tdocument.body.appendChild(element);\r\n\t\t\t\t\telement.click();\r\n\r\n\t\t\t\t\t//remove temporary link element\r\n\t\t\t\t\tdocument.body.removeChild(element);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\r\n\t\t\tif(this.table.options.downloadComplete){\r\n\t\t\t\tthis.table.options.downloadComplete();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tcommsReceived(table, action, data){\r\n\t\tswitch(action){\r\n\t\t\tcase \"intercept\":\r\n\t\t\tthis.download(data.type, \"\", data.options, data.active, data.intercept);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nDownload.moduleName = \"download\";\r\n\r\n//load defaults\r\nDownload.downloaders = defaultDownloaders;\r\n\r\nexport default Download;","//input element\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\t//create and style input\r\n\tvar cellValue = cell.getValue(),\r\n\tinput = document.createElement(\"input\");\r\n\r\n\tinput.setAttribute(\"type\", editorParams.search ? \"search\" : \"text\");\r\n\r\n\tinput.style.padding = \"4px\";\r\n\tinput.style.width = \"100%\";\r\n\tinput.style.boxSizing = \"border-box\";\r\n\r\n\tif(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n\t\tfor (let key in editorParams.elementAttributes){\r\n\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\tkey = key.slice(1);\r\n\t\t\t\tinput.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n\t\t\t}else{\r\n\t\t\t\tinput.setAttribute(key, editorParams.elementAttributes[key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinput.value = typeof cellValue !== \"undefined\" ? cellValue : \"\";\r\n\r\n\tonRendered(function(){\r\n\t\tinput.focus({preventScroll: true});\r\n\t\tinput.style.height = \"100%\";\r\n\t});\r\n\r\n\tfunction onChange(e){\r\n\t\tif(((cellValue === null || typeof cellValue === \"undefined\") && input.value !== \"\") || input.value !== cellValue){\r\n\t\t\tif(success(input.value)){\r\n\t\t\t\tcellValue = input.value; //persist value if successfully validated incase editor is used as header filter\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tcancel();\r\n\t\t}\r\n\t}\r\n\r\n\t//submit new value on blur or change\r\n\tinput.addEventListener(\"change\", onChange);\r\n\tinput.addEventListener(\"blur\", onChange);\r\n\r\n\t//submit new value on enter\r\n\tinput.addEventListener(\"keydown\", function(e){\r\n\t\tswitch(e.keyCode){\r\n\t\t\t// case 9:\r\n\t\t\tcase 13:\r\n\t\t\tonChange(e);\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 27:\r\n\t\t\tcancel();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 35:\r\n\t\t\tcase 36:\r\n\t\t\te.stopPropagation();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tif(editorParams.mask){\r\n\t\tthis.table.modules.edit.maskInput(input, editorParams);\r\n\t}\r\n\r\n\treturn input;\r\n};","//resizable text area element\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n var self = this,\r\n cellValue = cell.getValue(),\r\n vertNav = editorParams.verticalNavigation || \"hybrid\",\r\n value = String(cellValue !== null && typeof cellValue !== \"undefined\" ? cellValue : \"\"),\r\n count = (value.match(/(?:\\r\\n|\\r|\\n)/g) || []).length + 1,\r\n input = document.createElement(\"textarea\"),\r\n scrollHeight = 0;\r\n\r\n //create and style input\r\n input.style.display = \"block\";\r\n input.style.padding = \"2px\";\r\n input.style.height = \"100%\";\r\n input.style.width = \"100%\";\r\n input.style.boxSizing = \"border-box\";\r\n input.style.whiteSpace = \"pre-wrap\";\r\n input.style.resize = \"none\";\r\n\r\n if(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n for (let key in editorParams.elementAttributes){\r\n if(key.charAt(0) == \"+\"){\r\n key = key.slice(1);\r\n input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n }else{\r\n input.setAttribute(key, editorParams.elementAttributes[key]);\r\n }\r\n }\r\n }\r\n\r\n input.value = value;\r\n\r\n onRendered(function(){\r\n input.focus({preventScroll: true});\r\n input.style.height = \"100%\";\r\n\r\n input.scrollHeight;\r\n input.style.height = input.scrollHeight + \"px\";\r\n cell.getRow().normalizeHeight();\r\n });\r\n\r\n function onChange(e){\r\n\r\n if(((cellValue === null || typeof cellValue === \"undefined\") && input.value !== \"\") || input.value !== cellValue){\r\n\r\n if(success(input.value)){\r\n cellValue = input.value; //persist value if successfully validated incase editor is used as header filter\r\n }\r\n\r\n setTimeout(function(){\r\n cell.getRow().normalizeHeight();\r\n },300)\r\n }else{\r\n cancel();\r\n }\r\n }\r\n\r\n //submit new value on blur or change\r\n input.addEventListener(\"change\", onChange);\r\n input.addEventListener(\"blur\", onChange);\r\n\r\n input.addEventListener(\"keyup\", function(){\r\n\r\n input.style.height = \"\";\r\n\r\n var heightNow = input.scrollHeight;\r\n\r\n input.style.height = heightNow + \"px\";\r\n\r\n if(heightNow != scrollHeight){\r\n scrollHeight = heightNow;\r\n cell.getRow().normalizeHeight();\r\n }\r\n });\r\n\r\n input.addEventListener(\"keydown\", function(e){\r\n\r\n switch(e.keyCode){\r\n case 27:\r\n cancel();\r\n break;\r\n\r\n case 38: //up arrow\r\n if(vertNav == \"editor\" || (vertNav == \"hybrid\" && input.selectionStart)){\r\n e.stopImmediatePropagation();\r\n e.stopPropagation();\r\n }\r\n\r\n break;\r\n\r\n case 40: //down arrow\r\n if(vertNav == \"editor\" || (vertNav == \"hybrid\" && input.selectionStart !== input.value.length)){\r\n e.stopImmediatePropagation();\r\n e.stopPropagation();\r\n }\r\n break;\r\n\r\n case 35:\r\n case 36:\r\n e.stopPropagation();\r\n break;\r\n }\r\n });\r\n\r\n if(editorParams.mask){\r\n this.table.modules.edit.maskInput(input, editorParams);\r\n }\r\n\r\n return input;\r\n};","//input element with type of number\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\tvar cellValue = cell.getValue(),\r\n\tvertNav = editorParams.verticalNavigation || \"editor\",\r\n\tinput = document.createElement(\"input\");\r\n\r\n\tinput.setAttribute(\"type\", \"number\");\r\n\r\n\tif(typeof editorParams.max != \"undefined\"){\r\n\t\tinput.setAttribute(\"max\", editorParams.max);\r\n\t}\r\n\r\n\tif(typeof editorParams.min != \"undefined\"){\r\n\t\tinput.setAttribute(\"min\", editorParams.min);\r\n\t}\r\n\r\n\tif(typeof editorParams.step != \"undefined\"){\r\n\t\tinput.setAttribute(\"step\", editorParams.step);\r\n\t}\r\n\r\n\t//create and style input\r\n\tinput.style.padding = \"4px\";\r\n\tinput.style.width = \"100%\";\r\n\tinput.style.boxSizing = \"border-box\";\r\n\r\n\tif(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n\t\tfor (let key in editorParams.elementAttributes){\r\n\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\tkey = key.slice(1);\r\n\t\t\t\tinput.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n\t\t\t}else{\r\n\t\t\t\tinput.setAttribute(key, editorParams.elementAttributes[key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinput.value = cellValue;\r\n\r\n\tvar blurFunc = function(e){\r\n\t\tonChange();\r\n\t};\r\n\r\n\tonRendered(function () {\r\n\t\t//submit new value on blur\r\n\t\tinput.removeEventListener(\"blur\", blurFunc);\r\n\r\n\t\tinput.focus({preventScroll: true});\r\n\t\tinput.style.height = \"100%\";\r\n\r\n\t\t//submit new value on blur\r\n\t\tinput.addEventListener(\"blur\", blurFunc);\r\n\t});\r\n\r\n\tfunction onChange(){\r\n\t\tvar value = input.value;\r\n\r\n\t\tif(!isNaN(value) && value !==\"\"){\r\n\t\t\tvalue = Number(value);\r\n\t\t}\r\n\r\n\t\tif(value !== cellValue){\r\n\t\t\tif(success(value)){\r\n\t\t\t\tcellValue = value; //persist value if successfully validated incase editor is used as header filter\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tcancel();\r\n\t\t}\r\n\t}\r\n\r\n\t//submit new value on enter\r\n\tinput.addEventListener(\"keydown\", function(e){\r\n\t\tswitch(e.keyCode){\r\n\t\t\tcase 13:\r\n\t\t\t// case 9:\r\n\t\t\tonChange();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 27:\r\n\t\t\tcancel();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 38: //up arrow\r\n\t\t\tcase 40: //down arrow\r\n\t\t\tif(vertNav == \"editor\"){\r\n\t\t\t\te.stopImmediatePropagation();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 35:\r\n\t\t\tcase 36:\r\n\t\t\te.stopPropagation();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tif(editorParams.mask){\r\n\t\tthis.table.modules.edit.maskInput(input, editorParams);\r\n\t}\r\n\r\n\treturn input;\r\n};","//input element with type of number\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\tvar cellValue = cell.getValue(),\r\n\tinput = document.createElement(\"input\");\r\n\r\n\tinput.setAttribute(\"type\", \"range\");\r\n\r\n\tif (typeof editorParams.max != \"undefined\") {\r\n\t\tinput.setAttribute(\"max\", editorParams.max);\r\n\t}\r\n\r\n\tif (typeof editorParams.min != \"undefined\") {\r\n\t\tinput.setAttribute(\"min\", editorParams.min);\r\n\t}\r\n\r\n\tif (typeof editorParams.step != \"undefined\") {\r\n\t\tinput.setAttribute(\"step\", editorParams.step);\r\n\t}\r\n\r\n\t//create and style input\r\n\tinput.style.padding = \"4px\";\r\n\tinput.style.width = \"100%\";\r\n\tinput.style.boxSizing = \"border-box\";\r\n\r\n\tif(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n\t\tfor (let key in editorParams.elementAttributes){\r\n\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\tkey = key.slice(1);\r\n\t\t\t\tinput.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n\t\t\t}else{\r\n\t\t\t\tinput.setAttribute(key, editorParams.elementAttributes[key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinput.value = cellValue;\r\n\r\n\tonRendered(function () {\r\n\t\tinput.focus({preventScroll: true});\r\n\t\tinput.style.height = \"100%\";\r\n\t});\r\n\r\n\tfunction onChange(){\r\n\t\tvar value = input.value;\r\n\r\n\t\tif(!isNaN(value) && value !==\"\"){\r\n\t\t\tvalue = Number(value);\r\n\t\t}\r\n\r\n\t\tif(value != cellValue){\r\n\t\t\tif(success(value)){\r\n\t\t\t\tcellValue = value; //persist value if successfully validated incase editor is used as header filter\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tcancel();\r\n\t\t}\r\n\t}\r\n\r\n\t//submit new value on blur\r\n\tinput.addEventListener(\"blur\", function(e){\r\n\t\tonChange();\r\n\t});\r\n\r\n\t//submit new value on enter\r\n\tinput.addEventListener(\"keydown\", function(e){\r\n\t\tswitch(e.keyCode){\r\n\t\t\tcase 13:\r\n\t\t\t// case 9:\r\n\t\t\tonChange();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 27:\r\n\t\t\tcancel();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\treturn input;\r\n};","import Helpers from '../../../../core/Helpers.js';\r\n\r\n//dropdown select editor\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\tvar self = this,\r\n\tcellEl = cell.getElement(),\r\n\tinitialValue = cell.getValue(),\r\n\tvertNav = editorParams.verticalNavigation || \"editor\",\r\n\tinitialDisplayValue = typeof initialValue !== \"undefined\" || initialValue === null ? (Array.isArray(initialValue) ? initialValue : [initialValue]) : (typeof editorParams.defaultValue !== \"undefined\" ? editorParams.defaultValue : []),\r\n\tinput = document.createElement(\"input\"),\r\n\tlistEl = document.createElement(\"div\"),\r\n\tmultiselect = editorParams.multiselect,\r\n\tdataItems = [],\r\n\tcurrentItem = {},\r\n\tdisplayItems = [],\r\n\tcurrentItems = [],\r\n\tblurable = true,\r\n\tblockListShow = false,\r\n\tsearchWord = \"\",\r\n\tsearchWordTimeout = null;\r\n\r\n\tif(Array.isArray(editorParams) || (!Array.isArray(editorParams) && typeof editorParams === \"object\" && !editorParams.values)){\r\n\t\tconsole.warn(\"DEPRECATION WARNING - values for the select editor must now be passed into the values property of the editorParams object, not as the editorParams object\");\r\n\t\teditorParams = {values:editorParams};\r\n\t}\r\n\r\n\tfunction getUniqueColumnValues(field){\r\n\t\tvar output = {},\r\n\t\tdata = self.table.getData(),\r\n\t\tcolumn;\r\n\r\n\t\tif(field){\r\n\t\t\tcolumn = self.table.columnManager.getColumnByField(field);\r\n\t\t}else{\r\n\t\t\tcolumn = cell.getColumn()._getSelf();\r\n\t\t}\r\n\r\n\t\tif(column){\r\n\t\t\tdata.forEach(function(row){\r\n\t\t\t\tvar val = column.getFieldValue(row);\r\n\r\n\t\t\t\tif(val !== null && typeof val !== \"undefined\" && val !== \"\"){\r\n\t\t\t\t\toutput[val] = true;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"unable to find matching column to create select lookup list:\", field);\r\n\t\t}\r\n\r\n\t\treturn Object.keys(output);\r\n\t}\r\n\r\n\tfunction parseItems(inputValues, curentValues){\r\n\t\tvar dataList = [];\r\n\t\tvar displayList = [];\r\n\r\n\t\tfunction processComplexListItem(item){\r\n\t\t\tvar item = {\r\n\t\t\t\tlabel:item.label,\r\n\t\t\t\tvalue:item.value,\r\n\t\t\t\titemParams:item.itemParams,\r\n\t\t\t\telementAttributes: item.elementAttributes,\r\n\t\t\t\telement:false,\r\n\t\t\t};\r\n\r\n\t\t\t// if(item.value === curentValue || (!isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue))){\r\n\t\t\t// \tsetCurrentItem(item);\r\n\t\t\t// }\r\n\r\n\t\t\tif(curentValues.indexOf(item.value) > -1){\r\n\t\t\t\tsetItem(item);\r\n\t\t\t}\r\n\r\n\t\t\tdataList.push(item);\r\n\t\t\tdisplayList.push(item);\r\n\r\n\t\t\treturn item;\r\n\t\t}\r\n\r\n\t\tif(typeof inputValues == \"function\"){\r\n\t\t\tinputValues = inputValues(cell);\r\n\t\t}\r\n\r\n\t\tif(Array.isArray(inputValues)){\r\n\t\t\tinputValues.forEach(function(value){\r\n\t\t\t\tvar item;\r\n\r\n\t\t\t\tif(typeof value === \"object\"){\r\n\r\n\t\t\t\t\tif(value.options){\r\n\t\t\t\t\t\titem = {\r\n\t\t\t\t\t\t\tlabel:value.label,\r\n\t\t\t\t\t\t\tgroup:true,\r\n\t\t\t\t\t\t\titemParams:value.itemParams,\r\n\t\t\t\t\t\t\telementAttributes:value.elementAttributes,\r\n\t\t\t\t\t\t\telement:false,\r\n\t\t\t\t\t\t};\r\n\r\n\t\t\t\t\t\tdisplayList.push(item);\r\n\r\n\t\t\t\t\t\tvalue.options.forEach(function(item){\r\n\t\t\t\t\t\t\tprocessComplexListItem(item);\r\n\t\t\t\t\t\t});\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tprocessComplexListItem(value);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t}else{\r\n\r\n\t\t\t\t\titem = {\r\n\t\t\t\t\t\tlabel:value,\r\n\t\t\t\t\t\tvalue:value,\r\n\t\t\t\t\t\telement:false,\r\n\t\t\t\t\t};\r\n\r\n\t\t\t\t\t// if(item.value === curentValue || (!isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue))){\r\n\t\t\t\t\t// \tsetCurrentItem(item);\r\n\t\t\t\t\t// }\r\n\r\n\t\t\t\t\tif(curentValues.indexOf(item.value) > -1){\r\n\t\t\t\t\t\tsetItem(item);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdataList.push(item);\r\n\t\t\t\t\tdisplayList.push(item);\r\n\t\t\t\t}\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tfor(var key in inputValues){\r\n\t\t\t\tvar item = {\r\n\t\t\t\t\tlabel:inputValues[key],\r\n\t\t\t\t\tvalue:key,\r\n\t\t\t\t\telement:false,\r\n\t\t\t\t};\r\n\r\n\t\t\t\t// if(item.value === curentValue || (!isNaN(parseFloat(item.value)) && !isNaN(parseFloat(item.value)) && parseFloat(item.value) === parseFloat(curentValue))){\r\n\t\t\t\t// \tsetCurrentItem(item);\r\n\t\t\t\t// }\r\n\r\n\t\t\t\tif(curentValues.indexOf(item.value) > -1){\r\n\t\t\t\t\tsetItem(item);\r\n\t\t\t\t}\r\n\r\n\t\t\t\tdataList.push(item);\r\n\t\t\t\tdisplayList.push(item);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(editorParams.sortValuesList){\r\n\t\t\tdataList.sort((a, b) => {\r\n\t\t\t\treturn a.label < b.label ? -1 : (a.label > b.label ? 1 : 0);\r\n\t\t\t});\r\n\r\n\t\t\tdisplayList.sort((a, b) => {\r\n\t\t\t\treturn a.label < b.label ? -1 : (a.label > b.label ? 1 : 0);\r\n\t\t\t});\r\n\r\n\t\t\tif(editorParams.sortValuesList !== \"asc\"){\r\n\t\t\t\tdataList.reverse();\r\n\t\t\t\tdisplayList.reverse();\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tdataItems = dataList;\r\n\t\tdisplayItems = displayList;\r\n\r\n\t\tfillList();\r\n\t}\r\n\r\n\tfunction fillList(){\r\n\t\twhile(listEl.firstChild) listEl.removeChild(listEl.firstChild);\r\n\r\n\t\tdisplayItems.forEach(function(item){\r\n\r\n\t\t\tvar el = item.element;\r\n\r\n\t\t\tif(!el){\r\n\t\t\t\tel = document.createElement(\"div\");\r\n\t\t\t\titem.label = editorParams.listItemFormatter ? editorParams.listItemFormatter(item.value, item.label, cell, el, item.itemParams) : item.label;\r\n\t\t\t\tif(item.group){\r\n\t\t\t\t\tel.classList.add(\"tabulator-edit-select-list-group\");\r\n\t\t\t\t\tel.tabIndex = 0;\r\n\t\t\t\t\tel.innerHTML = item.label === \"\" ? \" \" : item.label;\r\n\t\t\t\t}else{\r\n\t\t\t\t\tel.classList.add(\"tabulator-edit-select-list-item\");\r\n\t\t\t\t\tel.tabIndex = 0;\r\n\t\t\t\t\tel.innerHTML = item.label === \"\" ? \" \" : item.label;\r\n\r\n\t\t\t\t\tel.addEventListener(\"click\", function(){\r\n\t\t\t\t\t\tblockListShow = true;\r\n\r\n\t\t\t\t\t\tsetTimeout(() => {\r\n\t\t\t\t\t\t\tblockListShow = false;\r\n\t\t\t\t\t\t}, 10);\r\n\r\n\t\t\t\t\t\t// setCurrentItem(item);\r\n\t\t\t\t\t\t// chooseItem();\r\n\t\t\t\t\t\tif(multiselect){\r\n\t\t\t\t\t\t\ttoggleItem(item);\r\n\t\t\t\t\t\t\tinput.focus();\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tchooseItem(item);\r\n\t\t\t\t\t\t}\r\n\r\n\t\t\t\t\t});\r\n\r\n\t\t\t\t\t// if(item === currentItem){\r\n\t\t\t\t\t// \tel.classList.add(\"active\");\r\n\t\t\t\t\t// }\r\n\r\n\t\t\t\t\tif(currentItems.indexOf(item) > -1){\r\n\t\t\t\t\t\tel.classList.add(\"active\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(item.elementAttributes && typeof item.elementAttributes == \"object\"){\r\n\t\t\t\t\tfor (let key in item.elementAttributes){\r\n\t\t\t\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\t\t\t\tkey = key.slice(1);\r\n\t\t\t\t\t\t\tel.setAttribute(key, input.getAttribute(key) + item.elementAttributes[\"+\" + key]);\r\n\t\t\t\t\t\t}else{\r\n\t\t\t\t\t\t\tel.setAttribute(key, item.elementAttributes[key]);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\tel.addEventListener(\"mousedown\", function(){\r\n\t\t\t\t\tblurable = false;\r\n\r\n\t\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\t\tblurable = true;\r\n\t\t\t\t\t}, 10);\r\n\t\t\t\t});\r\n\r\n\t\t\t\titem.element = el;\r\n\r\n\r\n\t\t\t}\r\n\r\n\t\t\tlistEl.appendChild(el);\r\n\t\t});\r\n\t}\r\n\r\n\r\n\tfunction setCurrentItem(item, active){\r\n\r\n\t\tif(!multiselect && currentItem && currentItem.element){\r\n\t\t\tcurrentItem.element.classList.remove(\"active\");\r\n\t\t}\r\n\r\n\t\tif(currentItem && currentItem.element){\r\n\t\t\tcurrentItem.element.classList.remove(\"focused\");\r\n\t\t}\r\n\r\n\t\tcurrentItem = item;\r\n\r\n\t\tif(item.element){\r\n\t\t\titem.element.classList.add(\"focused\");\r\n\t\t\tif(active){\r\n\t\t\t\titem.element.classList.add(\"active\");\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tif(item && item.element && item.element.scrollIntoView){\r\n\t\t\titem.element.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'start'});\r\n\t\t}\r\n\t}\r\n\r\n\r\n\t// function chooseItem(){\r\n\t// \thideList();\r\n\r\n\t// \tif(initialValue !== currentItem.value){\r\n\t// \t\tinitialValue = currentItem.value;\r\n\t// \t\tsuccess(currentItem.value);\r\n\t// \t}else{\r\n\t// \t\tcancel();\r\n\t// \t}\r\n\t// }\r\n\r\n\tfunction setItem(item) {\r\n\t\tvar index = currentItems.indexOf(item);\r\n\r\n\t\tif(index == -1){\r\n\t\t\tcurrentItems.push(item);\r\n\t\t\tsetCurrentItem(item, true);\r\n\t\t}\r\n\r\n\t\tfillInput();\r\n\t}\r\n\r\n\tfunction unsetItem(index) {\r\n\t\tvar item = currentItems[index];\r\n\r\n\t\tif(index > -1){\r\n\t\t\tcurrentItems.splice(index, 1);\r\n\t\t\tif(item.element){\r\n\t\t\t\titem.element.classList.remove(\"active\");\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction toggleItem(item) {\r\n\t\tif(!item){\r\n\t\t\titem = currentItem;\r\n\t\t}\r\n\r\n\t\tvar index = currentItems.indexOf(item);\r\n\r\n\t\tif(index > -1){\r\n\t\t\tunsetItem(index);\r\n\t\t}else{\r\n\t\t\tif(multiselect !== true && currentItems.length >= multiselect){\r\n\t\t\t\tunsetItem(0);\r\n\t\t\t}\r\n\r\n\t\t\tsetItem(item);\r\n\t\t}\r\n\r\n\t\tfillInput();\r\n\r\n\t}\r\n\r\n\tfunction chooseItem(item){\r\n\t\thideList();\r\n\r\n\t\tif(!item){\r\n\t\t\titem = currentItem;\r\n\t\t}\r\n\r\n\t\tif(item){\r\n\t\t\tinput.value = item.label;\r\n\t\t\tsuccess(item.value);\r\n\t\t}\r\n\r\n\t\tinitialDisplayValue = [item.value];\r\n\t}\r\n\r\n\r\n\tfunction chooseItems(silent){\r\n\t\tif(!silent){\r\n\t\t\thideList();\r\n\t\t}\r\n\r\n\t\tvar output = [];\r\n\r\n\t\tcurrentItems.forEach((item) => {\r\n\t\t\toutput.push(item.value);\r\n\t\t});\r\n\r\n\t\tinitialDisplayValue = output;\r\n\r\n\t\tsuccess(output);\r\n\t}\r\n\r\n\tfunction fillInput(){\r\n\t\tvar output = [];\r\n\r\n\t\tcurrentItems.forEach((item) => {\r\n\t\t\toutput.push(item.label);\r\n\t\t});\r\n\r\n\t\tinput.value = output.join(\", \");\r\n\r\n\t\tif(self.currentCell === false){\r\n\t\t\tchooseItems(true);\r\n\t\t}\r\n\t}\r\n\r\n\r\n\tfunction unsetItems() {\r\n\r\n\t\tvar len = currentItems.length;\r\n\r\n\t\tfor(let i = 0; i < len; i++){\r\n\t\t\tunsetItem(0);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction cancelItem(){\r\n\t\thideList();\r\n\t\tcancel();\r\n\t}\r\n\r\n\tfunction showList(){\r\n\t\tcurrentItems = [];\r\n\r\n\t\tif(!listEl.parentNode){\r\n\t\t\tif(editorParams.values === true){\r\n\t\t\t\tparseItems(getUniqueColumnValues(), initialDisplayValue);\r\n\t\t\t}else if(typeof editorParams.values === \"string\"){\r\n\t\t\t\tparseItems(getUniqueColumnValues(editorParams.values), initialDisplayValue);\r\n\t\t\t}else{\r\n\t\t\t\tparseItems(editorParams.values || [], initialDisplayValue);\r\n\t\t\t}\r\n\r\n\r\n\t\t\tvar offset = Helpers.elOffset(cellEl);\r\n\r\n\t\t\tlistEl.style.minWidth = cellEl.offsetWidth + \"px\";\r\n\r\n\t\t\tlistEl.style.top = (offset.top + cellEl.offsetHeight) + \"px\";\r\n\t\t\tlistEl.style.left = offset.left + \"px\";\r\n\r\n\r\n\t\t\tlistEl.addEventListener(\"mousedown\", function(e){\r\n\t\t\t\tblurable = false;\r\n\r\n\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\tblurable = true;\r\n\t\t\t\t}, 10);\r\n\t\t\t});\r\n\r\n\t\t\tdocument.body.appendChild(listEl);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction hideList(){\r\n\t\tif(listEl.parentNode){\r\n\t\t\tlistEl.parentNode.removeChild(listEl);\r\n\t\t}\r\n\r\n\t\tremoveScrollListener();\r\n\t}\r\n\r\n\tfunction removeScrollListener() {\r\n\t\tself.table.rowManager.element.removeEventListener(\"scroll\", cancelItem);\r\n\t}\r\n\r\n\tfunction scrollTovalue(char){\r\n\r\n\t\tclearTimeout(searchWordTimeout);\r\n\r\n\t\tvar character = String.fromCharCode(event.keyCode).toLowerCase();\r\n\t\tsearchWord += character.toLowerCase();\r\n\r\n\t\tvar match = dataItems.find((item) => {\r\n\t\t\treturn typeof item.label !== \"undefined\" && item.label.toLowerCase().startsWith(searchWord);\r\n\t\t});\r\n\r\n\t\tif(match){\r\n\t\t\tsetCurrentItem(match, !multiselect);\r\n\t\t}\r\n\r\n\t\tsearchWordTimeout = setTimeout(() => {\r\n\t\t\tsearchWord = \"\";\r\n\t\t}, 800)\r\n\t}\r\n\r\n\t//style input\r\n\tinput.setAttribute(\"type\", \"text\");\r\n\r\n\tinput.style.padding = \"4px\";\r\n\tinput.style.width = \"100%\";\r\n\tinput.style.boxSizing = \"border-box\";\r\n\tinput.style.cursor = \"default\";\r\n\tinput.readOnly = (this.currentCell != false);\r\n\r\n\tif(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n\t\tfor (let key in editorParams.elementAttributes){\r\n\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\tkey = key.slice(1);\r\n\t\t\t\tinput.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n\t\t\t}else{\r\n\t\t\t\tinput.setAttribute(key, editorParams.elementAttributes[key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tinput.value = typeof initialValue !== \"undefined\" || initialValue === null ? initialValue : \"\";\r\n\r\n\t// if(editorParams.values === true){\r\n\t// \tparseItems(getUniqueColumnValues(), initialValue);\r\n\t// }else if(typeof editorParams.values === \"string\"){\r\n\t// \tparseItems(getUniqueColumnValues(editorParams.values), initialValue);\r\n\t// }else{\r\n\t// \tparseItems(editorParams.values || [], initialValue);\r\n\t// }\r\n\r\n\tinput.addEventListener(\"search\", function(e){\r\n\t\tif(!input.value){\r\n\t\t\tunsetItems();\r\n\t\t\tchooseItems();\r\n\t\t}\r\n\t});\r\n\r\n\t//allow key based navigation\r\n\tinput.addEventListener(\"keydown\", function(e){\r\n\t\tvar index;\r\n\r\n\t\tswitch(e.keyCode){\r\n\t\t\tcase 38: //up arrow\r\n\t\t\tindex = dataItems.indexOf(currentItem);\r\n\r\n\t\t\tif(vertNav == \"editor\" || (vertNav == \"hybrid\" && index)){\r\n\t\t\t\te.stopImmediatePropagation();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\tif(index > 0){\r\n\t\t\t\t\tsetCurrentItem(dataItems[index - 1], !multiselect);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 40: //down arrow\r\n\t\t\tindex = dataItems.indexOf(currentItem);\r\n\r\n\t\t\tif(vertNav == \"editor\" || (vertNav == \"hybrid\" && index < dataItems.length - 1)){\r\n\t\t\t\te.stopImmediatePropagation();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\tif(index < dataItems.length - 1){\r\n\t\t\t\t\tif(index == -1){\r\n\t\t\t\t\t\tsetCurrentItem(dataItems[0], !multiselect);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tsetCurrentItem(dataItems[index + 1], !multiselect);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 37: //left arrow\r\n\t\t\tcase 39: //right arrow\r\n\t\t\te.stopImmediatePropagation();\r\n\t\t\te.stopPropagation();\r\n\t\t\te.preventDefault();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 13: //enter\r\n\t\t\t// chooseItem();\r\n\r\n\t\t\tif(multiselect){\r\n\t\t\t\ttoggleItem();\r\n\t\t\t}else{\r\n\t\t\t\tchooseItem();\r\n\t\t\t}\r\n\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 27: //escape\r\n\t\t\tcancelItem();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 9: //tab\r\n\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\tif(self.currentCell === false){\r\n\t\t\t\te.preventDefault();\r\n\t\t\t}\r\n\r\n\t\t\tif(e.keyCode >= 38 && e.keyCode <= 90){\r\n\t\t\t\tscrollTovalue(e.keyCode);\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\r\n\tinput.addEventListener(\"blur\", function(e){\r\n\t\tif(blurable){\r\n\t\t\tif(multiselect){\r\n\t\t\t\tchooseItems();\r\n\t\t\t}else{\r\n\t\t\t\tcancelItem();\r\n\t\t\t}\r\n\t\t}\r\n\t});\r\n\r\n\tinput.addEventListener(\"focus\", function(e){\r\n\t\tif(!blockListShow){\r\n\t\t\tshowList();\r\n\t\t}\r\n\t});\r\n\r\n\t//style list element\r\n\tlistEl = document.createElement(\"div\");\r\n\tlistEl.classList.add(\"tabulator-edit-select-list\");\r\n\r\n\tonRendered(function(){\r\n\t\tinput.style.height = \"100%\";\r\n\t\tinput.focus({preventScroll: true});\r\n\t});\r\n\r\n\tsetTimeout(() => {\r\n\t\tthis.table.rowManager.element.addEventListener(\"scroll\", cancelItem);\r\n\t}, 10);\r\n\r\n\treturn input;\r\n};","import Helpers from '../../../../core/Helpers.js';\r\n\r\n//autocomplete\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\tvar self = this,\r\n\tcellEl = cell.getElement(),\r\n\tinitialValue = cell.getValue(),\r\n\tvertNav = editorParams.verticalNavigation || \"editor\",\r\n\tinitialDisplayValue = typeof initialValue !== \"undefined\" || initialValue === null ? initialValue : (typeof editorParams.defaultValue !== \"undefined\" ? editorParams.defaultValue : \"\"),\r\n\tinput = document.createElement(\"input\"),\r\n\tlistEl = document.createElement(\"div\"),\r\n\tallItems = [],\r\n\tdisplayItems = [],\r\n\tvalues = [],\r\n\tcurrentItem = false,\r\n\tblurable = true,\r\n\tuniqueColumnValues = false;\r\n\r\n\t//style input\r\n\tinput.setAttribute(\"type\", \"search\");\r\n\r\n\tinput.style.padding = \"4px\";\r\n\tinput.style.width = \"100%\";\r\n\tinput.style.boxSizing = \"border-box\";\r\n\r\n\tif(editorParams.elementAttributes && typeof editorParams.elementAttributes == \"object\"){\r\n\t\tfor (let key in editorParams.elementAttributes){\r\n\t\t\tif(key.charAt(0) == \"+\"){\r\n\t\t\t\tkey = key.slice(1);\r\n\t\t\t\tinput.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes[\"+\" + key]);\r\n\t\t\t}else{\r\n\t\t\t\tinput.setAttribute(key, editorParams.elementAttributes[key]);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\t//style list element\r\n\tlistEl.classList.add(\"tabulator-edit-select-list\");\r\n\r\n\tlistEl.addEventListener(\"mousedown\", function(e){\r\n\t\tblurable = false;\r\n\r\n\t\tsetTimeout(function(){\r\n\t\t\tblurable = true;\r\n\t\t}, 10);\r\n\t});\r\n\r\n\r\n\tfunction genUniqueColumnValues(){\r\n\t\tif(editorParams.values === true){\r\n\t\t\tuniqueColumnValues = getUniqueColumnValues();\r\n\t\t}else if(typeof editorParams.values === \"string\"){\r\n\t\t\tuniqueColumnValues = getUniqueColumnValues(editorParams.values);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction getUniqueColumnValues(field){\r\n\t\tvar output = {},\r\n\t\tdata = self.table.getData(),\r\n\t\tcolumn;\r\n\r\n\t\tif(field){\r\n\t\t\tcolumn = self.table.columnManager.getColumnByField(field);\r\n\t\t}else{\r\n\t\t\tcolumn = cell.getColumn()._getSelf();\r\n\t\t}\r\n\r\n\t\tif(column){\r\n\t\t\tdata.forEach(function(row){\r\n\t\t\t\tvar val = column.getFieldValue(row);\r\n\r\n\t\t\t\tif(val !== null && typeof val !== \"undefined\" && val !== \"\"){\r\n\t\t\t\t\toutput[val] = true;\r\n\t\t\t\t}\r\n\t\t\t});\r\n\r\n\t\t\tif(editorParams.sortValuesList){\r\n\t\t\t\tif(editorParams.sortValuesList == \"asc\"){\r\n\t\t\t\t\toutput = Object.keys(output).sort();\r\n\t\t\t\t}else{\r\n\t\t\t\t\toutput = Object.keys(output).sort().reverse();\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\toutput = Object.keys(output);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tconsole.warn(\"unable to find matching column to create autocomplete lookup list:\", field);\r\n\t\t}\r\n\r\n\r\n\t\treturn output;\r\n\t}\r\n\r\n\tfunction filterList(term, intialLoad){\r\n\t\tvar matches = [],\r\n\t\tvalues, items, searchEl;\r\n\r\n\t\t//lookup base values list\r\n\t\tif(uniqueColumnValues){\r\n\t\t\tvalues = uniqueColumnValues;\r\n\t\t}else{\r\n\t\t\tvalues = editorParams.values || [];\r\n\t\t}\r\n\r\n\t\tif(editorParams.searchFunc){\r\n\t\t\tmatches = editorParams.searchFunc(term, values);\r\n\r\n\t\t\tif(matches instanceof Promise){\r\n\r\n\t\t\t\taddNotice(typeof editorParams.searchingPlaceholder !== \"undefined\" ? editorParams.searchingPlaceholder : \"Searching...\");\r\n\r\n\t\t\t\tmatches.then((result) => {\r\n\t\t\t\t\tfillListIfNotEmpty(parseItems(result), intialLoad);\r\n\t\t\t\t}).catch((err) => {\r\n\t\t\t\t\tconsole.err(\"error in autocomplete search promise:\", err);\r\n\t\t\t\t});\r\n\r\n\t\t\t}else{\r\n\t\t\t\tfillListIfNotEmpty(parseItems(matches), intialLoad);\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\titems = parseItems(values);\r\n\r\n\t\t\tif(term === \"\"){\r\n\t\t\t\tif(editorParams.showListOnEmpty){\r\n\t\t\t\t\tmatches = items;\r\n\t\t\t\t}\r\n\t\t\t}else{\r\n\t\t\t\titems.forEach(function(item){\r\n\t\t\t\t\tif(item.value !== null || typeof item.value !== \"undefined\"){\r\n\t\t\t\t\t\tif(String(item.value).toLowerCase().indexOf(String(term).toLowerCase()) > -1 || String(item.title).toLowerCase().indexOf(String(term).toLowerCase()) > -1){\r\n\t\t\t\t\t\t\tmatches.push(item);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r\n\t\t\t}\r\n\r\n\t\t\tfillListIfNotEmpty(matches, intialLoad);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction addNotice(notice){\r\n\t\tvar searchEl = document.createElement(\"div\");\r\n\r\n\t\tclearList();\r\n\r\n\t\tif(notice !== false){\r\n\t\t\tsearchEl.classList.add(\"tabulator-edit-select-list-notice\");\r\n\t\t\tsearchEl.tabIndex = 0;\r\n\r\n\t\t\tif(notice instanceof Node){\r\n\t\t\t\tsearchEl.appendChild(notice);\r\n\t\t\t}else{\r\n\t\t\t\tsearchEl.innerHTML = notice;\r\n\t\t\t}\r\n\r\n\t\t\tlistEl.appendChild(searchEl);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction parseItems(inputValues){\r\n\t\tvar itemList = [];\r\n\r\n\t\tif(Array.isArray(inputValues)){\r\n\t\t\tinputValues.forEach(function(value){\r\n\r\n\t\t\t\tvar item = {};\r\n\r\n\t\t\t\tif(typeof value === \"object\"){\r\n\t\t\t\t\titem.title = editorParams.listItemFormatter ? editorParams.listItemFormatter(value.value, value.label) : value.label;\r\n\t\t\t\t\titem.value = value.value;\r\n\t\t\t\t}else{\r\n\t\t\t\t\titem.title = editorParams.listItemFormatter ? editorParams.listItemFormatter(value, value) : value;\r\n\t\t\t\t\titem.value = value;\r\n\t\t\t\t}\r\n\r\n\t\t\t\titemList.push(item);\r\n\t\t\t});\r\n\t\t}else{\r\n\t\t\tfor(var key in inputValues){\r\n\t\t\t\tvar item = {\r\n\t\t\t\t\ttitle:editorParams.listItemFormatter ? editorParams.listItemFormatter(key, inputValues[key]) : inputValues[key],\r\n\t\t\t\t\tvalue:key,\r\n\t\t\t\t};\r\n\r\n\t\t\t\titemList.push(item);\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\treturn itemList;\r\n\t}\r\n\r\n\tfunction clearList(){\r\n\t\twhile(listEl.firstChild) listEl.removeChild(listEl.firstChild);\r\n\t}\r\n\r\n\tfunction fillListIfNotEmpty(items, intialLoad){\r\n\t\tif(items.length){\r\n\t\t\tfillList(items, intialLoad);\r\n\t\t}else{\r\n\t\t\tif(editorParams.emptyPlaceholder){\r\n\t\t\t\taddNotice(editorParams.emptyPlaceholder);\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction fillList(items, intialLoad){\r\n\t\tvar current = false;\r\n\r\n\t\tclearList();\r\n\r\n\t\tdisplayItems = items;\r\n\r\n\t\tdisplayItems.forEach(function(item){\r\n\t\t\tvar el = item.element;\r\n\r\n\t\t\tif(!el){\r\n\t\t\t\tel = document.createElement(\"div\");\r\n\t\t\t\tel.classList.add(\"tabulator-edit-select-list-item\");\r\n\t\t\t\tel.tabIndex = 0;\r\n\t\t\t\tel.innerHTML = item.title;\r\n\r\n\t\t\t\tel.addEventListener(\"click\", function(e){\r\n\t\t\t\t\tsetCurrentItem(item);\r\n\t\t\t\t\tchooseItem();\r\n\t\t\t\t});\r\n\r\n\t\t\t\tel.addEventListener(\"mousedown\", function(e){\r\n\t\t\t\t\tblurable = false;\r\n\r\n\t\t\t\t\tsetTimeout(function(){\r\n\t\t\t\t\t\tblurable = true;\r\n\t\t\t\t\t}, 10);\r\n\t\t\t\t});\r\n\r\n\t\t\t\titem.element = el;\r\n\r\n\t\t\t\tif(intialLoad && item.value == initialValue){\r\n\t\t\t\t\tinput.value = item.title;\r\n\t\t\t\t\titem.element.classList.add(\"active\");\r\n\t\t\t\t\tcurrent = true;\r\n\t\t\t\t}\r\n\r\n\t\t\t\tif(item === currentItem){\r\n\t\t\t\t\titem.element.classList.add(\"active\");\r\n\t\t\t\t\tcurrent = true;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tlistEl.appendChild(el);\r\n\t\t});\r\n\r\n\t\tif(!current){\r\n\t\t\tsetCurrentItem(false);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction chooseItem(){\r\n\t\thideList();\r\n\r\n\t\tif(currentItem){\r\n\t\t\tif(initialValue !== currentItem.value){\r\n\t\t\t\tinitialValue = currentItem.value;\r\n\t\t\t\tinput.value = currentItem.title;\r\n\t\t\t\tsuccess(currentItem.value);\r\n\t\t\t}else{\r\n\t\t\t\tcancel();\r\n\t\t\t}\r\n\t\t}else{\r\n\t\t\tif(editorParams.freetext){\r\n\t\t\t\tinitialValue = input.value;\r\n\t\t\t\tsuccess(input.value);\r\n\t\t\t}else{\r\n\t\t\t\tif(editorParams.allowEmpty && input.value === \"\"){\r\n\t\t\t\t\tinitialValue = input.value;\r\n\t\t\t\t\tsuccess(input.value);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tcancel();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tfunction showList(){\r\n\t\tif(!listEl.parentNode){\r\n\r\n\t\t\tconsole.log(\"show\", initialDisplayValue)\r\n\t\t\twhile(listEl.firstChild) listEl.removeChild(listEl.firstChild);\r\n\r\n\t\t\tvar offset = Helpers.elOffset(cellEl);\r\n\r\n\t\t\tlistEl.style.minWidth = cellEl.offsetWidth + \"px\";\r\n\r\n\t\t\tlistEl.style.top = (offset.top + cellEl.offsetHeight) + \"px\";\r\n\t\t\tlistEl.style.left = offset.left + \"px\";\r\n\t\t\tdocument.body.appendChild(listEl);\r\n\t\t}\r\n\t}\r\n\r\n\tfunction setCurrentItem(item, showInputValue){\r\n\t\tif(currentItem && currentItem.element){\r\n\t\t\tcurrentItem.element.classList.remove(\"active\");\r\n\t\t}\r\n\r\n\t\tcurrentItem = item;\r\n\r\n\t\tif(item && item.element){\r\n\t\t\titem.element.classList.add(\"active\");\r\n\t\t}\r\n\r\n\t\tif(item && item.element && item.element.scrollIntoView){\r\n\t\t\titem.element.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'start'});\r\n\t\t}\r\n\t}\r\n\r\n\tfunction hideList(){\r\n\t\tif(listEl.parentNode){\r\n\t\t\tlistEl.parentNode.removeChild(listEl);\r\n\t\t}\r\n\r\n\t\tremoveScrollListener();\r\n\t}\r\n\r\n\r\n\tfunction cancelItem(){\r\n\t\thideList();\r\n\t\tcancel();\r\n\t}\r\n\r\n\tfunction removeScrollListener() {\r\n\t\tself.table.rowManager.element.removeEventListener(\"scroll\", cancelItem);\r\n\t}\r\n\r\n\t//allow key based navigation\r\n\tinput.addEventListener(\"keydown\", function(e){\r\n\t\tvar index;\r\n\r\n\t\tswitch(e.keyCode){\r\n\t\t\tcase 38: //up arrow\r\n\t\t\tindex = displayItems.indexOf(currentItem);\r\n\r\n\t\t\tif(vertNav == \"editor\" || (vertNav == \"hybrid\" && index)){\r\n\t\t\t\te.stopImmediatePropagation();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\tif(index > 0){\r\n\t\t\t\t\tsetCurrentItem(displayItems[index - 1]);\r\n\t\t\t\t}else{\r\n\t\t\t\t\tsetCurrentItem(false);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 40: //down arrow\r\n\r\n\t\t\tindex = displayItems.indexOf(currentItem);\r\n\r\n\t\t\tif(vertNav == \"editor\" || (vertNav == \"hybrid\" && index < displayItems.length - 1)){\r\n\r\n\t\t\t\te.stopImmediatePropagation();\r\n\t\t\t\te.stopPropagation();\r\n\t\t\t\te.preventDefault();\r\n\r\n\t\t\t\tif(index < displayItems.length - 1){\r\n\t\t\t\t\tif(index == -1){\r\n\t\t\t\t\t\tsetCurrentItem(displayItems[0]);\r\n\t\t\t\t\t}else{\r\n\t\t\t\t\t\tsetCurrentItem(displayItems[index + 1]);\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tbreak;\r\n\r\n\r\n\t\t\tcase 37: //left arrow\r\n\t\t\tcase 39: //right arrow\r\n\t\t\te.stopImmediatePropagation();\r\n\t\t\te.stopPropagation();\r\n\t\t\t// e.preventDefault();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 13: //enter\r\n\t\t\tchooseItem();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 27: //escape\r\n\t\t\tcancelItem();\r\n\t\t\tbreak;\r\n\r\n\t\t\tcase 36: //home\r\n\t\t\tcase 35: //end\r\n\t\t\t//prevent table navigation while using input element\r\n\t\t\te.stopImmediatePropagation();\r\n\t\t\tbreak;\r\n\t\t}\r\n\t});\r\n\r\n\tinput.addEventListener(\"keyup\", function(e){\r\n\r\n\t\tswitch(e.keyCode){\r\n\t\t\tcase 38: //up arrow\r\n\t\t\tcase 37: //left arrow\r\n\t\t\tcase 39: //up arrow\r\n\t\t\tcase 40: //right arrow\r\n\t\t\tcase 13: //enter\r\n\t\t\tcase 27: //escape\r\n\t\t\tbreak;\r\n\r\n\t\t\tdefault:\r\n\t\t\tfilterList(input.value);\r\n\t\t}\r\n\r\n\t});\r\n\r\n\tinput.addEventListener(\"search\", function(e){\r\n\t\tfilterList(input.value);\r\n\t});\r\n\r\n\tinput.addEventListener(\"blur\", function(e){\r\n\t\tif(blurable){\r\n\t\t\tchooseItem();\r\n\t\t}\r\n\t});\r\n\r\n\tinput.addEventListener(\"focus\", function(e){\r\n\t\tvar value = initialDisplayValue;\r\n\t\tgenUniqueColumnValues();\r\n\t\tshowList();\r\n\t\tinput.value = value;\r\n\t\tfilterList(value, true);\r\n\t});\r\n\r\n\r\n\tonRendered(function(){\r\n\t\tinput.style.height = \"100%\";\r\n\t\tinput.focus({preventScroll: true});\r\n\t});\r\n\r\n\tif(editorParams.mask){\r\n\t\tthis.table.modules.edit.maskInput(input, editorParams);\r\n\t}\r\n\r\n\tsetTimeout(() => {\r\n\t\tthis.table.rowManager.element.addEventListener(\"scroll\", cancelItem);\r\n\t}, 10);\r\n\r\n\tgenUniqueColumnValues();\r\n\tinput.value = initialDisplayValue;\r\n\tfilterList(initialDisplayValue, true);\r\n\r\n\treturn input;\r\n};","//star rating\r\nexport default function(cell, onRendered, success, cancel, editorParams){\r\n\tvar self = this,\r\n\telement = cell.getElement(),\r\n\tvalue = cell.getValue(),\r\n\tmaxStars = element.getElementsByTagName(\"svg\").length || 5,\r\n\tsize = element.getElementsByTagName(\"svg\")[0] ? element.getElementsByTagName(\"svg\")[0].getAttribute(\"width\") : 14,\r\n\tstars = [],\r\n\tstarsHolder = document.createElement(\"div\"),\r\n\tstar = document.createElementNS('http://www.w3.org/2000/svg', \"svg\");\r\n\r\n\r\n\t//change star type\r\n\tfunction starChange(val){\r\n\t\tstars.forEach(function(star, i){\r\n\t\t\tif(i < val){\r\n\t\t\t\tif(self.table.browser == \"ie\"){\r\n\t\t\t\t\tstar.setAttribute(\"class\", \"tabulator-star-active\");\r\n\t\t\t\t}else{\r\n\t\t\t\t\tstar.classList.replace(\"tabulator-star-inactive\", \"tabulator-star-active\");\r\n\t\t\t\t}\r\n\r\n\t\t\t\tstar.innerHTML = '