@visactor/vtable 1.21.1 → 1.22.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 (75) hide show
  1. package/cjs/ListTable.d.ts +3 -2
  2. package/cjs/ListTable.js +54 -14
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotTable.d.ts +1 -1
  5. package/cjs/PivotTable.js +1 -1
  6. package/cjs/PivotTable.js.map +1 -1
  7. package/cjs/core/BaseTable.js +1 -1
  8. package/cjs/core/BaseTable.js.map +1 -1
  9. package/cjs/core/TABLE_EVENT_TYPE.d.ts +7 -0
  10. package/cjs/core/TABLE_EVENT_TYPE.js +8 -1
  11. package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
  12. package/cjs/core/record-helper.d.ts +2 -2
  13. package/cjs/core/record-helper.js +141 -129
  14. package/cjs/core/record-helper.js.map +1 -1
  15. package/cjs/core/tableHelper.js +6 -1
  16. package/cjs/core/tableHelper.js.map +1 -1
  17. package/cjs/data/CachedDataSource.js +2 -2
  18. package/cjs/data/CachedDataSource.js.map +1 -1
  19. package/cjs/event/listener/table-group.js +2 -1
  20. package/cjs/event/listener/table-group.js.map +1 -1
  21. package/cjs/index.d.ts +1 -1
  22. package/cjs/index.js +1 -1
  23. package/cjs/index.js.map +1 -1
  24. package/cjs/scenegraph/group-creater/cell-type/progress-bar-cell.js +8 -2
  25. package/cjs/scenegraph/group-creater/cell-type/progress-bar-cell.js.map +1 -1
  26. package/cjs/scenegraph/group-creater/progress/proxy.js +1 -1
  27. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  28. package/cjs/scenegraph/scenegraph.js +1 -1
  29. package/cjs/scenegraph/scenegraph.js.map +1 -1
  30. package/cjs/scenegraph/select/update-select-border.js +6 -1
  31. package/cjs/scenegraph/select/update-select-border.js.map +1 -1
  32. package/cjs/scenegraph/utils/text-icon-layout.js +17 -3
  33. package/cjs/scenegraph/utils/text-icon-layout.js.map +1 -1
  34. package/cjs/ts-types/events.d.ts +51 -2
  35. package/cjs/ts-types/events.js.map +1 -1
  36. package/cjs/vrender.js.map +1 -1
  37. package/dist/vtable.js +354 -210
  38. package/dist/vtable.min.js +2 -2
  39. package/es/ListTable.d.ts +3 -2
  40. package/es/ListTable.js +54 -14
  41. package/es/ListTable.js.map +1 -1
  42. package/es/PivotTable.d.ts +1 -1
  43. package/es/PivotTable.js +1 -1
  44. package/es/PivotTable.js.map +1 -1
  45. package/es/core/BaseTable.js +1 -1
  46. package/es/core/BaseTable.js.map +1 -1
  47. package/es/core/TABLE_EVENT_TYPE.d.ts +7 -0
  48. package/es/core/TABLE_EVENT_TYPE.js +8 -1
  49. package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
  50. package/es/core/record-helper.d.ts +2 -2
  51. package/es/core/record-helper.js +141 -129
  52. package/es/core/record-helper.js.map +1 -1
  53. package/es/core/tableHelper.js +7 -2
  54. package/es/core/tableHelper.js.map +1 -1
  55. package/es/data/CachedDataSource.js +2 -2
  56. package/es/data/CachedDataSource.js.map +1 -1
  57. package/es/event/listener/table-group.js +2 -1
  58. package/es/event/listener/table-group.js.map +1 -1
  59. package/es/index.d.ts +1 -1
  60. package/es/index.js +1 -1
  61. package/es/index.js.map +1 -1
  62. package/es/scenegraph/group-creater/cell-type/progress-bar-cell.js +8 -2
  63. package/es/scenegraph/group-creater/cell-type/progress-bar-cell.js.map +1 -1
  64. package/es/scenegraph/group-creater/progress/proxy.js +1 -1
  65. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  66. package/es/scenegraph/scenegraph.js +1 -1
  67. package/es/scenegraph/scenegraph.js.map +1 -1
  68. package/es/scenegraph/select/update-select-border.js +7 -0
  69. package/es/scenegraph/select/update-select-border.js.map +1 -1
  70. package/es/scenegraph/utils/text-icon-layout.js +18 -2
  71. package/es/scenegraph/utils/text-icon-layout.js.map +1 -1
  72. package/es/ts-types/events.d.ts +51 -2
  73. package/es/ts-types/events.js.map +1 -1
  74. package/es/vrender.js.map +1 -1
  75. package/package.json +4 -4
package/dist/vtable.js CHANGED
@@ -36319,6 +36319,8 @@
36319
36319
  AFTER_RENDER: 'after_render',
36320
36320
  INITIALIZED: 'initialized',
36321
36321
  UPDATED: 'updated',
36322
+ AFTER_UPDATE_CELL_CONTENT_WIDTH: 'after_update_cell_content_width',
36323
+ AFTER_UPDATE_SELECT_BORDER_HEIGHT: 'after_update_select_border_height',
36322
36324
  CHANGE_CELL_VALUE: 'change_cell_value',
36323
36325
  DRAG_FILL_HANDLE_END: 'drag_fill_handle_end',
36324
36326
  MOUSEDOWN_FILL_HANDLE: 'mousedown_fill_handle',
@@ -36328,7 +36330,12 @@
36328
36330
  BUTTON_CLICK: 'button_click',
36329
36331
  BEFORE_CACHE_CHART_IMAGE: 'before_cache_chart_image',
36330
36332
  PASTED_DATA: 'pasted_data',
36331
- PLUGIN_EVENT: 'plugin_event'
36333
+ PLUGIN_EVENT: 'plugin_event',
36334
+ ADD_RECORD: 'add_record',
36335
+ DELETE_RECORD: 'delete_record',
36336
+ UPDATE_RECORD: 'update_record',
36337
+ ADD_COLUMN: 'add_column',
36338
+ DELETE_COLUMN: 'delete_column'
36332
36339
  };
36333
36340
 
36334
36341
  const judgeType = (value) => {
@@ -40818,7 +40825,6 @@
40818
40825
  constructor(opt, dataConfig, pagination, columns, rowHierarchyType, hierarchyExpandLevel) {
40819
40826
  let _isGrouped;
40820
40827
  if (isArray$7(dataConfig?.groupByRules)) {
40821
- rowHierarchyType = 'tree';
40822
40828
  _isGrouped = true;
40823
40829
  }
40824
40830
  super(opt, dataConfig, pagination, columns, rowHierarchyType, hierarchyExpandLevel);
@@ -41662,9 +41668,17 @@
41662
41668
  ];
41663
41669
  }
41664
41670
  function _setRecords(table, records = []) {
41671
+ const tableWithPlugins = table;
41665
41672
  _dealWithUpdateDataSource(table, () => {
41666
41673
  table.internalProps.records = records;
41667
- const newDataSource = (table.internalProps.dataSource = CachedDataSource.ofArray(records, table.internalProps.dataConfig, table.pagination, table.internalProps.columns, table.internalProps.layoutMap.rowHierarchyType, getHierarchyExpandLevel(table)));
41674
+ let rowHierarchyType = table.internalProps.layoutMap.rowHierarchyType;
41675
+ if (isArray$7(table.internalProps.dataConfig?.groupByRules)) {
41676
+ rowHierarchyType = 'tree';
41677
+ }
41678
+ if (tableWithPlugins.pluginManager.getPluginByName('Master Detail Plugin')) {
41679
+ rowHierarchyType = 'grid';
41680
+ }
41681
+ const newDataSource = (table.internalProps.dataSource = CachedDataSource.ofArray(records, table.internalProps.dataConfig, table.pagination, table.internalProps.columns, rowHierarchyType, getHierarchyExpandLevel(table)));
41668
41682
  table.addReleaseObj(newDataSource);
41669
41683
  });
41670
41684
  }
@@ -44290,6 +44304,16 @@
44290
44304
  if (autoRowHeight) {
44291
44305
  let newHeight = Math.max(leftIconHeight, contentHeight, rightIconHeight);
44292
44306
  if (isCellHeightUpdate(scene, cellGroup, Math.round(newHeight + padding[0] + padding[2]), oldCellHeight)) {
44307
+ if (scene.table.hasListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH)) {
44308
+ scene.table.fireListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH, {
44309
+ col: cellGroup.col,
44310
+ row: cellGroup.row,
44311
+ cellHeight,
44312
+ cellGroup,
44313
+ padding,
44314
+ textBaseline
44315
+ });
44316
+ }
44293
44317
  return true;
44294
44318
  }
44295
44319
  newHeight = (cellGroup.contentHeight ?? cellHeight) - (padding[0] + padding[2]);
@@ -44330,6 +44354,16 @@
44330
44354
  }
44331
44355
  });
44332
44356
  }
44357
+ if (scene.table.hasListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH)) {
44358
+ scene.table.fireListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_CELL_CONTENT_WIDTH, {
44359
+ col: cellGroup.col,
44360
+ row: cellGroup.row,
44361
+ cellHeight,
44362
+ cellGroup,
44363
+ padding,
44364
+ textBaseline
44365
+ });
44366
+ }
44333
44367
  return false;
44334
44368
  }
44335
44369
  function updateCellContentHeight(cellGroup, distHeight, detaY, autoRowHeight, padding, textAlign, textBaseline, table) {
@@ -53151,8 +53185,9 @@
53151
53185
  else if (this.rowEnd === this.bodyBottomRow) {
53152
53186
  const cellGroup = this.table.scenegraph.highPerformanceGetCell(this.colStart, this.rowEnd, true);
53153
53187
  if (cellGroup.role === 'cell') {
53188
+ const actualRowHeight = this.table.getRowHeight(this.rowEnd);
53154
53189
  const deltaY = cellGroup.attribute.y +
53155
- cellGroup.attribute.height -
53190
+ actualRowHeight -
53156
53191
  (this.table.getAllRowsHeight() - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight());
53157
53192
  this.deltaY = -deltaY;
53158
53193
  }
@@ -53376,6 +53411,14 @@
53376
53411
  height: rowsHeight,
53377
53412
  visible: true
53378
53413
  });
53414
+ if (table.hasListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT)) {
53415
+ table.fireListeners(TABLE_EVENT_TYPE.AFTER_UPDATE_SELECT_BORDER_HEIGHT, {
53416
+ startRow: computeRectCellRangeStartRow,
53417
+ endRow: computeRectCellRangeEndRow,
53418
+ currentHeight: rowsHeight,
53419
+ selectComp
53420
+ });
53421
+ }
53379
53422
  if (selectComp.fillhandle) {
53380
53423
  const fillHandle = scene.table.options.excelOptions?.fillHandle;
53381
53424
  let visible = true;
@@ -57069,14 +57112,14 @@
57069
57112
  else if (lastBodyCell &&
57070
57113
  this.table.tableNoFrameHeight < this.table.getAllRowsHeight() &&
57071
57114
  lastBodyCell.row === this.table.rowCount - this.table.bottomFrozenRowCount - 1 &&
57072
- lastBodyCell.attribute.y + lastBodyCell.attribute.height + y <
57115
+ lastBodyCell.attribute.y + this.table.getRowHeight(lastBodyCell.row) + y <
57073
57116
  this.table.tableNoFrameHeight - this.table.getFrozenRowsHeight() - this.table.getBottomFrozenRowsHeight()) {
57074
57117
  y =
57075
57118
  this.table.tableNoFrameHeight -
57076
57119
  this.table.getFrozenRowsHeight() -
57077
57120
  this.table.getBottomFrozenRowsHeight() -
57078
57121
  lastBodyCell.attribute.y -
57079
- lastBodyCell.attribute.height;
57122
+ this.table.getRowHeight(lastBodyCell.row);
57080
57123
  }
57081
57124
  if (this.colHeaderGroup.attribute.height + y === this.bodyGroup.attribute.y) {
57082
57125
  return;
@@ -62132,6 +62175,10 @@
62132
62175
  });
62133
62176
  table.scenegraph.stage.addEventListener('pointermove', (e) => {
62134
62177
  const eventArgsSet = getCellEventArgsSet(e);
62178
+ const isEventFromCurrentTable = e.target?.isDescendantsOf?.(table.scenegraph.tableGroup) ?? false;
62179
+ if (!isEventFromCurrentTable) {
62180
+ return;
62181
+ }
62135
62182
  if (stateManager.isResizeCol() || eventManager.checkColumnResize(eventArgsSet)) {
62136
62183
  if (table.stateManager.select && eventManager.checkCellFillhandle(eventArgsSet)) {
62137
62184
  stateManager.updateCursor('crosshair');
@@ -69128,7 +69175,7 @@
69128
69175
  return TABLE_EVENT_TYPE;
69129
69176
  }
69130
69177
  options;
69131
- version = "1.21.1";
69178
+ version = "1.22.0";
69132
69179
  pagination;
69133
69180
  id = `VTable${Date.now()}`;
69134
69181
  headerStyleCache;
@@ -76049,226 +76096,259 @@
76049
76096
  }
76050
76097
  }
76051
76098
  function listTableAddRecord(record, recordIndex, table) {
76052
- if (table.internalProps.groupBy) {
76053
- table.dataSource.addRecordsForGroup?.([record], recordIndex);
76054
- table.refreshRowColCount();
76055
- table.internalProps.layoutMap.clearCellRangeMap();
76056
- table.sortState && sortRecords(table);
76057
- table.scenegraph.clearCells();
76058
- table.scenegraph.createSceneGraph();
76059
- }
76060
- else if (table.dataSource.rowHierarchyType === 'tree') {
76061
- table.dataSource.addRecordsForTree?.([record], recordIndex);
76062
- adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1);
76063
- table.refreshRowColCount();
76064
- table.internalProps.layoutMap.clearCellRangeMap();
76065
- table.sortState && sortRecords(table);
76066
- table.scenegraph.clearCells();
76067
- table.scenegraph.createSceneGraph();
76068
- }
76069
- else if (table.sortState) {
76070
- table.dataSource.addRecordForSorted(record);
76071
- table.stateManager.checkedState.clear();
76072
- sortRecords(table);
76073
- table.refreshRowColCount();
76074
- table.scenegraph.clearCells();
76075
- table.scenegraph.createSceneGraph();
76076
- }
76077
- else {
76078
- recordIndex = recordIndex;
76079
- if (recordIndex === undefined || recordIndex > table.dataSource.sourceLength) {
76080
- recordIndex = table.dataSource.sourceLength;
76081
- }
76082
- const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
76083
- table.dataSource.addRecord(record, recordIndex);
76084
- adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1);
76085
- const oldRowCount = table.rowCount;
76086
- table.refreshRowColCount();
76087
- if (table.scenegraph.proxy.totalActualBodyRowCount === 0) {
76099
+ try {
76100
+ if (!record) {
76101
+ return false;
76102
+ }
76103
+ if (table.internalProps.groupBy) {
76104
+ table.dataSource.addRecordsForGroup?.([record], recordIndex);
76105
+ table.refreshRowColCount();
76106
+ table.internalProps.layoutMap.clearCellRangeMap();
76107
+ table.sortState && sortRecords(table);
76088
76108
  table.scenegraph.clearCells();
76089
76109
  table.scenegraph.createSceneGraph();
76090
- return;
76091
76110
  }
76092
- const newRowCount = table.transpose ? table.colCount : table.rowCount;
76093
- if (table.pagination) {
76094
- const { perPageCount, currentPage } = table.pagination;
76095
- const startIndex = perPageCount * (currentPage || 0);
76096
- const endIndex = startIndex + perPageCount;
76097
- if (recordIndex < endIndex) {
76098
- if (recordIndex < endIndex - perPageCount) {
76099
- table.scenegraph.clearCells();
76100
- table.scenegraph.createSceneGraph();
76101
- }
76102
- else {
76103
- const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
76104
- if (oldRowCount - headerCount === table.pagination.perPageCount) {
76105
- const updateRows = [];
76106
- for (let row = rowNum; row < newRowCount; row++) {
76107
- if (table.transpose) {
76108
- updateRows.push({ col: row, row: 0 });
76109
- }
76110
- else {
76111
- updateRows.push({ col: 0, row });
76112
- }
76113
- }
76114
- table.transpose
76115
- ? table.scenegraph.updateCol([], [], updateRows)
76116
- : table.scenegraph.updateRow([], [], updateRows);
76111
+ else if (table.dataSource.rowHierarchyType === 'tree') {
76112
+ table.dataSource.addRecordsForTree?.([record], recordIndex);
76113
+ adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1);
76114
+ table.refreshRowColCount();
76115
+ table.internalProps.layoutMap.clearCellRangeMap();
76116
+ table.sortState && sortRecords(table);
76117
+ table.scenegraph.clearCells();
76118
+ table.scenegraph.createSceneGraph();
76119
+ }
76120
+ else if (table.sortState) {
76121
+ table.dataSource.addRecordForSorted(record);
76122
+ table.stateManager.checkedState.clear();
76123
+ sortRecords(table);
76124
+ table.refreshRowColCount();
76125
+ table.scenegraph.clearCells();
76126
+ table.scenegraph.createSceneGraph();
76127
+ }
76128
+ else {
76129
+ recordIndex = recordIndex;
76130
+ if (recordIndex === undefined || recordIndex > table.dataSource.sourceLength) {
76131
+ recordIndex = table.dataSource.sourceLength;
76132
+ }
76133
+ const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
76134
+ table.dataSource.addRecord(record, recordIndex);
76135
+ adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1);
76136
+ const oldRowCount = table.rowCount;
76137
+ table.refreshRowColCount();
76138
+ if (table.scenegraph.proxy.totalActualBodyRowCount === 0) {
76139
+ table.scenegraph.clearCells();
76140
+ table.scenegraph.createSceneGraph();
76141
+ return true;
76142
+ }
76143
+ const newRowCount = table.transpose ? table.colCount : table.rowCount;
76144
+ if (table.pagination) {
76145
+ const { perPageCount, currentPage } = table.pagination;
76146
+ const startIndex = perPageCount * (currentPage || 0);
76147
+ const endIndex = startIndex + perPageCount;
76148
+ if (recordIndex < endIndex) {
76149
+ if (recordIndex < endIndex - perPageCount) {
76150
+ table.scenegraph.clearCells();
76151
+ table.scenegraph.createSceneGraph();
76117
76152
  }
76118
76153
  else {
76119
- const addRows = [];
76120
- for (let row = rowNum; row < Math.min(newRowCount, rowNum + 1); row++) {
76121
- if (table.transpose) {
76122
- addRows.push({ col: row, row: 0 });
76154
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
76155
+ if (oldRowCount - headerCount === table.pagination.perPageCount) {
76156
+ const updateRows = [];
76157
+ for (let row = rowNum; row < newRowCount; row++) {
76158
+ if (table.transpose) {
76159
+ updateRows.push({ col: row, row: 0 });
76160
+ }
76161
+ else {
76162
+ updateRows.push({ col: 0, row });
76163
+ }
76123
76164
  }
76124
- else {
76125
- addRows.push({ col: 0, row });
76165
+ table.transpose
76166
+ ? table.scenegraph.updateCol([], [], updateRows)
76167
+ : table.scenegraph.updateRow([], [], updateRows);
76168
+ }
76169
+ else {
76170
+ const addRows = [];
76171
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + 1); row++) {
76172
+ if (table.transpose) {
76173
+ addRows.push({ col: row, row: 0 });
76174
+ }
76175
+ else {
76176
+ addRows.push({ col: 0, row });
76177
+ }
76126
76178
  }
76179
+ table.transpose
76180
+ ? table.scenegraph.updateCol([], addRows, [])
76181
+ : table.scenegraph.updateRow([], addRows, []);
76127
76182
  }
76128
- table.transpose ? table.scenegraph.updateCol([], addRows, []) : table.scenegraph.updateRow([], addRows, []);
76129
76183
  }
76130
76184
  }
76131
76185
  }
76132
- }
76133
- else {
76134
- const addRows = [];
76135
- for (let row = recordIndex + headerCount; row < recordIndex + headerCount + 1; row++) {
76136
- if (table.transpose) {
76137
- addRows.push({ col: row, row: 0 });
76186
+ else {
76187
+ const addRows = [];
76188
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + 1; row++) {
76189
+ if (table.transpose) {
76190
+ addRows.push({ col: row, row: 0 });
76191
+ }
76192
+ else {
76193
+ addRows.push({ col: 0, row });
76194
+ }
76138
76195
  }
76139
- else {
76140
- addRows.push({ col: 0, row });
76196
+ const updateRows = [];
76197
+ const topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount;
76198
+ const bottomAggregationCount = table.internalProps.layoutMap.hasAggregationOnBottomCount;
76199
+ for (let row = headerCount; row < headerCount + topAggregationCount; row++) {
76200
+ if (table.transpose) {
76201
+ updateRows.push({ col: row, row: 0 });
76202
+ }
76203
+ else {
76204
+ updateRows.push({ col: 0, row });
76205
+ }
76141
76206
  }
76207
+ for (let row = (table.transpose ? table.colCount : table.rowCount) - bottomAggregationCount; row < (table.transpose ? table.colCount : table.rowCount); row++) {
76208
+ if (table.transpose) {
76209
+ updateRows.push({ col: row, row: 0 });
76210
+ }
76211
+ else {
76212
+ updateRows.push({ col: 0, row });
76213
+ }
76214
+ }
76215
+ table.transpose ? table.scenegraph.updateCol([], addRows, []) : table.scenegraph.updateRow([], addRows, []);
76142
76216
  }
76143
- const topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount;
76144
- const bottomAggregationCount = table.internalProps.layoutMap.hasAggregationOnBottomCount;
76145
- for (let row = headerCount; row < headerCount + topAggregationCount; row++) {
76146
- if (table.transpose) ;
76147
- }
76148
- for (let row = (table.transpose ? table.colCount : table.rowCount) - bottomAggregationCount; row < (table.transpose ? table.colCount : table.rowCount); row++) {
76149
- if (table.transpose) ;
76150
- }
76151
- table.transpose ? table.scenegraph.updateCol([], addRows, []) : table.scenegraph.updateRow([], addRows, []);
76152
76217
  }
76218
+ return true;
76219
+ }
76220
+ catch (error) {
76221
+ return false;
76153
76222
  }
76154
76223
  }
76155
76224
  function listTableAddRecords(records, recordIndex, table) {
76156
- if (table.internalProps.groupBy) {
76157
- table.dataSource.addRecordsForGroup?.(records, recordIndex);
76158
- table.refreshRowColCount();
76159
- table.internalProps.layoutMap.clearCellRangeMap();
76160
- table.sortState && sortRecords(table);
76161
- table.scenegraph.clearCells();
76162
- table.scenegraph.createSceneGraph();
76163
- }
76164
- else if (table.dataSource.rowHierarchyType === 'tree') {
76165
- table.dataSource.addRecordsForTree?.(records, recordIndex);
76166
- adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length);
76167
- table.refreshRowColCount();
76168
- table.internalProps.layoutMap.clearCellRangeMap();
76169
- table.sortState && sortRecords(table);
76170
- table.scenegraph.clearCells();
76171
- table.scenegraph.createSceneGraph();
76172
- }
76173
- else if (table.sortState) {
76174
- table.dataSource.addRecordsForSorted(records);
76175
- sortRecords(table);
76176
- table.refreshRowColCount();
76177
- table.scenegraph.clearCells();
76178
- table.scenegraph.createSceneGraph();
76179
- }
76180
- else {
76181
- recordIndex = recordIndex;
76182
- if (recordIndex === undefined || recordIndex > table.dataSource.sourceLength) {
76183
- recordIndex = table.dataSource.sourceLength;
76225
+ try {
76226
+ if (!records || records.length === 0) {
76227
+ return false;
76184
76228
  }
76185
- else if (recordIndex < 0) {
76186
- recordIndex = 0;
76229
+ if (table.internalProps.groupBy) {
76230
+ table.dataSource.addRecordsForGroup?.(records, recordIndex);
76231
+ table.refreshRowColCount();
76232
+ table.internalProps.layoutMap.clearCellRangeMap();
76233
+ table.sortState && sortRecords(table);
76234
+ table.scenegraph.clearCells();
76235
+ table.scenegraph.createSceneGraph();
76187
76236
  }
76188
- const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
76189
- table.dataSource.addRecords(records, recordIndex);
76190
- adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length);
76191
- const oldRowCount = table.transpose ? table.colCount : table.rowCount;
76192
- table.refreshRowColCount();
76193
- if (table.scenegraph.proxy.totalActualBodyRowCount === 0) {
76237
+ else if (table.dataSource.rowHierarchyType === 'tree') {
76238
+ table.dataSource.addRecordsForTree?.(records, recordIndex);
76239
+ adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length);
76240
+ table.refreshRowColCount();
76241
+ table.internalProps.layoutMap.clearCellRangeMap();
76242
+ table.sortState && sortRecords(table);
76194
76243
  table.scenegraph.clearCells();
76195
76244
  table.scenegraph.createSceneGraph();
76196
- return;
76197
76245
  }
76198
- const newRowCount = table.transpose ? table.colCount : table.rowCount;
76199
- if (table.pagination) {
76200
- const { perPageCount, currentPage } = table.pagination;
76201
- const startIndex = perPageCount * (currentPage || 0);
76202
- const endIndex = startIndex + perPageCount;
76203
- if (recordIndex < endIndex) {
76204
- if (recordIndex < endIndex - perPageCount) {
76205
- table.scenegraph.clearCells();
76206
- table.scenegraph.createSceneGraph();
76207
- }
76208
- else {
76209
- const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
76210
- if (oldRowCount - headerCount === table.pagination.perPageCount) {
76211
- const updateRows = [];
76212
- for (let row = rowNum; row < newRowCount; row++) {
76213
- if (table.transpose) {
76214
- updateRows.push({ col: row, row: 0 });
76215
- }
76216
- else {
76217
- updateRows.push({ col: 0, row });
76218
- }
76219
- }
76220
- table.transpose
76221
- ? table.scenegraph.updateCol([], [], updateRows)
76222
- : table.scenegraph.updateRow([], [], updateRows);
76246
+ else if (table.sortState) {
76247
+ table.dataSource.addRecordsForSorted(records);
76248
+ sortRecords(table);
76249
+ table.refreshRowColCount();
76250
+ table.scenegraph.clearCells();
76251
+ table.scenegraph.createSceneGraph();
76252
+ }
76253
+ else {
76254
+ recordIndex = recordIndex;
76255
+ if (recordIndex === undefined || recordIndex > table.dataSource.sourceLength) {
76256
+ recordIndex = table.dataSource.sourceLength;
76257
+ }
76258
+ else if (recordIndex < 0) {
76259
+ recordIndex = 0;
76260
+ }
76261
+ const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount;
76262
+ table.dataSource.addRecords(records, recordIndex);
76263
+ adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length);
76264
+ const oldRowCount = table.transpose ? table.colCount : table.rowCount;
76265
+ table.refreshRowColCount();
76266
+ if (table.scenegraph.proxy.totalActualBodyRowCount === 0) {
76267
+ table.scenegraph.clearCells();
76268
+ table.scenegraph.createSceneGraph();
76269
+ return true;
76270
+ }
76271
+ const newRowCount = table.transpose ? table.colCount : table.rowCount;
76272
+ if (table.pagination) {
76273
+ const { perPageCount, currentPage } = table.pagination;
76274
+ const startIndex = perPageCount * (currentPage || 0);
76275
+ const endIndex = startIndex + perPageCount;
76276
+ if (recordIndex < endIndex) {
76277
+ if (recordIndex < endIndex - perPageCount) {
76278
+ table.scenegraph.clearCells();
76279
+ table.scenegraph.createSceneGraph();
76223
76280
  }
76224
76281
  else {
76225
- const addRows = [];
76226
- for (let row = rowNum; row < Math.min(newRowCount, rowNum + (Array.isArray(records) ? records.length : 1)); row++) {
76227
- if (table.transpose) {
76228
- addRows.push({ col: row, row: 0 });
76282
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
76283
+ if (oldRowCount - headerCount === table.pagination.perPageCount) {
76284
+ const updateRows = [];
76285
+ for (let row = rowNum; row < newRowCount; row++) {
76286
+ if (table.transpose) {
76287
+ updateRows.push({ col: row, row: 0 });
76288
+ }
76289
+ else {
76290
+ updateRows.push({ col: 0, row });
76291
+ }
76229
76292
  }
76230
- else {
76231
- addRows.push({ col: 0, row });
76293
+ table.transpose
76294
+ ? table.scenegraph.updateCol([], [], updateRows)
76295
+ : table.scenegraph.updateRow([], [], updateRows);
76296
+ }
76297
+ else {
76298
+ const addRows = [];
76299
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + (Array.isArray(records) ? records.length : 1)); row++) {
76300
+ if (table.transpose) {
76301
+ addRows.push({ col: row, row: 0 });
76302
+ }
76303
+ else {
76304
+ addRows.push({ col: 0, row });
76305
+ }
76232
76306
  }
76307
+ table.transpose
76308
+ ? table.scenegraph.updateCol([], addRows, [])
76309
+ : table.scenegraph.updateRow([], addRows, []);
76233
76310
  }
76234
- table.transpose ? table.scenegraph.updateCol([], addRows, []) : table.scenegraph.updateRow([], addRows, []);
76235
76311
  }
76236
76312
  }
76237
76313
  }
76238
- }
76239
- else {
76240
- const addRows = [];
76241
- for (let row = recordIndex + headerCount; row < recordIndex + headerCount + (Array.isArray(records) ? records.length : 1); row++) {
76242
- if (table.transpose) {
76243
- addRows.push({ col: row, row: 0 });
76244
- }
76245
- else {
76246
- addRows.push({ col: 0, row });
76247
- }
76248
- }
76249
- const topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount;
76250
- const bottomAggregationCount = table.internalProps.layoutMap.hasAggregationOnBottomCount;
76251
- const updateRows = [];
76252
- for (let row = headerCount; row < headerCount + topAggregationCount; row++) {
76253
- if (table.transpose) {
76254
- updateRows.push({ col: row, row: 0 });
76255
- }
76256
- else {
76257
- updateRows.push({ col: 0, row });
76314
+ else {
76315
+ const addRows = [];
76316
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + (Array.isArray(records) ? records.length : 1); row++) {
76317
+ if (table.transpose) {
76318
+ addRows.push({ col: row, row: 0 });
76319
+ }
76320
+ else {
76321
+ addRows.push({ col: 0, row });
76322
+ }
76258
76323
  }
76259
- }
76260
- for (let row = (table.transpose ? table.colCount : table.rowCount) - bottomAggregationCount; row < (table.transpose ? table.colCount : table.rowCount); row++) {
76261
- if (table.transpose) {
76262
- updateRows.push({ col: row, row: 0 });
76324
+ const topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount;
76325
+ const bottomAggregationCount = table.internalProps.layoutMap.hasAggregationOnBottomCount;
76326
+ const updateRows = [];
76327
+ for (let row = headerCount; row < headerCount + topAggregationCount; row++) {
76328
+ if (table.transpose) {
76329
+ updateRows.push({ col: row, row: 0 });
76330
+ }
76331
+ else {
76332
+ updateRows.push({ col: 0, row });
76333
+ }
76263
76334
  }
76264
- else {
76265
- updateRows.push({ col: 0, row });
76335
+ for (let row = (table.transpose ? table.colCount : table.rowCount) - bottomAggregationCount; row < (table.transpose ? table.colCount : table.rowCount); row++) {
76336
+ if (table.transpose) {
76337
+ updateRows.push({ col: row, row: 0 });
76338
+ }
76339
+ else {
76340
+ updateRows.push({ col: 0, row });
76341
+ }
76266
76342
  }
76343
+ table.transpose
76344
+ ? table.scenegraph.updateCol([], addRows, updateRows)
76345
+ : table.scenegraph.updateRow([], addRows, updateRows);
76267
76346
  }
76268
- table.transpose
76269
- ? table.scenegraph.updateCol([], addRows, updateRows)
76270
- : table.scenegraph.updateRow([], addRows, updateRows);
76271
76347
  }
76348
+ return true;
76349
+ }
76350
+ catch (error) {
76351
+ return false;
76272
76352
  }
76273
76353
  }
76274
76354
  function listTableDeleteRecords(recordIndexs, table) {
@@ -76881,37 +76961,57 @@
76881
76961
  this.renderAsync();
76882
76962
  this.eventManager.updateEventBinder();
76883
76963
  }
76884
- addColumn(column, colIndex, isMaintainArrayData = true) {
76964
+ addColumns(toAddColumns, colIndex, isMaintainArrayData = true) {
76885
76965
  const columns = this.options.columns;
76886
76966
  if (colIndex === undefined) {
76887
- columns.push(column);
76967
+ colIndex = columns.length;
76968
+ columns.push(...toAddColumns);
76888
76969
  }
76889
76970
  else {
76890
- if (isMaintainArrayData) {
76891
- for (let i = 0; i < columns.length; i++) {
76892
- if (typeof columns[i].field === 'number') {
76893
- if (columns[i].field >= colIndex) {
76894
- columns[i].field = columns[i].field + 1;
76895
- }
76896
- }
76897
- }
76898
- }
76899
- columns.splice(colIndex, 0, column);
76971
+ columns.splice(colIndex, 0, ...toAddColumns);
76900
76972
  }
76901
76973
  if (isMaintainArrayData) {
76974
+ for (let i = 0; i < columns.length; i++) {
76975
+ columns[i].field = i;
76976
+ }
76902
76977
  for (let i = 0; i < this.records.length; i++) {
76903
76978
  const record = this.records[i];
76904
76979
  if (Array.isArray(record)) {
76905
- record.splice(colIndex, 0, undefined);
76980
+ record.splice(colIndex, 0, ...Array(toAddColumns.length).fill(undefined));
76906
76981
  }
76907
76982
  }
76908
76983
  }
76909
76984
  this.updateColumns(columns);
76985
+ this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
76986
+ columnIndex: colIndex,
76987
+ columnCount: toAddColumns.length,
76988
+ columns
76989
+ });
76910
76990
  }
76911
- deleteColumn(colIndex) {
76991
+ deleteColumns(deleteColIndexs, isMaintainArrayData = true) {
76912
76992
  const columns = this.options.columns;
76913
- columns.splice(colIndex, 1);
76993
+ deleteColIndexs.sort((a, b) => b - a);
76994
+ for (let i = 0; i < deleteColIndexs.length; i++) {
76995
+ columns.splice(deleteColIndexs[i], 1);
76996
+ if (isMaintainArrayData) {
76997
+ for (let j = 0; j < this.records.length; j++) {
76998
+ const record = this.records[j];
76999
+ if (Array.isArray(record)) {
77000
+ record.splice(deleteColIndexs[i], 1);
77001
+ }
77002
+ }
77003
+ }
77004
+ }
77005
+ if (isMaintainArrayData) {
77006
+ for (let i = 0; i < columns.length; i++) {
77007
+ columns[i].field = i;
77008
+ }
77009
+ }
76914
77010
  this.updateColumns(columns);
77011
+ this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
77012
+ deleteColIndexs: deleteColIndexs,
77013
+ columns
77014
+ });
76915
77015
  }
76916
77016
  get columns() {
76917
77017
  return this.internalProps.layoutMap.columnTree.getCopiedTree();
@@ -77575,6 +77675,9 @@
77575
77675
  this.scenegraph.createSceneGraph();
77576
77676
  this.resize();
77577
77677
  }
77678
+ getFilteredRecords() {
77679
+ return this.dataSource.records;
77680
+ }
77578
77681
  getCheckboxState(field) {
77579
77682
  if (this.stateManager.checkedState.size < this.rowCount - this.columnHeaderLevelCount) {
77580
77683
  this.stateManager.initLeftRecordsCheckState(this.records);
@@ -77777,19 +77880,49 @@
77777
77880
  return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this);
77778
77881
  }
77779
77882
  addRecord(record, recordIndex) {
77780
- listTableAddRecord(record, recordIndex, this);
77883
+ const success = listTableAddRecord(record, recordIndex, this);
77781
77884
  this.internalProps.emptyTip?.resetVisible();
77885
+ if (success) {
77886
+ this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
77887
+ records: [record],
77888
+ recordIndex,
77889
+ recordCount: 1
77890
+ });
77891
+ }
77782
77892
  }
77783
77893
  addRecords(records, recordIndex) {
77784
- listTableAddRecords(records, recordIndex, this);
77894
+ const success = listTableAddRecords(records, recordIndex, this);
77785
77895
  this.internalProps.emptyTip?.resetVisible();
77896
+ if (success) {
77897
+ this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
77898
+ records,
77899
+ recordIndex,
77900
+ recordCount: records.length
77901
+ });
77902
+ }
77786
77903
  }
77787
77904
  deleteRecords(recordIndexs) {
77788
77905
  listTableDeleteRecords(recordIndexs, this);
77789
77906
  this.internalProps.emptyTip?.resetVisible();
77907
+ const rowIndexs = [];
77908
+ for (let i = 0; i < recordIndexs.length; i++) {
77909
+ rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
77910
+ }
77911
+ this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
77912
+ recordIndexs,
77913
+ rowIndexs,
77914
+ deletedCount: Array.isArray(recordIndexs[0])
77915
+ ? recordIndexs.length
77916
+ : recordIndexs.length
77917
+ });
77790
77918
  }
77791
77919
  updateRecords(records, recordIndexs) {
77792
77920
  listTableUpdateRecords(records, recordIndexs, this);
77921
+ this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
77922
+ records,
77923
+ recordIndexs,
77924
+ updateCount: records.length
77925
+ });
77793
77926
  }
77794
77927
  _hasCustomRenderOrLayout() {
77795
77928
  const { headerObjects } = this.internalProps.layoutMap;
@@ -83676,6 +83809,17 @@
83676
83809
  else {
83677
83810
  height = table.getRowHeight(row);
83678
83811
  }
83812
+ if (table.pluginManager) {
83813
+ const masterDetailPlugin = table.pluginManager.getPluginByName('Master Detail Plugin');
83814
+ if (masterDetailPlugin) {
83815
+ const bodyRowIndex = row - table.columnHeaderLevelCount;
83816
+ const internalProps = table.internalProps;
83817
+ const originalHeight = internalProps?.originalRowHeights?.get(bodyRowIndex);
83818
+ if (originalHeight !== undefined && originalHeight > 0) {
83819
+ height = originalHeight;
83820
+ }
83821
+ }
83822
+ }
83679
83823
  let contentWidth = width;
83680
83824
  let contentHeight = height;
83681
83825
  let _contentOffset = 0;
@@ -91546,7 +91690,7 @@
91546
91690
  this.renderWithRecreateCells();
91547
91691
  }
91548
91692
  getFilteredRecords() {
91549
- return this.dataset?.filterRules;
91693
+ return this.dataset?.filteredRecords;
91550
91694
  }
91551
91695
  getCellPivotRole(col, row) {
91552
91696
  const path = this.getCellHeaderPaths(col, row);
@@ -93426,7 +93570,7 @@
93426
93570
  }
93427
93571
 
93428
93572
  registerForVrender();
93429
- const version = "1.21.1";
93573
+ const version = "1.22.0";
93430
93574
  function getIcons() {
93431
93575
  return get$2();
93432
93576
  }