tabulator-tables 5.5.4 → 5.6.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 (99) hide show
  1. package/bower.json +1 -1
  2. package/dist/css/tabulator.css +72 -2
  3. package/dist/css/tabulator.css.map +1 -1
  4. package/dist/css/tabulator.min.css +1 -1
  5. package/dist/css/tabulator.min.css.map +1 -1
  6. package/dist/css/tabulator_bootstrap3.css +72 -2
  7. package/dist/css/tabulator_bootstrap3.css.map +1 -1
  8. package/dist/css/tabulator_bootstrap3.min.css +1 -1
  9. package/dist/css/tabulator_bootstrap3.min.css.map +1 -1
  10. package/dist/css/tabulator_bootstrap4.css +72 -2
  11. package/dist/css/tabulator_bootstrap4.css.map +1 -1
  12. package/dist/css/tabulator_bootstrap4.min.css +1 -1
  13. package/dist/css/tabulator_bootstrap4.min.css.map +1 -1
  14. package/dist/css/tabulator_bootstrap5.css +72 -2
  15. package/dist/css/tabulator_bootstrap5.css.map +1 -1
  16. package/dist/css/tabulator_bootstrap5.min.css +1 -1
  17. package/dist/css/tabulator_bootstrap5.min.css.map +1 -1
  18. package/dist/css/tabulator_bulma.css +72 -2
  19. package/dist/css/tabulator_bulma.css.map +1 -1
  20. package/dist/css/tabulator_bulma.min.css +1 -1
  21. package/dist/css/tabulator_bulma.min.css.map +1 -1
  22. package/dist/css/tabulator_materialize.css +72 -2
  23. package/dist/css/tabulator_materialize.css.map +1 -1
  24. package/dist/css/tabulator_materialize.min.css +1 -1
  25. package/dist/css/tabulator_materialize.min.css.map +1 -1
  26. package/dist/css/tabulator_midnight.css +72 -2
  27. package/dist/css/tabulator_midnight.css.map +1 -1
  28. package/dist/css/tabulator_midnight.min.css +1 -1
  29. package/dist/css/tabulator_midnight.min.css.map +1 -1
  30. package/dist/css/tabulator_modern.css +72 -2
  31. package/dist/css/tabulator_modern.css.map +1 -1
  32. package/dist/css/tabulator_modern.min.css +1 -1
  33. package/dist/css/tabulator_modern.min.css.map +1 -1
  34. package/dist/css/tabulator_semanticui.css +72 -2
  35. package/dist/css/tabulator_semanticui.css.map +1 -1
  36. package/dist/css/tabulator_semanticui.min.css +1 -1
  37. package/dist/css/tabulator_semanticui.min.css.map +1 -1
  38. package/dist/css/tabulator_simple.css +72 -2
  39. package/dist/css/tabulator_simple.css.map +1 -1
  40. package/dist/css/tabulator_simple.min.css +1 -1
  41. package/dist/css/tabulator_simple.min.css.map +1 -1
  42. package/dist/css/tabulator_site.css +74 -4
  43. package/dist/css/tabulator_site.css.map +1 -1
  44. package/dist/css/tabulator_site.min.css +1 -1
  45. package/dist/css/tabulator_site.min.css.map +1 -1
  46. package/dist/js/tabulator.js +1830 -244
  47. package/dist/js/tabulator.js.map +1 -1
  48. package/dist/js/tabulator.min.js +2 -2
  49. package/dist/js/tabulator.min.js.map +1 -1
  50. package/dist/js/tabulator_esm.js +1900 -312
  51. package/dist/js/tabulator_esm.js.map +1 -1
  52. package/dist/js/tabulator_esm.min.js +2 -2
  53. package/dist/js/tabulator_esm.min.js.map +1 -1
  54. package/package.json +2 -2
  55. package/src/js/core/ColumnManager.js +4 -0
  56. package/src/js/core/CoreFeature.js +2 -2
  57. package/src/js/core/RowManager.js +9 -1
  58. package/src/js/core/Tabulator.js +1 -0
  59. package/src/js/core/TabulatorFull.js +1 -1
  60. package/src/js/core/column/Column.js +6 -0
  61. package/src/js/core/modules/optional.js +2 -1
  62. package/src/js/core/rendering/renderers/BasicVertical.js +4 -2
  63. package/src/js/core/rendering/renderers/VirtualDomHorizontal.js +1 -1
  64. package/src/js/core/row/PseudoRow.js +2 -0
  65. package/src/js/core/tools/Alert.js +4 -0
  66. package/src/js/core/tools/DeprecationAdvisor.js +5 -1
  67. package/src/js/core/tools/Helpers.js +1 -1
  68. package/src/js/core/tools/InteractionMonitor.js +3 -3
  69. package/src/js/modules/Clipboard/Clipboard.js +5 -3
  70. package/src/js/modules/Clipboard/defaults/pasteActions.js +49 -6
  71. package/src/js/modules/Clipboard/defaults/pasteParsers.js +69 -14
  72. package/src/js/modules/ColumnCalcs/ColumnCalcs.js +7 -1
  73. package/src/js/modules/Edit/Edit.js +55 -19
  74. package/src/js/modules/Export/Export.js +38 -18
  75. package/src/js/modules/Format/defaults/formatters/rowSelection.js +2 -2
  76. package/src/js/modules/Format/defaults/formatters/rownum.js +5 -1
  77. package/src/js/modules/FrozenColumns/FrozenColumns.js +10 -11
  78. package/src/js/modules/FrozenRows/FrozenRows.js +6 -1
  79. package/src/js/modules/History/History.js +2 -2
  80. package/src/js/modules/History/defaults/redoers.js +4 -0
  81. package/src/js/modules/History/defaults/undoers.js +4 -0
  82. package/src/js/modules/Keybindings/defaults/actions.js +38 -1
  83. package/src/js/modules/Keybindings/defaults/bindings.js +16 -1
  84. package/src/js/modules/Menu/Menu.js +3 -1
  85. package/src/js/modules/MoveColumns/MoveColumns.js +5 -0
  86. package/src/js/modules/Popup/Popup.js +1 -1
  87. package/src/js/modules/ResizeTable/ResizeTable.js +3 -3
  88. package/src/js/modules/SelectRange/Range.js +347 -0
  89. package/src/js/modules/SelectRange/RangeComponent.js +93 -0
  90. package/src/js/modules/SelectRange/SelectRange.js +855 -0
  91. package/src/js/modules/SelectRow/SelectRow.js +46 -26
  92. package/src/js/modules/Sort/Sort.js +111 -105
  93. package/src/js/modules/Validate/defaults/validators.js +11 -0
  94. package/src/scss/tabulator.scss +95 -13
  95. package/src/scss/themes/bulma/tabulator_bulma.scss +7 -0
  96. package/src/scss/themes/materialize/tabulator_materialize.scss +7 -1
  97. package/src/scss/themes/tabulator_midnight.scss +13 -0
  98. package/src/scss/themes/tabulator_modern.scss +9 -0
  99. package/src/scss/themes/tabulator_site.scss +13 -2
@@ -0,0 +1,347 @@
1
+ import CoreFeature from '../../core/CoreFeature.js';
2
+ import RangeComponent from "./RangeComponent";
3
+
4
+ class Range extends CoreFeature{
5
+ constructor(table, rangeManager, start, end) {
6
+ super(table);
7
+
8
+ this.rangeManager = rangeManager;
9
+ this.element = null;
10
+ this.initialized = false;
11
+ this.initializing = {
12
+ start:false,
13
+ end:false,
14
+ };
15
+ this.destroyed = false;
16
+
17
+ this.top = 0;
18
+ this.bottom = 0;
19
+ this.left = 0;
20
+ this.right = 0;
21
+
22
+ this.table = table;
23
+ this.start = {row:0, col:0};
24
+ this.end = {row:0, col:0};
25
+
26
+ this.initElement();
27
+
28
+ setTimeout(() => {
29
+ this.initBounds(start, end);
30
+ });
31
+ }
32
+
33
+ initElement(){
34
+ this.element = document.createElement("div");
35
+ this.element.classList.add("tabulator-range");
36
+ }
37
+
38
+ initBounds(start, end){
39
+ this._updateMinMax();
40
+
41
+ if(start){
42
+ this.setBounds(start, end || start);
43
+ }
44
+ }
45
+
46
+ ///////////////////////////////////
47
+ /////// Boundary Setup ///////
48
+ ///////////////////////////////////
49
+
50
+ setStart(row, col) {
51
+ if(this.start.row !== row || this.start.col !== col){
52
+ this.start.row = row;
53
+ this.start.col = col;
54
+
55
+ this.initializing.start = true;
56
+ this._updateMinMax();
57
+ }
58
+ }
59
+
60
+ setEnd(row, col) {
61
+ if(this.end.row !== row || this.end.col !== col){
62
+ this.end.row = row;
63
+ this.end.col = col;
64
+
65
+ this.initializing.end = true;
66
+ this._updateMinMax();
67
+ }
68
+ }
69
+
70
+ setBounds(start, end, visibleRows){
71
+ if(start){
72
+ this.setStartBound(start);
73
+ }
74
+
75
+ this.setEndBound(end || start);
76
+ this.rangeManager.layoutElement(visibleRows);
77
+ }
78
+
79
+ setStartBound(element){
80
+ var row, col;
81
+
82
+ if (element.type === "column") {
83
+ if(this.rangeManager.columnSelection){
84
+ this.setStart(0, element.getPosition() - 2);
85
+ }
86
+ }else{
87
+ row = element.row.position - 1;
88
+ col = element.column.getPosition() - 2;
89
+
90
+ if (element.column === this.rangeManager.rowHeader) {
91
+ this.setStart(row, 0);
92
+ } else {
93
+ this.setStart(row, col);
94
+ }
95
+ }
96
+ }
97
+
98
+ setEndBound(element){
99
+ var rowsCount = this._getTableRows().length,
100
+ row, col, isRowHeader;
101
+
102
+ if (element.type === "column") {
103
+ if(this.rangeManager.columnSelection){
104
+ if (this.rangeManager.selecting === "column") {
105
+ this.setEnd(rowsCount - 1, element.getPosition() - 2);
106
+ } else if (this.rangeManager.selecting === "cell") {
107
+ this.setEnd(0, element.getPosition() - 2);
108
+ }
109
+ }
110
+ }else{
111
+ row = element.row.position - 1;
112
+ col = element.column.getPosition() - 2;
113
+ isRowHeader = element.column === this.rangeManager.rowHeader;
114
+
115
+ if (this.rangeManager.selecting === "row") {
116
+ this.setEnd(row, this._getTableColumns().length - 2);
117
+ } else if (this.rangeManager.selecting !== "row" && isRowHeader) {
118
+ this.setEnd(row, 0);
119
+ } else if (this.rangeManager.selecting === "column") {
120
+ this.setEnd(rowsCount - 1, col);
121
+ } else {
122
+ this.setEnd(row, col);
123
+ }
124
+ }
125
+ }
126
+
127
+ _updateMinMax() {
128
+ this.top = Math.min(this.start.row, this.end.row);
129
+ this.bottom = Math.max(this.start.row, this.end.row);
130
+ this.left = Math.min(this.start.col, this.end.col);
131
+ this.right = Math.max(this.start.col, this.end.col);
132
+
133
+ if(this.initialized){
134
+ this.dispatchExternal("rangeChanged", this.getComponent());
135
+ }else{
136
+ if(this.initializing.start && this.initializing.end){
137
+ this.initialized = true;
138
+ this.dispatchExternal("rangeAdded", this.getComponent());
139
+ }
140
+ }
141
+ }
142
+
143
+ _getTableColumns() {
144
+ return this.table.columnManager.getVisibleColumnsByIndex();
145
+ }
146
+
147
+ _getTableRows() {
148
+ return this.table.rowManager.getDisplayRows();
149
+ }
150
+
151
+ ///////////////////////////////////
152
+ /////// Rendering ///////
153
+ ///////////////////////////////////
154
+
155
+ layout() {
156
+ var _vDomTop = this.table.rowManager.renderer.vDomTop,
157
+ _vDomBottom = this.table.rowManager.renderer.vDomBottom,
158
+ _vDomLeft = this.table.columnManager.renderer.leftCol,
159
+ _vDomRight = this.table.columnManager.renderer.rightCol,
160
+ top, bottom, left, right, topLeftCell, bottomRightCell;
161
+
162
+ if (_vDomTop == null) {
163
+ _vDomTop = 0;
164
+ }
165
+
166
+ if (_vDomBottom == null) {
167
+ _vDomBottom = Infinity;
168
+ }
169
+
170
+ if (_vDomLeft == null) {
171
+ _vDomLeft = 0;
172
+ }
173
+
174
+ if (_vDomRight == null) {
175
+ _vDomRight = Infinity;
176
+ }
177
+
178
+ if (this.overlaps(_vDomLeft, _vDomTop, _vDomRight, _vDomBottom)) {
179
+ top = Math.max(this.top, _vDomTop);
180
+ bottom = Math.min(this.bottom, _vDomBottom);
181
+ left = Math.max(this.left, _vDomLeft);
182
+ right = Math.min(this.right, _vDomRight);
183
+
184
+ topLeftCell = this.rangeManager.getCell(top, left);
185
+ bottomRightCell = this.rangeManager.getCell(bottom, right);
186
+
187
+ this.element.classList.add("tabulator-range-active");
188
+ // this.element.classList.toggle("tabulator-range-active", this === this.rangeManager.activeRange);
189
+
190
+ this.element.style.left = topLeftCell.row.getElement().offsetLeft + topLeftCell.getElement().offsetLeft + "px";
191
+ this.element.style.top = topLeftCell.row.getElement().offsetTop + "px";
192
+ this.element.style.width = bottomRightCell.getElement().offsetLeft + bottomRightCell.getElement().offsetWidth - topLeftCell.getElement().offsetLeft + "px";
193
+ this.element.style.height = bottomRightCell.row.getElement().offsetTop + bottomRightCell.row.getElement().offsetHeight - topLeftCell.row.getElement().offsetTop + "px";
194
+ }
195
+ }
196
+
197
+ atTopLeft(cell) {
198
+ return cell.row.position - 1 === this.top && cell.column.getPosition() - 2 === this.left;
199
+ }
200
+
201
+ atBottomRight(cell) {
202
+ return cell.row.position - 1 === this.bottom && cell.column.getPosition() - 2 === this.right;
203
+ }
204
+
205
+ occupies(cell) {
206
+ return this.occupiesRow(cell.row) && this.occupiesColumn(cell.column);
207
+ }
208
+
209
+ occupiesRow(row) {
210
+ return this.top <= row.position - 1 && row.position - 1 <= this.bottom;
211
+ }
212
+
213
+ occupiesColumn(col) {
214
+ return this.left <= col.getPosition() - 2 && col.getPosition() - 2 <= this.right;
215
+ }
216
+
217
+ overlaps(left, top, right, bottom) {
218
+ if ((this.left > right || left > this.right) || (this.top > bottom || top > this.bottom)){
219
+ return false;
220
+ }
221
+
222
+ return true;
223
+ }
224
+
225
+ getData() {
226
+ var data = [],
227
+ rows = this.getRows(),
228
+ columns = this.getColumns();
229
+
230
+ rows.forEach((row) => {
231
+ var rowData = row.getData(),
232
+ result = {};
233
+
234
+ columns.forEach((column) => {
235
+ result[column.field] = rowData[column.field];
236
+ });
237
+
238
+ data.push(result);
239
+ });
240
+
241
+ return data;
242
+ }
243
+
244
+ getCells(structured, component) {
245
+ var cells = [],
246
+ rows = this.getRows(),
247
+ columns = this.getColumns();
248
+
249
+ if (structured) {
250
+ cells = rows.map((row) => {
251
+ var arr = [];
252
+
253
+ row.getCells().forEach((cell) => {
254
+ if (columns.includes(cell.column)) {
255
+ arr.push(component ? cell.getComponent() : cell);
256
+ }
257
+ });
258
+
259
+ return arr;
260
+ });
261
+ } else {
262
+ rows.forEach((row) => {
263
+ row.getCells().forEach((cell) => {
264
+ if (columns.includes(cell.column)) {
265
+ cells.push(component ? cell.getComponent() : cell);
266
+ }
267
+ });
268
+ });
269
+ }
270
+
271
+ return cells;
272
+ }
273
+
274
+ getStructuredCells() {
275
+ return this.getCells(true, true);
276
+ }
277
+
278
+ getRows() {
279
+ return this._getTableRows().slice(this.top, this.bottom + 1);
280
+ }
281
+
282
+ getColumns() {
283
+ return this._getTableColumns().slice(this.left + 1, this.right + 2);
284
+ }
285
+
286
+ clearValues(){
287
+ var cells = this.getCells();
288
+ var clearValue = this.table.options.selectableRangeClearCellsValue;
289
+
290
+ this.table.blockRedraw();
291
+
292
+ cells.forEach((cell) => {
293
+ cell.setValue(clearValue);
294
+ });
295
+
296
+ this.table.restoreRedraw();
297
+
298
+ }
299
+
300
+ getBounds(component){
301
+ var cells = this.getCells(false, component),
302
+ output = {
303
+ start:null,
304
+ end:null,
305
+ };
306
+
307
+ if(cells.length){
308
+ output.start = cells[0];
309
+ output.end = cells[cells.length - 1];
310
+ }else{
311
+ console.warn("No bounds defined on range");
312
+ }
313
+
314
+ return output;
315
+ }
316
+
317
+ getComponent() {
318
+ if (!this.component) {
319
+ this.component = new RangeComponent(this);
320
+ }
321
+ return this.component;
322
+ }
323
+
324
+ destroy(notify) {
325
+ this.destroyed = true;
326
+
327
+ this.element.remove();
328
+
329
+ if(notify){
330
+ this.rangeManager.rangeRemoved(this);
331
+ }
332
+
333
+ if(this.initialized){
334
+ this.dispatchExternal("rangeRemoved", this.getComponent());
335
+ }
336
+ }
337
+
338
+ destroyedGuard(func){
339
+ if(this.destroyed){
340
+ console.warn("You cannot call the " + func + " function on a destroyed range");
341
+ }
342
+
343
+ return !this.destroyed;
344
+ }
345
+ }
346
+
347
+ export default Range;
@@ -0,0 +1,93 @@
1
+ class RangeComponent {
2
+ constructor(range) {
3
+ this._range = range;
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._range.table.componentFunctionBinder.handle("range", target._range, name);
11
+ }
12
+ },
13
+ });
14
+ }
15
+
16
+ getElement() {
17
+ return this._range.element;
18
+ }
19
+
20
+ getData() {
21
+ return this._range.getData();
22
+ }
23
+
24
+ getCells() {
25
+ return this._range.getCells(true);
26
+ }
27
+
28
+ getStructuredCells() {
29
+ return this._range.getStructuredCells();
30
+ }
31
+
32
+ getRows() {
33
+ return this._range.getRows().map((row) => row.getComponent());
34
+ }
35
+
36
+ getColumns() {
37
+ return this._range.getColumns().map((column) => column.getComponent());
38
+ }
39
+
40
+ getBounds() {
41
+ return this._range.getBounds();
42
+ }
43
+
44
+ getTopEdge() {
45
+ return this._range.top;
46
+ }
47
+
48
+ getBottomEdge() {
49
+ return this._range.bottom;
50
+ }
51
+
52
+ getLeftEdge() {
53
+ return this._range.left;
54
+ }
55
+
56
+ getRightEdge() {
57
+ return this._range.right;
58
+ }
59
+
60
+ setBounds(start, end){
61
+ if(this._range.destroyedGuard("setBounds")){
62
+ this._range.setBounds(start ? start._cell : start, end ? end._cell : end);
63
+ }
64
+ }
65
+
66
+ setStartBound(start){
67
+ if(this._range.destroyedGuard("setStartBound")){
68
+ this._range.setEndBound(start ? start._cell : start);
69
+ this._range.rangeManager.layoutElement();
70
+ }
71
+ }
72
+
73
+ setEndBound(end){
74
+ if(this._range.destroyedGuard("setEndBound")){
75
+ this._range.setEndBound(end ? end._cell : end);
76
+ this._range.rangeManager.layoutElement();
77
+ }
78
+ }
79
+
80
+ clearValues(){
81
+ if(this._range.destroyedGuard("clearValues")){
82
+ this._range.clearValues();
83
+ }
84
+ }
85
+
86
+ remove(){
87
+ if(this._range.destroyedGuard("remove")){
88
+ this._range.destroy(true);
89
+ }
90
+ }
91
+ }
92
+
93
+ export default RangeComponent;