@lavalogic/scoria 0.11.2 → 0.11.4
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,8 +151,10 @@ export declare class TableContext<T extends object> {
|
|
|
152
151
|
readonly sortedData: T[];
|
|
153
152
|
readonly sortedRowModel: RowModel<T>;
|
|
154
153
|
_currentPageData: T[];
|
|
155
|
-
readonly paginationRowModel: RowModel<T>;
|
|
156
154
|
get currentPageData(): T[];
|
|
155
|
+
private _originalRowIndices;
|
|
156
|
+
get originalRowIndices(): Map<T, number>;
|
|
157
|
+
readonly paginationRowModel: RowModel<T>;
|
|
157
158
|
readonly selectionContains: (item: T) => boolean;
|
|
158
159
|
readonly addInvalidValue: (item: T) => void;
|
|
159
160
|
readonly removeInvalidValue: (item: T) => void;
|
|
@@ -66,6 +66,17 @@ export class TableContext {
|
|
|
66
66
|
}
|
|
67
67
|
this._dataRepo = $state(dataRepo);
|
|
68
68
|
// this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
|
|
69
|
+
const [_currentPageData, _originalRowIndices] = $derived.by(() => {
|
|
70
|
+
const x = dataRepo.paginationType == PaginationType.Local
|
|
71
|
+
? this.sortedData.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive)
|
|
72
|
+
: (this.sortedData ?? []);
|
|
73
|
+
const y = new Map((dataRepo.data ?? []).map((item, index) => [item, index]));
|
|
74
|
+
return [x, y];
|
|
75
|
+
});
|
|
76
|
+
$effect(() => {
|
|
77
|
+
this._currentPageData = _currentPageData;
|
|
78
|
+
this._originalRowIndices = _originalRowIndices;
|
|
79
|
+
});
|
|
69
80
|
if (defaultColumnDefs.remoteFilters) {
|
|
70
81
|
this.remoteFilters = defaultColumnDefs.remoteFilters;
|
|
71
82
|
}
|
|
@@ -600,9 +611,6 @@ export class TableContext {
|
|
|
600
611
|
// }
|
|
601
612
|
return comparableSortingFn(id, desc);
|
|
602
613
|
};
|
|
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
614
|
// private _filterTimer: ReturnType<typeof setTimeout> | undefined;
|
|
607
615
|
_filterTimer = 1;
|
|
608
616
|
get filterTimer() {
|
|
@@ -660,11 +668,11 @@ export class TableContext {
|
|
|
660
668
|
});
|
|
661
669
|
sortedRowModel = $derived.by(() => {
|
|
662
670
|
const rows = this.sortedData.map((item, index) => {
|
|
663
|
-
const originalIndex = this.
|
|
671
|
+
const originalIndex = this._originalRowIndices.get(item);
|
|
664
672
|
const unsortedIndex = originalIndex ?? index;
|
|
665
673
|
if (originalIndex == null) {
|
|
666
674
|
console.log($state.snapshot(this.sortedData));
|
|
667
|
-
console.log($state.snapshot(this.
|
|
675
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
668
676
|
throw new Error(`Sorted Data not found in Original Row Indices: original index ${originalIndex}, index ${index}`);
|
|
669
677
|
}
|
|
670
678
|
return this.createRow(item, index, unsortedIndex);
|
|
@@ -675,16 +683,23 @@ export class TableContext {
|
|
|
675
683
|
rowsById: new Map(rows.map((it, index) => [index.toString(), it])) //FIXME should this be by sorted id or by original id?
|
|
676
684
|
};
|
|
677
685
|
});
|
|
678
|
-
_currentPageData = $
|
|
679
|
-
|
|
680
|
-
|
|
686
|
+
_currentPageData = $state([]);
|
|
687
|
+
get currentPageData() {
|
|
688
|
+
return this._currentPageData;
|
|
689
|
+
}
|
|
690
|
+
// FIXME this is most likely the cuplrit for add pod not working on receipt. It may be one tick behind the other values
|
|
691
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
692
|
+
_originalRowIndices = $state(new Map());
|
|
693
|
+
get originalRowIndices() {
|
|
694
|
+
return this._originalRowIndices;
|
|
695
|
+
}
|
|
681
696
|
paginationRowModel = $derived.by(() => {
|
|
682
697
|
const sortedData = this._currentPageData;
|
|
683
698
|
const rows = sortedData.map((item, index) => {
|
|
684
|
-
const unsortedIndex = this.
|
|
699
|
+
const unsortedIndex = this._originalRowIndices.get(item) ?? index;
|
|
685
700
|
if (!item) {
|
|
686
701
|
console.log($state.snapshot(sortedData));
|
|
687
|
-
console.log($state.snapshot(this.
|
|
702
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
688
703
|
throw new Error(`No Item was found at index ${index}`);
|
|
689
704
|
}
|
|
690
705
|
const row = {
|
|
@@ -755,9 +770,6 @@ export class TableContext {
|
|
|
755
770
|
rowsById: new Map(rows.map((it, index) => [index.toString(), it])) //FIXME should this be by sorted id or by original id?
|
|
756
771
|
};
|
|
757
772
|
});
|
|
758
|
-
get currentPageData() {
|
|
759
|
-
return this._currentPageData;
|
|
760
|
-
}
|
|
761
773
|
// #endregion
|
|
762
774
|
// #region public methods
|
|
763
775
|
selectionContains = (item) => {
|
|
@@ -1685,7 +1697,7 @@ export class TableContext {
|
|
|
1685
1697
|
// #region private methods
|
|
1686
1698
|
createRow(item, index, unsortedIndex) {
|
|
1687
1699
|
if (!item) {
|
|
1688
|
-
console.log($state.snapshot(this.
|
|
1700
|
+
console.log($state.snapshot(this._originalRowIndices));
|
|
1689
1701
|
throw new Error(`No Item was found at index ${index} (unsorted index ${unsortedIndex})`);
|
|
1690
1702
|
}
|
|
1691
1703
|
const row = {
|