@visactor/vtable 1.22.11-alpha.8 → 1.22.11-alpha.9
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 +34 -7
- package/cjs/ListTable.js +138 -18
- package/cjs/ListTable.js.map +1 -1
- package/cjs/PivotChart.d.ts +0 -3
- package/cjs/PivotChart.js +5 -12
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/components/index.js +1 -1
- package/cjs/core/BaseTable.js +1 -1
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/core/TABLE_EVENT_TYPE.d.ts +1 -0
- package/cjs/core/TABLE_EVENT_TYPE.js +1 -0
- package/cjs/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/cjs/core/index.d.ts +1 -0
- package/cjs/core/index.js +30 -0
- package/cjs/core/index.js.map +1 -0
- package/cjs/core/record-helper.d.ts +4 -2
- package/cjs/core/record-helper.js +120 -47
- package/cjs/core/record-helper.js.map +1 -1
- package/cjs/data/DataSource.d.ts +13 -4
- package/cjs/data/DataSource.js +174 -60
- package/cjs/data/DataSource.js.map +1 -1
- package/cjs/event/event.d.ts +2 -1
- package/cjs/event/event.js +20 -9
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/listener/container-dom.js +1 -1
- package/cjs/event/listener/container-dom.js.map +1 -1
- package/cjs/event/listener/scroll-bar.js +2 -8
- package/cjs/event/listener/scroll-bar.js.map +1 -1
- package/cjs/event/listener/table-group.js +8 -14
- package/cjs/event/listener/table-group.js.map +1 -1
- package/cjs/event/media-click.js +1 -1
- package/cjs/event/scroll.js +1 -1
- package/cjs/event/sparkline-event.js +1 -1
- package/cjs/event/util.js +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/index.js +1 -2
- package/cjs/layout/pivot-header-layout.d.ts +0 -6
- package/cjs/layout/pivot-header-layout.js +20 -39
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/plugins/custom-cell-style.d.ts +5 -0
- package/cjs/plugins/custom-cell-style.js +9 -0
- package/cjs/plugins/custom-cell-style.js.map +1 -1
- package/cjs/plugins/interface.js +1 -1
- package/cjs/plugins/invert-highlight.js +2 -1
- package/cjs/plugins/list-tree-stick-cell.js +1 -1
- package/cjs/plugins/plugin-manager.js +1 -1
- package/cjs/scenegraph/graphic/active-cell-chart-list.d.ts +2 -15
- package/cjs/scenegraph/graphic/active-cell-chart-list.js +75 -198
- package/cjs/scenegraph/graphic/active-cell-chart-list.js.map +1 -1
- package/cjs/scenegraph/graphic/chart.d.ts +1 -10
- package/cjs/scenegraph/graphic/chart.js +27 -61
- package/cjs/scenegraph/graphic/chart.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render.js +4 -3
- package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.d.ts +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.js +1 -2
- package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/cjs/scenegraph/scenegraph.d.ts +2 -2
- package/cjs/scenegraph/scenegraph.js +11 -44
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/tools/util.d.ts +0 -5
- package/cjs/tools/util.js +4 -22
- package/cjs/tools/util.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +2 -2
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/ts-types/events.d.ts +15 -0
- package/cjs/ts-types/events.js.map +1 -1
- package/cjs/ts-types/table-engine.d.ts +33 -13
- package/cjs/ts-types/table-engine.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +898 -711
- package/dist/vtable.min.js +2 -2
- package/es/ListTable.d.ts +34 -7
- package/es/ListTable.js +134 -18
- package/es/ListTable.js.map +1 -1
- package/es/PivotChart.d.ts +0 -3
- package/es/PivotChart.js +4 -13
- package/es/PivotChart.js.map +1 -1
- package/es/components/index.js +1 -1
- package/es/core/BaseTable.js +1 -1
- package/es/core/BaseTable.js.map +1 -1
- package/es/core/TABLE_EVENT_TYPE.d.ts +1 -0
- package/es/core/TABLE_EVENT_TYPE.js +1 -0
- package/es/core/TABLE_EVENT_TYPE.js.map +1 -1
- package/es/core/index.d.ts +1 -0
- package/es/core/index.js +2 -0
- package/es/core/index.js.map +1 -0
- package/es/core/record-helper.d.ts +4 -2
- package/es/core/record-helper.js +114 -43
- package/es/core/record-helper.js.map +1 -1
- package/es/data/DataSource.d.ts +13 -4
- package/es/data/DataSource.js +174 -60
- package/es/data/DataSource.js.map +1 -1
- package/es/event/event.d.ts +2 -1
- package/es/event/event.js +20 -9
- package/es/event/event.js.map +1 -1
- package/es/event/listener/container-dom.js +1 -1
- package/es/event/listener/container-dom.js.map +1 -1
- package/es/event/listener/scroll-bar.js +2 -8
- package/es/event/listener/scroll-bar.js.map +1 -1
- package/es/event/listener/table-group.js +8 -13
- package/es/event/listener/table-group.js.map +1 -1
- package/es/event/media-click.js +1 -1
- package/es/event/scroll.js +1 -1
- package/es/event/sparkline-event.js +1 -1
- package/es/event/util.js +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/index.js +1 -2
- package/es/layout/pivot-header-layout.d.ts +0 -6
- package/es/layout/pivot-header-layout.js +20 -39
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/plugins/custom-cell-style.d.ts +5 -0
- package/es/plugins/custom-cell-style.js +9 -0
- package/es/plugins/custom-cell-style.js.map +1 -1
- package/es/plugins/interface.js +1 -1
- package/es/plugins/invert-highlight.js +2 -1
- package/es/plugins/list-tree-stick-cell.js +1 -1
- package/es/plugins/plugin-manager.js +1 -1
- package/es/scenegraph/graphic/active-cell-chart-list.d.ts +2 -15
- package/es/scenegraph/graphic/active-cell-chart-list.js +68 -186
- package/es/scenegraph/graphic/active-cell-chart-list.js.map +1 -1
- package/es/scenegraph/graphic/chart.d.ts +1 -10
- package/es/scenegraph/graphic/chart.js +25 -58
- package/es/scenegraph/graphic/chart.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render.js +4 -3
- package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/es/scenegraph/refresh-node/update-chart.d.ts +1 -1
- package/es/scenegraph/refresh-node/update-chart.js +1 -2
- package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/es/scenegraph/scenegraph.d.ts +2 -2
- package/es/scenegraph/scenegraph.js +10 -43
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/tools/util.d.ts +0 -5
- package/es/tools/util.js +0 -18
- package/es/tools/util.js.map +1 -1
- package/es/ts-types/base-table.d.ts +2 -2
- package/es/ts-types/base-table.js.map +1 -1
- package/es/ts-types/events.d.ts +15 -0
- package/es/ts-types/events.js.map +1 -1
- package/es/ts-types/table-engine.d.ts +33 -13
- package/es/ts-types/table-engine.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +4 -4
package/cjs/data/DataSource.js
CHANGED
|
@@ -349,6 +349,23 @@ class DataSource extends EventTarget_1.EventTarget {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
+
changeFieldValueByRecordIndex(value, recordIndex, field, table) {
|
|
353
|
+
var _a, _b, _c, _d;
|
|
354
|
+
if (null === field) return;
|
|
355
|
+
if (null == recordIndex) return;
|
|
356
|
+
const rawKey = recordIndex.toString();
|
|
357
|
+
if (!this.beforeChangedRecordsMap.has(rawKey)) {
|
|
358
|
+
const rawRecords = Array.isArray(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records) ? this.dataSourceObj.records : null, originRecord = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
|
|
359
|
+
this.beforeChangedRecordsMap.set(rawKey, null !== (_b = (0, vutils_1.cloneDeep)(originRecord, void 0, [ "vtable_gantt_linkedFrom", "vtable_gantt_linkedTo" ])) && void 0 !== _b ? _b : {});
|
|
360
|
+
}
|
|
361
|
+
if ("string" == typeof field || "number" == typeof field) {
|
|
362
|
+
const beforeChangedValue = null === (_c = this.beforeChangedRecordsMap.get(rawKey)) || void 0 === _c ? void 0 : _c[field], rawRecords = Array.isArray(null === (_d = this.dataSourceObj) || void 0 === _d ? void 0 : _d.records) ? this.dataSourceObj.records : null, record = rawRecords ? Array.isArray(recordIndex) ? getValueFromDeepArray(rawRecords, recordIndex) : rawRecords[recordIndex] : void 0;
|
|
363
|
+
let formatValue = value;
|
|
364
|
+
"number" == typeof beforeChangedValue && (0, util_1.isAllDigits)(value) && (formatValue = parseFloat(value)),
|
|
365
|
+
record ? record[field] = formatValue : rawRecords && "number" == typeof recordIndex && (rawRecords[recordIndex] = "Array" === this.addRecordRule ? [] : {},
|
|
366
|
+
rawRecords[recordIndex][field] = formatValue);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
352
369
|
cacheBeforeChangedRecord(dataIndex, table) {
|
|
353
370
|
var _a;
|
|
354
371
|
if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
|
|
@@ -365,38 +382,89 @@ class DataSource extends EventTarget_1.EventTarget {
|
|
|
365
382
|
Array.isArray(indexed) || this.records.splice(indexed, 1, record);
|
|
366
383
|
}
|
|
367
384
|
}
|
|
368
|
-
|
|
369
|
-
var _a;
|
|
370
|
-
if (Array.isArray(this.records)) {
|
|
371
|
-
this.records.splice(index, 0, record), this.adjustBeforeChangedRecordsMap(index, 1),
|
|
372
|
-
this.currentIndexedData.push(this.currentIndexedData.length), this._sourceLength += 1;
|
|
373
|
-
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].push(record);
|
|
374
|
-
if ("tree" === this.rowHierarchyType && this.initTreeHierarchyState(), this.userPagination) {
|
|
375
|
-
this.pagination.totalCount = this._sourceLength;
|
|
376
|
-
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
377
|
-
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
378
|
-
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
379
|
-
this.updatePagerData();
|
|
380
|
-
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, 1);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
addRecords(recordArr, index) {
|
|
385
|
+
_getRawRecordsArray() {
|
|
384
386
|
var _a;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
const rawRecords = null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records;
|
|
388
|
+
return Array.isArray(rawRecords) ? rawRecords : null;
|
|
389
|
+
}
|
|
390
|
+
_hasFilterInEffect() {
|
|
391
|
+
var _a, _b, _c, _d, _e;
|
|
392
|
+
return (null !== (_c = null === (_b = null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) >= 1 || (null !== (_e = null === (_d = this.lastFilterRules) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : 0) >= 1;
|
|
393
|
+
}
|
|
394
|
+
_normalizeInsertIndex(index, length) {
|
|
395
|
+
return null == index || index > length ? length : index < 0 ? 0 : index;
|
|
396
|
+
}
|
|
397
|
+
_mapViewInsertIndexToRawInsertIndex(rawRecords, viewIndex) {
|
|
398
|
+
if (0 === this.records.length) return rawRecords.length;
|
|
399
|
+
if (viewIndex <= 0) {
|
|
400
|
+
const firstVisibleRecord = this.records[0], rawIndex = rawRecords.indexOf(firstVisibleRecord);
|
|
401
|
+
return rawIndex >= 0 ? rawIndex : 0;
|
|
402
|
+
}
|
|
403
|
+
if (viewIndex >= this.records.length) {
|
|
404
|
+
const lastVisibleRecord = this.records[this.records.length - 1], rawIndex = rawRecords.indexOf(lastVisibleRecord);
|
|
405
|
+
return rawIndex >= 0 ? rawIndex + 1 : rawRecords.length;
|
|
406
|
+
}
|
|
407
|
+
const prevRecord = this.records[viewIndex - 1], rawIndex = rawRecords.indexOf(prevRecord);
|
|
408
|
+
return rawIndex >= 0 ? rawIndex + 1 : rawRecords.length;
|
|
409
|
+
}
|
|
410
|
+
_resetIndexingFromViewRecords() {
|
|
411
|
+
if (this._sourceLength = this.records.length, this.currentIndexedData = Array.from({
|
|
412
|
+
length: this._sourceLength
|
|
413
|
+
}, ((_, i) => i)), "tree" === this.rowHierarchyType && this.initTreeHierarchyState(),
|
|
414
|
+
this.userPagination) return this.pagination.totalCount = this._sourceLength, void this.updatePagerData();
|
|
415
|
+
this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
416
|
+
this.updatePagerData();
|
|
417
|
+
}
|
|
418
|
+
addRecord(record, index, syncToOriginalRecords = !1) {
|
|
419
|
+
var _a, _b, _c;
|
|
420
|
+
if (!syncToOriginalRecords) {
|
|
421
|
+
if (Array.isArray(this.records)) {
|
|
422
|
+
this.records.splice(index, 0, record), this.adjustBeforeChangedRecordsMap(index, 1),
|
|
423
|
+
this.currentIndexedData.push(this.currentIndexedData.length), this._sourceLength += 1;
|
|
424
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].push(record);
|
|
425
|
+
if ("tree" === this.rowHierarchyType && this.initTreeHierarchyState(), this.userPagination) {
|
|
426
|
+
this.pagination.totalCount = this._sourceLength;
|
|
427
|
+
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
428
|
+
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
429
|
+
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
430
|
+
this.updatePagerData();
|
|
431
|
+
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, 1);
|
|
432
|
+
}
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
const rawRecords = this._getRawRecordsArray();
|
|
436
|
+
if (!rawRecords) return;
|
|
437
|
+
const viewInsertIndex = this._normalizeInsertIndex(index, this.records.length), rawInsertIndex = this._hasFilterInEffect() ? this._mapViewInsertIndexToRawInsertIndex(rawRecords, viewInsertIndex) : this._normalizeInsertIndex(viewInsertIndex, rawRecords.length);
|
|
438
|
+
rawRecords.splice(rawInsertIndex, 0, record), syncToOriginalRecords && this._hasFilterInEffect() && this.markForceVisibleRecord(record),
|
|
439
|
+
this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
440
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.added) && this.dataSourceObj.added(rawInsertIndex, 1);
|
|
441
|
+
}
|
|
442
|
+
addRecords(recordArr, index, syncToOriginalRecords = !1) {
|
|
443
|
+
var _a, _b, _c;
|
|
444
|
+
if (!syncToOriginalRecords) {
|
|
445
|
+
if (Array.isArray(this.records)) {
|
|
446
|
+
if (Array.isArray(recordArr)) {
|
|
447
|
+
this.records.splice(index, 0, ...recordArr), this.adjustBeforeChangedRecordsMap(index, recordArr.length);
|
|
448
|
+
for (let i = 0; i < recordArr.length; i++) this.currentIndexedData.push(this.currentIndexedData.length);
|
|
449
|
+
this._sourceLength += recordArr.length;
|
|
450
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) for (let j = 0; j < recordArr.length; j++) this.fieldAggregators[i].push(recordArr[j]);
|
|
451
|
+
}
|
|
452
|
+
if (this.userPagination) {
|
|
453
|
+
this.pagination.totalCount = this._sourceLength;
|
|
454
|
+
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
455
|
+
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
456
|
+
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
457
|
+
this.updatePagerData();
|
|
458
|
+
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, recordArr.length);
|
|
391
459
|
}
|
|
392
|
-
|
|
393
|
-
this.pagination.totalCount = this._sourceLength;
|
|
394
|
-
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
395
|
-
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
396
|
-
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
397
|
-
this.updatePagerData();
|
|
398
|
-
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, recordArr.length);
|
|
460
|
+
return;
|
|
399
461
|
}
|
|
462
|
+
const rawRecords = this._getRawRecordsArray();
|
|
463
|
+
if (!rawRecords || !Array.isArray(recordArr) || 0 === recordArr.length) return;
|
|
464
|
+
const viewInsertIndex = this._normalizeInsertIndex(index, this.records.length), rawInsertIndex = this._hasFilterInEffect() ? this._mapViewInsertIndexToRawInsertIndex(rawRecords, viewInsertIndex) : this._normalizeInsertIndex(viewInsertIndex, rawRecords.length);
|
|
465
|
+
if (rawRecords.splice(rawInsertIndex, 0, ...recordArr), syncToOriginalRecords && this._hasFilterInEffect()) for (let i = 0; i < recordArr.length; i++) this.markForceVisibleRecord(recordArr[i]);
|
|
466
|
+
this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
467
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.added) && this.dataSourceObj.added(rawInsertIndex, recordArr.length);
|
|
400
468
|
}
|
|
401
469
|
addRecordForSorted(record) {
|
|
402
470
|
Array.isArray(this.records) && (this.beforeChangedRecordsMap.clear(), this.records.push(record),
|
|
@@ -415,28 +483,48 @@ class DataSource extends EventTarget_1.EventTarget {
|
|
|
415
483
|
}
|
|
416
484
|
}
|
|
417
485
|
adjustBeforeChangedRecordsMap(insertIndex, insertCount, type = "add") {
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
486
|
+
const delta = "add" === type ? insertCount : -insertCount, numericKeys = [];
|
|
487
|
+
this.beforeChangedRecordsMap.forEach(((_, key) => {
|
|
488
|
+
const numKey = Number(key);
|
|
489
|
+
Number.isInteger(numKey) && numKey.toString() === key && numKey >= insertIndex && numericKeys.push(numKey);
|
|
490
|
+
})), numericKeys.sort(((a, b) => "add" === type ? b - a : a - b));
|
|
491
|
+
for (let i = 0; i < numericKeys.length; i++) {
|
|
492
|
+
const key = numericKeys[i], record = this.beforeChangedRecordsMap.get(key.toString());
|
|
493
|
+
this.beforeChangedRecordsMap.delete(key.toString()), this.beforeChangedRecordsMap.set((key + delta).toString(), record);
|
|
421
494
|
}
|
|
422
495
|
}
|
|
423
|
-
deleteRecords(recordIndexs) {
|
|
424
|
-
var _a;
|
|
425
|
-
if (
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
496
|
+
deleteRecords(recordIndexs, syncToOriginalRecords = !1) {
|
|
497
|
+
var _a, _b, _c;
|
|
498
|
+
if (!syncToOriginalRecords) {
|
|
499
|
+
if (Array.isArray(this.records)) {
|
|
500
|
+
const realDeletedRecordIndexs = [], recordIndexsMaxToMin = recordIndexs.sort(((a, b) => b - a));
|
|
501
|
+
for (let index = 0; index < recordIndexsMaxToMin.length; index++) {
|
|
502
|
+
const recordIndex = recordIndexsMaxToMin[index];
|
|
503
|
+
if (recordIndex >= this._sourceLength || recordIndex < 0) continue;
|
|
504
|
+
this.adjustBeforeChangedRecordsMap(recordIndex, 1, "delete"), realDeletedRecordIndexs.push(recordIndex);
|
|
505
|
+
const deletedRecord = this.records[recordIndex];
|
|
506
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].deleteRecord(deletedRecord);
|
|
507
|
+
this.records.splice(recordIndex, 1), this.currentIndexedData.pop(), this._sourceLength -= 1;
|
|
508
|
+
}
|
|
509
|
+
return this.userPagination || (this.pagination.perPageCount = this._sourceLength,
|
|
510
|
+
this.pagination.totalCount = this._sourceLength), this.updatePagerData(), (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.deleted) && this.dataSourceObj.deleted(realDeletedRecordIndexs),
|
|
511
|
+
realDeletedRecordIndexs;
|
|
434
512
|
}
|
|
435
|
-
return
|
|
436
|
-
this.pagination.totalCount = this._sourceLength), this.updatePagerData(), (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.deleted) && this.dataSourceObj.deleted(realDeletedRecordIndexs),
|
|
437
|
-
realDeletedRecordIndexs;
|
|
513
|
+
return [];
|
|
438
514
|
}
|
|
439
|
-
|
|
515
|
+
const rawRecords = this._getRawRecordsArray();
|
|
516
|
+
if (!rawRecords || !Array.isArray(this.records)) return [];
|
|
517
|
+
const realDeletedRecordIndexs = [], recordIndexsMaxToMin = recordIndexs.slice().sort(((a, b) => b - a)), rawDeletedIndexs = [];
|
|
518
|
+
for (let index = 0; index < recordIndexsMaxToMin.length; index++) {
|
|
519
|
+
const viewIndex = recordIndexsMaxToMin[index];
|
|
520
|
+
if (viewIndex >= this.records.length || viewIndex < 0) continue;
|
|
521
|
+
const deletedRecord = this.records[viewIndex], rawIndex = rawRecords.indexOf(deletedRecord);
|
|
522
|
+
rawIndex >= 0 && (rawRecords.splice(rawIndex, 1), rawDeletedIndexs.push(rawIndex)),
|
|
523
|
+
realDeletedRecordIndexs.push(viewIndex);
|
|
524
|
+
}
|
|
525
|
+
return this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
526
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.deleted) && this.dataSourceObj.deleted(rawDeletedIndexs),
|
|
527
|
+
realDeletedRecordIndexs;
|
|
440
528
|
}
|
|
441
529
|
deleteRecordsForSorted(recordIndexs) {
|
|
442
530
|
if (Array.isArray(this.records)) {
|
|
@@ -451,20 +539,38 @@ class DataSource extends EventTarget_1.EventTarget {
|
|
|
451
539
|
this.pagination.totalCount = this._sourceLength), this.beforeChangedRecordsMap.clear();
|
|
452
540
|
}
|
|
453
541
|
}
|
|
454
|
-
updateRecords(records, recordIndexs) {
|
|
455
|
-
|
|
542
|
+
updateRecords(records, recordIndexs, syncToOriginalRecords = !1) {
|
|
543
|
+
var _a;
|
|
544
|
+
if (!syncToOriginalRecords) {
|
|
545
|
+
const realDeletedRecordIndexs = [];
|
|
546
|
+
for (let index = 0; index < recordIndexs.length; index++) {
|
|
547
|
+
const recordIndex = recordIndexs[index];
|
|
548
|
+
if (Array.isArray(recordIndex)) this.beforeChangedRecordsMap.delete(recordIndex.toString()),
|
|
549
|
+
realDeletedRecordIndexs.push(recordIndex), recordIndex.slice(0, -1).reduce(((acc, key) => (void 0 === acc[key] && (acc[key] = {}),
|
|
550
|
+
acc[key].children)), this.records)[recordIndex[recordIndex.length - 1]] = records[index]; else {
|
|
551
|
+
if (recordIndex >= this._sourceLength || recordIndex < 0) continue;
|
|
552
|
+
this.beforeChangedRecordsMap.delete(recordIndex.toString()), realDeletedRecordIndexs.push(recordIndex);
|
|
553
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].updateRecord(this.records[recordIndex], records[index]);
|
|
554
|
+
this.records[recordIndex] = records[index];
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return this.userPagination && this.updatePagerData(), realDeletedRecordIndexs;
|
|
558
|
+
}
|
|
559
|
+
const rawRecords = this._getRawRecordsArray();
|
|
560
|
+
if (!rawRecords || !Array.isArray(this.records)) return [];
|
|
561
|
+
const realUpdatedIndexs = [];
|
|
456
562
|
for (let index = 0; index < recordIndexs.length; index++) {
|
|
457
563
|
const recordIndex = recordIndexs[index];
|
|
458
564
|
if (Array.isArray(recordIndex)) this.beforeChangedRecordsMap.delete(recordIndex.toString()),
|
|
459
|
-
|
|
460
|
-
acc[key].children)),
|
|
461
|
-
if (recordIndex >= this.
|
|
462
|
-
this.
|
|
463
|
-
|
|
464
|
-
this.records[recordIndex] = records[index];
|
|
565
|
+
realUpdatedIndexs.push(recordIndex), recordIndex.slice(0, -1).reduce(((acc, key) => (void 0 === acc[key] && (acc[key] = {}),
|
|
566
|
+
acc[key].children)), rawRecords)[recordIndex[recordIndex.length - 1]] = records[index]; else {
|
|
567
|
+
if (recordIndex >= this.records.length || recordIndex < 0) continue;
|
|
568
|
+
const oldRecord = this.records[recordIndex], rawIndex = rawRecords.indexOf(oldRecord);
|
|
569
|
+
rawIndex >= 0 && (rawRecords[rawIndex] = records[index]), realUpdatedIndexs.push(recordIndex);
|
|
465
570
|
}
|
|
466
571
|
}
|
|
467
|
-
return this.
|
|
572
|
+
return this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules),
|
|
573
|
+
realUpdatedIndexs;
|
|
468
574
|
}
|
|
469
575
|
updateRecordsForSorted(records, recordIndexs) {
|
|
470
576
|
const realDeletedRecordIndexs = [];
|
|
@@ -530,23 +636,31 @@ class DataSource extends EventTarget_1.EventTarget {
|
|
|
530
636
|
setSortedIndexMap(field, filedMap) {
|
|
531
637
|
this.sortedIndexMap.set(field, filedMap);
|
|
532
638
|
}
|
|
639
|
+
markForceVisibleRecord(record) {
|
|
640
|
+
!record || "object" != typeof record && "function" != typeof record || (this._forceVisibleRecords || (this._forceVisibleRecords = new WeakSet),
|
|
641
|
+
this._forceVisibleRecords.add(record));
|
|
642
|
+
}
|
|
643
|
+
clearForceVisibleRecords() {
|
|
644
|
+
this._forceVisibleRecords = void 0;
|
|
645
|
+
}
|
|
533
646
|
clearFilteredChildren(record) {
|
|
534
647
|
var _a, _b;
|
|
535
648
|
record.filteredChildren = void 0;
|
|
536
649
|
for (let i = 0; i < (null !== (_b = null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); i++) this.clearFilteredChildren(record.children[i]);
|
|
537
650
|
}
|
|
538
651
|
filterRecord(record) {
|
|
539
|
-
var _a, _b, _c;
|
|
652
|
+
var _a, _b, _c, _d;
|
|
653
|
+
if (null === (_a = this._forceVisibleRecords) || void 0 === _a ? void 0 : _a.has(record)) return !0;
|
|
540
654
|
let isReserved = !0;
|
|
541
|
-
for (let i = 0; i < (null === (
|
|
542
|
-
const filterRule = null === (
|
|
655
|
+
for (let i = 0; i < (null === (_b = this.dataConfig.filterRules) || void 0 === _b ? void 0 : _b.length); i++) {
|
|
656
|
+
const filterRule = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.filterRules[i];
|
|
543
657
|
if (filterRule.filterKey) {
|
|
544
658
|
const filterValue = record[filterRule.filterKey];
|
|
545
659
|
if (-1 === filterRule.filteredValues.indexOf(filterValue)) {
|
|
546
660
|
isReserved = !1;
|
|
547
661
|
break;
|
|
548
662
|
}
|
|
549
|
-
} else if (!(null === (
|
|
663
|
+
} else if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
|
|
550
664
|
isReserved = !1;
|
|
551
665
|
break;
|
|
552
666
|
}
|