@visactor/vtable 1.23.3-alpha.0 → 1.24.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.
- package/cjs/ListTable.d.ts +1 -0
- package/cjs/ListTable.js +182 -24
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotTable.d.ts +1 -0
- package/cjs/PivotTable.js +10 -2
- package/cjs/PivotTable.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +9 -0
- package/cjs/core/BaseTable.js +64 -15
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/core/TABLE_EVENT_TYPE.d.ts +2 -0
- package/cjs/core/TABLE_EVENT_TYPE.js +2 -0
- package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/cjs/core/animation.js +5 -3
- package/cjs/core/animation.js.map +1 -1
- package/cjs/core/record-helper.js +83 -13
- package/cjs/core/record-helper.js.map +1 -1
- package/cjs/data/DataSource.js +3 -2
- package/cjs/data/DataSource.js.map +1 -1
- package/cjs/dataset/DataStatistics.js +1 -2
- package/cjs/dataset/dataset.js +6 -1
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/edit/edit-manager.js +24 -16
- package/cjs/edit/edit-manager.js.map +1 -1
- package/cjs/event/EventTarget.js +3 -1
- package/cjs/event/EventTarget.js.map +1 -1
- package/cjs/index.d.ts +3 -3
- package/cjs/index.js +51 -12
- package/cjs/index.js.map +1 -1
- package/cjs/layout/cell-range/simple-cell-range.js +14 -4
- package/cjs/layout/cell-range/simple-cell-range.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js +1 -1
- package/cjs/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/cjs/scenegraph/group-creater/init-scenegraph.js +1 -1
- package/cjs/scenegraph/group-creater/init-scenegraph.js.map +1 -1
- package/cjs/state/state.js +14 -11
- package/cjs/state/state.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +5 -0
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/events.d.ts +16 -0
- package/cjs/ts-types/events.js.map +1 -1
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +968 -232
- package/dist/vtable.min.js +2 -2
- package/es/ListTable.d.ts +1 -0
- package/es/ListTable.js +177 -24
- package/es/ListTable.js.map +1 -1
- package/es/PivotTable.d.ts +1 -0
- package/es/PivotTable.js +8 -2
- package/es/PivotTable.js.map +1 -1
- package/es/core/BaseTable.d.ts +9 -0
- package/es/core/BaseTable.js +64 -15
- package/es/core/BaseTable.js.map +1 -1
- package/es/core/TABLE_EVENT_TYPE.d.ts +2 -0
- package/es/core/TABLE_EVENT_TYPE.js +2 -0
- package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/es/core/animation.js +5 -3
- package/es/core/animation.js.map +1 -1
- package/es/core/record-helper.js +83 -12
- package/es/core/record-helper.js.map +1 -1
- package/es/data/DataSource.js +3 -2
- package/es/data/DataSource.js.map +1 -1
- package/es/dataset/DataStatistics.js +1 -2
- package/es/dataset/dataset.js +7 -2
- package/es/dataset/dataset.js.map +1 -1
- package/es/edit/edit-manager.js +22 -16
- package/es/edit/edit-manager.js.map +1 -1
- package/es/event/EventTarget.js +3 -1
- package/es/event/EventTarget.js.map +1 -1
- package/es/index.d.ts +3 -3
- package/es/index.js +5 -3
- package/es/index.js.map +1 -1
- package/es/layout/cell-range/simple-cell-range.js +14 -4
- package/es/layout/cell-range/simple-cell-range.js.map +1 -1
- package/es/scenegraph/group-creater/cell-helper.js +1 -1
- package/es/scenegraph/group-creater/cell-helper.js.map +1 -1
- package/es/scenegraph/group-creater/init-scenegraph.js +1 -1
- package/es/scenegraph/group-creater/init-scenegraph.js.map +1 -1
- package/es/state/state.js +14 -11
- package/es/state/state.js.map +1 -1
- package/es/ts-types/base-table.d.ts +5 -0
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/events.d.ts +16 -0
- package/es/ts-types/events.js.map +1 -1
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +6 -6
package/cjs/ListTable.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export declare class ListTable extends BaseTable implements ListTableAPI {
|
|
|
71
71
|
updateSortState(sortState: SortState[] | SortState | null, executeSort?: boolean): void;
|
|
72
72
|
updateFilterRules(filterRules: FilterRules, options?: {
|
|
73
73
|
clearRowHeightCache?: boolean;
|
|
74
|
+
clearForceVisibleRecords?: boolean;
|
|
74
75
|
onFilterRecordsEnd?: (records: any[]) => any[];
|
|
75
76
|
}): void;
|
|
76
77
|
getFilteredRecords(): any[];
|
package/cjs/ListTable.js
CHANGED
|
@@ -119,10 +119,32 @@ class ListTable extends core_1.BaseTable {
|
|
|
119
119
|
this.renderAsync(), this.eventManager.updateEventBinder();
|
|
120
120
|
}
|
|
121
121
|
addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
|
|
122
|
-
var _a;
|
|
122
|
+
var _a, _b;
|
|
123
123
|
const columns = this.options.columns;
|
|
124
|
+
if (Array.isArray(this.options.customMergeCell) && (null == toAddColumns ? void 0 : toAddColumns.length)) {
|
|
125
|
+
const axis = this.transpose ? "row" : "col";
|
|
126
|
+
let insertIndex = colIndex;
|
|
127
|
+
void 0 === insertIndex ? insertIndex = columns.length : insertIndex < 0 ? insertIndex = 0 : insertIndex > columns.length && (insertIndex = columns.length);
|
|
128
|
+
const toAddCount = toAddColumns.length, merges = this.options.customMergeCell.map((m => Object.assign(Object.assign({}, m), {
|
|
129
|
+
range: {
|
|
130
|
+
start: Object.assign({}, m.range.start),
|
|
131
|
+
end: Object.assign({}, m.range.end)
|
|
132
|
+
}
|
|
133
|
+
})));
|
|
134
|
+
for (let i = 0; i < merges.length; i++) {
|
|
135
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
136
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
137
|
+
const start = r.start[axis], end = r.end[axis];
|
|
138
|
+
end < insertIndex || (start > insertIndex ? (r.start[axis] = start + toAddCount,
|
|
139
|
+
r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
140
|
+
}
|
|
141
|
+
this.options.customMergeCell = merges.filter((m => {
|
|
142
|
+
const r = null == m ? void 0 : m.range;
|
|
143
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && (!(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col));
|
|
144
|
+
})), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
145
|
+
}
|
|
124
146
|
void 0 === colIndex ? (colIndex = columns.length, columns.push(...toAddColumns)) : columns.splice(colIndex, 0, ...toAddColumns);
|
|
125
|
-
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (
|
|
147
|
+
for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (_b = toAddColumns[i].width) && void 0 !== _b ? _b : this.internalProps.defaultColWidth);
|
|
126
148
|
this.internalProps._colRangeWidthsMap.clear();
|
|
127
149
|
const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
|
|
128
150
|
for (let i = 0; i < resizedColIndexs.length; i++) resizedColIndexs[i] >= colIndex && (this.internalProps._widthResizedColMap.delete(resizedColIndexs[i]),
|
|
@@ -136,15 +158,46 @@ class ListTable extends core_1.BaseTable {
|
|
|
136
158
|
}
|
|
137
159
|
this.updateColumns(columns, {
|
|
138
160
|
clearRowHeightCache: !1
|
|
139
|
-
}), this.
|
|
161
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = (0,
|
|
162
|
+
get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell),
|
|
163
|
+
this.options.customMergeCell.forEach((m => {
|
|
164
|
+
const r = null == m ? void 0 : m.range;
|
|
165
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
166
|
+
})), this.scenegraph.updateNextFrame()), this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.ADD_COLUMN, {
|
|
140
167
|
columnIndex: colIndex,
|
|
141
168
|
columnCount: toAddColumns.length,
|
|
142
169
|
columns: columns
|
|
143
170
|
});
|
|
144
171
|
}
|
|
145
172
|
deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
|
|
173
|
+
var _a;
|
|
146
174
|
const columns = this.options.columns;
|
|
147
175
|
deleteColIndexs.sort(((a, b) => b - a));
|
|
176
|
+
const deletedColumns = deleteColIndexs.map((idx => (0, vutils_extension_1.cloneDeepSpec)(columns[idx], [ "children" ])));
|
|
177
|
+
let deletedRecordValues;
|
|
178
|
+
if (Array.isArray(this.options.customMergeCell) && (null == deleteColIndexs ? void 0 : deleteColIndexs.length)) {
|
|
179
|
+
const axis = this.transpose ? "row" : "col", deleteIndexNums = deleteColIndexs.slice().sort(((a, b) => a - b)).map(((idx, i) => idx - i)), merges = this.options.customMergeCell.map((m => Object.assign(Object.assign({}, m), {
|
|
180
|
+
range: {
|
|
181
|
+
start: Object.assign({}, m.range.start),
|
|
182
|
+
end: Object.assign({}, m.range.end)
|
|
183
|
+
}
|
|
184
|
+
})));
|
|
185
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
186
|
+
const deleteIndex = deleteIndexNums[i];
|
|
187
|
+
for (let j = 0; j < merges.length; j++) {
|
|
188
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
189
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
190
|
+
const start = r.start[axis], end = r.end[axis];
|
|
191
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
this.options.customMergeCell = merges.filter((m => {
|
|
195
|
+
const r = null == m ? void 0 : m.range;
|
|
196
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && (!(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col));
|
|
197
|
+
})), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
198
|
+
}
|
|
199
|
+
isMaintainArrayData && Array.isArray(this.records) && this.records.length && (deletedRecordValues = this.records.map((record => Array.isArray(record) ? deleteColIndexs.map((idx => record[idx])) : [])),
|
|
200
|
+
deletedRecordValues.every((v => 0 === v.length)) && (deletedRecordValues = void 0));
|
|
148
201
|
for (let i = 0; i < deleteColIndexs.length; i++) if (columns.splice(deleteColIndexs[i], 1),
|
|
149
202
|
this.colWidthsMap.delAndReorder(deleteColIndexs[i]), this.internalProps._widthResizedColMap.delete(deleteColIndexs[i]),
|
|
150
203
|
isMaintainArrayData) for (let j = 0; j < this.records.length; j++) {
|
|
@@ -162,7 +215,9 @@ class ListTable extends core_1.BaseTable {
|
|
|
162
215
|
clearRowHeightCache: !1
|
|
163
216
|
}), this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.DELETE_COLUMN, {
|
|
164
217
|
deleteColIndexs: deleteColIndexs,
|
|
165
|
-
columns: columns
|
|
218
|
+
columns: columns,
|
|
219
|
+
deletedColumns: deletedColumns,
|
|
220
|
+
deletedRecordValues: deletedRecordValues
|
|
166
221
|
});
|
|
167
222
|
}
|
|
168
223
|
get columns() {
|
|
@@ -548,10 +603,10 @@ class ListTable extends core_1.BaseTable {
|
|
|
548
603
|
}
|
|
549
604
|
}
|
|
550
605
|
updateSortState(sortState, executeSort = !0) {
|
|
551
|
-
var _a;
|
|
552
|
-
|
|
553
|
-
sortState = this.internalProps.sortState
|
|
554
|
-
|
|
606
|
+
var _a, _b, _c, _d, _e;
|
|
607
|
+
const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [ sortState ] : []).filter(Boolean);
|
|
608
|
+
if (normalizedSortState.length ? this.internalProps.sortState = sortState : this.internalProps.sortState = null,
|
|
609
|
+
executeSort) if (normalizedSortState.length) this.internalProps.layoutMap.headerObjects.some((item => !1 !== item.define.sort)) && (this.dataSource.sort(normalizedSortState.map((item => {
|
|
555
610
|
const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
|
|
556
611
|
this.internalProps.layoutMap.headerObjects.find((col => col && col.field === item.field));
|
|
557
612
|
return {
|
|
@@ -560,13 +615,22 @@ class ListTable extends core_1.BaseTable {
|
|
|
560
615
|
orderFn: null != sortFunc ? sortFunc : util_1.defaultOrderFn
|
|
561
616
|
};
|
|
562
617
|
}))), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1,
|
|
563
|
-
this.scenegraph.sortCell())
|
|
618
|
+
this.scenegraph.sortCell()); else {
|
|
619
|
+
const ds = this.dataSource, sourceLength = null !== (_c = null !== (_b = null !== (_a = null == ds ? void 0 : ds.sourceLength) && void 0 !== _a ? _a : null == ds ? void 0 : ds._sourceLength) && void 0 !== _b ? _b : null == ds ? void 0 : ds.length) && void 0 !== _c ? _c : 0;
|
|
620
|
+
(null === (_d = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _d ? void 0 : _d.clear) && ds.sortedIndexMap.clear(),
|
|
621
|
+
void 0 !== ds.currentIndexedData && (ds.currentIndexedData = Array.from({
|
|
622
|
+
length: sourceLength
|
|
623
|
+
}, ((_, i) => i))), ds.lastSortStates = [], null === (_e = ds.updatePagination) || void 0 === _e || _e.call(ds, ds.pagination),
|
|
624
|
+
this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1,
|
|
625
|
+
this.scenegraph.sortCell();
|
|
626
|
+
}
|
|
627
|
+
this.stateManager.updateSortState(normalizedSortState);
|
|
564
628
|
}
|
|
565
629
|
updateFilterRules(filterRules, options = {
|
|
566
630
|
clearRowHeightCache: !0
|
|
567
631
|
}) {
|
|
568
632
|
var _a, _b, _c;
|
|
569
|
-
this.scenegraph.clearCells(), null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a),
|
|
633
|
+
this.scenegraph.clearCells(), !1 !== (null == options ? void 0 : options.clearForceVisibleRecords) && (null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a)),
|
|
570
634
|
this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), (0, record_helper_1.sortRecords)(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd),
|
|
571
635
|
this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)),
|
|
572
636
|
null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(),
|
|
@@ -844,35 +908,107 @@ class ListTable extends core_1.BaseTable {
|
|
|
844
908
|
this.resize();
|
|
845
909
|
}
|
|
846
910
|
addRecord(record, recordIndex, triggerEvent = !0) {
|
|
847
|
-
var _a;
|
|
911
|
+
var _a, _b;
|
|
912
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex) {
|
|
913
|
+
const axis = this.transpose ? "col" : "row", headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount, topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
914
|
+
let insertIndex = recordIndex;
|
|
915
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
916
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount, merges = this.options.customMergeCell.map((m => Object.assign(Object.assign({}, m), {
|
|
917
|
+
range: {
|
|
918
|
+
start: Object.assign({}, m.range.start),
|
|
919
|
+
end: Object.assign({}, m.range.end)
|
|
920
|
+
}
|
|
921
|
+
})));
|
|
922
|
+
for (let i = 0; i < merges.length; i++) {
|
|
923
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
924
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
925
|
+
const start = r.start[axis], end = r.end[axis];
|
|
926
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + 1, r.end[axis] = end + 1) : r.end[axis] = end + 1);
|
|
927
|
+
}
|
|
928
|
+
this.options.customMergeCell = merges.filter((m => {
|
|
929
|
+
const r = null == m ? void 0 : m.range;
|
|
930
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && (!(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col));
|
|
931
|
+
})), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
932
|
+
}
|
|
848
933
|
const success = (0, record_helper_1.listTableAddRecord)(record, recordIndex, this);
|
|
849
934
|
(0, adjust_header_1.adjustHeightResizedRowMapWithAddRecordIndex)(this, recordIndex, [ record ]),
|
|
850
|
-
null === (
|
|
851
|
-
|
|
935
|
+
null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(),
|
|
936
|
+
success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = (0,
|
|
937
|
+
get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell),
|
|
938
|
+
this.options.customMergeCell.forEach((m => {
|
|
939
|
+
const r = null == m ? void 0 : m.range;
|
|
940
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
941
|
+
})), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
852
942
|
records: [ record ],
|
|
853
943
|
recordIndex: recordIndex,
|
|
854
944
|
recordCount: 1
|
|
855
945
|
});
|
|
856
946
|
}
|
|
857
947
|
addRecords(records, recordIndex, triggerEvent = !0) {
|
|
858
|
-
var _a;
|
|
948
|
+
var _a, _b;
|
|
949
|
+
if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex && (null == records ? void 0 : records.length)) {
|
|
950
|
+
const axis = this.transpose ? "col" : "row", headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount, topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
|
|
951
|
+
let insertIndex = recordIndex;
|
|
952
|
+
void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
|
|
953
|
+
const insertIndexNum = insertIndex + headerCount + topAggregationCount, toAddCount = records.length, merges = this.options.customMergeCell.map((m => Object.assign(Object.assign({}, m), {
|
|
954
|
+
range: {
|
|
955
|
+
start: Object.assign({}, m.range.start),
|
|
956
|
+
end: Object.assign({}, m.range.end)
|
|
957
|
+
}
|
|
958
|
+
})));
|
|
959
|
+
for (let i = 0; i < merges.length; i++) {
|
|
960
|
+
const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
|
|
961
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
962
|
+
const start = r.start[axis], end = r.end[axis];
|
|
963
|
+
end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + toAddCount,
|
|
964
|
+
r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
|
|
965
|
+
}
|
|
966
|
+
this.options.customMergeCell = merges.filter((m => {
|
|
967
|
+
const r = null == m ? void 0 : m.range;
|
|
968
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && (!(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col));
|
|
969
|
+
})), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
970
|
+
}
|
|
859
971
|
const success = (0, record_helper_1.listTableAddRecords)(records, recordIndex, this);
|
|
860
972
|
"number" == typeof recordIndex && (0, adjust_header_1.adjustHeightResizedRowMapWithAddRecordIndex)(this, recordIndex, records),
|
|
861
|
-
null === (
|
|
862
|
-
|
|
973
|
+
null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(),
|
|
974
|
+
success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = (0,
|
|
975
|
+
get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell),
|
|
976
|
+
this.options.customMergeCell.forEach((m => {
|
|
977
|
+
const r = null == m ? void 0 : m.range;
|
|
978
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
979
|
+
})), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.ADD_RECORD, {
|
|
863
980
|
records: records,
|
|
864
981
|
recordIndex: recordIndex,
|
|
865
982
|
recordCount: records.length
|
|
866
983
|
});
|
|
867
984
|
}
|
|
868
985
|
deleteRecords(recordIndexs, triggerEvent = !0) {
|
|
869
|
-
var _a;
|
|
870
|
-
const
|
|
871
|
-
|
|
986
|
+
var _a, _b;
|
|
987
|
+
const prevMergeRanges = Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map((m => null == m ? void 0 : m.range)).filter(Boolean).map((r => ({
|
|
988
|
+
start: Object.assign({}, r.start),
|
|
989
|
+
end: Object.assign({}, r.end)
|
|
990
|
+
}))) : [], deletedRecords = [];
|
|
991
|
+
if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach((index => {
|
|
872
992
|
let record = null;
|
|
873
993
|
record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
|
|
874
|
-
})), (
|
|
875
|
-
|
|
994
|
+
})), Array.isArray(this.options.customMergeCell) && (null == recordIndexs ? void 0 : recordIndexs.length) && "number" == typeof recordIndexs[0]) {
|
|
995
|
+
const axis = this.transpose ? "col" : "row", headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount, topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount, deleteIndexNums = recordIndexs.slice().sort(((a, b) => a - b)).map(((index, i) => index + headerCount + topAggregationCount - i)), merges = this.options.customMergeCell;
|
|
996
|
+
for (let i = 0; i < deleteIndexNums.length; i++) {
|
|
997
|
+
const deleteIndex = deleteIndexNums[i];
|
|
998
|
+
for (let j = 0; j < merges.length; j++) {
|
|
999
|
+
const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
|
|
1000
|
+
if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
|
|
1001
|
+
const start = r.start[axis], end = r.end[axis];
|
|
1002
|
+
end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
this.options.customMergeCell = merges.filter((m => {
|
|
1006
|
+
const r = null == m ? void 0 : m.range;
|
|
1007
|
+
return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && (!(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col));
|
|
1008
|
+
}));
|
|
1009
|
+
}
|
|
1010
|
+
(0, record_helper_1.listTableDeleteRecords)(recordIndexs, this), (0, adjust_header_1.adjustHeightResizedRowMapWithDeleteRecordIndex)(this, recordIndexs),
|
|
1011
|
+
null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible();
|
|
876
1012
|
const rowIndexs = [];
|
|
877
1013
|
for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
|
|
878
1014
|
triggerEvent && this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.DELETE_RECORD, {
|
|
@@ -880,7 +1016,19 @@ class ListTable extends core_1.BaseTable {
|
|
|
880
1016
|
records: deletedRecords,
|
|
881
1017
|
rowIndexs: rowIndexs,
|
|
882
1018
|
deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
|
|
883
|
-
})
|
|
1019
|
+
}), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = (0,
|
|
1020
|
+
get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell),
|
|
1021
|
+
this.options.customMergeCell.forEach((m => {
|
|
1022
|
+
const r = null == m ? void 0 : m.range;
|
|
1023
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
1024
|
+
})), this.scenegraph.updateNextFrame(), setTimeout((() => {
|
|
1025
|
+
if (!this.internalProps || !this.options || !this.scenegraph) return;
|
|
1026
|
+
Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = (0,
|
|
1027
|
+
get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell));
|
|
1028
|
+
[ ...prevMergeRanges, ...Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map((m => null == m ? void 0 : m.range)) : [] ].filter(Boolean).forEach((r => {
|
|
1029
|
+
if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
|
|
1030
|
+
})), this.scenegraph.updateNextFrame();
|
|
1031
|
+
}), 0));
|
|
884
1032
|
}
|
|
885
1033
|
updateRecords(records, recordIndexs, triggerEvent = !0) {
|
|
886
1034
|
(0, record_helper_1.listTableUpdateRecords)(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.UPDATE_RECORD, {
|
|
@@ -984,7 +1132,12 @@ class ListTable extends core_1.BaseTable {
|
|
|
984
1132
|
}
|
|
985
1133
|
}), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
986
1134
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
987
|
-
this.scenegraph.updateNextFrame()
|
|
1135
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.MERGE_CELLS, {
|
|
1136
|
+
startCol: startCol,
|
|
1137
|
+
startRow: startRow,
|
|
1138
|
+
endCol: endCol,
|
|
1139
|
+
endRow: endRow
|
|
1140
|
+
});
|
|
988
1141
|
}
|
|
989
1142
|
unmergeCells(startCol, startRow, endCol, endRow) {
|
|
990
1143
|
this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [],
|
|
@@ -993,7 +1146,12 @@ class ListTable extends core_1.BaseTable {
|
|
|
993
1146
|
return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
|
|
994
1147
|
})), this.internalProps.customMergeCell = (0, get_custom_merge_cell_func_1.getCustomMergeCellFunc)(this.options.customMergeCell);
|
|
995
1148
|
for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
|
|
996
|
-
this.scenegraph.updateNextFrame()
|
|
1149
|
+
this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE_1.TABLE_EVENT_TYPE.UNMERGE_CELLS, {
|
|
1150
|
+
startCol: startCol,
|
|
1151
|
+
startRow: startRow,
|
|
1152
|
+
endCol: endCol,
|
|
1153
|
+
endRow: endRow
|
|
1154
|
+
});
|
|
997
1155
|
}
|
|
998
1156
|
}
|
|
999
1157
|
|