handsontable 0.0.0-next-662a118-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/overlay/inlineStart.js +1 -1
- package/3rdparty/walkontable/src/overlay/inlineStart.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 +0 -7
- package/3rdparty/walkontable/src/settings.mjs +0 -7
- package/3rdparty/walkontable/src/table.js +0 -24
- package/3rdparty/walkontable/src/table.mjs +0 -24
- package/3rdparty/walkontable/src/utils/column.js +0 -42
- package/3rdparty/walkontable/src/utils/column.mjs +0 -42
- package/3rdparty/walkontable/src/viewport.js +66 -87
- package/3rdparty/walkontable/src/viewport.mjs +67 -88
- 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 -4
- package/core.mjs +6 -4
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +2217 -1821
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +10 -10
- package/dist/handsontable.js +2219 -1823
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +10 -10
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/index.d.ts +7 -0
- package/package.json +6 -1
- package/plugins/comments/comments.js +1 -1
- package/plugins/comments/comments.mjs +1 -1
- 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/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 -6
- package/tableView.mjs +39 -6
- package/3rdparty/walkontable/src/utils/columnStretching.js +0 -197
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +0 -193
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-802f59c-20241024";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-802f59c-20241024";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let domMessageState = 'invalid';
|
package/index.d.ts
CHANGED
@@ -220,6 +220,9 @@ import {
|
|
220
220
|
SearchCallback,
|
221
221
|
SearchQueryMethod,
|
222
222
|
} from './plugins/search';
|
223
|
+
import {
|
224
|
+
Settings as StretchColumnsSettings,
|
225
|
+
} from './plugins/stretchColumns';
|
223
226
|
import {
|
224
227
|
TouchScroll as _TouchScroll,
|
225
228
|
Settings as TouchScrollSettings,
|
@@ -523,6 +526,10 @@ declare namespace Handsontable {
|
|
523
526
|
export { SearchQueryMethod };
|
524
527
|
}
|
525
528
|
|
529
|
+
export namespace StretchColumns {
|
530
|
+
export { StretchColumnsSettings as Settings };
|
531
|
+
}
|
532
|
+
|
526
533
|
export namespace TouchScroll {
|
527
534
|
export { TouchScrollSettings as Settings };
|
528
535
|
}
|
package/package.json
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
"url": "https://github.com/handsontable/handsontable/issues"
|
11
11
|
},
|
12
12
|
"author": "Handsoncode <hello@handsontable.com>",
|
13
|
-
"version": "0.0.0-next-
|
13
|
+
"version": "0.0.0-next-802f59c-20241024",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -472,6 +472,11 @@
|
|
472
472
|
"require": "./plugins/search/index.js",
|
473
473
|
"import": "./plugins/search/index.mjs"
|
474
474
|
},
|
475
|
+
"./plugins/stretchColumns": {
|
476
|
+
"types": "./plugins/stretchColumns/index.d.ts",
|
477
|
+
"require": "./plugins/stretchColumns/index.js",
|
478
|
+
"import": "./plugins/stretchColumns/index.mjs"
|
479
|
+
},
|
475
480
|
"./plugins/touchScroll": {
|
476
481
|
"types": "./plugins/touchScroll/index.d.ts",
|
477
482
|
"require": "./plugins/touchScroll/index.js",
|
@@ -575,7 +575,7 @@ class Comments extends _base.BasePlugin {
|
|
575
575
|
} else {
|
576
576
|
_classPrivateFieldGet(_editor, this).resetSize();
|
577
577
|
}
|
578
|
-
const lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.
|
578
|
+
const lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getColumnWidth(renderableColumn);
|
579
579
|
const lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? (0, _element.outerHeight)(TD) : 0;
|
580
580
|
const {
|
581
581
|
left,
|
@@ -571,7 +571,7 @@ export class Comments extends BasePlugin {
|
|
571
571
|
} else {
|
572
572
|
_classPrivateFieldGet(_editor, this).resetSize();
|
573
573
|
}
|
574
|
-
const lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.
|
574
|
+
const lastColWidth = isBeforeRenderedColumns ? 0 : wtTable.getColumnWidth(renderableColumn);
|
575
575
|
const lastRowHeight = targetingPreviousRow && !isBeforeRenderedRows ? outerHeight(TD) : 0;
|
576
576
|
const {
|
577
577
|
left,
|
package/plugins/index.d.ts
CHANGED
@@ -29,6 +29,7 @@ import { NestedHeaders } from './nestedHeaders';
|
|
29
29
|
import { NestedRows } from './nestedRows';
|
30
30
|
import { PersistentState } from './persistentState';
|
31
31
|
import { Search } from './search';
|
32
|
+
import { StretchColumns } from './stretchColumns';
|
32
33
|
import { TouchScroll } from './touchScroll';
|
33
34
|
import { TrimRows } from './trimRows';
|
34
35
|
import { UndoRedo } from './undoRedo';
|
@@ -65,6 +66,7 @@ export interface Plugins {
|
|
65
66
|
nestedRows: NestedRows;
|
66
67
|
persistentState: PersistentState;
|
67
68
|
search: Search;
|
69
|
+
stretchColumns: StretchColumns;
|
68
70
|
touchScroll: TouchScroll;
|
69
71
|
trimRows: TrimRows;
|
70
72
|
undoRedo: UndoRedo;
|
@@ -105,6 +107,7 @@ export {
|
|
105
107
|
NestedRows,
|
106
108
|
PersistentState,
|
107
109
|
Search,
|
110
|
+
StretchColumns,
|
108
111
|
TouchScroll,
|
109
112
|
TrimRows,
|
110
113
|
UndoRedo
|
package/plugins/index.js
CHANGED
@@ -64,6 +64,8 @@ var _persistentState = require("./persistentState");
|
|
64
64
|
exports.PersistentState = _persistentState.PersistentState;
|
65
65
|
var _search = require("./search");
|
66
66
|
exports.Search = _search.Search;
|
67
|
+
var _stretchColumns = require("./stretchColumns");
|
68
|
+
exports.StretchColumns = _stretchColumns.StretchColumns;
|
67
69
|
var _touchScroll = require("./touchScroll");
|
68
70
|
exports.TouchScroll = _touchScroll.TouchScroll;
|
69
71
|
var _trimRows = require("./trimRows");
|
@@ -108,6 +110,7 @@ function registerAllPlugins() {
|
|
108
110
|
(0, _registry.registerPlugin)(_nestedRows.NestedRows);
|
109
111
|
(0, _registry.registerPlugin)(_persistentState.PersistentState);
|
110
112
|
(0, _registry.registerPlugin)(_search.Search);
|
113
|
+
(0, _registry.registerPlugin)(_stretchColumns.StretchColumns);
|
111
114
|
(0, _registry.registerPlugin)(_touchScroll.TouchScroll);
|
112
115
|
(0, _registry.registerPlugin)(_trimRows.TrimRows);
|
113
116
|
(0, _registry.registerPlugin)(_undoRedo.UndoRedo);
|
package/plugins/index.mjs
CHANGED
@@ -29,6 +29,7 @@ import { NestedHeaders } from "./nestedHeaders/index.mjs";
|
|
29
29
|
import { NestedRows } from "./nestedRows/index.mjs";
|
30
30
|
import { PersistentState } from "./persistentState/index.mjs";
|
31
31
|
import { Search } from "./search/index.mjs";
|
32
|
+
import { StretchColumns } from "./stretchColumns/index.mjs";
|
32
33
|
import { TouchScroll } from "./touchScroll/index.mjs";
|
33
34
|
import { TrimRows } from "./trimRows/index.mjs";
|
34
35
|
import { UndoRedo } from "./undoRedo/index.mjs";
|
@@ -67,9 +68,10 @@ export function registerAllPlugins() {
|
|
67
68
|
registerPlugin(NestedRows);
|
68
69
|
registerPlugin(PersistentState);
|
69
70
|
registerPlugin(Search);
|
71
|
+
registerPlugin(StretchColumns);
|
70
72
|
registerPlugin(TouchScroll);
|
71
73
|
registerPlugin(TrimRows);
|
72
74
|
registerPlugin(UndoRedo);
|
73
75
|
}
|
74
|
-
export { AutoColumnSize, Autofill, AutoRowSize, BasePlugin, BindRowsWithHeaders, CollapsibleColumns, ColumnSorting, ColumnSummary, Comments, ContextMenu, CopyPaste, CustomBorders, DragToScroll, DropdownMenu, ExportFile, Filters, Formulas, HiddenColumns, HiddenRows, ManualColumnFreeze, ManualColumnMove, ManualColumnResize, ManualRowMove, ManualRowResize, MergeCells, MultiColumnSorting, MultipleSelectionHandles, NestedHeaders, NestedRows, PersistentState, Search, TouchScroll, TrimRows, UndoRedo };
|
76
|
+
export { AutoColumnSize, Autofill, AutoRowSize, BasePlugin, BindRowsWithHeaders, CollapsibleColumns, ColumnSorting, ColumnSummary, Comments, ContextMenu, CopyPaste, CustomBorders, DragToScroll, DropdownMenu, ExportFile, Filters, Formulas, HiddenColumns, HiddenRows, ManualColumnFreeze, ManualColumnMove, ManualColumnResize, ManualRowMove, ManualRowResize, MergeCells, MultiColumnSorting, MultipleSelectionHandles, NestedHeaders, NestedRows, PersistentState, Search, StretchColumns, TouchScroll, TrimRows, UndoRedo };
|
75
77
|
export { getPlugin, getPluginsNames, registerPlugin } from "./registry.mjs";
|
@@ -339,13 +339,11 @@ class ManualColumnMove extends _base.BasePlugin {
|
|
339
339
|
const columnMapper = this.hot.columnIndexMapper;
|
340
340
|
let columnsWidth = 0;
|
341
341
|
for (let visualColumnIndex = fromColumn; visualColumnIndex <= toColumn; visualColumnIndex += 1) {
|
342
|
-
// We can't use just `getColWidth` (even without indexes translation) as it doesn't return proper values
|
343
|
-
// when column is stretched.
|
344
342
|
const renderableIndex = columnMapper.getRenderableFromVisualIndex(visualColumnIndex);
|
345
343
|
if (visualColumnIndex < 0) {
|
346
344
|
columnsWidth += this.hot.view._wt.wtViewport.getRowHeaderWidth() || 0;
|
347
345
|
} else if (renderableIndex !== null) {
|
348
|
-
columnsWidth += this.hot.view._wt.wtTable.
|
346
|
+
columnsWidth += this.hot.view._wt.wtTable.getColumnWidth(renderableIndex) || 0;
|
349
347
|
}
|
350
348
|
}
|
351
349
|
return columnsWidth;
|
@@ -335,13 +335,11 @@ export class ManualColumnMove extends BasePlugin {
|
|
335
335
|
const columnMapper = this.hot.columnIndexMapper;
|
336
336
|
let columnsWidth = 0;
|
337
337
|
for (let visualColumnIndex = fromColumn; visualColumnIndex <= toColumn; visualColumnIndex += 1) {
|
338
|
-
// We can't use just `getColWidth` (even without indexes translation) as it doesn't return proper values
|
339
|
-
// when column is stretched.
|
340
338
|
const renderableIndex = columnMapper.getRenderableFromVisualIndex(visualColumnIndex);
|
341
339
|
if (visualColumnIndex < 0) {
|
342
340
|
columnsWidth += this.hot.view._wt.wtViewport.getRowHeaderWidth() || 0;
|
343
341
|
} else if (renderableIndex !== null) {
|
344
|
-
columnsWidth += this.hot.view._wt.wtTable.
|
342
|
+
columnsWidth += this.hot.view._wt.wtTable.getColumnWidth(renderableIndex) || 0;
|
345
343
|
}
|
346
344
|
}
|
347
345
|
return columnsWidth;
|
@@ -162,15 +162,31 @@ class ManualColumnResize extends _base.BasePlugin {
|
|
162
162
|
* Enables the plugin functionality for this Handsontable instance.
|
163
163
|
*/
|
164
164
|
enablePlugin() {
|
165
|
+
var _this = this;
|
165
166
|
if (this.enabled) {
|
166
167
|
return;
|
167
168
|
}
|
168
169
|
_classPrivateFieldSet(_columnWidthsMap, this, new _translations.PhysicalIndexToValueMap());
|
169
170
|
_classPrivateFieldGet(_columnWidthsMap, this).addLocalHook('init', () => _assertClassBrand(_ManualColumnResize_brand, this, _onMapInit).call(this));
|
170
171
|
this.hot.columnIndexMapper.registerMap(this.pluginName, _classPrivateFieldGet(_columnWidthsMap, this));
|
171
|
-
this.addHook('modifyColWidth',
|
172
|
-
|
173
|
-
|
172
|
+
this.addHook('modifyColWidth', function () {
|
173
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
174
|
+
args[_key] = arguments[_key];
|
175
|
+
}
|
176
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onModifyColWidth).call(_this, ...args);
|
177
|
+
}, 1);
|
178
|
+
this.addHook('beforeStretchingColumnWidth', function () {
|
179
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
180
|
+
args[_key2] = arguments[_key2];
|
181
|
+
}
|
182
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onBeforeStretchingColumnWidth).call(_this, ...args);
|
183
|
+
}, 1);
|
184
|
+
this.addHook('beforeColumnResize', function () {
|
185
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
186
|
+
args[_key3] = arguments[_key3];
|
187
|
+
}
|
188
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onBeforeColumnResize).call(_this, ...args);
|
189
|
+
});
|
174
190
|
this.bindEvents();
|
175
191
|
super.enablePlugin();
|
176
192
|
}
|
@@ -408,11 +424,7 @@ class ManualColumnResize extends _base.BasePlugin {
|
|
408
424
|
if (hookNewSize !== undefined) {
|
409
425
|
_classPrivateFieldSet(_newSize, this, hookNewSize);
|
410
426
|
}
|
411
|
-
|
412
|
-
this.clearManualSize(column);
|
413
|
-
} else {
|
414
|
-
this.setManualSize(column, _classPrivateFieldGet(_newSize, this)); // double click sets by auto row size plugin
|
415
|
-
}
|
427
|
+
this.setManualSize(column, _classPrivateFieldGet(_newSize, this)); // double click sets by auto row size plugin
|
416
428
|
this.saveManualColumnWidths();
|
417
429
|
this.hot.runHooks('afterColumnResize', _classPrivateFieldGet(_newSize, this), column, true);
|
418
430
|
if (forceRender) {
|
@@ -630,11 +642,11 @@ function _onModifyColWidth(width, column) {
|
|
630
642
|
* @returns {number}
|
631
643
|
*/
|
632
644
|
function _onBeforeStretchingColumnWidth(stretchedWidth, column) {
|
633
|
-
|
634
|
-
if (width ===
|
635
|
-
width
|
645
|
+
const width = _classPrivateFieldGet(_columnWidthsMap, this).getValueAtIndex(this.hot.toPhysicalColumn(column));
|
646
|
+
if (typeof width === 'number') {
|
647
|
+
return width;
|
636
648
|
}
|
637
|
-
return
|
649
|
+
return stretchedWidth;
|
638
650
|
}
|
639
651
|
/**
|
640
652
|
* `beforeColumnResize` hook callback.
|
@@ -157,15 +157,31 @@ export class ManualColumnResize extends BasePlugin {
|
|
157
157
|
* Enables the plugin functionality for this Handsontable instance.
|
158
158
|
*/
|
159
159
|
enablePlugin() {
|
160
|
+
var _this = this;
|
160
161
|
if (this.enabled) {
|
161
162
|
return;
|
162
163
|
}
|
163
164
|
_classPrivateFieldSet(_columnWidthsMap, this, new IndexToValueMap());
|
164
165
|
_classPrivateFieldGet(_columnWidthsMap, this).addLocalHook('init', () => _assertClassBrand(_ManualColumnResize_brand, this, _onMapInit).call(this));
|
165
166
|
this.hot.columnIndexMapper.registerMap(this.pluginName, _classPrivateFieldGet(_columnWidthsMap, this));
|
166
|
-
this.addHook('modifyColWidth',
|
167
|
-
|
168
|
-
|
167
|
+
this.addHook('modifyColWidth', function () {
|
168
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
169
|
+
args[_key] = arguments[_key];
|
170
|
+
}
|
171
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onModifyColWidth).call(_this, ...args);
|
172
|
+
}, 1);
|
173
|
+
this.addHook('beforeStretchingColumnWidth', function () {
|
174
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
175
|
+
args[_key2] = arguments[_key2];
|
176
|
+
}
|
177
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onBeforeStretchingColumnWidth).call(_this, ...args);
|
178
|
+
}, 1);
|
179
|
+
this.addHook('beforeColumnResize', function () {
|
180
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
181
|
+
args[_key3] = arguments[_key3];
|
182
|
+
}
|
183
|
+
return _assertClassBrand(_ManualColumnResize_brand, _this, _onBeforeColumnResize).call(_this, ...args);
|
184
|
+
});
|
169
185
|
this.bindEvents();
|
170
186
|
super.enablePlugin();
|
171
187
|
}
|
@@ -403,11 +419,7 @@ export class ManualColumnResize extends BasePlugin {
|
|
403
419
|
if (hookNewSize !== undefined) {
|
404
420
|
_classPrivateFieldSet(_newSize, this, hookNewSize);
|
405
421
|
}
|
406
|
-
|
407
|
-
this.clearManualSize(column);
|
408
|
-
} else {
|
409
|
-
this.setManualSize(column, _classPrivateFieldGet(_newSize, this)); // double click sets by auto row size plugin
|
410
|
-
}
|
422
|
+
this.setManualSize(column, _classPrivateFieldGet(_newSize, this)); // double click sets by auto row size plugin
|
411
423
|
this.saveManualColumnWidths();
|
412
424
|
this.hot.runHooks('afterColumnResize', _classPrivateFieldGet(_newSize, this), column, true);
|
413
425
|
if (forceRender) {
|
@@ -624,11 +636,11 @@ function _onModifyColWidth(width, column) {
|
|
624
636
|
* @returns {number}
|
625
637
|
*/
|
626
638
|
function _onBeforeStretchingColumnWidth(stretchedWidth, column) {
|
627
|
-
|
628
|
-
if (width ===
|
629
|
-
width
|
639
|
+
const width = _classPrivateFieldGet(_columnWidthsMap, this).getValueAtIndex(this.hot.toPhysicalColumn(column));
|
640
|
+
if (typeof width === 'number') {
|
641
|
+
return width;
|
630
642
|
}
|
631
|
-
return
|
643
|
+
return stretchedWidth;
|
632
644
|
}
|
633
645
|
/**
|
634
646
|
* `beforeColumnResize` hook callback.
|
@@ -0,0 +1,159 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
exports.__esModule = true;
|
4
|
+
require("core-js/modules/es.error.cause.js");
|
5
|
+
var _src = require("../../3rdparty/walkontable/src");
|
6
|
+
var _element = require("../../helpers/dom/element");
|
7
|
+
var _all = require("./strategies/all");
|
8
|
+
var _last = require("./strategies/last");
|
9
|
+
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
10
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
11
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
12
|
+
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
13
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
14
|
+
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"); }
|
15
|
+
const STRETCH_WIDTH_MAP_NAME = 'stretchColumns';
|
16
|
+
|
17
|
+
/**
|
18
|
+
* The class responsible for calculating the column widths based on the specified column stretching strategy.
|
19
|
+
*
|
20
|
+
* @private
|
21
|
+
* @class StretchCalculator
|
22
|
+
*/
|
23
|
+
var _hot = /*#__PURE__*/new WeakMap();
|
24
|
+
var _widthsMap = /*#__PURE__*/new WeakMap();
|
25
|
+
var _stretchStrategies = /*#__PURE__*/new WeakMap();
|
26
|
+
var _activeStrategy = /*#__PURE__*/new WeakMap();
|
27
|
+
var _StretchCalculator_brand = /*#__PURE__*/new WeakSet();
|
28
|
+
class StretchCalculator {
|
29
|
+
constructor(hotInstance) {
|
30
|
+
/**
|
31
|
+
* Checks if the vertical scrollbar will appear. Based on the current data and viewport size
|
32
|
+
* the method calculates if the vertical scrollbar will appear after the table is rendered.
|
33
|
+
* The method is a workaround for the issue in the Walkontable that returns unstable viewport
|
34
|
+
* size.
|
35
|
+
*
|
36
|
+
* @returns {boolean}
|
37
|
+
*/
|
38
|
+
_classPrivateMethodInitSpec(this, _StretchCalculator_brand);
|
39
|
+
/**
|
40
|
+
* The Handsontable instance.
|
41
|
+
*
|
42
|
+
* @type {Core}
|
43
|
+
*/
|
44
|
+
_classPrivateFieldInitSpec(this, _hot, void 0);
|
45
|
+
/**
|
46
|
+
* The map that stores the calculated column widths.
|
47
|
+
*
|
48
|
+
* @type {IndexToValueMap}
|
49
|
+
*/
|
50
|
+
_classPrivateFieldInitSpec(this, _widthsMap, void 0);
|
51
|
+
/**
|
52
|
+
* The map that stores the available stretch strategies.
|
53
|
+
*
|
54
|
+
* @type {Map<string, StretchAllStrategy | StretchLastStrategy>}
|
55
|
+
*/
|
56
|
+
_classPrivateFieldInitSpec(this, _stretchStrategies, new Map([['all', new _all.StretchAllStrategy(_assertClassBrand(_StretchCalculator_brand, this, _overwriteColumnWidthFn).bind(this))], ['last', new _last.StretchLastStrategy(_assertClassBrand(_StretchCalculator_brand, this, _overwriteColumnWidthFn).bind(this))]]));
|
57
|
+
/**
|
58
|
+
* The active stretch mode.
|
59
|
+
*
|
60
|
+
* @type {'all' | 'last' | 'none'}
|
61
|
+
*/
|
62
|
+
_classPrivateFieldInitSpec(this, _activeStrategy, 'none');
|
63
|
+
_classPrivateFieldSet(_hot, this, hotInstance);
|
64
|
+
_classPrivateFieldSet(_widthsMap, this, _classPrivateFieldGet(_hot, this).columnIndexMapper.createAndRegisterIndexMap(STRETCH_WIDTH_MAP_NAME, 'physicalIndexToValue'));
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Sets the active stretch strategy.
|
69
|
+
*
|
70
|
+
* @param {'all' | 'last' | 'none'} strategyName The stretch strategy to use.
|
71
|
+
*/
|
72
|
+
useStrategy(strategyName) {
|
73
|
+
_classPrivateFieldSet(_activeStrategy, this, _classPrivateFieldGet(_stretchStrategies, this).has(strategyName) ? strategyName : 'none');
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
* Recalculates the column widths.
|
78
|
+
*/
|
79
|
+
refreshStretching() {
|
80
|
+
if (_classPrivateFieldGet(_activeStrategy, this) === 'none') {
|
81
|
+
_classPrivateFieldGet(_widthsMap, this).clear();
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
_classPrivateFieldGet(_hot, this).batchExecution(() => {
|
85
|
+
_classPrivateFieldGet(_widthsMap, this).clear();
|
86
|
+
const stretchStrategy = _classPrivateFieldGet(_stretchStrategies, this).get(_classPrivateFieldGet(_activeStrategy, this));
|
87
|
+
const view = _classPrivateFieldGet(_hot, this).view;
|
88
|
+
let viewportWidth = view.getViewportWidth();
|
89
|
+
if (_assertClassBrand(_StretchCalculator_brand, this, _willVerticalScrollAppear).call(this)) {
|
90
|
+
viewportWidth -= (0, _element.getScrollbarWidth)(_classPrivateFieldGet(_hot, this).rootDocument);
|
91
|
+
}
|
92
|
+
stretchStrategy.prepare({
|
93
|
+
viewportWidth
|
94
|
+
});
|
95
|
+
for (let columnIndex = 0; columnIndex < _classPrivateFieldGet(_hot, this).countCols(); columnIndex++) {
|
96
|
+
if (!_classPrivateFieldGet(_hot, this).columnIndexMapper.isHidden(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnIndex))) {
|
97
|
+
stretchStrategy.setColumnBaseWidth(columnIndex, _assertClassBrand(_StretchCalculator_brand, this, _getWidthWithoutStretching).call(this, columnIndex));
|
98
|
+
}
|
99
|
+
}
|
100
|
+
stretchStrategy.calculate();
|
101
|
+
stretchStrategy.getWidths().forEach(_ref => {
|
102
|
+
let [columnIndex, width] = _ref;
|
103
|
+
_classPrivateFieldGet(_widthsMap, this).setValueAtIndex(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnIndex), width);
|
104
|
+
});
|
105
|
+
}, true);
|
106
|
+
}
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Gets the calculated column width.
|
110
|
+
*
|
111
|
+
* @param {number} columnVisualIndex Column visual index.
|
112
|
+
* @returns {number | null}
|
113
|
+
*/
|
114
|
+
getStretchedWidth(columnVisualIndex) {
|
115
|
+
return _classPrivateFieldGet(_widthsMap, this).getValueAtIndex(_classPrivateFieldGet(_hot, this).toPhysicalColumn(columnVisualIndex));
|
116
|
+
}
|
117
|
+
}
|
118
|
+
exports.StretchCalculator = StretchCalculator;
|
119
|
+
function _willVerticalScrollAppear() {
|
120
|
+
const {
|
121
|
+
view
|
122
|
+
} = _classPrivateFieldGet(_hot, this);
|
123
|
+
if (view.isVerticallyScrollableByWindow()) {
|
124
|
+
return false;
|
125
|
+
}
|
126
|
+
const viewportHeight = view.getViewportHeight();
|
127
|
+
const totalRows = _classPrivateFieldGet(_hot, this).countRows();
|
128
|
+
let totalHeight = 0;
|
129
|
+
let hasVerticalScroll = false;
|
130
|
+
for (let row = 0; row < totalRows; row++) {
|
131
|
+
var _classPrivateFieldGet2;
|
132
|
+
totalHeight += ((_classPrivateFieldGet2 = _classPrivateFieldGet(_hot, this).getRowHeight(row)) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : _src.DEFAULT_ROW_HEIGHT) + (row === 0 ? 1 : 0);
|
133
|
+
if (totalHeight > viewportHeight) {
|
134
|
+
hasVerticalScroll = true;
|
135
|
+
break;
|
136
|
+
}
|
137
|
+
}
|
138
|
+
return hasVerticalScroll;
|
139
|
+
}
|
140
|
+
/**
|
141
|
+
* Gets the column width from the Handsontable API without logic related to stretching.
|
142
|
+
*
|
143
|
+
* @param {number} columnVisualIndex Column visual index.
|
144
|
+
* @returns {number}
|
145
|
+
*/
|
146
|
+
function _getWidthWithoutStretching(columnVisualIndex) {
|
147
|
+
var _classPrivateFieldGet3;
|
148
|
+
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_hot, this).getColWidth(columnVisualIndex, 'StretchColumns')) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : _src.DEFAULT_COLUMN_WIDTH;
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Executes the hook that allows to overwrite the column width.
|
152
|
+
*
|
153
|
+
* @param {number} columnWidth The column width.
|
154
|
+
* @param {number} columnVisualIndex Column visual index.
|
155
|
+
* @returns {number}
|
156
|
+
*/
|
157
|
+
function _overwriteColumnWidthFn(columnWidth, columnVisualIndex) {
|
158
|
+
return _classPrivateFieldGet(_hot, this).runHooks('beforeStretchingColumnWidth', columnWidth, columnVisualIndex);
|
159
|
+
}
|
@@ -0,0 +1,155 @@
|
|
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
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './stretchColumns';
|
@@ -0,0 +1,7 @@
|
|
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;
|
@@ -0,0 +1 @@
|
|
1
|
+
export { PLUGIN_KEY, PLUGIN_PRIORITY, StretchColumns } from "./stretchColumns.mjs";
|