@visactor/vtable 0.13.2-alpha.2 → 0.13.2-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/cjs/core/BaseTable.js +1 -1
  2. package/cjs/core/BaseTable.js.map +1 -1
  3. package/cjs/event/listener/scroll-bar.js.map +1 -1
  4. package/cjs/index.d.ts +1 -1
  5. package/cjs/index.js +1 -1
  6. package/cjs/index.js.map +1 -1
  7. package/cjs/scenegraph/graphic/group.js +6 -6
  8. package/cjs/scenegraph/graphic/group.js.map +1 -1
  9. package/cjs/scenegraph/group-creater/cell-helper.js +42 -6
  10. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  11. package/cjs/scenegraph/group-creater/progress/proxy.js +3 -3
  12. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  13. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  14. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +5 -5
  15. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  16. package/cjs/scenegraph/layout/compute-col-width.js +6 -3
  17. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  18. package/cjs/scenegraph/layout/frozen.js +2 -1
  19. package/cjs/scenegraph/layout/frozen.js.map +1 -1
  20. package/cjs/scenegraph/layout/move-cell.js +1 -1
  21. package/cjs/scenegraph/layout/move-cell.js.map +1 -1
  22. package/cjs/scenegraph/layout/update-row.js +22 -16
  23. package/cjs/scenegraph/layout/update-row.js.map +1 -1
  24. package/cjs/scenegraph/scenegraph.d.ts +2 -1
  25. package/cjs/scenegraph/scenegraph.js +10 -7
  26. package/cjs/scenegraph/scenegraph.js.map +1 -1
  27. package/cjs/state/state.js.map +1 -1
  28. package/dist/vtable.js +121 -29
  29. package/dist/vtable.min.js +2 -2
  30. package/es/core/BaseTable.js +1 -1
  31. package/es/core/BaseTable.js.map +1 -1
  32. package/es/event/listener/scroll-bar.js.map +1 -1
  33. package/es/index.d.ts +1 -1
  34. package/es/index.js +1 -1
  35. package/es/index.js.map +1 -1
  36. package/es/scenegraph/graphic/group.js +6 -6
  37. package/es/scenegraph/graphic/group.js.map +1 -1
  38. package/es/scenegraph/group-creater/cell-helper.js +43 -4
  39. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  40. package/es/scenegraph/group-creater/progress/proxy.js +3 -3
  41. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  42. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  43. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +5 -5
  44. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  45. package/es/scenegraph/layout/compute-col-width.js +6 -3
  46. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  47. package/es/scenegraph/layout/frozen.js +2 -1
  48. package/es/scenegraph/layout/frozen.js.map +1 -1
  49. package/es/scenegraph/layout/move-cell.js +1 -1
  50. package/es/scenegraph/layout/move-cell.js.map +1 -1
  51. package/es/scenegraph/layout/update-row.js +23 -15
  52. package/es/scenegraph/layout/update-row.js.map +1 -1
  53. package/es/scenegraph/scenegraph.d.ts +2 -1
  54. package/es/scenegraph/scenegraph.js +10 -7
  55. package/es/scenegraph/scenegraph.js.map +1 -1
  56. package/es/state/state.js.map +1 -1
  57. package/package.json +1 -1
package/dist/vtable.js CHANGED
@@ -38116,21 +38116,33 @@
38116
38116
  return Math.max(height, this.attribute.height ?? 0);
38117
38117
  }
38118
38118
  setDeltaWidth(deltaX) {
38119
+ if (deltaX === 0) {
38120
+ return;
38121
+ }
38119
38122
  this.setAttribute('width', (this.attribute.width ?? 0) + deltaX);
38120
38123
  if (this.border) {
38121
38124
  this.border.setAttribute('width', this.border.attribute.width + deltaX);
38122
38125
  }
38123
38126
  }
38124
38127
  setDeltaHeight(deltaY) {
38128
+ if (deltaY === 0) {
38129
+ return;
38130
+ }
38125
38131
  this.setAttribute('height', (this.attribute.height ?? 0) + deltaY);
38126
38132
  if (this.border) {
38127
38133
  this.border.setAttribute('height', this.border.attribute.height + deltaY);
38128
38134
  }
38129
38135
  }
38130
38136
  setDeltaX(deltaX) {
38137
+ if (deltaX === 0) {
38138
+ return;
38139
+ }
38131
38140
  this.setAttribute('x', this.attribute.x + deltaX);
38132
38141
  }
38133
38142
  setDeltaY(deltaY) {
38143
+ if (deltaY === 0) {
38144
+ return;
38145
+ }
38134
38146
  this.setAttribute('y', this.attribute.y + deltaY);
38135
38147
  }
38136
38148
  forEachChildrenSkipChild(cb, skipChildName = 'border-rect', reverse = false) {
@@ -43730,9 +43742,10 @@
43730
43742
  for (let col = 0; col < table.colCount; col++) {
43731
43743
  const newColWidth = newWidths[col] ?? table.getColWidth(col);
43732
43744
  if (newColWidth !== oldColWidths[col]) {
43733
- table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col]);
43745
+ table.scenegraph.updateColWidth(col, newColWidth - oldColWidths[col], true);
43734
43746
  }
43735
43747
  }
43748
+ table.scenegraph.updateContainer();
43736
43749
  }
43737
43750
  }
43738
43751
  function computeColWidth(col, startRow, endRow, table, forceCompute) {
@@ -44413,6 +44426,43 @@
44413
44426
  }
44414
44427
  function updateCell$1(col, row, table, addNew) {
44415
44428
  const oldCellGroup = table.scenegraph.highPerformanceGetCell(col, row, true);
44429
+ const cellStyle = table._getCellStyle(col, row);
44430
+ const autoWrapText = cellStyle.autoWrapText ?? table.internalProps.autoWrapText;
44431
+ const cellTheme = getStyleTheme(cellStyle, table, col, row, getProp).theme;
44432
+ if (!addNew && canUseFastUpdate(col, row, oldCellGroup, autoWrapText, table)) {
44433
+ const cellWidth = table.getColWidth(col);
44434
+ const cellHeight = table.getRowHeight(row);
44435
+ oldCellGroup.setAttributes({
44436
+ width: cellWidth,
44437
+ height: cellHeight,
44438
+ lineWidth: cellTheme?.group?.lineWidth ?? undefined,
44439
+ fill: cellTheme?.group?.fill ?? undefined,
44440
+ stroke: cellTheme?.group?.stroke ?? undefined,
44441
+ strokeArrayWidth: cellTheme?.group?.strokeArrayWidth ?? undefined,
44442
+ strokeArrayColor: cellTheme?.group?.strokeArrayColor ?? undefined,
44443
+ cursor: cellTheme?.group?.cursor ?? undefined
44444
+ });
44445
+ const textMark = oldCellGroup.getChildByName('text');
44446
+ if (textMark) {
44447
+ const text = table.getCellValue(col, row);
44448
+ const hierarchyOffset = getHierarchyOffset(col, row, table);
44449
+ const lineClamp = cellStyle.lineClamp;
44450
+ const padding = getQuadProps(getProp('padding', cellStyle, col, row, table)) ?? [0, 0, 0, 0];
44451
+ const attribute = {
44452
+ text: text.length === 1 && !autoWrapText ? text[0] : text,
44453
+ maxLineWidth: cellWidth - (padding[1] + padding[3] + hierarchyOffset),
44454
+ textBaseline: 'top',
44455
+ autoWrapText,
44456
+ lineClamp,
44457
+ wordBreak: 'break-word',
44458
+ heightLimit: cellHeight - (padding[0] + padding[2]),
44459
+ pickable: false,
44460
+ dx: hierarchyOffset
44461
+ };
44462
+ textMark.setAttributes(cellTheme.text ? Object.assign({}, cellTheme.text, attribute) : attribute);
44463
+ }
44464
+ return oldCellGroup;
44465
+ }
44416
44466
  if (!addNew && oldCellGroup.role === 'empty') {
44417
44467
  return undefined;
44418
44468
  }
@@ -44450,8 +44500,6 @@
44450
44500
  }
44451
44501
  else {
44452
44502
  const mayHaveIcon = cellLocation !== 'body' ? true : !!define?.icon || !!define?.tree;
44453
- const headerStyle = table._getCellStyle(col, row);
44454
- const cellTheme = getStyleTheme(headerStyle, table, col, row, getProp).theme;
44455
44503
  const padding = cellTheme._vtable.padding;
44456
44504
  const textAlign = cellTheme._vtable.textAlign;
44457
44505
  const textBaseline = cellTheme._vtable.textBaseline;
@@ -44508,6 +44556,22 @@
44508
44556
  }
44509
44557
  return newCellGroup;
44510
44558
  }
44559
+ function canUseFastUpdate(col, row, oldCellGroup, autoWrapText, table) {
44560
+ const define = table.getBodyColumnDefine(col, row);
44561
+ const mayHaveIcon = !!define?.icon || !!define?.tree;
44562
+ const cellType = table.getBodyColumnType(col, row);
44563
+ const autoRowHeight = table.heightMode === 'autoHeight';
44564
+ if (!table.isHeader(col, row) &&
44565
+ oldCellGroup.role === 'cell' &&
44566
+ cellType === 'text' &&
44567
+ !autoWrapText &&
44568
+ !autoRowHeight &&
44569
+ !mayHaveIcon &&
44570
+ oldCellGroup.firstChild?.type === 'text') {
44571
+ return true;
44572
+ }
44573
+ return false;
44574
+ }
44511
44575
 
44512
44576
  function createComplexColumn(columnGroup, col, colWidth, rowStart, rowEnd, mergeMap, defaultRowHeight, table, cellLocation, rowLimit) {
44513
44577
  let maxWidth = 0;
@@ -45142,7 +45206,7 @@
45142
45206
  proxy.table.scenegraph.proxy.deltaY += delaY;
45143
45207
  }
45144
45208
  proxy.currentRow = direction === 'up' ? proxy.currentRow + count : proxy.currentRow - count;
45145
- proxy.totalRow = direction === 'up' ? proxy.totalRow + count : proxy.totalRow - count;
45209
+ proxy.totalRow = Math.max(0, Math.min(proxy.table.rowCount - 1, direction === 'up' ? proxy.totalRow + count : proxy.totalRow - count));
45146
45210
  proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2);
45147
45211
  proxy.rowUpdatePos = Math.min(proxy.rowUpdatePos, distStartRow);
45148
45212
  proxy.rowUpdateDirection = direction;
@@ -45176,7 +45240,7 @@
45176
45240
  }
45177
45241
  proxy.table.scenegraph.proxy.deltaY = 0;
45178
45242
  proxy.currentRow = direction === 'up' ? proxy.currentRow + count : proxy.currentRow - count;
45179
- proxy.totalRow = direction === 'up' ? proxy.totalRow + count : proxy.totalRow - count;
45243
+ proxy.totalRow = Math.max(0, Math.min(proxy.table.rowCount - 1, direction === 'up' ? proxy.totalRow + count : proxy.totalRow - count));
45180
45244
  proxy.referenceRow = proxy.rowStart + Math.floor((proxy.rowEnd - proxy.rowStart) / 2);
45181
45245
  proxy.rowUpdatePos = proxy.rowStart;
45182
45246
  proxy.rowUpdateDirection = distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up';
@@ -45189,20 +45253,28 @@
45189
45253
  function updatePartRowPosition(startRow, endRow, direction, proxy) {
45190
45254
  for (let col = 0; col < proxy.table.frozenColCount; col++) {
45191
45255
  const colGroup = proxy.table.scenegraph.getColGroup(col);
45256
+ if (!colGroup) {
45257
+ continue;
45258
+ }
45192
45259
  for (let row = startRow; row <= endRow; row++) {
45193
45260
  updateCellGroupPosition(colGroup, direction, proxy);
45194
45261
  }
45195
45262
  }
45196
45263
  for (let col = proxy.table.colCount - proxy.table.rightFrozenColCount; col < proxy.table.colCount; col++) {
45197
45264
  const colGroup = proxy.table.scenegraph.getColGroup(col);
45265
+ if (!colGroup) {
45266
+ continue;
45267
+ }
45198
45268
  for (let row = startRow; row <= endRow; row++) {
45199
45269
  updateCellGroupPosition(colGroup, direction, proxy);
45200
45270
  }
45201
45271
  }
45202
45272
  for (let col = proxy.bodyLeftCol; col <= proxy.bodyRightCol; col++) {
45203
45273
  const colGroup = proxy.table.scenegraph.getColGroup(col);
45204
- for (let row = startRow; row <= endRow; row++) {
45205
- updateCellGroupPosition(colGroup, direction, proxy);
45274
+ if (colGroup) {
45275
+ for (let row = startRow; row <= endRow; row++) {
45276
+ updateCellGroupPosition(colGroup, direction, proxy);
45277
+ }
45206
45278
  }
45207
45279
  }
45208
45280
  }
@@ -45340,7 +45412,7 @@
45340
45412
  isRelease = false;
45341
45413
  mode = 'column';
45342
45414
  isProgressing;
45343
- rowLimit = 1000;
45415
+ rowLimit = 200;
45344
45416
  currentRow = 0;
45345
45417
  totalRow;
45346
45418
  yLimitTop;
@@ -45562,6 +45634,7 @@
45562
45634
  this.colEnd = endCol;
45563
45635
  this.colUpdatePos = this.colEnd;
45564
45636
  this.referenceCol = this.colStart + Math.floor((endCol - this.colStart) / 2);
45637
+ this.table.scenegraph.updateContainerAttrWidthAndX();
45565
45638
  this.table.scenegraph.updateContainer();
45566
45639
  this.table.scenegraph.updateBorderSizeAndPosition();
45567
45640
  }
@@ -45756,6 +45829,7 @@
45756
45829
  columnGroup.setAttribute('width', table.getColWidth(col));
45757
45830
  }
45758
45831
  }
45832
+ scene.updateContainerAttrWidthAndX();
45759
45833
  scene.updateContainer();
45760
45834
  for (let col = updateColStart; col <= updateColEnd; col++) {
45761
45835
  const columnGroup = table.scenegraph.getColGroup(col);
@@ -46056,7 +46130,14 @@
46056
46130
  updateCells.forEach(cell => {
46057
46131
  cell && updateCell$1(cell.col, cell.row, scene.table, false);
46058
46132
  });
46059
- resetRowNumberAndY(scene);
46133
+ const newTotalHeight = resetRowNumberAndY(scene);
46134
+ if (addRows.length) {
46135
+ scene.proxy.rowUpdatePos = scene.proxy.rowStart;
46136
+ scene.proxy.rowUpdateDirection = 'up';
46137
+ scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);
46138
+ scene.proxy.progress();
46139
+ }
46140
+ scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);
46060
46141
  }
46061
46142
  function removeRow(row, scene) {
46062
46143
  for (let col = 0; col < scene.table.colCount; col++) {
@@ -46075,42 +46156,46 @@
46075
46156
  }
46076
46157
  scene.proxy.rowEnd--;
46077
46158
  scene.proxy.bodyBottomRow--;
46159
+ scene.proxy.currentRow--;
46078
46160
  scene.proxy.totalRow--;
46079
46161
  }
46080
46162
  function addRow(row, scene) {
46081
46163
  for (let col = 0; col < scene.table.colCount; col++) {
46082
- const cellGroup = updateCell$1(col, row, scene.table, true);
46164
+ const cellGroup = new Group({
46165
+ x: 0,
46166
+ y: 0,
46167
+ width: scene.table.getColWidth(col),
46168
+ height: scene.table.getRowHeight(row)
46169
+ });
46170
+ cellGroup.role = 'cell';
46171
+ cellGroup.col = col;
46172
+ cellGroup.row = row;
46173
+ cellGroup.needUpdate = true;
46083
46174
  if (!cellGroup) {
46084
46175
  continue;
46085
46176
  }
46086
46177
  const colGroup = scene.getColGroup(col);
46087
46178
  if (colGroup.firstChild && row < colGroup.firstChild.row) {
46088
46179
  colGroup.insertBefore(cellGroup, colGroup.firstChild);
46180
+ colGroup.firstChild.row = colGroup.firstChild.row + 1;
46089
46181
  }
46090
46182
  else if (colGroup.lastChild && row > colGroup.lastChild.row) {
46091
46183
  colGroup.appendChild(cellGroup);
46092
46184
  }
46093
46185
  else {
46094
- let cellBefore;
46095
- colGroup.forEachChildren((cellGroup) => {
46096
- if (cellGroup.row === row) {
46097
- cellBefore = cellGroup;
46098
- return true;
46099
- }
46100
- return false;
46101
- });
46186
+ const cellBefore = scene.highPerformanceGetCell(col, row, true);
46102
46187
  if (cellBefore !== cellGroup) {
46103
46188
  colGroup.insertBefore(cellGroup, cellBefore);
46189
+ cellBefore && (cellBefore.row = cellBefore.row + 1);
46190
+ if (cellBefore !== colGroup.lastChild) {
46191
+ colGroup.lastChild && (colGroup.lastChild.row = colGroup.lastChild.row + 1);
46192
+ }
46104
46193
  }
46105
46194
  }
46106
- let rowIndex = colGroup.firstChild?.row;
46107
- colGroup.forEachChildren((cellGroup) => {
46108
- cellGroup.row = rowIndex;
46109
- rowIndex++;
46110
- });
46111
46195
  }
46112
46196
  scene.proxy.rowEnd++;
46113
46197
  scene.proxy.bodyBottomRow++;
46198
+ scene.proxy.currentRow++;
46114
46199
  scene.proxy.totalRow++;
46115
46200
  }
46116
46201
  function deduplication(array) {
@@ -46158,7 +46243,7 @@
46158
46243
  });
46159
46244
  newTotalHeight = y;
46160
46245
  }
46161
- scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);
46246
+ return newTotalHeight;
46162
46247
  }
46163
46248
 
46164
46249
  const changedCells = [];
@@ -46332,6 +46417,7 @@
46332
46417
  scene.proxy.colStart = scene.table.frozenColCount;
46333
46418
  scene.bodyGroup.setAttribute('x', scene.rowHeaderGroup.attribute.width);
46334
46419
  scene.colHeaderGroup.setAttribute('x', scene.cornerHeaderGroup.attribute.width);
46420
+ scene.updateContainerAttrWidthAndX();
46335
46421
  scene.updateContainer();
46336
46422
  scene.updateBorderSizeAndPosition();
46337
46423
  if (!scene.isPivot && !scene.transpose) {
@@ -47423,9 +47509,12 @@
47423
47509
  icon.image = icon.attribute.originImage;
47424
47510
  }
47425
47511
  }
47426
- updateColWidth(col, detaX) {
47512
+ updateColWidth(col, detaX, skipUpdateContainer) {
47427
47513
  updateColWidth(this, col, Math.round(detaX));
47428
- this.updateContainer();
47514
+ if (!skipUpdateContainer) {
47515
+ this.updateContainerAttrWidthAndX();
47516
+ this.updateContainer();
47517
+ }
47429
47518
  }
47430
47519
  updateChartSize(col) {
47431
47520
  updateChartSize(this, col);
@@ -47670,6 +47759,7 @@
47670
47759
  this.component.setFrozenColumnShadow(this.table.frozenColCount - 1);
47671
47760
  }
47672
47761
  this.table.stateManeger.checkFrozen();
47762
+ this.updateContainerAttrWidthAndX();
47673
47763
  this.updateContainer();
47674
47764
  this.createFrameBorder();
47675
47765
  this.updateBorderSizeAndPosition();
@@ -47836,7 +47926,7 @@
47836
47926
  updateHeaderPosition(colSource, rowSource, colTarget, rowTarget) {
47837
47927
  moveHeaderPosition(colSource, rowSource, colTarget, rowTarget, this.table);
47838
47928
  }
47839
- updateContainer() {
47929
+ updateContainerAttrWidthAndX() {
47840
47930
  const cornerX = updateContainerChildrenX(this.cornerHeaderGroup);
47841
47931
  const rowHeaderX = updateContainerChildrenX(this.rowHeaderGroup);
47842
47932
  const colHeaderX = updateContainerChildrenX(this.colHeaderGroup);
@@ -47859,6 +47949,8 @@
47859
47949
  this.colHeaderGroup.setAttribute('x', this.cornerHeaderGroup.attribute.width);
47860
47950
  this.bottomFrozenGroup.setAttribute('x', this.rowHeaderGroup.attribute.width);
47861
47951
  this.bodyGroup.setAttribute('x', this.rowHeaderGroup.attribute.width);
47952
+ }
47953
+ updateContainer() {
47862
47954
  this.updateTableSize();
47863
47955
  const oldHorizontalBarPos = this.table.stateManeger.scroll.horizontalBarPos;
47864
47956
  const oldVerticalBarPos = this.table.stateManeger.scroll.verticalBarPos;
@@ -53863,7 +53955,7 @@
53863
53955
  return TABLE_EVENT_TYPE;
53864
53956
  }
53865
53957
  options;
53866
- version = "0.13.2-alpha.2";
53958
+ version = "0.13.2-alpha.3";
53867
53959
  pagination;
53868
53960
  id = `VTable${Date.now()}`;
53869
53961
  headerStyleCache;
@@ -63733,7 +63825,7 @@
63733
63825
  return new Tag(params ? params.attribute : {});
63734
63826
  }
63735
63827
 
63736
- const version = "0.13.2-alpha.2";
63828
+ const version = "0.13.2-alpha.3";
63737
63829
  function getIcons() {
63738
63830
  return get$1();
63739
63831
  }