Skip to content

Commit 5322e14

Browse files
github-actions[bot]CopilotCopilot
authored
docs: update DataTable docs for badge array support and inferColumns render removal (#291)
- Correct accessor description: badge columns accept array return types; only text/number/money/link reject arrays - Fix compile error example comment to remove 'badge' from the list - Update 'Combining type with inferColumns' section: inferColumns no longer sets a default render function; it derives label, sort, filter, and id only - Update inline comment and trailing note to remove references to 'default render' Prompted by changesets: - badge-array-support.md (BadgeOptions array support, inferColumns render removal) Co-authored-by: Copilot <copilot@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 9bc489e commit 5322e14

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

docs/components/data-table.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ A column definition passed to `useDataTable`. `Column<TRow>` is a discriminated
225225
| `width` | `number` | Fixed column width in pixels. Optional. |
226226
| `align` | `"left" \| "right"` | Horizontal alignment. Defaults to `"right"` for `type: "number"` and `type: "money"`; `"left"` otherwise. Pass `"left"` to opt a numeric column out. |
227227
| `truncate` | `boolean` | Truncate overflowing text with an ellipsis. Wires up an app-shell `<Tooltip>` automatically when the resolved cell value is a string or number — resolved via `accessor` first, then `row[col.id]` as a fallback — so hovering the cell reveals the full value. With `inferColumns`, no explicit `accessor` is needed because `id` is pinned to the field name. Requires another column to anchor the row width (`width` on a neighbor, or a fixed-size column like selection / row actions). |
228-
| `accessor` | _(narrowed per `type`)_ | Extracts the raw value. The return type is narrowed per `type` branch — returning an array or a plain object is a compile error on a typed column. Untyped columns (`type` omitted) retain `unknown`. `null` and `undefined` are always allowed. |
228+
| `accessor` | _(narrowed per `type`)_ | Extracts the raw value. The return type is narrowed per `type` branch — returning an array is a compile error on all typed columns except `badge`, and returning a plain object is a compile error on all typed columns. Untyped columns (`type` omitted) retain `unknown`. `null` and `undefined` are always allowed. |
229229
| `sort` | `SortConfig` | Sort configuration. When set, the column header becomes clickable (Asc → Desc → off). |
230230
| `filter` | `FilterConfig` | Filter configuration. When set, the column appears as an option in `DataTable.Filters`. |
231231

@@ -277,7 +277,7 @@ column({ type: "link", accessor: (r) => r.title });
277277
// ❌ Compile error — text columns reject typeOptions entirely
278278
column({ type: "text", accessor: (r) => r.title, typeOptions: { locale: "en-US" } });
279279

280-
// ❌ Compile error — text/number/money/badge/link accessor cannot return an array or object
280+
// ❌ Compile error — text/number/money/link accessor cannot return an array or object
281281
column({ type: "text", accessor: (row) => row.tags }); // row.tags is string[]
282282
column({ type: "number", accessor: (row) => row.meta }); // row.meta is an object
283283
```
@@ -444,13 +444,13 @@ column({
444444

445445
### Combining `type` with `inferColumns`
446446

447-
`inferColumns` (from `@tailor-platform/app-shell-sdk-plugin`) derives `label`, `sort`, `filter`, and a default `render` from TailorDB metadata. You can layer a `type` on top to swap the rendering without losing the inferred sort/filter config:
447+
`inferColumns` (from `@tailor-platform/app-shell-sdk-plugin`) derives `label`, `sort`, `filter`, and `id` from TailorDB metadata. You can layer a `type` on top to get a built-in renderer without losing the inferred sort/filter config:
448448

449449
```tsx
450450
const infer = inferColumns(tableMetadata.order);
451451

452452
const columns = [
453-
// Inferred string column — keeps the default render
453+
// Inferred column — displays row[id] as plain text
454454
column(infer("reference")),
455455

456456
// Inferred datetime column, swapped to a `date` cell with long format
@@ -473,7 +473,7 @@ const columns = [
473473
];
474474
```
475475

476-
When you spread `...infer("field")`, drop in `accessor` if the inferred render doesn't already match what your `type` expects — built-in renderers read from `accessor` (or `row[id]`), not from the inferred `render`.
476+
When you spread `...infer("field")`, add `accessor` when you want a typed renderer to read a specific value — built-in renderers read from `accessor` (or `row[id]`).
477477

478478
## `FilterConfig`
479479

0 commit comments

Comments
 (0)