handsontable 0.0.0-next-2ae8e35-20240613 → 0.0.0-next-fd8b2aa-20240614

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 (47) hide show
  1. package/3rdparty/walkontable/src/core/core.js +16 -0
  2. package/3rdparty/walkontable/src/core/core.mjs +16 -0
  3. package/3rdparty/walkontable/src/facade/core.js +3 -0
  4. package/3rdparty/walkontable/src/facade/core.mjs +3 -0
  5. package/3rdparty/walkontable/src/renderer/index.js +11 -0
  6. package/3rdparty/walkontable/src/renderer/index.mjs +11 -0
  7. package/3rdparty/walkontable/src/renderer/table.js +16 -1
  8. package/3rdparty/walkontable/src/renderer/table.mjs +16 -1
  9. package/3rdparty/walkontable/src/settings.js +5 -1
  10. package/3rdparty/walkontable/src/settings.mjs +5 -1
  11. package/3rdparty/walkontable/src/table.js +1 -1
  12. package/3rdparty/walkontable/src/table.mjs +1 -1
  13. package/3rdparty/walkontable/src/utils/row.js +16 -0
  14. package/3rdparty/walkontable/src/utils/row.mjs +16 -0
  15. package/base.js +2 -2
  16. package/base.mjs +2 -2
  17. package/common.d.ts +3 -0
  18. package/core.js +0 -6
  19. package/core.mjs +0 -6
  20. package/dist/handsontable.css +2 -2
  21. package/dist/handsontable.full.css +2 -2
  22. package/dist/handsontable.full.js +504 -249
  23. package/dist/handsontable.full.min.css +2 -2
  24. package/dist/handsontable.full.min.js +80 -80
  25. package/dist/handsontable.js +504 -249
  26. package/dist/handsontable.min.css +2 -2
  27. package/dist/handsontable.min.js +14 -14
  28. package/helpers/mixed.js +1 -1
  29. package/helpers/mixed.mjs +1 -1
  30. package/package.json +1 -1
  31. package/pluginHooks.d.ts +3 -1
  32. package/pluginHooks.js +11 -0
  33. package/pluginHooks.mjs +11 -0
  34. package/plugins/mergeCells/calculations/autofill.js +1 -1
  35. package/plugins/mergeCells/calculations/autofill.mjs +1 -1
  36. package/plugins/mergeCells/cellCoords.js +61 -22
  37. package/plugins/mergeCells/cellCoords.mjs +61 -22
  38. package/plugins/mergeCells/cellsCollection.js +46 -53
  39. package/plugins/mergeCells/cellsCollection.mjs +46 -53
  40. package/plugins/mergeCells/mergeCells.js +133 -92
  41. package/plugins/mergeCells/mergeCells.mjs +134 -93
  42. package/plugins/mergeCells/renderer.js +70 -0
  43. package/plugins/mergeCells/renderer.mjs +66 -0
  44. package/tableView.js +92 -22
  45. package/tableView.mjs +92 -22
  46. package/plugins/mergeCells/utils.js +0 -28
  47. package/plugins/mergeCells/utils.mjs +0 -24
@@ -24,13 +24,13 @@ import AutofillCalculations from "./calculations/autofill.mjs";
24
24
  import SelectionCalculations from "./calculations/selection.mjs";
25
25
  import toggleMergeItem from "./contextMenuItem/toggleMerge.mjs";
26
26
  import { arrayEach } from "../../helpers/array.mjs";
27
- import { isObject, clone } from "../../helpers/object.mjs";
27
+ import { isObject } from "../../helpers/object.mjs";
28
28
  import { warn } from "../../helpers/console.mjs";
29
29
  import { rangeEach } from "../../helpers/number.mjs";
30
- import { applySpanProperties } from "./utils.mjs";
31
30
  import { getStyle } from "../../helpers/dom/element.mjs";
32
31
  import { isChrome } from "../../helpers/browser.mjs";
33
32
  import { FocusOrder } from "./focusOrder.mjs";
33
+ import { createMergeCellRenderer } from "./renderer.mjs";
34
34
  Hooks.getSingleton().register('beforeMergeCells');
35
35
  Hooks.getSingleton().register('afterMergeCells');
36
36
  Hooks.getSingleton().register('beforeUnmergeCells');
@@ -79,6 +79,7 @@ const SHORTCUTS_GROUP = PLUGIN_KEY;
79
79
  var _lastSelectedFocus = /*#__PURE__*/new WeakMap();
80
80
  var _lastFocusDelta = /*#__PURE__*/new WeakMap();
81
81
  var _focusOrder = /*#__PURE__*/new WeakMap();
82
+ var _cellRenderer = /*#__PURE__*/new WeakMap();
82
83
  var _MergeCells_brand = /*#__PURE__*/new WeakSet();
83
84
  export class MergeCells extends BasePlugin {
84
85
  constructor() {
@@ -135,6 +136,12 @@ export class MergeCells extends BasePlugin {
135
136
  rowIndexMapper: this.hot.rowIndexMapper,
136
137
  columnIndexMapper: this.hot.columnIndexMapper
137
138
  }));
139
+ /**
140
+ * The cell renderer responsible for rendering the merged cells.
141
+ *
142
+ * @type {{before: Function, after: Function}}
143
+ */
144
+ _classPrivateFieldInitSpec(this, _cellRenderer, createMergeCellRenderer(this));
138
145
  }
139
146
  static get PLUGIN_KEY() {
140
147
  return PLUGIN_KEY;
@@ -236,94 +243,97 @@ export class MergeCells extends BasePlugin {
236
243
  return _assertClassBrand(_MergeCells_brand, _this, _onAfterIsMultipleSelection).call(_this, ...args);
237
244
  });
238
245
  this.addHook('afterRenderer', function () {
246
+ return _classPrivateFieldGet(_cellRenderer, _this).after(...arguments);
247
+ });
248
+ this.addHook('afterContextMenuDefaultOptions', function () {
239
249
  for (var _len13 = arguments.length, args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
240
250
  args[_key13] = arguments[_key13];
241
251
  }
242
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterRenderer).call(_this, ...args);
252
+ return _assertClassBrand(_MergeCells_brand, _this, _addMergeActionsToContextMenu).call(_this, ...args);
243
253
  });
244
- this.addHook('afterContextMenuDefaultOptions', function () {
254
+ this.addHook('afterGetCellMeta', function () {
245
255
  for (var _len14 = arguments.length, args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
246
256
  args[_key14] = arguments[_key14];
247
257
  }
248
- return _assertClassBrand(_MergeCells_brand, _this, _addMergeActionsToContextMenu).call(_this, ...args);
258
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterGetCellMeta).call(_this, ...args);
249
259
  });
250
- this.addHook('afterGetCellMeta', function () {
260
+ this.addHook('afterViewportRowCalculatorOverride', function () {
251
261
  for (var _len15 = arguments.length, args = new Array(_len15), _key15 = 0; _key15 < _len15; _key15++) {
252
262
  args[_key15] = arguments[_key15];
253
263
  }
254
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterGetCellMeta).call(_this, ...args);
264
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportRowCalculatorOverride).call(_this, ...args);
255
265
  });
256
- this.addHook('afterViewportRowCalculatorOverride', function () {
266
+ this.addHook('afterViewportColumnCalculatorOverride', function () {
257
267
  for (var _len16 = arguments.length, args = new Array(_len16), _key16 = 0; _key16 < _len16; _key16++) {
258
268
  args[_key16] = arguments[_key16];
259
269
  }
260
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportRowCalculatorOverride).call(_this, ...args);
270
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportColumnCalculatorOverride).call(_this, ...args);
261
271
  });
262
- this.addHook('afterViewportColumnCalculatorOverride', function () {
272
+ this.addHook('modifyAutofillRange', function () {
263
273
  for (var _len17 = arguments.length, args = new Array(_len17), _key17 = 0; _key17 < _len17; _key17++) {
264
274
  args[_key17] = arguments[_key17];
265
275
  }
266
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterViewportColumnCalculatorOverride).call(_this, ...args);
276
+ return _assertClassBrand(_MergeCells_brand, _this, _onModifyAutofillRange).call(_this, ...args);
267
277
  });
268
- this.addHook('modifyAutofillRange', function () {
278
+ this.addHook('afterCreateCol', function () {
269
279
  for (var _len18 = arguments.length, args = new Array(_len18), _key18 = 0; _key18 < _len18; _key18++) {
270
280
  args[_key18] = arguments[_key18];
271
281
  }
272
- return _assertClassBrand(_MergeCells_brand, _this, _onModifyAutofillRange).call(_this, ...args);
282
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateCol).call(_this, ...args);
273
283
  });
274
- this.addHook('afterCreateCol', function () {
284
+ this.addHook('afterRemoveCol', function () {
275
285
  for (var _len19 = arguments.length, args = new Array(_len19), _key19 = 0; _key19 < _len19; _key19++) {
276
286
  args[_key19] = arguments[_key19];
277
287
  }
278
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateCol).call(_this, ...args);
288
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveCol).call(_this, ...args);
279
289
  });
280
- this.addHook('afterRemoveCol', function () {
290
+ this.addHook('afterCreateRow', function () {
281
291
  for (var _len20 = arguments.length, args = new Array(_len20), _key20 = 0; _key20 < _len20; _key20++) {
282
292
  args[_key20] = arguments[_key20];
283
293
  }
284
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveCol).call(_this, ...args);
294
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateRow).call(_this, ...args);
285
295
  });
286
- this.addHook('afterCreateRow', function () {
296
+ this.addHook('afterRemoveRow', function () {
287
297
  for (var _len21 = arguments.length, args = new Array(_len21), _key21 = 0; _key21 < _len21; _key21++) {
288
298
  args[_key21] = arguments[_key21];
289
299
  }
290
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterCreateRow).call(_this, ...args);
300
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveRow).call(_this, ...args);
291
301
  });
292
- this.addHook('afterRemoveRow', function () {
302
+ this.addHook('afterChange', function () {
293
303
  for (var _len22 = arguments.length, args = new Array(_len22), _key22 = 0; _key22 < _len22; _key22++) {
294
304
  args[_key22] = arguments[_key22];
295
305
  }
296
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterRemoveRow).call(_this, ...args);
306
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterChange).call(_this, ...args);
297
307
  });
298
- this.addHook('afterChange', function () {
308
+ this.addHook('beforeDrawBorders', function () {
299
309
  for (var _len23 = arguments.length, args = new Array(_len23), _key23 = 0; _key23 < _len23; _key23++) {
300
310
  args[_key23] = arguments[_key23];
301
311
  }
302
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterChange).call(_this, ...args);
312
+ return _assertClassBrand(_MergeCells_brand, _this, _onBeforeDrawAreaBorders).call(_this, ...args);
303
313
  });
304
- this.addHook('beforeDrawBorders', function () {
314
+ this.addHook('afterDrawSelection', function () {
305
315
  for (var _len24 = arguments.length, args = new Array(_len24), _key24 = 0; _key24 < _len24; _key24++) {
306
316
  args[_key24] = arguments[_key24];
307
317
  }
308
- return _assertClassBrand(_MergeCells_brand, _this, _onBeforeDrawAreaBorders).call(_this, ...args);
318
+ return _assertClassBrand(_MergeCells_brand, _this, _onAfterDrawSelection).call(_this, ...args);
309
319
  });
310
- this.addHook('afterDrawSelection', function () {
320
+ this.addHook('beforeRemoveCellClassNames', function () {
311
321
  for (var _len25 = arguments.length, args = new Array(_len25), _key25 = 0; _key25 < _len25; _key25++) {
312
322
  args[_key25] = arguments[_key25];
313
323
  }
314
- return _assertClassBrand(_MergeCells_brand, _this, _onAfterDrawSelection).call(_this, ...args);
324
+ return _assertClassBrand(_MergeCells_brand, _this, _onBeforeRemoveCellClassNames).call(_this, ...args);
315
325
  });
316
- this.addHook('beforeRemoveCellClassNames', function () {
326
+ this.addHook('beforeBeginEditing', function () {
317
327
  for (var _len26 = arguments.length, args = new Array(_len26), _key26 = 0; _key26 < _len26; _key26++) {
318
328
  args[_key26] = arguments[_key26];
319
329
  }
320
- return _assertClassBrand(_MergeCells_brand, _this, _onBeforeRemoveCellClassNames).call(_this, ...args);
330
+ return _assertClassBrand(_MergeCells_brand, _this, _onBeforeBeginEditing).call(_this, ...args);
321
331
  });
322
- this.addHook('beforeBeginEditing', function () {
332
+ this.addHook('modifyRowHeightByOverlayName', function () {
323
333
  for (var _len27 = arguments.length, args = new Array(_len27), _key27 = 0; _key27 < _len27; _key27++) {
324
334
  args[_key27] = arguments[_key27];
325
335
  }
326
- return _assertClassBrand(_MergeCells_brand, _this, _onBeforeBeginEditing).call(_this, ...args);
336
+ return _assertClassBrand(_MergeCells_brand, _this, _onModifyRowHeightByOverlayName).call(_this, ...args);
327
337
  });
328
338
  this.addHook('beforeUndoStackChange', (action, source) => {
329
339
  if (source === 'MergeCells') {
@@ -414,24 +424,26 @@ export class MergeCells extends BasePlugin {
414
424
  * @returns {boolean}
415
425
  */
416
426
  validateSetting(setting) {
417
- let valid = true;
418
427
  if (!setting) {
419
428
  return false;
420
429
  }
421
430
  if (MergedCellCoords.containsNegativeValues(setting)) {
422
431
  warn(MergedCellCoords.NEGATIVE_VALUES_WARNING(setting));
423
- valid = false;
424
- } else if (MergedCellCoords.isOutOfBounds(setting, this.hot.countRows(), this.hot.countCols())) {
432
+ return false;
433
+ }
434
+ if (MergedCellCoords.isOutOfBounds(setting, this.hot.countRows(), this.hot.countCols())) {
425
435
  warn(MergedCellCoords.IS_OUT_OF_BOUNDS_WARNING(setting));
426
- valid = false;
427
- } else if (MergedCellCoords.isSingleCell(setting)) {
436
+ return false;
437
+ }
438
+ if (MergedCellCoords.isSingleCell(setting)) {
428
439
  warn(MergedCellCoords.IS_SINGLE_CELL(setting));
429
- valid = false;
430
- } else if (MergedCellCoords.containsZeroSpan(setting)) {
440
+ return false;
441
+ }
442
+ if (MergedCellCoords.containsZeroSpan(setting)) {
431
443
  warn(MergedCellCoords.ZERO_SPAN_WARNING(setting));
432
- valid = false;
444
+ return false;
433
445
  }
434
- return valid;
446
+ return true;
435
447
  }
436
448
 
437
449
  /**
@@ -612,7 +624,7 @@ export class MergeCells extends BasePlugin {
612
624
  unmergeRange(cellRange) {
613
625
  let auto = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
614
626
  const mergedCells = this.mergedCellsCollection.getWithinRange(cellRange);
615
- if (!mergedCells) {
627
+ if (mergedCells.length === 0) {
616
628
  return;
617
629
  }
618
630
  this.hot.runHooks('beforeUnmergeCells', cellRange, auto);
@@ -1116,47 +1128,6 @@ function _addMergeActionsToContextMenu(defaultOptions) {
1116
1128
  name: '---------'
1117
1129
  }, toggleMergeItem(this));
1118
1130
  }
1119
- /**
1120
- * `afterRenderer` hook callback.
1121
- *
1122
- * @param {HTMLElement} TD The cell to be modified.
1123
- * @param {number} row Row index.
1124
- * @param {number} col Visual column index.
1125
- */
1126
- function _onAfterRenderer(TD, row, col) {
1127
- const mergedCell = this.mergedCellsCollection.get(row, col);
1128
- if (isObject(mergedCell)) {
1129
- // We shouldn't override data in the collection.
1130
- const mergedCellCopy = clone(mergedCell);
1131
- const {
1132
- rowIndexMapper: rowMapper,
1133
- columnIndexMapper: columnMapper
1134
- } = this.hot;
1135
- const {
1136
- row: mergeRow,
1137
- col: mergeColumn,
1138
- colspan,
1139
- rowspan
1140
- } = mergedCellCopy;
1141
- const [lastMergedRowIndex, lastMergedColumnIndex] = this.translateMergedCellToRenderable(mergeRow, rowspan, mergeColumn, colspan);
1142
- const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
1143
- const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
1144
- const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
1145
- const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
1146
-
1147
- // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
1148
- mergedCellCopy.row = rowMapper.getNearestNotHiddenIndex(mergedCellCopy.row, 1);
1149
- // We just try to determine some values basing on the actual number of rendered indexes (some columns may be hidden).
1150
- mergedCellCopy.col = columnMapper.getNearestNotHiddenIndex(mergedCellCopy.col, 1);
1151
- // The `rowSpan` property for a `TD` element should be at most equal to number of rendered rows in the merge area.
1152
- mergedCellCopy.rowspan = Math.min(mergedCellCopy.rowspan, maxRowSpan);
1153
- // The `colSpan` property for a `TD` element should be at most equal to number of rendered columns in the merge area.
1154
- mergedCellCopy.colspan = Math.min(mergedCellCopy.colspan, maxColSpan);
1155
- applySpanProperties(TD, mergedCellCopy, row, col);
1156
- } else {
1157
- applySpanProperties(TD, null, row, col);
1158
- }
1159
- }
1160
1131
  /**
1161
1132
  * Clears the last selected coordinates before setting a new selection range.
1162
1133
  */
@@ -1298,17 +1269,11 @@ function _onModifyAutofillRange(drag, select) {
1298
1269
  dragArea = select;
1299
1270
  return dragArea;
1300
1271
  }
1301
- const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange({
1302
- from: {
1303
- row: select[0],
1304
- col: select[1]
1305
- },
1306
- to: {
1307
- row: select[2],
1308
- col: select[3]
1309
- }
1310
- });
1311
- if (!mergedCellsWithinSelectionArea) {
1272
+ const from = this.hot._createCellCoords(select[0], select[1]);
1273
+ const to = this.hot._createCellCoords(select[2], select[3]);
1274
+ const range = this.hot._createCellRange(from, from, to);
1275
+ const mergedCellsWithinSelectionArea = this.mergedCellsCollection.getWithinRange(range);
1276
+ if (mergedCellsWithinSelectionArea.length === 0) {
1312
1277
  return dragArea;
1313
1278
  }
1314
1279
  dragArea = this.autofillCalculations.snapDragArea(select, dragArea, dragDirection, mergedCellsWithinSelectionArea);
@@ -1432,4 +1397,80 @@ function _onBeforeBeginEditing(row, column, initialValue, event) {
1432
1397
  const from = this.hot._createCellCoords(mergeCell.row, mergeCell.col);
1433
1398
  const to = this.hot._createCellCoords(mergeCell.row + mergeCell.rowspan - 1, mergeCell.col + mergeCell.colspan - 1);
1434
1399
  return this.hot.selection.getLayerLevel() === 0 && selection.isEqual(this.hot._createCellRange(from, from, to));
1400
+ }
1401
+ /**
1402
+ * Hook used to modify the row height depends on the merged cells in the row.
1403
+ *
1404
+ * @param {number} height The row height value provided by the Core.
1405
+ * @param {number} row The visual row index.
1406
+ * @param {string} overlayType The overlay type that is currently rendered.
1407
+ * @returns {number}
1408
+ */
1409
+ function _onModifyRowHeightByOverlayName(height, row, overlayType) {
1410
+ if (this.hot.getSettings().rowHeaders ||
1411
+ // merged cells do not work with the bottom overlays
1412
+ overlayType === 'bottom' || overlayType === 'bottom_inline_start_corner') {
1413
+ return height;
1414
+ }
1415
+ let firstColumn;
1416
+ let lastColumn;
1417
+ if (overlayType === 'master') {
1418
+ firstColumn = this.hot.view.getFirstRenderedVisibleColumn();
1419
+ lastColumn = this.hot.view.getLastRenderedVisibleColumn();
1420
+ } else {
1421
+ const activeOverlay = this.hot.view.getOverlayByName(overlayType);
1422
+ firstColumn = this.hot.columnIndexMapper.getVisualFromRenderableIndex(activeOverlay.clone.wtTable.getFirstRenderedColumn());
1423
+ lastColumn = this.hot.columnIndexMapper.getVisualFromRenderableIndex(activeOverlay.clone.wtTable.getLastRenderedColumn());
1424
+ }
1425
+ const firstMergedCellInRow = this.mergedCellsCollection.get(row, firstColumn);
1426
+ if (!firstMergedCellInRow) {
1427
+ return height;
1428
+ }
1429
+ const from = this.hot._createCellCoords(row, firstColumn);
1430
+ const to = this.hot._createCellCoords(row, lastColumn);
1431
+ const viewportRange = this.hot._createCellRange(from, from, to);
1432
+ const mergedCellsWithinRange = this.mergedCellsCollection.getWithinRange(viewportRange);
1433
+ const maxRowspan = mergedCellsWithinRange.reduce((acc, _ref) => {
1434
+ let {
1435
+ rowspan
1436
+ } = _ref;
1437
+ return Math.max(acc, rowspan);
1438
+ }, 1);
1439
+ let rowspanCorrection = 0;
1440
+ if (mergedCellsWithinRange.length > 1 && mergedCellsWithinRange[0].rowspan < maxRowspan) {
1441
+ rowspanCorrection = maxRowspan - mergedCellsWithinRange[0].rowspan;
1442
+ }
1443
+ mergedCellsWithinRange.forEach(_ref2 => {
1444
+ var _height;
1445
+ let {
1446
+ rowspan
1447
+ } = _ref2;
1448
+ let rowspanAfterCorrection = 0;
1449
+ if (overlayType === 'top' || overlayType === 'top_inline_start_corner') {
1450
+ rowspanAfterCorrection = Math.min(maxRowspan, this.hot.view.countNotHiddenFixedRowsTop() - row);
1451
+ } else {
1452
+ rowspanAfterCorrection = rowspan - rowspanCorrection;
1453
+ }
1454
+ height = Math.max((_height = height) !== null && _height !== void 0 ? _height : 0, _assertClassBrand(_MergeCells_brand, this, _sumCellsHeights).call(this, row, rowspanAfterCorrection));
1455
+ });
1456
+ return height;
1457
+ }
1458
+ /**
1459
+ * Sums the heights of the all cells that the merge cell consists of.
1460
+ *
1461
+ * @param {number} row The visual row index of the merged cell.
1462
+ * @param {number} rowspan The rowspan value of the merged cell.
1463
+ * @returns {number}
1464
+ */
1465
+ function _sumCellsHeights(row, rowspan) {
1466
+ const defaultHeight = this.hot.view._wt.wtSettings.getSettingPure('defaultRowHeight');
1467
+ const autoRowSizePlugin = this.hot.getPlugin('autoRowSize');
1468
+ let height = 0;
1469
+ for (let i = row; i < row + rowspan; i++) {
1470
+ if (!this.hot.rowIndexMapper.isHidden(i)) {
1471
+ var _autoRowSizePlugin$ge;
1472
+ height += (_autoRowSizePlugin$ge = autoRowSizePlugin === null || autoRowSizePlugin === void 0 ? void 0 : autoRowSizePlugin.getRowHeight(i)) !== null && _autoRowSizePlugin$ge !== void 0 ? _autoRowSizePlugin$ge : defaultHeight;
1473
+ }
1474
+ }
1475
+ return height;
1435
1476
  }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.createMergeCellRenderer = createMergeCellRenderer;
5
+ var _object = require("../../helpers/object");
6
+ /**
7
+ * Creates a renderer object for the `MergeCells` plugin.
8
+ *
9
+ * @param {MergeCells} plugin The `MergeCells` plugin instance.
10
+ * @returns {{before: Function, after: Function}}
11
+ */
12
+ function createMergeCellRenderer(plugin) {
13
+ const {
14
+ hot
15
+ } = plugin;
16
+ const {
17
+ rowIndexMapper: rowMapper,
18
+ columnIndexMapper: columnMapper
19
+ } = hot;
20
+
21
+ /**
22
+ * Runs before the cell is rendered.
23
+ */
24
+ function before() {}
25
+
26
+ /**
27
+ * Runs after the cell is rendered.
28
+ *
29
+ * @param {HTMLElement} TD The cell to be modified.
30
+ * @param {number} row Row index.
31
+ * @param {number} col Visual column index.
32
+ */
33
+ function after(TD, row, col) {
34
+ const mergedCell = plugin.mergedCellsCollection.get(row, col);
35
+ if (!(0, _object.isObject)(mergedCell)) {
36
+ TD.removeAttribute('rowspan');
37
+ TD.removeAttribute('colspan');
38
+ TD.style.display = '';
39
+ return;
40
+ }
41
+ const {
42
+ row: origRow,
43
+ col: origColumn,
44
+ colspan: origColspan,
45
+ rowspan: origRowspan
46
+ } = mergedCell;
47
+ const [lastMergedRowIndex, lastMergedColumnIndex] = plugin.translateMergedCellToRenderable(origRow, origRowspan, origColumn, origColspan);
48
+ const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
49
+ const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
50
+ const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
51
+ const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
52
+
53
+ const notHiddenRow = rowMapper.getNearestNotHiddenIndex(origRow, 1);
54
+ const notHiddenColumn = columnMapper.getNearestNotHiddenIndex(origColumn, 1);
55
+ const notHiddenRowspan = Math.min(origRowspan, maxRowSpan);
56
+ const notHiddenColspan = Math.min(origColspan, maxColSpan);
57
+ if (notHiddenRow === row && notHiddenColumn === col) {
58
+ TD.setAttribute('rowspan', notHiddenRowspan);
59
+ TD.setAttribute('colspan', notHiddenColspan);
60
+ } else {
61
+ TD.removeAttribute('rowspan');
62
+ TD.removeAttribute('colspan');
63
+ TD.style.display = 'none';
64
+ }
65
+ }
66
+ return {
67
+ before,
68
+ after
69
+ };
70
+ }
@@ -0,0 +1,66 @@
1
+ import { isObject } from "../../helpers/object.mjs";
2
+ /**
3
+ * Creates a renderer object for the `MergeCells` plugin.
4
+ *
5
+ * @param {MergeCells} plugin The `MergeCells` plugin instance.
6
+ * @returns {{before: Function, after: Function}}
7
+ */
8
+ export function createMergeCellRenderer(plugin) {
9
+ const {
10
+ hot
11
+ } = plugin;
12
+ const {
13
+ rowIndexMapper: rowMapper,
14
+ columnIndexMapper: columnMapper
15
+ } = hot;
16
+
17
+ /**
18
+ * Runs before the cell is rendered.
19
+ */
20
+ function before() {}
21
+
22
+ /**
23
+ * Runs after the cell is rendered.
24
+ *
25
+ * @param {HTMLElement} TD The cell to be modified.
26
+ * @param {number} row Row index.
27
+ * @param {number} col Visual column index.
28
+ */
29
+ function after(TD, row, col) {
30
+ const mergedCell = plugin.mergedCellsCollection.get(row, col);
31
+ if (!isObject(mergedCell)) {
32
+ TD.removeAttribute('rowspan');
33
+ TD.removeAttribute('colspan');
34
+ TD.style.display = '';
35
+ return;
36
+ }
37
+ const {
38
+ row: origRow,
39
+ col: origColumn,
40
+ colspan: origColspan,
41
+ rowspan: origRowspan
42
+ } = mergedCell;
43
+ const [lastMergedRowIndex, lastMergedColumnIndex] = plugin.translateMergedCellToRenderable(origRow, origRowspan, origColumn, origColspan);
44
+ const renderedRowIndex = rowMapper.getRenderableFromVisualIndex(row);
45
+ const renderedColumnIndex = columnMapper.getRenderableFromVisualIndex(col);
46
+ const maxRowSpan = lastMergedRowIndex - renderedRowIndex + 1; // Number of rendered columns.
47
+ const maxColSpan = lastMergedColumnIndex - renderedColumnIndex + 1; // Number of rendered columns.
48
+
49
+ const notHiddenRow = rowMapper.getNearestNotHiddenIndex(origRow, 1);
50
+ const notHiddenColumn = columnMapper.getNearestNotHiddenIndex(origColumn, 1);
51
+ const notHiddenRowspan = Math.min(origRowspan, maxRowSpan);
52
+ const notHiddenColspan = Math.min(origColspan, maxColSpan);
53
+ if (notHiddenRow === row && notHiddenColumn === col) {
54
+ TD.setAttribute('rowspan', notHiddenRowspan);
55
+ TD.setAttribute('colspan', notHiddenColspan);
56
+ } else {
57
+ TD.removeAttribute('rowspan');
58
+ TD.removeAttribute('colspan');
59
+ TD.style.display = 'none';
60
+ }
61
+ }
62
+ return {
63
+ before,
64
+ after
65
+ };
66
+ }