handsontable 0.0.0-next-9891faa-20240822 → 0.0.0-next-0306a1a-20240826

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 (97) hide show
  1. package/3rdparty/walkontable/src/calculator/constants.js +26 -0
  2. package/3rdparty/walkontable/src/calculator/constants.mjs +23 -0
  3. package/3rdparty/walkontable/src/calculator/index.js +17 -18
  4. package/3rdparty/walkontable/src/calculator/index.mjs +6 -11
  5. package/3rdparty/walkontable/src/calculator/{calculationType/renderedAllColumns.js → renderAllColumns.js} +9 -32
  6. package/3rdparty/walkontable/src/calculator/{calculationType/renderedAllColumns.mjs → renderAllColumns.mjs} +8 -31
  7. package/3rdparty/walkontable/src/calculator/{calculationType/renderedAllRows.js → renderAllRows.js} +9 -32
  8. package/3rdparty/walkontable/src/calculator/{calculationType/renderedAllRows.mjs → renderAllRows.mjs} +8 -31
  9. package/3rdparty/walkontable/src/calculator/viewportColumns.js +145 -51
  10. package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +145 -51
  11. package/3rdparty/walkontable/src/calculator/viewportRows.js +141 -59
  12. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +141 -59
  13. package/3rdparty/walkontable/src/index.js +0 -2
  14. package/3rdparty/walkontable/src/index.mjs +2 -2
  15. package/3rdparty/walkontable/src/table.js +11 -5
  16. package/3rdparty/walkontable/src/table.mjs +11 -5
  17. package/3rdparty/walkontable/src/utils/column.js +1 -2
  18. package/3rdparty/walkontable/src/utils/column.mjs +1 -2
  19. package/3rdparty/walkontable/src/utils/columnStretching.js +19 -10
  20. package/3rdparty/walkontable/src/utils/columnStretching.mjs +19 -10
  21. package/3rdparty/walkontable/src/viewport.js +46 -35
  22. package/3rdparty/walkontable/src/viewport.mjs +47 -36
  23. package/CHANGELOG.md +0 -27
  24. package/base.js +2 -2
  25. package/base.mjs +2 -2
  26. package/core.d.ts +2 -1
  27. package/core.js +1 -1
  28. package/core.mjs +2 -2
  29. package/dataMap/metaManager/metaSchema.js +6 -5
  30. package/dataMap/metaManager/metaSchema.mjs +6 -5
  31. package/dist/handsontable.css +20 -32
  32. package/dist/handsontable.full.css +20 -32
  33. package/dist/handsontable.full.js +2085 -2703
  34. package/dist/handsontable.full.min.css +5 -5
  35. package/dist/handsontable.full.min.js +148 -148
  36. package/dist/handsontable.js +2086 -2704
  37. package/dist/handsontable.min.css +4 -4
  38. package/dist/handsontable.min.js +14 -14
  39. package/editors/autocompleteEditor/autocompleteEditor.d.ts +1 -1
  40. package/helpers/a11y.js +0 -2
  41. package/helpers/a11y.mjs +0 -1
  42. package/helpers/mixed.js +2 -2
  43. package/helpers/mixed.mjs +2 -2
  44. package/package.json +1 -1
  45. package/pluginHooks.js +1 -0
  46. package/pluginHooks.mjs +1 -0
  47. package/plugins/autoColumnSize/autoColumnSize.js +1 -1
  48. package/plugins/autoColumnSize/autoColumnSize.mjs +2 -2
  49. package/plugins/autoRowSize/autoRowSize.js +2 -1
  50. package/plugins/autoRowSize/autoRowSize.mjs +2 -1
  51. package/plugins/columnSorting/columnSorting.js +1 -10
  52. package/plugins/columnSorting/columnSorting.mjs +1 -10
  53. package/plugins/contextMenu/menu/menuItemRenderer.js +4 -3
  54. package/plugins/contextMenu/menu/menuItemRenderer.mjs +6 -5
  55. package/plugins/contextMenu/menu/positioner.js +12 -4
  56. package/plugins/contextMenu/menu/positioner.mjs +12 -4
  57. package/plugins/contextMenu/menu/utils.js +0 -11
  58. package/plugins/contextMenu/menu/utils.mjs +0 -10
  59. package/plugins/contextMenu/predefinedItems/alignment.js +49 -67
  60. package/plugins/contextMenu/predefinedItems/alignment.mjs +50 -68
  61. package/plugins/contextMenu/predefinedItems/readOnly.js +0 -11
  62. package/plugins/contextMenu/predefinedItems/readOnly.mjs +0 -11
  63. package/plugins/contextMenu/utils.js +0 -26
  64. package/plugins/contextMenu/utils.mjs +0 -24
  65. package/plugins/copyPaste/copyPaste.js +14 -14
  66. package/plugins/copyPaste/copyPaste.mjs +14 -14
  67. package/plugins/dropdownMenu/dropdownMenu.js +4 -10
  68. package/plugins/dropdownMenu/dropdownMenu.mjs +4 -10
  69. package/plugins/filters/component/condition.js +1 -6
  70. package/plugins/filters/component/condition.mjs +1 -6
  71. package/plugins/filters/component/value.js +1 -6
  72. package/plugins/filters/component/value.mjs +1 -6
  73. package/plugins/filters/conditionCollection.d.ts +3 -4
  74. package/plugins/filters/ui/multipleSelect.js +9 -7
  75. package/plugins/filters/ui/multipleSelect.mjs +9 -7
  76. package/plugins/manualRowResize/manualRowResize.js +1 -1
  77. package/plugins/manualRowResize/manualRowResize.mjs +2 -2
  78. package/plugins/mergeCells/cellsCollection.js +9 -11
  79. package/plugins/mergeCells/cellsCollection.mjs +10 -12
  80. package/shortcuts/utils.js +1 -3
  81. package/shortcuts/utils.mjs +1 -3
  82. package/utils/ghostTable.js +9 -11
  83. package/utils/ghostTable.mjs +10 -12
  84. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleColumns.js +0 -126
  85. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleColumns.mjs +0 -122
  86. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleRows.js +0 -119
  87. package/3rdparty/walkontable/src/calculator/calculationType/fullyVisibleRows.mjs +0 -115
  88. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleColumns.js +0 -125
  89. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleColumns.mjs +0 -121
  90. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleRows.js +0 -118
  91. package/3rdparty/walkontable/src/calculator/calculationType/partiallyVisibleRows.mjs +0 -114
  92. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.js +0 -37
  93. package/3rdparty/walkontable/src/calculator/calculationType/renderedColumns.mjs +0 -33
  94. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.js +0 -37
  95. package/3rdparty/walkontable/src/calculator/calculationType/renderedRows.mjs +0 -33
  96. package/3rdparty/walkontable/src/calculator/viewportBase.js +0 -92
  97. package/3rdparty/walkontable/src/calculator/viewportBase.mjs +0 -88
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ /**
5
+ * Render type calculation calculates how many DOM nodes should be created and where placed
6
+ * based on `startRow` and `endRow` properties.
7
+ *
8
+ * @type {number}
9
+ */
10
+ const RENDER_TYPE = exports.RENDER_TYPE = 1;
11
+ /**
12
+ * Fully visible type calculation calculates rows that are fully visible in the viewport.
13
+ * This type of calculation is used in scrolling by arrow keys navigation.
14
+ *
15
+ * @type {number}
16
+ */
17
+ const FULLY_VISIBLE_TYPE = exports.FULLY_VISIBLE_TYPE = 2;
18
+ /**
19
+ * Partially visible type calculation calculates rows that are fully and partially visible in
20
+ * the viewport. This type of calculation is used to check `endRow` (or `startRow`) with properties
21
+ * calculated in render calculator. If checking met the criteria slow render is
22
+ * performed (which render calculator with new data).
23
+ *
24
+ * @type {number}
25
+ */
26
+ const PARTIALLY_VISIBLE_TYPE = exports.PARTIALLY_VISIBLE_TYPE = 3;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Render type calculation calculates how many DOM nodes should be created and where placed
3
+ * based on `startRow` and `endRow` properties.
4
+ *
5
+ * @type {number}
6
+ */
7
+ export const RENDER_TYPE = 1;
8
+ /**
9
+ * Fully visible type calculation calculates rows that are fully visible in the viewport.
10
+ * This type of calculation is used in scrolling by arrow keys navigation.
11
+ *
12
+ * @type {number}
13
+ */
14
+ export const FULLY_VISIBLE_TYPE = 2;
15
+ /**
16
+ * Partially visible type calculation calculates rows that are fully and partially visible in
17
+ * the viewport. This type of calculation is used to check `endRow` (or `startRow`) with properties
18
+ * calculated in render calculator. If checking met the criteria slow render is
19
+ * performed (which render calculator with new data).
20
+ *
21
+ * @type {number}
22
+ */
23
+ export const PARTIALLY_VISIBLE_TYPE = 3;
@@ -1,25 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
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;
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;
20
14
  var _viewportColumns = require("./viewportColumns");
21
15
  exports.ViewportColumnsCalculator = _viewportColumns.ViewportColumnsCalculator;
22
- exports.DEFAULT_COLUMN_WIDTH = _viewportColumns.DEFAULT_WIDTH;
23
16
  var _viewportRows = require("./viewportRows");
24
17
  exports.ViewportRowsCalculator = _viewportRows.ViewportRowsCalculator;
25
- exports.DEFAULT_ROW_HEIGHT = _viewportRows.DEFAULT_HEIGHT;
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
+ });
@@ -1,11 +1,6 @@
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 };
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 };
@@ -6,16 +6,19 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
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
8
  /**
9
- * @typedef {object} RenderedAllColumnsCalculatorOptions
9
+ * @typedef {object} RenderAllColumnsCalculatorOptions
10
10
  * @property {number} totalColumns Total number of columns.
11
11
  */
12
12
  /**
13
13
  * Holds all calculations needed to perform the rendering of all columns.
14
14
  *
15
- * @class RenderedAllColumnsCalculationType
15
+ * @class RenderAllColumnsCalculator
16
16
  */
17
- class RenderedAllColumnsCalculationType {
18
- constructor() {
17
+ class RenderAllColumnsCalculator {
18
+ /**
19
+ * @param {RenderAllColumnsCalculatorOptions} options Object with all options specified for column viewport calculation.
20
+ */
21
+ constructor(options) {
19
22
  /**
20
23
  * Number of rendered/visible columns.
21
24
  *
@@ -40,34 +43,8 @@ class RenderedAllColumnsCalculationType {
40
43
  * @type {number}
41
44
  */
42
45
  _defineProperty(this, "startPosition", 0);
43
- /**
44
- * Determines if the viewport is visible in the trimming container.
45
- *
46
- * @type {boolean}
47
- */
48
- _defineProperty(this, "isVisibleInTrimmingContainer", true);
49
- }
50
- /**
51
- * Initializes the calculation.
52
- *
53
- * @param {ViewportColumnsCalculator} viewportCalculator The viewport calculator object.
54
- */
55
- initialize(_ref) {
56
- let {
57
- totalColumns
58
- } = _ref;
59
- this.count = totalColumns;
46
+ this.count = options.totalColumns;
60
47
  this.endColumn = this.count - 1;
61
48
  }
62
-
63
- /**
64
- * Processes the column.
65
- */
66
- process() {}
67
-
68
- /**
69
- * Finalizes the calculation.
70
- */
71
- finalize() {}
72
49
  }
73
- exports.RenderedAllColumnsCalculationType = RenderedAllColumnsCalculationType;
50
+ exports.RenderAllColumnsCalculator = RenderAllColumnsCalculator;
@@ -3,16 +3,19 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
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
5
  /**
6
- * @typedef {object} RenderedAllColumnsCalculatorOptions
6
+ * @typedef {object} RenderAllColumnsCalculatorOptions
7
7
  * @property {number} totalColumns Total number of columns.
8
8
  */
9
9
  /**
10
10
  * Holds all calculations needed to perform the rendering of all columns.
11
11
  *
12
- * @class RenderedAllColumnsCalculationType
12
+ * @class RenderAllColumnsCalculator
13
13
  */
14
- export class RenderedAllColumnsCalculationType {
15
- constructor() {
14
+ export class RenderAllColumnsCalculator {
15
+ /**
16
+ * @param {RenderAllColumnsCalculatorOptions} options Object with all options specified for column viewport calculation.
17
+ */
18
+ constructor(options) {
16
19
  /**
17
20
  * Number of rendered/visible columns.
18
21
  *
@@ -37,33 +40,7 @@ export class RenderedAllColumnsCalculationType {
37
40
  * @type {number}
38
41
  */
39
42
  _defineProperty(this, "startPosition", 0);
40
- /**
41
- * Determines if the viewport is visible in the trimming container.
42
- *
43
- * @type {boolean}
44
- */
45
- _defineProperty(this, "isVisibleInTrimmingContainer", true);
46
- }
47
- /**
48
- * Initializes the calculation.
49
- *
50
- * @param {ViewportColumnsCalculator} viewportCalculator The viewport calculator object.
51
- */
52
- initialize(_ref) {
53
- let {
54
- totalColumns
55
- } = _ref;
56
- this.count = totalColumns;
43
+ this.count = options.totalColumns;
57
44
  this.endColumn = this.count - 1;
58
45
  }
59
-
60
- /**
61
- * Processes the column.
62
- */
63
- process() {}
64
-
65
- /**
66
- * Finalizes the calculation.
67
- */
68
- finalize() {}
69
46
  }
@@ -6,16 +6,19 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
6
6
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
7
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
8
  /**
9
- * @typedef {object} RenderedAllRowsCalculatorOptions
9
+ * @typedef {object} RenderAllRowsCalculatorOptions
10
10
  * @property {number} totalRows Total number of rows.
11
11
  */
12
12
  /**
13
13
  * Holds all calculations needed to perform the rendering of all rows.
14
14
  *
15
- * @class RenderedAllRowsCalculationType
15
+ * @class RenderAllRowsCalculator
16
16
  */
17
- class RenderedAllRowsCalculationType {
18
- constructor() {
17
+ class RenderAllRowsCalculator {
18
+ /**
19
+ * @param {RenderAllRowsCalculatorOptions} options Object with all options specified for row viewport calculation.
20
+ */
21
+ constructor(options) {
19
22
  /**
20
23
  * Number of rendered/visible rows.
21
24
  *
@@ -40,34 +43,8 @@ class RenderedAllRowsCalculationType {
40
43
  * @type {number}
41
44
  */
42
45
  _defineProperty(this, "startPosition", 0);
43
- /**
44
- * Determines if the viewport is visible in the trimming container.
45
- *
46
- * @type {boolean}
47
- */
48
- _defineProperty(this, "isVisibleInTrimmingContainer", true);
49
- }
50
- /**
51
- * Initializes the calculation.
52
- *
53
- * @param {ViewportRowsCalculator} viewportCalculator The viewport calculator object.
54
- */
55
- initialize(_ref) {
56
- let {
57
- totalRows
58
- } = _ref;
59
- this.count = totalRows;
46
+ this.count = options.totalRows;
60
47
  this.endRow = this.count - 1;
61
48
  }
62
-
63
- /**
64
- * Processes the row.
65
- */
66
- process() {}
67
-
68
- /**
69
- * Finalizes the calculation.
70
- */
71
- finalize() {}
72
49
  }
73
- exports.RenderedAllRowsCalculationType = RenderedAllRowsCalculationType;
50
+ exports.RenderAllRowsCalculator = RenderAllRowsCalculator;
@@ -3,16 +3,19 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
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
5
  /**
6
- * @typedef {object} RenderedAllRowsCalculatorOptions
6
+ * @typedef {object} RenderAllRowsCalculatorOptions
7
7
  * @property {number} totalRows Total number of rows.
8
8
  */
9
9
  /**
10
10
  * Holds all calculations needed to perform the rendering of all rows.
11
11
  *
12
- * @class RenderedAllRowsCalculationType
12
+ * @class RenderAllRowsCalculator
13
13
  */
14
- export class RenderedAllRowsCalculationType {
15
- constructor() {
14
+ export class RenderAllRowsCalculator {
15
+ /**
16
+ * @param {RenderAllRowsCalculatorOptions} options Object with all options specified for row viewport calculation.
17
+ */
18
+ constructor(options) {
16
19
  /**
17
20
  * Number of rendered/visible rows.
18
21
  *
@@ -37,33 +40,7 @@ export class RenderedAllRowsCalculationType {
37
40
  * @type {number}
38
41
  */
39
42
  _defineProperty(this, "startPosition", 0);
40
- /**
41
- * Determines if the viewport is visible in the trimming container.
42
- *
43
- * @type {boolean}
44
- */
45
- _defineProperty(this, "isVisibleInTrimmingContainer", true);
46
- }
47
- /**
48
- * Initializes the calculation.
49
- *
50
- * @param {ViewportRowsCalculator} viewportCalculator The viewport calculator object.
51
- */
52
- initialize(_ref) {
53
- let {
54
- totalRows
55
- } = _ref;
56
- this.count = totalRows;
43
+ this.count = options.totalRows;
57
44
  this.endRow = this.count - 1;
58
45
  }
59
-
60
- /**
61
- * Processes the row.
62
- */
63
- process() {}
64
-
65
- /**
66
- * Finalizes the calculation.
67
- */
68
- finalize() {}
69
46
  }
@@ -2,61 +2,89 @@
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");
5
6
  require("core-js/modules/es.array.push.js");
6
- var _viewportBase = require("./viewportBase");
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"); }
7
10
  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
11
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
9
12
  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); }
10
- const DEFAULT_WIDTH = exports.DEFAULT_WIDTH = 50;
11
-
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"); }
12
16
  /**
13
17
  * @typedef {object} ViewportColumnsCalculatorOptions
14
- * @property {Map<string, ViewportBaseCalculator>} calculationTypes The calculation types to be performed.
15
18
  * @property {number} viewportWidth Width of the viewport.
16
19
  * @property {number} scrollOffset Current horizontal scroll position of the viewport.
17
20
  * @property {number} totalColumns Total number of columns.
18
21
  * @property {Function} columnWidthFn Function that returns the width of the column at a given index (in px).
19
- * @property {Function} overrideFn Function that allows to adjust the `startRow` and `endRow` parameters.
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.
20
25
  * @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.
21
28
  */
22
29
  /**
23
- * Calculates indexes of columns to render OR columns that are visible OR partially visible in the viewport.
30
+ * Calculates indexes of columns to render OR columns that are visible.
31
+ * To redo the calculation, you need to create a new calculator.
24
32
  *
25
33
  * @class ViewportColumnsCalculator
26
34
  */
27
- class ViewportColumnsCalculator extends _viewportBase.ViewportBaseCalculator {
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
+
28
52
  /**
29
53
  * @param {ViewportColumnsCalculatorOptions} options Object with all options specified for column viewport calculation.
30
54
  */
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;
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);
60
88
  this.calculate();
61
89
  }
62
90
 
@@ -64,30 +92,96 @@ class ViewportColumnsCalculator extends _viewportBase.ViewportBaseCalculator {
64
92
  * Calculates viewport.
65
93
  */
66
94
  calculate() {
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;
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;
75
132
  break;
76
133
  }
77
134
  }
78
- this._finalize(this);
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
+ }
79
174
  }
80
175
 
81
176
  /**
82
- * Gets the column width at the specified column index.
83
- *
84
- * @param {number} column Column index.
177
+ * @param {number} column The visual column index.
85
178
  * @returns {number}
179
+ * @private
86
180
  */
87
- getColumnWidth(column) {
88
- const width = this.columnWidthFn(column);
181
+ _getColumnWidth(column) {
182
+ let width = _classPrivateFieldGet(_options, this).columnWidthFn(column);
89
183
  if (isNaN(width)) {
90
- return DEFAULT_WIDTH;
184
+ width = ViewportColumnsCalculator.DEFAULT_WIDTH;
91
185
  }
92
186
  return width;
93
187
  }