tabulator-tables 5.6.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bower.json +1 -1
- package/build/{Bundler.js → Bundler.mjs} +8 -6
- package/build/rollup.mjs +9 -0
- package/dist/css/tabulator.css +67 -5
- package/dist/css/tabulator.css.map +1 -1
- package/dist/css/tabulator.min.css +1 -1
- package/dist/css/tabulator.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.css +77 -5
- package/dist/css/tabulator_bootstrap3.css.map +1 -1
- package/dist/css/tabulator_bootstrap3.min.css +1 -1
- package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.css +83 -5
- package/dist/css/tabulator_bootstrap4.css.map +1 -1
- package/dist/css/tabulator_bootstrap4.min.css +1 -1
- package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.css +83 -5
- package/dist/css/tabulator_bootstrap5.css.map +1 -1
- package/dist/css/tabulator_bootstrap5.min.css +1 -1
- package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
- package/dist/css/tabulator_bulma.css +89 -5
- package/dist/css/tabulator_bulma.css.map +1 -1
- package/dist/css/tabulator_bulma.min.css +1 -1
- package/dist/css/tabulator_bulma.min.css.map +1 -1
- package/dist/css/tabulator_materialize.css +82 -5
- package/dist/css/tabulator_materialize.css.map +1 -1
- package/dist/css/tabulator_materialize.min.css +1 -1
- package/dist/css/tabulator_materialize.min.css.map +1 -1
- package/dist/css/tabulator_midnight.css +77 -5
- package/dist/css/tabulator_midnight.css.map +1 -1
- package/dist/css/tabulator_midnight.min.css +1 -1
- package/dist/css/tabulator_midnight.min.css.map +1 -1
- package/dist/css/tabulator_modern.css +87 -5
- package/dist/css/tabulator_modern.css.map +1 -1
- package/dist/css/tabulator_modern.min.css +1 -1
- package/dist/css/tabulator_modern.min.css.map +1 -1
- package/dist/css/tabulator_semanticui.css +79 -5
- package/dist/css/tabulator_semanticui.css.map +1 -1
- package/dist/css/tabulator_semanticui.min.css +1 -1
- package/dist/css/tabulator_semanticui.min.css.map +1 -1
- package/dist/css/tabulator_simple.css +80 -5
- package/dist/css/tabulator_simple.css.map +1 -1
- package/dist/css/tabulator_simple.min.css +1 -1
- package/dist/css/tabulator_simple.min.css.map +1 -1
- package/dist/css/tabulator_site.css +90 -5
- package/dist/css/tabulator_site.css.map +1 -1
- package/dist/css/tabulator_site.min.css +1 -1
- package/dist/css/tabulator_site.min.css.map +1 -1
- package/dist/js/tabulator.js +3865 -2755
- package/dist/js/tabulator.js.map +1 -1
- package/dist/js/tabulator.min.js +2 -2
- package/dist/js/tabulator.min.js.map +1 -1
- package/dist/js/tabulator_esm.js +3857 -2745
- package/dist/js/tabulator_esm.js.map +1 -1
- package/dist/js/tabulator_esm.min.js +2 -2
- package/dist/js/tabulator_esm.min.js.map +1 -1
- package/package.json +17 -17
- package/src/js/builds/esm.js +2 -0
- package/src/js/core/ColumnManager.js +15 -0
- package/src/js/core/Module.js +2 -4
- package/src/js/core/RowManager.js +4 -6
- package/src/js/core/Tabulator.js +36 -23
- package/src/js/core/TabulatorFull.js +15 -5
- package/src/js/core/cell/Cell.js +4 -0
- package/src/js/core/column/Column.js +231 -216
- package/src/js/core/column/ColumnComponent.js +1 -3
- package/src/js/core/defaults/options.js +1 -0
- package/src/js/core/modules/optional.js +2 -1
- package/src/js/core/row/Row.js +23 -11
- package/src/js/core/tools/DataLoader.js +1 -1
- package/src/js/core/tools/ModuleBinder.js +123 -75
- package/src/js/core/tools/TableRegistry.js +58 -55
- package/src/js/modules/Accessor/Accessor.js +7 -8
- package/src/js/modules/Accessor/defaults/accessors.js +5 -1
- package/src/js/modules/Ajax/Ajax.js +10 -12
- package/src/js/modules/Clipboard/Clipboard.js +10 -10
- package/src/js/modules/Clipboard/defaults/pasteActions.js +0 -43
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +0 -55
- package/src/js/modules/Clipboard/extensions/extensions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/actions.js +9 -0
- package/src/js/modules/Clipboard/extensions/keybindings/bindings.js +3 -0
- package/src/js/modules/ColumnCalcs/CalcComponent.js +2 -4
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +16 -18
- package/src/js/modules/Comms/Comms.js +5 -8
- package/src/js/modules/DataTree/DataTree.js +11 -11
- package/src/js/modules/Download/Download.js +9 -11
- package/src/js/modules/Edit/Edit.js +63 -21
- package/src/js/modules/Edit/List.js +12 -12
- package/src/js/modules/Edit/defaults/editors/datetime.js +1 -1
- package/src/js/modules/Edit/defaults/editors/time.js +1 -1
- package/src/js/modules/Edit/defaults/editors.js +0 -4
- package/src/js/modules/Export/Export.js +70 -62
- package/src/js/modules/Export/ExportColumn.js +2 -4
- package/src/js/modules/Export/ExportRow.js +2 -4
- package/src/js/modules/Export/defaults/columnLookups.js +3 -0
- package/src/js/modules/Export/defaults/rowLookups.js +18 -0
- package/src/js/modules/Filter/Filter.js +7 -9
- package/src/js/modules/Format/Format.js +7 -9
- package/src/js/modules/Format/defaults/formatters.js +0 -4
- package/src/js/modules/FrozenColumns/FrozenColumns.js +9 -6
- package/src/js/modules/FrozenRows/FrozenRows.js +4 -6
- package/src/js/modules/GroupRows/Group.js +2 -4
- package/src/js/modules/GroupRows/GroupComponent.js +2 -4
- package/src/js/modules/GroupRows/GroupRows.js +4 -6
- package/src/js/modules/History/History.js +10 -10
- package/src/js/modules/History/extensions/extensions.js +9 -0
- package/src/js/modules/History/extensions/keybindings/actions.js +27 -0
- package/src/js/modules/History/extensions/keybindings/bindings.js +4 -0
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +4 -6
- package/src/js/modules/Import/Import.js +7 -9
- package/src/js/modules/Import/defaults/importers/array.js +2 -4
- package/src/js/modules/Import/defaults/importers/csv.js +2 -4
- package/src/js/modules/Interaction/Interaction.js +4 -6
- package/src/js/modules/Keybindings/Keybindings.js +8 -10
- package/src/js/modules/Keybindings/defaults/actions.js +5 -71
- package/src/js/modules/Keybindings/defaults/bindings.js +0 -16
- package/src/js/modules/Layout/Layout.js +7 -9
- package/src/js/modules/Localize/Localize.js +7 -9
- package/src/js/modules/Menu/Menu.js +7 -9
- package/src/js/modules/MoveColumns/MoveColumns.js +6 -8
- package/src/js/modules/MoveRows/MoveRows.js +13 -45
- package/src/js/modules/MoveRows/defaults/receivers.js +30 -0
- package/src/js/modules/MoveRows/defaults/senders.js +5 -0
- package/src/js/modules/Mutator/Mutator.js +7 -9
- package/src/js/modules/Page/Page.js +7 -9
- package/src/js/modules/Persistence/Persistence.js +10 -12
- package/src/js/modules/Popup/Popup.js +4 -8
- package/src/js/modules/Print/Print.js +4 -6
- package/src/js/modules/ReactiveData/ReactiveData.js +4 -9
- package/src/js/modules/ResizeColumns/ResizeColumns.js +91 -53
- package/src/js/modules/ResizeRows/ResizeRows.js +41 -8
- package/src/js/modules/ResizeTable/ResizeTable.js +4 -6
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +15 -9
- package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
- package/src/js/modules/SelectRange/Range.js +40 -21
- package/src/js/modules/SelectRange/RangeComponent.js +2 -4
- package/src/js/modules/SelectRange/SelectRange.js +88 -43
- package/src/js/modules/SelectRange/extensions/clipboard/pasteActions.js +45 -0
- package/src/js/modules/SelectRange/extensions/clipboard/pasteParsers.js +57 -0
- package/src/js/modules/SelectRange/extensions/export/columnLookups.js +11 -0
- package/src/js/modules/SelectRange/extensions/export/rowLookups.js +5 -0
- package/src/js/modules/SelectRange/extensions/extensions.js +21 -0
- package/src/js/modules/SelectRange/extensions/keybindings/actions.js +38 -0
- package/src/js/modules/SelectRange/extensions/keybindings/bindings.js +14 -0
- package/src/js/modules/SelectRow/SelectRow.js +12 -12
- package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
- package/src/js/modules/Sort/Sort.js +16 -13
- package/src/js/modules/Spreadsheet/GridCalculator.js +64 -0
- package/src/js/modules/Spreadsheet/Sheet.js +243 -0
- package/src/js/modules/Spreadsheet/SheetComponent.js +59 -0
- package/src/js/modules/Spreadsheet/Spreadsheet.js +309 -0
- package/src/js/modules/Tooltip/Tooltip.js +6 -8
- package/src/js/modules/Validate/Validate.js +7 -9
- package/src/scss/tabulator.scss +86 -10
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +14 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +18 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +18 -0
- package/src/scss/themes/bulma/tabulator_bulma.scss +24 -0
- package/src/scss/themes/materialize/tabulator_materialize.scss +18 -0
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +14 -0
- package/src/scss/themes/tabulator_midnight.scss +34 -21
- package/src/scss/themes/tabulator_modern.scss +23 -0
- package/src/scss/themes/tabulator_simple.scss +15 -0
- package/src/scss/themes/tabulator_site.scss +25 -0
- package/build/rollup.js +0 -6
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +0 -12
- package/src/js/modules/Edit/defaults/editors/select.js +0 -10
- /package/src/js/modules/{Format/defaults → ResponsiveLayout/extensions}/formatters/responsiveCollapse.js +0 -0
- /package/src/js/modules/{Format/defaults → SelectRow/extensions}/formatters/rowSelection.js +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export default class GridCalculator{
|
|
2
|
+
constructor(columns, rows){
|
|
3
|
+
this.columnCount = columns;
|
|
4
|
+
this.rowCount = rows;
|
|
5
|
+
|
|
6
|
+
this.columnString = [];
|
|
7
|
+
this.columns = [];
|
|
8
|
+
this.rows = [];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
genColumns(data){
|
|
12
|
+
var colCount = Math.max(this.columnCount, Math.max(...data.map(item => item.length)));
|
|
13
|
+
|
|
14
|
+
this.columnString = [];
|
|
15
|
+
this.columns = [];
|
|
16
|
+
|
|
17
|
+
for(let i = 1; i <= colCount; i++){
|
|
18
|
+
this.incrementChar(this.columnString.length - 1);
|
|
19
|
+
this.columns.push(this.columnString.join(""));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return this.columns;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
genRows(data){
|
|
26
|
+
var rowCount = Math.max(this.rowCount, data.length);
|
|
27
|
+
|
|
28
|
+
this.rows = [];
|
|
29
|
+
|
|
30
|
+
for(let i = 1; i <= rowCount; i++){
|
|
31
|
+
this.rows.push(i);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return this.rows;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
incrementChar(i){
|
|
38
|
+
let char = this.columnString[i];
|
|
39
|
+
|
|
40
|
+
if(char){
|
|
41
|
+
if(char !== "Z"){
|
|
42
|
+
this.columnString[i] = String.fromCharCode(this.columnString[i].charCodeAt(0) + 1);
|
|
43
|
+
}else{
|
|
44
|
+
this.columnString[i] = "A";
|
|
45
|
+
|
|
46
|
+
if(i){
|
|
47
|
+
this.incrementChar(i-1);
|
|
48
|
+
}else{
|
|
49
|
+
this.columnString.push("A");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}else{
|
|
53
|
+
this.columnString.push("A");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setRowCount(count){
|
|
58
|
+
this.rowCount = count;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setColumnCount(count){
|
|
62
|
+
this.columnCount = count;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import CoreFeature from '../../core/CoreFeature.js';
|
|
2
|
+
import GridCalculator from "./GridCalculator";
|
|
3
|
+
import SheetComponent from "./SheetComponent";
|
|
4
|
+
|
|
5
|
+
export default class Sheet extends CoreFeature{
|
|
6
|
+
constructor(spreadsheetManager, definition) {
|
|
7
|
+
super(spreadsheetManager.table);
|
|
8
|
+
|
|
9
|
+
this.spreadsheetManager = spreadsheetManager;
|
|
10
|
+
this.definition = definition;
|
|
11
|
+
|
|
12
|
+
this.title = this.definition.title || "";
|
|
13
|
+
this.key = this.definition.key || this.definition.title;
|
|
14
|
+
this.rowCount = this.definition.rows;
|
|
15
|
+
this.columnCount = this.definition.columns;
|
|
16
|
+
this.data = this.definition.data || [];
|
|
17
|
+
this.element = null;
|
|
18
|
+
this.isActive = false;
|
|
19
|
+
|
|
20
|
+
this.grid = new GridCalculator(this.columnCount, this.rowCount);
|
|
21
|
+
|
|
22
|
+
this.defaultColumnDefinition = {width:100, headerHozAlign:"center", headerSort:false};
|
|
23
|
+
this.columnDefinition = Object.assign(this.defaultColumnDefinition, this.options("spreadsheetColumnDefinition"));
|
|
24
|
+
|
|
25
|
+
this.columnDefs = [];
|
|
26
|
+
this.rowDefs = [];
|
|
27
|
+
this.columnFields = [];
|
|
28
|
+
this.columns = [];
|
|
29
|
+
this.rows = [];
|
|
30
|
+
|
|
31
|
+
this.scrollTop = null;
|
|
32
|
+
this.scrollLeft = null;
|
|
33
|
+
|
|
34
|
+
this.initialize();
|
|
35
|
+
|
|
36
|
+
this.dispatchExternal("sheetAdded", this.getComponent());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
///////////////////////////////////
|
|
40
|
+
///////// Initialization //////////
|
|
41
|
+
///////////////////////////////////
|
|
42
|
+
|
|
43
|
+
initialize(){
|
|
44
|
+
this.initializeElement();
|
|
45
|
+
this.initializeColumns();
|
|
46
|
+
this.initializeRows();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
reinitialize(){
|
|
50
|
+
this.initializeColumns();
|
|
51
|
+
this.initializeRows();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
initializeElement(){
|
|
55
|
+
this.element = document.createElement("div");
|
|
56
|
+
this.element.classList.add("tabulator-spreadsheet-tab");
|
|
57
|
+
this.element.innerText = this.title;
|
|
58
|
+
|
|
59
|
+
this.element.addEventListener("click", () => {
|
|
60
|
+
this.spreadsheetManager.loadSheet(this);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
initializeColumns(){
|
|
65
|
+
this.grid.setColumnCount(this.columnCount);
|
|
66
|
+
this.columnFields = this.grid.genColumns(this.data);
|
|
67
|
+
|
|
68
|
+
this.columnDefs = [];
|
|
69
|
+
|
|
70
|
+
this.columnFields.forEach((ref) => {
|
|
71
|
+
var def = Object.assign({}, this.columnDefinition);
|
|
72
|
+
def.field = ref;
|
|
73
|
+
def.title = ref;
|
|
74
|
+
|
|
75
|
+
this.columnDefs.push(def);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
initializeRows(){
|
|
80
|
+
var refs;
|
|
81
|
+
|
|
82
|
+
this.grid.setRowCount(this.rowCount);
|
|
83
|
+
|
|
84
|
+
refs = this.grid.genRows(this.data);
|
|
85
|
+
|
|
86
|
+
this.rowDefs = [];
|
|
87
|
+
|
|
88
|
+
refs.forEach((ref, i) => {
|
|
89
|
+
var def = {"_id":ref};
|
|
90
|
+
var data = this.data[i];
|
|
91
|
+
|
|
92
|
+
if(data){
|
|
93
|
+
data.forEach((val, j) => {
|
|
94
|
+
var field = this.columnFields[j];
|
|
95
|
+
|
|
96
|
+
if(field){
|
|
97
|
+
def[field] = val;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.rowDefs.push(def);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
unload(){
|
|
107
|
+
this.isActive = false;
|
|
108
|
+
this.scrollTop = this.table.rowManager.scrollTop;
|
|
109
|
+
this.scrollLeft = this.table.rowManager.scrollLeft;
|
|
110
|
+
this.data = this.getData(true);
|
|
111
|
+
this.element.classList.remove("tabulator-spreadsheet-tab-active");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
load(){
|
|
115
|
+
|
|
116
|
+
var wasInactive = !this.isActive;
|
|
117
|
+
|
|
118
|
+
this.isActive = true;
|
|
119
|
+
this.table.blockRedraw();
|
|
120
|
+
this.table.setData([]);
|
|
121
|
+
this.table.setColumns(this.columnDefs);
|
|
122
|
+
this.table.setData(this.rowDefs);
|
|
123
|
+
this.table.restoreRedraw();
|
|
124
|
+
|
|
125
|
+
if(wasInactive && this.scrollTop !== null){
|
|
126
|
+
this.table.rowManager.element.scrollLeft = this.scrollLeft;
|
|
127
|
+
this.table.rowManager.element.scrollTop = this.scrollTop;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
this.element.classList.add("tabulator-spreadsheet-tab-active");
|
|
131
|
+
|
|
132
|
+
this.dispatchExternal("sheetLoaded", this.getComponent());
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
///////////////////////////////////
|
|
136
|
+
//////// Helper Functions /////////
|
|
137
|
+
///////////////////////////////////
|
|
138
|
+
|
|
139
|
+
getComponent(){
|
|
140
|
+
return new SheetComponent(this);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
getDefinition(){
|
|
144
|
+
return {
|
|
145
|
+
title:this.title,
|
|
146
|
+
key:this.key,
|
|
147
|
+
rows:this.rowCount,
|
|
148
|
+
columns:this.columnCount,
|
|
149
|
+
data:this.getData(),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
getData(full){
|
|
154
|
+
var output = [],
|
|
155
|
+
rowWidths,
|
|
156
|
+
outputWidth, outputHeight;
|
|
157
|
+
|
|
158
|
+
//map data to array format
|
|
159
|
+
this.rowDefs.forEach((rowData) => {
|
|
160
|
+
var row = [];
|
|
161
|
+
|
|
162
|
+
this.columnFields.forEach((field) => {
|
|
163
|
+
row.push(rowData[field]);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
output.push(row);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
//trim output
|
|
170
|
+
if(!full && !this.options("spreadsheetOutputFull")){
|
|
171
|
+
|
|
172
|
+
//calculate used area of data
|
|
173
|
+
rowWidths = output.map(row => row.findLastIndex(val => typeof val !== 'undefined') + 1);
|
|
174
|
+
outputWidth = Math.max(...rowWidths);
|
|
175
|
+
outputHeight = rowWidths.findLastIndex(width => width > 0) + 1;
|
|
176
|
+
|
|
177
|
+
output = output.slice(0, outputHeight);
|
|
178
|
+
output = output.map(row => row.slice(0, outputWidth));
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return output;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setData(data){
|
|
185
|
+
this.data = data;
|
|
186
|
+
this.reinitialize();
|
|
187
|
+
|
|
188
|
+
this.dispatchExternal("sheetUpdated", this.getComponent());
|
|
189
|
+
|
|
190
|
+
if(this.isActive){
|
|
191
|
+
this.load();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
clear(){
|
|
196
|
+
this.setData([]);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
setTitle(title){
|
|
200
|
+
this.title = title;
|
|
201
|
+
this.element.innerText = title;
|
|
202
|
+
|
|
203
|
+
this.dispatchExternal("sheetUpdated", this.getComponent());
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
setRows(rows){
|
|
207
|
+
this.rowCount = rows;
|
|
208
|
+
this.initializeRows();
|
|
209
|
+
|
|
210
|
+
this.dispatchExternal("sheetUpdated", this.getComponent());
|
|
211
|
+
|
|
212
|
+
if(this.isActive){
|
|
213
|
+
this.load();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
setColumns(columns){
|
|
218
|
+
this.columnCount = columns;
|
|
219
|
+
this.reinitialize();
|
|
220
|
+
|
|
221
|
+
this.dispatchExternal("sheetUpdated", this.getComponent());
|
|
222
|
+
|
|
223
|
+
if(this.isActive){
|
|
224
|
+
this.load();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
remove(){
|
|
229
|
+
this.spreadsheetManager.removeSheet(this);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
destroy(){
|
|
233
|
+
if(this.element.parentNode){
|
|
234
|
+
this.element.parentNode.removeChild(this.element);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
this.dispatchExternal("sheetRemoved", this.getComponent());
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
active(){
|
|
241
|
+
this.spreadsheetManager.loadSheet(this);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export default class SheetComponent {
|
|
2
|
+
constructor(sheet) {
|
|
3
|
+
this._sheet = sheet;
|
|
4
|
+
|
|
5
|
+
return new Proxy(this, {
|
|
6
|
+
get: function (target, name, receiver) {
|
|
7
|
+
if (typeof target[name] !== "undefined") {
|
|
8
|
+
return target[name];
|
|
9
|
+
} else {
|
|
10
|
+
return target._sheet.table.componentFunctionBinder.handle("sheet", target._sheet, name);
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getTitle(){
|
|
17
|
+
return this._sheet.title;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
getKey(){
|
|
21
|
+
return this._sheet.key;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getDefinition(){
|
|
25
|
+
return this._sheet.getDefinition();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getData() {
|
|
29
|
+
return this._sheet.getData();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
setData(data) {
|
|
33
|
+
return this._sheet.setData(data);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
clear(){
|
|
37
|
+
return this._sheet.clear();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
remove(){
|
|
41
|
+
return this._sheet.remove();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
active(){
|
|
45
|
+
return this._sheet.active();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
setTitle(title){
|
|
49
|
+
return this._sheet.setTitle(title);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setRows(rows){
|
|
53
|
+
return this._sheet.setRows(rows);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
setColumns(columns){
|
|
57
|
+
return this._sheet.setColumns(columns);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
import Sheet from "./Sheet";
|
|
3
|
+
import SheetComponent from "./SheetComponent";
|
|
4
|
+
|
|
5
|
+
export default class Spreadsheet extends Module{
|
|
6
|
+
|
|
7
|
+
static moduleName = "spreadsheet";
|
|
8
|
+
|
|
9
|
+
constructor(table){
|
|
10
|
+
super(table);
|
|
11
|
+
|
|
12
|
+
this.sheets = [];
|
|
13
|
+
this.element = null;
|
|
14
|
+
|
|
15
|
+
this.registerTableOption("spreadsheet", false);
|
|
16
|
+
this.registerTableOption("spreadsheetRows", 50);
|
|
17
|
+
this.registerTableOption("spreadsheetColumns", 50);
|
|
18
|
+
this.registerTableOption("spreadsheetColumnDefinition", {});
|
|
19
|
+
this.registerTableOption("spreadsheetOutputFull", false);
|
|
20
|
+
this.registerTableOption("spreadsheetData", false);
|
|
21
|
+
this.registerTableOption("spreadsheetSheets", false);
|
|
22
|
+
this.registerTableOption("spreadsheetSheetTabs", false);
|
|
23
|
+
this.registerTableOption("spreadsheetSheetTabsElement", false);
|
|
24
|
+
|
|
25
|
+
this.registerTableFunction("setSheets", this.setSheets.bind(this));
|
|
26
|
+
this.registerTableFunction("addSheet", this.addSheet.bind(this));
|
|
27
|
+
this.registerTableFunction("getSheets", this.getSheets.bind(this));
|
|
28
|
+
this.registerTableFunction("getSheetDefinitions", this.getSheetDefinitions.bind(this));
|
|
29
|
+
this.registerTableFunction("setSheetData", this.setSheetData.bind(this));
|
|
30
|
+
this.registerTableFunction("getSheet", this.getSheet.bind(this));
|
|
31
|
+
this.registerTableFunction("getSheetData", this.getSheetData.bind(this));
|
|
32
|
+
this.registerTableFunction("clearSheet", this.clearSheet.bind(this));
|
|
33
|
+
this.registerTableFunction("removeSheet", this.removeSheetFunc.bind(this));
|
|
34
|
+
this.registerTableFunction("activeSheet", this.activeSheetFunc.bind(this));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
///////////////////////////////////
|
|
38
|
+
////// Module Initialization //////
|
|
39
|
+
///////////////////////////////////
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
initialize(){
|
|
43
|
+
if(this.options("spreadsheet")){
|
|
44
|
+
this.subscribe("table-initialized", this.tableInitialized.bind(this));
|
|
45
|
+
this.subscribe("data-loaded", this.loadRemoteData.bind(this));
|
|
46
|
+
|
|
47
|
+
this.table.options.index = "_id";
|
|
48
|
+
|
|
49
|
+
if(this.options("spreadsheetData") && this.options("spreadsheetSheets")){
|
|
50
|
+
console.warn("You cannot use spreadsheetData and spreadsheetSheets at the same time, ignoring spreadsheetData");
|
|
51
|
+
|
|
52
|
+
this.table.options.spreadsheetData = false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.compatibilityCheck();
|
|
56
|
+
|
|
57
|
+
if(this.options("spreadsheetSheetTabs")){
|
|
58
|
+
this.initializeTabset();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
compatibilityCheck(){
|
|
64
|
+
if(this.options("data")){
|
|
65
|
+
console.warn("Do not use the data option when working with spreadsheets, use either spreadsheetData or spreadsheetSheets to pass data into the table");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if(this.options("pagination")){
|
|
69
|
+
console.warn("The spreadsheet module is not compatible with the pagination module");
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if(this.options("groupBy")){
|
|
73
|
+
console.warn("The spreadsheet module is not compatible with the row grouping module");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if(this.options("responsiveCollapse")){
|
|
77
|
+
console.warn("The spreadsheet module is not compatible with the responsive collapse module");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
initializeTabset(){
|
|
81
|
+
this.element = document.createElement("div");
|
|
82
|
+
this.element.classList.add("tabulator-spreadsheet-tabs");
|
|
83
|
+
var altContainer = this.options("spreadsheetSheetTabsElement");
|
|
84
|
+
|
|
85
|
+
if(altContainer && !(altContainer instanceof HTMLElement)){
|
|
86
|
+
altContainer = document.querySelector(altContainer);
|
|
87
|
+
|
|
88
|
+
if(!altContainer){
|
|
89
|
+
console.warn("Unable to find element matching spreadsheetSheetTabsElement selector:", this.options("spreadsheetSheetTabsElement"));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if(altContainer){
|
|
94
|
+
altContainer.appendChild(this.element);
|
|
95
|
+
}else{
|
|
96
|
+
this.footerAppend(this.element);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
tableInitialized(){
|
|
101
|
+
if(this.sheets.length){
|
|
102
|
+
this.loadSheet(this.sheets[0]);
|
|
103
|
+
}else{
|
|
104
|
+
|
|
105
|
+
if(this.options("spreadsheetSheets")){
|
|
106
|
+
this.loadSheets(this.options("spreadsheetSheets"));
|
|
107
|
+
}else if(this.options("spreadsheetData")){
|
|
108
|
+
this.loadData(this.options("spreadsheetData"));
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
///////////////////////////////////
|
|
114
|
+
/////////// Ajax Parsing //////////
|
|
115
|
+
///////////////////////////////////
|
|
116
|
+
|
|
117
|
+
loadRemoteData(data, data1, data2){
|
|
118
|
+
console.log("data", data, data1, data2);
|
|
119
|
+
|
|
120
|
+
if(Array.isArray(data)){
|
|
121
|
+
|
|
122
|
+
this.table.dataLoader.clearAlert();
|
|
123
|
+
this.dispatchExternal("dataLoaded", data);
|
|
124
|
+
|
|
125
|
+
if(!data.length || Array.isArray(data[0])){
|
|
126
|
+
this.loadData(data);
|
|
127
|
+
}else{
|
|
128
|
+
this.loadSheets(data);
|
|
129
|
+
}
|
|
130
|
+
}else{
|
|
131
|
+
console.error("Spreadsheet Loading Error - Unable to process remote data due to invalid data type \nExpecting: array \nReceived: ", typeof data, "\nData: ", data);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
///////////////////////////////////
|
|
138
|
+
///////// Sheet Management ////////
|
|
139
|
+
///////////////////////////////////
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
loadData(data){
|
|
143
|
+
var def = {
|
|
144
|
+
data:data,
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
this.loadSheet(this.newSheet(def));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
destroySheets(){
|
|
151
|
+
this.sheets.forEach((sheet) => {
|
|
152
|
+
sheet.destroy();
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
this.sheets = [];
|
|
156
|
+
this.activeSheet = null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
loadSheets(sheets){
|
|
160
|
+
if(!Array.isArray(sheets)){
|
|
161
|
+
sheets = [];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
this.destroySheets();
|
|
165
|
+
|
|
166
|
+
sheets.forEach((def) => {
|
|
167
|
+
this.newSheet(def);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
this.loadSheet(this.sheets[0]);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
loadSheet(sheet){
|
|
174
|
+
if(this.activeSheet !== sheet){
|
|
175
|
+
if(this.activeSheet){
|
|
176
|
+
this.activeSheet.unload();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
this.activeSheet = sheet;
|
|
180
|
+
|
|
181
|
+
sheet.load();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
newSheet(definition = {}){
|
|
186
|
+
var sheet;
|
|
187
|
+
|
|
188
|
+
if(!definition.rows){
|
|
189
|
+
definition.rows = this.options("spreadsheetRows");
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if(!definition.columns){
|
|
193
|
+
definition.columns = this.options("spreadsheetColumns");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
sheet = new Sheet(this, definition);
|
|
197
|
+
|
|
198
|
+
this.sheets.push(sheet);
|
|
199
|
+
|
|
200
|
+
if(this.element){
|
|
201
|
+
this.element.appendChild(sheet.element);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return sheet;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
removeSheet(sheet){
|
|
208
|
+
var index = this.sheets.indexOf(sheet),
|
|
209
|
+
prevSheet;
|
|
210
|
+
|
|
211
|
+
if(this.sheets.length > 1){
|
|
212
|
+
if(index > -1){
|
|
213
|
+
this.sheets.splice(index, 1);
|
|
214
|
+
sheet.destroy();
|
|
215
|
+
|
|
216
|
+
if(this.activeSheet === sheet){
|
|
217
|
+
|
|
218
|
+
prevSheet = this.sheets[index - 1] || this.sheets[0];
|
|
219
|
+
|
|
220
|
+
if(prevSheet){
|
|
221
|
+
this.loadSheet(prevSheet);
|
|
222
|
+
}else{
|
|
223
|
+
this.activeSheet = null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}else{
|
|
228
|
+
console.warn("Unable to remove sheet, at least one sheet must be active");
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
lookupSheet(key){
|
|
233
|
+
if(!key){
|
|
234
|
+
return this.activeSheet;
|
|
235
|
+
}else if(key instanceof Sheet){
|
|
236
|
+
return key;
|
|
237
|
+
}else if(key instanceof SheetComponent){
|
|
238
|
+
return key._sheet;
|
|
239
|
+
}else{
|
|
240
|
+
return this.sheets.find(sheet => sheet.key === key) || false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
///////////////////////////////////
|
|
246
|
+
//////// Public Functions /////////
|
|
247
|
+
///////////////////////////////////
|
|
248
|
+
|
|
249
|
+
setSheets(sheets){
|
|
250
|
+
this.loadSheets(sheets);
|
|
251
|
+
|
|
252
|
+
return this.getSheets();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
addSheet(sheet){
|
|
256
|
+
return this.newSheet(sheet).getComponent();
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
getSheetDefinitions(){
|
|
260
|
+
return this.sheets.map(sheet => sheet.getDefinition());
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
getSheets(){
|
|
264
|
+
return this.sheets.map(sheet => sheet.getComponent());
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
getSheet(key){
|
|
268
|
+
var sheet = this.lookupSheet(key);
|
|
269
|
+
|
|
270
|
+
return sheet ? sheet.getComponent() : false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
setSheetData(key, data){
|
|
274
|
+
if (key && !data){
|
|
275
|
+
data = key;
|
|
276
|
+
key = false;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
var sheet = this.lookupSheet(key);
|
|
280
|
+
|
|
281
|
+
return sheet ? sheet.setData(data) : false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
getSheetData(key){
|
|
285
|
+
var sheet = this.lookupSheet(key);
|
|
286
|
+
|
|
287
|
+
return sheet ? sheet.getData() : false;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
clearSheet(key){
|
|
291
|
+
var sheet = this.lookupSheet(key);
|
|
292
|
+
|
|
293
|
+
return sheet ? sheet.clear() : false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
removeSheetFunc(key){
|
|
297
|
+
var sheet = this.lookupSheet(key);
|
|
298
|
+
|
|
299
|
+
if(sheet){
|
|
300
|
+
this.removeSheet(sheet);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
activeSheetFunc(key){
|
|
305
|
+
var sheet = this.lookupSheet(key);
|
|
306
|
+
|
|
307
|
+
return sheet ? this.loadSheet(sheet) : false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import Module from '../../core/Module.js';
|
|
2
2
|
import Cell from '../../core/cell/Cell.js';
|
|
3
3
|
|
|
4
|
-
class Tooltip extends Module{
|
|
4
|
+
export default class Tooltip extends Module{
|
|
5
|
+
|
|
6
|
+
static moduleName = "tooltip";
|
|
5
7
|
|
|
6
8
|
constructor(table){
|
|
7
9
|
super(table);
|
|
@@ -12,7 +14,7 @@ class Tooltip extends Module{
|
|
|
12
14
|
this.timeout = null;
|
|
13
15
|
this.popupInstance = null;
|
|
14
16
|
|
|
15
|
-
this.registerTableOption("tooltipGenerationMode", undefined); //deprecated
|
|
17
|
+
// this.registerTableOption("tooltipGenerationMode", undefined); //deprecated
|
|
16
18
|
this.registerTableOption("tooltipDelay", 300);
|
|
17
19
|
|
|
18
20
|
this.registerColumnOption("tooltip");
|
|
@@ -26,7 +28,7 @@ class Tooltip extends Module{
|
|
|
26
28
|
}
|
|
27
29
|
|
|
28
30
|
deprecatedOptionsCheck(){
|
|
29
|
-
this.deprecationCheckMsg("tooltipGenerationMode", "This option is no longer needed as tooltips are always generated on hover now");
|
|
31
|
+
// this.deprecationCheckMsg("tooltipGenerationMode", "This option is no longer needed as tooltips are always generated on hover now");
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
initializeColumn(column){
|
|
@@ -123,8 +125,4 @@ class Tooltip extends Module{
|
|
|
123
125
|
this.dispatchExternal("TooltipOpened", component.getComponent());
|
|
124
126
|
}
|
|
125
127
|
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
Tooltip.moduleName = "tooltip";
|
|
129
|
-
|
|
130
|
-
export default Tooltip;
|
|
128
|
+
}
|