@lavalogic/scoria 0.11.10 → 0.11.11
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.
|
@@ -147,7 +147,8 @@ export declare class TableContext<T extends object> {
|
|
|
147
147
|
private _filteredIndices;
|
|
148
148
|
get filteredIndices(): number[];
|
|
149
149
|
set filteredIndices(v: number[]);
|
|
150
|
-
|
|
150
|
+
private _filteredData;
|
|
151
|
+
get filteredData(): T[];
|
|
151
152
|
private _sortedData;
|
|
152
153
|
get sortedData(): T[];
|
|
153
154
|
readonly sortedRowModel: RowModel<T>;
|
|
@@ -67,13 +67,25 @@ export class TableContext {
|
|
|
67
67
|
this._dataRepo = $state(dataRepo);
|
|
68
68
|
// this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
|
|
69
69
|
$effect(() => {
|
|
70
|
+
const fd = (() => {
|
|
71
|
+
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
72
|
+
const data = this.showSelectedOnly
|
|
73
|
+
? // FIXME this will show the selected items by order of insertion to the selectedItems map.
|
|
74
|
+
[...this.selectedItems.values()]
|
|
75
|
+
: (this.filteredIndices.map((index) => {
|
|
76
|
+
return dataRepo.data[index];
|
|
77
|
+
}) ?? []);
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
return this.showSelectedOnly ? [...this.selectedItems.values()] : (dataRepo?.data ?? []);
|
|
81
|
+
})();
|
|
70
82
|
const sd = (() => {
|
|
71
83
|
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
72
|
-
const state =
|
|
84
|
+
const state = dataRepo.sorting ?? [];
|
|
73
85
|
const sortedData = this.showSelectedOnly
|
|
74
86
|
? // FIXME this will show the selected items by order of insertion to the selectedItems map.
|
|
75
87
|
[...this.selectedItems.values()]
|
|
76
|
-
:
|
|
88
|
+
: fd.concat();
|
|
77
89
|
sortedData.sort((a, b) => {
|
|
78
90
|
const end = state.length;
|
|
79
91
|
for (let i = 0; i < end; i++) {
|
|
@@ -93,7 +105,7 @@ export class TableContext {
|
|
|
93
105
|
});
|
|
94
106
|
return sortedData;
|
|
95
107
|
}
|
|
96
|
-
return
|
|
108
|
+
return fd ?? [];
|
|
97
109
|
})();
|
|
98
110
|
const cpd = (() => {
|
|
99
111
|
if (dataRepo.paginationType != PaginationType.Local) {
|
|
@@ -102,13 +114,10 @@ export class TableContext {
|
|
|
102
114
|
return sd.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive);
|
|
103
115
|
})();
|
|
104
116
|
const ori = new Map((dataRepo.data ?? []).map((item, index) => [item, index]));
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
}
|
|
117
|
+
this._filteredData = fd;
|
|
118
|
+
this._sortedData = sd;
|
|
119
|
+
this._currentPageData = cpd;
|
|
120
|
+
this._originalRowIndices = ori;
|
|
112
121
|
});
|
|
113
122
|
$effect(() => {
|
|
114
123
|
if (this._currentPageData) {
|
|
@@ -668,18 +677,10 @@ export class TableContext {
|
|
|
668
677
|
set filteredIndices(v) {
|
|
669
678
|
this._filteredIndices = v;
|
|
670
679
|
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
[...this.selectedItems.values()]
|
|
676
|
-
: (this.filteredIndices.map((index) => {
|
|
677
|
-
return this.dataRepo.data[index];
|
|
678
|
-
}) ?? []);
|
|
679
|
-
return data;
|
|
680
|
-
}
|
|
681
|
-
return this.showSelectedOnly ? [...this.selectedItems.values()] : (this.dataRepo?.data ?? []);
|
|
682
|
-
});
|
|
680
|
+
_filteredData = $state([]);
|
|
681
|
+
get filteredData() {
|
|
682
|
+
return this._filteredData;
|
|
683
|
+
}
|
|
683
684
|
_sortedData = $state([]);
|
|
684
685
|
get sortedData() {
|
|
685
686
|
return this._sortedData;
|
|
@@ -714,8 +715,6 @@ export class TableContext {
|
|
|
714
715
|
const rows = sortedData.map((item, index) => {
|
|
715
716
|
const unsortedIndex = this._originalRowIndices.get(item) ?? index;
|
|
716
717
|
if (!item) {
|
|
717
|
-
console.log($state.snapshot(sortedData));
|
|
718
|
-
console.log($state.snapshot(this._originalRowIndices));
|
|
719
718
|
throw new Error(`No Item was found at index ${index}`);
|
|
720
719
|
}
|
|
721
720
|
const row = {
|
|
@@ -875,7 +874,7 @@ export class TableContext {
|
|
|
875
874
|
const item = this.sortedData[index];
|
|
876
875
|
// HACK: Please find why this is happening and fix it properly
|
|
877
876
|
if (!item) {
|
|
878
|
-
console.warn(`skipping update because there is a data mismatch
|
|
877
|
+
console.warn(`skipping update because there is a data mismatch (with selectable method)`);
|
|
879
878
|
return;
|
|
880
879
|
}
|
|
881
880
|
if (await selectableMethod(item, index)) {
|
|
@@ -888,7 +887,7 @@ export class TableContext {
|
|
|
888
887
|
const item = this.sortedData[index];
|
|
889
888
|
// HACK: Please find why this is happening and fix it properly
|
|
890
889
|
if (!item) {
|
|
891
|
-
console.warn(`skipping update because there is a data mismatch
|
|
890
|
+
console.warn(`skipping update because there is a data mismatch (no selectable method)`);
|
|
892
891
|
return;
|
|
893
892
|
}
|
|
894
893
|
updateSelectedItem(item);
|
|
@@ -903,10 +902,18 @@ export class TableContext {
|
|
|
903
902
|
this.recalculateAllSelectedInCurrentPage();
|
|
904
903
|
};
|
|
905
904
|
recalculateAllSelectedInCurrentPage = () => {
|
|
906
|
-
tick()
|
|
907
|
-
|
|
905
|
+
tick()
|
|
906
|
+
.then(() => {
|
|
907
|
+
this.allSelectedInCurrentPage
|
|
908
|
+
?.then(() => {
|
|
908
909
|
this.hasInvalidSelectedItems = [...this.selectedItems.keys()].some((key) => this._invalidValues.has(key));
|
|
910
|
+
})
|
|
911
|
+
.catch((e) => {
|
|
912
|
+
console.log(e);
|
|
909
913
|
});
|
|
914
|
+
})
|
|
915
|
+
.catch((e) => {
|
|
916
|
+
console.log(e);
|
|
910
917
|
});
|
|
911
918
|
};
|
|
912
919
|
selectAllInCurrentPage = async () => {
|