@lavalogic/scoria 0.37.54 → 0.37.55

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.
@@ -23,15 +23,24 @@ export interface JSONTableLayout {
23
23
  visibility: VisibilityState;
24
24
  /** Pinned-left / pinned-right column ids with their pinned widths. */
25
25
  pinning: JSONColumnPinningState;
26
- /** Per-column user-set widths in pixels. */
26
+ /**
27
+ * Widths (px) of columns the user has explicitly resized, keyed by
28
+ * column id. Columns absent from this map keep their factory-default
29
+ * width; on restore each entry sets the def's `width` and marks it
30
+ * `userResized` so the grid renders the fixed track.
31
+ */
27
32
  sizing: ColumnSizingState;
28
33
  }
29
34
  /**
30
35
  * Schema version for the persisted `JSONTableLayout` envelope. Bump when
31
- * the shape changes in a backwards-incompatible way; `readVersionedJSON`
32
- * silently drops envelopes written under a different version.
36
+ * the shape or field semantics change in a backwards-incompatible way;
37
+ * `readVersionedJSON` silently drops envelopes written under a different
38
+ * version.
39
+ *
40
+ * v2: `sizing` switched from a snapshot of the (vestigial) `columnSizing`
41
+ * map to the real per-`ColumnDef` `width` of user-resized columns.
33
42
  */
34
- export declare const TABLE_LAYOUT_SCHEMA_VERSION = 1;
43
+ export declare const TABLE_LAYOUT_SCHEMA_VERSION = 2;
35
44
  /**
36
45
  * Conservative typeguard for a persisted `JSONTableLayout`. localStorage
37
46
  * is same-origin-writable so the decoded value is untrusted; this checks
@@ -1,9 +1,13 @@
1
1
  /**
2
2
  * Schema version for the persisted `JSONTableLayout` envelope. Bump when
3
- * the shape changes in a backwards-incompatible way; `readVersionedJSON`
4
- * silently drops envelopes written under a different version.
3
+ * the shape or field semantics change in a backwards-incompatible way;
4
+ * `readVersionedJSON` silently drops envelopes written under a different
5
+ * version.
6
+ *
7
+ * v2: `sizing` switched from a snapshot of the (vestigial) `columnSizing`
8
+ * map to the real per-`ColumnDef` `width` of user-resized columns.
5
9
  */
6
- export const TABLE_LAYOUT_SCHEMA_VERSION = 1;
10
+ export const TABLE_LAYOUT_SCHEMA_VERSION = 2;
7
11
  /**
8
12
  * Conservative typeguard for a persisted `JSONTableLayout`. localStorage
9
13
  * is same-origin-writable so the decoded value is untrusted; this checks
@@ -1826,11 +1826,23 @@ export class TableContext {
1826
1826
  left: [...(this.columnPinning.left?.entries() ?? [])],
1827
1827
  right: [...(this.columnPinning.right?.entries() ?? [])],
1828
1828
  };
1829
+ // Width state lives on each `ColumnDef` (`width` + `userResized`),
1830
+ // not in `columnSizing`: the grid template reads the def fields and
1831
+ // the resize-handle drag writes them. Persist only columns the user
1832
+ // has actually resized; the rest keep their factory-default width.
1833
+ // Reading `userResized` / `width` here also makes the auto-persist
1834
+ // `$effect` re-run on every drag-resize.
1835
+ const sizing = {};
1836
+ for (const def of this.columnDefs) {
1837
+ if (def.userResized) {
1838
+ sizing[def.id] = def.width;
1839
+ }
1840
+ }
1829
1841
  return {
1830
1842
  columnOrder,
1831
1843
  visibility: { ...this.columnVisibility },
1832
1844
  pinning,
1833
- sizing: { ...this.columnSizing },
1845
+ sizing,
1834
1846
  };
1835
1847
  }
1836
1848
  /**
@@ -1863,7 +1875,7 @@ export class TableContext {
1863
1875
  return def;
1864
1876
  });
1865
1877
  this.columnDefs = ordered;
1866
- // Visibility / sizing: keep only ids still present in the table.
1878
+ // Visibility: keep only ids still present in the table.
1867
1879
  const visibility = {};
1868
1880
  for (const [id, visible] of Object.entries(layout.visibility)) {
1869
1881
  if (byId.has(id)) {
@@ -1871,13 +1883,16 @@ export class TableContext {
1871
1883
  }
1872
1884
  }
1873
1885
  this.columnVisibility = visibility;
1874
- const sizing = {};
1886
+ // Sizing: restore user-resized widths onto the matching defs. The
1887
+ // grid template reads `def.width` + `def.userResized`, so set both;
1888
+ // columns absent from the snapshot keep their factory default.
1875
1889
  for (const [id, width] of Object.entries(layout.sizing)) {
1876
- if (byId.has(id)) {
1877
- sizing[id] = width;
1890
+ const def = byId.get(id);
1891
+ if (def) {
1892
+ def.width = width;
1893
+ def.userResized = true;
1878
1894
  }
1879
1895
  }
1880
- this.columnSizing = sizing;
1881
1896
  this.columnPinning = adaptJSONPinningState(layout.pinning);
1882
1897
  }
1883
1898
  /**
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.37.54",
4
+ "version": "0.37.55",
5
5
  "publishConfig": {
6
6
  "access": "restricted"
7
7
  },