Path: blob/main/dev-docs/feature-format-matrix/dist/js/tabulator_esm.js
12926 views
/* Tabulator v5.5.2 (c) Oliver Folkerd 2023 */1class CoreFeature{23constructor(table){4this.table = table;5}67//////////////////////////////////////////8/////////////// DataLoad /////////////////9//////////////////////////////////////////1011reloadData(data, silent, columnsChanged){12return this.table.dataLoader.load(data, undefined, undefined, undefined, silent, columnsChanged);13}1415//////////////////////////////////////////16///////////// Localization ///////////////17//////////////////////////////////////////1819langText(){20return this.table.modules.localize.getText(...arguments);21}2223langBind(){24return this.table.modules.localize.bind(...arguments);25}2627langLocale(){28return this.table.modules.localize.getLocale(...arguments);29}303132//////////////////////////////////////////33////////// Inter Table Comms /////////////34//////////////////////////////////////////3536commsConnections(){37return this.table.modules.comms.getConnections(...arguments);38}3940commsSend(){41return this.table.modules.comms.send(...arguments);42}4344//////////////////////////////////////////45//////////////// Layout /////////////////46//////////////////////////////////////////4748layoutMode(){49return this.table.modules.layout.getMode();50}5152layoutRefresh(force){53return this.table.modules.layout.layout(force);54}555657//////////////////////////////////////////58/////////////// Event Bus ////////////////59//////////////////////////////////////////6061subscribe(){62return this.table.eventBus.subscribe(...arguments);63}6465unsubscribe(){66return this.table.eventBus.unsubscribe(...arguments);67}6869subscribed(key){70return this.table.eventBus.subscribed(key);71}7273subscriptionChange(){74return this.table.eventBus.subscriptionChange(...arguments);75}7677dispatch(){78return this.table.eventBus.dispatch(...arguments);79}8081chain(){82return this.table.eventBus.chain(...arguments);83}8485confirm(){86return this.table.eventBus.confirm(...arguments);87}8889dispatchExternal(){90return this.table.externalEvents.dispatch(...arguments);91}9293subscribedExternal(key){94return this.table.externalEvents.subscribed(key);95}9697subscriptionChangeExternal(){98return this.table.externalEvents.subscriptionChange(...arguments);99}100101//////////////////////////////////////////102//////////////// Options /////////////////103//////////////////////////////////////////104105options(key){106return this.table.options[key];107}108109setOption(key, value){110if(typeof value !== "undefined"){111this.table.options[key] = value;112}113114return this.table.options[key];115}116117//////////////////////////////////////////118/////////// Deprecation Checks ///////////119//////////////////////////////////////////120121deprecationCheck(oldOption, newOption){122return this.table.deprecationAdvisor.check(oldOption, newOption);123}124125deprecationCheckMsg(oldOption, msg){126return this.table.deprecationAdvisor.checkMsg(oldOption, msg);127}128129deprecationMsg(msg){130return this.table.deprecationAdvisor.msg(msg);131}132//////////////////////////////////////////133//////////////// Modules /////////////////134//////////////////////////////////////////135136module(key){137return this.table.module(key);138}139}140141class Helpers{142143static elVisible(el){144return !(el.offsetWidth <= 0 && el.offsetHeight <= 0);145}146147static elOffset(el){148var box = el.getBoundingClientRect();149150return {151top: box.top + window.pageYOffset - document.documentElement.clientTop,152left: box.left + window.pageXOffset - document.documentElement.clientLeft153};154}155156static deepClone(obj, clone, list = []){157var objectProto = {}.__proto__,158arrayProto = [].__proto__;159160if (!clone){161clone = Object.assign(Array.isArray(obj) ? [] : {}, obj);162}163164for(var i in obj) {165let subject = obj[i],166match, copy;167168if(subject != null && typeof subject === "object" && (subject.__proto__ === objectProto || subject.__proto__ === arrayProto)){169match = list.findIndex((item) => {170return item.subject === subject;171});172173if(match > -1){174clone[i] = list[match].copy;175}else {176copy = Object.assign(Array.isArray(subject) ? [] : {}, subject);177178list.unshift({subject, copy});179180clone[i] = this.deepClone(subject, copy, list);181}182}183}184185return clone;186}187}188189class Popup extends CoreFeature{190constructor(table, element, parent){191super(table);192193this.element = element;194this.container = this._lookupContainer();195196this.parent = parent;197198this.reversedX = false;199this.childPopup = null;200this.blurable = false;201this.blurCallback = null;202this.blurEventsBound = false;203this.renderedCallback = null;204205this.visible = false;206this.hideable = true;207208this.element.classList.add("tabulator-popup-container");209210this.blurEvent = this.hide.bind(this, false);211this.escEvent = this._escapeCheck.bind(this);212213this.destroyBinding = this.tableDestroyed.bind(this);214this.destroyed = false;215}216217tableDestroyed(){218this.destroyed = true;219this.hide(true);220}221222_lookupContainer(){223var container = this.table.options.popupContainer;224225if(typeof container === "string"){226container = document.querySelector(container);227228if(!container){229console.warn("Menu Error - no container element found matching selector:", this.table.options.popupContainer , "(defaulting to document body)");230}231}else if (container === true){232container = this.table.element;233}234235if(container && !this._checkContainerIsParent(container)){236container = false;237console.warn("Menu Error - container element does not contain this table:", this.table.options.popupContainer , "(defaulting to document body)");238}239240if(!container){241container = document.body;242}243244return container;245}246247_checkContainerIsParent(container, element = this.table.element){248if(container === element){249return true;250}else {251return element.parentNode ? this._checkContainerIsParent(container, element.parentNode) : false;252}253}254255renderCallback(callback){256this.renderedCallback = callback;257}258259containerEventCoords(e){260var touch = !(e instanceof MouseEvent);261262var x = touch ? e.touches[0].pageX : e.pageX;263var y = touch ? e.touches[0].pageY : e.pageY;264265if(this.container !== document.body){266let parentOffset = Helpers.elOffset(this.container);267268x -= parentOffset.left;269y -= parentOffset.top;270}271272return {x, y};273}274275elementPositionCoords(element, position = "right"){276var offset = Helpers.elOffset(element),277containerOffset, x, y;278279if(this.container !== document.body){280containerOffset = Helpers.elOffset(this.container);281282offset.left -= containerOffset.left;283offset.top -= containerOffset.top;284}285286switch(position){287case "right":288x = offset.left + element.offsetWidth;289y = offset.top - 1;290break;291292case "bottom":293x = offset.left;294y = offset.top + element.offsetHeight;295break;296297case "left":298x = offset.left;299y = offset.top - 1;300break;301302case "top":303x = offset.left;304y = offset.top;305break;306307case "center":308x = offset.left + (element.offsetWidth / 2);309y = offset.top + (element.offsetHeight / 2);310break;311312}313314return {x, y, offset};315}316317show(origin, position){318var x, y, parentEl, parentOffset, coords;319320if(this.destroyed || this.table.destroyed){321return this;322}323324if(origin instanceof HTMLElement){325parentEl = origin;326coords = this.elementPositionCoords(origin, position);327328parentOffset = coords.offset;329x = coords.x;330y = coords.y;331332}else if(typeof origin === "number"){333parentOffset = {top:0, left:0};334x = origin;335y = position;336}else {337coords = this.containerEventCoords(origin);338339x = coords.x;340y = coords.y;341342this.reversedX = false;343}344345this.element.style.top = y + "px";346this.element.style.left = x + "px";347348this.container.appendChild(this.element);349350if(typeof this.renderedCallback === "function"){351this.renderedCallback();352}353354this._fitToScreen(x, y, parentEl, parentOffset, position);355356this.visible = true;357358this.subscribe("table-destroy", this.destroyBinding);359360this.element.addEventListener("mousedown", (e) => {361e.stopPropagation();362});363364return this;365}366367_fitToScreen(x, y, parentEl, parentOffset, position){368var scrollTop = this.container === document.body ? document.documentElement.scrollTop : this.container.scrollTop;369370//move menu to start on right edge if it is too close to the edge of the screen371if((x + this.element.offsetWidth) >= this.container.offsetWidth || this.reversedX){372this.element.style.left = "";373374if(parentEl){375this.element.style.right = (this.container.offsetWidth - parentOffset.left) + "px";376}else {377this.element.style.right = (this.container.offsetWidth - x) + "px";378}379380this.reversedX = true;381}382383//move menu to start on bottom edge if it is too close to the edge of the screen384if((y + this.element.offsetHeight) > Math.max(this.container.offsetHeight, scrollTop ? this.container.scrollHeight : 0)) {385if(parentEl){386switch(position){387case "bottom":388this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight - parentEl.offsetHeight - 1) + "px";389break;390391default:392this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight + parentEl.offsetHeight + 1) + "px";393}394395}else {396this.element.style.top = (parseInt(this.element.style.top) - this.element.offsetHeight) + "px";397}398}399}400401isVisible(){402return this.visible;403}404405hideOnBlur(callback){406this.blurable = true;407408if(this.visible){409setTimeout(() => {410if(this.visible){411this.table.rowManager.element.addEventListener("scroll", this.blurEvent);412this.subscribe("cell-editing", this.blurEvent);413document.body.addEventListener("click", this.blurEvent);414document.body.addEventListener("contextmenu", this.blurEvent);415document.body.addEventListener("mousedown", this.blurEvent);416window.addEventListener("resize", this.blurEvent);417document.body.addEventListener("keydown", this.escEvent);418419this.blurEventsBound = true;420}421}, 100);422423this.blurCallback = callback;424}425426return this;427}428429_escapeCheck(e){430if(e.keyCode == 27){431this.hide();432}433}434435blockHide(){436this.hideable = false;437}438439restoreHide(){440this.hideable = true;441}442443hide(silent = false){444if(this.visible && this.hideable){445if(this.blurable && this.blurEventsBound){446document.body.removeEventListener("keydown", this.escEvent);447document.body.removeEventListener("click", this.blurEvent);448document.body.removeEventListener("contextmenu", this.blurEvent);449document.body.removeEventListener("mousedown", this.blurEvent);450window.removeEventListener("resize", this.blurEvent);451this.table.rowManager.element.removeEventListener("scroll", this.blurEvent);452this.unsubscribe("cell-editing", this.blurEvent);453454this.blurEventsBound = false;455}456457if(this.childPopup){458this.childPopup.hide();459}460461if(this.parent){462this.parent.childPopup = null;463}464465if(this.element.parentNode){466this.element.parentNode.removeChild(this.element);467}468469this.visible = false;470471if(this.blurCallback && !silent){472this.blurCallback();473}474475this.unsubscribe("table-destroy", this.destroyBinding);476}477478return this;479}480481child(element){482if(this.childPopup){483this.childPopup.hide();484}485486this.childPopup = new Popup(this.table, element, this);487488return this.childPopup;489}490}491492class Module extends CoreFeature{493494constructor(table, name){495super(table);496497this._handler = null;498}499500initialize(){501// setup module when table is initialized, to be overridden in module502}503504505///////////////////////////////////506////// Options Registration ///////507///////////////////////////////////508509registerTableOption(key, value){510this.table.optionsList.register(key, value);511}512513registerColumnOption(key, value){514this.table.columnManager.optionsList.register(key, value);515}516517///////////////////////////////////518/// Public Function Registration ///519///////////////////////////////////520521registerTableFunction(name, func){522if(typeof this.table[name] === "undefined"){523this.table[name] = (...args) => {524this.table.initGuard(name);525526return func(...args);527};528}else {529console.warn("Unable to bind table function, name already in use", name);530}531}532533registerComponentFunction(component, func, handler){534return this.table.componentFunctionBinder.bind(component, func, handler);535}536537///////////////////////////////////538////////// Data Pipeline //////////539///////////////////////////////////540541registerDataHandler(handler, priority){542this.table.rowManager.registerDataPipelineHandler(handler, priority);543this._handler = handler;544}545546registerDisplayHandler(handler, priority){547this.table.rowManager.registerDisplayPipelineHandler(handler, priority);548this._handler = handler;549}550551displayRows(adjust){552var index = this.table.rowManager.displayRows.length - 1,553lookupIndex;554555if(this._handler){556lookupIndex = this.table.rowManager.displayPipeline.findIndex((item) => {557return item.handler === this._handler;558});559560if(lookupIndex > -1){561index = lookupIndex;562}563}564565if(adjust){566index = index + adjust;567}568569if(this._handler){570if(index > -1){571return this.table.rowManager.getDisplayRows(index);572}else {573return this.activeRows();574}575}576}577578activeRows(){579return this.table.rowManager.activeRows;580}581582refreshData(renderInPosition, handler){583if(!handler){584handler = this._handler;585}586587if(handler){588this.table.rowManager.refreshActiveData(handler, false, renderInPosition);589}590}591592///////////////////////////////////593//////// Footer Management ////////594///////////////////////////////////595596footerAppend(element){597return this.table.footerManager.append(element);598}599600footerPrepend(element){601return this.table.footerManager.prepend(element);602}603604footerRemove(element){605return this.table.footerManager.remove(element);606}607608///////////////////////////////////609//////// Popups Management ////////610///////////////////////////////////611612popup(menuEl, menuContainer){613return new Popup(this.table, menuEl, menuContainer);614}615616///////////////////////////////////617//////// Alert Management ////////618///////////////////////////////////619620alert(content, type){621return this.table.alertManager.alert(content, type);622}623624clearAlert(){625return this.table.alertManager.clear();626}627628}629630var defaultAccessors = {};631632class Accessor extends Module{633634constructor(table){635super(table);636637this.allowedTypes = ["", "data", "download", "clipboard", "print", "htmlOutput"]; //list of accessor types638639this.registerColumnOption("accessor");640this.registerColumnOption("accessorParams");641this.registerColumnOption("accessorData");642this.registerColumnOption("accessorDataParams");643this.registerColumnOption("accessorDownload");644this.registerColumnOption("accessorDownloadParams");645this.registerColumnOption("accessorClipboard");646this.registerColumnOption("accessorClipboardParams");647this.registerColumnOption("accessorPrint");648this.registerColumnOption("accessorPrintParams");649this.registerColumnOption("accessorHtmlOutput");650this.registerColumnOption("accessorHtmlOutputParams");651}652653initialize(){654this.subscribe("column-layout", this.initializeColumn.bind(this));655this.subscribe("row-data-retrieve", this.transformRow.bind(this));656}657658//initialize column accessor659initializeColumn(column){660var match = false,661config = {};662663this.allowedTypes.forEach((type) => {664var key = "accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),665accessor;666667if(column.definition[key]){668accessor = this.lookupAccessor(column.definition[key]);669670if(accessor){671match = true;672673config[key] = {674accessor:accessor,675params: column.definition[key + "Params"] || {},676};677}678}679});680681if(match){682column.modules.accessor = config;683}684}685686lookupAccessor(value){687var accessor = false;688689//set column accessor690switch(typeof value){691case "string":692if(Accessor.accessors[value]){693accessor = Accessor.accessors[value];694}else {695console.warn("Accessor Error - No such accessor found, ignoring: ", value);696}697break;698699case "function":700accessor = value;701break;702}703704return accessor;705}706707//apply accessor to row708transformRow(row, type){709var key = "accessor" + (type.charAt(0).toUpperCase() + type.slice(1)),710rowComponent = row.getComponent();711712//clone data object with deep copy to isolate internal data from returned result713var data = Helpers.deepClone(row.data || {});714715this.table.columnManager.traverse(function(column){716var value, accessor, params, colComponent;717718if(column.modules.accessor){719720accessor = column.modules.accessor[key] || column.modules.accessor.accessor || false;721722if(accessor){723value = column.getFieldValue(data);724725if(value != "undefined"){726colComponent = column.getComponent();727params = typeof accessor.params === "function" ? accessor.params(value, data, type, colComponent, rowComponent) : accessor.params;728column.setFieldValue(data, accessor.accessor(value, data, type, params, colComponent, rowComponent));729}730}731}732});733734return data;735}736}737738//load defaults739Accessor.moduleName = "accessor";740Accessor.accessors = defaultAccessors;741742var defaultConfig = {743method: "GET",744};745746function generateParamsList(data, prefix){747var output = [];748749prefix = prefix || "";750751if(Array.isArray(data)){752data.forEach((item, i) => {753output = output.concat(generateParamsList(item, prefix ? prefix + "[" + i + "]" : i));754});755}else if (typeof data === "object"){756for (var key in data){757output = output.concat(generateParamsList(data[key], prefix ? prefix + "[" + key + "]" : key));758}759}else {760output.push({key:prefix, value:data});761}762763return output;764}765766function serializeParams(params){767var output = generateParamsList(params),768encoded = [];769770output.forEach(function(item){771encoded.push(encodeURIComponent(item.key) + "=" + encodeURIComponent(item.value));772});773774return encoded.join("&");775}776777function urlBuilder(url, config, params){778if(url){779if(params && Object.keys(params).length){780if(!config.method || config.method.toLowerCase() == "get"){781config.method = "get";782783url += (url.includes("?") ? "&" : "?") + serializeParams(params);784}785}786}787788return url;789}790791function defaultLoaderPromise(url, config, params){792var contentType;793794return new Promise((resolve, reject) => {795//set url796url = this.urlGenerator.call(this.table, url, config, params);797798//set body content if not GET request799if(config.method.toUpperCase() != "GET"){800contentType = typeof this.table.options.ajaxContentType === "object" ? this.table.options.ajaxContentType : this.contentTypeFormatters[this.table.options.ajaxContentType];801if(contentType){802803for(var key in contentType.headers){804if(!config.headers){805config.headers = {};806}807808if(typeof config.headers[key] === "undefined"){809config.headers[key] = contentType.headers[key];810}811}812813config.body = contentType.body.call(this, url, config, params);814815}else {816console.warn("Ajax Error - Invalid ajaxContentType value:", this.table.options.ajaxContentType);817}818}819820if(url){821//configure headers822if(typeof config.headers === "undefined"){823config.headers = {};824}825826if(typeof config.headers.Accept === "undefined"){827config.headers.Accept = "application/json";828}829830if(typeof config.headers["X-Requested-With"] === "undefined"){831config.headers["X-Requested-With"] = "XMLHttpRequest";832}833834if(typeof config.mode === "undefined"){835config.mode = "cors";836}837838if(config.mode == "cors"){839if(typeof config.headers["Origin"] === "undefined"){840config.headers["Origin"] = window.location.origin;841}842843if(typeof config.credentials === "undefined"){844config.credentials = 'same-origin';845}846}else {847if(typeof config.credentials === "undefined"){848config.credentials = 'include';849}850}851852//send request853fetch(url, config)854.then((response)=>{855if(response.ok) {856response.json()857.then((data)=>{858resolve(data);859}).catch((error)=>{860reject(error);861console.warn("Ajax Load Error - Invalid JSON returned", error);862});863}else {864console.error("Ajax Load Error - Connection Error: " + response.status, response.statusText);865reject(response);866}867})868.catch((error)=>{869console.error("Ajax Load Error - Connection Error: ", error);870reject(error);871});872}else {873console.warn("Ajax Load Error - No URL Set");874resolve([]);875}876});877}878879function generateParamsList$1(data, prefix){880var output = [];881882prefix = prefix || "";883884if(Array.isArray(data)){885data.forEach((item, i) => {886output = output.concat(generateParamsList$1(item, prefix ? prefix + "[" + i + "]" : i));887});888}else if (typeof data === "object"){889for (var key in data){890output = output.concat(generateParamsList$1(data[key], prefix ? prefix + "[" + key + "]" : key));891}892}else {893output.push({key:prefix, value:data});894}895896return output;897}898899var defaultContentTypeFormatters = {900"json":{901headers:{902'Content-Type': 'application/json',903},904body:function(url, config, params){905return JSON.stringify(params);906},907},908"form":{909headers:{910},911body:function(url, config, params){912913var output = generateParamsList$1(params),914form = new FormData();915916output.forEach(function(item){917form.append(item.key, item.value);918});919920return form;921},922},923};924925class Ajax extends Module{926927constructor(table){928super(table);929930this.config = {}; //hold config object for ajax request931this.url = ""; //request URL932this.urlGenerator = false;933this.params = false; //request parameters934935this.loaderPromise = false;936937this.registerTableOption("ajaxURL", false); //url for ajax loading938this.registerTableOption("ajaxURLGenerator", false);939this.registerTableOption("ajaxParams", {}); //params for ajax loading940this.registerTableOption("ajaxConfig", "get"); //ajax request type941this.registerTableOption("ajaxContentType", "form"); //ajax request type942this.registerTableOption("ajaxRequestFunc", false); //promise function943944this.registerTableOption("ajaxRequesting", function(){});945this.registerTableOption("ajaxResponse", false);946947this.contentTypeFormatters = Ajax.contentTypeFormatters;948}949950//initialize setup options951initialize(){952this.loaderPromise = this.table.options.ajaxRequestFunc || Ajax.defaultLoaderPromise;953this.urlGenerator = this.table.options.ajaxURLGenerator || Ajax.defaultURLGenerator;954955if(this.table.options.ajaxURL){956this.setUrl(this.table.options.ajaxURL);957}958959960this.setDefaultConfig(this.table.options.ajaxConfig);961962this.registerTableFunction("getAjaxUrl", this.getUrl.bind(this));963964this.subscribe("data-loading", this.requestDataCheck.bind(this));965this.subscribe("data-params", this.requestParams.bind(this));966this.subscribe("data-load", this.requestData.bind(this));967}968969requestParams(data, config, silent, params){970var ajaxParams = this.table.options.ajaxParams;971972if(ajaxParams){973if(typeof ajaxParams === "function"){974ajaxParams = ajaxParams.call(this.table);975}976977params = Object.assign(params, ajaxParams);978}979980return params;981}982983requestDataCheck(data, params, config, silent){984return !!((!data && this.url) || typeof data === "string");985}986987requestData(url, params, config, silent, previousData){988var ajaxConfig;989990if(!previousData && this.requestDataCheck(url)){991if(url){992this.setUrl(url);993}994995ajaxConfig = this.generateConfig(config);996997return this.sendRequest(this.url, params, ajaxConfig);998}else {999return previousData;1000}1001}10021003setDefaultConfig(config = {}){1004this.config = Object.assign({}, Ajax.defaultConfig);10051006if(typeof config == "string"){1007this.config.method = config;1008}else {1009Object.assign(this.config, config);1010}1011}10121013//load config object1014generateConfig(config = {}){1015var ajaxConfig = Object.assign({}, this.config);10161017if(typeof config == "string"){1018ajaxConfig.method = config;1019}else {1020Object.assign(ajaxConfig, config);1021}10221023return ajaxConfig;1024}10251026//set request url1027setUrl(url){1028this.url = url;1029}10301031//get request url1032getUrl(){1033return this.url;1034}10351036//send ajax request1037sendRequest(url, params, config){1038if(this.table.options.ajaxRequesting.call(this.table, url, params) !== false){1039return this.loaderPromise(url, config, params)1040.then((data)=>{1041if(this.table.options.ajaxResponse){1042data = this.table.options.ajaxResponse.call(this.table, url, params, data);1043}10441045return data;1046});1047}else {1048return Promise.reject();1049}1050}1051}10521053Ajax.moduleName = "ajax";10541055//load defaults1056Ajax.defaultConfig = defaultConfig;1057Ajax.defaultURLGenerator = urlBuilder;1058Ajax.defaultLoaderPromise = defaultLoaderPromise;1059Ajax.contentTypeFormatters = defaultContentTypeFormatters;10601061var defaultPasteActions = {1062replace:function(rows){1063return this.table.setData(rows);1064},1065update:function(rows){1066return this.table.updateOrAddData(rows);1067},1068insert:function(rows){1069return this.table.addData(rows);1070},1071};10721073var defaultPasteParsers = {1074table:function(clipboard){1075var data = [],1076headerFindSuccess = true,1077columns = this.table.columnManager.columns,1078columnMap = [],1079rows = [];10801081//get data from clipboard into array of columns and rows.1082clipboard = clipboard.split("\n");10831084clipboard.forEach(function(row){1085data.push(row.split("\t"));1086});10871088if(data.length && !(data.length === 1 && data[0].length < 2)){10891090//check if headers are present by title1091data[0].forEach(function(value){1092var column = columns.find(function(column){1093return value && column.definition.title && value.trim() && column.definition.title.trim() === value.trim();1094});10951096if(column){1097columnMap.push(column);1098}else {1099headerFindSuccess = false;1100}1101});11021103//check if column headers are present by field1104if(!headerFindSuccess){1105headerFindSuccess = true;1106columnMap = [];11071108data[0].forEach(function(value){1109var column = columns.find(function(column){1110return value && column.field && value.trim() && column.field.trim() === value.trim();1111});11121113if(column){1114columnMap.push(column);1115}else {1116headerFindSuccess = false;1117}1118});11191120if(!headerFindSuccess){1121columnMap = this.table.columnManager.columnsByIndex;1122}1123}11241125//remove header row if found1126if(headerFindSuccess){1127data.shift();1128}11291130data.forEach(function(item){1131var row = {};11321133item.forEach(function(value, i){1134if(columnMap[i]){1135row[columnMap[i].field] = value;1136}1137});11381139rows.push(row);1140});11411142return rows;1143}else {1144return false;1145}1146}1147};11481149class Clipboard extends Module{11501151constructor(table){1152super(table);11531154this.mode = true;1155this.pasteParser = function(){};1156this.pasteAction = function(){};1157this.customSelection = false;1158this.rowRange = false;1159this.blocked = true; //block copy actions not originating from this command11601161this.registerTableOption("clipboard", false); //enable clipboard1162this.registerTableOption("clipboardCopyStyled", true); //formatted table data1163this.registerTableOption("clipboardCopyConfig", false); //clipboard config1164this.registerTableOption("clipboardCopyFormatter", false); //DEPRECATED - REMOVE in 5.01165this.registerTableOption("clipboardCopyRowRange", "active"); //restrict clipboard to visible rows only1166this.registerTableOption("clipboardPasteParser", "table"); //convert pasted clipboard data to rows1167this.registerTableOption("clipboardPasteAction", "insert"); //how to insert pasted data into the table11681169this.registerColumnOption("clipboard");1170this.registerColumnOption("titleClipboard");1171}11721173initialize(){1174this.mode = this.table.options.clipboard;11751176this.rowRange = this.table.options.clipboardCopyRowRange;11771178if(this.mode === true || this.mode === "copy"){1179this.table.element.addEventListener("copy", (e) => {1180var plain, html, list;11811182if(!this.blocked){1183e.preventDefault();11841185if(this.customSelection){1186plain = this.customSelection;11871188if(this.table.options.clipboardCopyFormatter){1189plain = this.table.options.clipboardCopyFormatter("plain", plain);1190}1191}else {11921193list = this.table.modules.export.generateExportList(this.table.options.clipboardCopyConfig, this.table.options.clipboardCopyStyled, this.rowRange, "clipboard");11941195html = this.table.modules.export.generateHTMLTable(list);1196plain = html ? this.generatePlainContent(list) : "";11971198if(this.table.options.clipboardCopyFormatter){1199plain = this.table.options.clipboardCopyFormatter("plain", plain);1200html = this.table.options.clipboardCopyFormatter("html", html);1201}1202}12031204if (window.clipboardData && window.clipboardData.setData) {1205window.clipboardData.setData('Text', plain);1206} else if (e.clipboardData && e.clipboardData.setData) {1207e.clipboardData.setData('text/plain', plain);1208if(html){1209e.clipboardData.setData('text/html', html);1210}1211} else if (e.originalEvent && e.originalEvent.clipboardData.setData) {1212e.originalEvent.clipboardData.setData('text/plain', plain);1213if(html){1214e.originalEvent.clipboardData.setData('text/html', html);1215}1216}12171218this.dispatchExternal("clipboardCopied", plain, html);12191220this.reset();1221}1222});1223}12241225if(this.mode === true || this.mode === "paste"){1226this.table.element.addEventListener("paste", (e) => {1227this.paste(e);1228});1229}12301231this.setPasteParser(this.table.options.clipboardPasteParser);1232this.setPasteAction(this.table.options.clipboardPasteAction);12331234this.registerTableFunction("copyToClipboard", this.copy.bind(this));1235}12361237reset(){1238this.blocked = true;1239this.customSelection = false;1240}12411242generatePlainContent (list) {1243var output = [];12441245list.forEach((row) => {1246var rowData = [];12471248row.columns.forEach((col) => {1249var value = "";12501251if(col){12521253if(row.type === "group"){1254col.value = col.component.getKey();1255}12561257if(col.value === null){1258value = "";1259}else {1260switch(typeof col.value){1261case "object":1262value = JSON.stringify(col.value);1263break;12641265case "undefined":1266value = "";1267break;12681269default:1270value = col.value;1271}1272}1273}12741275rowData.push(value);1276});12771278output.push(rowData.join("\t"));1279});12801281return output.join("\n");1282}12831284copy (range, internal) {1285var sel, textRange;1286this.blocked = false;1287this.customSelection = false;12881289if (this.mode === true || this.mode === "copy") {12901291this.rowRange = range || this.table.options.clipboardCopyRowRange;12921293if (typeof window.getSelection != "undefined" && typeof document.createRange != "undefined") {1294range = document.createRange();1295range.selectNodeContents(this.table.element);1296sel = window.getSelection();12971298if (sel.toString() && internal) {1299this.customSelection = sel.toString();1300}13011302sel.removeAllRanges();1303sel.addRange(range);1304} else if (typeof document.selection != "undefined" && typeof document.body.createTextRange != "undefined") {1305textRange = document.body.createTextRange();1306textRange.moveToElementText(this.table.element);1307textRange.select();1308}13091310document.execCommand('copy');13111312if (sel) {1313sel.removeAllRanges();1314}1315}1316}13171318//PASTE EVENT HANDLING1319setPasteAction(action){13201321switch(typeof action){1322case "string":1323this.pasteAction = Clipboard.pasteActions[action];13241325if(!this.pasteAction){1326console.warn("Clipboard Error - No such paste action found:", action);1327}1328break;13291330case "function":1331this.pasteAction = action;1332break;1333}1334}13351336setPasteParser(parser){1337switch(typeof parser){1338case "string":1339this.pasteParser = Clipboard.pasteParsers[parser];13401341if(!this.pasteParser){1342console.warn("Clipboard Error - No such paste parser found:", parser);1343}1344break;13451346case "function":1347this.pasteParser = parser;1348break;1349}1350}13511352paste(e){1353var data, rowData, rows;13541355if(this.checkPaseOrigin(e)){13561357data = this.getPasteData(e);13581359rowData = this.pasteParser.call(this, data);13601361if(rowData){1362e.preventDefault();13631364if(this.table.modExists("mutator")){1365rowData = this.mutateData(rowData);1366}13671368rows = this.pasteAction.call(this, rowData);13691370this.dispatchExternal("clipboardPasted", data, rowData, rows);1371}else {1372this.dispatchExternal("clipboardPasteError", data);1373}1374}1375}13761377mutateData(data){1378var output = [];13791380if(Array.isArray(data)){1381data.forEach((row) => {1382output.push(this.table.modules.mutator.transformRow(row, "clipboard"));1383});1384}else {1385output = data;1386}13871388return output;1389}139013911392checkPaseOrigin(e){1393var valid = true;13941395if(e.target.tagName != "DIV" || this.table.modules.edit.currentCell){1396valid = false;1397}13981399return valid;1400}14011402getPasteData(e){1403var data;14041405if (window.clipboardData && window.clipboardData.getData) {1406data = window.clipboardData.getData('Text');1407} else if (e.clipboardData && e.clipboardData.getData) {1408data = e.clipboardData.getData('text/plain');1409} else if (e.originalEvent && e.originalEvent.clipboardData.getData) {1410data = e.originalEvent.clipboardData.getData('text/plain');1411}14121413return data;1414}1415}14161417Clipboard.moduleName = "clipboard";14181419//load defaults1420Clipboard.pasteActions = defaultPasteActions;1421Clipboard.pasteParsers = defaultPasteParsers;14221423class CalcComponent{1424constructor (row){1425this._row = row;14261427return new Proxy(this, {1428get: function(target, name, receiver) {1429if (typeof target[name] !== "undefined") {1430return target[name];1431}else {1432return target._row.table.componentFunctionBinder.handle("row", target._row, name);1433}1434}1435});1436}14371438getData(transform){1439return this._row.getData(transform);1440}14411442getElement(){1443return this._row.getElement();1444}14451446getTable(){1447return this._row.table;1448}14491450getCells(){1451var cells = [];14521453this._row.getCells().forEach(function(cell){1454cells.push(cell.getComponent());1455});14561457return cells;1458}14591460getCell(column){1461var cell = this._row.getCell(column);1462return cell ? cell.getComponent() : false;1463}14641465_getSelf(){1466return this._row;1467}1468}14691470//public cell object1471class CellComponent {14721473constructor (cell){1474this._cell = cell;14751476return new Proxy(this, {1477get: function(target, name, receiver) {1478if (typeof target[name] !== "undefined") {1479return target[name];1480}else {1481return target._cell.table.componentFunctionBinder.handle("cell", target._cell, name);1482}1483}1484});1485}14861487getValue(){1488return this._cell.getValue();1489}14901491getOldValue(){1492return this._cell.getOldValue();1493}14941495getInitialValue(){1496return this._cell.initialValue;1497}14981499getElement(){1500return this._cell.getElement();1501}15021503getRow(){1504return this._cell.row.getComponent();1505}15061507getData(transform){1508return this._cell.row.getData(transform);1509}1510getType(){1511return "cell";1512}1513getField(){1514return this._cell.column.getField();1515}15161517getColumn(){1518return this._cell.column.getComponent();1519}15201521setValue(value, mutate){1522if(typeof mutate == "undefined"){1523mutate = true;1524}15251526this._cell.setValue(value, mutate);1527}15281529restoreOldValue(){1530this._cell.setValueActual(this._cell.getOldValue());1531}15321533restoreInitialValue(){1534this._cell.setValueActual(this._cell.initialValue);1535}15361537checkHeight(){1538this._cell.checkHeight();1539}15401541getTable(){1542return this._cell.table;1543}15441545_getSelf(){1546return this._cell;1547}1548}15491550class Cell extends CoreFeature{1551constructor(column, row){1552super(column.table);15531554this.table = column.table;1555this.column = column;1556this.row = row;1557this.element = null;1558this.value = null;1559this.initialValue;1560this.oldValue = null;1561this.modules = {};15621563this.height = null;1564this.width = null;1565this.minWidth = null;15661567this.component = null;15681569this.loaded = false; //track if the cell has been added to the DOM yet15701571this.build();1572}15731574//////////////// Setup Functions /////////////////1575//generate element1576build(){1577this.generateElement();15781579this.setWidth();15801581this._configureCell();15821583this.setValueActual(this.column.getFieldValue(this.row.data));15841585this.initialValue = this.value;1586}15871588generateElement(){1589this.element = document.createElement('div');1590this.element.className = "tabulator-cell";1591this.element.setAttribute("role", "gridcell");1592}15931594_configureCell(){1595var element = this.element,1596field = this.column.getField(),1597vertAligns = {1598top:"flex-start",1599bottom:"flex-end",1600middle:"center",1601},1602hozAligns = {1603left:"flex-start",1604right:"flex-end",1605center:"center",1606};16071608//set text alignment1609element.style.textAlign = this.column.hozAlign;16101611if(this.column.vertAlign){1612element.style.display = "inline-flex";16131614element.style.alignItems = vertAligns[this.column.vertAlign] || "";16151616if(this.column.hozAlign){1617element.style.justifyContent = hozAligns[this.column.hozAlign] || "";1618}1619}16201621if(field){1622element.setAttribute("tabulator-field", field);1623}16241625//add class to cell if needed1626if(this.column.definition.cssClass){1627var classNames = this.column.definition.cssClass.split(" ");1628classNames.forEach((className) => {1629element.classList.add(className);1630});1631}16321633this.dispatch("cell-init", this);16341635//hide cell if not visible1636if(!this.column.visible){1637this.hide();1638}1639}16401641//generate cell contents1642_generateContents(){1643var val;16441645val = this.chain("cell-format", this, null, () => {1646return this.element.innerHTML = this.value;1647});16481649switch(typeof val){1650case "object":1651if(val instanceof Node){16521653//clear previous cell contents1654while(this.element.firstChild) this.element.removeChild(this.element.firstChild);16551656this.element.appendChild(val);1657}else {1658this.element.innerHTML = "";16591660if(val != null){1661console.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);1662}1663}1664break;1665case "undefined":1666this.element.innerHTML = "";1667break;1668default:1669this.element.innerHTML = val;1670}1671}16721673cellRendered(){1674this.dispatch("cell-rendered", this);1675}16761677//////////////////// Getters ////////////////////1678getElement(containerOnly){1679if(!this.loaded){1680this.loaded = true;1681if(!containerOnly){1682this.layoutElement();1683}1684}16851686return this.element;1687}16881689getValue(){1690return this.value;1691}16921693getOldValue(){1694return this.oldValue;1695}16961697//////////////////// Actions ////////////////////1698setValue(value, mutate, force){1699var changed = this.setValueProcessData(value, mutate, force);17001701if(changed){1702this.dispatch("cell-value-updated", this);17031704this.cellRendered();17051706if(this.column.definition.cellEdited){1707this.column.definition.cellEdited.call(this.table, this.getComponent());1708}17091710this.dispatchExternal("cellEdited", this.getComponent());17111712if(this.subscribedExternal("dataChanged")){1713this.dispatchExternal("dataChanged", this.table.rowManager.getData());1714}1715}1716}17171718setValueProcessData(value, mutate, force){1719var changed = false;17201721if(this.value !== value || force){17221723changed = true;17241725if(mutate){1726value = this.chain("cell-value-changing", [this, value], null, value);1727}1728}17291730this.setValueActual(value);17311732if(changed){1733this.dispatch("cell-value-changed", this);1734}17351736return changed;1737}17381739setValueActual(value){1740this.oldValue = this.value;17411742this.value = value;17431744this.dispatch("cell-value-save-before", this);17451746this.column.setFieldValue(this.row.data, value);17471748this.dispatch("cell-value-save-after", this);17491750if(this.loaded){1751this.layoutElement();1752}1753}17541755layoutElement(){1756this._generateContents();17571758this.dispatch("cell-layout", this);1759}17601761setWidth(){1762this.width = this.column.width;1763this.element.style.width = this.column.widthStyled;1764}17651766clearWidth(){1767this.width = "";1768this.element.style.width = "";1769}17701771getWidth(){1772return this.width || this.element.offsetWidth;1773}17741775setMinWidth(){1776this.minWidth = this.column.minWidth;1777this.element.style.minWidth = this.column.minWidthStyled;1778}17791780setMaxWidth(){1781this.maxWidth = this.column.maxWidth;1782this.element.style.maxWidth = this.column.maxWidthStyled;1783}17841785checkHeight(){1786// var height = this.element.css("height");1787this.row.reinitializeHeight();1788}17891790clearHeight(){1791this.element.style.height = "";1792this.height = null;17931794this.dispatch("cell-height", this, "");1795}17961797setHeight(){1798this.height = this.row.height;1799this.element.style.height = this.row.heightStyled;18001801this.dispatch("cell-height", this, this.row.heightStyled);1802}18031804getHeight(){1805return this.height || this.element.offsetHeight;1806}18071808show(){1809this.element.style.display = this.column.vertAlign ? "inline-flex" : "";1810}18111812hide(){1813this.element.style.display = "none";1814}18151816delete(){1817this.dispatch("cell-delete", this);18181819if(!this.table.rowManager.redrawBlock && this.element.parentNode){1820this.element.parentNode.removeChild(this.element);1821}18221823this.element = false;1824this.column.deleteCell(this);1825this.row.deleteCell(this);1826this.calcs = {};1827}18281829getIndex(){1830return this.row.getCellIndex(this);1831}18321833//////////////// Object Generation /////////////////1834getComponent(){1835if(!this.component){1836this.component = new CellComponent(this);1837}18381839return this.component;1840}1841}18421843//public column object1844class ColumnComponent {1845constructor (column){1846this._column = column;1847this.type = "ColumnComponent";18481849return new Proxy(this, {1850get: function(target, name, receiver) {1851if (typeof target[name] !== "undefined") {1852return target[name];1853}else {1854return target._column.table.componentFunctionBinder.handle("column", target._column, name);1855}1856}1857});1858}18591860getElement(){1861return this._column.getElement();1862}18631864getDefinition(){1865return this._column.getDefinition();1866}18671868getField(){1869return this._column.getField();1870}18711872getTitleDownload() {1873return this._column.getTitleDownload();1874}18751876getCells(){1877var cells = [];18781879this._column.cells.forEach(function(cell){1880cells.push(cell.getComponent());1881});18821883return cells;1884}18851886isVisible(){1887return this._column.visible;1888}18891890show(){1891if(this._column.isGroup){1892this._column.columns.forEach(function(column){1893column.show();1894});1895}else {1896this._column.show();1897}1898}18991900hide(){1901if(this._column.isGroup){1902this._column.columns.forEach(function(column){1903column.hide();1904});1905}else {1906this._column.hide();1907}1908}19091910toggle(){1911if(this._column.visible){1912this.hide();1913}else {1914this.show();1915}1916}19171918delete(){1919return this._column.delete();1920}19211922getSubColumns(){1923var output = [];19241925if(this._column.columns.length){1926this._column.columns.forEach(function(column){1927output.push(column.getComponent());1928});1929}19301931return output;1932}19331934getParentColumn(){1935return this._column.parent instanceof Column ? this._column.parent.getComponent() : false;1936}19371938_getSelf(){1939return this._column;1940}19411942scrollTo(position, ifVisible){1943return this._column.table.columnManager.scrollToColumn(this._column, position, ifVisible);1944}19451946getTable(){1947return this._column.table;1948}19491950move(to, after){1951var toColumn = this._column.table.columnManager.findColumn(to);19521953if(toColumn){1954this._column.table.columnManager.moveColumn(this._column, toColumn, after);1955}else {1956console.warn("Move Error - No matching column found:", toColumn);1957}1958}19591960getNextColumn(){1961var nextCol = this._column.nextColumn();19621963return nextCol ? nextCol.getComponent() : false;1964}19651966getPrevColumn(){1967var prevCol = this._column.prevColumn();19681969return prevCol ? prevCol.getComponent() : false;1970}19711972updateDefinition(updates){1973return this._column.updateDefinition(updates);1974}19751976getWidth(){1977return this._column.getWidth();1978}19791980setWidth(width){1981var result;19821983if(width === true){1984result = this._column.reinitializeWidth(true);1985}else {1986result = this._column.setWidth(width);1987}19881989this._column.table.columnManager.rerenderColumns(true);19901991return result;1992}1993}19941995var defaultColumnOptions = {1996"title": undefined,1997"field": undefined,1998"columns": undefined,1999"visible": undefined,2000"hozAlign": undefined,2001"vertAlign": undefined,2002"width": undefined,2003"minWidth": 40,2004"maxWidth": undefined,2005"maxInitialWidth": undefined,2006"cssClass": undefined,2007"variableHeight": undefined,2008"headerVertical": undefined,2009"headerHozAlign": undefined,2010"headerWordWrap": false,2011"editableTitle": undefined,2012};20132014class Column extends CoreFeature{20152016constructor(def, parent){2017super(parent.table);20182019this.definition = def; //column definition2020this.parent = parent; //hold parent object2021this.type = "column"; //type of element2022this.columns = []; //child columns2023this.cells = []; //cells bound to this column2024this.element = this.createElement(); //column header element2025this.contentElement = false;2026this.titleHolderElement = false;2027this.titleElement = false;2028this.groupElement = this.createGroupElement(); //column group holder element2029this.isGroup = false;2030this.hozAlign = ""; //horizontal text alignment2031this.vertAlign = ""; //vert text alignment20322033//multi dimensional filed handling2034this.field ="";2035this.fieldStructure = "";2036this.getFieldValue = "";2037this.setFieldValue = "";20382039this.titleDownload = null;2040this.titleFormatterRendered = false;20412042this.mapDefinitions();20432044this.setField(this.definition.field);20452046this.modules = {}; //hold module variables;20472048this.width = null; //column width2049this.widthStyled = ""; //column width pre-styled to improve render efficiency2050this.maxWidth = null; //column maximum width2051this.maxWidthStyled = ""; //column maximum pre-styled to improve render efficiency2052this.maxInitialWidth = null;2053this.minWidth = null; //column minimum width2054this.minWidthStyled = ""; //column minimum pre-styled to improve render efficiency2055this.widthFixed = false; //user has specified a width for this column20562057this.visible = true; //default visible state20582059this.component = null;20602061//initialize column2062if(this.definition.columns){20632064this.isGroup = true;20652066this.definition.columns.forEach((def, i) => {2067var newCol = new Column(def, this);2068this.attachColumn(newCol);2069});20702071this.checkColumnVisibility();2072}else {2073parent.registerColumnField(this);2074}20752076this._initialize();2077}20782079createElement (){2080var el = document.createElement("div");20812082el.classList.add("tabulator-col");2083el.setAttribute("role", "columnheader");2084el.setAttribute("aria-sort", "none");20852086switch(this.table.options.columnHeaderVertAlign){2087case "middle":2088el.style.justifyContent = "center";2089break;2090case "bottom":2091el.style.justifyContent = "flex-end";2092break;2093}20942095return el;2096}20972098createGroupElement (){2099var el = document.createElement("div");21002101el.classList.add("tabulator-col-group-cols");21022103return el;2104}21052106mapDefinitions(){2107var defaults = this.table.options.columnDefaults;21082109//map columnDefaults onto column definitions2110if(defaults){2111for(let key in defaults){2112if(typeof this.definition[key] === "undefined"){2113this.definition[key] = defaults[key];2114}2115}2116}21172118this.definition = this.table.columnManager.optionsList.generate(Column.defaultOptionList, this.definition);2119}21202121checkDefinition(){2122Object.keys(this.definition).forEach((key) => {2123if(Column.defaultOptionList.indexOf(key) === -1){2124console.warn("Invalid column definition option in '" + (this.field || this.definition.title) + "' column:", key);2125}2126});2127}21282129setField(field){2130this.field = field;2131this.fieldStructure = field ? (this.table.options.nestedFieldSeparator ? field.split(this.table.options.nestedFieldSeparator) : [field]) : [];2132this.getFieldValue = this.fieldStructure.length > 1 ? this._getNestedData : this._getFlatData;2133this.setFieldValue = this.fieldStructure.length > 1 ? this._setNestedData : this._setFlatData;2134}21352136//register column position with column manager2137registerColumnPosition(column){2138this.parent.registerColumnPosition(column);2139}21402141//register column position with column manager2142registerColumnField(column){2143this.parent.registerColumnField(column);2144}21452146//trigger position registration2147reRegisterPosition(){2148if(this.isGroup){2149this.columns.forEach(function(column){2150column.reRegisterPosition();2151});2152}else {2153this.registerColumnPosition(this);2154}2155}21562157//build header element2158_initialize(){2159var def = this.definition;21602161while(this.element.firstChild) this.element.removeChild(this.element.firstChild);21622163if(def.headerVertical){2164this.element.classList.add("tabulator-col-vertical");21652166if(def.headerVertical === "flip"){2167this.element.classList.add("tabulator-col-vertical-flip");2168}2169}21702171this.contentElement = this._buildColumnHeaderContent();21722173this.element.appendChild(this.contentElement);21742175if(this.isGroup){2176this._buildGroupHeader();2177}else {2178this._buildColumnHeader();2179}21802181this.dispatch("column-init", this);2182}21832184//build header element for header2185_buildColumnHeader(){2186var def = this.definition;21872188this.dispatch("column-layout", this);21892190//set column visibility2191if(typeof def.visible != "undefined"){2192if(def.visible){2193this.show(true);2194}else {2195this.hide(true);2196}2197}21982199//assign additional css classes to column header2200if(def.cssClass){2201var classNames = def.cssClass.split(" ");2202classNames.forEach((className) => {2203this.element.classList.add(className);2204});2205}22062207if(def.field){2208this.element.setAttribute("tabulator-field", def.field);2209}22102211//set min width if present2212this.setMinWidth(parseInt(def.minWidth));22132214if (def.maxInitialWidth) {2215this.maxInitialWidth = parseInt(def.maxInitialWidth);2216}22172218if(def.maxWidth){2219this.setMaxWidth(parseInt(def.maxWidth));2220}22212222this.reinitializeWidth();22232224//set horizontal text alignment2225this.hozAlign = this.definition.hozAlign;2226this.vertAlign = this.definition.vertAlign;22272228this.titleElement.style.textAlign = this.definition.headerHozAlign;2229}22302231_buildColumnHeaderContent(){2232var contentElement = document.createElement("div");2233contentElement.classList.add("tabulator-col-content");22342235this.titleHolderElement = document.createElement("div");2236this.titleHolderElement.classList.add("tabulator-col-title-holder");22372238contentElement.appendChild(this.titleHolderElement);22392240this.titleElement = this._buildColumnHeaderTitle();22412242this.titleHolderElement.appendChild(this.titleElement);22432244return contentElement;2245}22462247//build title element of column2248_buildColumnHeaderTitle(){2249var def = this.definition;22502251var titleHolderElement = document.createElement("div");2252titleHolderElement.classList.add("tabulator-col-title");22532254if(def.headerWordWrap){2255titleHolderElement.classList.add("tabulator-col-title-wrap");2256}22572258if(def.editableTitle){2259var titleElement = document.createElement("input");2260titleElement.classList.add("tabulator-title-editor");22612262titleElement.addEventListener("click", (e) => {2263e.stopPropagation();2264titleElement.focus();2265});22662267titleElement.addEventListener("change", () => {2268def.title = titleElement.value;2269this.dispatchExternal("columnTitleChanged", this.getComponent());2270});22712272titleHolderElement.appendChild(titleElement);22732274if(def.field){2275this.langBind("columns|" + def.field, (text) => {2276titleElement.value = text || (def.title || " ");2277});2278}else {2279titleElement.value = def.title || " ";2280}22812282}else {2283if(def.field){2284this.langBind("columns|" + def.field, (text) => {2285this._formatColumnHeaderTitle(titleHolderElement, text || (def.title || " "));2286});2287}else {2288this._formatColumnHeaderTitle(titleHolderElement, def.title || " ");2289}2290}22912292return titleHolderElement;2293}22942295_formatColumnHeaderTitle(el, title){2296var contents = this.chain("column-format", [this, title, el], null, () => {2297return title;2298});22992300switch(typeof contents){2301case "object":2302if(contents instanceof Node){2303el.appendChild(contents);2304}else {2305el.innerHTML = "";2306console.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);2307}2308break;2309case "undefined":2310el.innerHTML = "";2311break;2312default:2313el.innerHTML = contents;2314}2315}23162317//build header element for column group2318_buildGroupHeader(){2319this.element.classList.add("tabulator-col-group");2320this.element.setAttribute("role", "columngroup");2321this.element.setAttribute("aria-title", this.definition.title);23222323//asign additional css classes to column header2324if(this.definition.cssClass){2325var classNames = this.definition.cssClass.split(" ");2326classNames.forEach((className) => {2327this.element.classList.add(className);2328});2329}23302331this.titleElement.style.textAlign = this.definition.headerHozAlign;23322333this.element.appendChild(this.groupElement);2334}23352336//flat field lookup2337_getFlatData(data){2338return data[this.field];2339}23402341//nested field lookup2342_getNestedData(data){2343var dataObj = data,2344structure = this.fieldStructure,2345length = structure.length,2346output;23472348for(let i = 0; i < length; i++){23492350dataObj = dataObj[structure[i]];23512352output = dataObj;23532354if(!dataObj){2355break;2356}2357}23582359return output;2360}23612362//flat field set2363_setFlatData(data, value){2364if(this.field){2365data[this.field] = value;2366}2367}23682369//nested field set2370_setNestedData(data, value){2371var dataObj = data,2372structure = this.fieldStructure,2373length = structure.length;23742375for(let i = 0; i < length; i++){23762377if(i == length -1){2378dataObj[structure[i]] = value;2379}else {2380if(!dataObj[structure[i]]){2381if(typeof value !== "undefined"){2382dataObj[structure[i]] = {};2383}else {2384break;2385}2386}23872388dataObj = dataObj[structure[i]];2389}2390}2391}23922393//attach column to this group2394attachColumn(column){2395if(this.groupElement){2396this.columns.push(column);2397this.groupElement.appendChild(column.getElement());23982399column.columnRendered();2400}else {2401console.warn("Column Warning - Column being attached to another column instead of column group");2402}2403}24042405//vertically align header in column2406verticalAlign(alignment, height){24072408//calculate height of column header and group holder element2409var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : (height || this.parent.getHeadersElement().clientHeight);2410// var parentHeight = this.parent.isGroup ? this.parent.getGroupElement().clientHeight : this.parent.getHeadersElement().clientHeight;24112412this.element.style.height = parentHeight + "px";24132414this.dispatch("column-height", this, this.element.style.height);24152416if(this.isGroup){2417this.groupElement.style.minHeight = (parentHeight - this.contentElement.offsetHeight) + "px";2418}24192420//vertically align cell contents2421// if(!this.isGroup && alignment !== "top"){2422// if(alignment === "bottom"){2423// this.element.style.paddingTop = (this.element.clientHeight - this.contentElement.offsetHeight) + "px";2424// }else{2425// this.element.style.paddingTop = ((this.element.clientHeight - this.contentElement.offsetHeight) / 2) + "px";2426// }2427// }24282429this.columns.forEach(function(column){2430column.verticalAlign(alignment);2431});2432}24332434//clear vertical alignment2435clearVerticalAlign(){2436this.element.style.paddingTop = "";2437this.element.style.height = "";2438this.element.style.minHeight = "";2439this.groupElement.style.minHeight = "";24402441this.columns.forEach(function(column){2442column.clearVerticalAlign();2443});24442445this.dispatch("column-height", this, "");2446}24472448//// Retrieve Column Information ////2449//return column header element2450getElement(){2451return this.element;2452}24532454//return column group element2455getGroupElement(){2456return this.groupElement;2457}24582459//return field name2460getField(){2461return this.field;2462}24632464getTitleDownload() {2465return this.titleDownload;2466}24672468//return the first column in a group2469getFirstColumn(){2470if(!this.isGroup){2471return this;2472}else {2473if(this.columns.length){2474return this.columns[0].getFirstColumn();2475}else {2476return false;2477}2478}2479}24802481//return the last column in a group2482getLastColumn(){2483if(!this.isGroup){2484return this;2485}else {2486if(this.columns.length){2487return this.columns[this.columns.length -1].getLastColumn();2488}else {2489return false;2490}2491}2492}24932494//return all columns in a group2495getColumns(traverse){2496var columns = [];24972498if(traverse){2499this.columns.forEach((column) => {2500columns.push(column);25012502columns = columns.concat(column.getColumns(true));2503});2504}else {2505columns = this.columns;2506}25072508return columns;2509}25102511//return all columns in a group2512getCells(){2513return this.cells;2514}25152516//retrieve the top column in a group of columns2517getTopColumn(){2518if(this.parent.isGroup){2519return this.parent.getTopColumn();2520}else {2521return this;2522}2523}25242525//return column definition object2526getDefinition(updateBranches){2527var colDefs = [];25282529if(this.isGroup && updateBranches){2530this.columns.forEach(function(column){2531colDefs.push(column.getDefinition(true));2532});25332534this.definition.columns = colDefs;2535}25362537return this.definition;2538}25392540//////////////////// Actions ////////////////////2541checkColumnVisibility(){2542var visible = false;25432544this.columns.forEach(function(column){2545if(column.visible){2546visible = true;2547}2548});25492550if(visible){2551this.show();2552this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);2553}else {2554this.hide();2555}2556}25572558//show column2559show(silent, responsiveToggle){2560if(!this.visible){2561this.visible = true;25622563this.element.style.display = "";25642565if(this.parent.isGroup){2566this.parent.checkColumnVisibility();2567}25682569this.cells.forEach(function(cell){2570cell.show();2571});25722573if(!this.isGroup && this.width === null){2574this.reinitializeWidth();2575}25762577this.table.columnManager.verticalAlignHeaders();25782579this.dispatch("column-show", this, responsiveToggle);25802581if(!silent){2582this.dispatchExternal("columnVisibilityChanged", this.getComponent(), true);2583}25842585if(this.parent.isGroup){2586this.parent.matchChildWidths();2587}25882589if(!this.silent){2590this.table.columnManager.rerenderColumns();2591}2592}2593}25942595//hide column2596hide(silent, responsiveToggle){2597if(this.visible){2598this.visible = false;25992600this.element.style.display = "none";26012602this.table.columnManager.verticalAlignHeaders();26032604if(this.parent.isGroup){2605this.parent.checkColumnVisibility();2606}26072608this.cells.forEach(function(cell){2609cell.hide();2610});26112612this.dispatch("column-hide", this, responsiveToggle);26132614if(!silent){2615this.dispatchExternal("columnVisibilityChanged", this.getComponent(), false);2616}26172618if(this.parent.isGroup){2619this.parent.matchChildWidths();2620}26212622if(!this.silent){2623this.table.columnManager.rerenderColumns();2624}2625}2626}26272628matchChildWidths(){2629var childWidth = 0;26302631if(this.contentElement && this.columns.length){2632this.columns.forEach(function(column){2633if(column.visible){2634childWidth += column.getWidth();2635}2636});26372638this.contentElement.style.maxWidth = (childWidth - 1) + "px";26392640if(this.parent.isGroup){2641this.parent.matchChildWidths();2642}2643}2644}26452646removeChild(child){2647var index = this.columns.indexOf(child);26482649if(index > -1){2650this.columns.splice(index, 1);2651}26522653if(!this.columns.length){2654this.delete();2655}2656}26572658setWidth(width){2659this.widthFixed = true;2660this.setWidthActual(width);2661}26622663setWidthActual(width){2664if(isNaN(width)){2665width = Math.floor((this.table.element.clientWidth/100) * parseInt(width));2666}26672668width = Math.max(this.minWidth, width);26692670if(this.maxWidth){2671width = Math.min(this.maxWidth, width);2672}26732674this.width = width;2675this.widthStyled = width ? width + "px" : "";26762677this.element.style.width = this.widthStyled;26782679if(!this.isGroup){2680this.cells.forEach(function(cell){2681cell.setWidth();2682});2683}26842685if(this.parent.isGroup){2686this.parent.matchChildWidths();2687}26882689this.dispatch("column-width", this);2690}26912692checkCellHeights(){2693var rows = [];26942695this.cells.forEach(function(cell){2696if(cell.row.heightInitialized){2697if(cell.row.getElement().offsetParent !== null){2698rows.push(cell.row);2699cell.row.clearCellHeight();2700}else {2701cell.row.heightInitialized = false;2702}2703}2704});27052706rows.forEach(function(row){2707row.calcHeight();2708});27092710rows.forEach(function(row){2711row.setCellHeight();2712});2713}27142715getWidth(){2716var width = 0;27172718if(this.isGroup){2719this.columns.forEach(function(column){2720if(column.visible){2721width += column.getWidth();2722}2723});2724}else {2725width = this.width;2726}27272728return width;2729}27302731getLeftOffset(){2732var offset = this.element.offsetLeft;27332734if(this.parent.isGroup){2735offset += this.parent.getLeftOffset();2736}27372738return offset;2739}27402741getHeight(){2742return Math.ceil(this.element.getBoundingClientRect().height);2743}27442745setMinWidth(minWidth){2746if(this.maxWidth && minWidth > this.maxWidth){2747minWidth = this.maxWidth;27482749console.warn("the minWidth ("+ minWidth + "px) for column '" + this.field + "' cannot be bigger that its maxWidth ("+ this.maxWidthStyled + ")");2750}27512752this.minWidth = minWidth;2753this.minWidthStyled = minWidth ? minWidth + "px" : "";27542755this.element.style.minWidth = this.minWidthStyled;27562757this.cells.forEach(function(cell){2758cell.setMinWidth();2759});2760}27612762setMaxWidth(maxWidth){2763if(this.minWidth && maxWidth < this.minWidth){2764maxWidth = this.minWidth;27652766console.warn("the maxWidth ("+ maxWidth + "px) for column '" + this.field + "' cannot be smaller that its minWidth ("+ this.minWidthStyled + ")");2767}27682769this.maxWidth = maxWidth;2770this.maxWidthStyled = maxWidth ? maxWidth + "px" : "";27712772this.element.style.maxWidth = this.maxWidthStyled;27732774this.cells.forEach(function(cell){2775cell.setMaxWidth();2776});2777}27782779delete(){2780return new Promise((resolve, reject) => {2781if(this.isGroup){2782this.columns.forEach(function(column){2783column.delete();2784});2785}27862787this.dispatch("column-delete", this);27882789var cellCount = this.cells.length;27902791for(let i = 0; i < cellCount; i++){2792this.cells[0].delete();2793}27942795if(this.element.parentNode){2796this.element.parentNode.removeChild(this.element);2797}27982799this.element = false;2800this.contentElement = false;2801this.titleElement = false;2802this.groupElement = false;28032804if(this.parent.isGroup){2805this.parent.removeChild(this);2806}28072808this.table.columnManager.deregisterColumn(this);28092810this.table.columnManager.rerenderColumns(true);28112812resolve();2813});2814}28152816columnRendered(){2817if(this.titleFormatterRendered){2818this.titleFormatterRendered();2819}28202821this.dispatch("column-rendered", this);2822}28232824//////////////// Cell Management /////////////////2825//generate cell for this column2826generateCell(row){2827var cell = new Cell(this, row);28282829this.cells.push(cell);28302831return cell;2832}28332834nextColumn(){2835var index = this.table.columnManager.findColumnIndex(this);2836return index > -1 ? this._nextVisibleColumn(index + 1) : false;2837}28382839_nextVisibleColumn(index){2840var column = this.table.columnManager.getColumnByIndex(index);2841return !column || column.visible ? column : this._nextVisibleColumn(index + 1);2842}28432844prevColumn(){2845var index = this.table.columnManager.findColumnIndex(this);2846return index > -1 ? this._prevVisibleColumn(index - 1) : false;2847}28482849_prevVisibleColumn(index){2850var column = this.table.columnManager.getColumnByIndex(index);2851return !column || column.visible ? column : this._prevVisibleColumn(index - 1);2852}28532854reinitializeWidth(force){2855this.widthFixed = false;28562857//set width if present2858if(typeof this.definition.width !== "undefined" && !force){2859// maxInitialWidth ignored here as width specified2860this.setWidth(this.definition.width);2861}28622863this.dispatch("column-width-fit-before", this);28642865this.fitToData(force);28662867this.dispatch("column-width-fit-after", this);2868}28692870//set column width to maximum cell width for non group columns2871fitToData(force){2872if(this.isGroup){2873return;2874}28752876if(!this.widthFixed){2877this.element.style.width = "";28782879this.cells.forEach((cell) => {2880cell.clearWidth();2881});2882}28832884var maxWidth = this.element.offsetWidth;28852886if(!this.width || !this.widthFixed){2887this.cells.forEach((cell) => {2888var width = cell.getWidth();28892890if(width > maxWidth){2891maxWidth = width;2892}2893});28942895if(maxWidth){2896var setTo = maxWidth + 1;2897if (this.maxInitialWidth && !force) {2898setTo = Math.min(setTo, this.maxInitialWidth);2899}2900this.setWidthActual(setTo);2901}2902}2903}29042905updateDefinition(updates){2906var definition;29072908if(!this.isGroup){2909if(!this.parent.isGroup){2910definition = Object.assign({}, this.getDefinition());2911definition = Object.assign(definition, updates);29122913return this.table.columnManager.addColumn(definition, false, this)2914.then((column) => {29152916if(definition.field == this.field){2917this.field = false; //clear field name to prevent deletion of duplicate column from arrays2918}29192920return this.delete()2921.then(() => {2922return column.getComponent();2923});29242925});2926}else {2927console.error("Column Update Error - The updateDefinition function is only available on ungrouped columns");2928return Promise.reject("Column Update Error - The updateDefinition function is only available on columns, not column groups");2929}2930}else {2931console.error("Column Update Error - The updateDefinition function is only available on ungrouped columns");2932return Promise.reject("Column Update Error - The updateDefinition function is only available on columns, not column groups");2933}2934}29352936deleteCell(cell){2937var index = this.cells.indexOf(cell);29382939if(index > -1){2940this.cells.splice(index, 1);2941}2942}29432944//////////////// Object Generation /////////////////2945getComponent(){2946if(!this.component){2947this.component = new ColumnComponent(this);2948}29492950return this.component;2951}2952}29532954Column.defaultOptionList = defaultColumnOptions;29552956//public row object2957class RowComponent {29582959constructor (row){2960this._row = row;29612962return new Proxy(this, {2963get: function(target, name, receiver) {2964if (typeof target[name] !== "undefined") {2965return target[name];2966}else {2967return target._row.table.componentFunctionBinder.handle("row", target._row, name);2968}2969}2970});2971}29722973getData(transform){2974return this._row.getData(transform);2975}29762977getElement(){2978return this._row.getElement();2979}29802981getCells(){2982var cells = [];29832984this._row.getCells().forEach(function(cell){2985cells.push(cell.getComponent());2986});29872988return cells;2989}29902991getCell(column){2992var cell = this._row.getCell(column);2993return cell ? cell.getComponent() : false;2994}29952996getIndex(){2997return this._row.getData("data")[this._row.table.options.index];2998}29993000getPosition(){3001return this._row.getPosition();3002}30033004watchPosition(callback){3005return this._row.watchPosition(callback);3006}30073008delete(){3009return this._row.delete();3010}30113012scrollTo(position, ifVisible){3013return this._row.table.rowManager.scrollToRow(this._row, position, ifVisible);3014}30153016move(to, after){3017this._row.moveToRow(to, after);3018}30193020update(data){3021return this._row.updateData(data);3022}30233024normalizeHeight(){3025this._row.normalizeHeight(true);3026}30273028_getSelf(){3029return this._row;3030}30313032reformat(){3033return this._row.reinitialize();3034}30353036getTable(){3037return this._row.table;3038}30393040getNextRow(){3041var row = this._row.nextRow();3042return row ? row.getComponent() : row;3043}30443045getPrevRow(){3046var row = this._row.prevRow();3047return row ? row.getComponent() : row;3048}3049}30503051class Row extends CoreFeature{3052constructor (data, parent, type = "row"){3053super(parent.table);30543055this.parent = parent;3056this.data = {};3057this.type = type; //type of element3058this.element = false;3059this.modules = {}; //hold module variables;3060this.cells = [];3061this.height = 0; //hold element height3062this.heightStyled = ""; //hold element height pre-styled to improve render efficiency3063this.manualHeight = false; //user has manually set row height3064this.outerHeight = 0; //hold elements outer height3065this.initialized = false; //element has been rendered3066this.heightInitialized = false; //element has resized cells to fit3067this.position = 0; //store position of element in row list3068this.positionWatchers = [];30693070this.component = null;30713072this.created = false;30733074this.setData(data);3075}30763077create(){3078if(!this.created){3079this.created = true;3080this.generateElement();3081}3082}30833084createElement (){3085var el = document.createElement("div");30863087el.classList.add("tabulator-row");3088el.setAttribute("role", "row");30893090this.element = el;3091}30923093getElement(){3094this.create();3095return this.element;3096}30973098detachElement(){3099if (this.element && this.element.parentNode){3100this.element.parentNode.removeChild(this.element);3101}3102}31033104generateElement(){3105this.createElement();3106this.dispatch("row-init", this);3107}31083109generateCells(){3110this.cells = this.table.columnManager.generateCells(this);3111}31123113//functions to setup on first render3114initialize(force, inFragment){3115this.create();31163117if(!this.initialized || force){31183119this.deleteCells();31203121while(this.element.firstChild) this.element.removeChild(this.element.firstChild);31223123this.dispatch("row-layout-before", this);31243125this.generateCells();31263127this.initialized = true;31283129this.table.columnManager.renderer.renderRowCells(this, inFragment);31303131if(force){3132this.normalizeHeight();3133}31343135this.dispatch("row-layout", this);31363137if(this.table.options.rowFormatter){3138this.table.options.rowFormatter(this.getComponent());3139}31403141this.dispatch("row-layout-after", this);3142}else {3143this.table.columnManager.renderer.rerenderRowCells(this, inFragment);3144}3145}31463147rendered(){3148this.cells.forEach((cell) => {3149cell.cellRendered();3150});3151}31523153reinitializeHeight(){3154this.heightInitialized = false;31553156if(this.element && this.element.offsetParent !== null){3157this.normalizeHeight(true);3158}3159}31603161deinitialize(){3162this.initialized = false;3163}31643165deinitializeHeight(){3166this.heightInitialized = false;3167}31683169reinitialize(children){3170this.initialized = false;3171this.heightInitialized = false;31723173if(!this.manualHeight){3174this.height = 0;3175this.heightStyled = "";3176}31773178if(this.element && this.element.offsetParent !== null){3179this.initialize(true);3180}31813182this.dispatch("row-relayout", this);3183}31843185//get heights when doing bulk row style calcs in virtual DOM3186calcHeight(force){3187var maxHeight = 0,3188minHeight;31893190if(this.table.options.rowHeight){3191this.height = this.table.options.rowHeight;3192}else {3193minHeight = this.table.options.resizableRows ? this.element.clientHeight : 0;31943195this.cells.forEach(function(cell){3196var height = cell.getHeight();3197if(height > maxHeight){3198maxHeight = height;3199}3200});32013202if(force){3203this.height = Math.max(maxHeight, minHeight);3204}else {3205this.height = this.manualHeight ? this.height : Math.max(maxHeight, minHeight);3206}3207}32083209this.heightStyled = this.height ? this.height + "px" : "";3210this.outerHeight = this.element.offsetHeight;3211}32123213//set of cells3214setCellHeight(){3215this.cells.forEach(function(cell){3216cell.setHeight();3217});32183219this.heightInitialized = true;3220}32213222clearCellHeight(){3223this.cells.forEach(function(cell){3224cell.clearHeight();3225});3226}32273228//normalize the height of elements in the row3229normalizeHeight(force){3230if(force && !this.table.options.rowHeight){3231this.clearCellHeight();3232}32333234this.calcHeight(force);32353236this.setCellHeight();3237}32383239//set height of rows3240setHeight(height, force){3241if(this.height != height || force){32423243this.manualHeight = true;32443245this.height = height;3246this.heightStyled = height ? height + "px" : "";32473248this.setCellHeight();32493250// this.outerHeight = this.element.outerHeight();3251this.outerHeight = this.element.offsetHeight;3252}3253}32543255//return rows outer height3256getHeight(){3257return this.outerHeight;3258}32593260//return rows outer Width3261getWidth(){3262return this.element.offsetWidth;3263}32643265//////////////// Cell Management /////////////////3266deleteCell(cell){3267var index = this.cells.indexOf(cell);32683269if(index > -1){3270this.cells.splice(index, 1);3271}3272}32733274//////////////// Data Management /////////////////3275setData(data){3276this.data = this.chain("row-data-init-before", [this, data], undefined, data);32773278this.dispatch("row-data-init-after", this);3279}32803281//update the rows data3282updateData(updatedData){3283var visible = this.element && Helpers.elVisible(this.element),3284tempData = {},3285newRowData;32863287return new Promise((resolve, reject) => {32883289if(typeof updatedData === "string"){3290updatedData = JSON.parse(updatedData);3291}32923293this.dispatch("row-data-save-before", this);32943295if(this.subscribed("row-data-changing")){3296tempData = Object.assign(tempData, this.data);3297tempData = Object.assign(tempData, updatedData);3298}32993300newRowData = this.chain("row-data-changing", [this, tempData, updatedData], null, updatedData);33013302//set data3303for (let attrname in newRowData) {3304this.data[attrname] = newRowData[attrname];3305}33063307this.dispatch("row-data-save-after", this);33083309//update affected cells only3310for (let attrname in updatedData) {33113312let columns = this.table.columnManager.getColumnsByFieldRoot(attrname);33133314columns.forEach((column) => {3315let cell = this.getCell(column.getField());33163317if(cell){3318let value = column.getFieldValue(newRowData);3319if(cell.getValue() !== value){3320cell.setValueProcessData(value);33213322if(visible){3323cell.cellRendered();3324}3325}3326}3327});3328}33293330//Partial reinitialization if visible3331if(visible){3332this.normalizeHeight(true);33333334if(this.table.options.rowFormatter){3335this.table.options.rowFormatter(this.getComponent());3336}3337}else {3338this.initialized = false;3339this.height = 0;3340this.heightStyled = "";3341}33423343this.dispatch("row-data-changed", this, visible, updatedData);33443345//this.reinitialize();33463347this.dispatchExternal("rowUpdated", this.getComponent());33483349if(this.subscribedExternal("dataChanged")){3350this.dispatchExternal("dataChanged", this.table.rowManager.getData());3351}33523353resolve();3354});3355}33563357getData(transform){3358if(transform){3359return this.chain("row-data-retrieve", [this, transform], null, this.data);3360}33613362return this.data;3363}33643365getCell(column){3366var match = false;33673368column = this.table.columnManager.findColumn(column);33693370if(!this.initialized && this.cells.length === 0){3371this.generateCells();3372}33733374match = this.cells.find(function(cell){3375return cell.column === column;3376});33773378return match;3379}33803381getCellIndex(findCell){3382return this.cells.findIndex(function(cell){3383return cell === findCell;3384});3385}33863387findCell(subject){3388return this.cells.find((cell) => {3389return cell.element === subject;3390});3391}33923393getCells(){3394if(!this.initialized && this.cells.length === 0){3395this.generateCells();3396}33973398return this.cells;3399}34003401nextRow(){3402var row = this.table.rowManager.nextDisplayRow(this, true);3403return row || false;3404}34053406prevRow(){3407var row = this.table.rowManager.prevDisplayRow(this, true);3408return row || false;3409}34103411moveToRow(to, before){3412var toRow = this.table.rowManager.findRow(to);34133414if(toRow){3415this.table.rowManager.moveRowActual(this, toRow, !before);3416this.table.rowManager.refreshActiveData("display", false, true);3417}else {3418console.warn("Move Error - No matching row found:", to);3419}3420}34213422///////////////////// Actions /////////////////////3423delete(){3424this.dispatch("row-delete", this);34253426this.deleteActual();34273428return Promise.resolve();3429}34303431deleteActual(blockRedraw){3432this.detachModules();34333434this.table.rowManager.deleteRow(this, blockRedraw);34353436this.deleteCells();34373438this.initialized = false;3439this.heightInitialized = false;3440this.element = false;34413442this.dispatch("row-deleted", this);3443}34443445detachModules(){3446this.dispatch("row-deleting", this);3447}34483449deleteCells(){3450var cellCount = this.cells.length;34513452for(let i = 0; i < cellCount; i++){3453this.cells[0].delete();3454}3455}34563457wipe(){3458this.detachModules();3459this.deleteCells();34603461if(this.element){3462while(this.element.firstChild) this.element.removeChild(this.element.firstChild);34633464if(this.element.parentNode){3465this.element.parentNode.removeChild(this.element);3466}3467}34683469this.element = false;3470this.modules = {};3471}34723473isDisplayed(){3474return this.table.rowManager.getDisplayRows().includes(this);3475}34763477getPosition(){3478return this.isDisplayed() ? this.position : false;3479}34803481setPosition(position){3482if(position != this.position){3483this.position = position;34843485this.positionWatchers.forEach((callback) => {3486callback(this.position);3487});3488}3489}34903491watchPosition(callback){3492this.positionWatchers.push(callback);34933494callback(this.position);3495}34963497getGroup(){3498return this.modules.group || false;3499}35003501//////////////// Object Generation /////////////////3502getComponent(){3503if(!this.component){3504this.component = new RowComponent(this);3505}35063507return this.component;3508}3509}35103511var defaultCalculations = {3512"avg":function(values, data, calcParams){3513var output = 0,3514precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : 2;35153516if(values.length){3517output = values.reduce(function(sum, value){3518return Number(sum) + Number(value);3519});35203521output = output / values.length;35223523output = precision !== false ? output.toFixed(precision) : output;3524}35253526return parseFloat(output).toString();3527},3528"max":function(values, data, calcParams){3529var output = null,3530precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;35313532values.forEach(function(value){35333534value = Number(value);35353536if(value > output || output === null){3537output = value;3538}3539});35403541return output !== null ? (precision !== false ? output.toFixed(precision) : output) : "";3542},3543"min":function(values, data, calcParams){3544var output = null,3545precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;35463547values.forEach(function(value){35483549value = Number(value);35503551if(value < output || output === null){3552output = value;3553}3554});35553556return output !== null ? (precision !== false ? output.toFixed(precision) : output) : "";3557},3558"sum":function(values, data, calcParams){3559var output = 0,3560precision = typeof calcParams.precision !== "undefined" ? calcParams.precision : false;35613562if(values.length){3563values.forEach(function(value){3564value = Number(value);35653566output += !isNaN(value) ? Number(value) : 0;3567});3568}35693570return precision !== false ? output.toFixed(precision) : output;3571},3572"concat":function(values, data, calcParams){3573var output = 0;35743575if(values.length){3576output = values.reduce(function(sum, value){3577return String(sum) + String(value);3578});3579}35803581return output;3582},3583"count":function(values, data, calcParams){3584var output = 0;35853586if(values.length){3587values.forEach(function(value){3588if(value){3589output ++;3590}3591});3592}35933594return output;3595},3596"unique":function(values, data, calcParams){3597var unique = values.filter((value, index) => {3598return (values || value === 0) && values.indexOf(value) === index;3599});36003601return unique.length;3602},3603};36043605class ColumnCalcs extends Module{36063607constructor(table){3608super(table);36093610this.topCalcs = [];3611this.botCalcs = [];3612this.genColumn = false;3613this.topElement = this.createElement();3614this.botElement = this.createElement();3615this.topRow = false;3616this.botRow = false;3617this.topInitialized = false;3618this.botInitialized = false;36193620this.blocked = false;3621this.recalcAfterBlock = false;36223623this.registerTableOption("columnCalcs", true);36243625this.registerColumnOption("topCalc");3626this.registerColumnOption("topCalcParams");3627this.registerColumnOption("topCalcFormatter");3628this.registerColumnOption("topCalcFormatterParams");3629this.registerColumnOption("bottomCalc");3630this.registerColumnOption("bottomCalcParams");3631this.registerColumnOption("bottomCalcFormatter");3632this.registerColumnOption("bottomCalcFormatterParams");3633}36343635createElement (){3636var el = document.createElement("div");3637el.classList.add("tabulator-calcs-holder");3638return el;3639}36403641initialize(){3642this.genColumn = new Column({field:"value"}, this);36433644this.subscribe("cell-value-changed", this.cellValueChanged.bind(this));3645this.subscribe("column-init", this.initializeColumnCheck.bind(this));3646this.subscribe("row-deleted", this.rowsUpdated.bind(this));3647this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this));3648this.subscribe("row-added", this.rowsUpdated.bind(this));3649this.subscribe("column-moved", this.recalcActiveRows.bind(this));3650this.subscribe("column-add", this.recalcActiveRows.bind(this));3651this.subscribe("data-refreshed", this.recalcActiveRowsRefresh.bind(this));3652this.subscribe("table-redraw", this.tableRedraw.bind(this));3653this.subscribe("rows-visible", this.visibleRows.bind(this));3654this.subscribe("scrollbar-vertical", this.adjustForScrollbar.bind(this));36553656this.subscribe("redraw-blocked", this.blockRedraw.bind(this));3657this.subscribe("redraw-restored", this.restoreRedraw.bind(this));36583659this.subscribe("table-redrawing", this.resizeHolderWidth.bind(this));3660this.subscribe("column-resized", this.resizeHolderWidth.bind(this));3661this.subscribe("column-show", this.resizeHolderWidth.bind(this));3662this.subscribe("column-hide", this.resizeHolderWidth.bind(this));36633664this.registerTableFunction("getCalcResults", this.getResults.bind(this));3665this.registerTableFunction("recalc", this.userRecalc.bind(this));366636673668this.resizeHolderWidth();3669}36703671resizeHolderWidth(){3672this.topElement.style.minWidth = this.table.columnManager.headersElement.offsetWidth + "px";3673}367436753676tableRedraw(force){3677this.recalc(this.table.rowManager.activeRows);36783679if(force){3680this.redraw();3681}3682}36833684blockRedraw(){3685this.blocked = true;3686this.recalcAfterBlock = false;3687}368836893690restoreRedraw(){3691this.blocked = false;36923693if(this.recalcAfterBlock){3694this.recalcAfterBlock = false;3695this.recalcActiveRowsRefresh();3696}3697}36983699///////////////////////////////////3700///////// Table Functions /////////3701///////////////////////////////////3702userRecalc(){3703this.recalc(this.table.rowManager.activeRows);3704}37053706///////////////////////////////////3707///////// Internal Logic //////////3708///////////////////////////////////37093710blockCheck(){3711if(this.blocked){3712this.recalcAfterBlock = true;3713}37143715return this.blocked;3716}37173718visibleRows(viewable, rows){3719if(this.topRow){3720rows.unshift(this.topRow);3721}37223723if(this.botRow){3724rows.push(this.botRow);3725}37263727return rows;3728}37293730rowsUpdated(row){3731if(this.table.options.groupBy){3732this.recalcRowGroup(row);3733}else {3734this.recalcActiveRows();3735}3736}37373738recalcActiveRowsRefresh(){3739if(this.table.options.groupBy && this.table.options.dataTreeStartExpanded && this.table.options.dataTree){3740this.recalcAll();3741}else {3742this.recalcActiveRows();3743}3744}37453746recalcActiveRows(){3747this.recalc(this.table.rowManager.activeRows);3748}37493750cellValueChanged(cell){3751if(cell.column.definition.topCalc || cell.column.definition.bottomCalc){3752if(this.table.options.groupBy){3753if(this.table.options.columnCalcs == "table" || this.table.options.columnCalcs == "both"){3754this.recalcActiveRows();3755}37563757if(this.table.options.columnCalcs != "table"){3758this.recalcRowGroup(cell.row);3759}3760}else {3761this.recalcActiveRows();3762}3763}3764}37653766initializeColumnCheck(column){3767if(column.definition.topCalc || column.definition.bottomCalc){3768this.initializeColumn(column);3769}3770}37713772//initialize column calcs3773initializeColumn(column){3774var def = column.definition;37753776var config = {3777topCalcParams:def.topCalcParams || {},3778botCalcParams:def.bottomCalcParams || {},3779};37803781if(def.topCalc){37823783switch(typeof def.topCalc){3784case "string":3785if(ColumnCalcs.calculations[def.topCalc]){3786config.topCalc = ColumnCalcs.calculations[def.topCalc];3787}else {3788console.warn("Column Calc Error - No such calculation found, ignoring: ", def.topCalc);3789}3790break;37913792case "function":3793config.topCalc = def.topCalc;3794break;37953796}37973798if(config.topCalc){3799column.modules.columnCalcs = config;3800this.topCalcs.push(column);38013802if(this.table.options.columnCalcs != "group"){3803this.initializeTopRow();3804}3805}38063807}38083809if(def.bottomCalc){3810switch(typeof def.bottomCalc){3811case "string":3812if(ColumnCalcs.calculations[def.bottomCalc]){3813config.botCalc = ColumnCalcs.calculations[def.bottomCalc];3814}else {3815console.warn("Column Calc Error - No such calculation found, ignoring: ", def.bottomCalc);3816}3817break;38183819case "function":3820config.botCalc = def.bottomCalc;3821break;38223823}38243825if(config.botCalc){3826column.modules.columnCalcs = config;3827this.botCalcs.push(column);38283829if(this.table.options.columnCalcs != "group"){3830this.initializeBottomRow();3831}3832}3833}38343835}38363837//dummy functions to handle being mock column manager3838registerColumnField(){}38393840removeCalcs(){3841var changed = false;38423843if(this.topInitialized){3844this.topInitialized = false;3845this.topElement.parentNode.removeChild(this.topElement);3846changed = true;3847}38483849if(this.botInitialized){3850this.botInitialized = false;3851this.footerRemove(this.botElement);3852changed = true;3853}38543855if(changed){3856this.table.rowManager.adjustTableSize();3857}3858}38593860reinitializeCalcs(){3861if(this.topCalcs.length){3862this.initializeTopRow();3863}38643865if(this.botCalcs.length){3866this.initializeBottomRow();3867}3868}38693870initializeTopRow(){3871if(!this.topInitialized){3872this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);3873this.topInitialized = true;3874}3875}38763877initializeBottomRow(){3878if(!this.botInitialized){3879this.footerPrepend(this.botElement);3880this.botInitialized = true;3881}3882}38833884scrollHorizontal(left){3885if(this.botInitialized && this.botRow){3886this.botElement.scrollLeft = left;3887}3888}38893890recalc(rows){3891var data, row;38923893if(!this.blockCheck()){3894if(this.topInitialized || this.botInitialized){3895data = this.rowsToData(rows);38963897if(this.topInitialized){3898if(this.topRow){3899this.topRow.deleteCells();3900}39013902row = this.generateRow("top", data);3903this.topRow = row;3904while(this.topElement.firstChild) this.topElement.removeChild(this.topElement.firstChild);3905this.topElement.appendChild(row.getElement());3906row.initialize(true);3907}39083909if(this.botInitialized){3910if(this.botRow){3911this.botRow.deleteCells();3912}39133914row = this.generateRow("bottom", data);3915this.botRow = row;3916while(this.botElement.firstChild) this.botElement.removeChild(this.botElement.firstChild);3917this.botElement.appendChild(row.getElement());3918row.initialize(true);3919}39203921this.table.rowManager.adjustTableSize();39223923//set resizable handles3924if(this.table.modExists("frozenColumns")){3925this.table.modules.frozenColumns.layout();3926}3927}3928}3929}39303931recalcRowGroup(row){3932this.recalcGroup(this.table.modules.groupRows.getRowGroup(row));3933}39343935recalcAll(){3936if(this.topCalcs.length || this.botCalcs.length){3937if(this.table.options.columnCalcs !== "group"){3938this.recalcActiveRows();3939}39403941if(this.table.options.groupBy && this.table.options.columnCalcs !== "table"){39423943var groups = this.table.modules.groupRows.getChildGroups();39443945groups.forEach((group) => {3946this.recalcGroup(group);3947});3948}3949}3950}39513952recalcGroup(group){3953var data, rowData;39543955if(!this.blockCheck()){3956if(group){3957if(group.calcs){3958if(group.calcs.bottom){3959data = this.rowsToData(group.rows);3960rowData = this.generateRowData("bottom", data);39613962group.calcs.bottom.updateData(rowData);3963group.calcs.bottom.reinitialize();3964}39653966if(group.calcs.top){3967data = this.rowsToData(group.rows);3968rowData = this.generateRowData("top", data);39693970group.calcs.top.updateData(rowData);3971group.calcs.top.reinitialize();3972}3973}3974}3975}3976}39773978//generate top stats row3979generateTopRow(rows){3980return this.generateRow("top", this.rowsToData(rows));3981}3982//generate bottom stats row3983generateBottomRow(rows){3984return this.generateRow("bottom", this.rowsToData(rows));3985}39863987rowsToData(rows){3988var data = [];39893990rows.forEach((row) => {3991data.push(row.getData());39923993if(this.table.options.dataTree && this.table.options.dataTreeChildColumnCalcs){3994if(row.modules.dataTree && row.modules.dataTree.open){3995var children = this.rowsToData(this.table.modules.dataTree.getFilteredTreeChildren(row));3996data = data.concat(children);3997}3998}3999});40004001return data;4002}40034004//generate stats row4005generateRow(pos, data){4006var rowData = this.generateRowData(pos, data),4007row;40084009if(this.table.modExists("mutator")){4010this.table.modules.mutator.disable();4011}40124013row = new Row(rowData, this, "calc");40144015if(this.table.modExists("mutator")){4016this.table.modules.mutator.enable();4017}40184019row.getElement().classList.add("tabulator-calcs", "tabulator-calcs-" + pos);40204021row.component = false;40224023row.getComponent = () => {4024if(!row.component){4025row.component = new CalcComponent(row);4026}40274028return row.component;4029};40304031row.generateCells = () => {40324033var cells = [];40344035this.table.columnManager.columnsByIndex.forEach((column) => {40364037//set field name of mock column4038this.genColumn.setField(column.getField());4039this.genColumn.hozAlign = column.hozAlign;40404041if(column.definition[pos + "CalcFormatter"] && this.table.modExists("format")){4042this.genColumn.modules.format = {4043formatter: this.table.modules.format.getFormatter(column.definition[pos + "CalcFormatter"]),4044params: column.definition[pos + "CalcFormatterParams"] || {},4045};4046}else {4047this.genColumn.modules.format = {4048formatter: this.table.modules.format.getFormatter("plaintext"),4049params:{}4050};4051}40524053//ensure css class definition is replicated to calculation cell4054this.genColumn.definition.cssClass = column.definition.cssClass;40554056//generate cell and assign to correct column4057var cell = new Cell(this.genColumn, row);4058cell.getElement();4059cell.column = column;4060cell.setWidth();40614062column.cells.push(cell);4063cells.push(cell);40644065if(!column.visible){4066cell.hide();4067}4068});40694070row.cells = cells;4071};40724073return row;4074}40754076//generate stats row4077generateRowData(pos, data){4078var rowData = {},4079calcs = pos == "top" ? this.topCalcs : this.botCalcs,4080type = pos == "top" ? "topCalc" : "botCalc",4081params, paramKey;40824083calcs.forEach(function(column){4084var values = [];40854086if(column.modules.columnCalcs && column.modules.columnCalcs[type]){4087data.forEach(function(item){4088values.push(column.getFieldValue(item));4089});40904091paramKey = type + "Params";4092params = typeof column.modules.columnCalcs[paramKey] === "function" ? column.modules.columnCalcs[paramKey](values, data) : column.modules.columnCalcs[paramKey];40934094column.setFieldValue(rowData, column.modules.columnCalcs[type](values, data, params));4095}4096});40974098return rowData;4099}41004101hasTopCalcs(){4102return !!(this.topCalcs.length);4103}41044105hasBottomCalcs(){4106return !!(this.botCalcs.length);4107}41084109//handle table redraw4110redraw(){4111if(this.topRow){4112this.topRow.normalizeHeight(true);4113}4114if(this.botRow){4115this.botRow.normalizeHeight(true);4116}4117}41184119//return the calculated4120getResults(){4121var results = {},4122groups;41234124if(this.table.options.groupBy && this.table.modExists("groupRows")){4125groups = this.table.modules.groupRows.getGroups(true);41264127groups.forEach((group) => {4128results[group.getKey()] = this.getGroupResults(group);4129});4130}else {4131results = {4132top: this.topRow ? this.topRow.getData() : {},4133bottom: this.botRow ? this.botRow.getData() : {},4134};4135}41364137return results;4138}41394140//get results from a group4141getGroupResults(group){4142var groupObj = group._getSelf(),4143subGroups = group.getSubGroups(),4144subGroupResults = {},4145results = {};41464147subGroups.forEach((subgroup) => {4148subGroupResults[subgroup.getKey()] = this.getGroupResults(subgroup);4149});41504151results = {4152top: groupObj.calcs.top ? groupObj.calcs.top.getData() : {},4153bottom: groupObj.calcs.bottom ? groupObj.calcs.bottom.getData() : {},4154groups: subGroupResults,4155};41564157return results;4158}41594160adjustForScrollbar(width){4161if(this.botRow){4162if(this.table.rtl){4163this.botElement.style.paddingLeft = width + "px";4164}else {4165this.botElement.style.paddingRight = width + "px";4166}4167}4168}4169}41704171ColumnCalcs.moduleName = "columnCalcs";41724173//load defaults4174ColumnCalcs.calculations = defaultCalculations;41754176class DataTree extends Module{41774178constructor(table){4179super(table);41804181this.indent = 10;4182this.field = "";4183this.collapseEl = null;4184this.expandEl = null;4185this.branchEl = null;4186this.elementField = false;41874188this.startOpen = function(){};41894190this.registerTableOption("dataTree", false); //enable data tree4191this.registerTableOption("dataTreeFilter", true); //filter child rows4192this.registerTableOption("dataTreeSort", true); //sort child rows4193this.registerTableOption("dataTreeElementColumn", false);4194this.registerTableOption("dataTreeBranchElement", true);//show data tree branch element4195this.registerTableOption("dataTreeChildIndent", 9); //data tree child indent in px4196this.registerTableOption("dataTreeChildField", "_children");//data tre column field to look for child rows4197this.registerTableOption("dataTreeCollapseElement", false);//data tree row collapse element4198this.registerTableOption("dataTreeExpandElement", false);//data tree row expand element4199this.registerTableOption("dataTreeStartExpanded", false);4200this.registerTableOption("dataTreeChildColumnCalcs", false);//include visible data tree rows in column calculations4201this.registerTableOption("dataTreeSelectPropagate", false);//selecting a parent row selects its children42024203//register component functions4204this.registerComponentFunction("row", "treeCollapse", this.collapseRow.bind(this));4205this.registerComponentFunction("row", "treeExpand", this.expandRow.bind(this));4206this.registerComponentFunction("row", "treeToggle", this.toggleRow.bind(this));4207this.registerComponentFunction("row", "getTreeParent", this.getTreeParent.bind(this));4208this.registerComponentFunction("row", "getTreeChildren", this.getRowChildren.bind(this));4209this.registerComponentFunction("row", "addTreeChild", this.addTreeChildRow.bind(this));4210this.registerComponentFunction("row", "isTreeExpanded", this.isRowExpanded.bind(this));4211}42124213initialize(){4214if(this.table.options.dataTree){4215var dummyEl = null,4216options = this.table.options;42174218this.field = options.dataTreeChildField;4219this.indent = options.dataTreeChildIndent;42204221if(this.options("movableRows")){4222console.warn("The movableRows option is not available with dataTree enabled, moving of child rows could result in unpredictable behavior");4223}42244225if(options.dataTreeBranchElement){42264227if(options.dataTreeBranchElement === true){4228this.branchEl = document.createElement("div");4229this.branchEl.classList.add("tabulator-data-tree-branch");4230}else {4231if(typeof options.dataTreeBranchElement === "string"){4232dummyEl = document.createElement("div");4233dummyEl.innerHTML = options.dataTreeBranchElement;4234this.branchEl = dummyEl.firstChild;4235}else {4236this.branchEl = options.dataTreeBranchElement;4237}4238}4239}else {4240this.branchEl = document.createElement("div");4241this.branchEl.classList.add("tabulator-data-tree-branch-empty");4242}42434244if(options.dataTreeCollapseElement){4245if(typeof options.dataTreeCollapseElement === "string"){4246dummyEl = document.createElement("div");4247dummyEl.innerHTML = options.dataTreeCollapseElement;4248this.collapseEl = dummyEl.firstChild;4249}else {4250this.collapseEl = options.dataTreeCollapseElement;4251}4252}else {4253this.collapseEl = document.createElement("div");4254this.collapseEl.classList.add("tabulator-data-tree-control");4255this.collapseEl.tabIndex = 0;4256this.collapseEl.innerHTML = "<div class='tabulator-data-tree-control-collapse'></div>";4257}42584259if(options.dataTreeExpandElement){4260if(typeof options.dataTreeExpandElement === "string"){4261dummyEl = document.createElement("div");4262dummyEl.innerHTML = options.dataTreeExpandElement;4263this.expandEl = dummyEl.firstChild;4264}else {4265this.expandEl = options.dataTreeExpandElement;4266}4267}else {4268this.expandEl = document.createElement("div");4269this.expandEl.classList.add("tabulator-data-tree-control");4270this.expandEl.tabIndex = 0;4271this.expandEl.innerHTML = "<div class='tabulator-data-tree-control-expand'></div>";4272}427342744275switch(typeof options.dataTreeStartExpanded){4276case "boolean":4277this.startOpen = function(row, index){4278return options.dataTreeStartExpanded;4279};4280break;42814282case "function":4283this.startOpen = options.dataTreeStartExpanded;4284break;42854286default:4287this.startOpen = function(row, index){4288return options.dataTreeStartExpanded[index];4289};4290break;4291}42924293this.subscribe("row-init", this.initializeRow.bind(this));4294this.subscribe("row-layout-after", this.layoutRow.bind(this));4295this.subscribe("row-deleted", this.rowDelete.bind(this),0);4296this.subscribe("row-data-changed", this.rowDataChanged.bind(this), 10);4297this.subscribe("cell-value-updated", this.cellValueChanged.bind(this));4298this.subscribe("edit-cancelled", this.cellValueChanged.bind(this));4299this.subscribe("column-moving-rows", this.columnMoving.bind(this));4300this.subscribe("table-built", this.initializeElementField.bind(this));4301this.subscribe("table-redrawing", this.tableRedrawing.bind(this));43024303this.registerDisplayHandler(this.getRows.bind(this), 30);4304}4305}43064307tableRedrawing(force){4308var rows;43094310if(force){4311rows = this.table.rowManager.getRows();43124313rows.forEach((row) => {4314this.reinitializeRowChildren(row);4315});4316}4317}43184319initializeElementField(){4320var firstCol = this.table.columnManager.getFirstVisibleColumn();43214322this.elementField = this.table.options.dataTreeElementColumn || (firstCol ? firstCol.field : false);4323}43244325getRowChildren(row){4326return this.getTreeChildren(row, true);4327}43284329columnMoving(){4330var rows = [];43314332this.table.rowManager.rows.forEach((row) => {4333rows = rows.concat(this.getTreeChildren(row, false, true));4334});43354336return rows;4337}43384339rowDataChanged(row, visible, updatedData){4340if(this.redrawNeeded(updatedData)){4341this.initializeRow(row);43424343if(visible){4344this.layoutRow(row);4345this.refreshData(true);4346}4347}4348}43494350cellValueChanged(cell){4351var field = cell.column.getField();43524353if(field === this.elementField){4354this.layoutRow(cell.row);4355}4356}43574358initializeRow(row){4359var childArray = row.getData()[this.field];4360var isArray = Array.isArray(childArray);43614362var children = isArray || (!isArray && typeof childArray === "object" && childArray !== null);43634364if(!children && row.modules.dataTree && row.modules.dataTree.branchEl){4365row.modules.dataTree.branchEl.parentNode.removeChild(row.modules.dataTree.branchEl);4366}43674368if(!children && row.modules.dataTree && row.modules.dataTree.controlEl){4369row.modules.dataTree.controlEl.parentNode.removeChild(row.modules.dataTree.controlEl);4370}43714372row.modules.dataTree = {4373index: row.modules.dataTree ? row.modules.dataTree.index : 0,4374open: children ? (row.modules.dataTree ? row.modules.dataTree.open : this.startOpen(row.getComponent(), 0)) : false,4375controlEl: row.modules.dataTree && children ? row.modules.dataTree.controlEl : false,4376branchEl: row.modules.dataTree && children ? row.modules.dataTree.branchEl : false,4377parent: row.modules.dataTree ? row.modules.dataTree.parent : false,4378children:children,4379};4380}43814382reinitializeRowChildren(row){4383var children = this.getTreeChildren(row, false, true);43844385children.forEach(function(child){4386child.reinitialize(true);4387});4388}43894390layoutRow(row){4391var cell = this.elementField ? row.getCell(this.elementField) : row.getCells()[0],4392el = cell.getElement(),4393config = row.modules.dataTree;43944395if(config.branchEl){4396if(config.branchEl.parentNode){4397config.branchEl.parentNode.removeChild(config.branchEl);4398}4399config.branchEl = false;4400}44014402if(config.controlEl){4403if(config.controlEl.parentNode){4404config.controlEl.parentNode.removeChild(config.controlEl);4405}4406config.controlEl = false;4407}44084409this.generateControlElement(row, el);44104411row.getElement().classList.add("tabulator-tree-level-" + config.index);44124413if(config.index){4414if(this.branchEl){4415config.branchEl = this.branchEl.cloneNode(true);4416el.insertBefore(config.branchEl, el.firstChild);44174418if(this.table.rtl){4419config.branchEl.style.marginRight = (((config.branchEl.offsetWidth + config.branchEl.style.marginLeft) * (config.index - 1)) + (config.index * this.indent)) + "px";4420}else {4421config.branchEl.style.marginLeft = (((config.branchEl.offsetWidth + config.branchEl.style.marginRight) * (config.index - 1)) + (config.index * this.indent)) + "px";4422}4423}else {44244425if(this.table.rtl){4426el.style.paddingRight = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-right')) + (config.index * this.indent) + "px";4427}else {4428el.style.paddingLeft = parseInt(window.getComputedStyle(el, null).getPropertyValue('padding-left')) + (config.index * this.indent) + "px";4429}4430}4431}4432}44334434generateControlElement(row, el){4435var config = row.modules.dataTree,4436oldControl = config.controlEl;44374438el = el || row.getCells()[0].getElement();44394440if(config.children !== false){44414442if(config.open){4443config.controlEl = this.collapseEl.cloneNode(true);4444config.controlEl.addEventListener("click", (e) => {4445e.stopPropagation();4446this.collapseRow(row);4447});4448}else {4449config.controlEl = this.expandEl.cloneNode(true);4450config.controlEl.addEventListener("click", (e) => {4451e.stopPropagation();4452this.expandRow(row);4453});4454}44554456config.controlEl.addEventListener("mousedown", (e) => {4457e.stopPropagation();4458});44594460if(oldControl && oldControl.parentNode === el){4461oldControl.parentNode.replaceChild(config.controlEl,oldControl);4462}else {4463el.insertBefore(config.controlEl, el.firstChild);4464}4465}4466}44674468getRows(rows){4469var output = [];44704471rows.forEach((row, i) => {4472var config, children;44734474output.push(row);44754476if(row instanceof Row){44774478row.create();44794480config = row.modules.dataTree;44814482if(!config.index && config.children !== false){4483children = this.getChildren(row);44844485children.forEach((child) => {4486child.create();4487output.push(child);4488});4489}4490}4491});44924493return output;4494}44954496getChildren(row, allChildren){4497var config = row.modules.dataTree,4498children = [],4499output = [];45004501if(config.children !== false && (config.open || allChildren)){4502if(!Array.isArray(config.children)){4503config.children = this.generateChildren(row);4504}45054506if(this.table.modExists("filter") && this.table.options.dataTreeFilter){4507children = this.table.modules.filter.filter(config.children);4508}else {4509children = config.children;4510}45114512if(this.table.modExists("sort") && this.table.options.dataTreeSort){4513this.table.modules.sort.sort(children);4514}45154516children.forEach((child) => {4517output.push(child);45184519var subChildren = this.getChildren(child);45204521subChildren.forEach((sub) => {4522output.push(sub);4523});4524});4525}45264527return output;4528}45294530generateChildren(row){4531var children = [];45324533var childArray = row.getData()[this.field];45344535if(!Array.isArray(childArray)){4536childArray = [childArray];4537}45384539childArray.forEach((childData) => {4540var childRow = new Row(childData || {}, this.table.rowManager);45414542childRow.create();45434544childRow.modules.dataTree.index = row.modules.dataTree.index + 1;4545childRow.modules.dataTree.parent = row;45464547if(childRow.modules.dataTree.children){4548childRow.modules.dataTree.open = this.startOpen(childRow.getComponent(), childRow.modules.dataTree.index);4549}4550children.push(childRow);4551});45524553return children;4554}45554556expandRow(row, silent){4557var config = row.modules.dataTree;45584559if(config.children !== false){4560config.open = true;45614562row.reinitialize();45634564this.refreshData(true);45654566this.dispatchExternal("dataTreeRowExpanded", row.getComponent(), row.modules.dataTree.index);4567}4568}45694570collapseRow(row){4571var config = row.modules.dataTree;45724573if(config.children !== false){4574config.open = false;45754576row.reinitialize();45774578this.refreshData(true);45794580this.dispatchExternal("dataTreeRowCollapsed", row.getComponent(), row.modules.dataTree.index);4581}4582}45834584toggleRow(row){4585var config = row.modules.dataTree;45864587if(config.children !== false){4588if(config.open){4589this.collapseRow(row);4590}else {4591this.expandRow(row);4592}4593}4594}45954596isRowExpanded(row){4597return row.modules.dataTree.open;4598}45994600getTreeParent(row){4601return row.modules.dataTree.parent ? row.modules.dataTree.parent.getComponent() : false;4602}46034604getTreeParentRoot(row){4605return row.modules.dataTree && row.modules.dataTree.parent ? this.getTreeParentRoot(row.modules.dataTree.parent) : row;4606}46074608getFilteredTreeChildren(row){4609var config = row.modules.dataTree,4610output = [], children;46114612if(config.children){46134614if(!Array.isArray(config.children)){4615config.children = this.generateChildren(row);4616}46174618if(this.table.modExists("filter") && this.table.options.dataTreeFilter){4619children = this.table.modules.filter.filter(config.children);4620}else {4621children = config.children;4622}46234624children.forEach((childRow) => {4625if(childRow instanceof Row){4626output.push(childRow);4627}4628});4629}46304631return output;4632}46334634rowDelete(row){4635var parent = row.modules.dataTree.parent,4636childIndex;46374638if(parent){4639childIndex = this.findChildIndex(row, parent);46404641if(childIndex !== false){4642parent.data[this.field].splice(childIndex, 1);4643}46444645if(!parent.data[this.field].length){4646delete parent.data[this.field];4647}46484649this.initializeRow(parent);4650this.layoutRow(parent);4651}46524653this.refreshData(true);4654}46554656addTreeChildRow(row, data, top, index){4657var childIndex = false;46584659if(typeof data === "string"){4660data = JSON.parse(data);4661}46624663if(!Array.isArray(row.data[this.field])){4664row.data[this.field] = [];46654666row.modules.dataTree.open = this.startOpen(row.getComponent(), row.modules.dataTree.index);4667}46684669if(typeof index !== "undefined"){4670childIndex = this.findChildIndex(index, row);46714672if(childIndex !== false){4673row.data[this.field].splice((top ? childIndex : childIndex + 1), 0, data);4674}4675}46764677if(childIndex === false){4678if(top){4679row.data[this.field].unshift(data);4680}else {4681row.data[this.field].push(data);4682}4683}46844685this.initializeRow(row);4686this.layoutRow(row);46874688this.refreshData(true);4689}46904691findChildIndex(subject, parent){4692var match = false;46934694if(typeof subject == "object"){46954696if(subject instanceof Row){4697//subject is row element4698match = subject.data;4699}else if(subject instanceof RowComponent){4700//subject is public row component4701match = subject._getSelf().data;4702}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){4703if(parent.modules.dataTree){4704match = parent.modules.dataTree.children.find((childRow) => {4705return childRow instanceof Row ? childRow.element === subject : false;4706});47074708if(match){4709match = match.data;4710}4711}4712}else if(subject === null){4713match = false;4714}47154716}else if(typeof subject == "undefined"){4717match = false;4718}else {4719//subject should be treated as the index of the row4720match = parent.data[this.field].find((row) => {4721return row.data[this.table.options.index] == subject;4722});4723}47244725if(match){47264727if(Array.isArray(parent.data[this.field])){4728match = parent.data[this.field].indexOf(match);4729}47304731if(match == -1){4732match = false;4733}4734}47354736//catch all for any other type of input47374738return match;4739}47404741getTreeChildren(row, component, recurse){4742var config = row.modules.dataTree,4743output = [];47444745if(config && config.children){47464747if(!Array.isArray(config.children)){4748config.children = this.generateChildren(row);4749}47504751config.children.forEach((childRow) => {4752if(childRow instanceof Row){4753output.push(component ? childRow.getComponent() : childRow);47544755if(recurse){4756output = output.concat(this.getTreeChildren(childRow, component, recurse));4757}4758}4759});4760}47614762return output;4763}47644765getChildField(){4766return this.field;4767}47684769redrawNeeded(data){4770return (this.field ? typeof data[this.field] !== "undefined" : false) || (this.elementField ? typeof data[this.elementField] !== "undefined" : false);4771}4772}47734774DataTree.moduleName = "dataTree";47754776function csv(list, options = {}, setFileContents){4777var delimiter = options.delimiter ? options.delimiter : ",",4778fileContents = [],4779headers = [];47804781list.forEach((row) => {4782var item = [];47834784switch(row.type){4785case "group":4786console.warn("Download Warning - CSV downloader cannot process row groups");4787break;47884789case "calc":4790console.warn("Download Warning - CSV downloader cannot process column calculations");4791break;47924793case "header":4794row.columns.forEach((col, i) => {4795if(col && col.depth === 1){4796headers[i] = typeof col.value == "undefined" || col.value === null ? "" : ('"' + String(col.value).split('"').join('""') + '"');4797}4798});4799break;48004801case "row":4802row.columns.forEach((col) => {48034804if(col){48054806switch(typeof col.value){4807case "object":4808col.value = col.value !== null ? JSON.stringify(col.value) : "";4809break;48104811case "undefined":4812col.value = "";4813break;4814}48154816item.push('"' + String(col.value).split('"').join('""') + '"');4817}4818});48194820fileContents.push(item.join(delimiter));4821break;4822}4823});48244825if(headers.length){4826fileContents.unshift(headers.join(delimiter));4827}48284829fileContents = fileContents.join("\n");48304831if(options.bom){4832fileContents = "\ufeff" + fileContents;4833}48344835setFileContents(fileContents, "text/csv");4836}48374838function json(list, options, setFileContents){4839var fileContents = [];48404841list.forEach((row) => {4842var item = {};48434844switch(row.type){4845case "header":4846break;48474848case "group":4849console.warn("Download Warning - JSON downloader cannot process row groups");4850break;48514852case "calc":4853console.warn("Download Warning - JSON downloader cannot process column calculations");4854break;48554856case "row":4857row.columns.forEach((col) => {4858if(col){4859item[col.component.getTitleDownload() || col.component.getField()] = col.value;4860}4861});48624863fileContents.push(item);4864break;4865}4866});48674868fileContents = JSON.stringify(fileContents, null, '\t');48694870setFileContents(fileContents, "application/json");4871}48724873function pdf(list, options = {}, setFileContents){4874var header = [],4875body = [],4876autoTableParams = {},4877rowGroupStyles = options.rowGroupStyles || {4878fontStyle: "bold",4879fontSize: 12,4880cellPadding: 6,4881fillColor: 220,4882},4883rowCalcStyles = options.rowCalcStyles || {4884fontStyle: "bold",4885fontSize: 10,4886cellPadding: 4,4887fillColor: 232,4888},4889jsPDFParams = options.jsPDF || {},4890title = options.title ? options.title : "";48914892if(!jsPDFParams.orientation){4893jsPDFParams.orientation = options.orientation || "landscape";4894}48954896if(!jsPDFParams.unit){4897jsPDFParams.unit = "pt";4898}48994900//parse row list4901list.forEach((row) => {4902switch(row.type){4903case "header":4904header.push(parseRow(row));4905break;49064907case "group":4908body.push(parseRow(row, rowGroupStyles));4909break;49104911case "calc":4912body.push(parseRow(row, rowCalcStyles));4913break;49144915case "row":4916body.push(parseRow(row));4917break;4918}4919});49204921function parseRow(row, styles){4922var rowData = [];49234924row.columns.forEach((col) =>{4925var cell;49264927if(col){4928switch(typeof col.value){4929case "object":4930col.value = col.value !== null ? JSON.stringify(col.value) : "";4931break;49324933case "undefined":4934col.value = "";4935break;4936}49374938cell = {4939content:col.value,4940colSpan:col.width,4941rowSpan:col.height,4942};49434944if(styles){4945cell.styles = styles;4946}49474948rowData.push(cell);4949}4950});49514952return rowData;4953}495449554956//configure PDF4957var doc = new jspdf.jsPDF(jsPDFParams); //set document to landscape, better for most tables49584959if(options.autoTable){4960if(typeof options.autoTable === "function"){4961autoTableParams = options.autoTable(doc) || {};4962}else {4963autoTableParams = options.autoTable;4964}4965}49664967if(title){4968autoTableParams.didDrawPage = function(data) {4969doc.text(title, 40, 30);4970};4971}49724973autoTableParams.head = header;4974autoTableParams.body = body;49754976doc.autoTable(autoTableParams);49774978if(options.documentProcessing){4979options.documentProcessing(doc);4980}49814982setFileContents(doc.output("arraybuffer"), "application/pdf");4983}49844985function xlsx(list, options, setFileContents){4986var self = this,4987sheetName = options.sheetName || "Sheet1",4988workbook = XLSX.utils.book_new(),4989tableFeatures = new CoreFeature(this),4990compression = 'compress' in options ? options.compress : true,4991writeOptions = options.writeOptions || {bookType:'xlsx', bookSST:true, compression},4992output;49934994writeOptions.type = 'binary';49954996workbook.SheetNames = [];4997workbook.Sheets = {};49984999function generateSheet(){5000var rows = [],5001merges = [],5002worksheet = {},5003range = {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 }};50045005//parse row list5006list.forEach((row, i) => {5007var rowData = [];50085009row.columns.forEach(function(col, j){50105011if(col){5012rowData.push(!(col.value instanceof Date) && typeof col.value === "object" ? JSON.stringify(col.value) : col.value);50135014if(col.width > 1 || col.height > -1){5015if(col.height > 1 || col.width > 1){5016merges.push({s:{r:i,c:j},e:{r:i + col.height - 1,c:j + col.width - 1}});5017}5018}5019}else {5020rowData.push("");5021}5022});50235024rows.push(rowData);5025});50265027//convert rows to worksheet5028XLSX.utils.sheet_add_aoa(worksheet, rows);50295030worksheet['!ref'] = XLSX.utils.encode_range(range);50315032if(merges.length){5033worksheet["!merges"] = merges;5034}50355036return worksheet;5037}50385039if(options.sheetOnly){5040setFileContents(generateSheet());5041return;5042}50435044if(options.sheets){5045for(var sheet in options.sheets){50465047if(options.sheets[sheet] === true){5048workbook.SheetNames.push(sheet);5049workbook.Sheets[sheet] = generateSheet();5050}else {50515052workbook.SheetNames.push(sheet);50535054tableFeatures.commsSend(options.sheets[sheet], "download", "intercept",{5055type:"xlsx",5056options:{sheetOnly:true},5057active:self.active,5058intercept:function(data){5059workbook.Sheets[sheet] = data;5060}5061});5062}5063}5064}else {5065workbook.SheetNames.push(sheetName);5066workbook.Sheets[sheetName] = generateSheet();5067}50685069if(options.documentProcessing){5070workbook = options.documentProcessing(workbook);5071}50725073//convert workbook to binary array5074function s2ab(s) {5075var buf = new ArrayBuffer(s.length);5076var view = new Uint8Array(buf);5077for (var i=0; i!=s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;5078return buf;5079}50805081output = XLSX.write(workbook, writeOptions);50825083setFileContents(s2ab(output), "application/octet-stream");5084}50855086function html(list, options, setFileContents){5087if(this.modExists("export", true)){5088setFileContents(this.modules.export.generateHTMLTable(list), "text/html");5089}5090}50915092function jsonLines (list, options, setFileContents) {5093const fileContents = [];50945095list.forEach((row) => {5096const item = {};50975098switch (row.type) {5099case "header":5100break;51015102case "group":5103console.warn("Download Warning - JSON downloader cannot process row groups");5104break;51055106case "calc":5107console.warn("Download Warning - JSON downloader cannot process column calculations");5108break;51095110case "row":5111row.columns.forEach((col) => {5112if (col) {5113item[col.component.getTitleDownload() || col.component.getField()] = col.value;5114}5115});51165117fileContents.push(JSON.stringify(item));5118break;5119}5120});51215122setFileContents(fileContents.join("\n"), "application/x-ndjson");5123}51245125var defaultDownloaders = {5126csv:csv,5127json:json,5128jsonLines:jsonLines,5129pdf:pdf,5130xlsx:xlsx,5131html:html,5132};51335134class Download extends Module{51355136constructor(table){5137super(table);51385139this.registerTableOption("downloadEncoder", function(data, mimeType){5140return new Blob([data],{type:mimeType});5141}); //function to manipulate download data5142this.registerTableOption("downloadReady", undefined); //warn of function deprecation5143this.registerTableOption("downloadConfig", {}); //download config5144this.registerTableOption("downloadRowRange", "active"); //restrict download to active rows only51455146this.registerColumnOption("download");5147this.registerColumnOption("titleDownload");5148}51495150initialize(){5151this.deprecatedOptionsCheck();51525153this.registerTableFunction("download", this.download.bind(this));5154this.registerTableFunction("downloadToTab", this.downloadToTab.bind(this));5155}51565157deprecatedOptionsCheck(){5158this.deprecationCheck("downloadReady", "downloadEncoder");5159}51605161///////////////////////////////////5162///////// Table Functions /////////5163///////////////////////////////////51645165downloadToTab(type, filename, options, active){5166this.download(type, filename, options, active, true);5167}51685169///////////////////////////////////5170///////// Internal Logic //////////5171///////////////////////////////////51725173//trigger file download5174download(type, filename, options, range, interceptCallback){5175var downloadFunc = false;51765177function buildLink(data, mime){5178if(interceptCallback){5179if(interceptCallback === true){5180this.triggerDownload(data, mime, type, filename, true);5181}else {5182interceptCallback(data);5183}51845185}else {5186this.triggerDownload(data, mime, type, filename);5187}5188}51895190if(typeof type == "function"){5191downloadFunc = type;5192}else {5193if(Download.downloaders[type]){5194downloadFunc = Download.downloaders[type];5195}else {5196console.warn("Download Error - No such download type found: ", type);5197}5198}51995200if(downloadFunc){5201var list = this.generateExportList(range);52025203downloadFunc.call(this.table, list , options || {}, buildLink.bind(this));5204}5205}52065207generateExportList(range){5208var list = this.table.modules.export.generateExportList(this.table.options.downloadConfig, false, range || this.table.options.downloadRowRange, "download");52095210//assign group header formatter5211var groupHeader = this.table.options.groupHeaderDownload;52125213if(groupHeader && !Array.isArray(groupHeader)){5214groupHeader = [groupHeader];5215}52165217list.forEach((row) => {5218var group;52195220if(row.type === "group"){5221group = row.columns[0];52225223if(groupHeader && groupHeader[row.indent]){5224group.value = groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);5225}5226}5227});52285229return list;5230}52315232triggerDownload(data, mime, type, filename, newTab){5233var element = document.createElement('a'),5234blob = this.table.options.downloadEncoder(data, mime);52355236if(blob){5237if(newTab){5238window.open(window.URL.createObjectURL(blob));5239}else {5240filename = filename || "Tabulator." + (typeof type === "function" ? "txt" : type);52415242if(navigator.msSaveOrOpenBlob){5243navigator.msSaveOrOpenBlob(blob, filename);5244}else {5245element.setAttribute('href', window.URL.createObjectURL(blob));52465247//set file title5248element.setAttribute('download', filename);52495250//trigger download5251element.style.display = 'none';5252document.body.appendChild(element);5253element.click();52545255//remove temporary link element5256document.body.removeChild(element);5257}5258}52595260this.dispatchExternal("downloadComplete");5261}5262}52635264commsReceived(table, action, data){5265switch(action){5266case "intercept":5267this.download(data.type, "", data.options, data.active, data.intercept);5268break;5269}5270}5271}52725273Download.moduleName = "download";52745275//load defaults5276Download.downloaders = defaultDownloaders;52775278function maskInput(el, options){5279var mask = options.mask,5280maskLetter = typeof options.maskLetterChar !== "undefined" ? options.maskLetterChar : "A",5281maskNumber = typeof options.maskNumberChar !== "undefined" ? options.maskNumberChar : "9",5282maskWildcard = typeof options.maskWildcardChar !== "undefined" ? options.maskWildcardChar : "*";52835284function fillSymbols(index){5285var symbol = mask[index];5286if(typeof symbol !== "undefined" && symbol !== maskWildcard && symbol !== maskLetter && symbol !== maskNumber){5287el.value = el.value + "" + symbol;5288fillSymbols(index+1);5289}5290}52915292el.addEventListener("keydown", (e) => {5293var index = el.value.length,5294char = e.key;52955296if(e.keyCode > 46 && !e.ctrlKey && !e.metaKey){5297if(index >= mask.length){5298e.preventDefault();5299e.stopPropagation();5300return false;5301}else {5302switch(mask[index]){5303case maskLetter:5304if(char.toUpperCase() == char.toLowerCase()){5305e.preventDefault();5306e.stopPropagation();5307return false;5308}5309break;53105311case maskNumber:5312if(isNaN(char)){5313e.preventDefault();5314e.stopPropagation();5315return false;5316}5317break;53185319case maskWildcard:5320break;53215322default:5323if(char !== mask[index]){5324e.preventDefault();5325e.stopPropagation();5326return false;5327}5328}5329}5330}53315332return;5333});53345335el.addEventListener("keyup", (e) => {5336if(e.keyCode > 46){5337if(options.maskAutoFill){5338fillSymbols(el.value.length);5339}5340}5341});534253435344if(!el.placeholder){5345el.placeholder = mask;5346}53475348if(options.maskAutoFill){5349fillSymbols(el.value.length);5350}5351}53525353//input element5354function input(cell, onRendered, success, cancel, editorParams){5355//create and style input5356var cellValue = cell.getValue(),5357input = document.createElement("input");53585359input.setAttribute("type", editorParams.search ? "search" : "text");53605361input.style.padding = "4px";5362input.style.width = "100%";5363input.style.boxSizing = "border-box";53645365if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5366for (let key in editorParams.elementAttributes){5367if(key.charAt(0) == "+"){5368key = key.slice(1);5369input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5370}else {5371input.setAttribute(key, editorParams.elementAttributes[key]);5372}5373}5374}53755376input.value = typeof cellValue !== "undefined" ? cellValue : "";53775378onRendered(function(){5379if(cell.getType() === "cell"){5380input.focus({preventScroll: true});5381input.style.height = "100%";53825383if(editorParams.selectContents){5384input.select();5385}5386}5387});53885389function onChange(e){5390if(((cellValue === null || typeof cellValue === "undefined") && input.value !== "") || input.value !== cellValue){5391if(success(input.value)){5392cellValue = input.value; //persist value if successfully validated incase editor is used as header filter5393}5394}else {5395cancel();5396}5397}53985399//submit new value on blur or change5400input.addEventListener("change", onChange);5401input.addEventListener("blur", onChange);54025403//submit new value on enter5404input.addEventListener("keydown", function(e){5405switch(e.keyCode){5406// case 9:5407case 13:5408onChange();5409break;54105411case 27:5412cancel();5413break;54145415case 35:5416case 36:5417e.stopPropagation();5418break;5419}5420});54215422if(editorParams.mask){5423maskInput(input, editorParams);5424}54255426return input;5427}54285429//resizable text area element5430function textarea(cell, onRendered, success, cancel, editorParams){5431var cellValue = cell.getValue(),5432vertNav = editorParams.verticalNavigation || "hybrid",5433value = String(cellValue !== null && typeof cellValue !== "undefined" ? cellValue : ""),5434input = document.createElement("textarea"),5435scrollHeight = 0;54365437//create and style input5438input.style.display = "block";5439input.style.padding = "2px";5440input.style.height = "100%";5441input.style.width = "100%";5442input.style.boxSizing = "border-box";5443input.style.whiteSpace = "pre-wrap";5444input.style.resize = "none";54455446if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5447for (let key in editorParams.elementAttributes){5448if(key.charAt(0) == "+"){5449key = key.slice(1);5450input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5451}else {5452input.setAttribute(key, editorParams.elementAttributes[key]);5453}5454}5455}54565457input.value = value;54585459onRendered(function(){5460if(cell.getType() === "cell"){5461input.focus({preventScroll: true});5462input.style.height = "100%";54635464input.scrollHeight;5465input.style.height = input.scrollHeight + "px";5466cell.getRow().normalizeHeight();54675468if(editorParams.selectContents){5469input.select();5470}5471}5472});54735474function onChange(e){54755476if(((cellValue === null || typeof cellValue === "undefined") && input.value !== "") || input.value !== cellValue){54775478if(success(input.value)){5479cellValue = input.value; //persist value if successfully validated incase editor is used as header filter5480}54815482setTimeout(function(){5483cell.getRow().normalizeHeight();5484},300);5485}else {5486cancel();5487}5488}54895490//submit new value on blur or change5491input.addEventListener("change", onChange);5492input.addEventListener("blur", onChange);54935494input.addEventListener("keyup", function(){54955496input.style.height = "";54975498var heightNow = input.scrollHeight;54995500input.style.height = heightNow + "px";55015502if(heightNow != scrollHeight){5503scrollHeight = heightNow;5504cell.getRow().normalizeHeight();5505}5506});55075508input.addEventListener("keydown", function(e){55095510switch(e.keyCode){55115512case 13:5513if(e.shiftKey && editorParams.shiftEnterSubmit){5514onChange();5515}5516break;55175518case 27:5519cancel();5520break;55215522case 38: //up arrow5523if(vertNav == "editor" || (vertNav == "hybrid" && input.selectionStart)){5524e.stopImmediatePropagation();5525e.stopPropagation();5526}55275528break;55295530case 40: //down arrow5531if(vertNav == "editor" || (vertNav == "hybrid" && input.selectionStart !== input.value.length)){5532e.stopImmediatePropagation();5533e.stopPropagation();5534}5535break;55365537case 35:5538case 36:5539e.stopPropagation();5540break;5541}5542});55435544if(editorParams.mask){5545maskInput(input, editorParams);5546}55475548return input;5549}55505551//input element with type of number5552function number(cell, onRendered, success, cancel, editorParams){5553var cellValue = cell.getValue(),5554vertNav = editorParams.verticalNavigation || "editor",5555input = document.createElement("input");55565557input.setAttribute("type", "number");55585559if(typeof editorParams.max != "undefined"){5560input.setAttribute("max", editorParams.max);5561}55625563if(typeof editorParams.min != "undefined"){5564input.setAttribute("min", editorParams.min);5565}55665567if(typeof editorParams.step != "undefined"){5568input.setAttribute("step", editorParams.step);5569}55705571//create and style input5572input.style.padding = "4px";5573input.style.width = "100%";5574input.style.boxSizing = "border-box";55755576if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5577for (let key in editorParams.elementAttributes){5578if(key.charAt(0) == "+"){5579key = key.slice(1);5580input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5581}else {5582input.setAttribute(key, editorParams.elementAttributes[key]);5583}5584}5585}55865587input.value = cellValue;55885589var blurFunc = function(e){5590onChange();5591};55925593onRendered(function () {5594if(cell.getType() === "cell"){5595//submit new value on blur5596input.removeEventListener("blur", blurFunc);55975598input.focus({preventScroll: true});5599input.style.height = "100%";56005601//submit new value on blur5602input.addEventListener("blur", blurFunc);56035604if(editorParams.selectContents){5605input.select();5606}5607}5608});56095610function onChange(){5611var value = input.value;56125613if(!isNaN(value) && value !==""){5614value = Number(value);5615}56165617if(value !== cellValue){5618if(success(value)){5619cellValue = value; //persist value if successfully validated incase editor is used as header filter5620}5621}else {5622cancel();5623}5624}56255626//submit new value on enter5627input.addEventListener("keydown", function(e){5628switch(e.keyCode){5629case 13:5630// case 9:5631onChange();5632break;56335634case 27:5635cancel();5636break;56375638case 38: //up arrow5639case 40: //down arrow5640if(vertNav == "editor"){5641e.stopImmediatePropagation();5642e.stopPropagation();5643}5644break;56455646case 35:5647case 36:5648e.stopPropagation();5649break;5650}5651});56525653if(editorParams.mask){5654maskInput(input, editorParams);5655}56565657return input;5658}56595660//input element with type of number5661function range(cell, onRendered, success, cancel, editorParams){5662var cellValue = cell.getValue(),5663input = document.createElement("input");56645665input.setAttribute("type", "range");56665667if (typeof editorParams.max != "undefined") {5668input.setAttribute("max", editorParams.max);5669}56705671if (typeof editorParams.min != "undefined") {5672input.setAttribute("min", editorParams.min);5673}56745675if (typeof editorParams.step != "undefined") {5676input.setAttribute("step", editorParams.step);5677}56785679//create and style input5680input.style.padding = "4px";5681input.style.width = "100%";5682input.style.boxSizing = "border-box";56835684if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5685for (let key in editorParams.elementAttributes){5686if(key.charAt(0) == "+"){5687key = key.slice(1);5688input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5689}else {5690input.setAttribute(key, editorParams.elementAttributes[key]);5691}5692}5693}56945695input.value = cellValue;56965697onRendered(function () {5698if(cell.getType() === "cell"){5699input.focus({preventScroll: true});5700input.style.height = "100%";5701}5702});57035704function onChange(){5705var value = input.value;57065707if(!isNaN(value) && value !==""){5708value = Number(value);5709}57105711if(value != cellValue){5712if(success(value)){5713cellValue = value; //persist value if successfully validated incase editor is used as header filter5714}5715}else {5716cancel();5717}5718}57195720//submit new value on blur5721input.addEventListener("blur", function(e){5722onChange();5723});57245725//submit new value on enter5726input.addEventListener("keydown", function(e){5727switch(e.keyCode){5728case 13:5729// case 9:5730onChange();5731break;57325733case 27:5734cancel();5735break;5736}5737});57385739return input;5740}57415742//input element5743function date(cell, onRendered, success, cancel, editorParams){5744var inputFormat = editorParams.format,5745vertNav = editorParams.verticalNavigation || "editor",5746DT = inputFormat ? (window.DateTime || luxon.DateTime) : null;57475748//create and style input5749var cellValue = cell.getValue(),5750input = document.createElement("input");57515752function convertDate(value){5753var newDatetime;57545755if(DT.isDateTime(value)){5756newDatetime = value;5757}else if(inputFormat === "iso"){5758newDatetime = DT.fromISO(String(value));5759}else {5760newDatetime = DT.fromFormat(String(value), inputFormat);5761}57625763return newDatetime.toFormat("yyyy-MM-dd");5764}57655766input.type = "date";5767input.style.padding = "4px";5768input.style.width = "100%";5769input.style.boxSizing = "border-box";57705771if(editorParams.max){5772input.setAttribute("max", inputFormat ? convertDate(editorParams.max) : editorParams.max);5773}57745775if(editorParams.min){5776input.setAttribute("min", inputFormat ? convertDate(editorParams.min) : editorParams.min);5777}57785779if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5780for (let key in editorParams.elementAttributes){5781if(key.charAt(0) == "+"){5782key = key.slice(1);5783input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5784}else {5785input.setAttribute(key, editorParams.elementAttributes[key]);5786}5787}5788}57895790cellValue = typeof cellValue !== "undefined" ? cellValue : "";57915792if(inputFormat){5793if(DT){5794cellValue = convertDate(cellValue);5795}else {5796console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");5797}5798}57995800input.value = cellValue;58015802onRendered(function(){5803if(cell.getType() === "cell"){5804input.focus({preventScroll: true});5805input.style.height = "100%";58065807if(editorParams.selectContents){5808input.select();5809}5810}5811});58125813function onChange(){5814var value = input.value,5815luxDate;58165817if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){58185819if(value && inputFormat){5820luxDate = DT.fromFormat(String(value), "yyyy-MM-dd");58215822switch(inputFormat){5823case true:5824value = luxDate;5825break;58265827case "iso":5828value = luxDate.toISO();5829break;58305831default:5832value = luxDate.toFormat(inputFormat);5833}5834}58355836if(success(value)){5837cellValue = input.value; //persist value if successfully validated incase editor is used as header filter5838}5839}else {5840cancel();5841}5842}58435844//submit new value on blur5845input.addEventListener("blur", function(e) {5846if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {5847onChange(); // only on a "true" blur; not when focusing browser's date/time picker5848}5849});58505851//submit new value on enter5852input.addEventListener("keydown", function(e){5853switch(e.keyCode){5854// case 9:5855case 13:5856onChange();5857break;58585859case 27:5860cancel();5861break;58625863case 35:5864case 36:5865e.stopPropagation();5866break;58675868case 38: //up arrow5869case 40: //down arrow5870if(vertNav == "editor"){5871e.stopImmediatePropagation();5872e.stopPropagation();5873}5874break;5875}5876});58775878return input;5879}58805881//input element5882function time(cell, onRendered, success, cancel, editorParams){5883var inputFormat = editorParams.format,5884vertNav = editorParams.verticalNavigation || "editor",5885DT = inputFormat ? (window.DateTime || luxon.DateTime) : null,5886newDatetime;58875888//create and style input5889var cellValue = cell.getValue(),5890input = document.createElement("input");58915892input.type = "time";5893input.style.padding = "4px";5894input.style.width = "100%";5895input.style.boxSizing = "border-box";58965897if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){5898for (let key in editorParams.elementAttributes){5899if(key.charAt(0) == "+"){5900key = key.slice(1);5901input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);5902}else {5903input.setAttribute(key, editorParams.elementAttributes[key]);5904}5905}5906}59075908cellValue = typeof cellValue !== "undefined" ? cellValue : "";59095910if(inputFormat){5911if(DT){5912if(DT.isDateTime(cellValue)){5913newDatetime = cellValue;5914}else if(inputFormat === "iso"){5915newDatetime = DT.fromISO(String(cellValue));5916}else {5917newDatetime = DT.fromFormat(String(cellValue), inputFormat);5918}59195920cellValue = newDatetime.toFormat("hh:mm");59215922}else {5923console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");5924}5925}59265927input.value = cellValue;59285929onRendered(function(){5930if(cell.getType() == "cell"){5931input.focus({preventScroll: true});5932input.style.height = "100%";59335934if(editorParams.selectContents){5935input.select();5936}5937}5938});59395940function onChange(){5941var value = input.value,5942luxTime;59435944if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){59455946if(value && inputFormat){5947luxTime = DT.fromFormat(String(value), "hh:mm");59485949switch(inputFormat){5950case true:5951value = luxTime;5952break;59535954case "iso":5955value = luxTime.toISO();5956break;59575958default:5959value = luxTime.toFormat(inputFormat);5960}5961}59625963if(success(value)){5964cellValue = input.value; //persist value if successfully validated incase editor is used as header filter5965}5966}else {5967cancel();5968}5969}59705971//submit new value on blur5972input.addEventListener("blur", function(e) {5973if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {5974onChange(); // only on a "true" blur; not when focusing browser's date/time picker5975}5976});59775978//submit new value on enter5979input.addEventListener("keydown", function(e){5980switch(e.keyCode){5981// case 9:5982case 13:5983onChange();5984break;59855986case 27:5987cancel();5988break;59895990case 35:5991case 36:5992e.stopPropagation();5993break;59945995case 38: //up arrow5996case 40: //down arrow5997if(vertNav == "editor"){5998e.stopImmediatePropagation();5999e.stopPropagation();6000}6001break;6002}6003});60046005return input;6006}60076008//input element6009function datetime(cell, onRendered, success, cancel, editorParams){6010var inputFormat = editorParams.format,6011vertNav = editorParams.verticalNavigation || "editor",6012DT = inputFormat ? (window.DateTime || luxon.DateTime) : null,6013newDatetime;60146015//create and style input6016var cellValue = cell.getValue(),6017input = document.createElement("input");60186019input.type = "datetime-local";6020input.style.padding = "4px";6021input.style.width = "100%";6022input.style.boxSizing = "border-box";60236024if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){6025for (let key in editorParams.elementAttributes){6026if(key.charAt(0) == "+"){6027key = key.slice(1);6028input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);6029}else {6030input.setAttribute(key, editorParams.elementAttributes[key]);6031}6032}6033}60346035cellValue = typeof cellValue !== "undefined" ? cellValue : "";60366037if(inputFormat){6038if(DT){6039if(DT.isDateTime(cellValue)){6040newDatetime = cellValue;6041}else if(inputFormat === "iso"){6042newDatetime = DT.fromISO(String(cellValue));6043}else {6044newDatetime = DT.fromFormat(String(cellValue), inputFormat);6045}60466047cellValue = newDatetime.toFormat("yyyy-MM-dd") + "T" + newDatetime.toFormat("hh:mm");6048}else {6049console.error("Editor Error - 'date' editor 'format' param is dependant on luxon.js");6050}6051}60526053input.value = cellValue;60546055onRendered(function(){6056if(cell.getType() === "cell"){6057input.focus({preventScroll: true});6058input.style.height = "100%";60596060if(editorParams.selectContents){6061input.select();6062}6063}6064});60656066function onChange(){6067var value = input.value,6068luxDateTime;60696070if(((cellValue === null || typeof cellValue === "undefined") && value !== "") || value !== cellValue){60716072if(value && inputFormat){6073luxDateTime = DT.fromISO(String(value));60746075switch(inputFormat){6076case true:6077value = luxDateTime;6078break;60796080case "iso":6081value = luxDateTime.toISO();6082break;60836084default:6085value = luxDateTime.toFormat(inputFormat);6086}6087}60886089if(success(value)){6090cellValue = input.value; //persist value if successfully validated incase editor is used as header filter6091}6092}else {6093cancel();6094}6095}60966097//submit new value on blur6098input.addEventListener("blur", function(e) {6099if (e.relatedTarget || e.rangeParent || e.explicitOriginalTarget !== input) {6100onChange(); // only on a "true" blur; not when focusing browser's date/time picker6101}6102});61036104//submit new value on enter6105input.addEventListener("keydown", function(e){6106switch(e.keyCode){6107// case 9:6108case 13:6109onChange();6110break;61116112case 27:6113cancel();6114break;61156116case 35:6117case 36:6118e.stopPropagation();6119break;61206121case 38: //up arrow6122case 40: //down arrow6123if(vertNav == "editor"){6124e.stopImmediatePropagation();6125e.stopPropagation();6126}6127break;6128}6129});61306131return input;6132}61336134class Edit{6135constructor(editor, cell, onRendered, success, cancel, editorParams){6136this.edit = editor;6137this.table = editor.table;6138this.cell = cell;6139this.params = this._initializeParams(editorParams);61406141this.data = [];6142this.displayItems = [];6143this.currentItems = [];6144this.focusedItem = null;61456146this.input = this._createInputElement();6147this.listEl = this._createListElement();61486149this.initialValues = null;61506151this.isFilter = cell.getType() === "header";61526153this.filterTimeout = null;6154this.filtered = false;6155this.typing = false;61566157this.values = [];6158this.popup = null;61596160this.listIteration = 0;61616162this.lastAction="";6163this.filterTerm="";61646165this.blurable = true;61666167this.actions = {6168success:success,6169cancel:cancel6170};61716172this._deprecatedOptionsCheck();6173this._initializeValue();61746175onRendered(this._onRendered.bind(this));6176}61776178_deprecatedOptionsCheck(){6179if(this.params.listItemFormatter){6180this.cell.getTable().deprecationAdvisor.msg("The listItemFormatter editor param has been deprecated, please see the latest editor documentation for updated options");6181}61826183if(this.params.sortValuesList){6184this.cell.getTable().deprecationAdvisor.msg("The sortValuesList editor param has been deprecated, please see the latest editor documentation for updated options");6185}61866187if(this.params.searchFunc){6188this.cell.getTable().deprecationAdvisor.msg("The searchFunc editor param has been deprecated, please see the latest editor documentation for updated options");6189}61906191if(this.params.searchingPlaceholder){6192this.cell.getTable().deprecationAdvisor.msg("The searchingPlaceholder editor param has been deprecated, please see the latest editor documentation for updated options");6193}6194}61956196_initializeValue(){6197var initialValue = this.cell.getValue();61986199if(typeof initialValue === "undefined" && typeof this.params.defaultValue !== "undefined"){6200initialValue = this.params.defaultValue;6201}62026203this.initialValues = this.params.multiselect ? initialValue : [initialValue];62046205if(this.isFilter){6206this.input.value = this.initialValues ? this.initialValues.join(",") : "";6207this.headerFilterInitialListGen();6208}6209}62106211_onRendered(){6212var cellEl = this.cell.getElement();62136214function clickStop(e){6215e.stopPropagation();6216}62176218if(!this.isFilter){6219this.input.style.height = "100%";6220this.input.focus({preventScroll: true});6221}622262236224cellEl.addEventListener("click", clickStop);62256226setTimeout(() => {6227cellEl.removeEventListener("click", clickStop);6228}, 1000);62296230this.input.addEventListener("mousedown", this._preventPopupBlur.bind(this));6231}62326233_createListElement(){6234var listEl = document.createElement("div");6235listEl.classList.add("tabulator-edit-list");62366237listEl.addEventListener("mousedown", this._preventBlur.bind(this));6238listEl.addEventListener("keydown", this._inputKeyDown.bind(this));62396240return listEl;6241}62426243_setListWidth(){6244var element = this.isFilter ? this.input : this.cell.getElement();62456246this.listEl.style.minWidth = element.offsetWidth + "px";62476248if(this.params.maxWidth){6249if(this.params.maxWidth === true){6250this.listEl.style.maxWidth = element.offsetWidth + "px";6251}else if(typeof this.params.maxWidth === "number"){6252this.listEl.style.maxWidth = this.params.maxWidth + "px";6253}else {6254this.listEl.style.maxWidth = this.params.maxWidth;6255}6256}62576258}62596260_createInputElement(){6261var attribs = this.params.elementAttributes;6262var input = document.createElement("input");62636264input.setAttribute("type", this.params.clearable ? "search" : "text");62656266input.style.padding = "4px";6267input.style.width = "100%";6268input.style.boxSizing = "border-box";62696270if(!this.params.autocomplete){6271input.style.cursor = "default";6272input.style.caretColor = "transparent";6273// input.readOnly = (this.edit.currentCell != false);6274}62756276if(attribs && typeof attribs == "object"){6277for (let key in attribs){6278if(key.charAt(0) == "+"){6279key = key.slice(1);6280input.setAttribute(key, input.getAttribute(key) + attribs["+" + key]);6281}else {6282input.setAttribute(key, attribs[key]);6283}6284}6285}62866287if(this.params.mask){6288maskInput(input, this.params);6289}62906291this._bindInputEvents(input);62926293return input;6294}62956296_initializeParams(params){6297var valueKeys = ["values", "valuesURL", "valuesLookup"],6298valueCheck;62996300params = Object.assign({}, params);63016302params.verticalNavigation = params.verticalNavigation || "editor";6303params.placeholderLoading = typeof params.placeholderLoading === "undefined" ? "Searching ..." : params.placeholderLoading;6304params.placeholderEmpty = typeof params.placeholderEmpty === "undefined" ? "No Results Found" : params.placeholderEmpty;6305params.filterDelay = typeof params.filterDelay === "undefined" ? 300 : params.filterDelay;63066307params.emptyValue = Object.keys(params).includes("emptyValue") ? params.emptyValue : "";63086309valueCheck = Object.keys(params).filter(key => valueKeys.includes(key)).length;63106311if(!valueCheck){6312console.warn("list editor config error - either the values, valuesURL, or valuesLookup option must be set");6313}else if(valueCheck > 1){6314console.warn("list editor config error - only one of the values, valuesURL, or valuesLookup options can be set on the same editor");6315}63166317if(params.autocomplete){6318if(params.multiselect){6319params.multiselect = false;6320console.warn("list editor config error - multiselect option is not available when autocomplete is enabled");6321}6322}else {6323if(params.freetext){6324params.freetext = false;6325console.warn("list editor config error - freetext option is only available when autocomplete is enabled");6326}63276328if(params.filterFunc){6329params.filterFunc = false;6330console.warn("list editor config error - filterFunc option is only available when autocomplete is enabled");6331}63326333if(params.filterRemote){6334params.filterRemote = false;6335console.warn("list editor config error - filterRemote option is only available when autocomplete is enabled");6336}63376338if(params.mask){6339params.mask = false;6340console.warn("list editor config error - mask option is only available when autocomplete is enabled");6341}63426343if(params.allowEmpty){6344params.allowEmpty = false;6345console.warn("list editor config error - allowEmpty option is only available when autocomplete is enabled");6346}63476348if(params.listOnEmpty){6349params.listOnEmpty = false;6350console.warn("list editor config error - listOnEmpty option is only available when autocomplete is enabled");6351}6352}63536354if(params.filterRemote && !(typeof params.valuesLookup === "function" || params.valuesURL)){6355params.filterRemote = false;6356console.warn("list editor config error - filterRemote option should only be used when values list is populated from a remote source");6357}6358return params;6359}6360//////////////////////////////////////6361////////// Event Handling ////////////6362//////////////////////////////////////63636364_bindInputEvents(input){6365input.addEventListener("focus", this._inputFocus.bind(this));6366input.addEventListener("click", this._inputClick.bind(this));6367input.addEventListener("blur", this._inputBlur.bind(this));6368input.addEventListener("keydown", this._inputKeyDown.bind(this));6369input.addEventListener("search", this._inputSearch.bind(this));63706371if(this.params.autocomplete){6372input.addEventListener("keyup", this._inputKeyUp.bind(this));6373}6374}637563766377_inputFocus(e){6378this.rebuildOptionsList();6379}63806381_filter(){6382if(this.params.filterRemote){6383clearTimeout(this.filterTimeout);63846385this.filterTimeout = setTimeout(() => {6386this.rebuildOptionsList();6387}, this.params.filterDelay);6388}else {6389this._filterList();6390}6391}63926393_inputClick(e){6394e.stopPropagation();6395}63966397_inputBlur(e){6398if(this.blurable){6399if(this.popup){6400this.popup.hide();6401}else {6402this._resolveValue(true);6403}6404}6405}64066407_inputSearch(){6408this._clearChoices();6409}64106411_inputKeyDown(e){6412switch(e.keyCode){64136414case 38: //up arrow6415this._keyUp(e);6416break;64176418case 40: //down arrow6419this._keyDown(e);6420break;64216422case 37: //left arrow6423case 39: //right arrow6424this._keySide(e);6425break;64266427case 13: //enter6428this._keyEnter();6429break;64306431case 27: //escape6432this._keyEsc();6433break;64346435case 36: //home6436case 35: //end6437this._keyHomeEnd(e);6438break;64396440case 9: //tab6441this._keyTab(e);6442break;64436444default:6445this._keySelectLetter(e);6446}6447}64486449_inputKeyUp(e){6450switch(e.keyCode){6451case 38: //up arrow6452case 37: //left arrow6453case 39: //up arrow6454case 40: //right arrow6455case 13: //enter6456case 27: //escape6457break;64586459default:6460this._keyAutoCompLetter(e);6461}6462}64636464_preventPopupBlur(){6465if(this.popup){6466this.popup.blockHide();6467}64686469setTimeout(() =>{6470if(this.popup){6471this.popup.restoreHide();6472}6473}, 10);6474}64756476_preventBlur(){6477this.blurable = false;64786479setTimeout(() =>{6480this.blurable = true;6481}, 10);6482}64836484//////////////////////////////////////6485//////// Keyboard Navigation /////////6486//////////////////////////////////////64876488_keyTab(e){6489if(this.params.autocomplete && this.lastAction === "typing"){6490this._resolveValue(true);6491}else {6492if(this.focusedItem){6493this._chooseItem(this.focusedItem, true);6494}6495}6496}64976498_keyUp(e){6499var index = this.displayItems.indexOf(this.focusedItem);65006501if(this.params.verticalNavigation == "editor" || (this.params.verticalNavigation == "hybrid" && index)){6502e.stopImmediatePropagation();6503e.stopPropagation();6504e.preventDefault();65056506if(index > 0){6507this._focusItem(this.displayItems[index - 1]);6508}6509}6510}65116512_keyDown(e){6513var index = this.displayItems.indexOf(this.focusedItem);65146515if(this.params.verticalNavigation == "editor" || (this.params.verticalNavigation == "hybrid" && index < this.displayItems.length - 1)){6516e.stopImmediatePropagation();6517e.stopPropagation();6518e.preventDefault();65196520if(index < this.displayItems.length - 1){6521if(index == -1){6522this._focusItem(this.displayItems[0]);6523}else {6524this._focusItem(this.displayItems[index + 1]);6525}6526}6527}6528}65296530_keySide(e){6531if(!this.params.autocomplete){6532e.stopImmediatePropagation();6533e.stopPropagation();6534e.preventDefault();6535}6536}65376538_keyEnter(e){6539if(this.params.autocomplete && this.lastAction === "typing"){6540this._resolveValue(true);6541}else {6542if(this.focusedItem){6543this._chooseItem(this.focusedItem);6544}6545}6546}65476548_keyEsc(e){6549this._cancel();6550}65516552_keyHomeEnd(e){6553if(this.params.autocomplete){6554//prevent table navigation while using input element6555e.stopImmediatePropagation();6556}6557}65586559_keySelectLetter(e){6560if(!this.params.autocomplete){6561// if(this.edit.currentCell === false){6562e.preventDefault();6563// }65646565if(e.keyCode >= 38 && e.keyCode <= 90){6566this._scrollToValue(e.keyCode);6567}6568}6569}65706571_keyAutoCompLetter(e){6572this._filter();6573this.lastAction = "typing";6574this.typing = true;6575}657665776578_scrollToValue(char){6579clearTimeout(this.filterTimeout);65806581var character = String.fromCharCode(char).toLowerCase();6582this.filterTerm += character.toLowerCase();65836584var match = this.displayItems.find((item) => {6585return typeof item.label !== "undefined" && item.label.toLowerCase().startsWith(this.filterTerm);6586});65876588if(match){6589this._focusItem(match);6590}65916592this.filterTimeout = setTimeout(() => {6593this.filterTerm = "";6594}, 800);6595}65966597_focusItem(item){6598this.lastAction = "focus";65996600if(this.focusedItem && this.focusedItem.element){6601this.focusedItem.element.classList.remove("focused");6602}66036604this.focusedItem = item;66056606if(item && item.element){6607item.element.classList.add("focused");6608item.element.scrollIntoView({behavior: 'smooth', block: 'nearest', inline: 'start'});6609}6610}661166126613//////////////////////////////////////6614/////// Data List Generation /////////6615//////////////////////////////////////6616headerFilterInitialListGen(){6617this._generateOptions(true);6618}66196620rebuildOptionsList(){6621this._generateOptions()6622.then(this._sortOptions.bind(this))6623.then(this._buildList.bind(this))6624.then(this._showList.bind(this))6625.catch((e) => {6626if(!Number.isInteger(e)){6627console.error("List generation error", e);6628}6629});6630}66316632_filterList(){6633this._buildList(this._filterOptions());6634this._showList();6635}66366637_generateOptions(silent){6638var values = [];6639var iteration = ++ this.listIteration;66406641this.filtered = false;66426643if(this.params.values){6644values = this.params.values;6645}else if (this.params.valuesURL){6646values = this._ajaxRequest(this.params.valuesURL, this.input.value);6647}else {6648if(typeof this.params.valuesLookup === "function"){6649values = this.params.valuesLookup(this.cell, this.input.value);6650}else if(this.params.valuesLookup){6651values = this._uniqueColumnValues(this.params.valuesLookupField);6652}6653}66546655if(values instanceof Promise){6656if(!silent){6657this._addPlaceholder(this.params.placeholderLoading);6658}66596660return values.then()6661.then((responseValues) => {6662if(this.listIteration === iteration){6663return this._parseList(responseValues);6664}else {6665return Promise.reject(iteration);6666}6667});6668}else {6669return Promise.resolve(this._parseList(values));6670}6671}66726673_addPlaceholder(contents){6674var placeholder = document.createElement("div");66756676if(typeof contents === "function"){6677contents = contents(this.cell.getComponent(), this.listEl);6678}66796680if(contents){6681this._clearList();66826683if(contents instanceof HTMLElement){6684placeholder = contents;6685}else {6686placeholder.classList.add("tabulator-edit-list-placeholder");6687placeholder.innerHTML = contents;6688}66896690this.listEl.appendChild(placeholder);66916692this._showList();6693}6694}66956696_ajaxRequest(url, term){6697var params = this.params.filterRemote ? {term:term} : {};6698url = urlBuilder(url, {}, params);66996700return fetch(url)6701.then((response)=>{6702if(response.ok) {6703return response.json()6704.catch((error)=>{6705console.warn("List Ajax Load Error - Invalid JSON returned", error);6706return Promise.reject(error);6707});6708}else {6709console.error("List Ajax Load Error - Connection Error: " + response.status, response.statusText);6710return Promise.reject(response);6711}6712})6713.catch((error)=>{6714console.error("List Ajax Load Error - Connection Error: ", error);6715return Promise.reject(error);6716});6717}67186719_uniqueColumnValues(field){6720var output = {},6721data = this.table.getData(this.params.valuesLookup),6722column;67236724if(field){6725column = this.table.columnManager.getColumnByField(field);6726}else {6727column = this.cell.getColumn()._getSelf();6728}67296730if(column){6731data.forEach((row) => {6732var val = column.getFieldValue(row);67336734if(val !== null && typeof val !== "undefined" && val !== ""){6735output[val] = true;6736}6737});6738}else {6739console.warn("unable to find matching column to create select lookup list:", field);6740output = [];6741}67426743return Object.keys(output);6744}674567466747_parseList(inputValues){6748var data = [];67496750if(!Array.isArray(inputValues)){6751inputValues = Object.entries(inputValues).map(([key, value]) => {6752return {6753label:value,6754value:key,6755};6756});6757}67586759inputValues.forEach((value) => {6760if(typeof value !== "object"){6761value = {6762label:value,6763value:value,6764};6765}67666767this._parseListItem(value, data, 0);6768});67696770if(!this.currentItems.length && this.params.freetext){6771this.input.value = this.initialValues;6772this.typing = true;6773this.lastAction = "typing";6774}67756776this.data = data;67776778return data;6779}67806781_parseListItem(option, data, level){6782var item = {};67836784if(option.options){6785item = this._parseListGroup(option, level + 1);6786}else {6787item = {6788label:option.label,6789value:option.value,6790itemParams:option.itemParams,6791elementAttributes: option.elementAttributes,6792element:false,6793selected:false,6794visible:true,6795level:level,6796original:option,6797};67986799if(this.initialValues && this.initialValues.indexOf(option.value) > -1){6800this._chooseItem(item, true);6801}6802}68036804data.push(item);6805}68066807_parseListGroup(option, level){6808var item = {6809label:option.label,6810group:true,6811itemParams:option.itemParams,6812elementAttributes:option.elementAttributes,6813element:false,6814visible:true,6815level:level,6816options:[],6817original:option,6818};68196820option.options.forEach((child) => {6821this._parseListItem(child, item.options, level);6822});68236824return item;6825}68266827_sortOptions(options){6828var sorter;68296830if(this.params.sort){6831sorter = typeof this.params.sort === "function" ? this.params.sort : this._defaultSortFunction.bind(this);68326833this._sortGroup(sorter, options);6834}68356836return options;6837}68386839_sortGroup(sorter, options){6840options.sort((a,b) => {6841return sorter(a.label, b.label, a.value, b.value, a.original, b.original);6842});68436844options.forEach((option) => {6845if(option.group){6846this._sortGroup(sorter, option.options);6847}6848});6849}68506851_defaultSortFunction(as, bs){6852var a, b, a1, b1, i= 0, L, rx = /(\d+)|(\D+)/g, rd = /\d/;6853var emptyAlign = 0;68546855if(this.params.sort === "desc"){6856[as, bs] = [bs, as];6857}68586859//handle empty values6860if(!as && as!== 0){6861emptyAlign = !bs && bs!== 0 ? 0 : -1;6862}else if(!bs && bs!== 0){6863emptyAlign = 1;6864}else {6865if(isFinite(as) && isFinite(bs)) return as - bs;6866a = String(as).toLowerCase();6867b = String(bs).toLowerCase();6868if(a === b) return 0;6869if(!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;6870a = a.match(rx);6871b = b.match(rx);6872L = a.length > b.length ? b.length : a.length;6873while(i < L){6874a1= a[i];6875b1= b[i++];6876if(a1 !== b1){6877if(isFinite(a1) && isFinite(b1)){6878if(a1.charAt(0) === "0") a1 = "." + a1;6879if(b1.charAt(0) === "0") b1 = "." + b1;6880return a1 - b1;6881}6882else return a1 > b1 ? 1 : -1;6883}6884}68856886return a.length > b.length;6887}68886889return emptyAlign;6890}68916892_filterOptions(){6893var filterFunc = this.params.filterFunc || this._defaultFilterFunc,6894term = this.input.value;68956896if(term){6897this.filtered = true;68986899this.data.forEach((item) => {6900this._filterItem(filterFunc, term, item);6901});6902}else {6903this.filtered = false;6904}69056906return this.data;6907}69086909_filterItem(func, term, item){6910var matches = false;69116912if(!item.group){6913item.visible = func(term, item.label, item.value, item.original);6914}else {6915item.options.forEach((option) => {6916if(this._filterItem(func, term, option)){6917matches = true;6918}6919});69206921item.visible = matches;6922}69236924return item.visible;6925}69266927_defaultFilterFunc(term, label, value, item){6928term = String(term).toLowerCase();69296930if(label !== null && typeof label !== "undefined"){6931if(String(label).toLowerCase().indexOf(term) > -1 || String(value).toLowerCase().indexOf(term) > -1){6932return true;6933}6934}69356936return false;6937}69386939//////////////////////////////////////6940/////////// Display List /////////////6941//////////////////////////////////////69426943_clearList(){6944while(this.listEl.firstChild) this.listEl.removeChild(this.listEl.firstChild);69456946this.displayItems = [];6947}69486949_buildList(data){6950this._clearList();69516952data.forEach((option) => {6953this._buildItem(option);6954});69556956if(!this.displayItems.length){6957this._addPlaceholder(this.params.placeholderEmpty);6958}6959}69606961_buildItem(item){6962var el = item.element,6963contents;69646965if(!this.filtered || item.visible){69666967if(!el){6968el = document.createElement("div");6969el.tabIndex = 0;69706971contents = this.params.itemFormatter ? this.params.itemFormatter(item.label, item.value, item.original, el) : item.label;69726973if(contents instanceof HTMLElement){6974el.appendChild(contents);6975}else {6976el.innerHTML = contents;6977}69786979if(item.group){6980el.classList.add("tabulator-edit-list-group");6981}else {6982el.classList.add("tabulator-edit-list-item");6983}69846985el.classList.add("tabulator-edit-list-group-level-" + item.level);69866987if(item.elementAttributes && typeof item.elementAttributes == "object"){6988for (let key in item.elementAttributes){6989if(key.charAt(0) == "+"){6990key = key.slice(1);6991el.setAttribute(key, this.input.getAttribute(key) + item.elementAttributes["+" + key]);6992}else {6993el.setAttribute(key, item.elementAttributes[key]);6994}6995}6996}69976998if(item.group){6999el.addEventListener("click", this._groupClick.bind(this, item));7000}else {7001el.addEventListener("click", this._itemClick.bind(this, item));7002}70037004el.addEventListener("mousedown", this._preventBlur.bind(this));70057006item.element = el;7007}70087009this._styleItem(item);70107011this.listEl.appendChild(el);70127013if(item.group){7014item.options.forEach((option) => {7015this._buildItem(option);7016});7017}else {7018this.displayItems.push(item);7019}7020}7021}70227023_showList(){7024var startVis = this.popup && this.popup.isVisible();70257026if(this.input.parentNode){7027if(this.params.autocomplete && this.input.value === "" && !this.params.listOnEmpty){7028if(this.popup){7029this.popup.hide(true);7030}7031return;7032}70337034this._setListWidth();70357036if(!this.popup){7037this.popup = this.edit.popup(this.listEl);7038}70397040this.popup.show(this.cell.getElement(), "bottom");70417042if(!startVis){7043setTimeout(() => {7044this.popup.hideOnBlur(this._resolveValue.bind(this, true));7045}, 10);7046}7047}7048}70497050_styleItem(item){7051if(item && item.element){7052if(item.selected){7053item.element.classList.add("active");7054}else {7055item.element.classList.remove("active");7056}7057}7058}70597060//////////////////////////////////////7061///////// User Interaction ///////////7062//////////////////////////////////////70637064_itemClick(item, e){7065e.stopPropagation();70667067this._chooseItem(item);7068}70697070_groupClick(item, e){7071e.stopPropagation();7072}707370747075//////////////////////////////////////7076////// Current Item Management ///////7077//////////////////////////////////////70787079_cancel(){7080this.popup.hide(true);7081this.actions.cancel();7082}70837084_clearChoices(){7085this.typing = true;70867087this.currentItems.forEach((item) => {7088item.selected = false;7089this._styleItem(item);7090});70917092this.currentItems = [];70937094this.focusedItem = null;7095}70967097_chooseItem(item, silent){7098var index;70997100this.typing = false;71017102if(this.params.multiselect){7103index = this.currentItems.indexOf(item);71047105if(index > -1){7106this.currentItems.splice(index, 1);7107item.selected = false;7108}else {7109this.currentItems.push(item);7110item.selected = true;7111}71127113this.input.value = this.currentItems.map(item => item.label).join(",");71147115this._styleItem(item);71167117}else {7118this.currentItems = [item];7119item.selected = true;71207121this.input.value = item.label;71227123this._styleItem(item);71247125if(!silent){7126this._resolveValue();7127}7128}71297130this._focusItem(item);7131}71327133_resolveValue(blur){7134var output, initialValue;71357136if(this.popup){7137this.popup.hide(true);7138}71397140if(this.params.multiselect){7141output = this.currentItems.map(item => item.value);7142}else {7143if(blur && this.params.autocomplete && this.typing){7144if(this.params.freetext || (this.params.allowEmpty && this.input.value === "")){7145output = this.input.value;7146}else {7147this.actions.cancel();7148return;7149}7150}else {7151if(this.currentItems[0]){7152output = this.currentItems[0].value;7153}else {7154initialValue = Array.isArray(this.initialValues) ? this.initialValues[0] : this.initialValues;71557156if(initialValue === null || typeof initialValue === "undefined" || initialValue === ""){7157output = initialValue;7158}else {7159output = this.params.emptyValue;7160}7161}71627163}7164}71657166if(output === ""){7167output = this.params.emptyValue;7168}71697170this.actions.success(output);71717172if(this.isFilter){7173this.initialValues = output && !Array.isArray(output) ? [output] : output;7174this.currentItems = [];7175}7176}71777178}71797180function select(cell, onRendered, success, cancel, editorParams){71817182this.deprecationMsg("The select editor has been deprecated, please use the new list editor");71837184var list = new Edit(this, cell, onRendered, success, cancel, editorParams);71857186return list.input;7187}71887189function list(cell, onRendered, success, cancel, editorParams){7190var list = new Edit(this, cell, onRendered, success, cancel, editorParams);71917192return list.input;7193}71947195function autocomplete(cell, onRendered, success, cancel, editorParams){71967197this.deprecationMsg("The autocomplete editor has been deprecated, please use the new list editor with the 'autocomplete' editorParam");71987199editorParams.autocomplete = true;72007201var list = new Edit(this, cell, onRendered, success, cancel, editorParams);72027203return list.input;7204}72057206//star rating7207function star(cell, onRendered, success, cancel, editorParams){7208var self = this,7209element = cell.getElement(),7210value = cell.getValue(),7211maxStars = element.getElementsByTagName("svg").length || 5,7212size = element.getElementsByTagName("svg")[0] ? element.getElementsByTagName("svg")[0].getAttribute("width") : 14,7213stars = [],7214starsHolder = document.createElement("div"),7215star = document.createElementNS('http://www.w3.org/2000/svg', "svg");721672177218//change star type7219function starChange(val){7220stars.forEach(function(star, i){7221if(i < val){7222if(self.table.browser == "ie"){7223star.setAttribute("class", "tabulator-star-active");7224}else {7225star.classList.replace("tabulator-star-inactive", "tabulator-star-active");7226}72277228star.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 "/>';7229}else {7230if(self.table.browser == "ie"){7231star.setAttribute("class", "tabulator-star-inactive");7232}else {7233star.classList.replace("tabulator-star-active", "tabulator-star-inactive");7234}72357236star.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 "/>';7237}7238});7239}72407241//build stars7242function buildStar(i){72437244var starHolder = document.createElement("span");7245var nextStar = star.cloneNode(true);72467247stars.push(nextStar);72487249starHolder.addEventListener("mouseenter", function(e){7250e.stopPropagation();7251e.stopImmediatePropagation();7252starChange(i);7253});72547255starHolder.addEventListener("mousemove", function(e){7256e.stopPropagation();7257e.stopImmediatePropagation();7258});72597260starHolder.addEventListener("click", function(e){7261e.stopPropagation();7262e.stopImmediatePropagation();7263success(i);7264element.blur();7265});72667267starHolder.appendChild(nextStar);7268starsHolder.appendChild(starHolder);72697270}72717272//handle keyboard navigation value change7273function changeValue(val){7274value = val;7275starChange(val);7276}72777278//style cell7279element.style.whiteSpace = "nowrap";7280element.style.overflow = "hidden";7281element.style.textOverflow = "ellipsis";72827283//style holding element7284starsHolder.style.verticalAlign = "middle";7285starsHolder.style.display = "inline-block";7286starsHolder.style.padding = "4px";72877288//style star7289star.setAttribute("width", size);7290star.setAttribute("height", size);7291star.setAttribute("viewBox", "0 0 512 512");7292star.setAttribute("xml:space", "preserve");7293star.style.padding = "0 1px";72947295if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){7296for (let key in editorParams.elementAttributes){7297if(key.charAt(0) == "+"){7298key = key.slice(1);7299starsHolder.setAttribute(key, starsHolder.getAttribute(key) + editorParams.elementAttributes["+" + key]);7300}else {7301starsHolder.setAttribute(key, editorParams.elementAttributes[key]);7302}7303}7304}73057306//create correct number of stars7307for(var i=1;i<= maxStars;i++){7308buildStar(i);7309}73107311//ensure value does not exceed number of stars7312value = Math.min(parseInt(value), maxStars);73137314// set initial styling of stars7315starChange(value);73167317starsHolder.addEventListener("mousemove", function(e){7318starChange(0);7319});73207321starsHolder.addEventListener("click", function(e){7322success(0);7323});73247325element.addEventListener("blur", function(e){7326cancel();7327});73287329//allow key based navigation7330element.addEventListener("keydown", function(e){7331switch(e.keyCode){7332case 39: //right arrow7333changeValue(value + 1);7334break;73357336case 37: //left arrow7337changeValue(value - 1);7338break;73397340case 13: //enter7341success(value);7342break;73437344case 27: //escape7345cancel();7346break;7347}7348});73497350return starsHolder;7351}73527353//draggable progress bar7354function progress(cell, onRendered, success, cancel, editorParams){7355var element = cell.getElement(),7356max = typeof editorParams.max === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("max")) || 100) : editorParams.max,7357min = typeof editorParams.min === "undefined" ? ((element.getElementsByTagName("div")[0] && element.getElementsByTagName("div")[0].getAttribute("min")) || 0) : editorParams.min,7358percent = (max - min) / 100,7359value = cell.getValue() || 0,7360handle = document.createElement("div"),7361bar = document.createElement("div"),7362mouseDrag, mouseDragWidth;73637364//set new value7365function updateValue(){7366var style = window.getComputedStyle(element, null);73677368var calcVal = (percent * Math.round(bar.offsetWidth / ((element.clientWidth - parseInt(style.getPropertyValue("padding-left")) - parseInt(style.getPropertyValue("padding-right")))/100))) + min;7369success(calcVal);7370element.setAttribute("aria-valuenow", calcVal);7371element.setAttribute("aria-label", value);7372}73737374//style handle7375handle.style.position = "absolute";7376handle.style.right = "0";7377handle.style.top = "0";7378handle.style.bottom = "0";7379handle.style.width = "5px";7380handle.classList.add("tabulator-progress-handle");73817382//style bar7383bar.style.display = "inline-block";7384bar.style.position = "relative";7385// bar.style.top = "8px";7386// bar.style.bottom = "8px";7387// bar.style.left = "4px";7388// bar.style.marginRight = "4px";7389bar.style.height = "100%";7390bar.style.backgroundColor = "#488CE9";7391bar.style.maxWidth = "100%";7392bar.style.minWidth = "0%";73937394if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){7395for (let key in editorParams.elementAttributes){7396if(key.charAt(0) == "+"){7397key = key.slice(1);7398bar.setAttribute(key, bar.getAttribute(key) + editorParams.elementAttributes["+" + key]);7399}else {7400bar.setAttribute(key, editorParams.elementAttributes[key]);7401}7402}7403}74047405//style cell7406element.style.padding = "4px 4px";74077408//make sure value is in range7409value = Math.min(parseFloat(value), max);7410value = Math.max(parseFloat(value), min);74117412//workout percentage7413value = Math.round((value - min) / percent);7414// bar.style.right = value + "%";7415bar.style.width = value + "%";74167417element.setAttribute("aria-valuemin", min);7418element.setAttribute("aria-valuemax", max);74197420bar.appendChild(handle);74217422handle.addEventListener("mousedown", function(e){7423mouseDrag = e.screenX;7424mouseDragWidth = bar.offsetWidth;7425});74267427handle.addEventListener("mouseover", function(){7428handle.style.cursor = "ew-resize";7429});74307431element.addEventListener("mousemove", function(e){7432if(mouseDrag){7433bar.style.width = (mouseDragWidth + e.screenX - mouseDrag) + "px";7434}7435});74367437element.addEventListener("mouseup", function(e){7438if(mouseDrag){7439e.stopPropagation();7440e.stopImmediatePropagation();74417442mouseDrag = false;7443mouseDragWidth = false;74447445updateValue();7446}7447});74487449//allow key based navigation7450element.addEventListener("keydown", function(e){7451switch(e.keyCode){7452case 39: //right arrow7453e.preventDefault();7454bar.style.width = (bar.clientWidth + element.clientWidth/100) + "px";7455break;74567457case 37: //left arrow7458e.preventDefault();7459bar.style.width = (bar.clientWidth - element.clientWidth/100) + "px";7460break;74617462case 9: //tab7463case 13: //enter7464updateValue();7465break;74667467case 27: //escape7468cancel();7469break;74707471}7472});74737474element.addEventListener("blur", function(){7475cancel();7476});74777478return bar;7479}74807481//checkbox7482function tickCross(cell, onRendered, success, cancel, editorParams){7483var value = cell.getValue(),7484input = document.createElement("input"),7485tristate = editorParams.tristate,7486indetermValue = typeof editorParams.indeterminateValue === "undefined" ? null : editorParams.indeterminateValue,7487indetermState = false,7488trueValueSet = Object.keys(editorParams).includes("trueValue"),7489falseValueSet = Object.keys(editorParams).includes("falseValue");74907491input.setAttribute("type", "checkbox");7492input.style.marginTop = "5px";7493input.style.boxSizing = "border-box";74947495if(editorParams.elementAttributes && typeof editorParams.elementAttributes == "object"){7496for (let key in editorParams.elementAttributes){7497if(key.charAt(0) == "+"){7498key = key.slice(1);7499input.setAttribute(key, input.getAttribute(key) + editorParams.elementAttributes["+" + key]);7500}else {7501input.setAttribute(key, editorParams.elementAttributes[key]);7502}7503}7504}75057506input.value = value;75077508if(tristate && (typeof value === "undefined" || value === indetermValue || value === "")){7509indetermState = true;7510input.indeterminate = true;7511}75127513if(this.table.browser != "firefox" && this.table.browser != "safari"){ //prevent blur issue on mac firefox7514onRendered(function(){7515if(cell.getType() === "cell"){7516input.focus({preventScroll: true});7517}7518});7519}75207521input.checked = trueValueSet ? value === editorParams.trueValue : (value === true || value === "true" || value === "True" || value === 1);75227523function setValue(blur){7524var checkedValue = input.checked;75257526if(trueValueSet && checkedValue){7527checkedValue = editorParams.trueValue;7528}else if(falseValueSet && !checkedValue){7529checkedValue = editorParams.falseValue;7530}75317532if(tristate){7533if(!blur){7534if(input.checked && !indetermState){7535input.checked = false;7536input.indeterminate = true;7537indetermState = true;7538return indetermValue;7539}else {7540indetermState = false;7541return checkedValue;7542}7543}else {7544if(indetermState){7545return indetermValue;7546}else {7547return checkedValue;7548}7549}7550}else {7551return checkedValue;7552}7553}75547555//submit new value on blur7556input.addEventListener("change", function(e){7557success(setValue());7558});75597560input.addEventListener("blur", function(e){7561success(setValue(true));7562});75637564//submit new value on enter7565input.addEventListener("keydown", function(e){7566if(e.keyCode == 13){7567success(setValue());7568}7569if(e.keyCode == 27){7570cancel();7571}7572});75737574return input;7575}75767577var defaultEditors = {7578input:input,7579textarea:textarea,7580number:number,7581range:range,7582date:date,7583time:time,7584datetime:datetime,7585select:select,7586list:list,7587autocomplete:autocomplete,7588star:star,7589progress:progress,7590tickCross:tickCross,7591};75927593class Edit$1 extends Module{75947595constructor(table){7596super(table);75977598this.currentCell = false; //hold currently editing cell7599this.mouseClick = false; //hold mousedown state to prevent click binding being overridden by editor opening7600this.recursionBlock = false; //prevent focus recursion7601this.invalidEdit = false;7602this.editedCells = [];76037604this.editors = Edit$1.editors;76057606this.registerColumnOption("editable");7607this.registerColumnOption("editor");7608this.registerColumnOption("editorParams");76097610this.registerColumnOption("cellEditing");7611this.registerColumnOption("cellEdited");7612this.registerColumnOption("cellEditCancelled");76137614this.registerTableFunction("getEditedCells", this.getEditedCells.bind(this));7615this.registerTableFunction("clearCellEdited", this.clearCellEdited.bind(this));7616this.registerTableFunction("navigatePrev", this.navigatePrev.bind(this));7617this.registerTableFunction("navigateNext", this.navigateNext.bind(this));7618this.registerTableFunction("navigateLeft", this.navigateLeft.bind(this));7619this.registerTableFunction("navigateRight", this.navigateRight.bind(this));7620this.registerTableFunction("navigateUp", this.navigateUp.bind(this));7621this.registerTableFunction("navigateDown", this.navigateDown.bind(this));76227623this.registerComponentFunction("cell", "isEdited", this.cellIsEdited.bind(this));7624this.registerComponentFunction("cell", "clearEdited", this.clearEdited.bind(this));7625this.registerComponentFunction("cell", "edit", this.editCell.bind(this));7626this.registerComponentFunction("cell", "cancelEdit", this.cellCancelEdit.bind(this));76277628this.registerComponentFunction("cell", "navigatePrev", this.navigatePrev.bind(this));7629this.registerComponentFunction("cell", "navigateNext", this.navigateNext.bind(this));7630this.registerComponentFunction("cell", "navigateLeft", this.navigateLeft.bind(this));7631this.registerComponentFunction("cell", "navigateRight", this.navigateRight.bind(this));7632this.registerComponentFunction("cell", "navigateUp", this.navigateUp.bind(this));7633this.registerComponentFunction("cell", "navigateDown", this.navigateDown.bind(this));7634}76357636initialize(){7637this.subscribe("cell-init", this.bindEditor.bind(this));7638this.subscribe("cell-delete", this.clearEdited.bind(this));7639this.subscribe("cell-value-changed", this.updateCellClass.bind(this));7640this.subscribe("column-layout", this.initializeColumnCheck.bind(this));7641this.subscribe("column-delete", this.columnDeleteCheck.bind(this));7642this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));7643this.subscribe("row-layout", this.rowEditableCheck.bind(this));7644this.subscribe("data-refreshing", this.cancelEdit.bind(this));76457646this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));7647this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));7648this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined));7649this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined));7650this.subscribe("keybinding-nav-up", this.navigateUp.bind(this, undefined));7651this.subscribe("keybinding-nav-down", this.navigateDown.bind(this, undefined));7652}765376547655///////////////////////////////////7656////// Keybinding Functions ///////7657///////////////////////////////////76587659keybindingNavigateNext(e){7660var cell = this.currentCell,7661newRow = this.options("tabEndNewRow");76627663if(cell){7664if(!this.navigateNext(cell, e)){7665if(newRow){7666cell.getElement().firstChild.blur();76677668if(newRow === true){7669newRow = this.table.addRow({});7670}else {7671if(typeof newRow == "function"){7672newRow = this.table.addRow(newRow(cell.row.getComponent()));7673}else {7674newRow = this.table.addRow(Object.assign({}, newRow));7675}7676}76777678newRow.then(() => {7679setTimeout(() => {7680cell.getComponent().navigateNext();7681});7682});7683}7684}7685}7686}76877688///////////////////////////////////7689///////// Cell Functions //////////7690///////////////////////////////////76917692cellIsEdited(cell){7693return !! cell.modules.edit && cell.modules.edit.edited;7694}76957696cellCancelEdit(cell){7697if(cell === this.currentCell){7698this.table.modules.edit.cancelEdit();7699}else {7700console.warn("Cancel Editor Error - This cell is not currently being edited ");7701}7702}770377047705///////////////////////////////////7706///////// Table Functions /////////7707///////////////////////////////////7708updateCellClass(cell){7709if(this.allowEdit(cell)) {7710cell.getElement().classList.add("tabulator-editable");7711}7712else {7713cell.getElement().classList.remove("tabulator-editable");7714}7715}77167717clearCellEdited(cells){7718if(!cells){7719cells = this.table.modules.edit.getEditedCells();7720}77217722if(!Array.isArray(cells)){7723cells = [cells];7724}77257726cells.forEach((cell) => {7727this.table.modules.edit.clearEdited(cell._getSelf());7728});7729}77307731navigatePrev(cell = this.currentCell, e){7732var nextCell, prevRow;77337734if(cell){77357736if(e){7737e.preventDefault();7738}77397740nextCell = this.navigateLeft();77417742if(nextCell){7743return true;7744}else {7745prevRow = this.table.rowManager.prevDisplayRow(cell.row, true);77467747if(prevRow){7748nextCell = this.findPrevEditableCell(prevRow, prevRow.cells.length);77497750if(nextCell){7751nextCell.getComponent().edit();7752return true;7753}7754}7755}7756}77577758return false;7759}77607761navigateNext(cell = this.currentCell, e){7762var nextCell, nextRow;77637764if(cell){77657766if(e){7767e.preventDefault();7768}77697770nextCell = this.navigateRight();77717772if(nextCell){7773return true;7774}else {7775nextRow = this.table.rowManager.nextDisplayRow(cell.row, true);77767777if(nextRow){7778nextCell = this.findNextEditableCell(nextRow, -1);77797780if(nextCell){7781nextCell.getComponent().edit();7782return true;7783}7784}7785}7786}77877788return false;7789}77907791navigateLeft(cell = this.currentCell, e){7792var index, nextCell;77937794if(cell){77957796if(e){7797e.preventDefault();7798}77997800index = cell.getIndex();7801nextCell = this.findPrevEditableCell(cell.row, index);78027803if(nextCell){7804nextCell.getComponent().edit();7805return true;7806}7807}78087809return false;7810}78117812navigateRight(cell = this.currentCell, e){7813var index, nextCell;78147815if(cell){78167817if(e){7818e.preventDefault();7819}78207821index = cell.getIndex();7822nextCell = this.findNextEditableCell(cell.row, index);78237824if(nextCell){7825nextCell.getComponent().edit();7826return true;7827}7828}78297830return false;7831}78327833navigateUp(cell = this.currentCell, e){7834var index, nextRow;78357836if(cell){78377838if(e){7839e.preventDefault();7840}78417842index = cell.getIndex();7843nextRow = this.table.rowManager.prevDisplayRow(cell.row, true);78447845if(nextRow){7846nextRow.cells[index].getComponent().edit();7847return true;7848}7849}78507851return false;7852}78537854navigateDown(cell = this.currentCell, e){7855var index, nextRow;78567857if(cell){78587859if(e){7860e.preventDefault();7861}78627863index = cell.getIndex();7864nextRow = this.table.rowManager.nextDisplayRow(cell.row, true);78657866if(nextRow){7867nextRow.cells[index].getComponent().edit();7868return true;7869}7870}78717872return false;7873}78747875findNextEditableCell(row, index){7876var nextCell = false;78777878if(index < row.cells.length-1){7879for(var i = index+1; i < row.cells.length; i++){7880let cell = row.cells[i];78817882if(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){7883let allowEdit = this.allowEdit(cell);78847885if(allowEdit){7886nextCell = cell;7887break;7888}7889}7890}7891}78927893return nextCell;7894}78957896findPrevEditableCell(row, index){7897var prevCell = false;78987899if(index > 0){7900for(var i = index-1; i >= 0; i--){7901let cell = row.cells[i];79027903if(cell.column.modules.edit && Helpers.elVisible(cell.getElement())){7904let allowEdit = this.allowEdit(cell);79057906if(allowEdit){7907prevCell = cell;7908break;7909}7910}7911}7912}79137914return prevCell;7915}79167917///////////////////////////////////7918///////// Internal Logic //////////7919///////////////////////////////////79207921initializeColumnCheck(column){7922if(typeof column.definition.editor !== "undefined"){7923this.initializeColumn(column);7924}7925}79267927columnDeleteCheck(column){7928if(this.currentCell && this.currentCell.column === column){7929this.cancelEdit();7930}7931}79327933rowDeleteCheck(row){7934if(this.currentCell && this.currentCell.row === row){7935this.cancelEdit();7936}7937}79387939rowEditableCheck(row){7940row.getCells().forEach((cell) => {7941if(cell.column.modules.edit && typeof cell.column.modules.edit.check === "function"){7942this.updateCellClass(cell);7943}7944});7945}79467947//initialize column editor7948initializeColumn(column){7949var config = {7950editor:false,7951blocked:false,7952check:column.definition.editable,7953params:column.definition.editorParams || {}7954};79557956//set column editor7957switch(typeof column.definition.editor){7958case "string":7959if(this.editors[column.definition.editor]){7960config.editor = this.editors[column.definition.editor];7961}else {7962console.warn("Editor Error - No such editor found: ", column.definition.editor);7963}7964break;79657966case "function":7967config.editor = column.definition.editor;7968break;79697970case "boolean":7971if(column.definition.editor === true){7972if(typeof column.definition.formatter !== "function"){7973if(this.editors[column.definition.formatter]){7974config.editor = this.editors[column.definition.formatter];7975}else {7976config.editor = this.editors["input"];7977}7978}else {7979console.warn("Editor Error - Cannot auto lookup editor for a custom formatter: ", column.definition.formatter);7980}7981}7982break;7983}79847985if(config.editor){7986column.modules.edit = config;7987}7988}79897990getCurrentCell(){7991return this.currentCell ? this.currentCell.getComponent() : false;7992}79937994clearEditor(cancel){7995var cell = this.currentCell,7996cellEl;79977998this.invalidEdit = false;79998000if(cell){8001this.currentCell = false;80028003cellEl = cell.getElement();80048005this.dispatch("edit-editor-clear", cell, cancel);80068007cellEl.classList.remove("tabulator-editing");80088009while(cellEl.firstChild) cellEl.removeChild(cellEl.firstChild);80108011cell.row.getElement().classList.remove("tabulator-editing");80128013cell.table.element.classList.remove("tabulator-editing");8014}8015}80168017cancelEdit(){8018if(this.currentCell){8019var cell = this.currentCell;8020var component = this.currentCell.getComponent();80218022this.clearEditor(true);8023cell.setValueActual(cell.getValue());8024cell.cellRendered();80258026if(cell.column.definition.editor == "textarea" || cell.column.definition.variableHeight){8027cell.row.normalizeHeight(true);8028}80298030if(cell.column.definition.cellEditCancelled){8031cell.column.definition.cellEditCancelled.call(this.table, component);8032}80338034this.dispatch("edit-cancelled", cell);8035this.dispatchExternal("cellEditCancelled", component);8036}8037}80388039//return a formatted value for a cell8040bindEditor(cell){8041if(cell.column.modules.edit){8042var self = this,8043element = cell.getElement(true);80448045this.updateCellClass(cell);8046element.setAttribute("tabindex", 0);80478048element.addEventListener("click", function(e){8049if(!element.classList.contains("tabulator-editing")){8050element.focus({preventScroll: true});8051}8052});80538054element.addEventListener("mousedown", function(e){8055if (e.button === 2) {8056e.preventDefault();8057}else {8058self.mouseClick = true;8059}8060});80618062element.addEventListener("focus", function(e){8063if(!self.recursionBlock){8064self.edit(cell, e, false);8065}8066});8067}8068}80698070focusCellNoEvent(cell, block){8071this.recursionBlock = true;80728073if(!(block && this.table.browser === "ie")){8074cell.getElement().focus({preventScroll: true});8075}80768077this.recursionBlock = false;8078}80798080editCell(cell, forceEdit){8081this.focusCellNoEvent(cell);8082this.edit(cell, false, forceEdit);8083}80848085focusScrollAdjust(cell){8086if(this.table.rowManager.getRenderMode() == "virtual"){8087var topEdge = this.table.rowManager.element.scrollTop,8088bottomEdge = this.table.rowManager.element.clientHeight + this.table.rowManager.element.scrollTop,8089rowEl = cell.row.getElement();80908091if(rowEl.offsetTop < topEdge){8092this.table.rowManager.element.scrollTop -= (topEdge - rowEl.offsetTop);8093}else {8094if(rowEl.offsetTop + rowEl.offsetHeight > bottomEdge){8095this.table.rowManager.element.scrollTop += (rowEl.offsetTop + rowEl.offsetHeight - bottomEdge);8096}8097}80988099var leftEdge = this.table.rowManager.element.scrollLeft,8100rightEdge = this.table.rowManager.element.clientWidth + this.table.rowManager.element.scrollLeft,8101cellEl = cell.getElement();81028103if(this.table.modExists("frozenColumns")){8104leftEdge += parseInt(this.table.modules.frozenColumns.leftMargin || 0);8105rightEdge -= parseInt(this.table.modules.frozenColumns.rightMargin || 0);8106}81078108if(this.table.options.renderHorizontal === "virtual"){8109leftEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft);8110rightEdge -= parseInt(this.table.columnManager.renderer.vDomPadLeft);8111}81128113if(cellEl.offsetLeft < leftEdge){8114this.table.rowManager.element.scrollLeft -= (leftEdge - cellEl.offsetLeft);8115}else {8116if(cellEl.offsetLeft + cellEl.offsetWidth > rightEdge){8117this.table.rowManager.element.scrollLeft += (cellEl.offsetLeft + cellEl.offsetWidth - rightEdge);8118}8119}8120}8121}81228123allowEdit(cell) {8124var check = cell.column.modules.edit ? true : false;81258126if(cell.column.modules.edit){8127switch(typeof cell.column.modules.edit.check){8128case "function":8129if(cell.row.initialized){8130check = cell.column.modules.edit.check(cell.getComponent());8131}8132break;81338134case "string":8135check = !!cell.row.data[cell.column.modules.edit.check];8136break;81378138case "boolean":8139check = cell.column.modules.edit.check;8140break;8141}8142}81438144return check;8145}81468147edit(cell, e, forceEdit){8148var self = this,8149allowEdit = true,8150rendered = function(){},8151element = cell.getElement(),8152cellEditor, component, params;81538154//prevent editing if another cell is refusing to leave focus (eg. validation fail)81558156if(this.currentCell){8157if(!this.invalidEdit && this.currentCell !== cell){8158this.cancelEdit();8159}8160return;8161}81628163//handle successful value change8164function success(value){8165if(self.currentCell === cell){8166var valid = self.chain("edit-success", [cell, value], true, true);81678168if(valid === true || self.table.options.validationMode === "highlight"){8169self.clearEditor();817081718172if(!cell.modules.edit){8173cell.modules.edit = {};8174}81758176cell.modules.edit.edited = true;81778178if(self.editedCells.indexOf(cell) == -1){8179self.editedCells.push(cell);8180}81818182cell.setValue(value, true);81838184return valid === true;8185}else {8186self.invalidEdit = true;8187self.focusCellNoEvent(cell, true);8188rendered();8189return false;8190}8191}8192}81938194//handle aborted edit8195function cancel(){8196if(self.currentCell === cell){8197self.cancelEdit();8198}8199}82008201function onRendered(callback){8202rendered = callback;8203}82048205if(!cell.column.modules.edit.blocked){8206if(e){8207e.stopPropagation();8208}82098210allowEdit = this.allowEdit(cell);82118212if(allowEdit || forceEdit){82138214self.cancelEdit();82158216self.currentCell = cell;82178218this.focusScrollAdjust(cell);82198220component = cell.getComponent();82218222if(this.mouseClick){8223this.mouseClick = false;82248225if(cell.column.definition.cellClick){8226cell.column.definition.cellClick.call(this.table, e, component);8227}8228}82298230if(cell.column.definition.cellEditing){8231cell.column.definition.cellEditing.call(this.table, component);8232}82338234this.dispatch("cell-editing", cell);8235this.dispatchExternal("cellEditing", component);82368237params = typeof cell.column.modules.edit.params === "function" ? cell.column.modules.edit.params(component) : cell.column.modules.edit.params;82388239cellEditor = cell.column.modules.edit.editor.call(self, component, onRendered, success, cancel, params);82408241//if editor returned, add to DOM, if false, abort edit8242if(this.currentCell && cellEditor !== false){8243if(cellEditor instanceof Node){8244element.classList.add("tabulator-editing");8245cell.row.getElement().classList.add("tabulator-editing");8246cell.table.element.classList.add("tabulator-editing");8247while(element.firstChild) element.removeChild(element.firstChild);8248element.appendChild(cellEditor);82498250//trigger onRendered Callback8251rendered();82528253//prevent editing from triggering rowClick event8254var children = element.children;82558256for (var i = 0; i < children.length; i++) {8257children[i].addEventListener("click", function(e){8258e.stopPropagation();8259});8260}8261}else {8262console.warn("Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor);8263element.blur();8264return false;8265}8266}else {8267element.blur();8268return false;8269}82708271return true;8272}else {8273this.mouseClick = false;8274element.blur();8275return false;8276}8277}else {8278this.mouseClick = false;8279element.blur();8280return false;8281}8282}82838284getEditedCells(){8285var output = [];82868287this.editedCells.forEach((cell) => {8288output.push(cell.getComponent());8289});82908291return output;8292}82938294clearEdited(cell){8295var editIndex;82968297if(cell.modules.edit && cell.modules.edit.edited){8298cell.modules.edit.edited = false;82998300this.dispatch("edit-edited-clear", cell);8301}83028303editIndex = this.editedCells.indexOf(cell);83048305if(editIndex > -1){8306this.editedCells.splice(editIndex, 1);8307}8308}8309}83108311Edit$1.moduleName = "edit";83128313//load defaults8314Edit$1.editors = defaultEditors;83158316class ExportRow{8317constructor(type, columns, component, indent){8318this.type = type;8319this.columns = columns;8320this.component = component || false;8321this.indent = indent || 0;8322}8323}83248325class ExportColumn{8326constructor(value, component, width, height, depth){8327this.value = value;8328this.component = component || false;8329this.width = width;8330this.height = height;8331this.depth = depth;8332}8333}83348335class Export extends Module{83368337constructor(table){8338super(table);83398340this.config = {};8341this.cloneTableStyle = true;8342this.colVisProp = "";83438344this.registerTableOption("htmlOutputConfig", false); //html output config83458346this.registerColumnOption("htmlOutput");8347this.registerColumnOption("titleHtmlOutput");8348}83498350initialize(){8351this.registerTableFunction("getHtml", this.getHtml.bind(this));8352}83538354///////////////////////////////////8355///////// Table Functions /////////8356///////////////////////////////////835783588359///////////////////////////////////8360///////// Internal Logic //////////8361///////////////////////////////////83628363generateExportList(config, style, range, colVisProp){8364this.cloneTableStyle = style;8365this.config = config || {};8366this.colVisProp = colVisProp;83678368var headers = this.config.columnHeaders !== false ? this.headersToExportRows(this.generateColumnGroupHeaders()) : [];8369var body = this.bodyToExportRows(this.rowLookup(range));83708371return headers.concat(body);8372}83738374generateTable(config, style, range, colVisProp){8375var list = this.generateExportList(config, style, range, colVisProp);83768377return this.generateTableElement(list);8378}83798380rowLookup(range){8381var rows = [];83828383if(typeof range == "function"){8384range.call(this.table).forEach((row) =>{8385row = this.table.rowManager.findRow(row);83868387if(row){8388rows.push(row);8389}8390});8391}else {8392switch(range){8393case true:8394case "visible":8395rows = this.table.rowManager.getVisibleRows(false, true);8396break;83978398case "all":8399rows = this.table.rowManager.rows;8400break;84018402case "selected":8403rows = this.table.modules.selectRow.selectedRows;8404break;84058406case "active":8407default:8408if(this.table.options.pagination){8409rows = this.table.rowManager.getDisplayRows(this.table.rowManager.displayRows.length - 2);8410}else {8411rows = this.table.rowManager.getDisplayRows();8412}8413}8414}84158416return Object.assign([], rows);8417}84188419generateColumnGroupHeaders(){8420var output = [];84218422var columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex;84238424columns.forEach((column) => {8425var colData = this.processColumnGroup(column);84268427if(colData){8428output.push(colData);8429}8430});84318432return output;8433}84348435processColumnGroup(column){8436var subGroups = column.columns,8437maxDepth = 0,8438title = column.definition["title" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))] || column.definition.title;84398440var groupData = {8441title:title,8442column:column,8443depth:1,8444};84458446if(subGroups.length){8447groupData.subGroups = [];8448groupData.width = 0;84498450subGroups.forEach((subGroup) => {8451var subGroupData = this.processColumnGroup(subGroup);84528453if(subGroupData){8454groupData.width += subGroupData.width;8455groupData.subGroups.push(subGroupData);84568457if(subGroupData.depth > maxDepth){8458maxDepth = subGroupData.depth;8459}8460}8461});84628463groupData.depth += maxDepth;84648465if(!groupData.width){8466return false;8467}8468}else {8469if(this.columnVisCheck(column)){8470groupData.width = 1;8471}else {8472return false;8473}8474}84758476return groupData;8477}84788479columnVisCheck(column){8480var visProp = column.definition[this.colVisProp];84818482if(typeof visProp === "function"){8483visProp = visProp.call(this.table, column.getComponent());8484}84858486return visProp !== false && (column.visible || (!column.visible && visProp));8487}84888489headersToExportRows(columns){8490var headers = [],8491headerDepth = 0,8492exportRows = [];84938494function parseColumnGroup(column, level){84958496var depth = headerDepth - level;84978498if(typeof headers[level] === "undefined"){8499headers[level] = [];8500}85018502column.height = column.subGroups ? 1 : (depth - column.depth) + 1;85038504headers[level].push(column);85058506if(column.height > 1){8507for(let i = 1; i < column.height; i ++){85088509if(typeof headers[level + i] === "undefined"){8510headers[level + i] = [];8511}85128513headers[level + i].push(false);8514}8515}85168517if(column.width > 1){8518for(let i = 1; i < column.width; i ++){8519headers[level].push(false);8520}8521}85228523if(column.subGroups){8524column.subGroups.forEach(function(subGroup){8525parseColumnGroup(subGroup, level+1);8526});8527}8528}85298530//calculate maximum header depth8531columns.forEach(function(column){8532if(column.depth > headerDepth){8533headerDepth = column.depth;8534}8535});85368537columns.forEach(function(column){8538parseColumnGroup(column,0);8539});85408541headers.forEach((header) => {8542var columns = [];85438544header.forEach((col) => {8545if(col){8546let title = typeof col.title === "undefined" ? "" : col.title;8547columns.push(new ExportColumn(title, col.column.getComponent(), col.width, col.height, col.depth));8548}else {8549columns.push(null);8550}8551});85528553exportRows.push(new ExportRow("header", columns));8554});85558556return exportRows;8557}85588559bodyToExportRows(rows){85608561var columns = [];8562var exportRows = [];85638564this.table.columnManager.columnsByIndex.forEach((column) => {8565if (this.columnVisCheck(column)) {8566columns.push(column.getComponent());8567}8568});85698570if(this.config.columnCalcs !== false && this.table.modExists("columnCalcs")){8571if(this.table.modules.columnCalcs.topInitialized){8572rows.unshift(this.table.modules.columnCalcs.topRow);8573}85748575if(this.table.modules.columnCalcs.botInitialized){8576rows.push(this.table.modules.columnCalcs.botRow);8577}8578}85798580rows = rows.filter((row) => {8581switch(row.type){8582case "group":8583return this.config.rowGroups !== false;85848585case "calc":8586return this.config.columnCalcs !== false;85878588case "row":8589return !(this.table.options.dataTree && this.config.dataTree === false && row.modules.dataTree.parent);8590}85918592return true;8593});85948595rows.forEach((row, i) => {8596var rowData = row.getData(this.colVisProp);8597var exportCols = [];8598var indent = 0;85998600switch(row.type){8601case "group":8602indent = row.level;8603exportCols.push(new ExportColumn(row.key, row.getComponent(), columns.length, 1));8604break;86058606case "calc" :8607case "row" :8608columns.forEach((col) => {8609exportCols.push(new ExportColumn(col._column.getFieldValue(rowData), col, 1, 1));8610});86118612if(this.table.options.dataTree && this.config.dataTree !== false){8613indent = row.modules.dataTree.index;8614}8615break;8616}86178618exportRows.push(new ExportRow(row.type, exportCols, row.getComponent(), indent));8619});86208621return exportRows;8622}86238624generateTableElement(list){8625var table = document.createElement("table"),8626headerEl = document.createElement("thead"),8627bodyEl = document.createElement("tbody"),8628styles = this.lookupTableStyles(),8629rowFormatter = this.table.options["rowFormatter" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))],8630setup = {};86318632setup.rowFormatter = rowFormatter !== null ? rowFormatter : this.table.options.rowFormatter;86338634if(this.table.options.dataTree &&this.config.dataTree !== false && this.table.modExists("columnCalcs")){8635setup.treeElementField = this.table.modules.dataTree.elementField;8636}86378638//assign group header formatter8639setup.groupHeader = this.table.options["groupHeader" + (this.colVisProp.charAt(0).toUpperCase() + this.colVisProp.slice(1))];86408641if(setup.groupHeader && !Array.isArray(setup.groupHeader)){8642setup.groupHeader = [setup.groupHeader];8643}86448645table.classList.add("tabulator-print-table");86468647this.mapElementStyles(this.table.columnManager.getHeadersElement(), headerEl, ["border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);864886498650if(list.length > 1000){8651console.warn("It may take a long time to render an HTML table with more than 1000 rows");8652}86538654list.forEach((row, i) => {8655let rowEl;86568657switch(row.type){8658case "header":8659headerEl.appendChild(this.generateHeaderElement(row, setup, styles));8660break;86618662case "group":8663bodyEl.appendChild(this.generateGroupElement(row, setup, styles));8664break;86658666case "calc":8667bodyEl.appendChild(this.generateCalcElement(row, setup, styles));8668break;86698670case "row":8671rowEl = this.generateRowElement(row, setup, styles);86728673this.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"]);8674bodyEl.appendChild(rowEl);8675break;8676}8677});86788679if(headerEl.innerHTML){8680table.appendChild(headerEl);8681}86828683table.appendChild(bodyEl);868486858686this.mapElementStyles(this.table.element, table, ["border-top", "border-left", "border-right", "border-bottom"]);8687return table;8688}86898690lookupTableStyles(){8691var styles = {};86928693//lookup row styles8694if(this.cloneTableStyle && window.getComputedStyle){8695styles.oddRow = this.table.element.querySelector(".tabulator-row-odd:not(.tabulator-group):not(.tabulator-calcs)");8696styles.evenRow = this.table.element.querySelector(".tabulator-row-even:not(.tabulator-group):not(.tabulator-calcs)");8697styles.calcRow = this.table.element.querySelector(".tabulator-row.tabulator-calcs");8698styles.firstRow = this.table.element.querySelector(".tabulator-row:not(.tabulator-group):not(.tabulator-calcs)");8699styles.firstGroup = this.table.element.getElementsByClassName("tabulator-group")[0];87008701if(styles.firstRow){8702styles.styleCells = styles.firstRow.getElementsByClassName("tabulator-cell");8703styles.firstCell = styles.styleCells[0];8704styles.lastCell = styles.styleCells[styles.styleCells.length - 1];8705}8706}87078708return styles;8709}87108711generateHeaderElement(row, setup, styles){8712var rowEl = document.createElement("tr");87138714row.columns.forEach((column) => {8715if(column){8716var cellEl = document.createElement("th");8717var classNames = column.component._column.definition.cssClass ? column.component._column.definition.cssClass.split(" ") : [];87188719cellEl.colSpan = column.width;8720cellEl.rowSpan = column.height;87218722cellEl.innerHTML = column.value;87238724if(this.cloneTableStyle){8725cellEl.style.boxSizing = "border-box";8726}87278728classNames.forEach(function(className) {8729cellEl.classList.add(className);8730});87318732this.mapElementStyles(column.component.getElement(), cellEl, ["text-align", "border-top", "border-left", "border-right", "border-bottom", "background-color", "color", "font-weight", "font-family", "font-size"]);8733this.mapElementStyles(column.component._column.contentElement, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);87348735if(column.component._column.visible){8736this.mapElementStyles(column.component.getElement(), cellEl, ["width"]);8737}else {8738if(column.component._column.definition.width){8739cellEl.style.width = column.component._column.definition.width + "px";8740}8741}87428743if(column.component._column.parent){8744this.mapElementStyles(column.component._column.parent.groupElement, cellEl, ["border-top"]);8745}87468747rowEl.appendChild(cellEl);8748}8749});87508751return rowEl;8752}87538754generateGroupElement(row, setup, styles){87558756var rowEl = document.createElement("tr"),8757cellEl = document.createElement("td"),8758group = row.columns[0];87598760rowEl.classList.add("tabulator-print-table-row");87618762if(setup.groupHeader && setup.groupHeader[row.indent]){8763group.value = setup.groupHeader[row.indent](group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);8764}else {8765if(setup.groupHeader !== false){8766group.value = row.component._group.generator(group.value, row.component._group.getRowCount(), row.component._group.getData(), row.component);8767}8768}87698770cellEl.colSpan = group.width;8771cellEl.innerHTML = group.value;87728773rowEl.classList.add("tabulator-print-table-group");8774rowEl.classList.add("tabulator-group-level-" + row.indent);87758776if(group.component.isVisible()){8777rowEl.classList.add("tabulator-group-visible");8778}87798780this.mapElementStyles(styles.firstGroup, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);8781this.mapElementStyles(styles.firstGroup, cellEl, ["padding-top", "padding-left", "padding-right", "padding-bottom"]);87828783rowEl.appendChild(cellEl);87848785return rowEl;8786}87878788generateCalcElement(row, setup, styles){8789var rowEl = this.generateRowElement(row, setup, styles);87908791rowEl.classList.add("tabulator-print-table-calcs");8792this.mapElementStyles(styles.calcRow, rowEl, ["border-top", "border-left", "border-right", "border-bottom", "color", "font-weight", "font-family", "font-size", "background-color"]);87938794return rowEl;8795}87968797generateRowElement(row, setup, styles){8798var rowEl = document.createElement("tr");87998800rowEl.classList.add("tabulator-print-table-row");88018802row.columns.forEach((col, i) => {8803if(col){8804var cellEl = document.createElement("td"),8805column = col.component._column,8806index = this.table.columnManager.findColumnIndex(column),8807value = col.value,8808cellStyle;88098810var cellWrapper = {8811modules:{},8812getValue:function(){8813return value;8814},8815getField:function(){8816return column.definition.field;8817},8818getElement:function(){8819return cellEl;8820},8821getType:function(){8822return "cell";8823},8824getColumn:function(){8825return column.getComponent();8826},8827getData:function(){8828return row.component.getData();8829},8830getRow:function(){8831return row.component;8832},8833getComponent:function(){8834return cellWrapper;8835},8836column:column,8837};88388839var classNames = column.definition.cssClass ? column.definition.cssClass.split(" ") : [];88408841classNames.forEach(function(className) {8842cellEl.classList.add(className);8843});88448845if(this.table.modExists("format") && this.config.formatCells !== false){8846value = this.table.modules.format.formatExportValue(cellWrapper, this.colVisProp);8847}else {8848switch(typeof value){8849case "object":8850value = value !== null ? JSON.stringify(value) : "";8851break;88528853case "undefined":8854value = "";8855break;8856}8857}88588859if(value instanceof Node){8860cellEl.appendChild(value);8861}else {8862cellEl.innerHTML = value;8863}88648865cellStyle = styles.styleCells && styles.styleCells[index] ? styles.styleCells[index] : styles.firstCell;88668867if(cellStyle){8868this.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"]);88698870if(column.definition.align){8871cellEl.style.textAlign = column.definition.align;8872}8873}88748875if(this.table.options.dataTree && this.config.dataTree !== false){8876if((setup.treeElementField && setup.treeElementField == column.field) || (!setup.treeElementField && i == 0)){8877if(row.component._row.modules.dataTree.controlEl){8878cellEl.insertBefore(row.component._row.modules.dataTree.controlEl.cloneNode(true), cellEl.firstChild);8879}8880if(row.component._row.modules.dataTree.branchEl){8881cellEl.insertBefore(row.component._row.modules.dataTree.branchEl.cloneNode(true), cellEl.firstChild);8882}8883}8884}88858886rowEl.appendChild(cellEl);88878888if(cellWrapper.modules.format && cellWrapper.modules.format.renderedCallback){8889cellWrapper.modules.format.renderedCallback();8890}8891}8892});88938894if(setup.rowFormatter && row.type === "row" && this.config.formatCells !== false){8895let formatComponent = Object.assign(row.component);88968897formatComponent.getElement = function(){return rowEl;};88988899setup.rowFormatter(row.component);8900}89018902return rowEl;8903}89048905generateHTMLTable(list){8906var holder = document.createElement("div");89078908holder.appendChild(this.generateTableElement(list));89098910return holder.innerHTML;8911}89128913getHtml(visible, style, config, colVisProp){8914var list = this.generateExportList(config || this.table.options.htmlOutputConfig, style, visible, colVisProp || "htmlOutput");89158916return this.generateHTMLTable(list);8917}89188919mapElementStyles(from, to, props){8920if(this.cloneTableStyle && from && to){89218922var lookup = {8923"background-color" : "backgroundColor",8924"color" : "fontColor",8925"width" : "width",8926"font-weight" : "fontWeight",8927"font-family" : "fontFamily",8928"font-size" : "fontSize",8929"text-align" : "textAlign",8930"border-top" : "borderTop",8931"border-left" : "borderLeft",8932"border-right" : "borderRight",8933"border-bottom" : "borderBottom",8934"padding-top" : "paddingTop",8935"padding-left" : "paddingLeft",8936"padding-right" : "paddingRight",8937"padding-bottom" : "paddingBottom",8938};89398940if(window.getComputedStyle){8941var fromStyle = window.getComputedStyle(from);89428943props.forEach(function(prop){8944if(!to.style[lookup[prop]]){8945to.style[lookup[prop]] = fromStyle.getPropertyValue(prop);8946}8947});8948}8949}8950}8951}89528953Export.moduleName = "export";89548955var defaultFilters = {89568957//equal to8958"=":function(filterVal, rowVal, rowData, filterParams){8959return rowVal == filterVal ? true : false;8960},89618962//less than8963"<":function(filterVal, rowVal, rowData, filterParams){8964return rowVal < filterVal ? true : false;8965},89668967//less than or equal to8968"<=":function(filterVal, rowVal, rowData, filterParams){8969return rowVal <= filterVal ? true : false;8970},89718972//greater than8973">":function(filterVal, rowVal, rowData, filterParams){8974return rowVal > filterVal ? true : false;8975},89768977//greater than or equal to8978">=":function(filterVal, rowVal, rowData, filterParams){8979return rowVal >= filterVal ? true : false;8980},89818982//not equal to8983"!=":function(filterVal, rowVal, rowData, filterParams){8984return rowVal != filterVal ? true : false;8985},89868987"regex":function(filterVal, rowVal, rowData, filterParams){89888989if(typeof filterVal == "string"){8990filterVal = new RegExp(filterVal);8991}89928993return filterVal.test(rowVal);8994},89958996//contains the string8997"like":function(filterVal, rowVal, rowData, filterParams){8998if(filterVal === null || typeof filterVal === "undefined"){8999return rowVal === filterVal ? true : false;9000}else {9001if(typeof rowVal !== 'undefined' && rowVal !== null){9002return String(rowVal).toLowerCase().indexOf(filterVal.toLowerCase()) > -1;9003}9004else {9005return false;9006}9007}9008},90099010//contains the keywords9011"keywords":function(filterVal, rowVal, rowData, filterParams){9012var keywords = filterVal.toLowerCase().split(typeof filterParams.separator === "undefined" ? " " : filterParams.separator),9013value = String(rowVal === null || typeof rowVal === "undefined" ? "" : rowVal).toLowerCase(),9014matches = [];90159016keywords.forEach((keyword) =>{9017if(value.includes(keyword)){9018matches.push(true);9019}9020});90219022return filterParams.matchAll ? matches.length === keywords.length : !!matches.length;9023},90249025//starts with the string9026"starts":function(filterVal, rowVal, rowData, filterParams){9027if(filterVal === null || typeof filterVal === "undefined"){9028return rowVal === filterVal ? true : false;9029}else {9030if(typeof rowVal !== 'undefined' && rowVal !== null){9031return String(rowVal).toLowerCase().startsWith(filterVal.toLowerCase());9032}9033else {9034return false;9035}9036}9037},90389039//ends with the string9040"ends":function(filterVal, rowVal, rowData, filterParams){9041if(filterVal === null || typeof filterVal === "undefined"){9042return rowVal === filterVal ? true : false;9043}else {9044if(typeof rowVal !== 'undefined' && rowVal !== null){9045return String(rowVal).toLowerCase().endsWith(filterVal.toLowerCase());9046}9047else {9048return false;9049}9050}9051},90529053//in array9054"in":function(filterVal, rowVal, rowData, filterParams){9055if(Array.isArray(filterVal)){9056return filterVal.length ? filterVal.indexOf(rowVal) > -1 : true;9057}else {9058console.warn("Filter Error - filter value is not an array:", filterVal);9059return false;9060}9061},9062};90639064class Filter extends Module{90659066constructor(table){9067super(table);90689069this.filterList = []; //hold filter list9070this.headerFilters = {}; //hold column filters9071this.headerFilterColumns = []; //hold columns that use header filters90729073this.prevHeaderFilterChangeCheck = "";9074this.prevHeaderFilterChangeCheck = "{}";90759076this.changed = false; //has filtering changed since last render9077this.tableInitialized = false;90789079this.registerTableOption("filterMode", "local"); //local or remote filtering90809081this.registerTableOption("initialFilter", false); //initial filtering criteria9082this.registerTableOption("initialHeaderFilter", false); //initial header filtering criteria9083this.registerTableOption("headerFilterLiveFilterDelay", 300); //delay before updating column after user types in header filter9084this.registerTableOption("placeholderHeaderFilter", false); //placeholder when header filter is empty90859086this.registerColumnOption("headerFilter");9087this.registerColumnOption("headerFilterPlaceholder");9088this.registerColumnOption("headerFilterParams");9089this.registerColumnOption("headerFilterEmptyCheck");9090this.registerColumnOption("headerFilterFunc");9091this.registerColumnOption("headerFilterFuncParams");9092this.registerColumnOption("headerFilterLiveFilter");90939094this.registerTableFunction("searchRows", this.searchRows.bind(this));9095this.registerTableFunction("searchData", this.searchData.bind(this));90969097this.registerTableFunction("setFilter", this.userSetFilter.bind(this));9098this.registerTableFunction("refreshFilter", this.userRefreshFilter.bind(this));9099this.registerTableFunction("addFilter", this.userAddFilter.bind(this));9100this.registerTableFunction("getFilters", this.getFilters.bind(this));9101this.registerTableFunction("setHeaderFilterFocus", this.userSetHeaderFilterFocus.bind(this));9102this.registerTableFunction("getHeaderFilterValue", this.userGetHeaderFilterValue.bind(this));9103this.registerTableFunction("setHeaderFilterValue", this.userSetHeaderFilterValue.bind(this));9104this.registerTableFunction("getHeaderFilters", this.getHeaderFilters.bind(this));9105this.registerTableFunction("removeFilter", this.userRemoveFilter.bind(this));9106this.registerTableFunction("clearFilter", this.userClearFilter.bind(this));9107this.registerTableFunction("clearHeaderFilter", this.userClearHeaderFilter.bind(this));91089109this.registerComponentFunction("column", "headerFilterFocus", this.setHeaderFilterFocus.bind(this));9110this.registerComponentFunction("column", "reloadHeaderFilter", this.reloadHeaderFilter.bind(this));9111this.registerComponentFunction("column", "getHeaderFilterValue", this.getHeaderFilterValue.bind(this));9112this.registerComponentFunction("column", "setHeaderFilterValue", this.setHeaderFilterValue.bind(this));9113}91149115initialize(){9116this.subscribe("column-init", this.initializeColumnHeaderFilter.bind(this));9117this.subscribe("column-width-fit-before", this.hideHeaderFilterElements.bind(this));9118this.subscribe("column-width-fit-after", this.showHeaderFilterElements.bind(this));9119this.subscribe("table-built", this.tableBuilt.bind(this));9120this.subscribe("placeholder", this.generatePlaceholder.bind(this));91219122if(this.table.options.filterMode === "remote"){9123this.subscribe("data-params", this.remoteFilterParams.bind(this));9124}91259126this.registerDataHandler(this.filter.bind(this), 10);9127}91289129tableBuilt(){9130if(this.table.options.initialFilter){9131this.setFilter(this.table.options.initialFilter);9132}91339134if(this.table.options.initialHeaderFilter){9135this.table.options.initialHeaderFilter.forEach((item) => {91369137var column = this.table.columnManager.findColumn(item.field);91389139if(column){9140this.setHeaderFilterValue(column, item.value);9141}else {9142console.warn("Column Filter Error - No matching column found:", item.field);9143return false;9144}9145});9146}91479148this.tableInitialized = true;9149}91509151remoteFilterParams(data, config, silent, params){9152params.filter = this.getFilters(true, true);9153return params;9154}91559156generatePlaceholder(text){9157if(this.table.options.placeholderHeaderFilter && Object.keys(this.headerFilters).length){9158return this.table.options.placeholderHeaderFilter;9159}9160}91619162///////////////////////////////////9163///////// Table Functions /////////9164///////////////////////////////////91659166//set standard filters9167userSetFilter(field, type, value, params){9168this.setFilter(field, type, value, params);9169this.refreshFilter();9170}91719172//set standard filters9173userRefreshFilter(){9174this.refreshFilter();9175}91769177//add filter to array9178userAddFilter(field, type, value, params){9179this.addFilter(field, type, value, params);9180this.refreshFilter();9181}91829183userSetHeaderFilterFocus(field){9184var column = this.table.columnManager.findColumn(field);91859186if(column){9187this.setHeaderFilterFocus(column);9188}else {9189console.warn("Column Filter Focus Error - No matching column found:", field);9190return false;9191}9192}91939194userGetHeaderFilterValue(field) {9195var column = this.table.columnManager.findColumn(field);91969197if(column){9198return this.getHeaderFilterValue(column);9199}else {9200console.warn("Column Filter Error - No matching column found:", field);9201}9202}92039204userSetHeaderFilterValue(field, value){9205var column = this.table.columnManager.findColumn(field);92069207if(column){9208this.setHeaderFilterValue(column, value);9209}else {9210console.warn("Column Filter Error - No matching column found:", field);9211return false;9212}9213}92149215//remove filter from array9216userRemoveFilter(field, type, value){9217this.removeFilter(field, type, value);9218this.refreshFilter();9219}92209221//clear filters9222userClearFilter(all){9223this.clearFilter(all);9224this.refreshFilter();9225}92269227//clear header filters9228userClearHeaderFilter(){9229this.clearHeaderFilter();9230this.refreshFilter();9231}923292339234//search for specific row components9235searchRows(field, type, value){9236return this.search("rows", field, type, value);9237}92389239//search for specific data9240searchData(field, type, value){9241return this.search("data", field, type, value);9242}92439244///////////////////////////////////9245///////// Internal Logic //////////9246///////////////////////////////////92479248initializeColumnHeaderFilter(column){9249var def = column.definition;92509251if(def.headerFilter){9252this.initializeColumn(column);9253}9254}92559256//initialize column header filter9257initializeColumn(column, value){9258var self = this,9259field = column.getField();92609261//handle successfully value change9262function success(value){9263var filterType = (column.modules.filter.tagType == "input" && column.modules.filter.attrType == "text") || column.modules.filter.tagType == "textarea" ? "partial" : "match",9264type = "",9265filterChangeCheck = "",9266filterFunc;92679268if(typeof column.modules.filter.prevSuccess === "undefined" || column.modules.filter.prevSuccess !== value){92699270column.modules.filter.prevSuccess = value;92719272if(!column.modules.filter.emptyFunc(value)){9273column.modules.filter.value = value;92749275switch(typeof column.definition.headerFilterFunc){9276case "string":9277if(Filter.filters[column.definition.headerFilterFunc]){9278type = column.definition.headerFilterFunc;9279filterFunc = function(data){9280var params = column.definition.headerFilterFuncParams || {};9281var fieldVal = column.getFieldValue(data);92829283params = typeof params === "function" ? params(value, fieldVal, data) : params;92849285return Filter.filters[column.definition.headerFilterFunc](value, fieldVal, data, params);9286};9287}else {9288console.warn("Header Filter Error - Matching filter function not found: ", column.definition.headerFilterFunc);9289}9290break;92919292case "function":9293filterFunc = function(data){9294var params = column.definition.headerFilterFuncParams || {};9295var fieldVal = column.getFieldValue(data);92969297params = typeof params === "function" ? params(value, fieldVal, data) : params;92989299return column.definition.headerFilterFunc(value, fieldVal, data, params);9300};93019302type = filterFunc;9303break;9304}93059306if(!filterFunc){9307switch(filterType){9308case "partial":9309filterFunc = function(data){9310var colVal = column.getFieldValue(data);93119312if(typeof colVal !== 'undefined' && colVal !== null){9313return String(colVal).toLowerCase().indexOf(String(value).toLowerCase()) > -1;9314}else {9315return false;9316}9317};9318type = "like";9319break;93209321default:9322filterFunc = function(data){9323return column.getFieldValue(data) == value;9324};9325type = "=";9326}9327}93289329self.headerFilters[field] = {value:value, func:filterFunc, type:type};9330}else {9331delete self.headerFilters[field];9332}93339334column.modules.filter.value = value;93359336filterChangeCheck = JSON.stringify(self.headerFilters);93379338if(self.prevHeaderFilterChangeCheck !== filterChangeCheck){9339self.prevHeaderFilterChangeCheck = filterChangeCheck;93409341self.trackChanges();9342self.refreshFilter();9343}9344}93459346return true;9347}93489349column.modules.filter = {9350success:success,9351attrType:false,9352tagType:false,9353emptyFunc:false,9354};93559356this.generateHeaderFilterElement(column);9357}93589359generateHeaderFilterElement(column, initialValue, reinitialize){9360var self = this,9361success = column.modules.filter.success,9362field = column.getField(),9363filterElement, editor, editorElement, cellWrapper, typingTimer, searchTrigger, params, onRenderedCallback;93649365column.modules.filter.value = initialValue;93669367//handle aborted edit9368function cancel(){}93699370function onRendered(callback){9371onRenderedCallback = callback;9372}93739374if(column.modules.filter.headerElement && column.modules.filter.headerElement.parentNode){9375column.contentElement.removeChild(column.modules.filter.headerElement.parentNode);9376}93779378if(field){93799380//set empty value function9381column.modules.filter.emptyFunc = column.definition.headerFilterEmptyCheck || function(value){9382return !value && value !== 0;9383};93849385filterElement = document.createElement("div");9386filterElement.classList.add("tabulator-header-filter");93879388//set column editor9389switch(typeof column.definition.headerFilter){9390case "string":9391if(self.table.modules.edit.editors[column.definition.headerFilter]){9392editor = self.table.modules.edit.editors[column.definition.headerFilter];93939394if((column.definition.headerFilter === "tick" || column.definition.headerFilter === "tickCross") && !column.definition.headerFilterEmptyCheck){9395column.modules.filter.emptyFunc = function(value){9396return value !== true && value !== false;9397};9398}9399}else {9400console.warn("Filter Error - Cannot build header filter, No such editor found: ", column.definition.editor);9401}9402break;94039404case "function":9405editor = column.definition.headerFilter;9406break;94079408case "boolean":9409if(column.modules.edit && column.modules.edit.editor){9410editor = column.modules.edit.editor;9411}else {9412if(column.definition.formatter && self.table.modules.edit.editors[column.definition.formatter]){9413editor = self.table.modules.edit.editors[column.definition.formatter];94149415if((column.definition.formatter === "tick" || column.definition.formatter === "tickCross") && !column.definition.headerFilterEmptyCheck){9416column.modules.filter.emptyFunc = function(value){9417return value !== true && value !== false;9418};9419}9420}else {9421editor = self.table.modules.edit.editors["input"];9422}9423}9424break;9425}94269427if(editor){94289429cellWrapper = {9430getValue:function(){9431return typeof initialValue !== "undefined" ? initialValue : "";9432},9433getField:function(){9434return column.definition.field;9435},9436getElement:function(){9437return filterElement;9438},9439getColumn:function(){9440return column.getComponent();9441},9442getTable:() => {9443return this.table;9444},9445getType:() => {9446return "header";9447},9448getRow:function(){9449return {9450normalizeHeight:function(){94519452}9453};9454}9455};94569457params = column.definition.headerFilterParams || {};94589459params = typeof params === "function" ? params.call(self.table, cellWrapper) : params;94609461editorElement = editor.call(this.table.modules.edit, cellWrapper, onRendered, success, cancel, params);94629463if(!editorElement){9464console.warn("Filter Error - Cannot add filter to " + field + " column, editor returned a value of false");9465return;9466}94679468if(!(editorElement instanceof Node)){9469console.warn("Filter Error - Cannot add filter to " + field + " column, editor should return an instance of Node, the editor returned:", editorElement);9470return;9471}94729473//set Placeholder Text9474self.langBind("headerFilters|columns|" + column.definition.field, function(value){9475editorElement.setAttribute("placeholder", typeof value !== "undefined" && value ? value : (column.definition.headerFilterPlaceholder || self.langText("headerFilters|default")));9476});94779478//focus on element on click9479editorElement.addEventListener("click", function(e){9480e.stopPropagation();9481editorElement.focus();9482});94839484editorElement.addEventListener("focus", (e) => {9485var left = this.table.columnManager.contentsElement.scrollLeft;94869487var headerPos = this.table.rowManager.element.scrollLeft;94889489if(left !== headerPos){9490this.table.rowManager.scrollHorizontal(left);9491this.table.columnManager.scrollHorizontal(left);9492}9493});94949495//live update filters as user types9496typingTimer = false;94979498searchTrigger = function(e){9499if(typingTimer){9500clearTimeout(typingTimer);9501}95029503typingTimer = setTimeout(function(){9504success(editorElement.value);9505},self.table.options.headerFilterLiveFilterDelay);9506};95079508column.modules.filter.headerElement = editorElement;9509column.modules.filter.attrType = editorElement.hasAttribute("type") ? editorElement.getAttribute("type").toLowerCase() : "" ;9510column.modules.filter.tagType = editorElement.tagName.toLowerCase();95119512if(column.definition.headerFilterLiveFilter !== false){95139514if (9515!(9516column.definition.headerFilter === 'autocomplete' ||9517column.definition.headerFilter === 'tickCross' ||9518((column.definition.editor === 'autocomplete' ||9519column.definition.editor === 'tickCross') &&9520column.definition.headerFilter === true)9521)9522) {9523editorElement.addEventListener("keyup", searchTrigger);9524editorElement.addEventListener("search", searchTrigger);952595269527//update number filtered columns on change9528if(column.modules.filter.attrType == "number"){9529editorElement.addEventListener("change", function(e){9530success(editorElement.value);9531});9532}95339534//change text inputs to search inputs to allow for clearing of field9535if(column.modules.filter.attrType == "text" && this.table.browser !== "ie"){9536editorElement.setAttribute("type", "search");9537// editorElement.off("change blur"); //prevent blur from triggering filter and preventing selection click9538}95399540}95419542//prevent input and select elements from propagating click to column sorters etc9543if(column.modules.filter.tagType == "input" || column.modules.filter.tagType == "select" || column.modules.filter.tagType == "textarea"){9544editorElement.addEventListener("mousedown",function(e){9545e.stopPropagation();9546});9547}9548}95499550filterElement.appendChild(editorElement);95519552column.contentElement.appendChild(filterElement);95539554if(!reinitialize){9555self.headerFilterColumns.push(column);9556}95579558if(onRenderedCallback){9559onRenderedCallback();9560}9561}9562}else {9563console.warn("Filter Error - Cannot add header filter, column has no field set:", column.definition.title);9564}9565}95669567//hide all header filter elements (used to ensure correct column widths in "fitData" layout mode)9568hideHeaderFilterElements(){9569this.headerFilterColumns.forEach(function(column){9570if(column.modules.filter && column.modules.filter.headerElement){9571column.modules.filter.headerElement.style.display = 'none';9572}9573});9574}95759576//show all header filter elements (used to ensure correct column widths in "fitData" layout mode)9577showHeaderFilterElements(){9578this.headerFilterColumns.forEach(function(column){9579if(column.modules.filter && column.modules.filter.headerElement){9580column.modules.filter.headerElement.style.display = '';9581}9582});9583}95849585//programmatically set focus of header filter9586setHeaderFilterFocus(column){9587if(column.modules.filter && column.modules.filter.headerElement){9588column.modules.filter.headerElement.focus();9589}else {9590console.warn("Column Filter Focus Error - No header filter set on column:", column.getField());9591}9592}95939594//programmatically get value of header filter9595getHeaderFilterValue(column){9596if(column.modules.filter && column.modules.filter.headerElement){9597return column.modules.filter.value;9598} else {9599console.warn("Column Filter Error - No header filter set on column:", column.getField());9600}9601}96029603//programmatically set value of header filter9604setHeaderFilterValue(column, value){9605if (column){9606if(column.modules.filter && column.modules.filter.headerElement){9607this.generateHeaderFilterElement(column, value, true);9608column.modules.filter.success(value);9609}else {9610console.warn("Column Filter Error - No header filter set on column:", column.getField());9611}9612}9613}96149615reloadHeaderFilter(column){9616if (column){9617if(column.modules.filter && column.modules.filter.headerElement){9618this.generateHeaderFilterElement(column, column.modules.filter.value, true);9619}else {9620console.warn("Column Filter Error - No header filter set on column:", column.getField());9621}9622}9623}96249625refreshFilter(){9626if(this.tableInitialized){9627if(this.table.options.filterMode === "remote"){9628this.reloadData(null, false, false);9629}else {9630this.refreshData(true);9631}9632}96339634//TODO - Persist left position of row manager9635// left = this.scrollLeft;9636// this.scrollHorizontal(left);9637}96389639//check if the filters has changed since last use9640trackChanges(){9641this.changed = true;9642this.dispatch("filter-changed");9643}96449645//check if the filters has changed since last use9646hasChanged(){9647var changed = this.changed;9648this.changed = false;9649return changed;9650}96519652//set standard filters9653setFilter(field, type, value, params){9654this.filterList = [];96559656if(!Array.isArray(field)){9657field = [{field:field, type:type, value:value, params:params}];9658}96599660this.addFilter(field);9661}96629663//add filter to array9664addFilter(field, type, value, params){9665var changed = false;96669667if(!Array.isArray(field)){9668field = [{field:field, type:type, value:value, params:params}];9669}96709671field.forEach((filter) => {9672filter = this.findFilter(filter);96739674if(filter){9675this.filterList.push(filter);9676changed = true;9677}9678});96799680if(changed){9681this.trackChanges();9682}9683}96849685findFilter(filter){9686var column;96879688if(Array.isArray(filter)){9689return this.findSubFilters(filter);9690}96919692var filterFunc = false;96939694if(typeof filter.field == "function"){9695filterFunc = function(data){9696return filter.field(data, filter.type || {});// pass params to custom filter function9697};9698}else {96999700if(Filter.filters[filter.type]){97019702column = this.table.columnManager.getColumnByField(filter.field);97039704if(column){9705filterFunc = function(data){9706return Filter.filters[filter.type](filter.value, column.getFieldValue(data), data, filter.params || {});9707};9708}else {9709filterFunc = function(data){9710return Filter.filters[filter.type](filter.value, data[filter.field], data, filter.params || {});9711};9712}971397149715}else {9716console.warn("Filter Error - No such filter type found, ignoring: ", filter.type);9717}9718}97199720filter.func = filterFunc;97219722return filter.func ? filter : false;9723}97249725findSubFilters(filters){9726var output = [];97279728filters.forEach((filter) => {9729filter = this.findFilter(filter);97309731if(filter){9732output.push(filter);9733}9734});97359736return output.length ? output : false;9737}97389739//get all filters9740getFilters(all, ajax){9741var output = [];97429743if(all){9744output = this.getHeaderFilters();9745}97469747if(ajax){9748output.forEach(function(item){9749if(typeof item.type == "function"){9750item.type = "function";9751}9752});9753}97549755output = output.concat(this.filtersToArray(this.filterList, ajax));97569757return output;9758}97599760//filter to Object9761filtersToArray(filterList, ajax){9762var output = [];97639764filterList.forEach((filter) => {9765var item;97669767if(Array.isArray(filter)){9768output.push(this.filtersToArray(filter, ajax));9769}else {9770item = {field:filter.field, type:filter.type, value:filter.value};97719772if(ajax){9773if(typeof item.type == "function"){9774item.type = "function";9775}9776}97779778output.push(item);9779}9780});97819782return output;9783}97849785//get all filters9786getHeaderFilters(){9787var output = [];97889789for(var key in this.headerFilters){9790output.push({field:key, type:this.headerFilters[key].type, value:this.headerFilters[key].value});9791}97929793return output;9794}97959796//remove filter from array9797removeFilter(field, type, value){9798if(!Array.isArray(field)){9799field = [{field:field, type:type, value:value}];9800}98019802field.forEach((filter) => {9803var index = -1;98049805if(typeof filter.field == "object"){9806index = this.filterList.findIndex((element) => {9807return filter === element;9808});9809}else {9810index = this.filterList.findIndex((element) => {9811return filter.field === element.field && filter.type === element.type && filter.value === element.value;9812});9813}98149815if(index > -1){9816this.filterList.splice(index, 1);9817}else {9818console.warn("Filter Error - No matching filter type found, ignoring: ", filter.type);9819}9820});98219822this.trackChanges();9823}98249825//clear filters9826clearFilter(all){9827this.filterList = [];98289829if(all){9830this.clearHeaderFilter();9831}98329833this.trackChanges();9834}98359836//clear header filters9837clearHeaderFilter(){9838this.headerFilters = {};9839this.prevHeaderFilterChangeCheck = "{}";98409841this.headerFilterColumns.forEach((column) => {9842if(typeof column.modules.filter.value !== "undefined"){9843delete column.modules.filter.value;9844}9845column.modules.filter.prevSuccess = undefined;9846this.reloadHeaderFilter(column);9847});98489849this.trackChanges();9850}98519852//search data and return matching rows9853search (searchType, field, type, value){9854var activeRows = [],9855filterList = [];98569857if(!Array.isArray(field)){9858field = [{field:field, type:type, value:value}];9859}98609861field.forEach((filter) => {9862filter = this.findFilter(filter);98639864if(filter){9865filterList.push(filter);9866}9867});98689869this.table.rowManager.rows.forEach((row) => {9870var match = true;98719872filterList.forEach((filter) => {9873if(!this.filterRecurse(filter, row.getData())){9874match = false;9875}9876});98779878if(match){9879activeRows.push(searchType === "data" ? row.getData("data") : row.getComponent());9880}98819882});98839884return activeRows;9885}98869887//filter row array9888filter(rowList, filters){9889var activeRows = [],9890activeRowComponents = [];98919892if(this.subscribedExternal("dataFiltering")){9893this.dispatchExternal("dataFiltering", this.getFilters(true));9894}98959896if(this.table.options.filterMode !== "remote" && (this.filterList.length || Object.keys(this.headerFilters).length)){98979898rowList.forEach((row) => {9899if(this.filterRow(row)){9900activeRows.push(row);9901}9902});99039904}else {9905activeRows = rowList.slice(0);9906}99079908if(this.subscribedExternal("dataFiltered")){99099910activeRows.forEach((row) => {9911activeRowComponents.push(row.getComponent());9912});99139914this.dispatchExternal("dataFiltered", this.getFilters(true), activeRowComponents);9915}99169917return activeRows;9918}99199920//filter individual row9921filterRow(row, filters){9922var match = true,9923data = row.getData();99249925this.filterList.forEach((filter) => {9926if(!this.filterRecurse(filter, data)){9927match = false;9928}9929});993099319932for(var field in this.headerFilters){9933if(!this.headerFilters[field].func(data)){9934match = false;9935}9936}99379938return match;9939}99409941filterRecurse(filter, data){9942var match = false;99439944if(Array.isArray(filter)){9945filter.forEach((subFilter) => {9946if(this.filterRecurse(subFilter, data)){9947match = true;9948}9949});9950}else {9951match = filter.func(data);9952}99539954return match;9955}9956}99579958Filter.moduleName = "filter";99599960//load defaults9961Filter.filters = defaultFilters;99629963function plaintext(cell, formatterParams, onRendered){9964return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));9965}99669967function html$1(cell, formatterParams, onRendered){9968return cell.getValue();9969}99709971function textarea$1(cell, formatterParams, onRendered){9972cell.getElement().style.whiteSpace = "pre-wrap";9973return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));9974}99759976function money(cell, formatterParams, onRendered){9977var floatVal = parseFloat(cell.getValue()),9978sign = "",9979number, integer, decimal, rgx, value;99809981var decimalSym = formatterParams.decimal || ".";9982var thousandSym = formatterParams.thousand || ",";9983var negativeSign = formatterParams.negativeSign || "-";9984var symbol = formatterParams.symbol || "";9985var after = !!formatterParams.symbolAfter;9986var precision = typeof formatterParams.precision !== "undefined" ? formatterParams.precision : 2;99879988if(isNaN(floatVal)){9989return this.emptyToSpace(this.sanitizeHTML(cell.getValue()));9990}99919992if(floatVal < 0){9993floatVal = Math.abs(floatVal);9994sign = negativeSign;9995}99969997number = precision !== false ? floatVal.toFixed(precision) : floatVal;9998number = String(number).split(".");999910000integer = number[0];10001decimal = number.length > 1 ? decimalSym + number[1] : "";1000210003if (formatterParams.thousand !== false) {10004rgx = /(\d+)(\d{3})/;1000510006while (rgx.test(integer)){10007integer = integer.replace(rgx, "$1" + thousandSym + "$2");10008}10009}1001010011value = integer + decimal;1001210013if(sign === true){10014value = "(" + value + ")";10015return after ? value + symbol : symbol + value;10016}else {10017return after ? sign + value + symbol : sign + symbol + value;10018}10019}1002010021function link(cell, formatterParams, onRendered){10022var value = cell.getValue(),10023urlPrefix = formatterParams.urlPrefix || "",10024download = formatterParams.download,10025label = value,10026el = document.createElement("a"),10027data;1002810029function labelTraverse(path, data){10030var item = path.shift(),10031value = data[item];1003210033if(path.length && typeof value === "object"){10034return labelTraverse(path, value);10035}1003610037return value;10038}1003910040if(formatterParams.labelField){10041data = cell.getData();10042label = labelTraverse(formatterParams.labelField.split(this.table.options.nestedFieldSeparator), data);10043}1004410045if(formatterParams.label){10046switch(typeof formatterParams.label){10047case "string":10048label = formatterParams.label;10049break;1005010051case "function":10052label = formatterParams.label(cell);10053break;10054}10055}1005610057if(label){10058if(formatterParams.urlField){10059data = cell.getData();10060value = data[formatterParams.urlField];10061}1006210063if(formatterParams.url){10064switch(typeof formatterParams.url){10065case "string":10066value = formatterParams.url;10067break;1006810069case "function":10070value = formatterParams.url(cell);10071break;10072}10073}1007410075el.setAttribute("href", urlPrefix + value);1007610077if(formatterParams.target){10078el.setAttribute("target", formatterParams.target);10079}1008010081if(formatterParams.download){1008210083if(typeof download == "function"){10084download = download(cell);10085}else {10086download = download === true ? "" : download;10087}1008810089el.setAttribute("download", download);10090}1009110092el.innerHTML = this.emptyToSpace(this.sanitizeHTML(label));1009310094return el;10095}else {10096return " ";10097}10098}1009910100function image(cell, formatterParams, onRendered){10101var el = document.createElement("img"),10102src = cell.getValue();1010310104if(formatterParams.urlPrefix){10105src = formatterParams.urlPrefix + cell.getValue();10106}1010710108if(formatterParams.urlSuffix){10109src = src + formatterParams.urlSuffix;10110}1011110112el.setAttribute("src", src);1011310114switch(typeof formatterParams.height){10115case "number":10116el.style.height = formatterParams.height + "px";10117break;1011810119case "string":10120el.style.height = formatterParams.height;10121break;10122}1012310124switch(typeof formatterParams.width){10125case "number":10126el.style.width = formatterParams.width + "px";10127break;1012810129case "string":10130el.style.width = formatterParams.width;10131break;10132}1013310134el.addEventListener("load", function(){10135cell.getRow().normalizeHeight();10136});1013710138return el;10139}1014010141function tickCross$1(cell, formatterParams, onRendered){10142var value = cell.getValue(),10143element = cell.getElement(),10144empty = formatterParams.allowEmpty,10145truthy = formatterParams.allowTruthy,10146trueValueSet = Object.keys(formatterParams).includes("trueValue"),10147tick = 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>',10148cross = 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>';1014910150if((trueValueSet && value === formatterParams.trueValue) || (!trueValueSet && ((truthy && value) || (value === true || value === "true" || value === "True" || value === 1 || value === "1")))){10151element.setAttribute("aria-checked", true);10152return tick || "";10153}else {10154if(empty && (value === "null" || value === "" || value === null || typeof value === "undefined")){10155element.setAttribute("aria-checked", "mixed");10156return "";10157}else {10158element.setAttribute("aria-checked", false);10159return cross || "";10160}10161}10162}1016310164function datetime$1(cell, formatterParams, onRendered){10165var DT = window.DateTime || luxon.DateTime;10166var inputFormat = formatterParams.inputFormat || "yyyy-MM-dd HH:mm:ss";10167var outputFormat = formatterParams.outputFormat || "dd/MM/yyyy HH:mm:ss";10168var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";10169var value = cell.getValue();1017010171if(typeof DT != "undefined"){10172var newDatetime;1017310174if(DT.isDateTime(value)){10175newDatetime = value;10176}else if(inputFormat === "iso"){10177newDatetime = DT.fromISO(String(value));10178}else {10179newDatetime = DT.fromFormat(String(value), inputFormat);10180}1018110182if(newDatetime.isValid){10183if(formatterParams.timezone){10184newDatetime = newDatetime.setZone(formatterParams.timezone);10185}1018610187return newDatetime.toFormat(outputFormat);10188}else {10189if(invalid === true || !value){10190return value;10191}else if(typeof invalid === "function"){10192return invalid(value);10193}else {10194return invalid;10195}10196}10197}else {10198console.error("Format Error - 'datetime' formatter is dependant on luxon.js");10199}10200}1020110202function datetimediff (cell, formatterParams, onRendered) {10203var DT = window.DateTime || luxon.DateTime;10204var inputFormat = formatterParams.inputFormat || "yyyy-MM-dd HH:mm:ss";10205var invalid = typeof formatterParams.invalidPlaceholder !== "undefined" ? formatterParams.invalidPlaceholder : "";10206var suffix = typeof formatterParams.suffix !== "undefined" ? formatterParams.suffix : false;10207var unit = typeof formatterParams.unit !== "undefined" ? formatterParams.unit : "days";10208var humanize = typeof formatterParams.humanize !== "undefined" ? formatterParams.humanize : false;10209var date = typeof formatterParams.date !== "undefined" ? formatterParams.date : DT.now();10210var value = cell.getValue();1021110212if(typeof DT != "undefined"){10213var newDatetime;1021410215if(DT.isDateTime(value)){10216newDatetime = value;10217}else if(inputFormat === "iso"){10218newDatetime = DT.fromISO(String(value));10219}else {10220newDatetime = DT.fromFormat(String(value), inputFormat);10221}1022210223if (newDatetime.isValid){10224if(humanize){10225return newDatetime.diff(date, unit).toHuman() + (suffix ? " " + suffix : "");10226}else {10227return parseInt(newDatetime.diff(date, unit)[unit]) + (suffix ? " " + suffix : "");10228}10229} else {1023010231if (invalid === true) {10232return value;10233} else if (typeof invalid === "function") {10234return invalid(value);10235} else {10236return invalid;10237}10238}10239}else {10240console.error("Format Error - 'datetimediff' formatter is dependant on luxon.js");10241}10242}1024310244function lookup (cell, formatterParams, onRendered) {10245var value = cell.getValue();1024610247if (typeof formatterParams[value] === "undefined") {10248console.warn('Missing display value for ' + value);10249return value;10250}1025110252return formatterParams[value];10253}1025410255function star$1(cell, formatterParams, onRendered){10256var value = cell.getValue(),10257element = cell.getElement(),10258maxStars = formatterParams && formatterParams.stars ? formatterParams.stars : 5,10259stars = document.createElement("span"),10260star = document.createElementNS('http://www.w3.org/2000/svg', "svg"),10261starActive = '<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 "/>',10262starInactive = '<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 "/>';1026310264//style stars holder10265stars.style.verticalAlign = "middle";1026610267//style star10268star.setAttribute("width", "14");10269star.setAttribute("height", "14");10270star.setAttribute("viewBox", "0 0 512 512");10271star.setAttribute("xml:space", "preserve");10272star.style.padding = "0 1px";1027310274value = value && !isNaN(value) ? parseInt(value) : 0;1027510276value = Math.max(0, Math.min(value, maxStars));1027710278for(var i=1;i<= maxStars;i++){10279var nextStar = star.cloneNode(true);10280nextStar.innerHTML = i <= value ? starActive : starInactive;1028110282stars.appendChild(nextStar);10283}1028410285element.style.whiteSpace = "nowrap";10286element.style.overflow = "hidden";10287element.style.textOverflow = "ellipsis";1028810289element.setAttribute("aria-label", value);1029010291return stars;10292}1029310294function traffic(cell, formatterParams, onRendered){10295var value = this.sanitizeHTML(cell.getValue()) || 0,10296el = document.createElement("span"),10297max = formatterParams && formatterParams.max ? formatterParams.max : 100,10298min = formatterParams && formatterParams.min ? formatterParams.min : 0,10299colors = formatterParams && typeof formatterParams.color !== "undefined" ? formatterParams.color : ["red", "orange", "green"],10300color = "#666666",10301percent, percentValue;1030210303if(isNaN(value) || typeof cell.getValue() === "undefined"){10304return;10305}1030610307el.classList.add("tabulator-traffic-light");1030810309//make sure value is in range10310percentValue = parseFloat(value) <= max ? parseFloat(value) : max;10311percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;1031210313//workout percentage10314percent = (max - min) / 100;10315percentValue = Math.round((percentValue - min) / percent);1031610317//set color10318switch(typeof colors){10319case "string":10320color = colors;10321break;10322case "function":10323color = colors(value);10324break;10325case "object":10326if(Array.isArray(colors)){10327var unit = 100 / colors.length;10328var index = Math.floor(percentValue / unit);1032910330index = Math.min(index, colors.length - 1);10331index = Math.max(index, 0);10332color = colors[index];10333break;10334}10335}1033610337el.style.backgroundColor = color;1033810339return el;10340}1034110342function progress$1(cell, formatterParams = {}, onRendered){ //progress bar10343var value = this.sanitizeHTML(cell.getValue()) || 0,10344element = cell.getElement(),10345max = formatterParams.max ? formatterParams.max : 100,10346min = formatterParams.min ? formatterParams.min : 0,10347legendAlign = formatterParams.legendAlign ? formatterParams.legendAlign : "center",10348percent, percentValue, color, legend, legendColor;1034910350//make sure value is in range10351percentValue = parseFloat(value) <= max ? parseFloat(value) : max;10352percentValue = parseFloat(percentValue) >= min ? parseFloat(percentValue) : min;1035310354//workout percentage10355percent = (max - min) / 100;10356percentValue = Math.round((percentValue - min) / percent);1035710358//set bar color10359switch(typeof formatterParams.color){10360case "string":10361color = formatterParams.color;10362break;10363case "function":10364color = formatterParams.color(value);10365break;10366case "object":10367if(Array.isArray(formatterParams.color)){10368let unit = 100 / formatterParams.color.length;10369let index = Math.floor(percentValue / unit);1037010371index = Math.min(index, formatterParams.color.length - 1);10372index = Math.max(index, 0);10373color = formatterParams.color[index];10374break;10375}10376default:10377color = "#2DC214";10378}1037910380//generate legend10381switch(typeof formatterParams.legend){10382case "string":10383legend = formatterParams.legend;10384break;10385case "function":10386legend = formatterParams.legend(value);10387break;10388case "boolean":10389legend = value;10390break;10391default:10392legend = false;10393}1039410395//set legend color10396switch(typeof formatterParams.legendColor){10397case "string":10398legendColor = formatterParams.legendColor;10399break;10400case "function":10401legendColor = formatterParams.legendColor(value);10402break;10403case "object":10404if(Array.isArray(formatterParams.legendColor)){10405let unit = 100 / formatterParams.legendColor.length;10406let index = Math.floor(percentValue / unit);1040710408index = Math.min(index, formatterParams.legendColor.length - 1);10409index = Math.max(index, 0);10410legendColor = formatterParams.legendColor[index];10411}10412break;10413default:10414legendColor = "#000";10415}1041610417element.style.minWidth = "30px";10418element.style.position = "relative";1041910420element.setAttribute("aria-label", percentValue);1042110422var barEl = document.createElement("div");10423barEl.style.display = "inline-block";10424barEl.style.width = percentValue + "%";10425barEl.style.backgroundColor = color;10426barEl.style.height = "100%";1042710428barEl.setAttribute('data-max', max);10429barEl.setAttribute('data-min', min);1043010431var barContainer = document.createElement("div");10432barContainer.style.position = "relative";10433barContainer.style.width = "100%";10434barContainer.style.height = "100%";1043510436if(legend){10437var legendEl = document.createElement("div");10438legendEl.style.position = "absolute";10439legendEl.style.top = 0;10440legendEl.style.left = 0;10441legendEl.style.textAlign = legendAlign;10442legendEl.style.width = "100%";10443legendEl.style.color = legendColor;10444legendEl.innerHTML = legend;10445}1044610447onRendered(function(){1044810449//handle custom element needed if formatter is to be included in printed/downloaded output10450if(!(cell instanceof CellComponent)){10451var holderEl = document.createElement("div");10452holderEl.style.position = "absolute";10453holderEl.style.top = "4px";10454holderEl.style.bottom = "4px";10455holderEl.style.left = "4px";10456holderEl.style.right = "4px";1045710458element.appendChild(holderEl);1045910460element = holderEl;10461}1046210463element.appendChild(barContainer);10464barContainer.appendChild(barEl);1046510466if(legend){10467barContainer.appendChild(legendEl);10468}10469});1047010471return "";10472}1047310474function color(cell, formatterParams, onRendered){10475cell.getElement().style.backgroundColor = this.sanitizeHTML(cell.getValue());10476return "";10477}1047810479function buttonTick(cell, formatterParams, onRendered){10480return '<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>';10481}1048210483function buttonCross(cell, formatterParams, onRendered){10484return '<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>';10485}1048610487function rownum(cell, formatterParams, onRendered){10488var content = document.createElement("span");10489var row = cell.getRow();1049010491row.watchPosition((position) => {10492content.innerText = position;10493});1049410495return content;10496}1049710498function handle(cell, formatterParams, onRendered){10499cell.getElement().classList.add("tabulator-row-handle");10500return "<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>";10501}1050210503function responsiveCollapse(cell, formatterParams, onRendered){10504var el = document.createElement("div"),10505config = cell.getRow()._row.modules.responsiveLayout;1050610507el.classList.add("tabulator-responsive-collapse-toggle");1050810509el.innerHTML = `<svg class='tabulator-responsive-collapse-toggle-open' viewbox="0 0 24 24">10510<line x1="7" y1="12" x2="17" y2="12" fill="none" stroke-width="3" stroke-linecap="round" />10511<line y1="7" x1="12" y2="17" x2="12" fill="none" stroke-width="3" stroke-linecap="round" />10512</svg>1051310514<svg class='tabulator-responsive-collapse-toggle-close' viewbox="0 0 24 24">10515<line x1="7" y1="12" x2="17" y2="12" fill="none" stroke-width="3" stroke-linecap="round" />10516</svg>`;1051710518cell.getElement().classList.add("tabulator-row-handle");1051910520function toggleList(isOpen){10521var collapseEl = config.element;1052210523config.open = isOpen;1052410525if(collapseEl){1052610527if(config.open){10528el.classList.add("open");10529collapseEl.style.display = '';10530}else {10531el.classList.remove("open");10532collapseEl.style.display = 'none';10533}10534}10535}1053610537el.addEventListener("click", function(e){10538e.stopImmediatePropagation();10539toggleList(!config.open);10540cell.getTable().rowManager.adjustTableSize();10541});1054210543toggleList(config.open);1054410545return el;10546}1054710548function rowSelection(cell, formatterParams, onRendered){10549var checkbox = document.createElement("input");10550var blocked = false;1055110552checkbox.type = 'checkbox';1055310554checkbox.setAttribute("aria-label", "Select Row");1055510556if(this.table.modExists("selectRow", true)){1055710558checkbox.addEventListener("click", (e) => {10559e.stopPropagation();10560});1056110562if(typeof cell.getRow == 'function'){10563var row = cell.getRow();1056410565if(row instanceof RowComponent){1056610567checkbox.addEventListener("change", (e) => {10568if(this.table.options.selectableRangeMode === "click"){10569if(!blocked){10570row.toggleSelect();10571}else {10572blocked = false;10573}10574}else {10575row.toggleSelect();10576}10577});1057810579if(this.table.options.selectableRangeMode === "click"){10580checkbox.addEventListener("click", (e) => {10581blocked = true;10582this.table.modules.selectRow.handleComplexRowClick(row._row, e);10583});10584}1058510586checkbox.checked = row.isSelected && row.isSelected();10587this.table.modules.selectRow.registerRowSelectCheckbox(row, checkbox);10588}else {10589checkbox = "";10590}10591}else {10592checkbox.addEventListener("change", (e) => {10593if(this.table.modules.selectRow.selectedRows.length){10594this.table.deselectRow();10595}else {10596this.table.selectRow(formatterParams.rowRange);10597}10598});1059910600this.table.modules.selectRow.registerHeaderSelectCheckbox(checkbox);10601}10602}1060310604return checkbox;10605}1060610607var defaultFormatters = {10608plaintext:plaintext,10609html:html$1,10610textarea:textarea$1,10611money:money,10612link:link,10613image:image,10614tickCross:tickCross$1,10615datetime:datetime$1,10616datetimediff:datetimediff,10617lookup:lookup,10618star:star$1,10619traffic:traffic,10620progress:progress$1,10621color:color,10622buttonTick:buttonTick,10623buttonCross:buttonCross,10624rownum:rownum,10625handle:handle,10626responsiveCollapse:responsiveCollapse,10627rowSelection:rowSelection,10628};1062910630class Format extends Module{1063110632constructor(table){10633super(table);1063410635this.registerColumnOption("formatter");10636this.registerColumnOption("formatterParams");1063710638this.registerColumnOption("formatterPrint");10639this.registerColumnOption("formatterPrintParams");10640this.registerColumnOption("formatterClipboard");10641this.registerColumnOption("formatterClipboardParams");10642this.registerColumnOption("formatterHtmlOutput");10643this.registerColumnOption("formatterHtmlOutputParams");10644this.registerColumnOption("titleFormatter");10645this.registerColumnOption("titleFormatterParams");10646}1064710648initialize(){10649this.subscribe("cell-format", this.formatValue.bind(this));10650this.subscribe("cell-rendered", this.cellRendered.bind(this));10651this.subscribe("column-layout", this.initializeColumn.bind(this));10652this.subscribe("column-format", this.formatHeader.bind(this));10653}1065410655//initialize column formatter10656initializeColumn(column){10657column.modules.format = this.lookupFormatter(column, "");1065810659if(typeof column.definition.formatterPrint !== "undefined"){10660column.modules.format.print = this.lookupFormatter(column, "Print");10661}1066210663if(typeof column.definition.formatterClipboard !== "undefined"){10664column.modules.format.clipboard = this.lookupFormatter(column, "Clipboard");10665}1066610667if(typeof column.definition.formatterHtmlOutput !== "undefined"){10668column.modules.format.htmlOutput = this.lookupFormatter(column, "HtmlOutput");10669}10670}1067110672lookupFormatter(column, type){10673var config = {params:column.definition["formatter" + type + "Params"] || {}},10674formatter = column.definition["formatter" + type];1067510676//set column formatter10677switch(typeof formatter){10678case "string":10679if(Format.formatters[formatter]){10680config.formatter = Format.formatters[formatter];10681}else {10682console.warn("Formatter Error - No such formatter found: ", formatter);10683config.formatter = Format.formatters.plaintext;10684}10685break;1068610687case "function":10688config.formatter = formatter;10689break;1069010691default:10692config.formatter = Format.formatters.plaintext;10693break;10694}1069510696return config;10697}1069810699cellRendered(cell){10700if(cell.modules.format && cell.modules.format.renderedCallback && !cell.modules.format.rendered){10701cell.modules.format.renderedCallback();10702cell.modules.format.rendered = true;10703}10704}1070510706//return a formatted value for a column header10707formatHeader(column, title, el){10708var formatter, params, onRendered, mockCell;1070910710if(column.definition.titleFormatter){10711formatter = this.getFormatter(column.definition.titleFormatter);1071210713onRendered = (callback) => {10714column.titleFormatterRendered = callback;10715};1071610717mockCell = {10718getValue:function(){10719return title;10720},10721getElement:function(){10722return el;10723},10724getType:function(){10725return "header";10726},10727getColumn:function(){10728return column.getComponent();10729},10730getTable:() => {10731return this.table;10732}10733};1073410735params = column.definition.titleFormatterParams || {};1073610737params = typeof params === "function" ? params() : params;1073810739return formatter.call(this, mockCell, params, onRendered);10740}else {10741return title;10742}10743}107441074510746//return a formatted value for a cell10747formatValue(cell){10748var component = cell.getComponent(),10749params = typeof cell.column.modules.format.params === "function" ? cell.column.modules.format.params(component) : cell.column.modules.format.params;1075010751function onRendered(callback){10752if(!cell.modules.format){10753cell.modules.format = {};10754}1075510756cell.modules.format.renderedCallback = callback;10757cell.modules.format.rendered = false;10758}1075910760return cell.column.modules.format.formatter.call(this, component, params, onRendered);10761}1076210763formatExportValue(cell, type){10764var formatter = cell.column.modules.format[type],10765params;1076610767if(formatter){10768params = typeof formatter.params === "function" ? formatter.params(cell.getComponent()) : formatter.params;1076910770function onRendered(callback){10771if(!cell.modules.format){10772cell.modules.format = {};10773}1077410775cell.modules.format.renderedCallback = callback;10776cell.modules.format.rendered = false;10777}1077810779return formatter.formatter.call(this, cell.getComponent(), params, onRendered);1078010781}else {10782return this.formatValue(cell);10783}10784}1078510786sanitizeHTML(value){10787if(value){10788var entityMap = {10789'&': '&',10790'<': '<',10791'>': '>',10792'"': '"',10793"'": ''',10794'/': '/',10795'`': '`',10796'=': '='10797};1079810799return String(value).replace(/[&<>"'`=/]/g, function (s) {10800return entityMap[s];10801});10802}else {10803return value;10804}10805}1080610807emptyToSpace(value){10808return value === null || typeof value === "undefined" || value === "" ? " " : value;10809}1081010811//get formatter for cell10812getFormatter(formatter){10813switch(typeof formatter){10814case "string":10815if(Format.formatters[formatter]){10816formatter = Format.formatters[formatter];10817}else {10818console.warn("Formatter Error - No such formatter found: ", formatter);10819formatter = Format.formatters.plaintext;10820}10821break;1082210823case "function":10824//Custom formatter Function, do nothing10825break;1082610827default:10828formatter = Format.formatters.plaintext;10829break;10830}1083110832return formatter;10833}10834}1083510836Format.moduleName = "format";1083710838//load defaults10839Format.formatters = defaultFormatters;1084010841class FrozenColumns extends Module{1084210843constructor(table){10844super(table);1084510846this.leftColumns = [];10847this.rightColumns = [];10848this.initializationMode = "left";10849this.active = false;10850this.blocked = true;1085110852this.registerColumnOption("frozen");10853}1085410855//reset initial state10856reset(){10857this.initializationMode = "left";10858this.leftColumns = [];10859this.rightColumns = [];10860this.active = false;10861}1086210863initialize(){10864this.subscribe("cell-layout", this.layoutCell.bind(this));10865this.subscribe("column-init", this.initializeColumn.bind(this));10866this.subscribe("column-width", this.layout.bind(this));10867this.subscribe("row-layout-after", this.layoutRow.bind(this));10868this.subscribe("table-layout", this.layout.bind(this));10869this.subscribe("columns-loading", this.reset.bind(this));1087010871this.subscribe("column-add", this.reinitializeColumns.bind(this));10872this.subscribe("column-delete", this.reinitializeColumns.bind(this));1087310874this.subscribe("table-redraw", this.layout.bind(this));10875this.subscribe("layout-refreshing", this.blockLayout.bind(this));10876this.subscribe("layout-refreshed", this.unblockLayout.bind(this));10877this.subscribe("scrollbar-vertical", this.adjustForScrollbar.bind(this));10878}1087910880blockLayout(){10881this.blocked = true;10882}1088310884unblockLayout(){10885this.blocked = false;10886}1088710888layoutCell(cell){10889this.layoutElement(cell.element, cell.column);10890}1089110892reinitializeColumns(){10893this.reset();1089410895this.table.columnManager.columnsByIndex.forEach((column) => {10896this.initializeColumn(column);10897});10898}1089910900//initialize specific column10901initializeColumn(column){10902var config = {margin:0, edge:false};1090310904if(!column.isGroup){1090510906if(this.frozenCheck(column)){1090710908config.position = this.initializationMode;1090910910if(this.initializationMode == "left"){10911this.leftColumns.push(column);10912}else {10913this.rightColumns.unshift(column);10914}1091510916this.active = true;1091710918column.modules.frozen = config;10919}else {10920this.initializationMode = "right";10921}10922}10923}1092410925frozenCheck(column){10926if(column.parent.isGroup && column.definition.frozen){10927console.warn("Frozen Column Error - Parent column group must be frozen, not individual columns or sub column groups");10928}1092910930if(column.parent.isGroup){10931return this.frozenCheck(column.parent);10932}else {10933return column.definition.frozen;10934}10935}1093610937//layout calculation rows10938layoutCalcRows(){10939if(this.table.modExists("columnCalcs")){10940if(this.table.modules.columnCalcs.topInitialized && this.table.modules.columnCalcs.topRow){10941this.layoutRow(this.table.modules.columnCalcs.topRow);10942}1094310944if(this.table.modules.columnCalcs.botInitialized && this.table.modules.columnCalcs.botRow){10945this.layoutRow(this.table.modules.columnCalcs.botRow);10946}1094710948if(this.table.modExists("groupRows")){10949this.layoutGroupCalcs(this.table.modules.groupRows.getGroups());10950}10951}10952}1095310954layoutGroupCalcs(groups){10955groups.forEach((group) => {10956if(group.calcs.top){10957this.layoutRow(group.calcs.top);10958}1095910960if(group.calcs.bottom){10961this.layoutRow(group.calcs.bottom);10962}1096310964if(group.groupList && group.groupList.length){10965this.layoutGroupCalcs(group.groupList);10966}10967});10968}1096910970//calculate column positions and layout headers10971layoutColumnPosition(allCells){10972var leftParents = [];1097310974var leftMargin = 0;10975var rightMargin = 0;1097610977this.leftColumns.forEach((column, i) => {10978column.modules.frozen.marginValue = leftMargin;10979column.modules.frozen.margin = column.modules.frozen.marginValue + "px";1098010981if(column.visible){10982leftMargin += column.getWidth();10983}1098410985if(i == this.leftColumns.length - 1){10986column.modules.frozen.edge = true;10987}else {10988column.modules.frozen.edge = false;10989}1099010991if(column.parent.isGroup){10992var parentEl = this.getColGroupParentElement(column);10993if(!leftParents.includes(parentEl)){10994this.layoutElement(parentEl, column);10995leftParents.push(parentEl);10996}1099710998if(column.modules.frozen.edge){10999parentEl.classList.add("tabulator-frozen-" + column.modules.frozen.position);11000}11001}else {11002this.layoutElement(column.getElement(), column);11003}1100411005if(allCells){11006column.cells.forEach((cell) => {11007this.layoutElement(cell.getElement(true), column);11008});11009}11010});1101111012this.rightColumns.forEach((column, i) => {1101311014column.modules.frozen.marginValue = rightMargin;11015column.modules.frozen.margin = column.modules.frozen.marginValue + "px";1101611017if(column.visible){11018rightMargin += column.getWidth();11019}1102011021if(i == this.rightColumns.length - 1){11022column.modules.frozen.edge = true;11023}else {11024column.modules.frozen.edge = false;11025}1102611027if(column.parent.isGroup){11028this.layoutElement(this.getColGroupParentElement(column), column);11029}else {11030this.layoutElement(column.getElement(), column);11031}1103211033if(allCells){11034column.cells.forEach((cell) => {11035this.layoutElement(cell.getElement(true), column);11036});11037}11038});11039}1104011041getColGroupParentElement(column){11042return column.parent.isGroup ? this.getColGroupParentElement(column.parent) : column.getElement();11043}1104411045//layout columns appropriately11046layout(){11047if(this.active && !this.blocked){1104811049//calculate left columns11050this.layoutColumnPosition();1105111052this.reinitializeRows();1105311054this.layoutCalcRows();11055}11056}1105711058reinitializeRows(){11059var visibleRows = this.table.rowManager.getVisibleRows(true);11060var otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));1106111062otherRows.forEach((row) =>{11063row.deinitialize();11064});1106511066visibleRows.forEach((row) =>{11067if(row.type === "row"){11068this.layoutRow(row);11069}11070});11071}1107211073layoutRow(row){11074if(this.table.options.layout === "fitDataFill" && this.rightColumns.length){11075this.table.rowManager.getTableElement().style.minWidth = "calc(100% - " + this.rightMargin + ")";11076}1107711078this.leftColumns.forEach((column) => {11079var cell = row.getCell(column);1108011081if(cell){11082this.layoutElement(cell.getElement(true), column);11083}11084});1108511086this.rightColumns.forEach((column) => {11087var cell = row.getCell(column);1108811089if(cell){11090this.layoutElement(cell.getElement(true), column);11091}11092});11093}1109411095layoutElement(element, column){11096var position;1109711098if(column.modules.frozen && element){11099element.style.position = "sticky";1110011101if(this.table.rtl){11102position = column.modules.frozen.position === "left" ? "right" : "left";11103}else {11104position = column.modules.frozen.position;11105}1110611107element.style[position] = column.modules.frozen.margin;1110811109element.classList.add("tabulator-frozen");1111011111if(column.modules.frozen.edge){11112element.classList.add("tabulator-frozen-" + column.modules.frozen.position);11113}11114}11115}1111611117adjustForScrollbar(width){11118if(this.rightColumns.length){11119this.table.columnManager.getContentsElement().style.width = "calc(100% - " + width + "px)";11120}11121}1112211123_calcSpace(columns, index){11124var width = 0;1112511126for (let i = 0; i < index; i++){11127if(columns[i].visible){11128width += columns[i].getWidth();11129}11130}1113111132return width;11133}11134}1113511136FrozenColumns.moduleName = "frozenColumns";1113711138class FrozenRows extends Module{1113911140constructor(table){11141super(table);1114211143this.topElement = document.createElement("div");11144this.rows = [];1114511146//register component functions11147this.registerComponentFunction("row", "freeze", this.freezeRow.bind(this));11148this.registerComponentFunction("row", "unfreeze", this.unfreezeRow.bind(this));11149this.registerComponentFunction("row", "isFrozen", this.isRowFrozen.bind(this));1115011151//register table options11152this.registerTableOption("frozenRowsField", "id"); //field to choose frozen rows by11153this.registerTableOption("frozenRows", false); //holder for frozen row identifiers11154}1115511156initialize(){11157this.rows = [];1115811159this.topElement.classList.add("tabulator-frozen-rows-holder");1116011161// this.table.columnManager.element.append(this.topElement);11162this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);1116311164this.subscribe("row-deleting", this.detachRow.bind(this));11165this.subscribe("rows-visible", this.visibleRows.bind(this));1116611167this.registerDisplayHandler(this.getRows.bind(this), 10);1116811169if(this.table.options.frozenRows){11170this.subscribe("data-processed", this.initializeRows.bind(this));11171this.subscribe("row-added", this.initializeRow.bind(this));11172this.subscribe("table-redrawing", this.resizeHolderWidth.bind(this));11173this.subscribe("column-resized", this.resizeHolderWidth.bind(this));11174this.subscribe("column-show", this.resizeHolderWidth.bind(this));11175this.subscribe("column-hide", this.resizeHolderWidth.bind(this));11176}1117711178this.resizeHolderWidth();11179}1118011181resizeHolderWidth(){11182this.topElement.style.minWidth = this.table.columnManager.headersElement.offsetWidth + "px";11183}1118411185initializeRows(){11186this.table.rowManager.getRows().forEach((row) => {11187this.initializeRow(row);11188});11189}1119011191initializeRow(row){11192var frozenRows = this.table.options.frozenRows,11193rowType = typeof frozenRows;1119411195if(rowType === "number"){11196if(row.getPosition() && (row.getPosition() + this.rows.length) <= frozenRows){11197this.freezeRow(row);11198}11199}else if(rowType === "function"){11200if(frozenRows.call(this.table, row.getComponent())){11201this.freezeRow(row);11202}11203}else if(Array.isArray(frozenRows)){11204if(frozenRows.includes(row.data[this.options("frozenRowsField")])){11205this.freezeRow(row);11206}11207}11208}1120911210isRowFrozen(row){11211var index = this.rows.indexOf(row);11212return index > -1;11213}1121411215isFrozen(){11216return !!this.rows.length;11217}1121811219visibleRows(viewable, rows){11220this.rows.forEach((row) => {11221rows.push(row);11222});1122311224return rows;11225}1122611227//filter frozen rows out of display data11228getRows(rows){11229var output = rows.slice(0);1123011231this.rows.forEach(function(row){11232var index = output.indexOf(row);1123311234if(index > -1){11235output.splice(index, 1);11236}11237});1123811239return output;11240}1124111242freezeRow(row){11243if(!row.modules.frozen){11244row.modules.frozen = true;11245this.topElement.appendChild(row.getElement());11246row.initialize();11247row.normalizeHeight();1124811249this.rows.push(row);1125011251this.refreshData(false, "display");1125211253this.table.rowManager.adjustTableSize();1125411255this.styleRows();1125611257}else {11258console.warn("Freeze Error - Row is already frozen");11259}11260}1126111262unfreezeRow(row){11263if(row.modules.frozen){1126411265row.modules.frozen = false;1126611267this.detachRow(row);1126811269this.table.rowManager.adjustTableSize();1127011271this.refreshData(false, "display");1127211273if(this.rows.length){11274this.styleRows();11275}1127611277}else {11278console.warn("Freeze Error - Row is already unfrozen");11279}11280}1128111282detachRow(row){11283var index = this.rows.indexOf(row);1128411285if(index > -1){11286var rowEl = row.getElement();1128711288if(rowEl.parentNode){11289rowEl.parentNode.removeChild(rowEl);11290}1129111292this.rows.splice(index, 1);11293}11294}1129511296styleRows(row){11297this.rows.forEach((row, i) => {11298this.table.rowManager.styleRow(row, i);11299});11300}11301}1130211303FrozenRows.moduleName = "frozenRows";1130411305//public group object11306class GroupComponent {11307constructor (group){11308this._group = group;11309this.type = "GroupComponent";1131011311return new Proxy(this, {11312get: function(target, name, receiver) {11313if (typeof target[name] !== "undefined") {11314return target[name];11315}else {11316return target._group.groupManager.table.componentFunctionBinder.handle("group", target._group, name);11317}11318}11319});11320}1132111322getKey(){11323return this._group.key;11324}1132511326getField(){11327return this._group.field;11328}1132911330getElement(){11331return this._group.element;11332}1133311334getRows(){11335return this._group.getRows(true);11336}1133711338getSubGroups(){11339return this._group.getSubGroups(true);11340}1134111342getParentGroup(){11343return this._group.parent ? this._group.parent.getComponent() : false;11344}1134511346isVisible(){11347return this._group.visible;11348}1134911350show(){11351this._group.show();11352}1135311354hide(){11355this._group.hide();11356}1135711358toggle(){11359this._group.toggleVisibility();11360}1136111362scrollTo(position, ifVisible){11363return this._group.groupManager.table.rowManager.scrollToRow(this._group, position, ifVisible);11364}1136511366_getSelf(){11367return this._group;11368}1136911370getTable(){11371return this._group.groupManager.table;11372}11373}1137411375//Group functions11376class Group{1137711378constructor(groupManager, parent, level, key, field, generator, oldGroup){11379this.groupManager = groupManager;11380this.parent = parent;11381this.key = key;11382this.level = level;11383this.field = field;11384this.hasSubGroups = level < (groupManager.groupIDLookups.length - 1);11385this.addRow = this.hasSubGroups ? this._addRowToGroup : this._addRow;11386this.type = "group"; //type of element11387this.old = oldGroup;11388this.rows = [];11389this.groups = [];11390this.groupList = [];11391this.generator = generator;11392this.element = false;11393this.elementContents = false;11394this.height = 0;11395this.outerHeight = 0;11396this.initialized = false;11397this.calcs = {};11398this.initialized = false;11399this.modules = {};11400this.arrowElement = false;1140111402this.visible = oldGroup ? oldGroup.visible : (typeof groupManager.startOpen[level] !== "undefined" ? groupManager.startOpen[level] : groupManager.startOpen[0]);1140311404this.component = null;1140511406this.createElements();11407this.addBindings();1140811409this.createValueGroups();11410}1141111412wipe(elementsOnly){11413if(!elementsOnly){11414if(this.groupList.length){11415this.groupList.forEach(function(group){11416group.wipe();11417});11418}else {11419this.rows.forEach((row) => {11420if(row.modules){11421delete row.modules.group;11422}11423});11424}11425}1142611427this.element = false;11428this.arrowElement = false;11429this.elementContents = false;11430}1143111432createElements(){11433var arrow = document.createElement("div");11434arrow.classList.add("tabulator-arrow");1143511436this.element = document.createElement("div");11437this.element.classList.add("tabulator-row");11438this.element.classList.add("tabulator-group");11439this.element.classList.add("tabulator-group-level-" + this.level);11440this.element.setAttribute("role", "rowgroup");1144111442this.arrowElement = document.createElement("div");11443this.arrowElement.classList.add("tabulator-group-toggle");11444this.arrowElement.appendChild(arrow);1144511446//setup movable rows11447if(this.groupManager.table.options.movableRows !== false && this.groupManager.table.modExists("moveRow")){11448this.groupManager.table.modules.moveRow.initializeGroupHeader(this);11449}11450}1145111452createValueGroups(){11453var level = this.level + 1;11454if(this.groupManager.allowedValues && this.groupManager.allowedValues[level]){11455this.groupManager.allowedValues[level].forEach((value) => {11456this._createGroup(value, level);11457});11458}11459}1146011461addBindings(){11462var toggleElement;1146311464if(this.groupManager.table.options.groupToggleElement){11465toggleElement = this.groupManager.table.options.groupToggleElement == "arrow" ? this.arrowElement : this.element;1146611467toggleElement.addEventListener("click", (e) => {11468if(this.groupManager.table.options.groupToggleElement === "arrow"){11469e.stopPropagation();11470e.stopImmediatePropagation();11471}1147211473//allow click event to propagate before toggling visibility11474setTimeout(() => {11475this.toggleVisibility();11476});11477});11478}11479}1148011481_createGroup(groupID, level){11482var groupKey = level + "_" + groupID;11483var 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);1148411485this.groups[groupKey] = group;11486this.groupList.push(group);11487}1148811489_addRowToGroup(row){1149011491var level = this.level + 1;1149211493if(this.hasSubGroups){11494var groupID = this.groupManager.groupIDLookups[level].func(row.getData()),11495groupKey = level + "_" + groupID;1149611497if(this.groupManager.allowedValues && this.groupManager.allowedValues[level]){11498if(this.groups[groupKey]){11499this.groups[groupKey].addRow(row);11500}11501}else {11502if(!this.groups[groupKey]){11503this._createGroup(groupID, level);11504}1150511506this.groups[groupKey].addRow(row);11507}11508}11509}1151011511_addRow(row){11512this.rows.push(row);11513row.modules.group = this;11514}1151511516insertRow(row, to, after){11517var data = this.conformRowData({});1151811519row.updateData(data);1152011521var toIndex = this.rows.indexOf(to);1152211523if(toIndex > -1){11524if(after){11525this.rows.splice(toIndex+1, 0, row);11526}else {11527this.rows.splice(toIndex, 0, row);11528}11529}else {11530if(after){11531this.rows.push(row);11532}else {11533this.rows.unshift(row);11534}11535}1153611537row.modules.group = this;1153811539// this.generateGroupHeaderContents();1154011541if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){11542this.groupManager.table.modules.columnCalcs.recalcGroup(this);11543}1154411545this.groupManager.updateGroupRows(true);11546}1154711548scrollHeader(left){11549if(this.arrowElement){11550this.arrowElement.style.marginLeft = left;1155111552this.groupList.forEach(function(child){11553child.scrollHeader(left);11554});11555}11556}1155711558getRowIndex(row){}1155911560//update row data to match grouping constraints11561conformRowData(data){11562if(this.field){11563data[this.field] = this.key;11564}else {11565console.warn("Data Conforming Error - Cannot conform row data to match new group as groupBy is a function");11566}1156711568if(this.parent){11569data = this.parent.conformRowData(data);11570}1157111572return data;11573}1157411575removeRow(row){11576var index = this.rows.indexOf(row);11577var el = row.getElement();1157811579if(index > -1){11580this.rows.splice(index, 1);11581}1158211583if(!this.groupManager.table.options.groupValues && !this.rows.length){11584if(this.parent){11585this.parent.removeGroup(this);11586}else {11587this.groupManager.removeGroup(this);11588}1158911590this.groupManager.updateGroupRows(true);1159111592}else {1159311594if(el.parentNode){11595el.parentNode.removeChild(el);11596}1159711598if(!this.groupManager.blockRedraw){11599this.generateGroupHeaderContents();1160011601if(this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.options.columnCalcs != "table"){11602this.groupManager.table.modules.columnCalcs.recalcGroup(this);11603}11604}1160511606}11607}1160811609removeGroup(group){11610var groupKey = group.level + "_" + group.key,11611index;1161211613if(this.groups[groupKey]){11614delete this.groups[groupKey];1161511616index = this.groupList.indexOf(group);1161711618if(index > -1){11619this.groupList.splice(index, 1);11620}1162111622if(!this.groupList.length){11623if(this.parent){11624this.parent.removeGroup(this);11625}else {11626this.groupManager.removeGroup(this);11627}11628}11629}11630}1163111632getHeadersAndRows(){11633var output = [];1163411635output.push(this);1163611637this._visSet();116381163911640if(this.calcs.top){11641this.calcs.top.detachElement();11642this.calcs.top.deleteCells();11643}1164411645if(this.calcs.bottom){11646this.calcs.bottom.detachElement();11647this.calcs.bottom.deleteCells();11648}11649116501165111652if(this.visible){11653if(this.groupList.length){11654this.groupList.forEach(function(group){11655output = output.concat(group.getHeadersAndRows());11656});1165711658}else {11659if(this.groupManager.table.options.columnCalcs != "table" && this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.modules.columnCalcs.hasTopCalcs()){11660this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);11661output.push(this.calcs.top);11662}1166311664output = output.concat(this.rows);1166511666if(this.groupManager.table.options.columnCalcs != "table" && this.groupManager.table.modExists("columnCalcs") && this.groupManager.table.modules.columnCalcs.hasBottomCalcs()){11667this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);11668output.push(this.calcs.bottom);11669}11670}11671}else {11672if(!this.groupList.length && this.groupManager.table.options.columnCalcs != "table"){1167311674if(this.groupManager.table.modExists("columnCalcs")){11675if(this.groupManager.table.modules.columnCalcs.hasTopCalcs()){11676if(this.groupManager.table.options.groupClosedShowCalcs){11677this.calcs.top = this.groupManager.table.modules.columnCalcs.generateTopRow(this.rows);11678output.push(this.calcs.top);11679}11680}1168111682if(this.groupManager.table.modules.columnCalcs.hasBottomCalcs()){11683if(this.groupManager.table.options.groupClosedShowCalcs){11684this.calcs.bottom = this.groupManager.table.modules.columnCalcs.generateBottomRow(this.rows);11685output.push(this.calcs.bottom);11686}11687}11688}11689}1169011691}1169211693return output;11694}1169511696getData(visible, transform){11697var output = [];1169811699this._visSet();1170011701if(!visible || (visible && this.visible)){11702this.rows.forEach((row) => {11703output.push(row.getData(transform || "data"));11704});11705}1170611707return output;11708}1170911710getRowCount(){11711var count = 0;1171211713if(this.groupList.length){11714this.groupList.forEach((group) => {11715count += group.getRowCount();11716});11717}else {11718count = this.rows.length;11719}11720return count;11721}117221172311724toggleVisibility(){11725if(this.visible){11726this.hide();11727}else {11728this.show();11729}11730}1173111732hide(){11733this.visible = false;1173411735if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){1173611737this.element.classList.remove("tabulator-group-visible");1173811739if(this.groupList.length){11740this.groupList.forEach((group) => {1174111742var rows = group.getHeadersAndRows();1174311744rows.forEach((row) => {11745row.detachElement();11746});11747});1174811749}else {11750this.rows.forEach((row) => {11751var rowEl = row.getElement();11752rowEl.parentNode.removeChild(rowEl);11753});11754}1175511756this.groupManager.updateGroupRows(true);1175711758}else {11759this.groupManager.updateGroupRows(true);11760}1176111762this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), false);11763}1176411765show(){11766this.visible = true;1176711768if(this.groupManager.table.rowManager.getRenderMode() == "basic" && !this.groupManager.table.options.pagination){1176911770this.element.classList.add("tabulator-group-visible");1177111772var prev = this.generateElement();1177311774if(this.groupList.length){11775this.groupList.forEach((group) => {11776var rows = group.getHeadersAndRows();1177711778rows.forEach((row) => {11779var rowEl = row.getElement();11780prev.parentNode.insertBefore(rowEl, prev.nextSibling);11781row.initialize();11782prev = rowEl;11783});11784});1178511786}else {11787this.rows.forEach((row) => {11788var rowEl = row.getElement();11789prev.parentNode.insertBefore(rowEl, prev.nextSibling);11790row.initialize();11791prev = rowEl;11792});11793}1179411795this.groupManager.updateGroupRows(true);11796}else {11797this.groupManager.updateGroupRows(true);11798}1179911800this.groupManager.table.externalEvents.dispatch("groupVisibilityChanged", this.getComponent(), true);11801}1180211803_visSet(){11804var data = [];1180511806if(typeof this.visible == "function"){1180711808this.rows.forEach(function(row){11809data.push(row.getData());11810});1181111812this.visible = this.visible(this.key, this.getRowCount(), data, this.getComponent());11813}11814}1181511816getRowGroup(row){11817var match = false;11818if(this.groupList.length){11819this.groupList.forEach(function(group){11820var result = group.getRowGroup(row);1182111822if(result){11823match = result;11824}11825});11826}else {11827if(this.rows.find(function(item){11828return item === row;11829})){11830match = this;11831}11832}1183311834return match;11835}1183611837getSubGroups(component){11838var output = [];1183911840this.groupList.forEach(function(child){11841output.push(component ? child.getComponent() : child);11842});1184311844return output;11845}1184611847getRows(component, includeChildren){11848var output = [];1184911850if(includeChildren && this.groupList.length){11851this.groupList.forEach((group) => {11852output = output.concat(group.getRows(component, includeChildren));11853});11854}else {11855this.rows.forEach(function(row){11856output.push(component ? row.getComponent() : row);11857});11858}1185911860return output;11861}1186211863generateGroupHeaderContents(){11864var data = [];1186511866var rows = this.getRows(false, true);1186711868rows.forEach(function(row){11869data.push(row.getData());11870});1187111872this.elementContents = this.generator(this.key, this.getRowCount(), data, this.getComponent());1187311874while(this.element.firstChild) this.element.removeChild(this.element.firstChild);1187511876if(typeof this.elementContents === "string"){11877this.element.innerHTML = this.elementContents;11878}else {11879this.element.appendChild(this.elementContents);11880}1188111882this.element.insertBefore(this.arrowElement, this.element.firstChild);11883}1188411885getPath(path = []) {11886path.unshift(this.key);11887if(this.parent) {11888this.parent.getPath(path);11889}11890return path;11891}1189211893////////////// Standard Row Functions //////////////1189411895getElement(){11896return this.elementContents ? this.element : this.generateElement();11897}1189811899generateElement(){11900this.addBindings = false;1190111902this._visSet();1190311904if(this.visible){11905this.element.classList.add("tabulator-group-visible");11906}else {11907this.element.classList.remove("tabulator-group-visible");11908}1190911910for(var i = 0; i < this.element.childNodes.length; ++i){11911this.element.childNodes[i].parentNode.removeChild(this.element.childNodes[i]);11912}1191311914this.generateGroupHeaderContents();1191511916// this.addBindings();1191711918return this.element;11919}1192011921detachElement(){11922if (this.element && this.element.parentNode){11923this.element.parentNode.removeChild(this.element);11924}11925}1192611927//normalize the height of elements in the row11928normalizeHeight(){11929this.setHeight(this.element.clientHeight);11930}1193111932initialize(force){11933if(!this.initialized || force){11934this.normalizeHeight();11935this.initialized = true;11936}11937}1193811939reinitialize(){11940this.initialized = false;11941this.height = 0;1194211943if(Helpers.elVisible(this.element)){11944this.initialize(true);11945}11946}1194711948setHeight(height){11949if(this.height != height){11950this.height = height;11951this.outerHeight = this.element.offsetHeight;11952}11953}1195411955//return rows outer height11956getHeight(){11957return this.outerHeight;11958}1195911960getGroup(){11961return this;11962}1196311964reinitializeHeight(){}1196511966calcHeight(){}1196711968setCellHeight(){}1196911970clearCellHeight(){}1197111972deinitializeHeight(){}1197311974rendered(){}1197511976//////////////// Object Generation /////////////////11977getComponent(){11978if(!this.component){11979this.component = new GroupComponent(this);11980}1198111982return this.component;11983}11984}1198511986class GroupRows extends Module{1198711988constructor(table){11989super(table);1199011991this.groupIDLookups = false; //enable table grouping and set field to group by11992this.startOpen = [function(){return false;}]; //starting state of group11993this.headerGenerator = [function(){return "";}];11994this.groupList = []; //ordered list of groups11995this.allowedValues = false;11996this.groups = {}; //hold row groups1199711998this.displayHandler = this.getRows.bind(this);1199912000this.blockRedraw = false;1200112002//register table options12003this.registerTableOption("groupBy", false); //enable table grouping and set field to group by12004this.registerTableOption("groupStartOpen", true); //starting state of group12005this.registerTableOption("groupValues", false);12006this.registerTableOption("groupUpdateOnCellEdit", false);12007this.registerTableOption("groupHeader", false); //header generation function12008this.registerTableOption("groupHeaderPrint", null);12009this.registerTableOption("groupHeaderClipboard", null);12010this.registerTableOption("groupHeaderHtmlOutput", null);12011this.registerTableOption("groupHeaderDownload", null);12012this.registerTableOption("groupToggleElement", "arrow");12013this.registerTableOption("groupClosedShowCalcs", false);1201412015//register table functions12016this.registerTableFunction("setGroupBy", this.setGroupBy.bind(this));12017this.registerTableFunction("setGroupValues", this.setGroupValues.bind(this));12018this.registerTableFunction("setGroupStartOpen", this.setGroupStartOpen.bind(this));12019this.registerTableFunction("setGroupHeader", this.setGroupHeader.bind(this));12020this.registerTableFunction("getGroups", this.userGetGroups.bind(this));12021this.registerTableFunction("getGroupedData", this.userGetGroupedData.bind(this));1202212023//register component functions12024this.registerComponentFunction("row", "getGroup", this.rowGetGroup.bind(this));12025}1202612027//initialize group configuration12028initialize(){12029this.subscribe("table-destroy", this._blockRedrawing.bind(this));12030this.subscribe("rows-wipe", this._blockRedrawing.bind(this));12031this.subscribe("rows-wiped", this._restore_redrawing.bind(this));1203212033if(this.table.options.groupBy){12034if(this.table.options.groupUpdateOnCellEdit){12035this.subscribe("cell-value-updated", this.cellUpdated.bind(this));12036this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);12037}1203812039this.subscribe("table-built", this.configureGroupSetup.bind(this));1204012041this.subscribe("row-deleting", this.rowDeleting.bind(this));12042this.subscribe("row-deleted", this.rowsUpdated.bind(this));12043this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));12044this.subscribe("rows-wipe", this.wipe.bind(this));12045this.subscribe("rows-added", this.rowsUpdated.bind(this));12046this.subscribe("row-moving", this.rowMoving.bind(this));12047this.subscribe("row-adding-index", this.rowAddingIndex.bind(this));1204812049this.subscribe("rows-sample", this.rowSample.bind(this));1205012051this.subscribe("render-virtual-fill", this.virtualRenderFill.bind(this));1205212053this.registerDisplayHandler(this.displayHandler, 20);1205412055this.initialized = true;12056}12057}1205812059_blockRedrawing(){12060this.blockRedraw = true;12061}1206212063_restore_redrawing(){12064this.blockRedraw = false;12065}1206612067configureGroupSetup(){12068if(this.table.options.groupBy){12069var groupBy = this.table.options.groupBy,12070startOpen = this.table.options.groupStartOpen,12071groupHeader = this.table.options.groupHeader;1207212073this.allowedValues = this.table.options.groupValues;1207412075if(Array.isArray(groupBy) && Array.isArray(groupHeader) && groupBy.length > groupHeader.length){12076console.warn("Error creating group headers, groupHeader array is shorter than groupBy array");12077}1207812079this.headerGenerator = [function(){return "";}];12080this.startOpen = [function(){return false;}]; //starting state of group1208112082this.langBind("groups|item", (langValue, lang) => {12083this.headerGenerator[0] = (value, count, data) => { //header layout function12084return (typeof value === "undefined" ? "" : value) + "<span>(" + count + " " + ((count === 1) ? langValue : lang.groups.items) + ")</span>";12085};12086});1208712088this.groupIDLookups = [];1208912090if(groupBy){12091if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "table" && this.table.options.columnCalcs != "both"){12092this.table.modules.columnCalcs.removeCalcs();12093}12094}else {12095if(this.table.modExists("columnCalcs") && this.table.options.columnCalcs != "group"){1209612097var cols = this.table.columnManager.getRealColumns();1209812099cols.forEach((col) => {12100if(col.definition.topCalc){12101this.table.modules.columnCalcs.initializeTopRow();12102}1210312104if(col.definition.bottomCalc){12105this.table.modules.columnCalcs.initializeBottomRow();12106}12107});12108}12109}1211012111if(!Array.isArray(groupBy)){12112groupBy = [groupBy];12113}1211412115groupBy.forEach((group, i) => {12116var lookupFunc, column;1211712118if(typeof group == "function"){12119lookupFunc = group;12120}else {12121column = this.table.columnManager.getColumnByField(group);1212212123if(column){12124lookupFunc = function(data){12125return column.getFieldValue(data);12126};12127}else {12128lookupFunc = function(data){12129return data[group];12130};12131}12132}1213312134this.groupIDLookups.push({12135field: typeof group === "function" ? false : group,12136func:lookupFunc,12137values:this.allowedValues ? this.allowedValues[i] : false,12138});12139});1214012141if(startOpen){12142if(!Array.isArray(startOpen)){12143startOpen = [startOpen];12144}1214512146startOpen.forEach((level) => {12147});1214812149this.startOpen = startOpen;12150}1215112152if(groupHeader){12153this.headerGenerator = Array.isArray(groupHeader) ? groupHeader : [groupHeader];12154}12155}else {12156this.groupList = [];12157this.groups = {};12158}12159}1216012161rowSample(rows, prevValue){12162if(this.table.options.groupBy){12163var group = this.getGroups(false)[0];1216412165prevValue.push(group.getRows(false)[0]);12166}1216712168return prevValue;12169}1217012171virtualRenderFill(){12172var el = this.table.rowManager.tableElement;12173var rows = this.table.rowManager.getVisibleRows();1217412175if(this.table.options.groupBy){12176rows = rows.filter((row) => {12177return row.type !== "group";12178});1217912180el.style.minWidth = !rows.length ? this.table.columnManager.getWidth() + "px" : "";12181}else {12182return rows;12183}12184}1218512186rowAddingIndex(row, index, top){12187if(this.table.options.groupBy){12188this.assignRowToGroup(row);1218912190var groupRows = row.modules.group.rows;1219112192if(groupRows.length > 1){12193if(!index || (index && groupRows.indexOf(index) == -1)){12194if(top){12195if(groupRows[0] !== row){12196index = groupRows[0];12197this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);12198}12199}else {12200if(groupRows[groupRows.length -1] !== row){12201index = groupRows[groupRows.length -1];12202this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);12203}12204}12205}else {12206this.table.rowManager.moveRowInArray(row.modules.group.rows, row, index, !top);12207}12208}1220912210return index;12211}12212}1221312214trackChanges(){12215this.dispatch("group-changed");12216}1221712218///////////////////////////////////12219///////// Table Functions /////////12220///////////////////////////////////1222112222setGroupBy(groups){12223this.table.options.groupBy = groups;1222412225if(!this.initialized){12226this.initialize();12227}1222812229this.configureGroupSetup();1223012231if(!groups && this.table.modExists("columnCalcs") && this.table.options.columnCalcs === true){12232this.table.modules.columnCalcs.reinitializeCalcs();12233}1223412235this.refreshData();1223612237this.trackChanges();12238}1223912240setGroupValues(groupValues){12241this.table.options.groupValues = groupValues;12242this.configureGroupSetup();12243this.refreshData();1224412245this.trackChanges();12246}1224712248setGroupStartOpen(values){12249this.table.options.groupStartOpen = values;12250this.configureGroupSetup();1225112252if(this.table.options.groupBy){12253this.refreshData();1225412255this.trackChanges();12256}else {12257console.warn("Grouping Update - cant refresh view, no groups have been set");12258}12259}1226012261setGroupHeader(values){12262this.table.options.groupHeader = values;12263this.configureGroupSetup();1226412265if(this.table.options.groupBy){12266this.refreshData();1226712268this.trackChanges();12269}else {12270console.warn("Grouping Update - cant refresh view, no groups have been set");12271}12272}1227312274userGetGroups(values){12275return this.getGroups(true);12276}1227712278// get grouped table data in the same format as getData()12279userGetGroupedData(){12280return this.table.options.groupBy ? this.getGroupedData() : this.getData();12281}122821228312284///////////////////////////////////////12285///////// Component Functions /////////12286///////////////////////////////////////1228712288rowGetGroup(row){12289return row.modules.group ? row.modules.group.getComponent() : false;12290}1229112292///////////////////////////////////12293///////// Internal Logic //////////12294///////////////////////////////////1229512296rowMoving(from, to, after){12297if(this.table.options.groupBy){12298if(!after && to instanceof Group){12299to = this.table.rowManager.prevDisplayRow(from) || to;12300}1230112302var toGroup = to instanceof Group ? to : to.modules.group;12303var fromGroup = from instanceof Group ? from : from.modules.group;1230412305if(toGroup === fromGroup){12306this.table.rowManager.moveRowInArray(toGroup.rows, from, to, after);12307}else {12308if(fromGroup){12309fromGroup.removeRow(from);12310}1231112312toGroup.insertRow(from, to, after);12313}12314}12315}123161231712318rowDeleting(row){12319//remove from group12320if(this.table.options.groupBy && row.modules.group){12321row.modules.group.removeRow(row);12322}12323}1232412325rowsUpdated(row){12326if(this.table.options.groupBy){12327this.updateGroupRows(true);12328}12329}1233012331cellUpdated(cell){12332if(this.table.options.groupBy){12333this.reassignRowToGroup(cell.row);12334}12335}1233612337//return appropriate rows with group headers12338getRows(rows){12339if(this.table.options.groupBy && this.groupIDLookups.length){1234012341this.dispatchExternal("dataGrouping");1234212343this.generateGroups(rows);1234412345if(this.subscribedExternal("dataGrouped")){12346this.dispatchExternal("dataGrouped", this.getGroups(true));12347}1234812349return this.updateGroupRows();1235012351}else {12352return rows.slice(0);12353}12354}1235512356getGroups(component){12357var groupComponents = [];1235812359this.groupList.forEach(function(group){12360groupComponents.push(component ? group.getComponent() : group);12361});1236212363return groupComponents;12364}1236512366getChildGroups(group){12367var groupComponents = [];1236812369if(!group){12370group = this;12371}1237212373group.groupList.forEach((child) => {12374if(child.groupList.length){12375groupComponents = groupComponents.concat(this.getChildGroups(child));12376}else {12377groupComponents.push(child);12378}12379});1238012381return groupComponents;12382}1238312384wipe(){12385if(this.table.options.groupBy){12386this.groupList.forEach(function(group){12387group.wipe();12388});1238912390this.groupList = [];12391this.groups = {};12392}12393}1239412395pullGroupListData(groupList) {12396var groupListData = [];1239712398groupList.forEach((group) => {12399var groupHeader = {};12400groupHeader.level = 0;12401groupHeader.rowCount = 0;12402groupHeader.headerContent = "";12403var childData = [];1240412405if (group.hasSubGroups) {12406childData = this.pullGroupListData(group.groupList);1240712408groupHeader.level = group.level;12409groupHeader.rowCount = childData.length - group.groupList.length; // data length minus number of sub-headers12410groupHeader.headerContent = group.generator(group.key, groupHeader.rowCount, group.rows, group);1241112412groupListData.push(groupHeader);12413groupListData = groupListData.concat(childData);12414}1241512416else {12417groupHeader.level = group.level;12418groupHeader.headerContent = group.generator(group.key, group.rows.length, group.rows, group);12419groupHeader.rowCount = group.getRows().length;1242012421groupListData.push(groupHeader);1242212423group.getRows().forEach((row) => {12424groupListData.push(row.getData("data"));12425});12426}12427});1242812429return groupListData;12430}1243112432getGroupedData(){1243312434return this.pullGroupListData(this.groupList);12435}1243612437getRowGroup(row){12438var match = false;1243912440if(this.options("dataTree")){12441row = this.table.modules.dataTree.getTreeParentRoot(row);12442}1244312444this.groupList.forEach((group) => {12445var result = group.getRowGroup(row);1244612447if(result){12448match = result;12449}12450});1245112452return match;12453}1245412455countGroups(){12456return this.groupList.length;12457}1245812459generateGroups(rows){12460var oldGroups = this.groups;1246112462this.groups = {};12463this.groupList = [];1246412465if(this.allowedValues && this.allowedValues[0]){12466this.allowedValues[0].forEach((value) => {12467this.createGroup(value, 0, oldGroups);12468});1246912470rows.forEach((row) => {12471this.assignRowToExistingGroup(row, oldGroups);12472});12473}else {12474rows.forEach((row) => {12475this.assignRowToGroup(row, oldGroups);12476});12477}1247812479Object.values(oldGroups).forEach((group) => {12480group.wipe(true);12481});12482}124831248412485createGroup(groupID, level, oldGroups){12486var groupKey = level + "_" + groupID,12487group;1248812489oldGroups = oldGroups || [];1249012491group = new Group(this, false, level, groupID, this.groupIDLookups[0].field, this.headerGenerator[0], oldGroups[groupKey]);1249212493this.groups[groupKey] = group;12494this.groupList.push(group);12495}1249612497assignRowToExistingGroup(row, oldGroups){12498var groupID = this.groupIDLookups[0].func(row.getData()),12499groupKey = "0_" + groupID;1250012501if(this.groups[groupKey]){12502this.groups[groupKey].addRow(row);12503}12504}1250512506assignRowToGroup(row, oldGroups){12507var groupID = this.groupIDLookups[0].func(row.getData()),12508newGroupNeeded = !this.groups["0_" + groupID];1250912510if(newGroupNeeded){12511this.createGroup(groupID, 0, oldGroups);12512}1251312514this.groups["0_" + groupID].addRow(row);1251512516return !newGroupNeeded;12517}1251812519reassignRowToGroup(row){12520if(row.type === "row"){12521var oldRowGroup = row.modules.group,12522oldGroupPath = oldRowGroup.getPath(),12523newGroupPath = this.getExpectedPath(row),12524samePath;1252512526// figure out if new group path is the same as old group path12527samePath = (oldGroupPath.length == newGroupPath.length) && oldGroupPath.every((element, index) => {12528return element === newGroupPath[index];12529});1253012531// refresh if they new path and old path aren't the same (aka the row's groupings have changed)12532if(!samePath) {12533oldRowGroup.removeRow(row);12534this.assignRowToGroup(row, this.groups);12535this.refreshData(true);12536}12537}12538}1253912540getExpectedPath(row) {12541var groupPath = [], rowData = row.getData();1254212543this.groupIDLookups.forEach((groupId) => {12544groupPath.push(groupId.func(rowData));12545});1254612547return groupPath;12548}1254912550updateGroupRows(force){12551var output = [];1255212553if(!this.blockRedraw){12554this.groupList.forEach((group) => {12555output = output.concat(group.getHeadersAndRows());12556});1255712558if(force){12559this.refreshData(true);12560}12561}1256212563return output;12564}1256512566scrollHeaders(left){12567if(this.table.options.groupBy){12568if(this.table.options.renderHorizontal === "virtual"){12569left -= this.table.columnManager.renderer.vDomPadLeft;12570}1257112572left = left + "px";1257312574this.groupList.forEach((group) => {12575group.scrollHeader(left);12576});12577}12578}1257912580removeGroup(group){12581var groupKey = group.level + "_" + group.key,12582index;1258312584if(this.groups[groupKey]){12585delete this.groups[groupKey];1258612587index = this.groupList.indexOf(group);1258812589if(index > -1){12590this.groupList.splice(index, 1);12591}12592}12593}1259412595checkBasicModeGroupHeaderWidth(){12596var element = this.table.rowManager.tableElement,12597onlyGroupHeaders = true;1259812599this.table.rowManager.getDisplayRows().forEach((row, index) =>{12600this.table.rowManager.styleRow(row, index);12601element.appendChild(row.getElement());12602row.initialize(true);1260312604if(row.type !== "group"){12605onlyGroupHeaders = false;12606}12607});1260812609if(onlyGroupHeaders){12610element.style.minWidth = this.table.columnManager.getWidth() + "px";12611}else {12612element.style.minWidth = "";12613}12614}1261512616}1261712618GroupRows.moduleName = "groupRows";1261912620var defaultUndoers = {12621cellEdit: function(action){12622action.component.setValueProcessData(action.data.oldValue);12623action.component.cellRendered();12624},1262512626rowAdd: function(action){12627action.component.deleteActual();12628},1262912630rowDelete: function(action){12631var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);1263212633if(this.table.options.groupBy && this.table.modExists("groupRows")){12634this.table.modules.groupRows.updateGroupRows(true);12635}1263612637this._rebindRow(action.component, newRow);12638},1263912640rowMove: function(action){12641var after = (action.data.posFrom - action.data.posTo) > 0;1264212643this.table.rowManager.moveRowActual(action.component, this.table.rowManager.getRowFromPosition(action.data.posFrom), after);1264412645this.table.rowManager.regenerateRowPositions();12646this.table.rowManager.reRenderInPosition();12647},12648};1264912650var defaultRedoers = {12651cellEdit: function(action){12652action.component.setValueProcessData(action.data.newValue);12653action.component.cellRendered();12654},1265512656rowAdd: function(action){12657var newRow = this.table.rowManager.addRowActual(action.data.data, action.data.pos, action.data.index);1265812659if(this.table.options.groupBy && this.table.modExists("groupRows")){12660this.table.modules.groupRows.updateGroupRows(true);12661}1266212663this._rebindRow(action.component, newRow);12664},1266512666rowDelete:function(action){12667action.component.deleteActual();12668},1266912670rowMove: function(action){12671this.table.rowManager.moveRowActual(action.component, this.table.rowManager.getRowFromPosition(action.data.posTo), action.data.after);1267212673this.table.rowManager.regenerateRowPositions();12674this.table.rowManager.reRenderInPosition();12675},12676};1267712678class History extends Module{1267912680constructor(table){12681super(table);1268212683this.history = [];12684this.index = -1;1268512686this.registerTableOption("history", false); //enable edit history12687}1268812689initialize(){12690if(this.table.options.history){12691this.subscribe("cell-value-updated", this.cellUpdated.bind(this));12692this.subscribe("cell-delete", this.clearComponentHistory.bind(this));12693this.subscribe("row-delete", this.rowDeleted.bind(this));12694this.subscribe("rows-wipe", this.clear.bind(this));12695this.subscribe("row-added", this.rowAdded.bind(this));12696this.subscribe("row-move", this.rowMoved.bind(this));12697}1269812699this.registerTableFunction("undo", this.undo.bind(this));12700this.registerTableFunction("redo", this.redo.bind(this));12701this.registerTableFunction("getHistoryUndoSize", this.getHistoryUndoSize.bind(this));12702this.registerTableFunction("getHistoryRedoSize", this.getHistoryRedoSize.bind(this));12703this.registerTableFunction("clearHistory", this.clear.bind(this));12704}1270512706rowMoved(from, to, after){12707this.action("rowMove", from, {posFrom:from.getPosition(), posTo:to.getPosition(), to:to, after:after});12708}1270912710rowAdded(row, data, pos, index){12711this.action("rowAdd", row, {data:data, pos:pos, index:index});12712}1271312714rowDeleted(row){12715var index, rows;1271612717if(this.table.options.groupBy){1271812719rows = row.getComponent().getGroup()._getSelf().rows;12720index = rows.indexOf(row);1272112722if(index){12723index = rows[index-1];12724}12725}else {12726index = row.table.rowManager.getRowIndex(row);1272712728if(index){12729index = row.table.rowManager.rows[index-1];12730}12731}1273212733this.action("rowDelete", row, {data:row.getData(), pos:!index, index:index});12734}1273512736cellUpdated(cell){12737this.action("cellEdit", cell, {oldValue:cell.oldValue, newValue:cell.value});12738}1273912740clear(){12741this.history = [];12742this.index = -1;12743}1274412745action(type, component, data){12746this.history = this.history.slice(0, this.index + 1);1274712748this.history.push({12749type:type,12750component:component,12751data:data,12752});1275312754this.index ++;12755}1275612757getHistoryUndoSize(){12758return this.index + 1;12759}1276012761getHistoryRedoSize(){12762return this.history.length - (this.index + 1);12763}1276412765clearComponentHistory(component){12766var index = this.history.findIndex(function(item){12767return item.component === component;12768});1276912770if(index > -1){12771this.history.splice(index, 1);12772if(index <= this.index){12773this.index--;12774}1277512776this.clearComponentHistory(component);12777}12778}1277912780undo(){12781if(this.index > -1){12782let action = this.history[this.index];1278312784History.undoers[action.type].call(this, action);1278512786this.index--;1278712788this.dispatchExternal("historyUndo", action.type, action.component.getComponent(), action.data);1278912790return true;12791}else {12792console.warn("History Undo Error - No more history to undo");12793return false;12794}12795}1279612797redo(){12798if(this.history.length-1 > this.index){1279912800this.index++;1280112802let action = this.history[this.index];1280312804History.redoers[action.type].call(this, action);1280512806this.dispatchExternal("historyRedo", action.type, action.component.getComponent(), action.data);1280712808return true;12809}else {12810console.warn("History Redo Error - No more history to redo");12811return false;12812}12813}1281412815//rebind rows to new element after deletion12816_rebindRow(oldRow, newRow){12817this.history.forEach(function(action){12818if(action.component instanceof Row){12819if(action.component === oldRow){12820action.component = newRow;12821}12822}else if(action.component instanceof Cell){12823if(action.component.row === oldRow){12824var field = action.component.column.getField();1282512826if(field){12827action.component = newRow.getCell(field);12828}1282912830}12831}12832});12833}12834}1283512836History.moduleName = "history";1283712838//load defaults12839History.undoers = defaultUndoers;12840History.redoers = defaultRedoers;1284112842class HtmlTableImport extends Module{1284312844constructor(table){12845super(table);1284612847this.fieldIndex = [];12848this.hasIndex = false;12849}1285012851initialize(){12852this.tableElementCheck();12853}1285412855tableElementCheck(){12856if(this.table.originalElement && this.table.originalElement.tagName === "TABLE"){12857if(this.table.originalElement.childNodes.length){12858this.parseTable();12859}else {12860console.warn("Unable to parse data from empty table tag, Tabulator should be initialized on a div tag unless importing data from a table element.");12861}12862}12863}1286412865parseTable(){12866var element = this.table.originalElement,12867options = this.table.options,12868headers = element.getElementsByTagName("th"),12869rows = element.getElementsByTagName("tbody")[0],12870data = [];1287112872this.hasIndex = false;1287312874this.dispatchExternal("htmlImporting");1287512876rows = rows ? rows.getElementsByTagName("tr") : [];1287712878//check for Tabulator inline options12879this._extractOptions(element, options);1288012881if(headers.length){12882this._extractHeaders(headers, rows);12883}else {12884this._generateBlankHeaders(headers, rows);12885}1288612887//iterate through table rows and build data set12888for(var index = 0; index < rows.length; index++){12889var row = rows[index],12890cells = row.getElementsByTagName("td"),12891item = {};1289212893//create index if the don't exist in table12894if(!this.hasIndex){12895item[options.index] = index;12896}1289712898for(var i = 0; i < cells.length; i++){12899var cell = cells[i];12900if(typeof this.fieldIndex[i] !== "undefined"){12901item[this.fieldIndex[i]] = cell.innerHTML;12902}12903}1290412905//add row data to item12906data.push(item);12907}1290812909options.data = data;1291012911this.dispatchExternal("htmlImported");12912}1291312914//extract tabulator attribute options12915_extractOptions(element, options, defaultOptions){12916var attributes = element.attributes;12917var optionsArr = defaultOptions ? Object.keys(defaultOptions) : Object.keys(options);12918var optionsList = {};1291912920optionsArr.forEach((item) => {12921optionsList[item.toLowerCase()] = item;12922});1292312924for(var index in attributes){12925var attrib = attributes[index];12926var name;1292712928if(attrib && typeof attrib == "object" && attrib.name && attrib.name.indexOf("tabulator-") === 0){12929name = attrib.name.replace("tabulator-", "");1293012931if(typeof optionsList[name] !== "undefined"){12932options[optionsList[name]] = this._attribValue(attrib.value);12933}12934}12935}12936}1293712938//get value of attribute12939_attribValue(value){12940if(value === "true"){12941return true;12942}1294312944if(value === "false"){12945return false;12946}1294712948return value;12949}1295012951//find column if it has already been defined12952_findCol(title){12953var match = this.table.options.columns.find((column) => {12954return column.title === title;12955});1295612957return match || false;12958}1295912960//extract column from headers12961_extractHeaders(headers, rows){12962for(var index = 0; index < headers.length; index++){12963var header = headers[index],12964exists = false,12965col = this._findCol(header.textContent),12966width;1296712968if(col){12969exists = true;12970}else {12971col = {title:header.textContent.trim()};12972}1297312974if(!col.field) {12975col.field = header.textContent.trim().toLowerCase().replaceAll(" ", "_");12976}1297712978width = header.getAttribute("width");1297912980if(width && !col.width) {12981col.width = width;12982}1298312984//check for Tabulator inline options12985this._extractOptions(header, col, this.table.columnManager.optionsList.registeredDefaults);1298612987this.fieldIndex[index] = col.field;1298812989if(col.field == this.table.options.index){12990this.hasIndex = true;12991}1299212993if(!exists){12994this.table.options.columns.push(col);12995}1299612997}12998}1299913000//generate blank headers13001_generateBlankHeaders(headers, rows){13002for(var index = 0; index < headers.length; index++){13003var header = headers[index],13004col = {title:"", field:"col" + index};1300513006this.fieldIndex[index] = col.field;1300713008var width = header.getAttribute("width");1300913010if(width){13011col.width = width;13012}1301313014this.table.options.columns.push(col);13015}13016}13017}1301813019HtmlTableImport.moduleName = "htmlTableImport";1302013021function csvImporter(input){13022var data = [],13023row = 0,13024col = 0,13025inQuote = false;1302613027//Iterate over each character13028for (let index = 0; index < input.length; index++) {13029let char = input[index],13030nextChar = input[index+1];1303113032//Initialize empty row13033if(!data[row]){13034data[row] = [];13035}1303613037//Initialize empty column13038if(!data[row][col]){13039data[row][col] = "";13040}1304113042//Handle quotation mark inside string13043if (char == '"' && inQuote && nextChar == '"') {13044data[row][col] += char;13045index++;13046continue;13047}1304813049//Begin / End Quote13050if (char == '"') {13051inQuote = !inQuote;13052continue;13053}1305413055//Next column (if not in quote)13056if (char == ',' && !inQuote) {13057col++;13058continue;13059}1306013061//New row if new line and not in quote (CRLF)13062if (char == '\r' && nextChar == '\n' && !inQuote) {13063col = 0;13064row++;13065index++;13066continue;13067}1306813069//New row if new line and not in quote (CR or LF)13070if ((char == '\r' || char == '\n') && !inQuote) {13071col = 0;13072row++;13073continue;13074}1307513076//Normal Character, append to column13077data[row][col] += char;13078}1307913080return data;13081}1308213083function json$1(input){13084try {13085return JSON.parse(input);13086} catch(e) {13087console.warn("JSON Import Error - File contents is invalid JSON", e);13088return Promise.reject();13089}13090}1309113092function arrayImporter(input){13093return input;13094}1309513096var defaultImporters = {13097csv:csvImporter,13098json:json$1,13099array:arrayImporter,13100};1310113102class Import extends Module{1310313104constructor(table){13105super(table);1310613107this.registerTableOption("importFormat");13108this.registerTableOption("importReader", "text");13109}1311013111initialize(){13112this.registerTableFunction("import", this.importFromFile.bind(this));1311313114if(this.table.options.importFormat){13115this.subscribe("data-loading", this.loadDataCheck.bind(this), 10);13116this.subscribe("data-load", this.loadData.bind(this), 10);13117}13118}1311913120loadDataCheck(data){13121return this.table.options.importFormat && (typeof data === "string" || (Array.isArray(data) && data.length && Array.isArray(data)));13122}1312313124loadData(data, params, config, silent, previousData){13125return this.importData(this.lookupImporter(), data)13126.then(this.structureData.bind(this))13127.catch((err) => {13128console.error("Import Error:", err || "Unable to import data");13129return Promise.reject(err);13130});13131}1313213133lookupImporter(importFormat){13134var importer;1313513136if(!importFormat){13137importFormat = this.table.options.importFormat;13138}1313913140if(typeof importFormat === "string"){13141importer = Import.importers[importFormat];13142}else {13143importer = importFormat;13144}1314513146if(!importer){13147console.error("Import Error - Importer not found:", importFormat);13148}1314913150return importer;13151}1315213153importFromFile(importFormat, extension){13154var importer = this.lookupImporter(importFormat);1315513156if(importer){13157return this.pickFile(extension)13158.then(this.importData.bind(this, importer))13159.then(this.structureData.bind(this))13160.then(this.setData.bind(this))13161.catch((err) => {13162console.error("Import Error:", err || "Unable to import file");13163return Promise.reject(err);13164});13165}13166}1316713168pickFile(extensions){13169return new Promise((resolve, reject) => {13170var input = document.createElement("input");13171input.type = "file";13172input.accept = extensions;1317313174input.addEventListener("change", (e) => {13175var file = input.files[0],13176reader = new FileReader();1317713178switch(this.table.options.importReader){13179case "buffer":13180reader.readAsArrayBuffer(file);13181break;1318213183case "binary":13184reader.readAsBinaryString(file);13185break;1318613187case "url":13188reader.readAsDataURL(file);13189break;1319013191case "text":13192default:13193reader.readAsText(file);13194}1319513196reader.onload = (e) => {13197resolve(reader.result);13198};1319913200reader.onerror = (e) => {13201console.warn("File Load Error - Unable to read file");13202reject();13203};13204});1320513206input.click();13207});13208}1320913210importData(importer, fileContents){13211var data = importer.call(this.table, fileContents);1321213213if(data instanceof Promise){13214return data;13215}else {13216return data ? Promise.resolve(data) : Promise.reject();13217}13218}1321913220structureData(parsedData){13221var data = [];1322213223if(Array.isArray(parsedData) && parsedData.length && Array.isArray(parsedData[0])){13224if(this.table.options.autoColumns){13225data = this.structureArrayToObject(parsedData);13226}else {13227data = this.structureArrayToColumns(parsedData);13228}1322913230return data;13231}else {13232return parsedData;13233}13234}1323513236structureArrayToObject(parsedData){13237var columns = parsedData.shift();1323813239var data = parsedData.map((values) => {13240var row = {};1324113242columns.forEach((key, i) => {13243row[key] = values[i];13244});1324513246return row;13247});1324813249return data;13250}1325113252structureArrayToColumns(parsedData){13253var data = [],13254columns = this.table.getColumns();1325513256//remove first row if it is the column names13257if(columns[0] && parsedData[0][0]){13258if(columns[0].getDefinition().title === parsedData[0][0]){13259parsedData.shift();13260}13261}1326213263//convert row arrays to objects13264parsedData.forEach((rowData) => {13265var row = {};1326613267rowData.forEach((value, index) => {13268var column = columns[index];1326913270if(column){13271row[column.getField()] = value;13272}13273});1327413275data.push(row);13276});1327713278return data;13279}1328013281setData(data){13282return this.table.setData(data);13283}13284}1328513286Import.moduleName = "import";1328713288//load defaults13289Import.importers = defaultImporters;1329013291class Interaction extends Module{1329213293constructor(table){13294super(table);1329513296this.eventMap = {13297//row events13298rowClick:"row-click",13299rowDblClick:"row-dblclick",13300rowContext:"row-contextmenu",13301rowMouseEnter:"row-mouseenter",13302rowMouseLeave:"row-mouseleave",13303rowMouseOver:"row-mouseover",13304rowMouseOut:"row-mouseout",13305rowMouseMove:"row-mousemove",13306rowMouseDown:"row-mousedown",13307rowMouseUp:"row-mouseup",13308rowTap:"row",13309rowDblTap:"row",13310rowTapHold:"row",1331113312//cell events13313cellClick:"cell-click",13314cellDblClick:"cell-dblclick",13315cellContext:"cell-contextmenu",13316cellMouseEnter:"cell-mouseenter",13317cellMouseLeave:"cell-mouseleave",13318cellMouseOver:"cell-mouseover",13319cellMouseOut:"cell-mouseout",13320cellMouseMove:"cell-mousemove",13321cellMouseDown:"cell-mousedown",13322cellMouseUp:"cell-mouseup",13323cellTap:"cell",13324cellDblTap:"cell",13325cellTapHold:"cell",1332613327//column header events13328headerClick:"column-click",13329headerDblClick:"column-dblclick",13330headerContext:"column-contextmenu",13331headerMouseEnter:"column-mouseenter",13332headerMouseLeave:"column-mouseleave",13333headerMouseOver:"column-mouseover",13334headerMouseOut:"column-mouseout",13335headerMouseMove:"column-mousemove",13336headerMouseDown:"column-mousedown",13337headerMouseUp:"column-mouseup",13338headerTap:"column",13339headerDblTap:"column",13340headerTapHold:"column",1334113342//group header13343groupClick:"group-click",13344groupDblClick:"group-dblclick",13345groupContext:"group-contextmenu",13346groupMouseEnter:"group-mouseenter",13347groupMouseLeave:"group-mouseleave",13348groupMouseOver:"group-mouseover",13349groupMouseOut:"group-mouseout",13350groupMouseMove:"group-mousemove",13351groupMouseDown:"group-mousedown",13352groupMouseUp:"group-mouseup",13353groupTap:"group",13354groupDblTap:"group",13355groupTapHold:"group",13356};1335713358this.subscribers = {};1335913360this.touchSubscribers = {};1336113362this.columnSubscribers = {};1336313364this.touchWatchers = {13365row:{13366tap:null,13367tapDbl:null,13368tapHold:null,13369},13370cell:{13371tap:null,13372tapDbl:null,13373tapHold:null,13374},13375column:{13376tap:null,13377tapDbl:null,13378tapHold:null,13379},13380group:{13381tap:null,13382tapDbl:null,13383tapHold:null,13384}13385};1338613387this.registerColumnOption("headerClick");13388this.registerColumnOption("headerDblClick");13389this.registerColumnOption("headerContext");13390this.registerColumnOption("headerMouseEnter");13391this.registerColumnOption("headerMouseLeave");13392this.registerColumnOption("headerMouseOver");13393this.registerColumnOption("headerMouseOut");13394this.registerColumnOption("headerMouseMove");13395this.registerColumnOption("headerMouseDown");13396this.registerColumnOption("headerMouseUp");13397this.registerColumnOption("headerTap");13398this.registerColumnOption("headerDblTap");13399this.registerColumnOption("headerTapHold");1340013401this.registerColumnOption("cellClick");13402this.registerColumnOption("cellDblClick");13403this.registerColumnOption("cellContext");13404this.registerColumnOption("cellMouseEnter");13405this.registerColumnOption("cellMouseLeave");13406this.registerColumnOption("cellMouseOver");13407this.registerColumnOption("cellMouseOut");13408this.registerColumnOption("cellMouseMove");13409this.registerColumnOption("cellMouseDown");13410this.registerColumnOption("cellMouseUp");13411this.registerColumnOption("cellTap");13412this.registerColumnOption("cellDblTap");13413this.registerColumnOption("cellTapHold");1341413415}1341613417initialize(){13418this.initializeExternalEvents();1341913420this.subscribe("column-init", this.initializeColumn.bind(this));13421this.subscribe("cell-dblclick", this.cellContentsSelectionFixer.bind(this));13422this.subscribe("scroll-horizontal", this.clearTouchWatchers.bind(this));13423this.subscribe("scroll-vertical", this.clearTouchWatchers.bind(this));13424}1342513426clearTouchWatchers(){13427var types = Object.values(this.touchWatchers);1342813429types.forEach((type) => {13430for(let key in type){13431type[key] = null;13432}13433});13434}1343513436cellContentsSelectionFixer(e, cell){13437var range;1343813439if(this.table.modExists("edit")){13440if (this.table.modules.edit.currentCell === cell){13441return; //prevent instant selection of editor content13442}13443}1344413445e.preventDefault();1344613447try{13448if (document.selection) { // IE13449range = document.body.createTextRange();13450range.moveToElementText(cell.getElement());13451range.select();13452} else if (window.getSelection) {13453range = document.createRange();13454range.selectNode(cell.getElement());13455window.getSelection().removeAllRanges();13456window.getSelection().addRange(range);13457}13458}catch(e){}13459}1346013461initializeExternalEvents(){13462for(let key in this.eventMap){13463this.subscriptionChangeExternal(key, this.subscriptionChanged.bind(this, key));13464}13465}1346613467subscriptionChanged(key, added){13468if(added){13469if(!this.subscribers[key]){13470if(this.eventMap[key].includes("-")){13471this.subscribers[key] = this.handle.bind(this, key);13472this.subscribe(this.eventMap[key], this.subscribers[key]);13473}else {13474this.subscribeTouchEvents(key);13475}13476}13477}else {13478if(this.eventMap[key].includes("-")){13479if(this.subscribers[key] && !this.columnSubscribers[key] && !this.subscribedExternal(key)){13480this.unsubscribe(this.eventMap[key], this.subscribers[key]);13481delete this.subscribers[key];13482}13483}else {13484this.unsubscribeTouchEvents(key);13485}13486}13487}134881348913490subscribeTouchEvents(key){13491var type = this.eventMap[key];1349213493if(!this.touchSubscribers[type + "-touchstart"]){13494this.touchSubscribers[type + "-touchstart"] = this.handleTouch.bind(this, type, "start");13495this.touchSubscribers[type + "-touchend"] = this.handleTouch.bind(this, type, "end");1349613497this.subscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]);13498this.subscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]);13499}1350013501this.subscribers[key] = true;13502}1350313504unsubscribeTouchEvents(key){13505var noTouch = true,13506type = this.eventMap[key];1350713508if(this.subscribers[key] && !this.subscribedExternal(key)){13509delete this.subscribers[key];1351013511for(let i in this.eventMap){13512if(this.eventMap[i] === type){13513if(this.subscribers[i]){13514noTouch = false;13515}13516}13517}1351813519if(noTouch){13520this.unsubscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]);13521this.unsubscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]);1352213523delete this.touchSubscribers[type + "-touchstart"];13524delete this.touchSubscribers[type + "-touchend"];13525}13526}13527}1352813529initializeColumn(column){13530var def = column.definition;1353113532for(let key in this.eventMap){13533if(def[key]){13534this.subscriptionChanged(key, true);1353513536if(!this.columnSubscribers[key]){13537this.columnSubscribers[key] = [];13538}1353913540this.columnSubscribers[key].push(column);13541}13542}13543}1354413545handle(action, e, component){13546this.dispatchEvent(action, e, component);13547}1354813549handleTouch(type, action, e, component){13550var watchers = this.touchWatchers[type];1355113552if(type === "column"){13553type = "header";13554}1355513556switch(action){13557case "start":13558watchers.tap = true;1355913560clearTimeout(watchers.tapHold);1356113562watchers.tapHold = setTimeout(() => {13563clearTimeout(watchers.tapHold);13564watchers.tapHold = null;1356513566watchers.tap = null;13567clearTimeout(watchers.tapDbl);13568watchers.tapDbl = null;1356913570this.dispatchEvent(type + "TapHold", e, component);13571}, 1000);13572break;1357313574case "end":13575if(watchers.tap){1357613577watchers.tap = null;13578this.dispatchEvent(type + "Tap", e, component);13579}1358013581if(watchers.tapDbl){13582clearTimeout(watchers.tapDbl);13583watchers.tapDbl = null;1358413585this.dispatchEvent(type + "DblTap", e, component);13586}else {13587watchers.tapDbl = setTimeout(() => {13588clearTimeout(watchers.tapDbl);13589watchers.tapDbl = null;13590}, 300);13591}1359213593clearTimeout(watchers.tapHold);13594watchers.tapHold = null;13595break;13596}13597}1359813599dispatchEvent(action, e, component){13600var componentObj = component.getComponent(),13601callback;1360213603if(this.columnSubscribers[action]){1360413605if(component instanceof Cell){13606callback = component.column.definition[action];13607}else if(component instanceof Column){13608callback = component.definition[action];13609}1361013611if(callback){13612callback(e, componentObj);13613}13614}1361513616this.dispatchExternal(action, e, componentObj);13617}13618}1361913620Interaction.moduleName = "interaction";1362113622var defaultBindings = {13623navPrev:"shift + 9",13624navNext:9,13625navUp:38,13626navDown:40,13627scrollPageUp:33,13628scrollPageDown:34,13629scrollToStart:36,13630scrollToEnd:35,13631undo:["ctrl + 90", "meta + 90"],13632redo:["ctrl + 89", "meta + 89"],13633copyToClipboard:["ctrl + 67", "meta + 67"],13634};1363513636var defaultActions = {13637keyBlock:function(e){13638e.stopPropagation();13639e.preventDefault();13640},13641scrollPageUp:function(e){13642var rowManager = this.table.rowManager,13643newPos = rowManager.scrollTop - rowManager.element.clientHeight;1364413645e.preventDefault();1364613647if(rowManager.displayRowsCount){13648if(newPos >= 0){13649rowManager.element.scrollTop = newPos;13650}else {13651rowManager.scrollToRow(rowManager.getDisplayRows()[0]);13652}13653}1365413655this.table.element.focus();13656},13657scrollPageDown:function(e){13658var rowManager = this.table.rowManager,13659newPos = rowManager.scrollTop + rowManager.element.clientHeight,13660scrollMax = rowManager.element.scrollHeight;1366113662e.preventDefault();1366313664if(rowManager.displayRowsCount){13665if(newPos <= scrollMax){13666rowManager.element.scrollTop = newPos;13667}else {13668rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);13669}13670}1367113672this.table.element.focus();1367313674},13675scrollToStart:function(e){13676var rowManager = this.table.rowManager;1367713678e.preventDefault();1367913680if(rowManager.displayRowsCount){13681rowManager.scrollToRow(rowManager.getDisplayRows()[0]);13682}1368313684this.table.element.focus();13685},13686scrollToEnd:function(e){13687var rowManager = this.table.rowManager;1368813689e.preventDefault();1369013691if(rowManager.displayRowsCount){13692rowManager.scrollToRow(rowManager.getDisplayRows()[rowManager.displayRowsCount - 1]);13693}1369413695this.table.element.focus();13696},13697navPrev:function(e){13698this.dispatch("keybinding-nav-prev", e);13699},1370013701navNext:function(e){13702this.dispatch("keybinding-nav-next", e);13703},1370413705navLeft:function(e){13706this.dispatch("keybinding-nav-left", e);13707},1370813709navRight:function(e){13710this.dispatch("keybinding-nav-right", e);13711},1371213713navUp:function(e){13714this.dispatch("keybinding-nav-up", e);13715},1371613717navDown:function(e){13718this.dispatch("keybinding-nav-down", e);13719},1372013721undo:function(e){13722var cell = false;13723if(this.table.options.history && this.table.modExists("history") && this.table.modExists("edit")){1372413725cell = this.table.modules.edit.currentCell;1372613727if(!cell){13728e.preventDefault();13729this.table.modules.history.undo();13730}13731}13732},1373313734redo:function(e){13735var cell = false;13736if(this.table.options.history && this.table.modExists("history") && this.table.modExists("edit")){1373713738cell = this.table.modules.edit.currentCell;1373913740if(!cell){13741e.preventDefault();13742this.table.modules.history.redo();13743}13744}13745},1374613747copyToClipboard:function(e){13748if(!this.table.modules.edit.currentCell){13749if(this.table.modExists("clipboard", true)){13750this.table.modules.clipboard.copy(false, true);13751}13752}13753},13754};1375513756class Keybindings extends Module{1375713758constructor(table){13759super(table);1376013761this.watchKeys = null;13762this.pressedKeys = null;13763this.keyupBinding = false;13764this.keydownBinding = false;1376513766this.registerTableOption("keybindings", {}); //array for keybindings13767this.registerTableOption("tabEndNewRow", false); //create new row when tab to end of table13768}1376913770initialize(){13771var bindings = this.table.options.keybindings,13772mergedBindings = {};1377313774this.watchKeys = {};13775this.pressedKeys = [];1377613777if(bindings !== false){13778Object.assign(mergedBindings, Keybindings.bindings);13779Object.assign(mergedBindings, bindings);1378013781this.mapBindings(mergedBindings);13782this.bindEvents();13783}1378413785this.subscribe("table-destroy", this.clearBindings.bind(this));13786}1378713788mapBindings(bindings){13789for(let key in bindings){13790if(Keybindings.actions[key]){13791if(bindings[key]){13792if(typeof bindings[key] !== "object"){13793bindings[key] = [bindings[key]];13794}1379513796bindings[key].forEach((binding) => {13797var bindingList = Array.isArray(binding) ? binding : [binding];1379813799bindingList.forEach((item) => {13800this.mapBinding(key, item);13801});13802});13803}13804}else {13805console.warn("Key Binding Error - no such action:", key);13806}13807}13808}1380913810mapBinding(action, symbolsList){13811var binding = {13812action: Keybindings.actions[action],13813keys: [],13814ctrl: false,13815shift: false,13816meta: false,13817};1381813819var symbols = symbolsList.toString().toLowerCase().split(" ").join("").split("+");1382013821symbols.forEach((symbol) => {13822switch(symbol){13823case "ctrl":13824binding.ctrl = true;13825break;1382613827case "shift":13828binding.shift = true;13829break;1383013831case "meta":13832binding.meta = true;13833break;1383413835default:13836symbol = isNaN(symbol) ? symbol.toUpperCase().charCodeAt(0) : parseInt(symbol);13837binding.keys.push(symbol);1383813839if(!this.watchKeys[symbol]){13840this.watchKeys[symbol] = [];13841}1384213843this.watchKeys[symbol].push(binding);13844}13845});13846}1384713848bindEvents(){13849var self = this;1385013851this.keyupBinding = function(e){13852var code = e.keyCode;13853var bindings = self.watchKeys[code];1385413855if(bindings){1385613857self.pressedKeys.push(code);1385813859bindings.forEach(function(binding){13860self.checkBinding(e, binding);13861});13862}13863};1386413865this.keydownBinding = function(e){13866var code = e.keyCode;13867var bindings = self.watchKeys[code];1386813869if(bindings){1387013871var index = self.pressedKeys.indexOf(code);1387213873if(index > -1){13874self.pressedKeys.splice(index, 1);13875}13876}13877};1387813879this.table.element.addEventListener("keydown", this.keyupBinding);1388013881this.table.element.addEventListener("keyup", this.keydownBinding);13882}1388313884clearBindings(){13885if(this.keyupBinding){13886this.table.element.removeEventListener("keydown", this.keyupBinding);13887}1388813889if(this.keydownBinding){13890this.table.element.removeEventListener("keyup", this.keydownBinding);13891}13892}1389313894checkBinding(e, binding){13895var match = true;1389613897if(e.ctrlKey == binding.ctrl && e.shiftKey == binding.shift && e.metaKey == binding.meta){13898binding.keys.forEach((key) => {13899var index = this.pressedKeys.indexOf(key);1390013901if(index == -1){13902match = false;13903}13904});1390513906if(match){13907binding.action.call(this, e);13908}1390913910return true;13911}1391213913return false;13914}13915}1391613917Keybindings.moduleName = "keybindings";1391813919//load defaults13920Keybindings.bindings = defaultBindings;13921Keybindings.actions = defaultActions;1392213923class Menu extends Module{1392413925constructor(table){13926super(table);1392713928this.menuContainer = null;13929this.nestedMenuBlock = false;1393013931this.currentComponent = null;13932this.rootPopup = null;1393313934this.columnSubscribers = {};1393513936this.registerTableOption("menuContainer", undefined); //deprecated1393713938this.registerTableOption("rowContextMenu", false);13939this.registerTableOption("rowClickMenu", false);13940this.registerTableOption("rowDblClickMenu", false);13941this.registerTableOption("groupContextMenu", false);13942this.registerTableOption("groupClickMenu", false);13943this.registerTableOption("groupDblClickMenu", false);1394413945this.registerColumnOption("headerContextMenu");13946this.registerColumnOption("headerClickMenu");13947this.registerColumnOption("headerDblClickMenu");13948this.registerColumnOption("headerMenu");13949this.registerColumnOption("headerMenuIcon");13950this.registerColumnOption("contextMenu");13951this.registerColumnOption("clickMenu");13952this.registerColumnOption("dblClickMenu");1395313954}1395513956initialize(){13957this.deprecatedOptionsCheck();13958this.initializeRowWatchers();13959this.initializeGroupWatchers();1396013961this.subscribe("column-init", this.initializeColumn.bind(this));13962}1396313964deprecatedOptionsCheck(){13965if(!this.deprecationCheck("menuContainer", "popupContainer")){13966this.table.options.popupContainer = this.table.options.menuContainer;13967}13968}1396913970initializeRowWatchers(){13971if(this.table.options.rowContextMenu){13972this.subscribe("row-contextmenu", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));13973this.table.on("rowTapHold", this.loadMenuEvent.bind(this, this.table.options.rowContextMenu));13974}1397513976if(this.table.options.rowClickMenu){13977this.subscribe("row-click", this.loadMenuEvent.bind(this, this.table.options.rowClickMenu));13978}1397913980if(this.table.options.rowDblClickMenu){13981this.subscribe("row-dblclick", this.loadMenuEvent.bind(this, this.table.options.rowDblClickMenu));13982}13983}1398413985initializeGroupWatchers(){13986if(this.table.options.groupContextMenu){13987this.subscribe("group-contextmenu", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));13988this.table.on("groupTapHold", this.loadMenuEvent.bind(this, this.table.options.groupContextMenu));13989}1399013991if(this.table.options.groupClickMenu){13992this.subscribe("group-click", this.loadMenuEvent.bind(this, this.table.options.groupClickMenu));13993}1399413995if(this.table.options.groupDblClickMenu){13996this.subscribe("group-dblclick", this.loadMenuEvent.bind(this, this.table.options.groupDblClickMenu));13997}13998}1399914000initializeColumn(column){14001var def = column.definition;1400214003//handle column events14004if(def.headerContextMenu && !this.columnSubscribers.headerContextMenu){14005this.columnSubscribers.headerContextMenu = this.loadMenuTableColumnEvent.bind(this, "headerContextMenu");14006this.subscribe("column-contextmenu", this.columnSubscribers.headerContextMenu);14007this.table.on("headerTapHold", this.loadMenuTableColumnEvent.bind(this, "headerContextMenu"));14008}1400914010if(def.headerClickMenu && !this.columnSubscribers.headerClickMenu){14011this.columnSubscribers.headerClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerClickMenu");14012this.subscribe("column-click", this.columnSubscribers.headerClickMenu);14013}1401414015if(def.headerDblClickMenu && !this.columnSubscribers.headerDblClickMenu){14016this.columnSubscribers.headerDblClickMenu = this.loadMenuTableColumnEvent.bind(this, "headerDblClickMenu");14017this.subscribe("column-dblclick", this.columnSubscribers.headerDblClickMenu);14018}1401914020if(def.headerMenu){14021this.initializeColumnHeaderMenu(column);14022}1402314024//handle cell events14025if(def.contextMenu && !this.columnSubscribers.contextMenu){14026this.columnSubscribers.contextMenu = this.loadMenuTableCellEvent.bind(this, "contextMenu");14027this.subscribe("cell-contextmenu", this.columnSubscribers.contextMenu);14028this.table.on("cellTapHold", this.loadMenuTableCellEvent.bind(this, "contextMenu"));14029}1403014031if(def.clickMenu && !this.columnSubscribers.clickMenu){14032this.columnSubscribers.clickMenu = this.loadMenuTableCellEvent.bind(this, "clickMenu");14033this.subscribe("cell-click", this.columnSubscribers.clickMenu);14034}1403514036if(def.dblClickMenu && !this.columnSubscribers.dblClickMenu){14037this.columnSubscribers.dblClickMenu = this.loadMenuTableCellEvent.bind(this, "dblClickMenu");14038this.subscribe("cell-dblclick", this.columnSubscribers.dblClickMenu);14039}14040}1404114042initializeColumnHeaderMenu(column){14043var icon = column.definition.headerMenuIcon,14044headerMenuEl;1404514046headerMenuEl = document.createElement("span");14047headerMenuEl.classList.add("tabulator-header-popup-button");1404814049if(icon){14050if(typeof icon === "function"){14051icon = icon(column.getComponent());14052}1405314054if(icon instanceof HTMLElement){14055headerMenuEl.appendChild(icon);14056}else {14057headerMenuEl.innerHTML = icon;14058}14059}else {14060headerMenuEl.innerHTML = "⋮";14061}1406214063headerMenuEl.addEventListener("click", (e) => {14064e.stopPropagation();14065e.preventDefault();1406614067this.loadMenuEvent(column.definition.headerMenu, e, column);14068});1406914070column.titleElement.insertBefore(headerMenuEl, column.titleElement.firstChild);14071}1407214073loadMenuTableCellEvent(option, e, cell){14074if(cell._cell){14075cell = cell._cell;14076}1407714078if(cell.column.definition[option]){14079this.loadMenuEvent(cell.column.definition[option], e, cell);14080}14081}1408214083loadMenuTableColumnEvent(option, e, column){14084if(column._column){14085column = column._column;14086}1408714088if(column.definition[option]){14089this.loadMenuEvent(column.definition[option], e, column);14090}14091}1409214093loadMenuEvent(menu, e, component){14094if(component._group){14095component = component._group;14096}else if(component._row){14097component = component._row;14098}1409914100menu = typeof menu == "function" ? menu.call(this.table, e, component.getComponent()) : menu;1410114102this.loadMenu(e, component, menu);14103}1410414105loadMenu(e, component, menu, parentEl, parentPopup){14106var touch = !(e instanceof MouseEvent),14107menuEl = document.createElement("div"),14108popup;1410914110menuEl.classList.add("tabulator-menu");1411114112if(!touch){14113e.preventDefault();14114}1411514116//abort if no menu set14117if(!menu || !menu.length){14118return;14119}1412014121if(!parentEl){14122if(this.nestedMenuBlock){14123//abort if child menu already open14124if(this.rootPopup){14125return;14126}14127}else {14128this.nestedMenuBlock = setTimeout(() => {14129this.nestedMenuBlock = false;14130}, 100);14131}1413214133if(this.rootPopup){14134this.rootPopup.hide();14135}1413614137this.rootPopup = popup = this.popup(menuEl);1413814139}else {14140popup = parentPopup.child(menuEl);14141}1414214143menu.forEach((item) => {14144var itemEl = document.createElement("div"),14145label = item.label,14146disabled = item.disabled;1414714148if(item.separator){14149itemEl.classList.add("tabulator-menu-separator");14150}else {14151itemEl.classList.add("tabulator-menu-item");1415214153if(typeof label == "function"){14154label = label.call(this.table, component.getComponent());14155}1415614157if(label instanceof Node){14158itemEl.appendChild(label);14159}else {14160itemEl.innerHTML = label;14161}1416214163if(typeof disabled == "function"){14164disabled = disabled.call(this.table, component.getComponent());14165}1416614167if(disabled){14168itemEl.classList.add("tabulator-menu-item-disabled");14169itemEl.addEventListener("click", (e) => {14170e.stopPropagation();14171});14172}else {14173if(item.menu && item.menu.length){14174itemEl.addEventListener("click", (e) => {14175e.stopPropagation();14176this.loadMenu(e, component, item.menu, itemEl, popup);14177});14178}else {14179if(item.action){14180itemEl.addEventListener("click", (e) => {14181item.action(e, component.getComponent());14182});14183}14184}14185}1418614187if(item.menu && item.menu.length){14188itemEl.classList.add("tabulator-menu-item-submenu");14189}14190}1419114192menuEl.appendChild(itemEl);14193});1419414195menuEl.addEventListener("click", (e) => {14196if(this.rootPopup){14197this.rootPopup.hide();14198}14199});1420014201popup.show(parentEl || e);1420214203if(popup === this.rootPopup){14204this.rootPopup.hideOnBlur(() => {14205this.rootPopup = null;1420614207if(this.currentComponent){14208this.dispatchExternal("menuClosed", this.currentComponent.getComponent());14209this.currentComponent = null;14210}14211});1421214213this.currentComponent = component;1421414215this.dispatchExternal("menuOpened", component.getComponent());14216}14217}14218}1421914220Menu.moduleName = "menu";1422114222class MoveColumns extends Module{1422314224constructor(table){14225super(table);1422614227this.placeholderElement = this.createPlaceholderElement();14228this.hoverElement = false; //floating column header element14229this.checkTimeout = false; //click check timeout holder14230this.checkPeriod = 250; //period to wait on mousedown to consider this a move and not a click14231this.moving = false; //currently moving column14232this.toCol = false; //destination column14233this.toColAfter = false; //position of moving column relative to the destination column14234this.startX = 0; //starting position within header element14235this.autoScrollMargin = 40; //auto scroll on edge when within margin14236this.autoScrollStep = 5; //auto scroll distance in pixels14237this.autoScrollTimeout = false; //auto scroll timeout14238this.touchMove = false;1423914240this.moveHover = this.moveHover.bind(this);14241this.endMove = this.endMove.bind(this);1424214243this.registerTableOption("movableColumns", false); //enable movable columns14244}1424514246createPlaceholderElement(){14247var el = document.createElement("div");1424814249el.classList.add("tabulator-col");14250el.classList.add("tabulator-col-placeholder");1425114252return el;14253}1425414255initialize(){14256if(this.table.options.movableColumns){14257this.subscribe("column-init", this.initializeColumn.bind(this));14258}14259}1426014261initializeColumn(column){14262var self = this,14263config = {},14264colEl;1426514266if(!column.modules.frozen && !column.isGroup){14267colEl = column.getElement();1426814269config.mousemove = function(e){14270if(column.parent === self.moving.parent){14271if((((self.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(colEl).left) + self.table.columnManager.contentsElement.scrollLeft) > (column.getWidth() / 2)){14272if(self.toCol !== column || !self.toColAfter){14273colEl.parentNode.insertBefore(self.placeholderElement, colEl.nextSibling);14274self.moveColumn(column, true);14275}14276}else {14277if(self.toCol !== column || self.toColAfter){14278colEl.parentNode.insertBefore(self.placeholderElement, colEl);14279self.moveColumn(column, false);14280}14281}14282}14283}.bind(self);1428414285colEl.addEventListener("mousedown", function(e){14286self.touchMove = false;14287if(e.which === 1){14288self.checkTimeout = setTimeout(function(){14289self.startMove(e, column);14290}, self.checkPeriod);14291}14292});1429314294colEl.addEventListener("mouseup", function(e){14295if(e.which === 1){14296if(self.checkTimeout){14297clearTimeout(self.checkTimeout);14298}14299}14300});1430114302self.bindTouchEvents(column);14303}1430414305column.modules.moveColumn = config;14306}1430714308bindTouchEvents(column){14309var colEl = column.getElement(),14310startXMove = false, //shifting center position of the cell14311nextCol, prevCol, nextColWidth, prevColWidth, nextColWidthLast, prevColWidthLast;1431214313colEl.addEventListener("touchstart", (e) => {14314this.checkTimeout = setTimeout(() => {14315this.touchMove = true;14316nextCol = column.nextColumn();14317nextColWidth = nextCol ? nextCol.getWidth()/2 : 0;14318prevCol = column.prevColumn();14319prevColWidth = prevCol ? prevCol.getWidth()/2 : 0;14320nextColWidthLast = 0;14321prevColWidthLast = 0;14322startXMove = false;1432314324this.startMove(e, column);14325}, this.checkPeriod);14326}, {passive: true});1432714328colEl.addEventListener("touchmove", (e) => {14329var diff, moveToCol;1433014331if(this.moving){14332this.moveHover(e);1433314334if(!startXMove){14335startXMove = e.touches[0].pageX;14336}1433714338diff = e.touches[0].pageX - startXMove;1433914340if(diff > 0){14341if(nextCol && diff - nextColWidthLast > nextColWidth){14342moveToCol = nextCol;1434314344if(moveToCol !== column){14345startXMove = e.touches[0].pageX;14346moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement().nextSibling);14347this.moveColumn(moveToCol, true);14348}14349}14350}else {14351if(prevCol && -diff - prevColWidthLast > prevColWidth){14352moveToCol = prevCol;1435314354if(moveToCol !== column){14355startXMove = e.touches[0].pageX;14356moveToCol.getElement().parentNode.insertBefore(this.placeholderElement, moveToCol.getElement());14357this.moveColumn(moveToCol, false);14358}14359}14360}1436114362if(moveToCol){14363nextCol = moveToCol.nextColumn();14364nextColWidthLast = nextColWidth;14365nextColWidth = nextCol ? nextCol.getWidth() / 2 : 0;14366prevCol = moveToCol.prevColumn();14367prevColWidthLast = prevColWidth;14368prevColWidth = prevCol ? prevCol.getWidth() / 2 : 0;14369}14370}14371}, {passive: true});1437214373colEl.addEventListener("touchend", (e) => {14374if(this.checkTimeout){14375clearTimeout(this.checkTimeout);14376}14377if(this.moving){14378this.endMove(e);14379}14380});14381}1438214383startMove(e, column){14384var element = column.getElement(),14385headerElement = this.table.columnManager.getContentsElement(),14386headersElement = this.table.columnManager.getHeadersElement();1438714388this.moving = column;14389this.startX = (this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(element).left;1439014391this.table.element.classList.add("tabulator-block-select");1439214393//create placeholder14394this.placeholderElement.style.width = column.getWidth() + "px";14395this.placeholderElement.style.height = column.getHeight() + "px";1439614397element.parentNode.insertBefore(this.placeholderElement, element);14398element.parentNode.removeChild(element);1439914400//create hover element14401this.hoverElement = element.cloneNode(true);14402this.hoverElement.classList.add("tabulator-moving");1440314404headerElement.appendChild(this.hoverElement);1440514406this.hoverElement.style.left = "0";14407this.hoverElement.style.bottom = (headerElement.clientHeight - headersElement.offsetHeight) + "px";1440814409if(!this.touchMove){14410this._bindMouseMove();1441114412document.body.addEventListener("mousemove", this.moveHover);14413document.body.addEventListener("mouseup", this.endMove);14414}1441514416this.moveHover(e);14417}1441814419_bindMouseMove(){14420this.table.columnManager.columnsByIndex.forEach(function(column){14421if(column.modules.moveColumn.mousemove){14422column.getElement().addEventListener("mousemove", column.modules.moveColumn.mousemove);14423}14424});14425}1442614427_unbindMouseMove(){14428this.table.columnManager.columnsByIndex.forEach(function(column){14429if(column.modules.moveColumn.mousemove){14430column.getElement().removeEventListener("mousemove", column.modules.moveColumn.mousemove);14431}14432});14433}1443414435moveColumn(column, after){14436var movingCells = this.moving.getCells();1443714438this.toCol = column;14439this.toColAfter = after;1444014441if(after){14442column.getCells().forEach(function(cell, i){14443var cellEl = cell.getElement(true);1444414445if(cellEl.parentNode && movingCells[i]){14446cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl.nextSibling);14447}14448});14449}else {14450column.getCells().forEach(function(cell, i){14451var cellEl = cell.getElement(true);1445214453if(cellEl.parentNode && movingCells[i]){14454cellEl.parentNode.insertBefore(movingCells[i].getElement(), cellEl);14455}14456});14457}14458}1445914460endMove(e){14461if(e.which === 1 || this.touchMove){14462this._unbindMouseMove();1446314464this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);14465this.placeholderElement.parentNode.removeChild(this.placeholderElement);14466this.hoverElement.parentNode.removeChild(this.hoverElement);1446714468this.table.element.classList.remove("tabulator-block-select");1446914470if(this.toCol){14471this.table.columnManager.moveColumnActual(this.moving, this.toCol, this.toColAfter);14472}1447314474this.moving = false;14475this.toCol = false;14476this.toColAfter = false;1447714478if(!this.touchMove){14479document.body.removeEventListener("mousemove", this.moveHover);14480document.body.removeEventListener("mouseup", this.endMove);14481}14482}14483}1448414485moveHover(e){14486var columnHolder = this.table.columnManager.getContentsElement(),14487scrollLeft = columnHolder.scrollLeft,14488xPos = ((this.touchMove ? e.touches[0].pageX : e.pageX) - Helpers.elOffset(columnHolder).left) + scrollLeft,14489scrollPos;1449014491this.hoverElement.style.left = (xPos - this.startX) + "px";1449214493if(xPos - scrollLeft < this.autoScrollMargin){14494if(!this.autoScrollTimeout){14495this.autoScrollTimeout = setTimeout(() => {14496scrollPos = Math.max(0,scrollLeft-5);14497this.table.rowManager.getElement().scrollLeft = scrollPos;14498this.autoScrollTimeout = false;14499}, 1);14500}14501}1450214503if(scrollLeft + columnHolder.clientWidth - xPos < this.autoScrollMargin){14504if(!this.autoScrollTimeout){14505this.autoScrollTimeout = setTimeout(() => {14506scrollPos = Math.min(columnHolder.clientWidth, scrollLeft+5);14507this.table.rowManager.getElement().scrollLeft = scrollPos;14508this.autoScrollTimeout = false;14509}, 1);14510}14511}14512}14513}1451414515MoveColumns.moduleName = "moveColumn";1451614517class MoveRows extends Module{1451814519constructor(table){14520super(table);1452114522this.placeholderElement = this.createPlaceholderElement();14523this.hoverElement = false; //floating row header element14524this.checkTimeout = false; //click check timeout holder14525this.checkPeriod = 150; //period to wait on mousedown to consider this a move and not a click14526this.moving = false; //currently moving row14527this.toRow = false; //destination row14528this.toRowAfter = false; //position of moving row relative to the destination row14529this.hasHandle = false; //row has handle instead of fully movable row14530this.startY = 0; //starting Y position within header element14531this.startX = 0; //starting X position within header element1453214533this.moveHover = this.moveHover.bind(this);14534this.endMove = this.endMove.bind(this);14535this.tableRowDropEvent = false;1453614537this.touchMove = false;1453814539this.connection = false;14540this.connectionSelectorsTables = false;14541this.connectionSelectorsElements = false;14542this.connectionElements = [];14543this.connections = [];1454414545this.connectedTable = false;14546this.connectedRow = false;1454714548this.registerTableOption("movableRows", false); //enable movable rows14549this.registerTableOption("movableRowsConnectedTables", false); //tables for movable rows to be connected to14550this.registerTableOption("movableRowsConnectedElements", false); //other elements for movable rows to be connected to14551this.registerTableOption("movableRowsSender", false);14552this.registerTableOption("movableRowsReceiver", "insert");1455314554this.registerColumnOption("rowHandle");14555}1455614557createPlaceholderElement(){14558var el = document.createElement("div");1455914560el.classList.add("tabulator-row");14561el.classList.add("tabulator-row-placeholder");1456214563return el;14564}1456514566initialize(){14567if(this.table.options.movableRows){14568this.connectionSelectorsTables = this.table.options.movableRowsConnectedTables;14569this.connectionSelectorsElements = this.table.options.movableRowsConnectedElements;1457014571this.connection = this.connectionSelectorsTables || this.connectionSelectorsElements;1457214573this.subscribe("cell-init", this.initializeCell.bind(this));14574this.subscribe("column-init", this.initializeColumn.bind(this));14575this.subscribe("row-init", this.initializeRow.bind(this));14576}14577}1457814579initializeGroupHeader(group){14580var self = this,14581config = {};1458214583//inter table drag drop14584config.mouseup = function(e){14585self.tableRowDrop(e, group);14586}.bind(self);1458714588//same table drag drop14589config.mousemove = function(e){14590var rowEl;1459114592if(((e.pageY - Helpers.elOffset(group.element).top) + self.table.rowManager.element.scrollTop) > (group.getHeight() / 2)){14593if(self.toRow !== group || !self.toRowAfter){14594rowEl = group.getElement();14595rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);14596self.moveRow(group, true);14597}14598}else {14599if(self.toRow !== group || self.toRowAfter){14600rowEl = group.getElement();14601if(rowEl.previousSibling){14602rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);14603self.moveRow(group, false);14604}14605}14606}14607}.bind(self);1460814609group.modules.moveRow = config;14610}1461114612initializeRow(row){14613var self = this,14614config = {},14615rowEl;1461614617//inter table drag drop14618config.mouseup = function(e){14619self.tableRowDrop(e, row);14620}.bind(self);1462114622//same table drag drop14623config.mousemove = function(e){14624var rowEl = row.getElement();1462514626if(((e.pageY - Helpers.elOffset(rowEl).top) + self.table.rowManager.element.scrollTop) > (row.getHeight() / 2)){14627if(self.toRow !== row || !self.toRowAfter){14628rowEl.parentNode.insertBefore(self.placeholderElement, rowEl.nextSibling);14629self.moveRow(row, true);14630}14631}else {14632if(self.toRow !== row || self.toRowAfter){14633rowEl.parentNode.insertBefore(self.placeholderElement, rowEl);14634self.moveRow(row, false);14635}14636}14637}.bind(self);146381463914640if(!this.hasHandle){1464114642rowEl = row.getElement();1464314644rowEl.addEventListener("mousedown", function(e){14645if(e.which === 1){14646self.checkTimeout = setTimeout(function(){14647self.startMove(e, row);14648}, self.checkPeriod);14649}14650});1465114652rowEl.addEventListener("mouseup", function(e){14653if(e.which === 1){14654if(self.checkTimeout){14655clearTimeout(self.checkTimeout);14656}14657}14658});1465914660this.bindTouchEvents(row, row.getElement());14661}1466214663row.modules.moveRow = config;14664}1466514666initializeColumn(column){14667if(column.definition.rowHandle && this.table.options.movableRows !== false){14668this.hasHandle = true;14669}14670}1467114672initializeCell(cell){14673if(cell.column.definition.rowHandle && this.table.options.movableRows !== false){14674var self = this,14675cellEl = cell.getElement(true);1467614677cellEl.addEventListener("mousedown", function(e){14678if(e.which === 1){14679self.checkTimeout = setTimeout(function(){14680self.startMove(e, cell.row);14681}, self.checkPeriod);14682}14683});1468414685cellEl.addEventListener("mouseup", function(e){14686if(e.which === 1){14687if(self.checkTimeout){14688clearTimeout(self.checkTimeout);14689}14690}14691});1469214693this.bindTouchEvents(cell.row, cellEl);14694}14695}1469614697bindTouchEvents(row, element){14698var startYMove = false, //shifting center position of the cell14699nextRow, prevRow, nextRowHeight, prevRowHeight, nextRowHeightLast, prevRowHeightLast;1470014701element.addEventListener("touchstart", (e) => {14702this.checkTimeout = setTimeout(() => {14703this.touchMove = true;14704nextRow = row.nextRow();14705nextRowHeight = nextRow ? nextRow.getHeight()/2 : 0;14706prevRow = row.prevRow();14707prevRowHeight = prevRow ? prevRow.getHeight()/2 : 0;14708nextRowHeightLast = 0;14709prevRowHeightLast = 0;14710startYMove = false;1471114712this.startMove(e, row);14713}, this.checkPeriod);14714}, {passive: true});14715this.moving, this.toRow, this.toRowAfter;14716element.addEventListener("touchmove", (e) => {1471714718var diff, moveToRow;1471914720if(this.moving){14721e.preventDefault();1472214723this.moveHover(e);1472414725if(!startYMove){14726startYMove = e.touches[0].pageY;14727}1472814729diff = e.touches[0].pageY - startYMove;1473014731if(diff > 0){14732if(nextRow && diff - nextRowHeightLast > nextRowHeight){14733moveToRow = nextRow;1473414735if(moveToRow !== row){14736startYMove = e.touches[0].pageY;14737moveToRow.getElement().parentNode.insertBefore(this.placeholderElement, moveToRow.getElement().nextSibling);14738this.moveRow(moveToRow, true);14739}14740}14741}else {14742if(prevRow && -diff - prevRowHeightLast > prevRowHeight){14743moveToRow = prevRow;1474414745if(moveToRow !== row){14746startYMove = e.touches[0].pageY;14747moveToRow.getElement().parentNode.insertBefore(this.placeholderElement, moveToRow.getElement());14748this.moveRow(moveToRow, false);14749}14750}14751}1475214753if(moveToRow){14754nextRow = moveToRow.nextRow();14755nextRowHeightLast = nextRowHeight;14756nextRowHeight = nextRow ? nextRow.getHeight() / 2 : 0;14757prevRow = moveToRow.prevRow();14758prevRowHeightLast = prevRowHeight;14759prevRowHeight = prevRow ? prevRow.getHeight() / 2 : 0;14760}14761}14762});1476314764element.addEventListener("touchend", (e) => {14765if(this.checkTimeout){14766clearTimeout(this.checkTimeout);14767}14768if(this.moving){14769this.endMove(e);14770this.touchMove = false;14771}14772});14773}1477414775_bindMouseMove(){14776this.table.rowManager.getDisplayRows().forEach((row) => {14777if((row.type === "row" || row.type === "group") && row.modules.moveRow && row.modules.moveRow.mousemove){14778row.getElement().addEventListener("mousemove", row.modules.moveRow.mousemove);14779}14780});14781}1478214783_unbindMouseMove(){14784this.table.rowManager.getDisplayRows().forEach((row) => {14785if((row.type === "row" || row.type === "group") && row.modules.moveRow && row.modules.moveRow.mousemove){14786row.getElement().removeEventListener("mousemove", row.modules.moveRow.mousemove);14787}14788});14789}1479014791startMove(e, row){14792var element = row.getElement();1479314794this.setStartPosition(e, row);1479514796this.moving = row;1479714798this.table.element.classList.add("tabulator-block-select");1479914800//create placeholder14801this.placeholderElement.style.width = row.getWidth() + "px";14802this.placeholderElement.style.height = row.getHeight() + "px";1480314804if(!this.connection){14805element.parentNode.insertBefore(this.placeholderElement, element);14806element.parentNode.removeChild(element);14807}else {14808this.table.element.classList.add("tabulator-movingrow-sending");14809this.connectToTables(row);14810}1481114812//create hover element14813this.hoverElement = element.cloneNode(true);14814this.hoverElement.classList.add("tabulator-moving");1481514816if(this.connection){14817document.body.appendChild(this.hoverElement);14818this.hoverElement.style.left = "0";14819this.hoverElement.style.top = "0";14820this.hoverElement.style.width = this.table.element.clientWidth + "px";14821this.hoverElement.style.whiteSpace = "nowrap";14822this.hoverElement.style.overflow = "hidden";14823this.hoverElement.style.pointerEvents = "none";14824}else {14825this.table.rowManager.getTableElement().appendChild(this.hoverElement);1482614827this.hoverElement.style.left = "0";14828this.hoverElement.style.top = "0";1482914830this._bindMouseMove();14831}1483214833document.body.addEventListener("mousemove", this.moveHover);14834document.body.addEventListener("mouseup", this.endMove);1483514836this.dispatchExternal("rowMoving", row.getComponent());1483714838this.moveHover(e);14839}1484014841setStartPosition(e, row){14842var pageX = this.touchMove ? e.touches[0].pageX : e.pageX,14843pageY = this.touchMove ? e.touches[0].pageY : e.pageY,14844element, position;1484514846element = row.getElement();14847if(this.connection){14848position = element.getBoundingClientRect();1484914850this.startX = position.left - pageX + window.pageXOffset;14851this.startY = position.top - pageY + window.pageYOffset;14852}else {14853this.startY = (pageY - element.getBoundingClientRect().top);14854}14855}1485614857endMove(e){14858if(!e || e.which === 1 || this.touchMove){14859this._unbindMouseMove();1486014861if(!this.connection){14862this.placeholderElement.parentNode.insertBefore(this.moving.getElement(), this.placeholderElement.nextSibling);14863this.placeholderElement.parentNode.removeChild(this.placeholderElement);14864}1486514866this.hoverElement.parentNode.removeChild(this.hoverElement);1486714868this.table.element.classList.remove("tabulator-block-select");1486914870if(this.toRow){14871this.table.rowManager.moveRow(this.moving, this.toRow, this.toRowAfter);14872}else {14873this.dispatchExternal("rowMoveCancelled", this.moving.getComponent());14874}1487514876this.moving = false;14877this.toRow = false;14878this.toRowAfter = false;1487914880document.body.removeEventListener("mousemove", this.moveHover);14881document.body.removeEventListener("mouseup", this.endMove);1488214883if(this.connection){14884this.table.element.classList.remove("tabulator-movingrow-sending");14885this.disconnectFromTables();14886}14887}14888}1488914890moveRow(row, after){14891this.toRow = row;14892this.toRowAfter = after;14893}1489414895moveHover(e){14896if(this.connection){14897this.moveHoverConnections.call(this, e);14898}else {14899this.moveHoverTable.call(this, e);14900}14901}1490214903moveHoverTable(e){14904var rowHolder = this.table.rowManager.getElement(),14905scrollTop = rowHolder.scrollTop,14906yPos = ((this.touchMove ? e.touches[0].pageY : e.pageY) - rowHolder.getBoundingClientRect().top) + scrollTop;1490714908this.hoverElement.style.top = Math.min(yPos - this.startY, this.table.rowManager.element.scrollHeight - this.hoverElement.offsetHeight) + "px";14909}1491014911moveHoverConnections(e){14912this.hoverElement.style.left = (this.startX + (this.touchMove ? e.touches[0].pageX : e.pageX)) + "px";14913this.hoverElement.style.top = (this.startY + (this.touchMove ? e.touches[0].pageY : e.pageY)) + "px";14914}1491514916elementRowDrop(e, element, row){14917this.dispatchExternal("movableRowsElementDrop", e, element, row ? row.getComponent() : false);14918}1491914920//establish connection with other tables14921connectToTables(row){14922var connectionTables;1492314924if(this.connectionSelectorsTables){14925connectionTables = this.commsConnections(this.connectionSelectorsTables);1492614927this.dispatchExternal("movableRowsSendingStart", connectionTables);1492814929this.commsSend(this.connectionSelectorsTables, "moveRow", "connect", {14930row:row,14931});14932}1493314934if(this.connectionSelectorsElements){1493514936this.connectionElements = [];1493714938if(!Array.isArray(this.connectionSelectorsElements)){14939this.connectionSelectorsElements = [this.connectionSelectorsElements];14940}1494114942this.connectionSelectorsElements.forEach((query) => {14943if(typeof query === "string"){14944this.connectionElements = this.connectionElements.concat(Array.prototype.slice.call(document.querySelectorAll(query)));14945}else {14946this.connectionElements.push(query);14947}14948});1494914950this.connectionElements.forEach((element) => {14951var dropEvent = (e) => {14952this.elementRowDrop(e, element, this.moving);14953};1495414955element.addEventListener("mouseup", dropEvent);14956element.tabulatorElementDropEvent = dropEvent;1495714958element.classList.add("tabulator-movingrow-receiving");14959});14960}14961}1496214963//disconnect from other tables14964disconnectFromTables(){14965var connectionTables;1496614967if(this.connectionSelectorsTables){14968connectionTables = this.commsConnections(this.connectionSelectorsTables);1496914970this.dispatchExternal("movableRowsSendingStop", connectionTables);1497114972this.commsSend(this.connectionSelectorsTables, "moveRow", "disconnect");14973}1497414975this.connectionElements.forEach((element) => {14976element.classList.remove("tabulator-movingrow-receiving");14977element.removeEventListener("mouseup", element.tabulatorElementDropEvent);14978delete element.tabulatorElementDropEvent;14979});14980}1498114982//accept incomming connection14983connect(table, row){14984if(!this.connectedTable){14985this.connectedTable = table;14986this.connectedRow = row;1498714988this.table.element.classList.add("tabulator-movingrow-receiving");1498914990this.table.rowManager.getDisplayRows().forEach((row) => {14991if(row.type === "row" && row.modules.moveRow && row.modules.moveRow.mouseup){14992row.getElement().addEventListener("mouseup", row.modules.moveRow.mouseup);14993}14994});1499514996this.tableRowDropEvent = this.tableRowDrop.bind(this);1499714998this.table.element.addEventListener("mouseup", this.tableRowDropEvent);1499915000this.dispatchExternal("movableRowsReceivingStart", row, table);1500115002return true;15003}else {15004console.warn("Move Row Error - Table cannot accept connection, already connected to table:", this.connectedTable);15005return false;15006}15007}1500815009//close incoming connection15010disconnect(table){15011if(table === this.connectedTable){15012this.connectedTable = false;15013this.connectedRow = false;1501415015this.table.element.classList.remove("tabulator-movingrow-receiving");1501615017this.table.rowManager.getDisplayRows().forEach((row) =>{15018if(row.type === "row" && row.modules.moveRow && row.modules.moveRow.mouseup){15019row.getElement().removeEventListener("mouseup", row.modules.moveRow.mouseup);15020}15021});1502215023this.table.element.removeEventListener("mouseup", this.tableRowDropEvent);1502415025this.dispatchExternal("movableRowsReceivingStop", table);15026}else {15027console.warn("Move Row Error - trying to disconnect from non connected table");15028}15029}1503015031dropComplete(table, row, success){15032var sender = false;1503315034if(success){1503515036switch(typeof this.table.options.movableRowsSender){15037case "string":15038sender = this.senders[this.table.options.movableRowsSender];15039break;1504015041case "function":15042sender = this.table.options.movableRowsSender;15043break;15044}1504515046if(sender){15047sender.call(this, this.moving ? this.moving.getComponent() : undefined, row ? row.getComponent() : undefined, table);15048}else {15049if(this.table.options.movableRowsSender){15050console.warn("Mover Row Error - no matching sender found:", this.table.options.movableRowsSender);15051}15052}1505315054this.dispatchExternal("movableRowsSent", this.moving.getComponent(), row ? row.getComponent() : undefined, table);15055}else {15056this.dispatchExternal("movableRowsSentFailed", this.moving.getComponent(), row ? row.getComponent() : undefined, table);15057}1505815059this.endMove();15060}1506115062tableRowDrop(e, row){15063var receiver = false,15064success = false;1506515066e.stopImmediatePropagation();1506715068switch(typeof this.table.options.movableRowsReceiver){15069case "string":15070receiver = this.receivers[this.table.options.movableRowsReceiver];15071break;1507215073case "function":15074receiver = this.table.options.movableRowsReceiver;15075break;15076}1507715078if(receiver){15079success = receiver.call(this, this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);15080}else {15081console.warn("Mover Row Error - no matching receiver found:", this.table.options.movableRowsReceiver);15082}1508315084if(success){15085this.dispatchExternal("movableRowsReceived", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);15086}else {15087this.dispatchExternal("movableRowsReceivedFailed", this.connectedRow.getComponent(), row ? row.getComponent() : undefined, this.connectedTable);15088}1508915090this.commsSend(this.connectedTable, "moveRow", "dropcomplete", {15091row:row,15092success:success,15093});15094}1509515096commsReceived(table, action, data){15097switch(action){15098case "connect":15099return this.connect(table, data.row);1510015101case "disconnect":15102return this.disconnect(table);1510315104case "dropcomplete":15105return this.dropComplete(table, data.row, data.success);15106}15107}15108}1510915110MoveRows.prototype.receivers = {15111insert:function(fromRow, toRow, fromTable){15112this.table.addRow(fromRow.getData(), undefined, toRow);15113return true;15114},1511515116add:function(fromRow, toRow, fromTable){15117this.table.addRow(fromRow.getData());15118return true;15119},1512015121update:function(fromRow, toRow, fromTable){15122if(toRow){15123toRow.update(fromRow.getData());15124return true;15125}1512615127return false;15128},1512915130replace:function(fromRow, toRow, fromTable){15131if(toRow){15132this.table.addRow(fromRow.getData(), undefined, toRow);15133toRow.delete();15134return true;15135}1513615137return false;15138},15139};1514015141MoveRows.prototype.senders = {15142delete:function(fromRow, toRow, toTable){15143fromRow.delete();15144}15145};1514615147MoveRows.moduleName = "moveRow";1514815149var defaultMutators = {};1515015151class Mutator extends Module{1515215153constructor(table){15154super(table);1515515156this.allowedTypes = ["", "data", "edit", "clipboard"]; //list of mutation types15157this.enabled = true;1515815159this.registerColumnOption("mutator");15160this.registerColumnOption("mutatorParams");15161this.registerColumnOption("mutatorData");15162this.registerColumnOption("mutatorDataParams");15163this.registerColumnOption("mutatorEdit");15164this.registerColumnOption("mutatorEditParams");15165this.registerColumnOption("mutatorClipboard");15166this.registerColumnOption("mutatorClipboardParams");15167this.registerColumnOption("mutateLink");15168}1516915170initialize(){15171this.subscribe("cell-value-changing", this.transformCell.bind(this));15172this.subscribe("cell-value-changed", this.mutateLink.bind(this));15173this.subscribe("column-layout", this.initializeColumn.bind(this));15174this.subscribe("row-data-init-before", this.rowDataChanged.bind(this));15175this.subscribe("row-data-changing", this.rowDataChanged.bind(this));15176}1517715178rowDataChanged(row, tempData, updatedData){15179return this.transformRow(tempData, "data", updatedData);15180}1518115182//initialize column mutator15183initializeColumn(column){15184var match = false,15185config = {};1518615187this.allowedTypes.forEach((type) => {15188var key = "mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),15189mutator;1519015191if(column.definition[key]){15192mutator = this.lookupMutator(column.definition[key]);1519315194if(mutator){15195match = true;1519615197config[key] = {15198mutator:mutator,15199params: column.definition[key + "Params"] || {},15200};15201}15202}15203});1520415205if(match){15206column.modules.mutate = config;15207}15208}1520915210lookupMutator(value){15211var mutator = false;1521215213//set column mutator15214switch(typeof value){15215case "string":15216if(Mutator.mutators[value]){15217mutator = Mutator.mutators[value];15218}else {15219console.warn("Mutator Error - No such mutator found, ignoring: ", value);15220}15221break;1522215223case "function":15224mutator = value;15225break;15226}1522715228return mutator;15229}1523015231//apply mutator to row15232transformRow(data, type, updatedData){15233var key = "mutator" + (type.charAt(0).toUpperCase() + type.slice(1)),15234value;1523515236if(this.enabled){1523715238this.table.columnManager.traverse((column) => {15239var mutator, params, component;1524015241if(column.modules.mutate){15242mutator = column.modules.mutate[key] || column.modules.mutate.mutator || false;1524315244if(mutator){15245value = column.getFieldValue(typeof updatedData !== "undefined" ? updatedData : data);1524615247if((type == "data" && !updatedData)|| typeof value !== "undefined"){15248component = column.getComponent();15249params = typeof mutator.params === "function" ? mutator.params(value, data, type, component) : mutator.params;15250column.setFieldValue(data, mutator.mutator(value, data, type, params, component));15251}15252}15253}15254});15255}1525615257return data;15258}1525915260//apply mutator to new cell value15261transformCell(cell, value){15262if(cell.column.modules.mutate){15263var mutator = cell.column.modules.mutate.mutatorEdit || cell.column.modules.mutate.mutator || false,15264tempData = {};1526515266if(mutator){15267tempData = Object.assign(tempData, cell.row.getData());15268cell.column.setFieldValue(tempData, value);15269return mutator.mutator(value, tempData, "edit", mutator.params, cell.getComponent());15270}15271}1527215273return value;15274}1527515276mutateLink(cell){15277var links = cell.column.definition.mutateLink;1527815279if(links){15280if(!Array.isArray(links)){15281links = [links];15282}1528315284links.forEach((link) => {15285var linkCell = cell.row.getCell(link);1528615287if(linkCell){15288linkCell.setValue(linkCell.getValue(), true, true);15289}15290});15291}15292}1529315294enable(){15295this.enabled = true;15296}1529715298disable(){15299this.enabled = false;15300}15301}1530215303Mutator.moduleName = "mutator";1530415305//load defaults15306Mutator.mutators = defaultMutators;1530715308function rows(pageSize, currentRow, currentPage, totalRows, totalPages){15309var el = document.createElement("span"),15310showingEl = document.createElement("span"),15311valueEl = document.createElement("span"),15312ofEl = document.createElement("span"),15313totalEl = document.createElement("span"),15314rowsEl = document.createElement("span");1531515316this.table.modules.localize.langBind("pagination|counter|showing", (value) => {15317showingEl.innerHTML = value;15318});1531915320this.table.modules.localize.langBind("pagination|counter|of", (value) => {15321ofEl.innerHTML = value;15322});1532315324this.table.modules.localize.langBind("pagination|counter|rows", (value) => {15325rowsEl.innerHTML = value;15326});1532715328if(totalRows){15329valueEl.innerHTML = " " + currentRow + "-" + Math.min((currentRow + pageSize - 1), totalRows) + " ";1533015331totalEl.innerHTML = " " + totalRows + " ";1533215333el.appendChild(showingEl);15334el.appendChild(valueEl);15335el.appendChild(ofEl);15336el.appendChild(totalEl);15337el.appendChild(rowsEl);15338}else {15339valueEl.innerHTML = " 0 ";1534015341el.appendChild(showingEl);15342el.appendChild(valueEl);15343el.appendChild(rowsEl);15344}1534515346return el;15347}1534815349function pages(pageSize, currentRow, currentPage, totalRows, totalPages){1535015351var el = document.createElement("span"),15352showingEl = document.createElement("span"),15353valueEl = document.createElement("span"),15354ofEl = document.createElement("span"),15355totalEl = document.createElement("span"),15356rowsEl = document.createElement("span");1535715358this.table.modules.localize.langBind("pagination|counter|showing", (value) => {15359showingEl.innerHTML = value;15360});1536115362valueEl.innerHTML = " " + currentPage + " ";1536315364this.table.modules.localize.langBind("pagination|counter|of", (value) => {15365ofEl.innerHTML = value;15366});1536715368totalEl.innerHTML = " " + totalPages + " ";1536915370this.table.modules.localize.langBind("pagination|counter|pages", (value) => {15371rowsEl.innerHTML = value;15372});1537315374el.appendChild(showingEl);15375el.appendChild(valueEl);15376el.appendChild(ofEl);15377el.appendChild(totalEl);15378el.appendChild(rowsEl);1537915380return el;15381}1538215383var defaultPageCounters = {15384rows:rows,15385pages:pages,15386};1538715388class Page extends Module{1538915390constructor(table){15391super(table);1539215393this.mode = "local";15394this.progressiveLoad = false;1539515396this.element = null;15397this.pageCounterElement = null;15398this.pageCounter = null;1539915400this.size = 0;15401this.page = 1;15402this.count = 5;15403this.max = 1;1540415405this.remoteRowCountEstimate = null;1540615407this.initialLoad = true;15408this.dataChanging = false; //flag to check if data is being changed by this module1540915410this.pageSizes = [];1541115412this.registerTableOption("pagination", false); //set pagination type15413this.registerTableOption("paginationMode", "local"); //local or remote pagination15414this.registerTableOption("paginationSize", false); //set number of rows to a page15415this.registerTableOption("paginationInitialPage", 1); //initial page to show on load15416this.registerTableOption("paginationCounter", false); // set pagination counter15417this.registerTableOption("paginationCounterElement", false); // set pagination counter15418this.registerTableOption("paginationButtonCount", 5); // set count of page button15419this.registerTableOption("paginationSizeSelector", false); //add pagination size selector element15420this.registerTableOption("paginationElement", false); //element to hold pagination numbers15421// this.registerTableOption("paginationDataSent", {}); //pagination data sent to the server15422// this.registerTableOption("paginationDataReceived", {}); //pagination data received from the server15423this.registerTableOption("paginationAddRow", "page"); //add rows on table or page1542415425this.registerTableOption("progressiveLoad", false); //progressive loading15426this.registerTableOption("progressiveLoadDelay", 0); //delay between requests15427this.registerTableOption("progressiveLoadScrollMargin", 0); //margin before scroll begins1542815429this.registerTableFunction("setMaxPage", this.setMaxPage.bind(this));15430this.registerTableFunction("setPage", this.setPage.bind(this));15431this.registerTableFunction("setPageToRow", this.userSetPageToRow.bind(this));15432this.registerTableFunction("setPageSize", this.userSetPageSize.bind(this));15433this.registerTableFunction("getPageSize", this.getPageSize.bind(this));15434this.registerTableFunction("previousPage", this.previousPage.bind(this));15435this.registerTableFunction("nextPage", this.nextPage.bind(this));15436this.registerTableFunction("getPage", this.getPage.bind(this));15437this.registerTableFunction("getPageMax", this.getPageMax.bind(this));1543815439//register component functions15440this.registerComponentFunction("row", "pageTo", this.setPageToRow.bind(this));15441}1544215443initialize(){15444if(this.table.options.pagination){15445this.subscribe("row-deleted", this.rowsUpdated.bind(this));15446this.subscribe("row-added", this.rowsUpdated.bind(this));15447this.subscribe("data-processed", this.initialLoadComplete.bind(this));15448this.subscribe("table-built", this.calculatePageSizes.bind(this));15449this.subscribe("footer-redraw", this.footerRedraw.bind(this));1545015451if(this.table.options.paginationAddRow == "page"){15452this.subscribe("row-adding-position", this.rowAddingPosition.bind(this));15453}1545415455if(this.table.options.paginationMode === "remote"){15456this.subscribe("data-params", this.remotePageParams.bind(this));15457this.subscribe("data-loaded", this._parseRemoteData.bind(this));15458}1545915460if(this.table.options.progressiveLoad){15461console.error("Progressive Load Error - Pagination and progressive load cannot be used at the same time");15462}1546315464this.registerDisplayHandler(this.restOnRenderBefore.bind(this), 40);15465this.registerDisplayHandler(this.getRows.bind(this), 50);1546615467this.createElements();15468this.initializePageCounter();15469this.initializePaginator();15470}else if(this.table.options.progressiveLoad){15471this.subscribe("data-params", this.remotePageParams.bind(this));15472this.subscribe("data-loaded", this._parseRemoteData.bind(this));15473this.subscribe("table-built", this.calculatePageSizes.bind(this));15474this.subscribe("data-processed", this.initialLoadComplete.bind(this));1547515476this.initializeProgressive(this.table.options.progressiveLoad);1547715478if(this.table.options.progressiveLoad === "scroll"){15479this.subscribe("scroll-vertical", this.scrollVertical.bind(this));15480}15481}15482}1548315484rowAddingPosition(row, top){15485var rowManager = this.table.rowManager,15486displayRows = rowManager.getDisplayRows(),15487index;1548815489if(top){15490if(displayRows.length){15491index = displayRows[0];15492}else {15493if(rowManager.activeRows.length){15494index = rowManager.activeRows[rowManager.activeRows.length-1];15495top = false;15496}15497}15498}else {15499if(displayRows.length){15500index = displayRows[displayRows.length - 1];15501top = displayRows.length < this.size ? false : true;15502}15503}1550415505return {index, top};15506}1550715508calculatePageSizes(){15509var testElRow, testElCell;1551015511if(this.table.options.paginationSize){15512this.size = this.table.options.paginationSize;15513}else {15514testElRow = document.createElement("div");15515testElRow.classList.add("tabulator-row");15516testElRow.style.visibility = "hidden";1551715518testElCell = document.createElement("div");15519testElCell.classList.add("tabulator-cell");15520testElCell.innerHTML = "Page Row Test";1552115522testElRow.appendChild(testElCell);1552315524this.table.rowManager.getTableElement().appendChild(testElRow);1552515526this.size = Math.floor(this.table.rowManager.getElement().clientHeight / testElRow.offsetHeight);1552715528this.table.rowManager.getTableElement().removeChild(testElRow);15529}1553015531this.dispatchExternal("pageSizeChanged", this.size);1553215533this.generatePageSizeSelectList();15534}1553515536initialLoadComplete(){15537this.initialLoad = false;15538}1553915540remotePageParams(data, config, silent, params){15541if(!this.initialLoad){15542if((this.progressiveLoad && !silent) || (!this.progressiveLoad && !this.dataChanging)){15543this.reset(true);15544}15545}1554615547//configure request params15548params.page = this.page;1554915550//set page size if defined15551if(this.size){15552params.size = this.size;15553}1555415555return params;15556}1555715558///////////////////////////////////15559///////// Table Functions /////////15560///////////////////////////////////1556115562userSetPageToRow(row){15563if(this.table.options.pagination){15564row = this.rowManager.findRow(row);1556515566if(row){15567return this.setPageToRow(row);15568}15569}1557015571return Promise.reject();15572}1557315574userSetPageSize(size){15575if(this.table.options.pagination){15576this.setPageSize(size);15577return this.setPage(1);15578}else {15579return false;15580}15581}15582///////////////////////////////////15583///////// Internal Logic //////////15584///////////////////////////////////1558515586scrollVertical(top, dir){15587var element, diff, margin;15588if(!dir && !this.table.dataLoader.loading){15589element = this.table.rowManager.getElement();15590diff = element.scrollHeight - element.clientHeight - top;15591margin = this.table.options.progressiveLoadScrollMargin || (element.clientHeight * 2);1559215593if(diff < margin){15594this.nextPage()15595.catch(() => {}); //consume the exception thrown when on the last page15596}15597}15598}1559915600restOnRenderBefore(rows, renderInPosition){15601if(!renderInPosition){15602if(this.mode === "local"){15603this.reset();15604}15605}1560615607return rows;15608}1560915610rowsUpdated(){15611this.refreshData(true, "all");15612}1561315614createElements(){15615var button;1561615617this.element = document.createElement("span");15618this.element.classList.add("tabulator-paginator");1561915620this.pagesElement = document.createElement("span");15621this.pagesElement.classList.add("tabulator-pages");1562215623button = document.createElement("button");15624button.classList.add("tabulator-page");15625button.setAttribute("type", "button");15626button.setAttribute("role", "button");15627button.setAttribute("aria-label", "");15628button.setAttribute("title", "");1562915630this.firstBut = button.cloneNode(true);15631this.firstBut.setAttribute("data-page", "first");1563215633this.prevBut = button.cloneNode(true);15634this.prevBut.setAttribute("data-page", "prev");1563515636this.nextBut = button.cloneNode(true);15637this.nextBut.setAttribute("data-page", "next");1563815639this.lastBut = button.cloneNode(true);15640this.lastBut.setAttribute("data-page", "last");1564115642if(this.table.options.paginationSizeSelector){15643this.pageSizeSelect = document.createElement("select");15644this.pageSizeSelect.classList.add("tabulator-page-size");15645}15646}1564715648generatePageSizeSelectList(){15649var pageSizes = [];1565015651if(this.pageSizeSelect){1565215653if(Array.isArray(this.table.options.paginationSizeSelector)){15654pageSizes = this.table.options.paginationSizeSelector;15655this.pageSizes = pageSizes;1565615657if(this.pageSizes.indexOf(this.size) == -1){15658pageSizes.unshift(this.size);15659}15660}else {1566115662if(this.pageSizes.indexOf(this.size) == -1){15663pageSizes = [];1566415665for (let i = 1; i < 5; i++){15666pageSizes.push(this.size * i);15667}1566815669this.pageSizes = pageSizes;15670}else {15671pageSizes = this.pageSizes;15672}15673}1567415675while(this.pageSizeSelect.firstChild) this.pageSizeSelect.removeChild(this.pageSizeSelect.firstChild);1567615677pageSizes.forEach((item) => {15678var itemEl = document.createElement("option");15679itemEl.value = item;1568015681if(item === true){15682this.langBind("pagination|all", function(value){15683itemEl.innerHTML = value;15684});15685}else {15686itemEl.innerHTML = item;15687}15688156891569015691this.pageSizeSelect.appendChild(itemEl);15692});1569315694this.pageSizeSelect.value = this.size;15695}15696}1569715698initializePageCounter(){15699var counter = this.table.options.paginationCounter,15700pageCounter = null;1570115702if(counter){15703if(typeof counter === "function"){15704pageCounter = counter;15705}else {15706pageCounter = Page.pageCounters[counter];15707}1570815709if(pageCounter){15710this.pageCounter = pageCounter;1571115712this.pageCounterElement = document.createElement("span");15713this.pageCounterElement.classList.add("tabulator-page-counter");15714}else {15715console.warn("Pagination Error - No such page counter found: ", counter);15716}15717}15718}1571915720//setup pagination15721initializePaginator(hidden){15722var pageSelectLabel, paginationCounterHolder;1572315724if(!hidden){15725//build pagination element1572615727//bind localizations15728this.langBind("pagination|first", (value) => {15729this.firstBut.innerHTML = value;15730});1573115732this.langBind("pagination|first_title", (value) => {15733this.firstBut.setAttribute("aria-label", value);15734this.firstBut.setAttribute("title", value);15735});1573615737this.langBind("pagination|prev", (value) => {15738this.prevBut.innerHTML = value;15739});1574015741this.langBind("pagination|prev_title", (value) => {15742this.prevBut.setAttribute("aria-label", value);15743this.prevBut.setAttribute("title", value);15744});1574515746this.langBind("pagination|next", (value) => {15747this.nextBut.innerHTML = value;15748});1574915750this.langBind("pagination|next_title", (value) => {15751this.nextBut.setAttribute("aria-label", value);15752this.nextBut.setAttribute("title", value);15753});1575415755this.langBind("pagination|last", (value) => {15756this.lastBut.innerHTML = value;15757});1575815759this.langBind("pagination|last_title", (value) => {15760this.lastBut.setAttribute("aria-label", value);15761this.lastBut.setAttribute("title", value);15762});1576315764//click bindings15765this.firstBut.addEventListener("click", () => {15766this.setPage(1);15767});1576815769this.prevBut.addEventListener("click", () => {15770this.previousPage();15771});1577215773this.nextBut.addEventListener("click", () => {15774this.nextPage();15775});1577615777this.lastBut.addEventListener("click", () => {15778this.setPage(this.max);15779});1578015781if(this.table.options.paginationElement){15782this.element = this.table.options.paginationElement;15783}1578415785if(this.pageSizeSelect){15786pageSelectLabel = document.createElement("label");1578715788this.langBind("pagination|page_size", (value) => {15789this.pageSizeSelect.setAttribute("aria-label", value);15790this.pageSizeSelect.setAttribute("title", value);15791pageSelectLabel.innerHTML = value;15792});1579315794this.element.appendChild(pageSelectLabel);15795this.element.appendChild(this.pageSizeSelect);1579615797this.pageSizeSelect.addEventListener("change", (e) => {15798this.setPageSize(this.pageSizeSelect.value == "true" ? true : this.pageSizeSelect.value);15799this.setPage(1);15800});15801}1580215803//append to DOM15804this.element.appendChild(this.firstBut);15805this.element.appendChild(this.prevBut);15806this.element.appendChild(this.pagesElement);15807this.element.appendChild(this.nextBut);15808this.element.appendChild(this.lastBut);1580915810if(!this.table.options.paginationElement){15811if(this.table.options.paginationCounter){1581215813if(this.table.options.paginationCounterElement){15814if(this.table.options.paginationCounterElement instanceof HTMLElement){15815this.table.options.paginationCounterElement.appendChild(this.pageCounterElement);15816}else if(typeof this.table.options.paginationCounterElement === "string"){15817paginationCounterHolder = document.querySelector(this.table.options.paginationCounterElement);1581815819if(paginationCounterHolder){15820paginationCounterHolder.appendChild(this.pageCounterElement);15821}else {15822console.warn("Pagination Error - Unable to find element matching paginationCounterElement selector:", this.table.options.paginationCounterElement);15823}15824}15825}else {15826this.footerAppend(this.pageCounterElement);15827}1582815829}1583015831this.footerAppend(this.element);15832}1583315834this.page = this.table.options.paginationInitialPage;15835this.count = this.table.options.paginationButtonCount;15836}1583715838//set default values15839this.mode = this.table.options.paginationMode;15840}1584115842initializeProgressive(mode){15843this.initializePaginator(true);15844this.mode = "progressive_" + mode;15845this.progressiveLoad = true;15846}1584715848trackChanges(){15849this.dispatch("page-changed");15850}1585115852//calculate maximum page from number of rows15853setMaxRows(rowCount){15854if(!rowCount){15855this.max = 1;15856}else {15857this.max = this.size === true ? 1 : Math.ceil(rowCount/this.size);15858}1585915860if(this.page > this.max){15861this.page = this.max;15862}15863}1586415865//reset to first page without triggering action15866reset(force){15867if(!this.initialLoad){15868if(this.mode == "local" || force){15869this.page = 1;15870this.trackChanges();15871}15872}15873}1587415875//set the maximum page15876setMaxPage(max){1587715878max = parseInt(max);1587915880this.max = max || 1;1588115882if(this.page > this.max){15883this.page = this.max;15884this.trigger();15885}15886}1588715888//set current page number15889setPage(page){15890switch(page){15891case "first":15892return this.setPage(1);1589315894case "prev":15895return this.previousPage();1589615897case "next":15898return this.nextPage();1589915900case "last":15901return this.setPage(this.max);15902}1590315904page = parseInt(page);1590515906if((page > 0 && page <= this.max) || this.mode !== "local"){15907this.page = page;1590815909this.trackChanges();1591015911return this.trigger();15912}else {15913console.warn("Pagination Error - Requested page is out of range of 1 - " + this.max + ":", page);15914return Promise.reject();15915}15916}1591715918setPageToRow(row){15919var rows = this.displayRows(-1);15920var index = rows.indexOf(row);1592115922if(index > -1){15923var page = this.size === true ? 1 : Math.ceil((index + 1) / this.size);1592415925return this.setPage(page);15926}else {15927console.warn("Pagination Error - Requested row is not visible");15928return Promise.reject();15929}15930}1593115932setPageSize(size){15933if(size !== true){15934size = parseInt(size);15935}1593615937if(size > 0){15938this.size = size;15939this.dispatchExternal("pageSizeChanged", size);15940}1594115942if(this.pageSizeSelect){15943// this.pageSizeSelect.value = size;15944this.generatePageSizeSelectList();15945}1594615947this.trackChanges();15948}1594915950_setPageCounter(totalRows, size, currentRow){15951var content;1595215953if(this.pageCounter){1595415955if(this.mode === "remote"){15956size = this.size;15957currentRow = ((this.page - 1) * this.size) + 1;15958totalRows = this.remoteRowCountEstimate;15959}1596015961content = this.pageCounter.call(this, size, currentRow, this.page, totalRows, this.max);1596215963switch(typeof content){15964case "object":15965if(content instanceof Node){1596615967//clear previous cell contents15968while(this.pageCounterElement.firstChild) this.pageCounterElement.removeChild(this.pageCounterElement.firstChild);1596915970this.pageCounterElement.appendChild(content);15971}else {15972this.pageCounterElement.innerHTML = "";1597315974if(content != null){15975console.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);15976}15977}15978break;15979case "undefined":15980this.pageCounterElement.innerHTML = "";15981break;15982default:15983this.pageCounterElement.innerHTML = content;15984}15985}15986}1598715988//setup the pagination buttons15989_setPageButtons(){15990let leftSize = Math.floor((this.count-1) / 2);15991let rightSize = Math.ceil((this.count-1) / 2);15992let min = this.max - this.page + leftSize + 1 < this.count ? this.max-this.count+1: Math.max(this.page-leftSize,1);15993let max = this.page <= rightSize? Math.min(this.count, this.max) :Math.min(this.page+rightSize, this.max);1599415995while(this.pagesElement.firstChild) this.pagesElement.removeChild(this.pagesElement.firstChild);1599615997if(this.page == 1){15998this.firstBut.disabled = true;15999this.prevBut.disabled = true;16000}else {16001this.firstBut.disabled = false;16002this.prevBut.disabled = false;16003}1600416005if(this.page == this.max){16006this.lastBut.disabled = true;16007this.nextBut.disabled = true;16008}else {16009this.lastBut.disabled = false;16010this.nextBut.disabled = false;16011}1601216013for(let i = min; i <= max; i++){16014if(i>0 && i <= this.max){16015this.pagesElement.appendChild(this._generatePageButton(i));16016}16017}1601816019this.footerRedraw();16020}1602116022_generatePageButton(page){16023var button = document.createElement("button");1602416025button.classList.add("tabulator-page");16026if(page == this.page){16027button.classList.add("active");16028}1602916030button.setAttribute("type", "button");16031button.setAttribute("role", "button");1603216033this.langBind("pagination|page_title", (value) => {16034button.setAttribute("aria-label", value + " " + page);16035button.setAttribute("title", value + " " + page);16036});1603716038button.setAttribute("data-page", page);16039button.textContent = page;1604016041button.addEventListener("click", (e) => {16042this.setPage(page);16043});1604416045return button;16046}1604716048//previous page16049previousPage(){16050if(this.page > 1){16051this.page--;1605216053this.trackChanges();1605416055return this.trigger();1605616057}else {16058console.warn("Pagination Error - Previous page would be less than page 1:", 0);16059return Promise.reject();16060}16061}1606216063//next page16064nextPage(){16065if(this.page < this.max){16066this.page++;1606716068this.trackChanges();1606916070return this.trigger();1607116072}else {16073if(!this.progressiveLoad){16074console.warn("Pagination Error - Next page would be greater than maximum page of " + this.max + ":", this.max + 1);16075}16076return Promise.reject();16077}16078}1607916080//return current page number16081getPage(){16082return this.page;16083}1608416085//return max page number16086getPageMax(){16087return this.max;16088}1608916090getPageSize(size){16091return this.size;16092}1609316094getMode(){16095return this.mode;16096}1609716098//return appropriate rows for current page16099getRows(data){16100var actualRowPageSize = 0,16101output, start, end, actualStartRow;1610216103var actualRows = data.filter((row) => {16104return row.type === "row";16105});1610616107if(this.mode == "local"){16108output = [];1610916110this.setMaxRows(data.length);1611116112if(this.size === true){16113start = 0;16114end = data.length;16115}else {16116start = this.size * (this.page - 1);16117end = start + parseInt(this.size);16118}1611916120this._setPageButtons();1612116122for(let i = start; i < end; i++){16123let row = data[i];1612416125if(row){16126output.push(row);1612716128if(row.type === "row"){16129if(!actualStartRow){16130actualStartRow = row;16131}1613216133actualRowPageSize++;16134}16135}16136}1613716138this._setPageCounter(actualRows.length, actualRowPageSize, actualStartRow ? (actualRows.indexOf(actualStartRow) + 1) : 0);1613916140return output;16141}else {16142this._setPageButtons();16143this._setPageCounter(actualRows.length);1614416145return data.slice(0);16146}16147}1614816149trigger(){16150var left;1615116152switch(this.mode){16153case "local":16154left = this.table.rowManager.scrollLeft;1615516156this.refreshData();16157this.table.rowManager.scrollHorizontal(left);1615816159this.dispatchExternal("pageLoaded", this.getPage());1616016161return Promise.resolve();1616216163case "remote":16164this.dataChanging = true;16165return this.reloadData(null)16166.finally(() => {16167this.dataChanging = false;16168});1616916170case "progressive_load":16171case "progressive_scroll":16172return this.reloadData(null, true);1617316174default:16175console.warn("Pagination Error - no such pagination mode:", this.mode);16176return Promise.reject();16177}16178}1617916180_parseRemoteData(data){16181var margin;1618216183if(typeof data.last_page === "undefined"){16184console.warn("Remote Pagination Error - Server response missing '" + (this.options("dataReceiveParams").last_page || "last_page") + "' property");16185}1618616187if(data.data){16188this.max = parseInt(data.last_page) || 1;1618916190this.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));1619116192if(this.progressiveLoad){16193switch(this.mode){16194case "progressive_load":1619516196if(this.page == 1){16197this.table.rowManager.setData(data.data, false, this.page == 1);16198}else {16199this.table.rowManager.addRows(data.data);16200}1620116202if(this.page < this.max){16203setTimeout(() => {16204this.nextPage();16205}, this.table.options.progressiveLoadDelay);16206}16207break;1620816209case "progressive_scroll":16210data = this.page === 1 ? data.data : this.table.rowManager.getData().concat(data.data);1621116212this.table.rowManager.setData(data, this.page !== 1, this.page == 1);1621316214margin = this.table.options.progressiveLoadScrollMargin || (this.table.rowManager.element.clientHeight * 2);1621516216if(this.table.rowManager.element.scrollHeight <= (this.table.rowManager.element.clientHeight + margin)){16217if(this.page < this.max){16218setTimeout(() => {16219this.nextPage();16220});16221}16222}16223break;16224}1622516226return false;16227}else {16228// left = this.table.rowManager.scrollLeft;16229this.dispatchExternal("pageLoaded", this.getPage());16230// this.table.rowManager.scrollHorizontal(left);16231// this.table.columnManager.scrollHorizontal(left);16232}1623316234}else {16235console.warn("Remote Pagination Error - Server response missing '" + (this.options("dataReceiveParams").data || "data") + "' property");16236}1623716238return data.data;16239}1624016241//handle the footer element being redrawn16242footerRedraw(){16243var footer = this.table.footerManager.containerElement;1624416245if((Math.ceil(footer.clientWidth) - footer.scrollWidth) < 0){16246this.pagesElement.style.display = 'none';16247}else {16248this.pagesElement.style.display = '';1624916250if((Math.ceil(footer.clientWidth) - footer.scrollWidth) < 0){16251this.pagesElement.style.display = 'none';16252}16253}16254}16255}1625616257Page.moduleName = "page";1625816259//load defaults16260Page.pageCounters = defaultPageCounters;1626116262// read persistance information from storage16263var defaultReaders = {16264local:function(id, type){16265var data = localStorage.getItem(id + "-" + type);1626616267return data ? JSON.parse(data) : false;16268},16269cookie:function(id, type){16270var cookie = document.cookie,16271key = id + "-" + type,16272cookiePos = cookie.indexOf(key + "="),16273end, data;1627416275//if cookie exists, decode and load column data into tabulator16276if(cookiePos > -1){16277cookie = cookie.slice(cookiePos);1627816279end = cookie.indexOf(";");1628016281if(end > -1){16282cookie = cookie.slice(0, end);16283}1628416285data = cookie.replace(key + "=", "");16286}1628716288return data ? JSON.parse(data) : false;16289}16290};1629116292//write persistence information to storage16293var defaultWriters = {16294local:function(id, type, data){16295localStorage.setItem(id + "-" + type, JSON.stringify(data));16296},16297cookie:function(id, type, data){16298var expireDate = new Date();1629916300expireDate.setDate(expireDate.getDate() + 10000);1630116302document.cookie = id + "-" + type + "=" + JSON.stringify(data) + "; expires=" + expireDate.toUTCString();16303}16304};1630516306class Persistence extends Module{1630716308constructor(table){16309super(table);1631016311this.mode = "";16312this.id = "";16313// this.persistProps = ["field", "width", "visible"];16314this.defWatcherBlock = false;16315this.config = {};16316this.readFunc = false;16317this.writeFunc = false;1631816319this.registerTableOption("persistence", false);16320this.registerTableOption("persistenceID", ""); //key for persistent storage16321this.registerTableOption("persistenceMode", true); //mode for storing persistence information16322this.registerTableOption("persistenceReaderFunc", false); //function for handling persistence data reading16323this.registerTableOption("persistenceWriterFunc", false); //function for handling persistence data writing16324}1632516326// Test for whether localStorage is available for use.16327localStorageTest() {16328var testKey = "_tabulator_test";1632916330try {16331window.localStorage.setItem( testKey, testKey);16332window.localStorage.removeItem( testKey );16333return true;16334} catch(e) {16335return false;16336}16337}1633816339//setup parameters16340initialize(){16341if(this.table.options.persistence){16342//determine persistent layout storage type16343var mode = this.table.options.persistenceMode,16344id = this.table.options.persistenceID,16345retrievedData;1634616347this.mode = mode !== true ? mode : (this.localStorageTest() ? "local" : "cookie");1634816349if(this.table.options.persistenceReaderFunc){16350if(typeof this.table.options.persistenceReaderFunc === "function"){16351this.readFunc = this.table.options.persistenceReaderFunc;16352}else {16353if(Persistence.readers[this.table.options.persistenceReaderFunc]){16354this.readFunc = Persistence.readers[this.table.options.persistenceReaderFunc];16355}else {16356console.warn("Persistence Read Error - invalid reader set", this.table.options.persistenceReaderFunc);16357}16358}16359}else {16360if(Persistence.readers[this.mode]){16361this.readFunc = Persistence.readers[this.mode];16362}else {16363console.warn("Persistence Read Error - invalid reader set", this.mode);16364}16365}1636616367if(this.table.options.persistenceWriterFunc){16368if(typeof this.table.options.persistenceWriterFunc === "function"){16369this.writeFunc = this.table.options.persistenceWriterFunc;16370}else {16371if(Persistence.writers[this.table.options.persistenceWriterFunc]){16372this.writeFunc = Persistence.writers[this.table.options.persistenceWriterFunc];16373}else {16374console.warn("Persistence Write Error - invalid reader set", this.table.options.persistenceWriterFunc);16375}16376}16377}else {16378if(Persistence.writers[this.mode]){16379this.writeFunc = Persistence.writers[this.mode];16380}else {16381console.warn("Persistence Write Error - invalid writer set", this.mode);16382}16383}1638416385//set storage tag16386this.id = "tabulator-" + (id || (this.table.element.getAttribute("id") || ""));1638716388this.config = {16389sort:this.table.options.persistence === true || this.table.options.persistence.sort,16390filter:this.table.options.persistence === true || this.table.options.persistence.filter,16391headerFilter:this.table.options.persistence === true || this.table.options.persistence.headerFilter,16392group:this.table.options.persistence === true || this.table.options.persistence.group,16393page:this.table.options.persistence === true || this.table.options.persistence.page,16394columns:this.table.options.persistence === true ? ["title", "width", "visible"] : this.table.options.persistence.columns,16395};1639616397//load pagination data if needed16398if(this.config.page){16399retrievedData = this.retrieveData("page");1640016401if(retrievedData){16402if(typeof retrievedData.paginationSize !== "undefined" && (this.config.page === true || this.config.page.size)){16403this.table.options.paginationSize = retrievedData.paginationSize;16404}1640516406if(typeof retrievedData.paginationInitialPage !== "undefined" && (this.config.page === true || this.config.page.page)){16407this.table.options.paginationInitialPage = retrievedData.paginationInitialPage;16408}16409}16410}1641116412//load group data if needed16413if(this.config.group){16414retrievedData = this.retrieveData("group");1641516416if(retrievedData){16417if(typeof retrievedData.groupBy !== "undefined" && (this.config.group === true || this.config.group.groupBy)){16418this.table.options.groupBy = retrievedData.groupBy;16419}16420if(typeof retrievedData.groupStartOpen !== "undefined" && (this.config.group === true || this.config.group.groupStartOpen)){16421this.table.options.groupStartOpen = retrievedData.groupStartOpen;16422}16423if(typeof retrievedData.groupHeader !== "undefined" && (this.config.group === true || this.config.group.groupHeader)){16424this.table.options.groupHeader = retrievedData.groupHeader;16425}16426}16427}1642816429if(this.config.columns){16430this.table.options.columns = this.load("columns", this.table.options.columns);16431this.subscribe("column-init", this.initializeColumn.bind(this));16432this.subscribe("column-show", this.save.bind(this, "columns"));16433this.subscribe("column-hide", this.save.bind(this, "columns"));16434this.subscribe("column-moved", this.save.bind(this, "columns"));16435}1643616437this.subscribe("table-built", this.tableBuilt.bind(this), 0);1643816439this.subscribe("table-redraw", this.tableRedraw.bind(this));1644016441this.subscribe("filter-changed", this.eventSave.bind(this, "filter"));16442this.subscribe("filter-changed", this.eventSave.bind(this, "headerFilter"));16443this.subscribe("sort-changed", this.eventSave.bind(this, "sort"));16444this.subscribe("group-changed", this.eventSave.bind(this, "group"));16445this.subscribe("page-changed", this.eventSave.bind(this, "page"));16446this.subscribe("column-resized", this.eventSave.bind(this, "columns"));16447this.subscribe("column-width", this.eventSave.bind(this, "columns"));16448this.subscribe("layout-refreshed", this.eventSave.bind(this, "columns"));16449}1645016451this.registerTableFunction("getColumnLayout", this.getColumnLayout.bind(this));16452this.registerTableFunction("setColumnLayout", this.setColumnLayout.bind(this));16453}1645416455eventSave(type){16456if(this.config[type]){16457this.save(type);16458}16459}1646016461tableBuilt(){16462var sorters, filters, headerFilters;1646316464if(this.config.sort){16465sorters = this.load("sort");1646616467if(!sorters === false){16468this.table.options.initialSort = sorters;16469}16470}1647116472if(this.config.filter){16473filters = this.load("filter");1647416475if(!filters === false){16476this.table.options.initialFilter = filters;16477}16478}16479if(this.config.headerFilter){16480headerFilters = this.load("headerFilter");1648116482if(!headerFilters === false){16483this.table.options.initialHeaderFilter = headerFilters;16484}16485}1648616487}1648816489tableRedraw(force){16490if(force && this.config.columns){16491this.save("columns");16492}16493}1649416495///////////////////////////////////16496///////// Table Functions /////////16497///////////////////////////////////1649816499getColumnLayout(){16500return this.parseColumns(this.table.columnManager.getColumns());16501}1650216503setColumnLayout(layout){16504this.table.columnManager.setColumns(this.mergeDefinition(this.table.options.columns, layout));16505return true;16506}1650716508///////////////////////////////////16509///////// Internal Logic //////////16510///////////////////////////////////1651116512initializeColumn(column){16513var def, keys;1651416515if(this.config.columns){16516this.defWatcherBlock = true;1651716518def = column.getDefinition();1651916520keys = this.config.columns === true ? Object.keys(def) : this.config.columns;1652116522keys.forEach((key)=>{16523var props = Object.getOwnPropertyDescriptor(def, key);16524var value = def[key];1652516526if(props){16527Object.defineProperty(def, key, {16528set: (newValue) => {16529value = newValue;1653016531if(!this.defWatcherBlock){16532this.save("columns");16533}1653416535if(props.set){16536props.set(newValue);16537}16538},16539get:() => {16540if(props.get){16541props.get();16542}16543return value;16544}16545});16546}16547});1654816549this.defWatcherBlock = false;16550}16551}1655216553//load saved definitions16554load(type, current){16555var data = this.retrieveData(type);1655616557if(current){16558data = data ? this.mergeDefinition(current, data) : current;16559}1656016561return data;16562}1656316564//retrieve data from memory16565retrieveData(type){16566return this.readFunc ? this.readFunc(this.id, type) : false;16567}1656816569//merge old and new column definitions16570mergeDefinition(oldCols, newCols){16571var output = [];1657216573newCols = newCols || [];1657416575newCols.forEach((column, to) => {16576var from = this._findColumn(oldCols, column),16577keys;1657816579if(from){16580if(this.config.columns === true || this.config.columns == undefined){16581keys = Object.keys(from);16582keys.push("width");16583}else {16584keys = this.config.columns;16585}1658616587keys.forEach((key)=>{16588if(key !== "columns" && typeof column[key] !== "undefined"){16589from[key] = column[key];16590}16591});1659216593if(from.columns){16594from.columns = this.mergeDefinition(from.columns, column.columns);16595}1659616597output.push(from);16598}16599});1660016601oldCols.forEach((column, i) => {16602var from = this._findColumn(newCols, column);1660316604if (!from) {16605if(output.length>i){16606output.splice(i, 0, column);16607}else {16608output.push(column);16609}16610}16611});1661216613return output;16614}1661516616//find matching columns16617_findColumn(columns, subject){16618var type = subject.columns ? "group" : (subject.field ? "field" : "object");1661916620return columns.find(function(col){16621switch(type){16622case "group":16623return col.title === subject.title && col.columns.length === subject.columns.length;1662416625case "field":16626return col.field === subject.field;1662716628case "object":16629return col === subject;16630}16631});16632}1663316634//save data16635save(type){16636var data = {};1663716638switch(type){16639case "columns":16640data = this.parseColumns(this.table.columnManager.getColumns());16641break;1664216643case "filter":16644data = this.table.modules.filter.getFilters();16645break;1664616647case "headerFilter":16648data = this.table.modules.filter.getHeaderFilters();16649break;1665016651case "sort":16652data = this.validateSorters(this.table.modules.sort.getSort());16653break;1665416655case "group":16656data = this.getGroupConfig();16657break;1665816659case "page":16660data = this.getPageConfig();16661break;16662}1666316664if(this.writeFunc){16665this.writeFunc(this.id, type, data);16666}1666716668}1666916670//ensure sorters contain no function data16671validateSorters(data){16672data.forEach(function(item){16673item.column = item.field;16674delete item.field;16675});1667616677return data;16678}1667916680getGroupConfig(){16681var data = {};1668216683if(this.config.group){16684if(this.config.group === true || this.config.group.groupBy){16685data.groupBy = this.table.options.groupBy;16686}1668716688if(this.config.group === true || this.config.group.groupStartOpen){16689data.groupStartOpen = this.table.options.groupStartOpen;16690}1669116692if(this.config.group === true || this.config.group.groupHeader){16693data.groupHeader = this.table.options.groupHeader;16694}16695}1669616697return data;16698}1669916700getPageConfig(){16701var data = {};1670216703if(this.config.page){16704if(this.config.page === true || this.config.page.size){16705data.paginationSize = this.table.modules.page.getPageSize();16706}1670716708if(this.config.page === true || this.config.page.page){16709data.paginationInitialPage = this.table.modules.page.getPage();16710}16711}1671216713return data;16714}167151671616717//parse columns for data to store16718parseColumns(columns){16719var definitions = [],16720excludedKeys = ["headerContextMenu", "headerMenu", "contextMenu", "clickMenu"];1672116722columns.forEach((column) => {16723var defStore = {},16724colDef = column.getDefinition(),16725keys;1672616727if(column.isGroup){16728defStore.title = colDef.title;16729defStore.columns = this.parseColumns(column.getColumns());16730}else {16731defStore.field = column.getField();1673216733if(this.config.columns === true || this.config.columns == undefined){16734keys = Object.keys(colDef);16735keys.push("width");16736keys.push("visible");16737}else {16738keys = this.config.columns;16739}1674016741keys.forEach((key)=>{16742switch(key){16743case "width":16744defStore.width = column.getWidth();16745break;16746case "visible":16747defStore.visible = column.visible;16748break;1674916750default:16751if(typeof colDef[key] !== "function" && excludedKeys.indexOf(key) === -1){16752defStore[key] = colDef[key];16753}16754}16755});16756}1675716758definitions.push(defStore);16759});1676016761return definitions;16762}16763}1676416765Persistence.moduleName = "persistence";1676616767Persistence.moduleInitOrder = -10;1676816769//load defaults16770Persistence.readers = defaultReaders;16771Persistence.writers = defaultWriters;1677216773class Popup$1 extends Module{1677416775constructor(table){16776super(table);1677716778this.columnSubscribers = {};1677916780this.registerTableOption("rowContextPopup", false);16781this.registerTableOption("rowClickPopup", false);16782this.registerTableOption("rowDblClickPopup", false);16783this.registerTableOption("groupContextPopup", false);16784this.registerTableOption("groupClickPopup", false);16785this.registerTableOption("groupDblClickPopup", false);1678616787this.registerColumnOption("headerContextPopup");16788this.registerColumnOption("headerClickPopup");16789this.registerColumnOption("headerDblClickPopup");16790this.registerColumnOption("headerPopup");16791this.registerColumnOption("headerPopupIcon");16792this.registerColumnOption("contextPopup");16793this.registerColumnOption("clickPopup");16794this.registerColumnOption("dblClickPopup");1679516796this.registerComponentFunction("cell", "popup", this._componentPopupCall.bind(this));16797this.registerComponentFunction("column", "popup", this._componentPopupCall.bind(this));16798this.registerComponentFunction("row", "popup", this._componentPopupCall.bind(this));16799this.registerComponentFunction("group", "popup", this._componentPopupCall.bind(this));1680016801}1680216803initialize(){16804this.initializeRowWatchers();16805this.initializeGroupWatchers();1680616807this.subscribe("column-init", this.initializeColumn.bind(this));16808}1680916810_componentPopupCall(component, contents, position){16811this.loadPopupEvent(contents, null, component, position);16812}1681316814initializeRowWatchers(){16815if(this.table.options.rowContextPopup){16816this.subscribe("row-contextmenu", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));16817this.table.on("rowTapHold", this.loadPopupEvent.bind(this, this.table.options.rowContextPopup));16818}1681916820if(this.table.options.rowClickPopup){16821this.subscribe("row-click", this.loadPopupEvent.bind(this, this.table.options.rowClickPopup));16822}1682316824if(this.table.options.rowDblClickPopup){16825this.subscribe("row-dblclick", this.loadPopupEvent.bind(this, this.table.options.rowDblClickPopup));16826}16827}1682816829initializeGroupWatchers(){16830if(this.table.options.groupContextPopup){16831this.subscribe("group-contextmenu", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));16832this.table.on("groupTapHold", this.loadPopupEvent.bind(this, this.table.options.groupContextPopup));16833}1683416835if(this.table.options.groupClickPopup){16836this.subscribe("group-click", this.loadPopupEvent.bind(this, this.table.options.groupClickPopup));16837}1683816839if(this.table.options.groupDblClickPopup){16840this.subscribe("group-dblclick", this.loadPopupEvent.bind(this, this.table.options.groupDblClickPopup));16841}16842}1684316844initializeColumn(column){16845var def = column.definition;1684616847//handle column events16848if(def.headerContextPopup && !this.columnSubscribers.headerContextPopup){16849this.columnSubscribers.headerContextPopup = this.loadPopupTableColumnEvent.bind(this, "headerContextPopup");16850this.subscribe("column-contextmenu", this.columnSubscribers.headerContextPopup);16851this.table.on("headerTapHold", this.loadPopupTableColumnEvent.bind(this, "headerContextPopup"));16852}1685316854if(def.headerClickPopup && !this.columnSubscribers.headerClickPopup){16855this.columnSubscribers.headerClickPopup = this.loadPopupTableColumnEvent.bind(this, "headerClickPopup");16856this.subscribe("column-click", this.columnSubscribers.headerClickPopup);168571685816859}if(def.headerDblClickPopup && !this.columnSubscribers.headerDblClickPopup){16860this.columnSubscribers.headerDblClickPopup = this.loadPopupTableColumnEvent.bind(this, "headerDblClickPopup");16861this.subscribe("column-dblclick", this.columnSubscribers.headerDblClickPopup);16862}1686316864if(def.headerPopup){16865this.initializeColumnHeaderPopup(column);16866}1686716868//handle cell events16869if(def.contextPopup && !this.columnSubscribers.contextPopup){16870this.columnSubscribers.contextPopup = this.loadPopupTableCellEvent.bind(this, "contextPopup");16871this.subscribe("cell-contextmenu", this.columnSubscribers.contextPopup);16872this.table.on("cellTapHold", this.loadPopupTableCellEvent.bind(this, "contextPopup"));16873}1687416875if(def.clickPopup && !this.columnSubscribers.clickPopup){16876this.columnSubscribers.clickPopup = this.loadPopupTableCellEvent.bind(this, "clickPopup");16877this.subscribe("cell-click", this.columnSubscribers.clickPopup);16878}1687916880if(def.dblClickPopup && !this.columnSubscribers.dblClickPopup){16881this.columnSubscribers.dblClickPopup = this.loadPopupTableCellEvent.bind(this, "dblClickPopup");16882this.subscribe("cell-click", this.columnSubscribers.dblClickPopup);16883}16884}1688516886initializeColumnHeaderPopup(column){16887var icon = column.definition.headerPopupIcon,16888headerPopupEl;1688916890headerPopupEl = document.createElement("span");16891headerPopupEl.classList.add("tabulator-header-popup-button");1689216893if(icon){16894if(typeof icon === "function"){16895icon = icon(column.getComponent());16896}1689716898if(icon instanceof HTMLElement){16899headerPopupEl.appendChild(icon);16900}else {16901headerPopupEl.innerHTML = icon;16902}16903}else {16904headerPopupEl.innerHTML = "⋮";16905}1690616907headerPopupEl.addEventListener("click", (e) => {16908e.stopPropagation();16909e.preventDefault();1691016911this.loadPopupEvent(column.definition.headerPopup, e, column);16912});1691316914column.titleElement.insertBefore(headerPopupEl, column.titleElement.firstChild);16915}1691616917loadPopupTableCellEvent(option, e, cell){16918if(cell._cell){16919cell = cell._cell;16920}1692116922if(cell.column.definition[option]){16923this.loadPopupEvent(cell.column.definition[option], e, cell);16924}16925}1692616927loadPopupTableColumnEvent(option, e, column){16928if(column._column){16929column = column._column;16930}1693116932if(column.definition[option]){16933this.loadPopupEvent(column.definition[option], e, column);16934}16935}1693616937loadPopupEvent(contents, e, component, position){16938var renderedCallback;1693916940function onRendered(callback){16941renderedCallback = callback;16942}1694316944if(component._group){16945component = component._group;16946}else if(component._row){16947component = component._row;16948}1694916950contents = typeof contents == "function" ? contents.call(this.table, e, component.getComponent(), onRendered) : contents;1695116952this.loadPopup(e, component, contents, renderedCallback, position);16953}1695416955loadPopup(e, component, contents, renderedCallback, position){16956var touch = !(e instanceof MouseEvent),16957contentsEl, popup;1695816959if(contents instanceof HTMLElement){16960contentsEl = contents;16961}else {16962contentsEl = document.createElement("div");16963contentsEl.innerHTML = contents;16964}1696516966contentsEl.classList.add("tabulator-popup");1696716968contentsEl.addEventListener("click", (e) =>{16969e.stopPropagation();16970});1697116972if(!touch){16973e.preventDefault();16974}1697516976popup = this.popup(contentsEl);1697716978if(typeof renderedCallback === "function"){16979popup.renderCallback(renderedCallback);16980}1698116982if(e){16983popup.show(e);16984}else {16985popup.show(component.getElement(), position || "center");16986}169871698816989popup.hideOnBlur(() => {16990this.dispatchExternal("popupClosed", component.getComponent());16991});16992169931699416995this.dispatchExternal("popupOpened", component.getComponent());16996}16997}1699816999Popup$1.moduleName = "popup";1700017001class Print extends Module{1700217003constructor(table){17004super(table);1700517006this.element = false;17007this.manualBlock = false;17008this.beforeprintEventHandler = null;17009this.afterprintEventHandler = null;1701017011this.registerTableOption("printAsHtml", false); //enable print as html17012this.registerTableOption("printFormatter", false); //printing page formatter17013this.registerTableOption("printHeader", false); //page header contents17014this.registerTableOption("printFooter", false); //page footer contents17015this.registerTableOption("printStyled", true); //enable print as html styling17016this.registerTableOption("printRowRange", "visible"); //restrict print to visible rows only17017this.registerTableOption("printConfig", {}); //print config options1701817019this.registerColumnOption("print");17020this.registerColumnOption("titlePrint");17021}1702217023initialize(){17024if(this.table.options.printAsHtml){17025this.beforeprintEventHandler = this.replaceTable.bind(this);17026this.afterprintEventHandler = this.cleanup.bind(this);1702717028window.addEventListener("beforeprint", this.beforeprintEventHandler );17029window.addEventListener("afterprint", this.afterprintEventHandler);17030this.subscribe("table-destroy", this.destroy.bind(this));17031}1703217033this.registerTableFunction("print", this.printFullscreen.bind(this));17034}1703517036destroy(){17037if(this.table.options.printAsHtml){17038window.removeEventListener( "beforeprint", this.beforeprintEventHandler );17039window.removeEventListener( "afterprint", this.afterprintEventHandler );17040}17041}1704217043///////////////////////////////////17044///////// Table Functions /////////17045///////////////////////////////////1704617047///////////////////////////////////17048///////// Internal Logic //////////17049///////////////////////////////////1705017051replaceTable(){17052if(!this.manualBlock){17053this.element = document.createElement("div");17054this.element.classList.add("tabulator-print-table");1705517056this.element.appendChild(this.table.modules.export.generateTable(this.table.options.printConfig, this.table.options.printStyled, this.table.options.printRowRange, "print"));1705717058this.table.element.style.display = "none";1705917060this.table.element.parentNode.insertBefore(this.element, this.table.element);17061}17062}1706317064cleanup(){17065document.body.classList.remove("tabulator-print-fullscreen-hide");1706617067if(this.element && this.element.parentNode){17068this.element.parentNode.removeChild(this.element);17069this.table.element.style.display = "";17070}17071}1707217073printFullscreen(visible, style, config){17074var scrollX = window.scrollX,17075scrollY = window.scrollY,17076headerEl = document.createElement("div"),17077footerEl = document.createElement("div"),17078tableEl = 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"),17079headerContent, footerContent;1708017081this.manualBlock = true;1708217083this.element = document.createElement("div");17084this.element.classList.add("tabulator-print-fullscreen");1708517086if(this.table.options.printHeader){17087headerEl.classList.add("tabulator-print-header");1708817089headerContent = typeof this.table.options.printHeader == "function" ? this.table.options.printHeader.call(this.table) : this.table.options.printHeader;1709017091if(typeof headerContent == "string"){17092headerEl.innerHTML = headerContent;17093}else {17094headerEl.appendChild(headerContent);17095}1709617097this.element.appendChild(headerEl);17098}1709917100this.element.appendChild(tableEl);1710117102if(this.table.options.printFooter){17103footerEl.classList.add("tabulator-print-footer");1710417105footerContent = typeof this.table.options.printFooter == "function" ? this.table.options.printFooter.call(this.table) : this.table.options.printFooter;171061710717108if(typeof footerContent == "string"){17109footerEl.innerHTML = footerContent;17110}else {17111footerEl.appendChild(footerContent);17112}1711317114this.element.appendChild(footerEl);17115}1711617117document.body.classList.add("tabulator-print-fullscreen-hide");17118document.body.appendChild(this.element);1711917120if(this.table.options.printFormatter){17121this.table.options.printFormatter(this.element, tableEl);17122}1712317124window.print();1712517126this.cleanup();1712717128window.scrollTo(scrollX, scrollY);1712917130this.manualBlock = false;17131}17132}1713317134Print.moduleName = "print";1713517136class ReactiveData extends Module{1713717138constructor(table){17139super(table);1714017141this.data = false;17142this.blocked = false; //block reactivity while performing update17143this.origFuncs = {}; // hold original data array functions to allow replacement after data is done with17144this.currentVersion = 0;1714517146this.registerTableOption("reactiveData", false); //enable data reactivity17147}1714817149initialize(){17150if(this.table.options.reactiveData){17151this.subscribe("cell-value-save-before", this.block.bind(this, "cellsave"));17152this.subscribe("cell-value-save-after", this.unblock.bind(this, "cellsave"));17153this.subscribe("row-data-save-before", this.block.bind(this, "rowsave"));17154this.subscribe("row-data-save-after", this.unblock.bind(this, "rowsave"));17155this.subscribe("row-data-init-after", this.watchRow.bind(this));17156this.subscribe("data-processing", this.watchData.bind(this));17157this.subscribe("table-destroy", this.unwatchData.bind(this));17158}17159}1716017161watchData(data){17162var self = this,17163version;1716417165this.currentVersion ++;1716617167version = this.currentVersion;1716817169this.unwatchData();1717017171this.data = data;1717217173//override array push function17174this.origFuncs.push = data.push;1717517176Object.defineProperty(this.data, "push", {17177enumerable: false,17178configurable: true,17179value: function(){17180var args = Array.from(arguments),17181result;1718217183if(!self.blocked && version === self.currentVersion){17184self.block("data-push");1718517186args.forEach((arg) => {17187self.table.rowManager.addRowActual(arg, false);17188});1718917190result = self.origFuncs.push.apply(data, arguments);1719117192self.unblock("data-push");17193}1719417195return result;17196}17197});1719817199//override array unshift function17200this.origFuncs.unshift = data.unshift;1720117202Object.defineProperty(this.data, "unshift", {17203enumerable: false,17204configurable: true,17205value: function(){17206var args = Array.from(arguments),17207result;1720817209if(!self.blocked && version === self.currentVersion){17210self.block("data-unshift");1721117212args.forEach((arg) => {17213self.table.rowManager.addRowActual(arg, true);17214});1721517216result = self.origFuncs.unshift.apply(data, arguments);1721717218self.unblock("data-unshift");17219}1722017221return result;17222}17223});172241722517226//override array shift function17227this.origFuncs.shift = data.shift;1722817229Object.defineProperty(this.data, "shift", {17230enumerable: false,17231configurable: true,17232value: function(){17233var row, result;1723417235if(!self.blocked && version === self.currentVersion){17236self.block("data-shift");1723717238if(self.data.length){17239row = self.table.rowManager.getRowFromDataObject(self.data[0]);1724017241if(row){17242row.deleteActual();17243}17244}1724517246result = self.origFuncs.shift.call(data);1724717248self.unblock("data-shift");17249}1725017251return result;17252}17253});1725417255//override array pop function17256this.origFuncs.pop = data.pop;1725717258Object.defineProperty(this.data, "pop", {17259enumerable: false,17260configurable: true,17261value: function(){17262var row, result;1726317264if(!self.blocked && version === self.currentVersion){17265self.block("data-pop");1726617267if(self.data.length){17268row = self.table.rowManager.getRowFromDataObject(self.data[self.data.length - 1]);1726917270if(row){17271row.deleteActual();17272}17273}1727417275result = self.origFuncs.pop.call(data);1727617277self.unblock("data-pop");17278}1727917280return result;17281}17282});172831728417285//override array splice function17286this.origFuncs.splice = data.splice;1728717288Object.defineProperty(this.data, "splice", {17289enumerable: false,17290configurable: true,17291value: function(){17292var args = Array.from(arguments),17293start = args[0] < 0 ? data.length + args[0] : args[0],17294end = args[1],17295newRows = args[2] ? args.slice(2) : false,17296startRow, result;1729717298if(!self.blocked && version === self.currentVersion){17299self.block("data-splice");17300//add new rows17301if(newRows){17302startRow = data[start] ? self.table.rowManager.getRowFromDataObject(data[start]) : false;1730317304if(startRow){17305newRows.forEach((rowData) => {17306self.table.rowManager.addRowActual(rowData, true, startRow, true);17307});17308}else {17309newRows = newRows.slice().reverse();1731017311newRows.forEach((rowData) => {17312self.table.rowManager.addRowActual(rowData, true, false, true);17313});17314}17315}1731617317//delete removed rows17318if(end !== 0){17319var oldRows = data.slice(start, typeof args[1] === "undefined" ? args[1] : start + end);1732017321oldRows.forEach((rowData, i) => {17322var row = self.table.rowManager.getRowFromDataObject(rowData);1732317324if(row){17325row.deleteActual(i !== oldRows.length - 1);17326}17327});17328}1732917330if(newRows || end !== 0){17331self.table.rowManager.reRenderInPosition();17332}1733317334result = self.origFuncs.splice.apply(data, arguments);1733517336self.unblock("data-splice");17337}1733817339return result ;17340}17341});17342}1734317344unwatchData(){17345if(this.data !== false){17346for(var key in this.origFuncs){17347Object.defineProperty(this.data, key, {17348enumerable: true,17349configurable:true,17350writable:true,17351value: this.origFuncs.key,17352});17353}17354}17355}1735617357watchRow(row){17358var data = row.getData();1735917360for(var key in data){17361this.watchKey(row, data, key);17362}1736317364if(this.table.options.dataTree){17365this.watchTreeChildren(row);17366}17367}1736817369watchTreeChildren (row){17370var self = this,17371childField = row.getData()[this.table.options.dataTreeChildField],17372origFuncs = {};1737317374if(childField){1737517376origFuncs.push = childField.push;1737717378Object.defineProperty(childField, "push", {17379enumerable: false,17380configurable: true,17381value: () => {17382if(!self.blocked){17383self.block("tree-push");1738417385var result = origFuncs.push.apply(childField, arguments);17386this.rebuildTree(row);1738717388self.unblock("tree-push");17389}1739017391return result;17392}17393});1739417395origFuncs.unshift = childField.unshift;1739617397Object.defineProperty(childField, "unshift", {17398enumerable: false,17399configurable: true,17400value: () => {17401if(!self.blocked){17402self.block("tree-unshift");1740317404var result = origFuncs.unshift.apply(childField, arguments);17405this.rebuildTree(row);1740617407self.unblock("tree-unshift");17408}1740917410return result;17411}17412});1741317414origFuncs.shift = childField.shift;1741517416Object.defineProperty(childField, "shift", {17417enumerable: false,17418configurable: true,17419value: () => {17420if(!self.blocked){17421self.block("tree-shift");1742217423var result = origFuncs.shift.call(childField);17424this.rebuildTree(row);1742517426self.unblock("tree-shift");17427}1742817429return result;17430}17431});1743217433origFuncs.pop = childField.pop;1743417435Object.defineProperty(childField, "pop", {17436enumerable: false,17437configurable: true,17438value: () => {17439if(!self.blocked){17440self.block("tree-pop");1744117442var result = origFuncs.pop.call(childField);17443this.rebuildTree(row);1744417445self.unblock("tree-pop");17446}1744717448return result;17449}17450});1745117452origFuncs.splice = childField.splice;1745317454Object.defineProperty(childField, "splice", {17455enumerable: false,17456configurable: true,17457value: () => {17458if(!self.blocked){17459self.block("tree-splice");1746017461var result = origFuncs.splice.apply(childField, arguments);17462this.rebuildTree(row);1746317464self.unblock("tree-splice");17465}1746617467return result;17468}17469});17470}17471}1747217473rebuildTree(row){17474this.table.modules.dataTree.initializeRow(row);17475this.table.modules.dataTree.layoutRow(row);17476this.table.rowManager.refreshActiveData("tree", false, true);17477}1747817479watchKey(row, data, key){17480var self = this,17481props = Object.getOwnPropertyDescriptor(data, key),17482value = data[key],17483version = this.currentVersion;1748417485Object.defineProperty(data, key, {17486set: (newValue) => {17487value = newValue;17488if(!self.blocked && version === self.currentVersion){17489self.block("key");1749017491var update = {};17492update[key] = newValue;17493row.updateData(update);1749417495self.unblock("key");17496}1749717498if(props.set){17499props.set(newValue);17500}17501},17502get:() => {1750317504if(props.get){17505props.get();17506}1750717508return value;17509}17510});17511}1751217513unwatchRow(row){17514var data = row.getData();1751517516for(var key in data){17517Object.defineProperty(data, key, {17518value:data[key],17519});17520}17521}1752217523block(key){17524if(!this.blocked){17525this.blocked = key;17526}17527}1752817529unblock(key){17530if(this.blocked === key){17531this.blocked = false;17532}17533}17534}1753517536ReactiveData.moduleName = "reactiveData";1753717538class ResizeColumns extends Module{1753917540constructor(table){17541super(table);1754217543this.startColumn = false;17544this.startX = false;17545this.startWidth = false;17546this.latestX = false;17547this.handle = null;17548this.initialNextColumn = null;17549this.nextColumn = null;1755017551this.initialized = false;17552this.registerColumnOption("resizable", true);17553this.registerTableOption("resizableColumnFit", false);17554}1755517556initialize(){17557this.subscribe("column-rendered", this.layoutColumnHeader.bind(this));17558}1755917560initializeEventWatchers(){17561if(!this.initialized){1756217563this.subscribe("cell-rendered", this.layoutCellHandles.bind(this));17564this.subscribe("cell-delete", this.deInitializeComponent.bind(this));1756517566this.subscribe("cell-height", this.resizeHandle.bind(this));17567this.subscribe("column-moved", this.columnLayoutUpdated.bind(this));1756817569this.subscribe("column-hide", this.deInitializeColumn.bind(this));17570this.subscribe("column-show", this.columnLayoutUpdated.bind(this));17571this.subscribe("column-width", this.columnWidthUpdated.bind(this));1757217573this.subscribe("column-delete", this.deInitializeComponent.bind(this));17574this.subscribe("column-height", this.resizeHandle.bind(this));1757517576this.initialized = true;17577}17578}175791758017581layoutCellHandles(cell){17582if(cell.row.type === "row"){17583this.deInitializeComponent(cell);17584this.initializeColumn("cell", cell, cell.column, cell.element);17585}17586}1758717588layoutColumnHeader(column){17589if(column.definition.resizable){17590this.initializeEventWatchers();17591this.deInitializeComponent(column);17592this.initializeColumn("header", column, column, column.element);17593}17594}1759517596columnLayoutUpdated(column){17597var prev = column.prevColumn();1759817599this.reinitializeColumn(column);1760017601if(prev){17602this.reinitializeColumn(prev);17603}17604}1760517606columnWidthUpdated(column){17607if(column.modules.frozen){17608if(this.table.modules.frozenColumns.leftColumns.includes(column)){17609this.table.modules.frozenColumns.leftColumns.forEach((col) => {17610this.reinitializeColumn(col);17611});17612}else if(this.table.modules.frozenColumns.rightColumns.includes(column)){17613this.table.modules.frozenColumns.rightColumns.forEach((col) => {17614this.reinitializeColumn(col);17615});17616}17617}17618}1761917620frozenColumnOffset(column){17621var offset = false;1762217623if(column.modules.frozen){17624offset = column.modules.frozen.marginValue;1762517626if(column.modules.frozen.position === "left"){17627offset += column.getWidth() - 3;17628}else {17629if(offset){17630offset -= 3;17631}17632}17633}1763417635return offset !== false ? offset + "px" : false;17636}1763717638reinitializeColumn(column){17639var frozenOffset = this.frozenColumnOffset(column);1764017641column.cells.forEach((cell) => {17642if(cell.modules.resize && cell.modules.resize.handleEl){17643if(frozenOffset){17644cell.modules.resize.handleEl.style[column.modules.frozen.position] = frozenOffset;17645cell.modules.resize.handleEl.style["z-index"] = 11;17646}1764717648cell.element.after(cell.modules.resize.handleEl);17649}17650});1765117652if(column.modules.resize && column.modules.resize.handleEl){17653if(frozenOffset){17654column.modules.resize.handleEl.style[column.modules.frozen.position] = frozenOffset;17655}1765617657column.element.after(column.modules.resize.handleEl);17658}17659}1766017661initializeColumn(type, component, column, element){17662var self = this,17663variableHeight = false,17664mode = column.definition.resizable,17665config = {},17666nearestColumn = column.getLastColumn();1766717668//set column resize mode17669if(type === "header"){17670variableHeight = column.definition.formatter == "textarea" || column.definition.variableHeight;17671config = {variableHeight:variableHeight};17672}1767317674if((mode === true || mode == type) && this._checkResizability(nearestColumn)){1767517676var handle = document.createElement('span');17677handle.className = "tabulator-col-resize-handle";1767817679handle.addEventListener("click", function(e){17680e.stopPropagation();17681});1768217683var handleDown = function(e){17684self.startColumn = column;17685self.initialNextColumn = self.nextColumn = nearestColumn.nextColumn();17686self._mouseDown(e, nearestColumn, handle);17687};1768817689handle.addEventListener("mousedown", handleDown);17690handle.addEventListener("touchstart", handleDown, {passive: true});1769117692//resize column on double click17693handle.addEventListener("dblclick", (e) => {17694var oldWidth = nearestColumn.getWidth();1769517696e.stopPropagation();17697nearestColumn.reinitializeWidth(true);1769817699if(oldWidth !== nearestColumn.getWidth()){17700self.dispatch("column-resized", nearestColumn);17701self.table.externalEvents.dispatch("columnResized", nearestColumn.getComponent());17702}17703});1770417705if(column.modules.frozen){17706handle.style.position = "sticky";17707handle.style[column.modules.frozen.position] = this.frozenColumnOffset(column);17708}1770917710config.handleEl = handle;1771117712if(element.parentNode && column.visible){17713element.after(handle);17714}17715}1771617717component.modules.resize = config;17718}1771917720deInitializeColumn(column){17721this.deInitializeComponent(column);1772217723column.cells.forEach((cell) => {17724this.deInitializeComponent(cell);17725});17726}1772717728deInitializeComponent(component){17729var handleEl;1773017731if(component.modules.resize){17732handleEl = component.modules.resize.handleEl;1773317734if(handleEl && handleEl.parentElement){17735handleEl.parentElement.removeChild(handleEl);17736}17737}17738}1773917740resizeHandle(component, height){17741if(component.modules.resize && component.modules.resize.handleEl){17742component.modules.resize.handleEl.style.height = height;17743}17744}1774517746_checkResizability(column){17747return column.definition.resizable;17748}1774917750_mouseDown(e, column, handle){17751var self = this;1775217753self.table.element.classList.add("tabulator-block-select");1775417755function mouseMove(e){17756var x = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX,17757startDiff = x - self.startX,17758moveDiff = x - self.latestX,17759blockedBefore, blockedAfter;1776017761self.latestX = x;1776217763if(self.table.rtl){17764startDiff = -startDiff;17765moveDiff = -moveDiff;17766}1776717768blockedBefore = column.width == column.minWidth || column.width == column.maxWidth;1776917770column.setWidth(self.startWidth + startDiff);1777117772blockedAfter = column.width == column.minWidth || column.width == column.maxWidth;1777317774if(moveDiff < 0){17775self.nextColumn = self.initialNextColumn;17776}1777717778if(self.table.options.resizableColumnFit && self.nextColumn && !(blockedBefore && blockedAfter)){17779let colWidth = self.nextColumn.getWidth();1778017781if(moveDiff > 0){17782if(colWidth <= self.nextColumn.minWidth){17783self.nextColumn = self.nextColumn.nextColumn();17784}17785}1778617787if(self.nextColumn){17788self.nextColumn.setWidth(self.nextColumn.getWidth() - moveDiff);17789}17790}1779117792self.table.columnManager.rerenderColumns(true);1779317794if(!self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight){17795column.checkCellHeights();17796}17797}1779817799function mouseUp(e){1780017801//block editor from taking action while resizing is taking place17802if(self.startColumn.modules.edit){17803self.startColumn.modules.edit.blocked = false;17804}1780517806if(self.table.browserSlow && column.modules.resize && column.modules.resize.variableHeight){17807column.checkCellHeights();17808}1780917810document.body.removeEventListener("mouseup", mouseUp);17811document.body.removeEventListener("mousemove", mouseMove);1781217813handle.removeEventListener("touchmove", mouseMove);17814handle.removeEventListener("touchend", mouseUp);1781517816self.table.element.classList.remove("tabulator-block-select");1781717818if(self.startWidth !== column.getWidth()){17819self.table.columnManager.verticalAlignHeaders();1782017821self.dispatch("column-resized", column);17822self.table.externalEvents.dispatch("columnResized", column.getComponent());17823}17824}1782517826e.stopPropagation(); //prevent resize from interfering with movable columns1782717828//block editor from taking action while resizing is taking place17829if(self.startColumn.modules.edit){17830self.startColumn.modules.edit.blocked = true;17831}1783217833self.startX = typeof e.screenX === "undefined" ? e.touches[0].screenX : e.screenX;17834self.latestX = self.startX;17835self.startWidth = column.getWidth();1783617837document.body.addEventListener("mousemove", mouseMove);17838document.body.addEventListener("mouseup", mouseUp);17839handle.addEventListener("touchmove", mouseMove, {passive: true});17840handle.addEventListener("touchend", mouseUp);17841}17842}1784317844ResizeColumns.moduleName = "resizeColumns";1784517846class ResizeRows extends Module{1784717848constructor(table){17849super(table);1785017851this.startColumn = false;17852this.startY = false;17853this.startHeight = false;17854this.handle = null;17855this.prevHandle = null;1785617857this.registerTableOption("resizableRows", false); //resizable rows17858}1785917860initialize(){17861if(this.table.options.resizableRows){17862this.subscribe("row-layout-after", this.initializeRow.bind(this));17863}17864}1786517866initializeRow(row){17867var self = this,17868rowEl = row.getElement();1786917870var handle = document.createElement('div');17871handle.className = "tabulator-row-resize-handle";1787217873var prevHandle = document.createElement('div');17874prevHandle.className = "tabulator-row-resize-handle prev";1787517876handle.addEventListener("click", function(e){17877e.stopPropagation();17878});1787917880var handleDown = function(e){17881self.startRow = row;17882self._mouseDown(e, row, handle);17883};1788417885handle.addEventListener("mousedown", handleDown);17886handle.addEventListener("touchstart", handleDown, {passive: true});1788717888prevHandle.addEventListener("click", function(e){17889e.stopPropagation();17890});1789117892var prevHandleDown = function(e){17893var prevRow = self.table.rowManager.prevDisplayRow(row);1789417895if(prevRow){17896self.startRow = prevRow;17897self._mouseDown(e, prevRow, prevHandle);17898}17899};1790017901prevHandle.addEventListener("mousedown",prevHandleDown);17902prevHandle.addEventListener("touchstart",prevHandleDown, {passive: true});1790317904rowEl.appendChild(handle);17905rowEl.appendChild(prevHandle);17906}1790717908_mouseDown(e, row, handle){17909var self = this;1791017911self.table.element.classList.add("tabulator-block-select");1791217913function mouseMove(e){17914row.setHeight(self.startHeight + ((typeof e.screenY === "undefined" ? e.touches[0].screenY : e.screenY) - self.startY));17915}1791617917function mouseUp(e){1791817919// //block editor from taking action while resizing is taking place17920// if(self.startColumn.modules.edit){17921// self.startColumn.modules.edit.blocked = false;17922// }1792317924document.body.removeEventListener("mouseup", mouseMove);17925document.body.removeEventListener("mousemove", mouseMove);1792617927handle.removeEventListener("touchmove", mouseMove);17928handle.removeEventListener("touchend", mouseUp);1792917930self.table.element.classList.remove("tabulator-block-select");1793117932self.dispatchExternal("rowResized", row.getComponent());17933}1793417935e.stopPropagation(); //prevent resize from interfering with movable columns1793617937//block editor from taking action while resizing is taking place17938// if(self.startColumn.modules.edit){17939// self.startColumn.modules.edit.blocked = true;17940// }1794117942self.startY = typeof e.screenY === "undefined" ? e.touches[0].screenY : e.screenY;17943self.startHeight = row.getHeight();1794417945document.body.addEventListener("mousemove", mouseMove);17946document.body.addEventListener("mouseup", mouseUp);1794717948handle.addEventListener("touchmove", mouseMove, {passive: true});17949handle.addEventListener("touchend", mouseUp);17950}17951}1795217953ResizeRows.moduleName = "resizeRows";1795417955class ResizeTable extends Module{1795617957constructor(table){17958super(table);1795917960this.binding = false;17961this.visibilityObserver = false;17962this.resizeObserver = false;17963this.containerObserver = false;1796417965this.tableHeight = 0;17966this.tableWidth = 0;17967this.containerHeight = 0;17968this.containerWidth = 0;1796917970this.autoResize = false;1797117972this.visible = false;1797317974this.initialized = false;17975this.initialRedraw = false;1797617977this.registerTableOption("autoResize", true); //auto resize table17978}1797917980initialize(){17981if(this.table.options.autoResize){17982var table = this.table,17983tableStyle;1798417985this.tableHeight = table.element.clientHeight;17986this.tableWidth = table.element.clientWidth;1798717988if(table.element.parentNode){17989this.containerHeight = table.element.parentNode.clientHeight;17990this.containerWidth = table.element.parentNode.clientWidth;17991}1799217993if(typeof IntersectionObserver !== "undefined" && typeof ResizeObserver !== "undefined" && table.rowManager.getRenderMode() === "virtual"){1799417995this.initializeVisibilityObserver();1799617997this.autoResize = true;1799817999this.resizeObserver = new ResizeObserver((entry) => {18000if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){1800118002var nodeHeight = Math.floor(entry[0].contentRect.height);18003var nodeWidth = Math.floor(entry[0].contentRect.width);1800418005if(this.tableHeight != nodeHeight || this.tableWidth != nodeWidth){18006this.tableHeight = nodeHeight;18007this.tableWidth = nodeWidth;1800818009if(table.element.parentNode){18010this.containerHeight = table.element.parentNode.clientHeight;18011this.containerWidth = table.element.parentNode.clientWidth;18012}1801318014this.redrawTable();18015}18016}18017});1801818019this.resizeObserver.observe(table.element);1802018021tableStyle = window.getComputedStyle(table.element);1802218023if(this.table.element.parentNode && !this.table.rowManager.fixedHeight && (tableStyle.getPropertyValue("max-height") || tableStyle.getPropertyValue("min-height"))){1802418025this.containerObserver = new ResizeObserver((entry) => {18026if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){1802718028var nodeHeight = Math.floor(entry[0].contentRect.height);18029var nodeWidth = Math.floor(entry[0].contentRect.width);1803018031if(this.containerHeight != nodeHeight || this.containerWidth != nodeWidth){18032this.containerHeight = nodeHeight;18033this.containerWidth = nodeWidth;18034this.tableHeight = table.element.clientHeight;18035this.tableWidth = table.element.clientWidth;18036}1803718038this.redrawTable();18039}18040});1804118042this.containerObserver.observe(this.table.element.parentNode);18043}1804418045this.subscribe("table-resize", this.tableResized.bind(this));1804618047}else {18048this.binding = function(){18049if(!table.browserMobile || (table.browserMobile && !table.modules.edit.currentCell)){18050table.columnManager.rerenderColumns(true);18051table.redraw();18052}18053};1805418055window.addEventListener("resize", this.binding);18056}1805718058this.subscribe("table-destroy", this.clearBindings.bind(this));18059}18060}1806118062initializeVisibilityObserver(){18063this.visibilityObserver = new IntersectionObserver((entries) => {18064this.visible = entries[0].isIntersecting;1806518066if(!this.initialized){18067this.initialized = true;18068this.initialRedraw = !this.visible;18069}else {18070if(this.visible){18071this.redrawTable(this.initialRedraw);18072this.initialRedraw = false;18073}18074}18075});1807618077this.visibilityObserver.observe(this.table.element);18078}1807918080redrawTable(force){18081if(this.initialized && this.visible){18082this.table.columnManager.rerenderColumns(true);18083this.table.redraw(force);18084}18085}1808618087tableResized(){18088this.table.rowManager.redraw();18089}1809018091clearBindings(){18092if(this.binding){18093window.removeEventListener("resize", this.binding);18094}1809518096if(this.resizeObserver){18097this.resizeObserver.unobserve(this.table.element);18098}1809918100if(this.visibilityObserver){18101this.visibilityObserver.unobserve(this.table.element);18102}1810318104if(this.containerObserver){18105this.containerObserver.unobserve(this.table.element.parentNode);18106}18107}18108}1810918110ResizeTable.moduleName = "resizeTable";1811118112class ResponsiveLayout extends Module{1811318114constructor(table){18115super(table);1811618117this.columns = [];18118this.hiddenColumns = [];18119this.mode = "";18120this.index = 0;18121this.collapseFormatter = [];18122this.collapseStartOpen = true;18123this.collapseHandleColumn = false;1812418125this.registerTableOption("responsiveLayout", false); //responsive layout flags18126this.registerTableOption("responsiveLayoutCollapseStartOpen", true); //start showing collapsed data18127this.registerTableOption("responsiveLayoutCollapseUseFormatters", true); //responsive layout collapse formatter18128this.registerTableOption("responsiveLayoutCollapseFormatter", false); //responsive layout collapse formatter1812918130this.registerColumnOption("responsive");18131}1813218133//generate responsive columns list18134initialize(){18135if(this.table.options.responsiveLayout){18136this.subscribe("column-layout", this.initializeColumn.bind(this));18137this.subscribe("column-show", this.updateColumnVisibility.bind(this));18138this.subscribe("column-hide", this.updateColumnVisibility.bind(this));18139this.subscribe("columns-loaded", this.initializeResponsivity.bind(this));18140this.subscribe("column-moved", this.initializeResponsivity.bind(this));18141this.subscribe("column-add", this.initializeResponsivity.bind(this));18142this.subscribe("column-delete", this.initializeResponsivity.bind(this));1814318144this.subscribe("table-redrawing", this.tableRedraw.bind(this));1814518146if(this.table.options.responsiveLayout === "collapse"){18147this.subscribe("row-data-changed", this.generateCollapsedRowContent.bind(this));18148this.subscribe("row-init", this.initializeRow.bind(this));18149this.subscribe("row-layout", this.layoutRow.bind(this));18150}18151}18152}1815318154tableRedraw(force){18155if(["fitColumns", "fitDataStretch"].indexOf(this.layoutMode()) === -1){18156if(!force){18157this.update();18158}18159}18160}1816118162initializeResponsivity(){18163var columns = [];1816418165this.mode = this.table.options.responsiveLayout;18166this.collapseFormatter = this.table.options.responsiveLayoutCollapseFormatter || this.formatCollapsedData;18167this.collapseStartOpen = this.table.options.responsiveLayoutCollapseStartOpen;18168this.hiddenColumns = [];1816918170//determine level of responsivity for each column18171this.table.columnManager.columnsByIndex.forEach((column, i) => {18172if(column.modules.responsive){18173if(column.modules.responsive.order && column.modules.responsive.visible){18174column.modules.responsive.index = i;18175columns.push(column);1817618177if(!column.visible && this.mode === "collapse"){18178this.hiddenColumns.push(column);18179}18180}18181}18182});1818318184//sort list by responsivity18185columns = columns.reverse();18186columns = columns.sort((a, b) => {18187var diff = b.modules.responsive.order - a.modules.responsive.order;18188return diff || (b.modules.responsive.index - a.modules.responsive.index);18189});1819018191this.columns = columns;1819218193if(this.mode === "collapse"){18194this.generateCollapsedContent();18195}1819618197//assign collapse column18198for (let col of this.table.columnManager.columnsByIndex){18199if(col.definition.formatter == "responsiveCollapse"){18200this.collapseHandleColumn = col;18201break;18202}18203}1820418205if(this.collapseHandleColumn){18206if(this.hiddenColumns.length){18207this.collapseHandleColumn.show();18208}else {18209this.collapseHandleColumn.hide();18210}18211}18212}1821318214//define layout information18215initializeColumn(column){18216var def = column.getDefinition();1821718218column.modules.responsive = {order: typeof def.responsive === "undefined" ? 1 : def.responsive, visible:def.visible === false ? false : true};18219}1822018221initializeRow(row){18222var el;1822318224if(row.type !== "calc"){18225el = document.createElement("div");18226el.classList.add("tabulator-responsive-collapse");1822718228row.modules.responsiveLayout = {18229element:el,18230open:this.collapseStartOpen,18231};1823218233if(!this.collapseStartOpen){18234el.style.display = 'none';18235}18236}18237}1823818239layoutRow(row){18240var rowEl = row.getElement();1824118242if(row.modules.responsiveLayout){18243rowEl.appendChild(row.modules.responsiveLayout.element);18244this.generateCollapsedRowContent(row);18245}18246}1824718248//update column visibility18249updateColumnVisibility(column, responsiveToggle){18250if(!responsiveToggle && column.modules.responsive){18251column.modules.responsive.visible = column.visible;18252this.initializeResponsivity();18253}18254}1825518256hideColumn(column){18257var colCount = this.hiddenColumns.length;1825818259column.hide(false, true);1826018261if(this.mode === "collapse"){18262this.hiddenColumns.unshift(column);18263this.generateCollapsedContent();1826418265if(this.collapseHandleColumn && !colCount){18266this.collapseHandleColumn.show();18267}18268}18269}1827018271showColumn(column){18272var index;1827318274column.show(false, true);18275//set column width to prevent calculation loops on uninitialized columns18276column.setWidth(column.getWidth());1827718278if(this.mode === "collapse"){18279index = this.hiddenColumns.indexOf(column);1828018281if(index > -1){18282this.hiddenColumns.splice(index, 1);18283}1828418285this.generateCollapsedContent();1828618287if(this.collapseHandleColumn && !this.hiddenColumns.length){18288this.collapseHandleColumn.hide();18289}18290}18291}1829218293//redraw columns to fit space18294update(){18295var working = true;1829618297while(working){1829818299let width = this.table.modules.layout.getMode() == "fitColumns" ? this.table.columnManager.getFlexBaseWidth() : this.table.columnManager.getWidth();1830018301let diff = (this.table.options.headerVisible ? this.table.columnManager.element.clientWidth : this.table.element.clientWidth) - width;1830218303if(diff < 0){18304//table is too wide18305let column = this.columns[this.index];1830618307if(column){18308this.hideColumn(column);18309this.index ++;18310}else {18311working = false;18312}1831318314}else {1831518316//table has spare space18317let column = this.columns[this.index -1];1831818319if(column){18320if(diff > 0){18321if(diff >= column.getWidth()){18322this.showColumn(column);18323this.index --;18324}else {18325working = false;18326}18327}else {18328working = false;18329}18330}else {18331working = false;18332}18333}1833418335if(!this.table.rowManager.activeRowsCount){18336this.table.rowManager.renderEmptyScroll();18337}18338}18339}1834018341generateCollapsedContent(){18342var rows = this.table.rowManager.getDisplayRows();1834318344rows.forEach((row) => {18345this.generateCollapsedRowContent(row);18346});18347}1834818349generateCollapsedRowContent(row){18350var el, contents;1835118352if(row.modules.responsiveLayout){18353el = row.modules.responsiveLayout.element;1835418355while(el.firstChild) el.removeChild(el.firstChild);1835618357contents = this.collapseFormatter(this.generateCollapsedRowData(row));18358if(contents){18359el.appendChild(contents);18360}18361}18362}1836318364generateCollapsedRowData(row){18365var data = row.getData(),18366output = [],18367mockCellComponent;1836818369this.hiddenColumns.forEach((column) => {18370var value = column.getFieldValue(data);1837118372if(column.definition.title && column.field){18373if(column.modules.format && this.table.options.responsiveLayoutCollapseUseFormatters){1837418375mockCellComponent = {18376value:false,18377data:{},18378getValue:function(){18379return value;18380},18381getData:function(){18382return data;18383},18384getType:function(){18385return "cell";18386},18387getElement:function(){18388return document.createElement("div");18389},18390getRow:function(){18391return row.getComponent();18392},18393getColumn:function(){18394return column.getComponent();18395},18396getTable:() => {18397return this.table;18398},18399};1840018401function onRendered(callback){18402callback();18403}1840418405output.push({18406field: column.field,18407title: column.definition.title,18408value: column.modules.format.formatter.call(this.table.modules.format, mockCellComponent, column.modules.format.params, onRendered)18409});18410}else {18411output.push({18412field: column.field,18413title: column.definition.title,18414value: value18415});18416}18417}18418});1841918420return output;18421}1842218423formatCollapsedData(data){18424var list = document.createElement("table");1842518426data.forEach(function(item){18427var row = document.createElement("tr");18428var titleData = document.createElement("td");18429var valueData = document.createElement("td");18430var node_content;1843118432var titleHighlight = document.createElement("strong");18433titleData.appendChild(titleHighlight);18434this.langBind("columns|" + item.field, function(text){18435titleHighlight.innerHTML = text || item.title;18436});1843718438if(item.value instanceof Node){18439node_content = document.createElement("div");18440node_content.appendChild(item.value);18441valueData.appendChild(node_content);18442}else {18443valueData.innerHTML = item.value;18444}1844518446row.appendChild(titleData);18447row.appendChild(valueData);18448list.appendChild(row);18449}, this);1845018451return Object.keys(data).length ? list : "";18452}18453}1845418455ResponsiveLayout.moduleName = "responsiveLayout";1845618457class SelectRow extends Module{1845818459constructor(table){18460super(table);1846118462this.selecting = false; //flag selecting in progress18463this.lastClickedRow = false; //last clicked row18464this.selectPrev = []; //hold previously selected element for drag drop selection18465this.selectedRows = []; //hold selected rows18466this.headerCheckboxElement = null; // hold header select element1846718468this.registerTableOption("selectable", "highlight"); //highlight rows on hover18469this.registerTableOption("selectableRangeMode", "drag"); //highlight rows on hover18470this.registerTableOption("selectableRollingSelection", true); //roll selection once maximum number of selectable rows is reached18471this.registerTableOption("selectablePersistence", true); // maintain selection when table view is updated18472this.registerTableOption("selectableCheck", function(data, row){return true;}); //check whether row is selectable1847318474this.registerTableFunction("selectRow", this.selectRows.bind(this));18475this.registerTableFunction("deselectRow", this.deselectRows.bind(this));18476this.registerTableFunction("toggleSelectRow", this.toggleRow.bind(this));18477this.registerTableFunction("getSelectedRows", this.getSelectedRows.bind(this));18478this.registerTableFunction("getSelectedData", this.getSelectedData.bind(this));1847918480//register component functions18481this.registerComponentFunction("row", "select", this.selectRows.bind(this));18482this.registerComponentFunction("row", "deselect", this.deselectRows.bind(this));18483this.registerComponentFunction("row", "toggleSelect", this.toggleRow.bind(this));18484this.registerComponentFunction("row", "isSelected", this.isRowSelected.bind(this));18485}1848618487initialize(){18488if(this.table.options.selectable !== false){18489this.subscribe("row-init", this.initializeRow.bind(this));18490this.subscribe("row-deleting", this.rowDeleted.bind(this));18491this.subscribe("rows-wipe", this.clearSelectionData.bind(this));18492this.subscribe("rows-retrieve", this.rowRetrieve.bind(this));1849318494if(this.table.options.selectable && !this.table.options.selectablePersistence){18495this.subscribe("data-refreshing", this.deselectRows.bind(this));18496}18497}18498}1849918500rowRetrieve(type, prevValue){18501return type === "selected" ? this.selectedRows : prevValue;18502}1850318504rowDeleted(row){18505this._deselectRow(row, true);18506}1850718508clearSelectionData(silent){18509var prevSelected = this.selectedRows.length;1851018511this.selecting = false;18512this.lastClickedRow = false;18513this.selectPrev = [];18514this.selectedRows = [];1851518516if(prevSelected && silent !== true){18517this._rowSelectionChanged();18518}18519}1852018521initializeRow(row){18522var self = this,18523element = row.getElement();1852418525// trigger end of row selection18526var endSelect = function(){1852718528setTimeout(function(){18529self.selecting = false;18530}, 50);1853118532document.body.removeEventListener("mouseup", endSelect);18533};1853418535row.modules.select = {selected:false};1853618537//set row selection class18538if(self.checkRowSelectability(row)){18539element.classList.add("tabulator-selectable");18540element.classList.remove("tabulator-unselectable");1854118542if(self.table.options.selectable && self.table.options.selectable != "highlight"){18543if(self.table.options.selectableRangeMode === "click"){18544element.addEventListener("click", this.handleComplexRowClick.bind(this, row));18545}else {18546element.addEventListener("click", function(e){18547if(!self.table.modExists("edit") || !self.table.modules.edit.getCurrentCell()){18548self.table._clearSelection();18549}1855018551if(!self.selecting){18552self.toggleRow(row);18553}18554});1855518556element.addEventListener("mousedown", function(e){18557if(e.shiftKey){18558self.table._clearSelection();1855918560self.selecting = true;1856118562self.selectPrev = [];1856318564document.body.addEventListener("mouseup", endSelect);18565document.body.addEventListener("keyup", endSelect);1856618567self.toggleRow(row);1856818569return false;18570}18571});1857218573element.addEventListener("mouseenter", function(e){18574if(self.selecting){18575self.table._clearSelection();18576self.toggleRow(row);1857718578if(self.selectPrev[1] == row){18579self.toggleRow(self.selectPrev[0]);18580}18581}18582});1858318584element.addEventListener("mouseout", function(e){18585if(self.selecting){18586self.table._clearSelection();18587self.selectPrev.unshift(row);18588}18589});18590}18591}1859218593}else {18594element.classList.add("tabulator-unselectable");18595element.classList.remove("tabulator-selectable");18596}18597}1859818599handleComplexRowClick(row, e){18600if(e.shiftKey){18601this.table._clearSelection();18602this.lastClickedRow = this.lastClickedRow || row;1860318604var lastClickedRowIdx = this.table.rowManager.getDisplayRowIndex(this.lastClickedRow);18605var rowIdx = this.table.rowManager.getDisplayRowIndex(row);1860618607var fromRowIdx = lastClickedRowIdx <= rowIdx ? lastClickedRowIdx : rowIdx;18608var toRowIdx = lastClickedRowIdx >= rowIdx ? lastClickedRowIdx : rowIdx;1860918610var rows = this.table.rowManager.getDisplayRows().slice(0);18611var toggledRows = rows.splice(fromRowIdx, toRowIdx - fromRowIdx + 1);1861218613if(e.ctrlKey || e.metaKey){18614toggledRows.forEach((toggledRow)=>{18615if(toggledRow !== this.lastClickedRow){1861618617if(this.table.options.selectable !== true && !this.isRowSelected(row)){18618if(this.selectedRows.length < this.table.options.selectable){18619this.toggleRow(toggledRow);18620}18621}else {18622this.toggleRow(toggledRow);18623}18624}18625});18626this.lastClickedRow = row;18627}else {18628this.deselectRows(undefined, true);1862918630if(this.table.options.selectable !== true){18631if(toggledRows.length > this.table.options.selectable){18632toggledRows = toggledRows.slice(0, this.table.options.selectable);18633}18634}1863518636this.selectRows(toggledRows);18637}18638this.table._clearSelection();18639}18640else if(e.ctrlKey || e.metaKey){18641this.toggleRow(row);18642this.lastClickedRow = row;18643}else {18644this.deselectRows(undefined, true);18645this.selectRows(row);18646this.lastClickedRow = row;18647}18648}1864918650checkRowSelectability(row){18651if(row && row.type === "row"){18652return this.table.options.selectableCheck.call(this.table, row.getComponent());18653}1865418655return false;18656}1865718658//toggle row selection18659toggleRow(row){18660if(this.checkRowSelectability(row)){18661if(row.modules.select && row.modules.select.selected){18662this._deselectRow(row);18663}else {18664this._selectRow(row);18665}18666}18667}1866818669//select a number of rows18670selectRows(rows){18671var changes = [],18672rowMatch, change;1867318674switch(typeof rows){18675case "undefined":18676rowMatch = this.table.rowManager.rows;18677break;1867818679case "string":18680rowMatch = this.table.rowManager.findRow(rows);1868118682if(!rowMatch){18683rowMatch = this.table.rowManager.getRows(rows);18684}18685break;1868618687default:18688rowMatch = rows;18689break;18690}1869118692if(Array.isArray(rowMatch)){18693if(rowMatch.length){18694rowMatch.forEach((row) => {18695change = this._selectRow(row, true, true);1869618697if(change){18698changes.push(change);18699}18700});1870118702this._rowSelectionChanged(false, changes);18703}18704}else {18705if(rowMatch){18706this._selectRow(rowMatch, false, true);18707}18708}18709}1871018711//select an individual row18712_selectRow(rowInfo, silent, force){18713//handle max row count18714if(!isNaN(this.table.options.selectable) && this.table.options.selectable !== true && !force){18715if(this.selectedRows.length >= this.table.options.selectable){18716if(this.table.options.selectableRollingSelection){18717this._deselectRow(this.selectedRows[0]);18718}else {18719return false;18720}18721}18722}1872318724var row = this.table.rowManager.findRow(rowInfo);1872518726if(row){18727if(this.selectedRows.indexOf(row) == -1){18728row.getElement().classList.add("tabulator-selected");18729if(!row.modules.select){18730row.modules.select = {};18731}1873218733row.modules.select.selected = true;18734if(row.modules.select.checkboxEl){18735row.modules.select.checkboxEl.checked = true;18736}1873718738this.selectedRows.push(row);1873918740if(this.table.options.dataTreeSelectPropagate){18741this.childRowSelection(row, true);18742}1874318744this.dispatchExternal("rowSelected", row.getComponent());1874518746this._rowSelectionChanged(silent, row);1874718748return row;18749}18750}else {18751if(!silent){18752console.warn("Selection Error - No such row found, ignoring selection:" + rowInfo);18753}18754}18755}1875618757isRowSelected(row){18758return this.selectedRows.indexOf(row) !== -1;18759}1876018761//deselect a number of rows18762deselectRows(rows, silent){18763var changes = [],18764rowMatch, change;1876518766switch(typeof rows){18767case "undefined":18768rowMatch = Object.assign([], this.selectedRows);18769break;1877018771case "string":18772rowMatch = this.table.rowManager.findRow(rows);1877318774if(!rowMatch){18775rowMatch = this.table.rowManager.getRows(rows);18776}18777break;1877818779default:18780rowMatch = rows;18781break;18782}1878318784if(Array.isArray(rowMatch)){18785if(rowMatch.length){18786rowMatch.forEach((row) => {18787change = this._deselectRow(row, true, true);1878818789if(change){18790changes.push(change);18791}18792});1879318794this._rowSelectionChanged(silent, [], changes);18795}18796}else {18797if(rowMatch){18798this._deselectRow(rowMatch, silent, true);18799}18800}18801}1880218803//deselect an individual row18804_deselectRow(rowInfo, silent){18805var self = this,18806row = self.table.rowManager.findRow(rowInfo),18807index, element;1880818809if(row){18810index = self.selectedRows.findIndex(function(selectedRow){18811return selectedRow == row;18812});1881318814if(index > -1){1881518816element = row.getElement();1881718818if(element){18819element.classList.remove("tabulator-selected");18820}1882118822if(!row.modules.select){18823row.modules.select = {};18824}1882518826row.modules.select.selected = false;18827if(row.modules.select.checkboxEl){18828row.modules.select.checkboxEl.checked = false;18829}18830self.selectedRows.splice(index, 1);1883118832if(this.table.options.dataTreeSelectPropagate){18833this.childRowSelection(row, false);18834}1883518836this.dispatchExternal("rowDeselected", row.getComponent());1883718838self._rowSelectionChanged(silent, undefined, row);1883918840return row;18841}18842}else {18843if(!silent){18844console.warn("Deselection Error - No such row found, ignoring selection:" + rowInfo);18845}18846}18847}1884818849getSelectedData(){18850var data = [];1885118852this.selectedRows.forEach(function(row){18853data.push(row.getData());18854});1885518856return data;18857}1885818859getSelectedRows(){18860var rows = [];1886118862this.selectedRows.forEach(function(row){18863rows.push(row.getComponent());18864});1886518866return rows;18867}1886818869_rowSelectionChanged(silent, selected = [], deselected = []){18870if(this.headerCheckboxElement){18871if(this.selectedRows.length === 0){18872this.headerCheckboxElement.checked = false;18873this.headerCheckboxElement.indeterminate = false;18874} else if(this.table.rowManager.rows.length === this.selectedRows.length){18875this.headerCheckboxElement.checked = true;18876this.headerCheckboxElement.indeterminate = false;18877} else {18878this.headerCheckboxElement.indeterminate = true;18879this.headerCheckboxElement.checked = false;18880}18881}1888218883if(!silent){18884if(!Array.isArray(selected)){18885selected = [selected];18886}1888718888selected = selected.map(row => row.getComponent());1888918890if(!Array.isArray(deselected)){18891deselected = [deselected];18892}1889318894deselected = deselected.map(row => row.getComponent());1889518896this.dispatchExternal("rowSelectionChanged", this.getSelectedData(), this.getSelectedRows(), selected, deselected);18897}18898}1889918900registerRowSelectCheckbox (row, element) {18901if(!row._row.modules.select){18902row._row.modules.select = {};18903}1890418905row._row.modules.select.checkboxEl = element;18906}1890718908registerHeaderSelectCheckbox (element) {18909this.headerCheckboxElement = element;18910}1891118912childRowSelection(row, select){18913var children = this.table.modules.dataTree.getChildren(row, true);1891418915if(select){18916for(let child of children){18917this._selectRow(child, true);18918}18919}else {18920for(let child of children){18921this._deselectRow(child, true);18922}18923}18924}18925}1892618927SelectRow.moduleName = "selectRow";1892818929//sort numbers18930function number$1(a, b, aRow, bRow, column, dir, params){18931var alignEmptyValues = params.alignEmptyValues;18932var decimal = params.decimalSeparator;18933var thousand = params.thousandSeparator;18934var emptyAlign = 0;1893518936a = String(a);18937b = String(b);1893818939if(thousand){18940a = a.split(thousand).join("");18941b = b.split(thousand).join("");18942}1894318944if(decimal){18945a = a.split(decimal).join(".");18946b = b.split(decimal).join(".");18947}1894818949a = parseFloat(a);18950b = parseFloat(b);1895118952//handle non numeric values18953if(isNaN(a)){18954emptyAlign = isNaN(b) ? 0 : -1;18955}else if(isNaN(b)){18956emptyAlign = 1;18957}else {18958//compare valid values18959return a - b;18960}1896118962//fix empty values in position18963if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){18964emptyAlign *= -1;18965}1896618967return emptyAlign;18968}1896918970//sort strings18971function string(a, b, aRow, bRow, column, dir, params){18972var alignEmptyValues = params.alignEmptyValues;18973var emptyAlign = 0;18974var locale;1897518976//handle empty values18977if(!a){18978emptyAlign = !b ? 0 : -1;18979}else if(!b){18980emptyAlign = 1;18981}else {18982//compare valid values18983switch(typeof params.locale){18984case "boolean":18985if(params.locale){18986locale = this.langLocale();18987}18988break;18989case "string":18990locale = params.locale;18991break;18992}1899318994return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);18995}1899618997//fix empty values in position18998if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){18999emptyAlign *= -1;19000}1900119002return emptyAlign;19003}1900419005//sort datetime19006function datetime$2(a, b, aRow, bRow, column, dir, params){19007var DT = window.DateTime || luxon.DateTime;19008var format = params.format || "dd/MM/yyyy HH:mm:ss",19009alignEmptyValues = params.alignEmptyValues,19010emptyAlign = 0;1901119012if(typeof DT != "undefined"){19013if(!DT.isDateTime(a)){19014if(format === "iso"){19015a = DT.fromISO(String(a));19016}else {19017a = DT.fromFormat(String(a), format);19018}19019}1902019021if(!DT.isDateTime(b)){19022if(format === "iso"){19023b = DT.fromISO(String(b));19024}else {19025b = DT.fromFormat(String(b), format);19026}19027}1902819029if(!a.isValid){19030emptyAlign = !b.isValid ? 0 : -1;19031}else if(!b.isValid){19032emptyAlign = 1;19033}else {19034//compare valid values19035return a - b;19036}1903719038//fix empty values in position19039if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){19040emptyAlign *= -1;19041}1904219043return emptyAlign;1904419045}else {19046console.error("Sort Error - 'datetime' sorter is dependant on luxon.js");19047}19048}1904919050//sort date19051function date$1(a, b, aRow, bRow, column, dir, params){19052if(!params.format){19053params.format = "dd/MM/yyyy";19054}1905519056return datetime$2.call(this, a, b, aRow, bRow, column, dir, params);19057}1905819059//sort times19060function time$1(a, b, aRow, bRow, column, dir, params){19061if(!params.format){19062params.format = "HH:mm";19063}1906419065return datetime$2.call(this, a, b, aRow, bRow, column, dir, params);19066}1906719068//sort booleans19069function boolean(a, b, aRow, bRow, column, dir, params){19070var el1 = a === true || a === "true" || a === "True" || a === 1 ? 1 : 0;19071var el2 = b === true || b === "true" || b === "True" || b === 1 ? 1 : 0;1907219073return el1 - el2;19074}1907519076//sort if element contains any data19077function array(a, b, aRow, bRow, column, dir, params){19078var type = params.type || "length",19079alignEmptyValues = params.alignEmptyValues,19080emptyAlign = 0;1908119082function calc(value){19083var result;1908419085switch(type){19086case "length":19087result = value.length;19088break;1908919090case "sum":19091result = value.reduce(function(c, d){19092return c + d;19093});19094break;1909519096case "max":19097result = Math.max.apply(null, value) ;19098break;1909919100case "min":19101result = Math.min.apply(null, value) ;19102break;1910319104case "avg":19105result = value.reduce(function(c, d){19106return c + d;19107}) / value.length;19108break;19109}1911019111return result;19112}1911319114//handle non array values19115if(!Array.isArray(a)){19116emptyAlign = !Array.isArray(b) ? 0 : -1;19117}else if(!Array.isArray(b)){19118emptyAlign = 1;19119}else {19120return calc(b) - calc(a);19121}1912219123//fix empty values in position19124if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){19125emptyAlign *= -1;19126}1912719128return emptyAlign;19129}1913019131//sort if element contains any data19132function exists(a, b, aRow, bRow, column, dir, params){19133var el1 = typeof a == "undefined" ? 0 : 1;19134var el2 = typeof b == "undefined" ? 0 : 1;1913519136return el1 - el2;19137}1913819139//sort alpha numeric strings19140function alphanum(as, bs, aRow, bRow, column, dir, params){19141var a, b, a1, b1, i= 0, L, rx = /(\d+)|(\D+)/g, rd = /\d/;19142var alignEmptyValues = params.alignEmptyValues;19143var emptyAlign = 0;1914419145//handle empty values19146if(!as && as!== 0){19147emptyAlign = !bs && bs!== 0 ? 0 : -1;19148}else if(!bs && bs!== 0){19149emptyAlign = 1;19150}else {1915119152if(isFinite(as) && isFinite(bs)) return as - bs;19153a = String(as).toLowerCase();19154b = String(bs).toLowerCase();19155if(a === b) return 0;19156if(!(rd.test(a) && rd.test(b))) return a > b ? 1 : -1;19157a = a.match(rx);19158b = b.match(rx);19159L = a.length > b.length ? b.length : a.length;19160while(i < L){19161a1= a[i];19162b1= b[i++];19163if(a1 !== b1){19164if(isFinite(a1) && isFinite(b1)){19165if(a1.charAt(0) === "0") a1 = "." + a1;19166if(b1.charAt(0) === "0") b1 = "." + b1;19167return a1 - b1;19168}19169else return a1 > b1 ? 1 : -1;19170}19171}1917219173return a.length > b.length;19174}1917519176//fix empty values in position19177if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){19178emptyAlign *= -1;19179}1918019181return emptyAlign;19182}1918319184var defaultSorters = {19185number:number$1,19186string:string,19187date:date$1,19188time:time$1,19189datetime:datetime$2,19190boolean:boolean,19191array:array,19192exists:exists,19193alphanum:alphanum19194};1919519196class Sort extends Module{1919719198constructor(table){19199super(table);1920019201this.sortList = []; //holder current sort19202this.changed = false; //has the sort changed since last render1920319204this.registerTableOption("sortMode", "local"); //local or remote sorting1920519206this.registerTableOption("initialSort", false); //initial sorting criteria19207this.registerTableOption("columnHeaderSortMulti", true); //multiple or single column sorting19208this.registerTableOption("sortOrderReverse", false); //reverse internal sort ordering19209this.registerTableOption("headerSortElement", "<div class='tabulator-arrow'></div>"); //header sort element19210this.registerTableOption("headerSortClickElement", "header"); //element which triggers sort when clicked1921119212this.registerColumnOption("sorter");19213this.registerColumnOption("sorterParams");1921419215this.registerColumnOption("headerSort", true);19216this.registerColumnOption("headerSortStartingDir");19217this.registerColumnOption("headerSortTristate");1921819219}1922019221initialize(){19222this.subscribe("column-layout", this.initializeColumn.bind(this));19223this.subscribe("table-built", this.tableBuilt.bind(this));19224this.registerDataHandler(this.sort.bind(this), 20);1922519226this.registerTableFunction("setSort", this.userSetSort.bind(this));19227this.registerTableFunction("getSorters", this.getSort.bind(this));19228this.registerTableFunction("clearSort", this.clearSort.bind(this));1922919230if(this.table.options.sortMode === "remote"){19231this.subscribe("data-params", this.remoteSortParams.bind(this));19232}19233}1923419235tableBuilt(){19236if(this.table.options.initialSort){19237this.setSort(this.table.options.initialSort);19238}19239}1924019241remoteSortParams(data, config, silent, params){19242var sorters = this.getSort();1924319244sorters.forEach((item) => {19245delete item.column;19246});1924719248params.sort = sorters;1924919250return params;19251}192521925319254///////////////////////////////////19255///////// Table Functions /////////19256///////////////////////////////////1925719258userSetSort(sortList, dir){19259this.setSort(sortList, dir);19260// this.table.rowManager.sorterRefresh();19261this.refreshSort();19262}1926319264clearSort(){19265this.clear();19266// this.table.rowManager.sorterRefresh();19267this.refreshSort();19268}192691927019271///////////////////////////////////19272///////// Internal Logic //////////19273///////////////////////////////////1927419275//initialize column header for sorting19276initializeColumn(column){19277var sorter = false,19278colEl,19279arrowEl;1928019281switch(typeof column.definition.sorter){19282case "string":19283if(Sort.sorters[column.definition.sorter]){19284sorter = Sort.sorters[column.definition.sorter];19285}else {19286console.warn("Sort Error - No such sorter found: ", column.definition.sorter);19287}19288break;1928919290case "function":19291sorter = column.definition.sorter;19292break;19293}1929419295column.modules.sort = {19296sorter:sorter, dir:"none",19297params:column.definition.sorterParams || {},19298startingDir:column.definition.headerSortStartingDir || "asc",19299tristate: column.definition.headerSortTristate,19300};1930119302if(column.definition.headerSort !== false){1930319304colEl = column.getElement();1930519306colEl.classList.add("tabulator-sortable");1930719308arrowEl = document.createElement("div");19309arrowEl.classList.add("tabulator-col-sorter");1931019311switch(this.table.options.headerSortClickElement){19312case "icon":19313arrowEl.classList.add("tabulator-col-sorter-element");19314break;19315case "header":19316colEl.classList.add("tabulator-col-sorter-element");19317break;19318default:19319colEl.classList.add("tabulator-col-sorter-element");19320break;19321}1932219323switch(this.table.options.headerSortElement){19324case "function":19325//do nothing19326break;1932719328case "object":19329arrowEl.appendChild(this.table.options.headerSortElement);19330break;1933119332default:19333arrowEl.innerHTML = this.table.options.headerSortElement;19334}1933519336//create sorter arrow19337column.titleHolderElement.appendChild(arrowEl);1933819339column.modules.sort.element = arrowEl;1934019341this.setColumnHeaderSortIcon(column, "none");1934219343//sort on click19344(this.table.options.headerSortClickElement === "icon" ? arrowEl : colEl).addEventListener("click", (e) => {19345var dir = "",19346sorters=[],19347match = false;1934819349if(column.modules.sort){19350if(column.modules.sort.tristate){19351if(column.modules.sort.dir == "none"){19352dir = column.modules.sort.startingDir;19353}else {19354if(column.modules.sort.dir == column.modules.sort.startingDir){19355dir = column.modules.sort.dir == "asc" ? "desc" : "asc";19356}else {19357dir = "none";19358}19359}19360}else {19361switch(column.modules.sort.dir){19362case "asc":19363dir = "desc";19364break;1936519366case "desc":19367dir = "asc";19368break;1936919370default:19371dir = column.modules.sort.startingDir;19372}19373}1937419375if (this.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) {19376sorters = this.getSort();1937719378match = sorters.findIndex((sorter) => {19379return sorter.field === column.getField();19380});1938119382if(match > -1){19383sorters[match].dir = dir;1938419385match = sorters.splice(match, 1)[0];19386if(dir != "none"){19387sorters.push(match);19388}19389}else {19390if(dir != "none"){19391sorters.push({column:column, dir:dir});19392}19393}1939419395//add to existing sort19396this.setSort(sorters);19397}else {19398if(dir == "none"){19399this.clear();19400}else {19401//sort by column only19402this.setSort(column, dir);19403}1940419405}1940619407// this.table.rowManager.sorterRefresh(!this.sortList.length);19408this.refreshSort();19409}19410});19411}19412}1941319414refreshSort(){19415if(this.table.options.sortMode === "remote"){19416this.reloadData(null, false, false);19417}else {19418this.refreshData(true);19419}1942019421//TODO - Persist left position of row manager19422// left = this.scrollLeft;19423// this.scrollHorizontal(left);19424}1942519426//check if the sorters have changed since last use19427hasChanged(){19428var changed = this.changed;19429this.changed = false;19430return changed;19431}1943219433//return current sorters19434getSort(){19435var self = this,19436sorters = [];1943719438self.sortList.forEach(function(item){19439if(item.column){19440sorters.push({column:item.column.getComponent(), field:item.column.getField(), dir:item.dir});19441}19442});1944319444return sorters;19445}1944619447//change sort list and trigger sort19448setSort(sortList, dir){19449var self = this,19450newSortList = [];1945119452if(!Array.isArray(sortList)){19453sortList = [{column: sortList, dir:dir}];19454}1945519456sortList.forEach(function(item){19457var column;1945819459column = self.table.columnManager.findColumn(item.column);1946019461if(column){19462item.column = column;19463newSortList.push(item);19464self.changed = true;19465}else {19466console.warn("Sort Warning - Sort field does not exist and is being ignored: ", item.column);19467}1946819469});1947019471self.sortList = newSortList;1947219473this.dispatch("sort-changed");19474}1947519476//clear sorters19477clear(){19478this.setSort([]);19479}1948019481//find appropriate sorter for column19482findSorter(column){19483var row = this.table.rowManager.activeRows[0],19484sorter = "string",19485field, value;1948619487if(row){19488row = row.getData();19489field = column.getField();1949019491if(field){1949219493value = column.getFieldValue(row);1949419495switch(typeof value){19496case "undefined":19497sorter = "string";19498break;1949919500case "boolean":19501sorter = "boolean";19502break;1950319504default:19505if(!isNaN(value) && value !== ""){19506sorter = "number";19507}else {19508if(value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)){19509sorter = "alphanum";19510}19511}19512break;19513}19514}19515}1951619517return Sort.sorters[sorter];19518}1951919520//work through sort list sorting data19521sort(data){19522var self = this,19523sortList = this.table.options.sortOrderReverse ? self.sortList.slice().reverse() : self.sortList,19524sortListActual = [],19525rowComponents = [];1952619527if(this.subscribedExternal("dataSorting")){19528this.dispatchExternal("dataSorting", self.getSort());19529}1953019531self.clearColumnHeaders();1953219533if(this.table.options.sortMode !== "remote"){1953419535//build list of valid sorters and trigger column specific callbacks before sort begins19536sortList.forEach(function(item, i){19537var sortObj;1953819539if(item.column){19540sortObj = item.column.modules.sort;1954119542if(sortObj){1954319544//if no sorter has been defined, take a guess19545if(!sortObj.sorter){19546sortObj.sorter = self.findSorter(item.column);19547}1954819549item.params = typeof sortObj.params === "function" ? sortObj.params(item.column.getComponent(), item.dir) : sortObj.params;1955019551sortListActual.push(item);19552}1955319554self.setColumnHeader(item.column, item.dir);19555}19556});1955719558//sort data19559if (sortListActual.length) {19560self._sortItems(data, sortListActual);19561}1956219563}else {19564sortList.forEach(function(item, i){19565self.setColumnHeader(item.column, item.dir);19566});19567}1956819569if(this.subscribedExternal("dataSorted")){19570data.forEach((row) => {19571rowComponents.push(row.getComponent());19572});1957319574this.dispatchExternal("dataSorted", self.getSort(), rowComponents);19575}1957619577return data;19578}1957919580//clear sort arrows on columns19581clearColumnHeaders(){19582this.table.columnManager.getRealColumns().forEach((column) => {19583if(column.modules.sort){19584column.modules.sort.dir = "none";19585column.getElement().setAttribute("aria-sort", "none");19586this.setColumnHeaderSortIcon(column, "none");19587}19588});19589}1959019591//set the column header sort direction19592setColumnHeader(column, dir){19593column.modules.sort.dir = dir;19594column.getElement().setAttribute("aria-sort", dir === "asc" ? "ascending" : "descending");19595this.setColumnHeaderSortIcon(column, dir);19596}1959719598setColumnHeaderSortIcon(column, dir){19599var sortEl = column.modules.sort.element,19600arrowEl;1960119602if(column.definition.headerSort && typeof this.table.options.headerSortElement === "function"){19603while(sortEl.firstChild) sortEl.removeChild(sortEl.firstChild);1960419605arrowEl = this.table.options.headerSortElement.call(this.table, column.getComponent(), dir);1960619607if(typeof arrowEl === "object"){19608sortEl.appendChild(arrowEl);19609}else {19610sortEl.innerHTML = arrowEl;19611}19612}19613}1961419615//sort each item in sort list19616_sortItems(data, sortList){19617var sorterCount = sortList.length - 1;1961819619data.sort((a, b) => {19620var result;1962119622for(var i = sorterCount; i>= 0; i--){19623let sortItem = sortList[i];1962419625result = this._sortRow(a, b, sortItem.column, sortItem.dir, sortItem.params);1962619627if(result !== 0){19628break;19629}19630}1963119632return result;19633});19634}1963519636//process individual rows for a sort function on active data19637_sortRow(a, b, column, dir, params){19638var el1Comp, el2Comp;1963919640//switch elements depending on search direction19641var el1 = dir == "asc" ? a : b;19642var el2 = dir == "asc" ? b : a;1964319644a = column.getFieldValue(el1.getData());19645b = column.getFieldValue(el2.getData());1964619647a = typeof a !== "undefined" ? a : "";19648b = typeof b !== "undefined" ? b : "";1964919650el1Comp = el1.getComponent();19651el2Comp = el2.getComponent();1965219653return column.modules.sort.sorter.call(this, a, b, el1Comp, el2Comp, column.getComponent(), dir, params);19654}19655}1965619657Sort.moduleName = "sort";1965819659//load defaults19660Sort.sorters = defaultSorters;1966119662class Tooltip extends Module{1966319664constructor(table){19665super(table);1966619667this.tooltipSubscriber = null,19668this.headerSubscriber = null,1966919670this.timeout = null;19671this.popupInstance = null;1967219673this.registerTableOption("tooltipGenerationMode", undefined); //deprecated19674this.registerTableOption("tooltipDelay", 300);1967519676this.registerColumnOption("tooltip");19677this.registerColumnOption("headerTooltip");19678}1967919680initialize(){19681this.deprecatedOptionsCheck();1968219683this.subscribe("column-init", this.initializeColumn.bind(this));19684}1968519686deprecatedOptionsCheck(){19687this.deprecationCheckMsg("tooltipGenerationMode", "This option is no longer needed as tooltips are always generated on hover now");19688}1968919690initializeColumn(column){19691if(column.definition.headerTooltip && !this.headerSubscriber){19692this.headerSubscriber = true;1969319694this.subscribe("column-mousemove", this.mousemoveCheck.bind(this, "headerTooltip"));19695this.subscribe("column-mouseout", this.mouseoutCheck.bind(this, "headerTooltip"));19696}1969719698if(column.definition.tooltip && !this.tooltipSubscriber){19699this.tooltipSubscriber = true;1970019701this.subscribe("cell-mousemove", this.mousemoveCheck.bind(this, "tooltip"));19702this.subscribe("cell-mouseout", this.mouseoutCheck.bind(this, "tooltip"));19703}19704}1970519706mousemoveCheck(action, e, component){19707var tooltip = action === "tooltip" ? component.column.definition.tooltip : component.definition.headerTooltip;1970819709if(tooltip){19710this.clearPopup();19711this.timeout = setTimeout(this.loadTooltip.bind(this, e, component, tooltip), this.table.options.tooltipDelay);19712}19713}1971419715mouseoutCheck(action, e, component){19716if(!this.popupInstance){19717this.clearPopup();19718}19719}1972019721clearPopup(action, e, component){19722clearTimeout(this.timeout);19723this.timeout = null;1972419725if(this.popupInstance){19726this.popupInstance.hide();19727}19728}1972919730loadTooltip(e, component, tooltip){19731var contentsEl, renderedCallback, coords;1973219733function onRendered(callback){19734renderedCallback = callback;19735}1973619737if(typeof tooltip === "function"){19738tooltip = tooltip(e, component.getComponent(), onRendered);19739}1974019741if(tooltip instanceof HTMLElement){19742contentsEl = tooltip;19743}else {19744contentsEl = document.createElement("div");1974519746if(tooltip === true){19747if(component instanceof Cell){19748tooltip = component.value;19749}else {19750if(component.definition.field){19751this.langBind("columns|" + component.definition.field, (value) => {19752contentsEl.innerHTML = tooltip = value || component.definition.title;19753});19754}else {19755tooltip = component.definition.title;19756}19757}19758}1975919760contentsEl.innerHTML = tooltip;19761}1976219763if(tooltip || tooltip === 0 || tooltip === false){19764contentsEl.classList.add("tabulator-tooltip");1976519766contentsEl.addEventListener("mousemove", e => e.preventDefault());1976719768this.popupInstance = this.popup(contentsEl);1976919770if(typeof renderedCallback === "function"){19771this.popupInstance.renderCallback(renderedCallback);19772}1977319774coords = this.popupInstance.containerEventCoords(e);1977519776this.popupInstance.show(coords.x + 15, coords.y + 15).hideOnBlur(() => {19777this.dispatchExternal("TooltipClosed", component.getComponent());19778this.popupInstance = null;19779});1978019781this.dispatchExternal("TooltipOpened", component.getComponent());19782}19783}19784}1978519786Tooltip.moduleName = "tooltip";1978719788var defaultValidators = {19789//is integer19790integer: function(cell, value, parameters){19791if(value === "" || value === null || typeof value === "undefined"){19792return true;19793}1979419795value = Number(value);1979619797return !isNaN(value) && isFinite(value) && Math.floor(value) === value;19798},1979919800//is float19801float: function(cell, value, parameters){19802if(value === "" || value === null || typeof value === "undefined"){19803return true;19804}1980519806value = Number(value);1980719808return !isNaN(value) && isFinite(value) && value % 1 !== 0;19809},1981019811//must be a number19812numeric: function(cell, value, parameters){19813if(value === "" || value === null || typeof value === "undefined"){19814return true;19815}19816return !isNaN(value);19817},1981819819//must be a string19820string: function(cell, value, parameters){19821if(value === "" || value === null || typeof value === "undefined"){19822return true;19823}19824return isNaN(value);19825},1982619827//maximum value19828max: function(cell, value, parameters){19829if(value === "" || value === null || typeof value === "undefined"){19830return true;19831}19832return parseFloat(value) <= parameters;19833},1983419835//minimum value19836min: function(cell, value, parameters){19837if(value === "" || value === null || typeof value === "undefined"){19838return true;19839}19840return parseFloat(value) >= parameters;19841},1984219843//starts with value19844starts: function(cell, value, parameters){19845if(value === "" || value === null || typeof value === "undefined"){19846return true;19847}19848return String(value).toLowerCase().startsWith(String(parameters).toLowerCase());19849},1985019851//ends with value19852ends: function(cell, value, parameters){19853if(value === "" || value === null || typeof value === "undefined"){19854return true;19855}19856return String(value).toLowerCase().endsWith(String(parameters).toLowerCase());19857},198581985919860//minimum string length19861minLength: function(cell, value, parameters){19862if(value === "" || value === null || typeof value === "undefined"){19863return true;19864}19865return String(value).length >= parameters;19866},1986719868//maximum string length19869maxLength: function(cell, value, parameters){19870if(value === "" || value === null || typeof value === "undefined"){19871return true;19872}19873return String(value).length <= parameters;19874},1987519876//in provided value list19877in: function(cell, value, parameters){19878if(value === "" || value === null || typeof value === "undefined"){19879return true;19880}1988119882if(typeof parameters == "string"){19883parameters = parameters.split("|");19884}1988519886return parameters.indexOf(value) > -1;19887},1988819889//must match provided regex19890regex: function(cell, value, parameters){19891if(value === "" || value === null || typeof value === "undefined"){19892return true;19893}19894var reg = new RegExp(parameters);1989519896return reg.test(value);19897},1989819899//value must be unique in this column19900unique: function(cell, value, parameters){19901if(value === "" || value === null || typeof value === "undefined"){19902return true;19903}19904var unique = true;1990519906var cellData = cell.getData();19907var column = cell.getColumn()._getSelf();1990819909this.table.rowManager.rows.forEach(function(row){19910var data = row.getData();1991119912if(data !== cellData){19913if(value == column.getFieldValue(data)){19914unique = false;19915}19916}19917});1991819919return unique;19920},1992119922//must have a value19923required:function(cell, value, parameters){19924return value !== "" && value !== null && typeof value !== "undefined";19925},19926};1992719928class Validate extends Module{1992919930constructor(table){19931super(table);1993219933this.invalidCells = [];1993419935this.registerTableOption("validationMode", "blocking");1993619937this.registerColumnOption("validator");1993819939this.registerTableFunction("getInvalidCells", this.getInvalidCells.bind(this));19940this.registerTableFunction("clearCellValidation", this.userClearCellValidation.bind(this));19941this.registerTableFunction("validate", this.userValidate.bind(this));1994219943this.registerComponentFunction("cell", "isValid", this.cellIsValid.bind(this));19944this.registerComponentFunction("cell", "clearValidation", this.clearValidation.bind(this));19945this.registerComponentFunction("cell", "validate", this.cellValidate.bind(this));1994619947this.registerComponentFunction("column", "validate", this.columnValidate.bind(this));19948this.registerComponentFunction("row", "validate", this.rowValidate.bind(this));19949}199501995119952initialize(){19953this.subscribe("cell-delete", this.clearValidation.bind(this));19954this.subscribe("column-layout", this.initializeColumnCheck.bind(this));1995519956this.subscribe("edit-success", this.editValidate.bind(this));19957this.subscribe("edit-editor-clear", this.editorClear.bind(this));19958this.subscribe("edit-edited-clear", this.editedClear.bind(this));19959}1996019961///////////////////////////////////19962///////// Event Handling //////////19963///////////////////////////////////1996419965editValidate(cell, value, previousValue){19966var valid = this.table.options.validationMode !== "manual" ? this.validate(cell.column.modules.validate, cell, value) : true;1996719968// allow time for editor to make render changes then style cell19969if(valid !== true){19970setTimeout(() => {19971cell.getElement().classList.add("tabulator-validation-fail");19972this.dispatchExternal("validationFailed", cell.getComponent(), value, valid);19973});19974}1997519976return valid;19977}1997819979editorClear(cell, cancelled){19980if(cancelled){19981if(cell.column.modules.validate){19982this.cellValidate(cell);19983}19984}1998519986cell.getElement().classList.remove("tabulator-validation-fail");19987}1998819989editedClear(cell){19990if(cell.modules.validate){19991cell.modules.validate.invalid = false;19992}19993}1999419995///////////////////////////////////19996////////// Cell Functions /////////19997///////////////////////////////////1999819999cellIsValid(cell){20000return cell.modules.validate ? (cell.modules.validate.invalid || true) : true;20001}2000220003cellValidate(cell){20004return this.validate(cell.column.modules.validate, cell, cell.getValue());20005}2000620007///////////////////////////////////20008///////// Column Functions ////////20009///////////////////////////////////2001020011columnValidate(column){20012var invalid = [];2001320014column.cells.forEach((cell) => {20015if(this.cellValidate(cell) !== true){20016invalid.push(cell.getComponent());20017}20018});2001920020return invalid.length ? invalid : true;20021}2002220023///////////////////////////////////20024////////// Row Functions //////////20025///////////////////////////////////2002620027rowValidate(row){20028var invalid = [];2002920030row.cells.forEach((cell) => {20031if(this.cellValidate(cell) !== true){20032invalid.push(cell.getComponent());20033}20034});2003520036return invalid.length ? invalid : true;20037}2003820039///////////////////////////////////20040///////// Table Functions /////////20041///////////////////////////////////200422004320044userClearCellValidation(cells){20045if(!cells){20046cells = this.getInvalidCells();20047}2004820049if(!Array.isArray(cells)){20050cells = [cells];20051}2005220053cells.forEach((cell) => {20054this.clearValidation(cell._getSelf());20055});20056}2005720058userValidate(cells){20059var output = [];2006020061//clear row data20062this.table.rowManager.rows.forEach((row) => {20063row = row.getComponent();2006420065var valid = row.validate();2006620067if(valid !== true){20068output = output.concat(valid);20069}20070});2007120072return output.length ? output : true;20073}2007420075///////////////////////////////////20076///////// Internal Logic //////////20077///////////////////////////////////2007820079initializeColumnCheck(column){20080if(typeof column.definition.validator !== "undefined"){20081this.initializeColumn(column);20082}20083}2008420085//validate20086initializeColumn(column){20087var self = this,20088config = [],20089validator;2009020091if(column.definition.validator){2009220093if(Array.isArray(column.definition.validator)){20094column.definition.validator.forEach((item) => {20095validator = self._extractValidator(item);2009620097if(validator){20098config.push(validator);20099}20100});2010120102}else {20103validator = this._extractValidator(column.definition.validator);2010420105if(validator){20106config.push(validator);20107}20108}2010920110column.modules.validate = config.length ? config : false;20111}20112}2011320114_extractValidator(value){20115var type, params, pos;2011620117switch(typeof value){20118case "string":20119pos = value.indexOf(':');2012020121if(pos > -1){20122type = value.substring(0,pos);20123params = value.substring(pos+1);20124}else {20125type = value;20126}2012720128return this._buildValidator(type, params);2012920130case "function":20131return this._buildValidator(value);2013220133case "object":20134return this._buildValidator(value.type, value.parameters);20135}20136}2013720138_buildValidator(type, params){2013920140var func = typeof type == "function" ? type : Validate.validators[type];2014120142if(!func){20143console.warn("Validator Setup Error - No matching validator found:", type);20144return false;20145}else {20146return {20147type:typeof type == "function" ? "function" : type,20148func:func,20149params:params,20150};20151}20152}2015320154validate(validators, cell, value){20155var self = this,20156failedValidators = [],20157invalidIndex = this.invalidCells.indexOf(cell);2015820159if(validators){20160validators.forEach((item) => {20161if(!item.func.call(self, cell.getComponent(), value, item.params)){20162failedValidators.push({20163type:item.type,20164parameters:item.params20165});20166}20167});20168}2016920170if(!cell.modules.validate){20171cell.modules.validate = {};20172}2017320174if(!failedValidators.length){20175cell.modules.validate.invalid = false;20176cell.getElement().classList.remove("tabulator-validation-fail");2017720178if(invalidIndex > -1){20179this.invalidCells.splice(invalidIndex, 1);20180}20181}else {20182cell.modules.validate.invalid = failedValidators;2018320184if(this.table.options.validationMode !== "manual"){20185cell.getElement().classList.add("tabulator-validation-fail");20186}2018720188if(invalidIndex == -1){20189this.invalidCells.push(cell);20190}20191}2019220193return failedValidators.length ? failedValidators : true;20194}2019520196getInvalidCells(){20197var output = [];2019820199this.invalidCells.forEach((cell) => {20200output.push(cell.getComponent());20201});2020220203return output;20204}2020520206clearValidation(cell){20207var invalidIndex;2020820209if(cell.modules.validate && cell.modules.validate.invalid){2021020211cell.getElement().classList.remove("tabulator-validation-fail");20212cell.modules.validate.invalid = false;2021320214invalidIndex = this.invalidCells.indexOf(cell);2021520216if(invalidIndex > -1){20217this.invalidCells.splice(invalidIndex, 1);20218}20219}20220}20221}2022220223Validate.moduleName = "validate";2022420225//load defaults20226Validate.validators = defaultValidators;2022720228var modules = /*#__PURE__*/Object.freeze({20229__proto__: null,20230AccessorModule: Accessor,20231AjaxModule: Ajax,20232ClipboardModule: Clipboard,20233ColumnCalcsModule: ColumnCalcs,20234DataTreeModule: DataTree,20235DownloadModule: Download,20236EditModule: Edit$1,20237ExportModule: Export,20238FilterModule: Filter,20239FormatModule: Format,20240FrozenColumnsModule: FrozenColumns,20241FrozenRowsModule: FrozenRows,20242GroupRowsModule: GroupRows,20243HistoryModule: History,20244HtmlTableImportModule: HtmlTableImport,20245ImportModule: Import,20246InteractionModule: Interaction,20247KeybindingsModule: Keybindings,20248MenuModule: Menu,20249MoveColumnsModule: MoveColumns,20250MoveRowsModule: MoveRows,20251MutatorModule: Mutator,20252PageModule: Page,20253PersistenceModule: Persistence,20254PopupModule: Popup$1,20255PrintModule: Print,20256ReactiveDataModule: ReactiveData,20257ResizeColumnsModule: ResizeColumns,20258ResizeRowsModule: ResizeRows,20259ResizeTableModule: ResizeTable,20260ResponsiveLayoutModule: ResponsiveLayout,20261SelectRowModule: SelectRow,20262SortModule: Sort,20263TooltipModule: Tooltip,20264ValidateModule: Validate20265});2026620267var defaultOptions = {2026820269debugEventsExternal:false, //flag to console log events20270debugEventsInternal:false, //flag to console log events20271debugInvalidOptions:true, //allow toggling of invalid option warnings20272debugInvalidComponentFuncs:true, //allow toggling of invalid component warnings20273debugInitialization:true, //allow toggling of pre initialization function call warnings20274debugDeprecation:true, //allow toggling of deprecation warnings2027520276height:false, //height of tabulator20277minHeight:false, //minimum height of tabulator20278maxHeight:false, //maximum height of tabulator2027920280columnHeaderVertAlign:"top", //vertical alignment of column headers2028120282popupContainer:false,2028320284columns:[],//store for colum header info20285columnDefaults:{}, //store column default props2028620287data:false, //default starting data2028820289autoColumns:false, //build columns from data row structure20290autoColumnsDefinitions:false,2029120292nestedFieldSeparator:".", //separator for nested data2029320294footerElement:false, //hold footer element2029520296index:"id", //filed for row index2029720298textDirection:"auto",2029920300addRowPos:"bottom", //position to insert blank rows, top|bottom2030120302headerVisible:true, //hide header2030320304renderVertical:"virtual",20305renderHorizontal:"basic",20306renderVerticalBuffer:0, // set virtual DOM buffer size2030720308scrollToRowPosition:"top",20309scrollToRowIfVisible:true,2031020311scrollToColumnPosition:"left",20312scrollToColumnIfVisible:true,2031320314rowFormatter:false,20315rowFormatterPrint:null,20316rowFormatterClipboard:null,20317rowFormatterHtmlOutput:null,2031820319rowHeight:null,2032020321placeholder:false,2032220323dataLoader:true,20324dataLoaderLoading:false,20325dataLoaderError:false,20326dataLoaderErrorTimeout:3000,2032720328dataSendParams:{},2032920330dataReceiveParams:{},20331};2033220333class OptionsList {20334constructor(table, msgType, defaults = {}){20335this.table = table;20336this.msgType = msgType;20337this.registeredDefaults = Object.assign({}, defaults);20338}2033920340register(option, value){20341this.registeredDefaults[option] = value;20342}2034320344generate(defaultOptions, userOptions = {}){20345var output = Object.assign({}, this.registeredDefaults),20346warn = this.table.options.debugInvalidOptions || userOptions.debugInvalidOptions === true;2034720348Object.assign(output, defaultOptions);2034920350for (let key in userOptions){20351if(!output.hasOwnProperty(key)){20352if(warn){20353console.warn("Invalid " + this.msgType + " option:", key);20354}2035520356output[key] = userOptions.key;20357}20358}203592036020361for (let key in output){20362if(key in userOptions){20363output[key] = userOptions[key];20364}else {20365if(Array.isArray(output[key])){20366output[key] = Object.assign([], output[key]);20367}else if(typeof output[key] === "object" && output[key] !== null){20368output[key] = Object.assign({}, output[key]);20369}else if (typeof output[key] === "undefined"){20370delete output[key];20371}20372}20373}2037420375return output;20376}20377}2037820379class Renderer extends CoreFeature{20380constructor(table){20381super(table);2038220383this.elementVertical = table.rowManager.element;20384this.elementHorizontal = table.columnManager.element;20385this.tableElement = table.rowManager.tableElement;2038620387this.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)20388}203892039020391///////////////////////////////////20392/////// Internal Bindings /////////20393///////////////////////////////////2039420395initialize(){20396//initialize core functionality20397}2039820399clearRows(){20400//clear down existing rows layout20401}2040220403clearColumns(){20404//clear down existing columns layout20405}204062040720408reinitializeColumnWidths(columns){20409//resize columns to fit data20410}204112041220413renderRows(){20414//render rows from a clean slate20415}2041620417renderColumns(){20418//render columns from a clean slate20419}2042020421rerenderRows(callback){20422// rerender rows and keep position20423if(callback){20424callback();20425}20426}2042720428rerenderColumns(update, blockRedraw){20429//rerender columns20430}2043120432renderRowCells(row){20433//render the cells in a row20434}2043520436rerenderRowCells(row, force){20437//rerender the cells in a row20438}2043920440scrollColumns(left, dir){20441//handle horizontal scrolling20442}2044320444scrollRows(top, dir){20445//handle vertical scrolling20446}2044720448resize(){20449//container has resized, carry out any needed recalculations (DO NOT RERENDER IN THIS FUNCTION)20450}2045120452scrollToRow(row){20453//scroll to a specific row20454}2045520456scrollToRowNearestTop(row){20457//determine weather the row is nearest the top or bottom of the table, return true for top or false for bottom20458}2045920460visibleRows(includingBuffer){20461//return the visible rows20462return [];20463}2046420465///////////////////////////////////20466//////// Helper Functions /////////20467///////////////////////////////////2046820469rows(){20470return this.table.rowManager.getDisplayRows();20471}2047220473styleRow(row, index){20474var rowEl = row.getElement();2047520476if(index % 2){20477rowEl.classList.add("tabulator-row-even");20478rowEl.classList.remove("tabulator-row-odd");20479}else {20480rowEl.classList.add("tabulator-row-odd");20481rowEl.classList.remove("tabulator-row-even");20482}20483}2048420485///////////////////////////////////20486/////// External Triggers /////////20487/////// (DO NOT OVERRIDE) /////////20488///////////////////////////////////2048920490clear(){20491//clear down existing layout20492this.clearRows();20493this.clearColumns();20494}2049520496render(){20497//render from a clean slate20498this.renderRows();20499this.renderColumns();20500}2050120502rerender(callback){20503// rerender and keep position20504this.rerenderRows();20505this.rerenderColumns();20506}2050720508scrollToRowPosition(row, position, ifVisible){20509var rowIndex = this.rows().indexOf(row),20510rowEl = row.getElement(),20511offset = 0;2051220513return new Promise((resolve, reject) => {20514if(rowIndex > -1){2051520516if(typeof ifVisible === "undefined"){20517ifVisible = this.table.options.scrollToRowIfVisible;20518}2051920520//check row visibility20521if(!ifVisible){20522if(Helpers.elVisible(rowEl)){20523offset = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top;2052420525if(offset > 0 && offset < this.elementVertical.clientHeight - rowEl.offsetHeight){20526resolve();20527return false;20528}20529}20530}2053120532if(typeof position === "undefined"){20533position = this.table.options.scrollToRowPosition;20534}2053520536if(position === "nearest"){20537position = this.scrollToRowNearestTop(row) ? "top" : "bottom";20538}2053920540//scroll to row20541this.scrollToRow(row);2054220543//align to correct position20544switch(position){20545case "middle":20546case "center":2054720548if(this.elementVertical.scrollHeight - this.elementVertical.scrollTop == this.elementVertical.clientHeight){20549this.elementVertical.scrollTop = this.elementVertical.scrollTop + (rowEl.offsetTop - this.elementVertical.scrollTop) - ((this.elementVertical.scrollHeight - rowEl.offsetTop) / 2);20550}else {20551this.elementVertical.scrollTop = this.elementVertical.scrollTop - (this.elementVertical.clientHeight / 2);20552}2055320554break;2055520556case "bottom":2055720558if(this.elementVertical.scrollHeight - this.elementVertical.scrollTop == this.elementVertical.clientHeight){20559this.elementVertical.scrollTop = this.elementVertical.scrollTop - (this.elementVertical.scrollHeight - rowEl.offsetTop) + rowEl.offsetHeight;20560}else {20561this.elementVertical.scrollTop = this.elementVertical.scrollTop - this.elementVertical.clientHeight + rowEl.offsetHeight;20562}2056320564break;2056520566case "top":20567this.elementVertical.scrollTop = rowEl.offsetTop;20568break;20569}2057020571resolve();2057220573}else {20574console.warn("Scroll Error - Row not visible");20575reject("Scroll Error - Row not visible");20576}20577});20578}20579}2058020581class BasicHorizontal extends Renderer{20582constructor(table){20583super(table);20584}2058520586renderRowCells(row, inFragment) {20587const rowFrag = document.createDocumentFragment();20588row.cells.forEach((cell) => {20589rowFrag.appendChild(cell.getElement());20590});20591row.element.appendChild(rowFrag);2059220593if(!inFragment){20594row.cells.forEach((cell) => {20595cell.cellRendered();20596});20597}20598}2059920600reinitializeColumnWidths(columns){20601columns.forEach(function(column){20602column.reinitializeWidth();20603});20604}20605}2060620607class VirtualDomHorizontal extends Renderer{20608constructor(table){20609super(table);2061020611this.leftCol = 0;20612this.rightCol = 0;20613this.scrollLeft = 0;2061420615this.vDomScrollPosLeft = 0;20616this.vDomScrollPosRight = 0;2061720618this.vDomPadLeft = 0;20619this.vDomPadRight = 0;2062020621this.fitDataColAvg = 0;2062220623this.windowBuffer = 200; //pixel margin to make column visible before it is shown on screen2062420625this.visibleRows = null;2062620627this.initialized = false;20628this.isFitData = false;2062920630this.columns = [];20631}2063220633initialize(){20634this.compatibilityCheck();20635this.layoutCheck();20636this.vertScrollListen();20637}2063820639compatibilityCheck(){20640if(this.options("layout") == "fitDataTable"){20641console.warn("Horizontal Virtual DOM is not compatible with fitDataTable layout mode");20642}2064320644if(this.options("responsiveLayout")){20645console.warn("Horizontal Virtual DOM is not compatible with responsive columns");20646}2064720648if(this.options("rtl")){20649console.warn("Horizontal Virtual DOM is not currently compatible with RTL text direction");20650}20651}2065220653layoutCheck(){20654this.isFitData = this.options("layout").startsWith('fitData');20655}2065620657vertScrollListen(){20658this.subscribe("scroll-vertical", this.clearVisRowCache.bind(this));20659this.subscribe("data-refreshed", this.clearVisRowCache.bind(this));20660}2066120662clearVisRowCache(){20663this.visibleRows = null;20664}2066520666//////////////////////////////////////20667///////// Public Functions ///////////20668//////////////////////////////////////2066920670renderColumns(row, force){20671this.dataChange();20672}206732067420675scrollColumns(left, dir){20676if(this.scrollLeft != left){20677this.scrollLeft = left;2067820679this.scroll(left - (this.vDomScrollPosLeft + this.windowBuffer));20680}20681}2068220683calcWindowBuffer(){20684var buffer = this.elementVertical.clientWidth;2068520686this.table.columnManager.columnsByIndex.forEach((column) => {20687if(column.visible){20688var width = column.getWidth();2068920690if(width > buffer){20691buffer = width;20692}20693}20694});2069520696this.windowBuffer = buffer * 2;20697}2069820699rerenderColumns(update, blockRedraw){20700var old = {20701cols:this.columns,20702leftCol:this.leftCol,20703rightCol:this.rightCol,20704},20705colPos = 0;2070620707if(update && !this.initialized){20708return;20709}2071020711this.clear();2071220713this.calcWindowBuffer();2071420715this.scrollLeft = this.elementVertical.scrollLeft;2071620717this.vDomScrollPosLeft = this.scrollLeft - this.windowBuffer;20718this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;2071920720this.table.columnManager.columnsByIndex.forEach((column) => {20721var config = {},20722width;2072320724if(column.visible){20725if(!column.modules.frozen){20726width = column.getWidth();2072720728config.leftPos = colPos;20729config.rightPos = colPos + width;2073020731config.width = width;2073220733if (this.isFitData) {20734config.fitDataCheck = column.modules.vdomHoz ? column.modules.vdomHoz.fitDataCheck : true;20735}2073620737if((colPos + width > this.vDomScrollPosLeft) && (colPos < this.vDomScrollPosRight)){20738//column is visible2073920740if(this.leftCol == -1){20741this.leftCol = this.columns.length;20742this.vDomPadLeft = colPos;20743}2074420745this.rightCol = this.columns.length;20746}else {20747// column is hidden20748if(this.leftCol !== -1){20749this.vDomPadRight += width;20750}20751}2075220753this.columns.push(column);2075420755column.modules.vdomHoz = config;2075620757colPos += width;20758}20759}20760});2076120762this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";20763this.tableElement.style.paddingRight = this.vDomPadRight + "px";2076420765this.initialized = true;2076620767if(!blockRedraw){20768if(!update || this.reinitChanged(old)){20769this.reinitializeRows();20770}20771}2077220773this.elementVertical.scrollLeft = this.scrollLeft;20774}2077520776renderRowCells(row){20777if(this.initialized){20778this.initializeRow(row);20779}else {20780const rowFrag = document.createDocumentFragment();20781row.cells.forEach((cell) => {20782rowFrag.appendChild(cell.getElement());20783});20784row.element.appendChild(rowFrag);2078520786row.cells.forEach((cell) => {20787cell.cellRendered();20788});20789}20790}2079120792rerenderRowCells(row, force){20793this.reinitializeRow(row, force);20794}2079520796reinitializeColumnWidths(columns){20797for(let i = this.leftCol; i <= this.rightCol; i++){20798this.columns[i].reinitializeWidth();20799}20800}2080120802//////////////////////////////////////20803//////// Internal Rendering //////////20804//////////////////////////////////////2080520806deinitialize(){20807this.initialized = false;20808}2080920810clear(){20811this.columns = [];2081220813this.leftCol = -1;20814this.rightCol = 0;2081520816this.vDomScrollPosLeft = 0;20817this.vDomScrollPosRight = 0;20818this.vDomPadLeft = 0;20819this.vDomPadRight = 0;20820}2082120822dataChange(){20823var change = false,20824row, rowEl;2082520826if(this.isFitData){20827this.table.columnManager.columnsByIndex.forEach((column) => {20828if(!column.definition.width && column.visible){20829change = true;20830}20831});2083220833if(change && this.table.rowManager.getDisplayRows().length){20834this.vDomScrollPosRight = this.scrollLeft + this.elementVertical.clientWidth + this.windowBuffer;2083520836row = this.chain("rows-sample", [1], [], () => {20837return this.table.rowManager.getDisplayRows();20838})[0];2083920840if(row){20841rowEl = row.getElement();2084220843row.generateCells();2084420845this.tableElement.appendChild(rowEl);2084620847for(let colEnd = 0; colEnd < row.cells.length; colEnd++){20848let cell = row.cells[colEnd];20849rowEl.appendChild(cell.getElement());2085020851cell.column.reinitializeWidth();20852}2085320854rowEl.parentNode.removeChild(rowEl);2085520856this.rerenderColumns(false, true);20857}20858}20859}else {20860if(this.options("layout") === "fitColumns"){20861this.layoutRefresh();20862this.rerenderColumns(false, true);20863}20864}20865}2086620867reinitChanged(old){20868var match = true;2086920870if(old.cols.length !== this.columns.length || old.leftCol !== this.leftCol || old.rightCol !== this.rightCol){20871return true;20872}2087320874old.cols.forEach((col, i) => {20875if(col !== this.columns[i]){20876match = false;20877}20878});2087920880return !match;20881}2088220883reinitializeRows(){20884var visibleRows = this.getVisibleRows(),20885otherRows = this.table.rowManager.getRows().filter(row => !visibleRows.includes(row));2088620887visibleRows.forEach((row) => {20888this.reinitializeRow(row, true);20889});2089020891otherRows.forEach((row) =>{20892row.deinitialize();20893});20894}2089520896getVisibleRows(){20897if (!this.visibleRows){20898this.visibleRows = this.table.rowManager.getVisibleRows();20899}2090020901return this.visibleRows;20902}2090320904scroll(diff){20905this.vDomScrollPosLeft += diff;20906this.vDomScrollPosRight += diff;2090720908if(Math.abs(diff) > (this.windowBuffer / 2)){20909this.rerenderColumns();20910}else {20911if(diff > 0){20912//scroll right20913this.addColRight();20914this.removeColLeft();20915}else {20916//scroll left20917this.addColLeft();20918this.removeColRight();20919}20920}20921}2092220923colPositionAdjust (start, end, diff){20924for(let i = start; i < end; i++){20925let column = this.columns[i];2092620927column.modules.vdomHoz.leftPos += diff;20928column.modules.vdomHoz.rightPos += diff;20929}20930}2093120932addColRight(){20933var changes = false,20934working = true;2093520936while(working){2093720938let column = this.columns[this.rightCol + 1];2093920940if(column){20941if(column.modules.vdomHoz.leftPos <= this.vDomScrollPosRight){20942changes = true;2094320944this.getVisibleRows().forEach((row) => {20945if(row.type !== "group"){20946var cell = row.getCell(column);20947row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.rightCol]).getElement().nextSibling);20948cell.cellRendered();20949}20950});2095120952this.fitDataColActualWidthCheck(column);2095320954this.rightCol++; // Don't move this below the >= check below2095520956this.getVisibleRows().forEach((row) => {20957if(row.type !== "group"){20958row.modules.vdomHoz.rightCol = this.rightCol;20959}20960});2096120962if(this.rightCol >= (this.columns.length - 1)){20963this.vDomPadRight = 0;20964}else {20965this.vDomPadRight -= column.getWidth();20966}20967}else {20968working = false;20969}20970}else {20971working = false;20972}20973}2097420975if(changes){20976this.tableElement.style.paddingRight = this.vDomPadRight + "px";20977}20978}2097920980addColLeft(){20981var changes = false,20982working = true;2098320984while(working){20985let column = this.columns[this.leftCol - 1];2098620987if(column){20988if(column.modules.vdomHoz.rightPos >= this.vDomScrollPosLeft){20989changes = true;2099020991this.getVisibleRows().forEach((row) => {20992if(row.type !== "group"){20993var cell = row.getCell(column);20994row.getElement().insertBefore(cell.getElement(), row.getCell(this.columns[this.leftCol]).getElement());20995cell.cellRendered();20996}20997});2099820999this.leftCol--; // don't move this below the <= check below2100021001this.getVisibleRows().forEach((row) => {21002if(row.type !== "group"){21003row.modules.vdomHoz.leftCol = this.leftCol;21004}21005});2100621007if(this.leftCol <= 0){ // replicating logic in addColRight21008this.vDomPadLeft = 0;21009}else {21010this.vDomPadLeft -= column.getWidth();21011}2101221013let diff = this.fitDataColActualWidthCheck(column);2101421015if(diff){21016this.scrollLeft = this.elementVertical.scrollLeft = this.elementVertical.scrollLeft + diff;21017this.vDomPadRight -= diff;21018}2101921020}else {21021working = false;21022}21023}else {21024working = false;21025}21026}2102721028if(changes){21029this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";21030}21031}2103221033removeColRight(){21034var changes = false,21035working = true;2103621037while(working){21038let column = this.columns[this.rightCol];2103921040if(column){21041if(column.modules.vdomHoz.leftPos > this.vDomScrollPosRight){21042changes = true;2104321044this.getVisibleRows().forEach((row) => {21045if(row.type !== "group"){21046var cell = row.getCell(column);2104721048try {21049row.getElement().removeChild(cell.getElement());21050} catch (ex) {21051console.warn("Could not removeColRight", ex.message);21052}21053}21054});2105521056this.vDomPadRight += column.getWidth();21057this.rightCol --;2105821059this.getVisibleRows().forEach((row) => {21060if(row.type !== "group"){21061row.modules.vdomHoz.rightCol = this.rightCol;21062}21063});21064}else {21065working = false;21066}21067}else {21068working = false;21069}21070}2107121072if(changes){21073this.tableElement.style.paddingRight = this.vDomPadRight + "px";21074}21075}2107621077removeColLeft(){21078var changes = false,21079working = true;2108021081while(working){21082let column = this.columns[this.leftCol];2108321084if(column){21085if(column.modules.vdomHoz.rightPos < this.vDomScrollPosLeft){21086changes = true;2108721088this.getVisibleRows().forEach((row) => {21089if(row.type !== "group"){21090var cell = row.getCell(column);2109121092try {21093row.getElement().removeChild(cell.getElement());21094} catch (ex) {21095console.warn("Could not removeColLeft", ex.message);21096}21097}21098});2109921100this.vDomPadLeft += column.getWidth();21101this.leftCol ++;2110221103this.getVisibleRows().forEach((row) => {21104if(row.type !== "group"){21105row.modules.vdomHoz.leftCol = this.leftCol;21106}21107});21108}else {21109working = false;21110}21111}else {21112working = false;21113}21114}2111521116if(changes){21117this.tableElement.style.paddingLeft = this.vDomPadLeft + "px";21118}21119}2112021121fitDataColActualWidthCheck(column){21122var newWidth, widthDiff;2112321124if(column.modules.vdomHoz.fitDataCheck){21125column.reinitializeWidth();2112621127newWidth = column.getWidth();21128widthDiff = newWidth - column.modules.vdomHoz.width;2112921130if(widthDiff){21131column.modules.vdomHoz.rightPos += widthDiff;21132column.modules.vdomHoz.width = newWidth;21133this.colPositionAdjust(this.columns.indexOf(column) + 1, this.columns.length, widthDiff);21134}2113521136column.modules.vdomHoz.fitDataCheck = false;21137}2113821139return widthDiff;21140}2114121142initializeRow(row){21143if(row.type !== "group"){21144row.modules.vdomHoz = {21145leftCol:this.leftCol,21146rightCol:this.rightCol,21147};2114821149if(this.table.modules.frozenColumns){21150this.table.modules.frozenColumns.leftColumns.forEach((column) => {21151this.appendCell(row, column);21152});21153}2115421155for(let i = this.leftCol; i <= this.rightCol; i++){21156this.appendCell(row, this.columns[i]);21157}2115821159if(this.table.modules.frozenColumns){21160this.table.modules.frozenColumns.rightColumns.forEach((column) => {21161this.appendCell(row, column);21162});21163}21164}21165}2116621167appendCell(row, column){21168if(column && column.visible){21169let cell = row.getCell(column);2117021171row.getElement().appendChild(cell.getElement());21172cell.cellRendered();21173}21174}2117521176reinitializeRow(row, force){21177if(row.type !== "group"){21178if(force || !row.modules.vdomHoz || row.modules.vdomHoz.leftCol !== this.leftCol || row.modules.vdomHoz.rightCol !== this.rightCol){2117921180var rowEl = row.getElement();21181while(rowEl.firstChild) rowEl.removeChild(rowEl.firstChild);2118221183this.initializeRow(row);21184}21185}21186}21187}2118821189class ColumnManager extends CoreFeature {2119021191constructor (table){21192super(table);2119321194this.blockHozScrollEvent = false;21195this.headersElement = null;21196this.contentsElement = null;21197this.element = null ; //containing element21198this.columns = []; // column definition object21199this.columnsByIndex = []; //columns by index21200this.columnsByField = {}; //columns by field21201this.scrollLeft = 0;21202this.optionsList = new OptionsList(this.table, "column definition", defaultColumnOptions);2120321204this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing21205this.redrawBlockUpdate = null; //store latest redraw update only status2120621207this.renderer = null;21208}2120921210////////////// Setup Functions /////////////////2121121212initialize(){21213this.initializeRenderer();2121421215this.headersElement = this.createHeadersElement();21216this.contentsElement = this.createHeaderContentsElement();21217this.element = this.createHeaderElement();2121821219this.contentsElement.insertBefore(this.headersElement, this.contentsElement.firstChild);21220this.element.insertBefore(this.contentsElement, this.element.firstChild);2122121222this.initializeScrollWheelWatcher();2122321224this.subscribe("scroll-horizontal", this.scrollHorizontal.bind(this));21225this.subscribe("scrollbar-vertical", this.padVerticalScrollbar.bind(this));21226}2122721228padVerticalScrollbar(width){21229if(this.table.rtl){21230this.headersElement.style.marginLeft = width + "px";21231}else {21232this.headersElement.style.marginRight = width + "px";21233}21234}2123521236initializeRenderer(){21237var renderClass;2123821239var renderers = {21240"virtual": VirtualDomHorizontal,21241"basic": BasicHorizontal,21242};2124321244if(typeof this.table.options.renderHorizontal === "string"){21245renderClass = renderers[this.table.options.renderHorizontal];21246}else {21247renderClass = this.table.options.renderHorizontal;21248}2124921250if(renderClass){21251this.renderer = new renderClass(this.table, this.element, this.tableElement);21252this.renderer.initialize();21253}else {21254console.error("Unable to find matching renderer:", this.table.options.renderHorizontal);21255}21256}212572125821259createHeadersElement (){21260var el = document.createElement("div");2126121262el.classList.add("tabulator-headers");21263el.setAttribute("role", "row");2126421265return el;21266}2126721268createHeaderContentsElement (){21269var el = document.createElement("div");2127021271el.classList.add("tabulator-header-contents");21272el.setAttribute("role", "rowgroup");2127321274return el;21275}2127621277createHeaderElement (){21278var el = document.createElement("div");2127921280el.classList.add("tabulator-header");21281el.setAttribute("role", "rowgroup");2128221283if(!this.table.options.headerVisible){21284el.classList.add("tabulator-header-hidden");21285}2128621287return el;21288}2128921290//return containing element21291getElement(){21292return this.element;21293}2129421295//return containing contents element21296getContentsElement(){21297return this.contentsElement;21298}212992130021301//return header containing element21302getHeadersElement(){21303return this.headersElement;21304}2130521306//scroll horizontally to match table body21307scrollHorizontal(left){21308this.contentsElement.scrollLeft = left;2130921310this.scrollLeft = left;2131121312this.renderer.scrollColumns(left);21313}2131421315initializeScrollWheelWatcher(){21316this.contentsElement.addEventListener("wheel", (e) => {21317var left;2131821319if(e.deltaX){21320left = this.contentsElement.scrollLeft + e.deltaX;2132121322this.table.rowManager.scrollHorizontal(left);21323this.table.columnManager.scrollHorizontal(left);21324}21325});21326}2132721328///////////// Column Setup Functions /////////////21329generateColumnsFromRowData(data){21330var cols = [],21331definitions = this.table.options.autoColumnsDefinitions,21332row, sorter;2133321334if(data && data.length){2133521336row = data[0];2133721338for(var key in row){21339let col = {21340field:key,21341title:key,21342};2134321344let value = row[key];2134521346switch(typeof value){21347case "undefined":21348sorter = "string";21349break;2135021351case "boolean":21352sorter = "boolean";21353break;2135421355case "object":21356if(Array.isArray(value)){21357sorter = "array";21358}else {21359sorter = "string";21360}21361break;2136221363default:21364if(!isNaN(value) && value !== ""){21365sorter = "number";21366}else {21367if(value.match(/((^[0-9]+[a-z]+)|(^[a-z]+[0-9]+))+$/i)){21368sorter = "alphanum";21369}else {21370sorter = "string";21371}21372}21373break;21374}2137521376col.sorter = sorter;2137721378cols.push(col);21379}2138021381if(definitions){2138221383switch(typeof definitions){21384case "function":21385this.table.options.columns = definitions.call(this.table, cols);21386break;2138721388case "object":21389if(Array.isArray(definitions)){21390cols.forEach((col) => {21391var match = definitions.find((def) => {21392return def.field === col.field;21393});2139421395if(match){21396Object.assign(col, match);21397}21398});2139921400}else {21401cols.forEach((col) => {21402if(definitions[col.field]){21403Object.assign(col, definitions[col.field]);21404}21405});21406}2140721408this.table.options.columns = cols;21409break;21410}21411}else {21412this.table.options.columns = cols;21413}2141421415this.setColumns(this.table.options.columns);21416}21417}2141821419setColumns(cols, row){21420while(this.headersElement.firstChild) this.headersElement.removeChild(this.headersElement.firstChild);2142121422this.columns = [];21423this.columnsByIndex = [];21424this.columnsByField = {};2142521426this.dispatch("columns-loading");2142721428cols.forEach((def, i) => {21429this._addColumn(def);21430});2143121432this._reIndexColumns();2143321434this.dispatch("columns-loaded");2143521436this.rerenderColumns(false, true);2143721438this.redraw(true);21439}2144021441_addColumn(definition, before, nextToColumn){21442var column = new Column(definition, this),21443colEl = column.getElement(),21444index = nextToColumn ? this.findColumnIndex(nextToColumn) : nextToColumn;2144521446if(nextToColumn && index > -1){21447var topColumn = nextToColumn.getTopColumn();21448var parentIndex = this.columns.indexOf(topColumn);21449var nextEl = topColumn.getElement();2145021451if(before){21452this.columns.splice(parentIndex, 0, column);21453nextEl.parentNode.insertBefore(colEl, nextEl);21454}else {21455this.columns.splice(parentIndex + 1, 0, column);21456nextEl.parentNode.insertBefore(colEl, nextEl.nextSibling);21457}21458}else {21459if(before){21460this.columns.unshift(column);21461this.headersElement.insertBefore(column.getElement(), this.headersElement.firstChild);21462}else {21463this.columns.push(column);21464this.headersElement.appendChild(column.getElement());21465}21466}2146721468column.columnRendered();2146921470return column;21471}2147221473registerColumnField(col){21474if(col.definition.field){21475this.columnsByField[col.definition.field] = col;21476}21477}2147821479registerColumnPosition(col){21480this.columnsByIndex.push(col);21481}2148221483_reIndexColumns(){21484this.columnsByIndex = [];2148521486this.columns.forEach(function(column){21487column.reRegisterPosition();21488});21489}2149021491//ensure column headers take up the correct amount of space in column groups21492verticalAlignHeaders(){21493var minHeight = 0;2149421495if(!this.redrawBlock){2149621497this.headersElement.style.height="";2149821499this.columns.forEach((column) => {21500column.clearVerticalAlign();21501});2150221503this.columns.forEach((column) => {21504var height = column.getHeight();2150521506if(height > minHeight){21507minHeight = height;21508}21509});2151021511this.headersElement.style.height = minHeight + "px";2151221513this.columns.forEach((column) => {21514column.verticalAlign(this.table.options.columnHeaderVertAlign, minHeight);21515});2151621517this.table.rowManager.adjustTableSize();21518}21519}2152021521//////////////// Column Details /////////////////21522findColumn(subject){21523var columns;2152421525if(typeof subject == "object"){2152621527if(subject instanceof Column){21528//subject is column element21529return subject;21530}else if(subject instanceof ColumnComponent){21531//subject is public column component21532return subject._getSelf() || false;21533}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){2153421535columns = [];2153621537this.columns.forEach((column) => {21538columns.push(column);21539columns = columns.concat(column.getColumns(true));21540});2154121542//subject is a HTML element of the column header21543let match = columns.find((column) => {21544return column.element === subject;21545});2154621547return match || false;21548}2154921550}else {21551//subject should be treated as the field name of the column21552return this.columnsByField[subject] || false;21553}2155421555//catch all for any other type of input21556return false;21557}2155821559getColumnByField(field){21560return this.columnsByField[field];21561}2156221563getColumnsByFieldRoot(root){21564var matches = [];2156521566Object.keys(this.columnsByField).forEach((field) => {21567var fieldRoot = field.split(".")[0];21568if(fieldRoot === root){21569matches.push(this.columnsByField[field]);21570}21571});2157221573return matches;21574}2157521576getColumnByIndex(index){21577return this.columnsByIndex[index];21578}2157921580getFirstVisibleColumn(){21581var index = this.columnsByIndex.findIndex((col) => {21582return col.visible;21583});2158421585return index > -1 ? this.columnsByIndex[index] : false;21586}2158721588getColumns(){21589return this.columns;21590}2159121592findColumnIndex(column){21593return this.columnsByIndex.findIndex((col) => {21594return column === col;21595});21596}2159721598//return all columns that are not groups21599getRealColumns(){21600return this.columnsByIndex;21601}2160221603//traverse across columns and call action21604traverse(callback){21605this.columnsByIndex.forEach((column,i) =>{21606callback(column, i);21607});21608}2160921610//get definitions of actual columns21611getDefinitions(active){21612var output = [];2161321614this.columnsByIndex.forEach((column) => {21615if(!active || (active && column.visible)){21616output.push(column.getDefinition());21617}21618});2161921620return output;21621}2162221623//get full nested definition tree21624getDefinitionTree(){21625var output = [];2162621627this.columns.forEach((column) => {21628output.push(column.getDefinition(true));21629});2163021631return output;21632}2163321634getComponents(structured){21635var output = [],21636columns = structured ? this.columns : this.columnsByIndex;2163721638columns.forEach((column) => {21639output.push(column.getComponent());21640});2164121642return output;21643}2164421645getWidth(){21646var width = 0;2164721648this.columnsByIndex.forEach((column) => {21649if(column.visible){21650width += column.getWidth();21651}21652});2165321654return width;21655}2165621657moveColumn(from, to, after){21658to.element.parentNode.insertBefore(from.element, to.element);2165921660if(after){21661to.element.parentNode.insertBefore(to.element, from.element);21662}2166321664this.moveColumnActual(from, to, after);2166521666this.verticalAlignHeaders();2166721668this.table.rowManager.reinitialize();21669}2167021671moveColumnActual(from, to, after){21672if(from.parent.isGroup){21673this._moveColumnInArray(from.parent.columns, from, to, after);21674}else {21675this._moveColumnInArray(this.columns, from, to, after);21676}2167721678this._moveColumnInArray(this.columnsByIndex, from, to, after, true);2167921680this.rerenderColumns(true);2168121682this.dispatch("column-moved", from, to, after);2168321684if(this.subscribedExternal("columnMoved")){21685this.dispatchExternal("columnMoved", from.getComponent(), this.table.columnManager.getComponents());21686}21687}2168821689_moveColumnInArray(columns, from, to, after, updateRows){21690var fromIndex = columns.indexOf(from),21691toIndex, rows = [];2169221693if (fromIndex > -1) {2169421695columns.splice(fromIndex, 1);2169621697toIndex = columns.indexOf(to);2169821699if (toIndex > -1) {2170021701if(after){21702toIndex = toIndex+1;21703}2170421705}else {21706toIndex = fromIndex;21707}2170821709columns.splice(toIndex, 0, from);2171021711if(updateRows){2171221713rows = this.chain("column-moving-rows", [from, to, after], null, []) || [];2171421715rows = rows.concat(this.table.rowManager.rows);2171621717rows.forEach(function(row){21718if(row.cells.length){21719var cell = row.cells.splice(fromIndex, 1)[0];21720row.cells.splice(toIndex, 0, cell);21721}21722});2172321724}21725}21726}2172721728scrollToColumn(column, position, ifVisible){21729var left = 0,21730offset = column.getLeftOffset(),21731adjust = 0,21732colEl = column.getElement();217332173421735return new Promise((resolve, reject) => {2173621737if(typeof position === "undefined"){21738position = this.table.options.scrollToColumnPosition;21739}2174021741if(typeof ifVisible === "undefined"){21742ifVisible = this.table.options.scrollToColumnIfVisible;21743}2174421745if(column.visible){2174621747//align to correct position21748switch(position){21749case "middle":21750case "center":21751adjust = -this.element.clientWidth / 2;21752break;2175321754case "right":21755adjust = colEl.clientWidth - this.headersElement.clientWidth;21756break;21757}2175821759//check column visibility21760if(!ifVisible){21761if(offset > 0 && offset + colEl.offsetWidth < this.element.clientWidth){21762return false;21763}21764}2176521766//calculate scroll position21767left = offset + adjust;2176821769left = Math.max(Math.min(left, this.table.rowManager.element.scrollWidth - this.table.rowManager.element.clientWidth),0);2177021771this.table.rowManager.scrollHorizontal(left);21772this.scrollHorizontal(left);2177321774resolve();21775}else {21776console.warn("Scroll Error - Column not visible");21777reject("Scroll Error - Column not visible");21778}2177921780});21781}2178221783//////////////// Cell Management /////////////////21784generateCells(row){21785var cells = [];2178621787this.columnsByIndex.forEach((column) => {21788cells.push(column.generateCell(row));21789});2179021791return cells;21792}2179321794//////////////// Column Management /////////////////21795getFlexBaseWidth(){21796var totalWidth = this.table.element.clientWidth, //table element width21797fixedWidth = 0;2179821799//adjust for vertical scrollbar if present21800if(this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight){21801totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;21802}2180321804this.columnsByIndex.forEach(function(column){21805var width, minWidth, colWidth;2180621807if(column.visible){2180821809width = column.definition.width || 0;2181021811minWidth = parseInt(column.minWidth);2181221813if(typeof(width) == "string"){21814if(width.indexOf("%") > -1){21815colWidth = (totalWidth / 100) * parseInt(width) ;21816}else {21817colWidth = parseInt(width);21818}21819}else {21820colWidth = width;21821}2182221823fixedWidth += colWidth > minWidth ? colWidth : minWidth;2182421825}21826});2182721828return fixedWidth;21829}2183021831addColumn(definition, before, nextToColumn){21832return new Promise((resolve, reject) => {21833var column = this._addColumn(definition, before, nextToColumn);2183421835this._reIndexColumns();2183621837this.dispatch("column-add", definition, before, nextToColumn);2183821839if(this.layoutMode() != "fitColumns"){21840column.reinitializeWidth();21841}2184221843this.redraw(true);2184421845this.table.rowManager.reinitialize();2184621847this.rerenderColumns();2184821849resolve(column);21850});21851}2185221853//remove column from system21854deregisterColumn(column){21855var field = column.getField(),21856index;2185721858//remove from field list21859if(field){21860delete this.columnsByField[field];21861}2186221863//remove from index list21864index = this.columnsByIndex.indexOf(column);2186521866if(index > -1){21867this.columnsByIndex.splice(index, 1);21868}2186921870//remove from column list21871index = this.columns.indexOf(column);2187221873if(index > -1){21874this.columns.splice(index, 1);21875}2187621877this.verticalAlignHeaders();2187821879this.redraw();21880}2188121882rerenderColumns(update, silent){21883if(!this.redrawBlock){21884this.renderer.rerenderColumns(update, silent);21885}else {21886if(update === false || (update === true && this.redrawBlockUpdate === null)){21887this.redrawBlockUpdate = update;21888}21889}21890}2189121892blockRedraw(){21893this.redrawBlock = true;21894this.redrawBlockUpdate = null;21895}2189621897restoreRedraw(){21898this.redrawBlock = false;21899this.verticalAlignHeaders();21900this.renderer.rerenderColumns(this.redrawBlockUpdate);2190121902}2190321904//redraw columns21905redraw(force){21906if(Helpers.elVisible(this.element)){21907this.verticalAlignHeaders();21908}2190921910if(force){21911this.table.rowManager.resetScroll();21912this.table.rowManager.reinitialize();21913}2191421915if(!this.confirm("table-redrawing", force)){21916this.layoutRefresh(force);21917}2191821919this.dispatch("table-redraw", force);2192021921this.table.footerManager.redraw();21922}21923}2192421925class BasicVertical extends Renderer{21926constructor(table){21927super(table);2192821929this.verticalFillMode = "fill";2193021931this.scrollTop = 0;21932this.scrollLeft = 0;2193321934this.scrollTop = 0;21935this.scrollLeft = 0;21936}2193721938clearRows(){21939var element = this.tableElement;2194021941// element.children.detach();21942while(element.firstChild) element.removeChild(element.firstChild);2194321944element.scrollTop = 0;21945element.scrollLeft = 0;2194621947element.style.minWidth = "";21948element.style.minHeight = "";21949element.style.display = "";21950element.style.visibility = "";21951}2195221953renderRows() {21954var element = this.tableElement,21955onlyGroupHeaders = true,21956tableFrag = document.createDocumentFragment(),21957rows = this.rows();2195821959rows.forEach((row, index) => {21960this.styleRow(row, index);21961row.initialize(false, true);2196221963if (row.type !== "group") {21964onlyGroupHeaders = false;21965}2196621967tableFrag.appendChild(row.getElement());21968});2196921970element.appendChild(tableFrag);2197121972rows.forEach((row) => {21973row.rendered();2197421975if(!row.heightInitialized) {21976row.calcHeight(true);21977}21978});2197921980rows.forEach((row) => {21981if(!row.heightInitialized) {21982row.setCellHeight();21983}21984});21985219862198721988if(onlyGroupHeaders){21989element.style.minWidth = this.table.columnManager.getWidth() + "px";21990}else {21991element.style.minWidth = "";21992}21993}219942199521996rerenderRows(callback){21997this.clearRows();2199821999if(callback){22000callback();22001}2200222003this.renderRows();22004}2200522006scrollToRowNearestTop(row){22007var rowTop = Helpers.elOffset(row.getElement()).top;2200822009return !(Math.abs(this.elementVertical.scrollTop - rowTop) > Math.abs(this.elementVertical.scrollTop + this.elementVertical.clientHeight - rowTop));22010}2201122012scrollToRow(row){22013var rowEl = row.getElement();2201422015this.elementVertical.scrollTop = Helpers.elOffset(rowEl).top - Helpers.elOffset(this.elementVertical).top + this.elementVertical.scrollTop;22016}2201722018visibleRows(includingBuffer){22019return this.rows();22020}2202122022}2202322024class VirtualDomVertical extends Renderer{22025constructor(table){22026super(table);2202722028this.verticalFillMode = "fill";2202922030this.scrollTop = 0;22031this.scrollLeft = 0;2203222033this.vDomRowHeight = 20; //approximation of row heights for padding2203422035this.vDomTop = 0; //hold position for first rendered row in the virtual DOM22036this.vDomBottom = 0; //hold position for last rendered row in the virtual DOM2203722038this.vDomScrollPosTop = 0; //last scroll position of the vDom top;22039this.vDomScrollPosBottom = 0; //last scroll position of the vDom bottom;2204022041this.vDomTopPad = 0; //hold value of padding for top of virtual DOM22042this.vDomBottomPad = 0; //hold value of padding for bottom of virtual DOM2204322044this.vDomMaxRenderChain = 90; //the maximum number of dom elements that can be rendered in 1 go2204522046this.vDomWindowBuffer = 0; //window row buffer before removing elements, to smooth scrolling2204722048this.vDomWindowMinTotalRows = 20; //minimum number of rows to be generated in virtual dom (prevent buffering issues on tables with tall rows)22049this.vDomWindowMinMarginRows = 5; //minimum number of rows to be generated in virtual dom margin2205022051this.vDomTopNewRows = []; //rows to normalize after appending to optimize render speed22052this.vDomBottomNewRows = []; //rows to normalize after appending to optimize render speed22053}2205422055//////////////////////////////////////22056///////// Public Functions ///////////22057//////////////////////////////////////2205822059clearRows(){22060var element = this.tableElement;2206122062// element.children.detach();22063while(element.firstChild) element.removeChild(element.firstChild);2206422065element.style.paddingTop = "";22066element.style.paddingBottom = "";22067element.style.minHeight = "";22068element.style.display = "";22069element.style.visibility = "";2207022071this.elementVertical.scrollTop = 0;22072this.elementVertical.scrollLeft = 0;2207322074this.scrollTop = 0;22075this.scrollLeft = 0;2207622077this.vDomTop = 0;22078this.vDomBottom = 0;22079this.vDomTopPad = 0;22080this.vDomBottomPad = 0;22081this.vDomScrollPosTop = 0;22082this.vDomScrollPosBottom = 0;22083}2208422085renderRows(){22086this._virtualRenderFill();22087}2208822089rerenderRows(callback){22090var scrollTop = this.elementVertical.scrollTop;22091var topRow = false;22092var topOffset = false;2209322094var left = this.table.rowManager.scrollLeft;2209522096var rows = this.rows();2209722098for(var i = this.vDomTop; i <= this.vDomBottom; i++){2209922100if(rows[i]){22101var diff = scrollTop - rows[i].getElement().offsetTop;2210222103if(topOffset === false || Math.abs(diff) < topOffset){22104topOffset = diff;22105topRow = i;22106}else {22107break;22108}22109}22110}2211122112rows.forEach((row) => {22113row.deinitializeHeight();22114});2211522116if(callback){22117callback();22118}2211922120if(this.rows().length){22121this._virtualRenderFill((topRow === false ? this.rows.length - 1 : topRow), true, topOffset || 0);22122}else {22123this.clear();22124this.table.rowManager.tableEmpty();22125}2212622127this.scrollColumns(left);22128}2212922130scrollColumns(left){22131this.table.rowManager.scrollHorizontal(left);22132}2213322134scrollRows(top, dir){22135var topDiff = top - this.vDomScrollPosTop;22136var bottomDiff = top - this.vDomScrollPosBottom;22137var margin = this.vDomWindowBuffer * 2;22138var rows = this.rows();2213922140this.scrollTop = top;2214122142if(-topDiff > margin || bottomDiff > margin){22143//if big scroll redraw table;22144var left = this.table.rowManager.scrollLeft;22145this._virtualRenderFill(Math.floor((this.elementVertical.scrollTop / this.elementVertical.scrollHeight) * rows.length));22146this.scrollColumns(left);22147}else {2214822149if(dir){22150//scrolling up22151if(topDiff < 0){22152this._addTopRow(rows, -topDiff);22153}2215422155if(bottomDiff < 0){22156//hide bottom row if needed22157if(this.vDomScrollHeight - this.scrollTop > this.vDomWindowBuffer){22158this._removeBottomRow(rows, -bottomDiff);22159}else {22160this.vDomScrollPosBottom = this.scrollTop;22161}22162}22163}else {2216422165if(bottomDiff >= 0){22166this._addBottomRow(rows, bottomDiff);22167}2216822169//scrolling down22170if(topDiff >= 0){22171//hide top row if needed22172if(this.scrollTop > this.vDomWindowBuffer){22173this._removeTopRow(rows, topDiff);22174}else {22175this.vDomScrollPosTop = this.scrollTop;22176}22177}22178}22179}22180}2218122182resize(){22183this.vDomWindowBuffer = this.table.options.renderVerticalBuffer || this.elementVertical.clientHeight;22184}2218522186scrollToRowNearestTop(row){22187var rowIndex = this.rows().indexOf(row);2218822189return !(Math.abs(this.vDomTop - rowIndex) > Math.abs(this.vDomBottom - rowIndex));22190}2219122192scrollToRow(row){22193var index = this.rows().indexOf(row);2219422195if(index > -1){22196this._virtualRenderFill(index, true);22197}22198}2219922200visibleRows(includingBuffer){22201var topEdge = this.elementVertical.scrollTop,22202bottomEdge = this.elementVertical.clientHeight + topEdge,22203topFound = false,22204topRow = 0,22205bottomRow = 0,22206rows = this.rows();2220722208if(includingBuffer){22209topRow = this.vDomTop;22210bottomRow = this.vDomBottom;22211}else {22212for(var i = this.vDomTop; i <= this.vDomBottom; i++){22213if(rows[i]){22214if(!topFound){22215if((topEdge - rows[i].getElement().offsetTop) >= 0){22216topRow = i;22217}else {22218topFound = true;2221922220if(bottomEdge - rows[i].getElement().offsetTop >= 0){22221bottomRow = i;22222}else {22223break;22224}22225}22226}else {22227if(bottomEdge - rows[i].getElement().offsetTop >= 0){22228bottomRow = i;22229}else {22230break;22231}22232}22233}22234}22235}2223622237return rows.slice(topRow, bottomRow + 1);22238}2223922240//////////////////////////////////////22241//////// Internal Rendering //////////22242//////////////////////////////////////2224322244//full virtual render22245_virtualRenderFill(position, forceMove, offset) {22246var element = this.tableElement,22247holder = this.elementVertical,22248topPad = 0,22249rowsHeight = 0,22250rowHeight = 0,22251heightOccupied = 0,22252topPadHeight = 0,22253i = 0,22254rows = this.rows(),22255rowsCount = rows.length,22256index = 0,22257row,22258rowFragment,22259renderedRows = [],22260totalRowsRendered = 0,22261rowsToRender = 0,22262fixedHeight = this.table.rowManager.fixedHeight,22263containerHeight = this.elementVertical.clientHeight,22264avgRowHeight = this.table.options.rowHeight,22265resized = true;2226622267position = position || 0;2226822269offset = offset || 0;2227022271if(!position){22272this.clear();22273}else {22274while(element.firstChild) element.removeChild(element.firstChild);2227522276//check if position is too close to bottom of table22277heightOccupied = (rowsCount - position + 1) * this.vDomRowHeight;2227822279if(heightOccupied < containerHeight){22280position -= Math.ceil((containerHeight - heightOccupied) / this.vDomRowHeight);22281if(position < 0){22282position = 0;22283}22284}2228522286//calculate initial pad22287topPad = Math.min(Math.max(Math.floor(this.vDomWindowBuffer / this.vDomRowHeight), this.vDomWindowMinMarginRows), position);22288position -= topPad;22289}2229022291if(rowsCount && Helpers.elVisible(this.elementVertical)){22292this.vDomTop = position;22293this.vDomBottom = position -1;2229422295if(fixedHeight || this.table.options.maxHeight) {22296if(avgRowHeight) {22297rowsToRender = (containerHeight / avgRowHeight) + (this.vDomWindowBuffer / avgRowHeight);22298}22299rowsToRender = Math.max(this.vDomWindowMinTotalRows, Math.ceil(rowsToRender));22300}22301else {22302rowsToRender = rowsCount;22303}2230422305while(((rowsToRender == rowsCount || rowsHeight <= containerHeight + this.vDomWindowBuffer) || totalRowsRendered < this.vDomWindowMinTotalRows) && this.vDomBottom < rowsCount -1) {22306renderedRows = [];22307rowFragment = document.createDocumentFragment();2230822309i = 0;2231022311while ((i < rowsToRender) && this.vDomBottom < rowsCount -1) {22312index = this.vDomBottom + 1,22313row = rows[index];2231422315this.styleRow(row, index);2231622317row.initialize(false, true);22318if(!row.heightInitialized && !this.table.options.rowHeight){22319row.clearCellHeight();22320}2232122322rowFragment.appendChild(row.getElement());22323renderedRows.push(row);22324this.vDomBottom ++;22325i++;22326}2232722328if(!renderedRows.length){22329break;22330}2233122332element.appendChild(rowFragment);2233322334// NOTE: The next 3 loops are separate on purpose22335// This is to batch up the dom writes and reads which drastically improves performance2233622337renderedRows.forEach((row) => {22338row.rendered();2233922340if(!row.heightInitialized) {22341row.calcHeight(true);22342}22343});2234422345renderedRows.forEach((row) => {22346if(!row.heightInitialized) {22347row.setCellHeight();22348}22349});2235022351renderedRows.forEach((row) => {22352rowHeight = row.getHeight();2235322354if(totalRowsRendered < topPad){22355topPadHeight += rowHeight;22356}else {22357rowsHeight += rowHeight;22358}2235922360if(rowHeight > this.vDomWindowBuffer){22361this.vDomWindowBuffer = rowHeight * 2;22362}22363totalRowsRendered++;22364});2236522366resized = this.table.rowManager.adjustTableSize();22367containerHeight = this.elementVertical.clientHeight;22368if(resized && (fixedHeight || this.table.options.maxHeight))22369{22370avgRowHeight = rowsHeight / totalRowsRendered;22371rowsToRender = Math.max(this.vDomWindowMinTotalRows, Math.ceil((containerHeight / avgRowHeight) + (this.vDomWindowBuffer / avgRowHeight)));22372}22373}2237422375if(!position){22376this.vDomTopPad = 0;22377//adjust row height to match average of rendered elements22378this.vDomRowHeight = Math.floor((rowsHeight + topPadHeight) / totalRowsRendered);22379this.vDomBottomPad = this.vDomRowHeight * (rowsCount - this.vDomBottom -1);2238022381this.vDomScrollHeight = topPadHeight + rowsHeight + this.vDomBottomPad - containerHeight;22382}else {22383this.vDomTopPad = !forceMove ? this.scrollTop - topPadHeight : (this.vDomRowHeight * this.vDomTop) + offset;22384this.vDomBottomPad = this.vDomBottom == rowsCount-1 ? 0 : Math.max(this.vDomScrollHeight - this.vDomTopPad - rowsHeight - topPadHeight, 0);22385}2238622387element.style.paddingTop = this.vDomTopPad+"px";22388element.style.paddingBottom = this.vDomBottomPad+"px";2238922390if(forceMove){22391this.scrollTop = this.vDomTopPad + (topPadHeight) + offset - (this.elementVertical.scrollWidth > this.elementVertical.clientWidth ? this.elementVertical.offsetHeight - containerHeight : 0);22392}2239322394this.scrollTop = Math.min(this.scrollTop, this.elementVertical.scrollHeight - containerHeight);2239522396//adjust for horizontal scrollbar if present (and not at top of table)22397if(this.elementVertical.scrollWidth > this.elementVertical.clientWidth && forceMove){22398this.scrollTop += this.elementVertical.offsetHeight - containerHeight;22399}2240022401this.vDomScrollPosTop = this.scrollTop;22402this.vDomScrollPosBottom = this.scrollTop;2240322404holder.scrollTop = this.scrollTop;2240522406this.dispatch("render-virtual-fill");22407}22408}2240922410_addTopRow(rows, fillableSpace){22411var table = this.tableElement,22412addedRows = [],22413paddingAdjust = 0,22414index = this.vDomTop -1,22415i = 0,22416working = true;2241722418while(working){22419if(this.vDomTop){22420let row = rows[index],22421rowHeight, initialized;2242222423if(row && i < this.vDomMaxRenderChain){22424rowHeight = row.getHeight() || this.vDomRowHeight;22425initialized = row.initialized;2242622427if(fillableSpace >= rowHeight){2242822429this.styleRow(row, index);22430table.insertBefore(row.getElement(), table.firstChild);2243122432if(!row.initialized || !row.heightInitialized){22433addedRows.push(row);22434}2243522436row.initialize();2243722438if(!initialized){22439rowHeight = row.getElement().offsetHeight;2244022441if(rowHeight > this.vDomWindowBuffer){22442this.vDomWindowBuffer = rowHeight * 2;22443}22444}2244522446fillableSpace -= rowHeight;22447paddingAdjust += rowHeight;2244822449this.vDomTop--;22450index--;22451i++;2245222453}else {22454working = false;22455}2245622457}else {22458working = false;22459}2246022461}else {22462working = false;22463}22464}2246522466for (let row of addedRows){22467row.clearCellHeight();22468}2246922470this._quickNormalizeRowHeight(addedRows);2247122472if(paddingAdjust){22473this.vDomTopPad -= paddingAdjust;2247422475if(this.vDomTopPad < 0){22476this.vDomTopPad = index * this.vDomRowHeight;22477}2247822479if(index < 1){22480this.vDomTopPad = 0;22481}2248222483table.style.paddingTop = this.vDomTopPad + "px";22484this.vDomScrollPosTop -= paddingAdjust;22485}22486}2248722488_removeTopRow(rows, fillableSpace){22489var removableRows = [],22490paddingAdjust = 0,22491i = 0,22492working = true;2249322494while(working){22495let row = rows[this.vDomTop],22496rowHeight;2249722498if(row && i < this.vDomMaxRenderChain){22499rowHeight = row.getHeight() || this.vDomRowHeight;2250022501if(fillableSpace >= rowHeight){22502this.vDomTop++;2250322504fillableSpace -= rowHeight;22505paddingAdjust += rowHeight;2250622507removableRows.push(row);22508i++;22509}else {22510working = false;22511}22512}else {22513working = false;22514}22515}2251622517for (let row of removableRows){22518let rowEl = row.getElement();2251922520if(rowEl.parentNode){22521rowEl.parentNode.removeChild(rowEl);22522}22523}2252422525if(paddingAdjust){22526this.vDomTopPad += paddingAdjust;22527this.tableElement.style.paddingTop = this.vDomTopPad + "px";22528this.vDomScrollPosTop += this.vDomTop ? paddingAdjust : paddingAdjust + this.vDomWindowBuffer;22529}22530}2253122532_addBottomRow(rows, fillableSpace){22533var table = this.tableElement,22534addedRows = [],22535paddingAdjust = 0,22536index = this.vDomBottom + 1,22537i = 0,22538working = true;2253922540while(working){22541let row = rows[index],22542rowHeight, initialized;2254322544if(row && i < this.vDomMaxRenderChain){22545rowHeight = row.getHeight() || this.vDomRowHeight;22546initialized = row.initialized;2254722548if(fillableSpace >= rowHeight){2254922550this.styleRow(row, index);22551table.appendChild(row.getElement());2255222553if(!row.initialized || !row.heightInitialized){22554addedRows.push(row);22555}2255622557row.initialize();2255822559if(!initialized){22560rowHeight = row.getElement().offsetHeight;2256122562if(rowHeight > this.vDomWindowBuffer){22563this.vDomWindowBuffer = rowHeight * 2;22564}22565}2256622567fillableSpace -= rowHeight;22568paddingAdjust += rowHeight;2256922570this.vDomBottom++;22571index++;22572i++;22573}else {22574working = false;22575}22576}else {22577working = false;22578}22579}2258022581for (let row of addedRows){22582row.clearCellHeight();22583}2258422585this._quickNormalizeRowHeight(addedRows);2258622587if(paddingAdjust){22588this.vDomBottomPad -= paddingAdjust;2258922590if(this.vDomBottomPad < 0 || index == rows.length -1){22591this.vDomBottomPad = 0;22592}2259322594table.style.paddingBottom = this.vDomBottomPad + "px";22595this.vDomScrollPosBottom += paddingAdjust;22596}22597}2259822599_removeBottomRow(rows, fillableSpace){22600var removableRows = [],22601paddingAdjust = 0,22602i = 0,22603working = true;2260422605while(working){22606let row = rows[this.vDomBottom],22607rowHeight;2260822609if(row && i < this.vDomMaxRenderChain){22610rowHeight = row.getHeight() || this.vDomRowHeight;2261122612if(fillableSpace >= rowHeight){22613this.vDomBottom --;2261422615fillableSpace -= rowHeight;22616paddingAdjust += rowHeight;2261722618removableRows.push(row);22619i++;22620}else {22621working = false;22622}22623}else {22624working = false;22625}22626}2262722628for (let row of removableRows){22629let rowEl = row.getElement();2263022631if(rowEl.parentNode){22632rowEl.parentNode.removeChild(rowEl);22633}22634}2263522636if(paddingAdjust){22637this.vDomBottomPad += paddingAdjust;2263822639if(this.vDomBottomPad < 0){22640this.vDomBottomPad = 0;22641}2264222643this.tableElement.style.paddingBottom = this.vDomBottomPad + "px";22644this.vDomScrollPosBottom -= paddingAdjust;22645}22646}2264722648_quickNormalizeRowHeight(rows){22649for(let row of rows){22650row.calcHeight();22651}2265222653for(let row of rows){22654row.setCellHeight();22655}22656}22657}2265822659class RowManager extends CoreFeature{2266022661constructor(table){22662super(table);2266322664this.element = this.createHolderElement(); //containing element22665this.tableElement = this.createTableElement(); //table element22666this.heightFixer = this.createTableElement(); //table element22667this.placeholder = null; //placeholder element22668this.placeholderContents = null; //placeholder element2266922670this.firstRender = false; //handle first render22671this.renderMode = "virtual"; //current rendering mode22672this.fixedHeight = false; //current rendering mode2267322674this.rows = []; //hold row data objects22675this.activeRowsPipeline = []; //hold calculation of active rows22676this.activeRows = []; //rows currently available to on display in the table22677this.activeRowsCount = 0; //count of active rows2267822679this.displayRows = []; //rows currently on display in the table22680this.displayRowsCount = 0; //count of display rows2268122682this.scrollTop = 0;22683this.scrollLeft = 0;2268422685this.redrawBlock = false; //prevent redraws to allow multiple data manipulations before continuing22686this.redrawBlockRestoreConfig = false; //store latest redraw function calls for when redraw is needed22687this.redrawBlockRenderInPosition = false; //store latest redraw function calls for when redraw is needed2268822689this.dataPipeline = []; //hold data pipeline tasks22690this.displayPipeline = []; //hold data display pipeline tasks2269122692this.scrollbarWidth = 0;2269322694this.renderer = null;22695}2269622697//////////////// Setup Functions /////////////////2269822699createHolderElement (){22700var el = document.createElement("div");2270122702el.classList.add("tabulator-tableholder");22703el.setAttribute("tabindex", 0);22704// el.setAttribute("role", "rowgroup");2270522706return el;22707}2270822709createTableElement (){22710var el = document.createElement("div");2271122712el.classList.add("tabulator-table");22713el.setAttribute("role", "rowgroup");2271422715return el;22716}2271722718initializePlaceholder(){22719var placeholder = this.table.options.placeholder;2272022721if(typeof placeholder === "function"){22722placeholder = placeholder.call(this.table);22723}2272422725placeholder = this.chain("placeholder", [placeholder], placeholder, placeholder) || placeholder;2272622727//configure placeholder element22728if(placeholder){22729let el = document.createElement("div");22730el.classList.add("tabulator-placeholder");2273122732if(typeof placeholder == "string"){22733let contents = document.createElement("div");22734contents.classList.add("tabulator-placeholder-contents");22735contents.innerHTML = placeholder;2273622737el.appendChild(contents);2273822739this.placeholderContents = contents;2274022741}else if(typeof HTMLElement !== "undefined" && placeholder instanceof HTMLElement){2274222743el.appendChild(placeholder);22744this.placeholderContents = placeholder;22745}else {22746console.warn("Invalid placeholder provided, must be string or HTML Element", placeholder);2274722748this.el = null;22749}2275022751this.placeholder = el;22752}22753}2275422755//return containing element22756getElement(){22757return this.element;22758}2275922760//return table element22761getTableElement(){22762return this.tableElement;22763}2276422765initialize(){22766this.initializePlaceholder();22767this.initializeRenderer();2276822769//initialize manager22770this.element.appendChild(this.tableElement);2277122772this.firstRender = true;2277322774//scroll header along with table body22775this.element.addEventListener("scroll", () => {22776var left = this.element.scrollLeft,22777leftDir = this.scrollLeft > left,22778top = this.element.scrollTop,22779topDir = this.scrollTop > top;2278022781//handle horizontal scrolling22782if(this.scrollLeft != left){22783this.scrollLeft = left;2278422785this.dispatch("scroll-horizontal", left, leftDir);22786this.dispatchExternal("scrollHorizontal", left, leftDir);2278722788this._positionPlaceholder();22789}2279022791//handle vertical scrolling22792if(this.scrollTop != top){22793this.scrollTop = top;2279422795this.renderer.scrollRows(top, topDir);2279622797this.dispatch("scroll-vertical", top, topDir);22798this.dispatchExternal("scrollVertical", top, topDir);22799}22800});22801}2280222803////////////////// Row Manipulation //////////////////22804findRow(subject){22805if(typeof subject == "object"){22806if(subject instanceof Row){22807//subject is row element22808return subject;22809}else if(subject instanceof RowComponent){22810//subject is public row component22811return subject._getSelf() || false;22812}else if(typeof HTMLElement !== "undefined" && subject instanceof HTMLElement){22813//subject is a HTML element of the row22814let match = this.rows.find((row) => {22815return row.getElement() === subject;22816});2281722818return match || false;22819}else if(subject === null){22820return false;22821}22822}else if(typeof subject == "undefined"){22823return false;22824}else {22825//subject should be treated as the index of the row22826let match = this.rows.find((row) => {22827return row.data[this.table.options.index] == subject;22828});2282922830return match || false;22831}2283222833//catch all for any other type of input22834return false;22835}2283622837getRowFromDataObject(data){22838var match = this.rows.find((row) => {22839return row.data === data;22840});2284122842return match || false;22843}2284422845getRowFromPosition(position){22846return this.getDisplayRows().find((row) => {22847return row.getPosition() === position && row.isDisplayed();22848});22849}2285022851scrollToRow(row, position, ifVisible){22852return this.renderer.scrollToRowPosition(row, position, ifVisible);22853}2285422855////////////////// Data Handling //////////////////22856setData(data, renderInPosition, columnsChanged){22857return new Promise((resolve, reject)=>{22858if(renderInPosition && this.getDisplayRows().length){22859if(this.table.options.pagination){22860this._setDataActual(data, true);22861}else {22862this.reRenderInPosition(() => {22863this._setDataActual(data);22864});22865}22866}else {22867if(this.table.options.autoColumns && columnsChanged && this.table.initialized){22868this.table.columnManager.generateColumnsFromRowData(data);22869}22870this.resetScroll();2287122872this._setDataActual(data);22873}2287422875resolve();22876});22877}2287822879_setDataActual(data, renderInPosition){22880this.dispatchExternal("dataProcessing", data);2288122882this._wipeElements();2288322884if(Array.isArray(data)){22885this.dispatch("data-processing", data);2288622887data.forEach((def, i) => {22888if(def && typeof def === "object"){22889var row = new Row(def, this);22890this.rows.push(row);22891}else {22892console.warn("Data Loading Warning - Invalid row data detected and ignored, expecting object but received:", def);22893}22894});2289522896this.refreshActiveData(false, false, renderInPosition);2289722898this.dispatch("data-processed", data);22899this.dispatchExternal("dataProcessed", data);22900}else {22901console.error("Data Loading Error - Unable to process data due to invalid data type \nExpecting: array \nReceived: ", typeof data, "\nData: ", data);22902}22903}2290422905_wipeElements(){22906this.dispatch("rows-wipe");2290722908this.destroy();2290922910this.adjustTableSize();2291122912this.dispatch("rows-wiped");22913}2291422915destroy(){22916this.rows.forEach((row) => {22917row.wipe();22918});2291922920this.rows = [];22921this.activeRows = [];22922this.activeRowsPipeline = [];22923this.activeRowsCount = 0;22924this.displayRows = [];22925this.displayRowsCount = 0;22926}2292722928deleteRow(row, blockRedraw){22929var allIndex = this.rows.indexOf(row),22930activeIndex = this.activeRows.indexOf(row);2293122932if(activeIndex > -1){22933this.activeRows.splice(activeIndex, 1);22934}2293522936if(allIndex > -1){22937this.rows.splice(allIndex, 1);22938}2293922940this.setActiveRows(this.activeRows);2294122942this.displayRowIterator((rows) => {22943var displayIndex = rows.indexOf(row);2294422945if(displayIndex > -1){22946rows.splice(displayIndex, 1);22947}22948});2294922950if(!blockRedraw){22951this.reRenderInPosition();22952}2295322954this.regenerateRowPositions();2295522956this.dispatchExternal("rowDeleted", row.getComponent());2295722958if(!this.displayRowsCount){22959this.tableEmpty();22960}2296122962if(this.subscribedExternal("dataChanged")){22963this.dispatchExternal("dataChanged", this.getData());22964}22965}2296622967addRow(data, pos, index, blockRedraw){22968var row = this.addRowActual(data, pos, index, blockRedraw);22969return row;22970}2297122972//add multiple rows22973addRows(data, pos, index, refreshDisplayOnly){22974var rows = [];2297522976return new Promise((resolve, reject) => {22977pos = this.findAddRowPos(pos);2297822979if(!Array.isArray(data)){22980data = [data];22981}2298222983if((typeof index == "undefined" && pos) || (typeof index !== "undefined" && !pos)){22984data.reverse();22985}2298622987data.forEach((item, i) => {22988var row = this.addRow(item, pos, index, true);22989rows.push(row);22990this.dispatch("row-added", row, item, pos, index);22991});2299222993this.refreshActiveData(refreshDisplayOnly ? "displayPipeline" : false, false, true);2299422995this.regenerateRowPositions();2299622997if(rows.length){22998this._clearPlaceholder();22999}2300023001resolve(rows);23002});23003}2300423005findAddRowPos(pos){23006if(typeof pos === "undefined"){23007pos = this.table.options.addRowPos;23008}2300923010if(pos === "pos"){23011pos = true;23012}2301323014if(pos === "bottom"){23015pos = false;23016}2301723018return pos;23019}2302023021addRowActual(data, pos, index, blockRedraw){23022var row = data instanceof Row ? data : new Row(data || {}, this),23023top = this.findAddRowPos(pos),23024allIndex = -1,23025activeIndex, chainResult;2302623027if(!index){23028chainResult = this.chain("row-adding-position", [row, top], null, {index, top});2302923030index = chainResult.index;23031top = chainResult.top;23032}2303323034if(typeof index !== "undefined"){23035index = this.findRow(index);23036}2303723038index = this.chain("row-adding-index", [row, index, top], null, index);2303923040if(index){23041allIndex = this.rows.indexOf(index);23042}2304323044if(index && allIndex > -1){23045activeIndex = this.activeRows.indexOf(index);2304623047this.displayRowIterator(function(rows){23048var displayIndex = rows.indexOf(index);2304923050if(displayIndex > -1){23051rows.splice((top ? displayIndex : displayIndex + 1), 0, row);23052}23053});2305423055if(activeIndex > -1){23056this.activeRows.splice((top ? activeIndex : activeIndex + 1), 0, row);23057}2305823059this.rows.splice((top ? allIndex : allIndex + 1), 0, row);2306023061}else {2306223063if(top){2306423065this.displayRowIterator(function(rows){23066rows.unshift(row);23067});2306823069this.activeRows.unshift(row);23070this.rows.unshift(row);23071}else {23072this.displayRowIterator(function(rows){23073rows.push(row);23074});2307523076this.activeRows.push(row);23077this.rows.push(row);23078}23079}2308023081this.setActiveRows(this.activeRows);2308223083this.dispatchExternal("rowAdded", row.getComponent());2308423085if(this.subscribedExternal("dataChanged")){23086this.dispatchExternal("dataChanged", this.table.rowManager.getData());23087}2308823089if(!blockRedraw){23090this.reRenderInPosition();23091}2309223093return row;23094}2309523096moveRow(from, to, after){23097this.dispatch("row-move", from, to, after);2309823099this.moveRowActual(from, to, after);2310023101this.regenerateRowPositions();2310223103this.dispatch("row-moved", from, to, after);23104this.dispatchExternal("rowMoved", from.getComponent());23105}2310623107moveRowActual(from, to, after){23108this.moveRowInArray(this.rows, from, to, after);23109this.moveRowInArray(this.activeRows, from, to, after);2311023111this.displayRowIterator((rows) => {23112this.moveRowInArray(rows, from, to, after);23113});2311423115this.dispatch("row-moving", from, to, after);23116}2311723118moveRowInArray(rows, from, to, after){23119var fromIndex, toIndex, start, end;2312023121if(from !== to){2312223123fromIndex = rows.indexOf(from);2312423125if (fromIndex > -1) {2312623127rows.splice(fromIndex, 1);2312823129toIndex = rows.indexOf(to);2313023131if (toIndex > -1) {2313223133if(after){23134rows.splice(toIndex+1, 0, from);23135}else {23136rows.splice(toIndex, 0, from);23137}2313823139}else {23140rows.splice(fromIndex, 0, from);23141}23142}2314323144//restyle rows23145if(rows === this.getDisplayRows()){2314623147start = fromIndex < toIndex ? fromIndex : toIndex;23148end = toIndex > fromIndex ? toIndex : fromIndex +1;2314923150for(let i = start; i <= end; i++){23151if(rows[i]){23152this.styleRow(rows[i], i);23153}23154}23155}23156}23157}2315823159clearData(){23160this.setData([]);23161}2316223163getRowIndex(row){23164return this.findRowIndex(row, this.rows);23165}2316623167getDisplayRowIndex(row){23168var index = this.getDisplayRows().indexOf(row);23169return index > -1 ? index : false;23170}2317123172nextDisplayRow(row, rowOnly){23173var index = this.getDisplayRowIndex(row),23174nextRow = false;231752317623177if(index !== false && index < this.displayRowsCount -1){23178nextRow = this.getDisplayRows()[index+1];23179}2318023181if(nextRow && (!(nextRow instanceof Row) || nextRow.type != "row")){23182return this.nextDisplayRow(nextRow, rowOnly);23183}2318423185return nextRow;23186}2318723188prevDisplayRow(row, rowOnly){23189var index = this.getDisplayRowIndex(row),23190prevRow = false;2319123192if(index){23193prevRow = this.getDisplayRows()[index-1];23194}2319523196if(rowOnly && prevRow && (!(prevRow instanceof Row) || prevRow.type != "row")){23197return this.prevDisplayRow(prevRow, rowOnly);23198}2319923200return prevRow;23201}2320223203findRowIndex(row, list){23204var rowIndex;2320523206row = this.findRow(row);2320723208if(row){23209rowIndex = list.indexOf(row);2321023211if(rowIndex > -1){23212return rowIndex;23213}23214}2321523216return false;23217}2321823219getData(active, transform){23220var output = [],23221rows = this.getRows(active);2322223223rows.forEach(function(row){23224if(row.type == "row"){23225output.push(row.getData(transform || "data"));23226}23227});2322823229return output;23230}2323123232getComponents(active){23233var output = [],23234rows = this.getRows(active);2323523236rows.forEach(function(row){23237output.push(row.getComponent());23238});2323923240return output;23241}2324223243getDataCount(active){23244var rows = this.getRows(active);2324523246return rows.length;23247}2324823249scrollHorizontal(left){23250this.scrollLeft = left;23251this.element.scrollLeft = left;2325223253this.dispatch("scroll-horizontal", left);23254}2325523256registerDataPipelineHandler(handler, priority){23257if(typeof priority !== "undefined"){23258this.dataPipeline.push({handler, priority});23259this.dataPipeline.sort((a, b) => {23260return a.priority - b.priority;23261});23262}else {23263console.error("Data pipeline handlers must have a priority in order to be registered");23264}23265}2326623267registerDisplayPipelineHandler(handler, priority){23268if(typeof priority !== "undefined"){23269this.displayPipeline.push({handler, priority});23270this.displayPipeline.sort((a, b) => {23271return a.priority - b.priority;23272});23273}else {23274console.error("Display pipeline handlers must have a priority in order to be registered");23275}23276}2327723278//set active data set23279refreshActiveData(handler, skipStage, renderInPosition){23280var table = this.table,23281stage = "",23282index = 0,23283cascadeOrder = ["all", "dataPipeline", "display", "displayPipeline", "end"];2328423285if(!this.table.destroyed){23286if(typeof handler === "function"){23287index = this.dataPipeline.findIndex((item) => {23288return item.handler === handler;23289});2329023291if(index > -1){23292stage = "dataPipeline";2329323294if(skipStage){23295if(index == this.dataPipeline.length - 1){23296stage = "display";23297}else {23298index++;23299}23300}23301}else {23302index = this.displayPipeline.findIndex((item) => {23303return item.handler === handler;23304});2330523306if(index > -1){23307stage = "displayPipeline";2330823309if(skipStage){23310if(index == this.displayPipeline.length - 1){23311stage = "end";23312}else {23313index++;23314}23315}23316}else {23317console.error("Unable to refresh data, invalid handler provided", handler);23318return;23319}23320}23321}else {23322stage = handler || "all";23323index = 0;23324}2332523326if(this.redrawBlock){23327if(!this.redrawBlockRestoreConfig || (this.redrawBlockRestoreConfig && ((this.redrawBlockRestoreConfig.stage === stage && index < this.redrawBlockRestoreConfig.index) || (cascadeOrder.indexOf(stage) < cascadeOrder.indexOf(this.redrawBlockRestoreConfig.stage))))){23328this.redrawBlockRestoreConfig = {23329handler: handler,23330skipStage: skipStage,23331renderInPosition: renderInPosition,23332stage:stage,23333index:index,23334};23335}2333623337return;23338}else {23339if(Helpers.elVisible(this.element)){23340if(renderInPosition){23341this.reRenderInPosition(this.refreshPipelines.bind(this, handler, stage, index, renderInPosition));23342}else {23343this.refreshPipelines(handler, stage, index, renderInPosition);2334423345if(!handler){23346this.table.columnManager.renderer.renderColumns();23347}2334823349this.renderTable();2335023351if(table.options.layoutColumnsOnNewData){23352this.table.columnManager.redraw(true);23353}23354}23355}else {23356this.refreshPipelines(handler, stage, index, renderInPosition);23357}2335823359this.dispatch("data-refreshed");23360}23361}23362}2336323364refreshPipelines(handler, stage, index, renderInPosition){23365this.dispatch("data-refreshing");2336623367if(!handler){23368this.activeRowsPipeline[0] = this.rows.slice(0);23369}2337023371//cascade through data refresh stages23372switch(stage){23373case "all":23374//handle case where all data needs refreshing2337523376case "dataPipeline":2337723378for(let i = index; i < this.dataPipeline.length; i++){23379let result = this.dataPipeline[i].handler(this.activeRowsPipeline[i].slice(0));2338023381this.activeRowsPipeline[i + 1] = result || this.activeRowsPipeline[i].slice(0);23382}2338323384this.setActiveRows(this.activeRowsPipeline[this.dataPipeline.length]);2338523386case "display":23387index = 0;23388this.resetDisplayRows();2338923390case "displayPipeline":23391for(let i = index; i < this.displayPipeline.length; i++){23392let result = this.displayPipeline[i].handler((i ? this.getDisplayRows(i - 1) : this.activeRows).slice(0), renderInPosition);2339323394this.setDisplayRows(result || this.getDisplayRows(i - 1).slice(0), i);23395}2339623397case "end":23398//case to handle scenario when trying to skip past end stage23399this.regenerateRowPositions();23400}2340123402if(this.getDisplayRows().length){23403this._clearPlaceholder();23404}23405}2340623407//regenerate row positions23408regenerateRowPositions(){23409var rows = this.getDisplayRows();23410var index = 1;2341123412rows.forEach((row) => {23413if (row.type === "row"){23414row.setPosition(index);23415index++;23416}23417});23418}2341923420setActiveRows(activeRows){23421this.activeRows = this.activeRows = Object.assign([], activeRows);23422this.activeRowsCount = this.activeRows.length;23423}2342423425//reset display rows array23426resetDisplayRows(){23427this.displayRows = [];2342823429this.displayRows.push(this.activeRows.slice(0));2343023431this.displayRowsCount = this.displayRows[0].length;23432}2343323434//set display row pipeline data23435setDisplayRows(displayRows, index){23436this.displayRows[index] = displayRows;2343723438if(index == this.displayRows.length -1){23439this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;23440}23441}2344223443getDisplayRows(index){23444if(typeof index == "undefined"){23445return this.displayRows.length ? this.displayRows[this.displayRows.length -1] : [];23446}else {23447return this.displayRows[index] || [];23448}23449}2345023451getVisibleRows(chain, viewable){23452var rows = Object.assign([], this.renderer.visibleRows(!viewable));2345323454if(chain){23455rows = this.chain("rows-visible", [viewable], rows, rows);23456}2345723458return rows;23459}2346023461//repeat action across display rows23462displayRowIterator(callback){23463this.activeRowsPipeline.forEach(callback);23464this.displayRows.forEach(callback);2346523466this.displayRowsCount = this.displayRows[this.displayRows.length -1].length;23467}2346823469//return only actual rows (not group headers etc)23470getRows(type){23471var rows = [];2347223473switch(type){23474case "active":23475rows = this.activeRows;23476break;2347723478case "display":23479rows = this.table.rowManager.getDisplayRows();23480break;2348123482case "visible":23483rows = this.getVisibleRows(false, true);23484break;2348523486default:23487rows = this.chain("rows-retrieve", type, null, this.rows) || this.rows;23488}2348923490return rows;23491}2349223493///////////////// Table Rendering /////////////////23494//trigger rerender of table in current position23495reRenderInPosition(callback){23496if(this.redrawBlock){23497if(callback){23498callback();23499}else {23500this.redrawBlockRenderInPosition = true;23501}23502}else {23503this.dispatchExternal("renderStarted");2350423505this.renderer.rerenderRows(callback);2350623507if(!this.fixedHeight){23508this.adjustTableSize();23509}2351023511this.scrollBarCheck();2351223513this.dispatchExternal("renderComplete");23514}23515}2351623517scrollBarCheck(){23518var scrollbarWidth = 0;2351923520//adjust for vertical scrollbar moving table when present23521if(this.element.scrollHeight > this.element.clientHeight){23522scrollbarWidth = this.element.offsetWidth - this.element.clientWidth;23523}2352423525if(scrollbarWidth !== this.scrollbarWidth){23526this.scrollbarWidth = scrollbarWidth;23527this.dispatch("scrollbar-vertical", scrollbarWidth);23528}23529}2353023531initializeRenderer(){23532var renderClass;2353323534var renderers = {23535"virtual": VirtualDomVertical,23536"basic": BasicVertical,23537};2353823539if(typeof this.table.options.renderVertical === "string"){23540renderClass = renderers[this.table.options.renderVertical];23541}else {23542renderClass = this.table.options.renderVertical;23543}2354423545if(renderClass){23546this.renderMode = this.table.options.renderVertical;2354723548this.renderer = new renderClass(this.table, this.element, this.tableElement);23549this.renderer.initialize();2355023551if((this.table.element.clientHeight || this.table.options.height) && !(this.table.options.minHeight && this.table.options.maxHeight)){23552this.fixedHeight = true;23553}else {23554this.fixedHeight = false;23555}23556}else {23557console.error("Unable to find matching renderer:", this.table.options.renderVertical);23558}23559}2356023561getRenderMode(){23562return this.renderMode;23563}2356423565renderTable(){23566this.dispatchExternal("renderStarted");2356723568this.element.scrollTop = 0;2356923570this._clearTable();2357123572if(this.displayRowsCount){23573this.renderer.renderRows();2357423575if(this.firstRender){23576this.firstRender = false;2357723578if(!this.fixedHeight){23579this.adjustTableSize();23580}2358123582this.layoutRefresh(true);23583}23584}else {23585this.renderEmptyScroll();23586}2358723588if(!this.fixedHeight){23589this.adjustTableSize();23590}2359123592this.dispatch("table-layout");2359323594if(!this.displayRowsCount){23595this._showPlaceholder();23596}2359723598this.scrollBarCheck();2359923600this.dispatchExternal("renderComplete");23601}2360223603//show scrollbars on empty table div23604renderEmptyScroll(){23605if(this.placeholder){23606this.tableElement.style.display = "none";23607}else {23608this.tableElement.style.minWidth = this.table.columnManager.getWidth() + "px";23609// this.tableElement.style.minHeight = "1px";23610// this.tableElement.style.visibility = "hidden";23611}23612}2361323614_clearTable(){23615this._clearPlaceholder();2361623617this.scrollTop = 0;23618this.scrollLeft = 0;2361923620this.renderer.clearRows();23621}2362223623tableEmpty(){23624this.renderEmptyScroll();23625this._showPlaceholder();23626}2362723628_showPlaceholder(){23629if(this.placeholder){23630if(this.placeholder && this.placeholder.parentNode){23631this.placeholder.parentNode.removeChild(this.placeholder);23632}2363323634this.initializePlaceholder();2363523636this.placeholder.setAttribute("tabulator-render-mode", this.renderMode);2363723638this.getElement().appendChild(this.placeholder);23639this._positionPlaceholder();2364023641this.adjustTableSize();23642}23643}2364423645_clearPlaceholder(){23646if(this.placeholder && this.placeholder.parentNode){23647this.placeholder.parentNode.removeChild(this.placeholder);23648}2364923650// clear empty table placeholder min23651this.tableElement.style.minWidth = "";23652this.tableElement.style.display = "";23653}2365423655_positionPlaceholder(){23656if(this.placeholder && this.placeholder.parentNode){23657this.placeholder.style.width = this.table.columnManager.getWidth() + "px";23658this.placeholderContents.style.width = this.table.rowManager.element.clientWidth + "px";23659this.placeholderContents.style.marginLeft = this.scrollLeft + "px";23660}23661}2366223663styleRow(row, index){23664var rowEl = row.getElement();2366523666if(index % 2){23667rowEl.classList.add("tabulator-row-even");23668rowEl.classList.remove("tabulator-row-odd");23669}else {23670rowEl.classList.add("tabulator-row-odd");23671rowEl.classList.remove("tabulator-row-even");23672}23673}2367423675//normalize height of active rows23676normalizeHeight(){23677this.activeRows.forEach(function(row){23678row.normalizeHeight();23679});23680}2368123682//adjust the height of the table holder to fit in the Tabulator element23683adjustTableSize(){23684let initialHeight = this.element.clientHeight, minHeight;23685let resized = false;2368623687if(this.renderer.verticalFillMode === "fill"){23688let 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));2368923690if(this.fixedHeight){23691minHeight = isNaN(this.table.options.minHeight) ? this.table.options.minHeight : this.table.options.minHeight + "px";2369223693const height = "calc(100% - " + otherHeight + "px)";23694this.element.style.minHeight = minHeight || "calc(100% - " + otherHeight + "px)";23695this.element.style.height = height;23696this.element.style.maxHeight = height;23697} else {23698this.element.style.height = "";23699this.element.style.height =23700this.table.element.clientHeight - otherHeight + "px";23701this.element.scrollTop = this.scrollTop;23702}2370323704this.renderer.resize();2370523706//check if the table has changed size when dealing with variable height tables23707if(!this.fixedHeight && initialHeight != this.element.clientHeight){23708resized = true;23709if(this.subscribed("table-resize")){23710this.dispatch("table-resize");23711}else {23712this.redraw();23713}23714}2371523716this.scrollBarCheck();23717}2371823719this._positionPlaceholder();23720return resized;23721}2372223723//reinitialize all rows23724reinitialize(){23725this.rows.forEach(function(row){23726row.reinitialize(true);23727});23728}2372923730//prevent table from being redrawn23731blockRedraw (){23732this.redrawBlock = true;23733this.redrawBlockRestoreConfig = false;23734}2373523736//restore table redrawing23737restoreRedraw (){23738this.redrawBlock = false;2373923740if(this.redrawBlockRestoreConfig){23741this.refreshActiveData(this.redrawBlockRestoreConfig.handler, this.redrawBlockRestoreConfig.skipStage, this.redrawBlockRestoreConfig.renderInPosition);2374223743this.redrawBlockRestoreConfig = false;23744}else {23745if(this.redrawBlockRenderInPosition){23746this.reRenderInPosition();23747}23748}2374923750this.redrawBlockRenderInPosition = false;23751}2375223753//redraw table23754redraw (force){23755const resized = this.adjustTableSize();23756this.table.tableWidth = this.table.element.clientWidth;2375723758if(!force){23759if(resized) {23760this.reRenderInPosition();23761}23762this.scrollHorizontal(this.scrollLeft);23763}else {23764this.renderTable();23765}23766}2376723768resetScroll(){23769this.element.scrollLeft = 0;23770this.element.scrollTop = 0;2377123772if(this.table.browser === "ie"){23773var event = document.createEvent("Event");23774event.initEvent("scroll", false, true);23775this.element.dispatchEvent(event);23776}else {23777this.element.dispatchEvent(new Event('scroll'));23778}23779}23780}2378123782class FooterManager extends CoreFeature{2378323784constructor(table){23785super(table);2378623787this.active = false;23788this.element = this.createElement(); //containing element23789this.containerElement = this.createContainerElement(); //containing element23790this.external = false;23791}2379223793initialize(){23794this.initializeElement();23795}2379623797createElement(){23798var el = document.createElement("div");2379923800el.classList.add("tabulator-footer");2380123802return el;23803}238042380523806createContainerElement(){23807var el = document.createElement("div");2380823809el.classList.add("tabulator-footer-contents");2381023811this.element.appendChild(el);2381223813return el;23814}2381523816initializeElement(){23817if(this.table.options.footerElement){2381823819switch(typeof this.table.options.footerElement){23820case "string":23821if(this.table.options.footerElement[0] === "<"){23822this.containerElement.innerHTML = this.table.options.footerElement;23823}else {23824this.external = true;23825this.containerElement = document.querySelector(this.table.options.footerElement);23826}23827break;2382823829default:23830this.element = this.table.options.footerElement;23831break;23832}23833}23834}2383523836getElement(){23837return this.element;23838}2383923840append(element){23841this.activate();2384223843this.containerElement.appendChild(element);23844this.table.rowManager.adjustTableSize();23845}2384623847prepend(element){23848this.activate();2384923850this.element.insertBefore(element, this.element.firstChild);23851this.table.rowManager.adjustTableSize();23852}2385323854remove(element){23855element.parentNode.removeChild(element);23856this.deactivate();23857}2385823859deactivate(force){23860if(!this.element.firstChild || force){23861if(!this.external){23862this.element.parentNode.removeChild(this.element);23863}23864this.active = false;23865}23866}2386723868activate(){23869if(!this.active){23870this.active = true;23871if(!this.external){23872this.table.element.appendChild(this.getElement());23873this.table.element.style.display = '';23874}23875}23876}2387723878redraw(){23879this.dispatch("footer-redraw");23880}23881}2388223883class InteractionManager extends CoreFeature {2388423885constructor (table){23886super(table);2388723888this.el = null;2388923890this.abortClasses = ["tabulator-headers", "tabulator-table"];2389123892this.previousTargets = {};2389323894this.listeners = [23895"click",23896"dblclick",23897"contextmenu",23898"mouseenter",23899"mouseleave",23900"mouseover",23901"mouseout",23902"mousemove",23903"mouseup",23904"mousedown",23905"touchstart",23906"touchend",23907];2390823909this.componentMap = {23910"tabulator-cell":"cell",23911"tabulator-row":"row",23912"tabulator-group":"group",23913"tabulator-col":"column",23914};2391523916this.pseudoTrackers = {23917"row":{23918subscriber:null,23919target:null,23920},23921"cell":{23922subscriber:null,23923target:null,23924},23925"group":{23926subscriber:null,23927target:null,23928},23929"column":{23930subscriber:null,23931target:null,23932},23933};2393423935this.pseudoTracking = false;23936}2393723938initialize(){23939this.el = this.table.element;2394023941this.buildListenerMap();23942this.bindSubscriptionWatchers();23943}2394423945buildListenerMap(){23946var listenerMap = {};2394723948this.listeners.forEach((listener) => {23949listenerMap[listener] = {23950handler:null,23951components:[],23952};23953});2395423955this.listeners = listenerMap;23956}2395723958bindPseudoEvents(){23959Object.keys(this.pseudoTrackers).forEach((key) => {23960this.pseudoTrackers[key].subscriber = this.pseudoMouseEnter.bind(this, key);23961this.subscribe(key + "-mouseover", this.pseudoTrackers[key].subscriber);23962});2396323964this.pseudoTracking = true;23965}2396623967pseudoMouseEnter(key, e, target){23968if(this.pseudoTrackers[key].target !== target){2396923970if(this.pseudoTrackers[key].target){23971this.dispatch(key + "-mouseleave", e, this.pseudoTrackers[key].target);23972}2397323974this.pseudoMouseLeave(key, e);2397523976this.pseudoTrackers[key].target = target;2397723978this.dispatch(key + "-mouseenter", e, target);23979}23980}2398123982pseudoMouseLeave(key, e){23983var leaveList = Object.keys(this.pseudoTrackers),23984linkedKeys = {23985"row":["cell"],23986"cell":["row"],23987};2398823989leaveList = leaveList.filter((item) => {23990var links = linkedKeys[key];23991return item !== key && (!links || (links && !links.includes(item)));23992});239932399423995leaveList.forEach((key) => {23996var target = this.pseudoTrackers[key].target;2399723998if(this.pseudoTrackers[key].target){23999this.dispatch(key + "-mouseleave", e, target);2400024001this.pseudoTrackers[key].target = null;24002}24003});24004}240052400624007bindSubscriptionWatchers(){24008var listeners = Object.keys(this.listeners),24009components = Object.values(this.componentMap);2401024011for(let comp of components){24012for(let listener of listeners){24013let key = comp + "-" + listener;2401424015this.subscriptionChange(key, this.subscriptionChanged.bind(this, comp, listener));24016}24017}2401824019this.subscribe("table-destroy", this.clearWatchers.bind(this));24020}2402124022subscriptionChanged(component, key, added){24023var listener = this.listeners[key].components,24024index = listener.indexOf(component),24025changed = false;2402624027if(added){24028if(index === -1){24029listener.push(component);24030changed = true;24031}24032}else {24033if(!this.subscribed(component + "-" + key)){24034if(index > -1){24035listener.splice(index, 1);24036changed = true;24037}24038}24039}2404024041if((key === "mouseenter" || key === "mouseleave") && !this.pseudoTracking){24042this.bindPseudoEvents();24043}2404424045if(changed){24046this.updateEventListeners();24047}24048}2404924050updateEventListeners(){24051for(let key in this.listeners){24052let listener = this.listeners[key];2405324054if(listener.components.length){24055if(!listener.handler){24056listener.handler = this.track.bind(this, key);24057this.el.addEventListener(key, listener.handler);24058// this.el.addEventListener(key, listener.handler, {passive: true})24059}24060}else {24061if(listener.handler){24062this.el.removeEventListener(key, listener.handler);24063listener.handler = null;24064}24065}24066}24067}2406824069track(type, e){24070var path = (e.composedPath && e.composedPath()) || e.path;2407124072var targets = this.findTargets(path);24073targets = this.bindComponents(type, targets);2407424075this.triggerEvents(type, e, targets);2407624077if(this.pseudoTracking && (type == "mouseover" || type == "mouseleave") && !Object.keys(targets).length){24078this.pseudoMouseLeave("none", e);24079}24080}2408124082findTargets(path){24083var targets = {};2408424085let componentMap = Object.keys(this.componentMap);2408624087for (let el of path) {24088let classList = el.classList ? [...el.classList] : [];2408924090let abort = classList.filter((item) => {24091return this.abortClasses.includes(item);24092});2409324094if(abort.length){24095break;24096}2409724098let elTargets = classList.filter((item) => {24099return componentMap.includes(item);24100});2410124102for (let target of elTargets) {24103if(!targets[this.componentMap[target]]){24104targets[this.componentMap[target]] = el;24105}24106}24107}2410824109if(targets.group && targets.group === targets.row){24110delete targets.row;24111}2411224113return targets;24114}2411524116bindComponents(type, targets){24117//ensure row component is looked up before cell24118var keys = Object.keys(targets).reverse(),24119listener = this.listeners[type],24120matches = {},24121targetMatches = {};2412224123for(let key of keys){24124let component,24125target = targets[key],24126previousTarget = this.previousTargets[key];2412724128if(previousTarget && previousTarget.target === target){24129component = previousTarget.component;24130}else {24131switch(key){24132case "row":24133case "group":24134if(listener.components.includes("row") || listener.components.includes("cell") || listener.components.includes("group")){24135let rows = this.table.rowManager.getVisibleRows(true);2413624137component = rows.find((row) => {24138return row.getElement() === target;24139});2414024141if(targets["row"] && targets["row"].parentNode && targets["row"].parentNode.closest(".tabulator-row")){24142targets[key] = false;24143}24144}24145break;2414624147case "column":24148if(listener.components.includes("column")){24149component = this.table.columnManager.findColumn(target);24150}24151break;2415224153case "cell":24154if(listener.components.includes("cell")){24155if(matches["row"] instanceof Row){24156component = matches["row"].findCell(target);24157}else {24158if(targets["row"]){24159console.warn("Event Target Lookup Error - The row this cell is attached to cannot be found, has the table been reinitialized without being destroyed first?");24160}24161}24162}24163break;24164}24165}2416624167if(component){24168matches[key] = component;24169targetMatches[key] = {24170target:target,24171component:component,24172};24173}24174}2417524176this.previousTargets = targetMatches;2417724178return matches;24179}2418024181triggerEvents(type, e, targets){24182var listener = this.listeners[type];2418324184for(let key in targets){24185if(targets[key] && listener.components.includes(key)){24186this.dispatch(key + "-" + type, e, targets[key]);24187}24188}24189}2419024191clearWatchers(){24192for(let key in this.listeners){24193let listener = this.listeners[key];2419424195if(listener.handler){24196this.el.removeEventListener(key, listener.handler);24197listener.handler = null;24198}24199}24200}24201}2420224203class ComponentFunctionBinder{2420424205constructor(table){24206this.table = table;2420724208this.bindings = {};24209}2421024211bind(type, funcName, handler){24212if(!this.bindings[type]){24213this.bindings[type] = {};24214}2421524216if(this.bindings[type][funcName]){24217console.warn("Unable to bind component handler, a matching function name is already bound", type, funcName, handler);24218}else {24219this.bindings[type][funcName] = handler;24220}24221}2422224223handle(type, component, name){24224if(this.bindings[type] && this.bindings[type][name] && typeof this.bindings[type][name].bind === 'function'){24225return this.bindings[type][name].bind(null, component);24226}else {24227if(name !== "then" && typeof name === "string" && !name.startsWith("_")){24228if(this.table.options.debugInvalidComponentFuncs){24229console.error("The " + type + " component does not have a " + name + " function, have you checked that you have the correct Tabulator module installed?");24230}24231}24232}24233}24234}2423524236class DataLoader extends CoreFeature{24237constructor(table){24238super(table);2423924240this.requestOrder = 0; //prevent requests coming out of sequence if overridden by another load request24241this.loading = false;24242}2424324244initialize(){}2424524246load(data, params, config, replace, silent, columnsChanged){24247var requestNo = ++this.requestOrder;2424824249if(this.table.destroyed){24250return Promise.resolve();24251}2425224253this.dispatchExternal("dataLoading", data);2425424255//parse json data to array24256if (data && (data.indexOf("{") == 0 || data.indexOf("[") == 0)){24257data = JSON.parse(data);24258}2425924260if(this.confirm("data-loading", [data, params, config, silent])){24261this.loading = true;2426224263if(!silent){24264this.alertLoader();24265}2426624267//get params for request24268params = this.chain("data-params", [data, config, silent], params || {}, params || {});2426924270params = this.mapParams(params, this.table.options.dataSendParams);2427124272var result = this.chain("data-load", [data, params, config, silent], false, Promise.resolve([]));2427324274return result.then((response) => {24275if(!this.table.destroyed){24276if(!Array.isArray(response) && typeof response == "object"){24277response = this.mapParams(response, this.objectInvert(this.table.options.dataReceiveParams));24278}2427924280var rowData = this.chain("data-loaded", response, null, response);2428124282if(requestNo == this.requestOrder){24283this.clearAlert();2428424285if(rowData !== false){24286this.dispatchExternal("dataLoaded", rowData);24287this.table.rowManager.setData(rowData, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);24288}24289}else {24290console.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");24291}24292}else {24293console.warn("Data Load Response Blocked - Table has been destroyed");24294}24295}).catch((error) => {24296console.error("Data Load Error: ", error);24297this.dispatchExternal("dataLoadError", error);2429824299if(!silent){24300this.alertError();24301}2430224303setTimeout(() => {24304this.clearAlert();24305}, this.table.options.dataLoaderErrorTimeout);24306})24307.finally(() => {24308this.loading = false;24309});24310}else {24311this.dispatchExternal("dataLoaded", data);2431224313if(!data){24314data = [];24315}2431624317this.table.rowManager.setData(data, replace, typeof columnsChanged === "undefined" ? !replace : columnsChanged);24318return Promise.resolve();24319}24320}2432124322mapParams(params, map){24323var output = {};2432424325for(let key in params){24326output[map.hasOwnProperty(key) ? map[key] : key] = params[key];24327}2432824329return output;24330}2433124332objectInvert(obj){24333var output = {};2433424335for(let key in obj){24336output[obj[key]] = key;24337}2433824339return output;24340}2434124342blockActiveLoad(){24343this.requestOrder++;24344}2434524346alertLoader(){24347var shouldLoad = typeof this.table.options.dataLoader === "function" ? this.table.options.dataLoader() : this.table.options.dataLoader;2434824349if(shouldLoad){24350this.table.alertManager.alert(this.table.options.dataLoaderLoading || this.langText("data|loading"));24351}24352}2435324354alertError(){24355this.table.alertManager.alert(this.table.options.dataLoaderError || this.langText("data|error"), "error");24356}2435724358clearAlert(){24359this.table.alertManager.clear();24360}24361}2436224363class ExternalEventBus {2436424365constructor(table, optionsList, debug){24366this.table = table;24367this.events = {};24368this.optionsList = optionsList || {};24369this.subscriptionNotifiers = {};2437024371this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this);24372this.debug = debug;24373}2437424375subscriptionChange(key, callback){24376if(!this.subscriptionNotifiers[key]){24377this.subscriptionNotifiers[key] = [];24378}2437924380this.subscriptionNotifiers[key].push(callback);2438124382if(this.subscribed(key)){24383this._notifySubscriptionChange(key, true);24384}24385}2438624387subscribe(key, callback){24388if(!this.events[key]){24389this.events[key] = [];24390}2439124392this.events[key].push(callback);2439324394this._notifySubscriptionChange(key, true);24395}2439624397unsubscribe(key, callback){24398var index;2439924400if(this.events[key]){24401if(callback){24402index = this.events[key].findIndex((item) => {24403return item === callback;24404});2440524406if(index > -1){24407this.events[key].splice(index, 1);24408}else {24409console.warn("Cannot remove event, no matching event found:", key, callback);24410return;24411}24412}else {24413delete this.events[key];24414}24415}else {24416console.warn("Cannot remove event, no events set on:", key);24417return;24418}2441924420this._notifySubscriptionChange(key, false);24421}2442224423subscribed(key){24424return this.events[key] && this.events[key].length;24425}2442624427_notifySubscriptionChange(key, subscribed){24428var notifiers = this.subscriptionNotifiers[key];2442924430if(notifiers){24431notifiers.forEach((callback)=>{24432callback(subscribed);24433});24434}24435}2443624437_dispatch(){24438var args = Array.from(arguments),24439key = args.shift(),24440result;2444124442if(this.events[key]){24443this.events[key].forEach((callback, i) => {24444let callResult = callback.apply(this.table, args);2444524446if(!i){24447result = callResult;24448}24449});24450}2445124452return result;24453}2445424455_debugDispatch(){24456var args = Array.from(arguments),24457key = args[0];2445824459args[0] = "ExternalEvent:" + args[0];2446024461if(this.debug === true || this.debug.includes(key)){24462console.log(...args);24463}2446424465return this._dispatch(...arguments);24466}24467}2446824469class InternalEventBus {2447024471constructor(debug){24472this.events = {};24473this.subscriptionNotifiers = {};2447424475this.dispatch = debug ? this._debugDispatch.bind(this) : this._dispatch.bind(this);24476this.chain = debug ? this._debugChain.bind(this) : this._chain.bind(this);24477this.confirm = debug ? this._debugConfirm.bind(this) : this._confirm.bind(this);24478this.debug = debug;24479}2448024481subscriptionChange(key, callback){24482if(!this.subscriptionNotifiers[key]){24483this.subscriptionNotifiers[key] = [];24484}2448524486this.subscriptionNotifiers[key].push(callback);2448724488if(this.subscribed(key)){24489this._notifySubscriptionChange(key, true);24490}24491}2449224493subscribe(key, callback, priority = 10000){24494if(!this.events[key]){24495this.events[key] = [];24496}2449724498this.events[key].push({callback, priority});2449924500this.events[key].sort((a, b) => {24501return a.priority - b.priority;24502});2450324504this._notifySubscriptionChange(key, true);24505}2450624507unsubscribe(key, callback){24508var index;2450924510if(this.events[key]){24511if(callback){24512index = this.events[key].findIndex((item) => {24513return item.callback === callback;24514});2451524516if(index > -1){24517this.events[key].splice(index, 1);24518}else {24519console.warn("Cannot remove event, no matching event found:", key, callback);24520return;24521}24522}24523}else {24524console.warn("Cannot remove event, no events set on:", key);24525return;24526}2452724528this._notifySubscriptionChange(key, false);24529}2453024531subscribed(key){24532return this.events[key] && this.events[key].length;24533}2453424535_chain(key, args, initialValue, fallback){24536var value = initialValue;2453724538if(!Array.isArray(args)){24539args = [args];24540}2454124542if(this.subscribed(key)){24543this.events[key].forEach((subscriber, i) => {24544value = subscriber.callback.apply(this, args.concat([value]));24545});2454624547return value;24548}else {24549return typeof fallback === "function" ? fallback() : fallback;24550}24551}2455224553_confirm(key, args){24554var confirmed = false;2455524556if(!Array.isArray(args)){24557args = [args];24558}2455924560if(this.subscribed(key)){24561this.events[key].forEach((subscriber, i) => {24562if(subscriber.callback.apply(this, args)){24563confirmed = true;24564}24565});24566}2456724568return confirmed;24569}2457024571_notifySubscriptionChange(key, subscribed){24572var notifiers = this.subscriptionNotifiers[key];2457324574if(notifiers){24575notifiers.forEach((callback)=>{24576callback(subscribed);24577});24578}24579}2458024581_dispatch(){24582var args = Array.from(arguments),24583key = args.shift();2458424585if(this.events[key]){24586this.events[key].forEach((subscriber) => {24587subscriber.callback.apply(this, args);24588});24589}24590}2459124592_debugDispatch(){24593var args = Array.from(arguments),24594key = args[0];2459524596args[0] = "InternalEvent:" + key;2459724598if(this.debug === true || this.debug.includes(key)){24599console.log(...args);24600}2460124602return this._dispatch(...arguments);24603}2460424605_debugChain(){24606var args = Array.from(arguments),24607key = args[0];2460824609args[0] = "InternalEvent:" + key;2461024611if(this.debug === true || this.debug.includes(key)){24612console.log(...args);24613}2461424615return this._chain(...arguments);24616}2461724618_debugConfirm(){24619var args = Array.from(arguments),24620key = args[0];2462124622args[0] = "InternalEvent:" + key;2462324624if(this.debug === true || this.debug.includes(key)){24625console.log(...args);24626}2462724628return this._confirm(...arguments);24629}24630}2463124632class DeprecationAdvisor extends CoreFeature{2463324634constructor(table){24635super(table);24636}2463724638_warnUser(){24639if(this.options("debugDeprecation")){24640console.warn(...arguments);24641}24642}2464324644check(oldOption, newOption){24645var msg = "";2464624647if(typeof this.options(oldOption) !== "undefined"){24648msg = "Deprecated Setup Option - Use of the %c" + oldOption + "%c option is now deprecated";2464924650if(newOption){24651msg = msg + ", Please use the %c" + newOption + "%c option instead";24652this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;', 'font-weight: bold;', 'font-weight: normal;');24653}else {24654this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;');24655}2465624657return false;24658}else {24659return true;24660}24661}2466224663checkMsg(oldOption, msg){24664if(typeof this.options(oldOption) !== "undefined"){24665this._warnUser("%cDeprecated Setup Option - Use of the %c" + oldOption + " %c option is now deprecated, " + msg, 'font-weight: normal;', 'font-weight: bold;', 'font-weight: normal;');2466624667return false;24668}else {24669return true;24670}24671}2467224673msg(msg){24674this._warnUser(msg);24675}24676}2467724678class TableRegistry {2467924680static register(table){24681TableRegistry.tables.push(table);24682}2468324684static deregister(table){24685var index = TableRegistry.tables.indexOf(table);2468624687if(index > -1){24688TableRegistry.tables.splice(index, 1);24689}24690}2469124692static lookupTable(query, silent){24693var results = [],24694matches, match;2469524696if(typeof query === "string"){24697matches = document.querySelectorAll(query);2469824699if(matches.length){24700for(var i = 0; i < matches.length; i++){24701match = TableRegistry.matchElement(matches[i]);2470224703if(match){24704results.push(match);24705}24706}24707}2470824709}else if((typeof HTMLElement !== "undefined" && query instanceof HTMLElement) || query instanceof Tabulator){24710match = TableRegistry.matchElement(query);2471124712if(match){24713results.push(match);24714}24715}else if(Array.isArray(query)){24716query.forEach(function(item){24717results = results.concat(TableRegistry.lookupTable(item));24718});24719}else {24720if(!silent){24721console.warn("Table Connection Error - Invalid Selector", query);24722}24723}2472424725return results;24726}2472724728static matchElement(element){24729return TableRegistry.tables.find(function(table){24730return element instanceof Tabulator ? table === element : table.element === element;24731});24732}24733}2473424735TableRegistry.tables = [];2473624737//resize columns to fit data they contain24738function fitData(columns, forced){24739if(forced){24740this.table.columnManager.renderer.reinitializeColumnWidths(columns);24741}2474224743if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){24744this.table.modules.responsiveLayout.update();24745}24746}2474724748//resize columns to fit data they contain and stretch row to fill table, also used for fitDataTable24749function fitDataGeneral(columns, forced){24750columns.forEach(function(column){24751column.reinitializeWidth();24752});2475324754if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){24755this.table.modules.responsiveLayout.update();24756}24757}2475824759//resize columns to fit data the contain and stretch last column to fill table24760function fitDataStretch(columns, forced){24761var colsWidth = 0,24762tableWidth = this.table.rowManager.element.clientWidth,24763gap = 0,24764lastCol = false;2476524766columns.forEach((column, i) => {24767if(!column.widthFixed){24768column.reinitializeWidth();24769}2477024771if(this.table.options.responsiveLayout ? column.modules.responsive.visible : column.visible){24772lastCol = column;24773}2477424775if(column.visible){24776colsWidth += column.getWidth();24777}24778});2477924780if(lastCol){24781gap = tableWidth - colsWidth + lastCol.getWidth();2478224783if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){24784lastCol.setWidth(0);24785this.table.modules.responsiveLayout.update();24786}2478724788if(gap > 0){24789lastCol.setWidth(gap);24790}else {24791lastCol.reinitializeWidth();24792}24793}else {24794if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){24795this.table.modules.responsiveLayout.update();24796}24797}24798}2479924800//resize columns to fit24801function fitColumns(columns, forced){24802var totalWidth = this.table.rowManager.element.getBoundingClientRect().width; //table element width24803var fixedWidth = 0; //total width of columns with a defined width24804var flexWidth = 0; //total width available to flexible columns24805var flexGrowUnits = 0; //total number of widthGrow blocks across all columns24806var flexColWidth = 0; //desired width of flexible columns24807var flexColumns = []; //array of flexible width columns24808var fixedShrinkColumns = []; //array of fixed width columns that can shrink24809var flexShrinkUnits = 0; //total number of widthShrink blocks across all columns24810var overflowWidth = 0; //horizontal overflow width24811var gapFill = 0; //number of pixels to be added to final column to close and half pixel gaps2481224813function calcWidth(width){24814var colWidth;2481524816if(typeof(width) == "string"){24817if(width.indexOf("%") > -1){24818colWidth = (totalWidth / 100) * parseInt(width);24819}else {24820colWidth = parseInt(width);24821}24822}else {24823colWidth = width;24824}2482524826return colWidth;24827}2482824829//ensure columns resize to take up the correct amount of space24830function scaleColumns(columns, freeSpace, colWidth, shrinkCols){24831var oversizeCols = [],24832oversizeSpace = 0,24833remainingSpace = 0,24834nextColWidth = 0,24835remainingFlexGrowUnits = flexGrowUnits,24836gap = 0,24837changeUnits = 0,24838undersizeCols = [];2483924840function calcGrow(col){24841return (colWidth * (col.column.definition.widthGrow || 1));24842}2484324844function calcShrink(col){24845return (calcWidth(col.width) - (colWidth * (col.column.definition.widthShrink || 0)));24846}2484724848columns.forEach(function(col, i){24849var width = shrinkCols ? calcShrink(col) : calcGrow(col);24850if(col.column.minWidth >= width){24851oversizeCols.push(col);24852}else {24853if(col.column.maxWidth && col.column.maxWidth < width){24854col.width = col.column.maxWidth;24855freeSpace -= col.column.maxWidth;2485624857remainingFlexGrowUnits -= shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);2485824859if(remainingFlexGrowUnits){24860colWidth = Math.floor(freeSpace/remainingFlexGrowUnits);24861}24862}else {24863undersizeCols.push(col);24864changeUnits += shrinkCols ? (col.column.definition.widthShrink || 1) : (col.column.definition.widthGrow || 1);24865}24866}24867});2486824869if(oversizeCols.length){24870oversizeCols.forEach(function(col){24871oversizeSpace += shrinkCols ? col.width - col.column.minWidth : col.column.minWidth;24872col.width = col.column.minWidth;24873});2487424875remainingSpace = freeSpace - oversizeSpace;2487624877nextColWidth = changeUnits ? Math.floor(remainingSpace/changeUnits) : remainingSpace;2487824879gap = scaleColumns(undersizeCols, remainingSpace, nextColWidth, shrinkCols);24880}else {24881gap = changeUnits ? freeSpace - (Math.floor(freeSpace/changeUnits) * changeUnits) : freeSpace;2488224883undersizeCols.forEach(function(column){24884column.width = shrinkCols ? calcShrink(column) : calcGrow(column);24885});24886}2488724888return gap;24889}2489024891if(this.table.options.responsiveLayout && this.table.modExists("responsiveLayout", true)){24892this.table.modules.responsiveLayout.update();24893}2489424895//adjust for vertical scrollbar if present24896if(this.table.rowManager.element.scrollHeight > this.table.rowManager.element.clientHeight){24897totalWidth -= this.table.rowManager.element.offsetWidth - this.table.rowManager.element.clientWidth;24898}2489924900columns.forEach(function(column){24901var width, minWidth, colWidth;2490224903if(column.visible){2490424905width = column.definition.width;24906minWidth = parseInt(column.minWidth);2490724908if(width){2490924910colWidth = calcWidth(width);2491124912fixedWidth += colWidth > minWidth ? colWidth : minWidth;2491324914if(column.definition.widthShrink){24915fixedShrinkColumns.push({24916column:column,24917width:colWidth > minWidth ? colWidth : minWidth24918});24919flexShrinkUnits += column.definition.widthShrink;24920}2492124922}else {24923flexColumns.push({24924column:column,24925width:0,24926});24927flexGrowUnits += column.definition.widthGrow || 1;24928}24929}24930});2493124932//calculate available space24933flexWidth = totalWidth - fixedWidth;2493424935//calculate correct column size24936flexColWidth = Math.floor(flexWidth / flexGrowUnits);2493724938//generate column widths24939gapFill = scaleColumns(flexColumns, flexWidth, flexColWidth, false);2494024941//increase width of last column to account for rounding errors24942if(flexColumns.length && gapFill > 0){24943flexColumns[flexColumns.length-1].width += gapFill;24944}2494524946//calculate space for columns to be shrunk into24947flexColumns.forEach(function(col){24948flexWidth -= col.width;24949});2495024951overflowWidth = Math.abs(gapFill) + flexWidth;2495224953//shrink oversize columns if there is no available space24954if(overflowWidth > 0 && flexShrinkUnits){24955gapFill = scaleColumns(fixedShrinkColumns, overflowWidth, Math.floor(overflowWidth / flexShrinkUnits), true);24956}2495724958//decrease width of last column to account for rounding errors24959if(gapFill && fixedShrinkColumns.length){24960fixedShrinkColumns[fixedShrinkColumns.length-1].width -= gapFill;24961}2496224963flexColumns.forEach(function(col){24964col.column.setWidth(col.width);24965});2496624967fixedShrinkColumns.forEach(function(col){24968col.column.setWidth(col.width);24969});24970}2497124972var defaultModes = {24973fitData:fitData,24974fitDataFill:fitDataGeneral,24975fitDataTable:fitDataGeneral,24976fitDataStretch:fitDataStretch,24977fitColumns:fitColumns ,24978};2497924980class Layout extends Module{2498124982constructor(table){24983super(table, "layout");2498424985this.mode = null;2498624987this.registerTableOption("layout", "fitData"); //layout type24988this.registerTableOption("layoutColumnsOnNewData", false); //update column widths on setData2498924990this.registerColumnOption("widthGrow");24991this.registerColumnOption("widthShrink");24992}2499324994//initialize layout system24995initialize(){24996var layout = this.table.options.layout;2499724998if(Layout.modes[layout]){24999this.mode = layout;25000}else {25001console.warn("Layout Error - invalid mode set, defaulting to 'fitData' : " + layout);25002this.mode = 'fitData';25003}2500425005this.table.element.setAttribute("tabulator-layout", this.mode);25006this.subscribe("column-init", this.initializeColumn.bind(this));25007}2500825009initializeColumn(column){25010if(column.definition.widthGrow){25011column.definition.widthGrow = Number(column.definition.widthGrow);25012}25013if(column.definition.widthShrink){25014column.definition.widthShrink = Number(column.definition.widthShrink);25015}25016}2501725018getMode(){25019return this.mode;25020}2502125022//trigger table layout25023layout(dataChanged){25024this.dispatch("layout-refreshing");25025Layout.modes[this.mode].call(this, this.table.columnManager.columnsByIndex, dataChanged);25026this.dispatch("layout-refreshed");25027}25028}2502925030Layout.moduleName = "layout";2503125032//load defaults25033Layout.modes = defaultModes;2503425035var defaultLangs = {25036"default":{ //hold default locale text25037"groups":{25038"item":"item",25039"items":"items",25040},25041"columns":{25042},25043"data":{25044"loading":"Loading",25045"error":"Error",25046},25047"pagination":{25048"page_size":"Page Size",25049"page_title":"Show Page",25050"first":"First",25051"first_title":"First Page",25052"last":"Last",25053"last_title":"Last Page",25054"prev":"Prev",25055"prev_title":"Prev Page",25056"next":"Next",25057"next_title":"Next Page",25058"all":"All",25059"counter":{25060"showing": "Showing",25061"of": "of",25062"rows": "rows",25063"pages": "pages",25064}25065},25066"headerFilters":{25067"default":"filter column...",25068"columns":{}25069}25070},25071};2507225073class Localize extends Module{2507425075constructor(table){25076super(table);2507725078this.locale = "default"; //current locale25079this.lang = false; //current language25080this.bindings = {}; //update events to call when locale is changed25081this.langList = {};2508225083this.registerTableOption("locale", false); //current system language25084this.registerTableOption("langs", {});25085}2508625087initialize(){25088this.langList = Helpers.deepClone(Localize.langs);2508925090if(this.table.options.columnDefaults.headerFilterPlaceholder !== false){25091this.setHeaderFilterPlaceholder(this.table.options.columnDefaults.headerFilterPlaceholder);25092}2509325094for(let locale in this.table.options.langs){25095this.installLang(locale, this.table.options.langs[locale]);25096}2509725098this.setLocale(this.table.options.locale);2509925100this.registerTableFunction("setLocale", this.setLocale.bind(this));25101this.registerTableFunction("getLocale", this.getLocale.bind(this));25102this.registerTableFunction("getLang", this.getLang.bind(this));25103}2510425105//set header placeholder25106setHeaderFilterPlaceholder(placeholder){25107this.langList.default.headerFilters.default = placeholder;25108}2510925110//setup a lang description object25111installLang(locale, lang){25112if(this.langList[locale]){25113this._setLangProp(this.langList[locale], lang);25114}else {25115this.langList[locale] = lang;25116}25117}2511825119_setLangProp(lang, values){25120for(let key in values){25121if(lang[key] && typeof lang[key] == "object"){25122this._setLangProp(lang[key], values[key]);25123}else {25124lang[key] = values[key];25125}25126}25127}2512825129//set current locale25130setLocale(desiredLocale){25131desiredLocale = desiredLocale || "default";2513225133//fill in any matching language values25134function traverseLang(trans, path){25135for(var prop in trans){25136if(typeof trans[prop] == "object"){25137if(!path[prop]){25138path[prop] = {};25139}25140traverseLang(trans[prop], path[prop]);25141}else {25142path[prop] = trans[prop];25143}25144}25145}2514625147//determining correct locale to load25148if(desiredLocale === true && navigator.language){25149//get local from system25150desiredLocale = navigator.language.toLowerCase();25151}2515225153if(desiredLocale){25154//if locale is not set, check for matching top level locale else use default25155if(!this.langList[desiredLocale]){25156let prefix = desiredLocale.split("-")[0];2515725158if(this.langList[prefix]){25159console.warn("Localization Error - Exact matching locale not found, using closest match: ", desiredLocale, prefix);25160desiredLocale = prefix;25161}else {25162console.warn("Localization Error - Matching locale not found, using default: ", desiredLocale);25163desiredLocale = "default";25164}25165}25166}2516725168this.locale = desiredLocale;2516925170//load default lang template25171this.lang = Helpers.deepClone(this.langList.default || {});2517225173if(desiredLocale != "default"){25174traverseLang(this.langList[desiredLocale], this.lang);25175}2517625177this.dispatchExternal("localized", this.locale, this.lang);2517825179this._executeBindings();25180}2518125182//get current locale25183getLocale(locale){25184return this.locale;25185}2518625187//get lang object for given local or current if none provided25188getLang(locale){25189return locale ? this.langList[locale] : this.lang;25190}2519125192//get text for current locale25193getText(path, value){25194var fillPath = value ? path + "|" + value : path,25195pathArray = fillPath.split("|"),25196text = this._getLangElement(pathArray, this.locale);2519725198// if(text === false){25199// console.warn("Localization Error - Matching localized text not found for given path: ", path);25200// }2520125202return text || "";25203}2520425205//traverse langs object and find localized copy25206_getLangElement(path, locale){25207var root = this.lang;2520825209path.forEach(function(level){25210var rootPath;2521125212if(root){25213rootPath = root[level];2521425215if(typeof rootPath != "undefined"){25216root = rootPath;25217}else {25218root = false;25219}25220}25221});2522225223return root;25224}2522525226//set update binding25227bind(path, callback){25228if(!this.bindings[path]){25229this.bindings[path] = [];25230}2523125232this.bindings[path].push(callback);2523325234callback(this.getText(path), this.lang);25235}2523625237//iterate through bindings and trigger updates25238_executeBindings(){25239for(let path in this.bindings){25240this.bindings[path].forEach((binding) => {25241binding(this.getText(path), this.lang);25242});25243}25244}25245}2524625247Localize.moduleName = "localize";2524825249//load defaults25250Localize.langs = defaultLangs;2525125252class Comms extends Module{2525325254constructor(table){25255super(table);25256}2525725258initialize(){25259this.registerTableFunction("tableComms", this.receive.bind(this));25260}2526125262getConnections(selectors){25263var connections = [],25264connection;2526525266connection = TableRegistry.lookupTable(selectors);2526725268connection.forEach((con) =>{25269if(this.table !== con){25270connections.push(con);25271}25272});2527325274return connections;25275}2527625277send(selectors, module, action, data){25278var connections = this.getConnections(selectors);2527925280connections.forEach((connection) => {25281connection.tableComms(this.table.element, module, action, data);25282});2528325284if(!connections.length && selectors){25285console.warn("Table Connection Error - No tables matching selector found", selectors);25286}25287}2528825289receive(table, module, action, data){25290if(this.table.modExists(module)){25291return this.table.modules[module].commsReceived(table, action, data);25292}else {25293console.warn("Inter-table Comms Error - no such module:", module);25294}25295}25296}2529725298Comms.moduleName = "comms";2529925300var coreModules = /*#__PURE__*/Object.freeze({25301__proto__: null,25302LayoutModule: Layout,25303LocalizeModule: Localize,25304CommsModule: Comms25305});2530625307class ModuleBinder {2530825309constructor(tabulator, modules){25310this.bindStaticFunctionality(tabulator);25311this.bindModules(tabulator, coreModules, true);2531225313if(modules){25314this.bindModules(tabulator, modules);25315}25316}2531725318bindStaticFunctionality(tabulator){25319tabulator.moduleBindings = {};2532025321tabulator.extendModule = function(name, property, values){25322if(tabulator.moduleBindings[name]){25323var source = tabulator.moduleBindings[name][property];2532425325if(source){25326if(typeof values == "object"){25327for(let key in values){25328source[key] = values[key];25329}25330}else {25331console.warn("Module Error - Invalid value type, it must be an object");25332}25333}else {25334console.warn("Module Error - property does not exist:", property);25335}25336}else {25337console.warn("Module Error - module does not exist:", name);25338}25339};2534025341tabulator.registerModule = function(modules){25342if(!Array.isArray(modules)){25343modules = [modules];25344}2534525346modules.forEach((mod) => {25347tabulator.registerModuleBinding(mod);25348});25349};2535025351tabulator.registerModuleBinding = function(mod){25352tabulator.moduleBindings[mod.moduleName] = mod;25353};2535425355tabulator.findTable = function(query){25356var results = TableRegistry.lookupTable(query, true);25357return Array.isArray(results) && !results.length ? false : results;25358};2535925360//ensure that module are bound to instantiated function25361tabulator.prototype.bindModules = function(){25362var orderedStartMods = [],25363orderedEndMods = [],25364unOrderedMods = [];2536525366this.modules = {};2536725368for(var name in tabulator.moduleBindings){25369let mod = tabulator.moduleBindings[name];25370let module = new mod(this);2537125372this.modules[name] = module;2537325374if(mod.prototype.moduleCore){25375this.modulesCore.push(module);25376}else {25377if(mod.moduleInitOrder){25378if(mod.moduleInitOrder < 0){25379orderedStartMods.push(module);25380}else {25381orderedEndMods.push(module);25382}2538325384}else {25385unOrderedMods.push(module);25386}25387}25388}2538925390orderedStartMods.sort((a, b) => a.moduleInitOrder > b.moduleInitOrder ? 1 : -1);25391orderedEndMods.sort((a, b) => a.moduleInitOrder > b.moduleInitOrder ? 1 : -1);2539225393this.modulesRegular = orderedStartMods.concat(unOrderedMods.concat(orderedEndMods));25394};25395}2539625397bindModules(tabulator, modules, core){25398var mods = Object.values(modules);2539925400if(core){25401mods.forEach((mod) => {25402mod.prototype.moduleCore = true;25403});25404}2540525406tabulator.registerModule(mods);25407}25408}2540925410class Alert extends CoreFeature{25411constructor(table){25412super(table);2541325414this.element = this._createAlertElement();25415this.msgElement = this._createMsgElement();25416this.type = null;2541725418this.element.appendChild(this.msgElement);25419}2542025421_createAlertElement(){25422var el = document.createElement("div");25423el.classList.add("tabulator-alert");25424return el;25425}2542625427_createMsgElement(){25428var el = document.createElement("div");25429el.classList.add("tabulator-alert-msg");25430el.setAttribute("role", "alert");25431return el;25432}2543325434_typeClass(){25435return "tabulator-alert-state-" + this.type;25436}2543725438alert(content, type = "msg"){25439if(content){25440this.clear();2544125442this.type = type;2544325444while(this.msgElement.firstChild) this.msgElement.removeChild(this.msgElement.firstChild);2544525446this.msgElement.classList.add(this._typeClass());2544725448if(typeof content === "function"){25449content = content();25450}2545125452if(content instanceof HTMLElement){25453this.msgElement.appendChild(content);25454}else {25455this.msgElement.innerHTML = content;25456}2545725458this.table.element.appendChild(this.element);25459}25460}2546125462clear(){25463if(this.element.parentNode){25464this.element.parentNode.removeChild(this.element);25465}2546625467this.msgElement.classList.remove(this._typeClass());25468}25469}2547025471class Tabulator {2547225473constructor(element, options){2547425475this.options = {};2547625477this.columnManager = null; // hold Column Manager25478this.rowManager = null; //hold Row Manager25479this.footerManager = null; //holder Footer Manager25480this.alertManager = null; //hold Alert Manager25481this.vdomHoz = null; //holder horizontal virtual dom25482this.externalEvents = null; //handle external event messaging25483this.eventBus = null; //handle internal event messaging25484this.interactionMonitor = false; //track user interaction25485this.browser = ""; //hold current browser type25486this.browserSlow = false; //handle reduced functionality for slower browsers25487this.browserMobile = false; //check if running on mobile, prevent resize cancelling edit on keyboard appearance25488this.rtl = false; //check if the table is in RTL mode25489this.originalElement = null; //hold original table element if it has been replaced2549025491this.componentFunctionBinder = new ComponentFunctionBinder(this); //bind component functions25492this.dataLoader = false; //bind component functions2549325494this.modules = {}; //hold all modules bound to this table25495this.modulesCore = []; //hold core modules bound to this table (for initialization purposes)25496this.modulesRegular = []; //hold regular modules bound to this table (for initialization purposes)2549725498this.deprecationAdvisor = new DeprecationAdvisor(this);25499this.optionsList = new OptionsList(this, "table constructor");2550025501this.initialized = false;25502this.destroyed = false;2550325504if(this.initializeElement(element)){2550525506this.initializeCoreSystems(options);2550725508//delay table creation to allow event bindings immediately after the constructor25509setTimeout(() => {25510this._create();25511});25512}2551325514TableRegistry.register(this); //register table for inter-device communication25515}2551625517initializeElement(element){25518if(typeof HTMLElement !== "undefined" && element instanceof HTMLElement){25519this.element = element;25520return true;25521}else if(typeof element === "string"){25522this.element = document.querySelector(element);2552325524if(this.element){25525return true;25526}else {25527console.error("Tabulator Creation Error - no element found matching selector: ", element);25528return false;25529}25530}else {25531console.error("Tabulator Creation Error - Invalid element provided:", element);25532return false;25533}25534}2553525536initializeCoreSystems(options){25537this.columnManager = new ColumnManager(this);25538this.rowManager = new RowManager(this);25539this.footerManager = new FooterManager(this);25540this.dataLoader = new DataLoader(this);25541this.alertManager = new Alert(this);2554225543this.bindModules();2554425545this.options = this.optionsList.generate(Tabulator.defaultOptions, options);2554625547this._clearObjectPointers();2554825549this._mapDeprecatedFunctionality();2555025551this.externalEvents = new ExternalEventBus(this, this.options, this.options.debugEventsExternal);25552this.eventBus = new InternalEventBus(this.options.debugEventsInternal);2555325554this.interactionMonitor = new InteractionManager(this);2555525556this.dataLoader.initialize();25557// this.columnManager.initialize();25558// this.rowManager.initialize();25559this.footerManager.initialize();25560}2556125562//convert deprecated functionality to new functions25563_mapDeprecatedFunctionality(){25564//all previously deprecated functionality removed in the 5.0 release25565}2556625567_clearSelection(){2556825569this.element.classList.add("tabulator-block-select");2557025571if (window.getSelection) {25572if (window.getSelection().empty) { // Chrome25573window.getSelection().empty();25574} else if (window.getSelection().removeAllRanges) { // Firefox25575window.getSelection().removeAllRanges();25576}25577} else if (document.selection) { // IE?25578document.selection.empty();25579}2558025581this.element.classList.remove("tabulator-block-select");25582}2558325584//create table25585_create(){25586this.externalEvents.dispatch("tableBuilding");25587this.eventBus.dispatch("table-building");2558825589this._rtlCheck();2559025591this._buildElement();2559225593this._initializeTable();2559425595this._loadInitialData();2559625597this.initialized = true;2559825599this.externalEvents.dispatch("tableBuilt");25600}2560125602_rtlCheck(){25603var style = window.getComputedStyle(this.element);2560425605switch(this.options.textDirection){25606case"auto":25607if(style.direction !== "rtl"){25608break;25609}2561025611case "rtl":25612this.element.classList.add("tabulator-rtl");25613this.rtl = true;25614break;2561525616case "ltr":25617this.element.classList.add("tabulator-ltr");2561825619default:25620this.rtl = false;25621}25622}2562325624//clear pointers to objects in default config object25625_clearObjectPointers(){25626this.options.columns = this.options.columns.slice(0);2562725628if(Array.isArray(this.options.data) && !this.options.reactiveData){25629this.options.data = this.options.data.slice(0);25630}25631}2563225633//build tabulator element25634_buildElement(){25635var element = this.element,25636options = this.options,25637newElement;2563825639if(element.tagName === "TABLE"){25640this.originalElement = this.element;25641newElement = document.createElement("div");2564225643//transfer attributes to new element25644var attributes = element.attributes;2564525646// loop through attributes and apply them on div25647for(var i in attributes){25648if(typeof attributes[i] == "object"){25649newElement.setAttribute(attributes[i].name, attributes[i].value);25650}25651}2565225653// replace table with div element25654element.parentNode.replaceChild(newElement, element);2565525656this.element = element = newElement;25657}2565825659element.classList.add("tabulator");25660element.setAttribute("role", "grid");2566125662//empty element25663while(element.firstChild) element.removeChild(element.firstChild);2566425665//set table height25666if(options.height){25667options.height = isNaN(options.height) ? options.height : options.height + "px";25668element.style.height = options.height;25669}2567025671//set table min height25672if(options.minHeight !== false){25673options.minHeight = isNaN(options.minHeight) ? options.minHeight : options.minHeight + "px";25674element.style.minHeight = options.minHeight;25675}2567625677//set table maxHeight25678if(options.maxHeight !== false){25679options.maxHeight = isNaN(options.maxHeight) ? options.maxHeight : options.maxHeight + "px";25680element.style.maxHeight = options.maxHeight;25681}25682}2568325684//initialize core systems and modules25685_initializeTable(){25686var element = this.element,25687options = this.options;2568825689this.interactionMonitor.initialize();2569025691this.columnManager.initialize();25692this.rowManager.initialize();2569325694this._detectBrowser();2569525696//initialize core modules25697this.modulesCore.forEach((mod) => {25698mod.initialize();25699});2570025701//build table elements25702element.appendChild(this.columnManager.getElement());25703element.appendChild(this.rowManager.getElement());2570425705if(options.footerElement){25706this.footerManager.activate();25707}2570825709if(options.autoColumns && options.data){2571025711this.columnManager.generateColumnsFromRowData(this.options.data);25712}2571325714//initialize regular modules25715this.modulesRegular.forEach((mod) => {25716mod.initialize();25717});2571825719this.columnManager.setColumns(options.columns);2572025721this.eventBus.dispatch("table-built");25722}2572325724_loadInitialData(){25725this.dataLoader.load(this.options.data);25726}2572725728//deconstructor25729destroy(){25730var element = this.element;2573125732this.destroyed = true;2573325734TableRegistry.deregister(this); //deregister table from inter-device communication2573525736this.eventBus.dispatch("table-destroy");2573725738//clear row data25739this.rowManager.destroy();2574025741//clear DOM25742while(element.firstChild) element.removeChild(element.firstChild);25743element.classList.remove("tabulator");2574425745this.externalEvents.dispatch("tableDestroyed");25746}2574725748_detectBrowser(){25749var ua = navigator.userAgent||navigator.vendor||window.opera;2575025751if(ua.indexOf("Trident") > -1){25752this.browser = "ie";25753this.browserSlow = true;25754}else if(ua.indexOf("Edge") > -1){25755this.browser = "edge";25756this.browserSlow = true;25757}else if(ua.indexOf("Firefox") > -1){25758this.browser = "firefox";25759this.browserSlow = false;25760}else if(ua.indexOf("Mac OS") > -1){25761this.browser = "safari";25762this.browserSlow = false;25763}else {25764this.browser = "other";25765this.browserSlow = false;25766}2576725768this.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));25769}2577025771initGuard(func, msg){25772var stack, line;2577325774if(this.options.debugInitialization && !this.initialized){25775if(!func){25776stack = new Error().stack.split("\n");2577725778line = stack[0] == "Error" ? stack[2] : stack[1];2577925780if(line[0] == " "){25781func = line.trim().split(" ")[1].split(".")[1];25782}else {25783func = line.trim().split("@")[0];25784}25785}2578625787console.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 : ""));25788}2578925790return this.initialized;25791}2579225793////////////////// Data Handling //////////////////25794//block table redrawing25795blockRedraw(){25796this.initGuard();2579725798this.eventBus.dispatch("redraw-blocking");2579925800this.rowManager.blockRedraw();25801this.columnManager.blockRedraw();2580225803this.eventBus.dispatch("redraw-blocked");25804}2580525806//restore table redrawing25807restoreRedraw(){25808this.initGuard();2580925810this.eventBus.dispatch("redraw-restoring");2581125812this.rowManager.restoreRedraw();25813this.columnManager.restoreRedraw();2581425815this.eventBus.dispatch("redraw-restored");25816}2581725818//load data25819setData(data, params, config){25820this.initGuard(false, "To set initial data please use the 'data' property in the table constructor.");2582125822return this.dataLoader.load(data, params, config, false);25823}2582425825//clear data25826clearData(){25827this.initGuard();2582825829this.dataLoader.blockActiveLoad();25830this.rowManager.clearData();25831}2583225833//get table data array25834getData(active){25835return this.rowManager.getData(active);25836}2583725838//get table data array count25839getDataCount(active){25840return this.rowManager.getDataCount(active);25841}2584225843//replace data, keeping table in position with same sort25844replaceData(data, params, config){25845this.initGuard();2584625847return this.dataLoader.load(data, params, config, true, true);25848}2584925850//update table data25851updateData(data){25852var responses = 0;2585325854this.initGuard();2585525856return new Promise((resolve, reject) => {25857this.dataLoader.blockActiveLoad();2585825859if(typeof data === "string"){25860data = JSON.parse(data);25861}2586225863if(data && data.length > 0){25864data.forEach((item) => {25865var row = this.rowManager.findRow(item[this.options.index]);2586625867if(row){25868responses++;2586925870row.updateData(item)25871.then(()=>{25872responses--;2587325874if(!responses){25875resolve();25876}25877})25878.catch((e) => {25879reject("Update Error - Unable to update row", item, e);25880});25881}else {25882reject("Update Error - Unable to find row", item);25883}25884});25885}else {25886console.warn("Update Error - No data provided");25887reject("Update Error - No data provided");25888}25889});25890}2589125892addData(data, pos, index){25893this.initGuard();2589425895return new Promise((resolve, reject) => {25896this.dataLoader.blockActiveLoad();2589725898if(typeof data === "string"){25899data = JSON.parse(data);25900}2590125902if(data){25903this.rowManager.addRows(data, pos, index)25904.then((rows) => {25905var output = [];2590625907rows.forEach(function(row){25908output.push(row.getComponent());25909});2591025911resolve(output);25912});25913}else {25914console.warn("Update Error - No data provided");25915reject("Update Error - No data provided");25916}25917});25918}2591925920//update table data25921updateOrAddData(data){25922var rows = [],25923responses = 0;2592425925this.initGuard();2592625927return new Promise((resolve, reject) => {25928this.dataLoader.blockActiveLoad();2592925930if(typeof data === "string"){25931data = JSON.parse(data);25932}2593325934if(data && data.length > 0){25935data.forEach((item) => {25936var row = this.rowManager.findRow(item[this.options.index]);2593725938responses++;2593925940if(row){25941row.updateData(item)25942.then(()=>{25943responses--;25944rows.push(row.getComponent());2594525946if(!responses){25947resolve(rows);25948}25949});25950}else {25951this.rowManager.addRows(item)25952.then((newRows)=>{25953responses--;25954rows.push(newRows[0].getComponent());2595525956if(!responses){25957resolve(rows);25958}25959});25960}25961});25962}else {25963console.warn("Update Error - No data provided");25964reject("Update Error - No data provided");25965}25966});25967}2596825969//get row object25970getRow(index){25971var row = this.rowManager.findRow(index);2597225973if(row){25974return row.getComponent();25975}else {25976console.warn("Find Error - No matching row found:", index);25977return false;25978}25979}2598025981//get row object25982getRowFromPosition(position){25983var row = this.rowManager.getRowFromPosition(position);2598425985if(row){25986return row.getComponent();25987}else {25988console.warn("Find Error - No matching row found:", position);25989return false;25990}25991}2599225993//delete row from table25994deleteRow(index){25995var foundRows = [];2599625997this.initGuard();2599825999if(!Array.isArray(index)){26000index = [index];26001}2600226003//find matching rows26004for(let item of index){26005let row = this.rowManager.findRow(item, true);2600626007if(row){26008foundRows.push(row);26009}else {26010console.error("Delete Error - No matching row found:", item);26011return Promise.reject("Delete Error - No matching row found");26012}26013}2601426015//sort rows into correct order to ensure smooth delete from table26016foundRows.sort((a, b) => {26017return this.rowManager.rows.indexOf(a) > this.rowManager.rows.indexOf(b) ? 1 : -1;26018});2601926020//delete rows26021foundRows.forEach((row) =>{26022row.delete();26023});2602426025this.rowManager.reRenderInPosition();2602626027return Promise.resolve();26028}2602926030//add row to table26031addRow(data, pos, index){26032this.initGuard();2603326034if(typeof data === "string"){26035data = JSON.parse(data);26036}2603726038return this.rowManager.addRows(data, pos, index, true)26039.then((rows)=>{26040return rows[0].getComponent();26041});26042}2604326044//update a row if it exists otherwise create it26045updateOrAddRow(index, data){26046var row = this.rowManager.findRow(index);2604726048this.initGuard();2604926050if(typeof data === "string"){26051data = JSON.parse(data);26052}2605326054if(row){26055return row.updateData(data)26056.then(()=>{26057return row.getComponent();26058});26059}else {26060return this.rowManager.addRows(data)26061.then((rows)=>{26062return rows[0].getComponent();26063});26064}26065}2606626067//update row data26068updateRow(index, data){26069var row = this.rowManager.findRow(index);2607026071this.initGuard();2607226073if(typeof data === "string"){26074data = JSON.parse(data);26075}2607626077if(row){26078return row.updateData(data)26079.then(()=>{26080return Promise.resolve(row.getComponent());26081});26082}else {26083console.warn("Update Error - No matching row found:", index);26084return Promise.reject("Update Error - No matching row found");26085}26086}2608726088//scroll to row in DOM26089scrollToRow(index, position, ifVisible){26090var row = this.rowManager.findRow(index);2609126092if(row){26093return this.rowManager.scrollToRow(row, position, ifVisible);26094}else {26095console.warn("Scroll Error - No matching row found:", index);26096return Promise.reject("Scroll Error - No matching row found");26097}26098}2609926100moveRow(from, to, after){26101var fromRow = this.rowManager.findRow(from);2610226103this.initGuard();2610426105if(fromRow){26106fromRow.moveToRow(to, after);26107}else {26108console.warn("Move Error - No matching row found:", from);26109}26110}2611126112getRows(active){26113return this.rowManager.getComponents(active);26114}2611526116//get position of row in table26117getRowPosition(index){26118var row = this.rowManager.findRow(index);2611926120if(row){26121return row.getPosition();26122}else {26123console.warn("Position Error - No matching row found:", index);26124return false;26125}26126}2612726128/////////////// Column Functions ///////////////26129setColumns(definition){26130this.initGuard(false, "To set initial columns please use the 'columns' property in the table constructor");2613126132this.columnManager.setColumns(definition);26133}2613426135getColumns(structured){26136return this.columnManager.getComponents(structured);26137}2613826139getColumn(field){26140var column = this.columnManager.findColumn(field);2614126142if(column){26143return column.getComponent();26144}else {26145console.warn("Find Error - No matching column found:", field);26146return false;26147}26148}2614926150getColumnDefinitions(){26151return this.columnManager.getDefinitionTree();26152}2615326154showColumn(field){26155var column = this.columnManager.findColumn(field);2615626157this.initGuard();2615826159if(column){26160column.show();26161}else {26162console.warn("Column Show Error - No matching column found:", field);26163return false;26164}26165}2616626167hideColumn(field){26168var column = this.columnManager.findColumn(field);2616926170this.initGuard();2617126172if(column){26173column.hide();26174}else {26175console.warn("Column Hide Error - No matching column found:", field);26176return false;26177}26178}2617926180toggleColumn(field){26181var column = this.columnManager.findColumn(field);2618226183this.initGuard();2618426185if(column){26186if(column.visible){26187column.hide();26188}else {26189column.show();26190}26191}else {26192console.warn("Column Visibility Toggle Error - No matching column found:", field);26193return false;26194}26195}2619626197addColumn(definition, before, field){26198var column = this.columnManager.findColumn(field);2619926200this.initGuard();2620126202return this.columnManager.addColumn(definition, before, column)26203.then((column) => {26204return column.getComponent();26205});26206}2620726208deleteColumn(field){26209var column = this.columnManager.findColumn(field);2621026211this.initGuard();2621226213if(column){26214return column.delete();26215}else {26216console.warn("Column Delete Error - No matching column found:", field);26217return Promise.reject();26218}26219}2622026221updateColumnDefinition(field, definition){26222var column = this.columnManager.findColumn(field);2622326224this.initGuard();2622526226if(column){26227return column.updateDefinition(definition);26228}else {26229console.warn("Column Update Error - No matching column found:", field);26230return Promise.reject();26231}26232}2623326234moveColumn(from, to, after){26235var fromColumn = this.columnManager.findColumn(from),26236toColumn = this.columnManager.findColumn(to);2623726238this.initGuard();2623926240if(fromColumn){26241if(toColumn){26242this.columnManager.moveColumn(fromColumn, toColumn, after);26243}else {26244console.warn("Move Error - No matching column found:", toColumn);26245}26246}else {26247console.warn("Move Error - No matching column found:", from);26248}26249}2625026251//scroll to column in DOM26252scrollToColumn(field, position, ifVisible){26253return new Promise((resolve, reject) => {26254var column = this.columnManager.findColumn(field);2625526256if(column){26257return this.columnManager.scrollToColumn(column, position, ifVisible);26258}else {26259console.warn("Scroll Error - No matching column found:", field);26260return Promise.reject("Scroll Error - No matching column found");26261}26262});26263}2626426265//////////// General Public Functions ////////////26266//redraw list without updating data26267redraw(force){26268this.initGuard();2626926270this.columnManager.redraw(force);26271this.rowManager.redraw(force);26272}2627326274setHeight(height){26275this.options.height = isNaN(height) ? height : height + "px";26276this.element.style.height = this.options.height;26277this.rowManager.initializeRenderer();26278this.rowManager.redraw();26279}2628026281//////////////////// Event Bus ///////////////////2628226283on(key, callback){26284this.externalEvents.subscribe(key, callback);26285}2628626287off(key, callback){26288this.externalEvents.unsubscribe(key, callback);26289}2629026291dispatchEvent(){26292var args = Array.from(arguments);26293args.shift();2629426295this.externalEvents.dispatch(...arguments);26296}2629726298//////////////////// Alerts ///////////////////2629926300alert(contents, type){26301this.initGuard();2630226303this.alertManager.alert(contents, type);26304}2630526306clearAlert(){26307this.initGuard();2630826309this.alertManager.clear();26310}2631126312////////////// Extension Management //////////////26313modExists(plugin, required){26314if(this.modules[plugin]){26315return true;26316}else {26317if(required){26318console.error("Tabulator Module Not Installed: " + plugin);26319}26320return false;26321}26322}2632326324module(key){26325var mod = this.modules[key];2632626327if(!mod){26328console.error("Tabulator module not installed: " + key);26329}2633026331return mod;26332}26333}2633426335//default setup options26336Tabulator.defaultOptions = defaultOptions;2633726338//bind modules and static functionality26339new ModuleBinder(Tabulator);2634026341//tabulator with all modules installed2634226343class TabulatorFull extends Tabulator {}2634426345//bind modules and static functionality26346new ModuleBinder(TabulatorFull, modules);2634726348class PseudoRow {2634926350constructor (type){26351this.type = type;26352this.element = this._createElement();26353}2635426355_createElement(){26356var el = document.createElement("div");26357el.classList.add("tabulator-row");26358return el;26359}2636026361getElement(){26362return this.element;26363}2636426365getComponent(){26366return false;26367}2636826369getData(){26370return {};26371}2637226373getHeight(){26374return this.element.outerHeight;26375}2637626377initialize(){}2637826379reinitialize(){}2638026381normalizeHeight(){}2638226383generateCells(){}2638426385reinitializeHeight(){}2638626387calcHeight(){}2638826389setCellHeight(){}2639026391clearCellHeight(){}26392}2639326394export { Accessor as AccessorModule, Ajax as AjaxModule, CalcComponent, CellComponent, Clipboard as ClipboardModule, ColumnCalcs as ColumnCalcsModule, ColumnComponent, DataTree as DataTreeModule, Download as DownloadModule, Edit$1 as EditModule, Export as ExportModule, Filter as FilterModule, Format as FormatModule, FrozenColumns as FrozenColumnsModule, FrozenRows as FrozenRowsModule, GroupComponent, GroupRows as GroupRowsModule, History as HistoryModule, HtmlTableImport as HtmlTableImportModule, Import as ImportModule, Interaction as InteractionModule, Keybindings as KeybindingsModule, Menu as MenuModule, Module, MoveColumns as MoveColumnsModule, MoveRows as MoveRowsModule, Mutator as MutatorModule, Page as PageModule, Persistence as PersistenceModule, Popup$1 as PopupModule, Print as PrintModule, PseudoRow, ReactiveData as ReactiveDataModule, Renderer, ResizeColumns as ResizeColumnsModule, ResizeRows as ResizeRowsModule, ResizeTable as ResizeTableModule, ResponsiveLayout as ResponsiveLayoutModule, RowComponent, SelectRow as SelectRowModule, Sort as SortModule, Tabulator, TabulatorFull, Tooltip as TooltipModule, Validate as ValidateModule };26395//# sourceMappingURL=tabulator_esm.js.map263962639726398