@lavalogic/scoria 0.11.2 → 0.11.3
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.
|
@@ -141,7 +141,6 @@ export declare class TableContext<T extends object> {
|
|
|
141
141
|
private set hasInvalidSelectedItems(value);
|
|
142
142
|
private columnDefsById;
|
|
143
143
|
private readonly getSortingFn;
|
|
144
|
-
readonly originalRowIndices: Map<T, number>;
|
|
145
144
|
private _filterTimer;
|
|
146
145
|
private get filterTimer();
|
|
147
146
|
private set filterTimer(value);
|
|
@@ -152,6 +151,8 @@ export declare class TableContext<T extends object> {
|
|
|
152
151
|
readonly sortedData: T[];
|
|
153
152
|
readonly sortedRowModel: RowModel<T>;
|
|
154
153
|
_currentPageData: T[];
|
|
154
|
+
private _originalRowIndices;
|
|
155
|
+
get originalRowIndices(): Map<T, number>;
|
|
155
156
|
readonly paginationRowModel: RowModel<T>;
|
|
156
157
|
get currentPageData(): T[];
|
|
157
158
|
readonly selectionContains: (item: T) => boolean;
|
|
@@ -66,6 +66,13 @@ export class TableContext {
|
|
|
66
66
|
}
|
|
67
67
|
this._dataRepo = $state(dataRepo);
|
|
68
68
|
// this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
|
|
69
|
+
[this._currentPageData, this._originalRowIndices] = $derived.by(() => {
|
|
70
|
+
const x = this.dataRepo?.paginationType == PaginationType.Local
|
|
71
|
+
? this.sortedData.slice(this.dataRepo.pageStartIndex, this.dataRepo.pageEndIndexExclusive)
|
|
72
|
+
: (this.sortedData ?? []);
|
|
73
|
+
const y = new Map((this.dataRepo?.data ?? []).map((item, index) => [item, index]));
|
|
74
|
+
return [x, y];
|
|
75
|
+
});
|
|
69
76
|
if (defaultColumnDefs.remoteFilters) {
|
|
70
77
|
this.remoteFilters = defaultColumnDefs.remoteFilters;
|
|
71
78
|
}
|
|
@@ -600,9 +607,6 @@ export class TableContext {
|
|
|
600
607
|
// }
|
|
601
608
|
return comparableSortingFn(id, desc);
|
|
602
609
|
};
|
|
603
|
-
// FIXME this is most likely the cuplrit for add pod not working on receipt. It may be one tick behind the other values
|
|
604
|
-
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
605
|
-
originalRowIndices = $derived(new Map((this.dataRepo?.data ?? []).map((item, index) => [item, index])));
|
|
606
610
|
// private _filterTimer: ReturnType<typeof setTimeout> | undefined;
|
|
607
611
|
_filterTimer = 1;
|
|
608
612
|
get filterTimer() {
|
|
@@ -660,11 +664,11 @@ export class TableContext {
|
|
|
660
664
|
});
|
|
661
665
|
sortedRowModel = $derived.by(() => {
|
|
662
666
|
const rows = this.sortedData.map((item, index) => {
|
|
663
|
-
const originalIndex = this.
|
|
667
|
+
const originalIndex = this._originalRowIndices.get(item);
|
|
664
668
|
const unsortedIndex = originalIndex ?? index;
|
|
665
669
|
if (originalIndex == null) {
|
|
666
670
|
console.log($state.snapshot(this.sortedData));
|
|
667
|
-
console.log($state.snapshot(this.
|
|
671
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
668
672
|
throw new Error(`Sorted Data not found in Original Row Indices: original index ${originalIndex}, index ${index}`);
|
|
669
673
|
}
|
|
670
674
|
return this.createRow(item, index, unsortedIndex);
|
|
@@ -675,16 +679,20 @@ export class TableContext {
|
|
|
675
679
|
rowsById: new Map(rows.map((it, index) => [index.toString(), it])) //FIXME should this be by sorted id or by original id?
|
|
676
680
|
};
|
|
677
681
|
});
|
|
678
|
-
_currentPageData
|
|
679
|
-
|
|
680
|
-
|
|
682
|
+
_currentPageData;
|
|
683
|
+
// FIXME this is most likely the cuplrit for add pod not working on receipt. It may be one tick behind the other values
|
|
684
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
685
|
+
_originalRowIndices;
|
|
686
|
+
get originalRowIndices() {
|
|
687
|
+
return this._originalRowIndices;
|
|
688
|
+
}
|
|
681
689
|
paginationRowModel = $derived.by(() => {
|
|
682
690
|
const sortedData = this._currentPageData;
|
|
683
691
|
const rows = sortedData.map((item, index) => {
|
|
684
|
-
const unsortedIndex = this.
|
|
692
|
+
const unsortedIndex = this._originalRowIndices.get(item) ?? index;
|
|
685
693
|
if (!item) {
|
|
686
694
|
console.log($state.snapshot(sortedData));
|
|
687
|
-
console.log($state.snapshot(this.
|
|
695
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
688
696
|
throw new Error(`No Item was found at index ${index}`);
|
|
689
697
|
}
|
|
690
698
|
const row = {
|
|
@@ -1685,7 +1693,7 @@ export class TableContext {
|
|
|
1685
1693
|
// #region private methods
|
|
1686
1694
|
createRow(item, index, unsortedIndex) {
|
|
1687
1695
|
if (!item) {
|
|
1688
|
-
console.log($state.snapshot(this.
|
|
1696
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
1689
1697
|
throw new Error(`No Item was found at index ${index} (unsorted index ${unsortedIndex})`);
|
|
1690
1698
|
}
|
|
1691
1699
|
const row = {
|