@visactor/vtable 0.14.0 → 0.14.2-alpha.0

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 (63) hide show
  1. package/cjs/core/BaseTable.js +1 -1
  2. package/cjs/core/BaseTable.js.map +1 -1
  3. package/cjs/event/listener/table-group.js +16 -8
  4. package/cjs/event/listener/table-group.js.map +1 -1
  5. package/cjs/index.d.ts +1 -1
  6. package/cjs/index.js +1 -1
  7. package/cjs/index.js.map +1 -1
  8. package/cjs/scenegraph/component/custom.d.ts +1 -0
  9. package/cjs/scenegraph/component/custom.js +3 -2
  10. package/cjs/scenegraph/component/custom.js.map +1 -1
  11. package/cjs/scenegraph/group-creater/column-helper.js +1 -1
  12. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  13. package/cjs/scenegraph/group-creater/progress/proxy.js +3 -1
  14. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  15. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +6 -2
  16. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  17. package/cjs/scenegraph/layout/compute-col-width.js +3 -2
  18. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  19. package/cjs/scenegraph/layout/compute-row-height.js +3 -2
  20. package/cjs/scenegraph/layout/compute-row-height.js.map +1 -1
  21. package/cjs/scenegraph/layout/update-row.js +31 -12
  22. package/cjs/scenegraph/layout/update-row.js.map +1 -1
  23. package/cjs/scenegraph/scenegraph.js +1 -1
  24. package/cjs/scenegraph/scenegraph.js.map +1 -1
  25. package/cjs/scenegraph/select/update-select-border.js +2 -2
  26. package/cjs/scenegraph/select/update-select-border.js.map +1 -1
  27. package/cjs/themes/DARK.js +2 -1
  28. package/cjs/themes/DEFAULT.js +1 -2
  29. package/cjs/ts-types/base-table.d.ts +2 -0
  30. package/cjs/ts-types/base-table.js.map +1 -1
  31. package/dist/vtable.js +92 -32
  32. package/dist/vtable.min.js +2 -2
  33. package/es/core/BaseTable.js +1 -1
  34. package/es/core/BaseTable.js.map +1 -1
  35. package/es/event/listener/table-group.js +16 -8
  36. package/es/event/listener/table-group.js.map +1 -1
  37. package/es/index.d.ts +1 -1
  38. package/es/index.js +1 -1
  39. package/es/index.js.map +1 -1
  40. package/es/scenegraph/component/custom.d.ts +1 -0
  41. package/es/scenegraph/component/custom.js +1 -1
  42. package/es/scenegraph/component/custom.js.map +1 -1
  43. package/es/scenegraph/group-creater/column-helper.js +1 -1
  44. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  45. package/es/scenegraph/group-creater/progress/proxy.js +3 -1
  46. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  47. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js +6 -2
  48. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-y.js.map +1 -1
  49. package/es/scenegraph/layout/compute-col-width.js +4 -3
  50. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  51. package/es/scenegraph/layout/compute-row-height.js +4 -3
  52. package/es/scenegraph/layout/compute-row-height.js.map +1 -1
  53. package/es/scenegraph/layout/update-row.js +32 -11
  54. package/es/scenegraph/layout/update-row.js.map +1 -1
  55. package/es/scenegraph/scenegraph.js +1 -1
  56. package/es/scenegraph/scenegraph.js.map +1 -1
  57. package/es/scenegraph/select/update-select-border.js +2 -2
  58. package/es/scenegraph/select/update-select-border.js.map +1 -1
  59. package/es/themes/DARK.js +2 -1
  60. package/es/themes/DEFAULT.js +1 -2
  61. package/es/ts-types/base-table.d.ts +2 -0
  62. package/es/ts-types/base-table.js.map +1 -1
  63. package/package.json +8 -3
package/dist/vtable.js CHANGED
@@ -52055,8 +52055,8 @@
52055
52055
  let textAlign;
52056
52056
  let textBaseline;
52057
52057
  let y = 0;
52058
- if (columnGroup.colHeight) {
52059
- y = columnGroup.colHeight;
52058
+ if (columnGroup.lastChild) {
52059
+ y = columnGroup.lastChild.attribute.y + columnGroup.lastChild.attribute.height;
52060
52060
  }
52061
52061
  for (let j = rowStart; j <= rowEnd; j++) {
52062
52062
  const row = j;
@@ -53376,10 +53376,10 @@
53376
53376
  };
53377
53377
  if (customLayout) {
53378
53378
  const customLayoutObj = customLayout(arg);
53379
- if (customLayoutObj.rootContainer) {
53380
- customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);
53381
- }
53382
53379
  if (customLayoutObj.rootContainer instanceof Group$3) {
53380
+ customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);
53381
+ dealPercentCalc(customLayoutObj.rootContainer, table.getColWidth(col), 0);
53382
+ customLayoutObj.rootContainer.setStage(table.scenegraph.stage);
53383
53383
  height = customLayoutObj.rootContainer.AABBBounds.height() ?? 0;
53384
53384
  }
53385
53385
  else {
@@ -55957,10 +55957,10 @@
55957
55957
  };
55958
55958
  if (customLayout) {
55959
55959
  const customLayoutObj = customLayout(arg);
55960
- if (customLayoutObj.rootContainer) {
55961
- customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);
55962
- }
55963
55960
  if (customLayoutObj.rootContainer instanceof Group$3) {
55961
+ customLayoutObj.rootContainer = decodeReactDom(customLayoutObj.rootContainer);
55962
+ dealPercentCalc(customLayoutObj.rootContainer, 0, table.getRowHeight(row));
55963
+ customLayoutObj.rootContainer.setStage(table.scenegraph.stage);
55964
55964
  width = customLayoutObj.rootContainer.AABBBounds.width() ?? 0;
55965
55965
  }
55966
55966
  else {
@@ -56496,7 +56496,9 @@
56496
56496
  proxy.rowEnd = direction === 'up' ? proxy.rowEnd + count : proxy.rowEnd - count;
56497
56497
  updateRowContent(syncTopRow, syncBottomRow, proxy);
56498
56498
  if (proxy.table.heightMode === 'autoHeight') {
56499
- updateAutoRow(proxy.bodyLeftCol, proxy.bodyRightCol, syncTopRow, syncBottomRow, proxy.table, direction);
56499
+ updateAutoRow(proxy.bodyLeftCol, proxy.bodyRightCol, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56500
+ updateAutoRow(0, proxy.table.frozenColCount - 1, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56501
+ updateAutoRow(proxy.table.colCount - proxy.table.rightFrozenColCount, proxy.table.colCount - 1, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56500
56502
  const cellGroup = proxy.table.scenegraph.highPerformanceGetCell(proxy.bodyLeftCol, screenTopRow, true);
56501
56503
  const delaY = screenTopY - (cellGroup.attribute.y + proxy.table.getFrozenRowsHeight() + proxy.table.scenegraph.proxy.deltaY);
56502
56504
  proxy.table.scenegraph.proxy.deltaY += delaY;
@@ -56532,6 +56534,8 @@
56532
56534
  updateRowContent(syncTopRow, syncBottomRow, proxy);
56533
56535
  if (proxy.table.heightMode === 'autoHeight') {
56534
56536
  updateAutoRow(proxy.bodyLeftCol, proxy.bodyRightCol, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56537
+ updateAutoRow(0, proxy.table.frozenColCount - 1, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56538
+ updateAutoRow(proxy.table.colCount - proxy.table.rightFrozenColCount, proxy.table.colCount - 1, syncTopRow, syncBottomRow, proxy.table, distEndRow > proxy.bodyBottomRow - (proxy.rowEnd - proxy.rowStart + 1) ? 'down' : 'up');
56535
56539
  }
56536
56540
  proxy.table.scenegraph.proxy.deltaY = 0;
56537
56541
  proxy.currentRow = direction === 'up' ? proxy.currentRow + count : proxy.currentRow - count;
@@ -56982,6 +56986,8 @@
56982
56986
  updateRowContent(this.rowUpdatePos, distRow, this);
56983
56987
  if (this.table.heightMode === 'autoHeight') {
56984
56988
  updateAutoRow(this.bodyLeftCol, this.bodyRightCol, this.rowUpdatePos, distRow, this.table, this.rowUpdateDirection);
56989
+ updateAutoRow(0, this.table.frozenColCount - 1, this.rowUpdatePos, distRow, this.table, this.rowUpdateDirection);
56990
+ updateAutoRow(this.table.colCount - this.table.rightFrozenColCount, this.table.colCount - 1, this.rowUpdatePos, distRow, this.table, this.rowUpdateDirection);
56985
56991
  }
56986
56992
  this.rowUpdatePos = distRow + 1;
56987
56993
  }
@@ -57210,7 +57216,7 @@
57210
57216
  const cellRange = scene.table.getCellRange(startCol, startRow);
57211
57217
  const colsWidth = scene.table.getColsWidth(cellRange.start.col, endCol);
57212
57218
  const rowsHeight = scene.table.getRowsHeight(cellRange.start.row, endRow);
57213
- const firstCellBound = scene.highPerformanceGetCell(startCol, startRow).globalAABBBounds;
57219
+ const firstCellBound = scene.highPerformanceGetCell(cellRange.start.col, cellRange.start.row).globalAABBBounds;
57214
57220
  selectComp.rect.setAttributes({
57215
57221
  x: firstCellBound.x1 - scene.tableGroup.attribute.x,
57216
57222
  y: firstCellBound.y1 - scene.tableGroup.attribute.y,
@@ -57218,9 +57224,9 @@
57218
57224
  height: rowsHeight,
57219
57225
  visible: true
57220
57226
  });
57221
- const isNearRowHeader = startCol === scene.table.frozenColCount;
57227
+ const isNearRowHeader = cellRange.start.col === scene.table.frozenColCount;
57222
57228
  const isNearRightRowHeader = endCol === scene.table.colCount - scene.table.rightFrozenColCount - 1;
57223
- const isNearColHeader = startRow === scene.table.frozenRowCount;
57229
+ const isNearColHeader = cellRange.start.row === scene.table.frozenRowCount;
57224
57230
  const isNearBottomColHeader = endRow === scene.table.rowCount - scene.table.bottomFrozenRowCount - 1;
57225
57231
  if ((isNearRowHeader && selectComp.rect.attribute.stroke[3]) ||
57226
57232
  (isNearRightRowHeader && selectComp.rect.attribute.stroke[1]) ||
@@ -57565,17 +57571,24 @@
57565
57571
 
57566
57572
  function updateRow(removeCells, addCells, updateCells, table) {
57567
57573
  const scene = table.scenegraph;
57568
- const removeRows = deduplication(removeCells.map(cell => cell.row)).sort((a, b) => a - b);
57574
+ const removeRows = deduplication(removeCells.map(cell => cell.row)).sort((a, b) => b - a);
57569
57575
  const addRows = deduplication(addCells.map(cell => cell.row)).sort((a, b) => a - b);
57570
57576
  removeRows.forEach(row => {
57571
57577
  removeRow(row, scene);
57572
57578
  });
57579
+ removeRows.forEach(row => {
57580
+ scene.table.rowHeightsMap.adjustOrder(row + 1, row, scene.table.rowHeightsMap.count() - row - 1);
57581
+ scene.table.rowHeightsMap.del(scene.table.rowHeightsMap.count() - 1);
57582
+ });
57573
57583
  if (removeRows.length) {
57574
57584
  resetRowNumber(scene);
57575
57585
  }
57586
+ scene.table._clearRowRangeHeightsMap();
57576
57587
  addRows.forEach(row => {
57577
57588
  addRow(row, scene);
57589
+ scene.table.rowHeightsMap.adjustOrder(row, row + 1, scene.table.rowHeightsMap.count() - row);
57578
57590
  });
57591
+ const newTotalHeight = resetRowNumberAndY(scene);
57579
57592
  updateCells.forEach(cell => {
57580
57593
  if (!cell) {
57581
57594
  return;
@@ -57592,13 +57605,17 @@
57592
57605
  updateCell$1(cell.col, cell.row, scene.table, false);
57593
57606
  }
57594
57607
  });
57595
- const newTotalHeight = resetRowNumberAndY(scene);
57596
57608
  if (addRows.length) {
57597
- scene.proxy.rowUpdatePos = scene.proxy.rowStart;
57609
+ const minRow = Math.min(...addRows);
57610
+ scene.proxy.rowUpdatePos = minRow;
57598
57611
  scene.proxy.rowUpdateDirection = 'up';
57599
57612
  scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);
57600
57613
  scene.proxy.progress();
57601
57614
  }
57615
+ else if (removeRows.length) {
57616
+ scene.proxy.updateCellGroups(scene.proxy.screenRowCount * 2);
57617
+ scene.proxy.progress();
57618
+ }
57602
57619
  scene.updateContainerHeight(scene.table.frozenRowCount, newTotalHeight - scene.bodyGroup.attribute.height);
57603
57620
  }
57604
57621
  function removeRow(row, scene) {
@@ -57616,13 +57633,18 @@
57616
57633
  return false;
57617
57634
  });
57618
57635
  if (cellGroup) {
57636
+ colGroup.updateColumnHeight(-cellGroup.attribute.height);
57619
57637
  colGroup.removeChild(cellGroup);
57620
57638
  }
57621
57639
  }
57622
- scene.proxy.rowEnd--;
57640
+ if (row <= scene.proxy.rowEnd) {
57641
+ scene.proxy.rowEnd--;
57642
+ scene.proxy.currentRow--;
57643
+ }
57623
57644
  scene.proxy.bodyBottomRow--;
57624
- scene.proxy.currentRow--;
57625
- scene.proxy.totalRow--;
57645
+ const totalActualBodyRowCount = Math.min(scene.proxy.rowLimit, scene.proxy.bodyBottomRow - scene.proxy.bodyTopRow + 1);
57646
+ scene.proxy.totalActualBodyRowCount = totalActualBodyRowCount;
57647
+ scene.proxy.totalRow = scene.proxy.bodyTopRow + totalActualBodyRowCount - 1;
57626
57648
  }
57627
57649
  function addRow(row, scene) {
57628
57650
  for (let col = 0; col < scene.table.colCount; col++) {
@@ -57661,10 +57683,10 @@
57661
57683
  }
57662
57684
  }
57663
57685
  }
57664
- scene.proxy.rowEnd++;
57665
57686
  scene.proxy.bodyBottomRow++;
57666
- scene.proxy.currentRow++;
57667
57687
  scene.proxy.totalRow++;
57688
+ scene.proxy.rowEnd++;
57689
+ scene.proxy.currentRow++;
57668
57690
  }
57669
57691
  function deduplication(array) {
57670
57692
  const result = [];
@@ -57684,11 +57706,25 @@
57684
57706
  }
57685
57707
  let rowIndex = headerColGroup.firstChild?.row;
57686
57708
  headerColGroup.forEachChildren((cellGroup) => {
57709
+ const oldRow = cellGroup.row;
57710
+ if (isNumber$7(cellGroup.mergeStartRow)) {
57711
+ cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;
57712
+ }
57713
+ if (isNumber$7(cellGroup.mergeEndRow)) {
57714
+ cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;
57715
+ }
57687
57716
  cellGroup.row = rowIndex;
57688
57717
  rowIndex++;
57689
57718
  });
57690
57719
  rowIndex = colGroup.firstChild?.row;
57691
57720
  colGroup.forEachChildren((cellGroup) => {
57721
+ const oldRow = cellGroup.row;
57722
+ if (isNumber$7(cellGroup.mergeStartRow)) {
57723
+ cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;
57724
+ }
57725
+ if (isNumber$7(cellGroup.mergeEndRow)) {
57726
+ cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;
57727
+ }
57692
57728
  cellGroup.row = rowIndex;
57693
57729
  rowIndex++;
57694
57730
  });
@@ -57708,6 +57744,13 @@
57708
57744
  rowIndex = colGroup.firstChild?.row;
57709
57745
  y = 0;
57710
57746
  colGroup.forEachChildren((cellGroup) => {
57747
+ const oldRow = cellGroup.row;
57748
+ if (isNumber$7(cellGroup.mergeStartRow)) {
57749
+ cellGroup.mergeStartRow = cellGroup.mergeStartRow - oldRow + rowIndex;
57750
+ }
57751
+ if (isNumber$7(cellGroup.mergeEndRow)) {
57752
+ cellGroup.mergeEndRow = cellGroup.mergeEndRow - oldRow + rowIndex;
57753
+ }
57711
57754
  cellGroup.row = rowIndex;
57712
57755
  rowIndex++;
57713
57756
  if (cellGroup.role !== 'cell') {
@@ -59799,6 +59842,7 @@
59799
59842
  if (!this.isPivot && !this.transpose) {
59800
59843
  this.component.setFrozenColumnShadow(this.table.frozenColCount - 1);
59801
59844
  }
59845
+ this.component.updateScrollBar();
59802
59846
  this.updateNextFrame();
59803
59847
  }
59804
59848
  getColumnGroupX(col) {
@@ -61637,10 +61681,29 @@
61637
61681
  }
61638
61682
 
61639
61683
  let LastPointerXY;
61684
+ let LastBodyPointerXY;
61685
+ let isDown = false;
61686
+ let isDraging = false;
61640
61687
  function bindTableGroupListener(eventManeger) {
61641
61688
  const table = eventManeger.table;
61642
61689
  const stateManeger = table.stateManeger;
61690
+ document.body.addEventListener('pointerdown', e => {
61691
+ LastBodyPointerXY = { x: e.x, y: e.y };
61692
+ isDown = true;
61693
+ });
61694
+ document.addEventListener('pointerup', e => {
61695
+ LastBodyPointerXY = null;
61696
+ isDown = false;
61697
+ isDraging = false;
61698
+ });
61643
61699
  document.body.addEventListener('pointermove', (e) => {
61700
+ if (isDown && LastBodyPointerXY) {
61701
+ const lastX = LastBodyPointerXY?.x ?? e.x;
61702
+ const lastY = LastBodyPointerXY?.y ?? e.y;
61703
+ if (Math.abs(lastX - e.x) > 1 || Math.abs(lastY - e.y) > 1) {
61704
+ isDraging = true;
61705
+ }
61706
+ }
61644
61707
  const { x, y } = table._getMouseAbstractPoint(e, false);
61645
61708
  if (stateManeger.interactionState === InteractionState.scrolling) {
61646
61709
  return;
@@ -61829,12 +61892,7 @@
61829
61892
  if (table.stateManeger.select?.ranges?.length) {
61830
61893
  const lastCol = table.stateManeger.select.ranges[table.stateManeger.select.ranges.length - 1].end.col;
61831
61894
  const lastRow = table.stateManeger.select.ranges[table.stateManeger.select.ranges.length - 1].end.row;
61832
- table.stateManeger.select.selecting = false;
61833
- table.fireListeners(TABLE_EVENT_TYPE.SELECTED_CELL, {
61834
- ranges: table.stateManeger.select.ranges,
61835
- col: lastCol,
61836
- row: lastRow
61837
- });
61895
+ table.stateManeger.endSelectCells();
61838
61896
  if (table.hasListeners(TABLE_EVENT_TYPE.DRAG_SELECT_END)) {
61839
61897
  const cellsEvent = {
61840
61898
  event: e.nativeEvent,
@@ -62062,16 +62120,18 @@
62062
62120
  });
62063
62121
  table.scenegraph.stage.addEventListener('pointertap', (e) => {
62064
62122
  const target = e.target;
62065
- if (target &&
62066
- !target.isDescendantsOf(table.scenegraph.tableGroup) &&
62067
- target !== table.scenegraph.tableGroup &&
62068
- target !== table.scenegraph.stage) {
62123
+ if (!isDraging &&
62124
+ target &&
62125
+ !target.isDescendantsOf(table.scenegraph.tableGroup)) {
62069
62126
  stateManeger.updateInteractionState(InteractionState.default);
62070
62127
  eventManeger.dealTableHover();
62071
62128
  eventManeger.dealTableSelect();
62072
62129
  stateManeger.updateCursor();
62073
62130
  table.scenegraph.updateChartState(null);
62074
62131
  }
62132
+ else if (isDraging) {
62133
+ stateManeger.endSelectCells();
62134
+ }
62075
62135
  });
62076
62136
  table.scenegraph.tableGroup.addEventListener('dblclick', (e) => {
62077
62137
  const eventArgsSet = getCellEventArgsSet(e);
@@ -65650,7 +65710,7 @@
65650
65710
  return TABLE_EVENT_TYPE;
65651
65711
  }
65652
65712
  options;
65653
- version = "0.14.0";
65713
+ version = "0.14.2-alpha.0";
65654
65714
  pagination;
65655
65715
  id = `VTable${Date.now()}`;
65656
65716
  headerStyleCache;
@@ -75053,7 +75113,7 @@
75053
75113
  return new Tag$1(params ? params.attribute : {});
75054
75114
  }
75055
75115
 
75056
- const version = "0.14.0";
75116
+ const version = "0.14.2-alpha.0";
75057
75117
  function getIcons() {
75058
75118
  return get$1();
75059
75119
  }