tabulator-tables 6.5.0 → 6.5.1
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/dist/js/tabulator.js +1 -1
- package/dist/js/tabulator.min.js +1 -1
- package/dist/js/tabulator_esm.js +1 -1
- package/dist/js/tabulator_esm.min.js +1 -1
- package/dist/js/tabulator_esm.min.mjs +1 -1
- package/dist/js/tabulator_esm.mjs +1 -1
- package/package.json +2 -1
- package/src/js/builds/esm.js +16 -0
- package/src/js/builds/jquery_wrapper.js +63 -0
- package/src/js/builds/usd.js +1 -0
- package/src/js/core/ColumnManager.js +789 -0
- package/src/js/core/CoreFeature.js +140 -0
- package/src/js/core/FooterManager.js +102 -0
- package/src/js/core/Module.js +140 -0
- package/src/js/core/RowManager.js +1140 -0
- package/src/js/core/Tabulator.js +928 -0
- package/src/js/core/TabulatorFull.js +21 -0
- package/src/js/core/cell/Cell.js +299 -0
- package/src/js/core/cell/CellComponent.js +79 -0
- package/src/js/core/column/Column.js +978 -0
- package/src/js/core/column/ColumnComponent.js +151 -0
- package/src/js/core/column/defaults/options.js +18 -0
- package/src/js/core/defaults/options.js +66 -0
- package/src/js/core/modules/core.js +3 -0
- package/src/js/core/modules/optional.js +37 -0
- package/src/js/core/rendering/Renderer.js +204 -0
- package/src/js/core/rendering/renderers/BasicHorizontal.js +27 -0
- package/src/js/core/rendering/renderers/BasicVertical.js +103 -0
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +587 -0
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +642 -0
- package/src/js/core/row/PseudoRow.js +47 -0
- package/src/js/core/row/Row.js +487 -0
- package/src/js/core/row/RowComponent.js +94 -0
- package/src/js/core/tools/Alert.js +66 -0
- package/src/js/core/tools/ComponentFunctionBinder.js +32 -0
- package/src/js/core/tools/DataLoader.js +128 -0
- package/src/js/core/tools/DependencyRegistry.js +82 -0
- package/src/js/core/tools/DeprecationAdvisor.js +51 -0
- package/src/js/core/tools/ExternalEventBus.js +105 -0
- package/src/js/core/tools/Helpers.js +66 -0
- package/src/js/core/tools/InteractionMonitor.js +329 -0
- package/src/js/core/tools/InternalEventBus.js +162 -0
- package/src/js/core/tools/ModuleBinder.js +153 -0
- package/src/js/core/tools/OptionsList.js +45 -0
- package/src/js/core/tools/Popup.js +317 -0
- package/src/js/core/tools/TableRegistry.js +65 -0
- package/src/js/modules/Accessor/Accessor.js +115 -0
- package/src/js/modules/Accessor/defaults/accessors.js +5 -0
- package/src/js/modules/Ajax/Ajax.js +142 -0
- package/src/js/modules/Ajax/defaults/config.js +3 -0
- package/src/js/modules/Ajax/defaults/contentTypeFormatters.js +45 -0
- package/src/js/modules/Ajax/defaults/loaderPromise.js +87 -0
- package/src/js/modules/Ajax/defaults/urlGenerator.js +44 -0
- package/src/js/modules/Clipboard/Clipboard.js +282 -0
- package/src/js/modules/Clipboard/defaults/pasteActions.js +11 -0
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +75 -0
- 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 +46 -0
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +586 -0
- package/src/js/modules/ColumnCalcs/defaults/calculations.js +93 -0
- package/src/js/modules/Comms/Comms.js +49 -0
- package/src/js/modules/DataTree/DataTree.js +620 -0
- package/src/js/modules/Download/Download.js +146 -0
- package/src/js/modules/Download/defaults/downloaders/csv.js +61 -0
- package/src/js/modules/Download/defaults/downloaders/html.js +5 -0
- package/src/js/modules/Download/defaults/downloaders/json.js +34 -0
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
- package/src/js/modules/Download/defaults/downloaders/pdf.js +113 -0
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +103 -0
- package/src/js/modules/Download/defaults/downloaders.js +15 -0
- package/src/js/modules/Edit/Edit.js +845 -0
- package/src/js/modules/Edit/List.js +1060 -0
- package/src/js/modules/Edit/defaults/editors/adaptable.js +37 -0
- package/src/js/modules/Edit/defaults/editors/date.js +144 -0
- package/src/js/modules/Edit/defaults/editors/datetime.js +131 -0
- package/src/js/modules/Edit/defaults/editors/input.js +77 -0
- package/src/js/modules/Edit/defaults/editors/list.js +7 -0
- package/src/js/modules/Edit/defaults/editors/number.js +110 -0
- package/src/js/modules/Edit/defaults/editors/progress.js +127 -0
- package/src/js/modules/Edit/defaults/editors/range.js +81 -0
- package/src/js/modules/Edit/defaults/editors/star.js +146 -0
- package/src/js/modules/Edit/defaults/editors/textarea.js +123 -0
- package/src/js/modules/Edit/defaults/editors/tickCross.js +95 -0
- package/src/js/modules/Edit/defaults/editors/time.js +132 -0
- package/src/js/modules/Edit/defaults/editors.js +27 -0
- package/src/js/modules/Edit/inputMask.js +74 -0
- package/src/js/modules/Export/Export.js +654 -0
- package/src/js/modules/Export/ExportColumn.js +9 -0
- package/src/js/modules/Export/ExportRow.js +8 -0
- 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 +902 -0
- package/src/js/modules/Filter/defaults/filters.js +215 -0
- package/src/js/modules/Format/Format.js +200 -0
- package/src/js/modules/Format/defaults/formatters/adaptable.js +32 -0
- package/src/js/modules/Format/defaults/formatters/array.js +30 -0
- package/src/js/modules/Format/defaults/formatters/buttonCross.js +3 -0
- package/src/js/modules/Format/defaults/formatters/buttonTick.js +3 -0
- package/src/js/modules/Format/defaults/formatters/color.js +4 -0
- package/src/js/modules/Format/defaults/formatters/datetime.js +39 -0
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +43 -0
- package/src/js/modules/Format/defaults/formatters/handle.js +4 -0
- package/src/js/modules/Format/defaults/formatters/html.js +3 -0
- package/src/js/modules/Format/defaults/formatters/image.js +40 -0
- package/src/js/modules/Format/defaults/formatters/json.js +12 -0
- package/src/js/modules/Format/defaults/formatters/link.js +82 -0
- package/src/js/modules/Format/defaults/formatters/lookup.js +10 -0
- package/src/js/modules/Format/defaults/formatters/money.js +44 -0
- package/src/js/modules/Format/defaults/formatters/plaintext.js +3 -0
- package/src/js/modules/Format/defaults/formatters/progress.js +133 -0
- package/src/js/modules/Format/defaults/formatters/rownum.js +14 -0
- package/src/js/modules/Format/defaults/formatters/star.js +38 -0
- package/src/js/modules/Format/defaults/formatters/textarea.js +4 -0
- package/src/js/modules/Format/defaults/formatters/tickCross.js +22 -0
- package/src/js/modules/Format/defaults/formatters/toggle.js +48 -0
- package/src/js/modules/Format/defaults/formatters/traffic.js +47 -0
- package/src/js/modules/Format/defaults/formatters.js +47 -0
- package/src/js/modules/FrozenColumns/FrozenColumns.js +302 -0
- package/src/js/modules/FrozenRows/FrozenRows.js +175 -0
- package/src/js/modules/GroupRows/Group.js +615 -0
- package/src/js/modules/GroupRows/GroupComponent.js +69 -0
- package/src/js/modules/GroupRows/GroupRows.js +636 -0
- package/src/js/modules/History/History.js +172 -0
- package/src/js/modules/History/defaults/redoers.js +31 -0
- package/src/js/modules/History/defaults/undoers.js +33 -0
- 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 +180 -0
- package/src/js/modules/Import/Import.js +303 -0
- package/src/js/modules/Import/defaults/importers/array.js +3 -0
- package/src/js/modules/Import/defaults/importers/csv.js +61 -0
- package/src/js/modules/Import/defaults/importers/json.js +8 -0
- package/src/js/modules/Import/defaults/importers/xlsx.js +7 -0
- package/src/js/modules/Import/defaults/importers.js +11 -0
- package/src/js/modules/Interaction/Interaction.js +339 -0
- package/src/js/modules/Keybindings/Keybindings.js +198 -0
- package/src/js/modules/Keybindings/defaults/actions.js +90 -0
- package/src/js/modules/Keybindings/defaults/bindings.js +12 -0
- package/src/js/modules/Layout/Layout.js +66 -0
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +171 -0
- package/src/js/modules/Layout/defaults/modes/fitData.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +10 -0
- package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +40 -0
- package/src/js/modules/Layout/defaults/modes.js +12 -0
- package/src/js/modules/Localize/Localize.js +184 -0
- package/src/js/modules/Localize/defaults/langs.js +37 -0
- package/src/js/modules/Menu/Menu.js +302 -0
- package/src/js/modules/MoveColumns/MoveColumns.js +311 -0
- package/src/js/modules/MoveRows/MoveRows.js +604 -0
- 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 +164 -0
- package/src/js/modules/Mutator/defaults/mutators.js +1 -0
- package/src/js/modules/Page/Page.js +891 -0
- package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
- package/src/js/modules/Page/defaults/pageCounters/rows.js +40 -0
- package/src/js/modules/Page/defaults/pageCounters.js +8 -0
- package/src/js/modules/Persistence/Persistence.js +473 -0
- package/src/js/modules/Persistence/defaults/readers.js +29 -0
- package/src/js/modules/Persistence/defaults/writers.js +13 -0
- package/src/js/modules/Popup/Popup.js +227 -0
- package/src/js/modules/Print/Print.js +136 -0
- package/src/js/modules/ReactiveData/ReactiveData.js +416 -0
- package/src/js/modules/ResizeColumns/ResizeColumns.js +365 -0
- package/src/js/modules/ResizeRows/ResizeRows.js +145 -0
- package/src/js/modules/ResizeTable/ResizeTable.js +158 -0
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +354 -0
- package/src/js/modules/ResponsiveLayout/extensions/extensions.js +9 -0
- package/src/js/modules/ResponsiveLayout/extensions/formatters/responsiveCollapse.js +44 -0
- package/src/js/modules/SelectRange/Range.js +366 -0
- package/src/js/modules/SelectRange/RangeComponent.js +91 -0
- package/src/js/modules/SelectRange/SelectRange.js +993 -0
- 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 +499 -0
- package/src/js/modules/SelectRow/extensions/extensions.js +9 -0
- package/src/js/modules/SelectRow/extensions/formatters/rowSelection.js +60 -0
- package/src/js/modules/Sort/Sort.js +480 -0
- package/src/js/modules/Sort/defaults/sorters/alphanum.js +44 -0
- package/src/js/modules/Sort/defaults/sorters/array.js +82 -0
- package/src/js/modules/Sort/defaults/sorters/boolean.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/date.js +10 -0
- package/src/js/modules/Sort/defaults/sorters/datetime.js +48 -0
- package/src/js/modules/Sort/defaults/sorters/exists.js +7 -0
- package/src/js/modules/Sort/defaults/sorters/number.js +40 -0
- package/src/js/modules/Sort/defaults/sorters/string.js +34 -0
- package/src/js/modules/Sort/defaults/sorters/time.js +10 -0
- package/src/js/modules/Sort/defaults/sorters.js +21 -0
- 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 +128 -0
- package/src/js/modules/Validate/Validate.js +303 -0
- package/src/js/modules/Validate/defaults/validators.js +150 -0
- package/src/scss/tabulator.scss +1693 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +302 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +589 -0
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +979 -0
- package/src/scss/themes/bootstrap/variables3.scss +872 -0
- package/src/scss/themes/bootstrap/variables4.scss +1059 -0
- package/src/scss/themes/bootstrap/variables5.scss +1967 -0
- package/src/scss/themes/bulma/tabulator_bulma.scss +316 -0
- package/src/scss/themes/bulma/variables.scss +198 -0
- package/src/scss/themes/materialize/tabulator_materialize.scss +318 -0
- package/src/scss/themes/materialize/variables.scss +71 -0
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +623 -0
- package/src/scss/themes/semanticui/variables.scss +843 -0
- package/src/scss/themes/semanticui/variables_table.scss +248 -0
- package/src/scss/themes/tabulator_midnight.scss +235 -0
- package/src/scss/themes/tabulator_modern.scss +308 -0
- package/src/scss/themes/tabulator_simple.scss +143 -0
- package/src/scss/themes/tabulator_site.scss +267 -0
- package/src/scss/themes/tabulator_site_dark.scss +496 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//sort datetime
|
|
2
|
+
export default function(a, b, aRow, bRow, column, dir, params){
|
|
3
|
+
var DT = this.table.dependencyRegistry.lookup(["luxon", "DateTime"], "DateTime");
|
|
4
|
+
var format = params.format || "dd/MM/yyyy HH:mm:ss",
|
|
5
|
+
alignEmptyValues = params.alignEmptyValues,
|
|
6
|
+
emptyAlign = 0;
|
|
7
|
+
|
|
8
|
+
if(typeof DT != "undefined"){
|
|
9
|
+
if(!DT.isDateTime(a)){
|
|
10
|
+
if(format === "iso"){
|
|
11
|
+
a = DT.fromISO(String(a));
|
|
12
|
+
}else if(format === "x"){
|
|
13
|
+
a = DT.fromMillis(a);
|
|
14
|
+
}else{
|
|
15
|
+
a = DT.fromFormat(String(a), format);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if(!DT.isDateTime(b)){
|
|
20
|
+
if(format === "iso"){
|
|
21
|
+
b = DT.fromISO(String(b));
|
|
22
|
+
}else if(format === "x"){
|
|
23
|
+
b = DT.fromMillis(b);
|
|
24
|
+
}else{
|
|
25
|
+
b = DT.fromFormat(String(b), format);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if(!a.isValid){
|
|
30
|
+
emptyAlign = !b.isValid ? 0 : -1;
|
|
31
|
+
}else if(!b.isValid){
|
|
32
|
+
emptyAlign = 1;
|
|
33
|
+
}else{
|
|
34
|
+
//compare valid values
|
|
35
|
+
return a - b;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
//fix empty values in position
|
|
39
|
+
if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){
|
|
40
|
+
emptyAlign *= -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return emptyAlign;
|
|
44
|
+
|
|
45
|
+
}else{
|
|
46
|
+
console.error("Sort Error - 'datetime' sorter is dependant on luxon.js");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
//sort numbers
|
|
2
|
+
export default function(a, b, aRow, bRow, column, dir, params){
|
|
3
|
+
var alignEmptyValues = params.alignEmptyValues;
|
|
4
|
+
var decimal = params.decimalSeparator;
|
|
5
|
+
var thousand = params.thousandSeparator;
|
|
6
|
+
var emptyAlign = 0;
|
|
7
|
+
|
|
8
|
+
a = String(a);
|
|
9
|
+
b = String(b);
|
|
10
|
+
|
|
11
|
+
if(thousand){
|
|
12
|
+
a = a.split(thousand).join("");
|
|
13
|
+
b = b.split(thousand).join("");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if(decimal){
|
|
17
|
+
a = a.split(decimal).join(".");
|
|
18
|
+
b = b.split(decimal).join(".");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
a = parseFloat(a);
|
|
22
|
+
b = parseFloat(b);
|
|
23
|
+
|
|
24
|
+
//handle non numeric values
|
|
25
|
+
if(isNaN(a)){
|
|
26
|
+
emptyAlign = isNaN(b) ? 0 : -1;
|
|
27
|
+
}else if(isNaN(b)){
|
|
28
|
+
emptyAlign = 1;
|
|
29
|
+
}else{
|
|
30
|
+
//compare valid values
|
|
31
|
+
return a - b;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//fix empty values in position
|
|
35
|
+
if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){
|
|
36
|
+
emptyAlign *= -1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return emptyAlign;
|
|
40
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//sort strings
|
|
2
|
+
export default function(a, b, aRow, bRow, column, dir, params){
|
|
3
|
+
var alignEmptyValues = params.alignEmptyValues;
|
|
4
|
+
var emptyAlign = 0;
|
|
5
|
+
var locale;
|
|
6
|
+
|
|
7
|
+
//handle empty values
|
|
8
|
+
if(!a){
|
|
9
|
+
emptyAlign = !b ? 0 : -1;
|
|
10
|
+
}else if(!b){
|
|
11
|
+
emptyAlign = 1;
|
|
12
|
+
}else{
|
|
13
|
+
//compare valid values
|
|
14
|
+
switch(typeof params.locale){
|
|
15
|
+
case "boolean":
|
|
16
|
+
if(params.locale){
|
|
17
|
+
locale = this.langLocale();
|
|
18
|
+
}
|
|
19
|
+
break;
|
|
20
|
+
case "string":
|
|
21
|
+
locale = params.locale;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return String(a).toLowerCase().localeCompare(String(b).toLowerCase(), locale);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//fix empty values in position
|
|
29
|
+
if((alignEmptyValues === "top" && dir === "desc") || (alignEmptyValues === "bottom" && dir === "asc")){
|
|
30
|
+
emptyAlign *= -1;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return emptyAlign;
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import number from './sorters/number.js';
|
|
2
|
+
import string from './sorters/string.js';
|
|
3
|
+
import date from './sorters/date.js';
|
|
4
|
+
import time from './sorters/time.js';
|
|
5
|
+
import datetime from './sorters/datetime.js';
|
|
6
|
+
import boolean from './sorters/boolean.js';
|
|
7
|
+
import array from './sorters/array.js';
|
|
8
|
+
import exists from './sorters/exists.js';
|
|
9
|
+
import alphanum from './sorters/alphanum.js';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
number:number,
|
|
13
|
+
string:string,
|
|
14
|
+
date:date,
|
|
15
|
+
time:time,
|
|
16
|
+
datetime:datetime,
|
|
17
|
+
boolean:boolean,
|
|
18
|
+
array:array,
|
|
19
|
+
exists:exists,
|
|
20
|
+
alphanum:alphanum
|
|
21
|
+
};
|
|
@@ -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
|
+
}
|