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,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
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import Module from '../../core/Module.js';
|
|
2
|
+
import Cell from '../../core/cell/Cell.js';
|
|
3
|
+
|
|
4
|
+
export default class Tooltip extends Module{
|
|
5
|
+
|
|
6
|
+
static moduleName = "tooltip";
|
|
7
|
+
|
|
8
|
+
constructor(table){
|
|
9
|
+
super(table);
|
|
10
|
+
|
|
11
|
+
this.tooltipSubscriber = null,
|
|
12
|
+
this.headerSubscriber = null,
|
|
13
|
+
|
|
14
|
+
this.timeout = null;
|
|
15
|
+
this.popupInstance = null;
|
|
16
|
+
|
|
17
|
+
// this.registerTableOption("tooltipGenerationMode", undefined); //deprecated
|
|
18
|
+
this.registerTableOption("tooltipDelay", 300);
|
|
19
|
+
|
|
20
|
+
this.registerColumnOption("tooltip");
|
|
21
|
+
this.registerColumnOption("headerTooltip");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
initialize(){
|
|
25
|
+
this.deprecatedOptionsCheck();
|
|
26
|
+
|
|
27
|
+
this.subscribe("column-init", this.initializeColumn.bind(this));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
deprecatedOptionsCheck(){
|
|
31
|
+
// this.deprecationCheckMsg("tooltipGenerationMode", "This option is no longer needed as tooltips are always generated on hover now");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
initializeColumn(column){
|
|
35
|
+
if(column.definition.headerTooltip && !this.headerSubscriber){
|
|
36
|
+
this.headerSubscriber = true;
|
|
37
|
+
|
|
38
|
+
this.subscribe("column-mousemove", this.mousemoveCheck.bind(this, "headerTooltip"));
|
|
39
|
+
this.subscribe("column-mouseout", this.mouseoutCheck.bind(this, "headerTooltip"));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if(column.definition.tooltip && !this.tooltipSubscriber){
|
|
43
|
+
this.tooltipSubscriber = true;
|
|
44
|
+
|
|
45
|
+
this.subscribe("cell-mousemove", this.mousemoveCheck.bind(this, "tooltip"));
|
|
46
|
+
this.subscribe("cell-mouseout", this.mouseoutCheck.bind(this, "tooltip"));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
mousemoveCheck(action, e, component){
|
|
51
|
+
var tooltip = action === "tooltip" ? component.column.definition.tooltip : component.definition.headerTooltip;
|
|
52
|
+
|
|
53
|
+
if(tooltip){
|
|
54
|
+
this.clearPopup();
|
|
55
|
+
this.timeout = setTimeout(this.loadTooltip.bind(this, e, component, tooltip), this.table.options.tooltipDelay);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
mouseoutCheck(action, e, component){
|
|
60
|
+
if(!this.popupInstance){
|
|
61
|
+
this.clearPopup();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
clearPopup(action, e, component){
|
|
66
|
+
clearTimeout(this.timeout);
|
|
67
|
+
this.timeout = null;
|
|
68
|
+
|
|
69
|
+
if(this.popupInstance){
|
|
70
|
+
this.popupInstance.hide();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
loadTooltip(e, component, tooltip){
|
|
75
|
+
var contentsEl, renderedCallback, coords;
|
|
76
|
+
|
|
77
|
+
function onRendered(callback){
|
|
78
|
+
renderedCallback = callback;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if(typeof tooltip === "function"){
|
|
82
|
+
tooltip = tooltip(e, component.getComponent(), onRendered);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if(tooltip instanceof HTMLElement){
|
|
86
|
+
contentsEl = tooltip;
|
|
87
|
+
}else{
|
|
88
|
+
contentsEl = document.createElement("div");
|
|
89
|
+
|
|
90
|
+
if(tooltip === true){
|
|
91
|
+
if(component instanceof Cell){
|
|
92
|
+
tooltip = component.value;
|
|
93
|
+
}else{
|
|
94
|
+
if(component.definition.field){
|
|
95
|
+
this.langBind("columns|" + component.definition.field, (value) => {
|
|
96
|
+
contentsEl.innerHTML = tooltip = value || component.definition.title;
|
|
97
|
+
});
|
|
98
|
+
}else{
|
|
99
|
+
tooltip = component.definition.title;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
contentsEl.innerHTML = tooltip;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if(tooltip || tooltip === 0 || tooltip === false){
|
|
108
|
+
contentsEl.classList.add("tabulator-tooltip");
|
|
109
|
+
|
|
110
|
+
contentsEl.addEventListener("mousemove", e => e.preventDefault());
|
|
111
|
+
|
|
112
|
+
this.popupInstance = this.popup(contentsEl);
|
|
113
|
+
|
|
114
|
+
if(typeof renderedCallback === "function"){
|
|
115
|
+
this.popupInstance.renderCallback(renderedCallback);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
coords = this.popupInstance.containerEventCoords(e);
|
|
119
|
+
|
|
120
|
+
this.popupInstance.show(coords.x + 15, coords.y + 15).hideOnBlur(() => {
|
|
121
|
+
this.dispatchExternal("TooltipClosed", component.getComponent());
|
|
122
|
+
this.popupInstance = null;
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
this.dispatchExternal("TooltipOpened", component.getComponent());
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|