@visactor/vtable 0.15.5-alpha.4 → 0.16.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 (161) hide show
  1. package/cjs/ListTable.d.ts +5 -2
  2. package/cjs/ListTable.js +163 -17
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/PivotChart.d.ts +1 -1
  5. package/cjs/PivotChart.js +8 -8
  6. package/cjs/PivotChart.js.map +1 -1
  7. package/cjs/PivotTable.d.ts +1 -1
  8. package/cjs/PivotTable.js +8 -8
  9. package/cjs/PivotTable.js.map +1 -1
  10. package/cjs/components/axis/axis.d.ts +1 -1
  11. package/cjs/components/axis/axis.js +16 -7
  12. package/cjs/components/axis/axis.js.map +1 -1
  13. package/cjs/components/axis/get-axis-attributes.d.ts +1 -0
  14. package/cjs/components/axis/get-axis-attributes.js +29 -2
  15. package/cjs/components/axis/get-axis-attributes.js.map +1 -1
  16. package/cjs/components/menu/dom/logic/MenuElement.js +3 -3
  17. package/cjs/components/menu/dom/logic/MenuElement.js.map +1 -1
  18. package/cjs/core/BaseTable.d.ts +1 -1
  19. package/cjs/core/BaseTable.js +6 -6
  20. package/cjs/core/BaseTable.js.map +1 -1
  21. package/cjs/core/tableHelper.d.ts +2 -0
  22. package/cjs/core/tableHelper.js +18 -3
  23. package/cjs/core/tableHelper.js.map +1 -1
  24. package/cjs/data/DataSource.d.ts +8 -1
  25. package/cjs/data/DataSource.js +59 -2
  26. package/cjs/data/DataSource.js.map +1 -1
  27. package/cjs/event/event.d.ts +2 -0
  28. package/cjs/event/event.js +10 -2
  29. package/cjs/event/event.js.map +1 -1
  30. package/cjs/index.d.ts +1 -1
  31. package/cjs/index.js +1 -1
  32. package/cjs/index.js.map +1 -1
  33. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js +6 -2
  34. package/cjs/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  35. package/cjs/scenegraph/graphic/contributions/index.js +9 -9
  36. package/cjs/scenegraph/graphic/contributions/index.js.map +1 -1
  37. package/cjs/scenegraph/group-creater/cell-helper.js +1 -1
  38. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  39. package/cjs/scenegraph/group-creater/column.d.ts +0 -4
  40. package/cjs/scenegraph/group-creater/column.js +1 -19
  41. package/cjs/scenegraph/group-creater/column.js.map +1 -1
  42. package/cjs/scenegraph/group-creater/progress/proxy.d.ts +2 -0
  43. package/cjs/scenegraph/group-creater/progress/proxy.js +15 -1
  44. package/cjs/scenegraph/group-creater/progress/proxy.js.map +1 -1
  45. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +4 -0
  46. package/cjs/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  47. package/cjs/scenegraph/layout/auto-height.d.ts +1 -2
  48. package/cjs/scenegraph/layout/auto-height.js +1 -36
  49. package/cjs/scenegraph/layout/auto-height.js.map +1 -1
  50. package/cjs/scenegraph/layout/compute-col-width.js +1 -1
  51. package/cjs/scenegraph/layout/compute-col-width.js.map +1 -1
  52. package/cjs/scenegraph/layout/update-col.d.ts +3 -0
  53. package/cjs/scenegraph/layout/update-col.js +203 -0
  54. package/cjs/scenegraph/layout/update-col.js.map +1 -0
  55. package/cjs/scenegraph/layout/update-height.js +1 -1
  56. package/cjs/scenegraph/layout/update-height.js.map +1 -1
  57. package/cjs/scenegraph/layout/update-row.js +94 -49
  58. package/cjs/scenegraph/layout/update-row.js.map +1 -1
  59. package/cjs/scenegraph/layout/update-width.js +1 -1
  60. package/cjs/scenegraph/layout/update-width.js.map +1 -1
  61. package/cjs/scenegraph/refresh-node/update-chart.js +1 -1
  62. package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
  63. package/cjs/scenegraph/scenegraph.d.ts +5 -0
  64. package/cjs/scenegraph/scenegraph.js +24 -3
  65. package/cjs/scenegraph/scenegraph.js.map +1 -1
  66. package/cjs/scenegraph/utils/get-hierarchy-offset.js +1 -1
  67. package/cjs/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  68. package/cjs/state/resize/update-resize-column.js +1 -1
  69. package/cjs/state/resize/update-resize-column.js.map +1 -1
  70. package/cjs/state/state.d.ts +2 -0
  71. package/cjs/state/state.js +47 -2
  72. package/cjs/state/state.js.map +1 -1
  73. package/cjs/themes/DARK.js.map +1 -1
  74. package/cjs/tools/diff-cell.js +1 -1
  75. package/cjs/tools/diff-cell.js.map +1 -1
  76. package/cjs/ts-types/base-table.d.ts +1 -1
  77. package/cjs/ts-types/base-table.js.map +1 -1
  78. package/cjs/ts-types/table-engine.d.ts +3 -0
  79. package/cjs/ts-types/table-engine.js.map +1 -1
  80. package/dist/vtable.js +20208 -3499
  81. package/dist/vtable.min.js +2 -2
  82. package/es/ListTable.d.ts +5 -2
  83. package/es/ListTable.js +163 -18
  84. package/es/ListTable.js.map +1 -1
  85. package/es/PivotChart.d.ts +1 -1
  86. package/es/PivotChart.js +8 -8
  87. package/es/PivotChart.js.map +1 -1
  88. package/es/PivotTable.d.ts +1 -1
  89. package/es/PivotTable.js +8 -8
  90. package/es/PivotTable.js.map +1 -1
  91. package/es/components/axis/axis.d.ts +1 -1
  92. package/es/components/axis/axis.js +16 -8
  93. package/es/components/axis/axis.js.map +1 -1
  94. package/es/components/axis/get-axis-attributes.d.ts +1 -0
  95. package/es/components/axis/get-axis-attributes.js +26 -0
  96. package/es/components/axis/get-axis-attributes.js.map +1 -1
  97. package/es/components/menu/dom/logic/MenuElement.js +3 -3
  98. package/es/components/menu/dom/logic/MenuElement.js.map +1 -1
  99. package/es/core/BaseTable.d.ts +1 -1
  100. package/es/core/BaseTable.js +5 -5
  101. package/es/core/BaseTable.js.map +1 -1
  102. package/es/core/tableHelper.d.ts +2 -0
  103. package/es/core/tableHelper.js +16 -0
  104. package/es/core/tableHelper.js.map +1 -1
  105. package/es/data/DataSource.d.ts +8 -1
  106. package/es/data/DataSource.js +59 -2
  107. package/es/data/DataSource.js.map +1 -1
  108. package/es/event/event.d.ts +2 -0
  109. package/es/event/event.js +10 -2
  110. package/es/event/event.js.map +1 -1
  111. package/es/index.d.ts +1 -1
  112. package/es/index.js +1 -1
  113. package/es/index.js.map +1 -1
  114. package/es/scenegraph/graphic/contributions/group-contribution-render.js +6 -2
  115. package/es/scenegraph/graphic/contributions/group-contribution-render.js.map +1 -1
  116. package/es/scenegraph/graphic/contributions/index.js +9 -9
  117. package/es/scenegraph/graphic/contributions/index.js.map +1 -1
  118. package/es/scenegraph/group-creater/cell-helper.js +1 -1
  119. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  120. package/es/scenegraph/group-creater/column.d.ts +0 -4
  121. package/es/scenegraph/group-creater/column.js +0 -16
  122. package/es/scenegraph/group-creater/column.js.map +1 -1
  123. package/es/scenegraph/group-creater/progress/proxy.d.ts +2 -0
  124. package/es/scenegraph/group-creater/progress/proxy.js +14 -0
  125. package/es/scenegraph/group-creater/progress/proxy.js.map +1 -1
  126. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js +4 -0
  127. package/es/scenegraph/group-creater/progress/update-position/dynamic-set-x.js.map +1 -1
  128. package/es/scenegraph/layout/auto-height.d.ts +1 -2
  129. package/es/scenegraph/layout/auto-height.js +0 -33
  130. package/es/scenegraph/layout/auto-height.js.map +1 -1
  131. package/es/scenegraph/layout/compute-col-width.js +1 -1
  132. package/es/scenegraph/layout/compute-col-width.js.map +1 -1
  133. package/es/scenegraph/layout/update-col.d.ts +3 -0
  134. package/es/scenegraph/layout/update-col.js +200 -0
  135. package/es/scenegraph/layout/update-col.js.map +1 -0
  136. package/es/scenegraph/layout/update-height.js +1 -1
  137. package/es/scenegraph/layout/update-height.js.map +1 -1
  138. package/es/scenegraph/layout/update-row.js +94 -49
  139. package/es/scenegraph/layout/update-row.js.map +1 -1
  140. package/es/scenegraph/layout/update-width.js +1 -1
  141. package/es/scenegraph/layout/update-width.js.map +1 -1
  142. package/es/scenegraph/refresh-node/update-chart.js +1 -1
  143. package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
  144. package/es/scenegraph/scenegraph.d.ts +5 -0
  145. package/es/scenegraph/scenegraph.js +25 -2
  146. package/es/scenegraph/scenegraph.js.map +1 -1
  147. package/es/scenegraph/utils/get-hierarchy-offset.js +1 -1
  148. package/es/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  149. package/es/state/resize/update-resize-column.js +1 -1
  150. package/es/state/resize/update-resize-column.js.map +1 -1
  151. package/es/state/state.d.ts +2 -0
  152. package/es/state/state.js +47 -2
  153. package/es/state/state.js.map +1 -1
  154. package/es/themes/DARK.js.map +1 -1
  155. package/es/tools/diff-cell.js +1 -1
  156. package/es/tools/diff-cell.js.map +1 -1
  157. package/es/ts-types/base-table.d.ts +1 -1
  158. package/es/ts-types/base-table.js.map +1 -1
  159. package/es/ts-types/table-engine.d.ts +3 -0
  160. package/es/ts-types/table-engine.js.map +1 -1
  161. package/package.json +6 -6
@@ -23,7 +23,7 @@ export declare class ListTable extends BaseTable implements ListTableAPI {
23
23
  getCellValue(col: number, row: number): FieldData;
24
24
  getCellOriginValue(col: number, row: number): FieldData;
25
25
  getCellRawValue(col: number, row: number): FieldData;
26
- getRecordIndexByCell(col: number, row: number): number;
26
+ getRecordShowIndexByCell(col: number, row: number): number;
27
27
  getTableIndexByRecordIndex(recordIndex: number): number;
28
28
  getTableIndexByField(field: FieldDef): number;
29
29
  getCellAddrByFieldRecord(field: FieldDef, recordIndex: number): CellAddress;
@@ -44,7 +44,7 @@ export declare class ListTable extends BaseTable implements ListTableAPI {
44
44
  _refreshHierarchyState(col: number, row: number): void;
45
45
  _hasHierarchyTreeHeader(): boolean;
46
46
  getMenuInfo(col: number, row: number, type: string): DropDownMenuEventInfo;
47
- protected _getSortFuncFromHeaderOption(columns: ColumnsDefine | undefined, field: FieldDef, fieldKey?: FieldKeyDef): ((v1: any, v2: any, order: SortOrder) => 0 | 1 | -1) | undefined;
47
+ _getSortFuncFromHeaderOption(columns: ColumnsDefine | undefined, field: FieldDef, fieldKey?: FieldKeyDef): ((v1: any, v2: any, order: SortOrder) => 0 | 1 | -1) | undefined;
48
48
  updateSortState(sortState: SortState[] | SortState | null, executeSort?: boolean): void;
49
49
  getCheckboxState(field?: string | number): boolean[] | Record<string | number, boolean>[];
50
50
  getCellCheckboxState(col: number, row: number): boolean;
@@ -54,4 +54,7 @@ export declare class ListTable extends BaseTable implements ListTableAPI {
54
54
  completeEditCell(): void;
55
55
  getEditor(col: number, row: number): IEditor;
56
56
  changeCellValue(col: number, row: number, value: string | number | null): void;
57
+ addRecord(record: any, recordIndex?: number): void;
58
+ addRecords(records: any[], recordIndex?: number): void;
59
+ deleteRecords(recordIndexs: number[]): void;
57
60
  }
package/cjs/ListTable.js CHANGED
@@ -71,7 +71,8 @@ class ListTable extends core_1.BaseTable {
71
71
  colDefine.editor && (this.internalProps.columns[index].editor = colDefine.editor);
72
72
  })), this.options.columns = columns, this.refreshHeader(), this.scenegraph.clearCells(),
73
73
  this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.scenegraph.createSceneGraph(),
74
- this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync();
74
+ this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync(),
75
+ this.eventManager.updateEventBinder();
75
76
  }
76
77
  get header() {
77
78
  return this.internalProps.columns;
@@ -121,7 +122,7 @@ class ListTable extends core_1.BaseTable {
121
122
  const {field: field} = table.internalProps.layoutMap.getBody(col, row);
122
123
  return table.getRawFieldData(field, col, row);
123
124
  }
124
- getRecordIndexByCell(col, row) {
125
+ getRecordShowIndexByCell(col, row) {
125
126
  const {layoutMap: layoutMap} = this.internalProps;
126
127
  return layoutMap.getRecordIndexByCell(col, row);
127
128
  }
@@ -142,11 +143,11 @@ class ListTable extends core_1.BaseTable {
142
143
  };
143
144
  }
144
145
  getCellOriginRecord(col, row) {
145
- const table = this, index = table.getRecordIndexByCell(col, row);
146
+ const table = this, index = table.getRecordShowIndexByCell(col, row);
146
147
  if (index > -1) return table.dataSource.get(index);
147
148
  }
148
149
  getCellRawRecord(col, row) {
149
- const table = this, index = table.getRecordIndexByCell(col, row);
150
+ const table = this, index = table.getRecordShowIndexByCell(col, row);
150
151
  if (index > -1) return table.dataSource.getRaw(index);
151
152
  }
152
153
  _canResizeColumn(col, row) {
@@ -192,29 +193,30 @@ class ListTable extends core_1.BaseTable {
192
193
  this.refreshRowColCount();
193
194
  }
194
195
  refreshRowColCount() {
195
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
196
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
196
197
  const table = this, {layoutMap: layoutMap} = table.internalProps;
197
198
  layoutMap && (layoutMap.recordsCount = null !== (_b = null === (_a = table.internalProps.dataSource) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0,
198
199
  table.transpose ? (table.rowCount = null !== (_c = layoutMap.rowCount) && void 0 !== _c ? _c : 0,
199
200
  table.colCount = (null !== (_e = null === (_d = table.internalProps.dataSource) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0) * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount,
200
201
  table.frozenRowCount = 0, this.internalProps.frozenColCount = null !== (_f = layoutMap.headerLevelCount) && void 0 !== _f ? _f : 0,
201
- table.rightFrozenColCount = null !== (_g = this.options.rightFrozenColCount) && void 0 !== _g ? _g : 0) : (table.colCount = null !== (_h = layoutMap.colCount) && void 0 !== _h ? _h : 0,
202
- table.rowCount = (null !== (_k = null === (_j = table.internalProps.dataSource) || void 0 === _j ? void 0 : _j.length) && void 0 !== _k ? _k : 0) * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount,
203
- this.internalProps.frozenColCount = null !== (_l = this.options.frozenColCount) && void 0 !== _l ? _l : 0,
204
- table.frozenRowCount = layoutMap.headerLevelCount, table.bottomFrozenRowCount = null !== (_m = this.options.bottomFrozenRowCount) && void 0 !== _m ? _m : 0,
205
- table.rightFrozenColCount = null !== (_o = this.options.rightFrozenColCount) && void 0 !== _o ? _o : 0),
202
+ table.bottomFrozenRowCount !== (null !== (_g = this.options.bottomFrozenRowCount) && void 0 !== _g ? _g : 0) && (table.bottomFrozenRowCount = null !== (_h = this.options.bottomFrozenRowCount) && void 0 !== _h ? _h : 0),
203
+ table.rightFrozenColCount !== (null !== (_j = this.options.rightFrozenColCount) && void 0 !== _j ? _j : 0) && (table.rightFrozenColCount = null !== (_k = this.options.rightFrozenColCount) && void 0 !== _k ? _k : 0)) : (table.colCount = null !== (_l = layoutMap.colCount) && void 0 !== _l ? _l : 0,
204
+ table.rowCount = (null !== (_o = null === (_m = table.internalProps.dataSource) || void 0 === _m ? void 0 : _m.length) && void 0 !== _o ? _o : 0) * layoutMap.bodyRowSpanCount + layoutMap.headerLevelCount,
205
+ this.internalProps.frozenColCount = null !== (_p = this.options.frozenColCount) && void 0 !== _p ? _p : 0,
206
+ table.frozenRowCount = layoutMap.headerLevelCount, table.bottomFrozenRowCount !== (null !== (_q = this.options.bottomFrozenRowCount) && void 0 !== _q ? _q : 0) && (table.bottomFrozenRowCount = null !== (_r = this.options.bottomFrozenRowCount) && void 0 !== _r ? _r : 0),
207
+ table.rightFrozenColCount !== (null !== (_s = this.options.rightFrozenColCount) && void 0 !== _s ? _s : 0) && (table.rightFrozenColCount = null !== (_t = this.options.rightFrozenColCount) && void 0 !== _t ? _t : 0)),
206
208
  this.stateManager.setFrozenCol(this.internalProps.frozenColCount));
207
209
  }
208
210
  getFieldData(field, col, row) {
209
211
  if (null === field) return null;
210
212
  if (this.internalProps.layoutMap.isHeader(col, row)) return null;
211
- const index = this.getRecordIndexByCell(col, row);
213
+ const index = this.getRecordShowIndexByCell(col, row);
212
214
  return this.internalProps.dataSource.getField(index, field, col, row, this);
213
215
  }
214
216
  getRawFieldData(field, col, row) {
215
217
  if (null === field) return null;
216
218
  if (this.internalProps.layoutMap.isHeader(col, row)) return null;
217
- const index = this.getRecordIndexByCell(col, row);
219
+ const index = this.getRecordShowIndexByCell(col, row);
218
220
  return this.internalProps.dataSource.getRawField(index, field, col, row, this);
219
221
  }
220
222
  moveHeaderPosition(source, target) {
@@ -291,7 +293,7 @@ class ListTable extends core_1.BaseTable {
291
293
  }
292
294
  getHierarchyState(col, row) {
293
295
  if (!this.getBodyColumnDefine(col, row).tree) return ts_types_1.HierarchyState.none;
294
- const index = this.getRecordIndexByCell(col, row);
296
+ const index = this.getRecordShowIndexByCell(col, row);
295
297
  return this.dataSource.getHierarchyState(index);
296
298
  }
297
299
  toggleHierarchyState(col, row) {
@@ -312,7 +314,7 @@ class ListTable extends core_1.BaseTable {
312
314
  }
313
315
  }
314
316
  _refreshHierarchyState(col, row) {
315
- const index = this.getRecordIndexByCell(col, row), diffDataIndices = this.dataSource.toggleHierarchyState(index), diffPositions = this.internalProps.layoutMap.toggleHierarchyState(diffDataIndices);
317
+ const index = this.getRecordShowIndexByCell(col, row), diffDataIndices = this.dataSource.toggleHierarchyState(index), diffPositions = this.internalProps.layoutMap.toggleHierarchyState(diffDataIndices);
316
318
  this.refreshRowColCount(), this.clearCellStyleCache(), this.scenegraph.updateHierarchyIcon(col, row),
317
319
  this.scenegraph.updateRow(diffPositions.removeCellPositions, diffPositions.addCellPositions);
318
320
  }
@@ -360,7 +362,7 @@ class ListTable extends core_1.BaseTable {
360
362
  getCellCheckboxState(col, row) {
361
363
  const define = this.getBodyColumnDefine(col, row), field = null == define ? void 0 : define.field, cellType = null == define ? void 0 : define.cellType;
362
364
  if ((0, vutils_1.isValid)(field) && "checkbox" === cellType) {
363
- const dataIndex = this.dataSource.getIndexKey(this.getRecordIndexByCell(col, row));
365
+ const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row));
364
366
  return this.stateManager.checkedState[dataIndex][field];
365
367
  }
366
368
  }
@@ -392,7 +394,7 @@ class ListTable extends core_1.BaseTable {
392
394
  setRecordChildren(records, col, row) {
393
395
  const record = this.getCellOriginRecord(col, row);
394
396
  record.children = records;
395
- const index = this.getRecordIndexByCell(col, row);
397
+ const index = this.getRecordShowIndexByCell(col, row);
396
398
  this.dataSource.setRecord(record, index), this._refreshHierarchyState(col, row);
397
399
  }
398
400
  startEditCell(col, row) {
@@ -421,7 +423,7 @@ class ListTable extends core_1.BaseTable {
421
423
  return "string" == typeof editorDefine ? editors.get(editorDefine) : editorDefine;
422
424
  }
423
425
  changeCellValue(col, row, value) {
424
- const recordIndex = this.getRecordIndexByCell(col, row), {field: field} = this.internalProps.layoutMap.getBody(col, row);
426
+ const recordIndex = this.getRecordShowIndexByCell(col, row), {field: field} = this.internalProps.layoutMap.getBody(col, row);
425
427
  if (this.dataSource.changeFieldValue(value, recordIndex, field, col, row, this),
426
428
  this.scenegraph.updateCellContent(col, row), "adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else if (!this.internalProps._widthResizedColMap.has(col)) {
427
429
  const oldWidth = this.getColWidth(col), newWidth = (0, compute_col_width_1.computeColWidth)(col, 0, this.rowCount - 1, this, !1);
@@ -438,6 +440,150 @@ class ListTable extends core_1.BaseTable {
438
440
  changedValue: this.getCellOriginValue(col, row)
439
441
  }), this.scenegraph.updateNextFrame();
440
442
  }
443
+ addRecord(record, recordIndex) {
444
+ if (this.sortState) this.dataSource.addRecordForSorted(record), (0, tableHelper_1.sortRecords)(this),
445
+ this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
446
+ (void 0 === recordIndex || recordIndex > this.dataSource.sourceLength) && (recordIndex = this.dataSource.sourceLength);
447
+ const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
448
+ this.dataSource.addRecord(record, recordIndex);
449
+ const oldRowCount = this.rowCount;
450
+ this.refreshRowColCount();
451
+ const newRowCount = this.transpose ? this.colCount : this.rowCount;
452
+ if (this.pagination) {
453
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
454
+ if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
455
+ this.scenegraph.createSceneGraph(); else {
456
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
457
+ if (oldRowCount - headerCount === this.pagination.perPageCount) {
458
+ const updateRows = [];
459
+ for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
460
+ col: row,
461
+ row: 0
462
+ }) : updateRows.push({
463
+ col: 0,
464
+ row: row
465
+ });
466
+ this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
467
+ } else {
468
+ const addRows = [];
469
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + 1); row++) this.transpose ? addRows.push({
470
+ col: row,
471
+ row: 0
472
+ }) : addRows.push({
473
+ col: 0,
474
+ row: row
475
+ });
476
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
477
+ }
478
+ }
479
+ } else {
480
+ const addRows = [];
481
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + 1; row++) this.transpose ? addRows.push({
482
+ col: row,
483
+ row: 0
484
+ }) : addRows.push({
485
+ col: 0,
486
+ row: row
487
+ });
488
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
489
+ }
490
+ }
491
+ }
492
+ addRecords(records, recordIndex) {
493
+ if (this.sortState) this.dataSource.addRecordsForSorted(records), (0, tableHelper_1.sortRecords)(this),
494
+ this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
495
+ void 0 === recordIndex || recordIndex > this.dataSource.sourceLength ? recordIndex = this.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
496
+ const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
497
+ this.dataSource.addRecords(records, recordIndex);
498
+ const oldRowCount = this.transpose ? this.colCount : this.rowCount;
499
+ this.refreshRowColCount();
500
+ const newRowCount = this.transpose ? this.colCount : this.rowCount;
501
+ if (this.pagination) {
502
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
503
+ if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
504
+ this.scenegraph.createSceneGraph(); else {
505
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
506
+ if (oldRowCount - headerCount === this.pagination.perPageCount) {
507
+ const updateRows = [];
508
+ for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
509
+ col: row,
510
+ row: 0
511
+ }) : updateRows.push({
512
+ col: 0,
513
+ row: row
514
+ });
515
+ this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
516
+ } else {
517
+ const addRows = [];
518
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + (Array.isArray(records) ? records.length : 1)); row++) this.transpose ? addRows.push({
519
+ col: row,
520
+ row: 0
521
+ }) : addRows.push({
522
+ col: 0,
523
+ row: row
524
+ });
525
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
526
+ }
527
+ }
528
+ } else {
529
+ const addRows = [];
530
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + (Array.isArray(records) ? records.length : 1); row++) this.transpose ? addRows.push({
531
+ col: row,
532
+ row: 0
533
+ }) : addRows.push({
534
+ col: 0,
535
+ row: row
536
+ });
537
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
538
+ }
539
+ }
540
+ }
541
+ deleteRecords(recordIndexs) {
542
+ if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (this.sortState) this.dataSource.deleteRecordsForSorted(recordIndexs),
543
+ (0, tableHelper_1.sortRecords)(this), this.refreshRowColCount(), this.scenegraph.clearCells(),
544
+ this.scenegraph.createSceneGraph(); else {
545
+ const deletedRecordIndexs = this.dataSource.deleteRecords(recordIndexs);
546
+ if (0 === deletedRecordIndexs.length) return;
547
+ const oldRowCount = this.transpose ? this.colCount : this.rowCount;
548
+ this.refreshRowColCount();
549
+ const newRowCount = this.transpose ? this.colCount : this.rowCount, recordIndexsMinToMax = deletedRecordIndexs.sort(((a, b) => a - b)), minRecordIndex = recordIndexsMinToMax[0];
550
+ if (this.pagination) {
551
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
552
+ if (minRecordIndex < endIndex) if (minRecordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
553
+ this.scenegraph.createSceneGraph(); else {
554
+ const updateRows = [], delRows = [];
555
+ for (let row = minRecordIndex - (endIndex - perPageCount) + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount); row < newRowCount; row++) this.transpose ? updateRows.push({
556
+ col: row,
557
+ row: 0
558
+ }) : updateRows.push({
559
+ col: 0,
560
+ row: row
561
+ });
562
+ if (newRowCount < oldRowCount) for (let row = newRowCount; row < oldRowCount; row++) this.transpose ? delRows.push({
563
+ col: row,
564
+ row: 0
565
+ }) : delRows.push({
566
+ col: 0,
567
+ row: row
568
+ });
569
+ this.transpose ? this.scenegraph.updateCol(delRows, [], updateRows) : this.scenegraph.updateRow(delRows, [], updateRows);
570
+ }
571
+ } else {
572
+ const delRows = [];
573
+ for (let index = 0; index < recordIndexsMinToMax.length; index++) {
574
+ const rowNum = recordIndexsMinToMax[index] + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount);
575
+ this.transpose ? delRows.push({
576
+ col: rowNum,
577
+ row: 0
578
+ }) : delRows.push({
579
+ col: 0,
580
+ row: rowNum
581
+ });
582
+ }
583
+ this.transpose ? this.scenegraph.updateCol(delRows, [], []) : this.scenegraph.updateRow(delRows, [], []);
584
+ }
585
+ }
586
+ }
441
587
  }
442
588
 
443
589
  exports.ListTable = ListTable;