@svelte-lean/table 0.16.1 → 0.16.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @svelte-lean/table
2
2
 
3
+ ## 0.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - @svelte-lean/core@0.16.3
8
+
9
+ ## 0.16.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 6c7e253: `Column.wrap`: in grid layout a column of text that may break onto more lines (a description, a note) no longer pushes a table that fits its card into a sideways scroll. The column stands at its measured content while there is room and narrows down to its `minWidth` (160 by default) before the rows scroll, its cells taking `white-space: normal` (`td[data-wrap]`); it is never clipped. Without `wrap` a column is still never narrower than its one-line content, and a screen too narrow for every column's floor still scrolls sideways.
14
+ - @svelte-lean/core@0.16.2
15
+
3
16
  ## 0.16.1
4
17
 
5
18
  ### Patch Changes
package/dist/style.css CHANGED
@@ -1165,6 +1165,23 @@
1165
1165
  text-overflow: ellipsis;
1166
1166
  display: block;
1167
1167
  }
1168
+ /* A `wrap` column's text breaks onto more lines as its track narrows (`Column.wrap`). */
1169
+ :where(
1170
+ .slean-table[data-layout='grid'] > .slean-table-scroll > table > tbody > tr > td[data-wrap]
1171
+ ),
1172
+ :where(
1173
+ .slean-table[data-layout='grid']
1174
+ > .slean-table-scroll
1175
+ > table
1176
+ > tbody
1177
+ > tr
1178
+ > td[data-wrap]
1179
+ > .slean-table-cell
1180
+ ) {
1181
+ white-space: normal;
1182
+ overflow-wrap: break-word;
1183
+ min-width: 0;
1184
+ }
1168
1185
  :where(.slean-table-scroll > table[data-measuring]) {
1169
1186
  display: block;
1170
1187
  width: max-content;
@@ -515,6 +515,7 @@
515
515
  pin: pin?.pin,
516
516
  edge: pin?.edge,
517
517
  clip: clipped.has(col.id) || undefined,
518
+ wrap: col.wrap || undefined,
518
519
  className: typeof col.class === 'string' ? col.class : undefined,
519
520
  gridClass: `slean-table-cell${typeof col.class === 'string' ? ` ${col.class}` : ''}`,
520
521
  style: pin?.style
@@ -588,6 +589,11 @@
588
589
  */
589
590
  const GRID_MAX = 480;
590
591
  const GRID_MIN = 48;
592
+ /**
593
+ * The narrowest a `wrap` column is squeezed to before the rows scroll sideways (unless its
594
+ * `minWidth` says otherwise): room for a few words a line.
595
+ */
596
+ const WRAP_MIN = 160;
591
597
  const MEASURE_ROWS = 30;
592
598
  /** The most placeholder rows a loading page draws when `skeletonRows` is not given. */
593
599
  const MAX_PLACEHOLDERS = 25;
@@ -605,7 +611,9 @@
605
611
  grid
606
612
  ? cols
607
613
  .filter(
608
- (col) => (measured[col.id] ?? 0) > Math.max(col.maxWidth ?? GRID_MAX, col.width ?? 0)
614
+ (col) =>
615
+ !col.wrap &&
616
+ (measured[col.id] ?? 0) > Math.max(col.maxWidth ?? GRID_MAX, col.width ?? 0)
609
617
  )
610
618
  .map((col) => col.id)
611
619
  : []
@@ -890,9 +898,12 @@
890
898
  * The grid track list, and the width below which the rows scroll sideways. A column is never
891
899
  * narrower than its content (its measured width, a declared `width` or `minWidth`); spare width
892
900
  * is shared in proportion to the content (`fr`). Header labels count with their longest word
893
- * (they wrap), so a long label does not widen a column of short values. When the content does
894
- * not fit, the rows scroll sideways. Pinned and resized columns keep their exact width, which
895
- * the sticky offsets are computed from.
901
+ * (they wrap), so a long label does not widen a column of short values. A `wrap` column is the
902
+ * exception: it stands at its content while there is room, and gives way down to its
903
+ * `minWidth` (default `WRAP_MIN`), its text breaking onto more lines, before the rows scroll —
904
+ * so one long description does not push a table that fits its card into a sideways scroll.
905
+ * When the content does not fit even so (a phone), the rows scroll sideways. Pinned and
906
+ * resized columns keep their exact width, which the sticky offsets are computed from.
896
907
  */
897
908
  const tracksNext = $derived.by(() => {
898
909
  if (!grid) return null;
@@ -906,7 +917,7 @@
906
917
  min += width;
907
918
  continue;
908
919
  }
909
- const floor = width;
920
+ const floor = col.wrap ? Math.min(width, col.minWidth ?? WRAP_MIN) : width;
910
921
  parts.push(`minmax(${floor}px, ${width}fr)`);
911
922
  min += floor;
912
923
  }
@@ -1498,6 +1509,7 @@
1498
1509
  data-pin={meta[col.id]!.pin}
1499
1510
  data-pin-edge={meta[col.id]!.edge}
1500
1511
  data-clip={meta[col.id]!.clip}
1512
+ data-wrap={meta[col.id]!.wrap}
1501
1513
  class={meta[col.id]!.gridClass}
1502
1514
  style={meta[col.id]!.style}>{@render (col.cell ?? plainCell)(contexts[col.id]!)}</td
1503
1515
  >{/each}</tr
@@ -1630,6 +1642,7 @@
1630
1642
  data-cell
1631
1643
  role={grid ? 'cell' : undefined}
1632
1644
  data-clip={clipped.has(col.id) || undefined}
1645
+ data-wrap={col.wrap || undefined}
1633
1646
  data-column={col.id}
1634
1647
  data-align={col.align !== 'start' ? col.align : undefined}
1635
1648
  data-pin={pin?.pin}
@@ -1713,6 +1726,7 @@
1713
1726
  data-cell
1714
1727
  role={grid ? 'cell' : undefined}
1715
1728
  data-clip={meta[col.id]!.clip}
1729
+ data-wrap={meta[col.id]!.wrap}
1716
1730
  data-column={col.id}
1717
1731
  data-align={meta[col.id]!.align}
1718
1732
  data-pin={meta[col.id]!.pin}
@@ -1730,6 +1744,7 @@
1730
1744
  data-pin={meta[col.id]!.pin}
1731
1745
  data-pin-edge={meta[col.id]!.edge}
1732
1746
  data-clip={meta[col.id]!.clip}
1747
+ data-wrap={meta[col.id]!.wrap}
1733
1748
  class={meta[col.id]!.gridClass}
1734
1749
  style={meta[col.id]!.style}>{@render (col.cell ?? plainCell)(contexts[col.id]!)}</td
1735
1750
  >{/each}{:else}{#each cols as col (col.id)}<td
package/dist/types.d.ts CHANGED
@@ -61,6 +61,13 @@ export interface Column<T> {
61
61
  width?: number;
62
62
  minWidth?: number;
63
63
  maxWidth?: number;
64
+ /**
65
+ * Text that may break onto more lines (a description, a note). In grid layout the column
66
+ * stands at its content while there is room and narrows down to `minWidth` (default 160)
67
+ * before the rows scroll sideways, its text wrapping; it is never clipped. Without it a
68
+ * column is never narrower than its one-line content.
69
+ */
70
+ wrap?: boolean;
64
71
  align?: 'start' | 'center' | 'end';
65
72
  sortable?: boolean;
66
73
  /** The first activation sorts descending: descending → ascending → none. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@svelte-lean/table",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "description": "A Svelte-native table and data-grid engine that ships only the features you use.",
5
5
  "license": "MIT",
6
6
  "author": "Ömer Say",
@@ -91,7 +91,7 @@
91
91
  "headless"
92
92
  ],
93
93
  "dependencies": {
94
- "@svelte-lean/core": "^0.16.1",
94
+ "@svelte-lean/core": "^0.16.3",
95
95
  "esm-env": "^1.2.2"
96
96
  }
97
97
  }