react-glide-table 1.7.0 → 2.0.1

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/README.md CHANGED
@@ -74,7 +74,8 @@ export function Products({ data }: { data: Product[] }) {
74
74
  | `slots.Pending` / `slots.Empty` | Loading and empty states |
75
75
  | `className` / column `className` / `headerClassName` | Extra class hooks |
76
76
  | `labels` / `summary` / `toolbar` | Copy and slot nodes |
77
- | `Column.render` | Cell content custom render |
77
+ | `Column.render` | Cell content custom render (single context object; prefer `update`) |
78
+ | `Column.kind` / `cellRenderers` | Built-in or custom cell kinds (override / add via registry) |
78
79
 
79
80
  Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
80
81
 
@@ -83,10 +84,59 @@ Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
83
84
 
84
85
  Example: `row: "data-[selected]:bg-blue-600"`.
85
86
 
86
- Row-level UI → `slots.Row`. Cell content → `Column.render`. Header/Cell are not separate slots.
87
+ Row-level UI → `slots.Row`. Cell content → `Column.render` or `Column.kind`. Header/Cell are not separate slots.
87
88
 
88
89
  `slots.Scroll` receives `{ scrollRef, className, children }`. Attach `scrollRef` to the element that owns overflow scrolling — virtualization depends on it. Styling-only changes can stay on `classNames.scroll`.
89
90
 
91
+ ### Cell render context (`Column.render`)
92
+
93
+ **Breaking change (v2.0.0):** `render` receives one context object (not positional args). Destructure only what you need.
94
+
95
+ ```tsx
96
+ <ProductTable.Column
97
+ field="status"
98
+ render={({ value, update }) => (
99
+ <button type="button" onClick={() => update("done")}>
100
+ {String(value)}
101
+ </button>
102
+ )}
103
+ />
104
+ ```
105
+
106
+ `update` commits through `onCellChange` (preferred) or `onDataChange`. Prefer `update` over calling `setData` inside the render.
107
+
108
+ Double-click inline editing (`editable` / `editType`) stays separate: use it for overlay text/number edits; use `render` + `update` for always-visible controls.
109
+
110
+ ### Cell kinds (`Column.kind` + `cellRenderers`)
111
+
112
+ Built-ins (DOM, inspired by [Glide All Cell Kinds](https://glideapps.github.io/glide-data-grid/?path=/story/glide-data-grid-dataeditor-demos--all-cell-kinds)):
113
+ `text`, `number`, `boolean`, `uri`, `image`, `bubble`, `markdown`, `drilldown`, `loading`, `protected`, `row-id`.
114
+
115
+ Priority: **column `render` > registry `kind` > default text**.
116
+
117
+ ```tsx
118
+ const buttonRenderer = {
119
+ kind: "my-button",
120
+ render: ({ value, update }) => (
121
+ <button type="button" onClick={() => update("done")}>
122
+ {String(value)}
123
+ </button>
124
+ ),
125
+ };
126
+
127
+ <ProductTable cellRenderers={[buttonRenderer]}>
128
+ <ProductTable.Header>
129
+ <ProductTable.Column field="active" kind="boolean">
130
+ Active
131
+ </ProductTable.Column>
132
+ <ProductTable.Column field="action" kind="my-button">
133
+ Action
134
+ </ProductTable.Column>
135
+ </ProductTable.Header>
136
+ </ProductTable>
137
+ ```
138
+
139
+ Same `kind` in `cellRenderers` overrides the builtin. Extra kinds are added by key.
90
140
  ## Escape hatch (`useGlideTable`)
91
141
 
92
142
  ```tsx
@@ -216,6 +266,8 @@ Opt in with `enableColumnResize`. Drag the handle on the right edge of a header
216
266
 
217
267
  Opt in with `enableColumnFreeze`. Mark columns with `frozen` — sticky insets are stacked so frozen cells never overlap, and **column order is unchanged** (middle columns may also freeze).
218
268
 
269
+ Keep vertical stickiness on the header via `classNames.head` (e.g. `sticky top-0`). Frozen header cells only stick horizontally (`left` / `right`); setting `top` on both `thead` and frozen `th` can detach the freeze band.
270
+
219
271
  ```tsx
220
272
  <ProductTable data={data} enableColumnFreeze>
221
273
  <ProductTable.Header>