Path: blob/main/dev-docs/feature-format-matrix/dist/js/tabulator.js
6465 views
/* Tabulator v5.5.2 (c) Oliver Folkerd 2023 */1(function (global, factory) {2typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :3typeof define === 'function' && define.amd ? define(factory) :4(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tabulator = factory());5}(this, (function () { 'use strict';67var defaultOptions = {89debugEventsExternal:false, //flag to console log events10debugEventsInternal:false, //flag to console log events11debugInvalidOptions:true, //allow toggling of invalid option warnings12debugInvalidComponentFuncs:true, //allow toggling of invalid component warnings13debugInitialization:true, //allow toggling of pre initialization function call warnings14debugDeprecation:true, //allow toggling of deprecation warnings1516height:false, //height of tabulator17minHeight:false, //minimum height of tabulator18maxHeight:false, //maximum height of tabulator1920columnHeaderVertAlign:"top", //vertical alignment of column headers2122popupContainer:false,2324columns:[],//store for colum header info25columnDefaults:{}, //store column default props2627data:false, //default starting data2829autoColumns:false, //build columns from data row structure30autoColumnsDefinitions:false,3132nestedFieldSeparator:".", //separator for nested data3334footerElement:false, //hold footer element3536index:"id", //filed for row index3738textDirection:"auto",3940addRowPos:"bottom", //position to insert blank rows, top|bottom4142headerVisible:true, //hide header4344renderVertical:"virtual",45renderHorizontal:"basic",46renderVerticalBuffer:0, // set virtual DOM buffer size4748scrollToRowPosition:"top",49scrollToRowIfVisible:true,5051scrollToColumnPosition:"left",52scrollToColumnIfVisible:true,5354rowFormatter:false,55rowFormatterPrint:null,56rowFormatterClipboard:null,57rowFormatterHtmlOutput:null,5859rowHeight:null,6061placeholder:false,6263dataLoader:true,64dataLoaderLoading:false,65dataLoaderError:false,66dataLoaderErrorTimeout:3000,6768dataSendParams:{},6970dataReceiveParams:{},71};7273class CoreFeature{7475constructor(table){76this.table = table;77}7879//////////////////////////////////////////80/////////////// DataLoad /////////////////81//////////////////////////////////////////8283reloadData(data, silent, columnsChanged){84return this.table.dataLoader.load(data, undefined, undefined, undefined, silent, columnsChanged);85}8687//////////////////////////////////////////88///////////// Localization ///////////////89//////////////////////////////////////////9091langText(){92return this.table.modules.localize.getText(...arguments);93}9495langBind(){96return this.table.modules.localize.bind(...arguments);97}9899langLocale(){100return this.table.modules.localize.getLocale(...arguments);101}102103104//////////////////////////////////////////105////////// Inter Table Comms /////////////106//////////////////////////////////////////107108commsConnections(){109return this.table.modules.comms.getConnections(...arguments);110}111112commsSend(){113return this.table.modules.comms.send(...arguments);114}115116//////////////////////////////////////////117//////////////// Layout /////////////////118//////////////////////////////////////////119120layoutMode(){121return this.table.modules.layout.getMode();122}123124layoutRefresh(force){125return this.table.modules.layout.layout(force);126}127128129//////////////////////////////////////////130/////////////// Event Bus ////////////////131//////////////////////////////////////////132133subscribe(){134return this.table.eventBus.subscribe(...arguments);135}136137unsubscribe(){138return this.table.eventBus.unsubscribe(...arguments);139}140141subscribed(key){142return this.table.eventBus.subscribed(key);143}144145subscriptionChange(){146return this.table.eventBus.subscriptionChange(...arguments);147}148149dispatch(){150return this.table.eventBus.dispatch(...arguments);151}152153chain(){154return this.table.eventBus.chain(...arguments);155}156157confirm(){158return this.table.eventBus.confirm(...arguments);159}160161dispatchExternal(){162return this.table.externalEvents.dispatch(...arguments);163}164165subscribedExternal(key){166return this.table.externalEvents.subscribed(key);167}168169subscriptionChangeExternal(){170return this.table.externalEvents.subscriptionChange(...arguments);171}172173//////////////////////////////////////////174//////////////// Options /////////////////175//////////////////////////////////////////176177options(key){178return this.table.options[key];179}180181setOption(key, value){182if(typeof value !== "undefined"){183this.table.options[key] = value;184}185186return this.table.options[key];187}188189//////////////////////////////////////////190/////////// Deprecation Checks ///////////191//////////////////////////////////////////192193deprecationCheck(oldOption, newOption){194return this.table.deprecationAdvisor.check(oldOption, newOption);195}196197deprecationCheckMsg(oldOption, msg){198return this.table.deprecationAdvisor.checkMsg(oldOption, msg);199}200201deprecationMsg(msg){202return this.table.deprecationAdvisor.msg(msg);203}204//////////////////////////////////////////205//////////////// Modules /////////////////206//////////////////////////////////////////207208module(key){209return this.table.module(key);210}211}212213//public column object214class ColumnComponent {215constructor (column){216this._column = column;217this.type = "ColumnComponent";218219return new Proxy(this, {220get: function(target, name, receiver) {221if (typeof target[name] !== "undefined") {222return target[name];223}else {224return target._column.table.componentFunctionBinder.handle("column", target._column, name);225}226}227});228}229230getElement(){231return this._column.getElement();232}233234getDefinition(){235return this._column.getDefinition();236}237238getField(){239return this._column.getField();240}241242getTitleDownload() {243return this._column.getTitleDownload();244}245246getCells(){247var cells = [];248249this._column.cells.forEach(function(cell){250cells.push(cell.getComponent());251});252253return cells;254}255256isVisible(){257return this._column.visible;258}259260show(){261if(this._column.isGroup){262this._column.columns.forEach(function(column){263column.show();264});265}else {266this._column.show();267}268}269270hide(){271if(this._column.isGroup){272this._column.columns.forEach(function(column){273column.hide();274});275}else {276this._column.hide();277}278}279280toggle(){281if(this._column.visible){282this.hide();283}else {284this.show();285}286}287288delete(){289return this._column.delete();290}291292getSubColumns(){293var output = [];294295if(this._column.columns.length){296this._column.columns.forEach(function(column){297output.push(column.getComponent());298});299}300301return output;302}303304getParentColumn(){305return this._column.parent instanceof Column ? this._column.parent.getComponent() : false;306}307308_getSelf(){309return this._column;310}311312scrollTo(position, ifVisible){313return this._column.table.columnManager.scrollToColumn(this._column, position, ifVisible);314}315316getTable(){317return this._column.table;318}319320move(to, after){321var toColumn = this._column.table.columnManager.findColumn(to);322323if(toColumn){324this._column.table.columnManager.moveColumn(this._column, toColumn, after);325}else {326console.warn("Move Error - No matching column found:", toColumn);327}328}329330getNextColumn(){331var nextCol = this._column.nextColumn();332333return nextCol ? nextCol.getComponent() : false;334}335336getPrevColumn(){337var prevCol = this._column.prevColumn();338339return prevCol ? prevCol.getComponent() : false;340}341342updateDefinition(updates){343return this._column.updateDefinition(updates);344}345346getWidth(){347return this._column.getWidth();348}349350setWidth(width){351var result;352353if(width === true){354result = this._column.reinitializeWidth(true);355}else {356result = this._column.setWidth(width);357}358359this._column.table.columnManager.rerenderColumns(true);360361return result;362}363}364365var defaultColumnOptions = {366"title": undefined,367"field": undefined,368"columns": undefined,369"visible": undefined,370"hozAlign": undefined,371"vertAlign": undefined,372"width": undefined,373"minWidth": 40,374"maxWidth": undefined,375"maxInitialWidth": undefined,376"cssClass": undefined,377"variableHeight": undefined,378"headerVertical": undefined,379"headerHozAlign": undefined,380"headerWordWrap": false,381"editableTitle": undefined,382};383384//public cell object385class CellComponent {386387constructor (cell){388this._cell = cell;389390return new Proxy(this, {391get: function(target, name, receiver) {392if (typeof target[name] !== "undefined") {393return target[name];394}else {395return target._cell.table.componentFunctionBinder.handle("cell", target._cell, name);396}397}398});399}400401getValue(){402return this._cell.getValue();403}404405getOldValue(){406return this._cell.getOldValue();407}408409getInitialValue(){410return this._cell.initialValue;411}412413getElement(){414return this._cell.getElement();415}416417getRow(){418return this._cell.row.getComponent();419}420421getData(transform){422return this._cell.row.getData(transform);423}424getType(){425return "cell";426}427getField(){428return this._cell.column.getField();429}430431getColumn(){432return this._cell.column.getComponent();433}434435setValue(value, mutate){436if(typeof mutate == "undefined"){437mutate = true;438}439440this._cell.setValue(value, mutate);441}442443restoreOldValue(){444this._cell.setValueActual(this._cell.getOldValue());445}446447restoreInitialValue(){448this._cell.setValueActual(this._cell.initialValue);449}450451checkHeight(){452this._cell.checkHeight();453}454455getTable(){456return this._cell.table;457}458459_getSelf(){460return this._cell;461}462}463464class Cell extends CoreFeature{465constructor(column, row){466super(column.table);467468this.table = column.table;469this.column = column;470this.row = row;471this.element = null;472this.value = null;473this.initialValue;474this.oldValue = null;475this.modules = {};476477this.height = null;478this.width = null;479this.minWidth = null;480481this.component = null;482483this.loaded = false; //track if the cell has been added to the DOM yet484485this.build();486}487488//////////////// Setup Functions /////////////////489//generate element490build(){491this.generateElement();492493this.setWidth();494495this._configureCell();496497this.setValueActual(this.column.getFieldValue(this.row.data));498499this.initialValue = this.value;500}501502generateElement(){503this.element = document.createElement('div');504this.element.className = "tabulator-cell";505this.element.setAttribute("role", "gridcell");506}507508_configureCell(){509var element = this.element,510field = this.column.getField(),511vertAligns = {512top:"flex-start",513bottom:"flex-end",514middle:"center",515},516hozAligns = {517left:"flex-start",518right:"flex-end",519center:"center",520};521522//set text alignment523element.style.textAlign = this.column.hozAlign;524525if(this.column.vertAlign){526element.style.display = "inline-flex";527528element.style.alignItems = vertAligns[this.column.vertAlign] || "";529530if(this.column.hozAlign){531element.style.justifyContent = hozAligns[this.column.hozAlign] || "";532}533}534535if(field){536element.setAttribute("tabulator-field", field);537}538539//add class to cell if needed540if(this.column.definition.cssClass){541var classNames = this.column.definition.cssClass.split(" ");542classNames.forEach((className) => {543element.classList.add(className);544});545}546547this.dispatch("cell-init", this);548549//hide cell if not visible550if(!this.column.visible){551this.hide();552}553}554555//generate cell contents556_generateContents(){557var val;558559val = this.chain("cell-format", this, null, () => {560return this.element.innerHTML = this.value;561});562563switch(typeof val){564case "object":565if(val instanceof Node){566567//clear previous cell contents568while(this.element.firstChild) this.element.removeChild(this.element.firstChild);569570this.element.appendChild(val);571}else {572this.element.innerHTML = "";573574if(val != null){575console.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);576}577}578break;579case "undefined":580this.element.innerHTML = "";581break;582default:583this.element.innerHTML = val;584}585}586587cellRendered(){588this.dispatch("cell-rendered", this);589}590591//////////////////// Getters ////////////////////592getElement(containerOnly){593if(!this.loaded){594this.loaded = true;595if(!containerOnly){596this.layoutElement();597}598}599600return this.element;601}602603getValue(){604return this.value;605}606607getOldValue(){608return this.oldValue;609}610611//////////////////// Actions ////////////////////612setValue(value, mutate, force){613var changed = this.setValueProcessData(value, mutate, force);614615if(changed){616this.dispatch("cell-value-updated", this);617618this.cellRendered();619620if(this.column.definition.cellEdited){621this.column.definition.cellEdited.call(this.table, this.getComponent());622}623624this.dispatchExternal("cellEdited", this.getComponent());625626if(this.subscribedExternal("dataChanged")){627this.dispatchExternal("dataChanged", this.table.rowManager.getData());628}629}630}631632setValueProcessData(value, mutate, force){633var changed = false;634635if(this.value !== value || force){636637changed = true;638639if(mutate){640value = this.chain("cell-value-changing", [this, value], null, value);641}642}643644this.setValueActual(value);645646if(changed){647this.dispatch("cell-value-changed", this);648}649650return changed;651}652653setValueActual(value){654this.oldValue = this.value;655656this.value = value;657658this.dispatch("cell-value-save-before", this);659660this.column.setFieldValue(this.row.data, value);661662this.dispatch("cell-value-save-after", this);663664if(this.loaded){665this.layoutElement();666}667}668669layoutElement(){670this._generateContents();671672this.dispatch("cell-layout", this);673}674675setWidth(){676this.width = this.column.width;677this.element.style.width = this.column.widthStyled;678}679680clearWidth(){681this.width = "";682this.element.style.width = "";683}684685getWidth(){686return this.width || this.element.offsetWidth;687}688689setMinWidth(){690this.minWidth = this.column.minWidth;691this.element.style.minWidth = this.column.minWidthStyled;692}693694setMaxWidth(){695this.maxWidth = this.column.maxWidth;696this.element.style.maxWidth = this.column.maxWidthStyled;697}698699checkHeight(){700// var height = this.element.css("height");701this.row.reinitializeHeight();702}703704clearHeight(){705this.element.style.height = "";706this.height = null;707708this.dispatch("cell-height", this, "");709}710711setHeight(){712this.height = this.row.height;713this.element.style.height = this.row.heightStyled;714715this.dispatch("cell-height", this, this.row.heightStyled);716}717718getHeight(){719return this.height || this.element.offsetHeight;720}721722show(){723this.element.style.display = this.column.vertAlign ? "inline-flex" : "";724}725726hide(){727this.element.style.display = "none";728}729730delete(){731this.dispatch("cell-delete", this);732733if(!this.table.rowManager.redrawBlock && this.element.parentNode){734this.element.parentNode.removeChild(this.element);735}736737this.element = false;738this.column.deleteCell(this);739this.row.deleteCell(this);740this.calcs = {};741}742743getIndex(){744return this.row.getCellIndex(this);745}746747//////////////// Object Generation /////////////////748getComponent(){749if(!this.component){750this.component = new CellComponent(this);751}752753return this.component;754}755}756757class Column extends CoreFeature{758759constructor(def, parent){760super(parent.table);761762this.definition = def; //column definition763this.parent = parent; //hold parent object764this.type = "column"; //type of element765this.columns = []; //child columns766this.cells = []; //cells bound to this column767this.element = this.createElement(); //column header element768this.contentElement = false;769this.titleHolderElement = false;770this.titleElement = false;771this.groupElement = this.createGroupElement(); //column group holder element772this.isGroup = false;773this.hozAlign = ""; //horizontal text alignment774this.vertAlign = ""; //vert text alignment775776//multi dimensional filed handling777this.field ="";778this.fieldStructure = "";779this.getFieldValue = "";780this.setFieldValue = "";781782this.titleDownload = null;783this.titleFormatterRendered = false;784785this.mapDefinitions();786787this.setField(this.definition.field);788789this.modules = {}; //hold module variables;790791this.width = null; //column width792this.widthStyled = ""; //column width pre-styled to improve render efficiency793this.maxWidth = null; //column maximum width794this.maxWidthStyled = ""; //column maximum pre-styled to improve render efficiency795this.maxInitialWidth = null;796this.minWidth = null; //column minimum width797this.minWidthStyled = ""; //column minimum pre-styled to improve render efficiency798this.widthFixed = false; //user has specified a width for this column799800this.visible = true; //default visible state801802this.component = null;803804//initialize column805if(this.definition.columns){806807this.isGroup = true;808809this.definition.columns.forEach((def, i) => {810var newCol = new Column(def, this);811this.attachColumn(newCol);812});813814this.checkColumnVisibility();815}else {816parent.registerColumnField(this);817}818819this._initialize();820}821822createElement (){823var el = document.createElement("div");824825el.classList.add("tabulator-col");826el.setAttribute("role", "columnheader");827el.setAttribute("aria-sort", "none");828829switch(this.table.options.columnHeaderVertAlign){830case "middle":831el.style.justifyContent = "center";832break;833case "bottom":834el.style.justifyContent = "flex-end";835break;836}837838return el;839}840841createGroupElement (){842var el = document.createElement("div");843844el.classList.add("tabulator-col-group-cols");845846return el;847}848849mapDefinitions(){850var defaults = this.table.options.columnDefaults;851852//map columnDefaults onto column definitions853if(defaults){854for(let key in defaults){855if(typeof this.definition[key] === "undefined"){856this.definition[key] = defaults[key];857}858}859}860861this.definition = this.table.columnManager.optionsList.generate(Column.defaultOptionList, this.definition);862}863864checkDefinition(){865Object.keys(this.definition).forEach((key) => {866if(Column.defaultOptionList.indexOf(key) === -1){867console.warn("Invalid column definition option in '" + (this.field || this.definition.title) + "' column:", key);868}869});870}871872setField(field){873this.field = field;874this.fieldStructure = field ? (this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field]) : [];875this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;876this.setFieldValue = this.fieldStructure.length > 1 ? this._setNestedData : this._setFlatData;877}878879//register column position with column manager880registerColumnPosition(column){881this.parent.registerColumnPosition(column);882}883884//register column position with column manager885registerColumnField(column){886this.parent.registerColumnField(column);887}888889//trigger position registration890reRegisterPosition(){891if(this.isGroup){892this.columns.forEach(function(column){893column.reRegisterPosition();894});895}else {896this.registerColumnPosition(this);897}898}899900//build header element901_initialize(){902var def = this.definition;903904while(this.element.firstChild) this.element.removeChild(this.element.firstChild);905906if(def.headerVertical){907this.element.classList.add("tabulator-col-vertical");908909if(def.headerVertical === "flip"){910this.element.classList.add("tabulator-col-vertical-flip");911}912}913914this.contentElement = this._buildColumnHeaderContent();915916this.element.appendChild(this.contentElement);917918if(this.isGroup){919this._buildGroupHeader();920}else {921this._buildColumnHeader();922}923924this.dispatch("column-init", this);925}926927//build header element for header928_buildColumnHeader(){929var def = this.definition;930931this.dispatch("column-layout", this);932933//set column visibility934if(typeof def.visible != "undefined"){935if(def.visible){936this.show(true);937}else {938this.hide(true);939}940}941942//assign additional css classes to column header943if(def.cssClass){944var classNames = def.cssClass.split(" ");945classNames.forEach((className) => {946this.element.classList.add(className);947});948}949950if(def.field){951this.element.setAttribute("tabulator-field", def.field);952}953954//set min width if present955this.setMinWidth(parseInt(def.minWidth));956957if (def.maxInitialWidth) {958this.maxInitialWidth = parseInt(def.maxInitialWidth);959}960961if(def.maxWidth){962this.setMaxWidth(parseInt(def.maxWidth));963}964965this.reinitializeWidth();966967//set horizontal text alignment968this.hozAlign = this.definition.hozAlign;969this.vertAlign = this.definition.vertAlign;970971this.titleElement.style.textAlign = this.definition.headerHozAlign;972}973974_buildColumnHeaderContent(){975var contentElement = document.createElement("div");976contentElement.classList.add("tabulator-col-content");977978this.titleHolderElement = document.createElement("div");979this.titleHolderElement.classList.add("tabulator-col-title-holder");980981contentElement.appendChild(this.titleHolderElement);982983this.titleElement = this._buildColumnHeaderTitle();984985this.titleHolderElement.appendChild(this.titleElement);986987return contentElement;988}989990//build title element of column991_buildColumnHeaderTitle(){992var def = this.definition;993994var titleHolderElement = document.createElement("div");995titleHolderElement.classList.add("tabulator-col-title");996997if(def.headerWordWrap){998titleHolderElement.classList.add("tabulator-col-title-wrap");999}10001001if(def.editableTitle){1002var titleElement = document.createElement("input");1003titleElement.classList.add("tabulator-title-editor");10041005titleElement.addEventListener("click", (e) => {1006e.stopPropagation();1007titleElement.focus();1008});10091010titleElement.addEventListener("change", () => {1011def.title = titleElement.value;1012this.dispatchExternal("columnTitleChanged", this.getComponent());1013});10141015titleHolderElement.appendChild(titleElement);10161017if(def.field){1018this.langBind("columns|" + def.field, (text) => {1019titleElement.value = text || (def.title || " ");1020});1021}else {1022titleElement.value = def.title || " ";1023}10241025}else {1026if(def.field){1027this.langBind("columns|" + def.field, (text) => {1028this._formatColumnHeaderTitle(titleHolderElement, text || (def.title || " "));1029});1030}else {1031this._formatColumnHeaderTitle(titleHolderElement, def.title || " ");1032}1033}10341035return titleHolderElement;1036}10371038_formatColumnHeaderTitle(el, title){1039var contents = this.chain("column-format", [this, title, el], null, () => {1040return title;1041});10421043switch(typeof contents){1044case "object":1045if(contents instanceof Node){1046el.appendChild(contents);1047}else {1048el.innerHTML = "";1049console.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);1050}1051break;1052case "undefined":1053el.innerHTML = "";1054break;1055default:1056el.innerHTML = contents;1057}1058}10591060//build header element for column group1061_buildGroupHeader(){1062this.element.classList.add("tabulator-col-group");1063this.element.setAttribute("role", "columngroup");1064this.element.setAttribute("aria-title", this.definition.title);10651066//asign additional css classes to column header1067if(this.definition.cssClass){1068var classNames = this.definition.cssClass.split(" ");1069classNames.forEach((className) => {1070this.element.classList.add(className);1071});1072}10731074this.titleElement.style.textAlign = this.definition.headerHozAlign;10751076this.element.appendChild(this.groupElement);1077}10781079//flat field lookup1080_getFlatData(data){1081return data[this.field];1082}10831084//nested field lookup1085_getNestedData(data){1086var dataObj = data,1087structure = this.fieldStructure,1088length = structure.length,1089output;10901091for(let i = 0; i < length; i++){10921093dataObj = dataObj[structure[i]];10941095output = dataObj;10961097if(!dataObj){1098break;1099}1100}11011102return output;1103}11041105//flat field set1106_setFlatData(data, value){1107if(this.field){1108data[this.field] = value;1109}1110}11111112//nested field set1113_setNestedData(data, value){1114var dataObj = data,1115structure = this.fieldStructure,1116length = structure.length;11171118for(let i = 0; i < length; i++){11191120if(i == length -1){1121dataObj[structure[i]] = value;1122}else {1123if(!dataObj[structure[i]]){1124if(typeof value !== "undefined"){1125dataObj[structure[i]] = {};1126}else {1127break;1128}1129}11301131dataObj = dataObj[structure[i]];1132}1133}1134}11351136//attach column to this group1137attachColumn(column){1138if(this.groupElement){1139this.columns.push(column);1140this.groupElement.appendChild(column.getElement());11411142column.columnRendered();1143}else {1144console.warn("Column Warning - Column being attached to another column instead of column group");1145}1146}11471148//vertically align header in column1149verticalAlign(alignment, height){11501151//calculate height of column header and group holder element1152var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : (height || this.parent.getHeadersElement().clientHeight);1153// var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : this.parent.getHeadersElement().clientHeight;11541155this.element.style.height = parentHeight + "px";11561157this.dispatch("column-height", this, this.element.style.height);11581159if(this.isGroup){1160this.groupElement.style.minHeight = (parentHeight - this.contentElement.offsetHeight) + "px";1161}11621163//vertically align cell contents1164// if(!this.isGroup && alignment !== "top"){1165// if(alignment === "bottom"){1166// this.element.style.paddingTop = (this.element.clientHeight - this.contentElement.offsetHeight) + "px";1167// }else{1168// this.element.style.paddingTop = ((this.element.clientHeight - this.contentElement.offsetHeight) / 2) + "px";1169// }1170// }11711172this.columns.forEach(function(column){1173column.verticalAlign(alignment);1174});1175}11761177//clear vertical alignment1178clearVerticalAlign(){1179this.element.style.paddingTop = "";1180this.element.style.height = "";1181this.element.style.minHeight = "";1182this.groupElement.style.minHeight = "";11831184this.columns.forEach(function(column){1185column.clearVerticalAlign();1186});11871188this.dispatch("column-height", this, "");1189}11901191//// Retrieve Column Information ////1192//return column header element1193getElement(){1194return this.element;1195}11961197//return column group element1198getGroupElement(){1199return this.groupElement;1200}12011202//return field name1203getField(){1204return this.field;1205}12061207getTitleDownload() {1208return this.titleDownload;1209}12101211//return the first column in a group1212getFirstColumn(){1213if(!this.isGroup){1214return this;1215}else {1216if(this.columns.length){1217return this.columns[0].getFirstColumn();1218}else {1219return false;1220}1221}1222}12231224//return the last column in a group1225getLastColumn(){1226if(!this.isGroup){1227return this;1228}else {1229if(this.columns.length){1230return this.columns[this.columns.length -1].getLastColumn();1231}else {1232return false;1233}1234}1235}12361237//return all columns in a group1238getColumns(traverse){1239var columns = [];12401241if(traverse){1242this.columns.forEach((column) => {1243columns.push(column);12441245columns = columns.concat(column.getColumns(true));1246});1247}else {1248columns = this.columns;1249}12501251return columns;1252}12531254//return all columns in a group1255getCells(){1256return this.cells;1257}12581259//retrieve the top column in a group of columns1260getTopColumn(){1261if(this.parent.isGroup){1262return this.parent.getTopColumn();1263}else {1264return this;1265}1266}12671268//return column definition object1269getDefinition(updateBranches){1270var colDefs = [];12711272if(this.isGroup && updateBranches){1273this.columns.forEach(function(column){1274colDefs.push(column.getDefinition(true));1275});12761277this.definition.columns = colDefs;1278}12791280return this.definition;1281}12821283//////////////////// Actions ////////////////////1284checkColumnVisibility(){1285var visible = false;12861287this.columns.forEach(function(column){1288if(column.visible){1289visible = true;1290}1291});12921293if(visible){1294this.show();1295this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);1296}else {1297this.hide();1298}1299}13001301//show column1302show(silent, responsiveToggle){1303if(!this.visible){1304this.visible = true;13051306this.element.style.display = "";13071308if(this.parent.isGroup){1309this.parent.checkColumnVisibility();1310}13111312this.cells.forEach(function(cell){1313cell.show();1314});13151316if(!this.isGroup && this.width === null){1317this.reinitializeWidth();1318}13191320this.table.columnManager.verticalAlignHeaders();13211322this.dispatch("column-show", this, responsiveToggle);13231324if(!silent){1325this.dispatchExternal("columnVisibilityChanged", this.getComponent(), true);1326}13271328if(this.parent.isGroup){1329this.parent.matchChildWidths();1330}13311332if(!this.silent){1333this.table.columnManager.rerenderColumns();1334}1335}1336}13371338//hide column1339hide(silent, responsiveToggle){1340if(this.visible){1341this.visible = false;13421343this.element.style.display = "none";13441345this.table.columnManager.verticalAlignHeaders();13461347if(this.parent.isGroup){1348this.parent.checkColumnVisibility();1349}13501351this.cells.forEach(function(cell){1352cell.hide();1353});13541355this.dispatch("column-hide", this, responsiveToggle);13561357if(!silent){1358this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);1359}13601361if(this.parent.isGroup){1362this.parent.matchChildWidths();1363}13641365if(!this.silent){1366this.table.columnManager.rerenderColumns();1367}1368}1369}13701371matchChildWidths(){1372var childWidth = 0;13731374if(this.contentElement && this.columns.length){1375this.columns.forEach(function(column){1376if(column.visible){1377childWidth += column.getWidth();1378}1379});13801381this.contentElement.style.maxWidth = (childWidth - 1) + "px";13821383if(this.parent.isGroup){1384this.parent.matchChildWidths();1385}1386}1387}13881389removeChild(child){1390var index = this.columns.indexOf(child);13911392if(index > -1){1393this.columns.splice(index, 1);1394}13951396if(!this.columns.length){1397this.delete();1398}1399}14001401setWidth(width){1402this.widthFixed = true;1403this.setWidthActual(width);1404}14051406setWidthActual(width){1407if(isNaN(width)){1408width = Math.floor((this.table.element.clientWidth/100) * parseInt(width));1409}14101411width = Math.max(this.minWidth, width);14121413if(this.maxWidth){1414width = Math.min(this.maxWidth, width);1415}14161417this.width = width;1418this.widthStyled = width ? width + "px" : "";14191420this.element.style.width = this.widthStyled;14211422if(!this.isGroup){1423this.cells.forEach(function(cell){1424cell.setWidth();1425});1426}14271428if(this.parent.isGroup){1429this.parent.matchChildWidths();1430}14311432this.dispatch("column-width", this);1433}14341435checkCellHeights(){1436var rows = [];14371438this.cells.forEach(function(cell){1439if(cell.row.heightInitialized){1440if(cell.row.getElement().offsetParent !== null){1441rows.push(cell.row);1442cell.row.clearCellHeight();1443}else {1444cell.row.heightInitialized = false;1445}1446}1447});14481449rows.forEach(function(row){1450row.calcHeight();1451});14521453rows.forEach(function(row){1454row.setCellHeight();1455});1456}14571458getWidth(){1459var width = 0;14601461if(this.isGroup){1462this.columns.forEach(function(column){1463if(column.visible){1464width += column.getWidth();1465}1466});1467}else {1468width = this.width;1469}14701471return width;1472}14731474getLeftOffset(){1475var offset = this.element.offsetLeft;14761477if(this.parent.isGroup){1478offset += this.parent.getLeftOffset();1479}14801481return offset;1482}14831484getHeight(){1485return Math.ceil(this.element.getBoundingClientRect().height);1486}14871488setMinWidth(minWidth){1489if(this.maxWidth && minWidth > this.maxWidth){1490minWidth = this.maxWidth;14911492console.warn("the minWidth ("+ minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth ("+ this.maxWidthStyled + ")");1493}14941495this.minWidth = minWidth;1496this.minWidthStyled = minWidth ? minWidth + "px" : "";14971498this.element.style.minWidth = this.minWidthStyled;14991500this.cells.forEach(function(cell){1501cell.setMinWidth();1502});1503}15041505setMaxWidth(maxWidth){1506if(this.minWidth && maxWidth < this.minWidth){1507maxWidth = this.minWidth;15081509console.warn("the maxWidth ("+ maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth ("+ this.minWidthStyled + ")");1510}15111512this.maxWidth = maxWidth;1513this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";15141515this.element.style.maxWidth = this.maxWidthStyled;15161517this.cells.forEach(function(cell){1518cell.setMaxWidth();1519});1520}15211522delete(){1523return new Promise((resolve, reject) => {1524if(this.isGroup){1525this.columns.forEach(function(column){1526column.delete();1527});1528}15291530this.dispatch("column-delete", this);15311532var cellCount = this.cells.length;15331534for(let i = 0; i < cellCount; i++){1535this.cells[0].delete();1536}15371538if(this.element.parentNode){1539this.element.parentNode.removeChild(this.element);1540}15411542this.element = false;1543this.contentElement = false;1544this.titleElement = false;1545this.groupElement = false;15461547if(this.parent.isGroup){1548this.parent.removeChild(this);1549}15501551this.table.columnManager.deregisterColumn(this);15521553this.table.columnManager.rerenderColumns(true);15541555resolve();1556});1557}15581559columnRendered(){1560if(this.titleFormatterRendered){1561this.titleFormatterRendered();1562}15631564this.dispatch("column-rendered", this);1565}15661567//////////////// Cell Management /////////////////1568//generate cell for this column1569generateCell(row){1570var cell = new Cell(this, row);15711572this.cells.push(cell);15731574return cell;1575}15761577nextColumn(){1578var index = this.table.columnManager.findColumnIndex(this);1579return index > -1 ? this._nextVisibleColumn(index + 1) : false;1580}15811582_nextVisibleColumn(index){1583var column = this.table.columnManager.getColumnByIndex(index);1584return !column || column.visible ? column : this._nextVisibleColumn(index + 1);1585}15861587prevColumn(){1588var index = this.table.columnManager.findColumnIndex(this);1589return index > -1 ? this._prevVisibleColumn(index - 1) : false;1590}15911592_prevVisibleColumn(index){1593var column = this.table.columnManager.getColumnByIndex(index);1594return !column || column.visible ? column : this._prevVisibleColumn(index - 1);1595}15961597reinitializeWidth(force){1598this.widthFixed = false;15991600//set width if present1601if(typeof this.definition.width !== "undefined" && !force){1602// maxInitialWidth ignored here as width specified1603this.setWidth(this.definition.width);1604}16051606this.dispatch("column-width-fit-before", this);16071608this.fitToData(force);16091610this.dispatch("column-width-fit-after", this);1611}16121613//set column width to maximum cell width for non group columns1614fitToData(force){1615if(this.isGroup){1616return;1617}16181619if(!this.widthFixed){1620this.element.style.width = "";16211622this.cells.forEach((cell) => {1623cell.clearWidth();1624});1625}16261627var maxWidth = this.element.offsetWidth;16281629if(!this.width || !this.widthFixed){1630this.cells.forEach((cell) => {1631var width = cell.getWidth();16321633if(width > maxWidth){1634maxWidth = width;1635}1636});16371638if(maxWidth){1639var setTo = maxWidth + 1;1640if (this.maxInitialWidth && !force) {1641setTo = Math.min(setTo, this.maxInitialWidth);1642}1643this.setWidthActual(setTo);1644}1645}1646}16471648updateDefinition(updates){1649var definition;16501651if(!this.isGroup){1652if(!this.parent.isGroup){1653definition = Object.assign({}, this.getDefinition());1654definition = Object.assign(definition, updates);16551656return this.table.columnManager.addColumn(definition, false, this)1657.then((column) => {16581659if(definition.field == this.field){1660this.field = false; //clear field name to prevent deletion of duplicate column from arrays1661}16621663return this.delete()1664.then(() => {1665return column.getComponent();1666});16671668});1669}else {1670console.error("Column Update Error - The updateDefinition function is only available on ungrouped columns");1671return Promise.reject("Column Update Error - The updateDefinition function is only available on columns, not column groups");1672}1673}else {1674console.error("Column Update Error - The updateDefinition function is only available on ungrouped columns");1675return Promise.reject("Column Update Error - The updateDefinition function is only available on columns, not column groups");1676}1677}16781679deleteCell(cell){1680var index = this.cells.indexOf(cell);16811682if(index > -1){1683this.cells.splice(index, 1);1684}1685}16861687//////////////// Object Generation /////////////////1688getComponent(){1689if(!this.component){1690this.component = new ColumnComponent(this);1691}16921693return this.component;1694}1695}16961697Column.defaultOptionList = defaultColumnOptions;16981699class Helpers{17001701static elVisible(el){1702return !(el.offsetWidth <= 0 && el.offsetHeight <= 0);1703}17041705static elOffset(el){1706var box = el.getBoundingClientRect();17071708return {1709top: box.top + window.pageYOffset - document.documentElement.clientTop,1710left: box.left + window.pageXOffset - document.documentElement.clientLeft1711};1712}17131714static deepClone(obj, clone, list = []){1715var objectProto = {}.__proto__,1716arrayProto = [].__proto__;17171718if (!clone){1719clone = Object.assign(Array.isArray(obj) ? [] : {}, obj);1720}17211722for(var i in obj) {1723let subject = obj[i],1724match, copy;17251726if(subject != null && typeof subject === "object" && (subject.__proto__ === objectProto || subject.__proto__ === arrayProto)){1727match = list.findIndex((item) => {1728return item.subject === subject;1729});17301731if(match > -1){1732clone[i] = list[match].copy;1733}else {1734copy = Object.assign(Array.isArray(subject) ? [] : {}, subject);17351736list.unshift({subject, copy});17371738clone[i] = this.deepClone(subject, copy, list);1739}1740}1741}17421743return clone;1744}1745}17461747class OptionsList {1748constructor(table, msgType, defaults = {}){1749this.table = table;1750this.msgType = msgType;1751this.registeredDefaults = Object.assign({}, defaults);1752}17531754register(option, value){1755this.registeredDefaults[option] = value;1756}17571758generate(defaultOptions, userOptions = {}){1759var output = Object.assign({}, this.registeredDefaults),1760warn = this.table.options.debugInvalidOptions || userOptions.debugInvalidOptions === true;17611762Object.assign(output, defaultOptions);17631764for (let key in userOptions){1765if(!output.hasOwnProperty(key)){1766if(warn){1767console.warn("Invalid " + this.msgType + " option:", key);1768}17691770output[key] = userOptions.key;1771}1772}177317741775for (let key in output){1776if(key in userOptions){1777output[key] = userOptions[key];1778}else {1779if(Array.isArray(output[key])){1780output[key] = Object.assign([], output[key]);1781}else if(typeof output[key] === "object" && output[key] !== null){1782output[key] = Object.assign({}, output[key]);1783}else if (typeof output[key] === "undefined"){1784delete output[key];1785}1786}1787}17881789return output;1790}1791}17921793class Renderer extends CoreFeature{1794constructor(table){1795super(table);17961797this.elementVertical = table.rowManager.element;1798this.elementHorizontal = table.columnManager.element;1799this.tableElement = table.rowManager.tableElement;18001801this.verticalFillMode = "fit"; // used by row manager to determine how to size the render area ("fit" - fits container to the contents, "fill" - fills the container without resizing it)1802}180318041805///////////////////////////////////1806/////// Internal Bindings /////////1807///////////////////////////////////18081809initialize(){1810//initialize core functionality1811}18121813clearRows(){1814//clear down existing rows layout1815}18161817clearColumns(){1818//clear down existing columns layout1819}182018211822reinitializeColumnWidths(columns){1823//resize columns to fit data1824}182518261827renderRows(){1828//render rows from a clean slate1829}18301831renderColumns(){1832//render columns from a clean slate1833}18341835rerenderRows(callback){1836// rerender rows and keep position1837if(callback){1838callback();1839}1840}18411842rerenderColumns(update, blockRedraw){1843//rerender columns1844}18451846renderRowCells(row){1847//render the cells in a row1848}18491850rerenderRowCells(row, force){1851//rerender the cells in a row1852}18531854scrollColumns(left, dir){1855//handle horizontal scrolling1856}18571858scrollRows(top, dir){1859//handle vertical scrolling1860}18611862resize(){1863//container has resized, carry out any needed recalculations (DO NOT RERENDER IN THIS FUNCTION)1864}18651866scrollToRow(row){1867//scroll to a specific row1868}18691870scrollToRowNearestTop(row){1871//determine weather the row is nearest the top or bottom of the table, return true for top or false for bottom1872}18731874visibleRows(includingBuffer){1875//return the visible rows1876return [];1877}18781879///////////////////////////////////1880//////// Helper Functions /////////1881///////////////////////////////////18821883rows(){1884return this.table.rowManager.getDisplayRows();1885}18861887styleRow(row, index){1888var rowEl = row.getElement();18891890if(index % 2){1891rowEl.classList.add("tabulator-row-even");1892rowEl.classList.remove("tabulator-row-odd");1893}else {1894rowEl.classList.add("tabulator-row-odd");1895rowEl.classList.remove("tabulator-row-even");1896}1897}18981899///////////////////////////////////1900/////// External Triggers /////////1901/////// (DO NOT OVERRIDE) /////////1902///////////////////////////////////19031904clear(){1905//clear down existing layout1906this.clearRows();1907this.clearColumns();1908}19091910render(){1911//render from a clean slate1912this.renderRows();1913this.renderColumns();1914}19151916rerender(callback){1917// rerender and keep position1918this.rerenderRows();1919this.rerenderColumns();1920}19211922scrollToRowPosition(row, position, ifVisible){1923var rowIndex = this.rows().indexOf(row),1924rowEl = row.getElement(),1925offset = 0;19261927return new Promise((resolve, reject) => {1928if(rowIndex > -1){19291930if(typeof ifVisible === "undefined"){1931ifVisible = this.table.options.scrollToRowIfVisible;1932}19331934//check row visibility1935if(!ifVisible){1936if(Helpers.elVisible(rowEl)){1937offset = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top;19381939if(offset > 0 && offset < this.elementVertical.clientHeight - rowEl.offsetHeight){1940resolve();1941return false;1942}1943}1944}19451946if(typeof position === "undefined"){1947position = this.table.options.scrollToRowPosition;1948}19491950if(position === "nearest"){1951position = this.scrollToRowNearestTop(row) ? "top" : "bottom";1952}19531954//scroll to row1955this.scrollToRow(row);19561957//align to correct position1958switch(position){1959case "middle":1960case "center":19611962if(this.elementVertical.scrollHeight - this.elementVertical.scrollTop == this.elementVertical.clientHeight){1963this.elementVertical.scrollTop = this.elementVertical.scrollTop + (rowEl.offsetTop - this.elementVertical.scrollTop) - ((this.elementVertical.scrollHeight - rowEl.offsetTop) / 2);1964}else {1965this.elementVertical.scrollTop = this.elementVertical.scrollTop - (this.elementVertical.clientHeight / 2);1966}19671968break;19691970case "bottom":19711972if(this.elementVertical.scrollHeight - this.elementVertical.scrollTop == this.elementVertical.clientHeight){1973this.elementVertical.scrollTop = this.elementVertical.scrollTop - (this.elementVertical.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight;1974}else {1975this.elementVertical.scrollTop = this.elementVertical.scrollTop - this.elementVertical.clientHeight + rowEl.offsetHeight;1976}19771978break;19791980case "top":1981this.elementVertical.scrollTop = rowEl.offsetTop;1982break;1983}19841985resolve();19861987}else {1988console.warn("Scroll Error - Row not visible");1989reject("Scroll Error - Row not visible");1990}1991});1992}1993}19941995class BasicHorizontal extends Renderer{1996constructor(table){1997super(table);1998}19992000renderRowCells(row, inFragment) {2001const rowFrag = document.createDocumentFragment();2002row.cells.forEach((cell) => {2003rowFrag.appendChild(cell.getElement());2004});2005row.element.appendChild(rowFrag);20062007if(!inFragment){2008row.cells.forEach((cell) => {2009cell.cellRendered();2010});2011}2012}20132014reinitializeColumnWidths(columns){2015columns.forEach(function(column){2016column.reinitializeWidth();2017});2018}2019}20202021class VirtualDomHorizontal extends Renderer{2022constructor(table){2023super(table);20242025this.leftCol = 0;2026this.rightCol = 0;2027this.scrollLeft = 0;20282029this.vDomScrollPosLeft = 0;2030this.vDomScrollPosRight = 0;20312032this.vDomPadLeft = 0;2033this.vDomPadRight = 0;20342035this.fitDataColAvg = 0;20362037this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen20382039this.visibleRows = null;20402041this.initialized = false;2042this.isFitData = false;20432044this.columns = [];2045}20462047initialize(){2048this.compatibilityCheck();2049this.layoutCheck();2050this.vertScrollListen();2051}20522053compatibilityCheck(){2054if(this.options("layout") == "fitDataTable"){2055console.warn("Horizontal Virtual DOM is not compatible with fitDataTable layout mode");2056}20572058if(this.options("responsiveLayout")){2059console.warn("Horizontal Virtual DOM is not compatible with responsive columns");2060}20612062if(this.options("rtl")){2063console.warn("Horizontal Virtual DOM is not currently compatible with RTL text direction");2064}2065}20662067layoutCheck(){2068this.isFitData = this.options("layout").startsWith('fitData');2069}20702071vertScrollListen(){2072this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));2073this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));2074}20752076clearVisRowCache(){2077this.visibleRows = null;2078}20792080//////////////////////////////////////2081///////// Public Functions ///////////2082//////////////////////////////////////20832084renderColumns(row, force){2085this.dataChange();2086}208720882089scrollColumns(left, dir){2090if(this.scrollLeft != left){2091this.scrollLeft = left;20922093this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));2094}2095}20962097calcWindowBuffer(){2098var buffer = this.elementVertical.clientWidth;20992100this.table.columnManager.columnsByIndex.forEach((column) => {2101if(column.visible){2102var width = column.getWidth();21032104if(width > buffer){2105buffer = width;2106}2107}2108});21092110this.windowBuffer = buffer * 2;2111}21122113rerenderColumns(update, blockRedraw){2114var old = {2115cols:this.columns,2116leftCol:this.leftCol,2117rightCol:this.rightCol,2118},2119colPos = 0;21202121if(update && !this.initialized){2122return;2123}21242125this.clear();21262127this.calcWindowBuffer();21282129this.scrollLeft = this.elementVertical.scrollLeft;21302131this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;2132this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;21332134this.table.columnManager.columnsByIndex.forEach((column) => {2135var config = {},2136width;21372138if(column.visible){2139if(!column.modules.frozen){2140width = column.getWidth();21412142config.leftPos = colPos;2143config.rightPos = colPos + width;21442145config.width = width;21462147if (this.isFitData) {2148config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;2149}21502151if((colPos + width > this.vDomScrollPosLeft) && (colPos < this.vDomScrollPosRight)){2152//column is visible21532154if(this.leftCol == -1){2155this.leftCol = this.columns.length;2156this.vDomPadLeft = colPos;2157}21582159this.rightCol = this.columns.length;2160}else {2161// column is hidden2162if(this.leftCol !== -1){2163this.vDomPadRight += width;2164}2165}21662167this.columns.push(column);21682169column.modules.vdomHoz = config;21702171colPos += width;2172}2173}2174});21752176this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";2177this.tableElement.style.paddingRight = this.vDomPadRight + "px";21782179this.initialized = true;21802181if(!blockRedraw){2182if(!update || this.reinitChanged(old)){2183this.reinitializeRows();2184}2185}21862187this.elementVertical.scrollLeft = this.scrollLeft;2188}21892190renderRowCells(row){2191if(this.initialized){2192this.initializeRow(row);2193}else {2194const rowFrag = document.createDocumentFragment();2195row.cells.forEach((cell) => {2196rowFrag.appendChild(cell.getElement());2197});2198row.element.appendChild(rowFrag);21992200row.cells.forEach((cell) => {2201cell.cellRendered();2202});2203}2204}22052206rerenderRowCells(row, force){2207this.reinitializeRow(row, force);2208}22092210reinitializeColumnWidths(columns){2211for(let i = this.leftCol; i <= this.rightCol; i++){2212this.columns[i].reinitializeWidth();2213}2214}22152216//////////////////////////////////////2217//////// Internal Rendering //////////2218//////////////////////////////////////22192220deinitialize(){2221this.initialized = false;2222}22232224clear(){2225this.columns = [];22262227this.leftCol = -1;2228this.rightCol = 0;22292230this.vDomScrollPosLeft = 0;2231this.vDomScrollPosRight = 0;2232this.vDomPadLeft = 0;2233this.vDomPadRight = 0;2234}22352236dataChange(){2237var change = false,2238row, rowEl;22392240if(this.isFitData){2241this.table.columnManager.columnsByIndex.forEach((column) => {2242if(!column.definition.width && column.visible){2243change = true;2244}2245});22462247if(change && this.table.rowManager.getDisplayRows().length){2248this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;22492250row = this.chain("rows-sample", [1], [], () => {2251return this.table.rowManager.getDisplayRows();2252})[0];22532254if(row){2255rowEl = row.getElement();22562257row.generateCells();22582259this.tableElement.appendChild(rowEl);22602261for(let colEnd = 0; colEnd < row.cells.length; colEnd++){2262let cell = row.cells[colEnd];2263rowEl.appendChild(cell.getElement());22642265cell.column.reinitializeWidth();2266}22672268rowEl.parentNode.removeChild(rowEl);22692270this.rerenderColumns(false, true);2271}2272}2273}else {2274if(this.options("layout") === "fitColumns"){2275this.layoutRefresh();2276this.rerenderColumns(false, true);2277}2278}2279}22802281reinitChanged(old){2282var match = true;22832284if(old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol){2285return true;2286}22872288old.cols.forEach((col, i) => {2289if(col !== this.columns[i]){2290match = false;2291}2292});22932294return !match;2295}22962297reinitializeRows(){2298var visibleRows = this.getVisibleRows(),2299otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));23002301visibleRows.forEach((row) => {2302this.reinitializeRow(row, true);2303});23042305otherRows.forEach((row) =>{2306row.deinitialize();2307});2308}23092310getVisibleRows(){2311if (!this.visibleRows){2312this.visibleRows = this.table.rowManager.getVisibleRows();2313}23142315return this.visibleRows;2316}23172318scroll(diff){2319this.vDomScrollPosLeft += diff;2320this.vDomScrollPosRight += diff;23212322if(Math.abs(diff) > (this.windowBuffer / 2)){2323this.rerenderColumns();2324}else {2325if(diff > 0){2326//scroll right2327this.addColRight();2328this.removeColLeft();2329}else {2330//scroll left2331this.addColLeft();2332this.removeColRight();2333}2334}2335}23362337colPositionAdjust (start, end, diff){2338for(let i = start; i < end; i++){2339let column = this.columns[i];23402341column.modules.vdomHoz.leftPos += diff;2342column.modules.vdomHoz.rightPos += diff;2343}2344}23452346addColRight(){2347var changes = false,2348working = true;23492350while(working){23512352let column = this.columns[this.rightCol + 1];23532354if(column){2355if(column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){2356changes = true;23572358this.getVisibleRows().forEach((row) => {2359if(row.type !== "group"){2360var cell = row.getCell(column);2361row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.rightCol]).getElement().nextSibling);2362cell.cellRendered();2363}2364});23652366this.fitDataColActualWidthCheck(column);23672368this.rightCol++; // Don't move this below the >= check below23692370this.getVisibleRows().forEach((row) => {2371if(row.type !== "group"){2372row.modules.vdomHoz.rightCol = this.rightCol;2373}2374});23752376if(this.rightCol >= (this.columns.length - 1)){2377this.vDomPadRight = 0;2378}else {2379this.vDomPadRight -= column.getWidth();2380}2381}else {2382working = false;2383}2384}else {2385working = false;2386}2387}23882389if(changes){2390this.tableElement.style.paddingRight = this.vDomPadRight + "px";2391}2392}23932394addColLeft(){2395var changes = false,2396working = true;23972398while(working){2399let column = this.columns[this.leftCol - 1];24002401if(column){2402if(column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){2403changes = true;24042405this.getVisibleRows().forEach((row) => {2406if(row.type !== "group"){2407var cell = row.getCell(column);2408row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.leftCol]).getElement());2409cell.cellRendered();2410}2411});24122413this.leftCol--; // don't move this below the <= check below24142415this.getVisibleRows().forEach((row) => {2416if(row.type !== "group"){2417row.modules.vdomHoz.leftCol = this.leftCol;2418}2419});24202421if(this.leftCol <= 0){ // replicating logic in addColRight2422this.vDomPadLeft = 0;2423}else {2424this.vDomPadLeft -= column.getWidth();2425}24262427let diff = this.fitDataColActualWidthCheck(column);24282429if(diff){2430this.scrollLeft = this.elementVertical.scrollLeft = this.elementVertical.scrollLeft + diff;2431this.vDomPadRight -= diff;2432}24332434}else {2435working = false;2436}2437}else {2438working = false;2439}2440}24412442if(changes){2443this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";2444}2445}24462447removeColRight(){2448var changes = false,2449working = true;24502451while(working){2452let column = this.columns[this.rightCol];24532454if(column){2455if(column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){2456changes = true;24572458this.getVisibleRows().forEach((row) => {2459if(row.type !== "group"){2460var cell = row.getCell(column);24612462try {2463row.getElement().removeChild(cell.getElement());2464} catch (ex) {2465console.warn("Could not removeColRight", ex.message);2466}2467}2468});24692470this.vDomPadRight += column.getWidth();2471this.rightCol --;24722473this.getVisibleRows().forEach((row) => {2474if(row.type !== "group"){2475row.modules.vdomHoz.rightCol = this.rightCol;2476}2477});2478}else {2479working = false;2480}2481}else {2482working = false;2483}2484}24852486if(changes){2487this.tableElement.style.paddingRight = this.vDomPadRight + "px";2488}2489}24902491removeColLeft(){2492var changes = false,2493working = true;24942495while(working){2496let column = this.columns[this.leftCol];24972498if(column){2499if(column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){2500changes = true;25012502this.getVisibleRows().forEach((row) => {2503if(row.type !== "group"){2504var cell = row.getCell(column);25052506try {2507row.getElement().removeChild(cell.getElement());2508} catch (ex) {2509console.warn("Could not removeColLeft", ex.message);2510}2511}2512});25132514this.vDomPadLeft += column.getWidth();2515this.leftCol ++;25162517this.getVisibleRows().forEach((row) => {2518if(row.type !== "group"){2519row.modules.vdomHoz.leftCol = this.leftCol;2520}2521});2522}else {2523working = false;2524}2525}else {2526working = false;2527}2528}25292530if(changes){2531this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";2532}2533}25342535fitDataColActualWidthCheck(column){2536var newWidth, widthDiff;25372538if(column.modules.vdomHoz.fitDataCheck){2539column.reinitializeWidth();25402541newWidth = column.getWidth();2542widthDiff = newWidth - column.modules.vdomHoz.width;25432544if(widthDiff){2545column.modules.vdomHoz.rightPos += widthDiff;2546column.modules.vdomHoz.width = newWidth;2547this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);2548}25492550column.modules.vdomHoz.fitDataCheck = false;2551}25522553return widthDiff;2554}25552556initializeRow(row){2557if(row.type !== "group"){2558row.modules.vdomHoz = {2559leftCol:this.leftCol,2560rightCol:this.rightCol,2561};25622563if(this.table.modules.frozenColumns){2564this.table.modules.frozenColumns.leftColumns.forEach((column) => {2565this.appendCell(row, column);2566});2567}25682569for(let i = this.leftCol; i <= this.rightCol; i++){2570this.appendCell(row, this.columns[i]);2571}25722573if(this.table.modules.frozenColumns){2574this.table.modules.frozenColumns.rightColumns.forEach((column) => {2575this.appendCell(row, column);2576});2577}2578}2579}25802581appendCell(row, column){2582if(column && column.visible){2583let cell = row.getCell(column);25842585row.getElement().appendChild(cell.getElement());2586cell.cellRendered();2587}2588}25892590reinitializeRow(row, force){2591if(row.type !== "group"){2592if(force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol){25932594var rowEl = row.getElement();2595while(rowEl.firstChild) rowEl.removeChild(rowEl.firstChild);25962597this.initializeRow(row);2598}2599}2600}2601}26022603class ColumnManager extends CoreFeature {26042605constructor (table){2606super(table);26072608this.blockHozScrollEvent = false;2609this.headersElement = null;2610this.contentsElement = null;2611this.element = null ; //containing element2612this.columns = []; // column definition object2613this.columnsByIndex = []; //columns by index2614this.columnsByField = {}; //columns by field2615this.scrollLeft = 0;2616this.optionsList = new OptionsList(this.table, "column definition", defaultColumnOptions);26172618this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing2619this.redrawBlockUpdate = null; //store latest redraw update only status26202621this.renderer = null;2622}26232624////////////// Setup Functions /////////////////26252626initialize(){2627this.initializeRenderer();26282629this.headersElement = this.createHeadersElement();2630this.contentsElement = this.createHeaderContentsElement();2631this.element = this.createHeaderElement();26322633this.contentsElement.insertBefore(this.headersElement, this.contentsElement.firstChild);2634this.element.insertBefore(this.contentsElement, this.element.firstChild);26352636this.initializeScrollWheelWatcher();26372638this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this));2639this.subscribe("scrollbar-vertical", this.padVerticalScrollbar.bind(this));2640}26412642padVerticalScrollbar(width){2643if(this.table.rtl){2644this.headersElement.style.marginLeft = width + "px";2645}else {2646this.headersElement.style.marginRight = width + "px";2647}2648}26492650initializeRenderer(){2651var renderClass;26522653var renderers = {2654"virtual": VirtualDomHorizontal,2655"basic": BasicHorizontal,2656};26572658if(typeof this.table.options.renderHorizontal === "string"){2659renderClass = renderers[this.table.options.renderHorizontal];2660}else {2661renderClass = this.table.options.renderHorizontal;2662}26632664if(renderClass){2665this.renderer = new renderClass(this.table, this.element, this.tableElement);2666this.renderer.initialize();2667}else {2668console.error("Unable to find matching renderer:", this.table.options.renderHorizontal);2669}2670}267126722673createHeadersElement (){2674var el = document.createElement("div");26752676el.classList.add("tabulator-headers");2677el.setAttribute("role", "row");26782679return el;2680}26812682createHeaderContentsElement (){2683var el = document.createElement("div");26842685el.classList.add("tabulator-header-contents");2686el.setAttribute("role", "rowgroup");26872688return el;2689}26902691createHeaderElement (){2692var el = document.createElement("div");26932694el.classList.add("tabulator-header");2695el.setAttribute("role", "rowgroup");26962697if(!this.table.options.headerVisible){2698el.classList.add("tabulator-header-hidden");2699}27002701return el;2702}27032704//return containing element2705getElement(){2706return this.element;2707}27082709//return containing contents element2710getContentsElement(){2711return this.contentsElement;2712}271327142715//return header containing element2716getHeadersElement(){2717return this.headersElement;2718}27192720//scroll horizontally to match table body2721scrollHorizontal(left){2722this.contentsElement.scrollLeft = left;27232724this.scrollLeft = left;27252726this.renderer.scrollColumns(left);2727}27282729initializeScrollWheelWatcher(){2730this.contentsElement.addEventListener("wheel", (e) => {2731var left;27322733if(e.deltaX){2734left = this.contentsElement.scrollLeft + e.deltaX;27352736this.table.rowManager.scrollHorizontal(left);2737this.table.columnManager.scrollHorizontal(left);2738}2739});2740}27412742///////////// Column Setup Functions /////////////2743generateColumnsFromRowData(data){2744var cols = [],2745definitions = this.table.options.autoColumnsDefinitions,2746row, sorter;27472748if(data && data.length){27492750row = data[0];27512752for(var key in row){2753let col = {2754field:key,2755title:key,2756};27572758let value = row[key];27592760switch(typeof value){2761case "undefined":2762sorter = "string";2763break;27642765case "boolean":2766sorter = "boolean";2767break;27682769case "object":2770if(Array.isArray(value)){2771sorter = "array";2772}else {2773sorter = "string";2774}2775break;27762777default:2778if(!isNaN(value) && value !== ""){2779sorter = "number";2780}else {2781if(value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)){2782sorter = "alphanum";2783}else {2784sorter = "string";2785}2786}2787break;2788}27892790col.sorter = sorter;27912792cols.push(col);2793}27942795if(definitions){27962797switch(typeof definitions){2798case "function":2799this.table.options.columns = definitions.call(this.table, cols);2800break;28012802case "object":2803if(Array.isArray(definitions)){2804cols.forEach((col) => {2805var match = definitions.find((def) => {2806return def.field === col.field;2807});28082809if(match){2810Object.assign(col, match);2811}2812});28132814}else {2815cols.forEach((col) => {2816if(definitions[col.field]){2817Object.assign(col, definitions[col.field]);2818}2819});2820}28212822this.table.options.columns = cols;2823break;2824}2825}else {2826this.table.options.columns = cols;2827}28282829this.setColumns(this.table.options.columns);2830}2831}28322833setColumns(cols, row){2834while(this.headersElement.firstChild) this.headersElement.removeChild(this.headersElement.firstChild);28352836this.columns = [];2837this.columnsByIndex = [];2838this.columnsByField = {};28392840this.dispatch("columns-loading");28412842cols.forEach((def, i) => {2843this._addColumn(def);2844});28452846this._reIndexColumns();28472848this.dispatch("columns-loaded");28492850this.rerenderColumns(false, true);28512852this.redraw(true);2853}28542855_addColumn(definition, before, nextToColumn){2856var column = new Column(definition, this),2857colEl = column.getElement(),2858index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;28592860if(nextToColumn && index > -1){2861var topColumn = nextToColumn.getTopColumn();2862var parentIndex = this.columns.indexOf(topColumn);2863var nextEl = topColumn.getElement();28642865if(before){2866this.columns.splice(parentIndex, 0, column);2867nextEl.parentNode.insertBefore(colEl, nextEl);2868}else {2869this.columns.splice(parentIndex + 1, 0, column);2870nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);2871}2872}else {2873if(before){2874this.columns.unshift(column);2875this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild);2876}else {2877this.columns.push(column);2878this.headersElement.appendChild(column.getElement());2879}2880}28812882column.columnRendered();28832884return column;2885}28862887registerColumnField(col){2888if(col.definition.field){2889this.columnsByField[col.definition.field] = col;2890}2891}28922893registerColumnPosition(col){2894this.columnsByIndex.push(col);2895}28962897_reIndexColumns(){2898this.columnsByIndex = [];28992900this.columns.forEach(function(column){2901column.reRegisterPosition();2902});2903}29042905//ensure column headers take up the correct amount of space in column groups2906verticalAlignHeaders(){2907var minHeight = 0;29082909if(!this.redrawBlock){29102911this.headersElement.style.height="";29122913this.columns.forEach((column) => {2914column.clearVerticalAlign();2915});29162917this.columns.forEach((column) => {2918var height = column.getHeight();29192920if(height > minHeight){2921minHeight = height;2922}2923});29242925this.headersElement.style.height = minHeight + "px";29262927this.columns.forEach((column) => {2928column.verticalAlign(this.table.options.columnHeaderVertAlign, minHeight);2929});29302931this.table.rowManager.adjustTableSize();2932}2933}29342935//////////////// Column Details /////////////////2936findColumn(subject){2937var columns;29382939if(typeof subject == "object"){29402941if(subject instanceof Column){2942//subject is column element2943return subject;2944}else if(subject instanceof ColumnComponent){2945//subject is public column component2946return subject._getSelf() || false;2947}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){29482949columns = [];29502951this.columns.forEach((column) => {2952columns.push(column);2953columns = columns.concat(column.getColumns(true));2954});29552956//subject is a HTML element of the column header2957let match = columns.find((column) => {2958return column.element === subject;2959});29602961return match || false;2962}29632964}else {2965//subject should be treated as the field name of the column2966return this.columnsByField[subject] || false;2967}29682969//catch all for any other type of input2970return false;2971}29722973getColumnByField(field){2974return this.columnsByField[field];2975}29762977getColumnsByFieldRoot(root){2978var matches = [];29792980Object.keys(this.columnsByField).forEach((field) => {2981var fieldRoot = field.split(".")[0];2982if(fieldRoot === root){2983matches.push(this.columnsByField[field]);2984}2985});29862987return matches;2988}29892990getColumnByIndex(index){2991return this.columnsByIndex[index];2992}29932994getFirstVisibleColumn(){2995var index = this.columnsByIndex.findIndex((col) => {2996return col.visible;2997});29982999return index > -1 ? this.columnsByIndex[index] : false;3000}30013002getColumns(){3003return this.columns;3004}30053006findColumnIndex(column){3007return this.columnsByIndex.findIndex((col) => {3008return column === col;3009});3010}30113012//return all columns that are not groups3013getRealColumns(){3014return this.columnsByIndex;3015}30163017//traverse across columns and call action3018traverse(callback){3019this.columnsByIndex.forEach((column,i) =>{3020callback(column, i);3021});3022}30233024//get definitions of actual columns3025getDefinitions(active){3026var output = [];30273028this.columnsByIndex.forEach((column) => {3029if(!active || (active && column.visible)){3030output.push(column.getDefinition());3031}3032});30333034return output;3035}30363037//get full nested definition tree3038getDefinitionTree(){3039var output = [];30403041this.columns.forEach((column) => {3042output.push(column.getDefinition(true));3043});30443045return output;3046}30473048getComponents(structured){3049var output = [],3050columns = structured ? this.columns : this.columnsByIndex;30513052columns.forEach((column) => {3053output.push(column.getComponent());3054});30553056return output;3057}30583059getWidth(){3060var width = 0;30613062this.columnsByIndex.forEach((column) => {3063if(column.visible){3064width += column.getWidth();3065}3066});30673068return width;3069}30703071moveColumn(from, to, after){3072to.element.parentNode.insertBefore(from.element, to.element);30733074if(after){3075to.element.parentNode.insertBefore(to.element, from.element);3076}30773078this.moveColumnActual(from, to, after);30793080this.verticalAlignHeaders();30813082this.table.rowManager.reinitialize();3083}30843085moveColumnActual(from, to, after){3086if(from.parent.isGroup){3087this._moveColumnInArray(from.parent.columns, from, to, after);3088}else {3089this._moveColumnInArray(this.columns, from, to, after);3090}30913092this._moveColumnInArray(this.columnsByIndex, from, to, after, true);30933094this.rerenderColumns(true);30953096this.dispatch("column-moved", from, to, after);30973098if(this.subscribedExternal("columnMoved")){3099this.dispatchExternal("columnMoved", from.getComponent(), this.table.columnManager.getComponents());3100}3101}31023103_moveColumnInArray(columns, from, to, after, updateRows){3104var fromIndex = columns.indexOf(from),3105toIndex, rows = [];31063107if (fromIndex > -1) {31083109columns.splice(fromIndex, 1);31103111toIndex = columns.indexOf(to);31123113if (toIndex > -1) {31143115if(after){3116toIndex = toIndex+1;3117}31183119}else {3120toIndex = fromIndex;3121}31223123columns.splice(toIndex, 0, from);31243125if(updateRows){31263127rows = this.chain("column-moving-rows", [from, to, after], null, []) || [];31283129rows = rows.concat(this.table.rowManager.rows);31303131rows.forEach(function(row){3132if(row.cells.length){3133var cell = row.cells.splice(fromIndex, 1)[0];3134row.cells.splice(toIndex, 0, cell);3135}3136});31373138}3139}3140}31413142scrollToColumn(column, position, ifVisible){3143var left = 0,3144offset = column.getLeftOffset(),3145adjust = 0,3146colEl = column.getElement();314731483149return new Promise((resolve, reject) => {31503151if(typeof position === "undefined"){3152position = this.table.options.scrollToColumnPosition;3153}31543155if(typeof ifVisible === "undefined"){3156ifVisible = this.table.options.scrollToColumnIfVisible;3157}31583159if(column.visible){31603161//align to correct position3162switch(position){3163case "middle":3164case "center":3165adjust = -this.element.clientWidth / 2;3166break;31673168case "right":3169adjust = colEl.clientWidth - this.headersElement.clientWidth;3170break;3171}31723173//check column visibility3174if(!ifVisible){3175if(offset > 0 && offset + colEl.offsetWidth < this.element.clientWidth){3176return false;3177}3178}31793180//calculate scroll position3181left = offset + adjust;31823183left = Math.max(Math.min(left, this.table.rowManager.element.scrollWidth - this.table.rowManager.element.clientWidth),0);31843185this.table.rowManager.scrollHorizontal(left);3186this.scrollHorizontal(left);31873188resolve();3189}else {3190console.warn("Scroll Error - Column not visible");3191reject("Scroll Error - Column not visible");3192}31933194});3195}31963197//////////////// Cell Management /////////////////3198generateCells(row){3199var cells = [];32003201this.columnsByIndex.forEach((column) => {3202cells.push(column.generateCell(row));3203});32043205return cells;3206}32073208//////////////// Column Management /////////////////3209getFlexBaseWidth(){3210var totalWidth = this.table.element.clientWidth, //table element width3211fixedWidth = 0;32123213//adjust for vertical scrollbar if present3214if(this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight){3215totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;3216}32173218this.columnsByIndex.forEach(function(column){3219var width, minWidth, colWidth;32203221if(column.visible){32223223width = column.definition.width || 0;32243225minWidth = parseInt(column.minWidth);32263227if(typeof(width) == "string"){3228if(width.indexOf("%") > -1){3229colWidth = (totalWidth / 100) * parseInt(width) ;3230}else {3231colWidth = parseInt(width);3232}3233}else {3234colWidth = width;3235}32363237fixedWidth += colWidth > minWidth ? colWidth : minWidth;32383239}3240});32413242return fixedWidth;3243}32443245addColumn(definition, before, nextToColumn){3246return new Promise((resolve, reject) => {3247var column = this._addColumn(definition, before, nextToColumn);32483249this._reIndexColumns();32503251this.dispatch("column-add", definition, before, nextToColumn);32523253if(this.layoutMode() != "fitColumns"){3254column.reinitializeWidth();3255}32563257this.redraw(true);32583259this.table.rowManager.reinitialize();32603261this.rerenderColumns();32623263resolve(column);3264});3265}32663267//remove column from system3268deregisterColumn(column){3269var field = column.getField(),3270index;32713272//remove from field list3273if(field){3274delete this.columnsByField[field];3275}32763277//remove from index list3278index = this.columnsByIndex.indexOf(column);32793280if(index > -1){3281this.columnsByIndex.splice(index, 1);3282}32833284//remove from column list3285index = this.columns.indexOf(column);32863287if(index > -1){3288this.columns.splice(index, 1);3289}32903291this.verticalAlignHeaders();32923293this.redraw();3294}32953296rerenderColumns(update, silent){3297if(!this.redrawBlock){3298this.renderer.rerenderColumns(update, silent);3299}else {3300if(update === false || (update === true && this.redrawBlockUpdate === null)){3301this.redrawBlockUpdate = update;3302}3303}3304}33053306blockRedraw(){3307this.redrawBlock = true;3308this.redrawBlockUpdate = null;3309}33103311restoreRedraw(){3312this.redrawBlock = false;3313this.verticalAlignHeaders();3314this.renderer.rerenderColumns(this.redrawBlockUpdate);33153316}33173318//redraw columns3319redraw(force){3320if(Helpers.elVisible(this.element)){3321this.verticalAlignHeaders();3322}33233324if(force){3325this.table.rowManager.resetScroll();3326this.table.rowManager.reinitialize();3327}33283329if(!this.confirm("table-redrawing", force)){3330this.layoutRefresh(force);3331}33323333this.dispatch("table-redraw", force);33343335this.table.footerManager.redraw();3336}3337}33383339//public row object3340class RowComponent {33413342constructor (row){3343this._row = row;33443345return new Proxy(this, {3346get: function(target, name, receiver) {3347if (typeof target[name] !== "undefined") {3348return target[name];3349}else {3350return target._row.table.componentFunctionBinder.handle("row", target._row, name);3351}3352}3353});3354}33553356getData(transform){3357return this._row.getData(transform);3358}33593360getElement(){3361return this._row.getElement();3362}33633364getCells(){3365var cells = [];33663367this._row.getCells().forEach(function(cell){3368cells.push(cell.getComponent());3369});33703371return cells;3372}33733374getCell(column){3375var cell = this._row.getCell(column);3376return cell ? cell.getComponent() : false;3377}33783379getIndex(){3380return this._row.getData("data")[this._row.table.options.index];3381}33823383getPosition(){3384return this._row.getPosition();3385}33863387watchPosition(callback){3388return this._row.watchPosition(callback);3389}33903391delete(){3392return this._row.delete();3393}33943395scrollTo(position, ifVisible){3396return this._row.table.rowManager.scrollToRow(this._row, position, ifVisible);3397}33983399move(to, after){3400this._row.moveToRow(to, after);3401}34023403update(data){3404return this._row.updateData(data);3405}34063407normalizeHeight(){3408this._row.normalizeHeight(true);3409}34103411_getSelf(){3412return this._row;3413}34143415reformat(){3416return this._row.reinitialize();3417}34183419getTable(){3420return this._row.table;3421}34223423getNextRow(){3424var row = this._row.nextRow();3425return row ? row.getComponent() : row;3426}34273428getPrevRow(){3429var row = this._row.prevRow();3430return row ? row.getComponent() : row;3431}3432}34333434class Row extends CoreFeature{3435constructor (data, parent, type = "row"){3436super(parent.table);34373438this.parent = parent;3439this.data = {};3440this.type = type; //type of element3441this.element = false;3442this.modules = {}; //hold module variables;3443this.cells = [];3444this.height = 0; //hold element height3445this.heightStyled = ""; //hold element height pre-styled to improve render efficiency3446this.manualHeight = false; //user has manually set row height3447this.outerHeight = 0; //hold elements outer height3448this.initialized = false; //element has been rendered3449this.heightInitialized = false; //element has resized cells to fit3450this.position = 0; //store position of element in row list3451this.positionWatchers = [];34523453this.component = null;34543455this.created = false;34563457this.setData(data);3458}34593460create(){3461if(!this.created){3462this.created = true;3463this.generateElement();3464}3465}34663467createElement (){3468var el = document.createElement("div");34693470el.classList.add("tabulator-row");3471el.setAttribute("role", "row");34723473this.element = el;3474}34753476getElement(){3477this.create();3478return this.element;3479}34803481detachElement(){3482if (this.element && this.element.parentNode){3483this.element.parentNode.removeChild(this.element);3484}3485}34863487generateElement(){3488this.createElement();3489this.dispatch("row-init", this);3490}34913492generateCells(){3493this.cells = this.table.columnManager.generateCells(this);3494}34953496//functions to setup on first render3497initialize(force, inFragment){3498this.create();34993500if(!this.initialized || force){35013502this.deleteCells();35033504while(this.element.firstChild) this.element.removeChild(this.element.firstChild);35053506this.dispatch("row-layout-before", this);35073508this.generateCells();35093510this.initialized = true;35113512this.table.columnManager.renderer.renderRowCells(this, inFragment);35133514if(force){3515this.normalizeHeight();3516}35173518this.dispatch("row-layout", this);35193520if(this.table.options.rowFormatter){3521this.table.options.rowFormatter(this.getComponent());3522}35233524this.dispatch("row-layout-after", this);3525}else {3526this.table.columnManager.renderer.rerenderRowCells(this, inFragment);3527}3528}35293530rendered(){3531this.cells.forEach((cell) => {3532cell.cellRendered();3533});3534}35353536reinitializeHeight(){3537this.heightInitialized = false;35383539if(this.element && this.element.offsetParent !== null){3540this.normalizeHeight(true);3541}3542}35433544deinitialize(){3545this.initialized = false;3546}35473548deinitializeHeight(){3549this.heightInitialized = false;3550}35513552reinitialize(children){3553this.initialized = false;3554this.heightInitialized = false;35553556if(!this.manualHeight){3557this.height = 0;3558this.heightStyled = "";3559}35603561if(this.element && this.element.offsetParent !== null){3562this.initialize(true);3563}35643565this.dispatch("row-relayout", this);3566}35673568//get heights when doing bulk row style calcs in virtual DOM3569calcHeight(force){3570var maxHeight = 0,3571minHeight;35723573if(this.table.options.rowHeight){3574this.height = this.table.options.rowHeight;3575}else {3576minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;35773578this.cells.forEach(function(cell){3579var height = cell.getHeight();3580if(height > maxHeight){3581maxHeight = height;3582}3583});35843585if(force){3586this.height = Math.max(maxHeight, minHeight);3587}else {3588this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);3589}3590}35913592this.heightStyled = this.height ? this.height + "px" : "";3593this.outerHeight = this.element.offsetHeight;3594}35953596//set of cells3597setCellHeight(){3598this.cells.forEach(function(cell){3599cell.setHeight();3600});36013602this.heightInitialized = true;3603}36043605clearCellHeight(){3606this.cells.forEach(function(cell){3607cell.clearHeight();3608});3609}36103611//normalize the height of elements in the row3612normalizeHeight(force){3613if(force && !this.table.options.rowHeight){3614this.clearCellHeight();3615}36163617this.calcHeight(force);36183619this.setCellHeight();3620}36213622//set height of rows3623setHeight(height, force){3624if(this.height != height || force){36253626this.manualHeight = true;36273628this.height = height;3629this.heightStyled = height ? height + "px" : "";36303631this.setCellHeight();36323633// this.outerHeight = this.element.outerHeight();3634this.outerHeight = this.element.offsetHeight;3635}3636}36373638//return rows outer height3639getHeight(){3640return this.outerHeight;3641}36423643//return rows outer Width3644getWidth(){3645return this.element.offsetWidth;3646}36473648//////////////// Cell Management /////////////////3649deleteCell(cell){3650var index = this.cells.indexOf(cell);36513652if(index > -1){3653this.cells.splice(index, 1);3654}3655}36563657//////////////// Data Management /////////////////3658setData(data){3659this.data = this.chain("row-data-init-before", [this, data], undefined, data);36603661this.dispatch("row-data-init-after", this);3662}36633664//update the rows data3665updateData(updatedData){3666var visible = this.element && Helpers.elVisible(this.element),3667tempData = {},3668newRowData;36693670return new Promise((resolve, reject) => {36713672if(typeof updatedData === "string"){3673updatedData = JSON.parse(updatedData);3674}36753676this.dispatch("row-data-save-before", this);36773678if(this.subscribed("row-data-changing")){3679tempData = Object.assign(tempData, this.data);3680tempData = Object.assign(tempData, updatedData);3681}36823683newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);36843685//set data3686for (let attrname in newRowData) {3687this.data[attrname] = newRowData[attrname];3688}36893690this.dispatch("row-data-save-after", this);36913692//update affected cells only3693for (let attrname in updatedData) {36943695let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);36963697columns.forEach((column) => {3698let cell = this.getCell(column.getField());36993700if(cell){3701let value = column.getFieldValue(newRowData);3702if(cell.getValue() !== value){3703cell.setValueProcessData(value);37043705if(visible){3706cell.cellRendered();3707}3708}3709}3710});3711}37123713//Partial reinitialization if visible3714if(visible){3715this.normalizeHeight(true);37163717if(this.table.options.rowFormatter){3718this.table.options.rowFormatter(this.getComponent());3719}3720}else {3721this.initialized = false;3722this.height = 0;3723this.heightStyled = "";3724}37253726this.dispatch("row-data-changed", this, visible, updatedData);37273728//this.reinitialize();37293730this.dispatchExternal("rowUpdated", this.getComponent());37313732if(this.subscribedExternal("dataChanged")){3733this.dispatchExternal("dataChanged", this.table.rowManager.getData());3734}37353736resolve();3737});3738}37393740getData(transform){3741if(transform){3742return this.chain("row-data-retrieve", [this, transform], null, this.data);3743}37443745return this.data;3746}37473748getCell(column){3749var match = false;37503751column = this.table.columnManager.findColumn(column);37523753if(!this.initialized && this.cells.length === 0){3754this.generateCells();3755}37563757match = this.cells.find(function(cell){3758return cell.column === column;3759});37603761return match;3762}37633764getCellIndex(findCell){3765return this.cells.findIndex(function(cell){3766return cell === findCell;3767});3768}37693770findCell(subject){3771return this.cells.find((cell) => {3772return cell.element === subject;3773});3774}37753776getCells(){3777if(!this.initialized && this.cells.length === 0){3778this.generateCells();3779}37803781return this.cells;3782}37833784nextRow(){3785var row = this.table.rowManager.nextDisplayRow(this, true);3786return row || false;3787}37883789prevRow(){3790var row = this.table.rowManager.prevDisplayRow(this, true);3791return row || false;3792}37933794moveToRow(to, before){3795var toRow = this.table.rowManager.findRow(to);37963797if(toRow){3798this.table.rowManager.moveRowActual(this, toRow, !before);3799this.table.rowManager.refreshActiveData("display", false, true);3800}else {3801console.warn("Move Error - No matching row found:", to);3802}3803}38043805///////////////////// Actions /////////////////////3806delete(){3807this.dispatch("row-delete", this);38083809this.deleteActual();38103811return Promise.resolve();3812}38133814deleteActual(blockRedraw){3815this.detachModules();38163817this.table.rowManager.deleteRow(this, blockRedraw);38183819this.deleteCells();38203821this.initialized = false;3822this.heightInitialized = false;3823this.element = false;38243825this.dispatch("row-deleted", this);3826}38273828detachModules(){3829this.dispatch("row-deleting", this);3830}38313832deleteCells(){3833var cellCount = this.cells.length;38343835for(let i = 0; i < cellCount; i++){3836this.cells[0].delete();3837}3838}38393840wipe(){3841this.detachModules();3842this.deleteCells();38433844if(this.element){3845while(this.element.firstChild) this.element.removeChild(this.element.firstChild);38463847if(this.element.parentNode){3848this.element.parentNode.removeChild(this.element);3849}3850}38513852this.element = false;3853this.modules = {};3854}38553856isDisplayed(){3857return this.table.rowManager.getDisplayRows().includes(this);3858}38593860getPosition(){3861return this.isDisplayed() ? this.position : false;3862}38633864setPosition(position){3865if(position != this.position){3866this.position = position;38673868this.positionWatchers.forEach((callback) => {3869callback(this.position);3870});3871}3872}38733874watchPosition(callback){3875this.positionWatchers.push(callback);38763877callback(this.position);3878}38793880getGroup(){3881return this.modules.group || false;3882}38833884//////////////// Object Generation /////////////////3885getComponent(){3886if(!this.component){3887this.component = new RowComponent(this);3888}38893890return this.component;3891}3892}38933894class BasicVertical extends Renderer{3895constructor(table){3896super(table);38973898this.verticalFillMode = "fill";38993900this.scrollTop = 0;3901this.scrollLeft = 0;39023903this.scrollTop = 0;3904this.scrollLeft = 0;3905}39063907clearRows(){3908var element = this.tableElement;39093910// element.children.detach();3911while(element.firstChild) element.removeChild(element.firstChild);39123913element.scrollTop = 0;3914element.scrollLeft = 0;39153916element.style.minWidth = "";3917element.style.minHeight = "";3918element.style.display = "";3919element.style.visibility = "";3920}39213922renderRows() {3923var element = this.tableElement,3924onlyGroupHeaders = true,3925tableFrag = document.createDocumentFragment(),3926rows = this.rows();39273928rows.forEach((row, index) => {3929this.styleRow(row, index);3930row.initialize(false, true);39313932if (row.type !== "group") {3933onlyGroupHeaders = false;3934}39353936tableFrag.appendChild(row.getElement());3937});39383939element.appendChild(tableFrag);39403941rows.forEach((row) => {3942row.rendered();39433944if(!row.heightInitialized) {3945row.calcHeight(true);3946}3947});39483949rows.forEach((row) => {3950if(!row.heightInitialized) {3951row.setCellHeight();3952}3953});3954395539563957if(onlyGroupHeaders){3958element.style.minWidth = this.table.columnManager.getWidth() + "px";3959}else {3960element.style.minWidth = "";3961}3962}396339643965rerenderRows(callback){3966this.clearRows();39673968if(callback){3969callback();3970}39713972this.renderRows();3973}39743975scrollToRowNearestTop(row){3976var rowTop = Helpers.elOffset(row.getElement()).top;39773978return !(Math.abs(this.elementVertical.scrollTop - rowTop) > Math.abs(this.elementVertical.scrollTop + this.elementVertical.clientHeight - rowTop));3979}39803981scrollToRow(row){3982var rowEl = row.getElement();39833984this.elementVertical.scrollTop = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top + this.elementVertical.scrollTop;3985}39863987visibleRows(includingBuffer){3988return this.rows();3989}39903991}39923993class VirtualDomVertical extends Renderer{3994constructor(table){3995super(table);39963997this.verticalFillMode = "fill";39983999this.scrollTop = 0;4000this.scrollLeft = 0;40014002this.vDomRowHeight = 20; //approximation of row heights for padding40034004this.vDomTop = 0; //hold position for first rendered row in the virtual DOM4005this.vDomBottom = 0; //hold position for last rendered row in the virtual DOM40064007this.vDomScrollPosTop = 0; //last scroll position of the vDom top;4008this.vDomScrollPosBottom = 0; //last scroll position of the vDom bottom;40094010this.vDomTopPad = 0; //hold value of padding for top of virtual DOM4011this.vDomBottomPad = 0; //hold value of padding for bottom of virtual DOM40124013this.vDomMaxRenderChain = 90; //the maximum number of dom elements that can be rendered in 1 go40144015this.vDomWindowBuffer = 0; //window row buffer before removing elements, to smooth scrolling40164017this.vDomWindowMinTotalRows = 20; //minimum number of rows to be generated in virtual dom (prevent buffering issues on tables with tall rows)4018this.vDomWindowMinMarginRows = 5; //minimum number of rows to be generated in virtual dom margin40194020this.vDomTopNewRows = []; //rows to normalize after appending to optimize render speed4021this.vDomBottomNewRows = []; //rows to normalize after appending to optimize render speed4022}40234024//////////////////////////////////////4025///////// Public Functions ///////////4026//////////////////////////////////////40274028clearRows(){4029var element = this.tableElement;40304031// element.children.detach();4032while(element.firstChild) element.removeChild(element.firstChild);40334034element.style.paddingTop = "";4035element.style.paddingBottom = "";4036element.style.minHeight = "";4037element.style.display = "";4038element.style.visibility = "";40394040this.elementVertical.scrollTop = 0;4041this.elementVertical.scrollLeft = 0;40424043this.scrollTop = 0;4044this.scrollLeft = 0;40454046this.vDomTop = 0;4047this.vDomBottom = 0;4048this.vDomTopPad = 0;4049this.vDomBottomPad = 0;4050this.vDomScrollPosTop = 0;4051this.vDomScrollPosBottom = 0;4052}40534054renderRows(){4055this._virtualRenderFill();4056}40574058rerenderRows(callback){4059var scrollTop = this.elementVertical.scrollTop;4060var topRow = false;4061var topOffset = false;40624063var left = this.table.rowManager.scrollLeft;40644065var rows = this.rows();40664067for(var i = this.vDomTop; i <= this.vDomBottom; i++){40684069if(rows[i]){4070var diff = scrollTop - rows[i].getElement().offsetTop;40714072if(topOffset === false || Math.abs(diff) < topOffset){4073topOffset = diff;4074topRow = i;4075}else {4076break;4077}4078}4079}40804081rows.forEach((row) => {4082row.deinitializeHeight();4083});40844085if(callback){4086callback();4087}40884089if(this.rows().length){4090this._virtualRenderFill((topRow === false ? this.rows.length - 1 : topRow), true, topOffset || 0);4091}else {4092this.clear();4093this.table.rowManager.tableEmpty();4094}40954096this.scrollColumns(left);4097}40984099scrollColumns(left){4100this.table.rowManager.scrollHorizontal(left);4101}41024103scrollRows(top, dir){4104var topDiff = top - this.vDomScrollPosTop;4105var bottomDiff = top - this.vDomScrollPosBottom;4106var margin = this.vDomWindowBuffer * 2;4107var rows = this.rows();41084109this.scrollTop = top;41104111if(-topDiff > margin || bottomDiff > margin){4112//if big scroll redraw table;4113var left = this.table.rowManager.scrollLeft;4114this._virtualRenderFill(Math.floor((this.elementVertical.scrollTop / this.elementVertical.scrollHeight) * rows.length));4115this.scrollColumns(left);4116}else {41174118if(dir){4119//scrolling up4120if(topDiff < 0){4121this._addTopRow(rows, -topDiff);4122}41234124if(bottomDiff < 0){4125//hide bottom row if needed4126if(this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer){4127this._removeBottomRow(rows, -bottomDiff);4128}else {4129this.vDomScrollPosBottom = this.scrollTop;4130}4131}4132}else {41334134if(bottomDiff >= 0){4135this._addBottomRow(rows, bottomDiff);4136}41374138//scrolling down4139if(topDiff >= 0){4140//hide top row if needed4141if(this.scrollTop > this.vDomWindowBuffer){4142this._removeTopRow(rows, topDiff);4143}else {4144this.vDomScrollPosTop = this.scrollTop;4145}4146}4147}4148}4149}41504151resize(){4152this.vDomWindowBuffer = this.table.options.renderVerticalBuffer || this.elementVertical.clientHeight;4153}41544155scrollToRowNearestTop(row){4156var rowIndex = this.rows().indexOf(row);41574158return !(Math.abs(this.vDomTop - rowIndex) > Math.abs(this.vDomBottom - rowIndex));4159}41604161scrollToRow(row){4162var index = this.rows().indexOf(row);41634164if(index > -1){4165this._virtualRenderFill(index, true);4166}4167}41684169visibleRows(includingBuffer){4170var topEdge = this.elementVertical.scrollTop,4171bottomEdge = this.elementVertical.clientHeight + topEdge,4172topFound = false,4173topRow = 0,4174bottomRow = 0,4175rows = this.rows();41764177if(includingBuffer){4178topRow = this.vDomTop;4179bottomRow = this.vDomBottom;4180}else {4181for(var i = this.vDomTop; i <= this.vDomBottom; i++){4182if(rows[i]){4183if(!topFound){4184if((topEdge - rows[i].getElement().offsetTop) >= 0){4185topRow = i;4186}else {4187topFound = true;41884189if(bottomEdge - rows[i].getElement().offsetTop >= 0){4190bottomRow = i;4191}else {4192break;4193}4194}4195}else {4196if(bottomEdge - rows[i].getElement().offsetTop >= 0){4197bottomRow = i;4198}else {4199break;4200}4201}4202}4203}4204}42054206return rows.slice(topRow, bottomRow + 1);4207}42084209//////////////////////////////////////4210//////// Internal Rendering //////////4211//////////////////////////////////////42124213//full virtual render4214_virtualRenderFill(position, forceMove, offset) {4215var element = this.tableElement,4216holder = this.elementVertical,4217topPad = 0,4218rowsHeight = 0,4219rowHeight = 0,4220heightOccupied = 0,4221topPadHeight = 0,4222i = 0,4223rows = this.rows(),4224rowsCount = rows.length,4225index = 0,4226row,4227rowFragment,4228renderedRows = [],4229totalRowsRendered = 0,4230rowsToRender = 0,4231fixedHeight = this.table.rowManager.fixedHeight,4232containerHeight = this.elementVertical.clientHeight,4233avgRowHeight = this.table.options.rowHeight,4234resized = true;42354236position = position || 0;42374238offset = offset || 0;42394240if(!position){4241this.clear();4242}else {4243while(element.firstChild) element.removeChild(element.firstChild);42444245//check if position is too close to bottom of table4246heightOccupied = (rowsCount - position + 1) * this.vDomRowHeight;42474248if(heightOccupied < containerHeight){4249position -= Math.ceil((containerHeight - heightOccupied) / this.vDomRowHeight);4250if(position < 0){4251position = 0;4252}4253}42544255//calculate initial pad4256topPad = Math.min(Math.max(Math.floor(this.vDomWindowBuffer / this.vDomRowHeight), this.vDomWindowMinMarginRows), position);4257position -= topPad;4258}42594260if(rowsCount && Helpers.elVisible(this.elementVertical)){4261this.vDomTop = position;4262this.vDomBottom = position -1;42634264if(fixedHeight || this.table.options.maxHeight) {4265if(avgRowHeight) {4266rowsToRender = (containerHeight / avgRowHeight) + (this.vDomWindowBuffer / avgRowHeight);4267}4268rowsToRender = Math.max(this.vDomWindowMinTotalRows, Math.ceil(rowsToRender));4269}4270else {4271rowsToRender = rowsCount;4272}42734274while(((rowsToRender == rowsCount || rowsHeight <= containerHeight + this.vDomWindowBuffer) || totalRowsRendered < this.vDomWindowMinTotalRows) && this.vDomBottom < rowsCount -1) {4275renderedRows = [];4276rowFragment = document.createDocumentFragment();42774278i = 0;42794280while ((i < rowsToRender) && this.vDomBottom < rowsCount -1) {4281index = this.vDomBottom + 1,4282row = rows[index];42834284this.styleRow(row, index);42854286row.initialize(false, true);4287if(!row.heightInitialized && !this.table.options.rowHeight){4288row.clearCellHeight();4289}42904291rowFragment.appendChild(row.getElement());4292renderedRows.push(row);4293this.vDomBottom ++;4294i++;4295}42964297if(!renderedRows.length){4298break;4299}43004301element.appendChild(rowFragment);43024303// NOTE: The next 3 loops are separate on purpose4304// This is to batch up the dom writes and reads which drastically improves performance43054306renderedRows.forEach((row) => {4307row.rendered();43084309if(!row.heightInitialized) {4310row.calcHeight(true);4311}4312});43134314renderedRows.forEach((row) => {4315if(!row.heightInitialized) {4316row.setCellHeight();4317}4318});43194320renderedRows.forEach((row) => {4321rowHeight = row.getHeight();43224323if(totalRowsRendered < topPad){4324topPadHeight += rowHeight;4325}else {4326rowsHeight += rowHeight;4327}43284329if(rowHeight > this.vDomWindowBuffer){4330this.vDomWindowBuffer = rowHeight * 2;4331}4332totalRowsRendered++;4333});43344335resized = this.table.rowManager.adjustTableSize();4336containerHeight = this.elementVertical.clientHeight;4337if(resized && (fixedHeight || this.table.options.maxHeight))4338{4339avgRowHeight = rowsHeight / totalRowsRendered;4340rowsToRender = Math.max(this.vDomWindowMinTotalRows, Math.ceil((containerHeight / avgRowHeight) + (this.vDomWindowBuffer / avgRowHeight)));4341}4342}43434344if(!position){4345this.vDomTopPad = 0;4346//adjust row height to match average of rendered elements4347this.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / totalRowsRendered);4348this.vDomBottomPad = this.vDomRowHeight * (rowsCount - this.vDomBottom -1);43494350this.vDomScrollHeight = topPadHeight + rowsHeight + this.vDomBottomPad - containerHeight;4351}else {4352this.vDomTopPad = !forceMove ? this.scrollTop - topPadHeight : (this.vDomRowHeight * this.vDomTop) + offset;4353this.vDomBottomPad = this.vDomBottom == rowsCount-1 ? 0 : Math.max(this.vDomScrollHeight - this.vDomTopPad - rowsHeight - topPadHeight, 0);4354}43554356element.style.paddingTop = this.vDomTopPad+"px";4357element.style.paddingBottom = this.vDomBottomPad+"px";43584359if(forceMove){4360this.scrollTop = this.vDomTopPad + (topPadHeight) + offset - (this.elementVertical.scrollWidth > this.elementVertical.clientWidth ? this.elementVertical.offsetHeight - containerHeight : 0);4361}43624363this.scrollTop = Math.min(this.scrollTop, this.elementVertical.scrollHeight - containerHeight);43644365//adjust for horizontal scrollbar if present (and not at top of table)4366if(this.elementVertical.scrollWidth > this.elementVertical.clientWidth && forceMove){4367this.scrollTop += this.elementVertical.offsetHeight - containerHeight;4368}43694370this.vDomScrollPosTop = this.scrollTop;4371this.vDomScrollPosBottom = this.scrollTop;43724373holder.scrollTop = this.scrollTop;43744375this.dispatch("render-virtual-fill");4376}4377}43784379_addTopRow(rows, fillableSpace){4380var table = this.tableElement,4381addedRows = [],4382paddingAdjust = 0,4383index = this.vDomTop -1,4384i = 0,4385working = true;43864387while(working){4388if(this.vDomTop){4389let row = rows[index],4390rowHeight, initialized;43914392if(row && i < this.vDomMaxRenderChain){4393rowHeight = row.getHeight() || this.vDomRowHeight;4394initialized = row.initialized;43954396if(fillableSpace >= rowHeight){43974398this.styleRow(row, index);4399table.insertBefore(row.getElement(), table.firstChild);44004401if(!row.initialized || !row.heightInitialized){4402addedRows.push(row);4403}44044405row.initialize();44064407if(!initialized){4408rowHeight = row.getElement().offsetHeight;44094410if(rowHeight > this.vDomWindowBuffer){4411this.vDomWindowBuffer = rowHeight * 2;4412}4413}44144415fillableSpace -= rowHeight;4416paddingAdjust += rowHeight;44174418this.vDomTop--;4419index--;4420i++;44214422}else {4423working = false;4424}44254426}else {4427working = false;4428}44294430}else {4431working = false;4432}4433}44344435for (let row of addedRows){4436row.clearCellHeight();4437}44384439this._quickNormalizeRowHeight(addedRows);44404441if(paddingAdjust){4442this.vDomTopPad -= paddingAdjust;44434444if(this.vDomTopPad < 0){4445this.vDomTopPad = index * this.vDomRowHeight;4446}44474448if(index < 1){4449this.vDomTopPad = 0;4450}44514452table.style.paddingTop = this.vDomTopPad + "px";4453this.vDomScrollPosTop -= paddingAdjust;4454}4455}44564457_removeTopRow(rows, fillableSpace){4458var removableRows = [],4459paddingAdjust = 0,4460i = 0,4461working = true;44624463while(working){4464let row = rows[this.vDomTop],4465rowHeight;44664467if(row && i < this.vDomMaxRenderChain){4468rowHeight = row.getHeight() || this.vDomRowHeight;44694470if(fillableSpace >= rowHeight){4471this.vDomTop++;44724473fillableSpace -= rowHeight;4474paddingAdjust += rowHeight;44754476removableRows.push(row);4477i++;4478}else {4479working = false;4480}4481}else {4482working = false;4483}4484}44854486for (let row of removableRows){4487let rowEl = row.getElement();44884489if(rowEl.parentNode){4490rowEl.parentNode.removeChild(rowEl);4491}4492}44934494if(paddingAdjust){4495this.vDomTopPad += paddingAdjust;4496this.tableElement.style.paddingTop = this.vDomTopPad + "px";4497this.vDomScrollPosTop += this.vDomTop ? paddingAdjust : paddingAdjust + this.vDomWindowBuffer;4498}4499}45004501_addBottomRow(rows, fillableSpace){4502var table = this.tableElement,4503addedRows = [],4504paddingAdjust = 0,4505index = this.vDomBottom + 1,4506i = 0,4507working = true;45084509while(working){4510let row = rows[index],4511rowHeight, initialized;45124513if(row && i < this.vDomMaxRenderChain){4514rowHeight = row.getHeight() || this.vDomRowHeight;4515initialized = row.initialized;45164517if(fillableSpace >= rowHeight){45184519this.styleRow(row, index);4520table.appendChild(row.getElement());45214522if(!row.initialized || !row.heightInitialized){4523addedRows.push(row);4524}45254526row.initialize();45274528if(!initialized){4529rowHeight = row.getElement().offsetHeight;45304531if(rowHeight > this.vDomWindowBuffer){4532this.vDomWindowBuffer = rowHeight * 2;4533}4534}45354536fillableSpace -= rowHeight;4537paddingAdjust += rowHeight;45384539this.vDomBottom++;4540index++;4541i++;4542}else {4543working = false;4544}4545}else {4546working = false;4547}4548}45494550for (let row of addedRows){4551row.clearCellHeight();4552}45534554this._quickNormalizeRowHeight(addedRows);45554556if(paddingAdjust){4557this.vDomBottomPad -= paddingAdjust;45584559if(this.vDomBottomPad < 0 || index == rows.length -1){4560this.vDomBottomPad = 0;4561}45624563table.style.paddingBottom = this.vDomBottomPad + "px";4564this.vDomScrollPosBottom += paddingAdjust;4565}4566}45674568_removeBottomRow(rows, fillableSpace){4569var removableRows = [],4570paddingAdjust = 0,4571i = 0,4572working = true;45734574while(working){4575let row = rows[this.vDomBottom],4576rowHeight;45774578if(row && i < this.vDomMaxRenderChain){4579rowHeight = row.getHeight() || this.vDomRowHeight;45804581if(fillableSpace >= rowHeight){4582this.vDomBottom --;45834584fillableSpace -= rowHeight;4585paddingAdjust += rowHeight;45864587removableRows.push(row);4588i++;4589}else {4590working = false;4591}4592}else {4593working = false;4594}4595}45964597for (let row of removableRows){4598let rowEl = row.getElement();45994600if(rowEl.parentNode){4601rowEl.parentNode.removeChild(rowEl);4602}4603}46044605if(paddingAdjust){4606this.vDomBottomPad += paddingAdjust;46074608if(this.vDomBottomPad < 0){4609this.vDomBottomPad = 0;4610}46114612this.tableElement.style.paddingBottom = this.vDomBottomPad + "px";4613this.vDomScrollPosBottom -= paddingAdjust;4614}4615}46164617_quickNormalizeRowHeight(rows){4618for(let row of rows){4619row.calcHeight();4620}46214622for(let row of rows){4623row.setCellHeight();4624}4625}4626}46274628class RowManager extends CoreFeature{46294630constructor(table){4631super(table);46324633this.element = this.createHolderElement(); //containing element4634this.tableElement = this.createTableElement(); //table element4635this.heightFixer = this.createTableElement(); //table element4636this.placeholder = null; //placeholder element4637this.placeholderContents = null; //placeholder element46384639this.firstRender = false; //handle first render4640this.renderMode = "virtual"; //current rendering mode4641this.fixedHeight = false; //current rendering mode46424643this.rows = []; //hold row data objects4644this.activeRowsPipeline = []; //hold calculation of active rows4645this.activeRows = []; //rows currently available to on display in the table4646this.activeRowsCount = 0; //count of active rows46474648this.displayRows = []; //rows currently on display in the table4649this.displayRowsCount = 0; //count of display rows46504651this.scrollTop = 0;4652this.scrollLeft = 0;46534654this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing4655this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed4656this.redrawBlockRenderInPosition = false; //store latest redraw function calls for when redraw is needed46574658this.dataPipeline = []; //hold data pipeline tasks4659this.displayPipeline = []; //hold data display pipeline tasks46604661this.scrollbarWidth = 0;46624663this.renderer = null;4664}46654666//////////////// Setup Functions /////////////////46674668createHolderElement (){4669var el = document.createElement("div");46704671el.classList.add("tabulator-tableholder");4672el.setAttribute("tabindex", 0);4673// el.setAttribute("role", "rowgroup");46744675return el;4676}46774678createTableElement (){4679var el = document.createElement("div");46804681el.classList.add("tabulator-table");4682el.setAttribute("role", "rowgroup");46834684return el;4685}46864687initializePlaceholder(){4688var placeholder = this.table.options.placeholder;46894690if(typeof placeholder === "function"){4691placeholder = placeholder.call(this.table);4692}46934694placeholder = this.chain("placeholder", [placeholder], placeholder, placeholder) || placeholder;46954696//configure placeholder element4697if(placeholder){4698let el = document.createElement("div");4699el.classList.add("tabulator-placeholder");47004701if(typeof placeholder == "string"){4702let contents = document.createElement("div");4703contents.classList.add("tabulator-placeholder-contents");4704contents.innerHTML = placeholder;47054706el.appendChild(contents);47074708this.placeholderContents = contents;47094710}else if(typeof HTMLElement !== "undefined" && placeholder instanceof HTMLElement){47114712el.appendChild(placeholder);4713this.placeholderContents = placeholder;4714}else {4715console.warn("Invalid placeholder provided, must be string or HTML Element", placeholder);47164717this.el = null;4718}47194720this.placeholder = el;4721}4722}47234724//return containing element4725getElement(){4726return this.element;4727}47284729//return table element4730getTableElement(){4731return this.tableElement;4732}47334734initialize(){4735this.initializePlaceholder();4736this.initializeRenderer();47374738//initialize manager4739this.element.appendChild(this.tableElement);47404741this.firstRender = true;47424743//scroll header along with table body4744this.element.addEventListener("scroll", () => {4745var left = this.element.scrollLeft,4746leftDir = this.scrollLeft > left,4747top = this.element.scrollTop,4748topDir = this.scrollTop > top;47494750//handle horizontal scrolling4751if(this.scrollLeft != left){4752this.scrollLeft = left;47534754this.dispatch("scroll-horizontal", left, leftDir);4755this.dispatchExternal("scrollHorizontal", left, leftDir);47564757this._positionPlaceholder();4758}47594760//handle vertical scrolling4761if(this.scrollTop != top){4762this.scrollTop = top;47634764this.renderer.scrollRows(top, topDir);47654766this.dispatch("scroll-vertical", top, topDir);4767this.dispatchExternal("scrollVertical", top, topDir);4768}4769});4770}47714772////////////////// Row Manipulation //////////////////4773findRow(subject){4774if(typeof subject == "object"){4775if(subject instanceof Row){4776//subject is row element4777return subject;4778}else if(subject instanceof RowComponent){4779//subject is public row component4780return subject._getSelf() || false;4781}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){4782//subject is a HTML element of the row4783let match = this.rows.find((row) => {4784return row.getElement() === subject;4785});47864787return match || false;4788}else if(subject === null){4789return false;4790}4791}else if(typeof subject == "undefined"){4792return false;4793}else {4794//subject should be treated as the index of the row4795let match = this.rows.find((row) => {4796return row.data[this.table.options.index] == subject;4797});47984799return match || false;4800}48014802//catch all for any other type of input4803return false;4804}48054806getRowFromDataObject(data){4807var match = this.rows.find((row) => {4808return row.data === data;4809});48104811return match || false;4812}48134814getRowFromPosition(position){4815return this.getDisplayRows().find((row) => {4816return row.getPosition() === position && row.isDisplayed();4817});4818}48194820scrollToRow(row, position, ifVisible){4821return this.renderer.scrollToRowPosition(row, position, ifVisible);4822}48234824////////////////// Data Handling //////////////////4825setData(data, renderInPosition, columnsChanged){4826return new Promise((resolve, reject)=>{4827if(renderInPosition && this.getDisplayRows().length){4828if(this.table.options.pagination){4829this._setDataActual(data, true);4830}else {4831this.reRenderInPosition(() => {4832this._setDataActual(data);4833});4834}4835}else {4836if(this.table.options.autoColumns && columnsChanged && this.table.initialized){4837this.table.columnManager.generateColumnsFromRowData(data);4838}4839this.resetScroll();48404841this._setDataActual(data);4842}48434844resolve();4845});4846}48474848_setDataActual(data, renderInPosition){4849this.dispatchExternal("dataProcessing", data);48504851this._wipeElements();48524853if(Array.isArray(data)){4854this.dispatch("data-processing", data);48554856data.forEach((def, i) => {4857if(def && typeof def === "object"){4858var row = new Row(def, this);4859this.rows.push(row);4860}else {4861console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);4862}4863});48644865this.refreshActiveData(false, false, renderInPosition);48664867this.dispatch("data-processed", data);4868this.dispatchExternal("dataProcessed", data);4869}else {4870console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", typeof data, "\nData: ", data);4871}4872}48734874_wipeElements(){4875this.dispatch("rows-wipe");48764877this.destroy();48784879this.adjustTableSize();48804881this.dispatch("rows-wiped");4882}48834884destroy(){4885this.rows.forEach((row) => {4886row.wipe();4887});48884889this.rows = [];4890this.activeRows = [];4891this.activeRowsPipeline = [];4892this.activeRowsCount = 0;4893this.displayRows = [];4894this.displayRowsCount = 0;4895}48964897deleteRow(row, blockRedraw){4898var allIndex = this.rows.indexOf(row),4899activeIndex = this.activeRows.indexOf(row);49004901if(activeIndex > -1){4902this.activeRows.splice(activeIndex, 1);4903}49044905if(allIndex > -1){4906this.rows.splice(allIndex, 1);4907}49084909this.setActiveRows(this.activeRows);49104911this.displayRowIterator((rows) => {4912var displayIndex = rows.indexOf(row);49134914if(displayIndex > -1){4915rows.splice(displayIndex, 1);4916}4917});49184919if(!blockRedraw){4920this.reRenderInPosition();4921}49224923this.regenerateRowPositions();49244925this.dispatchExternal("rowDeleted", row.getComponent());49264927if(!this.displayRowsCount){4928this.tableEmpty();4929}49304931if(this.subscribedExternal("dataChanged")){4932this.dispatchExternal("dataChanged", this.getData());4933}4934}49354936addRow(data, pos, index, blockRedraw){4937var row = this.addRowActual(data, pos, index, blockRedraw);4938return row;4939}49404941//add multiple rows4942addRows(data, pos, index, refreshDisplayOnly){4943var rows = [];49444945return new Promise((resolve, reject) => {4946pos = this.findAddRowPos(pos);49474948if(!Array.isArray(data)){4949data = [data];4950}49514952if((typeof index == "undefined" && pos) || (typeof index !== "undefined" && !pos)){4953data.reverse();4954}49554956data.forEach((item, i) => {4957var row = this.addRow(item, pos, index, true);4958rows.push(row);4959this.dispatch("row-added", row, item, pos, index);4960});49614962this.refreshActiveData(refreshDisplayOnly ? "displayPipeline" : false, false, true);49634964this.regenerateRowPositions();49654966if(rows.length){4967this._clearPlaceholder();4968}49694970resolve(rows);4971});4972}49734974findAddRowPos(pos){4975if(typeof pos === "undefined"){4976pos = this.table.options.addRowPos;4977}49784979if(pos === "pos"){4980pos = true;4981}49824983if(pos === "bottom"){4984pos = false;4985}49864987return pos;4988}49894990addRowActual(data, pos, index, blockRedraw){4991var row = data instanceof Row ? data : new Row(data || {}, this),4992top = this.findAddRowPos(pos),4993allIndex = -1,4994activeIndex, chainResult;49954996if(!index){4997chainResult = this.chain("row-adding-position", [row, top], null, {index, top});49984999index = chainResult.index;5000top = chainResult.top;5001}50025003if(typeof index !== "undefined"){5004index = this.findRow(index);5005}50065007index = this.chain("row-adding-index", [row, index, top], null, index);50085009if(index){5010allIndex = this.rows.indexOf(index);5011}50125013if(index && allIndex > -1){5014activeIndex = this.activeRows.indexOf(index);50155016this.displayRowIterator(function(rows){5017var displayIndex = rows.indexOf(index);50185019if(displayIndex > -1){5020rows.splice((top ? displayIndex : displayIndex + 1), 0, row);5021}5022});50235024if(activeIndex > -1){5025this.activeRows.splice((top ? activeIndex : activeIndex + 1), 0, row);5026}50275028this.rows.splice((top ? allIndex : allIndex + 1), 0, row);50295030}else {50315032if(top){50335034this.displayRowIterator(function(rows){5035rows.unshift(row);5036});50375038this.activeRows.unshift(row);5039this.rows.unshift(row);5040}else {5041this.displayRowIterator(function(rows){5042rows.push(row);5043});50445045this.activeRows.push(row);5046this.rows.push(row);5047}5048}50495050this.setActiveRows(this.activeRows);50515052this.dispatchExternal("rowAdded", row.getComponent());50535054if(this.subscribedExternal("dataChanged")){5055this.dispatchExternal("dataChanged", this.table.rowManager.getData());5056}50575058if(!blockRedraw){5059this.reRenderInPosition();5060}50615062return row;5063}50645065moveRow(from, to, after){5066this.dispatch("row-move", from, to, after);50675068this.moveRowActual(from, to, after);50695070this.regenerateRowPositions();50715072this.dispatch("row-moved", from, to, after);5073this.dispatchExternal("rowMoved", from.getComponent());5074}50755076moveRowActual(from, to, after){5077this.moveRowInArray(this.rows, from, to, after);5078this.moveRowInArray(this.activeRows, from, to, after);50795080this.displayRowIterator((rows) => {5081this.moveRowInArray(rows, from, to, after);5082});50835084this.dispatch("row-moving", from, to, after);5085}50865087moveRowInArray(rows, from, to, after){5088var fromIndex, toIndex, start, end;50895090if(from !== to){50915092fromIndex = rows.indexOf(from);50935094if (fromIndex > -1) {50955096rows.splice(fromIndex, 1);50975098toIndex = rows.indexOf(to);50995100if (toIndex > -1) {51015102if(after){5103rows.splice(toIndex+1, 0, from);5104}else {5105rows.splice(toIndex, 0, from);5106}51075108}else {5109rows.splice(fromIndex, 0, from);5110}5111}51125113//restyle rows5114if(rows === this.getDisplayRows()){51155116start = fromIndex < toIndex ? fromIndex : toIndex;5117end = toIndex > fromIndex ? toIndex : fromIndex +1;51185119for(let i = start; i <= end; i++){5120if(rows[i]){5121this.styleRow(rows[i], i);5122}5123}5124}5125}5126}51275128clearData(){5129this.setData([]);5130}51315132getRowIndex(row){5133return this.findRowIndex(row, this.rows);5134}51355136getDisplayRowIndex(row){5137var index = this.getDisplayRows().indexOf(row);5138return index > -1 ? index : false;5139}51405141nextDisplayRow(row, rowOnly){5142var index = this.getDisplayRowIndex(row),5143nextRow = false;514451455146if(index !== false && index < this.displayRowsCount -1){5147nextRow = this.getDisplayRows()[index+1];5148}51495150if(nextRow && (!(nextRow instanceof Row) || nextRow.type != "row")){5151return this.nextDisplayRow(nextRow, rowOnly);5152}51535154return nextRow;5155}51565157prevDisplayRow(row, rowOnly){5158var index = this.getDisplayRowIndex(row),5159prevRow = false;51605161if(index){5162prevRow = this.getDisplayRows()[index-1];5163}51645165if(rowOnly && prevRow && (!(prevRow instanceof Row) || prevRow.type != "row")){5166return this.prevDisplayRow(prevRow, rowOnly);5167}51685169return prevRow;5170}51715172findRowIndex(row, list){5173var rowIndex;51745175row = this.findRow(row);51765177if(row){5178rowIndex = list.indexOf(row);51795180if(rowIndex > -1){5181return rowIndex;5182}5183}51845185return false;5186}51875188getData(active, transform){5189var output = [],5190rows = this.getRows(active);51915192rows.forEach(function(row){5193if(row.type == "row"){5194output.push(row.getData(transform || "data"));5195}5196});51975198return output;5199}52005201getComponents(active){5202var output = [],5203rows = this.getRows(active);52045205rows.forEach(function(row){5206output.push(row.getComponent());5207});52085209return output;5210}52115212getDataCount(active){5213var rows = this.getRows(active);52145215return rows.length;5216}52175218scrollHorizontal(left){5219this.scrollLeft = left;5220this.element.scrollLeft = left;52215222this.dispatch("scroll-horizontal", left);5223}52245225registerDataPipelineHandler(handler, priority){5226if(typeof priority !== "undefined"){5227this.dataPipeline.push({handler, priority});5228this.dataPipeline.sort((a, b) => {5229return a.priority - b.priority;5230});5231}else {5232console.error("Data pipeline handlers must have a priority in order to be registered");5233}5234}52355236registerDisplayPipelineHandler(handler, priority){5237if(typeof priority !== "undefined"){5238this.displayPipeline.push({handler, priority});5239this.displayPipeline.sort((a, b) => {5240return a.priority - b.priority;5241});5242}else {5243console.error("Display pipeline handlers must have a priority in order to be registered");5244}5245}52465247//set active data set5248refreshActiveData(handler, skipStage, renderInPosition){5249var table = this.table,5250stage = "",5251index = 0,5252cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"];52535254if(!this.table.destroyed){5255if(typeof handler === "function"){5256index = this.dataPipeline.findIndex((item) => {5257return item.handler === handler;5258});52595260if(index > -1){5261stage = "dataPipeline";52625263if(skipStage){5264if(index == this.dataPipeline.length - 1){5265stage = "display";5266}else {5267index++;5268}5269}5270}else {5271index = this.displayPipeline.findIndex((item) => {5272return item.handler === handler;5273});52745275if(index > -1){5276stage = "displayPipeline";52775278if(skipStage){5279if(index == this.displayPipeline.length - 1){5280stage = "end";5281}else {5282index++;5283}5284}5285}else {5286console.error("Unable to refresh data, invalid handler provided", handler);5287return;5288}5289}5290}else {5291stage = handler || "all";5292index = 0;5293}52945295if(this.redrawBlock){5296if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){5297this.redrawBlockRestoreConfig = {5298handler: handler,5299skipStage: skipStage,5300renderInPosition: renderInPosition,5301stage:stage,5302index:index,5303};5304}53055306return;5307}else {5308if(Helpers.elVisible(this.element)){5309if(renderInPosition){5310this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));5311}else {5312this.refreshPipelines(handler, stage, index, renderInPosition);53135314if(!handler){5315this.table.columnManager.renderer.renderColumns();5316}53175318this.renderTable();53195320if(table.options.layoutColumnsOnNewData){5321this.table.columnManager.redraw(true);5322}5323}5324}else {5325this.refreshPipelines(handler, stage, index, renderInPosition);5326}53275328this.dispatch("data-refreshed");5329}5330}5331}53325333refreshPipelines(handler, stage, index, renderInPosition){5334this.dispatch("data-refreshing");53355336if(!handler){5337this.activeRowsPipeline[0] = this.rows.slice(0);5338}53395340//cascade through data refresh stages5341switch(stage){5342case "all":5343//handle case where all data needs refreshing53445345case "dataPipeline":53465347for(let i = index; i < this.dataPipeline.length; i++){5348let result = this.dataPipeline[i].handler(this.activeRowsPipeline[i].slice(0));53495350this.activeRowsPipeline[i + 1] = result || this.activeRowsPipeline[i].slice(0);5351}53525353this.setActiveRows(this.activeRowsPipeline[this.dataPipeline.length]);53545355case "display":5356index = 0;5357this.resetDisplayRows();53585359case "displayPipeline":5360for(let i = index; i < this.displayPipeline.length; i++){5361let result = this.displayPipeline[i].handler((i ? this.getDisplayRows(i - 1) : this.activeRows).slice(0), renderInPosition);53625363this.setDisplayRows(result || this.getDisplayRows(i - 1).slice(0), i);5364}53655366case "end":5367//case to handle scenario when trying to skip past end stage5368this.regenerateRowPositions();5369}53705371if(this.getDisplayRows().length){5372this._clearPlaceholder();5373}5374}53755376//regenerate row positions5377regenerateRowPositions(){5378var rows = this.getDisplayRows();5379var index = 1;53805381rows.forEach((row) => {5382if (row.type === "row"){5383row.setPosition(index);5384index++;5385}5386});5387}53885389setActiveRows(activeRows){5390this.activeRows = this.activeRows = Object.assign([], activeRows);5391this.activeRowsCount = this.activeRows.length;5392}53935394//reset display rows array5395resetDisplayRows(){5396this.displayRows = [];53975398this.displayRows.push(this.activeRows.slice(0));53995400this.displayRowsCount = this.displayRows[0].length;5401}54025403//set display row pipeline data5404setDisplayRows(displayRows, index){5405this.displayRows[index] = displayRows;54065407if(index == this.displayRows.length -1){5408this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;5409}5410}54115412getDisplayRows(index){5413if(typeof index == "undefined"){5414return this.displayRows.length ? this.displayRows[this.displayRows.length -1] : [];5415}else {5416return this.displayRows[index] || [];5417}5418}54195420getVisibleRows(chain, viewable){5421var rows = Object.assign([], this.renderer.visibleRows(!viewable));54225423if(chain){5424rows = this.chain("rows-visible", [viewable], rows, rows);5425}54265427return rows;5428}54295430//repeat action across display rows5431displayRowIterator(callback){5432this.activeRowsPipeline.forEach(callback);5433this.displayRows.forEach(callback);54345435this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;5436}54375438//return only actual rows (not group headers etc)5439getRows(type){5440var rows = [];54415442switch(type){5443case "active":5444rows = this.activeRows;5445break;54465447case "display":5448rows = this.table.rowManager.getDisplayRows();5449break;54505451case "visible":5452rows = this.getVisibleRows(false, true);5453break;54545455default:5456rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;5457}54585459return rows;5460}54615462///////////////// Table Rendering /////////////////5463//trigger rerender of table in current position5464reRenderInPosition(callback){5465if(this.redrawBlock){5466if(callback){5467callback();5468}else {5469this.redrawBlockRenderInPosition = true;5470}5471}else {5472this.dispatchExternal("renderStarted");54735474this.renderer.rerenderRows(callback);54755476if(!this.fixedHeight){5477this.adjustTableSize();5478}54795480this.scrollBarCheck();54815482this.dispatchExternal("renderComplete");5483}5484}54855486scrollBarCheck(){5487var scrollbarWidth = 0;54885489//adjust for vertical scrollbar moving table when present5490if(this.element.scrollHeight > this.element.clientHeight){5491scrollbarWidth = this.element.offsetWidth - this.element.clientWidth;5492}54935494if(scrollbarWidth !== this.scrollbarWidth){5495this.scrollbarWidth = scrollbarWidth;5496this.dispatch("scrollbar-vertical", scrollbarWidth);5497}5498}54995500initializeRenderer(){5501var renderClass;55025503var renderers = {5504"virtual": VirtualDomVertical,5505"basic": BasicVertical,5506};55075508if(typeof this.table.options.renderVertical === "string"){5509renderClass = renderers[this.table.options.renderVertical];5510}else {5511renderClass = this.table.options.renderVertical;5512}55135514if(renderClass){5515this.renderMode = this.table.options.renderVertical;55165517this.renderer = new renderClass(this.table, this.element, this.tableElement);5518this.renderer.initialize();55195520if((this.table.element.clientHeight || this.table.options.height) && !(this.table.options.minHeight && this.table.options.maxHeight)){5521this.fixedHeight = true;5522}else {5523this.fixedHeight = false;5524}5525}else {5526console.error("Unable to find matching renderer:", this.table.options.renderVertical);5527}5528}55295530getRenderMode(){5531return this.renderMode;5532}55335534renderTable(){5535this.dispatchExternal("renderStarted");55365537this.element.scrollTop = 0;55385539this._clearTable();55405541if(this.displayRowsCount){5542this.renderer.renderRows();55435544if(this.firstRender){5545this.firstRender = false;55465547if(!this.fixedHeight){5548this.adjustTableSize();5549}55505551this.layoutRefresh(true);5552}5553}else {5554this.renderEmptyScroll();5555}55565557if(!this.fixedHeight){5558this.adjustTableSize();5559}55605561this.dispatch("table-layout");55625563if(!this.displayRowsCount){5564this._showPlaceholder();5565}55665567this.scrollBarCheck();55685569this.dispatchExternal("renderComplete");5570}55715572//show scrollbars on empty table div5573renderEmptyScroll(){5574if(this.placeholder){5575this.tableElement.style.display = "none";5576}else {5577this.tableElement.style.minWidth = this.table.columnManager.getWidth() + "px";5578// this.tableElement.style.minHeight = "1px";5579// this.tableElement.style.visibility = "hidden";5580}5581}55825583_clearTable(){5584this._clearPlaceholder();55855586this.scrollTop = 0;5587this.scrollLeft = 0;55885589this.renderer.clearRows();5590}55915592tableEmpty(){5593this.renderEmptyScroll();5594this._showPlaceholder();5595}55965597_showPlaceholder(){5598if(this.placeholder){5599if(this.placeholder && this.placeholder.parentNode){5600this.placeholder.parentNode.removeChild(this.placeholder);5601}56025603this.initializePlaceholder();56045605this.placeholder.setAttribute("tabulator-render-mode", this.renderMode);56065607this.getElement().appendChild(this.placeholder);5608this._positionPlaceholder();56095610this.adjustTableSize();5611}5612}56135614_clearPlaceholder(){5615if(this.placeholder && this.placeholder.parentNode){5616this.placeholder.parentNode.removeChild(this.placeholder);5617}56185619// clear empty table placeholder min5620this.tableElement.style.minWidth = "";5621this.tableElement.style.display = "";5622}56235624_positionPlaceholder(){5625if(this.placeholder && this.placeholder.parentNode){5626this.placeholder.style.width = this.table.columnManager.getWidth() + "px";5627this.placeholderContents.style.width = this.table.rowManager.element.clientWidth + "px";5628this.placeholderContents.style.marginLeft = this.scrollLeft + "px";5629}5630}56315632styleRow(row, index){5633var rowEl = row.getElement();56345635if(index % 2){5636rowEl.classList.add("tabulator-row-even");5637rowEl.classList.remove("tabulator-row-odd");5638}else {5639rowEl.classList.add("tabulator-row-odd");5640rowEl.classList.remove("tabulator-row-even");5641}5642}56435644//normalize height of active rows5645normalizeHeight(){5646this.activeRows.forEach(function(row){5647row.normalizeHeight();5648});5649}56505651//adjust the height of the table holder to fit in the Tabulator element5652adjustTableSize(){5653let initialHeight = this.element.clientHeight, minHeight;5654let resized = false;56555656if(this.renderer.verticalFillMode === "fill"){5657let 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));56585659if(this.fixedHeight){5660minHeight = isNaN(this.table.options.minHeight) ? this.table.options.minHeight : this.table.options.minHeight + "px";56615662const height = "calc(100% - " + otherHeight + "px)";5663this.element.style.minHeight = minHeight || "calc(100% - " + otherHeight + "px)";5664this.element.style.height = height;5665this.element.style.maxHeight = height;5666} else {5667this.element.style.height = "";5668this.element.style.height =5669this.table.element.clientHeight - otherHeight + "px";5670this.element.scrollTop = this.scrollTop;5671}56725673this.renderer.resize();56745675//check if the table has changed size when dealing with variable height tables5676if(!this.fixedHeight && initialHeight != this.element.clientHeight){5677resized = true;5678if(this.subscribed("table-resize")){5679this.dispatch("table-resize");5680}else {5681this.redraw();5682}5683}56845685this.scrollBarCheck();5686}56875688this._positionPlaceholder();5689return resized;5690}56915692//reinitialize all rows5693reinitialize(){5694this.rows.forEach(function(row){5695row.reinitialize(true);5696});5697}56985699//prevent table from being redrawn5700blockRedraw (){5701this.redrawBlock = true;5702this.redrawBlockRestoreConfig = false;5703}57045705//restore table redrawing5706restoreRedraw (){5707this.redrawBlock = false;57085709if(this.redrawBlockRestoreConfig){5710this.refreshActiveData(this.redrawBlockRestoreConfig.handler, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition);57115712this.redrawBlockRestoreConfig = false;5713}else {5714if(this.redrawBlockRenderInPosition){5715this.reRenderInPosition();5716}5717}57185719this.redrawBlockRenderInPosition = false;5720}57215722//redraw table5723redraw (force){5724const resized = this.adjustTableSize();5725this.table.tableWidth = this.table.element.clientWidth;57265727if(!force){5728if(resized) {5729this.reRenderInPosition();5730}5731this.scrollHorizontal(this.scrollLeft);5732}else {5733this.renderTable();5734}5735}57365737resetScroll(){5738this.element.scrollLeft = 0;5739this.element.scrollTop = 0;57405741if(this.table.browser === "ie"){5742var event = document.createEvent("Event");5743event.initEvent("scroll", false, true);5744this.element.dispatchEvent(event);5745}else {5746this.element.dispatchEvent(new Event('scroll'));5747}5748}5749}57505751class FooterManager extends CoreFeature{57525753constructor(table){5754super(table);57555756this.active = false;5757this.element = this.createElement(); //containing element5758this.containerElement = this.createContainerElement(); //containing element5759this.external = false;5760}57615762initialize(){5763this.initializeElement();5764}57655766createElement(){5767var el = document.createElement("div");57685769el.classList.add("tabulator-footer");57705771return el;5772}577357745775createContainerElement(){5776var el = document.createElement("div");57775778el.classList.add("tabulator-footer-contents");57795780this.element.appendChild(el);57815782return el;5783}57845785initializeElement(){5786if(this.table.options.footerElement){57875788switch(typeof this.table.options.footerElement){5789case "string":5790if(this.table.options.footerElement[0] === "<"){5791this.containerElement.innerHTML = this.table.options.footerElement;5792}else {5793this.external = true;5794this.containerElement = document.querySelector(this.table.options.footerElement);5795}5796break;57975798default:5799this.element = this.table.options.footerElement;5800break;5801}5802}5803}58045805getElement(){5806return this.element;5807}58085809append(element){5810this.activate();58115812this.containerElement.appendChild(element);5813this.table.rowManager.adjustTableSize();5814}58155816prepend(element){5817this.activate();58185819this.element.insertBefore(element, this.element.firstChild);5820this.table.rowManager.adjustTableSize();5821}58225823remove(element){5824element.parentNode.removeChild(element);5825this.deactivate();5826}58275828deactivate(force){5829if(!this.element.firstChild || force){5830if(!this.external){5831this.element.parentNode.removeChild(this.element);5832}5833this.active = false;5834}5835}58365837activate(){5838if(!this.active){5839this.active = true;5840if(!this.external){5841this.table.element.appendChild(this.getElement());5842this.table.element.style.display = '';5843}5844}5845}58465847redraw(){5848this.dispatch("footer-redraw");5849}5850}58515852class InteractionManager extends CoreFeature {58535854constructor (table){5855super(table);58565857this.el = null;58585859this.abortClasses = ["tabulator-headers", "tabulator-table"];58605861this.previousTargets = {};58625863this.listeners = [5864"click",5865"dblclick",5866"contextmenu",5867"mouseenter",5868"mouseleave",5869"mouseover",5870"mouseout",5871"mousemove",5872"mouseup",5873"mousedown",5874"touchstart",5875"touchend",5876];58775878this.componentMap = {5879"tabulator-cell":"cell",5880"tabulator-row":"row",5881"tabulator-group":"group",5882"tabulator-col":"column",5883};58845885this.pseudoTrackers = {5886"row":{5887subscriber:null,5888target:null,5889},5890"cell":{5891subscriber:null,5892target:null,5893},5894"group":{5895subscriber:null,5896target:null,5897},5898"column":{5899subscriber:null,5900target:null,5901},5902};59035904this.pseudoTracking = false;5905}59065907initialize(){5908this.el = this.table.element;59095910this.buildListenerMap();5911this.bindSubscriptionWatchers();5912}59135914buildListenerMap(){5915var listenerMap = {};59165917this.listeners.forEach((listener) => {5918listenerMap[listener] = {5919handler:null,5920components:[],5921};5922});59235924this.listeners = listenerMap;5925}59265927bindPseudoEvents(){5928Object.keys(this.pseudoTrackers).forEach((key) => {5929this.pseudoTrackers[key].subscriber = this.pseudoMouseEnter.bind(this, key);5930this.subscribe(key + "-mouseover", this.pseudoTrackers[key].subscriber);5931});59325933this.pseudoTracking = true;5934}59355936pseudoMouseEnter(key, e, target){5937if(this.pseudoTrackers[key].target !== target){59385939if(this.pseudoTrackers[key].target){5940this.dispatch(key + "-mouseleave", e, this.pseudoTrackers[key].target);5941}59425943this.pseudoMouseLeave(key, e);59445945this.pseudoTrackers[key].target = target;59465947this.dispatch(key + "-mouseenter", e, target);5948}5949}59505951pseudoMouseLeave(key, e){5952var leaveList = Object.keys(this.pseudoTrackers),5953linkedKeys = {5954"row":["cell"],5955"cell":["row"],5956};59575958leaveList = leaveList.filter((item) => {5959var links = linkedKeys[key];5960return item !== key && (!links || (links && !links.includes(item)));5961});596259635964leaveList.forEach((key) => {5965var target = this.pseudoTrackers[key].target;59665967if(this.pseudoTrackers[key].target){5968this.dispatch(key + "-mouseleave", e, target);59695970this.pseudoTrackers[key].target = null;5971}5972});5973}597459755976bindSubscriptionWatchers(){5977var listeners = Object.keys(this.listeners),5978components = Object.values(this.componentMap);59795980for(let comp of components){5981for(let listener of listeners){5982let key = comp + "-" + listener;59835984this.subscriptionChange(key, this.subscriptionChanged.bind(this, comp, listener));5985}5986}59875988this.subscribe("table-destroy", this.clearWatchers.bind(this));5989}59905991subscriptionChanged(component, key, added){5992var listener = this.listeners[key].components,5993index = listener.indexOf(component),5994changed = false;59955996if(added){5997if(index === -1){5998listener.push(component);5999changed = true;6000}6001}else {6002if(!this.subscribed(component + "-" + key)){6003if(index > -1){6004listener.splice(index, 1);6005changed = true;6006}6007}6008}60096010if((key === "mouseenter" || key === "mouseleave") && !this.pseudoTracking){6011this.bindPseudoEvents();6012}60136014if(changed){6015this.updateEventListeners();6016}6017}60186019updateEventListeners(){6020for(let key in this.listeners){6021let listener = this.listeners[key];60226023if(listener.components.length){6024if(!listener.handler){6025listener.handler = this.track.bind(this, key);6026this.el.addEventListener(key, listener.handler);6027// this.el.addEventListener(key, listener.handler, {passive: true})6028}6029}else {6030if(listener.handler){6031this.el.removeEventListener(key, listener.handler);6032listener.handler = null;6033}6034}6035}6036}60376038track(type, e){6039var path = (e.composedPath && e.composedPath()) || e.path;60406041var targets = this.findTargets(path);6042targets = this.bindComponents(type, targets);60436044this.triggerEvents(type, e, targets);60456046if(this.pseudoTracking && (type == "mouseover" || type == "mouseleave") && !Object.keys(targets).length){6047this.pseudoMouseLeave("none", e);6048}6049}60506051findTargets(path){6052var targets = {};60536054let componentMap = Object.keys(this.componentMap);60556056for (let el of path) {6057let classList = el.classList ? [...el.classList] : [];60586059let abort = classList.filter((item) => {6060return this.abortClasses.includes(item);6061});60626063if(abort.length){6064break;6065}60666067let elTargets = classList.filter((item) => {6068return componentMap.includes(item);6069});60706071for (let target of elTargets) {6072if(!targets[this.componentMap[target]]){6073targets[this.componentMap[target]] = el;6074}6075}6076}60776078if(targets.group && targets.group === targets.row){6079delete targets.row;6080}60816082return targets;6083}60846085bindComponents(type, targets){6086//ensure row component is looked up before cell6087var keys = Object.keys(targets).reverse(),6088listener = this.listeners[type],6089matches = {},6090targetMatches = {};60916092for(let key of keys){6093let component,6094target = targets[key],6095previousTarget = this.previousTargets[key];60966097if(previousTarget && previousTarget.target === target){6098component = previousTarget.component;6099}else {6100switch(key){6101case "row":6102case "group":6103if(listener.components.includes("row") || listener.components.includes("cell") || listener.components.includes("group")){6104let rows = this.table.rowManager.getVisibleRows(true);61056106component = rows.find((row) => {6107return row.getElement() === target;6108});61096110if(targets["row"] && targets["row"].parentNode && targets["row"].parentNode.closest(".tabulator-row")){6111targets[key] = false;6112}6113}6114break;61156116case "column":6117if(listener.components.includes("column")){6118component = this.table.columnManager.findColumn(target);6119}6120break;61216122case "cell":6123if(listener.components.includes("cell")){6124if(matches["row"] instanceof Row){6125component = matches["row"].findCell(target);6126}else {6127if(targets["row"]){6128console.warn("Event Target Lookup Error - The row this cell is attached to cannot be found, has the table been reinitialized without being destroyed first?");6129}6130}6131}6132break;6133}6134}61356136if(component){6137matches[key] = component;6138targetMatches[key] = {6139target:target,6140component:component,6141};6142}6143}61446145this.previousTargets = targetMatches;61466147return matches;6148}61496150triggerEvents(type, e, targets){6151var listener = this.listeners[type];61526153for(let key in targets){6154if(targets[key] && listener.components.includes(key)){6155this.dispatch(key + "-" + type, e, targets[key]);6156}6157}6158}61596160clearWatchers(){6161for(let key in this.listeners){6162let listener = this.listeners[key];61636164if(listener.handler){6165this.el.removeEventListener(key, listener.handler);6166listener.handler = null;6167}6168}6169}6170}61716172class ComponentFunctionBinder{61736174constructor(table){6175this.table = table;61766177this.bindings = {};6178}61796180bind(type, funcName, handler){6181if(!this.bindings[type]){6182this.bindings[type] = {};6183}61846185if(this.bindings[type][funcName]){6186console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler);6187}else {6188this.bindings[type][funcName] = handler;6189}6190}61916192handle(type, component, name){6193if(this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function'){6194return this.bindings[type][name].bind(null, component);6195}else {6196if(name !== "then" && typeof name === "string" && !name.startsWith("_")){6197if(this.table.options.debugInvalidComponentFuncs){6198console.error("The " + type + " component does not have a " + name + " function, have you checked that you have the correct Tabulator module installed?");6199}6200}6201}6202}6203}62046205class DataLoader extends CoreFeature{6206constructor(table){6207super(table);62086209this.requestOrder = 0; //prevent requests coming out of sequence if overridden by another load request6210this.loading = false;6211}62126213initialize(){}62146215load(data, params, config, replace, silent, columnsChanged){6216var requestNo = ++this.requestOrder;62176218if(this.table.destroyed){6219return Promise.resolve();6220}62216222this.dispatchExternal("dataLoading", data);62236224//parse json data to array6225if (data && (data.indexOf("{") == 0 || data.indexOf("[") == 0)){6226data = JSON.parse(data);6227}62286229if(this.confirm("data-loading", [data, params, config, silent])){6230this.loading = true;62316232if(!silent){6233this.alertLoader();6234}62356236//get params for request6237params = this.chain("data-params", [data, config, silent], params || {}, params || {});62386239params = this.mapParams(params, this.table.options.dataSendParams);62406241var result = this.chain("data-load", [data, params, config, silent], false, Promise.resolve([]));62426243return result.then((response) => {6244if(!this.table.destroyed){6245if(!Array.isArray(response) && typeof response == "object"){6246response = this.mapParams(response, this.objectInvert(this.table.options.dataReceiveParams));6247}62486249var rowData = this.chain("data-loaded", response, null, response);62506251if(requestNo == this.requestOrder){6252this.clearAlert();62536254if(rowData !== false){6255this.dispatchExternal("dataLoaded", rowData);6256this.table.rowManager.setData(rowData, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);6257}6258}else {6259console.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");6260}6261}else {6262console.warn("Data Load Response Blocked - Table has been destroyed");6263}6264}).catch((error) => {6265console.error("Data Load Error: ", error);6266this.dispatchExternal("dataLoadError", error);62676268if(!silent){6269this.alertError();6270}62716272setTimeout(() => {6273this.clearAlert();6274}, this.table.options.dataLoaderErrorTimeout);6275})6276.finally(() => {6277this.loading = false;6278});6279}else {6280this.dispatchExternal("dataLoaded", data);62816282if(!data){6283data = [];6284}62856286this.table.rowManager.setData(data, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);6287return Promise.resolve();6288}6289}62906291mapParams(params, map){6292var output = {};62936294for(let key in params){6295output[map.hasOwnProperty(key) ? map[key] : key] = params[key];6296}62976298return output;6299}63006301objectInvert(obj){6302var output = {};63036304for(let key in obj){6305output[obj[key]] = key;6306}63076308return output;6309}63106311blockActiveLoad(){6312this.requestOrder++;6313}63146315alertLoader(){6316var shouldLoad = typeof this.table.options.dataLoader === "function" ? this.table.options.dataLoader() : this.table.options.dataLoader;63176318if(shouldLoad){6319this.table.alertManager.alert(this.table.options.dataLoaderLoading || this.langText("data|loading"));6320}6321}63226323alertError(){6324this.table.alertManager.alert(this.table.options.dataLoaderError || this.langText("data|error"), "error");6325}63266327clearAlert(){6328this.table.alertManager.clear();6329}6330}63316332class ExternalEventBus {63336334constructor(table, optionsList, debug){6335this.table = table;6336this.events = {};6337this.optionsList = optionsList || {};6338this.subscriptionNotifiers = {};63396340this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this);6341this.debug = debug;6342}63436344subscriptionChange(key, callback){6345if(!this.subscriptionNotifiers[key]){6346this.subscriptionNotifiers[key] = [];6347}63486349this.subscriptionNotifiers[key].push(callback);63506351if(this.subscribed(key)){6352this._notifySubscriptionChange(key, true);6353}6354}63556356subscribe(key, callback){6357if(!this.events[key]){6358this.events[key] = [];6359}63606361this.events[key].push(callback);63626363this._notifySubscriptionChange(key, true);6364}63656366unsubscribe(key, callback){6367var index;63686369if(this.events[key]){6370if(callback){6371index = this.events[key].findIndex((item) => {6372return item === callback;6373});63746375if(index > -1){6376this.events[key].splice(index, 1);6377}else {6378console.warn("Cannot remove event, no matching event found:", key, callback);6379return;6380}6381}else {6382delete this.events[key];6383}6384}else {6385console.warn("Cannot remove event, no events set on:", key);6386return;6387}63886389this._notifySubscriptionChange(key, false);6390}63916392subscribed(key){6393return this.events[key] && this.events[key].length;6394}63956396_notifySubscriptionChange(key, subscribed){6397var notifiers = this.subscriptionNotifiers[key];63986399if(notifiers){6400notifiers.forEach((callback)=>{6401callback(subscribed);6402});6403}6404}64056406_dispatch(){6407var args = Array.from(arguments),6408key = args.shift(),6409result;64106411if(this.events[key]){6412this.events[key].forEach((callback, i) => {6413let callResult = callback.apply(this.table, args);64146415if(!i){6416result = callResult;6417}6418});6419}64206421return result;6422}64236424_debugDispatch(){6425var args = Array.from(arguments),6426key = args[0];64276428args[0] = "ExternalEvent:" + args[0];64296430if(this.debug === true || this.debug.includes(key)){6431console.log(...args);6432}64336434return this._dispatch(...arguments);6435}6436}64376438class InternalEventBus {64396440constructor(debug){6441this.events = {};6442this.subscriptionNotifiers = {};64436444this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this);6445this.chain = debug ? this._debugChain.bind(this) : this._chain.bind(this);6446this.confirm = debug ? this._debugConfirm.bind(this) : this._confirm.bind(this);6447this.debug = debug;6448}64496450subscriptionChange(key, callback){6451if(!this.subscriptionNotifiers[key]){6452this.subscriptionNotifiers[key] = [];6453}64546455this.subscriptionNotifiers[key].push(callback);64566457if(this.subscribed(key)){6458this._notifySubscriptionChange(key, true);6459}6460}64616462subscribe(key, callback, priority = 10000){6463if(!this.events[key]){6464this.events[key] = [];6465}64666467this.events[key].push({callback, priority});64686469this.events[key].sort((a, b) => {6470return a.priority - b.priority;6471});64726473this._notifySubscriptionChange(key, true);6474}64756476unsubscribe(key, callback){6477var index;64786479if(this.events[key]){6480if(callback){6481index = this.events[key].findIndex((item) => {6482return item.callback === callback;6483});64846485if(index > -1){6486this.events[key].splice(index, 1);6487}else {6488console.warn("Cannot remove event, no matching event found:", key, callback);6489return;6490}6491}6492}else {6493console.warn("Cannot remove event, no events set on:", key);6494return;6495}64966497this._notifySubscriptionChange(key, false);6498}64996500subscribed(key){6501return this.events[key] && this.events[key].length;6502}65036504_chain(key, args, initialValue, fallback){6505var value = initialValue;65066507if(!Array.isArray(args)){6508args = [args];6509}65106511if(this.subscribed(key)){6512this.events[key].forEach((subscriber, i) => {6513value = subscriber.callback.apply(this, args.concat([value]));6514});65156516return value;6517}else {6518return typeof fallback === "function" ? fallback() : fallback;6519}6520}65216522_confirm(key, args){6523var confirmed = false;65246525if(!Array.isArray(args)){6526args = [args];6527}65286529if(this.subscribed(key)){6530this.events[key].forEach((subscriber, i) => {6531if(subscriber.callback.apply(this, args)){6532confirmed = true;6533}6534});6535}65366537return confirmed;6538}65396540_notifySubscriptionChange(key, subscribed){6541var notifiers = this.subscriptionNotifiers[key];65426543if(notifiers){6544notifiers.forEach((callback)=>{6545callback(subscribed);6546});6547}6548}65496550_dispatch(){6551var args = Array.from(arguments),6552key = args.shift();65536554if(this.events[key]){6555this.events[key].forEach((subscriber) => {6556subscriber.callback.apply(this, args);6557});6558}6559}65606561_debugDispatch(){6562var args = Array.from(arguments),6563key = args[0];65646565args[0] = "InternalEvent:" + key;65666567if(this.debug === true || this.debug.includes(key)){6568console.log(...args);6569}65706571return this._dispatch(...arguments);6572}65736574_debugChain(){6575var args = Array.from(arguments),6576key = args[0];65776578args[0] = "InternalEvent:" + key;65796580if(this.debug === true || this.debug.includes(key)){6581console.log(...args);6582}65836584return this._chain(...arguments);6585}65866587_debugConfirm(){6588var args = Array.from(arguments),6589key = args[0];65906591args[0] = "InternalEvent:" + key;65926593if(this.debug === true || this.debug.includes(key)){6594console.log(...args);6595}65966597return this._confirm(...arguments);6598}6599}66006601class DeprecationAdvisor extends CoreFeature{66026603constructor(table){6604super(table);6605}66066607_warnUser(){6608if(this.options("debugDeprecation")){6609console.warn(...arguments);6610}6611}66126613check(oldOption, newOption){6614var msg = "";66156616if(typeof this.options(oldOption) !== "undefined"){6617msg = "Deprecated Setup Option - Use of the %c" + oldOption + "%c option is now deprecated";66186619if(newOption){6620msg = msg + ", Please use the %c" + newOption + "%c option instead";6621this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;', 'font-weight: bold;', 'font-weight: normal;');6622}else {6623this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;');6624}66256626return false;6627}else {6628return true;6629}6630}66316632checkMsg(oldOption, msg){6633if(typeof this.options(oldOption) !== "undefined"){6634this._warnUser("%cDeprecated Setup Option - Use of the %c" + oldOption + " %c option is now deprecated, " + msg, 'font-weight: normal;', 'font-weight: bold;', 'font-weight: normal;');66356636return false;6637}else {6638return true;6639}6640}66416642msg(msg){6643this._warnUser(msg);6644}6645}66466647class TableRegistry {66486649static register(table){6650TableRegistry.tables.push(table);6651}66526653static deregister(table){6654var index = TableRegistry.tables.indexOf(table);66556656if(index > -1){6657TableRegistry.tables.splice(index, 1);6658}6659}66606661static lookupTable(query, silent){6662var results = [],6663matches, match;66646665if(typeof query === "string"){6666matches = document.querySelectorAll(query);66676668if(matches.length){6669for(var i = 0; i < matches.length; i++){6670match = TableRegistry.matchElement(matches[i]);66716672if(match){6673results.push(match);6674}6675}6676}66776678}else if((typeof HTMLElement !== "undefined" && query instanceof HTMLElement) || query instanceof Tabulator){6679match = TableRegistry.matchElement(query);66806681if(match){6682results.push(match);6683}6684}else if(Array.isArray(query)){6685query.forEach(function(item){6686results = results.concat(TableRegistry.lookupTable(item));6687});6688}else {6689if(!silent){6690console.warn("Table Connection Error - Invalid Selector", query);6691}6692}66936694return results;6695}66966697static matchElement(element){6698return TableRegistry.tables.find(function(table){6699return element instanceof Tabulator ? table === element : table.element === element;6700});6701}6702}67036704TableRegistry.tables = [];67056706class Popup extends CoreFeature{6707constructor(table, element, parent){6708super(table);67096710this.element = element;6711this.container = this._lookupContainer();67126713this.parent = parent;67146715this.reversedX = false;6716this.childPopup = null;6717this.blurable = false;6718this.blurCallback = null;6719this.blurEventsBound = false;6720this.renderedCallback = null;67216722this.visible = false;6723this.hideable = true;67246725this.element.classList.add("tabulator-popup-container");67266727this.blurEvent = this.hide.bind(this, false);6728this.escEvent = this._escapeCheck.bind(this);67296730this.destroyBinding = this.tableDestroyed.bind(this);6731this.destroyed = false;6732}67336734tableDestroyed(){6735this.destroyed = true;6736this.hide(true);6737}67386739_lookupContainer(){6740var container = this.table.options.popupContainer;67416742if(typeof container === "string"){6743container = document.querySelector(container);67446745if(!container){6746console.warn("Menu Error - no container element found matching selector:", this.table.options.popupContainer , "(defaulting to document body)");6747}6748}else if (container === true){6749container = this.table.element;6750}67516752if(container && !this._checkContainerIsParent(container)){6753container = false;6754console.warn("Menu Error - container element does not contain this table:", this.table.options.popupContainer , "(defaulting to document body)");6755}67566757if(!container){6758container = document.body;6759}67606761return container;6762}67636764_checkContainerIsParent(container, element = this.table.element){6765if(container === element){6766return true;6767}else {6768return element.parentNode ? this._checkContainerIsParent(container, element.parentNode) : false;6769}6770}67716772renderCallback(callback){6773this.renderedCallback = callback;6774}67756776containerEventCoords(e){6777var touch = !(e instanceof MouseEvent);67786779var x = touch ? e.touches[0].pageX : e.pageX;6780var y = touch ? e.touches[0].pageY : e.pageY;67816782if(this.container !== document.body){6783let parentOffset = Helpers.elOffset(this.container);67846785x -= parentOffset.left;6786y -= parentOffset.top;6787}67886789return {x, y};6790}67916792elementPositionCoords(element, position = "right"){6793var offset = Helpers.elOffset(element),6794containerOffset, x, y;67956796if(this.container !== document.body){6797containerOffset = Helpers.elOffset(this.container);67986799offset.left -= containerOffset.left;6800offset.top -= containerOffset.top;6801}68026803switch(position){6804case "right":6805x = offset.left + element.offsetWidth;6806y = offset.top - 1;6807break;68086809case "bottom":6810x = offset.left;6811y = offset.top + element.offsetHeight;6812break;68136814case "left":6815x = offset.left;6816y = offset.top - 1;6817break;68186819case "top":6820x = offset.left;6821y = offset.top;6822break;68236824case "center":6825x = offset.left + (element.offsetWidth / 2);6826y = offset.top + (element.offsetHeight / 2);6827break;68286829}68306831return {x, y, offset};6832}68336834show(origin, position){6835var x, y, parentEl, parentOffset, coords;68366837if(this.destroyed || this.table.destroyed){6838return this;6839}68406841if(origin instanceof HTMLElement){6842parentEl = origin;6843coords = this.elementPositionCoords(origin, position);68446845parentOffset = coords.offset;6846x = coords.x;6847y = coords.y;68486849}else if(typeof origin === "number"){6850parentOffset = {top:0, left:0};6851x = origin;6852y = position;6853}else {6854coords = this.containerEventCoords(origin);68556856x = coords.x;6857y = coords.y;68586859this.reversedX = false;6860}68616862this.element.style.top = y + "px";6863this.element.style.left = x + "px";68646865this.container.appendChild(this.element);68666867if(typeof this.renderedCallback === "function"){6868this.renderedCallback();6869}68706871this._fitToScreen(x, y, parentEl, parentOffset, position);68726873this.visible = true;68746875this.subscribe("table-destroy", this.destroyBinding);68766877this.element.addEventListener("mousedown", (e) => {6878e.stopPropagation();6879});68806881return this;6882}68836884_fitToScreen(x, y, parentEl, parentOffset, position){6885var scrollTop = this.container === document.body ? document.documentElement.scrollTop : this.container.scrollTop;68866887//move menu to start on right edge if it is too close to the edge of the screen6888if((x + this.element.offsetWidth) >= this.container.offsetWidth || this.reversedX){6889this.element.style.left = "";68906891if(parentEl){6892this.element.style.right = (this.container.offsetWidth - parentOffset.left) + "px";6893}else {6894this.element.style.right = (this.container.offsetWidth - x) + "px";6895}68966897this.reversedX = true;6898}68996900//move menu to start on bottom edge if it is too close to the edge of the screen6901if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) {6902if(parentEl){6903switch(position){6904case "bottom":6905this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight - parentEl.offsetHeight - 1) + "px";6906break;69076908default:6909this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight + parentEl.offsetHeight + 1) + "px";6910}69116912}else {6913this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px";6914}6915}6916}69176918isVisible(){6919return this.visible;6920}69216922hideOnBlur(callback){6923this.blurable = true;69246925if(this.visible){6926setTimeout(() => {6927if(this.visible){6928this.table.rowManager.element.addEventListener("scroll", this.blurEvent);6929this.subscribe("cell-editing", this.blurEvent);6930document.body.addEventListener("click", this.blurEvent);6931document.body.addEventListener("contextmenu", this.blurEvent);6932document.body.addEventListener("mousedown", this.blurEvent);6933window.addEventListener("resize", this.blurEvent);6934document.body.addEventListener("keydown", this.escEvent);69356936this.blurEventsBound = true;6937}6938}, 100);69396940this.blurCallback = callback;6941}69426943return this;6944}69456946_escapeCheck(e){6947if(e.keyCode == 27){6948this.hide();6949}6950}69516952blockHide(){6953this.hideable = false;6954}69556956restoreHide(){6957this.hideable = true;6958}69596960hide(silent = false){6961if(this.visible && this.hideable){6962if(this.blurable && this.blurEventsBound){6963document.body.removeEventListener("keydown", this.escEvent);6964document.body.removeEventListener("click", this.blurEvent);6965document.body.removeEventListener("contextmenu", this.blurEvent);6966document.body.removeEventListener("mousedown", this.blurEvent);6967window.removeEventListener("resize", this.blurEvent);6968this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);6969this.unsubscribe("cell-editing", this.blurEvent);69706971this.blurEventsBound = false;6972}69736974if(this.childPopup){6975this.childPopup.hide();6976}69776978if(this.parent){6979this.parent.childPopup = null;6980}69816982if(this.element.parentNode){6983this.element.parentNode.removeChild(this.element);6984}69856986this.visible = false;69876988if(this.blurCallback && !silent){6989this.blurCallback();6990}69916992this.unsubscribe("table-destroy", this.destroyBinding);6993}69946995return this;6996}69976998child(element){6999if(this.childPopup){7000this.childPopup.hide();7001}70027003this.childPopup = new Popup(this.table, element, this);70047005return this.childPopup;7006}7007}70087009class Module extends CoreFeature{70107011constructor(table, name){7012super(table);70137014this._handler = null;7015}70167017initialize(){7018// setup module when table is initialized, to be overridden in module7019}702070217022///////////////////////////////////7023////// Options Registration ///////7024///////////////////////////////////70257026registerTableOption(key, value){7027this.table.optionsList.register(key, value);7028}70297030registerColumnOption(key, value){7031this.table.columnManager.optionsList.register(key, value);7032}70337034///////////////////////////////////7035/// Public Function Registration ///7036///////////////////////////////////70377038registerTableFunction(name, func){7039if(typeof this.table[name] === "undefined"){7040this.table[name] = (...args) => {7041this.table.initGuard(name);70427043return func(...args);7044};7045}else {7046console.warn("Unable to bind table function, name already in use", name);7047}7048}70497050registerComponentFunction(component, func, handler){7051return this.table.componentFunctionBinder.bind(component, func, handler);7052}70537054///////////////////////////////////7055////////// Data Pipeline //////////7056///////////////////////////////////70577058registerDataHandler(handler, priority){7059this.table.rowManager.registerDataPipelineHandler(handler, priority);7060this._handler = handler;7061}70627063registerDisplayHandler(handler, priority){7064this.table.rowManager.registerDisplayPipelineHandler(handler, priority);7065this._handler = handler;7066}70677068displayRows(adjust){7069var index = this.table.rowManager.displayRows.length - 1,7070lookupIndex;70717072if(this._handler){7073lookupIndex = this.table.rowManager.displayPipeline.findIndex((item) => {7074return item.handler === this._handler;7075});70767077if(lookupIndex > -1){7078index = lookupIndex;7079}7080}70817082if(adjust){7083index = index + adjust;7084}70857086if(this._handler){7087if(index > -1){7088return this.table.rowManager.getDisplayRows(index);7089}else {7090return this.activeRows();7091}7092}7093}70947095activeRows(){7096return this.table.rowManager.activeRows;7097}70987099refreshData(renderInPosition, handler){7100if(!handler){7101handler = this._handler;7102}71037104if(handler){7105this.table.rowManager.refreshActiveData(handler, false, renderInPosition);7106}7107}71087109///////////////////////////////////7110//////// Footer Management ////////7111///////////////////////////////////71127113footerAppend(element){7114return this.table.footerManager.append(element);7115}71167117footerPrepend(element){7118return this.table.footerManager.prepend(element);7119}71207121footerRemove(element){7122return this.table.footerManager.remove(element);7123}71247125///////////////////////////////////7126//////// Popups Management ////////7127///////////////////////////////////71287129popup(menuEl, menuContainer){7130return new Popup(this.table, menuEl, menuContainer);7131}71327133///////////////////////////////////7134//////// Alert Management ////////7135///////////////////////////////////71367137alert(content, type){7138return this.table.alertManager.alert(content, type);7139}71407141clearAlert(){7142return this.table.alertManager.clear();7143}71447145}71467147//resize columns to fit data they contain7148function fitData(columns, forced){7149if(forced){7150this.table.columnManager.renderer.reinitializeColumnWidths(columns);7151}71527153if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){7154this.table.modules.responsiveLayout.update();7155}7156}71577158//resize columns to fit data they contain and stretch row to fill table, also used for fitDataTable7159function fitDataGeneral(columns, forced){7160columns.forEach(function(column){7161column.reinitializeWidth();7162});71637164if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){7165this.table.modules.responsiveLayout.update();7166}7167}71687169//resize columns to fit data the contain and stretch last column to fill table7170function fitDataStretch(columns, forced){7171var colsWidth = 0,7172tableWidth = this.table.rowManager.element.clientWidth,7173gap = 0,7174lastCol = false;71757176columns.forEach((column, i) => {7177if(!column.widthFixed){7178column.reinitializeWidth();7179}71807181if(this.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible){7182lastCol = column;7183}71847185if(column.visible){7186colsWidth += column.getWidth();7187}7188});71897190if(lastCol){7191gap = tableWidth - colsWidth + lastCol.getWidth();71927193if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){7194lastCol.setWidth(0);7195this.table.modules.responsiveLayout.update();7196}71977198if(gap > 0){7199lastCol.setWidth(gap);7200}else {7201lastCol.reinitializeWidth();7202}7203}else {7204if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){7205this.table.modules.responsiveLayout.update();7206}7207}7208}72097210//resize columns to fit7211function fitColumns(columns, forced){7212var totalWidth = this.table.rowManager.element.getBoundingClientRect().width; //table element width7213var fixedWidth = 0; //total width of columns with a defined width7214var flexWidth = 0; //total width available to flexible columns7215var flexGrowUnits = 0; //total number of widthGrow blocks across all columns7216var flexColWidth = 0; //desired width of flexible columns7217var flexColumns = []; //array of flexible width columns7218var fixedShrinkColumns = []; //array of fixed width columns that can shrink7219var flexShrinkUnits = 0; //total number of widthShrink blocks across all columns7220var overflowWidth = 0; //horizontal overflow width7221var gapFill = 0; //number of pixels to be added to final column to close and half pixel gaps72227223function calcWidth(width){7224var colWidth;72257226if(typeof(width) == "string"){7227if(width.indexOf("%") > -1){7228colWidth = (totalWidth / 100) * parseInt(width);7229}else {7230colWidth = parseInt(width);7231}7232}else {7233colWidth = width;7234}72357236return colWidth;7237}72387239//ensure columns resize to take up the correct amount of space7240function scaleColumns(columns, freeSpace, colWidth, shrinkCols){7241var oversizeCols = [],7242oversizeSpace = 0,7243remainingSpace = 0,7244nextColWidth = 0,7245remainingFlexGrowUnits = flexGrowUnits,7246gap = 0,7247changeUnits = 0,7248undersizeCols = [];72497250function calcGrow(col){7251return (colWidth * (col.column.definition.widthGrow || 1));7252}72537254function calcShrink(col){7255return (calcWidth(col.width) - (colWidth * (col.column.definition.widthShrink || 0)));7256}72577258columns.forEach(function(col, i){7259var width = shrinkCols ? calcShrink(col) : calcGrow(col);7260if(col.column.minWidth >= width){7261oversizeCols.push(col);7262}else {7263if(col.column.maxWidth && col.column.maxWidth < width){7264col.width = col.column.maxWidth;7265freeSpace -= col.column.maxWidth;72667267remainingFlexGrowUnits -= shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);72687269if(remainingFlexGrowUnits){7270colWidth = Math.floor(freeSpace/remainingFlexGrowUnits);7271}7272}else {7273undersizeCols.push(col);7274changeUnits += shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);7275}7276}7277});72787279if(oversizeCols.length){7280oversizeCols.forEach(function(col){7281oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;7282col.width = col.column.minWidth;7283});72847285remainingSpace = freeSpace - oversizeSpace;72867287nextColWidth = changeUnits ? Math.floor(remainingSpace/changeUnits) : remainingSpace;72887289gap = scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);7290}else {7291gap = changeUnits ? freeSpace - (Math.floor(freeSpace/changeUnits) * changeUnits) : freeSpace;72927293undersizeCols.forEach(function(column){7294column.width = shrinkCols ? calcShrink(column) : calcGrow(column);7295});7296}72977298return gap;7299}73007301if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){7302this.table.modules.responsiveLayout.update();7303}73047305//adjust for vertical scrollbar if present7306if(this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight){7307totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;7308}73097310columns.forEach(function(column){7311var width, minWidth, colWidth;73127313if(column.visible){73147315width = column.definition.width;7316minWidth = parseInt(column.minWidth);73177318if(width){73197320colWidth = calcWidth(width);73217322fixedWidth += colWidth > minWidth ? colWidth : minWidth;73237324if(column.definition.widthShrink){7325fixedShrinkColumns.push({7326column:column,7327width:colWidth > minWidth ? colWidth : minWidth7328});7329flexShrinkUnits += column.definition.widthShrink;7330}73317332}else {7333flexColumns.push({7334column:column,7335width:0,7336});7337flexGrowUnits += column.definition.widthGrow || 1;7338}7339}7340});73417342//calculate available space7343flexWidth = totalWidth - fixedWidth;73447345//calculate correct column size7346flexColWidth = Math.floor(flexWidth / flexGrowUnits);73477348//generate column widths7349gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false);73507351//increase width of last column to account for rounding errors7352if(flexColumns.length && gapFill > 0){7353flexColumns[flexColumns.length-1].width += gapFill;7354}73557356//calculate space for columns to be shrunk into7357flexColumns.forEach(function(col){7358flexWidth -= col.width;7359});73607361overflowWidth = Math.abs(gapFill) + flexWidth;73627363//shrink oversize columns if there is no available space7364if(overflowWidth > 0 && flexShrinkUnits){7365gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true);7366}73677368//decrease width of last column to account for rounding errors7369if(gapFill && fixedShrinkColumns.length){7370fixedShrinkColumns[fixedShrinkColumns.length-1].width -= gapFill;7371}73727373flexColumns.forEach(function(col){7374col.column.setWidth(col.width);7375});73767377fixedShrinkColumns.forEach(function(col){7378col.column.setWidth(col.width);7379});7380}73817382var defaultModes = {7383fitData:fitData,7384fitDataFill:fitDataGeneral,7385fitDataTable:fitDataGeneral,7386fitDataStretch:fitDataStretch,7387fitColumns:fitColumns ,7388};73897390class Layout extends Module{73917392constructor(table){7393super(table, "layout");73947395this.mode = null;73967397this.registerTableOption("layout", "fitData"); //layout type7398this.registerTableOption("layoutColumnsOnNewData", false); //update column widths on setData73997400this.registerColumnOption("widthGrow");7401this.registerColumnOption("widthShrink");7402}74037404//initialize layout system7405initialize(){7406var layout = this.table.options.layout;74077408if(Layout.modes[layout]){7409this.mode = layout;7410}else {7411console.warn("Layout Error - invalid mode set, defaulting to 'fitData' : " + layout);7412this.mode = 'fitData';7413}74147415this.table.element.setAttribute("tabulator-layout", this.mode);7416this.subscribe("column-init", this.initializeColumn.bind(this));7417}74187419initializeColumn(column){7420if(column.definition.widthGrow){7421column.definition.widthGrow = Number(column.definition.widthGrow);7422}7423if(column.definition.widthShrink){7424column.definition.widthShrink = Number(column.definition.widthShrink);7425}7426}74277428getMode(){7429return this.mode;7430}74317432//trigger table layout7433layout(dataChanged){7434this.dispatch("layout-refreshing");7435Layout.modes[this.mode].call(this, this.table.columnManager.columnsByIndex, dataChanged);7436this.dispatch("layout-refreshed");7437}7438}74397440Layout.moduleName = "layout";74417442//load defaults7443Layout.modes = defaultModes;74447445var defaultLangs = {7446"default":{ //hold default locale text7447"groups":{7448"item":"item",7449"items":"items",7450},7451"columns":{7452},7453"data":{7454"loading":"Loading",7455"error":"Error",7456},7457"pagination":{7458"page_size":"Page Size",7459"page_title":"Show Page",7460"first":"First",7461"first_title":"First Page",7462"last":"Last",7463"last_title":"Last Page",7464"prev":"Prev",7465"prev_title":"Prev Page",7466"next":"Next",7467"next_title":"Next Page",7468"all":"All",7469"counter":{7470"showing": "Showing",7471"of": "of",7472"rows": "rows",7473"pages": "pages",7474}7475},7476"headerFilters":{7477"default":"filter column...",7478"columns":{}7479}7480},7481};74827483class Localize extends Module{74847485constructor(table){7486super(table);74877488this.locale = "default"; //current locale7489this.lang = false; //current language7490this.bindings = {}; //update events to call when locale is changed7491this.langList = {};74927493this.registerTableOption("locale", false); //current system language7494this.registerTableOption("langs", {});7495}74967497initialize(){7498this.langList = Helpers.deepClone(Localize.langs);74997500if(this.table.options.columnDefaults.headerFilterPlaceholder !== false){7501this.setHeaderFilterPlaceholder(this.table.options.columnDefaults.headerFilterPlaceholder);7502}75037504for(let locale in this.table.options.langs){7505this.installLang(locale, this.table.options.langs[locale]);7506}75077508this.setLocale(this.table.options.locale);75097510this.registerTableFunction("setLocale", this.setLocale.bind(this));7511this.registerTableFunction("getLocale", this.getLocale.bind(this));7512this.registerTableFunction("getLang", this.getLang.bind(this));7513}75147515//set header placeholder7516setHeaderFilterPlaceholder(placeholder){7517this.langList.default.headerFilters.default = placeholder;7518}75197520//setup a lang description object7521installLang(locale, lang){7522if(this.langList[locale]){7523this._setLangProp(this.langList[locale], lang);7524}else {7525this.langList[locale] = lang;7526}7527}75287529_setLangProp(lang, values){7530for(let key in values){7531if(lang[key] && typeof lang[key] == "object"){7532this._setLangProp(lang[key], values[key]);7533}else {7534lang[key] = values[key];7535}7536}7537}75387539//set current locale7540setLocale(desiredLocale){7541desiredLocale = desiredLocale || "default";75427543//fill in any matching language values7544function traverseLang(trans, path){7545for(var prop in trans){7546if(typeof trans[prop] == "object"){7547if(!path[prop]){7548path[prop] = {};7549}7550traverseLang(trans[prop], path[prop]);7551}else {7552path[prop] = trans[prop];7553}7554}7555}75567557//determining correct locale to load7558if(desiredLocale === true && navigator.language){7559//get local from system7560desiredLocale = navigator.language.toLowerCase();7561}75627563if(desiredLocale){7564//if locale is not set, check for matching top level locale else use default7565if(!this.langList[desiredLocale]){7566let prefix = desiredLocale.split("-")[0];75677568if(this.langList[prefix]){7569console.warn("Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix);7570desiredLocale = prefix;7571}else {7572console.warn("Localization Error - Matching locale not found, using default: ", desiredLocale);7573desiredLocale = "default";7574}7575}7576}75777578this.locale = desiredLocale;75797580//load default lang template7581this.lang = Helpers.deepClone(this.langList.default || {});75827583if(desiredLocale != "default"){7584traverseLang(this.langList[desiredLocale], this.lang);7585}75867587this.dispatchExternal("localized", this.locale, this.lang);75887589this._executeBindings();7590}75917592//get current locale7593getLocale(locale){7594return this.locale;7595}75967597//get lang object for given local or current if none provided7598getLang(locale){7599return locale ? this.langList[locale] : this.lang;7600}76017602//get text for current locale7603getText(path, value){7604var fillPath = value ? path + "|" + value : path,7605pathArray = fillPath.split("|"),7606text = this._getLangElement(pathArray, this.locale);76077608// if(text === false){7609// console.warn("Localization Error - Matching localized text not found for given path: ", path);7610// }76117612return text || "";7613}76147615//traverse langs object and find localized copy7616_getLangElement(path, locale){7617var root = this.lang;76187619path.forEach(function(level){7620var rootPath;76217622if(root){7623rootPath = root[level];76247625if(typeof rootPath != "undefined"){7626root = rootPath;7627}else {7628root = false;7629}7630}7631});76327633return root;7634}76357636//set update binding7637bind(path, callback){7638if(!this.bindings[path]){7639this.bindings[path] = [];7640}76417642this.bindings[path].push(callback);76437644callback(this.getText(path), this.lang);7645}76467647//iterate through bindings and trigger updates7648_executeBindings(){7649for(let path in this.bindings){7650this.bindings[path].forEach((binding) => {7651binding(this.getText(path), this.lang);7652});7653}7654}7655}76567657Localize.moduleName = "localize";76587659//load defaults7660Localize.langs = defaultLangs;76617662class Comms extends Module{76637664constructor(table){7665super(table);7666}76677668initialize(){7669this.registerTableFunction("tableComms", this.receive.bind(this));7670}76717672getConnections(selectors){7673var connections = [],7674connection;76757676connection = TableRegistry.lookupTable(selectors);76777678connection.forEach((con) =>{7679if(this.table !== con){7680connections.push(con);7681}7682});76837684return connections;7685}76867687send(selectors, module, action, data){7688var connections = this.getConnections(selectors);76897690connections.forEach((connection) => {7691connection.tableComms(this.table.element, module, action, data);7692});76937694if(!connections.length && selectors){7695console.warn("Table Connection Error - No tables matching selector found", selectors);7696}7697}76987699receive(table, module, action, data){7700if(this.table.modExists(module)){7701return this.table.modules[module].commsReceived(table, action, data);7702}else {7703console.warn("Inter-table Comms Error - no such module:", module);7704}7705}7706}77077708Comms.moduleName = "comms";77097710var coreModules = /*#__PURE__*/Object.freeze({7711__proto__: null,7712LayoutModule: Layout,7713LocalizeModule: Localize,7714CommsModule: Comms7715});77167717class ModuleBinder {77187719constructor(tabulator, modules){7720this.bindStaticFunctionality(tabulator);7721this.bindModules(tabulator, coreModules, true);77227723if(modules){7724this.bindModules(tabulator, modules);7725}7726}77277728bindStaticFunctionality(tabulator){7729tabulator.moduleBindings = {};77307731tabulator.extendModule = function(name, property, values){7732if(tabulator.moduleBindings[name]){7733var source = tabulator.moduleBindings[name][property];77347735if(source){7736if(typeof values == "object"){7737for(let key in values){7738source[key] = values[key];7739}7740}else {7741console.warn("Module Error - Invalid value type, it must be an object");7742}7743}else {7744console.warn("Module Error - property does not exist:", property);7745}7746}else {7747console.warn("Module Error - module does not exist:", name);7748}7749};77507751tabulator.registerModule = function(modules){7752if(!Array.isArray(modules)){7753modules = [modules];7754}77557756modules.forEach((mod) => {7757tabulator.registerModuleBinding(mod);7758});7759};77607761tabulator.registerModuleBinding = function(mod){7762tabulator.moduleBindings[mod.moduleName] = mod;7763};77647765tabulator.findTable = function(query){7766var results = TableRegistry.lookupTable(query, true);7767return Array.isArray(results) && !results.length ? false : results;7768};77697770//ensure that module are bound to instantiated function7771tabulator.prototype.bindModules = function(){7772var orderedStartMods = [],7773orderedEndMods = [],7774unOrderedMods = [];77757776this.modules = {};77777778for(var name in tabulator.moduleBindings){7779let mod = tabulator.moduleBindings[name];7780let module = new mod(this);77817782this.modules[name] = module;77837784if(mod.prototype.moduleCore){7785this.modulesCore.push(module);7786}else {7787if(mod.moduleInitOrder){7788if(mod.moduleInitOrder < 0){7789orderedStartMods.push(module);7790}else {7791orderedEndMods.push(module);7792}77937794}else {7795unOrderedMods.push(module);7796}7797}7798}77997800orderedStartMods.sort((a, b) => a.moduleInitOrder > b.moduleInitOrder ? 1 : -1);7801orderedEndMods.sort((a, b) => a.moduleInitOrder > b.moduleInitOrder ? 1 : -1);78027803this.modulesRegular = orderedStartMods.concat(unOrderedMods.concat(orderedEndMods));7804};7805}78067807bindModules(tabulator, modules, core){7808var mods = Object.values(modules);78097810if(core){7811mods.forEach((mod) => {7812mod.prototype.moduleCore = true;7813});7814}78157816tabulator.registerModule(mods);7817}7818}78197820class Alert extends CoreFeature{7821constructor(table){7822super(table);78237824this.element = this._createAlertElement();7825this.msgElement = this._createMsgElement();7826this.type = null;78277828this.element.appendChild(this.msgElement);7829}78307831_createAlertElement(){7832var el = document.createElement("div");7833el.classList.add("tabulator-alert");7834return el;7835}78367837_createMsgElement(){7838var el = document.createElement("div");7839el.classList.add("tabulator-alert-msg");7840el.setAttribute("role", "alert");7841return el;7842}78437844_typeClass(){7845return "tabulator-alert-state-" + this.type;7846}78477848alert(content, type = "msg"){7849if(content){7850this.clear();78517852this.type = type;78537854while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);78557856this.msgElement.classList.add(this._typeClass());78577858if(typeof content === "function"){7859content = content();7860}78617862if(content instanceof HTMLElement){7863this.msgElement.appendChild(content);7864}else {7865this.msgElement.innerHTML = content;7866}78677868this.table.element.appendChild(this.element);7869}7870}78717872clear(){7873if(this.element.parentNode){7874this.element.parentNode.removeChild(this.element);7875}78767877this.msgElement.classList.remove(this._typeClass());7878}7879}78807881class Tabulator {78827883constructor(element, options){78847885this.options = {};78867887this.columnManager = null; // hold Column Manager7888this.rowManager = null; //hold Row Manager7889this.footerManager = null; //holder Footer Manager7890this.alertManager = null; //hold Alert Manager7891this.vdomHoz = null; //holder horizontal virtual dom7892this.externalEvents = null; //handle external event messaging7893this.eventBus = null; //handle internal event messaging7894this.interactionMonitor = false; //track user interaction7895this.browser = ""; //hold current browser type7896this.browserSlow = false; //handle reduced functionality for slower browsers7897this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance7898this.rtl = false; //check if the table is in RTL mode7899this.originalElement = null; //hold original table element if it has been replaced79007901this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions7902this.dataLoader = false; //bind component functions79037904this.modules = {}; //hold all modules bound to this table7905this.modulesCore = []; //hold core modules bound to this table (for initialization purposes)7906this.modulesRegular = []; //hold regular modules bound to this table (for initialization purposes)79077908this.deprecationAdvisor = new DeprecationAdvisor(this);7909this.optionsList = new OptionsList(this, "table constructor");79107911this.initialized = false;7912this.destroyed = false;79137914if(this.initializeElement(element)){79157916this.initializeCoreSystems(options);79177918//delay table creation to allow event bindings immediately after the constructor7919setTimeout(() => {7920this._create();7921});7922}79237924TableRegistry.register(this); //register table for inter-device communication7925}79267927initializeElement(element){7928if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){7929this.element = element;7930return true;7931}else if(typeof element === "string"){7932this.element = document.querySelector(element);79337934if(this.element){7935return true;7936}else {7937console.error("Tabulator Creation Error - no element found matching selector: ", element);7938return false;7939}7940}else {7941console.error("Tabulator Creation Error - Invalid element provided:", element);7942return false;7943}7944}79457946initializeCoreSystems(options){7947this.columnManager = new ColumnManager(this);7948this.rowManager = new RowManager(this);7949this.footerManager = new FooterManager(this);7950this.dataLoader = new DataLoader(this);7951this.alertManager = new Alert(this);79527953this.bindModules();79547955this.options = this.optionsList.generate(Tabulator.defaultOptions, options);79567957this._clearObjectPointers();79587959this._mapDeprecatedFunctionality();79607961this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);7962this.eventBus = new InternalEventBus(this.options.debugEventsInternal);79637964this.interactionMonitor = new InteractionManager(this);79657966this.dataLoader.initialize();7967// this.columnManager.initialize();7968// this.rowManager.initialize();7969this.footerManager.initialize();7970}79717972//convert deprecated functionality to new functions7973_mapDeprecatedFunctionality(){7974//all previously deprecated functionality removed in the 5.0 release7975}79767977_clearSelection(){79787979this.element.classList.add("tabulator-block-select");79807981if (window.getSelection) {7982if (window.getSelection().empty) { // Chrome7983window.getSelection().empty();7984} else if (window.getSelection().removeAllRanges) { // Firefox7985window.getSelection().removeAllRanges();7986}7987} else if (document.selection) { // IE?7988document.selection.empty();7989}79907991this.element.classList.remove("tabulator-block-select");7992}79937994//create table7995_create(){7996this.externalEvents.dispatch("tableBuilding");7997this.eventBus.dispatch("table-building");79987999this._rtlCheck();80008001this._buildElement();80028003this._initializeTable();80048005this._loadInitialData();80068007this.initialized = true;80088009this.externalEvents.dispatch("tableBuilt");8010}80118012_rtlCheck(){8013var style = window.getComputedStyle(this.element);80148015switch(this.options.textDirection){8016case"auto":8017if(style.direction !== "rtl"){8018break;8019}80208021case "rtl":8022this.element.classList.add("tabulator-rtl");8023this.rtl = true;8024break;80258026case "ltr":8027this.element.classList.add("tabulator-ltr");80288029default:8030this.rtl = false;8031}8032}80338034//clear pointers to objects in default config object8035_clearObjectPointers(){8036this.options.columns = this.options.columns.slice(0);80378038if(Array.isArray(this.options.data) && !this.options.reactiveData){8039this.options.data = this.options.data.slice(0);8040}8041}80428043//build tabulator element8044_buildElement(){8045var element = this.element,8046options = this.options,8047newElement;80488049if(element.tagName === "TABLE"){8050this.originalElement = this.element;8051newElement = document.createElement("div");80528053//transfer attributes to new element8054var attributes = element.attributes;80558056// loop through attributes and apply them on div8057for(var i in attributes){8058if(typeof attributes[i] == "object"){8059newElement.setAttribute(attributes[i].name, attributes[i].value);8060}8061}80628063// replace table with div element8064element.parentNode.replaceChild(newElement, element);80658066this.element = element = newElement;8067}80688069element.classList.add("tabulator");8070element.setAttribute("role", "grid");80718072//empty element8073while(element.firstChild) element.removeChild(element.firstChild);80748075//set table height8076if(options.height){8077options.height = isNaN(options.height) ? options.height : options.height + "px";8078element.style.height = options.height;8079}80808081//set table min height8082if(options.minHeight !== false){8083options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px";8084element.style.minHeight = options.minHeight;8085}80868087//set table maxHeight8088if(options.maxHeight !== false){8089options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";8090element.style.maxHeight = options.maxHeight;8091}8092}80938094//initialize core systems and modules8095_initializeTable(){8096var element = this.element,8097options = this.options;80988099this.interactionMonitor.initialize();81008101this.columnManager.initialize();8102this.rowManager.initialize();81038104this._detectBrowser();81058106//initialize core modules8107this.modulesCore.forEach((mod) => {8108mod.initialize();8109});81108111//build table elements8112element.appendChild(this.columnManager.getElement());8113element.appendChild(this.rowManager.getElement());81148115if(options.footerElement){8116this.footerManager.activate();8117}81188119if(options.autoColumns && options.data){81208121this.columnManager.generateColumnsFromRowData(this.options.data);8122}81238124//initialize regular modules8125this.modulesRegular.forEach((mod) => {8126mod.initialize();8127});81288129this.columnManager.setColumns(options.columns);81308131this.eventBus.dispatch("table-built");8132}81338134_loadInitialData(){8135this.dataLoader.load(this.options.data);8136}81378138//deconstructor8139destroy(){8140var element = this.element;81418142this.destroyed = true;81438144TableRegistry.deregister(this); //deregister table from inter-device communication81458146this.eventBus.dispatch("table-destroy");81478148//clear row data8149this.rowManager.destroy();81508151//clear DOM8152while(element.firstChild) element.removeChild(element.firstChild);8153element.classList.remove("tabulator");81548155this.externalEvents.dispatch("tableDestroyed");8156}81578158_detectBrowser(){8159var ua = navigator.userAgent||navigator.vendor||window.opera;81608161if(ua.indexOf("Trident") > -1){8162this.browser = "ie";8163this.browserSlow = true;8164}else if(ua.indexOf("Edge") > -1){8165this.browser = "edge";8166this.browserSlow = true;8167}else if(ua.indexOf("Firefox") > -1){8168this.browser = "firefox";8169this.browserSlow = false;8170}else if(ua.indexOf("Mac OS") > -1){8171this.browser = "safari";8172this.browserSlow = false;8173}else {8174this.browser = "other";8175this.browserSlow = false;8176}81778178this.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.slice(0,4));8179}81808181initGuard(func, msg){8182var stack, line;81838184if(this.options.debugInitialization && !this.initialized){8185if(!func){8186stack = new Error().stack.split("\n");81878188line = stack[0] == "Error" ? stack[2] : stack[1];81898190if(line[0] == " "){8191func = line.trim().split(" ")[1].split(".")[1];8192}else {8193func = line.trim().split("@")[0];8194}8195}81968197console.warn("Table Not Initialized - Calling the " + func + " function before the table is initialized may result in inconsistent behavior, Please wait for the `tableBuilt` event before calling this function." + (msg ? " " + msg : ""));8198}81998200return this.initialized;8201}82028203////////////////// Data Handling //////////////////8204//block table redrawing8205blockRedraw(){8206this.initGuard();82078208this.eventBus.dispatch("redraw-blocking");82098210this.rowManager.blockRedraw();8211this.columnManager.blockRedraw();82128213this.eventBus.dispatch("redraw-blocked");8214}82158216//restore table redrawing8217restoreRedraw(){8218this.initGuard();82198220this.eventBus.dispatch("redraw-restoring");82218222this.rowManager.restoreRedraw();8223this.columnManager.restoreRedraw();82248225this.eventBus.dispatch("redraw-restored");8226}82278228//load data8229setData(data, params, config){8230this.initGuard(false, "To set initial data please use the 'data' property in the table constructor.");82318232return this.dataLoader.load(data, params, config, false);8233}82348235//clear data8236clearData(){8237this.initGuard();82388239this.dataLoader.blockActiveLoad();8240this.rowManager.clearData();8241}82428243//get table data array8244getData(active){8245return this.rowManager.getData(active);8246}82478248//get table data array count8249getDataCount(active){8250return this.rowManager.getDataCount(active);8251}82528253//replace data, keeping table in position with same sort8254replaceData(data, params, config){8255this.initGuard();82568257return this.dataLoader.load(data, params, config, true, true);8258}82598260//update table data8261updateData(data){8262var responses = 0;82638264this.initGuard();82658266return new Promise((resolve, reject) => {8267this.dataLoader.blockActiveLoad();82688269if(typeof data === "string"){8270data = JSON.parse(data);8271}82728273if(data && data.length > 0){8274data.forEach((item) => {8275var row = this.rowManager.findRow(item[this.options.index]);82768277if(row){8278responses++;82798280row.updateData(item)8281.then(()=>{8282responses--;82838284if(!responses){8285resolve();8286}8287})8288.catch((e) => {8289reject("Update Error - Unable to update row", item, e);8290});8291}else {8292reject("Update Error - Unable to find row", item);8293}8294});8295}else {8296console.warn("Update Error - No data provided");8297reject("Update Error - No data provided");8298}8299});8300}83018302addData(data, pos, index){8303this.initGuard();83048305return new Promise((resolve, reject) => {8306this.dataLoader.blockActiveLoad();83078308if(typeof data === "string"){8309data = JSON.parse(data);8310}83118312if(data){8313this.rowManager.addRows(data, pos, index)8314.then((rows) => {8315var output = [];83168317rows.forEach(function(row){8318output.push(row.getComponent());8319});83208321resolve(output);8322});8323}else {8324console.warn("Update Error - No data provided");8325reject("Update Error - No data provided");8326}8327});8328}83298330//update table data8331updateOrAddData(data){8332var rows = [],8333responses = 0;83348335this.initGuard();83368337return new Promise((resolve, reject) => {8338this.dataLoader.blockActiveLoad();83398340if(typeof data === "string"){8341data = JSON.parse(data);8342}83438344if(data && data.length > 0){8345data.forEach((item) => {8346var row = this.rowManager.findRow(item[this.options.index]);83478348responses++;83498350if(row){8351row.updateData(item)8352.then(()=>{8353responses--;8354rows.push(row.getComponent());83558356if(!responses){8357resolve(rows);8358}8359});8360}else {8361this.rowManager.addRows(item)8362.then((newRows)=>{8363responses--;8364rows.push(newRows[0].getComponent());83658366if(!responses){8367resolve(rows);8368}8369});8370}8371});8372}else {8373console.warn("Update Error - No data provided");8374reject("Update Error - No data provided");8375}8376});8377}83788379//get row object8380getRow(index){8381var row = this.rowManager.findRow(index);83828383if(row){8384return row.getComponent();8385}else {8386console.warn("Find Error - No matching row found:", index);8387return false;8388}8389}83908391//get row object8392getRowFromPosition(position){8393var row = this.rowManager.getRowFromPosition(position);83948395if(row){8396return row.getComponent();8397}else {8398console.warn("Find Error - No matching row found:", position);8399return false;8400}8401}84028403//delete row from table8404deleteRow(index){8405var foundRows = [];84068407this.initGuard();84088409if(!Array.isArray(index)){8410index = [index];8411}84128413//find matching rows8414for(let item of index){8415let row = this.rowManager.findRow(item, true);84168417if(row){8418foundRows.push(row);8419}else {8420console.error("Delete Error - No matching row found:", item);8421return Promise.reject("Delete Error - No matching row found");8422}8423}84248425//sort rows into correct order to ensure smooth delete from table8426foundRows.sort((a, b) => {8427return this.rowManager.rows.indexOf(a) > this.rowManager.rows.indexOf(b) ? 1 : -1;8428});84298430//delete rows8431foundRows.forEach((row) =>{8432row.delete();8433});84348435this.rowManager.reRenderInPosition();84368437return Promise.resolve();8438}84398440//add row to table8441addRow(data, pos, index){8442this.initGuard();84438444if(typeof data === "string"){8445data = JSON.parse(data);8446}84478448return this.rowManager.addRows(data, pos, index, true)8449.then((rows)=>{8450return rows[0].getComponent();8451});8452}84538454//update a row if it exists otherwise create it8455updateOrAddRow(index, data){8456var row = this.rowManager.findRow(index);84578458this.initGuard();84598460if(typeof data === "string"){8461data = JSON.parse(data);8462}84638464if(row){8465return row.updateData(data)8466.then(()=>{8467return row.getComponent();8468});8469}else {8470return this.rowManager.addRows(data)8471.then((rows)=>{8472return rows[0].getComponent();8473});8474}8475}84768477//update row data8478updateRow(index, data){8479var row = this.rowManager.findRow(index);84808481this.initGuard();84828483if(typeof data === "string"){8484data = JSON.parse(data);8485}84868487if(row){8488return row.updateData(data)8489.then(()=>{8490return Promise.resolve(row.getComponent());8491});8492}else {8493console.warn("Update Error - No matching row found:", index);8494return Promise.reject("Update Error - No matching row found");8495}8496}84978498//scroll to row in DOM8499scrollToRow(index, position, ifVisible){8500var row = this.rowManager.findRow(index);85018502if(row){8503return this.rowManager.scrollToRow(row, position, ifVisible);8504}else {8505console.warn("Scroll Error - No matching row found:", index);8506return Promise.reject("Scroll Error - No matching row found");8507}8508}85098510moveRow(from, to, after){8511var fromRow = this.rowManager.findRow(from);85128513this.initGuard();85148515if(fromRow){8516fromRow.moveToRow(to, after);8517}else {8518console.warn("Move Error - No matching row found:", from);8519}8520}85218522getRows(active){8523return this.rowManager.getComponents(active);8524}85258526//get position of row in table8527getRowPosition(index){8528var row = this.rowManager.findRow(index);85298530if(row){8531return row.getPosition();8532}else {8533console.warn("Position Error - No matching row found:", index);8534return false;8535}8536}85378538/////////////// Column Functions ///////////////8539setColumns(definition){8540this.initGuard(false, "To set initial columns please use the 'columns' property in the table constructor");85418542this.columnManager.setColumns(definition);8543}85448545getColumns(structured){8546return this.columnManager.getComponents(structured);8547}85488549getColumn(field){8550var column = this.columnManager.findColumn(field);85518552if(column){8553return column.getComponent();8554}else {8555console.warn("Find Error - No matching column found:", field);8556return false;8557}8558}85598560getColumnDefinitions(){8561return this.columnManager.getDefinitionTree();8562}85638564showColumn(field){8565var column = this.columnManager.findColumn(field);85668567this.initGuard();85688569if(column){8570column.show();8571}else {8572console.warn("Column Show Error - No matching column found:", field);8573return false;8574}8575}85768577hideColumn(field){8578var column = this.columnManager.findColumn(field);85798580this.initGuard();85818582if(column){8583column.hide();8584}else {8585console.warn("Column Hide Error - No matching column found:", field);8586return false;8587}8588}85898590toggleColumn(field){8591var column = this.columnManager.findColumn(field);85928593this.initGuard();85948595if(column){8596if(column.visible){8597column.hide();8598}else {8599column.show();8600}8601}else {8602console.warn("Column Visibility Toggle Error - No matching column found:", field);8603return false;8604}8605}86068607addColumn(definition, before, field){8608var column = this.columnManager.findColumn(field);86098610this.initGuard();86118612return this.columnManager.addColumn(definition, before, column)8613.then((column) => {8614return column.getComponent();8615});8616}86178618deleteColumn(field){8619var column = this.columnManager.findColumn(field);86208621this.initGuard();86228623if(column){8624return column.delete();8625}else {8626console.warn("Column Delete Error - No matching column found:", field);8627return Promise.reject();8628}8629}86308631updateColumnDefinition(field, definition){8632var column = this.columnManager.findColumn(field);86338634this.initGuard();86358636if(column){8637return column.updateDefinition(definition);8638}else {8639console.warn("Column Update Error - No matching column found:", field);8640return Promise.reject();8641}8642}86438644moveColumn(from, to, after){8645var fromColumn = this.columnManager.findColumn(from),8646toColumn = this.columnManager.findColumn(to);86478648this.initGuard();86498650if(fromColumn){8651if(toColumn){8652this.columnManager.moveColumn(fromColumn, toColumn, after);8653}else {8654console.warn("Move Error - No matching column found:", toColumn);8655}8656}else {8657console.warn("Move Error - No matching column found:", from);8658}8659}86608661//scroll to column in DOM8662scrollToColumn(field, position, ifVisible){8663return new Promise((resolve, reject) => {8664var column = this.columnManager.findColumn(field);86658666if(column){8667return this.columnManager.scrollToColumn(column, position, ifVisible);8668}else {8669console.warn("Scroll Error - No matching column found:", field);8670return Promise.reject("Scroll Error - No matching column found");8671}8672});8673}86748675//////////// General Public Functions ////////////8676//redraw list without updating data8677redraw(force){8678this.initGuard();86798680this.columnManager.redraw(force);8681this.rowManager.redraw(force);8682}86838684setHeight(height){8685this.options.height = isNaN(height) ? height : height + "px";8686this.element.style.height = this.options.height;8687this.rowManager.initializeRenderer();8688this.rowManager.redraw();8689}86908691//////////////////// Event Bus ///////////////////86928693on(key, callback){8694this.externalEvents.subscribe(key, callback);8695}86968697off(key, callback){8698this.externalEvents.unsubscribe(key, callback);8699}87008701dispatchEvent(){8702var args = Array.from(arguments);8703args.shift();87048705this.externalEvents.dispatch(...arguments);8706}87078708//////////////////// Alerts ///////////////////87098710alert(contents, type){8711this.initGuard();87128713this.alertManager.alert(contents, type);8714}87158716clearAlert(){8717this.initGuard();87188719this.alertManager.clear();8720}87218722////////////// Extension Management //////////////8723modExists(plugin, required){8724if(this.modules[plugin]){8725return true;8726}else {8727if(required){8728console.error("Tabulator Module Not Installed: " + plugin);8729}8730return false;8731}8732}87338734module(key){8735var mod = this.modules[key];87368737if(!mod){8738console.error("Tabulator module not installed: " + key);8739}87408741return mod;8742}8743}87448745//default setup options8746Tabulator.defaultOptions = defaultOptions;87478748//bind modules and static functionality8749new ModuleBinder(Tabulator);87508751var defaultAccessors = {};87528753class Accessor extends Module{87548755constructor(table){8756super(table);87578758this.allowedTypes = ["", "data", "download", "clipboard", "print", "htmlOutput"]; //list of accessor types87598760this.registerColumnOption("accessor");8761this.registerColumnOption("accessorParams");8762this.registerColumnOption("accessorData");8763this.registerColumnOption("accessorDataParams");8764this.registerColumnOption("accessorDownload");8765this.registerColumnOption("accessorDownloadParams");8766this.registerColumnOption("accessorClipboard");8767this.registerColumnOption("accessorClipboardParams");8768this.registerColumnOption("accessorPrint");8769this.registerColumnOption("accessorPrintParams");8770this.registerColumnOption("accessorHtmlOutput");8771this.registerColumnOption("accessorHtmlOutputParams");8772}87738774initialize(){8775this.subscribe("column-layout", this.initializeColumn.bind(this));8776this.subscribe("row-data-retrieve", this.transformRow.bind(this));8777}87788779//initialize column accessor8780initializeColumn(column){8781var match = false,8782config = {};87838784this.allowedTypes.forEach((type) => {8785var key = "accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),8786accessor;87878788if(column.definition[key]){8789accessor = this.lookupAccessor(column.definition[key]);87908791if(accessor){8792match = true;87938794config[key] = {8795accessor:accessor,8796params: column.definition[key + "Params"] || {},8797};8798}8799}8800});88018802if(match){8803column.modules.accessor = config;8804}8805}88068807lookupAccessor(value){8808var accessor = false;88098810//set column accessor8811switch(typeof value){8812case "string":8813if(Accessor.accessors[value]){8814accessor = Accessor.accessors[value];8815}else {8816console.warn("Accessor Error - No such accessor found, ignoring: ", value);8817}8818break;88198820case "function":8821accessor = value;8822break;8823}88248825return accessor;8826}88278828//apply accessor to row8829transformRow(row, type){8830var key = "accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),8831rowComponent = row.getComponent();88328833//clone data object with deep copy to isolate internal data from returned result8834var data = Helpers.deepClone(row.data || {});88358836this.table.columnManager.traverse(function(column){8837var value, accessor, params, colComponent;88388839if(column.modules.accessor){88408841accessor = column.modules.accessor[key] || column.modules.accessor.accessor || false;88428843if(accessor){8844value = column.getFieldValue(data);88458846if(value != "undefined"){8847colComponent = column.getComponent();8848params = typeof accessor.params === "function" ? accessor.params(value, data, type, colComponent, rowComponent) : accessor.params;8849column.setFieldValue(data, accessor.accessor(value, data, type, params, colComponent, rowComponent));8850}8851}8852}8853});88548855return data;8856}8857}88588859//load defaults8860Accessor.moduleName = "accessor";8861Accessor.accessors = defaultAccessors;88628863var defaultConfig = {8864method: "GET",8865};88668867function generateParamsList(data, prefix){8868var output = [];88698870prefix = prefix || "";88718872if(Array.isArray(data)){8873data.forEach((item, i) => {8874output = output.concat(generateParamsList(item, prefix ? prefix + "[" + i + "]" : i));8875});8876}else if (typeof data === "object"){8877for (var key in data){8878output = output.concat(generateParamsList(data[key], prefix ? prefix + "[" + key + "]" : key));8879}8880}else {8881output.push({key:prefix, value:data});8882}88838884return output;8885}88868887function serializeParams(params){8888var output = generateParamsList(params),8889encoded = [];88908891output.forEach(function(item){8892encoded.push(encodeURIComponent(item.key) + "=" + encodeURIComponent(item.value));8893});88948895return encoded.join("&");8896}88978898function urlBuilder(url, config, params){8899if(url){8900if(params && Object.keys(params).length){8901if(!config.method || config.method.toLowerCase() == "get"){8902config.method = "get";89038904url += (url.includes("?") ? "&" : "?") + serializeParams(params);8905}8906}8907}89088909return url;8910}89118912function defaultLoaderPromise(url, config, params){8913var contentType;89148915return new Promise((resolve, reject) => {8916//set url8917url = this.urlGenerator.call(this.table, url, config, params);89188919//set body content if not GET request8920if(config.method.toUpperCase() != "GET"){8921contentType = typeof this.table.options.ajaxContentType === "object" ? this.table.options.ajaxContentType : this.contentTypeFormatters[this.table.options.ajaxContentType];8922if(contentType){89238924for(var key in contentType.headers){8925if(!config.headers){8926config.headers = {};8927}89288929if(typeof config.headers[key] === "undefined"){8930config.headers[key] = contentType.headers[key];8931}8932}89338934config.body = contentType.body.call(this, url, config, params);89358936}else {8937console.warn("Ajax Error - Invalid ajaxContentType value:", this.table.options.ajaxContentType);8938}8939}89408941if(url){8942//configure headers8943if(typeof config.headers === "undefined"){8944config.headers = {};8945}89468947if(typeof config.headers.Accept === "undefined"){8948config.headers.Accept = "application/json";8949}89508951if(typeof config.headers["X-Requested-With"] === "undefined"){8952config.headers["X-Requested-With"] = "XMLHttpRequest";8953}89548955if(typeof config.mode === "undefined"){8956config.mode = "cors";8957}89588959if(config.mode == "cors"){8960if(typeof config.headers["Origin"] === "undefined"){8961config.headers["Origin"] = window.location.origin;8962}89638964if(typeof config.credentials === "undefined"){8965config.credentials = 'same-origin';8966}8967}else {8968if(typeof config.credentials === "undefined"){8969config.credentials = 'include';8970}8971}89728973//send request8974fetch(url, config)8975.then((response)=>{8976if(response.ok) {8977response.json()8978.then((data)=>{8979resolve(data);8980}).catch((error)=>{8981reject(error);8982console.warn("Ajax Load Error - Invalid JSON returned", error);8983});8984}else {8985console.error("Ajax Load Error - Connection Error: " + response.status, response.statusText);8986reject(response);8987}8988})8989.catch((error)=>{8990console.error("Ajax Load Error - Connection Error: ", error);8991reject(error);8992});8993}else {8994console.warn("Ajax Load Error - No URL Set");8995resolve([]);8996}8997});8998}89999000function generateParamsList$1(data, prefix){9001var output = [];90029003prefix = prefix || "";90049005if(Array.isArray(data)){9006data.forEach((item, i) => {9007output = output.concat(generateParamsList$1(item, prefix ? prefix + "[" + i + "]" : i));9008});9009}else if (typeof data === "object"){9010for (var key in data){9011output = output.concat(generateParamsList$1(data[key], prefix ? prefix + "[" + key + "]" : key));9012}9013}else {9014output.push({key:prefix, value:data});9015}90169017return output;9018}90199020var defaultContentTypeFormatters = {9021"json":{9022headers:{9023'Content-Type': 'application/json',9024},9025body:function(url, config, params){9026return JSON.stringify(params);9027},9028},9029"form":{9030headers:{9031},9032body:function(url, config, params){90339034var output = generateParamsList$1(params),9035form = new FormData();90369037output.forEach(function(item){9038form.append(item.key, item.value);9039});90409041return form;9042},9043},9044};90459046class Ajax extends Module{90479048constructor(table){9049super(table);90509051this.config = {}; //hold config object for ajax request9052this.url = ""; //request URL9053this.urlGenerator = false;9054this.params = false; //request parameters90559056this.loaderPromise = false;90579058this.registerTableOption("ajaxURL", false); //url for ajax loading9059this.registerTableOption("ajaxURLGenerator", false);9060this.registerTableOption("ajaxParams", {}); //params for ajax loading9061this.registerTableOption("ajaxConfig", "get"); //ajax request type9062this.registerTableOption("ajaxContentType", "form"); //ajax request type9063this.registerTableOption("ajaxRequestFunc", false); //promise function90649065this.registerTableOption("ajaxRequesting", function(){});9066this.registerTableOption("ajaxResponse", false);90679068this.contentTypeFormatters = Ajax.contentTypeFormatters;9069}90709071//initialize setup options9072initialize(){9073this.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise;9074this.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator;90759076if(this.table.options.ajaxURL){9077this.setUrl(this.table.options.ajaxURL);9078}907990809081this.setDefaultConfig(this.table.options.ajaxConfig);90829083this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this));90849085this.subscribe("data-loading", this.requestDataCheck.bind(this));9086this.subscribe("data-params", this.requestParams.bind(this));9087this.subscribe("data-load", this.requestData.bind(this));9088}90899090requestParams(data, config, silent, params){9091var ajaxParams = this.table.options.ajaxParams;90929093if(ajaxParams){9094if(typeof ajaxParams === "function"){9095ajaxParams = ajaxParams.call(this.table);9096}90979098params = Object.assign(params, ajaxParams);9099}91009101return params;9102}91039104requestDataCheck(data, params, config, silent){9105return !!((!data && this.url) || typeof data === "string");9106}91079108requestData(url, params, config, silent, previousData){9109var ajaxConfig;91109111if(!previousData && this.requestDataCheck(url)){9112if(url){9113this.setUrl(url);9114}91159116ajaxConfig = this.generateConfig(config);91179118return this.sendRequest(this.url, params, ajaxConfig);9119}else {9120return previousData;9121}9122}91239124setDefaultConfig(config = {}){9125this.config = Object.assign({}, Ajax.defaultConfig);91269127if(typeof config == "string"){9128this.config.method = config;9129}else {9130Object.assign(this.config, config);9131}9132}91339134//load config object9135generateConfig(config = {}){9136var ajaxConfig = Object.assign({}, this.config);91379138if(typeof config == "string"){9139ajaxConfig.method = config;9140}else {9141Object.assign(ajaxConfig, config);9142}91439144return ajaxConfig;9145}91469147//set request url9148setUrl(url){9149this.url = url;9150}91519152//get request url9153getUrl(){9154return this.url;9155}91569157//send ajax request9158sendRequest(url, params, config){9159if(this.table.options.ajaxRequesting.call(this.table, url, params) !== false){9160return this.loaderPromise(url, config, params)9161.then((data)=>{9162if(this.table.options.ajaxResponse){9163data = this.table.options.ajaxResponse.call(this.table, url, params, data);9164}91659166return data;9167});9168}else {9169return Promise.reject();9170}9171}9172}91739174Ajax.moduleName = "ajax";91759176//load defaults9177Ajax.defaultConfig = defaultConfig;9178Ajax.defaultURLGenerator = urlBuilder;9179Ajax.defaultLoaderPromise = defaultLoaderPromise;9180Ajax.contentTypeFormatters = defaultContentTypeFormatters;91819182var defaultPasteActions = {9183replace:function(rows){9184return this.table.setData(rows);9185},9186update:function(rows){9187return this.table.updateOrAddData(rows);9188},9189insert:function(rows){9190return this.table.addData(rows);9191},9192};91939194var defaultPasteParsers = {9195table:function(clipboard){9196var data = [],9197headerFindSuccess = true,9198columns = this.table.columnManager.columns,9199columnMap = [],9200rows = [];92019202//get data from clipboard into array of columns and rows.9203clipboard = clipboard.split("\n");92049205clipboard.forEach(function(row){9206data.push(row.split("\t"));9207});92089209if(data.length && !(data.length === 1 && data[0].length < 2)){92109211//check if headers are present by title9212data[0].forEach(function(value){9213var column = columns.find(function(column){9214return value && column.definition.title && value.trim() && column.definition.title.trim() === value.trim();9215});92169217if(column){9218columnMap.push(column);9219}else {9220headerFindSuccess = false;9221}9222});92239224//check if column headers are present by field9225if(!headerFindSuccess){9226headerFindSuccess = true;9227columnMap = [];92289229data[0].forEach(function(value){9230var column = columns.find(function(column){9231return value && column.field && value.trim() && column.field.trim() === value.trim();9232});92339234if(column){9235columnMap.push(column);9236}else {9237headerFindSuccess = false;9238}9239});92409241if(!headerFindSuccess){9242columnMap = this.table.columnManager.columnsByIndex;9243}9244}92459246//remove header row if found9247if(headerFindSuccess){9248data.shift();9249}92509251data.forEach(function(item){9252var row = {};92539254item.forEach(function(value, i){9255if(columnMap[i]){9256row[columnMap[i].field] = value;9257}9258});92599260rows.push(row);9261});92629263return rows;9264}else {9265return false;9266}9267}9268};92699270class Clipboard extends Module{92719272constructor(table){9273super(table);92749275this.mode = true;9276this.pasteParser = function(){};9277this.pasteAction = function(){};9278this.customSelection = false;9279this.rowRange = false;9280this.blocked = true; //block copy actions not originating from this command92819282this.registerTableOption("clipboard", false); //enable clipboard9283this.registerTableOption("clipboardCopyStyled", true); //formatted table data9284this.registerTableOption("clipboardCopyConfig", false); //clipboard config9285this.registerTableOption("clipboardCopyFormatter", false); //DEPRECATED - REMOVE in 5.09286this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only9287this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows9288this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table92899290this.registerColumnOption("clipboard");9291this.registerColumnOption("titleClipboard");9292}92939294initialize(){9295this.mode = this.table.options.clipboard;92969297this.rowRange = this.table.options.clipboardCopyRowRange;92989299if(this.mode === true || this.mode === "copy"){9300this.table.element.addEventListener("copy", (e) => {9301var plain, html, list;93029303if(!this.blocked){9304e.preventDefault();93059306if(this.customSelection){9307plain = this.customSelection;93089309if(this.table.options.clipboardCopyFormatter){9310plain = this.table.options.clipboardCopyFormatter("plain", plain);9311}9312}else {93139314list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, "clipboard");93159316html = this.table.modules.export.generateHTMLTable(list);9317plain = html ? this.generatePlainContent(list) : "";93189319if(this.table.options.clipboardCopyFormatter){9320plain = this.table.options.clipboardCopyFormatter("plain", plain);9321html = this.table.options.clipboardCopyFormatter("html", html);9322}9323}93249325if (window.clipboardData && window.clipboardData.setData) {9326window.clipboardData.setData('Text', plain);9327} else if (e.clipboardData && e.clipboardData.setData) {9328e.clipboardData.setData('text/plain', plain);9329if(html){9330e.clipboardData.setData('text/html', html);9331}9332} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {9333e.originalEvent.clipboardData.setData('text/plain', plain);9334if(html){9335e.originalEvent.clipboardData.setData('text/html', html);9336}9337}93389339this.dispatchExternal("clipboardCopied", plain, html);93409341this.reset();9342}9343});9344}93459346if(this.mode === true || this.mode === "paste"){9347this.table.element.addEventListener("paste", (e) => {9348this.paste(e);9349});9350}93519352this.setPasteParser(this.table.options.clipboardPasteParser);9353this.setPasteAction(this.table.options.clipboardPasteAction);93549355this.registerTableFunction("copyToClipboard", this.copy.bind(this));9356}93579358reset(){9359this.blocked = true;9360this.customSelection = false;9361}93629363generatePlainContent (list) {9364var output = [];93659366list.forEach((row) => {9367var rowData = [];93689369row.columns.forEach((col) => {9370var value = "";93719372if(col){93739374if(row.type === "group"){9375col.value = col.component.getKey();9376}93779378if(col.value === null){9379value = "";9380}else {9381switch(typeof col.value){9382case "object":9383value = JSON.stringify(col.value);9384break;93859386case "undefined":9387value = "";9388break;93899390default:9391value = col.value;9392}9393}9394}93959396rowData.push(value);9397});93989399output.push(rowData.join("\t"));9400});94019402return output.join("\n");9403}94049405copy (range, internal) {9406var sel, textRange;9407this.blocked = false;9408this.customSelection = false;94099410if (this.mode === true || this.mode === "copy") {94119412this.rowRange = range || this.table.options.clipboardCopyRowRange;94139414if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {9415range = document.createRange();9416range.selectNodeContents(this.table.element);9417sel = window.getSelection();94189419if (sel.toString() && internal) {9420this.customSelection = sel.toString();9421}94229423sel.removeAllRanges();9424sel.addRange(range);9425} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {9426textRange = document.body.createTextRange();9427textRange.moveToElementText(this.table.element);9428textRange.select();9429}94309431document.execCommand('copy');94329433if (sel) {9434sel.removeAllRanges();9435}9436}9437}94389439//PASTE EVENT HANDLING9440setPasteAction(action){94419442switch(typeof action){9443case "string":9444this.pasteAction = Clipboard.pasteActions[action];94459446if(!this.pasteAction){9447console.warn("Clipboard Error - No such paste action found:", action);9448}9449break;94509451case "function":9452this.pasteAction = action;9453break;9454}9455}94569457setPasteParser(parser){9458switch(typeof parser){9459case "string":9460this.pasteParser = Clipboard.pasteParsers[parser];94619462if(!this.pasteParser){9463console.warn("Clipboard Error - No such paste parser found:", parser);9464}9465break;94669467case "function":9468this.pasteParser = parser;9469break;9470}9471}94729473paste(e){9474var data, rowData, rows;94759476if(this.checkPaseOrigin(e)){94779478data = this.getPasteData(e);94799480rowData = this.pasteParser.call(this, data);94819482if(rowData){9483e.preventDefault();94849485if(this.table.modExists("mutator")){9486rowData = this.mutateData(rowData);9487}94889489rows = this.pasteAction.call(this, rowData);94909491this.dispatchExternal("clipboardPasted", data, rowData, rows);9492}else {9493this.dispatchExternal("clipboardPasteError", data);9494}9495}9496}94979498mutateData(data){9499var output = [];95009501if(Array.isArray(data)){9502data.forEach((row) => {9503output.push(this.table.modules.mutator.transformRow(row, "clipboard"));9504});9505}else {9506output = data;9507}95089509return output;9510}951195129513checkPaseOrigin(e){9514var valid = true;95159516if(e.target.tagName != "DIV" || this.table.modules.edit.currentCell){9517valid = false;9518}95199520return valid;9521}95229523getPasteData(e){9524var data;95259526if (window.clipboardData && window.clipboardData.getData) {9527data = window.clipboardData.getData('Text');9528} else if (e.clipboardData && e.clipboardData.getData) {9529data = e.clipboardData.getData('text/plain');9530} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {9531data = e.originalEvent.clipboardData.getData('text/plain');9532}95339534return data;9535}9536}95379538Clipboard.moduleName = "clipboard";95399540//load defaults9541Clipboard.pasteActions = defaultPasteActions;9542Clipboard.pasteParsers = defaultPasteParsers;95439544class CalcComponent{9545constructor (row){9546this._row = row;95479548return new Proxy(this, {9549get: function(target, name, receiver) {9550if (typeof target[name] !== "undefined") {9551return target[name];9552}else {9553return target._row.table.componentFunctionBinder.handle("row", target._row, name);9554}9555}9556});9557}95589559getData(transform){9560return this._row.getData(transform);9561}95629563getElement(){9564return this._row.getElement();9565}95669567getTable(){9568return this._row.table;9569}95709571getCells(){9572var cells = [];95739574this._row.getCells().forEach(function(cell){9575cells.push(cell.getComponent());9576});95779578return cells;9579}95809581getCell(column){9582var cell = this._row.getCell(column);9583return cell ? cell.getComponent() : false;9584}95859586_getSelf(){9587return this._row;9588}9589}95909591var defaultCalculations = {9592"avg":function(values, data, calcParams){9593var output = 0,9594precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : 2;95959596if(values.length){9597output = values.reduce(function(sum, value){9598return Number(sum) + Number(value);9599});96009601output = output / values.length;96029603output = precision !== false ? output.toFixed(precision) : output;9604}96059606return parseFloat(output).toString();9607},9608"max":function(values, data, calcParams){9609var output = null,9610precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;96119612values.forEach(function(value){96139614value = Number(value);96159616if(value > output || output === null){9617output = value;9618}9619});96209621return output !== null ? (precision !== false ? output.toFixed(precision) : output) : "";9622},9623"min":function(values, data, calcParams){9624var output = null,9625precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;96269627values.forEach(function(value){96289629value = Number(value);96309631if(value < output || output === null){9632output = value;9633}9634});96359636return output !== null ? (precision !== false ? output.toFixed(precision) : output) : "";9637},9638"sum":function(values, data, calcParams){9639var output = 0,9640precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;96419642if(values.length){9643values.forEach(function(value){9644value = Number(value);96459646output += !isNaN(value) ? Number(value) : 0;9647});9648}96499650return precision !== false ? output.toFixed(precision) : output;9651},9652"concat":function(values, data, calcParams){9653var output = 0;96549655if(values.length){9656output = values.reduce(function(sum, value){9657return String(sum) + String(value);9658});9659}96609661return output;9662},9663"count":function(values, data, calcParams){9664var output = 0;96659666if(values.length){9667values.forEach(function(value){9668if(value){9669output ++;9670}9671});9672}96739674return output;9675},9676"unique":function(values, data, calcParams){9677var unique = values.filter((value, index) => {9678return (values || value === 0) && values.indexOf(value) === index;9679});96809681return unique.length;9682},9683};96849685class ColumnCalcs extends Module{96869687constructor(table){9688super(table);96899690this.topCalcs = [];9691this.botCalcs = [];9692this.genColumn = false;9693this.topElement = this.createElement();9694this.botElement = this.createElement();9695this.topRow = false;9696this.botRow = false;9697this.topInitialized = false;9698this.botInitialized = false;96999700this.blocked = false;9701this.recalcAfterBlock = false;97029703this.registerTableOption("columnCalcs", true);97049705this.registerColumnOption("topCalc");9706this.registerColumnOption("topCalcParams");9707this.registerColumnOption("topCalcFormatter");9708this.registerColumnOption("topCalcFormatterParams");9709this.registerColumnOption("bottomCalc");9710this.registerColumnOption("bottomCalcParams");9711this.registerColumnOption("bottomCalcFormatter");9712this.registerColumnOption("bottomCalcFormatterParams");9713}97149715createElement (){9716var el = document.createElement("div");9717el.classList.add("tabulator-calcs-holder");9718return el;9719}97209721initialize(){9722this.genColumn = new Column({field:"value"}, this);97239724this.subscribe("cell-value-changed", this.cellValueChanged.bind(this));9725this.subscribe("column-init", this.initializeColumnCheck.bind(this));9726this.subscribe("row-deleted", this.rowsUpdated.bind(this));9727this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this));9728this.subscribe("row-added", this.rowsUpdated.bind(this));9729this.subscribe("column-moved", this.recalcActiveRows.bind(this));9730this.subscribe("column-add", this.recalcActiveRows.bind(this));9731this.subscribe("data-refreshed", this.recalcActiveRowsRefresh.bind(this));9732this.subscribe("table-redraw", this.tableRedraw.bind(this));9733this.subscribe("rows-visible", this.visibleRows.bind(this));9734this.subscribe("scrollbar-vertical", this.adjustForScrollbar.bind(this));97359736this.subscribe("redraw-blocked", this.blockRedraw.bind(this));9737this.subscribe("redraw-restored", this.restoreRedraw.bind(this));97389739this.subscribe("table-redrawing", this.resizeHolderWidth.bind(this));9740this.subscribe("column-resized", this.resizeHolderWidth.bind(this));9741this.subscribe("column-show", this.resizeHolderWidth.bind(this));9742this.subscribe("column-hide", this.resizeHolderWidth.bind(this));97439744this.registerTableFunction("getCalcResults", this.getResults.bind(this));9745this.registerTableFunction("recalc", this.userRecalc.bind(this));974697479748this.resizeHolderWidth();9749}97509751resizeHolderWidth(){9752this.topElement.style.minWidth = this.table.columnManager.headersElement.offsetWidth + "px";9753}975497559756tableRedraw(force){9757this.recalc(this.table.rowManager.activeRows);97589759if(force){9760this.redraw();9761}9762}97639764blockRedraw(){9765this.blocked = true;9766this.recalcAfterBlock = false;9767}976897699770restoreRedraw(){9771this.blocked = false;97729773if(this.recalcAfterBlock){9774this.recalcAfterBlock = false;9775this.recalcActiveRowsRefresh();9776}9777}97789779///////////////////////////////////9780///////// Table Functions /////////9781///////////////////////////////////9782userRecalc(){9783this.recalc(this.table.rowManager.activeRows);9784}97859786///////////////////////////////////9787///////// Internal Logic //////////9788///////////////////////////////////97899790blockCheck(){9791if(this.blocked){9792this.recalcAfterBlock = true;9793}97949795return this.blocked;9796}97979798visibleRows(viewable, rows){9799if(this.topRow){9800rows.unshift(this.topRow);9801}98029803if(this.botRow){9804rows.push(this.botRow);9805}98069807return rows;9808}98099810rowsUpdated(row){9811if(this.table.options.groupBy){9812this.recalcRowGroup(row);9813}else {9814this.recalcActiveRows();9815}9816}98179818recalcActiveRowsRefresh(){9819if(this.table.options.groupBy && this.table.options.dataTreeStartExpanded && this.table.options.dataTree){9820this.recalcAll();9821}else {9822this.recalcActiveRows();9823}9824}98259826recalcActiveRows(){9827this.recalc(this.table.rowManager.activeRows);9828}98299830cellValueChanged(cell){9831if(cell.column.definition.topCalc || cell.column.definition.bottomCalc){9832if(this.table.options.groupBy){9833if(this.table.options.columnCalcs == "table" || this.table.options.columnCalcs == "both"){9834this.recalcActiveRows();9835}98369837if(this.table.options.columnCalcs != "table"){9838this.recalcRowGroup(cell.row);9839}9840}else {9841this.recalcActiveRows();9842}9843}9844}98459846initializeColumnCheck(column){9847if(column.definition.topCalc || column.definition.bottomCalc){9848this.initializeColumn(column);9849}9850}98519852//initialize column calcs9853initializeColumn(column){9854var def = column.definition;98559856var config = {9857topCalcParams:def.topCalcParams || {},9858botCalcParams:def.bottomCalcParams || {},9859};98609861if(def.topCalc){98629863switch(typeof def.topCalc){9864case "string":9865if(ColumnCalcs.calculations[def.topCalc]){9866config.topCalc = ColumnCalcs.calculations[def.topCalc];9867}else {9868console.warn("Column Calc Error - No such calculation found, ignoring: ", def.topCalc);9869}9870break;98719872case "function":9873config.topCalc = def.topCalc;9874break;98759876}98779878if(config.topCalc){9879column.modules.columnCalcs = config;9880this.topCalcs.push(column);98819882if(this.table.options.columnCalcs != "group"){9883this.initializeTopRow();9884}9885}98869887}98889889if(def.bottomCalc){9890switch(typeof def.bottomCalc){9891case "string":9892if(ColumnCalcs.calculations[def.bottomCalc]){9893config.botCalc = ColumnCalcs.calculations[def.bottomCalc];9894}else {9895console.warn("Column Calc Error - No such calculation found, ignoring: ", def.bottomCalc);9896}9897break;98989899case "function":9900config.botCalc = def.bottomCalc;9901break;99029903}99049905if(config.botCalc){9906column.modules.columnCalcs = config;9907this.botCalcs.push(column);99089909if(this.table.options.columnCalcs != "group"){9910this.initializeBottomRow();9911}9912}9913}99149915}99169917//dummy functions to handle being mock column manager9918registerColumnField(){}99199920removeCalcs(){9921var changed = false;99229923if(this.topInitialized){9924this.topInitialized = false;9925this.topElement.parentNode.removeChild(this.topElement);9926changed = true;9927}99289929if(this.botInitialized){9930this.botInitialized = false;9931this.footerRemove(this.botElement);9932changed = true;9933}99349935if(changed){9936this.table.rowManager.adjustTableSize();9937}9938}99399940reinitializeCalcs(){9941if(this.topCalcs.length){9942this.initializeTopRow();9943}99449945if(this.botCalcs.length){9946this.initializeBottomRow();9947}9948}99499950initializeTopRow(){9951if(!this.topInitialized){9952this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);9953this.topInitialized = true;9954}9955}99569957initializeBottomRow(){9958if(!this.botInitialized){9959this.footerPrepend(this.botElement);9960this.botInitialized = true;9961}9962}99639964scrollHorizontal(left){9965if(this.botInitialized && this.botRow){9966this.botElement.scrollLeft = left;9967}9968}99699970recalc(rows){9971var data, row;99729973if(!this.blockCheck()){9974if(this.topInitialized || this.botInitialized){9975data = this.rowsToData(rows);99769977if(this.topInitialized){9978if(this.topRow){9979this.topRow.deleteCells();9980}99819982row = this.generateRow("top", data);9983this.topRow = row;9984while(this.topElement.firstChild) this.topElement.removeChild(this.topElement.firstChild);9985this.topElement.appendChild(row.getElement());9986row.initialize(true);9987}99889989if(this.botInitialized){9990if(this.botRow){9991this.botRow.deleteCells();9992}99939994row = this.generateRow("bottom", data);9995this.botRow = row;9996while(this.botElement.firstChild) this.botElement.removeChild(this.botElement.firstChild);9997this.botElement.appendChild(row.getElement());9998row.initialize(true);9999}1000010001this.table.rowManager.adjustTableSize();1000210003//set resizable handles10004if(this.table.modExists("frozenColumns")){10005this.table.modules.frozenColumns.layout();10006}10007}10008}10009}1001010011recalcRowGroup(row){10012this.recalcGroup(this.table.modules.groupRows.getRowGroup(row));10013}1001410015recalcAll(){10016if(this.topCalcs.length || this.botCalcs.length){10017if(this.table.options.columnCalcs !== "group"){10018this.recalcActiveRows();10019}1002010021if(this.table.options.groupBy && this.table.options.columnCalcs !== "table"){1002210023var groups = this.table.modules.groupRows.getChildGroups();1002410025groups.forEach((group) => {10026this.recalcGroup(group);10027});10028}10029}10030}1003110032recalcGroup(group){10033var data, rowData;1003410035if(!this.blockCheck()){10036if(group){10037if(group.calcs){10038if(group.calcs.bottom){10039data = this.rowsToData(group.rows);10040rowData = this.generateRowData("bottom", data);1004110042group.calcs.bottom.updateData(rowData);10043group.calcs.bottom.reinitialize();10044}1004510046if(group.calcs.top){10047data = this.rowsToData(group.rows);10048rowData = this.generateRowData("top", data);1004910050group.calcs.top.updateData(rowData);10051group.calcs.top.reinitialize();10052}10053}10054}10055}10056}1005710058//generate top stats row10059generateTopRow(rows){10060return this.generateRow("top", this.rowsToData(rows));10061}10062//generate bottom stats row10063generateBottomRow(rows){10064return this.generateRow("bottom", this.rowsToData(rows));10065}1006610067rowsToData(rows){10068var data = [];1006910070rows.forEach((row) => {10071data.push(row.getData());1007210073if(this.table.options.dataTree && this.table.options.dataTreeChildColumnCalcs){10074if(row.modules.dataTree && row.modules.dataTree.open){10075var children = this.rowsToData(this.table.modules.dataTree.getFilteredTreeChildren(row));10076data = data.concat(children);10077}10078}10079});1008010081return data;10082}1008310084//generate stats row10085generateRow(pos, data){10086var rowData = this.generateRowData(pos, data),10087row;1008810089if(this.table.modExists("mutator")){10090this.table.modules.mutator.disable();10091}1009210093row = new Row(rowData, this, "calc");1009410095if(this.table.modExists("mutator")){10096this.table.modules.mutator.enable();10097}1009810099row.getElement().classList.add("tabulator-calcs", "tabulator-calcs-" + pos);1010010101row.component = false;1010210103row.getComponent = () => {10104if(!row.component){10105row.component = new CalcComponent(row);10106}1010710108return row.component;10109};1011010111row.generateCells = () => {1011210113var cells = [];1011410115this.table.columnManager.columnsByIndex.forEach((column) => {1011610117//set field name of mock column10118this.genColumn.setField(column.getField());10119this.genColumn.hozAlign = column.hozAlign;1012010121if(column.definition[pos + "CalcFormatter"] && this.table.modExists("format")){10122this.genColumn.modules.format = {10123formatter: this.table.modules.format.getFormatter(column.definition[pos + "CalcFormatter"]),10124params: column.definition[pos + "CalcFormatterParams"] || {},10125};10126}else {10127this.genColumn.modules.format = {10128formatter: this.table.modules.format.getFormatter("plaintext"),10129params:{}10130};10131}1013210133//ensure css class definition is replicated to calculation cell10134this.genColumn.definition.cssClass = column.definition.cssClass;1013510136//generate cell and assign to correct column10137var cell = new Cell(this.genColumn, row);10138cell.getElement();10139cell.column = column;10140cell.setWidth();1014110142column.cells.push(cell);10143cells.push(cell);1014410145if(!column.visible){10146cell.hide();10147}10148});1014910150row.cells = cells;10151};1015210153return row;10154}1015510156//generate stats row10157generateRowData(pos, data){10158var rowData = {},10159calcs = pos == "top" ? this.topCalcs : this.botCalcs,10160type = pos == "top" ? "topCalc" : "botCalc",10161params, paramKey;1016210163calcs.forEach(function(column){10164var values = [];1016510166if(column.modules.columnCalcs && column.modules.columnCalcs[type]){10167data.forEach(function(item){10168values.push(column.getFieldValue(item));10169});1017010171paramKey = type + "Params";10172params = typeof column.modules.columnCalcs[paramKey] === "function" ? column.modules.columnCalcs[paramKey](values, data) : column.modules.columnCalcs[paramKey];1017310174column.setFieldValue(rowData, column.modules.columnCalcs[type](values, data, params));10175}10176});1017710178return rowData;10179}1018010181hasTopCalcs(){10182return !!(this.topCalcs.length);10183}1018410185hasBottomCalcs(){10186return !!(this.botCalcs.length);10187}1018810189//handle table redraw10190redraw(){10191if(this.topRow){10192this.topRow.normalizeHeight(true);10193}10194if(this.botRow){10195this.botRow.normalizeHeight(true);10196}10197}1019810199//return the calculated10200getResults(){10201var results = {},10202groups;1020310204if(this.table.options.groupBy && this.table.modExists("groupRows")){10205groups = this.table.modules.groupRows.getGroups(true);1020610207groups.forEach((group) => {10208results[group.getKey()] = this.getGroupResults(group);10209});10210}else {10211results = {10212top: this.topRow ? this.topRow.getData() : {},10213bottom: this.botRow ? this.botRow.getData() : {},10214};10215}1021610217return results;10218}1021910220//get results from a group10221getGroupResults(group){10222var groupObj = group._getSelf(),10223subGroups = group.getSubGroups(),10224subGroupResults = {},10225results = {};1022610227subGroups.forEach((subgroup) => {10228subGroupResults[subgroup.getKey()] = this.getGroupResults(subgroup);10229});1023010231results = {10232top: groupObj.calcs.top ? groupObj.calcs.top.getData() : {},10233bottom: groupObj.calcs.bottom ? groupObj.calcs.bottom.getData() : {},10234groups: subGroupResults,10235};1023610237return results;10238}1023910240adjustForScrollbar(width){10241if(this.botRow){10242if(this.table.rtl){10243this.botElement.style.paddingLeft = width + "px";10244}else {10245this.botElement.style.paddingRight = width + "px";10246}10247}10248}10249}1025010251ColumnCalcs.moduleName = "columnCalcs";1025210253//load defaults10254ColumnCalcs.calculations = defaultCalculations;1025510256class DataTree extends Module{1025710258constructor(table){10259super(table);1026010261this.indent = 10;10262this.field = "";10263this.collapseEl = null;10264this.expandEl = null;10265this.branchEl = null;10266this.elementField = false;1026710268this.startOpen = function(){};1026910270this.registerTableOption("dataTree", false); //enable data tree10271this.registerTableOption("dataTreeFilter", true); //filter child rows10272this.registerTableOption("dataTreeSort", true); //sort child rows10273this.registerTableOption("dataTreeElementColumn", false);10274this.registerTableOption("dataTreeBranchElement", true);//show data tree branch element10275this.registerTableOption("dataTreeChildIndent", 9); //data tree child indent in px10276this.registerTableOption("dataTreeChildField", "_children");//data tre column field to look for child rows10277this.registerTableOption("dataTreeCollapseElement", false);//data tree row collapse element10278this.registerTableOption("dataTreeExpandElement", false);//data tree row expand element10279this.registerTableOption("dataTreeStartExpanded", false);10280this.registerTableOption("dataTreeChildColumnCalcs", false);//include visible data tree rows in column calculations10281this.registerTableOption("dataTreeSelectPropagate", false);//selecting a parent row selects its children1028210283//register component functions10284this.registerComponentFunction("row", "treeCollapse", this.collapseRow.bind(this));10285this.registerComponentFunction("row", "treeExpand", this.expandRow.bind(this));10286this.registerComponentFunction("row", "treeToggle", this.toggleRow.bind(this));10287this.registerComponentFunction("row", "getTreeParent", this.getTreeParent.bind(this));10288this.registerComponentFunction("row", "getTreeChildren", this.getRowChildren.bind(this));10289this.registerComponentFunction("row", "addTreeChild", this.addTreeChildRow.bind(this));10290this.registerComponentFunction("row", "isTreeExpanded", this.isRowExpanded.bind(this));10291}1029210293initialize(){10294if(this.table.options.dataTree){10295var dummyEl = null,10296options = this.table.options;1029710298this.field = options.dataTreeChildField;10299this.indent = options.dataTreeChildIndent;1030010301if(this.options("movableRows")){10302console.warn("The movableRows option is not available with dataTree enabled, moving of child rows could result in unpredictable behavior");10303}1030410305if(options.dataTreeBranchElement){1030610307if(options.dataTreeBranchElement === true){10308this.branchEl = document.createElement("div");10309this.branchEl.classList.add("tabulator-data-tree-branch");10310}else {10311if(typeof options.dataTreeBranchElement === "string"){10312dummyEl = document.createElement("div");10313dummyEl.innerHTML = options.dataTreeBranchElement;10314this.branchEl = dummyEl.firstChild;10315}else {10316this.branchEl = options.dataTreeBranchElement;10317}10318}10319}else {10320this.branchEl = document.createElement("div");10321this.branchEl.classList.add("tabulator-data-tree-branch-empty");10322}1032310324if(options.dataTreeCollapseElement){10325if(typeof options.dataTreeCollapseElement === "string"){10326dummyEl = document.createElement("div");10327dummyEl.innerHTML = options.dataTreeCollapseElement;10328this.collapseEl = dummyEl.firstChild;10329}else {10330this.collapseEl = options.dataTreeCollapseElement;10331}10332}else {10333this.collapseEl = document.createElement("div");10334this.collapseEl.classList.add("tabulator-data-tree-control");10335this.collapseEl.tabIndex = 0;10336this.collapseEl.innerHTML = "<div class='tabulator-data-tree-control-collapse'></div>";10337}1033810339if(options.dataTreeExpandElement){10340if(typeof options.dataTreeExpandElement === "string"){10341dummyEl = document.createElement("div");10342dummyEl.innerHTML = options.dataTreeExpandElement;10343this.expandEl = dummyEl.firstChild;10344}else {10345this.expandEl = options.dataTreeExpandElement;10346}10347}else {10348this.expandEl = document.createElement("div");10349this.expandEl.classList.add("tabulator-data-tree-control");10350this.expandEl.tabIndex = 0;10351this.expandEl.innerHTML = "<div class='tabulator-data-tree-control-expand'></div>";10352}103531035410355switch(typeof options.dataTreeStartExpanded){10356case "boolean":10357this.startOpen = function(row, index){10358return options.dataTreeStartExpanded;10359};10360break;1036110362case "function":10363this.startOpen = options.dataTreeStartExpanded;10364break;1036510366default:10367this.startOpen = function(row, index){10368return options.dataTreeStartExpanded[index];10369};10370break;10371}1037210373this.subscribe("row-init", this.initializeRow.bind(this));10374this.subscribe("row-layout-after", this.layoutRow.bind(this));10375this.subscribe("row-deleted", this.rowDelete.bind(this),0);10376this.subscribe("row-data-changed", this.rowDataChanged.bind(this), 10);10377this.subscribe("cell-value-updated", this.cellValueChanged.bind(this));10378this.subscribe("edit-cancelled", this.cellValueChanged.bind(this));10379this.subscribe("column-moving-rows", this.columnMoving.bind(this));10380this.subscribe("table-built", this.initializeElementField.bind(this));10381this.subscribe("table-redrawing", this.tableRedrawing.bind(this));1038210383this.registerDisplayHandler(this.getRows.bind(this), 30);10384}10385}1038610387tableRedrawing(force){10388var rows;1038910390if(force){10391rows = this.table.rowManager.getRows();1039210393rows.forEach((row) => {10394this.reinitializeRowChildren(row);10395});10396}10397}1039810399initializeElementField(){10400var firstCol = this.table.columnManager.getFirstVisibleColumn();1040110402this.elementField = this.table.options.dataTreeElementColumn || (firstCol ? firstCol.field : false);10403}1040410405getRowChildren(row){10406return this.getTreeChildren(row, true);10407}1040810409columnMoving(){10410var rows = [];1041110412this.table.rowManager.rows.forEach((row) => {10413rows = rows.concat(this.getTreeChildren(row, false, true));10414});1041510416return rows;10417}1041810419rowDataChanged(row, visible, updatedData){10420if(this.redrawNeeded(updatedData)){10421this.initializeRow(row);1042210423if(visible){10424this.layoutRow(row);10425this.refreshData(true);10426}10427}10428}1042910430cellValueChanged(cell){10431var field = cell.column.getField();1043210433if(field === this.elementField){10434this.layoutRow(cell.row);10435}10436}1043710438initializeRow(row){10439var childArray = row.getData()[this.field];10440var isArray = Array.isArray(childArray);1044110442var children = isArray || (!isArray && typeof childArray === "object" && childArray !== null);1044310444if(!children && row.modules.dataTree && row.modules.dataTree.branchEl){10445row.modules.dataTree.branchEl.parentNode.removeChild(row.modules.dataTree.branchEl);10446}1044710448if(!children && row.modules.dataTree && row.modules.dataTree.controlEl){10449row.modules.dataTree.controlEl.parentNode.removeChild(row.modules.dataTree.controlEl);10450}1045110452row.modules.dataTree = {10453index: row.modules.dataTree ? row.modules.dataTree.index : 0,10454open: children ? (row.modules.dataTree ? row.modules.dataTree.open : this.startOpen(row.getComponent(), 0)) : false,10455controlEl: row.modules.dataTree && children ? row.modules.dataTree.controlEl : false,10456branchEl: row.modules.dataTree && children ? row.modules.dataTree.branchEl : false,10457parent: row.modules.dataTree ? row.modules.dataTree.parent : false,10458children:children,10459};10460}1046110462reinitializeRowChildren(row){10463var children = this.getTreeChildren(row, false, true);1046410465children.forEach(function(child){10466child.reinitialize(true);10467});10468}1046910470layoutRow(row){10471var cell = this.elementField ? row.getCell(this.elementField) : row.getCells()[0],10472el = cell.getElement(),10473config = row.modules.dataTree;1047410475if(config.branchEl){10476if(config.branchEl.parentNode){10477config.branchEl.parentNode.removeChild(config.branchEl);10478}10479config.branchEl = false;10480}1048110482if(config.controlEl){10483if(config.controlEl.parentNode){10484config.controlEl.parentNode.removeChild(config.controlEl);10485}10486config.controlEl = false;10487}1048810489this.generateControlElement(row, el);1049010491row.getElement().classList.add("tabulator-tree-level-" + config.index);1049210493if(config.index){10494if(this.branchEl){10495config.branchEl = this.branchEl.cloneNode(true);10496el.insertBefore(config.branchEl, el.firstChild);1049710498if(this.table.rtl){10499config.branchEl.style.marginRight = (((config.branchEl.offsetWidth + config.branchEl.style.marginLeft) * (config.index - 1)) + (config.index * this.indent)) + "px";10500}else {10501config.branchEl.style.marginLeft = (((config.branchEl.offsetWidth + config.branchEl.style.marginRight) * (config.index - 1)) + (config.index * this.indent)) + "px";10502}10503}else {1050410505if(this.table.rtl){10506el.style.paddingRight = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + (config.index * this.indent) + "px";10507}else {10508el.style.paddingLeft = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + (config.index * this.indent) + "px";10509}10510}10511}10512}1051310514generateControlElement(row, el){10515var config = row.modules.dataTree,10516oldControl = config.controlEl;1051710518el = el || row.getCells()[0].getElement();1051910520if(config.children !== false){1052110522if(config.open){10523config.controlEl = this.collapseEl.cloneNode(true);10524config.controlEl.addEventListener("click", (e) => {10525e.stopPropagation();10526this.collapseRow(row);10527});10528}else {10529config.controlEl = this.expandEl.cloneNode(true);10530config.controlEl.addEventListener("click", (e) => {10531e.stopPropagation();10532this.expandRow(row);10533});10534}1053510536config.controlEl.addEventListener("mousedown", (e) => {10537e.stopPropagation();10538});1053910540if(oldControl && oldControl.parentNode === el){10541oldControl.parentNode.replaceChild(config.controlEl,oldControl);10542}else {10543el.insertBefore(config.controlEl, el.firstChild);10544}10545}10546}1054710548getRows(rows){10549var output = [];1055010551rows.forEach((row, i) => {10552var config, children;1055310554output.push(row);1055510556if(row instanceof Row){1055710558row.create();1055910560config = row.modules.dataTree;1056110562if(!config.index && config.children !== false){10563children = this.getChildren(row);1056410565children.forEach((child) => {10566child.create();10567output.push(child);10568});10569}10570}10571});1057210573return output;10574}1057510576getChildren(row, allChildren){10577var config = row.modules.dataTree,10578children = [],10579output = [];1058010581if(config.children !== false && (config.open || allChildren)){10582if(!Array.isArray(config.children)){10583config.children = this.generateChildren(row);10584}1058510586if(this.table.modExists("filter") && this.table.options.dataTreeFilter){10587children = this.table.modules.filter.filter(config.children);10588}else {10589children = config.children;10590}1059110592if(this.table.modExists("sort") && this.table.options.dataTreeSort){10593this.table.modules.sort.sort(children);10594}1059510596children.forEach((child) => {10597output.push(child);1059810599var subChildren = this.getChildren(child);1060010601subChildren.forEach((sub) => {10602output.push(sub);10603});10604});10605}1060610607return output;10608}1060910610generateChildren(row){10611var children = [];1061210613var childArray = row.getData()[this.field];1061410615if(!Array.isArray(childArray)){10616childArray = [childArray];10617}1061810619childArray.forEach((childData) => {10620var childRow = new Row(childData || {}, this.table.rowManager);1062110622childRow.create();1062310624childRow.modules.dataTree.index = row.modules.dataTree.index + 1;10625childRow.modules.dataTree.parent = row;1062610627if(childRow.modules.dataTree.children){10628childRow.modules.dataTree.open = this.startOpen(childRow.getComponent(), childRow.modules.dataTree.index);10629}10630children.push(childRow);10631});1063210633return children;10634}1063510636expandRow(row, silent){10637var config = row.modules.dataTree;1063810639if(config.children !== false){10640config.open = true;1064110642row.reinitialize();1064310644this.refreshData(true);1064510646this.dispatchExternal("dataTreeRowExpanded", row.getComponent(), row.modules.dataTree.index);10647}10648}1064910650collapseRow(row){10651var config = row.modules.dataTree;1065210653if(config.children !== false){10654config.open = false;1065510656row.reinitialize();1065710658this.refreshData(true);1065910660this.dispatchExternal("dataTreeRowCollapsed", row.getComponent(), row.modules.dataTree.index);10661}10662}1066310664toggleRow(row){10665var config = row.modules.dataTree;1066610667if(config.children !== false){10668if(config.open){10669this.collapseRow(row);10670}else {10671this.expandRow(row);10672}10673}10674}1067510676isRowExpanded(row){10677return row.modules.dataTree.open;10678}1067910680getTreeParent(row){10681return row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() : false;10682}1068310684getTreeParentRoot(row){10685return row.modules.dataTree && row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;10686}1068710688getFilteredTreeChildren(row){10689var config = row.modules.dataTree,10690output = [], children;1069110692if(config.children){1069310694if(!Array.isArray(config.children)){10695config.children = this.generateChildren(row);10696}1069710698if(this.table.modExists("filter") && this.table.options.dataTreeFilter){10699children = this.table.modules.filter.filter(config.children);10700}else {10701children = config.children;10702}1070310704children.forEach((childRow) => {10705if(childRow instanceof Row){10706output.push(childRow);10707}10708});10709}1071010711return output;10712}1071310714rowDelete(row){10715var parent = row.modules.dataTree.parent,10716childIndex;1071710718if(parent){10719childIndex = this.findChildIndex(row, parent);1072010721if(childIndex !== false){10722parent.data[this.field].splice(childIndex, 1);10723}1072410725if(!parent.data[this.field].length){10726delete parent.data[this.field];10727}1072810729this.initializeRow(parent);10730this.layoutRow(parent);10731}1073210733this.refreshData(true);10734}1073510736addTreeChildRow(row, data, top, index){10737var childIndex = false;1073810739if(typeof data === "string"){10740data = JSON.parse(data);10741}1074210743if(!Array.isArray(row.data[this.field])){10744row.data[this.field] = [];1074510746row.modules.dataTree.open = this.startOpen(row.getComponent(), row.modules.dataTree.index);10747}1074810749if(typeof index !== "undefined"){10750childIndex = this.findChildIndex(index, row);1075110752if(childIndex !== false){10753row.data[this.field].splice((top ? childIndex : childIndex + 1), 0, data);10754}10755}1075610757if(childIndex === false){10758if(top){10759row.data[this.field].unshift(data);10760}else {10761row.data[this.field].push(data);10762}10763}1076410765this.initializeRow(row);10766this.layoutRow(row);1076710768this.refreshData(true);10769}1077010771findChildIndex(subject, parent){10772var match = false;1077310774if(typeof subject == "object"){1077510776if(subject instanceof Row){10777//subject is row element10778match = subject.data;10779}else if(subject instanceof RowComponent){10780//subject is public row component10781match = subject._getSelf().data;10782}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){10783if(parent.modules.dataTree){10784match = parent.modules.dataTree.children.find((childRow) => {10785return childRow instanceof Row ? childRow.element === subject : false;10786});1078710788if(match){10789match = match.data;10790}10791}10792}else if(subject === null){10793match = false;10794}1079510796}else if(typeof subject == "undefined"){10797match = false;10798}else {10799//subject should be treated as the index of the row10800match = parent.data[this.field].find((row) => {10801return row.data[this.table.options.index] == subject;10802});10803}1080410805if(match){1080610807if(Array.isArray(parent.data[this.field])){10808match = parent.data[this.field].indexOf(match);10809}1081010811if(match == -1){10812match = false;10813}10814}1081510816//catch all for any other type of input1081710818return match;10819}1082010821getTreeChildren(row, component, recurse){10822var config = row.modules.dataTree,10823output = [];1082410825if(config && config.children){1082610827if(!Array.isArray(config.children)){10828config.children = this.generateChildren(row);10829}1083010831config.children.forEach((childRow) => {10832if(childRow instanceof Row){10833output.push(component ? childRow.getComponent() : childRow);1083410835if(recurse){10836output = output.concat(this.getTreeChildren(childRow, component, recurse));10837}10838}10839});10840}1084110842return output;10843}1084410845getChildField(){10846return this.field;10847}1084810849redrawNeeded(data){10850return (this.field ? typeof data[this.field] !== "undefined" : false) || (this.elementField ? typeof data[this.elementField] !== "undefined" : false);10851}10852}1085310854DataTree.moduleName = "dataTree";1085510856function csv(list, options = {}, setFileContents){10857var delimiter = options.delimiter ? options.delimiter : ",",10858fileContents = [],10859headers = [];1086010861list.forEach((row) => {10862var item = [];1086310864switch(row.type){10865case "group":10866console.warn("Download Warning - CSV downloader cannot process row groups");10867break;1086810869case "calc":10870console.warn("Download Warning - CSV downloader cannot process column calculations");10871break;1087210873case "header":10874row.columns.forEach((col, i) => {10875if(col && col.depth === 1){10876headers[i] = typeof col.value == "undefined" || col.value === null ? "" : ('"' + String(col.value).split('"').join('""') + '"');10877}10878});10879break;1088010881case "row":10882row.columns.forEach((col) => {1088310884if(col){1088510886switch(typeof col.value){10887case "object":10888col.value = col.value !== null ? JSON.stringify(col.value) : "";10889break;1089010891case "undefined":10892col.value = "";10893break;10894}1089510896item.push('"' + String(col.value).split('"').join('""') + '"');10897}10898});1089910900fileContents.push(item.join(delimiter));10901break;10902}10903});1090410905if(headers.length){10906fileContents.unshift(headers.join(delimiter));10907}1090810909fileContents = fileContents.join("\n");1091010911if(options.bom){10912fileContents = "\ufeff" + fileContents;10913}1091410915setFileContents(fileContents, "text/csv");10916}1091710918function json(list, options, setFileContents){10919var fileContents = [];1092010921list.forEach((row) => {10922var item = {};1092310924switch(row.type){10925case "header":10926break;1092710928case "group":10929console.warn("Download Warning - JSON downloader cannot process row groups");10930break;1093110932case "calc":10933console.warn("Download Warning - JSON downloader cannot process column calculations");10934break;1093510936case "row":10937row.columns.forEach((col) => {10938if(col){10939item[col.component.getTitleDownload() || col.component.getField()] = col.value;10940}10941});1094210943fileContents.push(item);10944break;10945}10946});1094710948fileContents = JSON.stringify(fileContents, null, '\t');1094910950setFileContents(fileContents, "application/json");10951}1095210953function pdf(list, options = {}, setFileContents){10954var header = [],10955body = [],10956autoTableParams = {},10957rowGroupStyles = options.rowGroupStyles || {10958fontStyle: "bold",10959fontSize: 12,10960cellPadding: 6,10961fillColor: 220,10962},10963rowCalcStyles = options.rowCalcStyles || {10964fontStyle: "bold",10965fontSize: 10,10966cellPadding: 4,10967fillColor: 232,10968},10969jsPDFParams = options.jsPDF || {},10970title = options.title ? options.title : "";1097110972if(!jsPDFParams.orientation){10973jsPDFParams.orientation = options.orientation || "landscape";10974}1097510976if(!jsPDFParams.unit){10977jsPDFParams.unit = "pt";10978}1097910980//parse row list10981list.forEach((row) => {10982switch(row.type){10983case "header":10984header.push(parseRow(row));10985break;1098610987case "group":10988body.push(parseRow(row, rowGroupStyles));10989break;1099010991case "calc":10992body.push(parseRow(row, rowCalcStyles));10993break;1099410995case "row":10996body.push(parseRow(row));10997break;10998}10999});1100011001function parseRow(row, styles){11002var rowData = [];1100311004row.columns.forEach((col) =>{11005var cell;1100611007if(col){11008switch(typeof col.value){11009case "object":11010col.value = col.value !== null ? JSON.stringify(col.value) : "";11011break;1101211013case "undefined":11014col.value = "";11015break;11016}1101711018cell = {11019content:col.value,11020colSpan:col.width,11021rowSpan:col.height,11022};1102311024if(styles){11025cell.styles = styles;11026}1102711028rowData.push(cell);11029}11030});1103111032return rowData;11033}110341103511036//configure PDF11037var doc = new jspdf.jsPDF(jsPDFParams); //set document to landscape, better for most tables1103811039if(options.autoTable){11040if(typeof options.autoTable === "function"){11041autoTableParams = options.autoTable(doc) || {};11042}else {11043autoTableParams = options.autoTable;11044}11045}1104611047if(title){11048autoTableParams.didDrawPage = function(data) {11049doc.text(title, 40, 30);11050};11051}1105211053autoTableParams.head = header;11054autoTableParams.body = body;1105511056doc.autoTable(autoTableParams);1105711058if(options.documentProcessing){11059options.documentProcessing(doc);11060}1106111062setFileContents(doc.output("arraybuffer"), "application/pdf");11063}1106411065function xlsx(list, options, setFileContents){11066var self = this,11067sheetName = options.sheetName || "Sheet1",11068workbook = XLSX.utils.book_new(),11069tableFeatures = new CoreFeature(this),11070compression = 'compress' in options ? options.compress : true,11071writeOptions = options.writeOptions || {bookType:'xlsx', bookSST:true, compression},11072output;1107311074writeOptions.type = 'binary';1107511076workbook.SheetNames = [];11077workbook.Sheets = {};1107811079function generateSheet(){11080var rows = [],11081merges = [],11082worksheet = {},11083range = {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 }};1108411085//parse row list11086list.forEach((row, i) => {11087var rowData = [];1108811089row.columns.forEach(function(col, j){1109011091if(col){11092rowData.push(!(col.value instanceof Date) && typeof col.value === "object" ? JSON.stringify(col.value) : col.value);1109311094if(col.width > 1 || col.height > -1){11095if(col.height > 1 || col.width > 1){11096merges.push({s:{r:i,c:j},e:{r:i + col.height - 1,c:j + col.width - 1}});11097}11098}11099}else {11100rowData.push("");11101}11102});1110311104rows.push(rowData);11105});1110611107//convert rows to worksheet11108XLSX.utils.sheet_add_aoa(worksheet, rows);1110911110worksheet['!ref'] = XLSX.utils.encode_range(range);1111111112if(merges.length){11113worksheet["!merges"] = merges;11114}1111511116return worksheet;11117}1111811119if(options.sheetOnly){11120setFileContents(generateSheet());11121return;11122}1112311124if(options.sheets){11125for(var sheet in options.sheets){1112611127if(options.sheets[sheet] === true){11128workbook.SheetNames.push(sheet);11129workbook.Sheets[sheet] = generateSheet();11130}else {1113111132workbook.SheetNames.push(sheet);1113311134tableFeatures.commsSend(options.sheets[sheet], "download", "intercept",{11135type:"xlsx",11136options:{sheetOnly:true},11137active:self.active,11138intercept:function(data){11139workbook.Sheets[sheet] = data;11140}11141});11142}11143}11144}else {11145workbook.SheetNames.push(sheetName);11146workbook.Sheets[sheetName] = generateSheet();11147}1114811149if(options.documentProcessing){11150workbook = options.documentProcessing(workbook);11151}1115211153//convert workbook to binary array11154function s2ab(s) {11155var buf = new ArrayBuffer(s.length);11156var view = new Uint8Array(buf);11157for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;11158return buf;11159}1116011161output = XLSX.write(workbook, writeOptions);1116211163setFileContents(s2ab(output), "application/octet-stream");11164}1116511166function html(list, options, setFileContents){11167if(this.modExists("export", true)){11168setFileContents(this.modules.export.generateHTMLTable(list), "text/html");11169}11170}1117111172function jsonLines (list, options, setFileContents) {11173const fileContents = [];1117411175list.forEach((row) => {11176const item = {};1117711178switch (row.type) {11179case "header":11180break;1118111182case "group":11183console.warn("Download Warning - JSON downloader cannot process row groups");11184break;1118511186case "calc":11187console.warn("Download Warning - JSON downloader cannot process column calculations");11188break;1118911190case "row":11191row.columns.forEach((col) => {11192if (col) {11193item[col.component.getTitleDownload() || col.component.getField()] = col.value;11194}11195});1119611197fileContents.push(JSON.stringify(item));11198break;11199}11200});1120111202setFileContents(fileContents.join("\n"), "application/x-ndjson");11203}1120411205var defaultDownloaders = {11206csv:csv,11207json:json,11208jsonLines:jsonLines,11209pdf:pdf,11210xlsx:xlsx,11211html:html,11212};1121311214class Download extends Module{1121511216constructor(table){11217super(table);1121811219this.registerTableOption("downloadEncoder", function(data, mimeType){11220return new Blob([data],{type:mimeType});11221}); //function to manipulate download data11222this.registerTableOption("downloadReady", undefined); //warn of function deprecation11223this.registerTableOption("downloadConfig", {}); //download config11224this.registerTableOption("downloadRowRange", "active"); //restrict download to active rows only1122511226this.registerColumnOption("download");11227this.registerColumnOption("titleDownload");11228}1122911230initialize(){11231this.deprecatedOptionsCheck();1123211233this.registerTableFunction("download", this.download.bind(this));11234this.registerTableFunction("downloadToTab", this.downloadToTab.bind(this));11235}1123611237deprecatedOptionsCheck(){11238this.deprecationCheck("downloadReady", "downloadEncoder");11239}1124011241///////////////////////////////////11242///////// Table Functions /////////11243///////////////////////////////////1124411245downloadToTab(type, filename, options, active){11246this.download(type, filename, options, active, true);11247}1124811249///////////////////////////////////11250///////// Internal Logic //////////11251///////////////////////////////////1125211253//trigger file download11254download(type, filename, options, range, interceptCallback){11255var downloadFunc = false;1125611257function buildLink(data, mime){11258if(interceptCallback){11259if(interceptCallback === true){11260this.triggerDownload(data, mime, type, filename, true);11261}else {11262interceptCallback(data);11263}1126411265}else {11266this.triggerDownload(data, mime, type, filename);11267}11268}1126911270if(typeof type == "function"){11271downloadFunc = type;11272}else {11273if(Download.downloaders[type]){11274downloadFunc = Download.downloaders[type];11275}else {11276console.warn("Download Error - No such download type found: ", type);11277}11278}1127911280if(downloadFunc){11281var list = this.generateExportList(range);1128211283downloadFunc.call(this.table, list , options || {}, buildLink.bind(this));11284}11285}1128611287generateExportList(range){11288var list = this.table.modules.export.generateExportList(this.table.options.downloadConfig, false, range || this.table.options.downloadRowRange, "download");1128911290//assign group header formatter11291var groupHeader = this.table.options.groupHeaderDownload;1129211293if(groupHeader && !Array.isArray(groupHeader)){11294groupHeader = [groupHeader];11295}1129611297list.forEach((row) => {11298var group;1129911300if(row.type === "group"){11301group = row.columns[0];1130211303if(groupHeader && groupHeader[row.indent]){11304group.value = groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);11305}11306}11307});1130811309return list;11310}1131111312triggerDownload(data, mime, type, filename, newTab){11313var element = document.createElement('a'),11314blob = this.table.options.downloadEncoder(data, mime);1131511316if(blob){11317if(newTab){11318window.open(window.URL.createObjectURL(blob));11319}else {11320filename = filename || "Tabulator." + (typeof type === "function" ? "txt" : type);1132111322if(navigator.msSaveOrOpenBlob){11323navigator.msSaveOrOpenBlob(blob, filename);11324}else {11325element.setAttribute('href', window.URL.createObjectURL(blob));1132611327//set file title11328element.setAttribute('download', filename);1132911330//trigger download11331element.style.display = 'none';11332document.body.appendChild(element);11333element.click();1133411335//remove temporary link element11336document.body.removeChild(element);11337}11338}1133911340this.dispatchExternal("downloadComplete");11341}11342}1134311344commsReceived(table, action, data){11345switch(action){11346case "intercept":11347this.download(data.type, "", data.options, data.active, data.intercept);11348break;11349}11350}11351}1135211353Download.moduleName = "download";1135411355//load defaults11356Download.downloaders = defaultDownloaders;1135711358function maskInput(el, options){11359var mask = options.mask,11360maskLetter = typeof options.maskLetterChar !== "undefined" ? options.maskLetterChar : "A",11361maskNumber = typeof options.maskNumberChar !== "undefined" ? options.maskNumberChar : "9",11362maskWildcard = typeof options.maskWildcardChar !== "undefined" ? options.maskWildcardChar : "*";1136311364function fillSymbols(index){11365var symbol = mask[index];11366if(typeof symbol !== "undefined" && symbol !== maskWildcard && symbol !== maskLetter && symbol !== maskNumber){11367el.value = el.value + "" + symbol;11368fillSymbols(index+1);11369}11370}1137111372el.addEventListener("keydown", (e) => {11373var index = el.value.length,11374char = e.key;1137511376if(e.keyCode > 46 && !e.ctrlKey && !e.metaKey){11377if(index >= mask.length){11378e.preventDefault();11379e.stopPropagation();11380return false;11381}else {11382switch(mask[index]){11383case maskLetter:11384if(char.toUpperCase() == char.toLowerCase()){11385e.preventDefault();11386e.stopPropagation();11387return false;11388}11389break;1139011391case maskNumber:11392if(isNaN(char)){11393e.preventDefault();11394e.stopPropagation();11395return false;11396}11397break;1139811399case maskWildcard:11400break;1140111402default:11403if(char !== mask[index]){11404e.preventDefault();11405e.stopPropagation();11406return false;11407}11408}11409}11410}1141111412return;11413});1141411415el.addEventListener("keyup", (e) => {11416if(e.keyCode > 46){11417if(options.maskAutoFill){11418fillSymbols(el.value.length);11419}11420}11421});114221142311424if(!el.placeholder){11425el.placeholder = mask;11426}1142711428if(options.maskAutoFill){11429fillSymbols(el.value.length);11430}11431}1143211433//input element11434function input(cell, onRendered, success, cancel, editorParams){11435//create and style input11436var cellValue = cell.getValue(),11437input = document.createElement("input");1143811439input.setAttribute("type", editorParams.search ? "search" : "text");1144011441input.style.padding = "4px";11442input.style.width = "100%";11443input.style.boxSizing = "border-box";1144411445if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11446for (let key in editorParams.elementAttributes){11447if(key.charAt(0) == "+"){11448key = key.slice(1);11449input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11450}else {11451input.setAttribute(key, editorParams.elementAttributes[key]);11452}11453}11454}1145511456input.value = typeof cellValue !== "undefined" ? cellValue : "";1145711458onRendered(function(){11459if(cell.getType() === "cell"){11460input.focus({preventScroll: true});11461input.style.height = "100%";1146211463if(editorParams.selectContents){11464input.select();11465}11466}11467});1146811469function onChange(e){11470if(((cellValue === null || typeof cellValue === "undefined") && input.value !== "") || input.value !== cellValue){11471if(success(input.value)){11472cellValue = input.value; //persist value if successfully validated incase editor is used as header filter11473}11474}else {11475cancel();11476}11477}1147811479//submit new value on blur or change11480input.addEventListener("change", onChange);11481input.addEventListener("blur", onChange);1148211483//submit new value on enter11484input.addEventListener("keydown", function(e){11485switch(e.keyCode){11486// case 9:11487case 13:11488onChange();11489break;1149011491case 27:11492cancel();11493break;1149411495case 35:11496case 36:11497e.stopPropagation();11498break;11499}11500});1150111502if(editorParams.mask){11503maskInput(input, editorParams);11504}1150511506return input;11507}1150811509//resizable text area element11510function textarea(cell, onRendered, success, cancel, editorParams){11511var cellValue = cell.getValue(),11512vertNav = editorParams.verticalNavigation || "hybrid",11513value = String(cellValue !== null && typeof cellValue !== "undefined" ? cellValue : ""),11514input = document.createElement("textarea"),11515scrollHeight = 0;1151611517//create and style input11518input.style.display = "block";11519input.style.padding = "2px";11520input.style.height = "100%";11521input.style.width = "100%";11522input.style.boxSizing = "border-box";11523input.style.whiteSpace = "pre-wrap";11524input.style.resize = "none";1152511526if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11527for (let key in editorParams.elementAttributes){11528if(key.charAt(0) == "+"){11529key = key.slice(1);11530input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11531}else {11532input.setAttribute(key, editorParams.elementAttributes[key]);11533}11534}11535}1153611537input.value = value;1153811539onRendered(function(){11540if(cell.getType() === "cell"){11541input.focus({preventScroll: true});11542input.style.height = "100%";1154311544input.scrollHeight;11545input.style.height = input.scrollHeight + "px";11546cell.getRow().normalizeHeight();1154711548if(editorParams.selectContents){11549input.select();11550}11551}11552});1155311554function onChange(e){1155511556if(((cellValue === null || typeof cellValue === "undefined") && input.value !== "") || input.value !== cellValue){1155711558if(success(input.value)){11559cellValue = input.value; //persist value if successfully validated incase editor is used as header filter11560}1156111562setTimeout(function(){11563cell.getRow().normalizeHeight();11564},300);11565}else {11566cancel();11567}11568}1156911570//submit new value on blur or change11571input.addEventListener("change", onChange);11572input.addEventListener("blur", onChange);1157311574input.addEventListener("keyup", function(){1157511576input.style.height = "";1157711578var heightNow = input.scrollHeight;1157911580input.style.height = heightNow + "px";1158111582if(heightNow != scrollHeight){11583scrollHeight = heightNow;11584cell.getRow().normalizeHeight();11585}11586});1158711588input.addEventListener("keydown", function(e){1158911590switch(e.keyCode){1159111592case 13:11593if(e.shiftKey && editorParams.shiftEnterSubmit){11594onChange();11595}11596break;1159711598case 27:11599cancel();11600break;1160111602case 38: //up arrow11603if(vertNav == "editor" || (vertNav == "hybrid" && input.selectionStart)){11604e.stopImmediatePropagation();11605e.stopPropagation();11606}1160711608break;1160911610case 40: //down arrow11611if(vertNav == "editor" || (vertNav == "hybrid" && input.selectionStart !== input.value.length)){11612e.stopImmediatePropagation();11613e.stopPropagation();11614}11615break;1161611617case 35:11618case 36:11619e.stopPropagation();11620break;11621}11622});1162311624if(editorParams.mask){11625maskInput(input, editorParams);11626}1162711628return input;11629}1163011631//input element with type of number11632function number(cell, onRendered, success, cancel, editorParams){11633var cellValue = cell.getValue(),11634vertNav = editorParams.verticalNavigation || "editor",11635input = document.createElement("input");1163611637input.setAttribute("type", "number");1163811639if(typeof editorParams.max != "undefined"){11640input.setAttribute("max", editorParams.max);11641}1164211643if(typeof editorParams.min != "undefined"){11644input.setAttribute("min", editorParams.min);11645}1164611647if(typeof editorParams.step != "undefined"){11648input.setAttribute("step", editorParams.step);11649}1165011651//create and style input11652input.style.padding = "4px";11653input.style.width = "100%";11654input.style.boxSizing = "border-box";1165511656if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11657for (let key in editorParams.elementAttributes){11658if(key.charAt(0) == "+"){11659key = key.slice(1);11660input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11661}else {11662input.setAttribute(key, editorParams.elementAttributes[key]);11663}11664}11665}1166611667input.value = cellValue;1166811669var blurFunc = function(e){11670onChange();11671};1167211673onRendered(function () {11674if(cell.getType() === "cell"){11675//submit new value on blur11676input.removeEventListener("blur", blurFunc);1167711678input.focus({preventScroll: true});11679input.style.height = "100%";1168011681//submit new value on blur11682input.addEventListener("blur", blurFunc);1168311684if(editorParams.selectContents){11685input.select();11686}11687}11688});1168911690function onChange(){11691var value = input.value;1169211693if(!isNaN(value) && value !==""){11694value = Number(value);11695}1169611697if(value !== cellValue){11698if(success(value)){11699cellValue = value; //persist value if successfully validated incase editor is used as header filter11700}11701}else {11702cancel();11703}11704}1170511706//submit new value on enter11707input.addEventListener("keydown", function(e){11708switch(e.keyCode){11709case 13:11710// case 9:11711onChange();11712break;1171311714case 27:11715cancel();11716break;1171711718case 38: //up arrow11719case 40: //down arrow11720if(vertNav == "editor"){11721e.stopImmediatePropagation();11722e.stopPropagation();11723}11724break;1172511726case 35:11727case 36:11728e.stopPropagation();11729break;11730}11731});1173211733if(editorParams.mask){11734maskInput(input, editorParams);11735}1173611737return input;11738}1173911740//input element with type of number11741function range(cell, onRendered, success, cancel, editorParams){11742var cellValue = cell.getValue(),11743input = document.createElement("input");1174411745input.setAttribute("type", "range");1174611747if (typeof editorParams.max != "undefined") {11748input.setAttribute("max", editorParams.max);11749}1175011751if (typeof editorParams.min != "undefined") {11752input.setAttribute("min", editorParams.min);11753}1175411755if (typeof editorParams.step != "undefined") {11756input.setAttribute("step", editorParams.step);11757}1175811759//create and style input11760input.style.padding = "4px";11761input.style.width = "100%";11762input.style.boxSizing = "border-box";1176311764if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11765for (let key in editorParams.elementAttributes){11766if(key.charAt(0) == "+"){11767key = key.slice(1);11768input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11769}else {11770input.setAttribute(key, editorParams.elementAttributes[key]);11771}11772}11773}1177411775input.value = cellValue;1177611777onRendered(function () {11778if(cell.getType() === "cell"){11779input.focus({preventScroll: true});11780input.style.height = "100%";11781}11782});1178311784function onChange(){11785var value = input.value;1178611787if(!isNaN(value) && value !==""){11788value = Number(value);11789}1179011791if(value != cellValue){11792if(success(value)){11793cellValue = value; //persist value if successfully validated incase editor is used as header filter11794}11795}else {11796cancel();11797}11798}1179911800//submit new value on blur11801input.addEventListener("blur", function(e){11802onChange();11803});1180411805//submit new value on enter11806input.addEventListener("keydown", function(e){11807switch(e.keyCode){11808case 13:11809// case 9:11810onChange();11811break;1181211813case 27:11814cancel();11815break;11816}11817});1181811819return input;11820}1182111822//input element11823function date(cell, onRendered, success, cancel, editorParams){11824var inputFormat = editorParams.format,11825vertNav = editorParams.verticalNavigation || "editor",11826DT = inputFormat ? (window.DateTime || luxon.DateTime) : null;1182711828//create and style input11829var cellValue = cell.getValue(),11830input = document.createElement("input");1183111832function convertDate(value){11833var newDatetime;1183411835if(DT.isDateTime(value)){11836newDatetime = value;11837}else if(inputFormat === "iso"){11838newDatetime = DT.fromISO(String(value));11839}else {11840newDatetime = DT.fromFormat(String(value), inputFormat);11841}1184211843return newDatetime.toFormat("yyyy-MM-dd");11844}1184511846input.type = "date";11847input.style.padding = "4px";11848input.style.width = "100%";11849input.style.boxSizing = "border-box";1185011851if(editorParams.max){11852input.setAttribute("max", inputFormat ? convertDate(editorParams.max) : editorParams.max);11853}1185411855if(editorParams.min){11856input.setAttribute("min", inputFormat ? convertDate(editorParams.min) : editorParams.min);11857}1185811859if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11860for (let key in editorParams.elementAttributes){11861if(key.charAt(0) == "+"){11862key = key.slice(1);11863input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11864}else {11865input.setAttribute(key, editorParams.elementAttributes[key]);11866}11867}11868}1186911870cellValue = typeof cellValue !== "undefined" ? cellValue : "";1187111872if(inputFormat){11873if(DT){11874cellValue = convertDate(cellValue);11875}else {11876console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");11877}11878}1187911880input.value = cellValue;1188111882onRendered(function(){11883if(cell.getType() === "cell"){11884input.focus({preventScroll: true});11885input.style.height = "100%";1188611887if(editorParams.selectContents){11888input.select();11889}11890}11891});1189211893function onChange(){11894var value = input.value,11895luxDate;1189611897if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){1189811899if(value && inputFormat){11900luxDate = DT.fromFormat(String(value), "yyyy-MM-dd");1190111902switch(inputFormat){11903case true:11904value = luxDate;11905break;1190611907case "iso":11908value = luxDate.toISO();11909break;1191011911default:11912value = luxDate.toFormat(inputFormat);11913}11914}1191511916if(success(value)){11917cellValue = input.value; //persist value if successfully validated incase editor is used as header filter11918}11919}else {11920cancel();11921}11922}1192311924//submit new value on blur11925input.addEventListener("blur", function(e) {11926if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {11927onChange(); // only on a "true" blur; not when focusing browser's date/time picker11928}11929});1193011931//submit new value on enter11932input.addEventListener("keydown", function(e){11933switch(e.keyCode){11934// case 9:11935case 13:11936onChange();11937break;1193811939case 27:11940cancel();11941break;1194211943case 35:11944case 36:11945e.stopPropagation();11946break;1194711948case 38: //up arrow11949case 40: //down arrow11950if(vertNav == "editor"){11951e.stopImmediatePropagation();11952e.stopPropagation();11953}11954break;11955}11956});1195711958return input;11959}1196011961//input element11962function time(cell, onRendered, success, cancel, editorParams){11963var inputFormat = editorParams.format,11964vertNav = editorParams.verticalNavigation || "editor",11965DT = inputFormat ? (window.DateTime || luxon.DateTime) : null,11966newDatetime;1196711968//create and style input11969var cellValue = cell.getValue(),11970input = document.createElement("input");1197111972input.type = "time";11973input.style.padding = "4px";11974input.style.width = "100%";11975input.style.boxSizing = "border-box";1197611977if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){11978for (let key in editorParams.elementAttributes){11979if(key.charAt(0) == "+"){11980key = key.slice(1);11981input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);11982}else {11983input.setAttribute(key, editorParams.elementAttributes[key]);11984}11985}11986}1198711988cellValue = typeof cellValue !== "undefined" ? cellValue : "";1198911990if(inputFormat){11991if(DT){11992if(DT.isDateTime(cellValue)){11993newDatetime = cellValue;11994}else if(inputFormat === "iso"){11995newDatetime = DT.fromISO(String(cellValue));11996}else {11997newDatetime = DT.fromFormat(String(cellValue), inputFormat);11998}1199912000cellValue = newDatetime.toFormat("hh:mm");1200112002}else {12003console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");12004}12005}1200612007input.value = cellValue;1200812009onRendered(function(){12010if(cell.getType() == "cell"){12011input.focus({preventScroll: true});12012input.style.height = "100%";1201312014if(editorParams.selectContents){12015input.select();12016}12017}12018});1201912020function onChange(){12021var value = input.value,12022luxTime;1202312024if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){1202512026if(value && inputFormat){12027luxTime = DT.fromFormat(String(value), "hh:mm");1202812029switch(inputFormat){12030case true:12031value = luxTime;12032break;1203312034case "iso":12035value = luxTime.toISO();12036break;1203712038default:12039value = luxTime.toFormat(inputFormat);12040}12041}1204212043if(success(value)){12044cellValue = input.value; //persist value if successfully validated incase editor is used as header filter12045}12046}else {12047cancel();12048}12049}1205012051//submit new value on blur12052input.addEventListener("blur", function(e) {12053if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {12054onChange(); // only on a "true" blur; not when focusing browser's date/time picker12055}12056});1205712058//submit new value on enter12059input.addEventListener("keydown", function(e){12060switch(e.keyCode){12061// case 9:12062case 13:12063onChange();12064break;1206512066case 27:12067cancel();12068break;1206912070case 35:12071case 36:12072e.stopPropagation();12073break;1207412075case 38: //up arrow12076case 40: //down arrow12077if(vertNav == "editor"){12078e.stopImmediatePropagation();12079e.stopPropagation();12080}12081break;12082}12083});1208412085return input;12086}1208712088//input element12089function datetime(cell, onRendered, success, cancel, editorParams){12090var inputFormat = editorParams.format,12091vertNav = editorParams.verticalNavigation || "editor",12092DT = inputFormat ? (window.DateTime || luxon.DateTime) : null,12093newDatetime;1209412095//create and style input12096var cellValue = cell.getValue(),12097input = document.createElement("input");1209812099input.type = "datetime-local";12100input.style.padding = "4px";12101input.style.width = "100%";12102input.style.boxSizing = "border-box";1210312104if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){12105for (let key in editorParams.elementAttributes){12106if(key.charAt(0) == "+"){12107key = key.slice(1);12108input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);12109}else {12110input.setAttribute(key, editorParams.elementAttributes[key]);12111}12112}12113}1211412115cellValue = typeof cellValue !== "undefined" ? cellValue : "";1211612117if(inputFormat){12118if(DT){12119if(DT.isDateTime(cellValue)){12120newDatetime = cellValue;12121}else if(inputFormat === "iso"){12122newDatetime = DT.fromISO(String(cellValue));12123}else {12124newDatetime = DT.fromFormat(String(cellValue), inputFormat);12125}1212612127cellValue = newDatetime.toFormat("yyyy-MM-dd") + "T" + newDatetime.toFormat("hh:mm");12128}else {12129console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");12130}12131}1213212133input.value = cellValue;1213412135onRendered(function(){12136if(cell.getType() === "cell"){12137input.focus({preventScroll: true});12138input.style.height = "100%";1213912140if(editorParams.selectContents){12141input.select();12142}12143}12144});1214512146function onChange(){12147var value = input.value,12148luxDateTime;1214912150if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){1215112152if(value && inputFormat){12153luxDateTime = DT.fromISO(String(value));1215412155switch(inputFormat){12156case true:12157value = luxDateTime;12158break;1215912160case "iso":12161value = luxDateTime.toISO();12162break;1216312164default:12165value = luxDateTime.toFormat(inputFormat);12166}12167}1216812169if(success(value)){12170cellValue = input.value; //persist value if successfully validated incase editor is used as header filter12171}12172}else {12173cancel();12174}12175}1217612177//submit new value on blur12178input.addEventListener("blur", function(e) {12179if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {12180onChange(); // only on a "true" blur; not when focusing browser's date/time picker12181}12182});1218312184//submit new value on enter12185input.addEventListener("keydown", function(e){12186switch(e.keyCode){12187// case 9:12188case 13:12189onChange();12190break;1219112192case 27:12193cancel();12194break;1219512196case 35:12197case 36:12198e.stopPropagation();12199break;1220012201case 38: //up arrow12202case 40: //down arrow12203if(vertNav == "editor"){12204e.stopImmediatePropagation();12205e.stopPropagation();12206}12207break;12208}12209});1221012211return input;12212}1221312214class Edit{12215constructor(editor, cell, onRendered, success, cancel, editorParams){12216this.edit = editor;12217this.table = editor.table;12218this.cell = cell;12219this.params = this._initializeParams(editorParams);1222012221this.data = [];12222this.displayItems = [];12223this.currentItems = [];12224this.focusedItem = null;1222512226this.input = this._createInputElement();12227this.listEl = this._createListElement();1222812229this.initialValues = null;1223012231this.isFilter = cell.getType() === "header";1223212233this.filterTimeout = null;12234this.filtered = false;12235this.typing = false;1223612237this.values = [];12238this.popup = null;1223912240this.listIteration = 0;1224112242this.lastAction="";12243this.filterTerm="";1224412245this.blurable = true;1224612247this.actions = {12248success:success,12249cancel:cancel12250};1225112252this._deprecatedOptionsCheck();12253this._initializeValue();1225412255onRendered(this._onRendered.bind(this));12256}1225712258_deprecatedOptionsCheck(){12259if(this.params.listItemFormatter){12260this.cell.getTable().deprecationAdvisor.msg("The listItemFormatter editor param has been deprecated, please see the latest editor documentation for updated options");12261}1226212263if(this.params.sortValuesList){12264this.cell.getTable().deprecationAdvisor.msg("The sortValuesList editor param has been deprecated, please see the latest editor documentation for updated options");12265}1226612267if(this.params.searchFunc){12268this.cell.getTable().deprecationAdvisor.msg("The searchFunc editor param has been deprecated, please see the latest editor documentation for updated options");12269}1227012271if(this.params.searchingPlaceholder){12272this.cell.getTable().deprecationAdvisor.msg("The searchingPlaceholder editor param has been deprecated, please see the latest editor documentation for updated options");12273}12274}1227512276_initializeValue(){12277var initialValue = this.cell.getValue();1227812279if(typeof initialValue === "undefined" && typeof this.params.defaultValue !== "undefined"){12280initialValue = this.params.defaultValue;12281}1228212283this.initialValues = this.params.multiselect ? initialValue : [initialValue];1228412285if(this.isFilter){12286this.input.value = this.initialValues ? this.initialValues.join(",") : "";12287this.headerFilterInitialListGen();12288}12289}1229012291_onRendered(){12292var cellEl = this.cell.getElement();1229312294function clickStop(e){12295e.stopPropagation();12296}1229712298if(!this.isFilter){12299this.input.style.height = "100%";12300this.input.focus({preventScroll: true});12301}123021230312304cellEl.addEventListener("click", clickStop);1230512306setTimeout(() => {12307cellEl.removeEventListener("click", clickStop);12308}, 1000);1230912310this.input.addEventListener("mousedown", this._preventPopupBlur.bind(this));12311}1231212313_createListElement(){12314var listEl = document.createElement("div");12315listEl.classList.add("tabulator-edit-list");1231612317listEl.addEventListener("mousedown", this._preventBlur.bind(this));12318listEl.addEventListener("keydown", this._inputKeyDown.bind(this));1231912320return listEl;12321}1232212323_setListWidth(){12324var element = this.isFilter ? this.input : this.cell.getElement();1232512326this.listEl.style.minWidth = element.offsetWidth + "px";1232712328if(this.params.maxWidth){12329if(this.params.maxWidth === true){12330this.listEl.style.maxWidth = element.offsetWidth + "px";12331}else if(typeof this.params.maxWidth === "number"){12332this.listEl.style.maxWidth = this.params.maxWidth + "px";12333}else {12334this.listEl.style.maxWidth = this.params.maxWidth;12335}12336}1233712338}1233912340_createInputElement(){12341var attribs = this.params.elementAttributes;12342var input = document.createElement("input");1234312344input.setAttribute("type", this.params.clearable ? "search" : "text");1234512346input.style.padding = "4px";12347input.style.width = "100%";12348input.style.boxSizing = "border-box";1234912350if(!this.params.autocomplete){12351input.style.cursor = "default";12352input.style.caretColor = "transparent";12353// input.readOnly = (this.edit.currentCell != false);12354}1235512356if(attribs && typeof attribs == "object"){12357for (let key in attribs){12358if(key.charAt(0) == "+"){12359key = key.slice(1);12360input.setAttribute(key, input.getAttribute(key) + attribs["+" + key]);12361}else {12362input.setAttribute(key, attribs[key]);12363}12364}12365}1236612367if(this.params.mask){12368maskInput(input, this.params);12369}1237012371this._bindInputEvents(input);1237212373return input;12374}1237512376_initializeParams(params){12377var valueKeys = ["values", "valuesURL", "valuesLookup"],12378valueCheck;1237912380params = Object.assign({}, params);1238112382params.verticalNavigation = params.verticalNavigation || "editor";12383params.placeholderLoading = typeof params.placeholderLoading === "undefined" ? "Searching ..." : params.placeholderLoading;12384params.placeholderEmpty = typeof params.placeholderEmpty === "undefined" ? "No Results Found" : params.placeholderEmpty;12385params.filterDelay = typeof params.filterDelay === "undefined" ? 300 : params.filterDelay;1238612387params.emptyValue = Object.keys(params).includes("emptyValue") ? params.emptyValue : "";1238812389valueCheck = Object.keys(params).filter(key => valueKeys.includes(key)).length;1239012391if(!valueCheck){12392console.warn("list editor config error - either the values, valuesURL, or valuesLookup option must be set");12393}else if(valueCheck > 1){12394console.warn("list editor config error - only one of the values, valuesURL, or valuesLookup options can be set on the same editor");12395}1239612397if(params.autocomplete){12398if(params.multiselect){12399params.multiselect = false;12400console.warn("list editor config error - multiselect option is not available when autocomplete is enabled");12401}12402}else {12403if(params.freetext){12404params.freetext = false;12405console.warn("list editor config error - freetext option is only available when autocomplete is enabled");12406}1240712408if(params.filterFunc){12409params.filterFunc = false;12410console.warn("list editor config error - filterFunc option is only available when autocomplete is enabled");12411}1241212413if(params.filterRemote){12414params.filterRemote = false;12415console.warn("list editor config error - filterRemote option is only available when autocomplete is enabled");12416}1241712418if(params.mask){12419params.mask = false;12420console.warn("list editor config error - mask option is only available when autocomplete is enabled");12421}1242212423if(params.allowEmpty){12424params.allowEmpty = false;12425console.warn("list editor config error - allowEmpty option is only available when autocomplete is enabled");12426}1242712428if(params.listOnEmpty){12429params.listOnEmpty = false;12430console.warn("list editor config error - listOnEmpty option is only available when autocomplete is enabled");12431}12432}1243312434if(params.filterRemote && !(typeof params.valuesLookup === "function" || params.valuesURL)){12435params.filterRemote = false;12436console.warn("list editor config error - filterRemote option should only be used when values list is populated from a remote source");12437}12438return params;12439}12440//////////////////////////////////////12441////////// Event Handling ////////////12442//////////////////////////////////////1244312444_bindInputEvents(input){12445input.addEventListener("focus", this._inputFocus.bind(this));12446input.addEventListener("click", this._inputClick.bind(this));12447input.addEventListener("blur", this._inputBlur.bind(this));12448input.addEventListener("keydown", this._inputKeyDown.bind(this));12449input.addEventListener("search", this._inputSearch.bind(this));1245012451if(this.params.autocomplete){12452input.addEventListener("keyup", this._inputKeyUp.bind(this));12453}12454}124551245612457_inputFocus(e){12458this.rebuildOptionsList();12459}1246012461_filter(){12462if(this.params.filterRemote){12463clearTimeout(this.filterTimeout);1246412465this.filterTimeout = setTimeout(() => {12466this.rebuildOptionsList();12467}, this.params.filterDelay);12468}else {12469this._filterList();12470}12471}1247212473_inputClick(e){12474e.stopPropagation();12475}1247612477_inputBlur(e){12478if(this.blurable){12479if(this.popup){12480this.popup.hide();12481}else {12482this._resolveValue(true);12483}12484}12485}1248612487_inputSearch(){12488this._clearChoices();12489}1249012491_inputKeyDown(e){12492switch(e.keyCode){1249312494case 38: //up arrow12495this._keyUp(e);12496break;1249712498case 40: //down arrow12499this._keyDown(e);12500break;1250112502case 37: //left arrow12503case 39: //right arrow12504this._keySide(e);12505break;1250612507case 13: //enter12508this._keyEnter();12509break;1251012511case 27: //escape12512this._keyEsc();12513break;1251412515case 36: //home12516case 35: //end12517this._keyHomeEnd(e);12518break;1251912520case 9: //tab12521this._keyTab(e);12522break;1252312524default:12525this._keySelectLetter(e);12526}12527}1252812529_inputKeyUp(e){12530switch(e.keyCode){12531case 38: //up arrow12532case 37: //left arrow12533case 39: //up arrow12534case 40: //right arrow12535case 13: //enter12536case 27: //escape12537break;1253812539default:12540this._keyAutoCompLetter(e);12541}12542}1254312544_preventPopupBlur(){12545if(this.popup){12546this.popup.blockHide();12547}1254812549setTimeout(() =>{12550if(this.popup){12551this.popup.restoreHide();12552}12553}, 10);12554}1255512556_preventBlur(){12557this.blurable = false;1255812559setTimeout(() =>{12560this.blurable = true;12561}, 10);12562}1256312564//////////////////////////////////////12565//////// Keyboard Navigation /////////12566//////////////////////////////////////1256712568_keyTab(e){12569if(this.params.autocomplete && this.lastAction === "typing"){12570this._resolveValue(true);12571}else {12572if(this.focusedItem){12573this._chooseItem(this.focusedItem, true);12574}12575}12576}1257712578_keyUp(e){12579var index = this.displayItems.indexOf(this.focusedItem);1258012581if(this.params.verticalNavigation == "editor" || (this.params.verticalNavigation == "hybrid" && index)){12582e.stopImmediatePropagation();12583e.stopPropagation();12584e.preventDefault();1258512586if(index > 0){12587this._focusItem(this.displayItems[index - 1]);12588}12589}12590}1259112592_keyDown(e){12593var index = this.displayItems.indexOf(this.focusedItem);1259412595if(this.params.verticalNavigation == "editor" || (this.params.verticalNavigation == "hybrid" && index < this.displayItems.length - 1)){12596e.stopImmediatePropagation();12597e.stopPropagation();12598e.preventDefault();1259912600if(index < this.displayItems.length - 1){12601if(index == -1){12602this._focusItem(this.displayItems[0]);12603}else {12604this._focusItem(this.displayItems[index + 1]);12605}12606}12607}12608}1260912610_keySide(e){12611if(!this.params.autocomplete){12612e.stopImmediatePropagation();12613e.stopPropagation();12614e.preventDefault();12615}12616}1261712618_keyEnter(e){12619if(this.params.autocomplete && this.lastAction === "typing"){12620this._resolveValue(true);12621}else {12622if(this.focusedItem){12623this._chooseItem(this.focusedItem);12624}12625}12626}1262712628_keyEsc(e){12629this._cancel();12630}1263112632_keyHomeEnd(e){12633if(this.params.autocomplete){12634//prevent table navigation while using input element12635e.stopImmediatePropagation();12636}12637}1263812639_keySelectLetter(e){12640if(!this.params.autocomplete){12641// if(this.edit.currentCell === false){12642e.preventDefault();12643// }1264412645if(e.keyCode >= 38 && e.keyCode <= 90){12646this._scrollToValue(e.keyCode);12647}12648}12649}1265012651_keyAutoCompLetter(e){12652this._filter();12653this.lastAction = "typing";12654this.typing = true;12655}126561265712658_scrollToValue(char){12659clearTimeout(this.filterTimeout);1266012661var character = String.fromCharCode(char).toLowerCase();12662this.filterTerm += character.toLowerCase();1266312664var match = this.displayItems.find((item) => {12665return typeof item.label !== "undefined" && item.label.toLowerCase().startsWith(this.filterTerm);12666});1266712668if(match){12669this._focusItem(match);12670}1267112672this.filterTimeout = setTimeout(() => {12673this.filterTerm = "";12674}, 800);12675}1267612677_focusItem(item){12678this.lastAction = "focus";1267912680if(this.focusedItem && this.focusedItem.element){12681this.focusedItem.element.classList.remove("focused");12682}1268312684this.focusedItem = item;1268512686if(item && item.element){12687item.element.classList.add("focused");12688item.element.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'start'});12689}12690}126911269212693//////////////////////////////////////12694/////// Data List Generation /////////12695//////////////////////////////////////12696headerFilterInitialListGen(){12697this._generateOptions(true);12698}1269912700rebuildOptionsList(){12701this._generateOptions()12702.then(this._sortOptions.bind(this))12703.then(this._buildList.bind(this))12704.then(this._showList.bind(this))12705.catch((e) => {12706if(!Number.isInteger(e)){12707console.error("List generation error", e);12708}12709});12710}1271112712_filterList(){12713this._buildList(this._filterOptions());12714this._showList();12715}1271612717_generateOptions(silent){12718var values = [];12719var iteration = ++ this.listIteration;1272012721this.filtered = false;1272212723if(this.params.values){12724values = this.params.values;12725}else if (this.params.valuesURL){12726values = this._ajaxRequest(this.params.valuesURL, this.input.value);12727}else {12728if(typeof this.params.valuesLookup === "function"){12729values = this.params.valuesLookup(this.cell, this.input.value);12730}else if(this.params.valuesLookup){12731values = this._uniqueColumnValues(this.params.valuesLookupField);12732}12733}1273412735if(values instanceof Promise){12736if(!silent){12737this._addPlaceholder(this.params.placeholderLoading);12738}1273912740return values.then()12741.then((responseValues) => {12742if(this.listIteration === iteration){12743return this._parseList(responseValues);12744}else {12745return Promise.reject(iteration);12746}12747});12748}else {12749return Promise.resolve(this._parseList(values));12750}12751}1275212753_addPlaceholder(contents){12754var placeholder = document.createElement("div");1275512756if(typeof contents === "function"){12757contents = contents(this.cell.getComponent(), this.listEl);12758}1275912760if(contents){12761this._clearList();1276212763if(contents instanceof HTMLElement){12764placeholder = contents;12765}else {12766placeholder.classList.add("tabulator-edit-list-placeholder");12767placeholder.innerHTML = contents;12768}1276912770this.listEl.appendChild(placeholder);1277112772this._showList();12773}12774}1277512776_ajaxRequest(url, term){12777var params = this.params.filterRemote ? {term:term} : {};12778url = urlBuilder(url, {}, params);1277912780return fetch(url)12781.then((response)=>{12782if(response.ok) {12783return response.json()12784.catch((error)=>{12785console.warn("List Ajax Load Error - Invalid JSON returned", error);12786return Promise.reject(error);12787});12788}else {12789console.error("List Ajax Load Error - Connection Error: " + response.status, response.statusText);12790return Promise.reject(response);12791}12792})12793.catch((error)=>{12794console.error("List Ajax Load Error - Connection Error: ", error);12795return Promise.reject(error);12796});12797}1279812799_uniqueColumnValues(field){12800var output = {},12801data = this.table.getData(this.params.valuesLookup),12802column;1280312804if(field){12805column = this.table.columnManager.getColumnByField(field);12806}else {12807column = this.cell.getColumn()._getSelf();12808}1280912810if(column){12811data.forEach((row) => {12812var val = column.getFieldValue(row);1281312814if(val !== null && typeof val !== "undefined" && val !== ""){12815output[val] = true;12816}12817});12818}else {12819console.warn("unable to find matching column to create select lookup list:", field);12820output = [];12821}1282212823return Object.keys(output);12824}128251282612827_parseList(inputValues){12828var data = [];1282912830if(!Array.isArray(inputValues)){12831inputValues = Object.entries(inputValues).map(([key, value]) => {12832return {12833label:value,12834value:key,12835};12836});12837}1283812839inputValues.forEach((value) => {12840if(typeof value !== "object"){12841value = {12842label:value,12843value:value,12844};12845}1284612847this._parseListItem(value, data, 0);12848});1284912850if(!this.currentItems.length && this.params.freetext){12851this.input.value = this.initialValues;12852this.typing = true;12853this.lastAction = "typing";12854}1285512856this.data = data;1285712858return data;12859}1286012861_parseListItem(option, data, level){12862var item = {};1286312864if(option.options){12865item = this._parseListGroup(option, level + 1);12866}else {12867item = {12868label:option.label,12869value:option.value,12870itemParams:option.itemParams,12871elementAttributes: option.elementAttributes,12872element:false,12873selected:false,12874visible:true,12875level:level,12876original:option,12877};1287812879if(this.initialValues && this.initialValues.indexOf(option.value) > -1){12880this._chooseItem(item, true);12881}12882}1288312884data.push(item);12885}1288612887_parseListGroup(option, level){12888var item = {12889label:option.label,12890group:true,12891itemParams:option.itemParams,12892elementAttributes:option.elementAttributes,12893element:false,12894visible:true,12895level:level,12896options:[],12897original:option,12898};1289912900option.options.forEach((child) => {12901this._parseListItem(child, item.options, level);12902});1290312904return item;12905}1290612907_sortOptions(options){12908var sorter;1290912910if(this.params.sort){12911sorter = typeof this.params.sort === "function" ? this.params.sort : this._defaultSortFunction.bind(this);1291212913this._sortGroup(sorter, options);12914}1291512916return options;12917}1291812919_sortGroup(sorter, options){12920options.sort((a,b) => {12921return sorter(a.label, b.label, a.value, b.value, a.original, b.original);12922});1292312924options.forEach((option) => {12925if(option.group){12926this._sortGroup(sorter, option.options);12927}12928});12929}1293012931_defaultSortFunction(as, bs){12932var a, b, a1, b1, i= 0, L, rx = /(\d+)|(\D+)/g, rd = /\d/;12933var emptyAlign = 0;1293412935if(this.params.sort === "desc"){12936[as, bs] = [bs, as];12937}1293812939//handle empty values12940if(!as && as!== 0){12941emptyAlign = !bs && bs!== 0 ? 0 : -1;12942}else if(!bs && bs!== 0){12943emptyAlign = 1;12944}else {12945if(isFinite(as) && isFinite(bs)) return as - bs;12946a = String(as).toLowerCase();12947b = String(bs).toLowerCase();12948if(a === b) return 0;12949if(!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;12950a = a.match(rx);12951b = b.match(rx);12952L = a.length > b.length ? b.length : a.length;12953while(i < L){12954a1= a[i];12955b1= b[i++];12956if(a1 !== b1){12957if(isFinite(a1) && isFinite(b1)){12958if(a1.charAt(0) === "0") a1 = "." + a1;12959if(b1.charAt(0) === "0") b1 = "." + b1;12960return a1 - b1;12961}12962else return a1 > b1 ? 1 : -1;12963}12964}1296512966return a.length > b.length;12967}1296812969return emptyAlign;12970}1297112972_filterOptions(){12973var filterFunc = this.params.filterFunc || this._defaultFilterFunc,12974term = this.input.value;1297512976if(term){12977this.filtered = true;1297812979this.data.forEach((item) => {12980this._filterItem(filterFunc, term, item);12981});12982}else {12983this.filtered = false;12984}1298512986return this.data;12987}1298812989_filterItem(func, term, item){12990var matches = false;1299112992if(!item.group){12993item.visible = func(term, item.label, item.value, item.original);12994}else {12995item.options.forEach((option) => {12996if(this._filterItem(func, term, option)){12997matches = true;12998}12999});1300013001item.visible = matches;13002}1300313004return item.visible;13005}1300613007_defaultFilterFunc(term, label, value, item){13008term = String(term).toLowerCase();1300913010if(label !== null && typeof label !== "undefined"){13011if(String(label).toLowerCase().indexOf(term) > -1 || String(value).toLowerCase().indexOf(term) > -1){13012return true;13013}13014}1301513016return false;13017}1301813019//////////////////////////////////////13020/////////// Display List /////////////13021//////////////////////////////////////1302213023_clearList(){13024while(this.listEl.firstChild) this.listEl.removeChild(this.listEl.firstChild);1302513026this.displayItems = [];13027}1302813029_buildList(data){13030this._clearList();1303113032data.forEach((option) => {13033this._buildItem(option);13034});1303513036if(!this.displayItems.length){13037this._addPlaceholder(this.params.placeholderEmpty);13038}13039}1304013041_buildItem(item){13042var el = item.element,13043contents;1304413045if(!this.filtered || item.visible){1304613047if(!el){13048el = document.createElement("div");13049el.tabIndex = 0;1305013051contents = this.params.itemFormatter ? this.params.itemFormatter(item.label, item.value, item.original, el) : item.label;1305213053if(contents instanceof HTMLElement){13054el.appendChild(contents);13055}else {13056el.innerHTML = contents;13057}1305813059if(item.group){13060el.classList.add("tabulator-edit-list-group");13061}else {13062el.classList.add("tabulator-edit-list-item");13063}1306413065el.classList.add("tabulator-edit-list-group-level-" + item.level);1306613067if(item.elementAttributes && typeof item.elementAttributes == "object"){13068for (let key in item.elementAttributes){13069if(key.charAt(0) == "+"){13070key = key.slice(1);13071el.setAttribute(key, this.input.getAttribute(key) + item.elementAttributes["+" + key]);13072}else {13073el.setAttribute(key, item.elementAttributes[key]);13074}13075}13076}1307713078if(item.group){13079el.addEventListener("click", this._groupClick.bind(this, item));13080}else {13081el.addEventListener("click", this._itemClick.bind(this, item));13082}1308313084el.addEventListener("mousedown", this._preventBlur.bind(this));1308513086item.element = el;13087}1308813089this._styleItem(item);1309013091this.listEl.appendChild(el);1309213093if(item.group){13094item.options.forEach((option) => {13095this._buildItem(option);13096});13097}else {13098this.displayItems.push(item);13099}13100}13101}1310213103_showList(){13104var startVis = this.popup && this.popup.isVisible();1310513106if(this.input.parentNode){13107if(this.params.autocomplete && this.input.value === "" && !this.params.listOnEmpty){13108if(this.popup){13109this.popup.hide(true);13110}13111return;13112}1311313114this._setListWidth();1311513116if(!this.popup){13117this.popup = this.edit.popup(this.listEl);13118}1311913120this.popup.show(this.cell.getElement(), "bottom");1312113122if(!startVis){13123setTimeout(() => {13124this.popup.hideOnBlur(this._resolveValue.bind(this, true));13125}, 10);13126}13127}13128}1312913130_styleItem(item){13131if(item && item.element){13132if(item.selected){13133item.element.classList.add("active");13134}else {13135item.element.classList.remove("active");13136}13137}13138}1313913140//////////////////////////////////////13141///////// User Interaction ///////////13142//////////////////////////////////////1314313144_itemClick(item, e){13145e.stopPropagation();1314613147this._chooseItem(item);13148}1314913150_groupClick(item, e){13151e.stopPropagation();13152}131531315413155//////////////////////////////////////13156////// Current Item Management ///////13157//////////////////////////////////////1315813159_cancel(){13160this.popup.hide(true);13161this.actions.cancel();13162}1316313164_clearChoices(){13165this.typing = true;1316613167this.currentItems.forEach((item) => {13168item.selected = false;13169this._styleItem(item);13170});1317113172this.currentItems = [];1317313174this.focusedItem = null;13175}1317613177_chooseItem(item, silent){13178var index;1317913180this.typing = false;1318113182if(this.params.multiselect){13183index = this.currentItems.indexOf(item);1318413185if(index > -1){13186this.currentItems.splice(index, 1);13187item.selected = false;13188}else {13189this.currentItems.push(item);13190item.selected = true;13191}1319213193this.input.value = this.currentItems.map(item => item.label).join(",");1319413195this._styleItem(item);1319613197}else {13198this.currentItems = [item];13199item.selected = true;1320013201this.input.value = item.label;1320213203this._styleItem(item);1320413205if(!silent){13206this._resolveValue();13207}13208}1320913210this._focusItem(item);13211}1321213213_resolveValue(blur){13214var output, initialValue;1321513216if(this.popup){13217this.popup.hide(true);13218}1321913220if(this.params.multiselect){13221output = this.currentItems.map(item => item.value);13222}else {13223if(blur && this.params.autocomplete && this.typing){13224if(this.params.freetext || (this.params.allowEmpty && this.input.value === "")){13225output = this.input.value;13226}else {13227this.actions.cancel();13228return;13229}13230}else {13231if(this.currentItems[0]){13232output = this.currentItems[0].value;13233}else {13234initialValue = Array.isArray(this.initialValues) ? this.initialValues[0] : this.initialValues;1323513236if(initialValue === null || typeof initialValue === "undefined" || initialValue === ""){13237output = initialValue;13238}else {13239output = this.params.emptyValue;13240}13241}1324213243}13244}1324513246if(output === ""){13247output = this.params.emptyValue;13248}1324913250this.actions.success(output);1325113252if(this.isFilter){13253this.initialValues = output && !Array.isArray(output) ? [output] : output;13254this.currentItems = [];13255}13256}1325713258}1325913260function select(cell, onRendered, success, cancel, editorParams){1326113262this.deprecationMsg("The select editor has been deprecated, please use the new list editor");1326313264var list = new Edit(this, cell, onRendered, success, cancel, editorParams);1326513266return list.input;13267}1326813269function list(cell, onRendered, success, cancel, editorParams){13270var list = new Edit(this, cell, onRendered, success, cancel, editorParams);1327113272return list.input;13273}1327413275function autocomplete(cell, onRendered, success, cancel, editorParams){1327613277this.deprecationMsg("The autocomplete editor has been deprecated, please use the new list editor with the 'autocomplete' editorParam");1327813279editorParams.autocomplete = true;1328013281var list = new Edit(this, cell, onRendered, success, cancel, editorParams);1328213283return list.input;13284}1328513286//star rating13287function star(cell, onRendered, success, cancel, editorParams){13288var self = this,13289element = cell.getElement(),13290value = cell.getValue(),13291maxStars = element.getElementsByTagName("svg").length || 5,13292size = element.getElementsByTagName("svg")[0] ? element.getElementsByTagName("svg")[0].getAttribute("width") : 14,13293stars = [],13294starsHolder = document.createElement("div"),13295star = document.createElementNS('http://www.w3.org/2000/svg', "svg");132961329713298//change star type13299function starChange(val){13300stars.forEach(function(star, i){13301if(i < val){13302if(self.table.browser == "ie"){13303star.setAttribute("class", "tabulator-star-active");13304}else {13305star.classList.replace("tabulator-star-inactive", "tabulator-star-active");13306}1330713308star.innerHTML = '<polygon fill="#488CE9" stroke="#014AAE" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';13309}else {13310if(self.table.browser == "ie"){13311star.setAttribute("class", "tabulator-star-inactive");13312}else {13313star.classList.replace("tabulator-star-active", "tabulator-star-inactive");13314}1331513316star.innerHTML = '<polygon fill="#010155" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';13317}13318});13319}1332013321//build stars13322function buildStar(i){1332313324var starHolder = document.createElement("span");13325var nextStar = star.cloneNode(true);1332613327stars.push(nextStar);1332813329starHolder.addEventListener("mouseenter", function(e){13330e.stopPropagation();13331e.stopImmediatePropagation();13332starChange(i);13333});1333413335starHolder.addEventListener("mousemove", function(e){13336e.stopPropagation();13337e.stopImmediatePropagation();13338});1333913340starHolder.addEventListener("click", function(e){13341e.stopPropagation();13342e.stopImmediatePropagation();13343success(i);13344element.blur();13345});1334613347starHolder.appendChild(nextStar);13348starsHolder.appendChild(starHolder);1334913350}1335113352//handle keyboard navigation value change13353function changeValue(val){13354value = val;13355starChange(val);13356}1335713358//style cell13359element.style.whiteSpace = "nowrap";13360element.style.overflow = "hidden";13361element.style.textOverflow = "ellipsis";1336213363//style holding element13364starsHolder.style.verticalAlign = "middle";13365starsHolder.style.display = "inline-block";13366starsHolder.style.padding = "4px";1336713368//style star13369star.setAttribute("width", size);13370star.setAttribute("height", size);13371star.setAttribute("viewBox", "0 0 512 512");13372star.setAttribute("xml:space", "preserve");13373star.style.padding = "0 1px";1337413375if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){13376for (let key in editorParams.elementAttributes){13377if(key.charAt(0) == "+"){13378key = key.slice(1);13379starsHolder.setAttribute(key, starsHolder.getAttribute(key) + editorParams.elementAttributes["+" + key]);13380}else {13381starsHolder.setAttribute(key, editorParams.elementAttributes[key]);13382}13383}13384}1338513386//create correct number of stars13387for(var i=1;i<= maxStars;i++){13388buildStar(i);13389}1339013391//ensure value does not exceed number of stars13392value = Math.min(parseInt(value), maxStars);1339313394// set initial styling of stars13395starChange(value);1339613397starsHolder.addEventListener("mousemove", function(e){13398starChange(0);13399});1340013401starsHolder.addEventListener("click", function(e){13402success(0);13403});1340413405element.addEventListener("blur", function(e){13406cancel();13407});1340813409//allow key based navigation13410element.addEventListener("keydown", function(e){13411switch(e.keyCode){13412case 39: //right arrow13413changeValue(value + 1);13414break;1341513416case 37: //left arrow13417changeValue(value - 1);13418break;1341913420case 13: //enter13421success(value);13422break;1342313424case 27: //escape13425cancel();13426break;13427}13428});1342913430return starsHolder;13431}1343213433//draggable progress bar13434function progress(cell, onRendered, success, cancel, editorParams){13435var element = cell.getElement(),13436max = typeof editorParams.max === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("max")) || 100) : editorParams.max,13437min = typeof editorParams.min === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("min")) || 0) : editorParams.min,13438percent = (max - min) / 100,13439value = cell.getValue() || 0,13440handle = document.createElement("div"),13441bar = document.createElement("div"),13442mouseDrag, mouseDragWidth;1344313444//set new value13445function updateValue(){13446var style = window.getComputedStyle(element, null);1344713448var calcVal = (percent * Math.round(bar.offsetWidth / ((element.clientWidth - parseInt(style.getPropertyValue("padding-left")) - parseInt(style.getPropertyValue("padding-right")))/100))) + min;13449success(calcVal);13450element.setAttribute("aria-valuenow", calcVal);13451element.setAttribute("aria-label", value);13452}1345313454//style handle13455handle.style.position = "absolute";13456handle.style.right = "0";13457handle.style.top = "0";13458handle.style.bottom = "0";13459handle.style.width = "5px";13460handle.classList.add("tabulator-progress-handle");1346113462//style bar13463bar.style.display = "inline-block";13464bar.style.position = "relative";13465// bar.style.top = "8px";13466// bar.style.bottom = "8px";13467// bar.style.left = "4px";13468// bar.style.marginRight = "4px";13469bar.style.height = "100%";13470bar.style.backgroundColor = "#488CE9";13471bar.style.maxWidth = "100%";13472bar.style.minWidth = "0%";1347313474if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){13475for (let key in editorParams.elementAttributes){13476if(key.charAt(0) == "+"){13477key = key.slice(1);13478bar.setAttribute(key, bar.getAttribute(key) + editorParams.elementAttributes["+" + key]);13479}else {13480bar.setAttribute(key, editorParams.elementAttributes[key]);13481}13482}13483}1348413485//style cell13486element.style.padding = "4px 4px";1348713488//make sure value is in range13489value = Math.min(parseFloat(value), max);13490value = Math.max(parseFloat(value), min);1349113492//workout percentage13493value = Math.round((value - min) / percent);13494// bar.style.right = value + "%";13495bar.style.width = value + "%";1349613497element.setAttribute("aria-valuemin", min);13498element.setAttribute("aria-valuemax", max);1349913500bar.appendChild(handle);1350113502handle.addEventListener("mousedown", function(e){13503mouseDrag = e.screenX;13504mouseDragWidth = bar.offsetWidth;13505});1350613507handle.addEventListener("mouseover", function(){13508handle.style.cursor = "ew-resize";13509});1351013511element.addEventListener("mousemove", function(e){13512if(mouseDrag){13513bar.style.width = (mouseDragWidth + e.screenX - mouseDrag) + "px";13514}13515});1351613517element.addEventListener("mouseup", function(e){13518if(mouseDrag){13519e.stopPropagation();13520e.stopImmediatePropagation();1352113522mouseDrag = false;13523mouseDragWidth = false;1352413525updateValue();13526}13527});1352813529//allow key based navigation13530element.addEventListener("keydown", function(e){13531switch(e.keyCode){13532case 39: //right arrow13533e.preventDefault();13534bar.style.width = (bar.clientWidth + element.clientWidth/100) + "px";13535break;1353613537case 37: //left arrow13538e.preventDefault();13539bar.style.width = (bar.clientWidth - element.clientWidth/100) + "px";13540break;1354113542case 9: //tab13543case 13: //enter13544updateValue();13545break;1354613547case 27: //escape13548cancel();13549break;1355013551}13552});1355313554element.addEventListener("blur", function(){13555cancel();13556});1355713558return bar;13559}1356013561//checkbox13562function tickCross(cell, onRendered, success, cancel, editorParams){13563var value = cell.getValue(),13564input = document.createElement("input"),13565tristate = editorParams.tristate,13566indetermValue = typeof editorParams.indeterminateValue === "undefined" ? null : editorParams.indeterminateValue,13567indetermState = false,13568trueValueSet = Object.keys(editorParams).includes("trueValue"),13569falseValueSet = Object.keys(editorParams).includes("falseValue");1357013571input.setAttribute("type", "checkbox");13572input.style.marginTop = "5px";13573input.style.boxSizing = "border-box";1357413575if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){13576for (let key in editorParams.elementAttributes){13577if(key.charAt(0) == "+"){13578key = key.slice(1);13579input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);13580}else {13581input.setAttribute(key, editorParams.elementAttributes[key]);13582}13583}13584}1358513586input.value = value;1358713588if(tristate && (typeof value === "undefined" || value === indetermValue || value === "")){13589indetermState = true;13590input.indeterminate = true;13591}1359213593if(this.table.browser != "firefox" && this.table.browser != "safari"){ //prevent blur issue on mac firefox13594onRendered(function(){13595if(cell.getType() === "cell"){13596input.focus({preventScroll: true});13597}13598});13599}1360013601input.checked = trueValueSet ? value === editorParams.trueValue : (value === true || value === "true" || value === "True" || value === 1);1360213603function setValue(blur){13604var checkedValue = input.checked;1360513606if(trueValueSet && checkedValue){13607checkedValue = editorParams.trueValue;13608}else if(falseValueSet && !checkedValue){13609checkedValue = editorParams.falseValue;13610}1361113612if(tristate){13613if(!blur){13614if(input.checked && !indetermState){13615input.checked = false;13616input.indeterminate = true;13617indetermState = true;13618return indetermValue;13619}else {13620indetermState = false;13621return checkedValue;13622}13623}else {13624if(indetermState){13625return indetermValue;13626}else {13627return checkedValue;13628}13629}13630}else {13631return checkedValue;13632}13633}1363413635//submit new value on blur13636input.addEventListener("change", function(e){13637success(setValue());13638});1363913640input.addEventListener("blur", function(e){13641success(setValue(true));13642});1364313644//submit new value on enter13645input.addEventListener("keydown", function(e){13646if(e.keyCode == 13){13647success(setValue());13648}13649if(e.keyCode == 27){13650cancel();13651}13652});1365313654return input;13655}1365613657var defaultEditors = {13658input:input,13659textarea:textarea,13660number:number,13661range:range,13662date:date,13663time:time,13664datetime:datetime,13665select:select,13666list:list,13667autocomplete:autocomplete,13668star:star,13669progress:progress,13670tickCross:tickCross,13671};1367213673class Edit$1 extends Module{1367413675constructor(table){13676super(table);1367713678this.currentCell = false; //hold currently editing cell13679this.mouseClick = false; //hold mousedown state to prevent click binding being overridden by editor opening13680this.recursionBlock = false; //prevent focus recursion13681this.invalidEdit = false;13682this.editedCells = [];1368313684this.editors = Edit$1.editors;1368513686this.registerColumnOption("editable");13687this.registerColumnOption("editor");13688this.registerColumnOption("editorParams");1368913690this.registerColumnOption("cellEditing");13691this.registerColumnOption("cellEdited");13692this.registerColumnOption("cellEditCancelled");1369313694this.registerTableFunction("getEditedCells", this.getEditedCells.bind(this));13695this.registerTableFunction("clearCellEdited", this.clearCellEdited.bind(this));13696this.registerTableFunction("navigatePrev", this.navigatePrev.bind(this));13697this.registerTableFunction("navigateNext", this.navigateNext.bind(this));13698this.registerTableFunction("navigateLeft", this.navigateLeft.bind(this));13699this.registerTableFunction("navigateRight", this.navigateRight.bind(this));13700this.registerTableFunction("navigateUp", this.navigateUp.bind(this));13701this.registerTableFunction("navigateDown", this.navigateDown.bind(this));1370213703this.registerComponentFunction("cell", "isEdited", this.cellIsEdited.bind(this));13704this.registerComponentFunction("cell", "clearEdited", this.clearEdited.bind(this));13705this.registerComponentFunction("cell", "edit", this.editCell.bind(this));13706this.registerComponentFunction("cell", "cancelEdit", this.cellCancelEdit.bind(this));1370713708this.registerComponentFunction("cell", "navigatePrev", this.navigatePrev.bind(this));13709this.registerComponentFunction("cell", "navigateNext", this.navigateNext.bind(this));13710this.registerComponentFunction("cell", "navigateLeft", this.navigateLeft.bind(this));13711this.registerComponentFunction("cell", "navigateRight", this.navigateRight.bind(this));13712this.registerComponentFunction("cell", "navigateUp", this.navigateUp.bind(this));13713this.registerComponentFunction("cell", "navigateDown", this.navigateDown.bind(this));13714}1371513716initialize(){13717this.subscribe("cell-init", this.bindEditor.bind(this));13718this.subscribe("cell-delete", this.clearEdited.bind(this));13719this.subscribe("cell-value-changed", this.updateCellClass.bind(this));13720this.subscribe("column-layout", this.initializeColumnCheck.bind(this));13721this.subscribe("column-delete", this.columnDeleteCheck.bind(this));13722this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));13723this.subscribe("row-layout", this.rowEditableCheck.bind(this));13724this.subscribe("data-refreshing", this.cancelEdit.bind(this));1372513726this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));13727this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));13728this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined));13729this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined));13730this.subscribe("keybinding-nav-up", this.navigateUp.bind(this, undefined));13731this.subscribe("keybinding-nav-down", this.navigateDown.bind(this, undefined));13732}137331373413735///////////////////////////////////13736////// Keybinding Functions ///////13737///////////////////////////////////1373813739keybindingNavigateNext(e){13740var cell = this.currentCell,13741newRow = this.options("tabEndNewRow");1374213743if(cell){13744if(!this.navigateNext(cell, e)){13745if(newRow){13746cell.getElement().firstChild.blur();1374713748if(newRow === true){13749newRow = this.table.addRow({});13750}else {13751if(typeof newRow == "function"){13752newRow = this.table.addRow(newRow(cell.row.getComponent()));13753}else {13754newRow = this.table.addRow(Object.assign({}, newRow));13755}13756}1375713758newRow.then(() => {13759setTimeout(() => {13760cell.getComponent().navigateNext();13761});13762});13763}13764}13765}13766}1376713768///////////////////////////////////13769///////// Cell Functions //////////13770///////////////////////////////////1377113772cellIsEdited(cell){13773return !! cell.modules.edit && cell.modules.edit.edited;13774}1377513776cellCancelEdit(cell){13777if(cell === this.currentCell){13778this.table.modules.edit.cancelEdit();13779}else {13780console.warn("Cancel Editor Error - This cell is not currently being edited ");13781}13782}137831378413785///////////////////////////////////13786///////// Table Functions /////////13787///////////////////////////////////13788updateCellClass(cell){13789if(this.allowEdit(cell)) {13790cell.getElement().classList.add("tabulator-editable");13791}13792else {13793cell.getElement().classList.remove("tabulator-editable");13794}13795}1379613797clearCellEdited(cells){13798if(!cells){13799cells = this.table.modules.edit.getEditedCells();13800}1380113802if(!Array.isArray(cells)){13803cells = [cells];13804}1380513806cells.forEach((cell) => {13807this.table.modules.edit.clearEdited(cell._getSelf());13808});13809}1381013811navigatePrev(cell = this.currentCell, e){13812var nextCell, prevRow;1381313814if(cell){1381513816if(e){13817e.preventDefault();13818}1381913820nextCell = this.navigateLeft();1382113822if(nextCell){13823return true;13824}else {13825prevRow = this.table.rowManager.prevDisplayRow(cell.row, true);1382613827if(prevRow){13828nextCell = this.findPrevEditableCell(prevRow, prevRow.cells.length);1382913830if(nextCell){13831nextCell.getComponent().edit();13832return true;13833}13834}13835}13836}1383713838return false;13839}1384013841navigateNext(cell = this.currentCell, e){13842var nextCell, nextRow;1384313844if(cell){1384513846if(e){13847e.preventDefault();13848}1384913850nextCell = this.navigateRight();1385113852if(nextCell){13853return true;13854}else {13855nextRow = this.table.rowManager.nextDisplayRow(cell.row, true);1385613857if(nextRow){13858nextCell = this.findNextEditableCell(nextRow, -1);1385913860if(nextCell){13861nextCell.getComponent().edit();13862return true;13863}13864}13865}13866}1386713868return false;13869}1387013871navigateLeft(cell = this.currentCell, e){13872var index, nextCell;1387313874if(cell){1387513876if(e){13877e.preventDefault();13878}1387913880index = cell.getIndex();13881nextCell = this.findPrevEditableCell(cell.row, index);1388213883if(nextCell){13884nextCell.getComponent().edit();13885return true;13886}13887}1388813889return false;13890}1389113892navigateRight(cell = this.currentCell, e){13893var index, nextCell;1389413895if(cell){1389613897if(e){13898e.preventDefault();13899}1390013901index = cell.getIndex();13902nextCell = this.findNextEditableCell(cell.row, index);1390313904if(nextCell){13905nextCell.getComponent().edit();13906return true;13907}13908}1390913910return false;13911}1391213913navigateUp(cell = this.currentCell, e){13914var index, nextRow;1391513916if(cell){1391713918if(e){13919e.preventDefault();13920}1392113922index = cell.getIndex();13923nextRow = this.table.rowManager.prevDisplayRow(cell.row, true);1392413925if(nextRow){13926nextRow.cells[index].getComponent().edit();13927return true;13928}13929}1393013931return false;13932}1393313934navigateDown(cell = this.currentCell, e){13935var index, nextRow;1393613937if(cell){1393813939if(e){13940e.preventDefault();13941}1394213943index = cell.getIndex();13944nextRow = this.table.rowManager.nextDisplayRow(cell.row, true);1394513946if(nextRow){13947nextRow.cells[index].getComponent().edit();13948return true;13949}13950}1395113952return false;13953}1395413955findNextEditableCell(row, index){13956var nextCell = false;1395713958if(index < row.cells.length-1){13959for(var i = index+1; i < row.cells.length; i++){13960let cell = row.cells[i];1396113962if(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){13963let allowEdit = this.allowEdit(cell);1396413965if(allowEdit){13966nextCell = cell;13967break;13968}13969}13970}13971}1397213973return nextCell;13974}1397513976findPrevEditableCell(row, index){13977var prevCell = false;1397813979if(index > 0){13980for(var i = index-1; i >= 0; i--){13981let cell = row.cells[i];1398213983if(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){13984let allowEdit = this.allowEdit(cell);1398513986if(allowEdit){13987prevCell = cell;13988break;13989}13990}13991}13992}1399313994return prevCell;13995}1399613997///////////////////////////////////13998///////// Internal Logic //////////13999///////////////////////////////////1400014001initializeColumnCheck(column){14002if(typeof column.definition.editor !== "undefined"){14003this.initializeColumn(column);14004}14005}1400614007columnDeleteCheck(column){14008if(this.currentCell && this.currentCell.column === column){14009this.cancelEdit();14010}14011}1401214013rowDeleteCheck(row){14014if(this.currentCell && this.currentCell.row === row){14015this.cancelEdit();14016}14017}1401814019rowEditableCheck(row){14020row.getCells().forEach((cell) => {14021if(cell.column.modules.edit && typeof cell.column.modules.edit.check === "function"){14022this.updateCellClass(cell);14023}14024});14025}1402614027//initialize column editor14028initializeColumn(column){14029var config = {14030editor:false,14031blocked:false,14032check:column.definition.editable,14033params:column.definition.editorParams || {}14034};1403514036//set column editor14037switch(typeof column.definition.editor){14038case "string":14039if(this.editors[column.definition.editor]){14040config.editor = this.editors[column.definition.editor];14041}else {14042console.warn("Editor Error - No such editor found: ", column.definition.editor);14043}14044break;1404514046case "function":14047config.editor = column.definition.editor;14048break;1404914050case "boolean":14051if(column.definition.editor === true){14052if(typeof column.definition.formatter !== "function"){14053if(this.editors[column.definition.formatter]){14054config.editor = this.editors[column.definition.formatter];14055}else {14056config.editor = this.editors["input"];14057}14058}else {14059console.warn("Editor Error - Cannot auto lookup editor for a custom formatter: ", column.definition.formatter);14060}14061}14062break;14063}1406414065if(config.editor){14066column.modules.edit = config;14067}14068}1406914070getCurrentCell(){14071return this.currentCell ? this.currentCell.getComponent() : false;14072}1407314074clearEditor(cancel){14075var cell = this.currentCell,14076cellEl;1407714078this.invalidEdit = false;1407914080if(cell){14081this.currentCell = false;1408214083cellEl = cell.getElement();1408414085this.dispatch("edit-editor-clear", cell, cancel);1408614087cellEl.classList.remove("tabulator-editing");1408814089while(cellEl.firstChild) cellEl.removeChild(cellEl.firstChild);1409014091cell.row.getElement().classList.remove("tabulator-editing");1409214093cell.table.element.classList.remove("tabulator-editing");14094}14095}1409614097cancelEdit(){14098if(this.currentCell){14099var cell = this.currentCell;14100var component = this.currentCell.getComponent();1410114102this.clearEditor(true);14103cell.setValueActual(cell.getValue());14104cell.cellRendered();1410514106if(cell.column.definition.editor == "textarea" || cell.column.definition.variableHeight){14107cell.row.normalizeHeight(true);14108}1410914110if(cell.column.definition.cellEditCancelled){14111cell.column.definition.cellEditCancelled.call(this.table, component);14112}1411314114this.dispatch("edit-cancelled", cell);14115this.dispatchExternal("cellEditCancelled", component);14116}14117}1411814119//return a formatted value for a cell14120bindEditor(cell){14121if(cell.column.modules.edit){14122var self = this,14123element = cell.getElement(true);1412414125this.updateCellClass(cell);14126element.setAttribute("tabindex", 0);1412714128element.addEventListener("click", function(e){14129if(!element.classList.contains("tabulator-editing")){14130element.focus({preventScroll: true});14131}14132});1413314134element.addEventListener("mousedown", function(e){14135if (e.button === 2) {14136e.preventDefault();14137}else {14138self.mouseClick = true;14139}14140});1414114142element.addEventListener("focus", function(e){14143if(!self.recursionBlock){14144self.edit(cell, e, false);14145}14146});14147}14148}1414914150focusCellNoEvent(cell, block){14151this.recursionBlock = true;1415214153if(!(block && this.table.browser === "ie")){14154cell.getElement().focus({preventScroll: true});14155}1415614157this.recursionBlock = false;14158}1415914160editCell(cell, forceEdit){14161this.focusCellNoEvent(cell);14162this.edit(cell, false, forceEdit);14163}1416414165focusScrollAdjust(cell){14166if(this.table.rowManager.getRenderMode() == "virtual"){14167var topEdge = this.table.rowManager.element.scrollTop,14168bottomEdge = this.table.rowManager.element.clientHeight + this.table.rowManager.element.scrollTop,14169rowEl = cell.row.getElement();1417014171if(rowEl.offsetTop < topEdge){14172this.table.rowManager.element.scrollTop -= (topEdge - rowEl.offsetTop);14173}else {14174if(rowEl.offsetTop + rowEl.offsetHeight > bottomEdge){14175this.table.rowManager.element.scrollTop += (rowEl.offsetTop + rowEl.offsetHeight - bottomEdge);14176}14177}1417814179var leftEdge = this.table.rowManager.element.scrollLeft,14180rightEdge = this.table.rowManager.element.clientWidth + this.table.rowManager.element.scrollLeft,14181cellEl = cell.getElement();1418214183if(this.table.modExists("frozenColumns")){14184leftEdge += parseInt(this.table.modules.frozenColumns.leftMargin || 0);14185rightEdge -= parseInt(this.table.modules.frozenColumns.rightMargin || 0);14186}1418714188if(this.table.options.renderHorizontal === "virtual"){14189leftEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft);14190rightEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft);14191}1419214193if(cellEl.offsetLeft < leftEdge){14194this.table.rowManager.element.scrollLeft -= (leftEdge - cellEl.offsetLeft);14195}else {14196if(cellEl.offsetLeft + cellEl.offsetWidth > rightEdge){14197this.table.rowManager.element.scrollLeft += (cellEl.offsetLeft + cellEl.offsetWidth - rightEdge);14198}14199}14200}14201}1420214203allowEdit(cell) {14204var check = cell.column.modules.edit ? true : false;1420514206if(cell.column.modules.edit){14207switch(typeof cell.column.modules.edit.check){14208case "function":14209if(cell.row.initialized){14210check = cell.column.modules.edit.check(cell.getComponent());14211}14212break;1421314214case "string":14215check = !!cell.row.data[cell.column.modules.edit.check];14216break;1421714218case "boolean":14219check = cell.column.modules.edit.check;14220break;14221}14222}1422314224return check;14225}1422614227edit(cell, e, forceEdit){14228var self = this,14229allowEdit = true,14230rendered = function(){},14231element = cell.getElement(),14232cellEditor, component, params;1423314234//prevent editing if another cell is refusing to leave focus (eg. validation fail)1423514236if(this.currentCell){14237if(!this.invalidEdit && this.currentCell !== cell){14238this.cancelEdit();14239}14240return;14241}1424214243//handle successful value change14244function success(value){14245if(self.currentCell === cell){14246var valid = self.chain("edit-success", [cell, value], true, true);1424714248if(valid === true || self.table.options.validationMode === "highlight"){14249self.clearEditor();142501425114252if(!cell.modules.edit){14253cell.modules.edit = {};14254}1425514256cell.modules.edit.edited = true;1425714258if(self.editedCells.indexOf(cell) == -1){14259self.editedCells.push(cell);14260}1426114262cell.setValue(value, true);1426314264return valid === true;14265}else {14266self.invalidEdit = true;14267self.focusCellNoEvent(cell, true);14268rendered();14269return false;14270}14271}14272}1427314274//handle aborted edit14275function cancel(){14276if(self.currentCell === cell){14277self.cancelEdit();14278}14279}1428014281function onRendered(callback){14282rendered = callback;14283}1428414285if(!cell.column.modules.edit.blocked){14286if(e){14287e.stopPropagation();14288}1428914290allowEdit = this.allowEdit(cell);1429114292if(allowEdit || forceEdit){1429314294self.cancelEdit();1429514296self.currentCell = cell;1429714298this.focusScrollAdjust(cell);1429914300component = cell.getComponent();1430114302if(this.mouseClick){14303this.mouseClick = false;1430414305if(cell.column.definition.cellClick){14306cell.column.definition.cellClick.call(this.table, e, component);14307}14308}1430914310if(cell.column.definition.cellEditing){14311cell.column.definition.cellEditing.call(this.table, component);14312}1431314314this.dispatch("cell-editing", cell);14315this.dispatchExternal("cellEditing", component);1431614317params = typeof cell.column.modules.edit.params === "function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;1431814319cellEditor = cell.column.modules.edit.editor.call(self, component, onRendered, success, cancel, params);1432014321//if editor returned, add to DOM, if false, abort edit14322if(this.currentCell && cellEditor !== false){14323if(cellEditor instanceof Node){14324element.classList.add("tabulator-editing");14325cell.row.getElement().classList.add("tabulator-editing");14326cell.table.element.classList.add("tabulator-editing");14327while(element.firstChild) element.removeChild(element.firstChild);14328element.appendChild(cellEditor);1432914330//trigger onRendered Callback14331rendered();1433214333//prevent editing from triggering rowClick event14334var children = element.children;1433514336for (var i = 0; i < children.length; i++) {14337children[i].addEventListener("click", function(e){14338e.stopPropagation();14339});14340}14341}else {14342console.warn("Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor);14343element.blur();14344return false;14345}14346}else {14347element.blur();14348return false;14349}1435014351return true;14352}else {14353this.mouseClick = false;14354element.blur();14355return false;14356}14357}else {14358this.mouseClick = false;14359element.blur();14360return false;14361}14362}1436314364getEditedCells(){14365var output = [];1436614367this.editedCells.forEach((cell) => {14368output.push(cell.getComponent());14369});1437014371return output;14372}1437314374clearEdited(cell){14375var editIndex;1437614377if(cell.modules.edit && cell.modules.edit.edited){14378cell.modules.edit.edited = false;1437914380this.dispatch("edit-edited-clear", cell);14381}1438214383editIndex = this.editedCells.indexOf(cell);1438414385if(editIndex > -1){14386this.editedCells.splice(editIndex, 1);14387}14388}14389}1439014391Edit$1.moduleName = "edit";1439214393//load defaults14394Edit$1.editors = defaultEditors;1439514396class ExportRow{14397constructor(type, columns, component, indent){14398this.type = type;14399this.columns = columns;14400this.component = component || false;14401this.indent = indent || 0;14402}14403}1440414405class ExportColumn{14406constructor(value, component, width, height, depth){14407this.value = value;14408this.component = component || false;14409this.width = width;14410this.height = height;14411this.depth = depth;14412}14413}1441414415class Export extends Module{1441614417constructor(table){14418super(table);1441914420this.config = {};14421this.cloneTableStyle = true;14422this.colVisProp = "";1442314424this.registerTableOption("htmlOutputConfig", false); //html output config1442514426this.registerColumnOption("htmlOutput");14427this.registerColumnOption("titleHtmlOutput");14428}1442914430initialize(){14431this.registerTableFunction("getHtml", this.getHtml.bind(this));14432}1443314434///////////////////////////////////14435///////// Table Functions /////////14436///////////////////////////////////144371443814439///////////////////////////////////14440///////// Internal Logic //////////14441///////////////////////////////////1444214443generateExportList(config, style, range, colVisProp){14444this.cloneTableStyle = style;14445this.config = config || {};14446this.colVisProp = colVisProp;1444714448var headers = this.config.columnHeaders !== false ? this.headersToExportRows(this.generateColumnGroupHeaders()) : [];14449var body = this.bodyToExportRows(this.rowLookup(range));1445014451return headers.concat(body);14452}1445314454generateTable(config, style, range, colVisProp){14455var list = this.generateExportList(config, style, range, colVisProp);1445614457return this.generateTableElement(list);14458}1445914460rowLookup(range){14461var rows = [];1446214463if(typeof range == "function"){14464range.call(this.table).forEach((row) =>{14465row = this.table.rowManager.findRow(row);1446614467if(row){14468rows.push(row);14469}14470});14471}else {14472switch(range){14473case true:14474case "visible":14475rows = this.table.rowManager.getVisibleRows(false, true);14476break;1447714478case "all":14479rows = this.table.rowManager.rows;14480break;1448114482case "selected":14483rows = this.table.modules.selectRow.selectedRows;14484break;1448514486case "active":14487default:14488if(this.table.options.pagination){14489rows = this.table.rowManager.getDisplayRows(this.table.rowManager.displayRows.length - 2);14490}else {14491rows = this.table.rowManager.getDisplayRows();14492}14493}14494}1449514496return Object.assign([], rows);14497}1449814499generateColumnGroupHeaders(){14500var output = [];1450114502var columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex;1450314504columns.forEach((column) => {14505var colData = this.processColumnGroup(column);1450614507if(colData){14508output.push(colData);14509}14510});1451114512return output;14513}1451414515processColumnGroup(column){14516var subGroups = column.columns,14517maxDepth = 0,14518title = column.definition["title" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))] || column.definition.title;1451914520var groupData = {14521title:title,14522column:column,14523depth:1,14524};1452514526if(subGroups.length){14527groupData.subGroups = [];14528groupData.width = 0;1452914530subGroups.forEach((subGroup) => {14531var subGroupData = this.processColumnGroup(subGroup);1453214533if(subGroupData){14534groupData.width += subGroupData.width;14535groupData.subGroups.push(subGroupData);1453614537if(subGroupData.depth > maxDepth){14538maxDepth = subGroupData.depth;14539}14540}14541});1454214543groupData.depth += maxDepth;1454414545if(!groupData.width){14546return false;14547}14548}else {14549if(this.columnVisCheck(column)){14550groupData.width = 1;14551}else {14552return false;14553}14554}1455514556return groupData;14557}1455814559columnVisCheck(column){14560var visProp = column.definition[this.colVisProp];1456114562if(typeof visProp === "function"){14563visProp = visProp.call(this.table, column.getComponent());14564}1456514566return visProp !== false && (column.visible || (!column.visible && visProp));14567}1456814569headersToExportRows(columns){14570var headers = [],14571headerDepth = 0,14572exportRows = [];1457314574function parseColumnGroup(column, level){1457514576var depth = headerDepth - level;1457714578if(typeof headers[level] === "undefined"){14579headers[level] = [];14580}1458114582column.height = column.subGroups ? 1 : (depth - column.depth) + 1;1458314584headers[level].push(column);1458514586if(column.height > 1){14587for(let i = 1; i < column.height; i ++){1458814589if(typeof headers[level + i] === "undefined"){14590headers[level + i] = [];14591}1459214593headers[level + i].push(false);14594}14595}1459614597if(column.width > 1){14598for(let i = 1; i < column.width; i ++){14599headers[level].push(false);14600}14601}1460214603if(column.subGroups){14604column.subGroups.forEach(function(subGroup){14605parseColumnGroup(subGroup, level+1);14606});14607}14608}1460914610//calculate maximum header depth14611columns.forEach(function(column){14612if(column.depth > headerDepth){14613headerDepth = column.depth;14614}14615});1461614617columns.forEach(function(column){14618parseColumnGroup(column,0);14619});1462014621headers.forEach((header) => {14622var columns = [];1462314624header.forEach((col) => {14625if(col){14626let title = typeof col.title === "undefined" ? "" : col.title;14627columns.push(new ExportColumn(title, col.column.getComponent(), col.width, col.height, col.depth));14628}else {14629columns.push(null);14630}14631});1463214633exportRows.push(new ExportRow("header", columns));14634});1463514636return exportRows;14637}1463814639bodyToExportRows(rows){1464014641var columns = [];14642var exportRows = [];1464314644this.table.columnManager.columnsByIndex.forEach((column) => {14645if (this.columnVisCheck(column)) {14646columns.push(column.getComponent());14647}14648});1464914650if(this.config.columnCalcs !== false && this.table.modExists("columnCalcs")){14651if(this.table.modules.columnCalcs.topInitialized){14652rows.unshift(this.table.modules.columnCalcs.topRow);14653}1465414655if(this.table.modules.columnCalcs.botInitialized){14656rows.push(this.table.modules.columnCalcs.botRow);14657}14658}1465914660rows = rows.filter((row) => {14661switch(row.type){14662case "group":14663return this.config.rowGroups !== false;1466414665case "calc":14666return this.config.columnCalcs !== false;1466714668case "row":14669return !(this.table.options.dataTree && this.config.dataTree === false && row.modules.dataTree.parent);14670}1467114672return true;14673});1467414675rows.forEach((row, i) => {14676var rowData = row.getData(this.colVisProp);14677var exportCols = [];14678var indent = 0;1467914680switch(row.type){14681case "group":14682indent = row.level;14683exportCols.push(new ExportColumn(row.key, row.getComponent(), columns.length, 1));14684break;1468514686case "calc" :14687case "row" :14688columns.forEach((col) => {14689exportCols.push(new ExportColumn(col._column.getFieldValue(rowData), col, 1, 1));14690});1469114692if(this.table.options.dataTree && this.config.dataTree !== false){14693indent = row.modules.dataTree.index;14694}14695break;14696}1469714698exportRows.push(new ExportRow(row.type, exportCols, row.getComponent(), indent));14699});1470014701return exportRows;14702}1470314704generateTableElement(list){14705var table = document.createElement("table"),14706headerEl = document.createElement("thead"),14707bodyEl = document.createElement("tbody"),14708styles = this.lookupTableStyles(),14709rowFormatter = this.table.options["rowFormatter" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))],14710setup = {};1471114712setup.rowFormatter = rowFormatter !== null ? rowFormatter : this.table.options.rowFormatter;1471314714if(this.table.options.dataTree &&this.config.dataTree !== false && this.table.modExists("columnCalcs")){14715setup.treeElementField = this.table.modules.dataTree.elementField;14716}1471714718//assign group header formatter14719setup.groupHeader = this.table.options["groupHeader" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))];1472014721if(setup.groupHeader && !Array.isArray(setup.groupHeader)){14722setup.groupHeader = [setup.groupHeader];14723}1472414725table.classList.add("tabulator-print-table");1472614727this.mapElementStyles(this.table.columnManager.getHeadersElement(), headerEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);147281472914730if(list.length > 1000){14731console.warn("It may take a long time to render an HTML table with more than 1000 rows");14732}1473314734list.forEach((row, i) => {14735let rowEl;1473614737switch(row.type){14738case "header":14739headerEl.appendChild(this.generateHeaderElement(row, setup, styles));14740break;1474114742case "group":14743bodyEl.appendChild(this.generateGroupElement(row, setup, styles));14744break;1474514746case "calc":14747bodyEl.appendChild(this.generateCalcElement(row, setup, styles));14748break;1474914750case "row":14751rowEl = this.generateRowElement(row, setup, styles);1475214753this.mapElementStyles(((i % 2) && styles.evenRow) ? styles.evenRow : styles.oddRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);14754bodyEl.appendChild(rowEl);14755break;14756}14757});1475814759if(headerEl.innerHTML){14760table.appendChild(headerEl);14761}1476214763table.appendChild(bodyEl);147641476514766this.mapElementStyles(this.table.element, table, ["border-top", "border-left", "border-right", "border-bottom"]);14767return table;14768}1476914770lookupTableStyles(){14771var styles = {};1477214773//lookup row styles14774if(this.cloneTableStyle && window.getComputedStyle){14775styles.oddRow = this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)");14776styles.evenRow = this.table.element.querySelector(".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)");14777styles.calcRow = this.table.element.querySelector(".tabulator-row.tabulator-calcs");14778styles.firstRow = this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)");14779styles.firstGroup = this.table.element.getElementsByClassName("tabulator-group")[0];1478014781if(styles.firstRow){14782styles.styleCells = styles.firstRow.getElementsByClassName("tabulator-cell");14783styles.firstCell = styles.styleCells[0];14784styles.lastCell = styles.styleCells[styles.styleCells.length - 1];14785}14786}1478714788return styles;14789}1479014791generateHeaderElement(row, setup, styles){14792var rowEl = document.createElement("tr");1479314794row.columns.forEach((column) => {14795if(column){14796var cellEl = document.createElement("th");14797var classNames = column.component._column.definition.cssClass ? column.component._column.definition.cssClass.split(" ") : [];1479814799cellEl.colSpan = column.width;14800cellEl.rowSpan = column.height;1480114802cellEl.innerHTML = column.value;1480314804if(this.cloneTableStyle){14805cellEl.style.boxSizing = "border-box";14806}1480714808classNames.forEach(function(className) {14809cellEl.classList.add(className);14810});1481114812this.mapElementStyles(column.component.getElement(), cellEl, ["text-align", "border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);14813this.mapElementStyles(column.component._column.contentElement, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);1481414815if(column.component._column.visible){14816this.mapElementStyles(column.component.getElement(), cellEl, ["width"]);14817}else {14818if(column.component._column.definition.width){14819cellEl.style.width = column.component._column.definition.width + "px";14820}14821}1482214823if(column.component._column.parent){14824this.mapElementStyles(column.component._column.parent.groupElement, cellEl, ["border-top"]);14825}1482614827rowEl.appendChild(cellEl);14828}14829});1483014831return rowEl;14832}1483314834generateGroupElement(row, setup, styles){1483514836var rowEl = document.createElement("tr"),14837cellEl = document.createElement("td"),14838group = row.columns[0];1483914840rowEl.classList.add("tabulator-print-table-row");1484114842if(setup.groupHeader && setup.groupHeader[row.indent]){14843group.value = setup.groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);14844}else {14845if(setup.groupHeader !== false){14846group.value = row.component._group.generator(group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);14847}14848}1484914850cellEl.colSpan = group.width;14851cellEl.innerHTML = group.value;1485214853rowEl.classList.add("tabulator-print-table-group");14854rowEl.classList.add("tabulator-group-level-" + row.indent);1485514856if(group.component.isVisible()){14857rowEl.classList.add("tabulator-group-visible");14858}1485914860this.mapElementStyles(styles.firstGroup, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);14861this.mapElementStyles(styles.firstGroup, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);1486214863rowEl.appendChild(cellEl);1486414865return rowEl;14866}1486714868generateCalcElement(row, setup, styles){14869var rowEl = this.generateRowElement(row, setup, styles);1487014871rowEl.classList.add("tabulator-print-table-calcs");14872this.mapElementStyles(styles.calcRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);1487314874return rowEl;14875}1487614877generateRowElement(row, setup, styles){14878var rowEl = document.createElement("tr");1487914880rowEl.classList.add("tabulator-print-table-row");1488114882row.columns.forEach((col, i) => {14883if(col){14884var cellEl = document.createElement("td"),14885column = col.component._column,14886index = this.table.columnManager.findColumnIndex(column),14887value = col.value,14888cellStyle;1488914890var cellWrapper = {14891modules:{},14892getValue:function(){14893return value;14894},14895getField:function(){14896return column.definition.field;14897},14898getElement:function(){14899return cellEl;14900},14901getType:function(){14902return "cell";14903},14904getColumn:function(){14905return column.getComponent();14906},14907getData:function(){14908return row.component.getData();14909},14910getRow:function(){14911return row.component;14912},14913getComponent:function(){14914return cellWrapper;14915},14916column:column,14917};1491814919var classNames = column.definition.cssClass ? column.definition.cssClass.split(" ") : [];1492014921classNames.forEach(function(className) {14922cellEl.classList.add(className);14923});1492414925if(this.table.modExists("format") && this.config.formatCells !== false){14926value = this.table.modules.format.formatExportValue(cellWrapper, this.colVisProp);14927}else {14928switch(typeof value){14929case "object":14930value = value !== null ? JSON.stringify(value) : "";14931break;1493214933case "undefined":14934value = "";14935break;14936}14937}1493814939if(value instanceof Node){14940cellEl.appendChild(value);14941}else {14942cellEl.innerHTML = value;14943}1494414945cellStyle = styles.styleCells && styles.styleCells[index] ? styles.styleCells[index] : styles.firstCell;1494614947if(cellStyle){14948this.mapElementStyles(cellStyle, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom", "border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "text-align"]);1494914950if(column.definition.align){14951cellEl.style.textAlign = column.definition.align;14952}14953}1495414955if(this.table.options.dataTree && this.config.dataTree !== false){14956if((setup.treeElementField && setup.treeElementField == column.field) || (!setup.treeElementField && i == 0)){14957if(row.component._row.modules.dataTree.controlEl){14958cellEl.insertBefore(row.component._row.modules.dataTree.controlEl.cloneNode(true), cellEl.firstChild);14959}14960if(row.component._row.modules.dataTree.branchEl){14961cellEl.insertBefore(row.component._row.modules.dataTree.branchEl.cloneNode(true), cellEl.firstChild);14962}14963}14964}1496514966rowEl.appendChild(cellEl);1496714968if(cellWrapper.modules.format && cellWrapper.modules.format.renderedCallback){14969cellWrapper.modules.format.renderedCallback();14970}14971}14972});1497314974if(setup.rowFormatter && row.type === "row" && this.config.formatCells !== false){14975let formatComponent = Object.assign(row.component);1497614977formatComponent.getElement = function(){return rowEl;};1497814979setup.rowFormatter(row.component);14980}1498114982return rowEl;14983}1498414985generateHTMLTable(list){14986var holder = document.createElement("div");1498714988holder.appendChild(this.generateTableElement(list));1498914990return holder.innerHTML;14991}1499214993getHtml(visible, style, config, colVisProp){14994var list = this.generateExportList(config || this.table.options.htmlOutputConfig, style, visible, colVisProp || "htmlOutput");1499514996return this.generateHTMLTable(list);14997}1499814999mapElementStyles(from, to, props){15000if(this.cloneTableStyle && from && to){1500115002var lookup = {15003"background-color" : "backgroundColor",15004"color" : "fontColor",15005"width" : "width",15006"font-weight" : "fontWeight",15007"font-family" : "fontFamily",15008"font-size" : "fontSize",15009"text-align" : "textAlign",15010"border-top" : "borderTop",15011"border-left" : "borderLeft",15012"border-right" : "borderRight",15013"border-bottom" : "borderBottom",15014"padding-top" : "paddingTop",15015"padding-left" : "paddingLeft",15016"padding-right" : "paddingRight",15017"padding-bottom" : "paddingBottom",15018};1501915020if(window.getComputedStyle){15021var fromStyle = window.getComputedStyle(from);1502215023props.forEach(function(prop){15024if(!to.style[lookup[prop]]){15025to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);15026}15027});15028}15029}15030}15031}1503215033Export.moduleName = "export";1503415035var defaultFilters = {1503615037//equal to15038"=":function(filterVal, rowVal, rowData, filterParams){15039return rowVal == filterVal ? true : false;15040},1504115042//less than15043"<":function(filterVal, rowVal, rowData, filterParams){15044return rowVal < filterVal ? true : false;15045},1504615047//less than or equal to15048"<=":function(filterVal, rowVal, rowData, filterParams){15049return rowVal <= filterVal ? true : false;15050},1505115052//greater than15053">":function(filterVal, rowVal, rowData, filterParams){15054return rowVal > filterVal ? true : false;15055},1505615057//greater than or equal to15058">=":function(filterVal, rowVal, rowData, filterParams){15059return rowVal >= filterVal ? true : false;15060},1506115062//not equal to15063"!=":function(filterVal, rowVal, rowData, filterParams){15064return rowVal != filterVal ? true : false;15065},1506615067"regex":function(filterVal, rowVal, rowData, filterParams){1506815069if(typeof filterVal == "string"){15070filterVal = new RegExp(filterVal);15071}1507215073return filterVal.test(rowVal);15074},1507515076//contains the string15077"like":function(filterVal, rowVal, rowData, filterParams){15078if(filterVal === null || typeof filterVal === "undefined"){15079return rowVal === filterVal ? true : false;15080}else {15081if(typeof rowVal !== 'undefined' && rowVal !== null){15082return String(rowVal).toLowerCase().indexOf(filterVal.toLowerCase()) > -1;15083}15084else {15085return false;15086}15087}15088},1508915090//contains the keywords15091"keywords":function(filterVal, rowVal, rowData, filterParams){15092var keywords = filterVal.toLowerCase().split(typeof filterParams.separator === "undefined" ? " " : filterParams.separator),15093value = String(rowVal === null || typeof rowVal === "undefined" ? "" : rowVal).toLowerCase(),15094matches = [];1509515096keywords.forEach((keyword) =>{15097if(value.includes(keyword)){15098matches.push(true);15099}15100});1510115102return filterParams.matchAll ? matches.length === keywords.length : !!matches.length;15103},1510415105//starts with the string15106"starts":function(filterVal, rowVal, rowData, filterParams){15107if(filterVal === null || typeof filterVal === "undefined"){15108return rowVal === filterVal ? true : false;15109}else {15110if(typeof rowVal !== 'undefined' && rowVal !== null){15111return String(rowVal).toLowerCase().startsWith(filterVal.toLowerCase());15112}15113else {15114return false;15115}15116}15117},1511815119//ends with the string15120"ends":function(filterVal, rowVal, rowData, filterParams){15121if(filterVal === null || typeof filterVal === "undefined"){15122return rowVal === filterVal ? true : false;15123}else {15124if(typeof rowVal !== 'undefined' && rowVal !== null){15125return String(rowVal).toLowerCase().endsWith(filterVal.toLowerCase());15126}15127else {15128return false;15129}15130}15131},1513215133//in array15134"in":function(filterVal, rowVal, rowData, filterParams){15135if(Array.isArray(filterVal)){15136return filterVal.length ? filterVal.indexOf(rowVal) > -1 : true;15137}else {15138console.warn("Filter Error - filter value is not an array:", filterVal);15139return false;15140}15141},15142};1514315144class Filter extends Module{1514515146constructor(table){15147super(table);1514815149this.filterList = []; //hold filter list15150this.headerFilters = {}; //hold column filters15151this.headerFilterColumns = []; //hold columns that use header filters1515215153this.prevHeaderFilterChangeCheck = "";15154this.prevHeaderFilterChangeCheck = "{}";1515515156this.changed = false; //has filtering changed since last render15157this.tableInitialized = false;1515815159this.registerTableOption("filterMode", "local"); //local or remote filtering1516015161this.registerTableOption("initialFilter", false); //initial filtering criteria15162this.registerTableOption("initialHeaderFilter", false); //initial header filtering criteria15163this.registerTableOption("headerFilterLiveFilterDelay", 300); //delay before updating column after user types in header filter15164this.registerTableOption("placeholderHeaderFilter", false); //placeholder when header filter is empty1516515166this.registerColumnOption("headerFilter");15167this.registerColumnOption("headerFilterPlaceholder");15168this.registerColumnOption("headerFilterParams");15169this.registerColumnOption("headerFilterEmptyCheck");15170this.registerColumnOption("headerFilterFunc");15171this.registerColumnOption("headerFilterFuncParams");15172this.registerColumnOption("headerFilterLiveFilter");1517315174this.registerTableFunction("searchRows", this.searchRows.bind(this));15175this.registerTableFunction("searchData", this.searchData.bind(this));1517615177this.registerTableFunction("setFilter", this.userSetFilter.bind(this));15178this.registerTableFunction("refreshFilter", this.userRefreshFilter.bind(this));15179this.registerTableFunction("addFilter", this.userAddFilter.bind(this));15180this.registerTableFunction("getFilters", this.getFilters.bind(this));15181this.registerTableFunction("setHeaderFilterFocus", this.userSetHeaderFilterFocus.bind(this));15182this.registerTableFunction("getHeaderFilterValue", this.userGetHeaderFilterValue.bind(this));15183this.registerTableFunction("setHeaderFilterValue", this.userSetHeaderFilterValue.bind(this));15184this.registerTableFunction("getHeaderFilters", this.getHeaderFilters.bind(this));15185this.registerTableFunction("removeFilter", this.userRemoveFilter.bind(this));15186this.registerTableFunction("clearFilter", this.userClearFilter.bind(this));15187this.registerTableFunction("clearHeaderFilter", this.userClearHeaderFilter.bind(this));1518815189this.registerComponentFunction("column", "headerFilterFocus", this.setHeaderFilterFocus.bind(this));15190this.registerComponentFunction("column", "reloadHeaderFilter", this.reloadHeaderFilter.bind(this));15191this.registerComponentFunction("column", "getHeaderFilterValue", this.getHeaderFilterValue.bind(this));15192this.registerComponentFunction("column", "setHeaderFilterValue", this.setHeaderFilterValue.bind(this));15193}1519415195initialize(){15196this.subscribe("column-init", this.initializeColumnHeaderFilter.bind(this));15197this.subscribe("column-width-fit-before", this.hideHeaderFilterElements.bind(this));15198this.subscribe("column-width-fit-after", this.showHeaderFilterElements.bind(this));15199this.subscribe("table-built", this.tableBuilt.bind(this));15200this.subscribe("placeholder", this.generatePlaceholder.bind(this));1520115202if(this.table.options.filterMode === "remote"){15203this.subscribe("data-params", this.remoteFilterParams.bind(this));15204}1520515206this.registerDataHandler(this.filter.bind(this), 10);15207}1520815209tableBuilt(){15210if(this.table.options.initialFilter){15211this.setFilter(this.table.options.initialFilter);15212}1521315214if(this.table.options.initialHeaderFilter){15215this.table.options.initialHeaderFilter.forEach((item) => {1521615217var column = this.table.columnManager.findColumn(item.field);1521815219if(column){15220this.setHeaderFilterValue(column, item.value);15221}else {15222console.warn("Column Filter Error - No matching column found:", item.field);15223return false;15224}15225});15226}1522715228this.tableInitialized = true;15229}1523015231remoteFilterParams(data, config, silent, params){15232params.filter = this.getFilters(true, true);15233return params;15234}1523515236generatePlaceholder(text){15237if(this.table.options.placeholderHeaderFilter && Object.keys(this.headerFilters).length){15238return this.table.options.placeholderHeaderFilter;15239}15240}1524115242///////////////////////////////////15243///////// Table Functions /////////15244///////////////////////////////////1524515246//set standard filters15247userSetFilter(field, type, value, params){15248this.setFilter(field, type, value, params);15249this.refreshFilter();15250}1525115252//set standard filters15253userRefreshFilter(){15254this.refreshFilter();15255}1525615257//add filter to array15258userAddFilter(field, type, value, params){15259this.addFilter(field, type, value, params);15260this.refreshFilter();15261}1526215263userSetHeaderFilterFocus(field){15264var column = this.table.columnManager.findColumn(field);1526515266if(column){15267this.setHeaderFilterFocus(column);15268}else {15269console.warn("Column Filter Focus Error - No matching column found:", field);15270return false;15271}15272}1527315274userGetHeaderFilterValue(field) {15275var column = this.table.columnManager.findColumn(field);1527615277if(column){15278return this.getHeaderFilterValue(column);15279}else {15280console.warn("Column Filter Error - No matching column found:", field);15281}15282}1528315284userSetHeaderFilterValue(field, value){15285var column = this.table.columnManager.findColumn(field);1528615287if(column){15288this.setHeaderFilterValue(column, value);15289}else {15290console.warn("Column Filter Error - No matching column found:", field);15291return false;15292}15293}1529415295//remove filter from array15296userRemoveFilter(field, type, value){15297this.removeFilter(field, type, value);15298this.refreshFilter();15299}1530015301//clear filters15302userClearFilter(all){15303this.clearFilter(all);15304this.refreshFilter();15305}1530615307//clear header filters15308userClearHeaderFilter(){15309this.clearHeaderFilter();15310this.refreshFilter();15311}153121531315314//search for specific row components15315searchRows(field, type, value){15316return this.search("rows", field, type, value);15317}1531815319//search for specific data15320searchData(field, type, value){15321return this.search("data", field, type, value);15322}1532315324///////////////////////////////////15325///////// Internal Logic //////////15326///////////////////////////////////1532715328initializeColumnHeaderFilter(column){15329var def = column.definition;1533015331if(def.headerFilter){15332this.initializeColumn(column);15333}15334}1533515336//initialize column header filter15337initializeColumn(column, value){15338var self = this,15339field = column.getField();1534015341//handle successfully value change15342function success(value){15343var filterType = (column.modules.filter.tagType == "input" && column.modules.filter.attrType == "text") || column.modules.filter.tagType == "textarea" ? "partial" : "match",15344type = "",15345filterChangeCheck = "",15346filterFunc;1534715348if(typeof column.modules.filter.prevSuccess === "undefined" || column.modules.filter.prevSuccess !== value){1534915350column.modules.filter.prevSuccess = value;1535115352if(!column.modules.filter.emptyFunc(value)){15353column.modules.filter.value = value;1535415355switch(typeof column.definition.headerFilterFunc){15356case "string":15357if(Filter.filters[column.definition.headerFilterFunc]){15358type = column.definition.headerFilterFunc;15359filterFunc = function(data){15360var params = column.definition.headerFilterFuncParams || {};15361var fieldVal = column.getFieldValue(data);1536215363params = typeof params === "function" ? params(value, fieldVal, data) : params;1536415365return Filter.filters[column.definition.headerFilterFunc](value, fieldVal, data, params);15366};15367}else {15368console.warn("Header Filter Error - Matching filter function not found: ", column.definition.headerFilterFunc);15369}15370break;1537115372case "function":15373filterFunc = function(data){15374var params = column.definition.headerFilterFuncParams || {};15375var fieldVal = column.getFieldValue(data);1537615377params = typeof params === "function" ? params(value, fieldVal, data) : params;1537815379return column.definition.headerFilterFunc(value, fieldVal, data, params);15380};1538115382type = filterFunc;15383break;15384}1538515386if(!filterFunc){15387switch(filterType){15388case "partial":15389filterFunc = function(data){15390var colVal = column.getFieldValue(data);1539115392if(typeof colVal !== 'undefined' && colVal !== null){15393return String(colVal).toLowerCase().indexOf(String(value).toLowerCase()) > -1;15394}else {15395return false;15396}15397};15398type = "like";15399break;1540015401default:15402filterFunc = function(data){15403return column.getFieldValue(data) == value;15404};15405type = "=";15406}15407}1540815409self.headerFilters[field] = {value:value, func:filterFunc, type:type};15410}else {15411delete self.headerFilters[field];15412}1541315414column.modules.filter.value = value;1541515416filterChangeCheck = JSON.stringify(self.headerFilters);1541715418if(self.prevHeaderFilterChangeCheck !== filterChangeCheck){15419self.prevHeaderFilterChangeCheck = filterChangeCheck;1542015421self.trackChanges();15422self.refreshFilter();15423}15424}1542515426return true;15427}1542815429column.modules.filter = {15430success:success,15431attrType:false,15432tagType:false,15433emptyFunc:false,15434};1543515436this.generateHeaderFilterElement(column);15437}1543815439generateHeaderFilterElement(column, initialValue, reinitialize){15440var self = this,15441success = column.modules.filter.success,15442field = column.getField(),15443filterElement, editor, editorElement, cellWrapper, typingTimer, searchTrigger, params, onRenderedCallback;1544415445column.modules.filter.value = initialValue;1544615447//handle aborted edit15448function cancel(){}1544915450function onRendered(callback){15451onRenderedCallback = callback;15452}1545315454if(column.modules.filter.headerElement && column.modules.filter.headerElement.parentNode){15455column.contentElement.removeChild(column.modules.filter.headerElement.parentNode);15456}1545715458if(field){1545915460//set empty value function15461column.modules.filter.emptyFunc = column.definition.headerFilterEmptyCheck || function(value){15462return !value && value !== 0;15463};1546415465filterElement = document.createElement("div");15466filterElement.classList.add("tabulator-header-filter");1546715468//set column editor15469switch(typeof column.definition.headerFilter){15470case "string":15471if(self.table.modules.edit.editors[column.definition.headerFilter]){15472editor = self.table.modules.edit.editors[column.definition.headerFilter];1547315474if((column.definition.headerFilter === "tick" || column.definition.headerFilter === "tickCross") && !column.definition.headerFilterEmptyCheck){15475column.modules.filter.emptyFunc = function(value){15476return value !== true && value !== false;15477};15478}15479}else {15480console.warn("Filter Error - Cannot build header filter, No such editor found: ", column.definition.editor);15481}15482break;1548315484case "function":15485editor = column.definition.headerFilter;15486break;1548715488case "boolean":15489if(column.modules.edit && column.modules.edit.editor){15490editor = column.modules.edit.editor;15491}else {15492if(column.definition.formatter && self.table.modules.edit.editors[column.definition.formatter]){15493editor = self.table.modules.edit.editors[column.definition.formatter];1549415495if((column.definition.formatter === "tick" || column.definition.formatter === "tickCross") && !column.definition.headerFilterEmptyCheck){15496column.modules.filter.emptyFunc = function(value){15497return value !== true && value !== false;15498};15499}15500}else {15501editor = self.table.modules.edit.editors["input"];15502}15503}15504break;15505}1550615507if(editor){1550815509cellWrapper = {15510getValue:function(){15511return typeof initialValue !== "undefined" ? initialValue : "";15512},15513getField:function(){15514return column.definition.field;15515},15516getElement:function(){15517return filterElement;15518},15519getColumn:function(){15520return column.getComponent();15521},15522getTable:() => {15523return this.table;15524},15525getType:() => {15526return "header";15527},15528getRow:function(){15529return {15530normalizeHeight:function(){1553115532}15533};15534}15535};1553615537params = column.definition.headerFilterParams || {};1553815539params = typeof params === "function" ? params.call(self.table, cellWrapper) : params;1554015541editorElement = editor.call(this.table.modules.edit, cellWrapper, onRendered, success, cancel, params);1554215543if(!editorElement){15544console.warn("Filter Error - Cannot add filter to " + field + " column, editor returned a value of false");15545return;15546}1554715548if(!(editorElement instanceof Node)){15549console.warn("Filter Error - Cannot add filter to " + field + " column, editor should return an instance of Node, the editor returned:", editorElement);15550return;15551}1555215553//set Placeholder Text15554self.langBind("headerFilters|columns|" + column.definition.field, function(value){15555editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : (column.definition.headerFilterPlaceholder || self.langText("headerFilters|default")));15556});1555715558//focus on element on click15559editorElement.addEventListener("click", function(e){15560e.stopPropagation();15561editorElement.focus();15562});1556315564editorElement.addEventListener("focus", (e) => {15565var left = this.table.columnManager.contentsElement.scrollLeft;1556615567var headerPos = this.table.rowManager.element.scrollLeft;1556815569if(left !== headerPos){15570this.table.rowManager.scrollHorizontal(left);15571this.table.columnManager.scrollHorizontal(left);15572}15573});1557415575//live update filters as user types15576typingTimer = false;1557715578searchTrigger = function(e){15579if(typingTimer){15580clearTimeout(typingTimer);15581}1558215583typingTimer = setTimeout(function(){15584success(editorElement.value);15585},self.table.options.headerFilterLiveFilterDelay);15586};1558715588column.modules.filter.headerElement = editorElement;15589column.modules.filter.attrType = editorElement.hasAttribute("type") ? editorElement.getAttribute("type").toLowerCase() : "" ;15590column.modules.filter.tagType = editorElement.tagName.toLowerCase();1559115592if(column.definition.headerFilterLiveFilter !== false){1559315594if (15595!(15596column.definition.headerFilter === 'autocomplete' ||15597column.definition.headerFilter === 'tickCross' ||15598((column.definition.editor === 'autocomplete' ||15599column.definition.editor === 'tickCross') &&15600column.definition.headerFilter === true)15601)15602) {15603editorElement.addEventListener("keyup", searchTrigger);15604editorElement.addEventListener("search", searchTrigger);156051560615607//update number filtered columns on change15608if(column.modules.filter.attrType == "number"){15609editorElement.addEventListener("change", function(e){15610success(editorElement.value);15611});15612}1561315614//change text inputs to search inputs to allow for clearing of field15615if(column.modules.filter.attrType == "text" && this.table.browser !== "ie"){15616editorElement.setAttribute("type", "search");15617// editorElement.off("change blur"); //prevent blur from triggering filter and preventing selection click15618}1561915620}1562115622//prevent input and select elements from propagating click to column sorters etc15623if(column.modules.filter.tagType == "input" || column.modules.filter.tagType == "select" || column.modules.filter.tagType == "textarea"){15624editorElement.addEventListener("mousedown",function(e){15625e.stopPropagation();15626});15627}15628}1562915630filterElement.appendChild(editorElement);1563115632column.contentElement.appendChild(filterElement);1563315634if(!reinitialize){15635self.headerFilterColumns.push(column);15636}1563715638if(onRenderedCallback){15639onRenderedCallback();15640}15641}15642}else {15643console.warn("Filter Error - Cannot add header filter, column has no field set:", column.definition.title);15644}15645}1564615647//hide all header filter elements (used to ensure correct column widths in "fitData" layout mode)15648hideHeaderFilterElements(){15649this.headerFilterColumns.forEach(function(column){15650if(column.modules.filter && column.modules.filter.headerElement){15651column.modules.filter.headerElement.style.display = 'none';15652}15653});15654}1565515656//show all header filter elements (used to ensure correct column widths in "fitData" layout mode)15657showHeaderFilterElements(){15658this.headerFilterColumns.forEach(function(column){15659if(column.modules.filter && column.modules.filter.headerElement){15660column.modules.filter.headerElement.style.display = '';15661}15662});15663}1566415665//programmatically set focus of header filter15666setHeaderFilterFocus(column){15667if(column.modules.filter && column.modules.filter.headerElement){15668column.modules.filter.headerElement.focus();15669}else {15670console.warn("Column Filter Focus Error - No header filter set on column:", column.getField());15671}15672}1567315674//programmatically get value of header filter15675getHeaderFilterValue(column){15676if(column.modules.filter && column.modules.filter.headerElement){15677return column.modules.filter.value;15678} else {15679console.warn("Column Filter Error - No header filter set on column:", column.getField());15680}15681}1568215683//programmatically set value of header filter15684setHeaderFilterValue(column, value){15685if (column){15686if(column.modules.filter && column.modules.filter.headerElement){15687this.generateHeaderFilterElement(column, value, true);15688column.modules.filter.success(value);15689}else {15690console.warn("Column Filter Error - No header filter set on column:", column.getField());15691}15692}15693}1569415695reloadHeaderFilter(column){15696if (column){15697if(column.modules.filter && column.modules.filter.headerElement){15698this.generateHeaderFilterElement(column, column.modules.filter.value, true);15699}else {15700console.warn("Column Filter Error - No header filter set on column:", column.getField());15701}15702}15703}1570415705refreshFilter(){15706if(this.tableInitialized){15707if(this.table.options.filterMode === "remote"){15708this.reloadData(null, false, false);15709}else {15710this.refreshData(true);15711}15712}1571315714//TODO - Persist left position of row manager15715// left = this.scrollLeft;15716// this.scrollHorizontal(left);15717}1571815719//check if the filters has changed since last use15720trackChanges(){15721this.changed = true;15722this.dispatch("filter-changed");15723}1572415725//check if the filters has changed since last use15726hasChanged(){15727var changed = this.changed;15728this.changed = false;15729return changed;15730}1573115732//set standard filters15733setFilter(field, type, value, params){15734this.filterList = [];1573515736if(!Array.isArray(field)){15737field = [{field:field, type:type, value:value, params:params}];15738}1573915740this.addFilter(field);15741}1574215743//add filter to array15744addFilter(field, type, value, params){15745var changed = false;1574615747if(!Array.isArray(field)){15748field = [{field:field, type:type, value:value, params:params}];15749}1575015751field.forEach((filter) => {15752filter = this.findFilter(filter);1575315754if(filter){15755this.filterList.push(filter);15756changed = true;15757}15758});1575915760if(changed){15761this.trackChanges();15762}15763}1576415765findFilter(filter){15766var column;1576715768if(Array.isArray(filter)){15769return this.findSubFilters(filter);15770}1577115772var filterFunc = false;1577315774if(typeof filter.field == "function"){15775filterFunc = function(data){15776return filter.field(data, filter.type || {});// pass params to custom filter function15777};15778}else {1577915780if(Filter.filters[filter.type]){1578115782column = this.table.columnManager.getColumnByField(filter.field);1578315784if(column){15785filterFunc = function(data){15786return Filter.filters[filter.type](filter.value, column.getFieldValue(data), data, filter.params || {});15787};15788}else {15789filterFunc = function(data){15790return Filter.filters[filter.type](filter.value, data[filter.field], data, filter.params || {});15791};15792}157931579415795}else {15796console.warn("Filter Error - No such filter type found, ignoring: ", filter.type);15797}15798}1579915800filter.func = filterFunc;1580115802return filter.func ? filter : false;15803}1580415805findSubFilters(filters){15806var output = [];1580715808filters.forEach((filter) => {15809filter = this.findFilter(filter);1581015811if(filter){15812output.push(filter);15813}15814});1581515816return output.length ? output : false;15817}1581815819//get all filters15820getFilters(all, ajax){15821var output = [];1582215823if(all){15824output = this.getHeaderFilters();15825}1582615827if(ajax){15828output.forEach(function(item){15829if(typeof item.type == "function"){15830item.type = "function";15831}15832});15833}1583415835output = output.concat(this.filtersToArray(this.filterList, ajax));1583615837return output;15838}1583915840//filter to Object15841filtersToArray(filterList, ajax){15842var output = [];1584315844filterList.forEach((filter) => {15845var item;1584615847if(Array.isArray(filter)){15848output.push(this.filtersToArray(filter, ajax));15849}else {15850item = {field:filter.field, type:filter.type, value:filter.value};1585115852if(ajax){15853if(typeof item.type == "function"){15854item.type = "function";15855}15856}1585715858output.push(item);15859}15860});1586115862return output;15863}1586415865//get all filters15866getHeaderFilters(){15867var output = [];1586815869for(var key in this.headerFilters){15870output.push({field:key, type:this.headerFilters[key].type, value:this.headerFilters[key].value});15871}1587215873return output;15874}1587515876//remove filter from array15877removeFilter(field, type, value){15878if(!Array.isArray(field)){15879field = [{field:field, type:type, value:value}];15880}1588115882field.forEach((filter) => {15883var index = -1;1588415885if(typeof filter.field == "object"){15886index = this.filterList.findIndex((element) => {15887return filter === element;15888});15889}else {15890index = this.filterList.findIndex((element) => {15891return filter.field === element.field && filter.type === element.type && filter.value === element.value;15892});15893}1589415895if(index > -1){15896this.filterList.splice(index, 1);15897}else {15898console.warn("Filter Error - No matching filter type found, ignoring: ", filter.type);15899}15900});1590115902this.trackChanges();15903}1590415905//clear filters15906clearFilter(all){15907this.filterList = [];1590815909if(all){15910this.clearHeaderFilter();15911}1591215913this.trackChanges();15914}1591515916//clear header filters15917clearHeaderFilter(){15918this.headerFilters = {};15919this.prevHeaderFilterChangeCheck = "{}";1592015921this.headerFilterColumns.forEach((column) => {15922if(typeof column.modules.filter.value !== "undefined"){15923delete column.modules.filter.value;15924}15925column.modules.filter.prevSuccess = undefined;15926this.reloadHeaderFilter(column);15927});1592815929this.trackChanges();15930}1593115932//search data and return matching rows15933search (searchType, field, type, value){15934var activeRows = [],15935filterList = [];1593615937if(!Array.isArray(field)){15938field = [{field:field, type:type, value:value}];15939}1594015941field.forEach((filter) => {15942filter = this.findFilter(filter);1594315944if(filter){15945filterList.push(filter);15946}15947});1594815949this.table.rowManager.rows.forEach((row) => {15950var match = true;1595115952filterList.forEach((filter) => {15953if(!this.filterRecurse(filter, row.getData())){15954match = false;15955}15956});1595715958if(match){15959activeRows.push(searchType === "data" ? row.getData("data") : row.getComponent());15960}1596115962});1596315964return activeRows;15965}1596615967//filter row array15968filter(rowList, filters){15969var activeRows = [],15970activeRowComponents = [];1597115972if(this.subscribedExternal("dataFiltering")){15973this.dispatchExternal("dataFiltering", this.getFilters(true));15974}1597515976if(this.table.options.filterMode !== "remote" && (this.filterList.length || Object.keys(this.headerFilters).length)){1597715978rowList.forEach((row) => {15979if(this.filterRow(row)){15980activeRows.push(row);15981}15982});1598315984}else {15985activeRows = rowList.slice(0);15986}1598715988if(this.subscribedExternal("dataFiltered")){1598915990activeRows.forEach((row) => {15991activeRowComponents.push(row.getComponent());15992});1599315994this.dispatchExternal("dataFiltered", this.getFilters(true), activeRowComponents);15995}1599615997return activeRows;15998}1599916000//filter individual row16001filterRow(row, filters){16002var match = true,16003data = row.getData();1600416005this.filterList.forEach((filter) => {16006if(!this.filterRecurse(filter, data)){16007match = false;16008}16009});160101601116012for(var field in this.headerFilters){16013if(!this.headerFilters[field].func(data)){16014match = false;16015}16016}1601716018return match;16019}1602016021filterRecurse(filter, data){16022var match = false;1602316024if(Array.isArray(filter)){16025filter.forEach((subFilter) => {16026if(this.filterRecurse(subFilter, data)){16027match = true;16028}16029});16030}else {16031match = filter.func(data);16032}1603316034return match;16035}16036}1603716038Filter.moduleName = "filter";1603916040//load defaults16041Filter.filters = defaultFilters;1604216043function plaintext(cell, formatterParams, onRendered){16044return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));16045}1604616047function html$1(cell, formatterParams, onRendered){16048return cell.getValue();16049}1605016051function textarea$1(cell, formatterParams, onRendered){16052cell.getElement().style.whiteSpace = "pre-wrap";16053return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));16054}1605516056function money(cell, formatterParams, onRendered){16057var floatVal = parseFloat(cell.getValue()),16058sign = "",16059number, integer, decimal, rgx, value;1606016061var decimalSym = formatterParams.decimal || ".";16062var thousandSym = formatterParams.thousand || ",";16063var negativeSign = formatterParams.negativeSign || "-";16064var symbol = formatterParams.symbol || "";16065var after = !!formatterParams.symbolAfter;16066var precision = typeof formatterParams.precision !== "undefined" ? formatterParams.precision : 2;1606716068if(isNaN(floatVal)){16069return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));16070}1607116072if(floatVal < 0){16073floatVal = Math.abs(floatVal);16074sign = negativeSign;16075}1607616077number = precision !== false ? floatVal.toFixed(precision) : floatVal;16078number = String(number).split(".");1607916080integer = number[0];16081decimal = number.length > 1 ? decimalSym + number[1] : "";1608216083if (formatterParams.thousand !== false) {16084rgx = /(\d+)(\d{3})/;1608516086while (rgx.test(integer)){16087integer = integer.replace(rgx, "$1" + thousandSym + "$2");16088}16089}1609016091value = integer + decimal;1609216093if(sign === true){16094value = "(" + value + ")";16095return after ? value + symbol : symbol + value;16096}else {16097return after ? sign + value + symbol : sign + symbol + value;16098}16099}1610016101function link(cell, formatterParams, onRendered){16102var value = cell.getValue(),16103urlPrefix = formatterParams.urlPrefix || "",16104download = formatterParams.download,16105label = value,16106el = document.createElement("a"),16107data;1610816109function labelTraverse(path, data){16110var item = path.shift(),16111value = data[item];1611216113if(path.length && typeof value === "object"){16114return labelTraverse(path, value);16115}1611616117return value;16118}1611916120if(formatterParams.labelField){16121data = cell.getData();16122label = labelTraverse(formatterParams.labelField.split(this.table.options.nestedFieldSeparator), data);16123}1612416125if(formatterParams.label){16126switch(typeof formatterParams.label){16127case "string":16128label = formatterParams.label;16129break;1613016131case "function":16132label = formatterParams.label(cell);16133break;16134}16135}1613616137if(label){16138if(formatterParams.urlField){16139data = cell.getData();16140value = data[formatterParams.urlField];16141}1614216143if(formatterParams.url){16144switch(typeof formatterParams.url){16145case "string":16146value = formatterParams.url;16147break;1614816149case "function":16150value = formatterParams.url(cell);16151break;16152}16153}1615416155el.setAttribute("href", urlPrefix + value);1615616157if(formatterParams.target){16158el.setAttribute("target", formatterParams.target);16159}1616016161if(formatterParams.download){1616216163if(typeof download == "function"){16164download = download(cell);16165}else {16166download = download === true ? "" : download;16167}1616816169el.setAttribute("download", download);16170}1617116172el.innerHTML = this.emptyToSpace(this.sanitizeHTML(label));1617316174return el;16175}else {16176return " ";16177}16178}1617916180function image(cell, formatterParams, onRendered){16181var el = document.createElement("img"),16182src = cell.getValue();1618316184if(formatterParams.urlPrefix){16185src = formatterParams.urlPrefix + cell.getValue();16186}1618716188if(formatterParams.urlSuffix){16189src = src + formatterParams.urlSuffix;16190}1619116192el.setAttribute("src", src);1619316194switch(typeof formatterParams.height){16195case "number":16196el.style.height = formatterParams.height + "px";16197break;1619816199case "string":16200el.style.height = formatterParams.height;16201break;16202}1620316204switch(typeof formatterParams.width){16205case "number":16206el.style.width = formatterParams.width + "px";16207break;1620816209case "string":16210el.style.width = formatterParams.width;16211break;16212}1621316214el.addEventListener("load", function(){16215cell.getRow().normalizeHeight();16216});1621716218return el;16219}1622016221function tickCross$1(cell, formatterParams, onRendered){16222var value = cell.getValue(),16223element = cell.getElement(),16224empty = formatterParams.allowEmpty,16225truthy = formatterParams.allowTruthy,16226trueValueSet = Object.keys(formatterParams).includes("trueValue"),16227tick = typeof formatterParams.tickElement !== "undefined" ? formatterParams.tickElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>',16228cross = typeof formatterParams.crossElement !== "undefined" ? formatterParams.crossElement : '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';1622916230if((trueValueSet && value === formatterParams.trueValue) || (!trueValueSet && ((truthy && value) || (value === true || value === "true" || value === "True" || value === 1 || value === "1")))){16231element.setAttribute("aria-checked", true);16232return tick || "";16233}else {16234if(empty && (value === "null" || value === "" || value === null || typeof value === "undefined")){16235element.setAttribute("aria-checked", "mixed");16236return "";16237}else {16238element.setAttribute("aria-checked", false);16239return cross || "";16240}16241}16242}1624316244function datetime$1(cell, formatterParams, onRendered){16245var DT = window.DateTime || luxon.DateTime;16246var inputFormat = formatterParams.inputFormat || "yyyy-MM-dd HH:mm:ss";16247var outputFormat = formatterParams.outputFormat || "dd/MM/yyyy HH:mm:ss";16248var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";16249var value = cell.getValue();1625016251if(typeof DT != "undefined"){16252var newDatetime;1625316254if(DT.isDateTime(value)){16255newDatetime = value;16256}else if(inputFormat === "iso"){16257newDatetime = DT.fromISO(String(value));16258}else {16259newDatetime = DT.fromFormat(String(value), inputFormat);16260}1626116262if(newDatetime.isValid){16263if(formatterParams.timezone){16264newDatetime = newDatetime.setZone(formatterParams.timezone);16265}1626616267return newDatetime.toFormat(outputFormat);16268}else {16269if(invalid === true || !value){16270return value;16271}else if(typeof invalid === "function"){16272return invalid(value);16273}else {16274return invalid;16275}16276}16277}else {16278console.error("Format Error - 'datetime' formatter is dependant on luxon.js");16279}16280}1628116282function datetimediff (cell, formatterParams, onRendered) {16283var DT = window.DateTime || luxon.DateTime;16284var inputFormat = formatterParams.inputFormat || "yyyy-MM-dd HH:mm:ss";16285var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";16286var suffix = typeof formatterParams.suffix !== "undefined" ? formatterParams.suffix : false;16287var unit = typeof formatterParams.unit !== "undefined" ? formatterParams.unit : "days";16288var humanize = typeof formatterParams.humanize !== "undefined" ? formatterParams.humanize : false;16289var date = typeof formatterParams.date !== "undefined" ? formatterParams.date : DT.now();16290var value = cell.getValue();1629116292if(typeof DT != "undefined"){16293var newDatetime;1629416295if(DT.isDateTime(value)){16296newDatetime = value;16297}else if(inputFormat === "iso"){16298newDatetime = DT.fromISO(String(value));16299}else {16300newDatetime = DT.fromFormat(String(value), inputFormat);16301}1630216303if (newDatetime.isValid){16304if(humanize){16305return newDatetime.diff(date, unit).toHuman() + (suffix ? " " + suffix : "");16306}else {16307return parseInt(newDatetime.diff(date, unit)[unit]) + (suffix ? " " + suffix : "");16308}16309} else {1631016311if (invalid === true) {16312return value;16313} else if (typeof invalid === "function") {16314return invalid(value);16315} else {16316return invalid;16317}16318}16319}else {16320console.error("Format Error - 'datetimediff' formatter is dependant on luxon.js");16321}16322}1632316324function lookup (cell, formatterParams, onRendered) {16325var value = cell.getValue();1632616327if (typeof formatterParams[value] === "undefined") {16328console.warn('Missing display value for ' + value);16329return value;16330}1633116332return formatterParams[value];16333}1633416335function star$1(cell, formatterParams, onRendered){16336var value = cell.getValue(),16337element = cell.getElement(),16338maxStars = formatterParams && formatterParams.stars ? formatterParams.stars : 5,16339stars = document.createElement("span"),16340star = document.createElementNS('http://www.w3.org/2000/svg', "svg"),16341starActive = '<polygon fill="#FFEA00" stroke="#C1AB60" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>',16342starInactive = '<polygon fill="#D2D2D2" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>';1634316344//style stars holder16345stars.style.verticalAlign = "middle";1634616347//style star16348star.setAttribute("width", "14");16349star.setAttribute("height", "14");16350star.setAttribute("viewBox", "0 0 512 512");16351star.setAttribute("xml:space", "preserve");16352star.style.padding = "0 1px";1635316354value = value && !isNaN(value) ? parseInt(value) : 0;1635516356value = Math.max(0, Math.min(value, maxStars));1635716358for(var i=1;i<= maxStars;i++){16359var nextStar = star.cloneNode(true);16360nextStar.innerHTML = i <= value ? starActive : starInactive;1636116362stars.appendChild(nextStar);16363}1636416365element.style.whiteSpace = "nowrap";16366element.style.overflow = "hidden";16367element.style.textOverflow = "ellipsis";1636816369element.setAttribute("aria-label", value);1637016371return stars;16372}1637316374function traffic(cell, formatterParams, onRendered){16375var value = this.sanitizeHTML(cell.getValue()) || 0,16376el = document.createElement("span"),16377max = formatterParams && formatterParams.max ? formatterParams.max : 100,16378min = formatterParams && formatterParams.min ? formatterParams.min : 0,16379colors = formatterParams && typeof formatterParams.color !== "undefined" ? formatterParams.color : ["red", "orange", "green"],16380color = "#666666",16381percent, percentValue;1638216383if(isNaN(value) || typeof cell.getValue() === "undefined"){16384return;16385}1638616387el.classList.add("tabulator-traffic-light");1638816389//make sure value is in range16390percentValue = parseFloat(value) <= max ? parseFloat(value) : max;16391percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;1639216393//workout percentage16394percent = (max - min) / 100;16395percentValue = Math.round((percentValue - min) / percent);1639616397//set color16398switch(typeof colors){16399case "string":16400color = colors;16401break;16402case "function":16403color = colors(value);16404break;16405case "object":16406if(Array.isArray(colors)){16407var unit = 100 / colors.length;16408var index = Math.floor(percentValue / unit);1640916410index = Math.min(index, colors.length - 1);16411index = Math.max(index, 0);16412color = colors[index];16413break;16414}16415}1641616417el.style.backgroundColor = color;1641816419return el;16420}1642116422function progress$1(cell, formatterParams = {}, onRendered){ //progress bar16423var value = this.sanitizeHTML(cell.getValue()) || 0,16424element = cell.getElement(),16425max = formatterParams.max ? formatterParams.max : 100,16426min = formatterParams.min ? formatterParams.min : 0,16427legendAlign = formatterParams.legendAlign ? formatterParams.legendAlign : "center",16428percent, percentValue, color, legend, legendColor;1642916430//make sure value is in range16431percentValue = parseFloat(value) <= max ? parseFloat(value) : max;16432percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;1643316434//workout percentage16435percent = (max - min) / 100;16436percentValue = Math.round((percentValue - min) / percent);1643716438//set bar color16439switch(typeof formatterParams.color){16440case "string":16441color = formatterParams.color;16442break;16443case "function":16444color = formatterParams.color(value);16445break;16446case "object":16447if(Array.isArray(formatterParams.color)){16448let unit = 100 / formatterParams.color.length;16449let index = Math.floor(percentValue / unit);1645016451index = Math.min(index, formatterParams.color.length - 1);16452index = Math.max(index, 0);16453color = formatterParams.color[index];16454break;16455}16456default:16457color = "#2DC214";16458}1645916460//generate legend16461switch(typeof formatterParams.legend){16462case "string":16463legend = formatterParams.legend;16464break;16465case "function":16466legend = formatterParams.legend(value);16467break;16468case "boolean":16469legend = value;16470break;16471default:16472legend = false;16473}1647416475//set legend color16476switch(typeof formatterParams.legendColor){16477case "string":16478legendColor = formatterParams.legendColor;16479break;16480case "function":16481legendColor = formatterParams.legendColor(value);16482break;16483case "object":16484if(Array.isArray(formatterParams.legendColor)){16485let unit = 100 / formatterParams.legendColor.length;16486let index = Math.floor(percentValue / unit);1648716488index = Math.min(index, formatterParams.legendColor.length - 1);16489index = Math.max(index, 0);16490legendColor = formatterParams.legendColor[index];16491}16492break;16493default:16494legendColor = "#000";16495}1649616497element.style.minWidth = "30px";16498element.style.position = "relative";1649916500element.setAttribute("aria-label", percentValue);1650116502var barEl = document.createElement("div");16503barEl.style.display = "inline-block";16504barEl.style.width = percentValue + "%";16505barEl.style.backgroundColor = color;16506barEl.style.height = "100%";1650716508barEl.setAttribute('data-max', max);16509barEl.setAttribute('data-min', min);1651016511var barContainer = document.createElement("div");16512barContainer.style.position = "relative";16513barContainer.style.width = "100%";16514barContainer.style.height = "100%";1651516516if(legend){16517var legendEl = document.createElement("div");16518legendEl.style.position = "absolute";16519legendEl.style.top = 0;16520legendEl.style.left = 0;16521legendEl.style.textAlign = legendAlign;16522legendEl.style.width = "100%";16523legendEl.style.color = legendColor;16524legendEl.innerHTML = legend;16525}1652616527onRendered(function(){1652816529//handle custom element needed if formatter is to be included in printed/downloaded output16530if(!(cell instanceof CellComponent)){16531var holderEl = document.createElement("div");16532holderEl.style.position = "absolute";16533holderEl.style.top = "4px";16534holderEl.style.bottom = "4px";16535holderEl.style.left = "4px";16536holderEl.style.right = "4px";1653716538element.appendChild(holderEl);1653916540element = holderEl;16541}1654216543element.appendChild(barContainer);16544barContainer.appendChild(barEl);1654516546if(legend){16547barContainer.appendChild(legendEl);16548}16549});1655016551return "";16552}1655316554function color(cell, formatterParams, onRendered){16555cell.getElement().style.backgroundColor = this.sanitizeHTML(cell.getValue());16556return "";16557}1655816559function buttonTick(cell, formatterParams, onRendered){16560return '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#2DC214" clip-rule="evenodd" d="M21.652,3.211c-0.293-0.295-0.77-0.295-1.061,0L9.41,14.34 c-0.293,0.297-0.771,0.297-1.062,0L3.449,9.351C3.304,9.203,3.114,9.13,2.923,9.129C2.73,9.128,2.534,9.201,2.387,9.351 l-2.165,1.946C0.078,11.445,0,11.63,0,11.823c0,0.194,0.078,0.397,0.223,0.544l4.94,5.184c0.292,0.296,0.771,0.776,1.062,1.07 l2.124,2.141c0.292,0.293,0.769,0.293,1.062,0l14.366-14.34c0.293-0.294,0.293-0.777,0-1.071L21.652,3.211z" fill-rule="evenodd"/></svg>';16561}1656216563function buttonCross(cell, formatterParams, onRendered){16564return '<svg enable-background="new 0 0 24 24" height="14" width="14" viewBox="0 0 24 24" xml:space="preserve" ><path fill="#CE1515" d="M22.245,4.015c0.313,0.313,0.313,0.826,0,1.139l-6.276,6.27c-0.313,0.312-0.313,0.826,0,1.14l6.273,6.272 c0.313,0.313,0.313,0.826,0,1.14l-2.285,2.277c-0.314,0.312-0.828,0.312-1.142,0l-6.271-6.271c-0.313-0.313-0.828-0.313-1.141,0 l-6.276,6.267c-0.313,0.313-0.828,0.313-1.141,0l-2.282-2.28c-0.313-0.313-0.313-0.826,0-1.14l6.278-6.269 c0.313-0.312,0.313-0.826,0-1.14L1.709,5.147c-0.314-0.313-0.314-0.827,0-1.14l2.284-2.278C4.308,1.417,4.821,1.417,5.135,1.73 L11.405,8c0.314,0.314,0.828,0.314,1.141,0.001l6.276-6.267c0.312-0.312,0.826-0.312,1.141,0L22.245,4.015z"/></svg>';16565}1656616567function rownum(cell, formatterParams, onRendered){16568var content = document.createElement("span");16569var row = cell.getRow();1657016571row.watchPosition((position) => {16572content.innerText = position;16573});1657416575return content;16576}1657716578function handle(cell, formatterParams, onRendered){16579cell.getElement().classList.add("tabulator-row-handle");16580return "<div class='tabulator-row-handle-box'><div class='tabulator-row-handle-bar'></div><div class='tabulator-row-handle-bar'></div><div class='tabulator-row-handle-bar'></div></div>";16581}1658216583function responsiveCollapse(cell, formatterParams, onRendered){16584var el = document.createElement("div"),16585config = cell.getRow()._row.modules.responsiveLayout;1658616587el.classList.add("tabulator-responsive-collapse-toggle");1658816589el.innerHTML = `<svg class='tabulator-responsive-collapse-toggle-open' viewbox="0 0 24 24">16590<line x1="7" y1="12" x2="17" y2="12" fill="none" stroke-width="3" stroke-linecap="round" />16591<line y1="7" x1="12" y2="17" x2="12" fill="none" stroke-width="3" stroke-linecap="round" />16592</svg>1659316594<svg class='tabulator-responsive-collapse-toggle-close' viewbox="0 0 24 24">16595<line x1="7" y1="12" x2="17" y2="12" fill="none" stroke-width="3" stroke-linecap="round" />16596</svg>`;1659716598cell.getElement().classList.add("tabulator-row-handle");1659916600function toggleList(isOpen){16601var collapseEl = config.element;1660216603config.open = isOpen;1660416605if(collapseEl){1660616607if(config.open){16608el.classList.add("open");16609collapseEl.style.display = '';16610}else {16611el.classList.remove("open");16612collapseEl.style.display = 'none';16613}16614}16615}1661616617el.addEventListener("click", function(e){16618e.stopImmediatePropagation();16619toggleList(!config.open);16620cell.getTable().rowManager.adjustTableSize();16621});1662216623toggleList(config.open);1662416625return el;16626}1662716628function rowSelection(cell, formatterParams, onRendered){16629var checkbox = document.createElement("input");16630var blocked = false;1663116632checkbox.type = 'checkbox';1663316634checkbox.setAttribute("aria-label", "Select Row");1663516636if(this.table.modExists("selectRow", true)){1663716638checkbox.addEventListener("click", (e) => {16639e.stopPropagation();16640});1664116642if(typeof cell.getRow == 'function'){16643var row = cell.getRow();1664416645if(row instanceof RowComponent){1664616647checkbox.addEventListener("change", (e) => {16648if(this.table.options.selectableRangeMode === "click"){16649if(!blocked){16650row.toggleSelect();16651}else {16652blocked = false;16653}16654}else {16655row.toggleSelect();16656}16657});1665816659if(this.table.options.selectableRangeMode === "click"){16660checkbox.addEventListener("click", (e) => {16661blocked = true;16662this.table.modules.selectRow.handleComplexRowClick(row._row, e);16663});16664}1666516666checkbox.checked = row.isSelected && row.isSelected();16667this.table.modules.selectRow.registerRowSelectCheckbox(row, checkbox);16668}else {16669checkbox = "";16670}16671}else {16672checkbox.addEventListener("change", (e) => {16673if(this.table.modules.selectRow.selectedRows.length){16674this.table.deselectRow();16675}else {16676this.table.selectRow(formatterParams.rowRange);16677}16678});1667916680this.table.modules.selectRow.registerHeaderSelectCheckbox(checkbox);16681}16682}1668316684return checkbox;16685}1668616687var defaultFormatters = {16688plaintext:plaintext,16689html:html$1,16690textarea:textarea$1,16691money:money,16692link:link,16693image:image,16694tickCross:tickCross$1,16695datetime:datetime$1,16696datetimediff:datetimediff,16697lookup:lookup,16698star:star$1,16699traffic:traffic,16700progress:progress$1,16701color:color,16702buttonTick:buttonTick,16703buttonCross:buttonCross,16704rownum:rownum,16705handle:handle,16706responsiveCollapse:responsiveCollapse,16707rowSelection:rowSelection,16708};1670916710class Format extends Module{1671116712constructor(table){16713super(table);1671416715this.registerColumnOption("formatter");16716this.registerColumnOption("formatterParams");1671716718this.registerColumnOption("formatterPrint");16719this.registerColumnOption("formatterPrintParams");16720this.registerColumnOption("formatterClipboard");16721this.registerColumnOption("formatterClipboardParams");16722this.registerColumnOption("formatterHtmlOutput");16723this.registerColumnOption("formatterHtmlOutputParams");16724this.registerColumnOption("titleFormatter");16725this.registerColumnOption("titleFormatterParams");16726}1672716728initialize(){16729this.subscribe("cell-format", this.formatValue.bind(this));16730this.subscribe("cell-rendered", this.cellRendered.bind(this));16731this.subscribe("column-layout", this.initializeColumn.bind(this));16732this.subscribe("column-format", this.formatHeader.bind(this));16733}1673416735//initialize column formatter16736initializeColumn(column){16737column.modules.format = this.lookupFormatter(column, "");1673816739if(typeof column.definition.formatterPrint !== "undefined"){16740column.modules.format.print = this.lookupFormatter(column, "Print");16741}1674216743if(typeof column.definition.formatterClipboard !== "undefined"){16744column.modules.format.clipboard = this.lookupFormatter(column, "Clipboard");16745}1674616747if(typeof column.definition.formatterHtmlOutput !== "undefined"){16748column.modules.format.htmlOutput = this.lookupFormatter(column, "HtmlOutput");16749}16750}1675116752lookupFormatter(column, type){16753var config = {params:column.definition["formatter" + type + "Params"] || {}},16754formatter = column.definition["formatter" + type];1675516756//set column formatter16757switch(typeof formatter){16758case "string":16759if(Format.formatters[formatter]){16760config.formatter = Format.formatters[formatter];16761}else {16762console.warn("Formatter Error - No such formatter found: ", formatter);16763config.formatter = Format.formatters.plaintext;16764}16765break;1676616767case "function":16768config.formatter = formatter;16769break;1677016771default:16772config.formatter = Format.formatters.plaintext;16773break;16774}1677516776return config;16777}1677816779cellRendered(cell){16780if(cell.modules.format && cell.modules.format.renderedCallback && !cell.modules.format.rendered){16781cell.modules.format.renderedCallback();16782cell.modules.format.rendered = true;16783}16784}1678516786//return a formatted value for a column header16787formatHeader(column, title, el){16788var formatter, params, onRendered, mockCell;1678916790if(column.definition.titleFormatter){16791formatter = this.getFormatter(column.definition.titleFormatter);1679216793onRendered = (callback) => {16794column.titleFormatterRendered = callback;16795};1679616797mockCell = {16798getValue:function(){16799return title;16800},16801getElement:function(){16802return el;16803},16804getType:function(){16805return "header";16806},16807getColumn:function(){16808return column.getComponent();16809},16810getTable:() => {16811return this.table;16812}16813};1681416815params = column.definition.titleFormatterParams || {};1681616817params = typeof params === "function" ? params() : params;1681816819return formatter.call(this, mockCell, params, onRendered);16820}else {16821return title;16822}16823}168241682516826//return a formatted value for a cell16827formatValue(cell){16828var component = cell.getComponent(),16829params = typeof cell.column.modules.format.params === "function" ? cell.column.modules.format.params(component) : cell.column.modules.format.params;1683016831function onRendered(callback){16832if(!cell.modules.format){16833cell.modules.format = {};16834}1683516836cell.modules.format.renderedCallback = callback;16837cell.modules.format.rendered = false;16838}1683916840return cell.column.modules.format.formatter.call(this, component, params, onRendered);16841}1684216843formatExportValue(cell, type){16844var formatter = cell.column.modules.format[type],16845params;1684616847if(formatter){16848params = typeof formatter.params === "function" ? formatter.params(cell.getComponent()) : formatter.params;1684916850function onRendered(callback){16851if(!cell.modules.format){16852cell.modules.format = {};16853}1685416855cell.modules.format.renderedCallback = callback;16856cell.modules.format.rendered = false;16857}1685816859return formatter.formatter.call(this, cell.getComponent(), params, onRendered);1686016861}else {16862return this.formatValue(cell);16863}16864}1686516866sanitizeHTML(value){16867if(value){16868var entityMap = {16869'&': '&',16870'<': '<',16871'>': '>',16872'"': '"',16873"'": ''',16874'/': '/',16875'`': '`',16876'=': '='16877};1687816879return String(value).replace(/[&<>"'`=/]/g, function (s) {16880return entityMap[s];16881});16882}else {16883return value;16884}16885}1688616887emptyToSpace(value){16888return value === null || typeof value === "undefined" || value === "" ? " " : value;16889}1689016891//get formatter for cell16892getFormatter(formatter){16893switch(typeof formatter){16894case "string":16895if(Format.formatters[formatter]){16896formatter = Format.formatters[formatter];16897}else {16898console.warn("Formatter Error - No such formatter found: ", formatter);16899formatter = Format.formatters.plaintext;16900}16901break;1690216903case "function":16904//Custom formatter Function, do nothing16905break;1690616907default:16908formatter = Format.formatters.plaintext;16909break;16910}1691116912return formatter;16913}16914}1691516916Format.moduleName = "format";1691716918//load defaults16919Format.formatters = defaultFormatters;1692016921class FrozenColumns extends Module{1692216923constructor(table){16924super(table);1692516926this.leftColumns = [];16927this.rightColumns = [];16928this.initializationMode = "left";16929this.active = false;16930this.blocked = true;1693116932this.registerColumnOption("frozen");16933}1693416935//reset initial state16936reset(){16937this.initializationMode = "left";16938this.leftColumns = [];16939this.rightColumns = [];16940this.active = false;16941}1694216943initialize(){16944this.subscribe("cell-layout", this.layoutCell.bind(this));16945this.subscribe("column-init", this.initializeColumn.bind(this));16946this.subscribe("column-width", this.layout.bind(this));16947this.subscribe("row-layout-after", this.layoutRow.bind(this));16948this.subscribe("table-layout", this.layout.bind(this));16949this.subscribe("columns-loading", this.reset.bind(this));1695016951this.subscribe("column-add", this.reinitializeColumns.bind(this));16952this.subscribe("column-delete", this.reinitializeColumns.bind(this));1695316954this.subscribe("table-redraw", this.layout.bind(this));16955this.subscribe("layout-refreshing", this.blockLayout.bind(this));16956this.subscribe("layout-refreshed", this.unblockLayout.bind(this));16957this.subscribe("scrollbar-vertical", this.adjustForScrollbar.bind(this));16958}1695916960blockLayout(){16961this.blocked = true;16962}1696316964unblockLayout(){16965this.blocked = false;16966}1696716968layoutCell(cell){16969this.layoutElement(cell.element, cell.column);16970}1697116972reinitializeColumns(){16973this.reset();1697416975this.table.columnManager.columnsByIndex.forEach((column) => {16976this.initializeColumn(column);16977});16978}1697916980//initialize specific column16981initializeColumn(column){16982var config = {margin:0, edge:false};1698316984if(!column.isGroup){1698516986if(this.frozenCheck(column)){1698716988config.position = this.initializationMode;1698916990if(this.initializationMode == "left"){16991this.leftColumns.push(column);16992}else {16993this.rightColumns.unshift(column);16994}1699516996this.active = true;1699716998column.modules.frozen = config;16999}else {17000this.initializationMode = "right";17001}17002}17003}1700417005frozenCheck(column){17006if(column.parent.isGroup && column.definition.frozen){17007console.warn("Frozen Column Error - Parent column group must be frozen, not individual columns or sub column groups");17008}1700917010if(column.parent.isGroup){17011return this.frozenCheck(column.parent);17012}else {17013return column.definition.frozen;17014}17015}1701617017//layout calculation rows17018layoutCalcRows(){17019if(this.table.modExists("columnCalcs")){17020if(this.table.modules.columnCalcs.topInitialized && this.table.modules.columnCalcs.topRow){17021this.layoutRow(this.table.modules.columnCalcs.topRow);17022}1702317024if(this.table.modules.columnCalcs.botInitialized && this.table.modules.columnCalcs.botRow){17025this.layoutRow(this.table.modules.columnCalcs.botRow);17026}1702717028if(this.table.modExists("groupRows")){17029this.layoutGroupCalcs(this.table.modules.groupRows.getGroups());17030}17031}17032}1703317034layoutGroupCalcs(groups){17035groups.forEach((group) => {17036if(group.calcs.top){17037this.layoutRow(group.calcs.top);17038}1703917040if(group.calcs.bottom){17041this.layoutRow(group.calcs.bottom);17042}1704317044if(group.groupList && group.groupList.length){17045this.layoutGroupCalcs(group.groupList);17046}17047});17048}1704917050//calculate column positions and layout headers17051layoutColumnPosition(allCells){17052var leftParents = [];1705317054var leftMargin = 0;17055var rightMargin = 0;1705617057this.leftColumns.forEach((column, i) => {17058column.modules.frozen.marginValue = leftMargin;17059column.modules.frozen.margin = column.modules.frozen.marginValue + "px";1706017061if(column.visible){17062leftMargin += column.getWidth();17063}1706417065if(i == this.leftColumns.length - 1){17066column.modules.frozen.edge = true;17067}else {17068column.modules.frozen.edge = false;17069}1707017071if(column.parent.isGroup){17072var parentEl = this.getColGroupParentElement(column);17073if(!leftParents.includes(parentEl)){17074this.layoutElement(parentEl, column);17075leftParents.push(parentEl);17076}1707717078if(column.modules.frozen.edge){17079parentEl.classList.add("tabulator-frozen-" + column.modules.frozen.position);17080}17081}else {17082this.layoutElement(column.getElement(), column);17083}1708417085if(allCells){17086column.cells.forEach((cell) => {17087this.layoutElement(cell.getElement(true), column);17088});17089}17090});1709117092this.rightColumns.forEach((column, i) => {1709317094column.modules.frozen.marginValue = rightMargin;17095column.modules.frozen.margin = column.modules.frozen.marginValue + "px";1709617097if(column.visible){17098rightMargin += column.getWidth();17099}1710017101if(i == this.rightColumns.length - 1){17102column.modules.frozen.edge = true;17103}else {17104column.modules.frozen.edge = false;17105}1710617107if(column.parent.isGroup){17108this.layoutElement(this.getColGroupParentElement(column), column);17109}else {17110this.layoutElement(column.getElement(), column);17111}1711217113if(allCells){17114column.cells.forEach((cell) => {17115this.layoutElement(cell.getElement(true), column);17116});17117}17118});17119}1712017121getColGroupParentElement(column){17122return column.parent.isGroup ? this.getColGroupParentElement(column.parent) : column.getElement();17123}1712417125//layout columns appropriately17126layout(){17127if(this.active && !this.blocked){1712817129//calculate left columns17130this.layoutColumnPosition();1713117132this.reinitializeRows();1713317134this.layoutCalcRows();17135}17136}1713717138reinitializeRows(){17139var visibleRows = this.table.rowManager.getVisibleRows(true);17140var otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));1714117142otherRows.forEach((row) =>{17143row.deinitialize();17144});1714517146visibleRows.forEach((row) =>{17147if(row.type === "row"){17148this.layoutRow(row);17149}17150});17151}1715217153layoutRow(row){17154if(this.table.options.layout === "fitDataFill" && this.rightColumns.length){17155this.table.rowManager.getTableElement().style.minWidth = "calc(100% - " + this.rightMargin + ")";17156}1715717158this.leftColumns.forEach((column) => {17159var cell = row.getCell(column);1716017161if(cell){17162this.layoutElement(cell.getElement(true), column);17163}17164});1716517166this.rightColumns.forEach((column) => {17167var cell = row.getCell(column);1716817169if(cell){17170this.layoutElement(cell.getElement(true), column);17171}17172});17173}1717417175layoutElement(element, column){17176var position;1717717178if(column.modules.frozen && element){17179element.style.position = "sticky";1718017181if(this.table.rtl){17182position = column.modules.frozen.position === "left" ? "right" : "left";17183}else {17184position = column.modules.frozen.position;17185}1718617187element.style[position] = column.modules.frozen.margin;1718817189element.classList.add("tabulator-frozen");1719017191if(column.modules.frozen.edge){17192element.classList.add("tabulator-frozen-" + column.modules.frozen.position);17193}17194}17195}1719617197adjustForScrollbar(width){17198if(this.rightColumns.length){17199this.table.columnManager.getContentsElement().style.width = "calc(100% - " + width + "px)";17200}17201}1720217203_calcSpace(columns, index){17204var width = 0;1720517206for (let i = 0; i < index; i++){17207if(columns[i].visible){17208width += columns[i].getWidth();17209}17210}1721117212return width;17213}17214}1721517216FrozenColumns.moduleName = "frozenColumns";1721717218class FrozenRows extends Module{1721917220constructor(table){17221super(table);1722217223this.topElement = document.createElement("div");17224this.rows = [];1722517226//register component functions17227this.registerComponentFunction("row", "freeze", this.freezeRow.bind(this));17228this.registerComponentFunction("row", "unfreeze", this.unfreezeRow.bind(this));17229this.registerComponentFunction("row", "isFrozen", this.isRowFrozen.bind(this));1723017231//register table options17232this.registerTableOption("frozenRowsField", "id"); //field to choose frozen rows by17233this.registerTableOption("frozenRows", false); //holder for frozen row identifiers17234}1723517236initialize(){17237this.rows = [];1723817239this.topElement.classList.add("tabulator-frozen-rows-holder");1724017241// this.table.columnManager.element.append(this.topElement);17242this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);1724317244this.subscribe("row-deleting", this.detachRow.bind(this));17245this.subscribe("rows-visible", this.visibleRows.bind(this));1724617247this.registerDisplayHandler(this.getRows.bind(this), 10);1724817249if(this.table.options.frozenRows){17250this.subscribe("data-processed", this.initializeRows.bind(this));17251this.subscribe("row-added", this.initializeRow.bind(this));17252this.subscribe("table-redrawing", this.resizeHolderWidth.bind(this));17253this.subscribe("column-resized", this.resizeHolderWidth.bind(this));17254this.subscribe("column-show", this.resizeHolderWidth.bind(this));17255this.subscribe("column-hide", this.resizeHolderWidth.bind(this));17256}1725717258this.resizeHolderWidth();17259}1726017261resizeHolderWidth(){17262this.topElement.style.minWidth = this.table.columnManager.headersElement.offsetWidth + "px";17263}1726417265initializeRows(){17266this.table.rowManager.getRows().forEach((row) => {17267this.initializeRow(row);17268});17269}1727017271initializeRow(row){17272var frozenRows = this.table.options.frozenRows,17273rowType = typeof frozenRows;1727417275if(rowType === "number"){17276if(row.getPosition() && (row.getPosition() + this.rows.length) <= frozenRows){17277this.freezeRow(row);17278}17279}else if(rowType === "function"){17280if(frozenRows.call(this.table, row.getComponent())){17281this.freezeRow(row);17282}17283}else if(Array.isArray(frozenRows)){17284if(frozenRows.includes(row.data[this.options("frozenRowsField")])){17285this.freezeRow(row);17286}17287}17288}1728917290isRowFrozen(row){17291var index = this.rows.indexOf(row);17292return index > -1;17293}1729417295isFrozen(){17296return !!this.rows.length;17297}1729817299visibleRows(viewable, rows){17300this.rows.forEach((row) => {17301rows.push(row);17302});1730317304return rows;17305}1730617307//filter frozen rows out of display data17308getRows(rows){17309var output = rows.slice(0);1731017311this.rows.forEach(function(row){17312var index = output.indexOf(row);1731317314if(index > -1){17315output.splice(index, 1);17316}17317});1731817319return output;17320}1732117322freezeRow(row){17323if(!row.modules.frozen){17324row.modules.frozen = true;17325this.topElement.appendChild(row.getElement());17326row.initialize();17327row.normalizeHeight();1732817329this.rows.push(row);1733017331this.refreshData(false, "display");1733217333this.table.rowManager.adjustTableSize();1733417335this.styleRows();1733617337}else {17338console.warn("Freeze Error - Row is already frozen");17339}17340}1734117342unfreezeRow(row){17343if(row.modules.frozen){1734417345row.modules.frozen = false;1734617347this.detachRow(row);1734817349this.table.rowManager.adjustTableSize();1735017351this.refreshData(false, "display");1735217353if(this.rows.length){17354this.styleRows();17355}1735617357}else {17358console.warn("Freeze Error - Row is already unfrozen");17359}17360}1736117362detachRow(row){17363var index = this.rows.indexOf(row);1736417365if(index > -1){17366var rowEl = row.getElement();1736717368if(rowEl.parentNode){17369rowEl.parentNode.removeChild(rowEl);17370}1737117372this.rows.splice(index, 1);17373}17374}1737517376styleRows(row){17377this.rows.forEach((row, i) => {17378this.table.rowManager.styleRow(row, i);17379});17380}17381}1738217383FrozenRows.moduleName = "frozenRows";1738417385//public group object17386class GroupComponent {17387constructor (group){17388this._group = group;17389this.type = "GroupComponent";1739017391return new Proxy(this, {17392get: function(target, name, receiver) {17393if (typeof target[name] !== "undefined") {17394return target[name];17395}else {17396return target._group.groupManager.table.componentFunctionBinder.handle("group", target._group, name);17397}17398}17399});17400}1740117402getKey(){17403return this._group.key;17404}1740517406getField(){17407return this._group.field;17408}1740917410getElement(){17411return this._group.element;17412}1741317414getRows(){17415return this._group.getRows(true);17416}1741717418getSubGroups(){17419return this._group.getSubGroups(true);17420}1742117422getParentGroup(){17423return this._group.parent ? this._group.parent.getComponent() : false;17424}1742517426isVisible(){17427return this._group.visible;17428}1742917430show(){17431this._group.show();17432}1743317434hide(){17435this._group.hide();17436}1743717438toggle(){17439this._group.toggleVisibility();17440}1744117442scrollTo(position, ifVisible){17443return this._group.groupManager.table.rowManager.scrollToRow(this._group, position, ifVisible);17444}1744517446_getSelf(){17447return this._group;17448}1744917450getTable(){17451return this._group.groupManager.table;17452}17453}1745417455//Group functions17456class Group{1745717458constructor(groupManager, parent, level, key, field, generator, oldGroup){17459this.groupManager = groupManager;17460this.parent = parent;17461this.key = key;17462this.level = level;17463this.field = field;17464this.hasSubGroups = level < (groupManager.groupIDLookups.length - 1);17465this.addRow = this.hasSubGroups ? this._addRowToGroup : this._addRow;17466this.type = "group"; //type of element17467this.old = oldGroup;17468this.rows = [];17469this.groups = [];17470this.groupList = [];17471this.generator = generator;17472this.element = false;17473this.elementContents = false;17474this.height = 0;17475this.outerHeight = 0;17476this.initialized = false;17477this.calcs = {};17478this.initialized = false;17479this.modules = {};17480this.arrowElement = false;1748117482this.visible = oldGroup ? oldGroup.visible : (typeof groupManager.startOpen[level] !== "undefined" ? groupManager.startOpen[level] : groupManager.startOpen[0]);1748317484this.component = null;1748517486this.createElements();17487this.addBindings();1748817489this.createValueGroups();17490}1749117492wipe(elementsOnly){17493if(!elementsOnly){17494if(this.groupList.length){17495this.groupList.forEach(function(group){17496group.wipe();17497});17498}else {17499this.rows.forEach((row) => {17500if(row.modules){17501delete row.modules.group;17502}17503});17504}17505}1750617507this.element = false;17508this.arrowElement = false;17509this.elementContents = false;17510}1751117512createElements(){17513var arrow = document.createElement("div");17514arrow.classList.add("tabulator-arrow");1751517516this.element = document.createElement("div");17517this.element.classList.add("tabulator-row");17518this.element.classList.add("tabulator-group");17519this.element.classList.add("tabulator-group-level-" + this.level);17520this.element.setAttribute("role", "rowgroup");1752117522this.arrowElement = document.createElement("div");17523this.arrowElement.classList.add("tabulator-group-toggle");17524this.arrowElement.appendChild(arrow);1752517526//setup movable rows17527if(this.groupManager.table.options.movableRows !== false && this.groupManager.table.modExists("moveRow")){17528this.groupManager.table.modules.moveRow.initializeGroupHeader(this);17529}17530}1753117532createValueGroups(){17533var level = this.level + 1;17534if(this.groupManager.allowedValues && this.groupManager.allowedValues[level]){17535this.groupManager.allowedValues[level].forEach((value) => {17536this._createGroup(value, level);17537});17538}17539}1754017541addBindings(){17542var toggleElement;1754317544if(this.groupManager.table.options.groupToggleElement){17545toggleElement = this.groupManager.table.options.groupToggleElement == "arrow" ? this.arrowElement : this.element;1754617547toggleElement.addEventListener("click", (e) => {17548if(this.groupManager.table.options.groupToggleElement === "arrow"){17549e.stopPropagation();17550e.stopImmediatePropagation();17551}1755217553//allow click event to propagate before toggling visibility17554setTimeout(() => {17555this.toggleVisibility();17556});17557});17558}17559}1756017561_createGroup(groupID, level){17562var groupKey = level + "_" + groupID;17563var group = new Group(this.groupManager, this, level, groupID, this.groupManager.groupIDLookups[level].field, this.groupManager.headerGenerator[level] || this.groupManager.headerGenerator[0], this.old ? this.old.groups[groupKey] : false);1756417565this.groups[groupKey] = group;17566this.groupList.push(group);17567}1756817569_addRowToGroup(row){1757017571var level = this.level + 1;1757217573if(this.hasSubGroups){17574var groupID = this.groupManager.groupIDLookups[level].func(row.getData()),17575groupKey = level + "_" + groupID;1757617577if(this.groupManager.allowedValues && this.groupManager.allowedValues[level]){17578if(this.groups[groupKey]){17579this.groups[groupKey].addRow(row);17580}17581}else {17582if(!this.groups[groupKey]){17583this._createGroup(groupID, level);17584}1758517586this.groups[groupKey].addRow(row);17587}17588}17589}1759017591_addRow(row){17592this.rows.push(row);17593row.modules.group = this;17594}1759517596insertRow(row, to, after){17597var data = this.conformRowData({});1759817599row.updateData(data);1760017601var toIndex = this.rows.indexOf(to);1760217603if(toIndex > -1){17604if(after){17605this.rows.splice(toIndex+1, 0, row);17606}else {17607this.rows.splice(toIndex, 0, row);17608}17609}else {17610if(after){17611this.rows.push(row);17612}else {17613this.rows.unshift(row);17614}17615}1761617617row.modules.group = this;1761817619// this.generateGroupHeaderContents();1762017621if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){17622this.groupManager.table.modules.columnCalcs.recalcGroup(this);17623}1762417625this.groupManager.updateGroupRows(true);17626}1762717628scrollHeader(left){17629if(this.arrowElement){17630this.arrowElement.style.marginLeft = left;1763117632this.groupList.forEach(function(child){17633child.scrollHeader(left);17634});17635}17636}1763717638getRowIndex(row){}1763917640//update row data to match grouping constraints17641conformRowData(data){17642if(this.field){17643data[this.field] = this.key;17644}else {17645console.warn("Data Conforming Error - Cannot conform row data to match new group as groupBy is a function");17646}1764717648if(this.parent){17649data = this.parent.conformRowData(data);17650}1765117652return data;17653}1765417655removeRow(row){17656var index = this.rows.indexOf(row);17657var el = row.getElement();1765817659if(index > -1){17660this.rows.splice(index, 1);17661}1766217663if(!this.groupManager.table.options.groupValues && !this.rows.length){17664if(this.parent){17665this.parent.removeGroup(this);17666}else {17667this.groupManager.removeGroup(this);17668}1766917670this.groupManager.updateGroupRows(true);1767117672}else {1767317674if(el.parentNode){17675el.parentNode.removeChild(el);17676}1767717678if(!this.groupManager.blockRedraw){17679this.generateGroupHeaderContents();1768017681if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){17682this.groupManager.table.modules.columnCalcs.recalcGroup(this);17683}17684}1768517686}17687}1768817689removeGroup(group){17690var groupKey = group.level + "_" + group.key,17691index;1769217693if(this.groups[groupKey]){17694delete this.groups[groupKey];1769517696index = this.groupList.indexOf(group);1769717698if(index > -1){17699this.groupList.splice(index, 1);17700}1770117702if(!this.groupList.length){17703if(this.parent){17704this.parent.removeGroup(this);17705}else {17706this.groupManager.removeGroup(this);17707}17708}17709}17710}1771117712getHeadersAndRows(){17713var output = [];1771417715output.push(this);1771617717this._visSet();177181771917720if(this.calcs.top){17721this.calcs.top.detachElement();17722this.calcs.top.deleteCells();17723}1772417725if(this.calcs.bottom){17726this.calcs.bottom.detachElement();17727this.calcs.bottom.deleteCells();17728}17729177301773117732if(this.visible){17733if(this.groupList.length){17734this.groupList.forEach(function(group){17735output = output.concat(group.getHeadersAndRows());17736});1773717738}else {17739if(this.groupManager.table.options.columnCalcs != "table" && this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.modules.columnCalcs.hasTopCalcs()){17740this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);17741output.push(this.calcs.top);17742}1774317744output = output.concat(this.rows);1774517746if(this.groupManager.table.options.columnCalcs != "table" && this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.modules.columnCalcs.hasBottomCalcs()){17747this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);17748output.push(this.calcs.bottom);17749}17750}17751}else {17752if(!this.groupList.length && this.groupManager.table.options.columnCalcs != "table"){1775317754if(this.groupManager.table.modExists("columnCalcs")){17755if(this.groupManager.table.modules.columnCalcs.hasTopCalcs()){17756if(this.groupManager.table.options.groupClosedShowCalcs){17757this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);17758output.push(this.calcs.top);17759}17760}1776117762if(this.groupManager.table.modules.columnCalcs.hasBottomCalcs()){17763if(this.groupManager.table.options.groupClosedShowCalcs){17764this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);17765output.push(this.calcs.bottom);17766}17767}17768}17769}1777017771}1777217773return output;17774}1777517776getData(visible, transform){17777var output = [];1777817779this._visSet();1778017781if(!visible || (visible && this.visible)){17782this.rows.forEach((row) => {17783output.push(row.getData(transform || "data"));17784});17785}1778617787return output;17788}1778917790getRowCount(){17791var count = 0;1779217793if(this.groupList.length){17794this.groupList.forEach((group) => {17795count += group.getRowCount();17796});17797}else {17798count = this.rows.length;17799}17800return count;17801}178021780317804toggleVisibility(){17805if(this.visible){17806this.hide();17807}else {17808this.show();17809}17810}1781117812hide(){17813this.visible = false;1781417815if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){1781617817this.element.classList.remove("tabulator-group-visible");1781817819if(this.groupList.length){17820this.groupList.forEach((group) => {1782117822var rows = group.getHeadersAndRows();1782317824rows.forEach((row) => {17825row.detachElement();17826});17827});1782817829}else {17830this.rows.forEach((row) => {17831var rowEl = row.getElement();17832rowEl.parentNode.removeChild(rowEl);17833});17834}1783517836this.groupManager.updateGroupRows(true);1783717838}else {17839this.groupManager.updateGroupRows(true);17840}1784117842this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), false);17843}1784417845show(){17846this.visible = true;1784717848if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){1784917850this.element.classList.add("tabulator-group-visible");1785117852var prev = this.generateElement();1785317854if(this.groupList.length){17855this.groupList.forEach((group) => {17856var rows = group.getHeadersAndRows();1785717858rows.forEach((row) => {17859var rowEl = row.getElement();17860prev.parentNode.insertBefore(rowEl, prev.nextSibling);17861row.initialize();17862prev = rowEl;17863});17864});1786517866}else {17867this.rows.forEach((row) => {17868var rowEl = row.getElement();17869prev.parentNode.insertBefore(rowEl, prev.nextSibling);17870row.initialize();17871prev = rowEl;17872});17873}1787417875this.groupManager.updateGroupRows(true);17876}else {17877this.groupManager.updateGroupRows(true);17878}1787917880this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), true);17881}1788217883_visSet(){17884var data = [];1788517886if(typeof this.visible == "function"){1788717888this.rows.forEach(function(row){17889data.push(row.getData());17890});1789117892this.visible = this.visible(this.key, this.getRowCount(), data, this.getComponent());17893}17894}1789517896getRowGroup(row){17897var match = false;17898if(this.groupList.length){17899this.groupList.forEach(function(group){17900var result = group.getRowGroup(row);1790117902if(result){17903match = result;17904}17905});17906}else {17907if(this.rows.find(function(item){17908return item === row;17909})){17910match = this;17911}17912}1791317914return match;17915}1791617917getSubGroups(component){17918var output = [];1791917920this.groupList.forEach(function(child){17921output.push(component ? child.getComponent() : child);17922});1792317924return output;17925}1792617927getRows(component, includeChildren){17928var output = [];1792917930if(includeChildren && this.groupList.length){17931this.groupList.forEach((group) => {17932output = output.concat(group.getRows(component, includeChildren));17933});17934}else {17935this.rows.forEach(function(row){17936output.push(component ? row.getComponent() : row);17937});17938}1793917940return output;17941}1794217943generateGroupHeaderContents(){17944var data = [];1794517946var rows = this.getRows(false, true);1794717948rows.forEach(function(row){17949data.push(row.getData());17950});1795117952this.elementContents = this.generator(this.key, this.getRowCount(), data, this.getComponent());1795317954while(this.element.firstChild) this.element.removeChild(this.element.firstChild);1795517956if(typeof this.elementContents === "string"){17957this.element.innerHTML = this.elementContents;17958}else {17959this.element.appendChild(this.elementContents);17960}1796117962this.element.insertBefore(this.arrowElement, this.element.firstChild);17963}1796417965getPath(path = []) {17966path.unshift(this.key);17967if(this.parent) {17968this.parent.getPath(path);17969}17970return path;17971}1797217973////////////// Standard Row Functions //////////////1797417975getElement(){17976return this.elementContents ? this.element : this.generateElement();17977}1797817979generateElement(){17980this.addBindings = false;1798117982this._visSet();1798317984if(this.visible){17985this.element.classList.add("tabulator-group-visible");17986}else {17987this.element.classList.remove("tabulator-group-visible");17988}1798917990for(var i = 0; i < this.element.childNodes.length; ++i){17991this.element.childNodes[i].parentNode.removeChild(this.element.childNodes[i]);17992}1799317994this.generateGroupHeaderContents();1799517996// this.addBindings();1799717998return this.element;17999}1800018001detachElement(){18002if (this.element && this.element.parentNode){18003this.element.parentNode.removeChild(this.element);18004}18005}1800618007//normalize the height of elements in the row18008normalizeHeight(){18009this.setHeight(this.element.clientHeight);18010}1801118012initialize(force){18013if(!this.initialized || force){18014this.normalizeHeight();18015this.initialized = true;18016}18017}1801818019reinitialize(){18020this.initialized = false;18021this.height = 0;1802218023if(Helpers.elVisible(this.element)){18024this.initialize(true);18025}18026}1802718028setHeight(height){18029if(this.height != height){18030this.height = height;18031this.outerHeight = this.element.offsetHeight;18032}18033}1803418035//return rows outer height18036getHeight(){18037return this.outerHeight;18038}1803918040getGroup(){18041return this;18042}1804318044reinitializeHeight(){}1804518046calcHeight(){}1804718048setCellHeight(){}1804918050clearCellHeight(){}1805118052deinitializeHeight(){}1805318054rendered(){}1805518056//////////////// Object Generation /////////////////18057getComponent(){18058if(!this.component){18059this.component = new GroupComponent(this);18060}1806118062return this.component;18063}18064}1806518066class GroupRows extends Module{1806718068constructor(table){18069super(table);1807018071this.groupIDLookups = false; //enable table grouping and set field to group by18072this.startOpen = [function(){return false;}]; //starting state of group18073this.headerGenerator = [function(){return "";}];18074this.groupList = []; //ordered list of groups18075this.allowedValues = false;18076this.groups = {}; //hold row groups1807718078this.displayHandler = this.getRows.bind(this);1807918080this.blockRedraw = false;1808118082//register table options18083this.registerTableOption("groupBy", false); //enable table grouping and set field to group by18084this.registerTableOption("groupStartOpen", true); //starting state of group18085this.registerTableOption("groupValues", false);18086this.registerTableOption("groupUpdateOnCellEdit", false);18087this.registerTableOption("groupHeader", false); //header generation function18088this.registerTableOption("groupHeaderPrint", null);18089this.registerTableOption("groupHeaderClipboard", null);18090this.registerTableOption("groupHeaderHtmlOutput", null);18091this.registerTableOption("groupHeaderDownload", null);18092this.registerTableOption("groupToggleElement", "arrow");18093this.registerTableOption("groupClosedShowCalcs", false);1809418095//register table functions18096this.registerTableFunction("setGroupBy", this.setGroupBy.bind(this));18097this.registerTableFunction("setGroupValues", this.setGroupValues.bind(this));18098this.registerTableFunction("setGroupStartOpen", this.setGroupStartOpen.bind(this));18099this.registerTableFunction("setGroupHeader", this.setGroupHeader.bind(this));18100this.registerTableFunction("getGroups", this.userGetGroups.bind(this));18101this.registerTableFunction("getGroupedData", this.userGetGroupedData.bind(this));1810218103//register component functions18104this.registerComponentFunction("row", "getGroup", this.rowGetGroup.bind(this));18105}1810618107//initialize group configuration18108initialize(){18109this.subscribe("table-destroy", this._blockRedrawing.bind(this));18110this.subscribe("rows-wipe", this._blockRedrawing.bind(this));18111this.subscribe("rows-wiped", this._restore_redrawing.bind(this));1811218113if(this.table.options.groupBy){18114if(this.table.options.groupUpdateOnCellEdit){18115this.subscribe("cell-value-updated", this.cellUpdated.bind(this));18116this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);18117}1811818119this.subscribe("table-built", this.configureGroupSetup.bind(this));1812018121this.subscribe("row-deleting", this.rowDeleting.bind(this));18122this.subscribe("row-deleted", this.rowsUpdated.bind(this));18123this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));18124this.subscribe("rows-wipe", this.wipe.bind(this));18125this.subscribe("rows-added", this.rowsUpdated.bind(this));18126this.subscribe("row-moving", this.rowMoving.bind(this));18127this.subscribe("row-adding-index", this.rowAddingIndex.bind(this));1812818129this.subscribe("rows-sample", this.rowSample.bind(this));1813018131this.subscribe("render-virtual-fill", this.virtualRenderFill.bind(this));1813218133this.registerDisplayHandler(this.displayHandler, 20);1813418135this.initialized = true;18136}18137}1813818139_blockRedrawing(){18140this.blockRedraw = true;18141}1814218143_restore_redrawing(){18144this.blockRedraw = false;18145}1814618147configureGroupSetup(){18148if(this.table.options.groupBy){18149var groupBy = this.table.options.groupBy,18150startOpen = this.table.options.groupStartOpen,18151groupHeader = this.table.options.groupHeader;1815218153this.allowedValues = this.table.options.groupValues;1815418155if(Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length){18156console.warn("Error creating group headers, groupHeader array is shorter than groupBy array");18157}1815818159this.headerGenerator = [function(){return "";}];18160this.startOpen = [function(){return false;}]; //starting state of group1816118162this.langBind("groups|item", (langValue, lang) => {18163this.headerGenerator[0] = (value, count, data) => { //header layout function18164return (typeof value === "undefined" ? "" : value) + "<span>(" + count + " " + ((count === 1) ? langValue : lang.groups.items) + ")</span>";18165};18166});1816718168this.groupIDLookups = [];1816918170if(groupBy){18171if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "table" && this.table.options.columnCalcs != "both"){18172this.table.modules.columnCalcs.removeCalcs();18173}18174}else {18175if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "group"){1817618177var cols = this.table.columnManager.getRealColumns();1817818179cols.forEach((col) => {18180if(col.definition.topCalc){18181this.table.modules.columnCalcs.initializeTopRow();18182}1818318184if(col.definition.bottomCalc){18185this.table.modules.columnCalcs.initializeBottomRow();18186}18187});18188}18189}1819018191if(!Array.isArray(groupBy)){18192groupBy = [groupBy];18193}1819418195groupBy.forEach((group, i) => {18196var lookupFunc, column;1819718198if(typeof group == "function"){18199lookupFunc = group;18200}else {18201column = this.table.columnManager.getColumnByField(group);1820218203if(column){18204lookupFunc = function(data){18205return column.getFieldValue(data);18206};18207}else {18208lookupFunc = function(data){18209return data[group];18210};18211}18212}1821318214this.groupIDLookups.push({18215field: typeof group === "function" ? false : group,18216func:lookupFunc,18217values:this.allowedValues ? this.allowedValues[i] : false,18218});18219});1822018221if(startOpen){18222if(!Array.isArray(startOpen)){18223startOpen = [startOpen];18224}1822518226startOpen.forEach((level) => {18227});1822818229this.startOpen = startOpen;18230}1823118232if(groupHeader){18233this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader];18234}18235}else {18236this.groupList = [];18237this.groups = {};18238}18239}1824018241rowSample(rows, prevValue){18242if(this.table.options.groupBy){18243var group = this.getGroups(false)[0];1824418245prevValue.push(group.getRows(false)[0]);18246}1824718248return prevValue;18249}1825018251virtualRenderFill(){18252var el = this.table.rowManager.tableElement;18253var rows = this.table.rowManager.getVisibleRows();1825418255if(this.table.options.groupBy){18256rows = rows.filter((row) => {18257return row.type !== "group";18258});1825918260el.style.minWidth = !rows.length ? this.table.columnManager.getWidth() + "px" : "";18261}else {18262return rows;18263}18264}1826518266rowAddingIndex(row, index, top){18267if(this.table.options.groupBy){18268this.assignRowToGroup(row);1826918270var groupRows = row.modules.group.rows;1827118272if(groupRows.length > 1){18273if(!index || (index && groupRows.indexOf(index) == -1)){18274if(top){18275if(groupRows[0] !== row){18276index = groupRows[0];18277this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);18278}18279}else {18280if(groupRows[groupRows.length -1] !== row){18281index = groupRows[groupRows.length -1];18282this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);18283}18284}18285}else {18286this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);18287}18288}1828918290return index;18291}18292}1829318294trackChanges(){18295this.dispatch("group-changed");18296}1829718298///////////////////////////////////18299///////// Table Functions /////////18300///////////////////////////////////1830118302setGroupBy(groups){18303this.table.options.groupBy = groups;1830418305if(!this.initialized){18306this.initialize();18307}1830818309this.configureGroupSetup();1831018311if(!groups && this.table.modExists("columnCalcs") && this.table.options.columnCalcs === true){18312this.table.modules.columnCalcs.reinitializeCalcs();18313}1831418315this.refreshData();1831618317this.trackChanges();18318}1831918320setGroupValues(groupValues){18321this.table.options.groupValues = groupValues;18322this.configureGroupSetup();18323this.refreshData();1832418325this.trackChanges();18326}1832718328setGroupStartOpen(values){18329this.table.options.groupStartOpen = values;18330this.configureGroupSetup();1833118332if(this.table.options.groupBy){18333this.refreshData();1833418335this.trackChanges();18336}else {18337console.warn("Grouping Update - cant refresh view, no groups have been set");18338}18339}1834018341setGroupHeader(values){18342this.table.options.groupHeader = values;18343this.configureGroupSetup();1834418345if(this.table.options.groupBy){18346this.refreshData();1834718348this.trackChanges();18349}else {18350console.warn("Grouping Update - cant refresh view, no groups have been set");18351}18352}1835318354userGetGroups(values){18355return this.getGroups(true);18356}1835718358// get grouped table data in the same format as getData()18359userGetGroupedData(){18360return this.table.options.groupBy ? this.getGroupedData() : this.getData();18361}183621836318364///////////////////////////////////////18365///////// Component Functions /////////18366///////////////////////////////////////1836718368rowGetGroup(row){18369return row.modules.group ? row.modules.group.getComponent() : false;18370}1837118372///////////////////////////////////18373///////// Internal Logic //////////18374///////////////////////////////////1837518376rowMoving(from, to, after){18377if(this.table.options.groupBy){18378if(!after && to instanceof Group){18379to = this.table.rowManager.prevDisplayRow(from) || to;18380}1838118382var toGroup = to instanceof Group ? to : to.modules.group;18383var fromGroup = from instanceof Group ? from : from.modules.group;1838418385if(toGroup === fromGroup){18386this.table.rowManager.moveRowInArray(toGroup.rows, from, to, after);18387}else {18388if(fromGroup){18389fromGroup.removeRow(from);18390}1839118392toGroup.insertRow(from, to, after);18393}18394}18395}183961839718398rowDeleting(row){18399//remove from group18400if(this.table.options.groupBy && row.modules.group){18401row.modules.group.removeRow(row);18402}18403}1840418405rowsUpdated(row){18406if(this.table.options.groupBy){18407this.updateGroupRows(true);18408}18409}1841018411cellUpdated(cell){18412if(this.table.options.groupBy){18413this.reassignRowToGroup(cell.row);18414}18415}1841618417//return appropriate rows with group headers18418getRows(rows){18419if(this.table.options.groupBy && this.groupIDLookups.length){1842018421this.dispatchExternal("dataGrouping");1842218423this.generateGroups(rows);1842418425if(this.subscribedExternal("dataGrouped")){18426this.dispatchExternal("dataGrouped", this.getGroups(true));18427}1842818429return this.updateGroupRows();1843018431}else {18432return rows.slice(0);18433}18434}1843518436getGroups(component){18437var groupComponents = [];1843818439this.groupList.forEach(function(group){18440groupComponents.push(component ? group.getComponent() : group);18441});1844218443return groupComponents;18444}1844518446getChildGroups(group){18447var groupComponents = [];1844818449if(!group){18450group = this;18451}1845218453group.groupList.forEach((child) => {18454if(child.groupList.length){18455groupComponents = groupComponents.concat(this.getChildGroups(child));18456}else {18457groupComponents.push(child);18458}18459});1846018461return groupComponents;18462}1846318464wipe(){18465if(this.table.options.groupBy){18466this.groupList.forEach(function(group){18467group.wipe();18468});1846918470this.groupList = [];18471this.groups = {};18472}18473}1847418475pullGroupListData(groupList) {18476var groupListData = [];1847718478groupList.forEach((group) => {18479var groupHeader = {};18480groupHeader.level = 0;18481groupHeader.rowCount = 0;18482groupHeader.headerContent = "";18483var childData = [];1848418485if (group.hasSubGroups) {18486childData = this.pullGroupListData(group.groupList);1848718488groupHeader.level = group.level;18489groupHeader.rowCount = childData.length - group.groupList.length; // data length minus number of sub-headers18490groupHeader.headerContent = group.generator(group.key, groupHeader.rowCount, group.rows, group);1849118492groupListData.push(groupHeader);18493groupListData = groupListData.concat(childData);18494}1849518496else {18497groupHeader.level = group.level;18498groupHeader.headerContent = group.generator(group.key, group.rows.length, group.rows, group);18499groupHeader.rowCount = group.getRows().length;1850018501groupListData.push(groupHeader);1850218503group.getRows().forEach((row) => {18504groupListData.push(row.getData("data"));18505});18506}18507});1850818509return groupListData;18510}1851118512getGroupedData(){1851318514return this.pullGroupListData(this.groupList);18515}1851618517getRowGroup(row){18518var match = false;1851918520if(this.options("dataTree")){18521row = this.table.modules.dataTree.getTreeParentRoot(row);18522}1852318524this.groupList.forEach((group) => {18525var result = group.getRowGroup(row);1852618527if(result){18528match = result;18529}18530});1853118532return match;18533}1853418535countGroups(){18536return this.groupList.length;18537}1853818539generateGroups(rows){18540var oldGroups = this.groups;1854118542this.groups = {};18543this.groupList = [];1854418545if(this.allowedValues && this.allowedValues[0]){18546this.allowedValues[0].forEach((value) => {18547this.createGroup(value, 0, oldGroups);18548});1854918550rows.forEach((row) => {18551this.assignRowToExistingGroup(row, oldGroups);18552});18553}else {18554rows.forEach((row) => {18555this.assignRowToGroup(row, oldGroups);18556});18557}1855818559Object.values(oldGroups).forEach((group) => {18560group.wipe(true);18561});18562}185631856418565createGroup(groupID, level, oldGroups){18566var groupKey = level + "_" + groupID,18567group;1856818569oldGroups = oldGroups || [];1857018571group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]);1857218573this.groups[groupKey] = group;18574this.groupList.push(group);18575}1857618577assignRowToExistingGroup(row, oldGroups){18578var groupID = this.groupIDLookups[0].func(row.getData()),18579groupKey = "0_" + groupID;1858018581if(this.groups[groupKey]){18582this.groups[groupKey].addRow(row);18583}18584}1858518586assignRowToGroup(row, oldGroups){18587var groupID = this.groupIDLookups[0].func(row.getData()),18588newGroupNeeded = !this.groups["0_" + groupID];1858918590if(newGroupNeeded){18591this.createGroup(groupID, 0, oldGroups);18592}1859318594this.groups["0_" + groupID].addRow(row);1859518596return !newGroupNeeded;18597}1859818599reassignRowToGroup(row){18600if(row.type === "row"){18601var oldRowGroup = row.modules.group,18602oldGroupPath = oldRowGroup.getPath(),18603newGroupPath = this.getExpectedPath(row),18604samePath;1860518606// figure out if new group path is the same as old group path18607samePath = (oldGroupPath.length == newGroupPath.length) && oldGroupPath.every((element, index) => {18608return element === newGroupPath[index];18609});1861018611// refresh if they new path and old path aren't the same (aka the row's groupings have changed)18612if(!samePath) {18613oldRowGroup.removeRow(row);18614this.assignRowToGroup(row, this.groups);18615this.refreshData(true);18616}18617}18618}1861918620getExpectedPath(row) {18621var groupPath = [], rowData = row.getData();1862218623this.groupIDLookups.forEach((groupId) => {18624groupPath.push(groupId.func(rowData));18625});1862618627return groupPath;18628}1862918630updateGroupRows(force){18631var output = [];1863218633if(!this.blockRedraw){18634this.groupList.forEach((group) => {18635output = output.concat(group.getHeadersAndRows());18636});1863718638if(force){18639this.refreshData(true);18640}18641}1864218643return output;18644}1864518646scrollHeaders(left){18647if(this.table.options.groupBy){18648if(this.table.options.renderHorizontal === "virtual"){18649left -= this.table.columnManager.renderer.vDomPadLeft;18650}1865118652left = left + "px";1865318654this.groupList.forEach((group) => {18655group.scrollHeader(left);18656});18657}18658}1865918660removeGroup(group){18661var groupKey = group.level + "_" + group.key,18662index;1866318664if(this.groups[groupKey]){18665delete this.groups[groupKey];1866618667index = this.groupList.indexOf(group);1866818669if(index > -1){18670this.groupList.splice(index, 1);18671}18672}18673}1867418675checkBasicModeGroupHeaderWidth(){18676var element = this.table.rowManager.tableElement,18677onlyGroupHeaders = true;1867818679this.table.rowManager.getDisplayRows().forEach((row, index) =>{18680this.table.rowManager.styleRow(row, index);18681element.appendChild(row.getElement());18682row.initialize(true);1868318684if(row.type !== "group"){18685onlyGroupHeaders = false;18686}18687});1868818689if(onlyGroupHeaders){18690element.style.minWidth = this.table.columnManager.getWidth() + "px";18691}else {18692element.style.minWidth = "";18693}18694}1869518696}1869718698GroupRows.moduleName = "groupRows";1869918700var defaultUndoers = {18701cellEdit: function(action){18702action.component.setValueProcessData(action.data.oldValue);18703action.component.cellRendered();18704},1870518706rowAdd: function(action){18707action.component.deleteActual();18708},1870918710rowDelete: function(action){18711var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);1871218713if(this.table.options.groupBy && this.table.modExists("groupRows")){18714this.table.modules.groupRows.updateGroupRows(true);18715}1871618717this._rebindRow(action.component, newRow);18718},1871918720rowMove: function(action){18721var after = (action.data.posFrom - action.data.posTo) > 0;1872218723this.table.rowManager.moveRowActual(action.component, this.table.rowManager.getRowFromPosition(action.data.posFrom), after);1872418725this.table.rowManager.regenerateRowPositions();18726this.table.rowManager.reRenderInPosition();18727},18728};1872918730var defaultRedoers = {18731cellEdit: function(action){18732action.component.setValueProcessData(action.data.newValue);18733action.component.cellRendered();18734},1873518736rowAdd: function(action){18737var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);1873818739if(this.table.options.groupBy && this.table.modExists("groupRows")){18740this.table.modules.groupRows.updateGroupRows(true);18741}1874218743this._rebindRow(action.component, newRow);18744},1874518746rowDelete:function(action){18747action.component.deleteActual();18748},1874918750rowMove: function(action){18751this.table.rowManager.moveRowActual(action.component, this.table.rowManager.getRowFromPosition(action.data.posTo), action.data.after);1875218753this.table.rowManager.regenerateRowPositions();18754this.table.rowManager.reRenderInPosition();18755},18756};1875718758class History extends Module{1875918760constructor(table){18761super(table);1876218763this.history = [];18764this.index = -1;1876518766this.registerTableOption("history", false); //enable edit history18767}1876818769initialize(){18770if(this.table.options.history){18771this.subscribe("cell-value-updated", this.cellUpdated.bind(this));18772this.subscribe("cell-delete", this.clearComponentHistory.bind(this));18773this.subscribe("row-delete", this.rowDeleted.bind(this));18774this.subscribe("rows-wipe", this.clear.bind(this));18775this.subscribe("row-added", this.rowAdded.bind(this));18776this.subscribe("row-move", this.rowMoved.bind(this));18777}1877818779this.registerTableFunction("undo", this.undo.bind(this));18780this.registerTableFunction("redo", this.redo.bind(this));18781this.registerTableFunction("getHistoryUndoSize", this.getHistoryUndoSize.bind(this));18782this.registerTableFunction("getHistoryRedoSize", this.getHistoryRedoSize.bind(this));18783this.registerTableFunction("clearHistory", this.clear.bind(this));18784}1878518786rowMoved(from, to, after){18787this.action("rowMove", from, {posFrom:from.getPosition(), posTo:to.getPosition(), to:to, after:after});18788}1878918790rowAdded(row, data, pos, index){18791this.action("rowAdd", row, {data:data, pos:pos, index:index});18792}1879318794rowDeleted(row){18795var index, rows;1879618797if(this.table.options.groupBy){1879818799rows = row.getComponent().getGroup()._getSelf().rows;18800index = rows.indexOf(row);1880118802if(index){18803index = rows[index-1];18804}18805}else {18806index = row.table.rowManager.getRowIndex(row);1880718808if(index){18809index = row.table.rowManager.rows[index-1];18810}18811}1881218813this.action("rowDelete", row, {data:row.getData(), pos:!index, index:index});18814}1881518816cellUpdated(cell){18817this.action("cellEdit", cell, {oldValue:cell.oldValue, newValue:cell.value});18818}1881918820clear(){18821this.history = [];18822this.index = -1;18823}1882418825action(type, component, data){18826this.history = this.history.slice(0, this.index + 1);1882718828this.history.push({18829type:type,18830component:component,18831data:data,18832});1883318834this.index ++;18835}1883618837getHistoryUndoSize(){18838return this.index + 1;18839}1884018841getHistoryRedoSize(){18842return this.history.length - (this.index + 1);18843}1884418845clearComponentHistory(component){18846var index = this.history.findIndex(function(item){18847return item.component === component;18848});1884918850if(index > -1){18851this.history.splice(index, 1);18852if(index <= this.index){18853this.index--;18854}1885518856this.clearComponentHistory(component);18857}18858}1885918860undo(){18861if(this.index > -1){18862let action = this.history[this.index];1886318864History.undoers[action.type].call(this, action);1886518866this.index--;1886718868this.dispatchExternal("historyUndo", action.type, action.component.getComponent(), action.data);1886918870return true;18871}else {18872console.warn("History Undo Error - No more history to undo");18873return false;18874}18875}1887618877redo(){18878if(this.history.length-1 > this.index){1887918880this.index++;1888118882let action = this.history[this.index];1888318884History.redoers[action.type].call(this, action);1888518886this.dispatchExternal("historyRedo", action.type, action.component.getComponent(), action.data);1888718888return true;18889}else {18890console.warn("History Redo Error - No more history to redo");18891return false;18892}18893}1889418895//rebind rows to new element after deletion18896_rebindRow(oldRow, newRow){18897this.history.forEach(function(action){18898if(action.component instanceof Row){18899if(action.component === oldRow){18900action.component = newRow;18901}18902}else if(action.component instanceof Cell){18903if(action.component.row === oldRow){18904var field = action.component.column.getField();1890518906if(field){18907action.component = newRow.getCell(field);18908}1890918910}18911}18912});18913}18914}1891518916History.moduleName = "history";1891718918//load defaults18919History.undoers = defaultUndoers;18920History.redoers = defaultRedoers;1892118922class HtmlTableImport extends Module{1892318924constructor(table){18925super(table);1892618927this.fieldIndex = [];18928this.hasIndex = false;18929}1893018931initialize(){18932this.tableElementCheck();18933}1893418935tableElementCheck(){18936if(this.table.originalElement && this.table.originalElement.tagName === "TABLE"){18937if(this.table.originalElement.childNodes.length){18938this.parseTable();18939}else {18940console.warn("Unable to parse data from empty table tag, Tabulator should be initialized on a div tag unless importing data from a table element.");18941}18942}18943}1894418945parseTable(){18946var element = this.table.originalElement,18947options = this.table.options,18948headers = element.getElementsByTagName("th"),18949rows = element.getElementsByTagName("tbody")[0],18950data = [];1895118952this.hasIndex = false;1895318954this.dispatchExternal("htmlImporting");1895518956rows = rows ? rows.getElementsByTagName("tr") : [];1895718958//check for Tabulator inline options18959this._extractOptions(element, options);1896018961if(headers.length){18962this._extractHeaders(headers, rows);18963}else {18964this._generateBlankHeaders(headers, rows);18965}1896618967//iterate through table rows and build data set18968for(var index = 0; index < rows.length; index++){18969var row = rows[index],18970cells = row.getElementsByTagName("td"),18971item = {};1897218973//create index if the don't exist in table18974if(!this.hasIndex){18975item[options.index] = index;18976}1897718978for(var i = 0; i < cells.length; i++){18979var cell = cells[i];18980if(typeof this.fieldIndex[i] !== "undefined"){18981item[this.fieldIndex[i]] = cell.innerHTML;18982}18983}1898418985//add row data to item18986data.push(item);18987}1898818989options.data = data;1899018991this.dispatchExternal("htmlImported");18992}1899318994//extract tabulator attribute options18995_extractOptions(element, options, defaultOptions){18996var attributes = element.attributes;18997var optionsArr = defaultOptions ? Object.keys(defaultOptions) : Object.keys(options);18998var optionsList = {};1899919000optionsArr.forEach((item) => {19001optionsList[item.toLowerCase()] = item;19002});1900319004for(var index in attributes){19005var attrib = attributes[index];19006var name;1900719008if(attrib && typeof attrib == "object" && attrib.name && attrib.name.indexOf("tabulator-") === 0){19009name = attrib.name.replace("tabulator-", "");1901019011if(typeof optionsList[name] !== "undefined"){19012options[optionsList[name]] = this._attribValue(attrib.value);19013}19014}19015}19016}1901719018//get value of attribute19019_attribValue(value){19020if(value === "true"){19021return true;19022}1902319024if(value === "false"){19025return false;19026}1902719028return value;19029}1903019031//find column if it has already been defined19032_findCol(title){19033var match = this.table.options.columns.find((column) => {19034return column.title === title;19035});1903619037return match || false;19038}1903919040//extract column from headers19041_extractHeaders(headers, rows){19042for(var index = 0; index < headers.length; index++){19043var header = headers[index],19044exists = false,19045col = this._findCol(header.textContent),19046width;1904719048if(col){19049exists = true;19050}else {19051col = {title:header.textContent.trim()};19052}1905319054if(!col.field) {19055col.field = header.textContent.trim().toLowerCase().replaceAll(" ", "_");19056}1905719058width = header.getAttribute("width");1905919060if(width && !col.width) {19061col.width = width;19062}1906319064//check for Tabulator inline options19065this._extractOptions(header, col, this.table.columnManager.optionsList.registeredDefaults);1906619067this.fieldIndex[index] = col.field;1906819069if(col.field == this.table.options.index){19070this.hasIndex = true;19071}1907219073if(!exists){19074this.table.options.columns.push(col);19075}1907619077}19078}1907919080//generate blank headers19081_generateBlankHeaders(headers, rows){19082for(var index = 0; index < headers.length; index++){19083var header = headers[index],19084col = {title:"", field:"col" + index};1908519086this.fieldIndex[index] = col.field;1908719088var width = header.getAttribute("width");1908919090if(width){19091col.width = width;19092}1909319094this.table.options.columns.push(col);19095}19096}19097}1909819099HtmlTableImport.moduleName = "htmlTableImport";1910019101function csvImporter(input){19102var data = [],19103row = 0,19104col = 0,19105inQuote = false;1910619107//Iterate over each character19108for (let index = 0; index < input.length; index++) {19109let char = input[index],19110nextChar = input[index+1];1911119112//Initialize empty row19113if(!data[row]){19114data[row] = [];19115}1911619117//Initialize empty column19118if(!data[row][col]){19119data[row][col] = "";19120}1912119122//Handle quotation mark inside string19123if (char == '"' && inQuote && nextChar == '"') {19124data[row][col] += char;19125index++;19126continue;19127}1912819129//Begin / End Quote19130if (char == '"') {19131inQuote = !inQuote;19132continue;19133}1913419135//Next column (if not in quote)19136if (char == ',' && !inQuote) {19137col++;19138continue;19139}1914019141//New row if new line and not in quote (CRLF)19142if (char == '\r' && nextChar == '\n' && !inQuote) {19143col = 0;19144row++;19145index++;19146continue;19147}1914819149//New row if new line and not in quote (CR or LF)19150if ((char == '\r' || char == '\n') && !inQuote) {19151col = 0;19152row++;19153continue;19154}1915519156//Normal Character, append to column19157data[row][col] += char;19158}1915919160return data;19161}1916219163function json$1(input){19164try {19165return JSON.parse(input);19166} catch(e) {19167console.warn("JSON Import Error - File contents is invalid JSON", e);19168return Promise.reject();19169}19170}1917119172function arrayImporter(input){19173return input;19174}1917519176var defaultImporters = {19177csv:csvImporter,19178json:json$1,19179array:arrayImporter,19180};1918119182class Import extends Module{1918319184constructor(table){19185super(table);1918619187this.registerTableOption("importFormat");19188this.registerTableOption("importReader", "text");19189}1919019191initialize(){19192this.registerTableFunction("import", this.importFromFile.bind(this));1919319194if(this.table.options.importFormat){19195this.subscribe("data-loading", this.loadDataCheck.bind(this), 10);19196this.subscribe("data-load", this.loadData.bind(this), 10);19197}19198}1919919200loadDataCheck(data){19201return this.table.options.importFormat && (typeof data === "string" || (Array.isArray(data) && data.length && Array.isArray(data)));19202}1920319204loadData(data, params, config, silent, previousData){19205return this.importData(this.lookupImporter(), data)19206.then(this.structureData.bind(this))19207.catch((err) => {19208console.error("Import Error:", err || "Unable to import data");19209return Promise.reject(err);19210});19211}1921219213lookupImporter(importFormat){19214var importer;1921519216if(!importFormat){19217importFormat = this.table.options.importFormat;19218}1921919220if(typeof importFormat === "string"){19221importer = Import.importers[importFormat];19222}else {19223importer = importFormat;19224}1922519226if(!importer){19227console.error("Import Error - Importer not found:", importFormat);19228}1922919230return importer;19231}1923219233importFromFile(importFormat, extension){19234var importer = this.lookupImporter(importFormat);1923519236if(importer){19237return this.pickFile(extension)19238.then(this.importData.bind(this, importer))19239.then(this.structureData.bind(this))19240.then(this.setData.bind(this))19241.catch((err) => {19242console.error("Import Error:", err || "Unable to import file");19243return Promise.reject(err);19244});19245}19246}1924719248pickFile(extensions){19249return new Promise((resolve, reject) => {19250var input = document.createElement("input");19251input.type = "file";19252input.accept = extensions;1925319254input.addEventListener("change", (e) => {19255var file = input.files[0],19256reader = new FileReader();1925719258switch(this.table.options.importReader){19259case "buffer":19260reader.readAsArrayBuffer(file);19261break;1926219263case "binary":19264reader.readAsBinaryString(file);19265break;1926619267case "url":19268reader.readAsDataURL(file);19269break;1927019271case "text":19272default:19273reader.readAsText(file);19274}1927519276reader.onload = (e) => {19277resolve(reader.result);19278};1927919280reader.onerror = (e) => {19281console.warn("File Load Error - Unable to read file");19282reject();19283};19284});1928519286input.click();19287});19288}1928919290importData(importer, fileContents){19291var data = importer.call(this.table, fileContents);1929219293if(data instanceof Promise){19294return data;19295}else {19296return data ? Promise.resolve(data) : Promise.reject();19297}19298}1929919300structureData(parsedData){19301var data = [];1930219303if(Array.isArray(parsedData) && parsedData.length && Array.isArray(parsedData[0])){19304if(this.table.options.autoColumns){19305data = this.structureArrayToObject(parsedData);19306}else {19307data = this.structureArrayToColumns(parsedData);19308}1930919310return data;19311}else {19312return parsedData;19313}19314}1931519316structureArrayToObject(parsedData){19317var columns = parsedData.shift();1931819319var data = parsedData.map((values) => {19320var row = {};1932119322columns.forEach((key, i) => {19323row[key] = values[i];19324});1932519326return row;19327});1932819329return data;19330}1933119332structureArrayToColumns(parsedData){19333var data = [],19334columns = this.table.getColumns();1933519336//remove first row if it is the column names19337if(columns[0] && parsedData[0][0]){19338if(columns[0].getDefinition().title === parsedData[0][0]){19339parsedData.shift();19340}19341}1934219343//convert row arrays to objects19344parsedData.forEach((rowData) => {19345var row = {};1934619347rowData.forEach((value, index) => {19348var column = columns[index];1934919350if(column){19351row[column.getField()] = value;19352}19353});1935419355data.push(row);19356});1935719358return data;19359}1936019361setData(data){19362return this.table.setData(data);19363}19364}1936519366Import.moduleName = "import";1936719368//load defaults19369Import.importers = defaultImporters;1937019371class Interaction extends Module{1937219373constructor(table){19374super(table);1937519376this.eventMap = {19377//row events19378rowClick:"row-click",19379rowDblClick:"row-dblclick",19380rowContext:"row-contextmenu",19381rowMouseEnter:"row-mouseenter",19382rowMouseLeave:"row-mouseleave",19383rowMouseOver:"row-mouseover",19384rowMouseOut:"row-mouseout",19385rowMouseMove:"row-mousemove",19386rowMouseDown:"row-mousedown",19387rowMouseUp:"row-mouseup",19388rowTap:"row",19389rowDblTap:"row",19390rowTapHold:"row",1939119392//cell events19393cellClick:"cell-click",19394cellDblClick:"cell-dblclick",19395cellContext:"cell-contextmenu",19396cellMouseEnter:"cell-mouseenter",19397cellMouseLeave:"cell-mouseleave",19398cellMouseOver:"cell-mouseover",19399cellMouseOut:"cell-mouseout",19400cellMouseMove:"cell-mousemove",19401cellMouseDown:"cell-mousedown",19402cellMouseUp:"cell-mouseup",19403cellTap:"cell",19404cellDblTap:"cell",19405cellTapHold:"cell",1940619407//column header events19408headerClick:"column-click",19409headerDblClick:"column-dblclick",19410headerContext:"column-contextmenu",19411headerMouseEnter:"column-mouseenter",19412headerMouseLeave:"column-mouseleave",19413headerMouseOver:"column-mouseover",19414headerMouseOut:"column-mouseout",19415headerMouseMove:"column-mousemove",19416headerMouseDown:"column-mousedown",19417headerMouseUp:"column-mouseup",19418headerTap:"column",19419headerDblTap:"column",19420headerTapHold:"column",1942119422//group header19423groupClick:"group-click",19424groupDblClick:"group-dblclick",19425groupContext:"group-contextmenu",19426groupMouseEnter:"group-mouseenter",19427groupMouseLeave:"group-mouseleave",19428groupMouseOver:"group-mouseover",19429groupMouseOut:"group-mouseout",19430groupMouseMove:"group-mousemove",19431groupMouseDown:"group-mousedown",19432groupMouseUp:"group-mouseup",19433groupTap:"group",19434groupDblTap:"group",19435groupTapHold:"group",19436};1943719438this.subscribers = {};1943919440this.touchSubscribers = {};1944119442this.columnSubscribers = {};1944319444this.touchWatchers = {19445row:{19446tap:null,19447tapDbl:null,19448tapHold:null,19449},19450cell:{19451tap:null,19452tapDbl:null,19453tapHold:null,19454},19455column:{19456tap:null,19457tapDbl:null,19458tapHold:null,19459},19460group:{19461tap:null,19462tapDbl:null,19463tapHold:null,19464}19465};1946619467this.registerColumnOption("headerClick");19468this.registerColumnOption("headerDblClick");19469this.registerColumnOption("headerContext");19470this.registerColumnOption("headerMouseEnter");19471this.registerColumnOption("headerMouseLeave");19472this.registerColumnOption("headerMouseOver");19473this.registerColumnOption("headerMouseOut");19474this.registerColumnOption("headerMouseMove");19475this.registerColumnOption("headerMouseDown");19476this.registerColumnOption("headerMouseUp");19477this.registerColumnOption("headerTap");19478this.registerColumnOption("headerDblTap");19479this.registerColumnOption("headerTapHold");1948019481this.registerColumnOption("cellClick");19482this.registerColumnOption("cellDblClick");19483this.registerColumnOption("cellContext");19484this.registerColumnOption("cellMouseEnter");19485this.registerColumnOption("cellMouseLeave");19486this.registerColumnOption("cellMouseOver");19487this.registerColumnOption("cellMouseOut");19488this.registerColumnOption("cellMouseMove");19489this.registerColumnOption("cellMouseDown");19490this.registerColumnOption("cellMouseUp");19491this.registerColumnOption("cellTap");19492this.registerColumnOption("cellDblTap");19493this.registerColumnOption("cellTapHold");1949419495}1949619497initialize(){19498this.initializeExternalEvents();1949919500this.subscribe("column-init", this.initializeColumn.bind(this));19501this.subscribe("cell-dblclick", this.cellContentsSelectionFixer.bind(this));19502this.subscribe("scroll-horizontal", this.clearTouchWatchers.bind(this));19503this.subscribe("scroll-vertical", this.clearTouchWatchers.bind(this));19504}1950519506clearTouchWatchers(){19507var types = Object.values(this.touchWatchers);1950819509types.forEach((type) => {19510for(let key in type){19511type[key] = null;19512}19513});19514}1951519516cellContentsSelectionFixer(e, cell){19517var range;1951819519if(this.table.modExists("edit")){19520if (this.table.modules.edit.currentCell === cell){19521return; //prevent instant selection of editor content19522}19523}1952419525e.preventDefault();1952619527try{19528if (document.selection) { // IE19529range = document.body.createTextRange();19530range.moveToElementText(cell.getElement());19531range.select();19532} else if (window.getSelection) {19533range = document.createRange();19534range.selectNode(cell.getElement());19535window.getSelection().removeAllRanges();19536window.getSelection().addRange(range);19537}19538}catch(e){}19539}1954019541initializeExternalEvents(){19542for(let key in this.eventMap){19543this.subscriptionChangeExternal(key, this.subscriptionChanged.bind(this, key));19544}19545}1954619547subscriptionChanged(key, added){19548if(added){19549if(!this.subscribers[key]){19550if(this.eventMap[key].includes("-")){19551this.subscribers[key] = this.handle.bind(this, key);19552this.subscribe(this.eventMap[key], this.subscribers[key]);19553}else {19554this.subscribeTouchEvents(key);19555}19556}19557}else {19558if(this.eventMap[key].includes("-")){19559if(this.subscribers[key] && !this.columnSubscribers[key] && !this.subscribedExternal(key)){19560this.unsubscribe(this.eventMap[key], this.subscribers[key]);19561delete this.subscribers[key];19562}19563}else {19564this.unsubscribeTouchEvents(key);19565}19566}19567}195681956919570subscribeTouchEvents(key){19571var type = this.eventMap[key];1957219573if(!this.touchSubscribers[type + "-touchstart"]){19574this.touchSubscribers[type + "-touchstart"] = this.handleTouch.bind(this, type, "start");19575this.touchSubscribers[type + "-touchend"] = this.handleTouch.bind(this, type, "end");1957619577this.subscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]);19578this.subscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]);19579}1958019581this.subscribers[key] = true;19582}1958319584unsubscribeTouchEvents(key){19585var noTouch = true,19586type = this.eventMap[key];1958719588if(this.subscribers[key] && !this.subscribedExternal(key)){19589delete this.subscribers[key];1959019591for(let i in this.eventMap){19592if(this.eventMap[i] === type){19593if(this.subscribers[i]){19594noTouch = false;19595}19596}19597}1959819599if(noTouch){19600this.unsubscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]);19601this.unsubscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]);1960219603delete this.touchSubscribers[type + "-touchstart"];19604delete this.touchSubscribers[type + "-touchend"];19605}19606}19607}1960819609initializeColumn(column){19610var def = column.definition;1961119612for(let key in this.eventMap){19613if(def[key]){19614this.subscriptionChanged(key, true);1961519616if(!this.columnSubscribers[key]){19617this.columnSubscribers[key] = [];19618}1961919620this.columnSubscribers[key].push(column);19621}19622}19623}1962419625handle(action, e, component){19626this.dispatchEvent(action, e, component);19627}1962819629handleTouch(type, action, e, component){19630var watchers = this.touchWatchers[type];1963119632if(type === "column"){19633type = "header";19634}1963519636switch(action){19637case "start":19638watchers.tap = true;1963919640clearTimeout(watchers.tapHold);1964119642watchers.tapHold = setTimeout(() => {19643clearTimeout(watchers.tapHold);19644watchers.tapHold = null;1964519646watchers.tap = null;19647clearTimeout(watchers.tapDbl);19648watchers.tapDbl = null;1964919650this.dispatchEvent(type + "TapHold", e, component);19651}, 1000);19652break;1965319654case "end":19655if(watchers.tap){1965619657watchers.tap = null;19658this.dispatchEvent(type + "Tap", e, component);19659}1966019661if(watchers.tapDbl){19662clearTimeout(watchers.tapDbl);19663watchers.tapDbl = null;1966419665this.dispatchEvent(type + "DblTap", e, component);19666}else {19667watchers.tapDbl = setTimeout(() => {19668clearTimeout(watchers.tapDbl);19669watchers.tapDbl = null;19670}, 300);19671}1967219673clearTimeout(watchers.tapHold);19674watchers.tapHold = null;19675break;19676}19677}1967819679dispatchEvent(action, e, component){19680var componentObj = component.getComponent(),19681callback;1968219683if(this.columnSubscribers[action]){1968419685if(component instanceof Cell){19686callback = component.column.definition[action];19687}else if(component instanceof Column){19688callback = component.definition[action];19689}1969019691if(callback){19692callback(e, componentObj);19693}19694}1969519696this.dispatchExternal(action, e, componentObj);19697}19698}1969919700Interaction.moduleName = "interaction";1970119702var defaultBindings = {19703navPrev:"shift + 9",19704navNext:9,19705navUp:38,19706navDown:40,19707scrollPageUp:33,19708scrollPageDown:34,19709scrollToStart:36,19710scrollToEnd:35,19711undo:["ctrl + 90", "meta + 90"],19712redo:["ctrl + 89", "meta + 89"],19713copyToClipboard:["ctrl + 67", "meta + 67"],19714};1971519716var defaultActions = {19717keyBlock:function(e){19718e.stopPropagation();19719e.preventDefault();19720},19721scrollPageUp:function(e){19722var rowManager = this.table.rowManager,19723newPos = rowManager.scrollTop - rowManager.element.clientHeight;1972419725e.preventDefault();1972619727if(rowManager.displayRowsCount){19728if(newPos >= 0){19729rowManager.element.scrollTop = newPos;19730}else {19731rowManager.scrollToRow(rowManager.getDisplayRows()[0]);19732}19733}1973419735this.table.element.focus();19736},19737scrollPageDown:function(e){19738var rowManager = this.table.rowManager,19739newPos = rowManager.scrollTop + rowManager.element.clientHeight,19740scrollMax = rowManager.element.scrollHeight;1974119742e.preventDefault();1974319744if(rowManager.displayRowsCount){19745if(newPos <= scrollMax){19746rowManager.element.scrollTop = newPos;19747}else {19748rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);19749}19750}1975119752this.table.element.focus();1975319754},19755scrollToStart:function(e){19756var rowManager = this.table.rowManager;1975719758e.preventDefault();1975919760if(rowManager.displayRowsCount){19761rowManager.scrollToRow(rowManager.getDisplayRows()[0]);19762}1976319764this.table.element.focus();19765},19766scrollToEnd:function(e){19767var rowManager = this.table.rowManager;1976819769e.preventDefault();1977019771if(rowManager.displayRowsCount){19772rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);19773}1977419775this.table.element.focus();19776},19777navPrev:function(e){19778this.dispatch("keybinding-nav-prev", e);19779},1978019781navNext:function(e){19782this.dispatch("keybinding-nav-next", e);19783},1978419785navLeft:function(e){19786this.dispatch("keybinding-nav-left", e);19787},1978819789navRight:function(e){19790this.dispatch("keybinding-nav-right", e);19791},1979219793navUp:function(e){19794this.dispatch("keybinding-nav-up", e);19795},1979619797navDown:function(e){19798this.dispatch("keybinding-nav-down", e);19799},1980019801undo:function(e){19802var cell = false;19803if(this.table.options.history && this.table.modExists("history") && this.table.modExists("edit")){1980419805cell = this.table.modules.edit.currentCell;1980619807if(!cell){19808e.preventDefault();19809this.table.modules.history.undo();19810}19811}19812},1981319814redo:function(e){19815var cell = false;19816if(this.table.options.history && this.table.modExists("history") && this.table.modExists("edit")){1981719818cell = this.table.modules.edit.currentCell;1981919820if(!cell){19821e.preventDefault();19822this.table.modules.history.redo();19823}19824}19825},1982619827copyToClipboard:function(e){19828if(!this.table.modules.edit.currentCell){19829if(this.table.modExists("clipboard", true)){19830this.table.modules.clipboard.copy(false, true);19831}19832}19833},19834};1983519836class Keybindings extends Module{1983719838constructor(table){19839super(table);1984019841this.watchKeys = null;19842this.pressedKeys = null;19843this.keyupBinding = false;19844this.keydownBinding = false;1984519846this.registerTableOption("keybindings", {}); //array for keybindings19847this.registerTableOption("tabEndNewRow", false); //create new row when tab to end of table19848}1984919850initialize(){19851var bindings = this.table.options.keybindings,19852mergedBindings = {};1985319854this.watchKeys = {};19855this.pressedKeys = [];1985619857if(bindings !== false){19858Object.assign(mergedBindings, Keybindings.bindings);19859Object.assign(mergedBindings, bindings);1986019861this.mapBindings(mergedBindings);19862this.bindEvents();19863}1986419865this.subscribe("table-destroy", this.clearBindings.bind(this));19866}1986719868mapBindings(bindings){19869for(let key in bindings){19870if(Keybindings.actions[key]){19871if(bindings[key]){19872if(typeof bindings[key] !== "object"){19873bindings[key] = [bindings[key]];19874}1987519876bindings[key].forEach((binding) => {19877var bindingList = Array.isArray(binding) ? binding : [binding];1987819879bindingList.forEach((item) => {19880this.mapBinding(key, item);19881});19882});19883}19884}else {19885console.warn("Key Binding Error - no such action:", key);19886}19887}19888}1988919890mapBinding(action, symbolsList){19891var binding = {19892action: Keybindings.actions[action],19893keys: [],19894ctrl: false,19895shift: false,19896meta: false,19897};1989819899var symbols = symbolsList.toString().toLowerCase().split(" ").join("").split("+");1990019901symbols.forEach((symbol) => {19902switch(symbol){19903case "ctrl":19904binding.ctrl = true;19905break;1990619907case "shift":19908binding.shift = true;19909break;1991019911case "meta":19912binding.meta = true;19913break;1991419915default:19916symbol = isNaN(symbol) ? symbol.toUpperCase().charCodeAt(0) : parseInt(symbol);19917binding.keys.push(symbol);1991819919if(!this.watchKeys[symbol]){19920this.watchKeys[symbol] = [];19921}1992219923this.watchKeys[symbol].push(binding);19924}19925});19926}1992719928bindEvents(){19929var self = this;1993019931this.keyupBinding = function(e){19932var code = e.keyCode;19933var bindings = self.watchKeys[code];1993419935if(bindings){1993619937self.pressedKeys.push(code);1993819939bindings.forEach(function(binding){19940self.checkBinding(e, binding);19941});19942}19943};1994419945this.keydownBinding = function(e){19946var code = e.keyCode;19947var bindings = self.watchKeys[code];1994819949if(bindings){1995019951var index = self.pressedKeys.indexOf(code);1995219953if(index > -1){19954self.pressedKeys.splice(index, 1);19955}19956}19957};1995819959this.table.element.addEventListener("keydown", this.keyupBinding);1996019961this.table.element.addEventListener("keyup", this.keydownBinding);19962}1996319964clearBindings(){19965if(this.keyupBinding){19966this.table.element.removeEventListener("keydown", this.keyupBinding);19967}1996819969if(this.keydownBinding){19970this.table.element.removeEventListener("keyup", this.keydownBinding);19971}19972}1997319974checkBinding(e, binding){19975var match = true;1997619977if(e.ctrlKey == binding.ctrl && e.shiftKey == binding.shift && e.metaKey == binding.meta){19978binding.keys.forEach((key) => {19979var index = this.pressedKeys.indexOf(key);1998019981if(index == -1){19982match = false;19983}19984});1998519986if(match){19987binding.action.call(this, e);19988}1998919990return true;19991}1999219993return false;19994}19995}1999619997Keybindings.moduleName = "keybindings";1999819999//load defaults20000Keybindings.bindings = defaultBindings;20001Keybindings.actions = defaultActions;2000220003class Menu extends Module{2000420005constructor(table){20006super(table);2000720008this.menuContainer = null;20009this.nestedMenuBlock = false;2001020011this.currentComponent = null;20012this.rootPopup = null;2001320014this.columnSubscribers = {};2001520016this.registerTableOption("menuContainer", undefined); //deprecated2001720018this.registerTableOption("rowContextMenu", false);20019this.registerTableOption("rowClickMenu", false);20020this.registerTableOption("rowDblClickMenu", false);20021this.registerTableOption("groupContextMenu", false);20022this.registerTableOption("groupClickMenu", false);20023this.registerTableOption("groupDblClickMenu", false);2002420025this.registerColumnOption("headerContextMenu");20026this.registerColumnOption("headerClickMenu");20027this.registerColumnOption("headerDblClickMenu");20028this.registerColumnOption("headerMenu");20029this.registerColumnOption("headerMenuIcon");20030this.registerColumnOption("contextMenu");20031this.registerColumnOption("clickMenu");20032this.registerColumnOption("dblClickMenu");2003320034}2003520036initialize(){20037this.deprecatedOptionsCheck();20038this.initializeRowWatchers();20039this.initializeGroupWatchers();2004020041this.subscribe("column-init", this.initializeColumn.bind(this));20042}2004320044deprecatedOptionsCheck(){20045if(!this.deprecationCheck("menuContainer", "popupContainer")){20046this.table.options.popupContainer = this.table.options.menuContainer;20047}20048}2004920050initializeRowWatchers(){20051if(this.table.options.rowContextMenu){20052this.subscribe("row-contextmenu", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));20053this.table.on("rowTapHold", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));20054}2005520056if(this.table.options.rowClickMenu){20057this.subscribe("row-click", this.loadMenuEvent.bind(this, this.table.options.rowClickMenu));20058}2005920060if(this.table.options.rowDblClickMenu){20061this.subscribe("row-dblclick", this.loadMenuEvent.bind(this, this.table.options.rowDblClickMenu));20062}20063}2006420065initializeGroupWatchers(){20066if(this.table.options.groupContextMenu){20067this.subscribe("group-contextmenu", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));20068this.table.on("groupTapHold", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));20069}2007020071if(this.table.options.groupClickMenu){20072this.subscribe("group-click", this.loadMenuEvent.bind(this, this.table.options.groupClickMenu));20073}2007420075if(this.table.options.groupDblClickMenu){20076this.subscribe("group-dblclick", this.loadMenuEvent.bind(this, this.table.options.groupDblClickMenu));20077}20078}2007920080initializeColumn(column){20081var def = column.definition;2008220083//handle column events20084if(def.headerContextMenu && !this.columnSubscribers.headerContextMenu){20085this.columnSubscribers.headerContextMenu = this.loadMenuTableColumnEvent.bind(this, "headerContextMenu");20086this.subscribe("column-contextmenu", this.columnSubscribers.headerContextMenu);20087this.table.on("headerTapHold", this.loadMenuTableColumnEvent.bind(this, "headerContextMenu"));20088}2008920090if(def.headerClickMenu && !this.columnSubscribers.headerClickMenu){20091this.columnSubscribers.headerClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerClickMenu");20092this.subscribe("column-click", this.columnSubscribers.headerClickMenu);20093}2009420095if(def.headerDblClickMenu && !this.columnSubscribers.headerDblClickMenu){20096this.columnSubscribers.headerDblClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerDblClickMenu");20097this.subscribe("column-dblclick", this.columnSubscribers.headerDblClickMenu);20098}2009920100if(def.headerMenu){20101this.initializeColumnHeaderMenu(column);20102}2010320104//handle cell events20105if(def.contextMenu && !this.columnSubscribers.contextMenu){20106this.columnSubscribers.contextMenu = this.loadMenuTableCellEvent.bind(this, "contextMenu");20107this.subscribe("cell-contextmenu", this.columnSubscribers.contextMenu);20108this.table.on("cellTapHold", this.loadMenuTableCellEvent.bind(this, "contextMenu"));20109}2011020111if(def.clickMenu && !this.columnSubscribers.clickMenu){20112this.columnSubscribers.clickMenu = this.loadMenuTableCellEvent.bind(this, "clickMenu");20113this.subscribe("cell-click", this.columnSubscribers.clickMenu);20114}2011520116if(def.dblClickMenu && !this.columnSubscribers.dblClickMenu){20117this.columnSubscribers.dblClickMenu = this.loadMenuTableCellEvent.bind(this, "dblClickMenu");20118this.subscribe("cell-dblclick", this.columnSubscribers.dblClickMenu);20119}20120}2012120122initializeColumnHeaderMenu(column){20123var icon = column.definition.headerMenuIcon,20124headerMenuEl;2012520126headerMenuEl = document.createElement("span");20127headerMenuEl.classList.add("tabulator-header-popup-button");2012820129if(icon){20130if(typeof icon === "function"){20131icon = icon(column.getComponent());20132}2013320134if(icon instanceof HTMLElement){20135headerMenuEl.appendChild(icon);20136}else {20137headerMenuEl.innerHTML = icon;20138}20139}else {20140headerMenuEl.innerHTML = "⋮";20141}2014220143headerMenuEl.addEventListener("click", (e) => {20144e.stopPropagation();20145e.preventDefault();2014620147this.loadMenuEvent(column.definition.headerMenu, e, column);20148});2014920150column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);20151}2015220153loadMenuTableCellEvent(option, e, cell){20154if(cell._cell){20155cell = cell._cell;20156}2015720158if(cell.column.definition[option]){20159this.loadMenuEvent(cell.column.definition[option], e, cell);20160}20161}2016220163loadMenuTableColumnEvent(option, e, column){20164if(column._column){20165column = column._column;20166}2016720168if(column.definition[option]){20169this.loadMenuEvent(column.definition[option], e, column);20170}20171}2017220173loadMenuEvent(menu, e, component){20174if(component._group){20175component = component._group;20176}else if(component._row){20177component = component._row;20178}2017920180menu = typeof menu == "function" ? menu.call(this.table, e, component.getComponent()) : menu;2018120182this.loadMenu(e, component, menu);20183}2018420185loadMenu(e, component, menu, parentEl, parentPopup){20186var touch = !(e instanceof MouseEvent),20187menuEl = document.createElement("div"),20188popup;2018920190menuEl.classList.add("tabulator-menu");2019120192if(!touch){20193e.preventDefault();20194}2019520196//abort if no menu set20197if(!menu || !menu.length){20198return;20199}2020020201if(!parentEl){20202if(this.nestedMenuBlock){20203//abort if child menu already open20204if(this.rootPopup){20205return;20206}20207}else {20208this.nestedMenuBlock = setTimeout(() => {20209this.nestedMenuBlock = false;20210}, 100);20211}2021220213if(this.rootPopup){20214this.rootPopup.hide();20215}2021620217this.rootPopup = popup = this.popup(menuEl);2021820219}else {20220popup = parentPopup.child(menuEl);20221}2022220223menu.forEach((item) => {20224var itemEl = document.createElement("div"),20225label = item.label,20226disabled = item.disabled;2022720228if(item.separator){20229itemEl.classList.add("tabulator-menu-separator");20230}else {20231itemEl.classList.add("tabulator-menu-item");2023220233if(typeof label == "function"){20234label = label.call(this.table, component.getComponent());20235}2023620237if(label instanceof Node){20238itemEl.appendChild(label);20239}else {20240itemEl.innerHTML = label;20241}2024220243if(typeof disabled == "function"){20244disabled = disabled.call(this.table, component.getComponent());20245}2024620247if(disabled){20248itemEl.classList.add("tabulator-menu-item-disabled");20249itemEl.addEventListener("click", (e) => {20250e.stopPropagation();20251});20252}else {20253if(item.menu && item.menu.length){20254itemEl.addEventListener("click", (e) => {20255e.stopPropagation();20256this.loadMenu(e, component, item.menu, itemEl, popup);20257});20258}else {20259if(item.action){20260itemEl.addEventListener("click", (e) => {20261item.action(e, component.getComponent());20262});20263}20264}20265}2026620267if(item.menu && item.menu.length){20268itemEl.classList.add("tabulator-menu-item-submenu");20269}20270}2027120272menuEl.appendChild(itemEl);20273});2027420275menuEl.addEventListener("click", (e) => {20276if(this.rootPopup){20277this.rootPopup.hide();20278}20279});2028020281popup.show(parentEl || e);2028220283if(popup === this.rootPopup){20284this.rootPopup.hideOnBlur(() => {20285this.rootPopup = null;2028620287if(this.currentComponent){20288this.dispatchExternal("menuClosed", this.currentComponent.getComponent());20289this.currentComponent = null;20290}20291});2029220293this.currentComponent = component;2029420295this.dispatchExternal("menuOpened", component.getComponent());20296}20297}20298}2029920300Menu.moduleName = "menu";2030120302class MoveColumns extends Module{2030320304constructor(table){20305super(table);2030620307this.placeholderElement = this.createPlaceholderElement();20308this.hoverElement = false; //floating column header element20309this.checkTimeout = false; //click check timeout holder20310this.checkPeriod = 250; //period to wait on mousedown to consider this a move and not a click20311this.moving = false; //currently moving column20312this.toCol = false; //destination column20313this.toColAfter = false; //position of moving column relative to the destination column20314this.startX = 0; //starting position within header element20315this.autoScrollMargin = 40; //auto scroll on edge when within margin20316this.autoScrollStep = 5; //auto scroll distance in pixels20317this.autoScrollTimeout = false; //auto scroll timeout20318this.touchMove = false;2031920320this.moveHover = this.moveHover.bind(this);20321this.endMove = this.endMove.bind(this);2032220323this.registerTableOption("movableColumns", false); //enable movable columns20324}2032520326createPlaceholderElement(){20327var el = document.createElement("div");2032820329el.classList.add("tabulator-col");20330el.classList.add("tabulator-col-placeholder");2033120332return el;20333}2033420335initialize(){20336if(this.table.options.movableColumns){20337this.subscribe("column-init", this.initializeColumn.bind(this));20338}20339}2034020341initializeColumn(column){20342var self = this,20343config = {},20344colEl;2034520346if(!column.modules.frozen && !column.isGroup){20347colEl = column.getElement();2034820349config.mousemove = function(e){20350if(column.parent === self.moving.parent){20351if((((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(colEl).left) + self.table.columnManager.contentsElement.scrollLeft) > (column.getWidth() / 2)){20352if(self.toCol !== column || !self.toColAfter){20353colEl.parentNode.insertBefore(self.placeholderElement, colEl.nextSibling);20354self.moveColumn(column, true);20355}20356}else {20357if(self.toCol !== column || self.toColAfter){20358colEl.parentNode.insertBefore(self.placeholderElement, colEl);20359self.moveColumn(column, false);20360}20361}20362}20363}.bind(self);2036420365colEl.addEventListener("mousedown", function(e){20366self.touchMove = false;20367if(e.which === 1){20368self.checkTimeout = setTimeout(function(){20369self.startMove(e, column);20370}, self.checkPeriod);20371}20372});2037320374colEl.addEventListener("mouseup", function(e){20375if(e.which === 1){20376if(self.checkTimeout){20377clearTimeout(self.checkTimeout);20378}20379}20380});2038120382self.bindTouchEvents(column);20383}2038420385column.modules.moveColumn = config;20386}2038720388bindTouchEvents(column){20389var colEl = column.getElement(),20390startXMove = false, //shifting center position of the cell20391nextCol, prevCol, nextColWidth, prevColWidth, nextColWidthLast, prevColWidthLast;2039220393colEl.addEventListener("touchstart", (e) => {20394this.checkTimeout = setTimeout(() => {20395this.touchMove = true;20396nextCol = column.nextColumn();20397nextColWidth = nextCol ? nextCol.getWidth()/2 : 0;20398prevCol = column.prevColumn();20399prevColWidth = prevCol ? prevCol.getWidth()/2 : 0;20400nextColWidthLast = 0;20401prevColWidthLast = 0;20402startXMove = false;2040320404this.startMove(e, column);20405}, this.checkPeriod);20406}, {passive: true});2040720408colEl.addEventListener("touchmove", (e) => {20409var diff, moveToCol;2041020411if(this.moving){20412this.moveHover(e);2041320414if(!startXMove){20415startXMove = e.touches[0].pageX;20416}2041720418diff = e.touches[0].pageX - startXMove;2041920420if(diff > 0){20421if(nextCol && diff - nextColWidthLast > nextColWidth){20422moveToCol = nextCol;2042320424if(moveToCol !== column){20425startXMove = e.touches[0].pageX;20426moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement().nextSibling);20427this.moveColumn(moveToCol, true);20428}20429}20430}else {20431if(prevCol && -diff - prevColWidthLast > prevColWidth){20432moveToCol = prevCol;2043320434if(moveToCol !== column){20435startXMove = e.touches[0].pageX;20436moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement());20437this.moveColumn(moveToCol, false);20438}20439}20440}2044120442if(moveToCol){20443nextCol = moveToCol.nextColumn();20444nextColWidthLast = nextColWidth;20445nextColWidth = nextCol ? nextCol.getWidth() / 2 : 0;20446prevCol = moveToCol.prevColumn();20447prevColWidthLast = prevColWidth;20448prevColWidth = prevCol ? prevCol.getWidth() / 2 : 0;20449}20450}20451}, {passive: true});2045220453colEl.addEventListener("touchend", (e) => {20454if(this.checkTimeout){20455clearTimeout(this.checkTimeout);20456}20457if(this.moving){20458this.endMove(e);20459}20460});20461}2046220463startMove(e, column){20464var element = column.getElement(),20465headerElement = this.table.columnManager.getContentsElement(),20466headersElement = this.table.columnManager.getHeadersElement();2046720468this.moving = column;20469this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;2047020471this.table.element.classList.add("tabulator-block-select");2047220473//create placeholder20474this.placeholderElement.style.width = column.getWidth() + "px";20475this.placeholderElement.style.height = column.getHeight() + "px";2047620477element.parentNode.insertBefore(this.placeholderElement, element);20478element.parentNode.removeChild(element);2047920480//create hover element20481this.hoverElement = element.cloneNode(true);20482this.hoverElement.classList.add("tabulator-moving");2048320484headerElement.appendChild(this.hoverElement);2048520486this.hoverElement.style.left = "0";20487this.hoverElement.style.bottom = (headerElement.clientHeight - headersElement.offsetHeight) + "px";2048820489if(!this.touchMove){20490this._bindMouseMove();2049120492document.body.addEventListener("mousemove", this.moveHover);20493document.body.addEventListener("mouseup", this.endMove);20494}2049520496this.moveHover(e);20497}2049820499_bindMouseMove(){20500this.table.columnManager.columnsByIndex.forEach(function(column){20501if(column.modules.moveColumn.mousemove){20502column.getElement().addEventListener("mousemove", column.modules.moveColumn.mousemove);20503}20504});20505}2050620507_unbindMouseMove(){20508this.table.columnManager.columnsByIndex.forEach(function(column){20509if(column.modules.moveColumn.mousemove){20510column.getElement().removeEventListener("mousemove", column.modules.moveColumn.mousemove);20511}20512});20513}2051420515moveColumn(column, after){20516var movingCells = this.moving.getCells();2051720518this.toCol = column;20519this.toColAfter = after;2052020521if(after){20522column.getCells().forEach(function(cell, i){20523var cellEl = cell.getElement(true);2052420525if(cellEl.parentNode && movingCells[i]){20526cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl.nextSibling);20527}20528});20529}else {20530column.getCells().forEach(function(cell, i){20531var cellEl = cell.getElement(true);2053220533if(cellEl.parentNode && movingCells[i]){20534cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl);20535}20536});20537}20538}2053920540endMove(e){20541if(e.which === 1 || this.touchMove){20542this._unbindMouseMove();2054320544this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);20545this.placeholderElement.parentNode.removeChild(this.placeholderElement);20546this.hoverElement.parentNode.removeChild(this.hoverElement);2054720548this.table.element.classList.remove("tabulator-block-select");2054920550if(this.toCol){20551this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);20552}2055320554this.moving = false;20555this.toCol = false;20556this.toColAfter = false;2055720558if(!this.touchMove){20559document.body.removeEventListener("mousemove", this.moveHover);20560document.body.removeEventListener("mouseup", this.endMove);20561}20562}20563}2056420565moveHover(e){20566var columnHolder = this.table.columnManager.getContentsElement(),20567scrollLeft = columnHolder.scrollLeft,20568xPos = ((this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(columnHolder).left) + scrollLeft,20569scrollPos;2057020571this.hoverElement.style.left = (xPos - this.startX) + "px";2057220573if(xPos - scrollLeft < this.autoScrollMargin){20574if(!this.autoScrollTimeout){20575this.autoScrollTimeout = setTimeout(() => {20576scrollPos = Math.max(0,scrollLeft-5);20577this.table.rowManager.getElement().scrollLeft = scrollPos;20578this.autoScrollTimeout = false;20579}, 1);20580}20581}2058220583if(scrollLeft + columnHolder.clientWidth - xPos < this.autoScrollMargin){20584if(!this.autoScrollTimeout){20585this.autoScrollTimeout = setTimeout(() => {20586scrollPos = Math.min(columnHolder.clientWidth, scrollLeft+5);20587this.table.rowManager.getElement().scrollLeft = scrollPos;20588this.autoScrollTimeout = false;20589}, 1);20590}20591}20592}20593}2059420595MoveColumns.moduleName = "moveColumn";2059620597class MoveRows extends Module{2059820599constructor(table){20600super(table);2060120602this.placeholderElement = this.createPlaceholderElement();20603this.hoverElement = false; //floating row header element20604this.checkTimeout = false; //click check timeout holder20605this.checkPeriod = 150; //period to wait on mousedown to consider this a move and not a click20606this.moving = false; //currently moving row20607this.toRow = false; //destination row20608this.toRowAfter = false; //position of moving row relative to the destination row20609this.hasHandle = false; //row has handle instead of fully movable row20610this.startY = 0; //starting Y position within header element20611this.startX = 0; //starting X position within header element2061220613this.moveHover = this.moveHover.bind(this);20614this.endMove = this.endMove.bind(this);20615this.tableRowDropEvent = false;2061620617this.touchMove = false;2061820619this.connection = false;20620this.connectionSelectorsTables = false;20621this.connectionSelectorsElements = false;20622this.connectionElements = [];20623this.connections = [];2062420625this.connectedTable = false;20626this.connectedRow = false;2062720628this.registerTableOption("movableRows", false); //enable movable rows20629this.registerTableOption("movableRowsConnectedTables", false); //tables for movable rows to be connected to20630this.registerTableOption("movableRowsConnectedElements", false); //other elements for movable rows to be connected to20631this.registerTableOption("movableRowsSender", false);20632this.registerTableOption("movableRowsReceiver", "insert");2063320634this.registerColumnOption("rowHandle");20635}2063620637createPlaceholderElement(){20638var el = document.createElement("div");2063920640el.classList.add("tabulator-row");20641el.classList.add("tabulator-row-placeholder");2064220643return el;20644}2064520646initialize(){20647if(this.table.options.movableRows){20648this.connectionSelectorsTables = this.table.options.movableRowsConnectedTables;20649this.connectionSelectorsElements = this.table.options.movableRowsConnectedElements;2065020651this.connection = this.connectionSelectorsTables || this.connectionSelectorsElements;2065220653this.subscribe("cell-init", this.initializeCell.bind(this));20654this.subscribe("column-init", this.initializeColumn.bind(this));20655this.subscribe("row-init", this.initializeRow.bind(this));20656}20657}2065820659initializeGroupHeader(group){20660var self = this,20661config = {};2066220663//inter table drag drop20664config.mouseup = function(e){20665self.tableRowDrop(e, group);20666}.bind(self);2066720668//same table drag drop20669config.mousemove = function(e){20670var rowEl;2067120672if(((e.pageY - Helpers.elOffset(group.element).top) + self.table.rowManager.element.scrollTop) > (group.getHeight() / 2)){20673if(self.toRow !== group || !self.toRowAfter){20674rowEl = group.getElement();20675rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);20676self.moveRow(group, true);20677}20678}else {20679if(self.toRow !== group || self.toRowAfter){20680rowEl = group.getElement();20681if(rowEl.previousSibling){20682rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);20683self.moveRow(group, false);20684}20685}20686}20687}.bind(self);2068820689group.modules.moveRow = config;20690}2069120692initializeRow(row){20693var self = this,20694config = {},20695rowEl;2069620697//inter table drag drop20698config.mouseup = function(e){20699self.tableRowDrop(e, row);20700}.bind(self);2070120702//same table drag drop20703config.mousemove = function(e){20704var rowEl = row.getElement();2070520706if(((e.pageY - Helpers.elOffset(rowEl).top) + self.table.rowManager.element.scrollTop) > (row.getHeight() / 2)){20707if(self.toRow !== row || !self.toRowAfter){20708rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);20709self.moveRow(row, true);20710}20711}else {20712if(self.toRow !== row || self.toRowAfter){20713rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);20714self.moveRow(row, false);20715}20716}20717}.bind(self);207182071920720if(!this.hasHandle){2072120722rowEl = row.getElement();2072320724rowEl.addEventListener("mousedown", function(e){20725if(e.which === 1){20726self.checkTimeout = setTimeout(function(){20727self.startMove(e, row);20728}, self.checkPeriod);20729}20730});2073120732rowEl.addEventListener("mouseup", function(e){20733if(e.which === 1){20734if(self.checkTimeout){20735clearTimeout(self.checkTimeout);20736}20737}20738});2073920740this.bindTouchEvents(row, row.getElement());20741}2074220743row.modules.moveRow = config;20744}2074520746initializeColumn(column){20747if(column.definition.rowHandle && this.table.options.movableRows !== false){20748this.hasHandle = true;20749}20750}2075120752initializeCell(cell){20753if(cell.column.definition.rowHandle && this.table.options.movableRows !== false){20754var self = this,20755cellEl = cell.getElement(true);2075620757cellEl.addEventListener("mousedown", function(e){20758if(e.which === 1){20759self.checkTimeout = setTimeout(function(){20760self.startMove(e, cell.row);20761}, self.checkPeriod);20762}20763});2076420765cellEl.addEventListener("mouseup", function(e){20766if(e.which === 1){20767if(self.checkTimeout){20768clearTimeout(self.checkTimeout);20769}20770}20771});2077220773this.bindTouchEvents(cell.row, cellEl);20774}20775}2077620777bindTouchEvents(row, element){20778var startYMove = false, //shifting center position of the cell20779nextRow, prevRow, nextRowHeight, prevRowHeight, nextRowHeightLast, prevRowHeightLast;2078020781element.addEventListener("touchstart", (e) => {20782this.checkTimeout = setTimeout(() => {20783this.touchMove = true;20784nextRow = row.nextRow();20785nextRowHeight = nextRow ? nextRow.getHeight()/2 : 0;20786prevRow = row.prevRow();20787prevRowHeight = prevRow ? prevRow.getHeight()/2 : 0;20788nextRowHeightLast = 0;20789prevRowHeightLast = 0;20790startYMove = false;2079120792this.startMove(e, row);20793}, this.checkPeriod);20794}, {passive: true});20795this.moving, this.toRow, this.toRowAfter;20796element.addEventListener("touchmove", (e) => {2079720798var diff, moveToRow;2079920800if(this.moving){20801e.preventDefault();2080220803this.moveHover(e);2080420805if(!startYMove){20806startYMove = e.touches[0].pageY;20807}2080820809diff = e.touches[0].pageY - startYMove;2081020811if(diff > 0){20812if(nextRow && diff - nextRowHeightLast > nextRowHeight){20813moveToRow = nextRow;2081420815if(moveToRow !== row){20816startYMove = e.touches[0].pageY;20817moveToRow.getElement().parentNode.insertBefore(this.placeholderElement, moveToRow.getElement().nextSibling);20818this.moveRow(moveToRow, true);20819}20820}20821}else {20822if(prevRow && -diff - prevRowHeightLast > prevRowHeight){20823moveToRow = prevRow;2082420825if(moveToRow !== row){20826startYMove = e.touches[0].pageY;20827moveToRow.getElement().parentNode.insertBefore(this.placeholderElement, moveToRow.getElement());20828this.moveRow(moveToRow, false);20829}20830}20831}2083220833if(moveToRow){20834nextRow = moveToRow.nextRow();20835nextRowHeightLast = nextRowHeight;20836nextRowHeight = nextRow ? nextRow.getHeight() / 2 : 0;20837prevRow = moveToRow.prevRow();20838prevRowHeightLast = prevRowHeight;20839prevRowHeight = prevRow ? prevRow.getHeight() / 2 : 0;20840}20841}20842});2084320844element.addEventListener("touchend", (e) => {20845if(this.checkTimeout){20846clearTimeout(this.checkTimeout);20847}20848if(this.moving){20849this.endMove(e);20850this.touchMove = false;20851}20852});20853}2085420855_bindMouseMove(){20856this.table.rowManager.getDisplayRows().forEach((row) => {20857if((row.type === "row" || row.type === "group") && row.modules.moveRow && row.modules.moveRow.mousemove){20858row.getElement().addEventListener("mousemove", row.modules.moveRow.mousemove);20859}20860});20861}2086220863_unbindMouseMove(){20864this.table.rowManager.getDisplayRows().forEach((row) => {20865if((row.type === "row" || row.type === "group") && row.modules.moveRow && row.modules.moveRow.mousemove){20866row.getElement().removeEventListener("mousemove", row.modules.moveRow.mousemove);20867}20868});20869}2087020871startMove(e, row){20872var element = row.getElement();2087320874this.setStartPosition(e, row);2087520876this.moving = row;2087720878this.table.element.classList.add("tabulator-block-select");2087920880//create placeholder20881this.placeholderElement.style.width = row.getWidth() + "px";20882this.placeholderElement.style.height = row.getHeight() + "px";2088320884if(!this.connection){20885element.parentNode.insertBefore(this.placeholderElement, element);20886element.parentNode.removeChild(element);20887}else {20888this.table.element.classList.add("tabulator-movingrow-sending");20889this.connectToTables(row);20890}2089120892//create hover element20893this.hoverElement = element.cloneNode(true);20894this.hoverElement.classList.add("tabulator-moving");2089520896if(this.connection){20897document.body.appendChild(this.hoverElement);20898this.hoverElement.style.left = "0";20899this.hoverElement.style.top = "0";20900this.hoverElement.style.width = this.table.element.clientWidth + "px";20901this.hoverElement.style.whiteSpace = "nowrap";20902this.hoverElement.style.overflow = "hidden";20903this.hoverElement.style.pointerEvents = "none";20904}else {20905this.table.rowManager.getTableElement().appendChild(this.hoverElement);2090620907this.hoverElement.style.left = "0";20908this.hoverElement.style.top = "0";2090920910this._bindMouseMove();20911}2091220913document.body.addEventListener("mousemove", this.moveHover);20914document.body.addEventListener("mouseup", this.endMove);2091520916this.dispatchExternal("rowMoving", row.getComponent());2091720918this.moveHover(e);20919}2092020921setStartPosition(e, row){20922var pageX = this.touchMove ? e.touches[0].pageX : e.pageX,20923pageY = this.touchMove ? e.touches[0].pageY : e.pageY,20924element, position;2092520926element = row.getElement();20927if(this.connection){20928position = element.getBoundingClientRect();2092920930this.startX = position.left - pageX + window.pageXOffset;20931this.startY = position.top - pageY + window.pageYOffset;20932}else {20933this.startY = (pageY - element.getBoundingClientRect().top);20934}20935}2093620937endMove(e){20938if(!e || e.which === 1 || this.touchMove){20939this._unbindMouseMove();2094020941if(!this.connection){20942this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);20943this.placeholderElement.parentNode.removeChild(this.placeholderElement);20944}2094520946this.hoverElement.parentNode.removeChild(this.hoverElement);2094720948this.table.element.classList.remove("tabulator-block-select");2094920950if(this.toRow){20951this.table.rowManager.moveRow(this.moving, this.toRow, this.toRowAfter);20952}else {20953this.dispatchExternal("rowMoveCancelled", this.moving.getComponent());20954}2095520956this.moving = false;20957this.toRow = false;20958this.toRowAfter = false;2095920960document.body.removeEventListener("mousemove", this.moveHover);20961document.body.removeEventListener("mouseup", this.endMove);2096220963if(this.connection){20964this.table.element.classList.remove("tabulator-movingrow-sending");20965this.disconnectFromTables();20966}20967}20968}2096920970moveRow(row, after){20971this.toRow = row;20972this.toRowAfter = after;20973}2097420975moveHover(e){20976if(this.connection){20977this.moveHoverConnections.call(this, e);20978}else {20979this.moveHoverTable.call(this, e);20980}20981}2098220983moveHoverTable(e){20984var rowHolder = this.table.rowManager.getElement(),20985scrollTop = rowHolder.scrollTop,20986yPos = ((this.touchMove ? e.touches[0].pageY : e.pageY) - rowHolder.getBoundingClientRect().top) + scrollTop;2098720988this.hoverElement.style.top = Math.min(yPos - this.startY, this.table.rowManager.element.scrollHeight - this.hoverElement.offsetHeight) + "px";20989}2099020991moveHoverConnections(e){20992this.hoverElement.style.left = (this.startX + (this.touchMove ? e.touches[0].pageX : e.pageX)) + "px";20993this.hoverElement.style.top = (this.startY + (this.touchMove ? e.touches[0].pageY : e.pageY)) + "px";20994}2099520996elementRowDrop(e, element, row){20997this.dispatchExternal("movableRowsElementDrop", e, element, row ? row.getComponent() : false);20998}2099921000//establish connection with other tables21001connectToTables(row){21002var connectionTables;2100321004if(this.connectionSelectorsTables){21005connectionTables = this.commsConnections(this.connectionSelectorsTables);2100621007this.dispatchExternal("movableRowsSendingStart", connectionTables);2100821009this.commsSend(this.connectionSelectorsTables, "moveRow", "connect", {21010row:row,21011});21012}2101321014if(this.connectionSelectorsElements){2101521016this.connectionElements = [];2101721018if(!Array.isArray(this.connectionSelectorsElements)){21019this.connectionSelectorsElements = [this.connectionSelectorsElements];21020}2102121022this.connectionSelectorsElements.forEach((query) => {21023if(typeof query === "string"){21024this.connectionElements = this.connectionElements.concat(Array.prototype.slice.call(document.querySelectorAll(query)));21025}else {21026this.connectionElements.push(query);21027}21028});2102921030this.connectionElements.forEach((element) => {21031var dropEvent = (e) => {21032this.elementRowDrop(e, element, this.moving);21033};2103421035element.addEventListener("mouseup", dropEvent);21036element.tabulatorElementDropEvent = dropEvent;2103721038element.classList.add("tabulator-movingrow-receiving");21039});21040}21041}2104221043//disconnect from other tables21044disconnectFromTables(){21045var connectionTables;2104621047if(this.connectionSelectorsTables){21048connectionTables = this.commsConnections(this.connectionSelectorsTables);2104921050this.dispatchExternal("movableRowsSendingStop", connectionTables);2105121052this.commsSend(this.connectionSelectorsTables, "moveRow", "disconnect");21053}2105421055this.connectionElements.forEach((element) => {21056element.classList.remove("tabulator-movingrow-receiving");21057element.removeEventListener("mouseup", element.tabulatorElementDropEvent);21058delete element.tabulatorElementDropEvent;21059});21060}2106121062//accept incomming connection21063connect(table, row){21064if(!this.connectedTable){21065this.connectedTable = table;21066this.connectedRow = row;2106721068this.table.element.classList.add("tabulator-movingrow-receiving");2106921070this.table.rowManager.getDisplayRows().forEach((row) => {21071if(row.type === "row" && row.modules.moveRow && row.modules.moveRow.mouseup){21072row.getElement().addEventListener("mouseup", row.modules.moveRow.mouseup);21073}21074});2107521076this.tableRowDropEvent = this.tableRowDrop.bind(this);2107721078this.table.element.addEventListener("mouseup", this.tableRowDropEvent);2107921080this.dispatchExternal("movableRowsReceivingStart", row, table);2108121082return true;21083}else {21084console.warn("Move Row Error - Table cannot accept connection, already connected to table:", this.connectedTable);21085return false;21086}21087}2108821089//close incoming connection21090disconnect(table){21091if(table === this.connectedTable){21092this.connectedTable = false;21093this.connectedRow = false;2109421095this.table.element.classList.remove("tabulator-movingrow-receiving");2109621097this.table.rowManager.getDisplayRows().forEach((row) =>{21098if(row.type === "row" && row.modules.moveRow && row.modules.moveRow.mouseup){21099row.getElement().removeEventListener("mouseup", row.modules.moveRow.mouseup);21100}21101});2110221103this.table.element.removeEventListener("mouseup", this.tableRowDropEvent);2110421105this.dispatchExternal("movableRowsReceivingStop", table);21106}else {21107console.warn("Move Row Error - trying to disconnect from non connected table");21108}21109}2111021111dropComplete(table, row, success){21112var sender = false;2111321114if(success){2111521116switch(typeof this.table.options.movableRowsSender){21117case "string":21118sender = this.senders[this.table.options.movableRowsSender];21119break;2112021121case "function":21122sender = this.table.options.movableRowsSender;21123break;21124}2112521126if(sender){21127sender.call(this, this.moving ? this.moving.getComponent() : undefined, row ? row.getComponent() : undefined, table);21128}else {21129if(this.table.options.movableRowsSender){21130console.warn("Mover Row Error - no matching sender found:", this.table.options.movableRowsSender);21131}21132}2113321134this.dispatchExternal("movableRowsSent", this.moving.getComponent(), row ? row.getComponent() : undefined, table);21135}else {21136this.dispatchExternal("movableRowsSentFailed", this.moving.getComponent(), row ? row.getComponent() : undefined, table);21137}2113821139this.endMove();21140}2114121142tableRowDrop(e, row){21143var receiver = false,21144success = false;2114521146e.stopImmediatePropagation();2114721148switch(typeof this.table.options.movableRowsReceiver){21149case "string":21150receiver = this.receivers[this.table.options.movableRowsReceiver];21151break;2115221153case "function":21154receiver = this.table.options.movableRowsReceiver;21155break;21156}2115721158if(receiver){21159success = receiver.call(this, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);21160}else {21161console.warn("Mover Row Error - no matching receiver found:", this.table.options.movableRowsReceiver);21162}2116321164if(success){21165this.dispatchExternal("movableRowsReceived", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);21166}else {21167this.dispatchExternal("movableRowsReceivedFailed", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);21168}2116921170this.commsSend(this.connectedTable, "moveRow", "dropcomplete", {21171row:row,21172success:success,21173});21174}2117521176commsReceived(table, action, data){21177switch(action){21178case "connect":21179return this.connect(table, data.row);2118021181case "disconnect":21182return this.disconnect(table);2118321184case "dropcomplete":21185return this.dropComplete(table, data.row, data.success);21186}21187}21188}2118921190MoveRows.prototype.receivers = {21191insert:function(fromRow, toRow, fromTable){21192this.table.addRow(fromRow.getData(), undefined, toRow);21193return true;21194},2119521196add:function(fromRow, toRow, fromTable){21197this.table.addRow(fromRow.getData());21198return true;21199},2120021201update:function(fromRow, toRow, fromTable){21202if(toRow){21203toRow.update(fromRow.getData());21204return true;21205}2120621207return false;21208},2120921210replace:function(fromRow, toRow, fromTable){21211if(toRow){21212this.table.addRow(fromRow.getData(), undefined, toRow);21213toRow.delete();21214return true;21215}2121621217return false;21218},21219};2122021221MoveRows.prototype.senders = {21222delete:function(fromRow, toRow, toTable){21223fromRow.delete();21224}21225};2122621227MoveRows.moduleName = "moveRow";2122821229var defaultMutators = {};2123021231class Mutator extends Module{2123221233constructor(table){21234super(table);2123521236this.allowedTypes = ["", "data", "edit", "clipboard"]; //list of mutation types21237this.enabled = true;2123821239this.registerColumnOption("mutator");21240this.registerColumnOption("mutatorParams");21241this.registerColumnOption("mutatorData");21242this.registerColumnOption("mutatorDataParams");21243this.registerColumnOption("mutatorEdit");21244this.registerColumnOption("mutatorEditParams");21245this.registerColumnOption("mutatorClipboard");21246this.registerColumnOption("mutatorClipboardParams");21247this.registerColumnOption("mutateLink");21248}2124921250initialize(){21251this.subscribe("cell-value-changing", this.transformCell.bind(this));21252this.subscribe("cell-value-changed", this.mutateLink.bind(this));21253this.subscribe("column-layout", this.initializeColumn.bind(this));21254this.subscribe("row-data-init-before", this.rowDataChanged.bind(this));21255this.subscribe("row-data-changing", this.rowDataChanged.bind(this));21256}2125721258rowDataChanged(row, tempData, updatedData){21259return this.transformRow(tempData, "data", updatedData);21260}2126121262//initialize column mutator21263initializeColumn(column){21264var match = false,21265config = {};2126621267this.allowedTypes.forEach((type) => {21268var key = "mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),21269mutator;2127021271if(column.definition[key]){21272mutator = this.lookupMutator(column.definition[key]);2127321274if(mutator){21275match = true;2127621277config[key] = {21278mutator:mutator,21279params: column.definition[key + "Params"] || {},21280};21281}21282}21283});2128421285if(match){21286column.modules.mutate = config;21287}21288}2128921290lookupMutator(value){21291var mutator = false;2129221293//set column mutator21294switch(typeof value){21295case "string":21296if(Mutator.mutators[value]){21297mutator = Mutator.mutators[value];21298}else {21299console.warn("Mutator Error - No such mutator found, ignoring: ", value);21300}21301break;2130221303case "function":21304mutator = value;21305break;21306}2130721308return mutator;21309}2131021311//apply mutator to row21312transformRow(data, type, updatedData){21313var key = "mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),21314value;2131521316if(this.enabled){2131721318this.table.columnManager.traverse((column) => {21319var mutator, params, component;2132021321if(column.modules.mutate){21322mutator = column.modules.mutate[key] || column.modules.mutate.mutator || false;2132321324if(mutator){21325value = column.getFieldValue(typeof updatedData !== "undefined" ? updatedData : data);2132621327if((type == "data" && !updatedData)|| typeof value !== "undefined"){21328component = column.getComponent();21329params = typeof mutator.params === "function" ? mutator.params(value, data, type, component) : mutator.params;21330column.setFieldValue(data, mutator.mutator(value, data, type, params, component));21331}21332}21333}21334});21335}2133621337return data;21338}2133921340//apply mutator to new cell value21341transformCell(cell, value){21342if(cell.column.modules.mutate){21343var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator || false,21344tempData = {};2134521346if(mutator){21347tempData = Object.assign(tempData, cell.row.getData());21348cell.column.setFieldValue(tempData, value);21349return mutator.mutator(value, tempData, "edit", mutator.params, cell.getComponent());21350}21351}2135221353return value;21354}2135521356mutateLink(cell){21357var links = cell.column.definition.mutateLink;2135821359if(links){21360if(!Array.isArray(links)){21361links = [links];21362}2136321364links.forEach((link) => {21365var linkCell = cell.row.getCell(link);2136621367if(linkCell){21368linkCell.setValue(linkCell.getValue(), true, true);21369}21370});21371}21372}2137321374enable(){21375this.enabled = true;21376}2137721378disable(){21379this.enabled = false;21380}21381}2138221383Mutator.moduleName = "mutator";2138421385//load defaults21386Mutator.mutators = defaultMutators;2138721388function rows(pageSize, currentRow, currentPage, totalRows, totalPages){21389var el = document.createElement("span"),21390showingEl = document.createElement("span"),21391valueEl = document.createElement("span"),21392ofEl = document.createElement("span"),21393totalEl = document.createElement("span"),21394rowsEl = document.createElement("span");2139521396this.table.modules.localize.langBind("pagination|counter|showing", (value) => {21397showingEl.innerHTML = value;21398});2139921400this.table.modules.localize.langBind("pagination|counter|of", (value) => {21401ofEl.innerHTML = value;21402});2140321404this.table.modules.localize.langBind("pagination|counter|rows", (value) => {21405rowsEl.innerHTML = value;21406});2140721408if(totalRows){21409valueEl.innerHTML = " " + currentRow + "-" + Math.min((currentRow + pageSize - 1), totalRows) + " ";2141021411totalEl.innerHTML = " " + totalRows + " ";2141221413el.appendChild(showingEl);21414el.appendChild(valueEl);21415el.appendChild(ofEl);21416el.appendChild(totalEl);21417el.appendChild(rowsEl);21418}else {21419valueEl.innerHTML = " 0 ";2142021421el.appendChild(showingEl);21422el.appendChild(valueEl);21423el.appendChild(rowsEl);21424}2142521426return el;21427}2142821429function pages(pageSize, currentRow, currentPage, totalRows, totalPages){2143021431var el = document.createElement("span"),21432showingEl = document.createElement("span"),21433valueEl = document.createElement("span"),21434ofEl = document.createElement("span"),21435totalEl = document.createElement("span"),21436rowsEl = document.createElement("span");2143721438this.table.modules.localize.langBind("pagination|counter|showing", (value) => {21439showingEl.innerHTML = value;21440});2144121442valueEl.innerHTML = " " + currentPage + " ";2144321444this.table.modules.localize.langBind("pagination|counter|of", (value) => {21445ofEl.innerHTML = value;21446});2144721448totalEl.innerHTML = " " + totalPages + " ";2144921450this.table.modules.localize.langBind("pagination|counter|pages", (value) => {21451rowsEl.innerHTML = value;21452});2145321454el.appendChild(showingEl);21455el.appendChild(valueEl);21456el.appendChild(ofEl);21457el.appendChild(totalEl);21458el.appendChild(rowsEl);2145921460return el;21461}2146221463var defaultPageCounters = {21464rows:rows,21465pages:pages,21466};2146721468class Page extends Module{2146921470constructor(table){21471super(table);2147221473this.mode = "local";21474this.progressiveLoad = false;2147521476this.element = null;21477this.pageCounterElement = null;21478this.pageCounter = null;2147921480this.size = 0;21481this.page = 1;21482this.count = 5;21483this.max = 1;2148421485this.remoteRowCountEstimate = null;2148621487this.initialLoad = true;21488this.dataChanging = false; //flag to check if data is being changed by this module2148921490this.pageSizes = [];2149121492this.registerTableOption("pagination", false); //set pagination type21493this.registerTableOption("paginationMode", "local"); //local or remote pagination21494this.registerTableOption("paginationSize", false); //set number of rows to a page21495this.registerTableOption("paginationInitialPage", 1); //initial page to show on load21496this.registerTableOption("paginationCounter", false); // set pagination counter21497this.registerTableOption("paginationCounterElement", false); // set pagination counter21498this.registerTableOption("paginationButtonCount", 5); // set count of page button21499this.registerTableOption("paginationSizeSelector", false); //add pagination size selector element21500this.registerTableOption("paginationElement", false); //element to hold pagination numbers21501// this.registerTableOption("paginationDataSent", {}); //pagination data sent to the server21502// this.registerTableOption("paginationDataReceived", {}); //pagination data received from the server21503this.registerTableOption("paginationAddRow", "page"); //add rows on table or page2150421505this.registerTableOption("progressiveLoad", false); //progressive loading21506this.registerTableOption("progressiveLoadDelay", 0); //delay between requests21507this.registerTableOption("progressiveLoadScrollMargin", 0); //margin before scroll begins2150821509this.registerTableFunction("setMaxPage", this.setMaxPage.bind(this));21510this.registerTableFunction("setPage", this.setPage.bind(this));21511this.registerTableFunction("setPageToRow", this.userSetPageToRow.bind(this));21512this.registerTableFunction("setPageSize", this.userSetPageSize.bind(this));21513this.registerTableFunction("getPageSize", this.getPageSize.bind(this));21514this.registerTableFunction("previousPage", this.previousPage.bind(this));21515this.registerTableFunction("nextPage", this.nextPage.bind(this));21516this.registerTableFunction("getPage", this.getPage.bind(this));21517this.registerTableFunction("getPageMax", this.getPageMax.bind(this));2151821519//register component functions21520this.registerComponentFunction("row", "pageTo", this.setPageToRow.bind(this));21521}2152221523initialize(){21524if(this.table.options.pagination){21525this.subscribe("row-deleted", this.rowsUpdated.bind(this));21526this.subscribe("row-added", this.rowsUpdated.bind(this));21527this.subscribe("data-processed", this.initialLoadComplete.bind(this));21528this.subscribe("table-built", this.calculatePageSizes.bind(this));21529this.subscribe("footer-redraw", this.footerRedraw.bind(this));2153021531if(this.table.options.paginationAddRow == "page"){21532this.subscribe("row-adding-position", this.rowAddingPosition.bind(this));21533}2153421535if(this.table.options.paginationMode === "remote"){21536this.subscribe("data-params", this.remotePageParams.bind(this));21537this.subscribe("data-loaded", this._parseRemoteData.bind(this));21538}2153921540if(this.table.options.progressiveLoad){21541console.error("Progressive Load Error - Pagination and progressive load cannot be used at the same time");21542}2154321544this.registerDisplayHandler(this.restOnRenderBefore.bind(this), 40);21545this.registerDisplayHandler(this.getRows.bind(this), 50);2154621547this.createElements();21548this.initializePageCounter();21549this.initializePaginator();21550}else if(this.table.options.progressiveLoad){21551this.subscribe("data-params", this.remotePageParams.bind(this));21552this.subscribe("data-loaded", this._parseRemoteData.bind(this));21553this.subscribe("table-built", this.calculatePageSizes.bind(this));21554this.subscribe("data-processed", this.initialLoadComplete.bind(this));2155521556this.initializeProgressive(this.table.options.progressiveLoad);2155721558if(this.table.options.progressiveLoad === "scroll"){21559this.subscribe("scroll-vertical", this.scrollVertical.bind(this));21560}21561}21562}2156321564rowAddingPosition(row, top){21565var rowManager = this.table.rowManager,21566displayRows = rowManager.getDisplayRows(),21567index;2156821569if(top){21570if(displayRows.length){21571index = displayRows[0];21572}else {21573if(rowManager.activeRows.length){21574index = rowManager.activeRows[rowManager.activeRows.length-1];21575top = false;21576}21577}21578}else {21579if(displayRows.length){21580index = displayRows[displayRows.length - 1];21581top = displayRows.length < this.size ? false : true;21582}21583}2158421585return {index, top};21586}2158721588calculatePageSizes(){21589var testElRow, testElCell;2159021591if(this.table.options.paginationSize){21592this.size = this.table.options.paginationSize;21593}else {21594testElRow = document.createElement("div");21595testElRow.classList.add("tabulator-row");21596testElRow.style.visibility = "hidden";2159721598testElCell = document.createElement("div");21599testElCell.classList.add("tabulator-cell");21600testElCell.innerHTML = "Page Row Test";2160121602testElRow.appendChild(testElCell);2160321604this.table.rowManager.getTableElement().appendChild(testElRow);2160521606this.size = Math.floor(this.table.rowManager.getElement().clientHeight / testElRow.offsetHeight);2160721608this.table.rowManager.getTableElement().removeChild(testElRow);21609}2161021611this.dispatchExternal("pageSizeChanged", this.size);2161221613this.generatePageSizeSelectList();21614}2161521616initialLoadComplete(){21617this.initialLoad = false;21618}2161921620remotePageParams(data, config, silent, params){21621if(!this.initialLoad){21622if((this.progressiveLoad && !silent) || (!this.progressiveLoad && !this.dataChanging)){21623this.reset(true);21624}21625}2162621627//configure request params21628params.page = this.page;2162921630//set page size if defined21631if(this.size){21632params.size = this.size;21633}2163421635return params;21636}2163721638///////////////////////////////////21639///////// Table Functions /////////21640///////////////////////////////////2164121642userSetPageToRow(row){21643if(this.table.options.pagination){21644row = this.rowManager.findRow(row);2164521646if(row){21647return this.setPageToRow(row);21648}21649}2165021651return Promise.reject();21652}2165321654userSetPageSize(size){21655if(this.table.options.pagination){21656this.setPageSize(size);21657return this.setPage(1);21658}else {21659return false;21660}21661}21662///////////////////////////////////21663///////// Internal Logic //////////21664///////////////////////////////////2166521666scrollVertical(top, dir){21667var element, diff, margin;21668if(!dir && !this.table.dataLoader.loading){21669element = this.table.rowManager.getElement();21670diff = element.scrollHeight - element.clientHeight - top;21671margin = this.table.options.progressiveLoadScrollMargin || (element.clientHeight * 2);2167221673if(diff < margin){21674this.nextPage()21675.catch(() => {}); //consume the exception thrown when on the last page21676}21677}21678}2167921680restOnRenderBefore(rows, renderInPosition){21681if(!renderInPosition){21682if(this.mode === "local"){21683this.reset();21684}21685}2168621687return rows;21688}2168921690rowsUpdated(){21691this.refreshData(true, "all");21692}2169321694createElements(){21695var button;2169621697this.element = document.createElement("span");21698this.element.classList.add("tabulator-paginator");2169921700this.pagesElement = document.createElement("span");21701this.pagesElement.classList.add("tabulator-pages");2170221703button = document.createElement("button");21704button.classList.add("tabulator-page");21705button.setAttribute("type", "button");21706button.setAttribute("role", "button");21707button.setAttribute("aria-label", "");21708button.setAttribute("title", "");2170921710this.firstBut = button.cloneNode(true);21711this.firstBut.setAttribute("data-page", "first");2171221713this.prevBut = button.cloneNode(true);21714this.prevBut.setAttribute("data-page", "prev");2171521716this.nextBut = button.cloneNode(true);21717this.nextBut.setAttribute("data-page", "next");2171821719this.lastBut = button.cloneNode(true);21720this.lastBut.setAttribute("data-page", "last");2172121722if(this.table.options.paginationSizeSelector){21723this.pageSizeSelect = document.createElement("select");21724this.pageSizeSelect.classList.add("tabulator-page-size");21725}21726}2172721728generatePageSizeSelectList(){21729var pageSizes = [];2173021731if(this.pageSizeSelect){2173221733if(Array.isArray(this.table.options.paginationSizeSelector)){21734pageSizes = this.table.options.paginationSizeSelector;21735this.pageSizes = pageSizes;2173621737if(this.pageSizes.indexOf(this.size) == -1){21738pageSizes.unshift(this.size);21739}21740}else {2174121742if(this.pageSizes.indexOf(this.size) == -1){21743pageSizes = [];2174421745for (let i = 1; i < 5; i++){21746pageSizes.push(this.size * i);21747}2174821749this.pageSizes = pageSizes;21750}else {21751pageSizes = this.pageSizes;21752}21753}2175421755while(this.pageSizeSelect.firstChild) this.pageSizeSelect.removeChild(this.pageSizeSelect.firstChild);2175621757pageSizes.forEach((item) => {21758var itemEl = document.createElement("option");21759itemEl.value = item;2176021761if(item === true){21762this.langBind("pagination|all", function(value){21763itemEl.innerHTML = value;21764});21765}else {21766itemEl.innerHTML = item;21767}21768217692177021771this.pageSizeSelect.appendChild(itemEl);21772});2177321774this.pageSizeSelect.value = this.size;21775}21776}2177721778initializePageCounter(){21779var counter = this.table.options.paginationCounter,21780pageCounter = null;2178121782if(counter){21783if(typeof counter === "function"){21784pageCounter = counter;21785}else {21786pageCounter = Page.pageCounters[counter];21787}2178821789if(pageCounter){21790this.pageCounter = pageCounter;2179121792this.pageCounterElement = document.createElement("span");21793this.pageCounterElement.classList.add("tabulator-page-counter");21794}else {21795console.warn("Pagination Error - No such page counter found: ", counter);21796}21797}21798}2179921800//setup pagination21801initializePaginator(hidden){21802var pageSelectLabel, paginationCounterHolder;2180321804if(!hidden){21805//build pagination element2180621807//bind localizations21808this.langBind("pagination|first", (value) => {21809this.firstBut.innerHTML = value;21810});2181121812this.langBind("pagination|first_title", (value) => {21813this.firstBut.setAttribute("aria-label", value);21814this.firstBut.setAttribute("title", value);21815});2181621817this.langBind("pagination|prev", (value) => {21818this.prevBut.innerHTML = value;21819});2182021821this.langBind("pagination|prev_title", (value) => {21822this.prevBut.setAttribute("aria-label", value);21823this.prevBut.setAttribute("title", value);21824});2182521826this.langBind("pagination|next", (value) => {21827this.nextBut.innerHTML = value;21828});2182921830this.langBind("pagination|next_title", (value) => {21831this.nextBut.setAttribute("aria-label", value);21832this.nextBut.setAttribute("title", value);21833});2183421835this.langBind("pagination|last", (value) => {21836this.lastBut.innerHTML = value;21837});2183821839this.langBind("pagination|last_title", (value) => {21840this.lastBut.setAttribute("aria-label", value);21841this.lastBut.setAttribute("title", value);21842});2184321844//click bindings21845this.firstBut.addEventListener("click", () => {21846this.setPage(1);21847});2184821849this.prevBut.addEventListener("click", () => {21850this.previousPage();21851});2185221853this.nextBut.addEventListener("click", () => {21854this.nextPage();21855});2185621857this.lastBut.addEventListener("click", () => {21858this.setPage(this.max);21859});2186021861if(this.table.options.paginationElement){21862this.element = this.table.options.paginationElement;21863}2186421865if(this.pageSizeSelect){21866pageSelectLabel = document.createElement("label");2186721868this.langBind("pagination|page_size", (value) => {21869this.pageSizeSelect.setAttribute("aria-label", value);21870this.pageSizeSelect.setAttribute("title", value);21871pageSelectLabel.innerHTML = value;21872});2187321874this.element.appendChild(pageSelectLabel);21875this.element.appendChild(this.pageSizeSelect);2187621877this.pageSizeSelect.addEventListener("change", (e) => {21878this.setPageSize(this.pageSizeSelect.value == "true" ? true : this.pageSizeSelect.value);21879this.setPage(1);21880});21881}2188221883//append to DOM21884this.element.appendChild(this.firstBut);21885this.element.appendChild(this.prevBut);21886this.element.appendChild(this.pagesElement);21887this.element.appendChild(this.nextBut);21888this.element.appendChild(this.lastBut);2188921890if(!this.table.options.paginationElement){21891if(this.table.options.paginationCounter){2189221893if(this.table.options.paginationCounterElement){21894if(this.table.options.paginationCounterElement instanceof HTMLElement){21895this.table.options.paginationCounterElement.appendChild(this.pageCounterElement);21896}else if(typeof this.table.options.paginationCounterElement === "string"){21897paginationCounterHolder = document.querySelector(this.table.options.paginationCounterElement);2189821899if(paginationCounterHolder){21900paginationCounterHolder.appendChild(this.pageCounterElement);21901}else {21902console.warn("Pagination Error - Unable to find element matching paginationCounterElement selector:", this.table.options.paginationCounterElement);21903}21904}21905}else {21906this.footerAppend(this.pageCounterElement);21907}2190821909}2191021911this.footerAppend(this.element);21912}2191321914this.page = this.table.options.paginationInitialPage;21915this.count = this.table.options.paginationButtonCount;21916}2191721918//set default values21919this.mode = this.table.options.paginationMode;21920}2192121922initializeProgressive(mode){21923this.initializePaginator(true);21924this.mode = "progressive_" + mode;21925this.progressiveLoad = true;21926}2192721928trackChanges(){21929this.dispatch("page-changed");21930}2193121932//calculate maximum page from number of rows21933setMaxRows(rowCount){21934if(!rowCount){21935this.max = 1;21936}else {21937this.max = this.size === true ? 1 : Math.ceil(rowCount/this.size);21938}2193921940if(this.page > this.max){21941this.page = this.max;21942}21943}2194421945//reset to first page without triggering action21946reset(force){21947if(!this.initialLoad){21948if(this.mode == "local" || force){21949this.page = 1;21950this.trackChanges();21951}21952}21953}2195421955//set the maximum page21956setMaxPage(max){2195721958max = parseInt(max);2195921960this.max = max || 1;2196121962if(this.page > this.max){21963this.page = this.max;21964this.trigger();21965}21966}2196721968//set current page number21969setPage(page){21970switch(page){21971case "first":21972return this.setPage(1);2197321974case "prev":21975return this.previousPage();2197621977case "next":21978return this.nextPage();2197921980case "last":21981return this.setPage(this.max);21982}2198321984page = parseInt(page);2198521986if((page > 0 && page <= this.max) || this.mode !== "local"){21987this.page = page;2198821989this.trackChanges();2199021991return this.trigger();21992}else {21993console.warn("Pagination Error - Requested page is out of range of 1 - " + this.max + ":", page);21994return Promise.reject();21995}21996}2199721998setPageToRow(row){21999var rows = this.displayRows(-1);22000var index = rows.indexOf(row);2200122002if(index > -1){22003var page = this.size === true ? 1 : Math.ceil((index + 1) / this.size);2200422005return this.setPage(page);22006}else {22007console.warn("Pagination Error - Requested row is not visible");22008return Promise.reject();22009}22010}2201122012setPageSize(size){22013if(size !== true){22014size = parseInt(size);22015}2201622017if(size > 0){22018this.size = size;22019this.dispatchExternal("pageSizeChanged", size);22020}2202122022if(this.pageSizeSelect){22023// this.pageSizeSelect.value = size;22024this.generatePageSizeSelectList();22025}2202622027this.trackChanges();22028}2202922030_setPageCounter(totalRows, size, currentRow){22031var content;2203222033if(this.pageCounter){2203422035if(this.mode === "remote"){22036size = this.size;22037currentRow = ((this.page - 1) * this.size) + 1;22038totalRows = this.remoteRowCountEstimate;22039}2204022041content = this.pageCounter.call(this, size, currentRow, this.page, totalRows, this.max);2204222043switch(typeof content){22044case "object":22045if(content instanceof Node){2204622047//clear previous cell contents22048while(this.pageCounterElement.firstChild) this.pageCounterElement.removeChild(this.pageCounterElement.firstChild);2204922050this.pageCounterElement.appendChild(content);22051}else {22052this.pageCounterElement.innerHTML = "";2205322054if(content != null){22055console.warn("Page Counter Error - Page Counter has returned a type of object, the only valid page counter object return is an instance of Node, the page counter returned:", content);22056}22057}22058break;22059case "undefined":22060this.pageCounterElement.innerHTML = "";22061break;22062default:22063this.pageCounterElement.innerHTML = content;22064}22065}22066}2206722068//setup the pagination buttons22069_setPageButtons(){22070let leftSize = Math.floor((this.count-1) / 2);22071let rightSize = Math.ceil((this.count-1) / 2);22072let min = this.max - this.page + leftSize + 1 < this.count ? this.max-this.count+1: Math.max(this.page-leftSize,1);22073let max = this.page <= rightSize? Math.min(this.count, this.max) :Math.min(this.page+rightSize, this.max);2207422075while(this.pagesElement.firstChild) this.pagesElement.removeChild(this.pagesElement.firstChild);2207622077if(this.page == 1){22078this.firstBut.disabled = true;22079this.prevBut.disabled = true;22080}else {22081this.firstBut.disabled = false;22082this.prevBut.disabled = false;22083}2208422085if(this.page == this.max){22086this.lastBut.disabled = true;22087this.nextBut.disabled = true;22088}else {22089this.lastBut.disabled = false;22090this.nextBut.disabled = false;22091}2209222093for(let i = min; i <= max; i++){22094if(i>0 && i <= this.max){22095this.pagesElement.appendChild(this._generatePageButton(i));22096}22097}2209822099this.footerRedraw();22100}2210122102_generatePageButton(page){22103var button = document.createElement("button");2210422105button.classList.add("tabulator-page");22106if(page == this.page){22107button.classList.add("active");22108}2210922110button.setAttribute("type", "button");22111button.setAttribute("role", "button");2211222113this.langBind("pagination|page_title", (value) => {22114button.setAttribute("aria-label", value + " " + page);22115button.setAttribute("title", value + " " + page);22116});2211722118button.setAttribute("data-page", page);22119button.textContent = page;2212022121button.addEventListener("click", (e) => {22122this.setPage(page);22123});2212422125return button;22126}2212722128//previous page22129previousPage(){22130if(this.page > 1){22131this.page--;2213222133this.trackChanges();2213422135return this.trigger();2213622137}else {22138console.warn("Pagination Error - Previous page would be less than page 1:", 0);22139return Promise.reject();22140}22141}2214222143//next page22144nextPage(){22145if(this.page < this.max){22146this.page++;2214722148this.trackChanges();2214922150return this.trigger();2215122152}else {22153if(!this.progressiveLoad){22154console.warn("Pagination Error - Next page would be greater than maximum page of " + this.max + ":", this.max + 1);22155}22156return Promise.reject();22157}22158}2215922160//return current page number22161getPage(){22162return this.page;22163}2216422165//return max page number22166getPageMax(){22167return this.max;22168}2216922170getPageSize(size){22171return this.size;22172}2217322174getMode(){22175return this.mode;22176}2217722178//return appropriate rows for current page22179getRows(data){22180var actualRowPageSize = 0,22181output, start, end, actualStartRow;2218222183var actualRows = data.filter((row) => {22184return row.type === "row";22185});2218622187if(this.mode == "local"){22188output = [];2218922190this.setMaxRows(data.length);2219122192if(this.size === true){22193start = 0;22194end = data.length;22195}else {22196start = this.size * (this.page - 1);22197end = start + parseInt(this.size);22198}2219922200this._setPageButtons();2220122202for(let i = start; i < end; i++){22203let row = data[i];2220422205if(row){22206output.push(row);2220722208if(row.type === "row"){22209if(!actualStartRow){22210actualStartRow = row;22211}2221222213actualRowPageSize++;22214}22215}22216}2221722218this._setPageCounter(actualRows.length, actualRowPageSize, actualStartRow ? (actualRows.indexOf(actualStartRow) + 1) : 0);2221922220return output;22221}else {22222this._setPageButtons();22223this._setPageCounter(actualRows.length);2222422225return data.slice(0);22226}22227}2222822229trigger(){22230var left;2223122232switch(this.mode){22233case "local":22234left = this.table.rowManager.scrollLeft;2223522236this.refreshData();22237this.table.rowManager.scrollHorizontal(left);2223822239this.dispatchExternal("pageLoaded", this.getPage());2224022241return Promise.resolve();2224222243case "remote":22244this.dataChanging = true;22245return this.reloadData(null)22246.finally(() => {22247this.dataChanging = false;22248});2224922250case "progressive_load":22251case "progressive_scroll":22252return this.reloadData(null, true);2225322254default:22255console.warn("Pagination Error - no such pagination mode:", this.mode);22256return Promise.reject();22257}22258}2225922260_parseRemoteData(data){22261var margin;2226222263if(typeof data.last_page === "undefined"){22264console.warn("Remote Pagination Error - Server response missing '" + (this.options("dataReceiveParams").last_page || "last_page") + "' property");22265}2226622267if(data.data){22268this.max = parseInt(data.last_page) || 1;2226922270this.remoteRowCountEstimate = typeof data.last_row !== "undefined" ? data.last_row : (data.last_page * this.size - (this.page == data.last_page ? (this.size - data.data.length) : 0));2227122272if(this.progressiveLoad){22273switch(this.mode){22274case "progressive_load":2227522276if(this.page == 1){22277this.table.rowManager.setData(data.data, false, this.page == 1);22278}else {22279this.table.rowManager.addRows(data.data);22280}2228122282if(this.page < this.max){22283setTimeout(() => {22284this.nextPage();22285}, this.table.options.progressiveLoadDelay);22286}22287break;2228822289case "progressive_scroll":22290data = this.page === 1 ? data.data : this.table.rowManager.getData().concat(data.data);2229122292this.table.rowManager.setData(data, this.page !== 1, this.page == 1);2229322294margin = this.table.options.progressiveLoadScrollMargin || (this.table.rowManager.element.clientHeight * 2);2229522296if(this.table.rowManager.element.scrollHeight <= (this.table.rowManager.element.clientHeight + margin)){22297if(this.page < this.max){22298setTimeout(() => {22299this.nextPage();22300});22301}22302}22303break;22304}2230522306return false;22307}else {22308// left = this.table.rowManager.scrollLeft;22309this.dispatchExternal("pageLoaded", this.getPage());22310// this.table.rowManager.scrollHorizontal(left);22311// this.table.columnManager.scrollHorizontal(left);22312}2231322314}else {22315console.warn("Remote Pagination Error - Server response missing '" + (this.options("dataReceiveParams").data || "data") + "' property");22316}2231722318return data.data;22319}2232022321//handle the footer element being redrawn22322footerRedraw(){22323var footer = this.table.footerManager.containerElement;2232422325if((Math.ceil(footer.clientWidth) - footer.scrollWidth) < 0){22326this.pagesElement.style.display = 'none';22327}else {22328this.pagesElement.style.display = '';2232922330if((Math.ceil(footer.clientWidth) - footer.scrollWidth) < 0){22331this.pagesElement.style.display = 'none';22332}22333}22334}22335}2233622337Page.moduleName = "page";2233822339//load defaults22340Page.pageCounters = defaultPageCounters;2234122342// read persistance information from storage22343var defaultReaders = {22344local:function(id, type){22345var data = localStorage.getItem(id + "-" + type);2234622347return data ? JSON.parse(data) : false;22348},22349cookie:function(id, type){22350var cookie = document.cookie,22351key = id + "-" + type,22352cookiePos = cookie.indexOf(key + "="),22353end, data;2235422355//if cookie exists, decode and load column data into tabulator22356if(cookiePos > -1){22357cookie = cookie.slice(cookiePos);2235822359end = cookie.indexOf(";");2236022361if(end > -1){22362cookie = cookie.slice(0, end);22363}2236422365data = cookie.replace(key + "=", "");22366}2236722368return data ? JSON.parse(data) : false;22369}22370};2237122372//write persistence information to storage22373var defaultWriters = {22374local:function(id, type, data){22375localStorage.setItem(id + "-" + type, JSON.stringify(data));22376},22377cookie:function(id, type, data){22378var expireDate = new Date();2237922380expireDate.setDate(expireDate.getDate() + 10000);2238122382document.cookie = id + "-" + type + "=" + JSON.stringify(data) + "; expires=" + expireDate.toUTCString();22383}22384};2238522386class Persistence extends Module{2238722388constructor(table){22389super(table);2239022391this.mode = "";22392this.id = "";22393// this.persistProps = ["field", "width", "visible"];22394this.defWatcherBlock = false;22395this.config = {};22396this.readFunc = false;22397this.writeFunc = false;2239822399this.registerTableOption("persistence", false);22400this.registerTableOption("persistenceID", ""); //key for persistent storage22401this.registerTableOption("persistenceMode", true); //mode for storing persistence information22402this.registerTableOption("persistenceReaderFunc", false); //function for handling persistence data reading22403this.registerTableOption("persistenceWriterFunc", false); //function for handling persistence data writing22404}2240522406// Test for whether localStorage is available for use.22407localStorageTest() {22408var testKey = "_tabulator_test";2240922410try {22411window.localStorage.setItem( testKey, testKey);22412window.localStorage.removeItem( testKey );22413return true;22414} catch(e) {22415return false;22416}22417}2241822419//setup parameters22420initialize(){22421if(this.table.options.persistence){22422//determine persistent layout storage type22423var mode = this.table.options.persistenceMode,22424id = this.table.options.persistenceID,22425retrievedData;2242622427this.mode = mode !== true ? mode : (this.localStorageTest() ? "local" : "cookie");2242822429if(this.table.options.persistenceReaderFunc){22430if(typeof this.table.options.persistenceReaderFunc === "function"){22431this.readFunc = this.table.options.persistenceReaderFunc;22432}else {22433if(Persistence.readers[this.table.options.persistenceReaderFunc]){22434this.readFunc = Persistence.readers[this.table.options.persistenceReaderFunc];22435}else {22436console.warn("Persistence Read Error - invalid reader set", this.table.options.persistenceReaderFunc);22437}22438}22439}else {22440if(Persistence.readers[this.mode]){22441this.readFunc = Persistence.readers[this.mode];22442}else {22443console.warn("Persistence Read Error - invalid reader set", this.mode);22444}22445}2244622447if(this.table.options.persistenceWriterFunc){22448if(typeof this.table.options.persistenceWriterFunc === "function"){22449this.writeFunc = this.table.options.persistenceWriterFunc;22450}else {22451if(Persistence.writers[this.table.options.persistenceWriterFunc]){22452this.writeFunc = Persistence.writers[this.table.options.persistenceWriterFunc];22453}else {22454console.warn("Persistence Write Error - invalid reader set", this.table.options.persistenceWriterFunc);22455}22456}22457}else {22458if(Persistence.writers[this.mode]){22459this.writeFunc = Persistence.writers[this.mode];22460}else {22461console.warn("Persistence Write Error - invalid writer set", this.mode);22462}22463}2246422465//set storage tag22466this.id = "tabulator-" + (id || (this.table.element.getAttribute("id") || ""));2246722468this.config = {22469sort:this.table.options.persistence === true || this.table.options.persistence.sort,22470filter:this.table.options.persistence === true || this.table.options.persistence.filter,22471headerFilter:this.table.options.persistence === true || this.table.options.persistence.headerFilter,22472group:this.table.options.persistence === true || this.table.options.persistence.group,22473page:this.table.options.persistence === true || this.table.options.persistence.page,22474columns:this.table.options.persistence === true ? ["title", "width", "visible"] : this.table.options.persistence.columns,22475};2247622477//load pagination data if needed22478if(this.config.page){22479retrievedData = this.retrieveData("page");2248022481if(retrievedData){22482if(typeof retrievedData.paginationSize !== "undefined" && (this.config.page === true || this.config.page.size)){22483this.table.options.paginationSize = retrievedData.paginationSize;22484}2248522486if(typeof retrievedData.paginationInitialPage !== "undefined" && (this.config.page === true || this.config.page.page)){22487this.table.options.paginationInitialPage = retrievedData.paginationInitialPage;22488}22489}22490}2249122492//load group data if needed22493if(this.config.group){22494retrievedData = this.retrieveData("group");2249522496if(retrievedData){22497if(typeof retrievedData.groupBy !== "undefined" && (this.config.group === true || this.config.group.groupBy)){22498this.table.options.groupBy = retrievedData.groupBy;22499}22500if(typeof retrievedData.groupStartOpen !== "undefined" && (this.config.group === true || this.config.group.groupStartOpen)){22501this.table.options.groupStartOpen = retrievedData.groupStartOpen;22502}22503if(typeof retrievedData.groupHeader !== "undefined" && (this.config.group === true || this.config.group.groupHeader)){22504this.table.options.groupHeader = retrievedData.groupHeader;22505}22506}22507}2250822509if(this.config.columns){22510this.table.options.columns = this.load("columns", this.table.options.columns);22511this.subscribe("column-init", this.initializeColumn.bind(this));22512this.subscribe("column-show", this.save.bind(this, "columns"));22513this.subscribe("column-hide", this.save.bind(this, "columns"));22514this.subscribe("column-moved", this.save.bind(this, "columns"));22515}2251622517this.subscribe("table-built", this.tableBuilt.bind(this), 0);2251822519this.subscribe("table-redraw", this.tableRedraw.bind(this));2252022521this.subscribe("filter-changed", this.eventSave.bind(this, "filter"));22522this.subscribe("filter-changed", this.eventSave.bind(this, "headerFilter"));22523this.subscribe("sort-changed", this.eventSave.bind(this, "sort"));22524this.subscribe("group-changed", this.eventSave.bind(this, "group"));22525this.subscribe("page-changed", this.eventSave.bind(this, "page"));22526this.subscribe("column-resized", this.eventSave.bind(this, "columns"));22527this.subscribe("column-width", this.eventSave.bind(this, "columns"));22528this.subscribe("layout-refreshed", this.eventSave.bind(this, "columns"));22529}2253022531this.registerTableFunction("getColumnLayout", this.getColumnLayout.bind(this));22532this.registerTableFunction("setColumnLayout", this.setColumnLayout.bind(this));22533}2253422535eventSave(type){22536if(this.config[type]){22537this.save(type);22538}22539}2254022541tableBuilt(){22542var sorters, filters, headerFilters;2254322544if(this.config.sort){22545sorters = this.load("sort");2254622547if(!sorters === false){22548this.table.options.initialSort = sorters;22549}22550}2255122552if(this.config.filter){22553filters = this.load("filter");2255422555if(!filters === false){22556this.table.options.initialFilter = filters;22557}22558}22559if(this.config.headerFilter){22560headerFilters = this.load("headerFilter");2256122562if(!headerFilters === false){22563this.table.options.initialHeaderFilter = headerFilters;22564}22565}2256622567}2256822569tableRedraw(force){22570if(force && this.config.columns){22571this.save("columns");22572}22573}2257422575///////////////////////////////////22576///////// Table Functions /////////22577///////////////////////////////////2257822579getColumnLayout(){22580return this.parseColumns(this.table.columnManager.getColumns());22581}2258222583setColumnLayout(layout){22584this.table.columnManager.setColumns(this.mergeDefinition(this.table.options.columns, layout));22585return true;22586}2258722588///////////////////////////////////22589///////// Internal Logic //////////22590///////////////////////////////////2259122592initializeColumn(column){22593var def, keys;2259422595if(this.config.columns){22596this.defWatcherBlock = true;2259722598def = column.getDefinition();2259922600keys = this.config.columns === true ? Object.keys(def) : this.config.columns;2260122602keys.forEach((key)=>{22603var props = Object.getOwnPropertyDescriptor(def, key);22604var value = def[key];2260522606if(props){22607Object.defineProperty(def, key, {22608set: (newValue) => {22609value = newValue;2261022611if(!this.defWatcherBlock){22612this.save("columns");22613}2261422615if(props.set){22616props.set(newValue);22617}22618},22619get:() => {22620if(props.get){22621props.get();22622}22623return value;22624}22625});22626}22627});2262822629this.defWatcherBlock = false;22630}22631}2263222633//load saved definitions22634load(type, current){22635var data = this.retrieveData(type);2263622637if(current){22638data = data ? this.mergeDefinition(current, data) : current;22639}2264022641return data;22642}2264322644//retrieve data from memory22645retrieveData(type){22646return this.readFunc ? this.readFunc(this.id, type) : false;22647}2264822649//merge old and new column definitions22650mergeDefinition(oldCols, newCols){22651var output = [];2265222653newCols = newCols || [];2265422655newCols.forEach((column, to) => {22656var from = this._findColumn(oldCols, column),22657keys;2265822659if(from){22660if(this.config.columns === true || this.config.columns == undefined){22661keys = Object.keys(from);22662keys.push("width");22663}else {22664keys = this.config.columns;22665}2266622667keys.forEach((key)=>{22668if(key !== "columns" && typeof column[key] !== "undefined"){22669from[key] = column[key];22670}22671});2267222673if(from.columns){22674from.columns = this.mergeDefinition(from.columns, column.columns);22675}2267622677output.push(from);22678}22679});2268022681oldCols.forEach((column, i) => {22682var from = this._findColumn(newCols, column);2268322684if (!from) {22685if(output.length>i){22686output.splice(i, 0, column);22687}else {22688output.push(column);22689}22690}22691});2269222693return output;22694}2269522696//find matching columns22697_findColumn(columns, subject){22698var type = subject.columns ? "group" : (subject.field ? "field" : "object");2269922700return columns.find(function(col){22701switch(type){22702case "group":22703return col.title === subject.title && col.columns.length === subject.columns.length;2270422705case "field":22706return col.field === subject.field;2270722708case "object":22709return col === subject;22710}22711});22712}2271322714//save data22715save(type){22716var data = {};2271722718switch(type){22719case "columns":22720data = this.parseColumns(this.table.columnManager.getColumns());22721break;2272222723case "filter":22724data = this.table.modules.filter.getFilters();22725break;2272622727case "headerFilter":22728data = this.table.modules.filter.getHeaderFilters();22729break;2273022731case "sort":22732data = this.validateSorters(this.table.modules.sort.getSort());22733break;2273422735case "group":22736data = this.getGroupConfig();22737break;2273822739case "page":22740data = this.getPageConfig();22741break;22742}2274322744if(this.writeFunc){22745this.writeFunc(this.id, type, data);22746}2274722748}2274922750//ensure sorters contain no function data22751validateSorters(data){22752data.forEach(function(item){22753item.column = item.field;22754delete item.field;22755});2275622757return data;22758}2275922760getGroupConfig(){22761var data = {};2276222763if(this.config.group){22764if(this.config.group === true || this.config.group.groupBy){22765data.groupBy = this.table.options.groupBy;22766}2276722768if(this.config.group === true || this.config.group.groupStartOpen){22769data.groupStartOpen = this.table.options.groupStartOpen;22770}2277122772if(this.config.group === true || this.config.group.groupHeader){22773data.groupHeader = this.table.options.groupHeader;22774}22775}2277622777return data;22778}2277922780getPageConfig(){22781var data = {};2278222783if(this.config.page){22784if(this.config.page === true || this.config.page.size){22785data.paginationSize = this.table.modules.page.getPageSize();22786}2278722788if(this.config.page === true || this.config.page.page){22789data.paginationInitialPage = this.table.modules.page.getPage();22790}22791}2279222793return data;22794}227952279622797//parse columns for data to store22798parseColumns(columns){22799var definitions = [],22800excludedKeys = ["headerContextMenu", "headerMenu", "contextMenu", "clickMenu"];2280122802columns.forEach((column) => {22803var defStore = {},22804colDef = column.getDefinition(),22805keys;2280622807if(column.isGroup){22808defStore.title = colDef.title;22809defStore.columns = this.parseColumns(column.getColumns());22810}else {22811defStore.field = column.getField();2281222813if(this.config.columns === true || this.config.columns == undefined){22814keys = Object.keys(colDef);22815keys.push("width");22816keys.push("visible");22817}else {22818keys = this.config.columns;22819}2282022821keys.forEach((key)=>{22822switch(key){22823case "width":22824defStore.width = column.getWidth();22825break;22826case "visible":22827defStore.visible = column.visible;22828break;2282922830default:22831if(typeof colDef[key] !== "function" && excludedKeys.indexOf(key) === -1){22832defStore[key] = colDef[key];22833}22834}22835});22836}2283722838definitions.push(defStore);22839});2284022841return definitions;22842}22843}2284422845Persistence.moduleName = "persistence";2284622847Persistence.moduleInitOrder = -10;2284822849//load defaults22850Persistence.readers = defaultReaders;22851Persistence.writers = defaultWriters;2285222853class Popup$1 extends Module{2285422855constructor(table){22856super(table);2285722858this.columnSubscribers = {};2285922860this.registerTableOption("rowContextPopup", false);22861this.registerTableOption("rowClickPopup", false);22862this.registerTableOption("rowDblClickPopup", false);22863this.registerTableOption("groupContextPopup", false);22864this.registerTableOption("groupClickPopup", false);22865this.registerTableOption("groupDblClickPopup", false);2286622867this.registerColumnOption("headerContextPopup");22868this.registerColumnOption("headerClickPopup");22869this.registerColumnOption("headerDblClickPopup");22870this.registerColumnOption("headerPopup");22871this.registerColumnOption("headerPopupIcon");22872this.registerColumnOption("contextPopup");22873this.registerColumnOption("clickPopup");22874this.registerColumnOption("dblClickPopup");2287522876this.registerComponentFunction("cell", "popup", this._componentPopupCall.bind(this));22877this.registerComponentFunction("column", "popup", this._componentPopupCall.bind(this));22878this.registerComponentFunction("row", "popup", this._componentPopupCall.bind(this));22879this.registerComponentFunction("group", "popup", this._componentPopupCall.bind(this));2288022881}2288222883initialize(){22884this.initializeRowWatchers();22885this.initializeGroupWatchers();2288622887this.subscribe("column-init", this.initializeColumn.bind(this));22888}2288922890_componentPopupCall(component, contents, position){22891this.loadPopupEvent(contents, null, component, position);22892}2289322894initializeRowWatchers(){22895if(this.table.options.rowContextPopup){22896this.subscribe("row-contextmenu", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));22897this.table.on("rowTapHold", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));22898}2289922900if(this.table.options.rowClickPopup){22901this.subscribe("row-click", this.loadPopupEvent.bind(this, this.table.options.rowClickPopup));22902}2290322904if(this.table.options.rowDblClickPopup){22905this.subscribe("row-dblclick", this.loadPopupEvent.bind(this, this.table.options.rowDblClickPopup));22906}22907}2290822909initializeGroupWatchers(){22910if(this.table.options.groupContextPopup){22911this.subscribe("group-contextmenu", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));22912this.table.on("groupTapHold", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));22913}2291422915if(this.table.options.groupClickPopup){22916this.subscribe("group-click", this.loadPopupEvent.bind(this, this.table.options.groupClickPopup));22917}2291822919if(this.table.options.groupDblClickPopup){22920this.subscribe("group-dblclick", this.loadPopupEvent.bind(this, this.table.options.groupDblClickPopup));22921}22922}2292322924initializeColumn(column){22925var def = column.definition;2292622927//handle column events22928if(def.headerContextPopup && !this.columnSubscribers.headerContextPopup){22929this.columnSubscribers.headerContextPopup = this.loadPopupTableColumnEvent.bind(this, "headerContextPopup");22930this.subscribe("column-contextmenu", this.columnSubscribers.headerContextPopup);22931this.table.on("headerTapHold", this.loadPopupTableColumnEvent.bind(this, "headerContextPopup"));22932}2293322934if(def.headerClickPopup && !this.columnSubscribers.headerClickPopup){22935this.columnSubscribers.headerClickPopup = this.loadPopupTableColumnEvent.bind(this, "headerClickPopup");22936this.subscribe("column-click", this.columnSubscribers.headerClickPopup);229372293822939}if(def.headerDblClickPopup && !this.columnSubscribers.headerDblClickPopup){22940this.columnSubscribers.headerDblClickPopup = this.loadPopupTableColumnEvent.bind(this, "headerDblClickPopup");22941this.subscribe("column-dblclick", this.columnSubscribers.headerDblClickPopup);22942}2294322944if(def.headerPopup){22945this.initializeColumnHeaderPopup(column);22946}2294722948//handle cell events22949if(def.contextPopup && !this.columnSubscribers.contextPopup){22950this.columnSubscribers.contextPopup = this.loadPopupTableCellEvent.bind(this, "contextPopup");22951this.subscribe("cell-contextmenu", this.columnSubscribers.contextPopup);22952this.table.on("cellTapHold", this.loadPopupTableCellEvent.bind(this, "contextPopup"));22953}2295422955if(def.clickPopup && !this.columnSubscribers.clickPopup){22956this.columnSubscribers.clickPopup = this.loadPopupTableCellEvent.bind(this, "clickPopup");22957this.subscribe("cell-click", this.columnSubscribers.clickPopup);22958}2295922960if(def.dblClickPopup && !this.columnSubscribers.dblClickPopup){22961this.columnSubscribers.dblClickPopup = this.loadPopupTableCellEvent.bind(this, "dblClickPopup");22962this.subscribe("cell-click", this.columnSubscribers.dblClickPopup);22963}22964}2296522966initializeColumnHeaderPopup(column){22967var icon = column.definition.headerPopupIcon,22968headerPopupEl;2296922970headerPopupEl = document.createElement("span");22971headerPopupEl.classList.add("tabulator-header-popup-button");2297222973if(icon){22974if(typeof icon === "function"){22975icon = icon(column.getComponent());22976}2297722978if(icon instanceof HTMLElement){22979headerPopupEl.appendChild(icon);22980}else {22981headerPopupEl.innerHTML = icon;22982}22983}else {22984headerPopupEl.innerHTML = "⋮";22985}2298622987headerPopupEl.addEventListener("click", (e) => {22988e.stopPropagation();22989e.preventDefault();2299022991this.loadPopupEvent(column.definition.headerPopup, e, column);22992});2299322994column.titleElement.insertBefore(headerPopupEl, column.titleElement.firstChild);22995}2299622997loadPopupTableCellEvent(option, e, cell){22998if(cell._cell){22999cell = cell._cell;23000}2300123002if(cell.column.definition[option]){23003this.loadPopupEvent(cell.column.definition[option], e, cell);23004}23005}2300623007loadPopupTableColumnEvent(option, e, column){23008if(column._column){23009column = column._column;23010}2301123012if(column.definition[option]){23013this.loadPopupEvent(column.definition[option], e, column);23014}23015}2301623017loadPopupEvent(contents, e, component, position){23018var renderedCallback;2301923020function onRendered(callback){23021renderedCallback = callback;23022}2302323024if(component._group){23025component = component._group;23026}else if(component._row){23027component = component._row;23028}2302923030contents = typeof contents == "function" ? contents.call(this.table, e, component.getComponent(), onRendered) : contents;2303123032this.loadPopup(e, component, contents, renderedCallback, position);23033}2303423035loadPopup(e, component, contents, renderedCallback, position){23036var touch = !(e instanceof MouseEvent),23037contentsEl, popup;2303823039if(contents instanceof HTMLElement){23040contentsEl = contents;23041}else {23042contentsEl = document.createElement("div");23043contentsEl.innerHTML = contents;23044}2304523046contentsEl.classList.add("tabulator-popup");2304723048contentsEl.addEventListener("click", (e) =>{23049e.stopPropagation();23050});2305123052if(!touch){23053e.preventDefault();23054}2305523056popup = this.popup(contentsEl);2305723058if(typeof renderedCallback === "function"){23059popup.renderCallback(renderedCallback);23060}2306123062if(e){23063popup.show(e);23064}else {23065popup.show(component.getElement(), position || "center");23066}230672306823069popup.hideOnBlur(() => {23070this.dispatchExternal("popupClosed", component.getComponent());23071});23072230732307423075this.dispatchExternal("popupOpened", component.getComponent());23076}23077}2307823079Popup$1.moduleName = "popup";2308023081class Print extends Module{2308223083constructor(table){23084super(table);2308523086this.element = false;23087this.manualBlock = false;23088this.beforeprintEventHandler = null;23089this.afterprintEventHandler = null;2309023091this.registerTableOption("printAsHtml", false); //enable print as html23092this.registerTableOption("printFormatter", false); //printing page formatter23093this.registerTableOption("printHeader", false); //page header contents23094this.registerTableOption("printFooter", false); //page footer contents23095this.registerTableOption("printStyled", true); //enable print as html styling23096this.registerTableOption("printRowRange", "visible"); //restrict print to visible rows only23097this.registerTableOption("printConfig", {}); //print config options2309823099this.registerColumnOption("print");23100this.registerColumnOption("titlePrint");23101}2310223103initialize(){23104if(this.table.options.printAsHtml){23105this.beforeprintEventHandler = this.replaceTable.bind(this);23106this.afterprintEventHandler = this.cleanup.bind(this);2310723108window.addEventListener("beforeprint", this.beforeprintEventHandler );23109window.addEventListener("afterprint", this.afterprintEventHandler);23110this.subscribe("table-destroy", this.destroy.bind(this));23111}2311223113this.registerTableFunction("print", this.printFullscreen.bind(this));23114}2311523116destroy(){23117if(this.table.options.printAsHtml){23118window.removeEventListener( "beforeprint", this.beforeprintEventHandler );23119window.removeEventListener( "afterprint", this.afterprintEventHandler );23120}23121}2312223123///////////////////////////////////23124///////// Table Functions /////////23125///////////////////////////////////2312623127///////////////////////////////////23128///////// Internal Logic //////////23129///////////////////////////////////2313023131replaceTable(){23132if(!this.manualBlock){23133this.element = document.createElement("div");23134this.element.classList.add("tabulator-print-table");2313523136this.element.appendChild(this.table.modules.export.generateTable(this.table.options.printConfig, this.table.options.printStyled, this.table.options.printRowRange, "print"));2313723138this.table.element.style.display = "none";2313923140this.table.element.parentNode.insertBefore(this.element, this.table.element);23141}23142}2314323144cleanup(){23145document.body.classList.remove("tabulator-print-fullscreen-hide");2314623147if(this.element && this.element.parentNode){23148this.element.parentNode.removeChild(this.element);23149this.table.element.style.display = "";23150}23151}2315223153printFullscreen(visible, style, config){23154var scrollX = window.scrollX,23155scrollY = window.scrollY,23156headerEl = document.createElement("div"),23157footerEl = document.createElement("div"),23158tableEl = this.table.modules.export.generateTable(typeof config != "undefined" ? config : this.table.options.printConfig, typeof style != "undefined" ? style : this.table.options.printStyled, visible || this.table.options.printRowRange, "print"),23159headerContent, footerContent;2316023161this.manualBlock = true;2316223163this.element = document.createElement("div");23164this.element.classList.add("tabulator-print-fullscreen");2316523166if(this.table.options.printHeader){23167headerEl.classList.add("tabulator-print-header");2316823169headerContent = typeof this.table.options.printHeader == "function" ? this.table.options.printHeader.call(this.table) : this.table.options.printHeader;2317023171if(typeof headerContent == "string"){23172headerEl.innerHTML = headerContent;23173}else {23174headerEl.appendChild(headerContent);23175}2317623177this.element.appendChild(headerEl);23178}2317923180this.element.appendChild(tableEl);2318123182if(this.table.options.printFooter){23183footerEl.classList.add("tabulator-print-footer");2318423185footerContent = typeof this.table.options.printFooter == "function" ? this.table.options.printFooter.call(this.table) : this.table.options.printFooter;231862318723188if(typeof footerContent == "string"){23189footerEl.innerHTML = footerContent;23190}else {23191footerEl.appendChild(footerContent);23192}2319323194this.element.appendChild(footerEl);23195}2319623197document.body.classList.add("tabulator-print-fullscreen-hide");23198document.body.appendChild(this.element);2319923200if(this.table.options.printFormatter){23201this.table.options.printFormatter(this.element, tableEl);23202}2320323204window.print();2320523206this.cleanup();2320723208window.scrollTo(scrollX, scrollY);2320923210this.manualBlock = false;23211}23212}2321323214Print.moduleName = "print";2321523216class ReactiveData extends Module{2321723218constructor(table){23219super(table);2322023221this.data = false;23222this.blocked = false; //block reactivity while performing update23223this.origFuncs = {}; // hold original data array functions to allow replacement after data is done with23224this.currentVersion = 0;2322523226this.registerTableOption("reactiveData", false); //enable data reactivity23227}2322823229initialize(){23230if(this.table.options.reactiveData){23231this.subscribe("cell-value-save-before", this.block.bind(this, "cellsave"));23232this.subscribe("cell-value-save-after", this.unblock.bind(this, "cellsave"));23233this.subscribe("row-data-save-before", this.block.bind(this, "rowsave"));23234this.subscribe("row-data-save-after", this.unblock.bind(this, "rowsave"));23235this.subscribe("row-data-init-after", this.watchRow.bind(this));23236this.subscribe("data-processing", this.watchData.bind(this));23237this.subscribe("table-destroy", this.unwatchData.bind(this));23238}23239}2324023241watchData(data){23242var self = this,23243version;2324423245this.currentVersion ++;2324623247version = this.currentVersion;2324823249this.unwatchData();2325023251this.data = data;2325223253//override array push function23254this.origFuncs.push = data.push;2325523256Object.defineProperty(this.data, "push", {23257enumerable: false,23258configurable: true,23259value: function(){23260var args = Array.from(arguments),23261result;2326223263if(!self.blocked && version === self.currentVersion){23264self.block("data-push");2326523266args.forEach((arg) => {23267self.table.rowManager.addRowActual(arg, false);23268});2326923270result = self.origFuncs.push.apply(data, arguments);2327123272self.unblock("data-push");23273}2327423275return result;23276}23277});2327823279//override array unshift function23280this.origFuncs.unshift = data.unshift;2328123282Object.defineProperty(this.data, "unshift", {23283enumerable: false,23284configurable: true,23285value: function(){23286var args = Array.from(arguments),23287result;2328823289if(!self.blocked && version === self.currentVersion){23290self.block("data-unshift");2329123292args.forEach((arg) => {23293self.table.rowManager.addRowActual(arg, true);23294});2329523296result = self.origFuncs.unshift.apply(data, arguments);2329723298self.unblock("data-unshift");23299}2330023301return result;23302}23303});233042330523306//override array shift function23307this.origFuncs.shift = data.shift;2330823309Object.defineProperty(this.data, "shift", {23310enumerable: false,23311configurable: true,23312value: function(){23313var row, result;2331423315if(!self.blocked && version === self.currentVersion){23316self.block("data-shift");2331723318if(self.data.length){23319row = self.table.rowManager.getRowFromDataObject(self.data[0]);2332023321if(row){23322row.deleteActual();23323}23324}2332523326result = self.origFuncs.shift.call(data);2332723328self.unblock("data-shift");23329}2333023331return result;23332}23333});2333423335//override array pop function23336this.origFuncs.pop = data.pop;2333723338Object.defineProperty(this.data, "pop", {23339enumerable: false,23340configurable: true,23341value: function(){23342var row, result;2334323344if(!self.blocked && version === self.currentVersion){23345self.block("data-pop");2334623347if(self.data.length){23348row = self.table.rowManager.getRowFromDataObject(self.data[self.data.length - 1]);2334923350if(row){23351row.deleteActual();23352}23353}2335423355result = self.origFuncs.pop.call(data);2335623357self.unblock("data-pop");23358}2335923360return result;23361}23362});233632336423365//override array splice function23366this.origFuncs.splice = data.splice;2336723368Object.defineProperty(this.data, "splice", {23369enumerable: false,23370configurable: true,23371value: function(){23372var args = Array.from(arguments),23373start = args[0] < 0 ? data.length + args[0] : args[0],23374end = args[1],23375newRows = args[2] ? args.slice(2) : false,23376startRow, result;2337723378if(!self.blocked && version === self.currentVersion){23379self.block("data-splice");23380//add new rows23381if(newRows){23382startRow = data[start] ? self.table.rowManager.getRowFromDataObject(data[start]) : false;2338323384if(startRow){23385newRows.forEach((rowData) => {23386self.table.rowManager.addRowActual(rowData, true, startRow, true);23387});23388}else {23389newRows = newRows.slice().reverse();2339023391newRows.forEach((rowData) => {23392self.table.rowManager.addRowActual(rowData, true, false, true);23393});23394}23395}2339623397//delete removed rows23398if(end !== 0){23399var oldRows = data.slice(start, typeof args[1] === "undefined" ? args[1] : start + end);2340023401oldRows.forEach((rowData, i) => {23402var row = self.table.rowManager.getRowFromDataObject(rowData);2340323404if(row){23405row.deleteActual(i !== oldRows.length - 1);23406}23407});23408}2340923410if(newRows || end !== 0){23411self.table.rowManager.reRenderInPosition();23412}2341323414result = self.origFuncs.splice.apply(data, arguments);2341523416self.unblock("data-splice");23417}2341823419return result ;23420}23421});23422}2342323424unwatchData(){23425if(this.data !== false){23426for(var key in this.origFuncs){23427Object.defineProperty(this.data, key, {23428enumerable: true,23429configurable:true,23430writable:true,23431value: this.origFuncs.key,23432});23433}23434}23435}2343623437watchRow(row){23438var data = row.getData();2343923440for(var key in data){23441this.watchKey(row, data, key);23442}2344323444if(this.table.options.dataTree){23445this.watchTreeChildren(row);23446}23447}2344823449watchTreeChildren (row){23450var self = this,23451childField = row.getData()[this.table.options.dataTreeChildField],23452origFuncs = {};2345323454if(childField){2345523456origFuncs.push = childField.push;2345723458Object.defineProperty(childField, "push", {23459enumerable: false,23460configurable: true,23461value: () => {23462if(!self.blocked){23463self.block("tree-push");2346423465var result = origFuncs.push.apply(childField, arguments);23466this.rebuildTree(row);2346723468self.unblock("tree-push");23469}2347023471return result;23472}23473});2347423475origFuncs.unshift = childField.unshift;2347623477Object.defineProperty(childField, "unshift", {23478enumerable: false,23479configurable: true,23480value: () => {23481if(!self.blocked){23482self.block("tree-unshift");2348323484var result = origFuncs.unshift.apply(childField, arguments);23485this.rebuildTree(row);2348623487self.unblock("tree-unshift");23488}2348923490return result;23491}23492});2349323494origFuncs.shift = childField.shift;2349523496Object.defineProperty(childField, "shift", {23497enumerable: false,23498configurable: true,23499value: () => {23500if(!self.blocked){23501self.block("tree-shift");2350223503var result = origFuncs.shift.call(childField);23504this.rebuildTree(row);2350523506self.unblock("tree-shift");23507}2350823509return result;23510}23511});2351223513origFuncs.pop = childField.pop;2351423515Object.defineProperty(childField, "pop", {23516enumerable: false,23517configurable: true,23518value: () => {23519if(!self.blocked){23520self.block("tree-pop");2352123522var result = origFuncs.pop.call(childField);23523this.rebuildTree(row);2352423525self.unblock("tree-pop");23526}2352723528return result;23529}23530});2353123532origFuncs.splice = childField.splice;2353323534Object.defineProperty(childField, "splice", {23535enumerable: false,23536configurable: true,23537value: () => {23538if(!self.blocked){23539self.block("tree-splice");2354023541var result = origFuncs.splice.apply(childField, arguments);23542this.rebuildTree(row);2354323544self.unblock("tree-splice");23545}2354623547return result;23548}23549});23550}23551}2355223553rebuildTree(row){23554this.table.modules.dataTree.initializeRow(row);23555this.table.modules.dataTree.layoutRow(row);23556this.table.rowManager.refreshActiveData("tree", false, true);23557}2355823559watchKey(row, data, key){23560var self = this,23561props = Object.getOwnPropertyDescriptor(data, key),23562value = data[key],23563version = this.currentVersion;2356423565Object.defineProperty(data, key, {23566set: (newValue) => {23567value = newValue;23568if(!self.blocked && version === self.currentVersion){23569self.block("key");2357023571var update = {};23572update[key] = newValue;23573row.updateData(update);2357423575self.unblock("key");23576}2357723578if(props.set){23579props.set(newValue);23580}23581},23582get:() => {2358323584if(props.get){23585props.get();23586}2358723588return value;23589}23590});23591}2359223593unwatchRow(row){23594var data = row.getData();2359523596for(var key in data){23597Object.defineProperty(data, key, {23598value:data[key],23599});23600}23601}2360223603block(key){23604if(!this.blocked){23605this.blocked = key;23606}23607}2360823609unblock(key){23610if(this.blocked === key){23611this.blocked = false;23612}23613}23614}2361523616ReactiveData.moduleName = "reactiveData";2361723618class ResizeColumns extends Module{2361923620constructor(table){23621super(table);2362223623this.startColumn = false;23624this.startX = false;23625this.startWidth = false;23626this.latestX = false;23627this.handle = null;23628this.initialNextColumn = null;23629this.nextColumn = null;2363023631this.initialized = false;23632this.registerColumnOption("resizable", true);23633this.registerTableOption("resizableColumnFit", false);23634}2363523636initialize(){23637this.subscribe("column-rendered", this.layoutColumnHeader.bind(this));23638}2363923640initializeEventWatchers(){23641if(!this.initialized){2364223643this.subscribe("cell-rendered", this.layoutCellHandles.bind(this));23644this.subscribe("cell-delete", this.deInitializeComponent.bind(this));2364523646this.subscribe("cell-height", this.resizeHandle.bind(this));23647this.subscribe("column-moved", this.columnLayoutUpdated.bind(this));2364823649this.subscribe("column-hide", this.deInitializeColumn.bind(this));23650this.subscribe("column-show", this.columnLayoutUpdated.bind(this));23651this.subscribe("column-width", this.columnWidthUpdated.bind(this));2365223653this.subscribe("column-delete", this.deInitializeComponent.bind(this));23654this.subscribe("column-height", this.resizeHandle.bind(this));2365523656this.initialized = true;23657}23658}236592366023661layoutCellHandles(cell){23662if(cell.row.type === "row"){23663this.deInitializeComponent(cell);23664this.initializeColumn("cell", cell, cell.column, cell.element);23665}23666}2366723668layoutColumnHeader(column){23669if(column.definition.resizable){23670this.initializeEventWatchers();23671this.deInitializeComponent(column);23672this.initializeColumn("header", column, column, column.element);23673}23674}2367523676columnLayoutUpdated(column){23677var prev = column.prevColumn();2367823679this.reinitializeColumn(column);2368023681if(prev){23682this.reinitializeColumn(prev);23683}23684}2368523686columnWidthUpdated(column){23687if(column.modules.frozen){23688if(this.table.modules.frozenColumns.leftColumns.includes(column)){23689this.table.modules.frozenColumns.leftColumns.forEach((col) => {23690this.reinitializeColumn(col);23691});23692}else if(this.table.modules.frozenColumns.rightColumns.includes(column)){23693this.table.modules.frozenColumns.rightColumns.forEach((col) => {23694this.reinitializeColumn(col);23695});23696}23697}23698}2369923700frozenColumnOffset(column){23701var offset = false;2370223703if(column.modules.frozen){23704offset = column.modules.frozen.marginValue;2370523706if(column.modules.frozen.position === "left"){23707offset += column.getWidth() - 3;23708}else {23709if(offset){23710offset -= 3;23711}23712}23713}2371423715return offset !== false ? offset + "px" : false;23716}2371723718reinitializeColumn(column){23719var frozenOffset = this.frozenColumnOffset(column);2372023721column.cells.forEach((cell) => {23722if(cell.modules.resize && cell.modules.resize.handleEl){23723if(frozenOffset){23724cell.modules.resize.handleEl.style[column.modules.frozen.position] = frozenOffset;23725cell.modules.resize.handleEl.style["z-index"] = 11;23726}2372723728cell.element.after(cell.modules.resize.handleEl);23729}23730});2373123732if(column.modules.resize && column.modules.resize.handleEl){23733if(frozenOffset){23734column.modules.resize.handleEl.style[column.modules.frozen.position] = frozenOffset;23735}2373623737column.element.after(column.modules.resize.handleEl);23738}23739}2374023741initializeColumn(type, component, column, element){23742var self = this,23743variableHeight = false,23744mode = column.definition.resizable,23745config = {},23746nearestColumn = column.getLastColumn();2374723748//set column resize mode23749if(type === "header"){23750variableHeight = column.definition.formatter == "textarea" || column.definition.variableHeight;23751config = {variableHeight:variableHeight};23752}2375323754if((mode === true || mode == type) && this._checkResizability(nearestColumn)){2375523756var handle = document.createElement('span');23757handle.className = "tabulator-col-resize-handle";2375823759handle.addEventListener("click", function(e){23760e.stopPropagation();23761});2376223763var handleDown = function(e){23764self.startColumn = column;23765self.initialNextColumn = self.nextColumn = nearestColumn.nextColumn();23766self._mouseDown(e, nearestColumn, handle);23767};2376823769handle.addEventListener("mousedown", handleDown);23770handle.addEventListener("touchstart", handleDown, {passive: true});2377123772//resize column on double click23773handle.addEventListener("dblclick", (e) => {23774var oldWidth = nearestColumn.getWidth();2377523776e.stopPropagation();23777nearestColumn.reinitializeWidth(true);2377823779if(oldWidth !== nearestColumn.getWidth()){23780self.dispatch("column-resized", nearestColumn);23781self.table.externalEvents.dispatch("columnResized", nearestColumn.getComponent());23782}23783});2378423785if(column.modules.frozen){23786handle.style.position = "sticky";23787handle.style[column.modules.frozen.position] = this.frozenColumnOffset(column);23788}2378923790config.handleEl = handle;2379123792if(element.parentNode && column.visible){23793element.after(handle);23794}23795}2379623797component.modules.resize = config;23798}2379923800deInitializeColumn(column){23801this.deInitializeComponent(column);2380223803column.cells.forEach((cell) => {23804this.deInitializeComponent(cell);23805});23806}2380723808deInitializeComponent(component){23809var handleEl;2381023811if(component.modules.resize){23812handleEl = component.modules.resize.handleEl;2381323814if(handleEl && handleEl.parentElement){23815handleEl.parentElement.removeChild(handleEl);23816}23817}23818}2381923820resizeHandle(component, height){23821if(component.modules.resize && component.modules.resize.handleEl){23822component.modules.resize.handleEl.style.height = height;23823}23824}2382523826_checkResizability(column){23827return column.definition.resizable;23828}2382923830_mouseDown(e, column, handle){23831var self = this;2383223833self.table.element.classList.add("tabulator-block-select");2383423835function mouseMove(e){23836var x = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX,23837startDiff = x - self.startX,23838moveDiff = x - self.latestX,23839blockedBefore, blockedAfter;2384023841self.latestX = x;2384223843if(self.table.rtl){23844startDiff = -startDiff;23845moveDiff = -moveDiff;23846}2384723848blockedBefore = column.width == column.minWidth || column.width == column.maxWidth;2384923850column.setWidth(self.startWidth + startDiff);2385123852blockedAfter = column.width == column.minWidth || column.width == column.maxWidth;2385323854if(moveDiff < 0){23855self.nextColumn = self.initialNextColumn;23856}2385723858if(self.table.options.resizableColumnFit && self.nextColumn && !(blockedBefore && blockedAfter)){23859let colWidth = self.nextColumn.getWidth();2386023861if(moveDiff > 0){23862if(colWidth <= self.nextColumn.minWidth){23863self.nextColumn = self.nextColumn.nextColumn();23864}23865}2386623867if(self.nextColumn){23868self.nextColumn.setWidth(self.nextColumn.getWidth() - moveDiff);23869}23870}2387123872self.table.columnManager.rerenderColumns(true);2387323874if(!self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight){23875column.checkCellHeights();23876}23877}2387823879function mouseUp(e){2388023881//block editor from taking action while resizing is taking place23882if(self.startColumn.modules.edit){23883self.startColumn.modules.edit.blocked = false;23884}2388523886if(self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight){23887column.checkCellHeights();23888}2388923890document.body.removeEventListener("mouseup", mouseUp);23891document.body.removeEventListener("mousemove", mouseMove);2389223893handle.removeEventListener("touchmove", mouseMove);23894handle.removeEventListener("touchend", mouseUp);2389523896self.table.element.classList.remove("tabulator-block-select");2389723898if(self.startWidth !== column.getWidth()){23899self.table.columnManager.verticalAlignHeaders();2390023901self.dispatch("column-resized", column);23902self.table.externalEvents.dispatch("columnResized", column.getComponent());23903}23904}2390523906e.stopPropagation(); //prevent resize from interfering with movable columns2390723908//block editor from taking action while resizing is taking place23909if(self.startColumn.modules.edit){23910self.startColumn.modules.edit.blocked = true;23911}2391223913self.startX = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX;23914self.latestX = self.startX;23915self.startWidth = column.getWidth();2391623917document.body.addEventListener("mousemove", mouseMove);23918document.body.addEventListener("mouseup", mouseUp);23919handle.addEventListener("touchmove", mouseMove, {passive: true});23920handle.addEventListener("touchend", mouseUp);23921}23922}2392323924ResizeColumns.moduleName = "resizeColumns";2392523926class ResizeRows extends Module{2392723928constructor(table){23929super(table);2393023931this.startColumn = false;23932this.startY = false;23933this.startHeight = false;23934this.handle = null;23935this.prevHandle = null;2393623937this.registerTableOption("resizableRows", false); //resizable rows23938}2393923940initialize(){23941if(this.table.options.resizableRows){23942this.subscribe("row-layout-after", this.initializeRow.bind(this));23943}23944}2394523946initializeRow(row){23947var self = this,23948rowEl = row.getElement();2394923950var handle = document.createElement('div');23951handle.className = "tabulator-row-resize-handle";2395223953var prevHandle = document.createElement('div');23954prevHandle.className = "tabulator-row-resize-handle prev";2395523956handle.addEventListener("click", function(e){23957e.stopPropagation();23958});2395923960var handleDown = function(e){23961self.startRow = row;23962self._mouseDown(e, row, handle);23963};2396423965handle.addEventListener("mousedown", handleDown);23966handle.addEventListener("touchstart", handleDown, {passive: true});2396723968prevHandle.addEventListener("click", function(e){23969e.stopPropagation();23970});2397123972var prevHandleDown = function(e){23973var prevRow = self.table.rowManager.prevDisplayRow(row);2397423975if(prevRow){23976self.startRow = prevRow;23977self._mouseDown(e, prevRow, prevHandle);23978}23979};2398023981prevHandle.addEventListener("mousedown",prevHandleDown);23982prevHandle.addEventListener("touchstart",prevHandleDown, {passive: true});2398323984rowEl.appendChild(handle);23985rowEl.appendChild(prevHandle);23986}2398723988_mouseDown(e, row, handle){23989var self = this;2399023991self.table.element.classList.add("tabulator-block-select");2399223993function mouseMove(e){23994row.setHeight(self.startHeight + ((typeof e.screenY === "undefined" ? e.touches[0].screenY : e.screenY) - self.startY));23995}2399623997function mouseUp(e){2399823999// //block editor from taking action while resizing is taking place24000// if(self.startColumn.modules.edit){24001// self.startColumn.modules.edit.blocked = false;24002// }2400324004document.body.removeEventListener("mouseup", mouseMove);24005document.body.removeEventListener("mousemove", mouseMove);2400624007handle.removeEventListener("touchmove", mouseMove);24008handle.removeEventListener("touchend", mouseUp);2400924010self.table.element.classList.remove("tabulator-block-select");2401124012self.dispatchExternal("rowResized", row.getComponent());24013}2401424015e.stopPropagation(); //prevent resize from interfering with movable columns2401624017//block editor from taking action while resizing is taking place24018// if(self.startColumn.modules.edit){24019// self.startColumn.modules.edit.blocked = true;24020// }2402124022self.startY = typeof e.screenY === "undefined" ? e.touches[0].screenY : e.screenY;24023self.startHeight = row.getHeight();2402424025document.body.addEventListener("mousemove", mouseMove);24026document.body.addEventListener("mouseup", mouseUp);2402724028handle.addEventListener("touchmove", mouseMove, {passive: true});24029handle.addEventListener("touchend", mouseUp);24030}24031}2403224033ResizeRows.moduleName = "resizeRows";2403424035class ResizeTable extends Module{2403624037constructor(table){24038super(table);2403924040this.binding = false;24041this.visibilityObserver = false;24042this.resizeObserver = false;24043this.containerObserver = false;2404424045this.tableHeight = 0;24046this.tableWidth = 0;24047this.containerHeight = 0;24048this.containerWidth = 0;2404924050this.autoResize = false;2405124052this.visible = false;2405324054this.initialized = false;24055this.initialRedraw = false;2405624057this.registerTableOption("autoResize", true); //auto resize table24058}2405924060initialize(){24061if(this.table.options.autoResize){24062var table = this.table,24063tableStyle;2406424065this.tableHeight = table.element.clientHeight;24066this.tableWidth = table.element.clientWidth;2406724068if(table.element.parentNode){24069this.containerHeight = table.element.parentNode.clientHeight;24070this.containerWidth = table.element.parentNode.clientWidth;24071}2407224073if(typeof IntersectionObserver !== "undefined" && typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual"){2407424075this.initializeVisibilityObserver();2407624077this.autoResize = true;2407824079this.resizeObserver = new ResizeObserver((entry) => {24080if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){2408124082var nodeHeight = Math.floor(entry[0].contentRect.height);24083var nodeWidth = Math.floor(entry[0].contentRect.width);2408424085if(this.tableHeight != nodeHeight || this.tableWidth != nodeWidth){24086this.tableHeight = nodeHeight;24087this.tableWidth = nodeWidth;2408824089if(table.element.parentNode){24090this.containerHeight = table.element.parentNode.clientHeight;24091this.containerWidth = table.element.parentNode.clientWidth;24092}2409324094this.redrawTable();24095}24096}24097});2409824099this.resizeObserver.observe(table.element);2410024101tableStyle = window.getComputedStyle(table.element);2410224103if(this.table.element.parentNode && !this.table.rowManager.fixedHeight && (tableStyle.getPropertyValue("max-height") || tableStyle.getPropertyValue("min-height"))){2410424105this.containerObserver = new ResizeObserver((entry) => {24106if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){2410724108var nodeHeight = Math.floor(entry[0].contentRect.height);24109var nodeWidth = Math.floor(entry[0].contentRect.width);2411024111if(this.containerHeight != nodeHeight || this.containerWidth != nodeWidth){24112this.containerHeight = nodeHeight;24113this.containerWidth = nodeWidth;24114this.tableHeight = table.element.clientHeight;24115this.tableWidth = table.element.clientWidth;24116}2411724118this.redrawTable();24119}24120});2412124122this.containerObserver.observe(this.table.element.parentNode);24123}2412424125this.subscribe("table-resize", this.tableResized.bind(this));2412624127}else {24128this.binding = function(){24129if(!table.browserMobile || (table.browserMobile && !table.modules.edit.currentCell)){24130table.columnManager.rerenderColumns(true);24131table.redraw();24132}24133};2413424135window.addEventListener("resize", this.binding);24136}2413724138this.subscribe("table-destroy", this.clearBindings.bind(this));24139}24140}2414124142initializeVisibilityObserver(){24143this.visibilityObserver = new IntersectionObserver((entries) => {24144this.visible = entries[0].isIntersecting;2414524146if(!this.initialized){24147this.initialized = true;24148this.initialRedraw = !this.visible;24149}else {24150if(this.visible){24151this.redrawTable(this.initialRedraw);24152this.initialRedraw = false;24153}24154}24155});2415624157this.visibilityObserver.observe(this.table.element);24158}2415924160redrawTable(force){24161if(this.initialized && this.visible){24162this.table.columnManager.rerenderColumns(true);24163this.table.redraw(force);24164}24165}2416624167tableResized(){24168this.table.rowManager.redraw();24169}2417024171clearBindings(){24172if(this.binding){24173window.removeEventListener("resize", this.binding);24174}2417524176if(this.resizeObserver){24177this.resizeObserver.unobserve(this.table.element);24178}2417924180if(this.visibilityObserver){24181this.visibilityObserver.unobserve(this.table.element);24182}2418324184if(this.containerObserver){24185this.containerObserver.unobserve(this.table.element.parentNode);24186}24187}24188}2418924190ResizeTable.moduleName = "resizeTable";2419124192class ResponsiveLayout extends Module{2419324194constructor(table){24195super(table);2419624197this.columns = [];24198this.hiddenColumns = [];24199this.mode = "";24200this.index = 0;24201this.collapseFormatter = [];24202this.collapseStartOpen = true;24203this.collapseHandleColumn = false;2420424205this.registerTableOption("responsiveLayout", false); //responsive layout flags24206this.registerTableOption("responsiveLayoutCollapseStartOpen", true); //start showing collapsed data24207this.registerTableOption("responsiveLayoutCollapseUseFormatters", true); //responsive layout collapse formatter24208this.registerTableOption("responsiveLayoutCollapseFormatter", false); //responsive layout collapse formatter2420924210this.registerColumnOption("responsive");24211}2421224213//generate responsive columns list24214initialize(){24215if(this.table.options.responsiveLayout){24216this.subscribe("column-layout", this.initializeColumn.bind(this));24217this.subscribe("column-show", this.updateColumnVisibility.bind(this));24218this.subscribe("column-hide", this.updateColumnVisibility.bind(this));24219this.subscribe("columns-loaded", this.initializeResponsivity.bind(this));24220this.subscribe("column-moved", this.initializeResponsivity.bind(this));24221this.subscribe("column-add", this.initializeResponsivity.bind(this));24222this.subscribe("column-delete", this.initializeResponsivity.bind(this));2422324224this.subscribe("table-redrawing", this.tableRedraw.bind(this));2422524226if(this.table.options.responsiveLayout === "collapse"){24227this.subscribe("row-data-changed", this.generateCollapsedRowContent.bind(this));24228this.subscribe("row-init", this.initializeRow.bind(this));24229this.subscribe("row-layout", this.layoutRow.bind(this));24230}24231}24232}2423324234tableRedraw(force){24235if(["fitColumns", "fitDataStretch"].indexOf(this.layoutMode()) === -1){24236if(!force){24237this.update();24238}24239}24240}2424124242initializeResponsivity(){24243var columns = [];2424424245this.mode = this.table.options.responsiveLayout;24246this.collapseFormatter = this.table.options.responsiveLayoutCollapseFormatter || this.formatCollapsedData;24247this.collapseStartOpen = this.table.options.responsiveLayoutCollapseStartOpen;24248this.hiddenColumns = [];2424924250//determine level of responsivity for each column24251this.table.columnManager.columnsByIndex.forEach((column, i) => {24252if(column.modules.responsive){24253if(column.modules.responsive.order && column.modules.responsive.visible){24254column.modules.responsive.index = i;24255columns.push(column);2425624257if(!column.visible && this.mode === "collapse"){24258this.hiddenColumns.push(column);24259}24260}24261}24262});2426324264//sort list by responsivity24265columns = columns.reverse();24266columns = columns.sort((a, b) => {24267var diff = b.modules.responsive.order - a.modules.responsive.order;24268return diff || (b.modules.responsive.index - a.modules.responsive.index);24269});2427024271this.columns = columns;2427224273if(this.mode === "collapse"){24274this.generateCollapsedContent();24275}2427624277//assign collapse column24278for (let col of this.table.columnManager.columnsByIndex){24279if(col.definition.formatter == "responsiveCollapse"){24280this.collapseHandleColumn = col;24281break;24282}24283}2428424285if(this.collapseHandleColumn){24286if(this.hiddenColumns.length){24287this.collapseHandleColumn.show();24288}else {24289this.collapseHandleColumn.hide();24290}24291}24292}2429324294//define layout information24295initializeColumn(column){24296var def = column.getDefinition();2429724298column.modules.responsive = {order: typeof def.responsive === "undefined" ? 1 : def.responsive, visible:def.visible === false ? false : true};24299}2430024301initializeRow(row){24302var el;2430324304if(row.type !== "calc"){24305el = document.createElement("div");24306el.classList.add("tabulator-responsive-collapse");2430724308row.modules.responsiveLayout = {24309element:el,24310open:this.collapseStartOpen,24311};2431224313if(!this.collapseStartOpen){24314el.style.display = 'none';24315}24316}24317}2431824319layoutRow(row){24320var rowEl = row.getElement();2432124322if(row.modules.responsiveLayout){24323rowEl.appendChild(row.modules.responsiveLayout.element);24324this.generateCollapsedRowContent(row);24325}24326}2432724328//update column visibility24329updateColumnVisibility(column, responsiveToggle){24330if(!responsiveToggle && column.modules.responsive){24331column.modules.responsive.visible = column.visible;24332this.initializeResponsivity();24333}24334}2433524336hideColumn(column){24337var colCount = this.hiddenColumns.length;2433824339column.hide(false, true);2434024341if(this.mode === "collapse"){24342this.hiddenColumns.unshift(column);24343this.generateCollapsedContent();2434424345if(this.collapseHandleColumn && !colCount){24346this.collapseHandleColumn.show();24347}24348}24349}2435024351showColumn(column){24352var index;2435324354column.show(false, true);24355//set column width to prevent calculation loops on uninitialized columns24356column.setWidth(column.getWidth());2435724358if(this.mode === "collapse"){24359index = this.hiddenColumns.indexOf(column);2436024361if(index > -1){24362this.hiddenColumns.splice(index, 1);24363}2436424365this.generateCollapsedContent();2436624367if(this.collapseHandleColumn && !this.hiddenColumns.length){24368this.collapseHandleColumn.hide();24369}24370}24371}2437224373//redraw columns to fit space24374update(){24375var working = true;2437624377while(working){2437824379let width = this.table.modules.layout.getMode() == "fitColumns" ? this.table.columnManager.getFlexBaseWidth() : this.table.columnManager.getWidth();2438024381let diff = (this.table.options.headerVisible ? this.table.columnManager.element.clientWidth : this.table.element.clientWidth) - width;2438224383if(diff < 0){24384//table is too wide24385let column = this.columns[this.index];2438624387if(column){24388this.hideColumn(column);24389this.index ++;24390}else {24391working = false;24392}2439324394}else {2439524396//table has spare space24397let column = this.columns[this.index -1];2439824399if(column){24400if(diff > 0){24401if(diff >= column.getWidth()){24402this.showColumn(column);24403this.index --;24404}else {24405working = false;24406}24407}else {24408working = false;24409}24410}else {24411working = false;24412}24413}2441424415if(!this.table.rowManager.activeRowsCount){24416this.table.rowManager.renderEmptyScroll();24417}24418}24419}2442024421generateCollapsedContent(){24422var rows = this.table.rowManager.getDisplayRows();2442324424rows.forEach((row) => {24425this.generateCollapsedRowContent(row);24426});24427}2442824429generateCollapsedRowContent(row){24430var el, contents;2443124432if(row.modules.responsiveLayout){24433el = row.modules.responsiveLayout.element;2443424435while(el.firstChild) el.removeChild(el.firstChild);2443624437contents = this.collapseFormatter(this.generateCollapsedRowData(row));24438if(contents){24439el.appendChild(contents);24440}24441}24442}2444324444generateCollapsedRowData(row){24445var data = row.getData(),24446output = [],24447mockCellComponent;2444824449this.hiddenColumns.forEach((column) => {24450var value = column.getFieldValue(data);2445124452if(column.definition.title && column.field){24453if(column.modules.format && this.table.options.responsiveLayoutCollapseUseFormatters){2445424455mockCellComponent = {24456value:false,24457data:{},24458getValue:function(){24459return value;24460},24461getData:function(){24462return data;24463},24464getType:function(){24465return "cell";24466},24467getElement:function(){24468return document.createElement("div");24469},24470getRow:function(){24471return row.getComponent();24472},24473getColumn:function(){24474return column.getComponent();24475},24476getTable:() => {24477return this.table;24478},24479};2448024481function onRendered(callback){24482callback();24483}2448424485output.push({24486field: column.field,24487title: column.definition.title,24488value: column.modules.format.formatter.call(this.table.modules.format, mockCellComponent, column.modules.format.params, onRendered)24489});24490}else {24491output.push({24492field: column.field,24493title: column.definition.title,24494value: value24495});24496}24497}24498});2449924500return output;24501}2450224503formatCollapsedData(data){24504var list = document.createElement("table");2450524506data.forEach(function(item){24507var row = document.createElement("tr");24508var titleData = document.createElement("td");24509var valueData = document.createElement("td");24510var node_content;2451124512var titleHighlight = document.createElement("strong");24513titleData.appendChild(titleHighlight);24514this.langBind("columns|" + item.field, function(text){24515titleHighlight.innerHTML = text || item.title;24516});2451724518if(item.value instanceof Node){24519node_content = document.createElement("div");24520node_content.appendChild(item.value);24521valueData.appendChild(node_content);24522}else {24523valueData.innerHTML = item.value;24524}2452524526row.appendChild(titleData);24527row.appendChild(valueData);24528list.appendChild(row);24529}, this);2453024531return Object.keys(data).length ? list : "";24532}24533}2453424535ResponsiveLayout.moduleName = "responsiveLayout";2453624537class SelectRow extends Module{2453824539constructor(table){24540super(table);2454124542this.selecting = false; //flag selecting in progress24543this.lastClickedRow = false; //last clicked row24544this.selectPrev = []; //hold previously selected element for drag drop selection24545this.selectedRows = []; //hold selected rows24546this.headerCheckboxElement = null; // hold header select element2454724548this.registerTableOption("selectable", "highlight"); //highlight rows on hover24549this.registerTableOption("selectableRangeMode", "drag"); //highlight rows on hover24550this.registerTableOption("selectableRollingSelection", true); //roll selection once maximum number of selectable rows is reached24551this.registerTableOption("selectablePersistence", true); // maintain selection when table view is updated24552this.registerTableOption("selectableCheck", function(data, row){return true;}); //check whether row is selectable2455324554this.registerTableFunction("selectRow", this.selectRows.bind(this));24555this.registerTableFunction("deselectRow", this.deselectRows.bind(this));24556this.registerTableFunction("toggleSelectRow", this.toggleRow.bind(this));24557this.registerTableFunction("getSelectedRows", this.getSelectedRows.bind(this));24558this.registerTableFunction("getSelectedData", this.getSelectedData.bind(this));2455924560//register component functions24561this.registerComponentFunction("row", "select", this.selectRows.bind(this));24562this.registerComponentFunction("row", "deselect", this.deselectRows.bind(this));24563this.registerComponentFunction("row", "toggleSelect", this.toggleRow.bind(this));24564this.registerComponentFunction("row", "isSelected", this.isRowSelected.bind(this));24565}2456624567initialize(){24568if(this.table.options.selectable !== false){24569this.subscribe("row-init", this.initializeRow.bind(this));24570this.subscribe("row-deleting", this.rowDeleted.bind(this));24571this.subscribe("rows-wipe", this.clearSelectionData.bind(this));24572this.subscribe("rows-retrieve", this.rowRetrieve.bind(this));2457324574if(this.table.options.selectable && !this.table.options.selectablePersistence){24575this.subscribe("data-refreshing", this.deselectRows.bind(this));24576}24577}24578}2457924580rowRetrieve(type, prevValue){24581return type === "selected" ? this.selectedRows : prevValue;24582}2458324584rowDeleted(row){24585this._deselectRow(row, true);24586}2458724588clearSelectionData(silent){24589var prevSelected = this.selectedRows.length;2459024591this.selecting = false;24592this.lastClickedRow = false;24593this.selectPrev = [];24594this.selectedRows = [];2459524596if(prevSelected && silent !== true){24597this._rowSelectionChanged();24598}24599}2460024601initializeRow(row){24602var self = this,24603element = row.getElement();2460424605// trigger end of row selection24606var endSelect = function(){2460724608setTimeout(function(){24609self.selecting = false;24610}, 50);2461124612document.body.removeEventListener("mouseup", endSelect);24613};2461424615row.modules.select = {selected:false};2461624617//set row selection class24618if(self.checkRowSelectability(row)){24619element.classList.add("tabulator-selectable");24620element.classList.remove("tabulator-unselectable");2462124622if(self.table.options.selectable && self.table.options.selectable != "highlight"){24623if(self.table.options.selectableRangeMode === "click"){24624element.addEventListener("click", this.handleComplexRowClick.bind(this, row));24625}else {24626element.addEventListener("click", function(e){24627if(!self.table.modExists("edit") || !self.table.modules.edit.getCurrentCell()){24628self.table._clearSelection();24629}2463024631if(!self.selecting){24632self.toggleRow(row);24633}24634});2463524636element.addEventListener("mousedown", function(e){24637if(e.shiftKey){24638self.table._clearSelection();2463924640self.selecting = true;2464124642self.selectPrev = [];2464324644document.body.addEventListener("mouseup", endSelect);24645document.body.addEventListener("keyup", endSelect);2464624647self.toggleRow(row);2464824649return false;24650}24651});2465224653element.addEventListener("mouseenter", function(e){24654if(self.selecting){24655self.table._clearSelection();24656self.toggleRow(row);2465724658if(self.selectPrev[1] == row){24659self.toggleRow(self.selectPrev[0]);24660}24661}24662});2466324664element.addEventListener("mouseout", function(e){24665if(self.selecting){24666self.table._clearSelection();24667self.selectPrev.unshift(row);24668}24669});24670}24671}2467224673}else {24674element.classList.add("tabulator-unselectable");24675element.classList.remove("tabulator-selectable");24676}24677}2467824679handleComplexRowClick(row, e){24680if(e.shiftKey){24681this.table._clearSelection();24682this.lastClickedRow = this.lastClickedRow || row;2468324684var lastClickedRowIdx = this.table.rowManager.getDisplayRowIndex(this.lastClickedRow);24685var rowIdx = this.table.rowManager.getDisplayRowIndex(row);2468624687var fromRowIdx = lastClickedRowIdx <= rowIdx ? lastClickedRowIdx : rowIdx;24688var toRowIdx = lastClickedRowIdx >= rowIdx ? lastClickedRowIdx : rowIdx;2468924690var rows = this.table.rowManager.getDisplayRows().slice(0);24691var toggledRows = rows.splice(fromRowIdx, toRowIdx - fromRowIdx + 1);2469224693if(e.ctrlKey || e.metaKey){24694toggledRows.forEach((toggledRow)=>{24695if(toggledRow !== this.lastClickedRow){2469624697if(this.table.options.selectable !== true && !this.isRowSelected(row)){24698if(this.selectedRows.length < this.table.options.selectable){24699this.toggleRow(toggledRow);24700}24701}else {24702this.toggleRow(toggledRow);24703}24704}24705});24706this.lastClickedRow = row;24707}else {24708this.deselectRows(undefined, true);2470924710if(this.table.options.selectable !== true){24711if(toggledRows.length > this.table.options.selectable){24712toggledRows = toggledRows.slice(0, this.table.options.selectable);24713}24714}2471524716this.selectRows(toggledRows);24717}24718this.table._clearSelection();24719}24720else if(e.ctrlKey || e.metaKey){24721this.toggleRow(row);24722this.lastClickedRow = row;24723}else {24724this.deselectRows(undefined, true);24725this.selectRows(row);24726this.lastClickedRow = row;24727}24728}2472924730checkRowSelectability(row){24731if(row && row.type === "row"){24732return this.table.options.selectableCheck.call(this.table, row.getComponent());24733}2473424735return false;24736}2473724738//toggle row selection24739toggleRow(row){24740if(this.checkRowSelectability(row)){24741if(row.modules.select && row.modules.select.selected){24742this._deselectRow(row);24743}else {24744this._selectRow(row);24745}24746}24747}2474824749//select a number of rows24750selectRows(rows){24751var changes = [],24752rowMatch, change;2475324754switch(typeof rows){24755case "undefined":24756rowMatch = this.table.rowManager.rows;24757break;2475824759case "string":24760rowMatch = this.table.rowManager.findRow(rows);2476124762if(!rowMatch){24763rowMatch = this.table.rowManager.getRows(rows);24764}24765break;2476624767default:24768rowMatch = rows;24769break;24770}2477124772if(Array.isArray(rowMatch)){24773if(rowMatch.length){24774rowMatch.forEach((row) => {24775change = this._selectRow(row, true, true);2477624777if(change){24778changes.push(change);24779}24780});2478124782this._rowSelectionChanged(false, changes);24783}24784}else {24785if(rowMatch){24786this._selectRow(rowMatch, false, true);24787}24788}24789}2479024791//select an individual row24792_selectRow(rowInfo, silent, force){24793//handle max row count24794if(!isNaN(this.table.options.selectable) && this.table.options.selectable !== true && !force){24795if(this.selectedRows.length >= this.table.options.selectable){24796if(this.table.options.selectableRollingSelection){24797this._deselectRow(this.selectedRows[0]);24798}else {24799return false;24800}24801}24802}2480324804var row = this.table.rowManager.findRow(rowInfo);2480524806if(row){24807if(this.selectedRows.indexOf(row) == -1){24808row.getElement().classList.add("tabulator-selected");24809if(!row.modules.select){24810row.modules.select = {};24811}2481224813row.modules.select.selected = true;24814if(row.modules.select.checkboxEl){24815row.modules.select.checkboxEl.checked = true;24816}2481724818this.selectedRows.push(row);2481924820if(this.table.options.dataTreeSelectPropagate){24821this.childRowSelection(row, true);24822}2482324824this.dispatchExternal("rowSelected", row.getComponent());2482524826this._rowSelectionChanged(silent, row);2482724828return row;24829}24830}else {24831if(!silent){24832console.warn("Selection Error - No such row found, ignoring selection:" + rowInfo);24833}24834}24835}2483624837isRowSelected(row){24838return this.selectedRows.indexOf(row) !== -1;24839}2484024841//deselect a number of rows24842deselectRows(rows, silent){24843var changes = [],24844rowMatch, change;2484524846switch(typeof rows){24847case "undefined":24848rowMatch = Object.assign([], this.selectedRows);24849break;2485024851case "string":24852rowMatch = this.table.rowManager.findRow(rows);2485324854if(!rowMatch){24855rowMatch = this.table.rowManager.getRows(rows);24856}24857break;2485824859default:24860rowMatch = rows;24861break;24862}2486324864if(Array.isArray(rowMatch)){24865if(rowMatch.length){24866rowMatch.forEach((row) => {24867change = this._deselectRow(row, true, true);2486824869if(change){24870changes.push(change);24871}24872});2487324874this._rowSelectionChanged(silent, [], changes);24875}24876}else {24877if(rowMatch){24878this._deselectRow(rowMatch, silent, true);24879}24880}24881}2488224883//deselect an individual row24884_deselectRow(rowInfo, silent){24885var self = this,24886row = self.table.rowManager.findRow(rowInfo),24887index, element;2488824889if(row){24890index = self.selectedRows.findIndex(function(selectedRow){24891return selectedRow == row;24892});2489324894if(index > -1){2489524896element = row.getElement();2489724898if(element){24899element.classList.remove("tabulator-selected");24900}2490124902if(!row.modules.select){24903row.modules.select = {};24904}2490524906row.modules.select.selected = false;24907if(row.modules.select.checkboxEl){24908row.modules.select.checkboxEl.checked = false;24909}24910self.selectedRows.splice(index, 1);2491124912if(this.table.options.dataTreeSelectPropagate){24913this.childRowSelection(row, false);24914}2491524916this.dispatchExternal("rowDeselected", row.getComponent());2491724918self._rowSelectionChanged(silent, undefined, row);2491924920return row;24921}24922}else {24923if(!silent){24924console.warn("Deselection Error - No such row found, ignoring selection:" + rowInfo);24925}24926}24927}2492824929getSelectedData(){24930var data = [];2493124932this.selectedRows.forEach(function(row){24933data.push(row.getData());24934});2493524936return data;24937}2493824939getSelectedRows(){24940var rows = [];2494124942this.selectedRows.forEach(function(row){24943rows.push(row.getComponent());24944});2494524946return rows;24947}2494824949_rowSelectionChanged(silent, selected = [], deselected = []){24950if(this.headerCheckboxElement){24951if(this.selectedRows.length === 0){24952this.headerCheckboxElement.checked = false;24953this.headerCheckboxElement.indeterminate = false;24954} else if(this.table.rowManager.rows.length === this.selectedRows.length){24955this.headerCheckboxElement.checked = true;24956this.headerCheckboxElement.indeterminate = false;24957} else {24958this.headerCheckboxElement.indeterminate = true;24959this.headerCheckboxElement.checked = false;24960}24961}2496224963if(!silent){24964if(!Array.isArray(selected)){24965selected = [selected];24966}2496724968selected = selected.map(row => row.getComponent());2496924970if(!Array.isArray(deselected)){24971deselected = [deselected];24972}2497324974deselected = deselected.map(row => row.getComponent());2497524976this.dispatchExternal("rowSelectionChanged", this.getSelectedData(), this.getSelectedRows(), selected, deselected);24977}24978}2497924980registerRowSelectCheckbox (row, element) {24981if(!row._row.modules.select){24982row._row.modules.select = {};24983}2498424985row._row.modules.select.checkboxEl = element;24986}2498724988registerHeaderSelectCheckbox (element) {24989this.headerCheckboxElement = element;24990}2499124992childRowSelection(row, select){24993var children = this.table.modules.dataTree.getChildren(row, true);2499424995if(select){24996for(let child of children){24997this._selectRow(child, true);24998}24999}else {25000for(let child of children){25001this._deselectRow(child, true);25002}25003}25004}25005}2500625007SelectRow.moduleName = "selectRow";2500825009//sort numbers25010function number$1(a, b, aRow, bRow, column, dir, params){25011var alignEmptyValues = params.alignEmptyValues;25012var decimal = params.decimalSeparator;25013var thousand = params.thousandSeparator;25014var emptyAlign = 0;2501525016a = String(a);25017b = String(b);2501825019if(thousand){25020a = a.split(thousand).join("");25021b = b.split(thousand).join("");25022}2502325024if(decimal){25025a = a.split(decimal).join(".");25026b = b.split(decimal).join(".");25027}2502825029a = parseFloat(a);25030b = parseFloat(b);2503125032//handle non numeric values25033if(isNaN(a)){25034emptyAlign = isNaN(b) ? 0 : -1;25035}else if(isNaN(b)){25036emptyAlign = 1;25037}else {25038//compare valid values25039return a - b;25040}2504125042//fix empty values in position25043if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){25044emptyAlign *= -1;25045}2504625047return emptyAlign;25048}2504925050//sort strings25051function string(a, b, aRow, bRow, column, dir, params){25052var alignEmptyValues = params.alignEmptyValues;25053var emptyAlign = 0;25054var locale;2505525056//handle empty values25057if(!a){25058emptyAlign = !b ? 0 : -1;25059}else if(!b){25060emptyAlign = 1;25061}else {25062//compare valid values25063switch(typeof params.locale){25064case "boolean":25065if(params.locale){25066locale = this.langLocale();25067}25068break;25069case "string":25070locale = params.locale;25071break;25072}2507325074return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);25075}2507625077//fix empty values in position25078if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){25079emptyAlign *= -1;25080}2508125082return emptyAlign;25083}2508425085//sort datetime25086function datetime$2(a, b, aRow, bRow, column, dir, params){25087var DT = window.DateTime || luxon.DateTime;25088var format = params.format || "dd/MM/yyyy HH:mm:ss",25089alignEmptyValues = params.alignEmptyValues,25090emptyAlign = 0;2509125092if(typeof DT != "undefined"){25093if(!DT.isDateTime(a)){25094if(format === "iso"){25095a = DT.fromISO(String(a));25096}else {25097a = DT.fromFormat(String(a), format);25098}25099}2510025101if(!DT.isDateTime(b)){25102if(format === "iso"){25103b = DT.fromISO(String(b));25104}else {25105b = DT.fromFormat(String(b), format);25106}25107}2510825109if(!a.isValid){25110emptyAlign = !b.isValid ? 0 : -1;25111}else if(!b.isValid){25112emptyAlign = 1;25113}else {25114//compare valid values25115return a - b;25116}2511725118//fix empty values in position25119if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){25120emptyAlign *= -1;25121}2512225123return emptyAlign;2512425125}else {25126console.error("Sort Error - 'datetime' sorter is dependant on luxon.js");25127}25128}2512925130//sort date25131function date$1(a, b, aRow, bRow, column, dir, params){25132if(!params.format){25133params.format = "dd/MM/yyyy";25134}2513525136return datetime$2.call(this, a, b, aRow, bRow, column, dir, params);25137}2513825139//sort times25140function time$1(a, b, aRow, bRow, column, dir, params){25141if(!params.format){25142params.format = "HH:mm";25143}2514425145return datetime$2.call(this, a, b, aRow, bRow, column, dir, params);25146}2514725148//sort booleans25149function boolean(a, b, aRow, bRow, column, dir, params){25150var el1 = a === true || a === "true" || a === "True" || a === 1 ? 1 : 0;25151var el2 = b === true || b === "true" || b === "True" || b === 1 ? 1 : 0;2515225153return el1 - el2;25154}2515525156//sort if element contains any data25157function array(a, b, aRow, bRow, column, dir, params){25158var type = params.type || "length",25159alignEmptyValues = params.alignEmptyValues,25160emptyAlign = 0;2516125162function calc(value){25163var result;2516425165switch(type){25166case "length":25167result = value.length;25168break;2516925170case "sum":25171result = value.reduce(function(c, d){25172return c + d;25173});25174break;2517525176case "max":25177result = Math.max.apply(null, value) ;25178break;2517925180case "min":25181result = Math.min.apply(null, value) ;25182break;2518325184case "avg":25185result = value.reduce(function(c, d){25186return c + d;25187}) / value.length;25188break;25189}2519025191return result;25192}2519325194//handle non array values25195if(!Array.isArray(a)){25196emptyAlign = !Array.isArray(b) ? 0 : -1;25197}else if(!Array.isArray(b)){25198emptyAlign = 1;25199}else {25200return calc(b) - calc(a);25201}2520225203//fix empty values in position25204if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){25205emptyAlign *= -1;25206}2520725208return emptyAlign;25209}2521025211//sort if element contains any data25212function exists(a, b, aRow, bRow, column, dir, params){25213var el1 = typeof a == "undefined" ? 0 : 1;25214var el2 = typeof b == "undefined" ? 0 : 1;2521525216return el1 - el2;25217}2521825219//sort alpha numeric strings25220function alphanum(as, bs, aRow, bRow, column, dir, params){25221var a, b, a1, b1, i= 0, L, rx = /(\d+)|(\D+)/g, rd = /\d/;25222var alignEmptyValues = params.alignEmptyValues;25223var emptyAlign = 0;2522425225//handle empty values25226if(!as && as!== 0){25227emptyAlign = !bs && bs!== 0 ? 0 : -1;25228}else if(!bs && bs!== 0){25229emptyAlign = 1;25230}else {2523125232if(isFinite(as) && isFinite(bs)) return as - bs;25233a = String(as).toLowerCase();25234b = String(bs).toLowerCase();25235if(a === b) return 0;25236if(!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;25237a = a.match(rx);25238b = b.match(rx);25239L = a.length > b.length ? b.length : a.length;25240while(i < L){25241a1= a[i];25242b1= b[i++];25243if(a1 !== b1){25244if(isFinite(a1) && isFinite(b1)){25245if(a1.charAt(0) === "0") a1 = "." + a1;25246if(b1.charAt(0) === "0") b1 = "." + b1;25247return a1 - b1;25248}25249else return a1 > b1 ? 1 : -1;25250}25251}2525225253return a.length > b.length;25254}2525525256//fix empty values in position25257if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){25258emptyAlign *= -1;25259}2526025261return emptyAlign;25262}2526325264var defaultSorters = {25265number:number$1,25266string:string,25267date:date$1,25268time:time$1,25269datetime:datetime$2,25270boolean:boolean,25271array:array,25272exists:exists,25273alphanum:alphanum25274};2527525276class Sort extends Module{2527725278constructor(table){25279super(table);2528025281this.sortList = []; //holder current sort25282this.changed = false; //has the sort changed since last render2528325284this.registerTableOption("sortMode", "local"); //local or remote sorting2528525286this.registerTableOption("initialSort", false); //initial sorting criteria25287this.registerTableOption("columnHeaderSortMulti", true); //multiple or single column sorting25288this.registerTableOption("sortOrderReverse", false); //reverse internal sort ordering25289this.registerTableOption("headerSortElement", "<div class='tabulator-arrow'></div>"); //header sort element25290this.registerTableOption("headerSortClickElement", "header"); //element which triggers sort when clicked2529125292this.registerColumnOption("sorter");25293this.registerColumnOption("sorterParams");2529425295this.registerColumnOption("headerSort", true);25296this.registerColumnOption("headerSortStartingDir");25297this.registerColumnOption("headerSortTristate");2529825299}2530025301initialize(){25302this.subscribe("column-layout", this.initializeColumn.bind(this));25303this.subscribe("table-built", this.tableBuilt.bind(this));25304this.registerDataHandler(this.sort.bind(this), 20);2530525306this.registerTableFunction("setSort", this.userSetSort.bind(this));25307this.registerTableFunction("getSorters", this.getSort.bind(this));25308this.registerTableFunction("clearSort", this.clearSort.bind(this));2530925310if(this.table.options.sortMode === "remote"){25311this.subscribe("data-params", this.remoteSortParams.bind(this));25312}25313}2531425315tableBuilt(){25316if(this.table.options.initialSort){25317this.setSort(this.table.options.initialSort);25318}25319}2532025321remoteSortParams(data, config, silent, params){25322var sorters = this.getSort();2532325324sorters.forEach((item) => {25325delete item.column;25326});2532725328params.sort = sorters;2532925330return params;25331}253322533325334///////////////////////////////////25335///////// Table Functions /////////25336///////////////////////////////////2533725338userSetSort(sortList, dir){25339this.setSort(sortList, dir);25340// this.table.rowManager.sorterRefresh();25341this.refreshSort();25342}2534325344clearSort(){25345this.clear();25346// this.table.rowManager.sorterRefresh();25347this.refreshSort();25348}253492535025351///////////////////////////////////25352///////// Internal Logic //////////25353///////////////////////////////////2535425355//initialize column header for sorting25356initializeColumn(column){25357var sorter = false,25358colEl,25359arrowEl;2536025361switch(typeof column.definition.sorter){25362case "string":25363if(Sort.sorters[column.definition.sorter]){25364sorter = Sort.sorters[column.definition.sorter];25365}else {25366console.warn("Sort Error - No such sorter found: ", column.definition.sorter);25367}25368break;2536925370case "function":25371sorter = column.definition.sorter;25372break;25373}2537425375column.modules.sort = {25376sorter:sorter, dir:"none",25377params:column.definition.sorterParams || {},25378startingDir:column.definition.headerSortStartingDir || "asc",25379tristate: column.definition.headerSortTristate,25380};2538125382if(column.definition.headerSort !== false){2538325384colEl = column.getElement();2538525386colEl.classList.add("tabulator-sortable");2538725388arrowEl = document.createElement("div");25389arrowEl.classList.add("tabulator-col-sorter");2539025391switch(this.table.options.headerSortClickElement){25392case "icon":25393arrowEl.classList.add("tabulator-col-sorter-element");25394break;25395case "header":25396colEl.classList.add("tabulator-col-sorter-element");25397break;25398default:25399colEl.classList.add("tabulator-col-sorter-element");25400break;25401}2540225403switch(this.table.options.headerSortElement){25404case "function":25405//do nothing25406break;2540725408case "object":25409arrowEl.appendChild(this.table.options.headerSortElement);25410break;2541125412default:25413arrowEl.innerHTML = this.table.options.headerSortElement;25414}2541525416//create sorter arrow25417column.titleHolderElement.appendChild(arrowEl);2541825419column.modules.sort.element = arrowEl;2542025421this.setColumnHeaderSortIcon(column, "none");2542225423//sort on click25424(this.table.options.headerSortClickElement === "icon" ? arrowEl : colEl).addEventListener("click", (e) => {25425var dir = "",25426sorters=[],25427match = false;2542825429if(column.modules.sort){25430if(column.modules.sort.tristate){25431if(column.modules.sort.dir == "none"){25432dir = column.modules.sort.startingDir;25433}else {25434if(column.modules.sort.dir == column.modules.sort.startingDir){25435dir = column.modules.sort.dir == "asc" ? "desc" : "asc";25436}else {25437dir = "none";25438}25439}25440}else {25441switch(column.modules.sort.dir){25442case "asc":25443dir = "desc";25444break;2544525446case "desc":25447dir = "asc";25448break;2544925450default:25451dir = column.modules.sort.startingDir;25452}25453}2545425455if (this.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {25456sorters = this.getSort();2545725458match = sorters.findIndex((sorter) => {25459return sorter.field === column.getField();25460});2546125462if(match > -1){25463sorters[match].dir = dir;2546425465match = sorters.splice(match, 1)[0];25466if(dir != "none"){25467sorters.push(match);25468}25469}else {25470if(dir != "none"){25471sorters.push({column:column, dir:dir});25472}25473}2547425475//add to existing sort25476this.setSort(sorters);25477}else {25478if(dir == "none"){25479this.clear();25480}else {25481//sort by column only25482this.setSort(column, dir);25483}2548425485}2548625487// this.table.rowManager.sorterRefresh(!this.sortList.length);25488this.refreshSort();25489}25490});25491}25492}2549325494refreshSort(){25495if(this.table.options.sortMode === "remote"){25496this.reloadData(null, false, false);25497}else {25498this.refreshData(true);25499}2550025501//TODO - Persist left position of row manager25502// left = this.scrollLeft;25503// this.scrollHorizontal(left);25504}2550525506//check if the sorters have changed since last use25507hasChanged(){25508var changed = this.changed;25509this.changed = false;25510return changed;25511}2551225513//return current sorters25514getSort(){25515var self = this,25516sorters = [];2551725518self.sortList.forEach(function(item){25519if(item.column){25520sorters.push({column:item.column.getComponent(), field:item.column.getField(), dir:item.dir});25521}25522});2552325524return sorters;25525}2552625527//change sort list and trigger sort25528setSort(sortList, dir){25529var self = this,25530newSortList = [];2553125532if(!Array.isArray(sortList)){25533sortList = [{column: sortList, dir:dir}];25534}2553525536sortList.forEach(function(item){25537var column;2553825539column = self.table.columnManager.findColumn(item.column);2554025541if(column){25542item.column = column;25543newSortList.push(item);25544self.changed = true;25545}else {25546console.warn("Sort Warning - Sort field does not exist and is being ignored: ", item.column);25547}2554825549});2555025551self.sortList = newSortList;2555225553this.dispatch("sort-changed");25554}2555525556//clear sorters25557clear(){25558this.setSort([]);25559}2556025561//find appropriate sorter for column25562findSorter(column){25563var row = this.table.rowManager.activeRows[0],25564sorter = "string",25565field, value;2556625567if(row){25568row = row.getData();25569field = column.getField();2557025571if(field){2557225573value = column.getFieldValue(row);2557425575switch(typeof value){25576case "undefined":25577sorter = "string";25578break;2557925580case "boolean":25581sorter = "boolean";25582break;2558325584default:25585if(!isNaN(value) && value !== ""){25586sorter = "number";25587}else {25588if(value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)){25589sorter = "alphanum";25590}25591}25592break;25593}25594}25595}2559625597return Sort.sorters[sorter];25598}2559925600//work through sort list sorting data25601sort(data){25602var self = this,25603sortList = this.table.options.sortOrderReverse ? self.sortList.slice().reverse() : self.sortList,25604sortListActual = [],25605rowComponents = [];2560625607if(this.subscribedExternal("dataSorting")){25608this.dispatchExternal("dataSorting", self.getSort());25609}2561025611self.clearColumnHeaders();2561225613if(this.table.options.sortMode !== "remote"){2561425615//build list of valid sorters and trigger column specific callbacks before sort begins25616sortList.forEach(function(item, i){25617var sortObj;2561825619if(item.column){25620sortObj = item.column.modules.sort;2562125622if(sortObj){2562325624//if no sorter has been defined, take a guess25625if(!sortObj.sorter){25626sortObj.sorter = self.findSorter(item.column);25627}2562825629item.params = typeof sortObj.params === "function" ? sortObj.params(item.column.getComponent(), item.dir) : sortObj.params;2563025631sortListActual.push(item);25632}2563325634self.setColumnHeader(item.column, item.dir);25635}25636});2563725638//sort data25639if (sortListActual.length) {25640self._sortItems(data, sortListActual);25641}2564225643}else {25644sortList.forEach(function(item, i){25645self.setColumnHeader(item.column, item.dir);25646});25647}2564825649if(this.subscribedExternal("dataSorted")){25650data.forEach((row) => {25651rowComponents.push(row.getComponent());25652});2565325654this.dispatchExternal("dataSorted", self.getSort(), rowComponents);25655}2565625657return data;25658}2565925660//clear sort arrows on columns25661clearColumnHeaders(){25662this.table.columnManager.getRealColumns().forEach((column) => {25663if(column.modules.sort){25664column.modules.sort.dir = "none";25665column.getElement().setAttribute("aria-sort", "none");25666this.setColumnHeaderSortIcon(column, "none");25667}25668});25669}2567025671//set the column header sort direction25672setColumnHeader(column, dir){25673column.modules.sort.dir = dir;25674column.getElement().setAttribute("aria-sort", dir === "asc" ? "ascending" : "descending");25675this.setColumnHeaderSortIcon(column, dir);25676}2567725678setColumnHeaderSortIcon(column, dir){25679var sortEl = column.modules.sort.element,25680arrowEl;2568125682if(column.definition.headerSort && typeof this.table.options.headerSortElement === "function"){25683while(sortEl.firstChild) sortEl.removeChild(sortEl.firstChild);2568425685arrowEl = this.table.options.headerSortElement.call(this.table, column.getComponent(), dir);2568625687if(typeof arrowEl === "object"){25688sortEl.appendChild(arrowEl);25689}else {25690sortEl.innerHTML = arrowEl;25691}25692}25693}2569425695//sort each item in sort list25696_sortItems(data, sortList){25697var sorterCount = sortList.length - 1;2569825699data.sort((a, b) => {25700var result;2570125702for(var i = sorterCount; i>= 0; i--){25703let sortItem = sortList[i];2570425705result = this._sortRow(a, b, sortItem.column, sortItem.dir, sortItem.params);2570625707if(result !== 0){25708break;25709}25710}2571125712return result;25713});25714}2571525716//process individual rows for a sort function on active data25717_sortRow(a, b, column, dir, params){25718var el1Comp, el2Comp;2571925720//switch elements depending on search direction25721var el1 = dir == "asc" ? a : b;25722var el2 = dir == "asc" ? b : a;2572325724a = column.getFieldValue(el1.getData());25725b = column.getFieldValue(el2.getData());2572625727a = typeof a !== "undefined" ? a : "";25728b = typeof b !== "undefined" ? b : "";2572925730el1Comp = el1.getComponent();25731el2Comp = el2.getComponent();2573225733return column.modules.sort.sorter.call(this, a, b, el1Comp, el2Comp, column.getComponent(), dir, params);25734}25735}2573625737Sort.moduleName = "sort";2573825739//load defaults25740Sort.sorters = defaultSorters;2574125742class Tooltip extends Module{2574325744constructor(table){25745super(table);2574625747this.tooltipSubscriber = null,25748this.headerSubscriber = null,2574925750this.timeout = null;25751this.popupInstance = null;2575225753this.registerTableOption("tooltipGenerationMode", undefined); //deprecated25754this.registerTableOption("tooltipDelay", 300);2575525756this.registerColumnOption("tooltip");25757this.registerColumnOption("headerTooltip");25758}2575925760initialize(){25761this.deprecatedOptionsCheck();2576225763this.subscribe("column-init", this.initializeColumn.bind(this));25764}2576525766deprecatedOptionsCheck(){25767this.deprecationCheckMsg("tooltipGenerationMode", "This option is no longer needed as tooltips are always generated on hover now");25768}2576925770initializeColumn(column){25771if(column.definition.headerTooltip && !this.headerSubscriber){25772this.headerSubscriber = true;2577325774this.subscribe("column-mousemove", this.mousemoveCheck.bind(this, "headerTooltip"));25775this.subscribe("column-mouseout", this.mouseoutCheck.bind(this, "headerTooltip"));25776}2577725778if(column.definition.tooltip && !this.tooltipSubscriber){25779this.tooltipSubscriber = true;2578025781this.subscribe("cell-mousemove", this.mousemoveCheck.bind(this, "tooltip"));25782this.subscribe("cell-mouseout", this.mouseoutCheck.bind(this, "tooltip"));25783}25784}2578525786mousemoveCheck(action, e, component){25787var tooltip = action === "tooltip" ? component.column.definition.tooltip : component.definition.headerTooltip;2578825789if(tooltip){25790this.clearPopup();25791this.timeout = setTimeout(this.loadTooltip.bind(this, e, component, tooltip), this.table.options.tooltipDelay);25792}25793}2579425795mouseoutCheck(action, e, component){25796if(!this.popupInstance){25797this.clearPopup();25798}25799}2580025801clearPopup(action, e, component){25802clearTimeout(this.timeout);25803this.timeout = null;2580425805if(this.popupInstance){25806this.popupInstance.hide();25807}25808}2580925810loadTooltip(e, component, tooltip){25811var contentsEl, renderedCallback, coords;2581225813function onRendered(callback){25814renderedCallback = callback;25815}2581625817if(typeof tooltip === "function"){25818tooltip = tooltip(e, component.getComponent(), onRendered);25819}2582025821if(tooltip instanceof HTMLElement){25822contentsEl = tooltip;25823}else {25824contentsEl = document.createElement("div");2582525826if(tooltip === true){25827if(component instanceof Cell){25828tooltip = component.value;25829}else {25830if(component.definition.field){25831this.langBind("columns|" + component.definition.field, (value) => {25832contentsEl.innerHTML = tooltip = value || component.definition.title;25833});25834}else {25835tooltip = component.definition.title;25836}25837}25838}2583925840contentsEl.innerHTML = tooltip;25841}2584225843if(tooltip || tooltip === 0 || tooltip === false){25844contentsEl.classList.add("tabulator-tooltip");2584525846contentsEl.addEventListener("mousemove", e => e.preventDefault());2584725848this.popupInstance = this.popup(contentsEl);2584925850if(typeof renderedCallback === "function"){25851this.popupInstance.renderCallback(renderedCallback);25852}2585325854coords = this.popupInstance.containerEventCoords(e);2585525856this.popupInstance.show(coords.x + 15, coords.y + 15).hideOnBlur(() => {25857this.dispatchExternal("TooltipClosed", component.getComponent());25858this.popupInstance = null;25859});2586025861this.dispatchExternal("TooltipOpened", component.getComponent());25862}25863}25864}2586525866Tooltip.moduleName = "tooltip";2586725868var defaultValidators = {25869//is integer25870integer: function(cell, value, parameters){25871if(value === "" || value === null || typeof value === "undefined"){25872return true;25873}2587425875value = Number(value);2587625877return !isNaN(value) && isFinite(value) && Math.floor(value) === value;25878},2587925880//is float25881float: function(cell, value, parameters){25882if(value === "" || value === null || typeof value === "undefined"){25883return true;25884}2588525886value = Number(value);2588725888return !isNaN(value) && isFinite(value) && value % 1 !== 0;25889},2589025891//must be a number25892numeric: function(cell, value, parameters){25893if(value === "" || value === null || typeof value === "undefined"){25894return true;25895}25896return !isNaN(value);25897},2589825899//must be a string25900string: function(cell, value, parameters){25901if(value === "" || value === null || typeof value === "undefined"){25902return true;25903}25904return isNaN(value);25905},2590625907//maximum value25908max: function(cell, value, parameters){25909if(value === "" || value === null || typeof value === "undefined"){25910return true;25911}25912return parseFloat(value) <= parameters;25913},2591425915//minimum value25916min: function(cell, value, parameters){25917if(value === "" || value === null || typeof value === "undefined"){25918return true;25919}25920return parseFloat(value) >= parameters;25921},2592225923//starts with value25924starts: function(cell, value, parameters){25925if(value === "" || value === null || typeof value === "undefined"){25926return true;25927}25928return String(value).toLowerCase().startsWith(String(parameters).toLowerCase());25929},2593025931//ends with value25932ends: function(cell, value, parameters){25933if(value === "" || value === null || typeof value === "undefined"){25934return true;25935}25936return String(value).toLowerCase().endsWith(String(parameters).toLowerCase());25937},259382593925940//minimum string length25941minLength: function(cell, value, parameters){25942if(value === "" || value === null || typeof value === "undefined"){25943return true;25944}25945return String(value).length >= parameters;25946},2594725948//maximum string length25949maxLength: function(cell, value, parameters){25950if(value === "" || value === null || typeof value === "undefined"){25951return true;25952}25953return String(value).length <= parameters;25954},2595525956//in provided value list25957in: function(cell, value, parameters){25958if(value === "" || value === null || typeof value === "undefined"){25959return true;25960}2596125962if(typeof parameters == "string"){25963parameters = parameters.split("|");25964}2596525966return parameters.indexOf(value) > -1;25967},2596825969//must match provided regex25970regex: function(cell, value, parameters){25971if(value === "" || value === null || typeof value === "undefined"){25972return true;25973}25974var reg = new RegExp(parameters);2597525976return reg.test(value);25977},2597825979//value must be unique in this column25980unique: function(cell, value, parameters){25981if(value === "" || value === null || typeof value === "undefined"){25982return true;25983}25984var unique = true;2598525986var cellData = cell.getData();25987var column = cell.getColumn()._getSelf();2598825989this.table.rowManager.rows.forEach(function(row){25990var data = row.getData();2599125992if(data !== cellData){25993if(value == column.getFieldValue(data)){25994unique = false;25995}25996}25997});2599825999return unique;26000},2600126002//must have a value26003required:function(cell, value, parameters){26004return value !== "" && value !== null && typeof value !== "undefined";26005},26006};2600726008class Validate extends Module{2600926010constructor(table){26011super(table);2601226013this.invalidCells = [];2601426015this.registerTableOption("validationMode", "blocking");2601626017this.registerColumnOption("validator");2601826019this.registerTableFunction("getInvalidCells", this.getInvalidCells.bind(this));26020this.registerTableFunction("clearCellValidation", this.userClearCellValidation.bind(this));26021this.registerTableFunction("validate", this.userValidate.bind(this));2602226023this.registerComponentFunction("cell", "isValid", this.cellIsValid.bind(this));26024this.registerComponentFunction("cell", "clearValidation", this.clearValidation.bind(this));26025this.registerComponentFunction("cell", "validate", this.cellValidate.bind(this));2602626027this.registerComponentFunction("column", "validate", this.columnValidate.bind(this));26028this.registerComponentFunction("row", "validate", this.rowValidate.bind(this));26029}260302603126032initialize(){26033this.subscribe("cell-delete", this.clearValidation.bind(this));26034this.subscribe("column-layout", this.initializeColumnCheck.bind(this));2603526036this.subscribe("edit-success", this.editValidate.bind(this));26037this.subscribe("edit-editor-clear", this.editorClear.bind(this));26038this.subscribe("edit-edited-clear", this.editedClear.bind(this));26039}2604026041///////////////////////////////////26042///////// Event Handling //////////26043///////////////////////////////////2604426045editValidate(cell, value, previousValue){26046var valid = this.table.options.validationMode !== "manual" ? this.validate(cell.column.modules.validate, cell, value) : true;2604726048// allow time for editor to make render changes then style cell26049if(valid !== true){26050setTimeout(() => {26051cell.getElement().classList.add("tabulator-validation-fail");26052this.dispatchExternal("validationFailed", cell.getComponent(), value, valid);26053});26054}2605526056return valid;26057}2605826059editorClear(cell, cancelled){26060if(cancelled){26061if(cell.column.modules.validate){26062this.cellValidate(cell);26063}26064}2606526066cell.getElement().classList.remove("tabulator-validation-fail");26067}2606826069editedClear(cell){26070if(cell.modules.validate){26071cell.modules.validate.invalid = false;26072}26073}2607426075///////////////////////////////////26076////////// Cell Functions /////////26077///////////////////////////////////2607826079cellIsValid(cell){26080return cell.modules.validate ? (cell.modules.validate.invalid || true) : true;26081}2608226083cellValidate(cell){26084return this.validate(cell.column.modules.validate, cell, cell.getValue());26085}2608626087///////////////////////////////////26088///////// Column Functions ////////26089///////////////////////////////////2609026091columnValidate(column){26092var invalid = [];2609326094column.cells.forEach((cell) => {26095if(this.cellValidate(cell) !== true){26096invalid.push(cell.getComponent());26097}26098});2609926100return invalid.length ? invalid : true;26101}2610226103///////////////////////////////////26104////////// Row Functions //////////26105///////////////////////////////////2610626107rowValidate(row){26108var invalid = [];2610926110row.cells.forEach((cell) => {26111if(this.cellValidate(cell) !== true){26112invalid.push(cell.getComponent());26113}26114});2611526116return invalid.length ? invalid : true;26117}2611826119///////////////////////////////////26120///////// Table Functions /////////26121///////////////////////////////////261222612326124userClearCellValidation(cells){26125if(!cells){26126cells = this.getInvalidCells();26127}2612826129if(!Array.isArray(cells)){26130cells = [cells];26131}2613226133cells.forEach((cell) => {26134this.clearValidation(cell._getSelf());26135});26136}2613726138userValidate(cells){26139var output = [];2614026141//clear row data26142this.table.rowManager.rows.forEach((row) => {26143row = row.getComponent();2614426145var valid = row.validate();2614626147if(valid !== true){26148output = output.concat(valid);26149}26150});2615126152return output.length ? output : true;26153}2615426155///////////////////////////////////26156///////// Internal Logic //////////26157///////////////////////////////////2615826159initializeColumnCheck(column){26160if(typeof column.definition.validator !== "undefined"){26161this.initializeColumn(column);26162}26163}2616426165//validate26166initializeColumn(column){26167var self = this,26168config = [],26169validator;2617026171if(column.definition.validator){2617226173if(Array.isArray(column.definition.validator)){26174column.definition.validator.forEach((item) => {26175validator = self._extractValidator(item);2617626177if(validator){26178config.push(validator);26179}26180});2618126182}else {26183validator = this._extractValidator(column.definition.validator);2618426185if(validator){26186config.push(validator);26187}26188}2618926190column.modules.validate = config.length ? config : false;26191}26192}2619326194_extractValidator(value){26195var type, params, pos;2619626197switch(typeof value){26198case "string":26199pos = value.indexOf(':');2620026201if(pos > -1){26202type = value.substring(0,pos);26203params = value.substring(pos+1);26204}else {26205type = value;26206}2620726208return this._buildValidator(type, params);2620926210case "function":26211return this._buildValidator(value);2621226213case "object":26214return this._buildValidator(value.type, value.parameters);26215}26216}2621726218_buildValidator(type, params){2621926220var func = typeof type == "function" ? type : Validate.validators[type];2622126222if(!func){26223console.warn("Validator Setup Error - No matching validator found:", type);26224return false;26225}else {26226return {26227type:typeof type == "function" ? "function" : type,26228func:func,26229params:params,26230};26231}26232}2623326234validate(validators, cell, value){26235var self = this,26236failedValidators = [],26237invalidIndex = this.invalidCells.indexOf(cell);2623826239if(validators){26240validators.forEach((item) => {26241if(!item.func.call(self, cell.getComponent(), value, item.params)){26242failedValidators.push({26243type:item.type,26244parameters:item.params26245});26246}26247});26248}2624926250if(!cell.modules.validate){26251cell.modules.validate = {};26252}2625326254if(!failedValidators.length){26255cell.modules.validate.invalid = false;26256cell.getElement().classList.remove("tabulator-validation-fail");2625726258if(invalidIndex > -1){26259this.invalidCells.splice(invalidIndex, 1);26260}26261}else {26262cell.modules.validate.invalid = failedValidators;2626326264if(this.table.options.validationMode !== "manual"){26265cell.getElement().classList.add("tabulator-validation-fail");26266}2626726268if(invalidIndex == -1){26269this.invalidCells.push(cell);26270}26271}2627226273return failedValidators.length ? failedValidators : true;26274}2627526276getInvalidCells(){26277var output = [];2627826279this.invalidCells.forEach((cell) => {26280output.push(cell.getComponent());26281});2628226283return output;26284}2628526286clearValidation(cell){26287var invalidIndex;2628826289if(cell.modules.validate && cell.modules.validate.invalid){2629026291cell.getElement().classList.remove("tabulator-validation-fail");26292cell.modules.validate.invalid = false;2629326294invalidIndex = this.invalidCells.indexOf(cell);2629526296if(invalidIndex > -1){26297this.invalidCells.splice(invalidIndex, 1);26298}26299}26300}26301}2630226303Validate.moduleName = "validate";2630426305//load defaults26306Validate.validators = defaultValidators;2630726308var modules = /*#__PURE__*/Object.freeze({26309__proto__: null,26310AccessorModule: Accessor,26311AjaxModule: Ajax,26312ClipboardModule: Clipboard,26313ColumnCalcsModule: ColumnCalcs,26314DataTreeModule: DataTree,26315DownloadModule: Download,26316EditModule: Edit$1,26317ExportModule: Export,26318FilterModule: Filter,26319FormatModule: Format,26320FrozenColumnsModule: FrozenColumns,26321FrozenRowsModule: FrozenRows,26322GroupRowsModule: GroupRows,26323HistoryModule: History,26324HtmlTableImportModule: HtmlTableImport,26325ImportModule: Import,26326InteractionModule: Interaction,26327KeybindingsModule: Keybindings,26328MenuModule: Menu,26329MoveColumnsModule: MoveColumns,26330MoveRowsModule: MoveRows,26331MutatorModule: Mutator,26332PageModule: Page,26333PersistenceModule: Persistence,26334PopupModule: Popup$1,26335PrintModule: Print,26336ReactiveDataModule: ReactiveData,26337ResizeColumnsModule: ResizeColumns,26338ResizeRowsModule: ResizeRows,26339ResizeTableModule: ResizeTable,26340ResponsiveLayoutModule: ResponsiveLayout,26341SelectRowModule: SelectRow,26342SortModule: Sort,26343TooltipModule: Tooltip,26344ValidateModule: Validate26345});2634626347//tabulator with all modules installed2634826349class TabulatorFull extends Tabulator {}2635026351//bind modules and static functionality26352new ModuleBinder(TabulatorFull, modules);2635326354return TabulatorFull;2635526356})));26357//# sourceMappingURL=tabulator.js.map263582635926360