@lavalogic/scoria 0.11.12 → 0.11.14
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.
|
@@ -167,6 +167,7 @@ export declare class TableContext<T extends object> {
|
|
|
167
167
|
setSelectionMap: (set: SvelteMap<unknown, T>) => void;
|
|
168
168
|
readonly updateSelectedItems: () => Promise<void>;
|
|
169
169
|
readonly resetSelectedItems: () => void;
|
|
170
|
+
private lastIncrement;
|
|
170
171
|
readonly recalculateAllSelectedInCurrentPage: () => void;
|
|
171
172
|
readonly selectAllInCurrentPage: () => Promise<void>;
|
|
172
173
|
readonly onHighlightAll: () => void;
|
|
@@ -82,11 +82,8 @@ export class TableContext {
|
|
|
82
82
|
const sd = (() => {
|
|
83
83
|
if (this.paginationRepo?.paginationType == PaginationType.Local) {
|
|
84
84
|
const state = dataRepo.sorting ?? [];
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
[...this.selectedItems.values()]
|
|
88
|
-
: fd.concat();
|
|
89
|
-
sortedData.sort((a, b) => {
|
|
85
|
+
const dataToSort = fd.concat();
|
|
86
|
+
dataToSort.sort((a, b) => {
|
|
90
87
|
const end = state.length;
|
|
91
88
|
for (let i = 0; i < end; i++) {
|
|
92
89
|
const { id, desc } = state[i];
|
|
@@ -97,13 +94,13 @@ export class TableContext {
|
|
|
97
94
|
return result;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
|
-
else {
|
|
97
|
+
else if (dev) {
|
|
101
98
|
console.warn('no sorting fn found for ' + id);
|
|
102
99
|
}
|
|
103
100
|
}
|
|
104
101
|
return 0;
|
|
105
102
|
});
|
|
106
|
-
return
|
|
103
|
+
return dataToSort;
|
|
107
104
|
}
|
|
108
105
|
return fd ?? [];
|
|
109
106
|
})();
|
|
@@ -111,7 +108,11 @@ export class TableContext {
|
|
|
111
108
|
if (dataRepo.paginationType != PaginationType.Local) {
|
|
112
109
|
return sd ?? [];
|
|
113
110
|
}
|
|
114
|
-
|
|
111
|
+
const x = sd.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive);
|
|
112
|
+
if (dev) {
|
|
113
|
+
console.log(x);
|
|
114
|
+
}
|
|
115
|
+
return x;
|
|
115
116
|
})();
|
|
116
117
|
const ori = new Map((dataRepo.data ?? []).map((item, index) => [item, index]));
|
|
117
118
|
this._filteredData = fd;
|
|
@@ -713,8 +714,8 @@ export class TableContext {
|
|
|
713
714
|
return this._originalRowIndices;
|
|
714
715
|
}
|
|
715
716
|
paginationRowModel = $derived.by(() => {
|
|
716
|
-
const
|
|
717
|
-
const rows =
|
|
717
|
+
const currentPageData = this._currentPageData;
|
|
718
|
+
const rows = currentPageData.map((item, index) => {
|
|
718
719
|
const unsortedIndex = this._originalRowIndices.get(item) ?? index;
|
|
719
720
|
if (!item) {
|
|
720
721
|
throw new Error(`No Item was found at index ${index}`);
|
|
@@ -798,22 +799,6 @@ export class TableContext {
|
|
|
798
799
|
}
|
|
799
800
|
return this.selectedItems.has(this.selectionExtractor(item));
|
|
800
801
|
};
|
|
801
|
-
// public readonly HACK__reselectItem = (item: T) => {
|
|
802
|
-
// if (!this.selectionExtractor) {
|
|
803
|
-
// throw new Error('No selection extractor was supplied');
|
|
804
|
-
// }
|
|
805
|
-
// if (!this.isSelectable) {
|
|
806
|
-
// return true;
|
|
807
|
-
// }
|
|
808
|
-
// const key = this.selectionExtractor(item);
|
|
809
|
-
// if (this.selectedItems.has(key)) {
|
|
810
|
-
// this.selectedItems.delete(key);
|
|
811
|
-
// this.selectedItems.set(key, item);
|
|
812
|
-
// } else {
|
|
813
|
-
// this.selectedItems.set(key, item);
|
|
814
|
-
// this.selectedItems.delete(key);
|
|
815
|
-
// }
|
|
816
|
-
// };
|
|
817
802
|
addInvalidValue = (item) => {
|
|
818
803
|
this.invalidValues.set(this.selectionExtractor(item), item);
|
|
819
804
|
};
|
|
@@ -832,13 +817,6 @@ export class TableContext {
|
|
|
832
817
|
this.highlightedItems.set(key, item);
|
|
833
818
|
}
|
|
834
819
|
};
|
|
835
|
-
// public readonly toggleHighlightedRow = (rowIndex: number) => {
|
|
836
|
-
// if (this.highlightedRowIndexIds.has(rowIndex)) {
|
|
837
|
-
// this.highlightedRowIndexIds.delete(rowIndex);
|
|
838
|
-
// } else {
|
|
839
|
-
// this.highlightedRowIndexIds.add(rowIndex);
|
|
840
|
-
// }
|
|
841
|
-
// };
|
|
842
820
|
resetHighlightedRows = () => {
|
|
843
821
|
this.highlightedItems.clear();
|
|
844
822
|
};
|
|
@@ -901,16 +879,23 @@ export class TableContext {
|
|
|
901
879
|
}
|
|
902
880
|
this.recalculateAllSelectedInCurrentPage();
|
|
903
881
|
};
|
|
882
|
+
lastIncrement = Number.MIN_SAFE_INTEGER;
|
|
904
883
|
recalculateAllSelectedInCurrentPage = () => {
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
.
|
|
912
|
-
|
|
913
|
-
|
|
884
|
+
const invalidValues = this._invalidValues;
|
|
885
|
+
const allSelectedInCurrentPage = [...this.selectedItems.keys()];
|
|
886
|
+
const currentIncrement = ++this.lastIncrement;
|
|
887
|
+
this.allSelectedInCurrentPage
|
|
888
|
+
?.then(() => {
|
|
889
|
+
if (this.lastIncrement == currentIncrement) {
|
|
890
|
+
this.hasInvalidSelectedItems = allSelectedInCurrentPage.some((key) => {
|
|
891
|
+
return invalidValues.has(key);
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
else {
|
|
895
|
+
if (dev) {
|
|
896
|
+
console.log('skipping recalculation due to stale data');
|
|
897
|
+
}
|
|
898
|
+
}
|
|
914
899
|
})
|
|
915
900
|
.catch((e) => {
|
|
916
901
|
console.log(e);
|