@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
package/es/ListTable.d.ts CHANGED
@@ -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/es/ListTable.js CHANGED
@@ -4,7 +4,7 @@ import { SimpleHeaderLayoutMap } from "./layout";
4
4
 
5
5
  import { isValid } from "@visactor/vutils";
6
6
 
7
- import { _setDataSource, _setRecords } from "./core/tableHelper";
7
+ import { _setDataSource, _setRecords, sortRecords } from "./core/tableHelper";
8
8
 
9
9
  import { BaseTable } from "./core";
10
10
 
@@ -66,7 +66,8 @@ export class ListTable extends BaseTable {
66
66
  colDefine.editor && (this.internalProps.columns[index].editor = colDefine.editor);
67
67
  })), this.options.columns = columns, this.refreshHeader(), this.scenegraph.clearCells(),
68
68
  this.headerStyleCache = new Map, this.bodyStyleCache = new Map, this.scenegraph.createSceneGraph(),
69
- this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync();
69
+ this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync(),
70
+ this.eventManager.updateEventBinder();
70
71
  }
71
72
  get header() {
72
73
  return this.internalProps.columns;
@@ -116,7 +117,7 @@ export class ListTable extends BaseTable {
116
117
  const {field: field} = table.internalProps.layoutMap.getBody(col, row);
117
118
  return table.getRawFieldData(field, col, row);
118
119
  }
119
- getRecordIndexByCell(col, row) {
120
+ getRecordShowIndexByCell(col, row) {
120
121
  const {layoutMap: layoutMap} = this.internalProps;
121
122
  return layoutMap.getRecordIndexByCell(col, row);
122
123
  }
@@ -137,11 +138,11 @@ export class ListTable extends BaseTable {
137
138
  };
138
139
  }
139
140
  getCellOriginRecord(col, row) {
140
- const table = this, index = table.getRecordIndexByCell(col, row);
141
+ const table = this, index = table.getRecordShowIndexByCell(col, row);
141
142
  if (index > -1) return table.dataSource.get(index);
142
143
  }
143
144
  getCellRawRecord(col, row) {
144
- const table = this, index = table.getRecordIndexByCell(col, row);
145
+ const table = this, index = table.getRecordShowIndexByCell(col, row);
145
146
  if (index > -1) return table.dataSource.getRaw(index);
146
147
  }
147
148
  _canResizeColumn(col, row) {
@@ -187,29 +188,30 @@ export class ListTable extends BaseTable {
187
188
  this.refreshRowColCount();
188
189
  }
189
190
  refreshRowColCount() {
190
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
191
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
191
192
  const table = this, {layoutMap: layoutMap} = table.internalProps;
192
193
  layoutMap && (layoutMap.recordsCount = null !== (_b = null === (_a = table.internalProps.dataSource) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0,
193
194
  table.transpose ? (table.rowCount = null !== (_c = layoutMap.rowCount) && void 0 !== _c ? _c : 0,
194
195
  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,
195
196
  table.frozenRowCount = 0, this.internalProps.frozenColCount = null !== (_f = layoutMap.headerLevelCount) && void 0 !== _f ? _f : 0,
196
- table.rightFrozenColCount = null !== (_g = this.options.rightFrozenColCount) && void 0 !== _g ? _g : 0) : (table.colCount = null !== (_h = layoutMap.colCount) && void 0 !== _h ? _h : 0,
197
- 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,
198
- this.internalProps.frozenColCount = null !== (_l = this.options.frozenColCount) && void 0 !== _l ? _l : 0,
199
- table.frozenRowCount = layoutMap.headerLevelCount, table.bottomFrozenRowCount = null !== (_m = this.options.bottomFrozenRowCount) && void 0 !== _m ? _m : 0,
200
- table.rightFrozenColCount = null !== (_o = this.options.rightFrozenColCount) && void 0 !== _o ? _o : 0),
197
+ table.bottomFrozenRowCount !== (null !== (_g = this.options.bottomFrozenRowCount) && void 0 !== _g ? _g : 0) && (table.bottomFrozenRowCount = null !== (_h = this.options.bottomFrozenRowCount) && void 0 !== _h ? _h : 0),
198
+ 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,
199
+ 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,
200
+ this.internalProps.frozenColCount = null !== (_p = this.options.frozenColCount) && void 0 !== _p ? _p : 0,
201
+ 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),
202
+ table.rightFrozenColCount !== (null !== (_s = this.options.rightFrozenColCount) && void 0 !== _s ? _s : 0) && (table.rightFrozenColCount = null !== (_t = this.options.rightFrozenColCount) && void 0 !== _t ? _t : 0)),
201
203
  this.stateManager.setFrozenCol(this.internalProps.frozenColCount));
202
204
  }
203
205
  getFieldData(field, col, row) {
204
206
  if (null === field) return null;
205
207
  if (this.internalProps.layoutMap.isHeader(col, row)) return null;
206
- const index = this.getRecordIndexByCell(col, row);
208
+ const index = this.getRecordShowIndexByCell(col, row);
207
209
  return this.internalProps.dataSource.getField(index, field, col, row, this);
208
210
  }
209
211
  getRawFieldData(field, col, row) {
210
212
  if (null === field) return null;
211
213
  if (this.internalProps.layoutMap.isHeader(col, row)) return null;
212
- const index = this.getRecordIndexByCell(col, row);
214
+ const index = this.getRecordShowIndexByCell(col, row);
213
215
  return this.internalProps.dataSource.getRawField(index, field, col, row, this);
214
216
  }
215
217
  moveHeaderPosition(source, target) {
@@ -286,7 +288,7 @@ export class ListTable extends BaseTable {
286
288
  }
287
289
  getHierarchyState(col, row) {
288
290
  if (!this.getBodyColumnDefine(col, row).tree) return HierarchyState.none;
289
- const index = this.getRecordIndexByCell(col, row);
291
+ const index = this.getRecordShowIndexByCell(col, row);
290
292
  return this.dataSource.getHierarchyState(index);
291
293
  }
292
294
  toggleHierarchyState(col, row) {
@@ -307,7 +309,7 @@ export class ListTable extends BaseTable {
307
309
  }
308
310
  }
309
311
  _refreshHierarchyState(col, row) {
310
- const index = this.getRecordIndexByCell(col, row), diffDataIndices = this.dataSource.toggleHierarchyState(index), diffPositions = this.internalProps.layoutMap.toggleHierarchyState(diffDataIndices);
312
+ const index = this.getRecordShowIndexByCell(col, row), diffDataIndices = this.dataSource.toggleHierarchyState(index), diffPositions = this.internalProps.layoutMap.toggleHierarchyState(diffDataIndices);
311
313
  this.refreshRowColCount(), this.clearCellStyleCache(), this.scenegraph.updateHierarchyIcon(col, row),
312
314
  this.scenegraph.updateRow(diffPositions.removeCellPositions, diffPositions.addCellPositions);
313
315
  }
@@ -355,7 +357,7 @@ export class ListTable extends BaseTable {
355
357
  getCellCheckboxState(col, row) {
356
358
  const define = this.getBodyColumnDefine(col, row), field = null == define ? void 0 : define.field, cellType = null == define ? void 0 : define.cellType;
357
359
  if (isValid(field) && "checkbox" === cellType) {
358
- const dataIndex = this.dataSource.getIndexKey(this.getRecordIndexByCell(col, row));
360
+ const dataIndex = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row));
359
361
  return this.stateManager.checkedState[dataIndex][field];
360
362
  }
361
363
  }
@@ -387,7 +389,7 @@ export class ListTable extends BaseTable {
387
389
  setRecordChildren(records, col, row) {
388
390
  const record = this.getCellOriginRecord(col, row);
389
391
  record.children = records;
390
- const index = this.getRecordIndexByCell(col, row);
392
+ const index = this.getRecordShowIndexByCell(col, row);
391
393
  this.dataSource.setRecord(record, index), this._refreshHierarchyState(col, row);
392
394
  }
393
395
  startEditCell(col, row) {
@@ -416,7 +418,7 @@ export class ListTable extends BaseTable {
416
418
  return "string" == typeof editorDefine ? editors.get(editorDefine) : editorDefine;
417
419
  }
418
420
  changeCellValue(col, row, value) {
419
- const recordIndex = this.getRecordIndexByCell(col, row), {field: field} = this.internalProps.layoutMap.getBody(col, row);
421
+ const recordIndex = this.getRecordShowIndexByCell(col, row), {field: field} = this.internalProps.layoutMap.getBody(col, row);
420
422
  if (this.dataSource.changeFieldValue(value, recordIndex, field, col, row, this),
421
423
  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)) {
422
424
  const oldWidth = this.getColWidth(col), newWidth = computeColWidth(col, 0, this.rowCount - 1, this, !1);
@@ -433,4 +435,147 @@ export class ListTable extends BaseTable {
433
435
  changedValue: this.getCellOriginValue(col, row)
434
436
  }), this.scenegraph.updateNextFrame();
435
437
  }
438
+ addRecord(record, recordIndex) {
439
+ if (this.sortState) this.dataSource.addRecordForSorted(record), sortRecords(this),
440
+ this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
441
+ (void 0 === recordIndex || recordIndex > this.dataSource.sourceLength) && (recordIndex = this.dataSource.sourceLength);
442
+ const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
443
+ this.dataSource.addRecord(record, recordIndex);
444
+ const oldRowCount = this.rowCount;
445
+ this.refreshRowColCount();
446
+ const newRowCount = this.transpose ? this.colCount : this.rowCount;
447
+ if (this.pagination) {
448
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
449
+ if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
450
+ this.scenegraph.createSceneGraph(); else {
451
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
452
+ if (oldRowCount - headerCount === this.pagination.perPageCount) {
453
+ const updateRows = [];
454
+ for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
455
+ col: row,
456
+ row: 0
457
+ }) : updateRows.push({
458
+ col: 0,
459
+ row: row
460
+ });
461
+ this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
462
+ } else {
463
+ const addRows = [];
464
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + 1); row++) this.transpose ? addRows.push({
465
+ col: row,
466
+ row: 0
467
+ }) : addRows.push({
468
+ col: 0,
469
+ row: row
470
+ });
471
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
472
+ }
473
+ }
474
+ } else {
475
+ const addRows = [];
476
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + 1; row++) this.transpose ? addRows.push({
477
+ col: row,
478
+ row: 0
479
+ }) : addRows.push({
480
+ col: 0,
481
+ row: row
482
+ });
483
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
484
+ }
485
+ }
486
+ }
487
+ addRecords(records, recordIndex) {
488
+ if (this.sortState) this.dataSource.addRecordsForSorted(records), sortRecords(this),
489
+ this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
490
+ void 0 === recordIndex || recordIndex > this.dataSource.sourceLength ? recordIndex = this.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
491
+ const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
492
+ this.dataSource.addRecords(records, recordIndex);
493
+ const oldRowCount = this.transpose ? this.colCount : this.rowCount;
494
+ this.refreshRowColCount();
495
+ const newRowCount = this.transpose ? this.colCount : this.rowCount;
496
+ if (this.pagination) {
497
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
498
+ if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
499
+ this.scenegraph.createSceneGraph(); else {
500
+ const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
501
+ if (oldRowCount - headerCount === this.pagination.perPageCount) {
502
+ const updateRows = [];
503
+ for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
504
+ col: row,
505
+ row: 0
506
+ }) : updateRows.push({
507
+ col: 0,
508
+ row: row
509
+ });
510
+ this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
511
+ } else {
512
+ const addRows = [];
513
+ for (let row = rowNum; row < Math.min(newRowCount, rowNum + (Array.isArray(records) ? records.length : 1)); row++) this.transpose ? addRows.push({
514
+ col: row,
515
+ row: 0
516
+ }) : addRows.push({
517
+ col: 0,
518
+ row: row
519
+ });
520
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
521
+ }
522
+ }
523
+ } else {
524
+ const addRows = [];
525
+ for (let row = recordIndex + headerCount; row < recordIndex + headerCount + (Array.isArray(records) ? records.length : 1); row++) this.transpose ? addRows.push({
526
+ col: row,
527
+ row: 0
528
+ }) : addRows.push({
529
+ col: 0,
530
+ row: row
531
+ });
532
+ this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
533
+ }
534
+ }
535
+ }
536
+ deleteRecords(recordIndexs) {
537
+ if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (this.sortState) this.dataSource.deleteRecordsForSorted(recordIndexs),
538
+ sortRecords(this), this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
539
+ const deletedRecordIndexs = this.dataSource.deleteRecords(recordIndexs);
540
+ if (0 === deletedRecordIndexs.length) return;
541
+ const oldRowCount = this.transpose ? this.colCount : this.rowCount;
542
+ this.refreshRowColCount();
543
+ const newRowCount = this.transpose ? this.colCount : this.rowCount, recordIndexsMinToMax = deletedRecordIndexs.sort(((a, b) => a - b)), minRecordIndex = recordIndexsMinToMax[0];
544
+ if (this.pagination) {
545
+ const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
546
+ if (minRecordIndex < endIndex) if (minRecordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
547
+ this.scenegraph.createSceneGraph(); else {
548
+ const updateRows = [], delRows = [];
549
+ for (let row = minRecordIndex - (endIndex - perPageCount) + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount); row < newRowCount; row++) this.transpose ? updateRows.push({
550
+ col: row,
551
+ row: 0
552
+ }) : updateRows.push({
553
+ col: 0,
554
+ row: row
555
+ });
556
+ if (newRowCount < oldRowCount) for (let row = newRowCount; row < oldRowCount; row++) this.transpose ? delRows.push({
557
+ col: row,
558
+ row: 0
559
+ }) : delRows.push({
560
+ col: 0,
561
+ row: row
562
+ });
563
+ this.transpose ? this.scenegraph.updateCol(delRows, [], updateRows) : this.scenegraph.updateRow(delRows, [], updateRows);
564
+ }
565
+ } else {
566
+ const delRows = [];
567
+ for (let index = 0; index < recordIndexsMinToMax.length; index++) {
568
+ const rowNum = recordIndexsMinToMax[index] + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount);
569
+ this.transpose ? delRows.push({
570
+ col: rowNum,
571
+ row: 0
572
+ }) : delRows.push({
573
+ col: 0,
574
+ row: rowNum
575
+ });
576
+ }
577
+ this.transpose ? this.scenegraph.updateCol(delRows, [], []) : this.scenegraph.updateRow(delRows, [], []);
578
+ }
579
+ }
580
+ }
436
581
  }