@lavalogic/scoria 0.11.7 → 0.11.8

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.
@@ -66,7 +66,7 @@ export class TableContext {
66
66
  }
67
67
  this._dataRepo = $state(dataRepo);
68
68
  // this.dataRepo.forceRefresh = this.forceVisibilityUpdate;
69
- const [_sortedData, _currentPageData, _originalRowIndices] = $derived.by(() => {
69
+ $effect(() => {
70
70
  const sd = (() => {
71
71
  if (this.paginationRepo?.paginationType == PaginationType.Local) {
72
72
  const state = this.dataRepo?.sorting ?? [];
@@ -95,19 +95,27 @@ export class TableContext {
95
95
  }
96
96
  return this.filteredData ?? [];
97
97
  })();
98
- const cpd = dataRepo.paginationType == PaginationType.Local
99
- ? sd.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive)
100
- : (sd ?? []);
98
+ const cpd = (() => {
99
+ if (dataRepo.paginationType != PaginationType.Local) {
100
+ return sd ?? [];
101
+ }
102
+ if (dataRepo.pageEndIndexExclusive > sd.length - 1) {
103
+ console.error(`Data Repository reports more items than what exists: End index: ${dataRepo.pageEndIndexExclusive} sorted data:`, $state.snapshot(sd));
104
+ return null;
105
+ }
106
+ return sd.slice(dataRepo.pageStartIndex, dataRepo.pageEndIndexExclusive);
107
+ })();
101
108
  const ori = new Map((dataRepo.data ?? []).map((item, index) => [item, index]));
102
- return [sd, cpd, ori];
103
- });
104
- $effect(() => {
105
- this._sortedData = _sortedData;
106
- this._currentPageData = _currentPageData;
107
- this._originalRowIndices = _originalRowIndices;
109
+ if (cpd != null) {
110
+ this._sortedData = sd;
111
+ this._currentPageData = cpd;
112
+ this._originalRowIndices = ori;
113
+ }
114
+ else {
115
+ }
108
116
  });
109
117
  $effect(() => {
110
- if (_currentPageData) {
118
+ if (this._currentPageData) {
111
119
  untrack(() => {
112
120
  if (this.paginationRepo?.paginationState.pageIndex != undefined &&
113
121
  this.paginationRepo?.paginationState.pageSize != undefined) {
@@ -355,12 +363,7 @@ export class TableContext {
355
363
  return this._columnDefs;
356
364
  }
357
365
  set columnDefs(v) {
358
- // if (this._columnDefs.length > 0 && v != this._columnDefs) {
359
- // debugger;
360
- // }
361
366
  this._columnDefs = v;
362
- // this causes an error...?
363
- // this.table = createTable(this.tableOptions);
364
367
  }
365
368
  _columnPresets = $state([]);
366
369
  get columnPresets() {
@@ -967,7 +970,6 @@ export class TableContext {
967
970
  onEditCell = async (item, coords, value) => {
968
971
  const oldKey = this.selectionExtractor?.(item);
969
972
  const wasSelected = oldKey != null && this.selectedItems.has(oldKey);
970
- // debugger;
971
973
  if (wasSelected) {
972
974
  this.selectedItems.delete(oldKey);
973
975
  }
@@ -1886,8 +1888,8 @@ export class TableContext {
1886
1888
  for (const item of selectedRows) {
1887
1889
  const rowIndex = this.sortedData.indexOf(item);
1888
1890
  if (rowIndex == -1) {
1889
- // eslint-disable-next-line no-debugger
1890
- debugger;
1891
+ console.warn(`row index for highlighted row data not found`);
1892
+ continue;
1891
1893
  }
1892
1894
  indices.set(item, rowIndex);
1893
1895
  }
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.7",
4
+ "version": "0.11.8",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },