react-gridix 0.2.7 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +44 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1513,6 +1513,50 @@ Other slots work the same way: `root`, `toolbar`, `search`, `table`, `thead`, `h
1513
1513
  #### Width
1514
1514
 
1515
1515
  The grid is `width: 100%` of its container by default (it never overflows it: `max-width: 100%; min-width: 0`). To make it narrower, give it a width through `className` (`max-w-3xl`) or `style` (`{ maxWidth: 900 }`).
1516
+ ## `overflow` column option
1517
+
1518
+ Controls what happens to text that doesn't fit the column, in both the header and the cells.
1519
+
1520
+ | Value | Behavior | Example (width 60) |
1521
+ |---|---|---|
1522
+ | `"wrap"` | Breaks the text onto new lines, even inside a word | `Alexa` / `nder` |
1523
+ | `"ellipsis"` | Cuts the text and shows `...` | `Alexa...` |
1524
+ | `"clip"` | Cuts the text, no dots | `Alexa` |
1525
+
1526
+ **Default** (when `overflow` is not set):
1527
+
1528
+ - Column has a `width`: `"wrap"`
1529
+ - Numeric `width` under 40: `"clip"`
1530
+ - No `width`: the grid's normal behavior
1531
+
1532
+ ### Example
1533
+
1534
+ ```tsx
1535
+ const columns: ColumnDef<Person>[] = [
1536
+ { field: "color", header: "", width: 6 }, // thin strip, "clip" by default
1537
+ { field: "id", header: "ID", width: 50 }, // "wrap" by default
1538
+ { field: "name", header: "Name", width: 120, overflow: "ellipsis" }, // "Alexander Ha..."
1539
+ { field: "notes", header: "Notes", width: 200, overflow: "wrap" }, // new lines
1540
+ { field: "code", header: "Code", width: 80, overflow: "clip" }, // cut off
1541
+ ];
1542
+ ```
1543
+
1544
+ ### Notes
1545
+
1546
+ - Widths under 40 also remove the column's side padding, so `width: 1` really is 1px.
1547
+ - `"wrap"` in a very narrow column puts one character per line and makes rows tall. Use `"ellipsis"` or `"clip"` there.
1548
+ - To show the full text on hover, add a tooltip in a `cellRenderer`:
1549
+
1550
+ ```tsx
1551
+ {
1552
+ field: "name",
1553
+ header: "Name",
1554
+ width: 120,
1555
+ overflow: "ellipsis",
1556
+ cellRenderer: ({ value }) => <span title={String(value)}>{String(value)}</span>,
1557
+ }
1558
+ ```
1559
+
1516
1560
 
1517
1561
  #### Plain CSS class reference
1518
1562
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-gridix",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "A simple React library for displaying arrays in tables",
5
5
  "author": "Felix Ongom",
6
6
  "type": "module",