@visactor/vtable 1.22.11-alpha.3 → 1.22.11-alpha.5

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 (87) hide show
  1. package/cjs/ListTable.d.ts +34 -7
  2. package/cjs/ListTable.js +134 -14
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/core/BaseTable.js +1 -1
  5. package/cjs/core/BaseTable.js.map +1 -1
  6. package/cjs/core/TABLE_EVENT_TYPE.d.ts +1 -0
  7. package/cjs/core/TABLE_EVENT_TYPE.js +1 -0
  8. package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
  9. package/cjs/core/index.d.ts +1 -0
  10. package/cjs/core/index.js +30 -0
  11. package/cjs/core/index.js.map +1 -0
  12. package/cjs/core/record-helper.d.ts +4 -2
  13. package/cjs/core/record-helper.js +81 -24
  14. package/cjs/core/record-helper.js.map +1 -1
  15. package/cjs/data/DataSource.d.ts +1 -0
  16. package/cjs/data/DataSource.js +25 -3
  17. package/cjs/data/DataSource.js.map +1 -1
  18. package/cjs/dataset/DataStatistics.js +1 -2
  19. package/cjs/dataset/dataset-pivot-table.js +2 -1
  20. package/cjs/edit/edit-manager.js +1 -1
  21. package/cjs/edit/editors.js +1 -1
  22. package/cjs/event/event.d.ts +2 -1
  23. package/cjs/event/event.js +20 -9
  24. package/cjs/event/event.js.map +1 -1
  25. package/cjs/header-helper/style.js +1 -2
  26. package/cjs/index.d.ts +1 -1
  27. package/cjs/index.js +1 -1
  28. package/cjs/index.js.map +1 -1
  29. package/cjs/layout/pivot-header-layout.js +1 -0
  30. package/cjs/plugins/custom-cell-style.d.ts +5 -0
  31. package/cjs/plugins/custom-cell-style.js +9 -0
  32. package/cjs/plugins/custom-cell-style.js.map +1 -1
  33. package/cjs/plugins/index.js +1 -1
  34. package/cjs/plugins/interface.js +1 -1
  35. package/cjs/plugins/invert-highlight.js +1 -1
  36. package/cjs/ts-types/base-table.d.ts +2 -2
  37. package/cjs/ts-types/base-table.js.map +1 -1
  38. package/cjs/ts-types/events.d.ts +15 -0
  39. package/cjs/ts-types/events.js.map +1 -1
  40. package/cjs/ts-types/table-engine.d.ts +32 -6
  41. package/cjs/ts-types/table-engine.js.map +1 -1
  42. package/cjs/vrender.js.map +1 -1
  43. package/dist/vtable.js +375 -48
  44. package/dist/vtable.min.js +2 -2
  45. package/es/ListTable.d.ts +34 -7
  46. package/es/ListTable.js +130 -14
  47. package/es/ListTable.js.map +1 -1
  48. package/es/core/BaseTable.js +1 -1
  49. package/es/core/BaseTable.js.map +1 -1
  50. package/es/core/TABLE_EVENT_TYPE.d.ts +1 -0
  51. package/es/core/TABLE_EVENT_TYPE.js +1 -0
  52. package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
  53. package/es/core/index.d.ts +1 -0
  54. package/es/core/index.js +2 -0
  55. package/es/core/index.js.map +1 -0
  56. package/es/core/record-helper.d.ts +4 -2
  57. package/es/core/record-helper.js +75 -20
  58. package/es/core/record-helper.js.map +1 -1
  59. package/es/data/DataSource.d.ts +1 -0
  60. package/es/data/DataSource.js +25 -3
  61. package/es/data/DataSource.js.map +1 -1
  62. package/es/dataset/DataStatistics.js +1 -2
  63. package/es/dataset/dataset-pivot-table.js +2 -1
  64. package/es/edit/edit-manager.js +1 -1
  65. package/es/edit/editors.js +1 -1
  66. package/es/event/event.d.ts +2 -1
  67. package/es/event/event.js +20 -9
  68. package/es/event/event.js.map +1 -1
  69. package/es/header-helper/style.js +1 -2
  70. package/es/index.d.ts +1 -1
  71. package/es/index.js +1 -1
  72. package/es/index.js.map +1 -1
  73. package/es/layout/pivot-header-layout.js +2 -1
  74. package/es/plugins/custom-cell-style.d.ts +5 -0
  75. package/es/plugins/custom-cell-style.js +9 -0
  76. package/es/plugins/custom-cell-style.js.map +1 -1
  77. package/es/plugins/index.js +1 -1
  78. package/es/plugins/interface.js +1 -1
  79. package/es/plugins/invert-highlight.js +1 -1
  80. package/es/ts-types/base-table.d.ts +2 -2
  81. package/es/ts-types/base-table.js.map +1 -1
  82. package/es/ts-types/events.d.ts +15 -0
  83. package/es/ts-types/events.js.map +1 -1
  84. package/es/ts-types/table-engine.d.ts +32 -6
  85. package/es/ts-types/table-engine.js.map +1 -1
  86. package/es/vrender.js.map +1 -1
  87. package/package.json +4 -4
package/dist/vtable.js CHANGED
@@ -36410,6 +36410,7 @@
36410
36410
  AFTER_UPDATE_CELL_CONTENT_WIDTH: 'after_update_cell_content_width',
36411
36411
  AFTER_UPDATE_SELECT_BORDER_HEIGHT: 'after_update_select_border_height',
36412
36412
  CHANGE_CELL_VALUE: 'change_cell_value',
36413
+ CHANGE_CELL_VALUES: 'change_cell_values',
36413
36414
  DRAG_FILL_HANDLE_END: 'drag_fill_handle_end',
36414
36415
  MOUSEDOWN_FILL_HANDLE: 'mousedown_fill_handle',
36415
36416
  DBLCLICK_FILL_HANDLE: 'dblclick_fill_handle',
@@ -38926,6 +38927,48 @@
38926
38927
  }
38927
38928
  }
38928
38929
  }
38930
+ changeFieldValueByRecordIndex(value, recordIndex, field, table) {
38931
+ if (field === null) {
38932
+ return undefined;
38933
+ }
38934
+ if (recordIndex === undefined || recordIndex === null) {
38935
+ return;
38936
+ }
38937
+ const rawKey = recordIndex.toString();
38938
+ if (!this.beforeChangedRecordsMap.has(rawKey)) {
38939
+ const rawRecords = Array.isArray(this.dataSourceObj?.records)
38940
+ ? this.dataSourceObj.records
38941
+ : null;
38942
+ const originRecord = rawRecords
38943
+ ? Array.isArray(recordIndex)
38944
+ ? getValueFromDeepArray(rawRecords, recordIndex)
38945
+ : rawRecords[recordIndex]
38946
+ : undefined;
38947
+ this.beforeChangedRecordsMap.set(rawKey, cloneDeep(originRecord, undefined, ['vtable_gantt_linkedFrom', 'vtable_gantt_linkedTo']) ?? {});
38948
+ }
38949
+ if (typeof field === 'string' || typeof field === 'number') {
38950
+ const beforeChangedValue = this.beforeChangedRecordsMap.get(rawKey)?.[field];
38951
+ const rawRecords = Array.isArray(this.dataSourceObj?.records)
38952
+ ? this.dataSourceObj.records
38953
+ : null;
38954
+ const record = rawRecords
38955
+ ? Array.isArray(recordIndex)
38956
+ ? getValueFromDeepArray(rawRecords, recordIndex)
38957
+ : rawRecords[recordIndex]
38958
+ : undefined;
38959
+ let formatValue = value;
38960
+ if (typeof beforeChangedValue === 'number' && isAllDigits(value)) {
38961
+ formatValue = parseFloat(value);
38962
+ }
38963
+ if (record) {
38964
+ record[field] = formatValue;
38965
+ }
38966
+ else if (rawRecords && typeof recordIndex === 'number') {
38967
+ rawRecords[recordIndex] = this.addRecordRule === 'Array' ? [] : {};
38968
+ rawRecords[recordIndex][field] = formatValue;
38969
+ }
38970
+ }
38971
+ }
38929
38972
  cacheBeforeChangedRecord(dataIndex, table) {
38930
38973
  if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
38931
38974
  const originRecord = this.getOriginalRecord(dataIndex);
@@ -39047,11 +39090,20 @@
39047
39090
  }
39048
39091
  }
39049
39092
  adjustBeforeChangedRecordsMap(insertIndex, insertCount, type = 'add') {
39050
- const length = this.beforeChangedRecordsMap.size;
39051
- for (let key = length - 1; key >= insertIndex; key--) {
39093
+ const delta = type === 'add' ? insertCount : -insertCount;
39094
+ const numericKeys = [];
39095
+ this.beforeChangedRecordsMap.forEach((_, key) => {
39096
+ const numKey = Number(key);
39097
+ if (Number.isInteger(numKey) && numKey.toString() === key && numKey >= insertIndex) {
39098
+ numericKeys.push(numKey);
39099
+ }
39100
+ });
39101
+ numericKeys.sort((a, b) => (type === 'add' ? b - a : a - b));
39102
+ for (let i = 0; i < numericKeys.length; i++) {
39103
+ const key = numericKeys[i];
39052
39104
  const record = this.beforeChangedRecordsMap.get(key.toString());
39053
39105
  this.beforeChangedRecordsMap.delete(key.toString());
39054
- this.beforeChangedRecordsMap.set((key + (type === 'add' ? insertCount : -insertCount)).toString(), record);
39106
+ this.beforeChangedRecordsMap.set((key + delta).toString(), record);
39055
39107
  }
39056
39108
  }
39057
39109
  deleteRecords(recordIndexs) {
@@ -39218,7 +39270,11 @@
39218
39270
  }
39219
39271
  }
39220
39272
  if (!filedMapArray.length) {
39221
- filedMapArray = states.map(() => ({ asc: [], desc: [], normal: [] }));
39273
+ filedMapArray = states.map(() => ({
39274
+ asc: [],
39275
+ desc: [],
39276
+ normal: []
39277
+ }));
39222
39278
  for (let index = 0; index < states.length; index++) {
39223
39279
  this.sortedIndexMap.set(states[index].field, filedMapArray[index]);
39224
39280
  }
@@ -65449,6 +65505,7 @@
65449
65505
  cutOperationTime = 0;
65450
65506
  lastClipboardContent = '';
65451
65507
  cutCellRange = null;
65508
+ cutRanges = null;
65452
65509
  copySourceRange = null;
65453
65510
  constructor(table) {
65454
65511
  this.table = table;
@@ -65576,7 +65633,7 @@
65576
65633
  }
65577
65634
  const shiftMultiSelect = this.table.keyboardOptions?.shiftMultiSelect ?? true;
65578
65635
  const ctrlMultiSelect = this.table.keyboardOptions?.ctrlMultiSelect ?? true;
65579
- this.table.stateManager.updateSelectPos(this.table.stateManager.select.selectInline === 'row' ? this.table.colCount - 1 : eventArgs.col, this.table.stateManager.select.selectInline === 'col' ? this.table.rowCount - 1 : eventArgs.row, eventArgs.event.shiftKey && shiftMultiSelect, (eventArgs.event.ctrlKey || eventArgs.event.metaKey) && ctrlMultiSelect, false, isSelectMoving ? false : (this.table.options.select?.makeSelectCellVisible ?? true));
65636
+ this.table.stateManager.updateSelectPos(this.table.stateManager.select.selectInline === 'row' ? this.table.colCount - 1 : eventArgs.col, this.table.stateManager.select.selectInline === 'col' ? this.table.rowCount - 1 : eventArgs.row, eventArgs.event.shiftKey && shiftMultiSelect, (eventArgs.event.ctrlKey || eventArgs.event.metaKey) && ctrlMultiSelect, false, isSelectMoving ? false : this.table.options.select?.makeSelectCellVisible ?? true);
65580
65637
  return true;
65581
65638
  }
65582
65639
  return false;
@@ -65968,6 +66025,10 @@
65968
66025
  this.handleCopy(e, true);
65969
66026
  this.cutWaitPaste = true;
65970
66027
  this.cutCellRange = this.table.getSelectedCellInfos();
66028
+ this.cutRanges = this.table.stateManager.select.ranges?.map(r => ({
66029
+ start: { col: r.start.col, row: r.start.row },
66030
+ end: { col: r.end.col, row: r.end.row }
66031
+ }));
65971
66032
  if (this.clipboardCheckTimer) {
65972
66033
  clearTimeout(this.clipboardCheckTimer);
65973
66034
  }
@@ -65975,6 +66036,7 @@
65975
66036
  if (this.cutWaitPaste) {
65976
66037
  this.cutWaitPaste = false;
65977
66038
  this.cutCellRange = null;
66039
+ this.cutRanges = null;
65978
66040
  this.clipboardCheckTimer = null;
65979
66041
  }
65980
66042
  }, 30000);
@@ -65994,6 +66056,7 @@
65994
66056
  if (this.cutWaitPaste) {
65995
66057
  this.cutWaitPaste = false;
65996
66058
  this.cutCellRange = null;
66059
+ this.cutRanges = null;
65997
66060
  if (this.clipboardCheckTimer) {
65998
66061
  clearTimeout(this.clipboardCheckTimer);
65999
66062
  this.clipboardCheckTimer = null;
@@ -66109,17 +66172,11 @@
66109
66172
  }
66110
66173
  clearCutArea(table) {
66111
66174
  try {
66112
- const selectCells = this.cutCellRange;
66113
- if (!selectCells || selectCells.length === 0) {
66175
+ const ranges = this.cutRanges;
66176
+ if (!ranges || ranges.length === 0) {
66114
66177
  return;
66115
66178
  }
66116
- for (let i = 0; i < selectCells.length; i++) {
66117
- for (let j = 0; j < selectCells[i].length; j++) {
66118
- if (selectCells[i][j]) {
66119
- table.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, undefined);
66120
- }
66121
- }
66122
- }
66179
+ table.changeCellValuesByIds(ranges, '');
66123
66180
  }
66124
66181
  catch (error) {
66125
66182
  }
@@ -69641,6 +69698,15 @@
69641
69698
  this.customCellStyle = customCellStyle;
69642
69699
  this.customCellStyleArrangement = customCellStyleArrangement;
69643
69700
  }
69701
+ clearCustomCellStyleArrangement() {
69702
+ this.customCellStyleArrangement = [];
69703
+ }
69704
+ addCustomCellStyleArrangement(cellPosition, customStyleId) {
69705
+ this.customCellStyleArrangement.push({
69706
+ cellPosition,
69707
+ customStyleId
69708
+ });
69709
+ }
69644
69710
  getCustomCellStyle(col, row) {
69645
69711
  const customStyleIds = this.getCustomCellStyleIds(col, row);
69646
69712
  if (customStyleIds.length) {
@@ -70169,7 +70235,7 @@
70169
70235
  return TABLE_EVENT_TYPE;
70170
70236
  }
70171
70237
  options;
70172
- version = "1.22.11-alpha.3";
70238
+ version = "1.22.11-alpha.5";
70173
70239
  pagination;
70174
70240
  id = `VTable${Date.now()}`;
70175
70241
  headerStyleCache;
@@ -76207,9 +76273,10 @@
76207
76273
  return { addRecordRule };
76208
76274
  }
76209
76275
 
76210
- function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table) {
76276
+ function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
76211
76277
  if ((workOnEditableCell && table.isHasEditorDefine(col, row)) || workOnEditableCell === false) {
76212
- const recordIndex = table.getRecordShowIndexByCell(col, row);
76278
+ const recordShowIndex = table.getRecordShowIndexByCell(col, row);
76279
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : undefined;
76213
76280
  const { field } = table.internalProps.layoutMap.getBody(col, row);
76214
76281
  const beforeChangeValue = table.getCellRawValue(col, row);
76215
76282
  const oldValue = table.getCellOriginValue(col, row);
@@ -76217,7 +76284,7 @@
76217
76284
  table.internalProps.layoutMap.updateColumnTitle(col, row, value);
76218
76285
  }
76219
76286
  else {
76220
- table.dataSource.changeFieldValue(value, recordIndex, field, col, row, table);
76287
+ table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
76221
76288
  }
76222
76289
  const range = table.getCellRange(col, row);
76223
76290
  const aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
@@ -76270,18 +76337,24 @@
76270
76337
  }
76271
76338
  const changedValue = table.getCellOriginValue(col, row);
76272
76339
  if (oldValue !== changedValue && triggerEvent) {
76273
- table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
76340
+ const changeValue = {
76274
76341
  col,
76275
76342
  row,
76343
+ recordIndex,
76344
+ field,
76276
76345
  rawValue: beforeChangeValue,
76277
76346
  currentValue: oldValue,
76278
76347
  changedValue
76279
- });
76348
+ };
76349
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue);
76350
+ if (!silentChangeCellValuesEvent) {
76351
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: [changeValue] });
76352
+ }
76280
76353
  }
76281
76354
  table.scenegraph.updateNextFrame();
76282
76355
  }
76283
76356
  }
76284
- async function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table) {
76357
+ async function listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
76285
76358
  const changedCellResults = [];
76286
76359
  let pasteColEnd = startCol;
76287
76360
  let pasteRowEnd = startRow;
@@ -76308,6 +76381,7 @@
76308
76381
  oldRowValues.push(oldValue);
76309
76382
  }
76310
76383
  }
76384
+ const resultChangeValues = [];
76311
76385
  for (let i = 0; i < values.length; i++) {
76312
76386
  if (startRow + i > table.rowCount - 1) {
76313
76387
  break;
@@ -76347,7 +76421,8 @@
76347
76421
  if (isCanChange) {
76348
76422
  changedCellResults[i][j] = true;
76349
76423
  const value = rowValues[j];
76350
- const recordIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i);
76424
+ const recordShowIndex = table.getRecordShowIndexByCell(startCol + j, startRow + i);
76425
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : undefined;
76351
76426
  const { field } = table.internalProps.layoutMap.getBody(startCol + j, startRow + i);
76352
76427
  const beforeChangeValue = beforeChangeValues[i][j];
76353
76428
  const oldValue = oldValues[i][j];
@@ -76355,17 +76430,21 @@
76355
76430
  table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value);
76356
76431
  }
76357
76432
  else {
76358
- table.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, table);
76433
+ table.dataSource.changeFieldValue(value, recordShowIndex, field, startCol + j, startRow + i, table);
76359
76434
  }
76360
76435
  const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
76361
76436
  if (oldValue !== changedValue && triggerEvent) {
76362
- table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
76437
+ const changeValue = {
76363
76438
  col: startCol + j,
76364
76439
  row: startRow + i,
76440
+ recordIndex,
76441
+ field,
76365
76442
  rawValue: beforeChangeValue,
76366
76443
  currentValue: oldValue,
76367
76444
  changedValue
76368
- });
76445
+ };
76446
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue);
76447
+ resultChangeValues.push(changeValue);
76369
76448
  }
76370
76449
  }
76371
76450
  else {
@@ -76374,6 +76453,9 @@
76374
76453
  }
76375
76454
  pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);
76376
76455
  }
76456
+ if (!silentChangeCellValuesEvent) {
76457
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: resultChangeValues });
76458
+ }
76377
76459
  const startRange = table.getCellRange(startCol, startRow);
76378
76460
  const range = table.getCellRange(pasteColEnd, pasteRowEnd);
76379
76461
  const aggregators = table.internalProps.layoutMap.getAggregatorsByCellRange(startRange.start.col, startRange.start.row, range.end.col, range.end.row);
@@ -76446,6 +76528,68 @@
76446
76528
  table.scenegraph.updateNextFrame();
76447
76529
  return changedCellResults;
76448
76530
  }
76531
+ async function listTableChangeCellValuesByIds(ranges, value, workOnEditableCell, triggerEvent, table, silentChangeCellValuesEvent) {
76532
+ const resultChangeValues = [];
76533
+ const processed = new Set();
76534
+ const nextValue = (value ?? '');
76535
+ for (let i = 0; i < (ranges?.length ?? 0); i++) {
76536
+ const range = ranges[i];
76537
+ const startCol = Math.min(range.start.col, range.end.col);
76538
+ const endCol = Math.max(range.start.col, range.end.col);
76539
+ const startRow = Math.min(range.start.row, range.end.row);
76540
+ const endRow = Math.max(range.start.row, range.end.row);
76541
+ if (startCol > endCol || startRow > endRow) {
76542
+ continue;
76543
+ }
76544
+ const values = [];
76545
+ const oldValues = [];
76546
+ for (let row = startRow; row <= endRow; row++) {
76547
+ const rowValues = [];
76548
+ const rowOldValues = [];
76549
+ for (let col = startCol; col <= endCol; col++) {
76550
+ rowValues.push(nextValue);
76551
+ rowOldValues.push(table.getCellOriginValue(col, row));
76552
+ }
76553
+ values.push(rowValues);
76554
+ oldValues.push(rowOldValues);
76555
+ }
76556
+ const changedCellResults = await listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, table, true);
76557
+ for (let r = 0; r < values.length; r++) {
76558
+ for (let c = 0; c < values[r].length; c++) {
76559
+ const col = startCol + c;
76560
+ const row = startRow + r;
76561
+ const key = `${col},${row}`;
76562
+ if (processed.has(key)) {
76563
+ continue;
76564
+ }
76565
+ processed.add(key);
76566
+ if (!triggerEvent || !changedCellResults?.[r]?.[c]) {
76567
+ continue;
76568
+ }
76569
+ const oldValue = oldValues[r][c];
76570
+ const changedValue = table.getCellOriginValue(col, row);
76571
+ if (oldValue === changedValue) {
76572
+ continue;
76573
+ }
76574
+ const recordShowIndex = table.getRecordShowIndexByCell(col, row);
76575
+ const recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : undefined;
76576
+ const { field } = table.internalProps.layoutMap.getBody(col, row);
76577
+ resultChangeValues.push({
76578
+ col,
76579
+ row,
76580
+ recordIndex,
76581
+ field,
76582
+ rawValue: oldValue,
76583
+ currentValue: oldValue,
76584
+ changedValue
76585
+ });
76586
+ }
76587
+ }
76588
+ }
76589
+ if (!silentChangeCellValuesEvent && triggerEvent) {
76590
+ table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: resultChangeValues });
76591
+ }
76592
+ }
76449
76593
  function getCellUpdateType(col, row, table, oldCellUpdateType) {
76450
76594
  if (oldCellUpdateType === 'group') {
76451
76595
  return oldCellUpdateType;
@@ -78296,17 +78440,182 @@
78296
78440
  }
78297
78441
  return isValid$1(editorDefine);
78298
78442
  }
78299
- changeCellValue(col, row, value, workOnEditableCell = false, triggerEvent = true) {
78300
- return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this);
78443
+ changeCellValue(col, row, value, workOnEditableCell = false, triggerEvent = true, silentChangeCellValuesEvent) {
78444
+ return listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
78445
+ }
78446
+ changeCellValues(startCol, startRow, values, workOnEditableCell = false, triggerEvent = true, silentChangeCellValuesEvent) {
78447
+ return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
78448
+ }
78449
+ changeCellValuesByIds(ranges, value, workOnEditableCell = false, triggerEvent = true, silentChangeCellValuesEvent) {
78450
+ return listTableChangeCellValuesByIds(ranges, value, workOnEditableCell, triggerEvent, this, silentChangeCellValuesEvent);
78451
+ }
78452
+ changeSourceCellValue(recordIndex, field, value) {
78453
+ const tableIndex = this.getTableIndexByRecordIndex(recordIndex);
78454
+ const cellAddr = this.getCellAddrByFieldRecord(field, recordIndex);
78455
+ if (tableIndex < 0 || cellAddr.col < 0 || cellAddr.row < 0) {
78456
+ return;
78457
+ }
78458
+ this.dataSource.changeFieldValue(value, tableIndex, field, cellAddr.col, cellAddr.row, this);
78459
+ const beforeChangeValue = this.getCellRawValue(cellAddr.col, cellAddr.row);
78460
+ const oldValue = this.getCellOriginValue(cellAddr.col, cellAddr.row);
78461
+ const changedValue = this.getCellOriginValue(cellAddr.col, cellAddr.row);
78462
+ if (oldValue !== changedValue) {
78463
+ const changeValue = {
78464
+ col: cellAddr.col,
78465
+ row: cellAddr.row,
78466
+ recordIndex,
78467
+ field,
78468
+ rawValue: beforeChangeValue,
78469
+ currentValue: oldValue,
78470
+ changedValue
78471
+ };
78472
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue);
78473
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: [changeValue] });
78474
+ }
78475
+ }
78476
+ changeCellValueByRecord(recordIndex, field, value, options) {
78477
+ const triggerEvent = options?.triggerEvent ?? true;
78478
+ const silentChangeCellValuesEvent = options?.silentChangeCellValuesEvent;
78479
+ const autoRefresh = options?.autoRefresh ?? true;
78480
+ const records = this.dataSource.dataSourceObj?.records;
78481
+ let record;
78482
+ let oldValue;
78483
+ if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number')) {
78484
+ record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
78485
+ oldValue = record?.[field];
78486
+ }
78487
+ this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this);
78488
+ if (!triggerEvent) {
78489
+ return;
78490
+ }
78491
+ const changedValue = record && (typeof field === 'string' || typeof field === 'number') ? record?.[field] : value;
78492
+ if (oldValue !== changedValue) {
78493
+ const cellAddr = this.getCellAddrByFieldRecord(field, recordIndex);
78494
+ const changeValue = {
78495
+ col: cellAddr?.col ?? -1,
78496
+ row: cellAddr?.row ?? -1,
78497
+ recordIndex,
78498
+ field,
78499
+ rawValue: oldValue,
78500
+ currentValue: oldValue,
78501
+ changedValue
78502
+ };
78503
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue);
78504
+ if (!silentChangeCellValuesEvent) {
78505
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: [changeValue] });
78506
+ }
78507
+ }
78508
+ if (autoRefresh) {
78509
+ this.refreshAfterSourceChange();
78510
+ }
78511
+ }
78512
+ changeCellValueBySource(recordIndex, field, value, triggerEvent = true, silentChangeCellValuesEvent) {
78513
+ return this.changeCellValueByRecord(recordIndex, field, value, {
78514
+ triggerEvent,
78515
+ silentChangeCellValuesEvent,
78516
+ autoRefresh: true
78517
+ });
78301
78518
  }
78302
- changeCellValues(startCol, startRow, values, workOnEditableCell = false, triggerEvent = true) {
78303
- return listTableChangeCellValues(startCol, startRow, values, workOnEditableCell, triggerEvent, this);
78519
+ changeCellValuesByRecords(changeValues, options) {
78520
+ const triggerEvent = options?.triggerEvent ?? true;
78521
+ const silentChangeCellValuesEvent = options?.silentChangeCellValuesEvent;
78522
+ const autoRefresh = options?.autoRefresh ?? true;
78523
+ const resultChangeValues = [];
78524
+ for (let i = 0; i < changeValues.length; i++) {
78525
+ const { recordIndex, field, value } = changeValues[i];
78526
+ const records = this.dataSource.dataSourceObj?.records;
78527
+ let record;
78528
+ let oldValue;
78529
+ if (Array.isArray(records) && (typeof field === 'string' || typeof field === 'number')) {
78530
+ record = Array.isArray(recordIndex) ? getValueFromDeepArray(records, recordIndex) : records[recordIndex];
78531
+ oldValue = record?.[field];
78532
+ }
78533
+ this.dataSource.changeFieldValueByRecordIndex(value, recordIndex, field, this);
78534
+ if (triggerEvent) {
78535
+ const changedValue = record && (typeof field === 'string' || typeof field === 'number') ? record?.[field] : value;
78536
+ if (oldValue !== changedValue) {
78537
+ const changeValue = {
78538
+ col: (this.getCellAddrByFieldRecord(field, recordIndex)?.col ?? -1),
78539
+ row: (this.getCellAddrByFieldRecord(field, recordIndex)?.row ?? -1),
78540
+ recordIndex,
78541
+ field,
78542
+ rawValue: oldValue,
78543
+ currentValue: oldValue,
78544
+ changedValue
78545
+ };
78546
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, changeValue);
78547
+ resultChangeValues.push(changeValue);
78548
+ }
78549
+ }
78550
+ }
78551
+ if (!silentChangeCellValuesEvent && resultChangeValues.length && triggerEvent) {
78552
+ this.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUES, { values: resultChangeValues });
78553
+ }
78554
+ if (autoRefresh) {
78555
+ this.refreshAfterSourceChange();
78556
+ }
78557
+ }
78558
+ changeCellValuesBySource(changeValues, triggerEvent = true, silentChangeCellValuesEvent) {
78559
+ return this.changeCellValuesByRecords(changeValues, {
78560
+ triggerEvent,
78561
+ silentChangeCellValuesEvent,
78562
+ autoRefresh: true
78563
+ });
78564
+ }
78565
+ refreshAfterSourceChange(options) {
78566
+ const reapplyFilter = options?.reapplyFilter ?? true;
78567
+ const reapplySort = options?.reapplySort ?? true;
78568
+ const clearRowHeightCache = options?.clearRowHeightCache ?? true;
78569
+ this.scenegraph.clearCells();
78570
+ if (this.sortState && reapplySort) {
78571
+ this.dataSource.clearSortedIndexMap?.();
78572
+ this.dataSource.sortedIndexMap?.clear?.();
78573
+ }
78574
+ if (reapplyFilter) {
78575
+ if (this.sortState && reapplySort) {
78576
+ this.dataSource.updateFilterRulesForSorted(this.dataSource.dataConfig?.filterRules);
78577
+ sortRecords(this);
78578
+ }
78579
+ else {
78580
+ this.dataSource.updateFilterRules(this.dataSource.dataConfig?.filterRules);
78581
+ }
78582
+ }
78583
+ else if (this.sortState && reapplySort) {
78584
+ sortRecords(this);
78585
+ }
78586
+ const traverseColumns = (columns) => {
78587
+ for (let i = 0; i < (columns?.length ?? 0); i++) {
78588
+ const column = columns[i];
78589
+ const aggregators = column?.vtable_aggregator;
78590
+ if (aggregators) {
78591
+ if (Array.isArray(aggregators)) {
78592
+ for (let j = 0; j < aggregators.length; j++) {
78593
+ aggregators[j]?.recalculate?.();
78594
+ }
78595
+ }
78596
+ else {
78597
+ aggregators?.recalculate?.();
78598
+ }
78599
+ }
78600
+ if (column?.columns) {
78601
+ traverseColumns(column.columns);
78602
+ }
78603
+ }
78604
+ };
78605
+ traverseColumns(this.internalProps.columns);
78606
+ this.refreshRowColCount();
78607
+ this.internalProps.layoutMap.clearCellRangeMap();
78608
+ this.internalProps.useOneRowHeightFillAll = false;
78609
+ this.stateManager.initCheckedState(this.records);
78610
+ this.scenegraph.createSceneGraph(!clearRowHeightCache);
78611
+ this.internalProps.emptyTip?.resetVisible();
78612
+ this.resize();
78304
78613
  }
78305
- addRecord(record, recordIndex) {
78614
+ addRecord(record, recordIndex, triggerEvent = true) {
78306
78615
  const success = listTableAddRecord(record, recordIndex, this);
78307
78616
  adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]);
78308
78617
  this.internalProps.emptyTip?.resetVisible();
78309
- if (success) {
78618
+ if (triggerEvent && success) {
78310
78619
  this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
78311
78620
  records: [record],
78312
78621
  recordIndex,
@@ -78314,13 +78623,13 @@
78314
78623
  });
78315
78624
  }
78316
78625
  }
78317
- addRecords(records, recordIndex) {
78626
+ addRecords(records, recordIndex, triggerEvent = true) {
78318
78627
  const success = listTableAddRecords(records, recordIndex, this);
78319
78628
  if (typeof recordIndex === 'number') {
78320
78629
  adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records);
78321
78630
  }
78322
78631
  this.internalProps.emptyTip?.resetVisible();
78323
- if (success) {
78632
+ if (triggerEvent && success) {
78324
78633
  this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
78325
78634
  records,
78326
78635
  recordIndex,
@@ -78328,7 +78637,20 @@
78328
78637
  });
78329
78638
  }
78330
78639
  }
78331
- deleteRecords(recordIndexs) {
78640
+ deleteRecords(recordIndexs, triggerEvent = true) {
78641
+ const deletedRecords = [];
78642
+ if (recordIndexs?.length > 0) {
78643
+ recordIndexs.forEach(index => {
78644
+ let record = null;
78645
+ if (typeof index === 'number') {
78646
+ record = this.dataSource.get(index);
78647
+ }
78648
+ else {
78649
+ record = [];
78650
+ }
78651
+ deletedRecords.push(record);
78652
+ });
78653
+ }
78332
78654
  listTableDeleteRecords(recordIndexs, this);
78333
78655
  adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs);
78334
78656
  this.internalProps.emptyTip?.resetVisible();
@@ -78336,21 +78658,26 @@
78336
78658
  for (let i = 0; i < recordIndexs.length; i++) {
78337
78659
  rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
78338
78660
  }
78339
- this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
78340
- recordIndexs,
78341
- rowIndexs,
78342
- deletedCount: Array.isArray(recordIndexs[0])
78343
- ? recordIndexs.length
78344
- : recordIndexs.length
78345
- });
78661
+ if (triggerEvent) {
78662
+ this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
78663
+ recordIndexs,
78664
+ records: deletedRecords,
78665
+ rowIndexs,
78666
+ deletedCount: Array.isArray(recordIndexs[0])
78667
+ ? recordIndexs.length
78668
+ : recordIndexs.length
78669
+ });
78670
+ }
78346
78671
  }
78347
- updateRecords(records, recordIndexs) {
78672
+ updateRecords(records, recordIndexs, triggerEvent = true) {
78348
78673
  listTableUpdateRecords(records, recordIndexs, this);
78349
- this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
78350
- records,
78351
- recordIndexs,
78352
- updateCount: records.length
78353
- });
78674
+ if (triggerEvent) {
78675
+ this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
78676
+ records,
78677
+ recordIndexs,
78678
+ updateCount: records.length
78679
+ });
78680
+ }
78354
78681
  }
78355
78682
  _hasCustomRenderOrLayout() {
78356
78683
  const { headerObjects } = this.internalProps.layoutMap;
@@ -93315,7 +93642,7 @@
93315
93642
  }
93316
93643
 
93317
93644
  registerForVrender();
93318
- const version = "1.22.11-alpha.3";
93645
+ const version = "1.22.11-alpha.5";
93319
93646
  function getIcons() {
93320
93647
  return get$2();
93321
93648
  }