handsontable 0.0.0-next-3e0b40d-20241017 → 0.0.0-next-802f59c-20241024
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.
- package/3rdparty/walkontable/src/calculator/viewportRows.js +1 -5
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +2 -5
- package/3rdparty/walkontable/src/core/clone.js +0 -1
- package/3rdparty/walkontable/src/core/clone.mjs +0 -1
- package/3rdparty/walkontable/src/core/core.js +0 -2
- package/3rdparty/walkontable/src/core/core.mjs +0 -2
- package/3rdparty/walkontable/src/overlay/_base.js +1 -3
- package/3rdparty/walkontable/src/overlay/_base.mjs +1 -3
- package/3rdparty/walkontable/src/overlay/bottom.js +2 -2
- package/3rdparty/walkontable/src/overlay/bottom.mjs +2 -2
- package/3rdparty/walkontable/src/overlay/inlineStart.js +1 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.mjs +1 -1
- package/3rdparty/walkontable/src/overlay/top.js +1 -1
- package/3rdparty/walkontable/src/overlay/top.mjs +1 -1
- package/3rdparty/walkontable/src/overlays.js +7 -6
- package/3rdparty/walkontable/src/overlays.mjs +7 -6
- package/3rdparty/walkontable/src/renderer/colGroup.js +1 -1
- package/3rdparty/walkontable/src/renderer/colGroup.mjs +1 -1
- package/3rdparty/walkontable/src/renderer/table.js +1 -1
- package/3rdparty/walkontable/src/renderer/table.mjs +1 -1
- package/3rdparty/walkontable/src/settings.js +2 -7
- package/3rdparty/walkontable/src/settings.mjs +2 -7
- package/3rdparty/walkontable/src/table.js +8 -35
- package/3rdparty/walkontable/src/table.mjs +8 -35
- package/3rdparty/walkontable/src/utils/column.js +1 -43
- package/3rdparty/walkontable/src/utils/column.mjs +1 -43
- package/3rdparty/walkontable/src/viewport.js +66 -88
- package/3rdparty/walkontable/src/viewport.mjs +67 -89
- package/CHANGELOG.md +5 -0
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/hooks/constants.js +2 -0
- package/core/hooks/constants.mjs +2 -0
- package/core/hooks/index.d.ts +2 -2
- package/core.d.ts +2 -2
- package/core.js +6 -15
- package/core.mjs +6 -15
- package/dataMap/metaManager/metaSchema.js +0 -17
- package/dataMap/metaManager/metaSchema.mjs +0 -17
- package/dist/handsontable.css +5 -236
- package/dist/handsontable.full.css +3 -3
- package/dist/handsontable.full.js +4539 -4231
- package/dist/handsontable.full.min.css +3 -4
- package/dist/handsontable.full.min.js +26 -26
- package/dist/handsontable.js +4230 -3928
- package/dist/handsontable.min.css +4 -9
- package/dist/handsontable.min.js +24 -24
- package/editors/autocompleteEditor/autocompleteEditor.js +1 -1
- package/editors/autocompleteEditor/autocompleteEditor.mjs +1 -1
- package/editors/baseEditor/baseEditor.js +1 -1
- package/editors/baseEditor/baseEditor.mjs +1 -1
- package/editors/dateEditor/dateEditor.js +0 -2
- package/editors/dateEditor/dateEditor.mjs +0 -2
- package/editors/handsontableEditor/handsontableEditor.js +1 -1
- package/editors/handsontableEditor/handsontableEditor.mjs +1 -1
- package/editors/passwordEditor/passwordEditor.js +0 -4
- package/editors/passwordEditor/passwordEditor.mjs +1 -5
- package/editors/selectEditor/selectEditor.js +9 -20
- package/editors/selectEditor/selectEditor.mjs +9 -20
- package/editors/textEditor/textEditor.js +11 -7
- package/editors/textEditor/textEditor.mjs +12 -8
- package/helpers/mixed.js +3 -3
- package/helpers/mixed.mjs +3 -3
- package/index.d.ts +7 -0
- package/package.json +8 -10
- package/plugins/comments/commentEditor.js +1 -8
- package/plugins/comments/commentEditor.mjs +1 -8
- package/plugins/comments/comments.js +2 -2
- package/plugins/comments/comments.mjs +2 -2
- package/plugins/contextMenu/menu/menu.js +4 -4
- package/plugins/contextMenu/menu/menu.mjs +4 -4
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +3 -0
- package/plugins/index.mjs +3 -1
- package/plugins/manualColumnMove/manualColumnMove.js +1 -3
- package/plugins/manualColumnMove/manualColumnMove.mjs +1 -3
- package/plugins/manualColumnResize/manualColumnResize.js +24 -12
- package/plugins/manualColumnResize/manualColumnResize.mjs +24 -12
- package/plugins/manualRowMove/manualRowMove.js +1 -1
- package/plugins/manualRowMove/manualRowMove.mjs +1 -1
- package/plugins/mergeCells/mergeCells.js +1 -1
- package/plugins/mergeCells/mergeCells.mjs +1 -1
- package/plugins/nestedRows/ui/headers.js +1 -3
- package/plugins/nestedRows/ui/headers.mjs +1 -3
- package/plugins/stretchColumns/calculator.js +159 -0
- package/plugins/stretchColumns/calculator.mjs +155 -0
- package/plugins/stretchColumns/index.d.ts +1 -0
- package/plugins/stretchColumns/index.js +7 -0
- package/plugins/stretchColumns/index.mjs +1 -0
- package/plugins/stretchColumns/strategies/_base.js +85 -0
- package/plugins/stretchColumns/strategies/_base.mjs +81 -0
- package/plugins/stretchColumns/strategies/all.js +68 -0
- package/plugins/stretchColumns/strategies/all.mjs +64 -0
- package/plugins/stretchColumns/strategies/last.js +77 -0
- package/plugins/stretchColumns/strategies/last.mjs +73 -0
- package/plugins/stretchColumns/stretchColumns.d.ts +11 -0
- package/plugins/stretchColumns/stretchColumns.js +211 -0
- package/plugins/stretchColumns/stretchColumns.mjs +207 -0
- package/tableView.js +39 -39
- package/tableView.mjs +39 -39
- package/utils/autoResize.js +1 -4
- package/utils/autoResize.mjs +1 -4
- package/utils/ghostTable.js +1 -1
- package/utils/ghostTable.mjs +1 -1
- package/3rdparty/walkontable/src/utils/columnStretching.js +0 -197
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -193
- package/3rdparty/walkontable/src/utils/stylesHandler.js +0 -185
- package/3rdparty/walkontable/src/utils/stylesHandler.mjs +0 -181
- package/helpers/themes.js +0 -17
- package/helpers/themes.mjs +0 -13
- package/styles/handsontable.css +0 -1920
- package/styles/handsontable.min.css +0 -30
- package/styles/ht-theme-gemini.css +0 -690
- package/styles/ht-theme-gemini.min.css +0 -30
- package/styles/ht-theme-main.css +0 -712
- package/styles/ht-theme-main.min.css +0 -30
@@ -0,0 +1,207 @@
|
|
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 _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
6
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
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 { BasePlugin } from "../base/index.mjs";
|
9
|
+
import { StretchCalculator } from "./calculator.mjs";
|
10
|
+
export const PLUGIN_KEY = 'stretchColumns';
|
11
|
+
export const PLUGIN_PRIORITY = 155;
|
12
|
+
|
13
|
+
/* eslint-disable jsdoc/require-description-complete-sentence */
|
14
|
+
/**
|
15
|
+
* @plugin StretchColumns
|
16
|
+
* @class StretchColumns
|
17
|
+
*
|
18
|
+
* @description
|
19
|
+
* This plugin allows to set column widths based on their widest cells.
|
20
|
+
*
|
21
|
+
* By default, the plugin is declared as `'none'`, which makes it disabled (same as if it was declared as `false`).
|
22
|
+
*
|
23
|
+
* The plugin determines what happens when the declared grid width is different from the calculated sum of all column widths.
|
24
|
+
*
|
25
|
+
* ```js
|
26
|
+
* // fit the grid to the container, by stretching only the last column
|
27
|
+
* stretchH: 'last',
|
28
|
+
*
|
29
|
+
* // fit the grid to the container, by stretching all columns evenly
|
30
|
+
* stretchH: 'all',
|
31
|
+
* ```
|
32
|
+
*
|
33
|
+
* To configure this plugin see {@link Options#stretchH}.
|
34
|
+
*
|
35
|
+
* @example
|
36
|
+
*
|
37
|
+
* ::: only-for javascript
|
38
|
+
* ```js
|
39
|
+
* const hot = new Handsontable(document.getElementById('example'), {
|
40
|
+
* data: getData(),
|
41
|
+
* stretchH: 'all',
|
42
|
+
* });
|
43
|
+
* ```
|
44
|
+
* :::
|
45
|
+
*
|
46
|
+
* ::: only-for react
|
47
|
+
* ```jsx
|
48
|
+
* const hotRef = useRef(null);
|
49
|
+
*
|
50
|
+
* ...
|
51
|
+
*
|
52
|
+
* // First, let's construct Handsontable
|
53
|
+
* <HotTable
|
54
|
+
* ref={hotRef}
|
55
|
+
* data={getData()}
|
56
|
+
* stretchH={'all'}
|
57
|
+
* />
|
58
|
+
* ```
|
59
|
+
* :::
|
60
|
+
*/
|
61
|
+
/* eslint-enable jsdoc/require-description-complete-sentence */
|
62
|
+
var _stretchCalculator = /*#__PURE__*/new WeakMap();
|
63
|
+
var _previousTableWidth = /*#__PURE__*/new WeakMap();
|
64
|
+
var _resizeObserver = /*#__PURE__*/new WeakMap();
|
65
|
+
var _StretchColumns_brand = /*#__PURE__*/new WeakSet();
|
66
|
+
export class StretchColumns extends BasePlugin {
|
67
|
+
constructor() {
|
68
|
+
super(...arguments);
|
69
|
+
/**
|
70
|
+
* Hook that modifies the column width - applies by the stretching logic.
|
71
|
+
*
|
72
|
+
* @param {number} width The column width.
|
73
|
+
* @param {number} column The visual column index.
|
74
|
+
* @param {string} source The source of the modification.
|
75
|
+
* @returns {number}
|
76
|
+
*/
|
77
|
+
_classPrivateMethodInitSpec(this, _StretchColumns_brand);
|
78
|
+
/**
|
79
|
+
* The stretch calculator.
|
80
|
+
*
|
81
|
+
* @type {StretchCalculator}
|
82
|
+
*/
|
83
|
+
_classPrivateFieldInitSpec(this, _stretchCalculator, new StretchCalculator(this.hot));
|
84
|
+
/**
|
85
|
+
* The previous width of the root element. Helps to determine if the width has changed.
|
86
|
+
*
|
87
|
+
* @type {number | null}
|
88
|
+
*/
|
89
|
+
_classPrivateFieldInitSpec(this, _previousTableWidth, null);
|
90
|
+
/**
|
91
|
+
* It observes the root element to detect changes in its width, and if detected, then it triggers
|
92
|
+
* the table dimension calculations. In a situation where the browser's vertical scrollbar
|
93
|
+
* appears - caused by some external UI element, the observer triggers the render.
|
94
|
+
*
|
95
|
+
* @type {ResizeObserver}
|
96
|
+
*/
|
97
|
+
_classPrivateFieldInitSpec(this, _resizeObserver, new ResizeObserver(entries => {
|
98
|
+
requestAnimationFrame(() => {
|
99
|
+
var _this$hot;
|
100
|
+
if (!((_this$hot = this.hot) !== null && _this$hot !== void 0 && _this$hot.view.isHorizontallyScrollableByWindow())) {
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
entries.forEach(_ref => {
|
104
|
+
let {
|
105
|
+
contentRect
|
106
|
+
} = _ref;
|
107
|
+
if (_classPrivateFieldGet(_previousTableWidth, this) !== null && _classPrivateFieldGet(_previousTableWidth, this) !== contentRect.width) {
|
108
|
+
this.hot.refreshDimensions();
|
109
|
+
this.hot.view.adjustElementsSize();
|
110
|
+
}
|
111
|
+
_classPrivateFieldSet(_previousTableWidth, this, contentRect.width);
|
112
|
+
});
|
113
|
+
});
|
114
|
+
}));
|
115
|
+
}
|
116
|
+
static get PLUGIN_KEY() {
|
117
|
+
return PLUGIN_KEY;
|
118
|
+
}
|
119
|
+
static get PLUGIN_PRIORITY() {
|
120
|
+
return PLUGIN_PRIORITY;
|
121
|
+
}
|
122
|
+
static get SETTING_KEYS() {
|
123
|
+
return true;
|
124
|
+
}
|
125
|
+
/**
|
126
|
+
* Checks if the plugin is enabled in the handsontable settings. This method is executed in {@link Hooks#beforeInit}
|
127
|
+
* hook and if it returns `true` then the {@link #enablePlugin} method is called.
|
128
|
+
*
|
129
|
+
* @returns {boolean}
|
130
|
+
*/
|
131
|
+
isEnabled() {
|
132
|
+
return ['all', 'last'].includes(this.hot.getSettings().stretchH);
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
* Enables the plugin functionality for this Handsontable instance.
|
137
|
+
*/
|
138
|
+
enablePlugin() {
|
139
|
+
var _this = this;
|
140
|
+
if (this.enabled) {
|
141
|
+
return;
|
142
|
+
}
|
143
|
+
_classPrivateFieldGet(_stretchCalculator, this).useStrategy(this.hot.getSettings().stretchH);
|
144
|
+
_classPrivateFieldGet(_resizeObserver, this).observe(this.hot.rootElement);
|
145
|
+
this.addHook('beforeRender', () => _assertClassBrand(_StretchColumns_brand, this, _onBeforeRender).call(this));
|
146
|
+
this.addHook('modifyColWidth', function () {
|
147
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
148
|
+
args[_key] = arguments[_key];
|
149
|
+
}
|
150
|
+
return _assertClassBrand(_StretchColumns_brand, _this, _onModifyColWidth).call(_this, ...args);
|
151
|
+
}, 10);
|
152
|
+
super.enablePlugin();
|
153
|
+
}
|
154
|
+
|
155
|
+
/**
|
156
|
+
* Updates the plugin's state. This method is executed when {@link Core#updateSettings} is invoked.
|
157
|
+
*/
|
158
|
+
updatePlugin() {
|
159
|
+
_classPrivateFieldGet(_stretchCalculator, this).useStrategy(this.hot.getSettings().stretchH);
|
160
|
+
super.updatePlugin();
|
161
|
+
}
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Disables the plugin functionality for this Handsontable instance.
|
165
|
+
*/
|
166
|
+
disablePlugin() {
|
167
|
+
super.disablePlugin();
|
168
|
+
_classPrivateFieldGet(_resizeObserver, this).unobserve(this.hot.rootElement);
|
169
|
+
}
|
170
|
+
|
171
|
+
/**
|
172
|
+
* Gets the calculated column width based on the stretching
|
173
|
+
* strategy defined by {@link Options#stretchH} option.
|
174
|
+
*
|
175
|
+
* @param {number} columnVisualIndex The visual index of the column.
|
176
|
+
* @returns {number | null}
|
177
|
+
*/
|
178
|
+
getColumnWidth(columnVisualIndex) {
|
179
|
+
return _classPrivateFieldGet(_stretchCalculator, this).getStretchedWidth(columnVisualIndex);
|
180
|
+
}
|
181
|
+
/**
|
182
|
+
* Destroys the plugin instance.
|
183
|
+
*/
|
184
|
+
destroy() {
|
185
|
+
_classPrivateFieldGet(_resizeObserver, this).disconnect();
|
186
|
+
_classPrivateFieldSet(_resizeObserver, this, null);
|
187
|
+
_classPrivateFieldSet(_stretchCalculator, this, null);
|
188
|
+
super.destroy();
|
189
|
+
}
|
190
|
+
}
|
191
|
+
function _onModifyColWidth(width, column, source) {
|
192
|
+
if (source === this.pluginName) {
|
193
|
+
return;
|
194
|
+
}
|
195
|
+
const newWidth = this.getColumnWidth(column);
|
196
|
+
if (typeof newWidth === 'number') {
|
197
|
+
return newWidth;
|
198
|
+
}
|
199
|
+
return width;
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* On each before render the plugin recalculates the column widths
|
203
|
+
* based on the chosen stretching strategy.
|
204
|
+
*/
|
205
|
+
function _onBeforeRender() {
|
206
|
+
_classPrivateFieldGet(_stretchCalculator, this).refreshStretching();
|
207
|
+
}
|
package/tableView.js
CHANGED
@@ -158,7 +158,7 @@ class TableView {
|
|
158
158
|
this.hot.runHooks('beforeRender', this.hot.forceFullRender);
|
159
159
|
if (this.postponedAdjustElementsSize) {
|
160
160
|
this.postponedAdjustElementsSize = false;
|
161
|
-
this.adjustElementsSize(
|
161
|
+
this.adjustElementsSize();
|
162
162
|
}
|
163
163
|
this._wt.draw(!this.hot.forceFullRender);
|
164
164
|
this.hot.runHooks('afterRender', this.hot.forceFullRender);
|
@@ -587,39 +587,6 @@ class TableView {
|
|
587
587
|
return count;
|
588
588
|
}
|
589
589
|
|
590
|
-
/**
|
591
|
-
* Returns the default row height.
|
592
|
-
*
|
593
|
-
* This method retrieves the default row height from the Walkontable styles handler.
|
594
|
-
*
|
595
|
-
* @returns {number} The default row height.
|
596
|
-
*/
|
597
|
-
getDefaultRowHeight() {
|
598
|
-
return this._wt._wot.stylesHandler.getDefaultRowHeight();
|
599
|
-
}
|
600
|
-
|
601
|
-
/**
|
602
|
-
* Retrieves the value of a specified CSS variable for the instance's container.
|
603
|
-
*
|
604
|
-
* @param {string} variableName - The name of the CSS variable to retrieve.
|
605
|
-
* @returns {string} The value of the specified CSS variable.
|
606
|
-
*/
|
607
|
-
getCSSVariableValue(variableName) {
|
608
|
-
return this._wt._wot.stylesHandler.getCSSVariableValue(variableName);
|
609
|
-
}
|
610
|
-
|
611
|
-
/**
|
612
|
-
* Checks if the classic theme is being used.
|
613
|
-
*
|
614
|
-
* This method verifies if the current theme applied to the Handsontable instance
|
615
|
-
* is the classic theme.
|
616
|
-
*
|
617
|
-
* @returns {boolean} `true` if the classic theme is being used, `false` otherwise.
|
618
|
-
*/
|
619
|
-
isUsingClassicTheme() {
|
620
|
-
return this._wt._wot.stylesHandler.isClassicTheme();
|
621
|
-
}
|
622
|
-
|
623
590
|
/**
|
624
591
|
* Checks if at least one cell than belongs to the main table is not covered by the top, left or
|
625
592
|
* bottom overlay.
|
@@ -646,7 +613,6 @@ class TableView {
|
|
646
613
|
isDataViewInstance: () => (0, _rootInstance.isRootInstance)(this.hot),
|
647
614
|
preventOverflow: () => this.settings.preventOverflow,
|
648
615
|
preventWheel: () => this.settings.preventWheel,
|
649
|
-
stretchH: () => this.settings.stretchH,
|
650
616
|
viewportColumnRenderingThreshold: () => this.settings.viewportColumnRenderingThreshold,
|
651
617
|
viewportRowRenderingThreshold: () => this.settings.viewportRowRenderingThreshold,
|
652
618
|
data: (renderableRow, renderableColumn) => {
|
@@ -945,10 +911,6 @@ class TableView {
|
|
945
911
|
},
|
946
912
|
onBeforeTouchScroll: () => this.hot.runHooks('beforeTouchScroll'),
|
947
913
|
onAfterMomentumScroll: () => this.hot.runHooks('afterMomentumScroll'),
|
948
|
-
onBeforeStretchingColumnWidth: (stretchedWidth, renderedColumnIndex) => {
|
949
|
-
const visualColumnIndex = this.hot.columnIndexMapper.getVisualFromRenderableIndex(renderedColumnIndex);
|
950
|
-
return this.hot.runHooks('beforeStretchingColumnWidth', stretchedWidth, visualColumnIndex);
|
951
|
-
},
|
952
914
|
onModifyRowHeaderWidth: rowHeaderWidth => this.hot.runHooks('modifyRowHeaderWidth', rowHeaderWidth),
|
953
915
|
onModifyGetCellCoords: (renderableRowIndex, renderableColumnIndex, topmost, source) => {
|
954
916
|
const rowMapper = this.hot.rowIndexMapper;
|
@@ -1572,6 +1534,44 @@ class TableView {
|
|
1572
1534
|
getTableHeight() {
|
1573
1535
|
return this._wt.wtTable.getHeight();
|
1574
1536
|
}
|
1537
|
+
|
1538
|
+
/**
|
1539
|
+
* Gets the row header width. If there are multiple row headers, the width of
|
1540
|
+
* the sum of all of them is returned.
|
1541
|
+
*
|
1542
|
+
* @returns {number}
|
1543
|
+
*/
|
1544
|
+
getRowHeaderWidth() {
|
1545
|
+
return this._wt.wtViewport.getRowHeaderWidth();
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
/**
|
1549
|
+
* Gets the column header height. If there are multiple column headers, the height
|
1550
|
+
* of the sum of all of them is returned.
|
1551
|
+
*
|
1552
|
+
* @returns {number}
|
1553
|
+
*/
|
1554
|
+
getColumnHeaderHeight() {
|
1555
|
+
return this._wt.wtViewport.getColumnHeaderHeight();
|
1556
|
+
}
|
1557
|
+
|
1558
|
+
/**
|
1559
|
+
* Checks if the table uses the window as a viewport and if there is a vertical scrollbar.
|
1560
|
+
*
|
1561
|
+
* @returns {boolean}
|
1562
|
+
*/
|
1563
|
+
isVerticallyScrollableByWindow() {
|
1564
|
+
return this._wt.wtViewport.isVerticallyScrollableByWindow();
|
1565
|
+
}
|
1566
|
+
|
1567
|
+
/**
|
1568
|
+
* Checks if the table uses the window as a viewport and if there is a horizontal scrollbar.
|
1569
|
+
*
|
1570
|
+
* @returns {boolean}
|
1571
|
+
*/
|
1572
|
+
isHorizontallyScrollableByWindow() {
|
1573
|
+
return this._wt.wtViewport.isHorizontallyScrollableByWindow();
|
1574
|
+
}
|
1575
1575
|
/**
|
1576
1576
|
* Destroys internal WalkOnTable's instance. Detaches all of the bonded listeners.
|
1577
1577
|
*
|
package/tableView.mjs
CHANGED
@@ -154,7 +154,7 @@ class TableView {
|
|
154
154
|
this.hot.runHooks('beforeRender', this.hot.forceFullRender);
|
155
155
|
if (this.postponedAdjustElementsSize) {
|
156
156
|
this.postponedAdjustElementsSize = false;
|
157
|
-
this.adjustElementsSize(
|
157
|
+
this.adjustElementsSize();
|
158
158
|
}
|
159
159
|
this._wt.draw(!this.hot.forceFullRender);
|
160
160
|
this.hot.runHooks('afterRender', this.hot.forceFullRender);
|
@@ -583,39 +583,6 @@ class TableView {
|
|
583
583
|
return count;
|
584
584
|
}
|
585
585
|
|
586
|
-
/**
|
587
|
-
* Returns the default row height.
|
588
|
-
*
|
589
|
-
* This method retrieves the default row height from the Walkontable styles handler.
|
590
|
-
*
|
591
|
-
* @returns {number} The default row height.
|
592
|
-
*/
|
593
|
-
getDefaultRowHeight() {
|
594
|
-
return this._wt._wot.stylesHandler.getDefaultRowHeight();
|
595
|
-
}
|
596
|
-
|
597
|
-
/**
|
598
|
-
* Retrieves the value of a specified CSS variable for the instance's container.
|
599
|
-
*
|
600
|
-
* @param {string} variableName - The name of the CSS variable to retrieve.
|
601
|
-
* @returns {string} The value of the specified CSS variable.
|
602
|
-
*/
|
603
|
-
getCSSVariableValue(variableName) {
|
604
|
-
return this._wt._wot.stylesHandler.getCSSVariableValue(variableName);
|
605
|
-
}
|
606
|
-
|
607
|
-
/**
|
608
|
-
* Checks if the classic theme is being used.
|
609
|
-
*
|
610
|
-
* This method verifies if the current theme applied to the Handsontable instance
|
611
|
-
* is the classic theme.
|
612
|
-
*
|
613
|
-
* @returns {boolean} `true` if the classic theme is being used, `false` otherwise.
|
614
|
-
*/
|
615
|
-
isUsingClassicTheme() {
|
616
|
-
return this._wt._wot.stylesHandler.isClassicTheme();
|
617
|
-
}
|
618
|
-
|
619
586
|
/**
|
620
587
|
* Checks if at least one cell than belongs to the main table is not covered by the top, left or
|
621
588
|
* bottom overlay.
|
@@ -642,7 +609,6 @@ class TableView {
|
|
642
609
|
isDataViewInstance: () => isRootInstance(this.hot),
|
643
610
|
preventOverflow: () => this.settings.preventOverflow,
|
644
611
|
preventWheel: () => this.settings.preventWheel,
|
645
|
-
stretchH: () => this.settings.stretchH,
|
646
612
|
viewportColumnRenderingThreshold: () => this.settings.viewportColumnRenderingThreshold,
|
647
613
|
viewportRowRenderingThreshold: () => this.settings.viewportRowRenderingThreshold,
|
648
614
|
data: (renderableRow, renderableColumn) => {
|
@@ -941,10 +907,6 @@ class TableView {
|
|
941
907
|
},
|
942
908
|
onBeforeTouchScroll: () => this.hot.runHooks('beforeTouchScroll'),
|
943
909
|
onAfterMomentumScroll: () => this.hot.runHooks('afterMomentumScroll'),
|
944
|
-
onBeforeStretchingColumnWidth: (stretchedWidth, renderedColumnIndex) => {
|
945
|
-
const visualColumnIndex = this.hot.columnIndexMapper.getVisualFromRenderableIndex(renderedColumnIndex);
|
946
|
-
return this.hot.runHooks('beforeStretchingColumnWidth', stretchedWidth, visualColumnIndex);
|
947
|
-
},
|
948
910
|
onModifyRowHeaderWidth: rowHeaderWidth => this.hot.runHooks('modifyRowHeaderWidth', rowHeaderWidth),
|
949
911
|
onModifyGetCellCoords: (renderableRowIndex, renderableColumnIndex, topmost, source) => {
|
950
912
|
const rowMapper = this.hot.rowIndexMapper;
|
@@ -1568,6 +1530,44 @@ class TableView {
|
|
1568
1530
|
getTableHeight() {
|
1569
1531
|
return this._wt.wtTable.getHeight();
|
1570
1532
|
}
|
1533
|
+
|
1534
|
+
/**
|
1535
|
+
* Gets the row header width. If there are multiple row headers, the width of
|
1536
|
+
* the sum of all of them is returned.
|
1537
|
+
*
|
1538
|
+
* @returns {number}
|
1539
|
+
*/
|
1540
|
+
getRowHeaderWidth() {
|
1541
|
+
return this._wt.wtViewport.getRowHeaderWidth();
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
/**
|
1545
|
+
* Gets the column header height. If there are multiple column headers, the height
|
1546
|
+
* of the sum of all of them is returned.
|
1547
|
+
*
|
1548
|
+
* @returns {number}
|
1549
|
+
*/
|
1550
|
+
getColumnHeaderHeight() {
|
1551
|
+
return this._wt.wtViewport.getColumnHeaderHeight();
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
/**
|
1555
|
+
* Checks if the table uses the window as a viewport and if there is a vertical scrollbar.
|
1556
|
+
*
|
1557
|
+
* @returns {boolean}
|
1558
|
+
*/
|
1559
|
+
isVerticallyScrollableByWindow() {
|
1560
|
+
return this._wt.wtViewport.isVerticallyScrollableByWindow();
|
1561
|
+
}
|
1562
|
+
|
1563
|
+
/**
|
1564
|
+
* Checks if the table uses the window as a viewport and if there is a horizontal scrollbar.
|
1565
|
+
*
|
1566
|
+
* @returns {boolean}
|
1567
|
+
*/
|
1568
|
+
isHorizontallyScrollableByWindow() {
|
1569
|
+
return this._wt.wtViewport.isHorizontallyScrollableByWindow();
|
1570
|
+
}
|
1571
1571
|
/**
|
1572
1572
|
* Destroys internal WalkOnTable's instance. Detaches all of the bonded listeners.
|
1573
1573
|
*
|
package/utils/autoResize.js
CHANGED
@@ -77,7 +77,6 @@ function createInputElementResizer(ownerDocument) {
|
|
77
77
|
* Resizes the element.
|
78
78
|
*/
|
79
79
|
function resize() {
|
80
|
-
var _getComputedStyle, _getComputedStyle2;
|
81
80
|
textHolder.textContent = observedElement.value;
|
82
81
|
// Won't expand the element size for displaying body as for example, `grid`, `inline-grid` or `flex` with
|
83
82
|
// `flex-direction` set as `column`.
|
@@ -86,9 +85,7 @@ function createInputElementResizer(ownerDocument) {
|
|
86
85
|
textContainer.style.fontFamily = getComputedStyle(observedElement).fontFamily;
|
87
86
|
textContainer.style.whiteSpace = 'pre';
|
88
87
|
body.appendChild(textContainer);
|
89
|
-
const
|
90
|
-
const paddingEnd = parseInt(((_getComputedStyle2 = getComputedStyle(observedElement)) === null || _getComputedStyle2 === void 0 ? void 0 : _getComputedStyle2.paddingInlineEnd) || 0, 10);
|
91
|
-
const width = textContainer.clientWidth + 2 + paddingStart + paddingEnd;
|
88
|
+
const width = textContainer.clientWidth + 2;
|
92
89
|
body.removeChild(textContainer);
|
93
90
|
const elementStyle = observedElement.style;
|
94
91
|
elementStyle.height = `${defaults.minHeight}px`;
|
package/utils/autoResize.mjs
CHANGED
@@ -73,7 +73,6 @@ export function createInputElementResizer(ownerDocument) {
|
|
73
73
|
* Resizes the element.
|
74
74
|
*/
|
75
75
|
function resize() {
|
76
|
-
var _getComputedStyle, _getComputedStyle2;
|
77
76
|
textHolder.textContent = observedElement.value;
|
78
77
|
// Won't expand the element size for displaying body as for example, `grid`, `inline-grid` or `flex` with
|
79
78
|
// `flex-direction` set as `column`.
|
@@ -82,9 +81,7 @@ export function createInputElementResizer(ownerDocument) {
|
|
82
81
|
textContainer.style.fontFamily = getComputedStyle(observedElement).fontFamily;
|
83
82
|
textContainer.style.whiteSpace = 'pre';
|
84
83
|
body.appendChild(textContainer);
|
85
|
-
const
|
86
|
-
const paddingEnd = parseInt(((_getComputedStyle2 = getComputedStyle(observedElement)) === null || _getComputedStyle2 === void 0 ? void 0 : _getComputedStyle2.paddingInlineEnd) || 0, 10);
|
87
|
-
const width = textContainer.clientWidth + 2 + paddingStart + paddingEnd;
|
84
|
+
const width = textContainer.clientWidth + 2;
|
88
85
|
body.removeChild(textContainer);
|
89
86
|
const elementStyle = observedElement.style;
|
90
87
|
elementStyle.height = `${defaults.minHeight}px`;
|
package/utils/ghostTable.js
CHANGED
@@ -131,7 +131,7 @@ class GhostTable {
|
|
131
131
|
if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
|
132
132
|
// Please keep in mind that the renderable column index equal to the visual columns index for the GhostTable.
|
133
133
|
// We render all columns.
|
134
|
-
this.hot.view.appendColHeader(column, this.table.th
|
134
|
+
this.hot.view.appendColHeader(column, this.table.th);
|
135
135
|
}
|
136
136
|
this.table.tBody.appendChild(this.createCol(column));
|
137
137
|
this.container.container.appendChild(this.table.fragment);
|
package/utils/ghostTable.mjs
CHANGED
@@ -128,7 +128,7 @@ class GhostTable {
|
|
128
128
|
if (this.getSetting('useHeaders') && this.hot.getColHeader(column) !== null) {
|
129
129
|
// Please keep in mind that the renderable column index equal to the visual columns index for the GhostTable.
|
130
130
|
// We render all columns.
|
131
|
-
this.hot.view.appendColHeader(column, this.table.th
|
131
|
+
this.hot.view.appendColHeader(column, this.table.th);
|
132
132
|
}
|
133
133
|
this.table.tBody.appendChild(this.createCol(column));
|
134
134
|
this.container.container.appendChild(this.table.fragment);
|
@@ -1,197 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
exports.__esModule = true;
|
4
|
-
require("core-js/modules/es.error.cause.js");
|
5
|
-
var _calculator = require("../calculator");
|
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 _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; }
|
9
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
10
|
-
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); }
|
11
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
12
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
13
|
-
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"); }
|
14
|
-
/**
|
15
|
-
* @typedef {object} ColumnStretchingOptions
|
16
|
-
* @property {number} totalColumns Total number of columns.
|
17
|
-
* @property {Function} columnWidthFn Function that returns the width of the column at a given index (in px).
|
18
|
-
* @property {'all' | 'last' | 'none'} stretchMode Stretch mode 'all', 'last' or 'none'.
|
19
|
-
* @property {Function} stretchingColumnWidthFn Function that returns the new width of the stretched column.
|
20
|
-
*/
|
21
|
-
/**
|
22
|
-
* @class ColumnStretching
|
23
|
-
*/
|
24
|
-
var _totalTargetWidth = /*#__PURE__*/new WeakMap();
|
25
|
-
var _totalColumns = /*#__PURE__*/new WeakMap();
|
26
|
-
var _stretchingColumnWidthFn = /*#__PURE__*/new WeakMap();
|
27
|
-
var _columnWidthFn = /*#__PURE__*/new WeakMap();
|
28
|
-
var _stretchMode = /*#__PURE__*/new WeakMap();
|
29
|
-
class ColumnStretching {
|
30
|
-
/**
|
31
|
-
* @param {ColumnStretchingOptions} options Object with all options specified for column viewport calculation.
|
32
|
-
*/
|
33
|
-
constructor(_ref) {
|
34
|
-
let {
|
35
|
-
totalColumns,
|
36
|
-
stretchMode,
|
37
|
-
stretchingColumnWidthFn,
|
38
|
-
columnWidthFn
|
39
|
-
} = _ref;
|
40
|
-
/**
|
41
|
-
* @type {number}
|
42
|
-
*/
|
43
|
-
_defineProperty(this, "stretchAllRatio", 0);
|
44
|
-
/**
|
45
|
-
* @type {number}
|
46
|
-
*/
|
47
|
-
_defineProperty(this, "stretchLastWidth", 0);
|
48
|
-
/**
|
49
|
-
* @type {number[]}
|
50
|
-
*/
|
51
|
-
_defineProperty(this, "stretchAllColumnsWidth", []);
|
52
|
-
/**
|
53
|
-
* @type {number}
|
54
|
-
*/
|
55
|
-
_classPrivateFieldInitSpec(this, _totalTargetWidth, 0);
|
56
|
-
/**
|
57
|
-
* @type {boolean}
|
58
|
-
*/
|
59
|
-
_defineProperty(this, "needVerifyLastColumnWidth", true);
|
60
|
-
/**
|
61
|
-
* The total number of columns.
|
62
|
-
*
|
63
|
-
* @type {function(): number}
|
64
|
-
*/
|
65
|
-
_classPrivateFieldInitSpec(this, _totalColumns, () => 0);
|
66
|
-
/**
|
67
|
-
* Function that returns the width of the stretched column at a given index (in px).
|
68
|
-
*
|
69
|
-
* @type {function(): number}
|
70
|
-
*/
|
71
|
-
_classPrivateFieldInitSpec(this, _stretchingColumnWidthFn, width => width);
|
72
|
-
/**
|
73
|
-
* Function that returns the width of the column at a given index (in px).
|
74
|
-
*
|
75
|
-
* @type {function(): number}
|
76
|
-
*/
|
77
|
-
_classPrivateFieldInitSpec(this, _columnWidthFn, width => width);
|
78
|
-
/**
|
79
|
-
* Stretch mode.
|
80
|
-
*
|
81
|
-
* @type {function(): 'all' | 'last' | 'none'}
|
82
|
-
*/
|
83
|
-
_classPrivateFieldInitSpec(this, _stretchMode, () => 'none');
|
84
|
-
_classPrivateFieldSet(_totalColumns, this, totalColumns);
|
85
|
-
_classPrivateFieldSet(_stretchMode, this, stretchMode);
|
86
|
-
_classPrivateFieldSet(_stretchingColumnWidthFn, this, stretchingColumnWidthFn !== null && stretchingColumnWidthFn !== void 0 ? stretchingColumnWidthFn : _classPrivateFieldGet(_stretchingColumnWidthFn, this));
|
87
|
-
_classPrivateFieldSet(_columnWidthFn, this, columnWidthFn !== null && columnWidthFn !== void 0 ? columnWidthFn : _classPrivateFieldGet(_columnWidthFn, this));
|
88
|
-
}
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Recalculate columns stretching.
|
92
|
-
*
|
93
|
-
* @param {number} totalWidth The total width of the table.
|
94
|
-
*/
|
95
|
-
refreshStretching(totalWidth) {
|
96
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'none') {
|
97
|
-
return;
|
98
|
-
}
|
99
|
-
this.stretchAllRatio = 0;
|
100
|
-
this.stretchAllColumnsWidth = [];
|
101
|
-
this.needVerifyLastColumnWidth = true;
|
102
|
-
this.stretchLastWidth = 0;
|
103
|
-
_classPrivateFieldSet(_totalTargetWidth, this, totalWidth);
|
104
|
-
let sumAll = 0;
|
105
|
-
for (let i = 0; i < _classPrivateFieldGet(_totalColumns, this).call(this); i++) {
|
106
|
-
const columnWidth = this._getColumnWidth(i);
|
107
|
-
const permanentColumnWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, undefined, i);
|
108
|
-
if (typeof permanentColumnWidth === 'number') {
|
109
|
-
totalWidth -= permanentColumnWidth;
|
110
|
-
} else {
|
111
|
-
sumAll += columnWidth;
|
112
|
-
}
|
113
|
-
}
|
114
|
-
const remainingSize = totalWidth - sumAll;
|
115
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && remainingSize > 0) {
|
116
|
-
this.stretchAllRatio = totalWidth / sumAll;
|
117
|
-
this.stretchAllColumnsWidth = [];
|
118
|
-
this.needVerifyLastColumnWidth = true;
|
119
|
-
} else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && totalWidth !== Infinity) {
|
120
|
-
const columnWidth = this._getColumnWidth(_classPrivateFieldGet(_totalColumns, this).call(this) - 1);
|
121
|
-
const lastColumnWidth = remainingSize + columnWidth;
|
122
|
-
this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : columnWidth;
|
123
|
-
}
|
124
|
-
}
|
125
|
-
|
126
|
-
/**
|
127
|
-
* Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
|
128
|
-
*
|
129
|
-
* @param {number} column The visual column index.
|
130
|
-
* @param {number} baseWidth The default column width.
|
131
|
-
* @returns {number|null}
|
132
|
-
*/
|
133
|
-
getStretchedColumnWidth(column, baseWidth) {
|
134
|
-
let result = null;
|
135
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && this.stretchAllRatio !== 0) {
|
136
|
-
result = this._getStretchedAllColumnWidth(column, baseWidth);
|
137
|
-
} else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && this.stretchLastWidth !== 0) {
|
138
|
-
result = this._getStretchedLastColumnWidth(column);
|
139
|
-
}
|
140
|
-
return result;
|
141
|
-
}
|
142
|
-
|
143
|
-
/**
|
144
|
-
* @param {number} column The visual column index.
|
145
|
-
* @param {number} baseWidth The default column width.
|
146
|
-
* @returns {number}
|
147
|
-
* @private
|
148
|
-
*/
|
149
|
-
_getStretchedAllColumnWidth(column, baseWidth) {
|
150
|
-
let sumRatioWidth = 0;
|
151
|
-
if (!this.stretchAllColumnsWidth[column]) {
|
152
|
-
const stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
|
153
|
-
const newStretchedWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, stretchedWidth, column);
|
154
|
-
if (newStretchedWidth === undefined) {
|
155
|
-
this.stretchAllColumnsWidth[column] = stretchedWidth;
|
156
|
-
} else {
|
157
|
-
this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
|
158
|
-
}
|
159
|
-
}
|
160
|
-
if (this.stretchAllColumnsWidth.length === _classPrivateFieldGet(_totalColumns, this).call(this) && this.needVerifyLastColumnWidth) {
|
161
|
-
this.needVerifyLastColumnWidth = false;
|
162
|
-
for (let i = 0; i < this.stretchAllColumnsWidth.length; i++) {
|
163
|
-
sumRatioWidth += this.stretchAllColumnsWidth[i];
|
164
|
-
}
|
165
|
-
if (sumRatioWidth !== _classPrivateFieldGet(_totalTargetWidth, this)) {
|
166
|
-
this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += _classPrivateFieldGet(_totalTargetWidth, this) - sumRatioWidth;
|
167
|
-
}
|
168
|
-
}
|
169
|
-
return this.stretchAllColumnsWidth[column];
|
170
|
-
}
|
171
|
-
|
172
|
-
/**
|
173
|
-
* @param {number} column The visual column index.
|
174
|
-
* @returns {number|null}
|
175
|
-
* @private
|
176
|
-
*/
|
177
|
-
_getStretchedLastColumnWidth(column) {
|
178
|
-
if (column === _classPrivateFieldGet(_totalColumns, this).call(this) - 1) {
|
179
|
-
return this.stretchLastWidth;
|
180
|
-
}
|
181
|
-
return null;
|
182
|
-
}
|
183
|
-
|
184
|
-
/**
|
185
|
-
* @param {number} column The visual column index.
|
186
|
-
* @returns {number}
|
187
|
-
* @private
|
188
|
-
*/
|
189
|
-
_getColumnWidth(column) {
|
190
|
-
let width = _classPrivateFieldGet(_columnWidthFn, this).call(this, column);
|
191
|
-
if (isNaN(width)) {
|
192
|
-
width = _calculator.DEFAULT_COLUMN_WIDTH;
|
193
|
-
}
|
194
|
-
return width;
|
195
|
-
}
|
196
|
-
}
|
197
|
-
exports.ColumnStretching = ColumnStretching;
|