@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
- readonly filteredData: T[];
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 = this.dataRepo?.sorting ?? [];
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
- : this.filteredData.concat();
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 this.filteredData ?? [];
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
- if (cpd != null) {
106
- this._sortedData = sd;
107
- this._currentPageData = cpd;
108
- this._originalRowIndices = ori;
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
- filteredData = $derived.by(() => {
672
- if (this.paginationRepo?.paginationType == PaginationType.Local) {
673
- const data = this.showSelectedOnly
674
- ? // FIXME this will show the selected items by order of insertion to the selectedItems map.
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, page start index: ${pageStartIndex}, current index ${index}, page end index (exclusive) ${pageEndIndexExclusive}`, $state.snapshot(this.sortedData));
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, page start index: ${pageStartIndex}, current index ${index}, page end index (exclusive) ${pageEndIndexExclusive}`, $state.snapshot(this.sortedData));
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().then(() => {
907
- this.allSelectedInCurrentPage?.then(() => {
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 () => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lavalogic/scoria",
3
3
  "description": "Svelte components used for the FloWMS Web Frontend",
4
- "version": "0.11.10",
4
+ "version": "0.11.11",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },