@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/es/data/DataSource.js
CHANGED
|
@@ -323,6 +323,23 @@ export class DataSource extends EventTarget {
|
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
}
|
|
326
|
+
changeFieldValueByRecordIndex(value, recordIndex, field, table) {
|
|
327
|
+
var _a, _b, _c, _d;
|
|
328
|
+
if (null === field) return;
|
|
329
|
+
if (null == recordIndex) return;
|
|
330
|
+
const rawKey = recordIndex.toString();
|
|
331
|
+
if (!this.beforeChangedRecordsMap.has(rawKey)) {
|
|
332
|
+
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;
|
|
333
|
+
this.beforeChangedRecordsMap.set(rawKey, null !== (_b = cloneDeep(originRecord, void 0, [ "vtable_gantt_linkedFrom", "vtable_gantt_linkedTo" ])) && void 0 !== _b ? _b : {});
|
|
334
|
+
}
|
|
335
|
+
if ("string" == typeof field || "number" == typeof field) {
|
|
336
|
+
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;
|
|
337
|
+
let formatValue = value;
|
|
338
|
+
"number" == typeof beforeChangedValue && isAllDigits(value) && (formatValue = parseFloat(value)),
|
|
339
|
+
record ? record[field] = formatValue : rawRecords && "number" == typeof recordIndex && (rawRecords[recordIndex] = "Array" === this.addRecordRule ? [] : {},
|
|
340
|
+
rawRecords[recordIndex][field] = formatValue);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
326
343
|
cacheBeforeChangedRecord(dataIndex, table) {
|
|
327
344
|
var _a;
|
|
328
345
|
if (!this.beforeChangedRecordsMap.has(dataIndex.toString())) {
|
|
@@ -339,38 +356,89 @@ export class DataSource extends EventTarget {
|
|
|
339
356
|
Array.isArray(indexed) || this.records.splice(indexed, 1, record);
|
|
340
357
|
}
|
|
341
358
|
}
|
|
342
|
-
|
|
343
|
-
var _a;
|
|
344
|
-
if (Array.isArray(this.records)) {
|
|
345
|
-
this.records.splice(index, 0, record), this.adjustBeforeChangedRecordsMap(index, 1),
|
|
346
|
-
this.currentIndexedData.push(this.currentIndexedData.length), this._sourceLength += 1;
|
|
347
|
-
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].push(record);
|
|
348
|
-
if ("tree" === this.rowHierarchyType && this.initTreeHierarchyState(), this.userPagination) {
|
|
349
|
-
this.pagination.totalCount = this._sourceLength;
|
|
350
|
-
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
351
|
-
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
352
|
-
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
353
|
-
this.updatePagerData();
|
|
354
|
-
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, 1);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
addRecords(recordArr, index) {
|
|
359
|
+
_getRawRecordsArray() {
|
|
358
360
|
var _a;
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
361
|
+
const rawRecords = null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.records;
|
|
362
|
+
return Array.isArray(rawRecords) ? rawRecords : null;
|
|
363
|
+
}
|
|
364
|
+
_hasFilterInEffect() {
|
|
365
|
+
var _a, _b, _c, _d, _e;
|
|
366
|
+
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;
|
|
367
|
+
}
|
|
368
|
+
_normalizeInsertIndex(index, length) {
|
|
369
|
+
return null == index || index > length ? length : index < 0 ? 0 : index;
|
|
370
|
+
}
|
|
371
|
+
_mapViewInsertIndexToRawInsertIndex(rawRecords, viewIndex) {
|
|
372
|
+
if (0 === this.records.length) return rawRecords.length;
|
|
373
|
+
if (viewIndex <= 0) {
|
|
374
|
+
const firstVisibleRecord = this.records[0], rawIndex = rawRecords.indexOf(firstVisibleRecord);
|
|
375
|
+
return rawIndex >= 0 ? rawIndex : 0;
|
|
376
|
+
}
|
|
377
|
+
if (viewIndex >= this.records.length) {
|
|
378
|
+
const lastVisibleRecord = this.records[this.records.length - 1], rawIndex = rawRecords.indexOf(lastVisibleRecord);
|
|
379
|
+
return rawIndex >= 0 ? rawIndex + 1 : rawRecords.length;
|
|
380
|
+
}
|
|
381
|
+
const prevRecord = this.records[viewIndex - 1], rawIndex = rawRecords.indexOf(prevRecord);
|
|
382
|
+
return rawIndex >= 0 ? rawIndex + 1 : rawRecords.length;
|
|
383
|
+
}
|
|
384
|
+
_resetIndexingFromViewRecords() {
|
|
385
|
+
if (this._sourceLength = this.records.length, this.currentIndexedData = Array.from({
|
|
386
|
+
length: this._sourceLength
|
|
387
|
+
}, ((_, i) => i)), "tree" === this.rowHierarchyType && this.initTreeHierarchyState(),
|
|
388
|
+
this.userPagination) return this.pagination.totalCount = this._sourceLength, void this.updatePagerData();
|
|
389
|
+
this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
390
|
+
this.updatePagerData();
|
|
391
|
+
}
|
|
392
|
+
addRecord(record, index, syncToOriginalRecords = !1) {
|
|
393
|
+
var _a, _b, _c;
|
|
394
|
+
if (!syncToOriginalRecords) {
|
|
395
|
+
if (Array.isArray(this.records)) {
|
|
396
|
+
this.records.splice(index, 0, record), this.adjustBeforeChangedRecordsMap(index, 1),
|
|
397
|
+
this.currentIndexedData.push(this.currentIndexedData.length), this._sourceLength += 1;
|
|
398
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].push(record);
|
|
399
|
+
if ("tree" === this.rowHierarchyType && this.initTreeHierarchyState(), this.userPagination) {
|
|
400
|
+
this.pagination.totalCount = this._sourceLength;
|
|
401
|
+
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
402
|
+
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
403
|
+
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
404
|
+
this.updatePagerData();
|
|
405
|
+
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, 1);
|
|
406
|
+
}
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
const rawRecords = this._getRawRecordsArray();
|
|
410
|
+
if (!rawRecords) return;
|
|
411
|
+
const viewInsertIndex = this._normalizeInsertIndex(index, this.records.length), rawInsertIndex = this._hasFilterInEffect() ? this._mapViewInsertIndexToRawInsertIndex(rawRecords, viewInsertIndex) : this._normalizeInsertIndex(viewInsertIndex, rawRecords.length);
|
|
412
|
+
rawRecords.splice(rawInsertIndex, 0, record), syncToOriginalRecords && this._hasFilterInEffect() && this.markForceVisibleRecord(record),
|
|
413
|
+
this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
414
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.added) && this.dataSourceObj.added(rawInsertIndex, 1);
|
|
415
|
+
}
|
|
416
|
+
addRecords(recordArr, index, syncToOriginalRecords = !1) {
|
|
417
|
+
var _a, _b, _c;
|
|
418
|
+
if (!syncToOriginalRecords) {
|
|
419
|
+
if (Array.isArray(this.records)) {
|
|
420
|
+
if (Array.isArray(recordArr)) {
|
|
421
|
+
this.records.splice(index, 0, ...recordArr), this.adjustBeforeChangedRecordsMap(index, recordArr.length);
|
|
422
|
+
for (let i = 0; i < recordArr.length; i++) this.currentIndexedData.push(this.currentIndexedData.length);
|
|
423
|
+
this._sourceLength += recordArr.length;
|
|
424
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) for (let j = 0; j < recordArr.length; j++) this.fieldAggregators[i].push(recordArr[j]);
|
|
425
|
+
}
|
|
426
|
+
if (this.userPagination) {
|
|
427
|
+
this.pagination.totalCount = this._sourceLength;
|
|
428
|
+
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
429
|
+
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
430
|
+
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
431
|
+
this.updatePagerData();
|
|
432
|
+
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, recordArr.length);
|
|
365
433
|
}
|
|
366
|
-
|
|
367
|
-
this.pagination.totalCount = this._sourceLength;
|
|
368
|
-
const {perPageCount: perPageCount, currentPage: currentPage} = this.pagination;
|
|
369
|
-
index < perPageCount * (currentPage || 0) + perPageCount && this.updatePagerData();
|
|
370
|
-
} else this.pagination.perPageCount = this._sourceLength, this.pagination.totalCount = this._sourceLength,
|
|
371
|
-
this.updatePagerData();
|
|
372
|
-
(null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.added) && this.dataSourceObj.added(index, recordArr.length);
|
|
434
|
+
return;
|
|
373
435
|
}
|
|
436
|
+
const rawRecords = this._getRawRecordsArray();
|
|
437
|
+
if (!rawRecords || !Array.isArray(recordArr) || 0 === recordArr.length) return;
|
|
438
|
+
const viewInsertIndex = this._normalizeInsertIndex(index, this.records.length), rawInsertIndex = this._hasFilterInEffect() ? this._mapViewInsertIndexToRawInsertIndex(rawRecords, viewInsertIndex) : this._normalizeInsertIndex(viewInsertIndex, rawRecords.length);
|
|
439
|
+
if (rawRecords.splice(rawInsertIndex, 0, ...recordArr), syncToOriginalRecords && this._hasFilterInEffect()) for (let i = 0; i < recordArr.length; i++) this.markForceVisibleRecord(recordArr[i]);
|
|
440
|
+
this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
441
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.added) && this.dataSourceObj.added(rawInsertIndex, recordArr.length);
|
|
374
442
|
}
|
|
375
443
|
addRecordForSorted(record) {
|
|
376
444
|
Array.isArray(this.records) && (this.beforeChangedRecordsMap.clear(), this.records.push(record),
|
|
@@ -389,28 +457,48 @@ export class DataSource extends EventTarget {
|
|
|
389
457
|
}
|
|
390
458
|
}
|
|
391
459
|
adjustBeforeChangedRecordsMap(insertIndex, insertCount, type = "add") {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
460
|
+
const delta = "add" === type ? insertCount : -insertCount, numericKeys = [];
|
|
461
|
+
this.beforeChangedRecordsMap.forEach(((_, key) => {
|
|
462
|
+
const numKey = Number(key);
|
|
463
|
+
Number.isInteger(numKey) && numKey.toString() === key && numKey >= insertIndex && numericKeys.push(numKey);
|
|
464
|
+
})), numericKeys.sort(((a, b) => "add" === type ? b - a : a - b));
|
|
465
|
+
for (let i = 0; i < numericKeys.length; i++) {
|
|
466
|
+
const key = numericKeys[i], record = this.beforeChangedRecordsMap.get(key.toString());
|
|
467
|
+
this.beforeChangedRecordsMap.delete(key.toString()), this.beforeChangedRecordsMap.set((key + delta).toString(), record);
|
|
395
468
|
}
|
|
396
469
|
}
|
|
397
|
-
deleteRecords(recordIndexs) {
|
|
398
|
-
var _a;
|
|
399
|
-
if (
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
470
|
+
deleteRecords(recordIndexs, syncToOriginalRecords = !1) {
|
|
471
|
+
var _a, _b, _c;
|
|
472
|
+
if (!syncToOriginalRecords) {
|
|
473
|
+
if (Array.isArray(this.records)) {
|
|
474
|
+
const realDeletedRecordIndexs = [], recordIndexsMaxToMin = recordIndexs.sort(((a, b) => b - a));
|
|
475
|
+
for (let index = 0; index < recordIndexsMaxToMin.length; index++) {
|
|
476
|
+
const recordIndex = recordIndexsMaxToMin[index];
|
|
477
|
+
if (recordIndex >= this._sourceLength || recordIndex < 0) continue;
|
|
478
|
+
this.adjustBeforeChangedRecordsMap(recordIndex, 1, "delete"), realDeletedRecordIndexs.push(recordIndex);
|
|
479
|
+
const deletedRecord = this.records[recordIndex];
|
|
480
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].deleteRecord(deletedRecord);
|
|
481
|
+
this.records.splice(recordIndex, 1), this.currentIndexedData.pop(), this._sourceLength -= 1;
|
|
482
|
+
}
|
|
483
|
+
return this.userPagination || (this.pagination.perPageCount = this._sourceLength,
|
|
484
|
+
this.pagination.totalCount = this._sourceLength), this.updatePagerData(), (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.deleted) && this.dataSourceObj.deleted(realDeletedRecordIndexs),
|
|
485
|
+
realDeletedRecordIndexs;
|
|
408
486
|
}
|
|
409
|
-
return
|
|
410
|
-
this.pagination.totalCount = this._sourceLength), this.updatePagerData(), (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.deleted) && this.dataSourceObj.deleted(realDeletedRecordIndexs),
|
|
411
|
-
realDeletedRecordIndexs;
|
|
487
|
+
return [];
|
|
412
488
|
}
|
|
413
|
-
|
|
489
|
+
const rawRecords = this._getRawRecordsArray();
|
|
490
|
+
if (!rawRecords || !Array.isArray(this.records)) return [];
|
|
491
|
+
const realDeletedRecordIndexs = [], recordIndexsMaxToMin = recordIndexs.slice().sort(((a, b) => b - a)), rawDeletedIndexs = [];
|
|
492
|
+
for (let index = 0; index < recordIndexsMaxToMin.length; index++) {
|
|
493
|
+
const viewIndex = recordIndexsMaxToMin[index];
|
|
494
|
+
if (viewIndex >= this.records.length || viewIndex < 0) continue;
|
|
495
|
+
const deletedRecord = this.records[viewIndex], rawIndex = rawRecords.indexOf(deletedRecord);
|
|
496
|
+
rawIndex >= 0 && (rawRecords.splice(rawIndex, 1), rawDeletedIndexs.push(rawIndex)),
|
|
497
|
+
realDeletedRecordIndexs.push(viewIndex);
|
|
498
|
+
}
|
|
499
|
+
return this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.filterRules),
|
|
500
|
+
(null === (_c = this.dataSourceObj) || void 0 === _c ? void 0 : _c.deleted) && this.dataSourceObj.deleted(rawDeletedIndexs),
|
|
501
|
+
realDeletedRecordIndexs;
|
|
414
502
|
}
|
|
415
503
|
deleteRecordsForSorted(recordIndexs) {
|
|
416
504
|
if (Array.isArray(this.records)) {
|
|
@@ -425,20 +513,38 @@ export class DataSource extends EventTarget {
|
|
|
425
513
|
this.pagination.totalCount = this._sourceLength), this.beforeChangedRecordsMap.clear();
|
|
426
514
|
}
|
|
427
515
|
}
|
|
428
|
-
updateRecords(records, recordIndexs) {
|
|
429
|
-
|
|
516
|
+
updateRecords(records, recordIndexs, syncToOriginalRecords = !1) {
|
|
517
|
+
var _a;
|
|
518
|
+
if (!syncToOriginalRecords) {
|
|
519
|
+
const realDeletedRecordIndexs = [];
|
|
520
|
+
for (let index = 0; index < recordIndexs.length; index++) {
|
|
521
|
+
const recordIndex = recordIndexs[index];
|
|
522
|
+
if (Array.isArray(recordIndex)) this.beforeChangedRecordsMap.delete(recordIndex.toString()),
|
|
523
|
+
realDeletedRecordIndexs.push(recordIndex), recordIndex.slice(0, -1).reduce(((acc, key) => (void 0 === acc[key] && (acc[key] = {}),
|
|
524
|
+
acc[key].children)), this.records)[recordIndex[recordIndex.length - 1]] = records[index]; else {
|
|
525
|
+
if (recordIndex >= this._sourceLength || recordIndex < 0) continue;
|
|
526
|
+
this.beforeChangedRecordsMap.delete(recordIndex.toString()), realDeletedRecordIndexs.push(recordIndex);
|
|
527
|
+
for (let i = 0; i < this.fieldAggregators.length; i++) this.fieldAggregators[i].updateRecord(this.records[recordIndex], records[index]);
|
|
528
|
+
this.records[recordIndex] = records[index];
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
return this.userPagination && this.updatePagerData(), realDeletedRecordIndexs;
|
|
532
|
+
}
|
|
533
|
+
const rawRecords = this._getRawRecordsArray();
|
|
534
|
+
if (!rawRecords || !Array.isArray(this.records)) return [];
|
|
535
|
+
const realUpdatedIndexs = [];
|
|
430
536
|
for (let index = 0; index < recordIndexs.length; index++) {
|
|
431
537
|
const recordIndex = recordIndexs[index];
|
|
432
538
|
if (Array.isArray(recordIndex)) this.beforeChangedRecordsMap.delete(recordIndex.toString()),
|
|
433
|
-
|
|
434
|
-
acc[key].children)),
|
|
435
|
-
if (recordIndex >= this.
|
|
436
|
-
this.
|
|
437
|
-
|
|
438
|
-
this.records[recordIndex] = records[index];
|
|
539
|
+
realUpdatedIndexs.push(recordIndex), recordIndex.slice(0, -1).reduce(((acc, key) => (void 0 === acc[key] && (acc[key] = {}),
|
|
540
|
+
acc[key].children)), rawRecords)[recordIndex[recordIndex.length - 1]] = records[index]; else {
|
|
541
|
+
if (recordIndex >= this.records.length || recordIndex < 0) continue;
|
|
542
|
+
const oldRecord = this.records[recordIndex], rawIndex = rawRecords.indexOf(oldRecord);
|
|
543
|
+
rawIndex >= 0 && (rawRecords[rawIndex] = records[index]), realUpdatedIndexs.push(recordIndex);
|
|
439
544
|
}
|
|
440
545
|
}
|
|
441
|
-
return this.
|
|
546
|
+
return this.beforeChangedRecordsMap.clear(), this.sortedIndexMap.clear(), this.updateFilterRules(null === (_a = this.dataConfig) || void 0 === _a ? void 0 : _a.filterRules),
|
|
547
|
+
realUpdatedIndexs;
|
|
442
548
|
}
|
|
443
549
|
updateRecordsForSorted(records, recordIndexs) {
|
|
444
550
|
const realDeletedRecordIndexs = [];
|
|
@@ -504,23 +610,31 @@ export class DataSource extends EventTarget {
|
|
|
504
610
|
setSortedIndexMap(field, filedMap) {
|
|
505
611
|
this.sortedIndexMap.set(field, filedMap);
|
|
506
612
|
}
|
|
613
|
+
markForceVisibleRecord(record) {
|
|
614
|
+
!record || "object" != typeof record && "function" != typeof record || (this._forceVisibleRecords || (this._forceVisibleRecords = new WeakSet),
|
|
615
|
+
this._forceVisibleRecords.add(record));
|
|
616
|
+
}
|
|
617
|
+
clearForceVisibleRecords() {
|
|
618
|
+
this._forceVisibleRecords = void 0;
|
|
619
|
+
}
|
|
507
620
|
clearFilteredChildren(record) {
|
|
508
621
|
var _a, _b;
|
|
509
622
|
record.filteredChildren = void 0;
|
|
510
623
|
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]);
|
|
511
624
|
}
|
|
512
625
|
filterRecord(record) {
|
|
513
|
-
var _a, _b, _c;
|
|
626
|
+
var _a, _b, _c, _d;
|
|
627
|
+
if (null === (_a = this._forceVisibleRecords) || void 0 === _a ? void 0 : _a.has(record)) return !0;
|
|
514
628
|
let isReserved = !0;
|
|
515
|
-
for (let i = 0; i < (null === (
|
|
516
|
-
const filterRule = null === (
|
|
629
|
+
for (let i = 0; i < (null === (_b = this.dataConfig.filterRules) || void 0 === _b ? void 0 : _b.length); i++) {
|
|
630
|
+
const filterRule = null === (_c = this.dataConfig) || void 0 === _c ? void 0 : _c.filterRules[i];
|
|
517
631
|
if (filterRule.filterKey) {
|
|
518
632
|
const filterValue = record[filterRule.filterKey];
|
|
519
633
|
if (-1 === filterRule.filteredValues.indexOf(filterValue)) {
|
|
520
634
|
isReserved = !1;
|
|
521
635
|
break;
|
|
522
636
|
}
|
|
523
|
-
} else if (!(null === (
|
|
637
|
+
} else if (!(null === (_d = filterRule.filterFunc) || void 0 === _d ? void 0 : _d.call(filterRule, record))) {
|
|
524
638
|
isReserved = !1;
|
|
525
639
|
break;
|
|
526
640
|
}
|