@visactor/vtable 1.5.3 → 1.6.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/cjs/ListTable.d.ts +1 -0
  2. package/cjs/ListTable.js +25 -273
  3. package/cjs/ListTable.js.map +1 -1
  4. package/cjs/core/BaseTable.d.ts +5 -3
  5. package/cjs/core/BaseTable.js +8 -79
  6. package/cjs/core/BaseTable.js.map +1 -1
  7. package/cjs/core/group-helper.d.ts +6 -0
  8. package/cjs/core/group-helper.js +22 -0
  9. package/cjs/core/group-helper.js.map +1 -0
  10. package/cjs/core/record-helper.d.ts +8 -0
  11. package/cjs/core/record-helper.js +337 -0
  12. package/cjs/core/record-helper.js.map +1 -0
  13. package/cjs/core/style-helper.d.ts +3 -0
  14. package/cjs/core/style-helper.js +110 -0
  15. package/cjs/core/style-helper.js.map +1 -0
  16. package/cjs/core/tableHelper.d.ts +0 -2
  17. package/cjs/core/tableHelper.js +9 -18
  18. package/cjs/core/tableHelper.js.map +1 -1
  19. package/cjs/data/CachedDataSource.d.ts +10 -1
  20. package/cjs/data/CachedDataSource.js +102 -3
  21. package/cjs/data/CachedDataSource.js.map +1 -1
  22. package/cjs/dataset/dataset.js +0 -1
  23. package/cjs/edit/edit-manager.js +2 -1
  24. package/cjs/event/listener/table-group.js.map +1 -1
  25. package/cjs/index.d.ts +1 -1
  26. package/cjs/index.js +1 -1
  27. package/cjs/index.js.map +1 -1
  28. package/cjs/layout/cell-range/simple-cell-range.d.ts +4 -0
  29. package/cjs/layout/cell-range/simple-cell-range.js +106 -0
  30. package/cjs/layout/cell-range/simple-cell-range.js.map +1 -0
  31. package/cjs/layout/layout-helper.js +2 -2
  32. package/cjs/layout/layout-helper.js.map +1 -1
  33. package/cjs/layout/row-height-map.js +1 -0
  34. package/cjs/layout/simple-header-layout.d.ts +1 -2
  35. package/cjs/layout/simple-header-layout.js +2 -88
  36. package/cjs/layout/simple-header-layout.js.map +1 -1
  37. package/cjs/plugins/icons.js +1 -1
  38. package/cjs/plugins/themes.js +1 -1
  39. package/cjs/scenegraph/group-creater/cell-helper.js +13 -6
  40. package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
  41. package/cjs/scenegraph/group-creater/column-helper.js +9 -2
  42. package/cjs/scenegraph/group-creater/column-helper.js.map +1 -1
  43. package/cjs/scenegraph/scenegraph.js +1 -1
  44. package/cjs/scenegraph/utils/get-cell-merge.js +1 -1
  45. package/cjs/scenegraph/utils/get-cell-merge.js.map +1 -1
  46. package/cjs/scenegraph/utils/get-hierarchy-offset.js +6 -8
  47. package/cjs/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  48. package/cjs/themes/theme.d.ts +2 -0
  49. package/cjs/themes/theme.js +13 -4
  50. package/cjs/themes/theme.js.map +1 -1
  51. package/cjs/tools/helper.js.map +1 -1
  52. package/cjs/ts-types/base-table.d.ts +9 -0
  53. package/cjs/ts-types/base-table.js.map +1 -1
  54. package/cjs/ts-types/new-data-set.d.ts +1 -0
  55. package/cjs/ts-types/new-data-set.js.map +1 -1
  56. package/cjs/ts-types/table-engine.d.ts +9 -0
  57. package/cjs/ts-types/table-engine.js.map +1 -1
  58. package/cjs/ts-types/theme.d.ts +1 -0
  59. package/cjs/ts-types/theme.js.map +1 -1
  60. package/cjs/vrender.js.map +1 -1
  61. package/dist/vtable.js +3411 -3056
  62. package/dist/vtable.min.js +2 -2
  63. package/es/ListTable.d.ts +1 -0
  64. package/es/ListTable.js +29 -275
  65. package/es/ListTable.js.map +1 -1
  66. package/es/core/BaseTable.d.ts +5 -3
  67. package/es/core/BaseTable.js +11 -83
  68. package/es/core/BaseTable.js.map +1 -1
  69. package/es/core/group-helper.d.ts +6 -0
  70. package/es/core/group-helper.js +14 -0
  71. package/es/core/group-helper.js.map +1 -0
  72. package/es/core/record-helper.d.ts +8 -0
  73. package/es/core/record-helper.js +332 -0
  74. package/es/core/record-helper.js.map +1 -0
  75. package/es/core/style-helper.d.ts +3 -0
  76. package/es/core/style-helper.js +86 -0
  77. package/es/core/style-helper.js.map +1 -0
  78. package/es/core/tableHelper.d.ts +0 -2
  79. package/es/core/tableHelper.js +6 -16
  80. package/es/core/tableHelper.js.map +1 -1
  81. package/es/data/CachedDataSource.d.ts +10 -1
  82. package/es/data/CachedDataSource.js +103 -0
  83. package/es/data/CachedDataSource.js.map +1 -1
  84. package/es/dataset/dataset.js +1 -2
  85. package/es/edit/edit-manager.js +2 -1
  86. package/es/event/listener/table-group.js.map +1 -1
  87. package/es/index.d.ts +1 -1
  88. package/es/index.js +1 -1
  89. package/es/index.js.map +1 -1
  90. package/es/layout/cell-range/simple-cell-range.d.ts +4 -0
  91. package/es/layout/cell-range/simple-cell-range.js +99 -0
  92. package/es/layout/cell-range/simple-cell-range.js.map +1 -0
  93. package/es/layout/layout-helper.js +2 -2
  94. package/es/layout/layout-helper.js.map +1 -1
  95. package/es/layout/row-height-map.js +2 -1
  96. package/es/layout/simple-header-layout.d.ts +1 -2
  97. package/es/layout/simple-header-layout.js +3 -87
  98. package/es/layout/simple-header-layout.js.map +1 -1
  99. package/es/plugins/icons.js +1 -1
  100. package/es/plugins/themes.js +1 -1
  101. package/es/scenegraph/group-creater/cell-helper.js +12 -6
  102. package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
  103. package/es/scenegraph/group-creater/column-helper.js +8 -2
  104. package/es/scenegraph/group-creater/column-helper.js.map +1 -1
  105. package/es/scenegraph/scenegraph.js +1 -1
  106. package/es/scenegraph/utils/get-cell-merge.js +1 -1
  107. package/es/scenegraph/utils/get-cell-merge.js.map +1 -1
  108. package/es/scenegraph/utils/get-hierarchy-offset.js +7 -9
  109. package/es/scenegraph/utils/get-hierarchy-offset.js.map +1 -1
  110. package/es/themes/theme.d.ts +2 -0
  111. package/es/themes/theme.js +13 -4
  112. package/es/themes/theme.js.map +1 -1
  113. package/es/tools/helper.js.map +1 -1
  114. package/es/ts-types/base-table.d.ts +9 -0
  115. package/es/ts-types/base-table.js.map +1 -1
  116. package/es/ts-types/new-data-set.d.ts +1 -0
  117. package/es/ts-types/new-data-set.js.map +1 -1
  118. package/es/ts-types/table-engine.d.ts +9 -0
  119. package/es/ts-types/table-engine.js.map +1 -1
  120. package/es/ts-types/theme.d.ts +1 -0
  121. package/es/ts-types/theme.js.map +1 -1
  122. package/es/vrender.js.map +1 -1
  123. package/package.json +5 -5
@@ -87,4 +87,5 @@ export declare class ListTable extends BaseTable implements ListTableAPI {
87
87
  }[];
88
88
  }[];
89
89
  isAggregation(col: number, row: number): boolean;
90
+ getGroupTitleLevel(col: number, row: number): number | undefined;
90
91
  }
package/cjs/ListTable.js CHANGED
@@ -29,20 +29,22 @@ Object.defineProperty(exports, "__esModule", {
29
29
  value: !0
30
30
  }), exports.ListTable = void 0;
31
31
 
32
- const ts_types_1 = require("./ts-types"), layout_1 = require("./layout"), vutils_1 = require("@visactor/vutils"), tableHelper_1 = require("./core/tableHelper"), core_1 = require("./core"), TABLE_EVENT_TYPE_1 = require("./core/TABLE_EVENT_TYPE"), env_1 = require("./tools/env"), editors = __importStar(require("./edit/editors")), edit_manager_1 = require("./edit/edit-manager"), compute_col_width_1 = require("./scenegraph/layout/compute-col-width"), compute_row_height_1 = require("./scenegraph/layout/compute-row-height"), util_1 = require("./tools/util"), radio_1 = require("./state/radio/radio"), vutils_extension_1 = require("@visactor/vutils-extension"), checkbox_1 = require("./state/checkbox/checkbox"), factory_1 = require("./core/factory");
32
+ const ts_types_1 = require("./ts-types"), layout_1 = require("./layout"), vutils_1 = require("@visactor/vutils"), tableHelper_1 = require("./core/tableHelper"), core_1 = require("./core"), TABLE_EVENT_TYPE_1 = require("./core/TABLE_EVENT_TYPE"), env_1 = require("./tools/env"), editors = __importStar(require("./edit/editors")), edit_manager_1 = require("./edit/edit-manager"), util_1 = require("./tools/util"), radio_1 = require("./state/radio/radio"), vutils_extension_1 = require("@visactor/vutils-extension"), checkbox_1 = require("./state/checkbox/checkbox"), factory_1 = require("./core/factory"), group_helper_1 = require("./core/group-helper"), record_helper_1 = require("./core/record-helper");
33
33
 
34
34
  class ListTable extends core_1.BaseTable {
35
35
  constructor(container, options) {
36
- var _a, _b;
36
+ var _a, _b, _c, _d;
37
37
  "node" === env_1.Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container,
38
38
  container = container.container ? container.container : null), super(container, options),
39
39
  this.showHeader = !0;
40
40
  const internalProps = this.internalProps;
41
41
  if (internalProps.frozenColDragHeaderMode = options.frozenColDragHeaderMode, this.pagination = options.pagination,
42
- internalProps.sortState = options.sortState, internalProps.dataConfig = {}, internalProps.columns = options.columns ? (0,
42
+ internalProps.sortState = options.sortState, internalProps.dataConfig = options.groupBy ? (0,
43
+ group_helper_1.getGroupByDataConfig)(options.groupBy) : {}, internalProps.columns = options.columns ? (0,
43
44
  vutils_extension_1.cloneDeepSpec)(options.columns, [ "children" ]) : options.header ? (0,
44
- vutils_extension_1.cloneDeepSpec)(options.header, [ "children" ]) : [], this.internalProps.headerHelper.setTableColumnsEditor(),
45
- this.showHeader = null === (_a = options.showHeader) || void 0 === _a || _a, this.transpose = null !== (_b = options.transpose) && void 0 !== _b && _b,
45
+ vutils_extension_1.cloneDeepSpec)(options.header, [ "children" ]) : [], internalProps.enableTreeNodeMerge = null !== (_b = null !== (_a = options.enableTreeNodeMerge) && void 0 !== _a ? _a : (0,
46
+ vutils_1.isValid)(options.groupBy)) && void 0 !== _b && _b, this.internalProps.headerHelper.setTableColumnsEditor(),
47
+ this.showHeader = null === (_c = options.showHeader) || void 0 === _c || _c, this.transpose = null !== (_d = options.transpose) && void 0 !== _d && _d,
46
48
  "node" !== env_1.Env.mode && (this.editorManager = new edit_manager_1.EditManeger(this)),
47
49
  this.refreshHeader(), this.internalProps.useOneRowHeightFillAll = !1, options.dataSource ? (0,
48
50
  tableHelper_1._setDataSource)(this, options.dataSource) : options.records ? this.setRecords(options.records, {
@@ -349,7 +351,9 @@ class ListTable extends core_1.BaseTable {
349
351
  return null;
350
352
  }
351
353
  getHierarchyState(col, row) {
352
- if (!this.getBodyColumnDefine(col, row).tree) return ts_types_1.HierarchyState.none;
354
+ if (!this.options.groupBy) {
355
+ if (!this.getBodyColumnDefine(col, row).tree) return ts_types_1.HierarchyState.none;
356
+ }
353
357
  const index = this.getRecordShowIndexByCell(col, row);
354
358
  return this.dataSource.getHierarchyState(index);
355
359
  }
@@ -420,7 +424,7 @@ class ListTable extends core_1.BaseTable {
420
424
  }
421
425
  updateFilterRules(filterRules) {
422
426
  this.scenegraph.clearCells(), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules),
423
- (0, tableHelper_1.sortRecords)(this)) : this.dataSource.updateFilterRules(filterRules),
427
+ (0, record_helper_1.sortRecords)(this)) : this.dataSource.updateFilterRules(filterRules),
424
428
  this.refreshRowColCount(), this.scenegraph.createSceneGraph();
425
429
  }
426
430
  getCheckboxState(field) {
@@ -528,282 +532,22 @@ class ListTable extends core_1.BaseTable {
528
532
  return (0, vutils_1.isValid)(editorDefine);
529
533
  }
530
534
  changeCellValue(col, row, value, workOnEditableCell = !1) {
531
- if (workOnEditableCell && this.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
532
- const recordIndex = this.getRecordShowIndexByCell(col, row), {field: field} = this.internalProps.layoutMap.getBody(col, row), beforeChangeValue = this.getCellRawValue(col, row), oldValue = this.getCellOriginValue(col, row);
533
- this.isHeader(col, row) ? this.internalProps.layoutMap.updateColumnTitle(col, row, value) : this.dataSource.changeFieldValue(value, recordIndex, field, col, row, this);
534
- const range = this.getCellRange(col, row), aggregators = this.internalProps.layoutMap.getAggregatorsByCell(col, row);
535
- if (aggregators) {
536
- if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate(); else aggregators.recalculate();
537
- const aggregatorCells = this.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
538
- for (let i = 0; i < aggregatorCells.length; i++) {
539
- const range = this.getCellRange(aggregatorCells[i].col, aggregatorCells[i].row);
540
- for (let sCol = range.start.col; sCol <= range.end.col; sCol++) for (let sRow = range.start.row; sRow <= range.end.row; sRow++) this.scenegraph.updateCellContent(sCol, sRow);
541
- }
542
- }
543
- for (let sCol = range.start.col; sCol <= range.end.col; sCol++) for (let sRow = range.start.row; sRow <= range.end.row; sRow++) this.scenegraph.updateCellContent(sCol, sRow);
544
- if ("adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else if (!this.internalProps._widthResizedColMap.has(col)) {
545
- const oldWidth = this.getColWidth(col), newWidth = (0, compute_col_width_1.computeColWidth)(col, 0, this.rowCount - 1, this, !1);
546
- newWidth !== oldWidth && this.scenegraph.updateColWidth(col, newWidth - oldWidth);
547
- }
548
- if ("adaptive" === this.heightMode || this.autoFillHeight && this.getAllRowsHeight() <= this.tableNoFrameHeight) 0 === this.internalProps._heightResizedRowMap.size && this.scenegraph.recalculateRowHeights(); else if ("autoHeight" === this.heightMode && !this.internalProps._heightResizedRowMap.has(row)) {
549
- const oldHeight = this.getRowHeight(row), newHeight = (0, compute_row_height_1.computeRowHeight)(row, 0, this.colCount - 1, this);
550
- this.scenegraph.updateRowHeight(row, newHeight - oldHeight);
551
- }
552
- this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
553
- col: col,
554
- row: row,
555
- rawValue: beforeChangeValue,
556
- currentValue: oldValue,
557
- changedValue: this.getCellOriginValue(col, row)
558
- }), this.scenegraph.updateNextFrame();
559
- }
535
+ return (0, record_helper_1.listTableChangeCellValue)(col, row, value, workOnEditableCell, this);
560
536
  }
561
537
  changeCellValues(startCol, startRow, values, workOnEditableCell = !1) {
562
- let pasteColEnd = startCol, pasteRowEnd = startRow;
563
- const beforeChangeValues = [], oldValues = [];
564
- for (let i = 0; i < values.length && !(startRow + i > this.rowCount - 1); i++) {
565
- const rowValues = values[i], rawRowValues = [], oldRowValues = [];
566
- beforeChangeValues.push(rawRowValues), oldValues.push(oldRowValues);
567
- for (let j = 0; j < rowValues.length && !(startCol + j > this.colCount - 1); j++) {
568
- const beforeChangeValue = this.getCellRawValue(startCol + j, startRow + i);
569
- rawRowValues.push(beforeChangeValue);
570
- const oldValue = this.getCellOriginValue(startCol + j, startRow + i);
571
- oldRowValues.push(oldValue);
572
- }
573
- }
574
- for (let i = 0; i < values.length && !(startRow + i > this.rowCount - 1); i++) {
575
- pasteRowEnd = startRow + i;
576
- const rowValues = values[i];
577
- let thisRowPasteColEnd = startCol;
578
- for (let j = 0; j < rowValues.length && !(startCol + j > this.colCount - 1); j++) if (thisRowPasteColEnd = startCol + j,
579
- workOnEditableCell && this.isHasEditorDefine(startCol + j, startRow + i) || !1 === workOnEditableCell) {
580
- const value = rowValues[j], recordIndex = this.getRecordShowIndexByCell(startCol + j, startRow + i), {field: field} = this.internalProps.layoutMap.getBody(startCol + j, startRow + i), beforeChangeValue = beforeChangeValues[i][j], oldValue = oldValues[i][j];
581
- this.isHeader(startCol + j, startRow + i) ? this.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : this.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, this),
582
- this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
583
- col: startCol + j,
584
- row: startRow + i,
585
- rawValue: beforeChangeValue,
586
- currentValue: oldValue,
587
- changedValue: this.getCellOriginValue(startCol + j, startRow + i)
588
- });
589
- }
590
- pasteColEnd = Math.max(pasteColEnd, thisRowPasteColEnd);
591
- }
592
- const startRange = this.getCellRange(startCol, startRow), range = this.getCellRange(pasteColEnd, pasteRowEnd), aggregators = this.internalProps.layoutMap.getAggregatorsByCellRange(startRange.start.col, startRange.start.row, range.end.col, range.end.row);
593
- if (aggregators) {
594
- for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();
595
- const aggregatorCells = this.internalProps.layoutMap.getAggregatorCellAddress(startRange.start.col, startRange.start.row, range.end.col, range.end.row);
596
- for (let i = 0; i < aggregatorCells.length; i++) {
597
- const range = this.getCellRange(aggregatorCells[i].col, aggregatorCells[i].row);
598
- for (let sCol = range.start.col; sCol <= range.end.col; sCol++) for (let sRow = range.start.row; sRow <= range.end.row; sRow++) this.scenegraph.updateCellContent(sCol, sRow);
599
- }
600
- }
601
- for (let sCol = startRange.start.col; sCol <= range.end.col; sCol++) for (let sRow = startRange.start.row; sRow <= range.end.row; sRow++) this.scenegraph.updateCellContent(sCol, sRow);
602
- if ("adaptive" === this.widthMode || this.autoFillWidth && this.getAllColsWidth() <= this.tableNoFrameWidth) 0 === this.internalProps._widthResizedColMap.size && this.scenegraph.recalculateColWidths(); else for (let sCol = startCol; sCol <= range.end.col; sCol++) if (!this.internalProps._widthResizedColMap.has(sCol)) {
603
- const oldWidth = this.getColWidth(sCol), newWidth = (0, compute_col_width_1.computeColWidth)(sCol, 0, this.rowCount - 1, this, !1);
604
- newWidth !== oldWidth && this.scenegraph.updateColWidth(sCol, newWidth - oldWidth);
605
- }
606
- if ("adaptive" === this.heightMode || this.autoFillHeight && this.getAllRowsHeight() <= this.tableNoFrameHeight) this.scenegraph.recalculateRowHeights(); else if ("autoHeight" === this.heightMode) {
607
- const rows = [], deltaYs = [];
608
- for (let sRow = startRow; sRow <= range.end.row; sRow++) if (this.rowHeightsMap.get(sRow)) {
609
- const oldHeight = this.getRowHeight(sRow), newHeight = (0, compute_row_height_1.computeRowHeight)(sRow, 0, this.colCount - 1, this);
610
- rows.push(sRow), deltaYs.push(newHeight - oldHeight);
611
- }
612
- this.scenegraph.updateRowsHeight(rows, deltaYs);
613
- }
614
- this.scenegraph.updateNextFrame();
538
+ return (0, record_helper_1.listTableChangeCellValues)(startCol, startRow, values, workOnEditableCell, this);
615
539
  }
616
540
  addRecord(record, recordIndex) {
617
- if (this.sortState) this.dataSource.addRecordForSorted(record), (0, tableHelper_1.sortRecords)(this),
618
- this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
619
- (void 0 === recordIndex || recordIndex > this.dataSource.sourceLength) && (recordIndex = this.dataSource.sourceLength);
620
- const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
621
- this.dataSource.addRecord(record, recordIndex);
622
- const oldRowCount = this.rowCount;
623
- if (this.refreshRowColCount(), 0 === this.scenegraph.proxy.totalActualBodyRowCount) return this.scenegraph.clearCells(),
624
- void this.scenegraph.createSceneGraph();
625
- const newRowCount = this.transpose ? this.colCount : this.rowCount;
626
- if (this.pagination) {
627
- const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
628
- if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
629
- this.scenegraph.createSceneGraph(); else {
630
- const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
631
- if (oldRowCount - headerCount === this.pagination.perPageCount) {
632
- const updateRows = [];
633
- for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
634
- col: row,
635
- row: 0
636
- }) : updateRows.push({
637
- col: 0,
638
- row: row
639
- });
640
- this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
641
- } else {
642
- const addRows = [];
643
- for (let row = rowNum; row < Math.min(newRowCount, rowNum + 1); row++) this.transpose ? addRows.push({
644
- col: row,
645
- row: 0
646
- }) : addRows.push({
647
- col: 0,
648
- row: row
649
- });
650
- this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
651
- }
652
- }
653
- } else {
654
- const addRows = [];
655
- for (let row = recordIndex + headerCount; row < recordIndex + headerCount + 1; row++) this.transpose ? addRows.push({
656
- col: row,
657
- row: 0
658
- }) : addRows.push({
659
- col: 0,
660
- row: row
661
- });
662
- this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
663
- }
664
- }
541
+ (0, record_helper_1.listTableAddRecord)(record, recordIndex, this);
665
542
  }
666
543
  addRecords(records, recordIndex) {
667
- if (this.sortState) this.dataSource.addRecordsForSorted(records), (0, tableHelper_1.sortRecords)(this),
668
- this.refreshRowColCount(), this.scenegraph.clearCells(), this.scenegraph.createSceneGraph(); else {
669
- void 0 === recordIndex || recordIndex > this.dataSource.sourceLength ? recordIndex = this.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
670
- const headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount;
671
- this.dataSource.addRecords(records, recordIndex);
672
- const oldRowCount = this.transpose ? this.colCount : this.rowCount;
673
- if (this.refreshRowColCount(), 0 === this.scenegraph.proxy.totalActualBodyRowCount) return this.scenegraph.clearCells(),
674
- void this.scenegraph.createSceneGraph();
675
- const newRowCount = this.transpose ? this.colCount : this.rowCount;
676
- if (this.pagination) {
677
- const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
678
- if (recordIndex < endIndex) if (recordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
679
- this.scenegraph.createSceneGraph(); else {
680
- const rowNum = recordIndex - (endIndex - perPageCount) + headerCount;
681
- if (oldRowCount - headerCount === this.pagination.perPageCount) {
682
- const updateRows = [];
683
- for (let row = rowNum; row < newRowCount; row++) this.transpose ? updateRows.push({
684
- col: row,
685
- row: 0
686
- }) : updateRows.push({
687
- col: 0,
688
- row: row
689
- });
690
- this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
691
- } else {
692
- const addRows = [];
693
- for (let row = rowNum; row < Math.min(newRowCount, rowNum + (Array.isArray(records) ? records.length : 1)); row++) this.transpose ? addRows.push({
694
- col: row,
695
- row: 0
696
- }) : addRows.push({
697
- col: 0,
698
- row: row
699
- });
700
- this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
701
- }
702
- }
703
- } else {
704
- const addRows = [];
705
- for (let row = recordIndex + headerCount; row < recordIndex + headerCount + (Array.isArray(records) ? records.length : 1); row++) this.transpose ? addRows.push({
706
- col: row,
707
- row: 0
708
- }) : addRows.push({
709
- col: 0,
710
- row: row
711
- });
712
- this.transpose ? this.scenegraph.updateCol([], addRows, []) : this.scenegraph.updateRow([], addRows, []);
713
- }
714
- }
544
+ (0, record_helper_1.listTableAddRecords)(records, recordIndex, this);
715
545
  }
716
546
  deleteRecords(recordIndexs) {
717
- if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (this.sortState) this.dataSource.deleteRecordsForSorted(recordIndexs),
718
- (0, tableHelper_1.sortRecords)(this), this.refreshRowColCount(), this.scenegraph.clearCells(),
719
- this.scenegraph.createSceneGraph(); else {
720
- const deletedRecordIndexs = this.dataSource.deleteRecords(recordIndexs);
721
- if (0 === deletedRecordIndexs.length) return;
722
- const oldRowCount = this.transpose ? this.colCount : this.rowCount;
723
- this.refreshRowColCount();
724
- const newRowCount = this.transpose ? this.colCount : this.rowCount, recordIndexsMinToMax = deletedRecordIndexs.sort(((a, b) => a - b)), minRecordIndex = recordIndexsMinToMax[0];
725
- if (this.pagination) {
726
- const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount;
727
- if (minRecordIndex < endIndex) if (minRecordIndex < endIndex - perPageCount) this.scenegraph.clearCells(),
728
- this.scenegraph.createSceneGraph(); else {
729
- const updateRows = [], delRows = [];
730
- for (let row = minRecordIndex - (endIndex - perPageCount) + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount); row < newRowCount; row++) this.transpose ? updateRows.push({
731
- col: row,
732
- row: 0
733
- }) : updateRows.push({
734
- col: 0,
735
- row: row
736
- });
737
- if (newRowCount < oldRowCount) for (let row = newRowCount; row < oldRowCount; row++) this.transpose ? delRows.push({
738
- col: row,
739
- row: 0
740
- }) : delRows.push({
741
- col: 0,
742
- row: row
743
- });
744
- this.transpose ? this.scenegraph.updateCol(delRows, [], updateRows) : this.scenegraph.updateRow(delRows, [], updateRows);
745
- }
746
- } else {
747
- const delRows = [];
748
- for (let index = 0; index < recordIndexsMinToMax.length; index++) {
749
- const rowNum = recordIndexsMinToMax[index] + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount);
750
- this.transpose ? delRows.push({
751
- col: rowNum,
752
- row: 0
753
- }) : delRows.push({
754
- col: 0,
755
- row: rowNum
756
- });
757
- }
758
- this.transpose ? this.scenegraph.updateCol(delRows, [], []) : this.scenegraph.updateRow(delRows, [], []);
759
- }
760
- }
547
+ (0, record_helper_1.listTableDeleteRecords)(recordIndexs, this);
761
548
  }
762
549
  updateRecords(records, recordIndexs) {
763
- if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (this.sortState) this.dataSource.updateRecordsForSorted(records, recordIndexs),
764
- (0, tableHelper_1.sortRecords)(this), this.refreshRowColCount(), this.scenegraph.clearCells(),
765
- this.scenegraph.createSceneGraph(); else {
766
- const updateRecordIndexs = this.dataSource.updateRecords(records, recordIndexs);
767
- if (0 === updateRecordIndexs.length) return;
768
- const recordIndexsMinToMax = updateRecordIndexs.sort(((a, b) => a - b));
769
- if (this.pagination) {
770
- const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination, endIndex = perPageCount * (currentPage || 0) + perPageCount, updateRows = [];
771
- for (let index = 0; index < recordIndexsMinToMax.length; index++) {
772
- const recordIndex = recordIndexsMinToMax[index];
773
- if (recordIndex < endIndex && recordIndex >= endIndex - perPageCount) {
774
- const rowNum = recordIndex - (endIndex - perPageCount) + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount);
775
- updateRows.push(rowNum);
776
- }
777
- }
778
- if (updateRows.length >= 1) {
779
- const updateRowCells = [];
780
- for (let index = 0; index < updateRows.length; index++) {
781
- const updateRow = updateRows[index];
782
- this.transpose ? updateRowCells.push({
783
- col: updateRow,
784
- row: 0
785
- }) : updateRowCells.push({
786
- col: 0,
787
- row: updateRow
788
- });
789
- }
790
- this.transpose ? this.scenegraph.updateCol([], [], updateRowCells) : this.scenegraph.updateRow([], [], updateRowCells);
791
- }
792
- } else {
793
- const updateRows = [];
794
- for (let index = 0; index < recordIndexsMinToMax.length; index++) {
795
- const rowNum = recordIndexsMinToMax[index] + (this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount);
796
- this.transpose ? updateRows.push({
797
- col: rowNum,
798
- row: 0
799
- }) : updateRows.push({
800
- col: 0,
801
- row: rowNum
802
- });
803
- }
804
- this.transpose ? this.scenegraph.updateCol([], [], updateRows) : this.scenegraph.updateRow([], [], updateRows);
805
- }
806
- }
550
+ (0, record_helper_1.listTableUpdateRecords)(records, recordIndexs, this);
807
551
  }
808
552
  _hasCustomRenderOrLayout() {
809
553
  var _a, _b, _c, _d;
@@ -839,6 +583,14 @@ class ListTable extends core_1.BaseTable {
839
583
  isAggregation(col, row) {
840
584
  return this.internalProps.layoutMap.isAggregation(col, row);
841
585
  }
586
+ getGroupTitleLevel(col, row) {
587
+ var _a;
588
+ if (!this.options.groupBy) return;
589
+ const indexArr = this.dataSource.getIndexKey(this.getRecordShowIndexByCell(col, row)), groupLength = null !== (_a = this.dataSource.getGroupLength()) && void 0 !== _a ? _a : 0;
590
+ let indexArrLngth = (0, vutils_1.isArray)(indexArr) ? indexArr.length - 1 : 0;
591
+ return groupLength > 0 && indexArrLngth === groupLength && (indexArrLngth = void 0),
592
+ indexArrLngth;
593
+ }
842
594
  }
843
595
 
844
596
  exports.ListTable = ListTable;