handsontable 0.0.0-next-fd98d33-20241029 → 0.0.0-next-3f2ad1e-20241030

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of handsontable might be problematic. Click here for more details.

Files changed (63) hide show
  1. package/3rdparty/walkontable/src/overlay/inlineStart.js +1 -1
  2. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +1 -1
  3. package/3rdparty/walkontable/src/overlays.js +7 -6
  4. package/3rdparty/walkontable/src/overlays.mjs +7 -6
  5. package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
  6. package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
  7. package/3rdparty/walkontable/src/renderer/table.js +1 -1
  8. package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
  9. package/3rdparty/walkontable/src/settings.js +0 -7
  10. package/3rdparty/walkontable/src/settings.mjs +0 -7
  11. package/3rdparty/walkontable/src/table.js +0 -24
  12. package/3rdparty/walkontable/src/table.mjs +0 -24
  13. package/3rdparty/walkontable/src/utils/column.js +0 -42
  14. package/3rdparty/walkontable/src/utils/column.mjs +0 -42
  15. package/3rdparty/walkontable/src/viewport.js +66 -87
  16. package/3rdparty/walkontable/src/viewport.mjs +67 -88
  17. package/base.js +2 -2
  18. package/base.mjs +2 -2
  19. package/core/hooks/constants.js +2 -0
  20. package/core/hooks/constants.mjs +2 -0
  21. package/core/hooks/index.d.ts +2 -2
  22. package/core.d.ts +2 -2
  23. package/core.js +6 -4
  24. package/core.mjs +6 -4
  25. package/dist/handsontable.css +2 -2
  26. package/dist/handsontable.full.css +2 -2
  27. package/dist/handsontable.full.js +2226 -1821
  28. package/dist/handsontable.full.min.css +2 -2
  29. package/dist/handsontable.full.min.js +10 -10
  30. package/dist/handsontable.js +2228 -1823
  31. package/dist/handsontable.min.css +2 -2
  32. package/dist/handsontable.min.js +10 -10
  33. package/helpers/mixed.js +1 -1
  34. package/helpers/mixed.mjs +1 -1
  35. package/index.d.ts +7 -0
  36. package/package.json +6 -1
  37. package/plugins/comments/comments.js +1 -1
  38. package/plugins/comments/comments.mjs +1 -1
  39. package/plugins/index.d.ts +3 -0
  40. package/plugins/index.js +3 -0
  41. package/plugins/index.mjs +3 -1
  42. package/plugins/manualColumnMove/manualColumnMove.js +1 -3
  43. package/plugins/manualColumnMove/manualColumnMove.mjs +1 -3
  44. package/plugins/manualColumnResize/manualColumnResize.js +24 -12
  45. package/plugins/manualColumnResize/manualColumnResize.mjs +24 -12
  46. package/plugins/stretchColumns/calculator.js +159 -0
  47. package/plugins/stretchColumns/calculator.mjs +155 -0
  48. package/plugins/stretchColumns/index.d.ts +1 -0
  49. package/plugins/stretchColumns/index.js +7 -0
  50. package/plugins/stretchColumns/index.mjs +1 -0
  51. package/plugins/stretchColumns/strategies/_base.js +85 -0
  52. package/plugins/stretchColumns/strategies/_base.mjs +81 -0
  53. package/plugins/stretchColumns/strategies/all.js +68 -0
  54. package/plugins/stretchColumns/strategies/all.mjs +64 -0
  55. package/plugins/stretchColumns/strategies/last.js +77 -0
  56. package/plugins/stretchColumns/strategies/last.mjs +73 -0
  57. package/plugins/stretchColumns/stretchColumns.d.ts +11 -0
  58. package/plugins/stretchColumns/stretchColumns.js +220 -0
  59. package/plugins/stretchColumns/stretchColumns.mjs +216 -0
  60. package/tableView.js +39 -6
  61. package/tableView.mjs +39 -6
  62. package/3rdparty/walkontable/src/utils/columnStretching.js +0 -197
  63. package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -193
@@ -119,7 +119,7 @@ class InlineStartOverlay extends _base.Overlay {
119
119
  let column = from;
120
120
  let sum = 0;
121
121
  while (column < to) {
122
- sum += this.wot.wtTable.getStretchedColumnWidth(column) || defaultColumnWidth;
122
+ sum += this.wot.wtTable.getColumnWidth(column) || defaultColumnWidth;
123
123
  column += 1;
124
124
  }
125
125
  return sum;
@@ -115,7 +115,7 @@ export class InlineStartOverlay extends Overlay {
115
115
  let column = from;
116
116
  let sum = 0;
117
117
  while (column < to) {
118
- sum += this.wot.wtTable.getStretchedColumnWidth(column) || defaultColumnWidth;
118
+ sum += this.wot.wtTable.getColumnWidth(column) || defaultColumnWidth;
119
119
  column += 1;
120
120
  }
121
121
  return sum;
@@ -329,13 +329,14 @@ class Overlays {
329
329
  });
330
330
  let resizeTimeout;
331
331
  this.eventManager.addEventListener(rootWindow, 'resize', () => {
332
- clearTimeout(resizeTimeout);
333
- resizeTimeout = setTimeout(() => {
332
+ (0, _feature.requestAnimationFrame)(() => {
333
+ clearTimeout(resizeTimeout);
334
334
  this.wtSettings.getSetting('onWindowResize');
335
-
336
- // Remove resizing the window from the ResizeObserver's endless-loop-blocking logic.
337
- _classPrivateFieldSet(_containerDomResizeCount, this, 0);
338
- }, 200);
335
+ resizeTimeout = setTimeout(() => {
336
+ // Remove resizing the window from the ResizeObserver's endless-loop-blocking logic.
337
+ _classPrivateFieldSet(_containerDomResizeCount, this, 0);
338
+ }, 200);
339
+ });
339
340
  });
340
341
  if (!isScrollOnWindow) {
341
342
  this.resizeObserver.observe(this.wtTable.wtRootElement.parentElement);
@@ -326,13 +326,14 @@ class Overlays {
326
326
  });
327
327
  let resizeTimeout;
328
328
  this.eventManager.addEventListener(rootWindow, 'resize', () => {
329
- clearTimeout(resizeTimeout);
330
- resizeTimeout = setTimeout(() => {
329
+ requestAnimationFrame(() => {
330
+ clearTimeout(resizeTimeout);
331
331
  this.wtSettings.getSetting('onWindowResize');
332
-
333
- // Remove resizing the window from the ResizeObserver's endless-loop-blocking logic.
334
- _classPrivateFieldSet(_containerDomResizeCount, this, 0);
335
- }, 200);
332
+ resizeTimeout = setTimeout(() => {
333
+ // Remove resizing the window from the ResizeObserver's endless-loop-blocking logic.
334
+ _classPrivateFieldSet(_containerDomResizeCount, this, 0);
335
+ }, 200);
336
+ });
336
337
  });
337
338
  if (!isScrollOnWindow) {
338
339
  this.resizeObserver.observe(this.wtTable.wtRootElement.parentElement);
@@ -70,7 +70,7 @@ class ColGroupRenderer extends _base.default {
70
70
  // Render column nodes for cells
71
71
  for (let visibleColumnIndex = 0; visibleColumnIndex < columnsToRender; visibleColumnIndex++) {
72
72
  const sourceColumnIndex = this.table.renderedColumnToSource(visibleColumnIndex);
73
- const width = this.table.columnUtils.getStretchedColumnWidth(sourceColumnIndex);
73
+ const width = this.table.columnUtils.getWidth(sourceColumnIndex);
74
74
  this.rootNode.childNodes[visibleColumnIndex + rowHeadersCount].style.width = `${width}px`;
75
75
  }
76
76
  const firstChild = this.rootNode.firstChild;
@@ -66,7 +66,7 @@ export default class ColGroupRenderer extends BaseRenderer {
66
66
  // Render column nodes for cells
67
67
  for (let visibleColumnIndex = 0; visibleColumnIndex < columnsToRender; visibleColumnIndex++) {
68
68
  const sourceColumnIndex = this.table.renderedColumnToSource(visibleColumnIndex);
69
- const width = this.table.columnUtils.getStretchedColumnWidth(sourceColumnIndex);
69
+ const width = this.table.columnUtils.getWidth(sourceColumnIndex);
70
70
  this.rootNode.childNodes[visibleColumnIndex + rowHeadersCount].style.width = `${width}px`;
71
71
  }
72
72
  const firstChild = this.rootNode.firstChild;
@@ -301,7 +301,7 @@ class TableRenderer {
301
301
  this.rowHeaders.render();
302
302
  this.cells.render();
303
303
 
304
- // After the cells are rendered calculate columns width (or columns stretch width) to prepare proper values
304
+ // After the cells are rendered calculate columns width to prepare proper values
305
305
  // for colGroup renderer (which renders COL elements).
306
306
  this.columnUtils.calculateWidths();
307
307
  this.colGroup.render();
@@ -298,7 +298,7 @@ export default class TableRenderer {
298
298
  this.rowHeaders.render();
299
299
  this.cells.render();
300
300
 
301
- // After the cells are rendered calculate columns width (or columns stretch width) to prepare proper values
301
+ // After the cells are rendered calculate columns width to prepare proper values
302
302
  // for colGroup renderer (which renders COL elements).
303
303
  this.columnUtils.calculateWidths();
304
304
  this.colGroup.render();
@@ -24,7 +24,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
24
24
  * @property {Option} fixedColumnsStart Option `fixedColumnsStart`.
25
25
  * @property {Option} fixedRowsBottom Option `fixedRowsBottom`.
26
26
  * @property {Option} fixedRowsTop Option `fixedRowsTop`.
27
- * @property {Option} freezeOverlays Option `freezeOverlays`.
28
27
  * @property {Option} groups Option `groups`.
29
28
  * @property {Option} hideBorderOnMouseDownOver Option `hideBorderOnMouseDownOver`.
30
29
  * @property {Option} isRtl Option `isRtl`.
@@ -33,7 +32,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
33
32
  * @property {Option} onBeforeHighlightingColumnHeader Option `onBeforeHighlightingColumnHeader`.
34
33
  * @property {Option} onBeforeHighlightingRowHeader Option `onBeforeHighlightingRowHeader`.
35
34
  * @property {Option} onBeforeRemoveCellClassNames Option `onBeforeRemoveCellClassNames`.
36
- * @property {Option} onBeforeStretchingColumnWidth Option `onBeforeStretchingColumnWidth`.
37
35
  * @property {Option} preventOverflow Option `preventOverflow`.
38
36
  * @property {Option} preventWheel Option `preventWheel`.
39
37
  * @property {Option} renderAllColumns Option `renderAllColumns`.
@@ -44,7 +42,6 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
44
42
  * @property {Option} shouldRenderBottomOverlay Option `shouldRenderBottomOverlay`.
45
43
  * @property {Option} shouldRenderInlineStartOverlay Option `shouldRenderInlineStartOverlay`.
46
44
  * @property {Option} shouldRenderTopOverlay Option `shouldRenderTopOverlay`.
47
- * @property {Option} stretchH Option `stretchH`.
48
45
  * @property {Option} table Option `table`.
49
46
  * @property {Option} totalColumns Option `totalColumns`.
50
47
  * @property {Option} totalRows Option `totalRows`.
@@ -137,8 +134,6 @@ class Settings {
137
134
  isDataViewInstance: true,
138
135
  // presentation mode
139
136
  externalRowCalculator: false,
140
- stretchH: 'none',
141
- // values: all, last, none
142
137
  currentRowClassName: null,
143
138
  currentColumnClassName: null,
144
139
  preventOverflow() {
@@ -147,7 +142,6 @@ class Settings {
147
142
  preventWheel: false,
148
143
  // data source
149
144
  data: undefined,
150
- freezeOverlays: false,
151
145
  // Number of renderable columns for the left overlay.
152
146
  fixedColumnsStart: 0,
153
147
  // Number of renderable rows for the top overlay.
@@ -223,7 +217,6 @@ class Settings {
223
217
  //
224
218
  onBeforeTouchScroll: null,
225
219
  onAfterMomentumScroll: null,
226
- onBeforeStretchingColumnWidth: width => width,
227
220
  onModifyRowHeaderWidth: null,
228
221
  onModifyGetCellCoords: null,
229
222
  onModifyGetCoordsElement: null,
@@ -21,7 +21,6 @@ import { objectEach } from "../../../helpers/object.mjs";
21
21
  * @property {Option} fixedColumnsStart Option `fixedColumnsStart`.
22
22
  * @property {Option} fixedRowsBottom Option `fixedRowsBottom`.
23
23
  * @property {Option} fixedRowsTop Option `fixedRowsTop`.
24
- * @property {Option} freezeOverlays Option `freezeOverlays`.
25
24
  * @property {Option} groups Option `groups`.
26
25
  * @property {Option} hideBorderOnMouseDownOver Option `hideBorderOnMouseDownOver`.
27
26
  * @property {Option} isRtl Option `isRtl`.
@@ -30,7 +29,6 @@ import { objectEach } from "../../../helpers/object.mjs";
30
29
  * @property {Option} onBeforeHighlightingColumnHeader Option `onBeforeHighlightingColumnHeader`.
31
30
  * @property {Option} onBeforeHighlightingRowHeader Option `onBeforeHighlightingRowHeader`.
32
31
  * @property {Option} onBeforeRemoveCellClassNames Option `onBeforeRemoveCellClassNames`.
33
- * @property {Option} onBeforeStretchingColumnWidth Option `onBeforeStretchingColumnWidth`.
34
32
  * @property {Option} preventOverflow Option `preventOverflow`.
35
33
  * @property {Option} preventWheel Option `preventWheel`.
36
34
  * @property {Option} renderAllColumns Option `renderAllColumns`.
@@ -41,7 +39,6 @@ import { objectEach } from "../../../helpers/object.mjs";
41
39
  * @property {Option} shouldRenderBottomOverlay Option `shouldRenderBottomOverlay`.
42
40
  * @property {Option} shouldRenderInlineStartOverlay Option `shouldRenderInlineStartOverlay`.
43
41
  * @property {Option} shouldRenderTopOverlay Option `shouldRenderTopOverlay`.
44
- * @property {Option} stretchH Option `stretchH`.
45
42
  * @property {Option} table Option `table`.
46
43
  * @property {Option} totalColumns Option `totalColumns`.
47
44
  * @property {Option} totalRows Option `totalRows`.
@@ -132,8 +129,6 @@ export default class Settings {
132
129
  isDataViewInstance: true,
133
130
  // presentation mode
134
131
  externalRowCalculator: false,
135
- stretchH: 'none',
136
- // values: all, last, none
137
132
  currentRowClassName: null,
138
133
  currentColumnClassName: null,
139
134
  preventOverflow() {
@@ -142,7 +137,6 @@ export default class Settings {
142
137
  preventWheel: false,
143
138
  // data source
144
139
  data: undefined,
145
- freezeOverlays: false,
146
140
  // Number of renderable columns for the left overlay.
147
141
  fixedColumnsStart: 0,
148
142
  // Number of renderable rows for the top overlay.
@@ -218,7 +212,6 @@ export default class Settings {
218
212
  //
219
213
  onBeforeTouchScroll: null,
220
214
  onAfterMomentumScroll: null,
221
- onBeforeStretchingColumnWidth: width => width,
222
215
  onModifyRowHeaderWidth: null,
223
216
  onModifyGetCellCoords: null,
224
217
  onModifyGetCoordsElement: null,
@@ -296,10 +296,7 @@ class Table {
296
296
  }
297
297
  this.resetOversizedRows();
298
298
  this.tableRenderer.setActiveOverlayName(this.name).setViewportSize(this.getRenderedRowsCount(), this.getRenderedColumnsCount()).setFilters(this.rowFilter, this.columnFilter).render();
299
- let workspaceWidth;
300
299
  if (this.isMaster) {
301
- workspaceWidth = this.dataAccessObject.workspaceWidth;
302
- wtViewport.containerWidth = null;
303
300
  this.markOversizedColumnHeaders();
304
301
  }
305
302
  this.adjustColumnHeaderHeights();
@@ -312,19 +309,6 @@ class Table {
312
309
  }
313
310
  wtOverlays.refresh(false);
314
311
  wtOverlays.applyToDOM();
315
- const hiderWidth = (0, _element.outerWidth)(this.hider);
316
- const tableWidth = (0, _element.outerWidth)(this.TABLE);
317
- if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
318
- // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
319
- this.columnUtils.calculateWidths();
320
- this.tableRenderer.renderer.colGroup.render();
321
- }
322
- if (workspaceWidth !== wtViewport.getWorkspaceWidth()) {
323
- // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
324
- wtViewport.containerWidth = null;
325
- this.columnUtils.calculateWidths();
326
- this.tableRenderer.renderer.colGroup.render();
327
- }
328
312
  this.wtSettings.getSetting('onDraw', true);
329
313
  } else if (this.is(_overlay.CLONE_BOTTOM)) {
330
314
  this.dataAccessObject.cloneSource.wtOverlays.adjustElementsSize();
@@ -913,14 +897,6 @@ class Table {
913
897
  return this.columnUtils.getWidth(sourceColumn);
914
898
  }
915
899
 
916
- /**
917
- * @param {number} sourceColumn The physical column index.
918
- * @returns {number}
919
- */
920
- getStretchedColumnWidth(sourceColumn) {
921
- return this.columnUtils.getStretchedColumnWidth(sourceColumn);
922
- }
923
-
924
900
  /**
925
901
  * Checks if the table has defined size. It returns `true` when the table has width and height
926
902
  * set bigger than `0px`.
@@ -292,10 +292,7 @@ class Table {
292
292
  }
293
293
  this.resetOversizedRows();
294
294
  this.tableRenderer.setActiveOverlayName(this.name).setViewportSize(this.getRenderedRowsCount(), this.getRenderedColumnsCount()).setFilters(this.rowFilter, this.columnFilter).render();
295
- let workspaceWidth;
296
295
  if (this.isMaster) {
297
- workspaceWidth = this.dataAccessObject.workspaceWidth;
298
- wtViewport.containerWidth = null;
299
296
  this.markOversizedColumnHeaders();
300
297
  }
301
298
  this.adjustColumnHeaderHeights();
@@ -308,19 +305,6 @@ class Table {
308
305
  }
309
306
  wtOverlays.refresh(false);
310
307
  wtOverlays.applyToDOM();
311
- const hiderWidth = outerWidth(this.hider);
312
- const tableWidth = outerWidth(this.TABLE);
313
- if (hiderWidth !== 0 && tableWidth !== hiderWidth) {
314
- // Recalculate the column widths, if width changes made in the overlays removed the scrollbar, thus changing the viewport width.
315
- this.columnUtils.calculateWidths();
316
- this.tableRenderer.renderer.colGroup.render();
317
- }
318
- if (workspaceWidth !== wtViewport.getWorkspaceWidth()) {
319
- // workspace width changed though to shown/hidden vertical scrollbar. Let's reapply stretching
320
- wtViewport.containerWidth = null;
321
- this.columnUtils.calculateWidths();
322
- this.tableRenderer.renderer.colGroup.render();
323
- }
324
308
  this.wtSettings.getSetting('onDraw', true);
325
309
  } else if (this.is(CLONE_BOTTOM)) {
326
310
  this.dataAccessObject.cloneSource.wtOverlays.adjustElementsSize();
@@ -909,14 +893,6 @@ class Table {
909
893
  return this.columnUtils.getWidth(sourceColumn);
910
894
  }
911
895
 
912
- /**
913
- * @param {number} sourceColumn The physical column index.
914
- * @returns {number}
915
- */
916
- getStretchedColumnWidth(sourceColumn) {
917
- return this.columnUtils.getStretchedColumnWidth(sourceColumn);
918
- }
919
-
920
896
  /**
921
897
  * Checks if the table has defined size. It returns `true` when the table has width and height
922
898
  * set bigger than `0px`.
@@ -2,8 +2,6 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.error.cause.js");
5
- var _element = require("./../../../../helpers/dom/element");
6
- var _columnStretching = require("./columnStretching");
7
5
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
8
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
7
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
@@ -30,18 +28,8 @@ class ColumnUtils {
30
28
  * @type {Map<number, number>}
31
29
  */
32
30
  _defineProperty(this, "headerWidths", new Map());
33
- /**
34
- * @type {ColumnStretching}
35
- */
36
- _defineProperty(this, "stretching", void 0);
37
31
  this.dataAccessObject = dataAccessObject;
38
32
  this.wtSettings = wtSettings;
39
- this.stretching = new _columnStretching.ColumnStretching({
40
- totalColumns: () => this.wtSettings.getSetting('totalColumns'),
41
- stretchMode: () => this.wtSettings.getSetting('stretchH'),
42
- stretchingColumnWidthFn: (stretchedWidth, column) => this.wtSettings.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column),
43
- columnWidthFn: sourceCol => this.dataAccessObject.wtTable.getColumnWidth(sourceCol)
44
- });
45
33
  }
46
34
 
47
35
  /**
@@ -55,21 +43,6 @@ class ColumnUtils {
55
43
  return width;
56
44
  }
57
45
 
58
- /**
59
- * Returns stretched column width based on passed source index.
60
- *
61
- * @param {number} sourceIndex Column source index.
62
- * @returns {number}
63
- */
64
- getStretchedColumnWidth(sourceIndex) {
65
- let width = this.getWidth(sourceIndex);
66
- const stretchedWidth = this.stretching.getStretchedColumnWidth(sourceIndex, width);
67
- if (stretchedWidth) {
68
- width = stretchedWidth;
69
- }
70
- return width;
71
- }
72
-
73
46
  /**
74
47
  * Returns column header height based on passed header level.
75
48
  *
@@ -95,20 +68,6 @@ class ColumnUtils {
95
68
  return this.headerWidths.get(this.dataAccessObject.wtTable.columnFilter.sourceToRendered(sourceIndex));
96
69
  }
97
70
 
98
- /**
99
- * Refreshes the stretching column width by recalculating the widths of the columns.
100
- */
101
- refreshStretching() {
102
- const {
103
- wtTable,
104
- wtViewport,
105
- cloneSource
106
- } = this.dataAccessObject;
107
- const mainHolder = cloneSource ? cloneSource.wtTable.holder : wtTable.holder;
108
- const scrollbarCompensation = mainHolder.offsetHeight < mainHolder.scrollHeight ? (0, _element.getScrollbarWidth)() : 0;
109
- this.stretching.refreshStretching(wtViewport.getViewportWidth() - scrollbarCompensation);
110
- }
111
-
112
71
  /**
113
72
  * Calculates column header widths that can be retrieved from the cache.
114
73
  */
@@ -117,7 +76,6 @@ class ColumnUtils {
117
76
  wtSettings
118
77
  } = this;
119
78
  let rowHeaderWidthSetting = wtSettings.getSetting('rowHeaderWidth');
120
- this.refreshStretching();
121
79
  rowHeaderWidthSetting = wtSettings.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
122
80
  if (rowHeaderWidthSetting !== null && rowHeaderWidthSetting !== undefined) {
123
81
  const rowHeadersCount = wtSettings.getSetting('rowHeaders').length;
@@ -2,8 +2,6 @@ import "core-js/modules/es.error.cause.js";
2
2
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
3
3
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
4
4
  function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
5
- import { getScrollbarWidth } from "./../../../../helpers/dom/element.mjs";
6
- import { ColumnStretching } from "./columnStretching.mjs";
7
5
  /**
8
6
  * Column utils class contains all necessary information about sizes of the columns.
9
7
  *
@@ -27,18 +25,8 @@ export default class ColumnUtils {
27
25
  * @type {Map<number, number>}
28
26
  */
29
27
  _defineProperty(this, "headerWidths", new Map());
30
- /**
31
- * @type {ColumnStretching}
32
- */
33
- _defineProperty(this, "stretching", void 0);
34
28
  this.dataAccessObject = dataAccessObject;
35
29
  this.wtSettings = wtSettings;
36
- this.stretching = new ColumnStretching({
37
- totalColumns: () => this.wtSettings.getSetting('totalColumns'),
38
- stretchMode: () => this.wtSettings.getSetting('stretchH'),
39
- stretchingColumnWidthFn: (stretchedWidth, column) => this.wtSettings.getSetting('onBeforeStretchingColumnWidth', stretchedWidth, column),
40
- columnWidthFn: sourceCol => this.dataAccessObject.wtTable.getColumnWidth(sourceCol)
41
- });
42
30
  }
43
31
 
44
32
  /**
@@ -52,21 +40,6 @@ export default class ColumnUtils {
52
40
  return width;
53
41
  }
54
42
 
55
- /**
56
- * Returns stretched column width based on passed source index.
57
- *
58
- * @param {number} sourceIndex Column source index.
59
- * @returns {number}
60
- */
61
- getStretchedColumnWidth(sourceIndex) {
62
- let width = this.getWidth(sourceIndex);
63
- const stretchedWidth = this.stretching.getStretchedColumnWidth(sourceIndex, width);
64
- if (stretchedWidth) {
65
- width = stretchedWidth;
66
- }
67
- return width;
68
- }
69
-
70
43
  /**
71
44
  * Returns column header height based on passed header level.
72
45
  *
@@ -92,20 +65,6 @@ export default class ColumnUtils {
92
65
  return this.headerWidths.get(this.dataAccessObject.wtTable.columnFilter.sourceToRendered(sourceIndex));
93
66
  }
94
67
 
95
- /**
96
- * Refreshes the stretching column width by recalculating the widths of the columns.
97
- */
98
- refreshStretching() {
99
- const {
100
- wtTable,
101
- wtViewport,
102
- cloneSource
103
- } = this.dataAccessObject;
104
- const mainHolder = cloneSource ? cloneSource.wtTable.holder : wtTable.holder;
105
- const scrollbarCompensation = mainHolder.offsetHeight < mainHolder.scrollHeight ? getScrollbarWidth() : 0;
106
- this.stretching.refreshStretching(wtViewport.getViewportWidth() - scrollbarCompensation);
107
- }
108
-
109
68
  /**
110
69
  * Calculates column header widths that can be retrieved from the cache.
111
70
  */
@@ -114,7 +73,6 @@ export default class ColumnUtils {
114
73
  wtSettings
115
74
  } = this;
116
75
  let rowHeaderWidthSetting = wtSettings.getSetting('rowHeaderWidth');
117
- this.refreshStretching();
118
76
  rowHeaderWidthSetting = wtSettings.getSetting('onModifyRowHeaderWidth', rowHeaderWidthSetting);
119
77
  if (rowHeaderWidthSetting !== null && rowHeaderWidthSetting !== undefined) {
120
78
  const rowHeadersCount = wtSettings.getSetting('rowHeaders').length;
@@ -27,7 +27,6 @@ class Viewport {
27
27
  this.oversizedColumnHeaders = [];
28
28
  this.hasOversizedColumnHeadersMarked = {};
29
29
  this.clientHeight = 0;
30
- this.containerWidth = NaN;
31
30
  this.rowHeaderWidth = NaN;
32
31
  this.rowsVisibleCalculator = null;
33
32
  this.columnsVisibleCalculator = null;
@@ -56,55 +55,65 @@ class Viewport {
56
55
  }
57
56
  return height;
58
57
  }
58
+
59
+ /**
60
+ * @returns {number}
61
+ */
62
+ getViewportHeight() {
63
+ let containerHeight = this.getWorkspaceHeight();
64
+ if (containerHeight === Infinity) {
65
+ return containerHeight;
66
+ }
67
+ const columnHeaderHeight = this.getColumnHeaderHeight();
68
+ if (columnHeaderHeight > 0) {
69
+ containerHeight -= columnHeaderHeight;
70
+ }
71
+ return containerHeight;
72
+ }
73
+
74
+ /**
75
+ * Gets the width of the table workspace (in pixels). The workspace size in the current
76
+ * implementation returns the width of the table holder element including scrollbar width when
77
+ * the table has defined size and the width of the window excluding scrollbar width when
78
+ * the table has no defined size (the window is a scrollable container).
79
+ *
80
+ * This is a bug, as the method should always return stable values, always without scrollbar width.
81
+ * Changing this behavior would break the column calculators, which would also need to be adjusted.
82
+ *
83
+ * @returns {number}
84
+ */
59
85
  getWorkspaceWidth() {
60
- const {
61
- wtSettings
62
- } = this;
63
86
  const {
64
87
  rootDocument,
65
88
  rootWindow
66
89
  } = this.domBindings;
67
90
  const trimmingContainer = this.dataAccessObject.inlineStartOverlayTrimmingContainer;
68
- const docOffsetWidth = rootDocument.documentElement.offsetWidth;
69
- const totalColumns = wtSettings.getSetting('totalColumns');
70
- const preventOverflow = wtSettings.getSetting('preventOverflow');
71
- const isRtl = wtSettings.getSetting('rtlMode');
72
- const tableRect = this.wtTable.TABLE.getBoundingClientRect();
73
- const inlineStart = isRtl ? tableRect.right - docOffsetWidth : tableRect.left;
74
- const tableOffset = docOffsetWidth - inlineStart;
75
91
  let width;
76
- let overflow;
77
- if (preventOverflow) {
78
- return (0, _element.outerWidth)(this.wtTable.wtRootElement);
79
- }
80
- if (wtSettings.getSetting('freezeOverlays')) {
81
- width = Math.min(tableOffset, docOffsetWidth);
92
+ if (trimmingContainer === rootWindow) {
93
+ const totalColumns = this.wtSettings.getSetting('totalColumns');
94
+ width = this.wtTable.holder.offsetWidth;
95
+ if (this.getRowHeaderWidth() + this.sumColumnWidths(0, totalColumns) > width) {
96
+ width = rootDocument.documentElement.clientWidth;
97
+ }
82
98
  } else {
83
- width = Math.min(this.getContainerFillWidth(), tableOffset, docOffsetWidth);
99
+ width = trimmingContainer.clientWidth;
84
100
  }
85
- if (trimmingContainer === rootWindow && totalColumns > 0 && this.sumColumnWidths(0, totalColumns - 1) > width) {
86
- // in case sum of column widths is higher than available stylesheet width, let's assume using the whole window
87
- // otherwise continue below, which will allow stretching
88
- // this is used in `scroll_window.html`
89
- // TODO test me
90
- return rootDocument.documentElement.clientWidth;
91
- }
92
- if (trimmingContainer !== rootWindow) {
93
- overflow = (0, _element.getStyle)(this.dataAccessObject.inlineStartOverlayTrimmingContainer, 'overflow', rootWindow);
94
- if (overflow === 'scroll' || overflow === 'hidden' || overflow === 'auto') {
95
- // this is used in `scroll.html`
96
- // TODO test me
97
- return Math.max(width, trimmingContainer.clientWidth);
98
- }
101
+ return width;
102
+ }
103
+
104
+ /**
105
+ * @returns {number}
106
+ */
107
+ getViewportWidth() {
108
+ const containerWidth = this.getWorkspaceWidth();
109
+ if (containerWidth === Infinity) {
110
+ return containerWidth;
99
111
  }
100
- const stretchSetting = wtSettings.getSetting('stretchH');
101
- if (stretchSetting === 'none' || !stretchSetting) {
102
- // if no stretching is used, return the maximum used workspace width
103
- return Math.max(width, (0, _element.outerWidth)(this.wtTable.TABLE));
112
+ const rowHeaderWidth = this.getRowHeaderWidth();
113
+ if (rowHeaderWidth > 0) {
114
+ return containerWidth - rowHeaderWidth;
104
115
  }
105
-
106
- // if stretching is used, return the actual container width, so the columns can fit inside it
107
- return width;
116
+ return containerWidth;
108
117
  }
109
118
 
110
119
  /**
@@ -125,6 +134,24 @@ class Viewport {
125
134
  return this.wtTable.hider.offsetWidth > this.getWorkspaceWidth();
126
135
  }
127
136
 
137
+ /**
138
+ * Checks if the table uses the window as a viewport and if there is a vertical scrollbar.
139
+ *
140
+ * @returns {boolean}
141
+ */
142
+ isVerticallyScrollableByWindow() {
143
+ return this.dataAccessObject.topOverlayTrimmingContainer === this.domBindings.rootWindow;
144
+ }
145
+
146
+ /**
147
+ * Checks if the table uses the window as a viewport and if there is a horizontal scrollbar.
148
+ *
149
+ * @returns {boolean}
150
+ */
151
+ isHorizontallyScrollableByWindow() {
152
+ return this.dataAccessObject.inlineStartOverlayTrimmingContainer === this.domBindings.rootWindow;
153
+ }
154
+
128
155
  /**
129
156
  * @param {number} from The visual column index from the width sum is start calculated.
130
157
  * @param {number} length The length of the column to traverse.
@@ -140,24 +167,6 @@ class Viewport {
140
167
  return sum;
141
168
  }
142
169
 
143
- /**
144
- * @returns {number}
145
- */
146
- getContainerFillWidth() {
147
- if (this.containerWidth) {
148
- return this.containerWidth;
149
- }
150
- const mainContainer = this.wtTable.holder;
151
- const dummyElement = this.domBindings.rootDocument.createElement('div');
152
- dummyElement.style.width = '100%';
153
- dummyElement.style.height = '1px';
154
- mainContainer.appendChild(dummyElement);
155
- const fillWidth = dummyElement.offsetWidth;
156
- this.containerWidth = fillWidth;
157
- mainContainer.removeChild(dummyElement);
158
- return fillWidth;
159
- }
160
-
161
170
  /**
162
171
  * @returns {number}
163
172
  */
@@ -178,21 +187,6 @@ class Viewport {
178
187
  return this.columnHeaderHeight;
179
188
  }
180
189
 
181
- /**
182
- * @returns {number}
183
- */
184
- getViewportHeight() {
185
- let containerHeight = this.getWorkspaceHeight();
186
- if (containerHeight === Infinity) {
187
- return containerHeight;
188
- }
189
- const columnHeaderHeight = this.getColumnHeaderHeight();
190
- if (columnHeaderHeight > 0) {
191
- containerHeight -= columnHeaderHeight;
192
- }
193
- return containerHeight;
194
- }
195
-
196
190
  /**
197
191
  * @returns {number}
198
192
  */
@@ -227,21 +221,6 @@ class Viewport {
227
221
  return this.rowHeaderWidth;
228
222
  }
229
223
 
230
- /**
231
- * @returns {number}
232
- */
233
- getViewportWidth() {
234
- const containerWidth = this.getWorkspaceWidth();
235
- if (containerWidth === Infinity) {
236
- return containerWidth;
237
- }
238
- const rowHeaderWidth = this.getRowHeaderWidth();
239
- if (rowHeaderWidth > 0) {
240
- return containerWidth - rowHeaderWidth;
241
- }
242
- return containerWidth;
243
- }
244
-
245
224
  /**
246
225
  * Creates rows calculators. The type of the calculations can be chosen from the list:
247
226
  * - 'rendered' Calculates rows that should be rendered within the current table's viewport;