tabulator-tables 5.0.10 → 5.1.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.
Files changed (100) hide show
  1. package/.editorconfig +6 -0
  2. package/LICENSE +1 -1
  3. package/bower.json +1 -1
  4. package/build/rollup.js +1 -1
  5. package/dist/css/tabulator.css +15 -6
  6. package/dist/css/tabulator.css.map +1 -1
  7. package/dist/css/tabulator.min.css +1 -1
  8. package/dist/css/tabulator.min.css.map +1 -1
  9. package/dist/css/tabulator_bootstrap3.css +15 -6
  10. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  11. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  12. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  13. package/dist/css/tabulator_bootstrap4.css +15 -6
  14. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  15. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  16. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  17. package/dist/css/tabulator_bulma.css +15 -6
  18. package/dist/css/tabulator_bulma.css.map +1 -1
  19. package/dist/css/tabulator_bulma.min.css +1 -1
  20. package/dist/css/tabulator_bulma.min.css.map +1 -1
  21. package/dist/css/tabulator_materialize.css +22 -10
  22. package/dist/css/tabulator_materialize.css.map +1 -1
  23. package/dist/css/tabulator_materialize.min.css +1 -1
  24. package/dist/css/tabulator_materialize.min.css.map +1 -1
  25. package/dist/css/tabulator_midnight.css +19 -6
  26. package/dist/css/tabulator_midnight.css.map +1 -1
  27. package/dist/css/tabulator_midnight.min.css +1 -1
  28. package/dist/css/tabulator_midnight.min.css.map +1 -1
  29. package/dist/css/tabulator_modern.css +15 -6
  30. package/dist/css/tabulator_modern.css.map +1 -1
  31. package/dist/css/tabulator_modern.min.css +1 -1
  32. package/dist/css/tabulator_modern.min.css.map +1 -1
  33. package/dist/css/tabulator_semanticui.css +15 -6
  34. package/dist/css/tabulator_semanticui.css.map +1 -1
  35. package/dist/css/tabulator_semanticui.min.css +1 -1
  36. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  37. package/dist/css/tabulator_simple.css +15 -6
  38. package/dist/css/tabulator_simple.css.map +1 -1
  39. package/dist/css/tabulator_simple.min.css +1 -1
  40. package/dist/css/tabulator_simple.min.css.map +1 -1
  41. package/dist/css/tabulator_site.css +19 -6
  42. package/dist/css/tabulator_site.css.map +1 -1
  43. package/dist/css/tabulator_site.min.css +1 -1
  44. package/dist/css/tabulator_site.min.css.map +1 -1
  45. package/dist/js/tabulator.js +853 -390
  46. package/dist/js/tabulator.js.map +1 -1
  47. package/dist/js/tabulator.min.js +2 -2
  48. package/dist/js/tabulator.min.js.map +1 -1
  49. package/dist/js/tabulator_esm.js +1106 -656
  50. package/dist/js/tabulator_esm.js.map +1 -1
  51. package/dist/js/tabulator_esm.min.js +2 -2
  52. package/dist/js/tabulator_esm.min.js.map +1 -1
  53. package/package.json +1 -1
  54. package/src/js/core/RowManager.js +7 -7
  55. package/src/js/core/Tabulator.js +0 -43
  56. package/src/js/core/cell/Cell.js +5 -1
  57. package/src/js/core/column/Column.js +19 -4
  58. package/src/js/core/column/ColumnComponent.js +4 -0
  59. package/src/js/core/column/defaults/options.js +1 -0
  60. package/src/js/core/defaults/options.js +2 -2
  61. package/src/js/core/modules/optional.js +1 -0
  62. package/src/js/core/rendering/renderers/BasicVertical.js +2 -1
  63. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +17 -8
  64. package/src/js/core/row/Row.js +2 -2
  65. package/src/js/core/tools/DataLoader.js +4 -4
  66. package/src/js/core/tools/InteractionMonitor.js +6 -2
  67. package/src/js/modules/Ajax/Ajax.js +62 -82
  68. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +1 -1
  69. package/src/js/modules/DataTree/DataTree.js +5 -0
  70. package/src/js/modules/Download/defaults/downloaders/json.js +1 -1
  71. package/src/js/modules/Download/defaults/downloaders/jsonLines.js +32 -0
  72. package/src/js/modules/Download/defaults/downloaders.js +2 -0
  73. package/src/js/modules/Edit/Edit.js +23 -31
  74. package/src/js/modules/Filter/Filter.js +1 -1
  75. package/src/js/modules/Format/defaults/formatters/datetime.js +1 -1
  76. package/src/js/modules/Format/defaults/formatters/datetimediff.js +2 -1
  77. package/src/js/modules/FrozenRows/FrozenRows.js +9 -0
  78. package/src/js/modules/GroupRows/Group.js +2 -61
  79. package/src/js/modules/GroupRows/GroupRows.js +2 -2
  80. package/src/js/modules/Import/Import.js +197 -0
  81. package/src/js/modules/Import/defaults/importers/csv.js +63 -0
  82. package/src/js/modules/Import/defaults/importers/json.js +8 -0
  83. package/src/js/modules/Import/defaults/importers.js +7 -0
  84. package/src/js/modules/Interaction/Interaction.js +5 -0
  85. package/src/js/modules/Keybindings/Keybindings.js +9 -14
  86. package/src/js/modules/Keybindings/defaults/bindings.js +3 -3
  87. package/src/js/modules/Localize/defaults/langs.js +6 -0
  88. package/src/js/modules/Menu/Menu.js +200 -155
  89. package/src/js/modules/MoveRows/MoveRows.js +4 -0
  90. package/src/js/modules/Page/Page.js +271 -173
  91. package/src/js/modules/Page/defaults/pageCounters/pages.js +33 -0
  92. package/src/js/modules/Page/defaults/pageCounters/rows.js +32 -0
  93. package/src/js/modules/Page/defaults/pageCounters.js +8 -0
  94. package/src/js/modules/ResizeRows/ResizeRows.js +1 -1
  95. package/src/js/modules/Sort/defaults/sorters/datetime.js +2 -2
  96. package/src/js/modules/Validate/Validate.js +7 -5
  97. package/src/scss/tabulator.scss +20 -6
  98. package/src/scss/themes/materialize/tabulator_materialize.scss +5 -4
  99. package/src/scss/themes/tabulator_midnight.scss +4 -0
  100. package/src/scss/themes/tabulator_site.scss +4 -0
@@ -0,0 +1,32 @@
1
+ export default function (list, options, setFileContents) {
2
+ const fileContents = [];
3
+
4
+ list.forEach((row) => {
5
+ const item = {};
6
+
7
+ switch (row.type) {
8
+ case "header":
9
+ break;
10
+
11
+ case "group":
12
+ console.warn("Download Warning - JSON downloader cannot process row groups");
13
+ break;
14
+
15
+ case "calc":
16
+ console.warn("Download Warning - JSON downloader cannot process column calculations");
17
+ break;
18
+
19
+ case "row":
20
+ row.columns.forEach((col) => {
21
+ if (col) {
22
+ item[col.component.getTitleDownload() || col.component.getField()] = col.value;
23
+ }
24
+ });
25
+
26
+ fileContents.push(JSON.stringify(item));
27
+ break;
28
+ }
29
+ });
30
+
31
+ setFileContents(fileContents.join("\n"), "application/x-ndjson");
32
+ };
@@ -3,10 +3,12 @@ import json from './downloaders/json.js';
3
3
  import pdf from './downloaders/pdf.js';
4
4
  import xlsx from './downloaders/xlsx.js';
5
5
  import html from './downloaders/html.js';
6
+ import jsonLines from './downloaders/jsonLines.js';
6
7
 
7
8
  export default {
8
9
  csv:csv,
9
10
  json:json,
11
+ jsonLines:jsonLines,
10
12
  pdf:pdf,
11
13
  xlsx:xlsx,
12
14
  html:html,
@@ -54,12 +54,12 @@ class Edit extends Module{
54
54
  this.subscribe("row-deleting", this.rowDeleteCheck.bind(this));
55
55
  this.subscribe("data-refeshing", this.cancelEdit.bind(this));
56
56
 
57
- this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this));
57
+ this.subscribe("keybinding-nav-prev", this.navigatePrev.bind(this, undefined));
58
58
  this.subscribe("keybinding-nav-next", this.keybindingNavigateNext.bind(this));
59
- this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this));
60
- this.subscribe("keybinding-nav-right", this.navigateRight.bind(this));
61
- this.subscribe("keybinding-nav-up", this.navigateUp.bind(this));
62
- this.subscribe("keybinding-nav-down", this.navigateDown.bind(this));
59
+ this.subscribe("keybinding-nav-left", this.navigateLeft.bind(this, undefined));
60
+ this.subscribe("keybinding-nav-right", this.navigateRight.bind(this, undefined));
61
+ this.subscribe("keybinding-nav-up", this.navigateUp.bind(this, undefined));
62
+ this.subscribe("keybinding-nav-down", this.navigateDown.bind(this, undefined));
63
63
  }
64
64
 
65
65
 
@@ -72,9 +72,9 @@ class Edit extends Module{
72
72
  newRow = this.options("tabEndNewRow");
73
73
 
74
74
  if(cell){
75
- if(!this.navigateNext(e)){
75
+ if(!this.navigateNext(cell, e)){
76
76
  if(newRow){
77
- cell.getElement().firstChild.blur();
77
+ // cell.getElement().firstChild.blur();
78
78
 
79
79
  if(newRow === true){
80
80
  newRow = this.table.addRow({})
@@ -88,7 +88,7 @@ class Edit extends Module{
88
88
 
89
89
  newRow.then(() => {
90
90
  setTimeout(() => {
91
- nav.next();
91
+ cell.getComponent().navigateNext();
92
92
  })
93
93
  });
94
94
  }
@@ -118,7 +118,7 @@ class Edit extends Module{
118
118
  ///////////////////////////////////
119
119
  clearCellEdited(cells){
120
120
  if(!cells){
121
- cells = this.modules.edit.getEditedCells();
121
+ cells = this.table.modules.edit.getEditedCells();
122
122
  }
123
123
 
124
124
  if(!Array.isArray(cells)){
@@ -126,13 +126,12 @@ class Edit extends Module{
126
126
  }
127
127
 
128
128
  cells.forEach((cell) => {
129
- this.modules.edit.clearEdited(cell._getSelf());
129
+ this.table.modules.edit.clearEdited(cell._getSelf());
130
130
  });
131
131
  }
132
132
 
133
- navigatePrev(e){
134
- var cell = this.currentCell,
135
- nextCell, prevRow;
133
+ navigatePrev(cell = this.currentCell, e){
134
+ var nextCell, prevRow;
136
135
 
137
136
  if(cell){
138
137
 
@@ -161,9 +160,8 @@ class Edit extends Module{
161
160
  return false;
162
161
  }
163
162
 
164
- navigateNext(e){
165
- var cell = this.currentCell,
166
- nextCell, nextRow;
163
+ navigateNext(cell = this.currentCell, e){
164
+ var nextCell, nextRow;
167
165
 
168
166
  if(cell){
169
167
 
@@ -192,9 +190,8 @@ class Edit extends Module{
192
190
  return false;
193
191
  }
194
192
 
195
- navigateLeft(e){
196
- var cell = this.currentCell,
197
- index, nextCell;
193
+ navigateLeft(cell = this.currentCell, e){
194
+ var index, nextCell;
198
195
 
199
196
  if(cell){
200
197
 
@@ -214,9 +211,8 @@ class Edit extends Module{
214
211
  return false;
215
212
  }
216
213
 
217
- navigateRight(e){
218
- var cell = this.currentCell,
219
- index, nextCell;
214
+ navigateRight(cell = this.currentCell, e){
215
+ var index, nextCell;
220
216
 
221
217
  if(cell){
222
218
 
@@ -236,9 +232,8 @@ class Edit extends Module{
236
232
  return false;
237
233
  }
238
234
 
239
- navigateUp(e){
240
- var cell = this.currentCell,
241
- index, nextRow;
235
+ navigateUp(cell = this.currentCell, e){
236
+ var index, nextRow;
242
237
 
243
238
  if(cell){
244
239
 
@@ -258,9 +253,8 @@ class Edit extends Module{
258
253
  return false;
259
254
  }
260
255
 
261
- navigateDown(e){
262
- var cell = this.currentCell,
263
- index, nextRow;
256
+ navigateDown(cell = this.currentCell, e){
257
+ var index, nextRow;
264
258
 
265
259
  if(cell){
266
260
 
@@ -405,8 +399,6 @@ class Edit extends Module{
405
399
 
406
400
  this.invalidEdit = false;
407
401
 
408
- console.log("clear", cancel, cell, cell.validate)
409
-
410
402
  if(cell){
411
403
  this.currentCell = false;
412
404
 
@@ -731,4 +723,4 @@ Edit.moduleName = "edit";
731
723
  Edit.editors = defaultEditors;
732
724
 
733
725
 
734
- export default Edit;
726
+ export default Edit;
@@ -382,7 +382,7 @@ class Filter extends Module{
382
382
 
383
383
  params = column.definition.headerFilterParams || {};
384
384
 
385
- params = typeof params === "function" ? params.call(self.table) : params;
385
+ params = typeof params === "function" ? params.call(self.table, cellWrapper) : params;
386
386
 
387
387
  editorElement = editor.call(this.table.modules.edit, cellWrapper, function(){}, success, cancel, params);
388
388
 
@@ -6,7 +6,7 @@ export default function(cell, formatterParams, onRendered){
6
6
  var value = cell.getValue();
7
7
 
8
8
  if(typeof DT != "undefined"){
9
- var newDatetime = DT.fromFormat(String(value), inputFormat);
9
+ var newDatetime = inputFormat === "iso" ? DT.fromISO(String(value)) : DT.fromFormat(String(value), inputFormat);
10
10
 
11
11
  if(newDatetime.isValid){
12
12
 
@@ -9,7 +9,8 @@ export default function (cell, formatterParams, onRendered) {
9
9
  var value = cell.getValue();
10
10
 
11
11
  if(typeof DT != "undefined"){
12
- var newDatetime = DT.fromFormat(String(value), inputFormat);
12
+
13
+ var newDatetime = inputFormat === "iso" ? DT.fromISO(String(value)) : DT.fromFormat(String(value), inputFormat);
13
14
 
14
15
  if (newDatetime.isValid){
15
16
  if(humanize){
@@ -23,6 +23,7 @@ class FrozenRows extends Module{
23
23
  this.table.columnManager.getElement().insertBefore(this.topElement, this.table.columnManager.headersElement.nextSibling);
24
24
 
25
25
  this.subscribe("row-deleting", this.detachRow.bind(this));
26
+ this.subscribe("rows-visible", this.visibleRows.bind(this));
26
27
 
27
28
  this.registerDisplayHandler(this.getRows.bind(this), 10);
28
29
  }
@@ -36,6 +37,14 @@ class FrozenRows extends Module{
36
37
  return !!this.rows.length;
37
38
  }
38
39
 
40
+ visibleRows(viewable, rows){
41
+ this.rows.forEach((row) => {
42
+ rows.push(row);
43
+ });
44
+
45
+ return rows;
46
+ }
47
+
39
48
  //filter frozen rows out of display data
40
49
  getRows(rows){
41
50
  var self = this,
@@ -18,6 +18,7 @@ class Group{
18
18
  this.groups = [];
19
19
  this.groupList = [];
20
20
  this.generator = generator;
21
+ this.element = false;
21
22
  this.elementContents = false;
22
23
  this.height = 0;
23
24
  this.outerHeight = 0;
@@ -85,67 +86,7 @@ class Group{
85
86
  }
86
87
 
87
88
  addBindings(){
88
- var dblTap, tapHold, tap, toggleElement;
89
-
90
- if ((this.groupManager.table.options.groupContextMenu || this.groupManager.table.options.groupClickMenu) && this.groupManager.table.modExists("menu")){
91
- this.groupManager.table.modules.menu.initializeGroup.call(this.groupManager.table.modules.menu, this);
92
- }
93
-
94
- if (this.groupManager.table.options.groupTap){
95
- tap = false;
96
-
97
- this.element.addEventListener("touchstart", (e) => {
98
- tap = true;
99
- }, {passive: true});
100
-
101
- this.element.addEventListener("touchend", (e) => {
102
- if(tap){
103
- this.groupManager.table.options.groupTap(e, this.getComponent());
104
- }
105
-
106
- tap = false;
107
- });
108
- }
109
-
110
- if (this.groupManager.table.options.groupDblTap){
111
- dblTap = null;
112
-
113
- this.element.addEventListener("touchend", (e) => {
114
- if(dblTap){
115
- clearTimeout(dblTap);
116
- dblTap = null;
117
-
118
- this.groupManager.table.options.groupDblTap(e, this.getComponent());
119
- }else{
120
-
121
- dblTap = setTimeout(() => {
122
- clearTimeout(dblTap);
123
- dblTap = null;
124
- }, 300);
125
- }
126
- });
127
- }
128
-
129
- if (this.groupManager.table.options.groupTapHold){
130
- tapHold = null;
131
-
132
- this.element.addEventListener("touchstart", (e) => {
133
- clearTimeout(tapHold);
134
-
135
- tapHold = setTimeout(() => {
136
- clearTimeout(tapHold);
137
- tapHold = null;
138
- tap = false;
139
- this.groupManager.table.options.groupTapHold(e, this.getComponent());
140
- }, 1000);
141
-
142
- }, {passive: true});
143
-
144
- this.element.addEventListener("touchend", (e) => {
145
- clearTimeout(tapHold);
146
- tapHold = null;
147
- });
148
- }
89
+ var toggleElement;
149
90
 
150
91
  if(this.groupManager.table.options.groupToggleElement){
151
92
  toggleElement = this.groupManager.table.options.groupToggleElement == "arrow" ? this.arrowElement : this.element;
@@ -47,13 +47,13 @@ class GroupRows extends Module{
47
47
  initialize(){
48
48
  if(this.table.options.groupBy){
49
49
 
50
- this.configureGroupSetup();
51
-
52
50
  if(this.table.options.groupUpdateOnCellEdit){
53
51
  this.subscribe("cell-value-updated", this.cellUpdated.bind(this));
54
52
  this.subscribe("row-data-changed", this.reassignRowToGroup.bind(this), 0);
55
53
  }
56
54
 
55
+ this.subscribe("table-built", this.configureGroupSetup.bind(this));
56
+
57
57
  this.subscribe("row-deleting", this.rowDeleting.bind(this));
58
58
  this.subscribe("row-deleted", this.rowsUpdated.bind(this));
59
59
  this.subscribe("scroll-horizontal", this.scrollHeaders.bind(this));
@@ -0,0 +1,197 @@
1
+ import Module from '../../core/Module.js';
2
+
3
+ import defaultImporters from './defaults/importers.js';
4
+
5
+ class Import extends Module{
6
+
7
+ constructor(table){
8
+ super(table);
9
+
10
+ this.registerTableOption("importFormat");
11
+ this.registerTableOption("importReader", "text");
12
+ }
13
+
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 typeof data === "string";
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
+
39
+ if(!importFormat){
40
+ importFormat = this.table.options.importFormat;
41
+ }
42
+
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
+
53
+ return importer;
54
+ }
55
+
56
+ importFromFile(importFormat, extension){
57
+ var importer = this.lookupImporter(importFormat);
58
+
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
+
71
+ pickFile(extensions){
72
+ return new Promise((resolve, reject) => {
73
+ var input = document.createElement("input");
74
+ input.type = "file";
75
+ input.accept = extensions;
76
+
77
+ input.addEventListener("change", (e) => {
78
+ var file = input.files[0],
79
+ reader = new FileReader(),
80
+ data;
81
+
82
+ switch(this.table.options.importReader){
83
+ case "buffer":
84
+ reader.readAsArrayBuffer(file);
85
+ break;
86
+
87
+ case "binary":
88
+ reader.readAsBinaryString(file);
89
+ break;
90
+
91
+ case "url":
92
+ reader.readAsDataURL(file);
93
+ break;
94
+
95
+ case "text":
96
+ default:
97
+ reader.readAsText(file);
98
+ }
99
+
100
+ reader.onload = (e) => {
101
+ resolve(reader.result)
102
+ };
103
+
104
+ reader.onerror = (e) => {
105
+ console.warn("File Load Error - Unable to read file");
106
+ reject();
107
+ };
108
+ });
109
+
110
+ input.click();
111
+ });
112
+ }
113
+
114
+ importData(importer, fileContents){
115
+ var data = importer.call(this.table, fileContents);
116
+
117
+ if(data instanceof Promise){
118
+ return data;
119
+ }else{
120
+ return data ? Promise.resolve(data) : Promise.reject();
121
+ }
122
+ }
123
+
124
+ structureData(parsedData){
125
+ var data = [];
126
+
127
+ console.log("structure", parsedData)
128
+
129
+ if(Array.isArray(parsedData) && parsedData.length && Array.isArray(parsedData[0])){
130
+ if(this.table.options.autoColumns){
131
+ data = this.structureArrayToObject(parsedData);
132
+ }else{
133
+ data = this.structureArrayToColumns(parsedData);
134
+ }
135
+
136
+ return data;
137
+ }else{
138
+ return parsedData;
139
+ }
140
+ }
141
+
142
+ structureArrayToObject(parsedData){
143
+ var columns = parsedData.shift();
144
+
145
+ var data = parsedData.map((values) => {
146
+ var row = {};
147
+
148
+ columns.forEach((key, i) => {
149
+ row[key] = values[i];
150
+ })
151
+
152
+ return row;
153
+ })
154
+
155
+ return data;
156
+ }
157
+
158
+ structureArrayToColumns(parsedData){
159
+ var data = [],
160
+ columns = this.table.getColumns();
161
+
162
+ //remove first row if it is the column names
163
+ if(columns[0] && parsedData[0][0]){
164
+ if(columns[0].getDefinition().title === parsedData[0][0]){
165
+ parsedData.shift();
166
+ }
167
+ }
168
+
169
+ //convert row arrays to objects
170
+ parsedData.forEach((rowData) => {
171
+ var row = {};
172
+
173
+ rowData.forEach((value, index) => {
174
+ var column = columns[index];
175
+
176
+ if(column){
177
+ row[column.getField()] = value;
178
+ }
179
+ })
180
+
181
+ data.push(row);
182
+ });
183
+
184
+ return data;
185
+ }
186
+
187
+ setData(data){
188
+ return this.table.setData(data);
189
+ }
190
+ }
191
+
192
+ Import.moduleName = "import";
193
+
194
+ //load defaults
195
+ Import.importers = defaultImporters;
196
+
197
+ export default Import;
@@ -0,0 +1,63 @@
1
+ function csvImporter(input){
2
+ var data = [],
3
+ row = 0,
4
+ col = 0,
5
+ inQuote = false;
6
+
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
+
12
+ //Initialize empty row
13
+ if(!data[row]){
14
+ data[row] = [];
15
+ }
16
+
17
+ //Initialize empty column
18
+ if(!data[row][col]){
19
+ data[row][col] = "";
20
+ }
21
+
22
+ //Handle quotation mark inside string
23
+ if (char == '"' && inQuote && nextChar == '"') {
24
+ data[row][col] += char;
25
+ index++;
26
+ continue;
27
+ }
28
+
29
+ //Begin / End Quote
30
+ if (char == '"') {
31
+ inQuote = !inQuote;
32
+ continue;
33
+ }
34
+
35
+ //Next column (if not in quote)
36
+ if (char == ',' && !inQuote) {
37
+ col++;
38
+ continue;
39
+ }
40
+
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
+
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
+
56
+ //Normal Character, append to column
57
+ data[row][col] += char;
58
+ }
59
+
60
+ return data;
61
+ }
62
+
63
+ export default csvImporter;
@@ -0,0 +1,8 @@
1
+ export default function(input){
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
+ }
@@ -0,0 +1,7 @@
1
+ import csv from './importers/csv.js';
2
+ import json from './importers/json.js';
3
+
4
+ export default {
5
+ csv:csv,
6
+ json:json,
7
+ };
@@ -84,6 +84,11 @@ class Interaction extends Module{
84
84
  tap:null,
85
85
  tapDbl:null,
86
86
  tapHold:null,
87
+ },
88
+ group:{
89
+ tap:null,
90
+ tapDbl:null,
91
+ tapHold:null,
87
92
  }
88
93
  }
89
94
 
@@ -13,7 +13,7 @@ class Keybindings extends Module{
13
13
  this.keyupBinding = false;
14
14
  this.keydownBinding = false;
15
15
 
16
- this.registerTableOption("keybindings", []); //array for keybindings
16
+ this.registerTableOption("keybindings", {}); //array for keybindings
17
17
  this.registerTableOption("tabEndNewRow", false); //create new row when tab to end of table
18
18
  }
19
19
 
@@ -25,17 +25,8 @@ class Keybindings extends Module{
25
25
  this.pressedKeys = [];
26
26
 
27
27
  if(bindings !== false){
28
-
29
- for(let key in Keybindings.bindings){
30
- mergedBindings[key] = Keybindings.bindings[key];
31
- }
32
-
33
- if(Object.keys(bindings).length){
34
-
35
- for(let key in bindings){
36
- mergedBindings[key] = bindings[key];
37
- }
38
- }
28
+ Object.assign(mergedBindings, Keybindings.bindings)
29
+ Object.assign(mergedBindings, bindings)
39
30
 
40
31
  this.mapBindings(mergedBindings);
41
32
  this.bindEvents();
@@ -53,7 +44,11 @@ class Keybindings extends Module{
53
44
  }
54
45
 
55
46
  bindings[key].forEach((binding) => {
56
- this.mapBinding(key, binding);
47
+ var bindingList = Array.isArray(binding) ? binding : [binding];
48
+
49
+ bindingList.forEach((item) => {
50
+ this.mapBinding(key, item);
51
+ });
57
52
  });
58
53
  }
59
54
  }else{
@@ -88,7 +83,7 @@ class Keybindings extends Module{
88
83
  break;
89
84
 
90
85
  default:
91
- symbol = parseInt(symbol);
86
+ symbol = isNaN(symbol) ? symbol.toUpperCase().charCodeAt(0) : parseInt(symbol);
92
87
  binding.keys.push(symbol);
93
88
 
94
89
  if(!this.watchKeys[symbol]){
@@ -7,7 +7,7 @@ export default {
7
7
  scrollPageDown:34,
8
8
  scrollToStart:36,
9
9
  scrollToEnd:35,
10
- undo:"ctrl + 90",
11
- redo:"ctrl + 89",
12
- copyToClipboard:"ctrl + 67",
10
+ undo:["ctrl + 90", "meta + 90"],
11
+ redo:["ctrl + 89", "meta + 89"],
12
+ copyToClipboard:["ctrl + 67", "meta + 89"],
13
13
  };