tabulator-tables 5.2.7 → 5.3.2
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/.eslintignore +3 -0
- package/.eslintrc.js +28 -0
- package/.github/workflows/bad-files-check.yml +39 -0
- package/.github/workflows/lint-and-test.yml +31 -0
- package/README.md +3 -3
- package/bower.json +1 -1
- package/build/Bundler.js +77 -77
- package/dist/css/tabulator.css +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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 +12 -7
- 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/jquery_wrapper.js +37 -37
- package/dist/js/tabulator.js +1551 -793
- 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 +4300 -3581
- 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 +4 -1
- package/src/js/builds/jquery_wrapper.js +37 -37
- package/src/js/core/ColumnManager.js +270 -232
- package/src/js/core/CoreFeature.js +16 -2
- package/src/js/core/FooterManager.js +10 -10
- package/src/js/core/Module.js +8 -8
- package/src/js/core/RowManager.js +139 -156
- package/src/js/core/Tabulator.js +88 -74
- package/src/js/core/TabulatorFull.js +1 -1
- package/src/js/core/cell/Cell.js +15 -16
- package/src/js/core/cell/CellComponent.js +2 -2
- package/src/js/core/column/Column.js +81 -68
- package/src/js/core/column/ColumnComponent.js +4 -4
- package/src/js/core/column/defaults/options.js +1 -1
- package/src/js/core/defaults/options.js +4 -2
- package/src/js/core/rendering/Renderer.js +19 -19
- package/src/js/core/rendering/renderers/BasicHorizontal.js +1 -2
- package/src/js/core/rendering/renderers/BasicVertical.js +1 -1
- package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +42 -58
- package/src/js/core/rendering/renderers/VirtualDomVertical.js +31 -22
- package/src/js/core/row/Row.js +32 -8
- package/src/js/core/row/RowComponent.js +8 -4
- package/src/js/core/tools/Alert.js +44 -45
- package/src/js/core/tools/ComponentFunctionBinder.js +4 -2
- package/src/js/core/tools/DataLoader.js +3 -3
- package/src/js/core/tools/DeprecationAdvisor.js +47 -0
- package/src/js/core/tools/ExternalEventBus.js +5 -5
- package/src/js/core/tools/InteractionMonitor.js +41 -39
- package/src/js/core/tools/InternalEventBus.js +5 -5
- package/src/js/core/tools/ModuleBinder.js +6 -6
- package/src/js/core/tools/OptionsList.js +4 -4
- package/src/js/core/tools/Popup.js +211 -202
- package/src/js/modules/Accessor/Accessor.js +16 -16
- package/src/js/modules/Accessor/defaults/accessors.js +1 -1
- package/src/js/modules/Ajax/Ajax.js +7 -7
- package/src/js/modules/Ajax/defaults/loaderPromise.js +19 -19
- package/src/js/modules/Ajax/defaults/urlGenerator.js +1 -1
- package/src/js/modules/Clipboard/Clipboard.js +23 -23
- package/src/js/modules/Clipboard/defaults/pasteParsers.js +0 -2
- package/src/js/modules/ColumnCalcs/CalcComponent.js +2 -2
- package/src/js/modules/ColumnCalcs/ColumnCalcs.js +55 -51
- package/src/js/modules/ColumnCalcs/defaults/calculations.js +1 -1
- package/src/js/modules/DataTree/DataTree.js +24 -15
- package/src/js/modules/Download/Download.js +15 -8
- package/src/js/modules/Download/defaults/downloaders/csv.js +28 -28
- package/src/js/modules/Download/defaults/downloaders/html.js +2 -2
- package/src/js/modules/Download/defaults/downloaders/json.js +14 -14
- package/src/js/modules/Download/defaults/downloaders/jsonLines.js +1 -1
- package/src/js/modules/Download/defaults/downloaders/pdf.js +17 -19
- package/src/js/modules/Download/defaults/downloaders/xlsx.js +2 -2
- package/src/js/modules/Edit/Edit.js +219 -201
- package/src/js/modules/Edit/List.js +1026 -1006
- package/src/js/modules/Edit/defaults/editors/autocomplete.js +3 -3
- package/src/js/modules/Edit/defaults/editors/date.js +110 -0
- package/src/js/modules/Edit/defaults/editors/datetime.js +97 -0
- package/src/js/modules/Edit/defaults/editors/input.js +7 -7
- package/src/js/modules/Edit/defaults/editors/list.js +2 -2
- package/src/js/modules/Edit/defaults/editors/number.js +12 -12
- package/src/js/modules/Edit/defaults/editors/progress.js +11 -11
- package/src/js/modules/Edit/defaults/editors/range.js +5 -5
- package/src/js/modules/Edit/defaults/editors/select.js +3 -3
- package/src/js/modules/Edit/defaults/editors/star.js +9 -9
- package/src/js/modules/Edit/defaults/editors/textarea.js +97 -92
- package/src/js/modules/Edit/defaults/editors/tickCross.js +1 -3
- package/src/js/modules/Edit/defaults/editors/time.js +98 -0
- package/src/js/modules/Edit/defaults/editors.js +8 -2
- package/src/js/modules/Edit/inputMask.js +19 -26
- package/src/js/modules/Export/Export.js +69 -65
- package/src/js/modules/Filter/Filter.js +88 -95
- package/src/js/modules/Format/Format.js +24 -26
- package/src/js/modules/Format/defaults/formatters/buttonCross.js +1 -1
- package/src/js/modules/Format/defaults/formatters/buttonTick.js +1 -1
- package/src/js/modules/Format/defaults/formatters/color.js +1 -1
- package/src/js/modules/Format/defaults/formatters/datetime.js +7 -7
- package/src/js/modules/Format/defaults/formatters/datetimediff.js +7 -7
- package/src/js/modules/Format/defaults/formatters/handle.js +1 -1
- package/src/js/modules/Format/defaults/formatters/html.js +1 -1
- package/src/js/modules/Format/defaults/formatters/image.js +9 -9
- package/src/js/modules/Format/defaults/formatters/link.js +10 -10
- package/src/js/modules/Format/defaults/formatters/lookup.js +1 -1
- package/src/js/modules/Format/defaults/formatters/money.js +1 -1
- package/src/js/modules/Format/defaults/formatters/plaintext.js +1 -1
- package/src/js/modules/Format/defaults/formatters/progress.js +41 -42
- package/src/js/modules/Format/defaults/formatters/responsiveCollapse.js +3 -3
- package/src/js/modules/Format/defaults/formatters/rowSelection.js +1 -1
- package/src/js/modules/Format/defaults/formatters/rownum.js +9 -2
- package/src/js/modules/Format/defaults/formatters/star.js +1 -1
- package/src/js/modules/Format/defaults/formatters/textarea.js +1 -1
- package/src/js/modules/Format/defaults/formatters/tickCross.js +1 -1
- package/src/js/modules/Format/defaults/formatters/traffic.js +14 -14
- package/src/js/modules/FrozenColumns/FrozenColumns.js +6 -8
- package/src/js/modules/FrozenRows/FrozenRows.js +37 -7
- package/src/js/modules/GroupRows/Group.js +7 -7
- package/src/js/modules/GroupRows/GroupComponent.js +2 -2
- package/src/js/modules/GroupRows/GroupRows.js +34 -11
- package/src/js/modules/History/History.js +2 -2
- package/src/js/modules/HtmlTableImport/HtmlTableImport.js +3 -6
- package/src/js/modules/Import/Import.js +158 -159
- package/src/js/modules/Import/defaults/importers/array.js +5 -0
- package/src/js/modules/Import/defaults/importers/csv.js +49 -49
- package/src/js/modules/Import/defaults/importers/json.js +6 -6
- package/src/js/modules/Import/defaults/importers.js +2 -0
- package/src/js/modules/Interaction/Interaction.js +42 -43
- package/src/js/modules/Keybindings/Keybindings.js +14 -14
- package/src/js/modules/Keybindings/defaults/actions.js +1 -2
- package/src/js/modules/Layout/Layout.js +4 -5
- package/src/js/modules/Layout/defaults/modes/fitColumns.js +13 -16
- package/src/js/modules/Layout/defaults/modes/fitData.js +6 -4
- package/src/js/modules/Layout/defaults/modes/fitDataGeneral.js +2 -2
- package/src/js/modules/Layout/defaults/modes/fitDataStretch.js +2 -2
- package/src/js/modules/Localize/Localize.js +7 -7
- package/src/js/modules/Menu/Menu.js +8 -11
- package/src/js/modules/MoveColumns/MoveColumns.js +3 -6
- package/src/js/modules/MoveRows/MoveRows.js +30 -36
- package/src/js/modules/Mutator/Mutator.js +9 -9
- package/src/js/modules/Page/Page.js +73 -80
- package/src/js/modules/Page/defaults/pageCounters/pages.js +2 -2
- package/src/js/modules/Page/defaults/pageCounters/rows.js +1 -1
- package/src/js/modules/Persistence/Persistence.js +40 -44
- package/src/js/modules/Persistence/defaults/readers.js +1 -1
- package/src/js/modules/Popup/Popup.js +4 -5
- package/src/js/modules/Print/Print.js +2 -2
- package/src/js/modules/ReactiveData/ReactiveData.js +178 -115
- package/src/js/modules/ResizeColumns/ResizeColumns.js +3 -3
- package/src/js/modules/ResizeRows/ResizeRows.js +1 -1
- package/src/js/modules/ResizeTable/ResizeTable.js +77 -46
- package/src/js/modules/ResponsiveLayout/ResponsiveLayout.js +3 -5
- package/src/js/modules/SelectRow/SelectRow.js +26 -28
- package/src/js/modules/Sort/Sort.js +113 -85
- package/src/js/modules/Sort/defaults/sorters/alphanum.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/array.js +24 -28
- package/src/js/modules/Sort/defaults/sorters/boolean.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/date.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/datetime.js +13 -13
- package/src/js/modules/Sort/defaults/sorters/exists.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/number.js +1 -1
- package/src/js/modules/Sort/defaults/sorters/string.js +7 -7
- package/src/js/modules/Sort/defaults/sorters/time.js +1 -1
- package/src/js/modules/Tooltip/Tooltip.js +5 -7
- package/src/js/modules/Validate/Validate.js +10 -13
- package/src/js/modules/Validate/defaults/validators.js +8 -3
- package/src/scss/tabulator.scss +28 -17
- package/src/scss/themes/bootstrap/functions4.scss +1 -1
- package/src/scss/themes/bootstrap/tabulator_bootstrap3.scss +8 -8
- package/src/scss/themes/bootstrap/tabulator_bootstrap4.scss +8 -8
- package/src/scss/themes/bootstrap/tabulator_bootstrap5.scss +8 -8
- package/src/scss/themes/bulma/tabulator_bulma.scss +7 -7
- package/src/scss/themes/materialize/tabulator_materialize.scss +6 -6
- package/src/scss/themes/materialize/variables.scss +1 -1
- package/src/scss/themes/semanticui/tabulator_semanticui.scss +7 -7
- package/src/scss/themes/tabulator_midnight.scss +7 -7
- package/src/scss/themes/tabulator_modern.scss +14 -14
- package/src/scss/themes/tabulator_simple.scss +8 -8
- package/src/scss/themes/tabulator_site.scss +15 -15
|
@@ -4,187 +4,186 @@ import defaultImporters from './defaults/importers.js';
|
|
|
4
4
|
|
|
5
5
|
class Import extends Module{
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
constructor(table){
|
|
8
|
+
super(table);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
this.registerTableOption("importFormat");
|
|
11
|
+
this.registerTableOption("importReader", "text");
|
|
12
|
+
}
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
14
|
+
initialize(){
|
|
15
|
+
this.registerTableFunction("import", this.importFromFile.bind(this));
|
|
16
|
+
|
|
17
|
+
if(this.table.options.importFormat){
|
|
18
|
+
this.subscribe("data-loading", this.loadDataCheck.bind(this), 10);
|
|
19
|
+
this.subscribe("data-load", this.loadData.bind(this), 10);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
loadDataCheck(data){
|
|
24
|
+
return this.table.options.importFormat && (typeof data === "string" || (Array.isArray(data) && data.length && Array.isArray(data)));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
loadData(data, params, config, silent, previousData){
|
|
28
|
+
return this.importData(this.lookupImporter(), data)
|
|
29
|
+
.then(this.structureData.bind(this))
|
|
30
|
+
.catch((err) => {
|
|
31
|
+
console.error("Import Error:", err || "Unable to import data");
|
|
32
|
+
return Promise.reject(err);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
lookupImporter(importFormat){
|
|
37
|
+
var importer;
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if(!importFormat){
|
|
40
|
+
importFormat = this.table.options.importFormat;
|
|
41
|
+
}
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
if(typeof importFormat === "string"){
|
|
44
|
+
importer = Import.importers[importFormat];
|
|
45
|
+
}else{
|
|
46
|
+
importer = importFormat;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if(!importer){
|
|
50
|
+
console.error("Import Error - Importer not found:", importFormat);
|
|
51
|
+
}
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
return importer;
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
importFromFile(importFormat, extension){
|
|
57
|
+
var importer = this.lookupImporter(importFormat);
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
59
|
+
if(importer){
|
|
60
|
+
return this.pickFile(extension)
|
|
61
|
+
.then(this.importData.bind(this, importer))
|
|
62
|
+
.then(this.structureData.bind(this))
|
|
63
|
+
.then(this.setData.bind(this))
|
|
64
|
+
.catch((err) => {
|
|
65
|
+
console.error("Import Error:", err || "Unable to import file");
|
|
66
|
+
return Promise.reject(err);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
pickFile(extensions){
|
|
72
|
+
return new Promise((resolve, reject) => {
|
|
73
|
+
var input = document.createElement("input");
|
|
74
|
+
input.type = "file";
|
|
75
|
+
input.accept = extensions;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
data;
|
|
77
|
+
input.addEventListener("change", (e) => {
|
|
78
|
+
var file = input.files[0],
|
|
79
|
+
reader = new FileReader();
|
|
81
80
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
switch(this.table.options.importReader){
|
|
82
|
+
case "buffer":
|
|
83
|
+
reader.readAsArrayBuffer(file);
|
|
84
|
+
break;
|
|
85
|
+
|
|
86
|
+
case "binary":
|
|
87
|
+
reader.readAsBinaryString(file);
|
|
88
|
+
break;
|
|
89
|
+
|
|
90
|
+
case "url":
|
|
91
|
+
reader.readAsDataURL(file);
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
case "text":
|
|
95
|
+
default:
|
|
96
|
+
reader.readAsText(file);
|
|
97
|
+
}
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
reader.onload = (e) => {
|
|
100
|
+
resolve(reader.result);
|
|
101
|
+
};
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
reader.onerror = (e) => {
|
|
104
|
+
console.warn("File Load Error - Unable to read file");
|
|
105
|
+
reject();
|
|
106
|
+
};
|
|
107
|
+
});
|
|
109
108
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
109
|
+
input.click();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
113
112
|
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
importData(importer, fileContents){
|
|
114
|
+
var data = importer.call(this.table, fileContents);
|
|
116
115
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
116
|
+
if(data instanceof Promise){
|
|
117
|
+
return data;
|
|
118
|
+
}else{
|
|
119
|
+
return data ? Promise.resolve(data) : Promise.reject();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
structureData(parsedData){
|
|
124
|
+
var data = [];
|
|
126
125
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
126
|
+
if(Array.isArray(parsedData) && parsedData.length && Array.isArray(parsedData[0])){
|
|
127
|
+
if(this.table.options.autoColumns){
|
|
128
|
+
data = this.structureArrayToObject(parsedData);
|
|
129
|
+
}else{
|
|
130
|
+
data = this.structureArrayToColumns(parsedData);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return data;
|
|
134
|
+
}else{
|
|
135
|
+
return parsedData;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
structureArrayToObject(parsedData){
|
|
140
|
+
var columns = parsedData.shift();
|
|
141
|
+
|
|
142
|
+
var data = parsedData.map((values) => {
|
|
143
|
+
var row = {};
|
|
144
|
+
|
|
145
|
+
columns.forEach((key, i) => {
|
|
146
|
+
row[key] = values[i];
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return row;
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return data;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
structureArrayToColumns(parsedData){
|
|
156
|
+
var data = [],
|
|
157
|
+
columns = this.table.getColumns();
|
|
158
|
+
|
|
159
|
+
//remove first row if it is the column names
|
|
160
|
+
if(columns[0] && parsedData[0][0]){
|
|
161
|
+
if(columns[0].getDefinition().title === parsedData[0][0]){
|
|
162
|
+
parsedData.shift();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
166
165
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
//convert row arrays to objects
|
|
167
|
+
parsedData.forEach((rowData) => {
|
|
168
|
+
var row = {};
|
|
170
169
|
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
rowData.forEach((value, index) => {
|
|
171
|
+
var column = columns[index];
|
|
173
172
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
if(column){
|
|
174
|
+
row[column.getField()] = value;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
178
177
|
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
data.push(row);
|
|
179
|
+
});
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
return data;
|
|
182
|
+
}
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
setData(data){
|
|
185
|
+
return this.table.setData(data);
|
|
186
|
+
}
|
|
188
187
|
}
|
|
189
188
|
|
|
190
189
|
Import.moduleName = "import";
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
function csvImporter(input){
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var data = [],
|
|
3
|
+
row = 0,
|
|
4
|
+
col = 0,
|
|
5
|
+
inQuote = false;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
//Iterate over each character
|
|
8
|
+
for (let index = 0; index < input.length; index++) {
|
|
9
|
+
let char = input[index],
|
|
10
|
+
nextChar = input[index+1];
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
//Initialize empty row
|
|
13
|
+
if(!data[row]){
|
|
14
|
+
data[row] = [];
|
|
15
|
+
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
//Initialize empty column
|
|
18
|
+
if(!data[row][col]){
|
|
19
|
+
data[row][col] = "";
|
|
20
|
+
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
//Handle quotation mark inside string
|
|
23
|
+
if (char == '"' && inQuote && nextChar == '"') {
|
|
24
|
+
data[row][col] += char;
|
|
25
|
+
index++;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
//Begin / End Quote
|
|
30
|
+
if (char == '"') {
|
|
31
|
+
inQuote = !inQuote;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
//Next column (if not in quote)
|
|
36
|
+
if (char == ',' && !inQuote) {
|
|
37
|
+
col++;
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
//New row if new line and not in quote (CRLF)
|
|
42
|
+
if (char == '\r' && nextChar == '\n' && !inQuote) {
|
|
43
|
+
col = 0;
|
|
44
|
+
row++;
|
|
45
|
+
index++;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
49
|
+
//New row if new line and not in quote (CR or LF)
|
|
50
|
+
if ((char == '\r' || char == '\n') && !inQuote) {
|
|
51
|
+
col = 0;
|
|
52
|
+
row++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
//Normal Character, append to column
|
|
57
|
+
data[row][col] += char;
|
|
58
|
+
}
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
return data;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export default csvImporter;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default function(input){
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
try {
|
|
3
|
+
return JSON.parse(input);
|
|
4
|
+
} catch(e) {
|
|
5
|
+
console.warn("JSON Import Error - File contents is invalid JSON", e);
|
|
6
|
+
return Promise.reject();
|
|
7
|
+
}
|
|
8
8
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Module from '../../core/Module.js';
|
|
2
|
-
import Helpers from '../../core/tools/Helpers.js';
|
|
3
2
|
|
|
4
3
|
import Cell from '../../core/cell/Cell.js';
|
|
5
4
|
import Column from '../../core/column/Column.js';
|
|
@@ -61,7 +60,7 @@ class Interaction extends Module{
|
|
|
61
60
|
groupTap:"group",
|
|
62
61
|
groupDblTap:"group",
|
|
63
62
|
groupTapHold:"group",
|
|
64
|
-
}
|
|
63
|
+
};
|
|
65
64
|
|
|
66
65
|
this.subscribers = {};
|
|
67
66
|
|
|
@@ -90,7 +89,7 @@ class Interaction extends Module{
|
|
|
90
89
|
tapDbl:null,
|
|
91
90
|
tapHold:null,
|
|
92
91
|
}
|
|
93
|
-
}
|
|
92
|
+
};
|
|
94
93
|
|
|
95
94
|
this.registerColumnOption("headerClick");
|
|
96
95
|
this.registerColumnOption("headerDblClick");
|
|
@@ -121,13 +120,15 @@ class Interaction extends Module{
|
|
|
121
120
|
initialize(){
|
|
122
121
|
this.initializeExternalEvents();
|
|
123
122
|
|
|
124
|
-
this.subscribe("column-init", this.initializeColumn.bind(this))
|
|
125
|
-
this.subscribe("cell-dblclick", this.cellContentsSelectionFixer.bind(this))
|
|
123
|
+
this.subscribe("column-init", this.initializeColumn.bind(this));
|
|
124
|
+
this.subscribe("cell-dblclick", this.cellContentsSelectionFixer.bind(this));
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
cellContentsSelectionFixer(e, cell){
|
|
128
|
+
var range;
|
|
129
|
+
|
|
129
130
|
if(this.table.modExists("edit")){
|
|
130
|
-
if (this.table.modules.edit.currentCell ===
|
|
131
|
+
if (this.table.modules.edit.currentCell === cell){
|
|
131
132
|
return; //prevent instant selection of editor content
|
|
132
133
|
}
|
|
133
134
|
}
|
|
@@ -136,12 +137,12 @@ class Interaction extends Module{
|
|
|
136
137
|
|
|
137
138
|
try{
|
|
138
139
|
if (document.selection) { // IE
|
|
139
|
-
|
|
140
|
-
range.moveToElementText(
|
|
140
|
+
range = document.body.createTextRange();
|
|
141
|
+
range.moveToElementText(cell.getElement());
|
|
141
142
|
range.select();
|
|
142
143
|
} else if (window.getSelection) {
|
|
143
|
-
|
|
144
|
-
range.selectNode(
|
|
144
|
+
range = document.createRange();
|
|
145
|
+
range.selectNode(cell.getElement());
|
|
145
146
|
window.getSelection().removeAllRanges();
|
|
146
147
|
window.getSelection().addRange(range);
|
|
147
148
|
}
|
|
@@ -150,13 +151,11 @@ class Interaction extends Module{
|
|
|
150
151
|
|
|
151
152
|
initializeExternalEvents(){
|
|
152
153
|
for(let key in this.eventMap){
|
|
153
|
-
this.subscriptionChangeExternal(key, this.subscriptionChanged.bind(this, key))
|
|
154
|
+
this.subscriptionChangeExternal(key, this.subscriptionChanged.bind(this, key));
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
157
|
|
|
157
158
|
subscriptionChanged(key, added){
|
|
158
|
-
var index;
|
|
159
|
-
|
|
160
159
|
if(added){
|
|
161
160
|
if(!this.subscribers[key]){
|
|
162
161
|
if(this.eventMap[key].includes("-")){
|
|
@@ -194,7 +193,7 @@ class Interaction extends Module{
|
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
unsubscribeTouchEvents(key){
|
|
197
|
-
var
|
|
196
|
+
var noTouch = true,
|
|
198
197
|
type = this.eventMap[key];
|
|
199
198
|
|
|
200
199
|
if(this.subscribers[key] && !this.subscribedExternal(key)){
|
|
@@ -203,12 +202,12 @@ class Interaction extends Module{
|
|
|
203
202
|
for(let i in this.eventMap){
|
|
204
203
|
if(this.eventMap[i] === type){
|
|
205
204
|
if(this.subscribers[i]){
|
|
206
|
-
|
|
205
|
+
noTouch = false;
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
208
|
}
|
|
210
209
|
|
|
211
|
-
if(
|
|
210
|
+
if(noTouch){
|
|
212
211
|
this.unsubscribe(type + "-touchstart", this.touchSubscribers[type + "-touchstart"]);
|
|
213
212
|
this.unsubscribe(type + "-touchend", this.touchSubscribers[type + "-touchend"]);
|
|
214
213
|
|
|
@@ -247,44 +246,44 @@ class Interaction extends Module{
|
|
|
247
246
|
|
|
248
247
|
switch(action){
|
|
249
248
|
case "start":
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
clearTimeout(watchers.tapHold);
|
|
249
|
+
watchers.tap = true;
|
|
253
250
|
|
|
254
|
-
watchers.tapHold = setTimeout(() => {
|
|
255
251
|
clearTimeout(watchers.tapHold);
|
|
256
|
-
watchers.tapHold = null;
|
|
257
252
|
|
|
258
|
-
watchers.
|
|
259
|
-
|
|
260
|
-
|
|
253
|
+
watchers.tapHold = setTimeout(() => {
|
|
254
|
+
clearTimeout(watchers.tapHold);
|
|
255
|
+
watchers.tapHold = null;
|
|
261
256
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
257
|
+
watchers.tap = null;
|
|
258
|
+
clearTimeout(watchers.tapDbl);
|
|
259
|
+
watchers.tapDbl = null;
|
|
265
260
|
|
|
266
|
-
|
|
267
|
-
|
|
261
|
+
this.dispatchEvent(type + "TapHold", e, component);
|
|
262
|
+
}, 1000);
|
|
263
|
+
break;
|
|
268
264
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
265
|
+
case "end":
|
|
266
|
+
if(watchers.tap){
|
|
272
267
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
268
|
+
watchers.tap = null;
|
|
269
|
+
this.dispatchEvent(type + "Tap", e, component);
|
|
270
|
+
}
|
|
276
271
|
|
|
277
|
-
|
|
278
|
-
}else{
|
|
279
|
-
watchers.tapDbl = setTimeout(() => {
|
|
272
|
+
if(watchers.tapDbl){
|
|
280
273
|
clearTimeout(watchers.tapDbl);
|
|
281
274
|
watchers.tapDbl = null;
|
|
282
|
-
}, 300);
|
|
283
|
-
}
|
|
284
275
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
276
|
+
this.dispatchEvent(type + "DblTap", e, component);
|
|
277
|
+
}else{
|
|
278
|
+
watchers.tapDbl = setTimeout(() => {
|
|
279
|
+
clearTimeout(watchers.tapDbl);
|
|
280
|
+
watchers.tapDbl = null;
|
|
281
|
+
}, 300);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
clearTimeout(watchers.tapHold);
|
|
285
|
+
watchers.tapHold = null;
|
|
286
|
+
break;
|
|
288
287
|
}
|
|
289
288
|
}
|
|
290
289
|
|