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