handsontable 0.0.0-next-802f59c-20241024 → 0.0.0-next-627918e-20241025

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 (128) hide show
  1. package/3rdparty/walkontable/src/calculator/index.js +1 -2
  2. package/3rdparty/walkontable/src/calculator/index.mjs +2 -2
  3. package/3rdparty/walkontable/src/calculator/viewportRows.js +3 -3
  4. package/3rdparty/walkontable/src/calculator/viewportRows.mjs +3 -3
  5. package/3rdparty/walkontable/src/core/_base.js +3 -0
  6. package/3rdparty/walkontable/src/core/_base.mjs +3 -0
  7. package/3rdparty/walkontable/src/core/clone.js +1 -0
  8. package/3rdparty/walkontable/src/core/clone.mjs +1 -0
  9. package/3rdparty/walkontable/src/core/core.js +2 -0
  10. package/3rdparty/walkontable/src/core/core.mjs +2 -0
  11. package/3rdparty/walkontable/src/facade/core.js +3 -0
  12. package/3rdparty/walkontable/src/facade/core.mjs +3 -0
  13. package/3rdparty/walkontable/src/index.js +0 -1
  14. package/3rdparty/walkontable/src/index.mjs +2 -2
  15. package/3rdparty/walkontable/src/overlay/_base.js +3 -1
  16. package/3rdparty/walkontable/src/overlay/_base.mjs +3 -1
  17. package/3rdparty/walkontable/src/overlay/bottom.js +2 -2
  18. package/3rdparty/walkontable/src/overlay/bottom.mjs +2 -2
  19. package/3rdparty/walkontable/src/overlay/inlineStart.js +1 -1
  20. package/3rdparty/walkontable/src/overlay/inlineStart.mjs +1 -1
  21. package/3rdparty/walkontable/src/overlay/top.js +1 -1
  22. package/3rdparty/walkontable/src/overlay/top.mjs +1 -1
  23. package/3rdparty/walkontable/src/overlays.js +6 -7
  24. package/3rdparty/walkontable/src/overlays.mjs +6 -7
  25. package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
  26. package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
  27. package/3rdparty/walkontable/src/renderer/table.js +1 -1
  28. package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
  29. package/3rdparty/walkontable/src/settings.js +8 -2
  30. package/3rdparty/walkontable/src/settings.mjs +8 -2
  31. package/3rdparty/walkontable/src/table.js +35 -8
  32. package/3rdparty/walkontable/src/table.mjs +35 -8
  33. package/3rdparty/walkontable/src/types.js +1 -0
  34. package/3rdparty/walkontable/src/types.mjs +1 -0
  35. package/3rdparty/walkontable/src/utils/column.js +43 -1
  36. package/3rdparty/walkontable/src/utils/column.mjs +43 -1
  37. package/3rdparty/walkontable/src/utils/columnStretching.js +197 -0
  38. package/3rdparty/walkontable/src/utils/columnStretching.mjs +193 -0
  39. package/3rdparty/walkontable/src/utils/stylesHandler.js +179 -0
  40. package/3rdparty/walkontable/src/utils/stylesHandler.mjs +175 -0
  41. package/3rdparty/walkontable/src/viewport.js +88 -66
  42. package/3rdparty/walkontable/src/viewport.mjs +89 -67
  43. package/base.js +2 -2
  44. package/base.mjs +2 -2
  45. package/core/hooks/constants.js +0 -2
  46. package/core/hooks/constants.mjs +0 -2
  47. package/core/hooks/index.d.ts +2 -2
  48. package/core.d.ts +2 -2
  49. package/core.js +18 -6
  50. package/core.mjs +18 -6
  51. package/dataMap/metaManager/metaSchema.js +17 -0
  52. package/dataMap/metaManager/metaSchema.mjs +17 -0
  53. package/dist/handsontable.css +17 -9
  54. package/dist/handsontable.full.css +17 -7
  55. package/dist/handsontable.full.js +4217 -4534
  56. package/dist/handsontable.full.min.css +5 -4
  57. package/dist/handsontable.full.min.js +26 -26
  58. package/dist/handsontable.js +3923 -4234
  59. package/dist/handsontable.min.css +5 -4
  60. package/dist/handsontable.min.js +24 -24
  61. package/editors/autocompleteEditor/autocompleteEditor.js +1 -1
  62. package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -1
  63. package/editors/baseEditor/baseEditor.js +1 -1
  64. package/editors/baseEditor/baseEditor.mjs +1 -1
  65. package/editors/dateEditor/dateEditor.js +2 -0
  66. package/editors/dateEditor/dateEditor.mjs +2 -0
  67. package/editors/handsontableEditor/handsontableEditor.js +1 -1
  68. package/editors/handsontableEditor/handsontableEditor.mjs +1 -1
  69. package/editors/selectEditor/selectEditor.js +20 -9
  70. package/editors/selectEditor/selectEditor.mjs +20 -9
  71. package/editors/textEditor/textEditor.js +4 -11
  72. package/editors/textEditor/textEditor.mjs +4 -11
  73. package/helpers/mixed.js +2 -2
  74. package/helpers/mixed.mjs +2 -2
  75. package/helpers/themes.js +17 -0
  76. package/helpers/themes.mjs +13 -0
  77. package/index.d.ts +0 -7
  78. package/package.json +10 -8
  79. package/plugins/comments/commentEditor.js +8 -1
  80. package/plugins/comments/commentEditor.mjs +8 -1
  81. package/plugins/comments/comments.js +2 -2
  82. package/plugins/comments/comments.mjs +2 -2
  83. package/plugins/contextMenu/menu/menu.js +4 -4
  84. package/plugins/contextMenu/menu/menu.mjs +4 -4
  85. package/plugins/index.d.ts +0 -3
  86. package/plugins/index.js +0 -3
  87. package/plugins/index.mjs +1 -3
  88. package/plugins/manualColumnMove/manualColumnMove.js +3 -1
  89. package/plugins/manualColumnMove/manualColumnMove.mjs +3 -1
  90. package/plugins/manualColumnResize/manualColumnResize.js +12 -24
  91. package/plugins/manualColumnResize/manualColumnResize.mjs +12 -24
  92. package/plugins/manualRowMove/manualRowMove.js +1 -1
  93. package/plugins/manualRowMove/manualRowMove.mjs +1 -1
  94. package/plugins/manualRowResize/manualRowResize.js +1 -2
  95. package/plugins/manualRowResize/manualRowResize.mjs +2 -3
  96. package/plugins/mergeCells/mergeCells.js +1 -1
  97. package/plugins/mergeCells/mergeCells.mjs +1 -1
  98. package/plugins/nestedRows/ui/headers.js +3 -1
  99. package/plugins/nestedRows/ui/headers.mjs +3 -1
  100. package/settings.d.ts +1 -0
  101. package/styles/handsontable.css +1983 -0
  102. package/styles/handsontable.min.css +30 -0
  103. package/styles/ht-theme-gemini.css +706 -0
  104. package/styles/ht-theme-gemini.min.css +30 -0
  105. package/styles/ht-theme-main.css +714 -0
  106. package/styles/ht-theme-main.min.css +30 -0
  107. package/stylesManager.js +1 -0
  108. package/stylesManager.mjs +0 -0
  109. package/tableView.js +40 -39
  110. package/tableView.mjs +40 -39
  111. package/utils/autoResize.js +4 -1
  112. package/utils/autoResize.mjs +4 -1
  113. package/utils/ghostTable.js +1 -1
  114. package/utils/ghostTable.mjs +1 -1
  115. package/plugins/stretchColumns/calculator.js +0 -159
  116. package/plugins/stretchColumns/calculator.mjs +0 -155
  117. package/plugins/stretchColumns/index.d.ts +0 -1
  118. package/plugins/stretchColumns/index.js +0 -7
  119. package/plugins/stretchColumns/index.mjs +0 -1
  120. package/plugins/stretchColumns/strategies/_base.js +0 -85
  121. package/plugins/stretchColumns/strategies/_base.mjs +0 -81
  122. package/plugins/stretchColumns/strategies/all.js +0 -68
  123. package/plugins/stretchColumns/strategies/all.mjs +0 -64
  124. package/plugins/stretchColumns/strategies/last.js +0 -77
  125. package/plugins/stretchColumns/strategies/last.mjs +0 -73
  126. package/plugins/stretchColumns/stretchColumns.d.ts +0 -11
  127. package/plugins/stretchColumns/stretchColumns.js +0 -211
  128. package/plugins/stretchColumns/stretchColumns.mjs +0 -207
@@ -1,155 +0,0 @@
1
- import "core-js/modules/es.error.cause.js";
2
- function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
3
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
4
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
5
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
6
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
7
- 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"); }
8
- import { DEFAULT_COLUMN_WIDTH, DEFAULT_ROW_HEIGHT } from "../../3rdparty/walkontable/src/index.mjs";
9
- import { getScrollbarWidth } from "../../helpers/dom/element.mjs";
10
- import { StretchAllStrategy } from "./strategies/all.mjs";
11
- import { StretchLastStrategy } from "./strategies/last.mjs";
12
- const STRETCH_WIDTH_MAP_NAME = 'stretchColumns';
13
-
14
- /**
15
- * The class responsible for calculating the column widths based on the specified column stretching strategy.
16
- *
17
- * @private
18
- * @class StretchCalculator
19
- */
20
- var _hot = /*#__PURE__*/new WeakMap();
21
- var _widthsMap = /*#__PURE__*/new WeakMap();
22
- var _stretchStrategies = /*#__PURE__*/new WeakMap();
23
- var _activeStrategy = /*#__PURE__*/new WeakMap();
24
- var _StretchCalculator_brand = /*#__PURE__*/new WeakSet();
25
- export class StretchCalculator {
26
- constructor(hotInstance) {
27
- /**
28
- * Checks if the vertical scrollbar will appear. Based on the current data and viewport size
29
- * the method calculates if the vertical scrollbar will appear after the table is rendered.
30
- * The method is a workaround for the issue in the Walkontable that returns unstable viewport
31
- * size.
32
- *
33
- * @returns {boolean}
34
- */
35
- _classPrivateMethodInitSpec(this, _StretchCalculator_brand);
36
- /**
37
- * The Handsontable instance.
38
- *
39
- * @type {Core}
40
- */
41
- _classPrivateFieldInitSpec(this, _hot, void 0);
42
- /**
43
- * The map that stores the calculated column widths.
44
- *
45
- * @type {IndexToValueMap}
46
- */
47
- _classPrivateFieldInitSpec(this, _widthsMap, void 0);
48
- /**
49
- * The map that stores the available stretch strategies.
50
- *
51
- * @type {Map<string, StretchAllStrategy | StretchLastStrategy>}
52
- */
53
- _classPrivateFieldInitSpec(this, _stretchStrategies, new Map([['all', new StretchAllStrategy(_assertClassBrand(_StretchCalculator_brand, this, _overwriteColumnWidthFn).bind(this))], ['last', new StretchLastStrategy(_assertClassBrand(_StretchCalculator_brand, this, _overwriteColumnWidthFn).bind(this))]]));
54
- /**
55
- * The active stretch mode.
56
- *
57
- * @type {'all' | 'last' | 'none'}
58
- */
59
- _classPrivateFieldInitSpec(this, _activeStrategy, 'none');
60
- _classPrivateFieldSet(_hot, this, hotInstance);
61
- _classPrivateFieldSet(_widthsMap, this, _classPrivateFieldGet(_hot, this).columnIndexMapper.createAndRegisterIndexMap(STRETCH_WIDTH_MAP_NAME, 'physicalIndexToValue'));
62
- }
63
-
64
- /**
65
- * Sets the active stretch strategy.
66
- *
67
- * @param {'all' | 'last' | 'none'} strategyName The stretch strategy to use.
68
- */
69
- useStrategy(strategyName) {
70
- _classPrivateFieldSet(_activeStrategy, this, _classPrivateFieldGet(_stretchStrategies, this).has(strategyName) ? strategyName : 'none');
71
- }
72
-
73
- /**
74
- * Recalculates the column widths.
75
- */
76
- refreshStretching() {
77
- if (_classPrivateFieldGet(_activeStrategy, this) === 'none') {
78
- _classPrivateFieldGet(_widthsMap, this).clear();
79
- return;
80
- }
81
- _classPrivateFieldGet(_hot, this).batchExecution(() => {
82
- _classPrivateFieldGet(_widthsMap, this).clear();
83
- const stretchStrategy = _classPrivateFieldGet(_stretchStrategies, this).get(_classPrivateFieldGet(_activeStrategy, this));
84
- const view = _classPrivateFieldGet(_hot, this).view;
85
- let viewportWidth = view.getViewportWidth();
86
- if (_assertClassBrand(_StretchCalculator_brand, this, _willVerticalScrollAppear).call(this)) {
87
- viewportWidth -= getScrollbarWidth(_classPrivateFieldGet(_hot, this).rootDocument);
88
- }
89
- stretchStrategy.prepare({
90
- viewportWidth
91
- });
92
- for (let columnIndex = 0; columnIndex < _classPrivateFieldGet(_hot, this).countCols(); columnIndex++) {
93
- if (!_classPrivateFieldGet(_hot, this).columnIndexMapper.isHidden(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnIndex))) {
94
- stretchStrategy.setColumnBaseWidth(columnIndex, _assertClassBrand(_StretchCalculator_brand, this, _getWidthWithoutStretching).call(this, columnIndex));
95
- }
96
- }
97
- stretchStrategy.calculate();
98
- stretchStrategy.getWidths().forEach(_ref => {
99
- let [columnIndex, width] = _ref;
100
- _classPrivateFieldGet(_widthsMap, this).setValueAtIndex(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnIndex), width);
101
- });
102
- }, true);
103
- }
104
-
105
- /**
106
- * Gets the calculated column width.
107
- *
108
- * @param {number} columnVisualIndex Column visual index.
109
- * @returns {number | null}
110
- */
111
- getStretchedWidth(columnVisualIndex) {
112
- return _classPrivateFieldGet(_widthsMap, this).getValueAtIndex(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnVisualIndex));
113
- }
114
- }
115
- function _willVerticalScrollAppear() {
116
- const {
117
- view
118
- } = _classPrivateFieldGet(_hot, this);
119
- if (view.isVerticallyScrollableByWindow()) {
120
- return false;
121
- }
122
- const viewportHeight = view.getViewportHeight();
123
- const totalRows = _classPrivateFieldGet(_hot, this).countRows();
124
- let totalHeight = 0;
125
- let hasVerticalScroll = false;
126
- for (let row = 0; row < totalRows; row++) {
127
- var _classPrivateFieldGet2;
128
- totalHeight += ((_classPrivateFieldGet2 = _classPrivateFieldGet(_hot, this).getRowHeight(row)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : DEFAULT_ROW_HEIGHT) + (row === 0 ? 1 : 0);
129
- if (totalHeight > viewportHeight) {
130
- hasVerticalScroll = true;
131
- break;
132
- }
133
- }
134
- return hasVerticalScroll;
135
- }
136
- /**
137
- * Gets the column width from the Handsontable API without logic related to stretching.
138
- *
139
- * @param {number} columnVisualIndex Column visual index.
140
- * @returns {number}
141
- */
142
- function _getWidthWithoutStretching(columnVisualIndex) {
143
- var _classPrivateFieldGet3;
144
- return (_classPrivateFieldGet3 = _classPrivateFieldGet(_hot, this).getColWidth(columnVisualIndex, 'StretchColumns')) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : DEFAULT_COLUMN_WIDTH;
145
- }
146
- /**
147
- * Executes the hook that allows to overwrite the column width.
148
- *
149
- * @param {number} columnWidth The column width.
150
- * @param {number} columnVisualIndex Column visual index.
151
- * @returns {number}
152
- */
153
- function _overwriteColumnWidthFn(columnWidth, columnVisualIndex) {
154
- return _classPrivateFieldGet(_hot, this).runHooks('beforeStretchingColumnWidth', columnWidth, columnVisualIndex);
155
- }
@@ -1 +0,0 @@
1
- export * from './stretchColumns';
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- var _stretchColumns = require("./stretchColumns");
5
- exports.PLUGIN_KEY = _stretchColumns.PLUGIN_KEY;
6
- exports.PLUGIN_PRIORITY = _stretchColumns.PLUGIN_PRIORITY;
7
- exports.StretchColumns = _stretchColumns.StretchColumns;
@@ -1 +0,0 @@
1
- export { PLUGIN_KEY, PLUGIN_PRIORITY, StretchColumns } from "./stretchColumns.mjs";
@@ -1,85 +0,0 @@
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 StretchStrategyCalcArgs
10
- * @property {number} viewportWidth The width of the viewport.
11
- */
12
- /**
13
- * The base strategy stretching strategy to extend from.
14
- *
15
- * @private
16
- * @class StretchStrategy
17
- */
18
- class StretchStrategy {
19
- constructor(overwriteColumnWidthFn) {
20
- /**
21
- * The width of the viewport.
22
- *
23
- * @type {number}
24
- */
25
- _defineProperty(this, "viewportWidth", void 0);
26
- /**
27
- * The function to overwrite the column width.
28
- *
29
- * @type {function(number, number): number | undefined}
30
- */
31
- _defineProperty(this, "overwriteColumnWidthFn", void 0);
32
- /**
33
- * The map that stores the base column widths.
34
- *
35
- * @type {Map<number, number>}
36
- */
37
- _defineProperty(this, "baseWidths", new Map());
38
- /**
39
- * The map that stores the calculated, stretched column widths.
40
- *
41
- * @type {Map<number, number>}
42
- */
43
- _defineProperty(this, "stretchedWidths", new Map());
44
- this.overwriteColumnWidthFn = overwriteColumnWidthFn;
45
- }
46
-
47
- /**
48
- * Prepares the strategy for the calculation.
49
- *
50
- * @param {StretchStrategyCalcArgs} calcArgs The calculation arguments.
51
- */
52
- prepare(_ref) {
53
- let {
54
- viewportWidth
55
- } = _ref;
56
- this.viewportWidth = viewportWidth;
57
- this.baseWidths.clear();
58
- this.stretchedWidths.clear();
59
- }
60
-
61
- /**
62
- * Sets the base widths of the columns with which the strategy will work with.
63
- *
64
- * @param {number} columnVisualIndex The visual index of the column.
65
- * @param {number} columnWidth The width of the column.
66
- */
67
- setColumnBaseWidth(columnVisualIndex, columnWidth) {
68
- this.baseWidths.set(columnVisualIndex, columnWidth);
69
- }
70
-
71
- /**
72
- * Calculates the width of the column.
73
- */
74
- calculate() {}
75
-
76
- /**
77
- * Gets the calculated stretched column widths.
78
- *
79
- * @returns {Array<number[]>}
80
- */
81
- getWidths() {
82
- return Array.from(this.stretchedWidths);
83
- }
84
- }
85
- exports.StretchStrategy = StretchStrategy;
@@ -1,81 +0,0 @@
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 StretchStrategyCalcArgs
7
- * @property {number} viewportWidth The width of the viewport.
8
- */
9
- /**
10
- * The base strategy stretching strategy to extend from.
11
- *
12
- * @private
13
- * @class StretchStrategy
14
- */
15
- export class StretchStrategy {
16
- constructor(overwriteColumnWidthFn) {
17
- /**
18
- * The width of the viewport.
19
- *
20
- * @type {number}
21
- */
22
- _defineProperty(this, "viewportWidth", void 0);
23
- /**
24
- * The function to overwrite the column width.
25
- *
26
- * @type {function(number, number): number | undefined}
27
- */
28
- _defineProperty(this, "overwriteColumnWidthFn", void 0);
29
- /**
30
- * The map that stores the base column widths.
31
- *
32
- * @type {Map<number, number>}
33
- */
34
- _defineProperty(this, "baseWidths", new Map());
35
- /**
36
- * The map that stores the calculated, stretched column widths.
37
- *
38
- * @type {Map<number, number>}
39
- */
40
- _defineProperty(this, "stretchedWidths", new Map());
41
- this.overwriteColumnWidthFn = overwriteColumnWidthFn;
42
- }
43
-
44
- /**
45
- * Prepares the strategy for the calculation.
46
- *
47
- * @param {StretchStrategyCalcArgs} calcArgs The calculation arguments.
48
- */
49
- prepare(_ref) {
50
- let {
51
- viewportWidth
52
- } = _ref;
53
- this.viewportWidth = viewportWidth;
54
- this.baseWidths.clear();
55
- this.stretchedWidths.clear();
56
- }
57
-
58
- /**
59
- * Sets the base widths of the columns with which the strategy will work with.
60
- *
61
- * @param {number} columnVisualIndex The visual index of the column.
62
- * @param {number} columnWidth The width of the column.
63
- */
64
- setColumnBaseWidth(columnVisualIndex, columnWidth) {
65
- this.baseWidths.set(columnVisualIndex, columnWidth);
66
- }
67
-
68
- /**
69
- * Calculates the width of the column.
70
- */
71
- calculate() {}
72
-
73
- /**
74
- * Gets the calculated stretched column widths.
75
- *
76
- * @returns {Array<number[]>}
77
- */
78
- getWidths() {
79
- return Array.from(this.stretchedWidths);
80
- }
81
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- require("core-js/modules/es.array.push.js");
5
- var _src = require("../../../3rdparty/walkontable/src");
6
- var _base = require("./_base");
7
- /**
8
- * The strategy calculates the column widths by stretching all columns evenly.
9
- *
10
- * @private
11
- * @class StretchAllStrategy
12
- */
13
- class StretchAllStrategy extends _base.StretchStrategy {
14
- /**
15
- * Calculates the columns widths.
16
- */
17
- calculate() {
18
- const allColumnsWidth = Array.from(this.baseWidths).reduce((sum, _ref) => {
19
- let [, width] = _ref;
20
- return sum + width;
21
- }, 0);
22
- const remainingViewportWidth = this.viewportWidth - allColumnsWidth;
23
- if (remainingViewportWidth < 0) {
24
- this.stretchedWidths.clear();
25
- return;
26
- }
27
- const initialStretchRatio = this.viewportWidth / allColumnsWidth;
28
- const stretchedWidths = [];
29
- const fixedColumns = [];
30
- let viewportWidth = this.viewportWidth;
31
- let allStretchedColumnsWidth = 0;
32
- this.baseWidths.forEach((columnWidth, columnVisualIndex) => {
33
- const stretchedWidth = Math.round(columnWidth * initialStretchRatio);
34
- const finalWidth = this.overwriteColumnWidthFn(stretchedWidth, columnVisualIndex);
35
- if (stretchedWidth === finalWidth && stretchedWidth >= _src.DEFAULT_COLUMN_WIDTH) {
36
- stretchedWidths.push([columnVisualIndex, finalWidth]);
37
- allStretchedColumnsWidth += finalWidth;
38
- } else if (stretchedWidth !== finalWidth) {
39
- stretchedWidths.push([columnVisualIndex, finalWidth]);
40
- fixedColumns.push(columnVisualIndex);
41
- viewportWidth -= finalWidth;
42
- }
43
- });
44
- if (viewportWidth <= _src.DEFAULT_COLUMN_WIDTH) {
45
- this.stretchedWidths.clear();
46
- return;
47
- }
48
- const finalStretchRatio = viewportWidth / allStretchedColumnsWidth;
49
- let lastColumnIndex = -1;
50
- let sumColumnsWithoutLastOne = 0;
51
- stretchedWidths.forEach((_ref2, index) => {
52
- let [columnVisualIndex, columnWidth] = _ref2;
53
- let newWidth = columnWidth;
54
- if (!fixedColumns.includes(columnVisualIndex)) {
55
- newWidth = Math.round(columnWidth * finalStretchRatio);
56
- }
57
- this.stretchedWidths.set(columnVisualIndex, newWidth);
58
- lastColumnIndex = columnVisualIndex;
59
- if (index < stretchedWidths.length - 1) {
60
- sumColumnsWithoutLastOne += newWidth;
61
- }
62
- });
63
- if (this.stretchedWidths.size > 1) {
64
- this.stretchedWidths.set(lastColumnIndex, Math.round(this.viewportWidth - sumColumnsWithoutLastOne));
65
- }
66
- }
67
- }
68
- exports.StretchAllStrategy = StretchAllStrategy;
@@ -1,64 +0,0 @@
1
- import "core-js/modules/es.array.push.js";
2
- import { DEFAULT_COLUMN_WIDTH } from "../../../3rdparty/walkontable/src/index.mjs";
3
- import { StretchStrategy } from "./_base.mjs";
4
- /**
5
- * The strategy calculates the column widths by stretching all columns evenly.
6
- *
7
- * @private
8
- * @class StretchAllStrategy
9
- */
10
- export class StretchAllStrategy extends StretchStrategy {
11
- /**
12
- * Calculates the columns widths.
13
- */
14
- calculate() {
15
- const allColumnsWidth = Array.from(this.baseWidths).reduce((sum, _ref) => {
16
- let [, width] = _ref;
17
- return sum + width;
18
- }, 0);
19
- const remainingViewportWidth = this.viewportWidth - allColumnsWidth;
20
- if (remainingViewportWidth < 0) {
21
- this.stretchedWidths.clear();
22
- return;
23
- }
24
- const initialStretchRatio = this.viewportWidth / allColumnsWidth;
25
- const stretchedWidths = [];
26
- const fixedColumns = [];
27
- let viewportWidth = this.viewportWidth;
28
- let allStretchedColumnsWidth = 0;
29
- this.baseWidths.forEach((columnWidth, columnVisualIndex) => {
30
- const stretchedWidth = Math.round(columnWidth * initialStretchRatio);
31
- const finalWidth = this.overwriteColumnWidthFn(stretchedWidth, columnVisualIndex);
32
- if (stretchedWidth === finalWidth && stretchedWidth >= DEFAULT_COLUMN_WIDTH) {
33
- stretchedWidths.push([columnVisualIndex, finalWidth]);
34
- allStretchedColumnsWidth += finalWidth;
35
- } else if (stretchedWidth !== finalWidth) {
36
- stretchedWidths.push([columnVisualIndex, finalWidth]);
37
- fixedColumns.push(columnVisualIndex);
38
- viewportWidth -= finalWidth;
39
- }
40
- });
41
- if (viewportWidth <= DEFAULT_COLUMN_WIDTH) {
42
- this.stretchedWidths.clear();
43
- return;
44
- }
45
- const finalStretchRatio = viewportWidth / allStretchedColumnsWidth;
46
- let lastColumnIndex = -1;
47
- let sumColumnsWithoutLastOne = 0;
48
- stretchedWidths.forEach((_ref2, index) => {
49
- let [columnVisualIndex, columnWidth] = _ref2;
50
- let newWidth = columnWidth;
51
- if (!fixedColumns.includes(columnVisualIndex)) {
52
- newWidth = Math.round(columnWidth * finalStretchRatio);
53
- }
54
- this.stretchedWidths.set(columnVisualIndex, newWidth);
55
- lastColumnIndex = columnVisualIndex;
56
- if (index < stretchedWidths.length - 1) {
57
- sumColumnsWithoutLastOne += newWidth;
58
- }
59
- });
60
- if (this.stretchedWidths.size > 1) {
61
- this.stretchedWidths.set(lastColumnIndex, Math.round(this.viewportWidth - sumColumnsWithoutLastOne));
62
- }
63
- }
64
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
-
3
- exports.__esModule = true;
4
- require("core-js/modules/es.error.cause.js");
5
- var _base = require("./_base");
6
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
7
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
8
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
9
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
10
- 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"); }
11
- /**
12
- * @typedef StretchStrategyCalcArgs
13
- * @property {number} viewportWidth The width of the viewport.
14
- */
15
- /**
16
- * The strategy calculates only the last column widths to fill the viewport.
17
- *
18
- * @private
19
- * @class StretchLastStrategy
20
- */
21
- var _lastColumnWidth = /*#__PURE__*/new WeakMap();
22
- var _lastColumnIndex = /*#__PURE__*/new WeakMap();
23
- class StretchLastStrategy extends _base.StretchStrategy {
24
- constructor() {
25
- super(...arguments);
26
- /**
27
- * The width of the last calculated column.
28
- *
29
- * @type {number}
30
- */
31
- _classPrivateFieldInitSpec(this, _lastColumnWidth, 0);
32
- /**
33
- * The index of the last calculated column.
34
- *
35
- * @type {number}
36
- */
37
- _classPrivateFieldInitSpec(this, _lastColumnIndex, -1);
38
- }
39
- /**
40
- * Prepares the strategy for the calculation.
41
- *
42
- * @param {StretchStrategyCalcArgs} calcArgs The calculation arguments.
43
- */
44
- prepare(calcArgs) {
45
- super.prepare(calcArgs);
46
- _classPrivateFieldSet(_lastColumnWidth, this, 0);
47
- _classPrivateFieldSet(_lastColumnIndex, this, -1);
48
- }
49
-
50
- /**
51
- * Sets the base widths of the columns with which the strategy will work with.
52
- *
53
- * @param {number} columnVisualIndex The visual index of the column.
54
- * @param {number} columnWidth The width of the column.
55
- */
56
- setColumnBaseWidth(columnVisualIndex, columnWidth) {
57
- super.setColumnBaseWidth(columnVisualIndex, columnWidth);
58
- _classPrivateFieldSet(_lastColumnIndex, this, columnVisualIndex);
59
- _classPrivateFieldSet(_lastColumnWidth, this, columnWidth);
60
- }
61
-
62
- /**
63
- * Calculates the columns widths.
64
- */
65
- calculate() {
66
- if (_classPrivateFieldGet(_lastColumnIndex, this) === -1) {
67
- return;
68
- }
69
- const allColumnsWidth = Array.from(this.baseWidths).reduce((sum, _ref) => {
70
- let [, width] = _ref;
71
- return sum + width;
72
- }, 0);
73
- const lastColumnWidth = Math.max(this.viewportWidth - allColumnsWidth + _classPrivateFieldGet(_lastColumnWidth, this), 0);
74
- this.stretchedWidths.set(_classPrivateFieldGet(_lastColumnIndex, this), lastColumnWidth);
75
- }
76
- }
77
- exports.StretchLastStrategy = StretchLastStrategy;
@@ -1,73 +0,0 @@
1
- import "core-js/modules/es.error.cause.js";
2
- function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
3
- function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
4
- function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
5
- function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
6
- 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"); }
7
- import { StretchStrategy } from "./_base.mjs";
8
- /**
9
- * @typedef StretchStrategyCalcArgs
10
- * @property {number} viewportWidth The width of the viewport.
11
- */
12
- /**
13
- * The strategy calculates only the last column widths to fill the viewport.
14
- *
15
- * @private
16
- * @class StretchLastStrategy
17
- */
18
- var _lastColumnWidth = /*#__PURE__*/new WeakMap();
19
- var _lastColumnIndex = /*#__PURE__*/new WeakMap();
20
- export class StretchLastStrategy extends StretchStrategy {
21
- constructor() {
22
- super(...arguments);
23
- /**
24
- * The width of the last calculated column.
25
- *
26
- * @type {number}
27
- */
28
- _classPrivateFieldInitSpec(this, _lastColumnWidth, 0);
29
- /**
30
- * The index of the last calculated column.
31
- *
32
- * @type {number}
33
- */
34
- _classPrivateFieldInitSpec(this, _lastColumnIndex, -1);
35
- }
36
- /**
37
- * Prepares the strategy for the calculation.
38
- *
39
- * @param {StretchStrategyCalcArgs} calcArgs The calculation arguments.
40
- */
41
- prepare(calcArgs) {
42
- super.prepare(calcArgs);
43
- _classPrivateFieldSet(_lastColumnWidth, this, 0);
44
- _classPrivateFieldSet(_lastColumnIndex, this, -1);
45
- }
46
-
47
- /**
48
- * Sets the base widths of the columns with which the strategy will work with.
49
- *
50
- * @param {number} columnVisualIndex The visual index of the column.
51
- * @param {number} columnWidth The width of the column.
52
- */
53
- setColumnBaseWidth(columnVisualIndex, columnWidth) {
54
- super.setColumnBaseWidth(columnVisualIndex, columnWidth);
55
- _classPrivateFieldSet(_lastColumnIndex, this, columnVisualIndex);
56
- _classPrivateFieldSet(_lastColumnWidth, this, columnWidth);
57
- }
58
-
59
- /**
60
- * Calculates the columns widths.
61
- */
62
- calculate() {
63
- if (_classPrivateFieldGet(_lastColumnIndex, this) === -1) {
64
- return;
65
- }
66
- const allColumnsWidth = Array.from(this.baseWidths).reduce((sum, _ref) => {
67
- let [, width] = _ref;
68
- return sum + width;
69
- }, 0);
70
- const lastColumnWidth = Math.max(this.viewportWidth - allColumnsWidth + _classPrivateFieldGet(_lastColumnWidth, this), 0);
71
- this.stretchedWidths.set(_classPrivateFieldGet(_lastColumnIndex, this), lastColumnWidth);
72
- }
73
- }
@@ -1,11 +0,0 @@
1
- import Core from '../../core';
2
- import { BasePlugin } from '../base';
3
-
4
- export type Settings = 'all' | 'last' | 'none';
5
-
6
- export class StretchColumns extends BasePlugin {
7
- constructor(hotInstance: Core);
8
-
9
- isEnabled(): boolean;
10
- getColumnWidth(columnVisualIndex: number): number | null;
11
- }