handsontable 14.5.0-next-ede811d-20240717 → 14.5.0-next-7541a88-20240725

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleColumns.js +126 -0
  2. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleColumns.mjs +122 -0
  3. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleRows.js +119 -0
  4. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleRows.mjs +115 -0
  5. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleColumns.js +125 -0
  6. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleColumns.mjs +121 -0
  7. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleRows.js +118 -0
  8. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleRows.mjs +114 -0
  9. package/3rdparty/walkontable/src/calculator/{renderAllColumns.js → calculationType/renderedAllColumns.js} +32 -9
  10. package/3rdparty/walkontable/src/calculator/{renderAllColumns.mjs → calculationType/renderedAllColumns.mjs} +31 -8
  11. package/3rdparty/walkontable/src/calculator/{renderAllRows.js → calculationType/renderedAllRows.js} +32 -9
  12. package/3rdparty/walkontable/src/calculator/{renderAllRows.mjs → calculationType/renderedAllRows.mjs} +31 -8
  13. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.js +37 -0
  14. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.mjs +33 -0
  15. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.js +37 -0
  16. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.mjs +33 -0
  17. package/3rdparty/walkontable/src/calculator/index.js +18 -17
  18. package/3rdparty/walkontable/src/calculator/index.mjs +11 -6
  19. package/3rdparty/walkontable/src/calculator/viewportBase.js +92 -0
  20. package/3rdparty/walkontable/src/calculator/viewportBase.mjs +88 -0
  21. package/3rdparty/walkontable/src/calculator/viewportColumns.js +51 -145
  22. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +51 -145
  23. package/3rdparty/walkontable/src/calculator/viewportRows.js +59 -141
  24. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +59 -141
  25. package/3rdparty/walkontable/src/index.js +2 -0
  26. package/3rdparty/walkontable/src/index.mjs +2 -2
  27. package/3rdparty/walkontable/src/table.js +5 -11
  28. package/3rdparty/walkontable/src/table.mjs +5 -11
  29. package/3rdparty/walkontable/src/utils/column.js +2 -1
  30. package/3rdparty/walkontable/src/utils/column.mjs +2 -1
  31. package/3rdparty/walkontable/src/utils/columnStretching.js +10 -19
  32. package/3rdparty/walkontable/src/utils/columnStretching.mjs +10 -19
  33. package/3rdparty/walkontable/src/viewport.js +35 -46
  34. package/3rdparty/walkontable/src/viewport.mjs +36 -47
  35. package/base.js +2 -2
  36. package/base.mjs +2 -2
  37. package/core.js +1 -1
  38. package/core.mjs +2 -2
  39. package/dist/handsontable.css +2 -2
  40. package/dist/handsontable.full.css +2 -2
  41. package/dist/handsontable.full.js +2494 -1961
  42. package/dist/handsontable.full.min.css +2 -2
  43. package/dist/handsontable.full.min.js +148 -148
  44. package/dist/handsontable.js +2495 -1962
  45. package/dist/handsontable.min.css +2 -2
  46. package/dist/handsontable.min.js +32 -32
  47. package/helpers/mixed.js +1 -1
  48. package/helpers/mixed.mjs +1 -1
  49. package/package.json +1 -1
  50. package/plugins/autoColumnSize/autoColumnSize.js +1 -1
  51. package/plugins/autoColumnSize/autoColumnSize.mjs +2 -2
  52. package/plugins/manualRowResize/manualRowResize.js +1 -1
  53. package/plugins/manualRowResize/manualRowResize.mjs +2 -2
  54. package/3rdparty/walkontable/src/calculator/constants.js +0 -26
  55. package/3rdparty/walkontable/src/calculator/constants.mjs +0 -23
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ var _partiallyVisibleRows = require("./partiallyVisibleRows");
5
+ /**
6
+ * @class RenderedRowsCalculationType
7
+ */
8
+ class RenderedRowsCalculationType extends _partiallyVisibleRows.PartiallyVisibleRowsCalculationType {
9
+ /**
10
+ * Finalizes the calculation.
11
+ *
12
+ * @param {ViewportRowsCalculator} viewportCalculator The viewport calculator object.
13
+ */
14
+ finalize(viewportCalculator) {
15
+ var _startPositions$this$;
16
+ super.finalize(viewportCalculator);
17
+ const {
18
+ overrideFn,
19
+ totalRows,
20
+ startPositions
21
+ } = viewportCalculator;
22
+ if (this.startRow !== null && typeof overrideFn === 'function') {
23
+ overrideFn(this);
24
+ }
25
+ if (this.startRow < 0) {
26
+ this.startRow = 0;
27
+ }
28
+ this.startPosition = (_startPositions$this$ = startPositions[this.startRow]) !== null && _startPositions$this$ !== void 0 ? _startPositions$this$ : null;
29
+ if (totalRows < this.endRow) {
30
+ this.endRow = totalRows - 1;
31
+ }
32
+ if (this.startRow !== null) {
33
+ this.count = this.endRow - this.startRow + 1;
34
+ }
35
+ }
36
+ }
37
+ exports.RenderedRowsCalculationType = RenderedRowsCalculationType;
@@ -0,0 +1,33 @@
1
+ import { PartiallyVisibleRowsCalculationType } from "./partiallyVisibleRows.mjs";
2
+ /**
3
+ * @class RenderedRowsCalculationType
4
+ */
5
+ export class RenderedRowsCalculationType extends PartiallyVisibleRowsCalculationType {
6
+ /**
7
+ * Finalizes the calculation.
8
+ *
9
+ * @param {ViewportRowsCalculator} viewportCalculator The viewport calculator object.
10
+ */
11
+ finalize(viewportCalculator) {
12
+ var _startPositions$this$;
13
+ super.finalize(viewportCalculator);
14
+ const {
15
+ overrideFn,
16
+ totalRows,
17
+ startPositions
18
+ } = viewportCalculator;
19
+ if (this.startRow !== null && typeof overrideFn === 'function') {
20
+ overrideFn(this);
21
+ }
22
+ if (this.startRow < 0) {
23
+ this.startRow = 0;
24
+ }
25
+ this.startPosition = (_startPositions$this$ = startPositions[this.startRow]) !== null && _startPositions$this$ !== void 0 ? _startPositions$this$ : null;
26
+ if (totalRows < this.endRow) {
27
+ this.endRow = totalRows - 1;
28
+ }
29
+ if (this.startRow !== null) {
30
+ this.count = this.endRow - this.startRow + 1;
31
+ }
32
+ }
33
+ }
@@ -1,24 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- var _exportNames = {
5
- RenderAllColumnsCalculator: true,
6
- RenderAllRowsCalculator: true,
7
- ViewportColumnsCalculator: true,
8
- ViewportRowsCalculator: true
9
- };
10
- var _renderAllColumns = require("./renderAllColumns");
11
- exports.RenderAllColumnsCalculator = _renderAllColumns.RenderAllColumnsCalculator;
12
- var _renderAllRows = require("./renderAllRows");
13
- exports.RenderAllRowsCalculator = _renderAllRows.RenderAllRowsCalculator;
4
+ var _fullyVisibleColumns = require("./calculationType/fullyVisibleColumns");
5
+ exports.FullyVisibleColumnsCalculationType = _fullyVisibleColumns.FullyVisibleColumnsCalculationType;
6
+ var _fullyVisibleRows = require("./calculationType/fullyVisibleRows");
7
+ exports.FullyVisibleRowsCalculationType = _fullyVisibleRows.FullyVisibleRowsCalculationType;
8
+ var _partiallyVisibleColumns = require("./calculationType/partiallyVisibleColumns");
9
+ exports.PartiallyVisibleColumnsCalculationType = _partiallyVisibleColumns.PartiallyVisibleColumnsCalculationType;
10
+ var _partiallyVisibleRows = require("./calculationType/partiallyVisibleRows");
11
+ exports.PartiallyVisibleRowsCalculationType = _partiallyVisibleRows.PartiallyVisibleRowsCalculationType;
12
+ var _renderedAllColumns = require("./calculationType/renderedAllColumns");
13
+ exports.RenderedAllColumnsCalculationType = _renderedAllColumns.RenderedAllColumnsCalculationType;
14
+ var _renderedAllRows = require("./calculationType/renderedAllRows");
15
+ exports.RenderedAllRowsCalculationType = _renderedAllRows.RenderedAllRowsCalculationType;
16
+ var _renderedColumns = require("./calculationType/renderedColumns");
17
+ exports.RenderedColumnsCalculationType = _renderedColumns.RenderedColumnsCalculationType;
18
+ var _renderedRows = require("./calculationType/renderedRows");
19
+ exports.RenderedRowsCalculationType = _renderedRows.RenderedRowsCalculationType;
14
20
  var _viewportColumns = require("./viewportColumns");
15
21
  exports.ViewportColumnsCalculator = _viewportColumns.ViewportColumnsCalculator;
22
+ exports.DEFAULT_COLUMN_WIDTH = _viewportColumns.DEFAULT_WIDTH;
16
23
  var _viewportRows = require("./viewportRows");
17
24
  exports.ViewportRowsCalculator = _viewportRows.ViewportRowsCalculator;
18
- var _constants = require("./constants");
19
- Object.keys(_constants).forEach(function (key) {
20
- if (key === "default" || key === "__esModule") return;
21
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
22
- if (key in exports && exports[key] === _constants[key]) return;
23
- exports[key] = _constants[key];
24
- });
25
+ exports.DEFAULT_ROW_HEIGHT = _viewportRows.DEFAULT_HEIGHT;
@@ -1,6 +1,11 @@
1
- import { RenderAllColumnsCalculator } from "./renderAllColumns.mjs";
2
- import { RenderAllRowsCalculator } from "./renderAllRows.mjs";
3
- import { ViewportColumnsCalculator } from "./viewportColumns.mjs";
4
- import { ViewportRowsCalculator } from "./viewportRows.mjs";
5
- export * from "./constants.mjs";
6
- export { RenderAllColumnsCalculator, RenderAllRowsCalculator, ViewportColumnsCalculator, ViewportRowsCalculator };
1
+ import { FullyVisibleColumnsCalculationType } from "./calculationType/fullyVisibleColumns.mjs";
2
+ import { FullyVisibleRowsCalculationType } from "./calculationType/fullyVisibleRows.mjs";
3
+ import { PartiallyVisibleColumnsCalculationType } from "./calculationType/partiallyVisibleColumns.mjs";
4
+ import { PartiallyVisibleRowsCalculationType } from "./calculationType/partiallyVisibleRows.mjs";
5
+ import { RenderedAllColumnsCalculationType } from "./calculationType/renderedAllColumns.mjs";
6
+ import { RenderedAllRowsCalculationType } from "./calculationType/renderedAllRows.mjs";
7
+ import { RenderedColumnsCalculationType } from "./calculationType/renderedColumns.mjs";
8
+ import { RenderedRowsCalculationType } from "./calculationType/renderedRows.mjs";
9
+ import { ViewportColumnsCalculator, DEFAULT_WIDTH } from "./viewportColumns.mjs";
10
+ import { ViewportRowsCalculator, DEFAULT_HEIGHT } from "./viewportRows.mjs";
11
+ export { DEFAULT_HEIGHT as DEFAULT_ROW_HEIGHT, DEFAULT_WIDTH as DEFAULT_COLUMN_WIDTH, FullyVisibleColumnsCalculationType, FullyVisibleRowsCalculationType, PartiallyVisibleColumnsCalculationType, PartiallyVisibleRowsCalculationType, RenderedAllColumnsCalculationType, RenderedAllRowsCalculationType, RenderedColumnsCalculationType, RenderedRowsCalculationType, ViewportColumnsCalculator, ViewportRowsCalculator };
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ require("core-js/modules/es.error.cause.js");
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; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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); }
8
+ /**
9
+ * @typedef {object} ColumnsCalculationType
10
+ * @property {number | null} startColumn The column index of the first column in the viewport.
11
+ * @property {number | null} endColumn The column index of the last column in the viewport.
12
+ * @property {number} count Total number of columns.
13
+ * @property {number | null} startPosition Position of the first fully column (in px).
14
+ * @property {boolean} isVisibleInTrimmingContainer Determines if the viewport is visible in the trimming container.
15
+ */
16
+ /**
17
+ * @typedef {object} RowsCalculationType
18
+ * @property {number | null} startRow The row index of the first row in the viewport.
19
+ * @property {number | null} endRow The row index of the last row in the viewport.
20
+ * @property {number} count Total number of rows.
21
+ * @property {number | null} startPosition Position of the first fully row (in px).
22
+ * @property {boolean} isVisibleInTrimmingContainer Determines if the viewport is visible in the trimming container.
23
+ */
24
+ /**
25
+ * @class ViewportBaseCalculator
26
+ */
27
+ class ViewportBaseCalculator {
28
+ constructor(calculationTypes) {
29
+ /**
30
+ * The calculation types to be performed.
31
+ *
32
+ * @type {Array}
33
+ */
34
+ _defineProperty(this, "calculationTypes", []);
35
+ /**
36
+ * The calculation results.
37
+ *
38
+ * @type {Map<string, ColumnsCalculationType | RowsCalculationType>}
39
+ */
40
+ _defineProperty(this, "calculationResults", new Map());
41
+ this.calculationTypes = calculationTypes;
42
+ }
43
+
44
+ /**
45
+ * Initializes all calculators (triggers all calculators before calculating the rows/columns sizes).
46
+ *
47
+ * @param {*} context The context object (rows or columns viewport calculator).
48
+ */
49
+ _initialize(context) {
50
+ this.calculationTypes.forEach(_ref => {
51
+ let [id, calculator] = _ref;
52
+ this.calculationResults.set(id, calculator);
53
+ calculator.initialize(context);
54
+ });
55
+ }
56
+
57
+ /**
58
+ * Processes the row/column at the given index.
59
+ *
60
+ * @param {number} index The index of the row/column.
61
+ * @param {*} context The context object (rows or columns viewport calculator).
62
+ */
63
+ _process(index, context) {
64
+ this.calculationTypes.forEach(_ref2 => {
65
+ let [, calculator] = _ref2;
66
+ return calculator.process(index, context);
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Finalizes all calculators (triggers all calculators after calculating the rows/columns sizes).
72
+ *
73
+ * @param {*} context The context object (rows or columns viewport calculator).
74
+ */
75
+ _finalize(context) {
76
+ this.calculationTypes.forEach(_ref3 => {
77
+ let [, calculator] = _ref3;
78
+ return calculator.finalize(context);
79
+ });
80
+ }
81
+
82
+ /**
83
+ * Gets the results for the given calculator.
84
+ *
85
+ * @param {string} calculatorId The id of the calculator.
86
+ * @returns {ColumnsCalculationType | RowsCalculationType}
87
+ */
88
+ getResultsFor(calculatorId) {
89
+ return this.calculationResults.get(calculatorId);
90
+ }
91
+ }
92
+ exports.ViewportBaseCalculator = ViewportBaseCalculator;
@@ -0,0 +1,88 @@
1
+ import "core-js/modules/es.error.cause.js";
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
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
+ /**
6
+ * @typedef {object} ColumnsCalculationType
7
+ * @property {number | null} startColumn The column index of the first column in the viewport.
8
+ * @property {number | null} endColumn The column index of the last column in the viewport.
9
+ * @property {number} count Total number of columns.
10
+ * @property {number | null} startPosition Position of the first fully column (in px).
11
+ * @property {boolean} isVisibleInTrimmingContainer Determines if the viewport is visible in the trimming container.
12
+ */
13
+ /**
14
+ * @typedef {object} RowsCalculationType
15
+ * @property {number | null} startRow The row index of the first row in the viewport.
16
+ * @property {number | null} endRow The row index of the last row in the viewport.
17
+ * @property {number} count Total number of rows.
18
+ * @property {number | null} startPosition Position of the first fully row (in px).
19
+ * @property {boolean} isVisibleInTrimmingContainer Determines if the viewport is visible in the trimming container.
20
+ */
21
+ /**
22
+ * @class ViewportBaseCalculator
23
+ */
24
+ export class ViewportBaseCalculator {
25
+ constructor(calculationTypes) {
26
+ /**
27
+ * The calculation types to be performed.
28
+ *
29
+ * @type {Array}
30
+ */
31
+ _defineProperty(this, "calculationTypes", []);
32
+ /**
33
+ * The calculation results.
34
+ *
35
+ * @type {Map<string, ColumnsCalculationType | RowsCalculationType>}
36
+ */
37
+ _defineProperty(this, "calculationResults", new Map());
38
+ this.calculationTypes = calculationTypes;
39
+ }
40
+
41
+ /**
42
+ * Initializes all calculators (triggers all calculators before calculating the rows/columns sizes).
43
+ *
44
+ * @param {*} context The context object (rows or columns viewport calculator).
45
+ */
46
+ _initialize(context) {
47
+ this.calculationTypes.forEach(_ref => {
48
+ let [id, calculator] = _ref;
49
+ this.calculationResults.set(id, calculator);
50
+ calculator.initialize(context);
51
+ });
52
+ }
53
+
54
+ /**
55
+ * Processes the row/column at the given index.
56
+ *
57
+ * @param {number} index The index of the row/column.
58
+ * @param {*} context The context object (rows or columns viewport calculator).
59
+ */
60
+ _process(index, context) {
61
+ this.calculationTypes.forEach(_ref2 => {
62
+ let [, calculator] = _ref2;
63
+ return calculator.process(index, context);
64
+ });
65
+ }
66
+
67
+ /**
68
+ * Finalizes all calculators (triggers all calculators after calculating the rows/columns sizes).
69
+ *
70
+ * @param {*} context The context object (rows or columns viewport calculator).
71
+ */
72
+ _finalize(context) {
73
+ this.calculationTypes.forEach(_ref3 => {
74
+ let [, calculator] = _ref3;
75
+ return calculator.finalize(context);
76
+ });
77
+ }
78
+
79
+ /**
80
+ * Gets the results for the given calculator.
81
+ *
82
+ * @param {string} calculatorId The id of the calculator.
83
+ * @returns {ColumnsCalculationType | RowsCalculationType}
84
+ */
85
+ getResultsFor(calculatorId) {
86
+ return this.calculationResults.get(calculatorId);
87
+ }
88
+ }
@@ -2,89 +2,61 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  require("core-js/modules/es.error.cause.js");
5
- require("core-js/modules/es.array.at.js");
6
5
  require("core-js/modules/es.array.push.js");
7
- var _constants = require("./constants");
8
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
9
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
6
+ var _viewportBase = require("./viewportBase");
10
7
  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; }
11
8
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
12
9
  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); }
13
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
14
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
15
- function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
10
+ const DEFAULT_WIDTH = exports.DEFAULT_WIDTH = 50;
11
+
16
12
  /**
17
13
  * @typedef {object} ViewportColumnsCalculatorOptions
14
+ * @property {Map<string, ViewportBaseCalculator>} calculationTypes The calculation types to be performed.
18
15
  * @property {number} viewportWidth Width of the viewport.
19
16
  * @property {number} scrollOffset Current horizontal scroll position of the viewport.
20
17
  * @property {number} totalColumns Total number of columns.
21
18
  * @property {Function} columnWidthFn Function that returns the width of the column at a given index (in px).
22
- * @property {Function} overrideFn Function that changes calculated this.startRow, this.endRow (used by
23
- * MergeCells plugin).
24
- * @property {string} calculationType String which describes types of calculation which will be performed.
19
+ * @property {Function} overrideFn Function that allows to adjust the `startRow` and `endRow` parameters.
25
20
  * @property {string} inlineStartOffset Inline-start offset of the parent container.
26
- * @property {string} stretchMode Stretch mode 'all' or 'last'.
27
- * @property {Function} stretchingColumnWidthFn Function that returns the new width of the stretched column.
28
21
  */
29
22
  /**
30
- * Calculates indexes of columns to render OR columns that are visible.
31
- * To redo the calculation, you need to create a new calculator.
23
+ * Calculates indexes of columns to render OR columns that are visible OR partially visible in the viewport.
32
24
  *
33
25
  * @class ViewportColumnsCalculator
34
26
  */
35
- var _options = /*#__PURE__*/new WeakMap();
36
- class ViewportColumnsCalculator {
37
- /**
38
- * Default column width.
39
- *
40
- * @type {number}
41
- */
42
- static get DEFAULT_WIDTH() {
43
- return 50;
44
- }
45
-
46
- /**
47
- * Number of rendered/visible columns.
48
- *
49
- * @type {number}
50
- */
51
-
27
+ class ViewportColumnsCalculator extends _viewportBase.ViewportBaseCalculator {
52
28
  /**
53
29
  * @param {ViewportColumnsCalculatorOptions} options Object with all options specified for column viewport calculation.
54
30
  */
55
- constructor(options) {
56
- _defineProperty(this, "count", 0);
57
- /**
58
- * Index of the first rendered/visible column (can be overwritten using overrideFn).
59
- *
60
- * @type {number|null}
61
- */
62
- _defineProperty(this, "startColumn", null);
63
- /**
64
- * Index of the last rendered/visible column (can be overwritten using overrideFn).
65
- *
66
- * @type {null}
67
- */
68
- _defineProperty(this, "endColumn", null);
69
- /**
70
- * Position of the first rendered/visible column (in px).
71
- *
72
- * @type {number|null}
73
- */
74
- _defineProperty(this, "startPosition", null);
75
- /**
76
- * Determines if the viewport is visible in the trimming container.
77
- *
78
- * @type {boolean}
79
- */
80
- _defineProperty(this, "isVisibleInTrimmingContainer", false);
81
- /**
82
- * The calculator options.
83
- *
84
- * @type {ViewportColumnsCalculatorOptions}
85
- */
86
- _classPrivateFieldInitSpec(this, _options, void 0);
87
- _classPrivateFieldSet(_options, this, options);
31
+ constructor(_ref) {
32
+ let {
33
+ calculationTypes,
34
+ viewportWidth,
35
+ scrollOffset,
36
+ totalColumns,
37
+ columnWidthFn,
38
+ overrideFn,
39
+ inlineStartOffset
40
+ } = _ref;
41
+ super(calculationTypes);
42
+ _defineProperty(this, "viewportWidth", 0);
43
+ _defineProperty(this, "scrollOffset", 0);
44
+ _defineProperty(this, "zeroBasedScrollOffset", 0);
45
+ _defineProperty(this, "totalColumns", 0);
46
+ _defineProperty(this, "columnWidthFn", null);
47
+ _defineProperty(this, "columnWidth", 0);
48
+ _defineProperty(this, "overrideFn", null);
49
+ _defineProperty(this, "inlineStartOffset", 0);
50
+ _defineProperty(this, "totalCalculatedWidth", 0);
51
+ _defineProperty(this, "startPositions", []);
52
+ _defineProperty(this, "needReverse", true);
53
+ this.viewportWidth = viewportWidth;
54
+ this.scrollOffset = scrollOffset;
55
+ this.zeroBasedScrollOffset = Math.max(scrollOffset, 0);
56
+ this.totalColumns = totalColumns;
57
+ this.columnWidthFn = columnWidthFn;
58
+ this.overrideFn = overrideFn;
59
+ this.inlineStartOffset = inlineStartOffset;
88
60
  this.calculate();
89
61
  }
90
62
 
@@ -92,96 +64,30 @@ class ViewportColumnsCalculator {
92
64
  * Calculates viewport.
93
65
  */
94
66
  calculate() {
95
- const {
96
- calculationType,
97
- overrideFn,
98
- scrollOffset,
99
- totalColumns,
100
- viewportWidth
101
- } = _classPrivateFieldGet(_options, this);
102
- const zeroBasedScrollOffset = Math.max(_classPrivateFieldGet(_options, this).scrollOffset, 0);
103
- // +1 pixel for row header width compensation for horizontal scroll > 0
104
- const compensatedViewportWidth = zeroBasedScrollOffset > 0 ? viewportWidth + 1 : viewportWidth;
105
- let sum = 0;
106
- let needReverse = true;
107
- const startPositions = [];
108
- let columnWidth;
109
- let firstVisibleColumnWidth = 0;
110
- let lastVisibleColumnWidth = 0;
111
- for (let i = 0; i < totalColumns; i++) {
112
- columnWidth = this._getColumnWidth(i);
113
- if (sum <= zeroBasedScrollOffset && calculationType !== _constants.FULLY_VISIBLE_TYPE) {
114
- this.startColumn = i;
115
- firstVisibleColumnWidth = columnWidth;
116
- }
117
- if (sum >= zeroBasedScrollOffset && sum + (calculationType === _constants.FULLY_VISIBLE_TYPE ? columnWidth : 0) <= zeroBasedScrollOffset + compensatedViewportWidth) {
118
- if (this.startColumn === null || this.startColumn === undefined) {
119
- this.startColumn = i;
120
- firstVisibleColumnWidth = columnWidth;
121
- }
122
- this.endColumn = i;
123
- }
124
- startPositions.push(sum);
125
- sum += columnWidth;
126
- lastVisibleColumnWidth = columnWidth;
127
- if (calculationType !== _constants.FULLY_VISIBLE_TYPE) {
128
- this.endColumn = i;
129
- }
130
- if (sum >= zeroBasedScrollOffset + viewportWidth) {
131
- needReverse = false;
67
+ this._initialize(this);
68
+ for (let column = 0; column < this.totalColumns; column++) {
69
+ this.columnWidth = this.getColumnWidth(column);
70
+ this._process(column, this);
71
+ this.startPositions.push(this.totalCalculatedWidth);
72
+ this.totalCalculatedWidth += this.columnWidth;
73
+ if (this.totalCalculatedWidth >= this.zeroBasedScrollOffset + this.viewportWidth) {
74
+ this.needReverse = false;
132
75
  break;
133
76
  }
134
77
  }
135
- const mostRightScrollOffset = scrollOffset + viewportWidth - compensatedViewportWidth;
136
- const inlineEndColumnOffset = calculationType === _constants.FULLY_VISIBLE_TYPE ? 0 : lastVisibleColumnWidth;
137
- const inlineStartColumnOffset = calculationType === _constants.FULLY_VISIBLE_TYPE ? firstVisibleColumnWidth : 0;
138
- if (
139
- // the table is to the left of the viewport
140
- mostRightScrollOffset < -1 * _classPrivateFieldGet(_options, this).inlineStartOffset || scrollOffset > startPositions.at(-1) + inlineEndColumnOffset ||
141
- // the table is to the right of the viewport
142
- -1 * _classPrivateFieldGet(_options, this).scrollOffset - _classPrivateFieldGet(_options, this).viewportWidth > -1 * inlineStartColumnOffset) {
143
- this.isVisibleInTrimmingContainer = false;
144
- } else {
145
- this.isVisibleInTrimmingContainer = true;
146
- }
147
- if (this.endColumn === totalColumns - 1 && needReverse) {
148
- this.startColumn = this.endColumn;
149
- while (this.startColumn > 0) {
150
- const viewportSum = startPositions[this.endColumn] + columnWidth - startPositions[this.startColumn - 1];
151
- if (viewportSum <= viewportWidth || calculationType !== _constants.FULLY_VISIBLE_TYPE) {
152
- this.startColumn -= 1;
153
- }
154
- if (viewportSum > viewportWidth) {
155
- break;
156
- }
157
- }
158
- }
159
- if (calculationType === _constants.RENDER_TYPE && this.startColumn !== null && overrideFn) {
160
- overrideFn(this);
161
- }
162
- this.startPosition = startPositions[this.startColumn];
163
- if (this.startPosition === undefined) {
164
- this.startPosition = null;
165
- }
166
-
167
- // If totalColumns exceeded its total columns size set endColumn to the latest item
168
- if (totalColumns < this.endColumn) {
169
- this.endColumn = totalColumns - 1;
170
- }
171
- if (this.startColumn !== null) {
172
- this.count = this.endColumn - this.startColumn + 1;
173
- }
78
+ this._finalize(this);
174
79
  }
175
80
 
176
81
  /**
177
- * @param {number} column The visual column index.
82
+ * Gets the column width at the specified column index.
83
+ *
84
+ * @param {number} column Column index.
178
85
  * @returns {number}
179
- * @private
180
86
  */
181
- _getColumnWidth(column) {
182
- let width = _classPrivateFieldGet(_options, this).columnWidthFn(column);
87
+ getColumnWidth(column) {
88
+ const width = this.columnWidthFn(column);
183
89
  if (isNaN(width)) {
184
- width = ViewportColumnsCalculator.DEFAULT_WIDTH;
90
+ return DEFAULT_WIDTH;
185
91
  }
186
92
  return width;
187
93
  }