@lavalogic/scoria 0.11.10 → 0.11.12
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,21 +114,20 @@ 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) {
|
|
124
|
+
void this.selectedItems;
|
|
115
125
|
untrack(() => {
|
|
116
126
|
if (this.paginationRepo?.paginationState.pageIndex != undefined &&
|
|
117
127
|
this.paginationRepo?.paginationState.pageSize != undefined) {
|
|
118
128
|
this.updateSelectedItems();
|
|
119
129
|
this.resetHighlightedRows();
|
|
130
|
+
this.recalculateAllSelectedInCurrentPage();
|
|
120
131
|
}
|
|
121
132
|
});
|
|
122
133
|
}
|
|
@@ -668,18 +679,10 @@ export class TableContext {
|
|
|
668
679
|
set filteredIndices(v) {
|
|
669
680
|
this._filteredIndices = v;
|
|
670
681
|
}
|
|
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
|
-
});
|
|
682
|
+
_filteredData = $state([]);
|
|
683
|
+
get filteredData() {
|
|
684
|
+
return this._filteredData;
|
|
685
|
+
}
|
|
683
686
|
_sortedData = $state([]);
|
|
684
687
|
get sortedData() {
|
|
685
688
|
return this._sortedData;
|
|
@@ -714,8 +717,6 @@ export class TableContext {
|
|
|
714
717
|
const rows = sortedData.map((item, index) => {
|
|
715
718
|
const unsortedIndex = this._originalRowIndices.get(item) ?? index;
|
|
716
719
|
if (!item) {
|
|
717
|
-
console.log($state.snapshot(sortedData));
|
|
718
|
-
console.log($state.snapshot(this._originalRowIndices));
|
|
719
720
|
throw new Error(`No Item was found at index ${index}`);
|
|
720
721
|
}
|
|
721
722
|
const row = {
|
|
@@ -849,7 +850,6 @@ export class TableContext {
|
|
|
849
850
|
else {
|
|
850
851
|
this.selectedItems.delete(key);
|
|
851
852
|
}
|
|
852
|
-
this.recalculateAllSelectedInCurrentPage();
|
|
853
853
|
};
|
|
854
854
|
setSelectionMap = (set) => {
|
|
855
855
|
this.selectedItems = set;
|
|
@@ -875,7 +875,7 @@ export class TableContext {
|
|
|
875
875
|
const item = this.sortedData[index];
|
|
876
876
|
// HACK: Please find why this is happening and fix it properly
|
|
877
877
|
if (!item) {
|
|
878
|
-
console.warn(`skipping update because there is a data mismatch
|
|
878
|
+
console.warn(`skipping update because there is a data mismatch (with selectable method)`);
|
|
879
879
|
return;
|
|
880
880
|
}
|
|
881
881
|
if (await selectableMethod(item, index)) {
|
|
@@ -888,13 +888,12 @@ export class TableContext {
|
|
|
888
888
|
const item = this.sortedData[index];
|
|
889
889
|
// HACK: Please find why this is happening and fix it properly
|
|
890
890
|
if (!item) {
|
|
891
|
-
console.warn(`skipping update because there is a data mismatch
|
|
891
|
+
console.warn(`skipping update because there is a data mismatch (no selectable method)`);
|
|
892
892
|
return;
|
|
893
893
|
}
|
|
894
894
|
updateSelectedItem(item);
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
|
-
this.recalculateAllSelectedInCurrentPage();
|
|
898
897
|
};
|
|
899
898
|
resetSelectedItems = () => {
|
|
900
899
|
for (const key of this.selectedItems.keys()) {
|
|
@@ -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 () => {
|
|
@@ -947,7 +954,6 @@ export class TableContext {
|
|
|
947
954
|
}
|
|
948
955
|
}
|
|
949
956
|
}
|
|
950
|
-
this.recalculateAllSelectedInCurrentPage();
|
|
951
957
|
};
|
|
952
958
|
onHighlightAll = () => {
|
|
953
959
|
if (!this.dataRepo) {
|