tabulator-tables
Advanced tools
Comparing version 5.5.4 to 5.6.0
{ | ||
"name": "tabulator", | ||
"main": "dist/js/tabulator.js", | ||
"version": "5.5.4", | ||
"version": "5.6.0", | ||
"description": "Interactive table generation JavaScript library", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
{ | ||
"name": "tabulator-tables", | ||
"version": "5.5.4", | ||
"version": "5.6.0", | ||
"description": "Interactive table generation JavaScript library", | ||
@@ -50,3 +50,3 @@ "style": "dist/css/tabulator.css", | ||
}, | ||
"homepage": "http://tabulator.info/", | ||
"homepage": "https://tabulator.info/", | ||
"devDependencies": { | ||
@@ -53,0 +53,0 @@ "@rollup/plugin-node-resolve": "^11.0.1", |
@@ -805,2 +805,4 @@ import CoreFeature from '../CoreFeature.js'; | ||
this.dispatch("column-deleted", this); | ||
resolve(); | ||
@@ -946,2 +948,6 @@ }); | ||
} | ||
getPosition(){ | ||
return this.table.columnManager.getVisibleColumnsByIndex().indexOf(this) + 1; | ||
} | ||
} | ||
@@ -948,0 +954,0 @@ |
@@ -410,2 +410,6 @@ import CoreFeature from './CoreFeature.js'; | ||
} | ||
getVisibleColumnsByIndex() { | ||
return this.columnsByIndex.filter((col) => col.visible); | ||
} | ||
@@ -412,0 +416,0 @@ getColumns(){ |
@@ -121,4 +121,4 @@ export default class CoreFeature{ | ||
deprecationCheck(oldOption, newOption){ | ||
return this.table.deprecationAdvisor.check(oldOption, newOption); | ||
deprecationCheck(oldOption, newOption, convert){ | ||
return this.table.deprecationAdvisor.check(oldOption, newOption, convert); | ||
} | ||
@@ -125,0 +125,0 @@ |
@@ -34,3 +34,4 @@ export {default as AccessorModule} from '../../modules/Accessor/Accessor.js'; | ||
export {default as SortModule} from '../../modules/Sort/Sort.js'; | ||
export {default as SelectRangeModule} from '../../modules/SelectRange/SelectRange.js'; | ||
export {default as TooltipModule} from '../../modules/Tooltip/Tooltip.js'; | ||
export {default as ValidateModule} from '../../modules/Validate/Validate.js'; | ||
export {default as ValidateModule} from '../../modules/Validate/Validate.js'; |
@@ -65,4 +65,2 @@ import Renderer from '../Renderer.js'; | ||
if(onlyGroupHeaders){ | ||
@@ -84,2 +82,6 @@ element.style.minWidth = this.table.columnManager.getWidth() + "px"; | ||
this.renderRows(); | ||
if(!this.rows().length){ | ||
this.table.rowManager.tableEmpty(); | ||
} | ||
} | ||
@@ -86,0 +88,0 @@ |
@@ -583,2 +583,2 @@ import Renderer from '../Renderer.js'; | ||
} | ||
} | ||
} |
@@ -45,2 +45,4 @@ export default class PseudoRow { | ||
clearCellHeight(){} | ||
rendered(){} | ||
} |
@@ -347,3 +347,3 @@ import CoreFeature from './CoreFeature.js'; | ||
if(rows.length){ | ||
if(this.displayRowsCount){ | ||
this._clearPlaceholder(); | ||
@@ -977,2 +977,10 @@ } | ||
} | ||
checkPlaceholder(){ | ||
if(this.displayRowsCount){ | ||
this._clearPlaceholder(); | ||
}else{ | ||
this.tableEmpty(); | ||
} | ||
} | ||
@@ -979,0 +987,0 @@ _showPlaceholder(){ |
@@ -280,2 +280,3 @@ 'use strict'; | ||
this.dataLoader.load(this.options.data); | ||
this.columnManager.verticalAlignHeaders(); | ||
} | ||
@@ -282,0 +283,0 @@ |
@@ -11,2 +11,2 @@ //tabulator with all modules installed | ||
export default TabulatorFull; | ||
export default TabulatorFull; |
@@ -34,2 +34,4 @@ import CoreFeature from '../CoreFeature.js'; | ||
this.clear(); | ||
this.dispatch("alert-show", type); | ||
@@ -57,2 +59,4 @@ this.type = type; | ||
clear(){ | ||
this.dispatch("alert-hide", this.type); | ||
if(this.element.parentNode){ | ||
@@ -59,0 +63,0 @@ this.element.parentNode.removeChild(this.element); |
@@ -15,3 +15,3 @@ import CoreFeature from '../CoreFeature.js'; | ||
check(oldOption, newOption){ | ||
check(oldOption, newOption, convert){ | ||
var msg = ""; | ||
@@ -25,2 +25,6 @@ | ||
this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;', 'font-weight: bold;', 'font-weight: normal;'); | ||
if(convert){ | ||
this.table.options[newOption] = this.table.options[oldOption]; | ||
} | ||
}else{ | ||
@@ -27,0 +31,0 @@ this._warnUser(msg, 'font-weight: bold;', 'font-weight: normal;'); |
@@ -66,2 +66,2 @@ export default class Helpers{ | ||
} | ||
} | ||
} |
@@ -229,7 +229,7 @@ import CoreFeature from '../CoreFeature.js'; | ||
} | ||
if(targets.group && targets.group === targets.row){ | ||
delete targets.row; | ||
} | ||
return targets; | ||
@@ -323,2 +323,2 @@ } | ||
} | ||
} | ||
} |
@@ -145,2 +145,3 @@ import Module from '../../core/Module.js'; | ||
this.customSelection = false; | ||
@@ -213,3 +214,3 @@ if (this.mode === true || this.mode === "copy") { | ||
if(this.checkPaseOrigin(e)){ | ||
if(this.checkPasteOrigin(e)){ | ||
@@ -251,6 +252,7 @@ data = this.getPasteData(e); | ||
checkPaseOrigin(e){ | ||
checkPasteOrigin(e){ | ||
var valid = true; | ||
var blocked = this.confirm("clipboard-paste", [e]); | ||
if(e.target.tagName != "DIV" || this.table.modules.edit.currentCell){ | ||
if(blocked || !["DIV", "SPAN"].includes(e.target.tagName)){ | ||
valid = false; | ||
@@ -257,0 +259,0 @@ } |
export default { | ||
replace:function(rows){ | ||
return this.table.setData(rows); | ||
replace:function(data){ | ||
return this.table.setData(data); | ||
}, | ||
update:function(rows){ | ||
return this.table.updateOrAddData(rows); | ||
update:function(data){ | ||
return this.table.updateOrAddData(data); | ||
}, | ||
insert:function(rows){ | ||
return this.table.addData(rows); | ||
insert:function(data){ | ||
return this.table.addData(data); | ||
}, | ||
range:function(data){ | ||
var rows = [], | ||
range = this.table.modules.selectRange.activeRange, | ||
singleCell = false, | ||
bounds, startCell, startRow, rowWidth, dataLength; | ||
dataLength = data.length; | ||
if(range){ | ||
bounds = range.getBounds(); | ||
startCell = bounds.start; | ||
if(bounds.start === bounds.end){ | ||
singleCell = true; | ||
} | ||
if(startCell){ | ||
rows = this.table.rowManager.activeRows.slice(); | ||
startRow = rows.indexOf(startCell.row); | ||
if(singleCell){ | ||
rowWidth = data.length; | ||
}else{ | ||
rowWidth = (rows.indexOf(bounds.end.row) - startRow) + 1; | ||
} | ||
if(startRow >-1){ | ||
this.table.blockRedraw(); | ||
rows = rows.slice(startRow, startRow + rowWidth); | ||
rows.forEach((row, i) => { | ||
row.updateData(data[i % dataLength]); | ||
}); | ||
this.table.restoreRedraw(); | ||
} | ||
} | ||
} | ||
return rows; | ||
} | ||
}; |
@@ -8,12 +8,12 @@ export default { | ||
rows = []; | ||
//get data from clipboard into array of columns and rows. | ||
clipboard = clipboard.split("\n"); | ||
clipboard.forEach(function(row){ | ||
data.push(row.split("\t")); | ||
}); | ||
if(data.length && !(data.length === 1 && data[0].length < 2)){ | ||
//check if headers are present by title | ||
@@ -24,3 +24,3 @@ data[0].forEach(function(value){ | ||
}); | ||
if(column){ | ||
@@ -32,3 +32,3 @@ columnMap.push(column); | ||
}); | ||
//check if column headers are present by field | ||
@@ -38,3 +38,3 @@ if(!headerFindSuccess){ | ||
columnMap = []; | ||
data[0].forEach(function(value){ | ||
@@ -44,3 +44,3 @@ var column = columns.find(function(column){ | ||
}); | ||
if(column){ | ||
@@ -52,3 +52,3 @@ columnMap.push(column); | ||
}); | ||
if(!headerFindSuccess){ | ||
@@ -58,3 +58,3 @@ columnMap = this.table.columnManager.columnsByIndex; | ||
} | ||
//remove header row if found | ||
@@ -64,6 +64,6 @@ if(headerFindSuccess){ | ||
} | ||
data.forEach(function(item){ | ||
var row = {}; | ||
item.forEach(function(value, i){ | ||
@@ -74,6 +74,6 @@ if(columnMap[i]){ | ||
}); | ||
rows.push(row); | ||
}); | ||
return rows; | ||
@@ -83,3 +83,58 @@ }else{ | ||
} | ||
}, | ||
range:function(clipboard){ | ||
var data = [], | ||
rows = [], | ||
range = this.table.modules.selectRange.activeRange, | ||
singleCell = false, | ||
bounds, startCell, colWidth, columnMap, startCol; | ||
if(range){ | ||
bounds = range.getBounds(); | ||
startCell = bounds.start; | ||
if(bounds.start === bounds.end){ | ||
singleCell = true; | ||
} | ||
if(startCell){ | ||
//get data from clipboard into array of columns and rows. | ||
clipboard = clipboard.split("\n"); | ||
clipboard.forEach(function(row){ | ||
data.push(row.split("\t")); | ||
}); | ||
if(data.length){ | ||
columnMap = this.table.columnManager.getVisibleColumnsByIndex(); | ||
startCol = columnMap.indexOf(startCell.column); | ||
if(startCol > -1){ | ||
if(singleCell){ | ||
colWidth = data[0].length; | ||
}else{ | ||
colWidth = (columnMap.indexOf(bounds.end.column) - startCol) + 1; | ||
} | ||
columnMap = columnMap.slice(startCol, startCol + colWidth); | ||
data.forEach((item) => { | ||
var row = {}; | ||
var itemLength = item.length; | ||
columnMap.forEach(function(col, i){ | ||
row[col.field] = item[i % itemLength]; | ||
}); | ||
rows.push(row); | ||
}); | ||
return rows; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
}; |
@@ -277,4 +277,10 @@ import Module from '../../core/Module.js'; | ||
initializeTopRow(){ | ||
var fragment = document.createDocumentFragment(); | ||
if(!this.topInitialized){ | ||
this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling); | ||
fragment.appendChild(document.createElement("br")); | ||
fragment.appendChild(this.topElement); | ||
this.table.columnManager.getContentsElement().insertBefore(fragment, this.table.columnManager.headersElement.nextSibling); | ||
this.topInitialized = true; | ||
@@ -281,0 +287,0 @@ } |
@@ -27,2 +27,4 @@ import Module from '../../core/Module.js'; | ||
this.registerTableOption("editTriggerEvent", "focus"); | ||
this.registerTableFunction("getEditedCells", this.getEditedCells.bind(this)); | ||
@@ -59,7 +61,10 @@ this.registerTableFunction("clearCellEdited", this.clearCellEdited.bind(this)); | ||
this.subscribe("data-refreshing", this.cancelEdit.bind(this)); | ||
this.subscribe("clipboard-paste", this.pasteBlocker.bind(this)); | ||
this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined)); | ||
this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this)); | ||
this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined)); | ||
this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined)); | ||
// this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined)); | ||
// this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined)); | ||
this.subscribe("keybinding-nav-up", this.navigateUp.bind(this, undefined)); | ||
@@ -71,2 +76,13 @@ this.subscribe("keybinding-nav-down", this.navigateDown.bind(this, undefined)); | ||
/////////////////////////////////// | ||
///////// Paste Negation ////////// | ||
/////////////////////////////////// | ||
pasteBlocker(e){ | ||
if(this.currentCell){ | ||
return true; | ||
} | ||
} | ||
/////////////////////////////////// | ||
////// Keybinding Functions /////// | ||
@@ -78,3 +94,3 @@ /////////////////////////////////// | ||
newRow = this.options("tabEndNewRow"); | ||
if(cell){ | ||
@@ -468,8 +484,2 @@ if(!this.navigateNext(cell, e)){ | ||
element.addEventListener("click", function(e){ | ||
if(!element.classList.contains("tabulator-editing")){ | ||
element.focus({preventScroll: true}); | ||
} | ||
}); | ||
element.addEventListener("mousedown", function(e){ | ||
@@ -482,8 +492,29 @@ if (e.button === 2) { | ||
}); | ||
if(this.options("editTriggerEvent") === "dblclick"){ | ||
element.addEventListener("dblclick", function(e){ | ||
if(!element.classList.contains("tabulator-editing")){ | ||
element.focus({preventScroll: true}); | ||
self.edit(cell, e, false); | ||
} | ||
}); | ||
} | ||
element.addEventListener("focus", function(e){ | ||
if(!self.recursionBlock){ | ||
self.edit(cell, e, false); | ||
} | ||
}); | ||
if(this.options("editTriggerEvent") === "focus" || this.options("editTriggerEvent") === "click"){ | ||
element.addEventListener("click", function(e){ | ||
if(!element.classList.contains("tabulator-editing")){ | ||
element.focus({preventScroll: true}); | ||
self.edit(cell, e, false); | ||
} | ||
}); | ||
} | ||
if(this.options("editTriggerEvent") === "focus"){ | ||
element.addEventListener("focus", function(e){ | ||
if(!self.recursionBlock){ | ||
self.edit(cell, e, false); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -639,3 +670,2 @@ } | ||
if(allowEdit || forceEdit){ | ||
self.cancelEdit(); | ||
@@ -690,7 +720,7 @@ | ||
console.warn("Edit Error - Editor should return an instance of Node, the editor returned:", cellEditor); | ||
element.blur(); | ||
this.blur(element); | ||
return false; | ||
} | ||
}else{ | ||
element.blur(); | ||
this.blur(element); | ||
return false; | ||
@@ -702,3 +732,3 @@ } | ||
this.mouseClick = false; | ||
element.blur(); | ||
this.blur(element); | ||
return false; | ||
@@ -708,3 +738,3 @@ } | ||
this.mouseClick = false; | ||
element.blur(); | ||
this.blur(element); | ||
return false; | ||
@@ -714,2 +744,8 @@ } | ||
blur(element){ | ||
if(!this.confirm("edit-blur", [element]) ){ | ||
element.blur(); | ||
} | ||
} | ||
getEditedCells(){ | ||
@@ -716,0 +752,0 @@ var output = []; |
@@ -38,6 +38,16 @@ import Module from '../../core/Module.js'; | ||
this.colVisProp = colVisProp; | ||
var headers, body; | ||
var headers = this.config.columnHeaders !== false ? this.headersToExportRows(this.generateColumnGroupHeaders()) : []; | ||
var body = this.bodyToExportRows(this.rowLookup(range)); | ||
if (range === 'range') { | ||
var columns = this.table.modules.selectRange.selectedColumns(); | ||
headers = this.config.columnHeaders !== false | ||
? this.headersToExportRows(this.generateColumnGroupHeaders(columns)) | ||
: []; | ||
body = this.bodyToExportRows(this.rowLookup(range), this.table.modules.selectRange.selectedColumns(true)); | ||
} else { | ||
headers = this.config.columnHeaders !== false ? this.headersToExportRows(this.generateColumnGroupHeaders()) : []; | ||
body = this.bodyToExportRows(this.rowLookup(range)); | ||
} | ||
return headers.concat(body); | ||
@@ -77,3 +87,7 @@ } | ||
break; | ||
case "range": | ||
rows = this.table.modules.selectRange.selectedRows(); | ||
break; | ||
case "active": | ||
@@ -92,6 +106,8 @@ default: | ||
generateColumnGroupHeaders(){ | ||
generateColumnGroupHeaders(columns){ | ||
var output = []; | ||
var columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex; | ||
if (!columns) { | ||
columns = this.config.columnGroups !== false ? this.table.columnManager.columns : this.table.columnManager.columnsByIndex; | ||
} | ||
@@ -105,3 +121,3 @@ columns.forEach((column) => { | ||
}); | ||
return output; | ||
@@ -234,12 +250,12 @@ } | ||
bodyToExportRows(rows){ | ||
var columns = []; | ||
bodyToExportRows(rows, columns = []){ | ||
var exportRows = []; | ||
this.table.columnManager.columnsByIndex.forEach((column) => { | ||
if (this.columnVisCheck(column)) { | ||
columns.push(column.getComponent()); | ||
} | ||
}); | ||
if (columns.length === 0) { | ||
this.table.columnManager.columnsByIndex.forEach((column) => { | ||
if (this.columnVisCheck(column)) { | ||
columns.push(column.getComponent()); | ||
} | ||
}); | ||
} | ||
@@ -255,3 +271,3 @@ if(this.config.columnCalcs !== false && this.table.modExists("columnCalcs")){ | ||
} | ||
rows = rows.filter((row) => { | ||
@@ -483,3 +499,4 @@ switch(row.type){ | ||
column = col.component._column, | ||
index = this.table.columnManager.findColumnIndex(column), | ||
table = this.table, | ||
index = table.columnManager.findColumnIndex(column), | ||
value = col.value, | ||
@@ -511,2 +528,5 @@ cellStyle; | ||
}, | ||
getTable:function(){ | ||
return table; | ||
}, | ||
getComponent:function(){ | ||
@@ -513,0 +533,0 @@ return cellWrapper; |
export default function(cell, formatterParams, onRendered){ | ||
var content = document.createElement("span"); | ||
var row = cell.getRow(); | ||
var table = cell.getTable(); | ||
row.watchPosition((position) => { | ||
if (formatterParams.relativeToPage) { | ||
position += table.modules.page.getPageSize() * (table.modules.page.getPage() - 1); | ||
} | ||
content.innerText = position; | ||
@@ -10,2 +14,2 @@ }); | ||
return content; | ||
} | ||
} |
@@ -23,3 +23,3 @@ import RowComponent from '../../../../core/row/RowComponent.js'; | ||
checkbox.addEventListener("change", (e) => { | ||
if(this.table.options.selectableRangeMode === "click"){ | ||
if(this.table.options.selectableRowsRangeMode === "click"){ | ||
if(!blocked){ | ||
@@ -35,3 +35,3 @@ row.toggleSelect(); | ||
if(this.table.options.selectableRangeMode === "click"){ | ||
if(this.table.options.selectableRowsRangeMode === "click"){ | ||
checkbox.addEventListener("click", (e) => { | ||
@@ -38,0 +38,0 @@ blocked = true; |
@@ -34,3 +34,5 @@ import Module from '../../core/Module.js'; | ||
this.subscribe("column-add", this.reinitializeColumns.bind(this)); | ||
this.subscribe("column-delete", this.reinitializeColumns.bind(this)); | ||
this.subscribe("column-deleted", this.reinitializeColumns.bind(this)); | ||
this.subscribe("column-hide", this.reinitializeColumns.bind(this)); | ||
this.subscribe("column-show", this.reinitializeColumns.bind(this)); | ||
@@ -61,2 +63,4 @@ this.subscribe("table-redraw", this.layout.bind(this)); | ||
}); | ||
this.layout(); | ||
} | ||
@@ -68,6 +72,4 @@ | ||
if(!column.isGroup){ | ||
if(!column.isGroup){ | ||
if(this.frozenCheck(column)){ | ||
config.position = this.initializationMode; | ||
@@ -163,5 +165,4 @@ | ||
if(column.modules.frozen.edge){ | ||
parentEl.classList.add("tabulator-frozen-" + column.modules.frozen.position); | ||
} | ||
parentEl.classList.toggle("tabulator-frozen-left", column.modules.frozen.edge && column.modules.frozen.position === "left"); | ||
parentEl.classList.toggle("tabulator-frozen-right", column.modules.frozen.edge && column.modules.frozen.position === "right"); | ||
}else{ | ||
@@ -214,3 +215,2 @@ this.layoutElement(column.getElement(), column); | ||
if(this.active && !this.blocked){ | ||
//calculate left columns | ||
@@ -278,5 +278,4 @@ this.layoutColumnPosition(); | ||
if(column.modules.frozen.edge){ | ||
element.classList.add("tabulator-frozen-" + column.modules.frozen.position); | ||
} | ||
element.classList.toggle("tabulator-frozen-left", column.modules.frozen.edge && column.modules.frozen.position === "left"); | ||
element.classList.toggle("tabulator-frozen-right", column.modules.frozen.edge && column.modules.frozen.position === "right"); | ||
} | ||
@@ -283,0 +282,0 @@ } |
@@ -22,8 +22,13 @@ import Module from '../../core/Module.js'; | ||
initialize(){ | ||
var fragment = document.createDocumentFragment(); | ||
this.rows = []; | ||
this.topElement.classList.add("tabulator-frozen-rows-holder"); | ||
fragment.appendChild(document.createElement("br")); | ||
fragment.appendChild(this.topElement); | ||
// this.table.columnManager.element.append(this.topElement); | ||
this.table.columnManager.getContentsElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling); | ||
this.table.columnManager.getContentsElement().insertBefore(fragment, this.table.columnManager.headersElement.nextSibling); | ||
@@ -30,0 +35,0 @@ this.subscribe("row-deleting", this.detachRow.bind(this)); |
@@ -15,2 +15,4 @@ export default { | ||
this._rebindRow(action.component, newRow); | ||
this.table.rowManager.checkPlaceholder(); | ||
}, | ||
@@ -20,2 +22,4 @@ | ||
action.component.deleteActual(); | ||
this.table.rowManager.checkPlaceholder(); | ||
}, | ||
@@ -22,0 +26,0 @@ |
@@ -9,2 +9,4 @@ export default { | ||
action.component.deleteActual(); | ||
this.table.rowManager.checkPlaceholder(); | ||
}, | ||
@@ -20,2 +22,4 @@ | ||
this._rebindRow(action.component, newRow); | ||
this.table.rowManager.checkPlaceholder(); | ||
}, | ||
@@ -22,0 +26,0 @@ |
@@ -122,3 +122,3 @@ import Module from '../../core/Module.js'; | ||
}else{ | ||
console.warn("History Undo Error - No more history to undo"); | ||
console.warn(this.options("history") ? "History Undo Error - No more history to undo" : "History module not enabled"); | ||
return false; | ||
@@ -141,3 +141,3 @@ } | ||
}else{ | ||
console.warn("History Redo Error - No more history to redo"); | ||
console.warn(this.options("history") ? "History Redo Error - No more history to redo" : "History module not enabled"); | ||
return false; | ||
@@ -144,0 +144,0 @@ } |
@@ -86,2 +86,39 @@ export default { | ||
rangeJumpLeft: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "left", true, false); | ||
}, | ||
rangeJumpRight: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "right", true, false); | ||
}, | ||
rangeJumpUp: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "up", true, false); | ||
}, | ||
rangeJumpDown: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "down", true, false); | ||
}, | ||
rangeExpandLeft: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "left", false, true); | ||
}, | ||
rangeExpandRight: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "right", false, true); | ||
}, | ||
rangeExpandUp: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "up", false, true); | ||
}, | ||
rangeExpandDown: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "down", false, true); | ||
}, | ||
rangeExpandJumpLeft: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "left", true, true); | ||
}, | ||
rangeExpandJumpRight: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "right", true, true); | ||
}, | ||
rangeExpandJumpUp: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "up", true, true); | ||
}, | ||
rangeExpandJumpDown: function(e){ | ||
this.dispatch("keybinding-nav-range", e, "down", true, true); | ||
}, | ||
undo:function(e){ | ||
@@ -120,2 +157,2 @@ var cell = false; | ||
}, | ||
}; | ||
}; |
@@ -6,2 +6,4 @@ export default { | ||
navDown:40, | ||
navLeft:37, | ||
navRight:39, | ||
scrollPageUp:33, | ||
@@ -14,2 +16,15 @@ scrollPageDown:34, | ||
copyToClipboard:["ctrl + 67", "meta + 67"], | ||
}; | ||
rangeJumpUp:["ctrl + 38", "meta + 38"], | ||
rangeJumpDown:["ctrl + 40", "meta + 40"], | ||
rangeJumpLeft:["ctrl + 37", "meta + 37"], | ||
rangeJumpRight:["ctrl + 39", "meta + 39"], | ||
rangeExpandUp:"shift + 38", | ||
rangeExpandDown:"shift + 40", | ||
rangeExpandLeft:"shift + 37", | ||
rangeExpandRight:"shift + 39", | ||
rangeExpandJumpUp:["ctrl + shift + 38", "meta + shift + 38"], | ||
rangeExpandJumpDown:["ctrl + shift + 40", "meta + shift + 40"], | ||
rangeExpandJumpLeft:["ctrl + shift + 37", "meta + shift + 37"], | ||
rangeExpandJumpRight:["ctrl + shift + 39", "meta + shift + 39"], | ||
}; |
@@ -79,3 +79,3 @@ import Module from '../../core/Module.js'; | ||
} | ||
initializeColumn(column){ | ||
@@ -289,2 +289,3 @@ var def = column.definition; | ||
if(this.currentComponent){ | ||
this.dispatch("menu-closed", menu, popup); | ||
this.dispatchExternal("menuClosed", this.currentComponent.getComponent()); | ||
@@ -297,2 +298,3 @@ this.currentComponent = null; | ||
this.dispatch("menu-opened", menu, popup); | ||
this.dispatchExternal("menuOpened", component.getComponent()); | ||
@@ -299,0 +301,0 @@ } |
@@ -40,4 +40,9 @@ import Module from '../../core/Module.js'; | ||
this.subscribe("column-init", this.initializeColumn.bind(this)); | ||
this.subscribe("alert-show", this.abortMove.bind(this)); | ||
} | ||
} | ||
abortMove(){ | ||
clearTimeout(this.checkTimeout); | ||
} | ||
@@ -44,0 +49,0 @@ initializeColumn(column){ |
@@ -73,3 +73,3 @@ import Module from '../../core/Module.js'; | ||
} | ||
initializeColumn(column){ | ||
@@ -76,0 +76,0 @@ var def = column.definition; |
@@ -48,3 +48,3 @@ import Module from '../../core/Module.js'; | ||
this.resizeObserver = new ResizeObserver((entry) => { | ||
if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){ | ||
if(!table.browserMobile || (table.browserMobile && (!table.modules.edit || (table.modules.edit && !table.modules.edit.currentCell)))){ | ||
@@ -75,3 +75,3 @@ var nodeHeight = Math.floor(entry[0].contentRect.height); | ||
this.containerObserver = new ResizeObserver((entry) => { | ||
if(!table.browserMobile || (table.browserMobile &&!table.modules.edit.currentCell)){ | ||
if(!table.browserMobile || (table.browserMobile && (!table.modules.edit || (table.modules.edit && !table.modules.edit.currentCell)))){ | ||
@@ -99,3 +99,3 @@ var nodeHeight = Math.floor(entry[0].contentRect.height); | ||
this.binding = function(){ | ||
if(!table.browserMobile || (table.browserMobile && !table.modules.edit.currentCell)){ | ||
if(!table.browserMobile || (table.browserMobile && (!table.modules.edit || (table.modules.edit && !table.modules.edit.currentCell)))){ | ||
table.columnManager.rerenderColumns(true); | ||
@@ -102,0 +102,0 @@ table.redraw(); |
@@ -14,7 +14,7 @@ import Module from '../../core/Module.js'; | ||
this.registerTableOption("selectable", "highlight"); //highlight rows on hover | ||
this.registerTableOption("selectableRangeMode", "drag"); //highlight rows on hover | ||
this.registerTableOption("selectableRollingSelection", true); //roll selection once maximum number of selectable rows is reached | ||
this.registerTableOption("selectablePersistence", true); // maintain selection when table view is updated | ||
this.registerTableOption("selectableCheck", function(data, row){return true;}); //check whether row is selectable | ||
this.registerTableOption("selectableRows", "highlight"); //highlight rows on hover | ||
this.registerTableOption("selectableRowsRangeMode", "drag"); //highlight rows on hover | ||
this.registerTableOption("selectableRowsRollingSelection", true); //roll selection once maximum number of selectable rows is reached | ||
this.registerTableOption("selectableRowsPersistence", true); // maintain selection when table view is updated | ||
this.registerTableOption("selectableRowsCheck", function(data, row){return true;}); //check whether row is selectable | ||
@@ -35,3 +35,10 @@ this.registerTableFunction("selectRow", this.selectRows.bind(this)); | ||
initialize(){ | ||
if(this.table.options.selectable !== false){ | ||
this.deprecatedOptionsCheck(); | ||
if(this.table.options.selectableRows === "highlight" && this.table.options.selectableRange){ | ||
this.table.options.selectableRows = false; | ||
} | ||
if(this.table.options.selectableRows !== false){ | ||
this.subscribe("row-init", this.initializeRow.bind(this)); | ||
@@ -42,3 +49,3 @@ this.subscribe("row-deleting", this.rowDeleted.bind(this)); | ||
if(this.table.options.selectable && !this.table.options.selectablePersistence){ | ||
if(this.table.options.selectableRows && !this.table.options.selectableRowsPersistence){ | ||
this.subscribe("data-refreshing", this.deselectRows.bind(this)); | ||
@@ -48,2 +55,10 @@ } | ||
} | ||
deprecatedOptionsCheck(){ | ||
this.deprecationCheck("selectable", "selectableRows", true); | ||
this.deprecationCheck("selectableRollingSelection", "selectableRowsRollingSelection", true); | ||
this.deprecationCheck("selectableRangeMode", "selectableRowsRangeMode", true); | ||
this.deprecationCheck("selectablePersistence", "selectableRowsPersistence", true); | ||
this.deprecationCheck("selectableCheck", "selectableRowsCheck", true); | ||
} | ||
@@ -73,2 +88,3 @@ rowRetrieve(type, prevValue){ | ||
var self = this, | ||
selectable = self.checkRowSelectability(row), | ||
element = row.getElement(); | ||
@@ -87,10 +103,10 @@ | ||
row.modules.select = {selected:false}; | ||
element.classList.toggle("tabulator-selectable", selectable); | ||
element.classList.toggle("tabulator-unselectable", !selectable); | ||
//set row selection class | ||
if(self.checkRowSelectability(row)){ | ||
element.classList.add("tabulator-selectable"); | ||
element.classList.remove("tabulator-unselectable"); | ||
if(self.table.options.selectable && self.table.options.selectable != "highlight"){ | ||
if(self.table.options.selectableRangeMode === "click"){ | ||
if(self.checkRowSelectability(row)){ | ||
if(self.table.options.selectableRows && self.table.options.selectableRows != "highlight"){ | ||
if(self.table.options.selectableRowsRangeMode === "click"){ | ||
element.addEventListener("click", this.handleComplexRowClick.bind(this, row)); | ||
@@ -144,6 +160,2 @@ }else{ | ||
} | ||
}else{ | ||
element.classList.add("tabulator-unselectable"); | ||
element.classList.remove("tabulator-selectable"); | ||
} | ||
@@ -170,4 +182,4 @@ } | ||
if(this.table.options.selectable !== true && !this.isRowSelected(row)){ | ||
if(this.selectedRows.length < this.table.options.selectable){ | ||
if(this.table.options.selectableRows !== true && !this.isRowSelected(row)){ | ||
if(this.selectedRows.length < this.table.options.selectableRows){ | ||
this.toggleRow(toggledRow); | ||
@@ -184,5 +196,5 @@ } | ||
if(this.table.options.selectable !== true){ | ||
if(toggledRows.length > this.table.options.selectable){ | ||
toggledRows = toggledRows.slice(0, this.table.options.selectable); | ||
if(this.table.options.selectableRows !== true){ | ||
if(toggledRows.length > this.table.options.selectableRows){ | ||
toggledRows = toggledRows.slice(0, this.table.options.selectableRows); | ||
} | ||
@@ -207,3 +219,3 @@ } | ||
if(row && row.type === "row"){ | ||
return this.table.options.selectableCheck.call(this.table, row.getComponent()); | ||
return this.table.options.selectableRowsCheck.call(this.table, row.getComponent()); | ||
} | ||
@@ -235,2 +247,6 @@ | ||
case "number": | ||
rowMatch = this.table.rowManager.findRow(rows); | ||
break; | ||
case "string": | ||
@@ -271,5 +287,5 @@ rowMatch = this.table.rowManager.findRow(rows); | ||
//handle max row count | ||
if(!isNaN(this.table.options.selectable) && this.table.options.selectable !== true && !force){ | ||
if(this.selectedRows.length >= this.table.options.selectable){ | ||
if(this.table.options.selectableRollingSelection){ | ||
if(!isNaN(this.table.options.selectableRows) && this.table.options.selectableRows !== true && !force){ | ||
if(this.selectedRows.length >= this.table.options.selectableRows){ | ||
if(this.table.options.selectableRowsRollingSelection){ | ||
this._deselectRow(this.selectedRows[0]); | ||
@@ -328,2 +344,6 @@ }else{ | ||
break; | ||
case "number": | ||
rowMatch = this.table.rowManager.findRow(rows); | ||
break; | ||
@@ -330,0 +350,0 @@ case "string": |
@@ -6,11 +6,11 @@ import Module from '../../core/Module.js'; | ||
class Sort extends Module{ | ||
constructor(table){ | ||
super(table); | ||
this.sortList = []; //holder current sort | ||
this.changed = false; //has the sort changed since last render | ||
this.registerTableOption("sortMode", "local"); //local or remote sorting | ||
this.registerTableOption("initialSort", false); //initial sorting criteria | ||
@@ -21,12 +21,12 @@ this.registerTableOption("columnHeaderSortMulti", true); //multiple or single column sorting | ||
this.registerTableOption("headerSortClickElement", "header"); //element which triggers sort when clicked | ||
this.registerColumnOption("sorter"); | ||
this.registerColumnOption("sorterParams"); | ||
this.registerColumnOption("headerSort", true); | ||
this.registerColumnOption("headerSortStartingDir"); | ||
this.registerColumnOption("headerSortTristate"); | ||
} | ||
initialize(){ | ||
@@ -36,7 +36,7 @@ this.subscribe("column-layout", this.initializeColumn.bind(this)); | ||
this.registerDataHandler(this.sort.bind(this), 20); | ||
this.registerTableFunction("setSort", this.userSetSort.bind(this)); | ||
this.registerTableFunction("getSorters", this.getSort.bind(this)); | ||
this.registerTableFunction("clearSort", this.clearSort.bind(this)); | ||
if(this.table.options.sortMode === "remote"){ | ||
@@ -46,3 +46,3 @@ this.subscribe("data-params", this.remoteSortParams.bind(this)); | ||
} | ||
tableBuilt(){ | ||
@@ -53,20 +53,20 @@ if(this.table.options.initialSort){ | ||
} | ||
remoteSortParams(data, config, silent, params){ | ||
var sorters = this.getSort(); | ||
sorters.forEach((item) => { | ||
delete item.column; | ||
}); | ||
params.sort = sorters; | ||
return params; | ||
} | ||
/////////////////////////////////// | ||
///////// Table Functions ///////// | ||
/////////////////////////////////// | ||
userSetSort(sortList, dir){ | ||
@@ -77,3 +77,3 @@ this.setSort(sortList, dir); | ||
} | ||
clearSort(){ | ||
@@ -84,8 +84,8 @@ this.clear(); | ||
} | ||
/////////////////////////////////// | ||
///////// Internal Logic ////////// | ||
/////////////////////////////////// | ||
//initialize column header for sorting | ||
@@ -96,3 +96,3 @@ initializeColumn(column){ | ||
arrowEl; | ||
switch(typeof column.definition.sorter){ | ||
@@ -106,3 +106,3 @@ case "string": | ||
break; | ||
case "function": | ||
@@ -112,3 +112,3 @@ sorter = column.definition.sorter; | ||
} | ||
column.modules.sort = { | ||
@@ -120,12 +120,12 @@ sorter:sorter, dir:"none", | ||
}; | ||
if(column.definition.headerSort !== false){ | ||
colEl = column.getElement(); | ||
colEl.classList.add("tabulator-sortable"); | ||
arrowEl = document.createElement("div"); | ||
arrowEl.classList.add("tabulator-col-sorter"); | ||
switch(this.table.options.headerSortClickElement){ | ||
@@ -142,23 +142,29 @@ case "icon": | ||
} | ||
switch(this.table.options.headerSortElement){ | ||
case "function": | ||
//do nothing | ||
//do nothing | ||
break; | ||
case "object": | ||
arrowEl.appendChild(this.table.options.headerSortElement); | ||
break; | ||
default: | ||
arrowEl.innerHTML = this.table.options.headerSortElement; | ||
} | ||
//create sorter arrow | ||
column.titleHolderElement.appendChild(arrowEl); | ||
column.modules.sort.element = arrowEl; | ||
this.setColumnHeaderSortIcon(column, "none"); | ||
if(this.table.options.headerSortClickElement === "icon"){ | ||
arrowEl.addEventListener("mousedown", (e) => { | ||
e.stopPropagation(); | ||
}); | ||
} | ||
//sort on click | ||
@@ -169,3 +175,3 @@ (this.table.options.headerSortClickElement === "icon" ? arrowEl : colEl).addEventListener("click", (e) => { | ||
match = false; | ||
if(column.modules.sort){ | ||
@@ -187,7 +193,7 @@ if(column.modules.sort.tristate){ | ||
break; | ||
case "desc": | ||
dir = "asc"; | ||
break; | ||
default: | ||
@@ -197,13 +203,13 @@ dir = column.modules.sort.startingDir; | ||
} | ||
if (this.table.options.columnHeaderSortMulti && (e.shiftKey || e.ctrlKey)) { | ||
sorters = this.getSort(); | ||
match = sorters.findIndex((sorter) => { | ||
return sorter.field === column.getField(); | ||
}); | ||
if(match > -1){ | ||
sorters[match].dir = dir; | ||
match = sorters.splice(match, 1)[0]; | ||
@@ -218,3 +224,3 @@ if(dir != "none"){ | ||
} | ||
//add to existing sort | ||
@@ -229,5 +235,5 @@ this.setSort(sorters); | ||
} | ||
} | ||
// this.table.rowManager.sorterRefresh(!this.sortList.length); | ||
@@ -239,3 +245,3 @@ this.refreshSort(); | ||
} | ||
refreshSort(){ | ||
@@ -247,3 +253,3 @@ if(this.table.options.sortMode === "remote"){ | ||
} | ||
//TODO - Persist left position of row manager | ||
@@ -253,3 +259,3 @@ // left = this.scrollLeft; | ||
} | ||
//check if the sorters have changed since last use | ||
@@ -261,3 +267,3 @@ hasChanged(){ | ||
} | ||
//return current sorters | ||
@@ -267,3 +273,3 @@ getSort(){ | ||
sorters = []; | ||
self.sortList.forEach(function(item){ | ||
@@ -274,6 +280,6 @@ if(item.column){ | ||
}); | ||
return sorters; | ||
} | ||
//change sort list and trigger sort | ||
@@ -283,12 +289,12 @@ setSort(sortList, dir){ | ||
newSortList = []; | ||
if(!Array.isArray(sortList)){ | ||
sortList = [{column: sortList, dir:dir}]; | ||
} | ||
sortList.forEach(function(item){ | ||
var column; | ||
column = self.table.columnManager.findColumn(item.column); | ||
if(column){ | ||
@@ -301,10 +307,10 @@ item.column = column; | ||
} | ||
}); | ||
self.sortList = newSortList; | ||
this.dispatch("sort-changed"); | ||
} | ||
//clear sorters | ||
@@ -314,3 +320,3 @@ clear(){ | ||
} | ||
//find appropriate sorter for column | ||
@@ -321,11 +327,11 @@ findSorter(column){ | ||
field, value; | ||
if(row){ | ||
row = row.getData(); | ||
field = column.getField(); | ||
if(field){ | ||
value = column.getFieldValue(row); | ||
switch(typeof value){ | ||
@@ -335,7 +341,7 @@ case "undefined": | ||
break; | ||
case "boolean": | ||
sorter = "boolean"; | ||
break; | ||
default: | ||
@@ -353,6 +359,6 @@ if(!isNaN(value) && value !== ""){ | ||
} | ||
return Sort.sorters[sorter]; | ||
} | ||
//work through sort list sorting data | ||
@@ -364,20 +370,20 @@ sort(data){ | ||
rowComponents = []; | ||
if(this.subscribedExternal("dataSorting")){ | ||
this.dispatchExternal("dataSorting", self.getSort()); | ||
} | ||
self.clearColumnHeaders(); | ||
if(this.table.options.sortMode !== "remote"){ | ||
//build list of valid sorters and trigger column specific callbacks before sort begins | ||
sortList.forEach(function(item, i){ | ||
var sortObj; | ||
if(item.column){ | ||
sortObj = item.column.modules.sort; | ||
if(sortObj){ | ||
//if no sorter has been defined, take a guess | ||
@@ -387,12 +393,12 @@ if(!sortObj.sorter){ | ||
} | ||
item.params = typeof sortObj.params === "function" ? sortObj.params(item.column.getComponent(), item.dir) : sortObj.params; | ||
sortListActual.push(item); | ||
} | ||
self.setColumnHeader(item.column, item.dir); | ||
} | ||
}); | ||
//sort data | ||
@@ -402,3 +408,3 @@ if (sortListActual.length) { | ||
} | ||
}else{ | ||
@@ -409,3 +415,3 @@ sortList.forEach(function(item, i){ | ||
} | ||
if(this.subscribedExternal("dataSorted")){ | ||
@@ -415,9 +421,9 @@ data.forEach((row) => { | ||
}); | ||
this.dispatchExternal("dataSorted", self.getSort(), rowComponents); | ||
} | ||
return data; | ||
} | ||
//clear sort arrows on columns | ||
@@ -433,3 +439,3 @@ clearColumnHeaders(){ | ||
} | ||
//set the column header sort direction | ||
@@ -441,10 +447,10 @@ setColumnHeader(column, dir){ | ||
} | ||
setColumnHeaderSortIcon(column, dir){ | ||
var sortEl = column.modules.sort.element, | ||
arrowEl; | ||
if(column.definition.headerSort && typeof this.table.options.headerSortElement === "function"){ | ||
while(sortEl.firstChild) sortEl.removeChild(sortEl.firstChild); | ||
arrowEl = this.table.options.headerSortElement.call(this.table, column.getComponent(), dir); | ||
@@ -459,15 +465,15 @@ | ||
} | ||
//sort each item in sort list | ||
_sortItems(data, sortList){ | ||
var sorterCount = sortList.length - 1; | ||
data.sort((a, b) => { | ||
var result; | ||
for(var i = sorterCount; i>= 0; i--){ | ||
let sortItem = sortList[i]; | ||
result = this._sortRow(a, b, sortItem.column, sortItem.dir, sortItem.params); | ||
if(result !== 0){ | ||
@@ -477,24 +483,24 @@ break; | ||
} | ||
return result; | ||
}); | ||
} | ||
//process individual rows for a sort function on active data | ||
_sortRow(a, b, column, dir, params){ | ||
var el1Comp, el2Comp; | ||
//switch elements depending on search direction | ||
var el1 = dir == "asc" ? a : b; | ||
var el2 = dir == "asc" ? b : a; | ||
a = column.getFieldValue(el1.getData()); | ||
b = column.getFieldValue(el2.getData()); | ||
a = typeof a !== "undefined" ? a : ""; | ||
b = typeof b !== "undefined" ? b : ""; | ||
el1Comp = el1.getComponent(); | ||
el2Comp = el2.getComponent(); | ||
return column.modules.sort.sorter.call(this, a, b, el1Comp, el2Comp, column.getComponent(), dir, params); | ||
@@ -509,2 +515,2 @@ } | ||
export default Sort; | ||
export default Sort; |
@@ -40,2 +40,13 @@ export default { | ||
//must be alphanumeric | ||
alphanumeric: function(cell, value, parameters){ | ||
if(value === "" || value === null || typeof value === "undefined"){ | ||
return true; | ||
} | ||
var reg = new RegExp(/^[a-z0-9]+$/i); | ||
return reg.test(value); | ||
}, | ||
//maximum value | ||
@@ -42,0 +53,0 @@ max: function(cell, value, parameters){ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11114009
259
84523