handsontable 0.0.0-next-fd98d33-20241029 → 0.0.0-next-4c8e3b1-20241029
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 +2226 -1821
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +10 -10
- package/dist/handsontable.js +2228 -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 +220 -0
- package/plugins/stretchColumns/stretchColumns.mjs +216 -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
@@ -1,193 +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 _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; }
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
6
|
-
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); }
|
7
|
-
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
8
|
-
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
9
|
-
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
10
|
-
import { DEFAULT_COLUMN_WIDTH } from "../calculator/index.mjs";
|
11
|
-
/**
|
12
|
-
* @typedef {object} ColumnStretchingOptions
|
13
|
-
* @property {number} totalColumns Total number of columns.
|
14
|
-
* @property {Function} columnWidthFn Function that returns the width of the column at a given index (in px).
|
15
|
-
* @property {'all' | 'last' | 'none'} stretchMode Stretch mode 'all', 'last' or 'none'.
|
16
|
-
* @property {Function} stretchingColumnWidthFn Function that returns the new width of the stretched column.
|
17
|
-
*/
|
18
|
-
/**
|
19
|
-
* @class ColumnStretching
|
20
|
-
*/
|
21
|
-
var _totalTargetWidth = /*#__PURE__*/new WeakMap();
|
22
|
-
var _totalColumns = /*#__PURE__*/new WeakMap();
|
23
|
-
var _stretchingColumnWidthFn = /*#__PURE__*/new WeakMap();
|
24
|
-
var _columnWidthFn = /*#__PURE__*/new WeakMap();
|
25
|
-
var _stretchMode = /*#__PURE__*/new WeakMap();
|
26
|
-
export class ColumnStretching {
|
27
|
-
/**
|
28
|
-
* @param {ColumnStretchingOptions} options Object with all options specified for column viewport calculation.
|
29
|
-
*/
|
30
|
-
constructor(_ref) {
|
31
|
-
let {
|
32
|
-
totalColumns,
|
33
|
-
stretchMode,
|
34
|
-
stretchingColumnWidthFn,
|
35
|
-
columnWidthFn
|
36
|
-
} = _ref;
|
37
|
-
/**
|
38
|
-
* @type {number}
|
39
|
-
*/
|
40
|
-
_defineProperty(this, "stretchAllRatio", 0);
|
41
|
-
/**
|
42
|
-
* @type {number}
|
43
|
-
*/
|
44
|
-
_defineProperty(this, "stretchLastWidth", 0);
|
45
|
-
/**
|
46
|
-
* @type {number[]}
|
47
|
-
*/
|
48
|
-
_defineProperty(this, "stretchAllColumnsWidth", []);
|
49
|
-
/**
|
50
|
-
* @type {number}
|
51
|
-
*/
|
52
|
-
_classPrivateFieldInitSpec(this, _totalTargetWidth, 0);
|
53
|
-
/**
|
54
|
-
* @type {boolean}
|
55
|
-
*/
|
56
|
-
_defineProperty(this, "needVerifyLastColumnWidth", true);
|
57
|
-
/**
|
58
|
-
* The total number of columns.
|
59
|
-
*
|
60
|
-
* @type {function(): number}
|
61
|
-
*/
|
62
|
-
_classPrivateFieldInitSpec(this, _totalColumns, () => 0);
|
63
|
-
/**
|
64
|
-
* Function that returns the width of the stretched column at a given index (in px).
|
65
|
-
*
|
66
|
-
* @type {function(): number}
|
67
|
-
*/
|
68
|
-
_classPrivateFieldInitSpec(this, _stretchingColumnWidthFn, width => width);
|
69
|
-
/**
|
70
|
-
* Function that returns the width of the column at a given index (in px).
|
71
|
-
*
|
72
|
-
* @type {function(): number}
|
73
|
-
*/
|
74
|
-
_classPrivateFieldInitSpec(this, _columnWidthFn, width => width);
|
75
|
-
/**
|
76
|
-
* Stretch mode.
|
77
|
-
*
|
78
|
-
* @type {function(): 'all' | 'last' | 'none'}
|
79
|
-
*/
|
80
|
-
_classPrivateFieldInitSpec(this, _stretchMode, () => 'none');
|
81
|
-
_classPrivateFieldSet(_totalColumns, this, totalColumns);
|
82
|
-
_classPrivateFieldSet(_stretchMode, this, stretchMode);
|
83
|
-
_classPrivateFieldSet(_stretchingColumnWidthFn, this, stretchingColumnWidthFn !== null && stretchingColumnWidthFn !== void 0 ? stretchingColumnWidthFn : _classPrivateFieldGet(_stretchingColumnWidthFn, this));
|
84
|
-
_classPrivateFieldSet(_columnWidthFn, this, columnWidthFn !== null && columnWidthFn !== void 0 ? columnWidthFn : _classPrivateFieldGet(_columnWidthFn, this));
|
85
|
-
}
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Recalculate columns stretching.
|
89
|
-
*
|
90
|
-
* @param {number} totalWidth The total width of the table.
|
91
|
-
*/
|
92
|
-
refreshStretching(totalWidth) {
|
93
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'none') {
|
94
|
-
return;
|
95
|
-
}
|
96
|
-
this.stretchAllRatio = 0;
|
97
|
-
this.stretchAllColumnsWidth = [];
|
98
|
-
this.needVerifyLastColumnWidth = true;
|
99
|
-
this.stretchLastWidth = 0;
|
100
|
-
_classPrivateFieldSet(_totalTargetWidth, this, totalWidth);
|
101
|
-
let sumAll = 0;
|
102
|
-
for (let i = 0; i < _classPrivateFieldGet(_totalColumns, this).call(this); i++) {
|
103
|
-
const columnWidth = this._getColumnWidth(i);
|
104
|
-
const permanentColumnWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, undefined, i);
|
105
|
-
if (typeof permanentColumnWidth === 'number') {
|
106
|
-
totalWidth -= permanentColumnWidth;
|
107
|
-
} else {
|
108
|
-
sumAll += columnWidth;
|
109
|
-
}
|
110
|
-
}
|
111
|
-
const remainingSize = totalWidth - sumAll;
|
112
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && remainingSize > 0) {
|
113
|
-
this.stretchAllRatio = totalWidth / sumAll;
|
114
|
-
this.stretchAllColumnsWidth = [];
|
115
|
-
this.needVerifyLastColumnWidth = true;
|
116
|
-
} else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && totalWidth !== Infinity) {
|
117
|
-
const columnWidth = this._getColumnWidth(_classPrivateFieldGet(_totalColumns, this).call(this) - 1);
|
118
|
-
const lastColumnWidth = remainingSize + columnWidth;
|
119
|
-
this.stretchLastWidth = lastColumnWidth >= 0 ? lastColumnWidth : columnWidth;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
|
123
|
-
/**
|
124
|
-
* Get stretched column width based on stretchH (all or last) setting passed in handsontable instance.
|
125
|
-
*
|
126
|
-
* @param {number} column The visual column index.
|
127
|
-
* @param {number} baseWidth The default column width.
|
128
|
-
* @returns {number|null}
|
129
|
-
*/
|
130
|
-
getStretchedColumnWidth(column, baseWidth) {
|
131
|
-
let result = null;
|
132
|
-
if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'all' && this.stretchAllRatio !== 0) {
|
133
|
-
result = this._getStretchedAllColumnWidth(column, baseWidth);
|
134
|
-
} else if (_classPrivateFieldGet(_stretchMode, this).call(this) === 'last' && this.stretchLastWidth !== 0) {
|
135
|
-
result = this._getStretchedLastColumnWidth(column);
|
136
|
-
}
|
137
|
-
return result;
|
138
|
-
}
|
139
|
-
|
140
|
-
/**
|
141
|
-
* @param {number} column The visual column index.
|
142
|
-
* @param {number} baseWidth The default column width.
|
143
|
-
* @returns {number}
|
144
|
-
* @private
|
145
|
-
*/
|
146
|
-
_getStretchedAllColumnWidth(column, baseWidth) {
|
147
|
-
let sumRatioWidth = 0;
|
148
|
-
if (!this.stretchAllColumnsWidth[column]) {
|
149
|
-
const stretchedWidth = Math.round(baseWidth * this.stretchAllRatio);
|
150
|
-
const newStretchedWidth = _classPrivateFieldGet(_stretchingColumnWidthFn, this).call(this, stretchedWidth, column);
|
151
|
-
if (newStretchedWidth === undefined) {
|
152
|
-
this.stretchAllColumnsWidth[column] = stretchedWidth;
|
153
|
-
} else {
|
154
|
-
this.stretchAllColumnsWidth[column] = isNaN(newStretchedWidth) ? this._getColumnWidth(column) : newStretchedWidth;
|
155
|
-
}
|
156
|
-
}
|
157
|
-
if (this.stretchAllColumnsWidth.length === _classPrivateFieldGet(_totalColumns, this).call(this) && this.needVerifyLastColumnWidth) {
|
158
|
-
this.needVerifyLastColumnWidth = false;
|
159
|
-
for (let i = 0; i < this.stretchAllColumnsWidth.length; i++) {
|
160
|
-
sumRatioWidth += this.stretchAllColumnsWidth[i];
|
161
|
-
}
|
162
|
-
if (sumRatioWidth !== _classPrivateFieldGet(_totalTargetWidth, this)) {
|
163
|
-
this.stretchAllColumnsWidth[this.stretchAllColumnsWidth.length - 1] += _classPrivateFieldGet(_totalTargetWidth, this) - sumRatioWidth;
|
164
|
-
}
|
165
|
-
}
|
166
|
-
return this.stretchAllColumnsWidth[column];
|
167
|
-
}
|
168
|
-
|
169
|
-
/**
|
170
|
-
* @param {number} column The visual column index.
|
171
|
-
* @returns {number|null}
|
172
|
-
* @private
|
173
|
-
*/
|
174
|
-
_getStretchedLastColumnWidth(column) {
|
175
|
-
if (column === _classPrivateFieldGet(_totalColumns, this).call(this) - 1) {
|
176
|
-
return this.stretchLastWidth;
|
177
|
-
}
|
178
|
-
return null;
|
179
|
-
}
|
180
|
-
|
181
|
-
/**
|
182
|
-
* @param {number} column The visual column index.
|
183
|
-
* @returns {number}
|
184
|
-
* @private
|
185
|
-
*/
|
186
|
-
_getColumnWidth(column) {
|
187
|
-
let width = _classPrivateFieldGet(_columnWidthFn, this).call(this, column);
|
188
|
-
if (isNaN(width)) {
|
189
|
-
width = DEFAULT_COLUMN_WIDTH;
|
190
|
-
}
|
191
|
-
return width;
|
192
|
-
}
|
193
|
-
}
|