Skip to content

Commit ce711b6

Browse files
committed
docs(plugin-view): re-teach the canonical table keys now that #5102 landed
Fixes #5271 objectui#5102 (PR #5274, merged) made ObjectView forward the canonical `table.pagination` / `.selection` / `.filter` / `.sort` on every rendering path, keeping `pageSize` / `selectable` / `defaultFilters` / `defaultSort` as working aliases. The two docs pages PR #5101 (README) and PR #5109 (docs-site mirror) wrote against the pre-#5102 reality — legacy-only — and now teach a stale caveat. Re-teach the canonical spellings as the recommended form without implying the legacy ones stopped working, and state the precedence read directly off the landed `ObjectView.tsx` / `ObjectGrid.tsx`: canonical wins when both are written; an active named view's own filter/sort still outranks anything on `table`; `table.columns` stays out of scope (#5269, still open, grid-path only). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RV6yuVCxymHYE16PL9vQkE
1 parent 12841b6 commit ce711b6

2 files changed

Lines changed: 128 additions & 37 deletions

File tree

‎content/docs/plugins/plugin-view.mdx‎

Lines changed: 73 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,24 +119,75 @@ object through. Anything else you put in them is ignored:
119119

120120
| Sub-config | Keys `ObjectView` forwards |
121121
| --- | --- |
122-
| `table` | `columns`, `fields`, `title`, `description`, `defaultFilters`, `defaultSort`, `pageSize`, `selectable`, `operations`, `className` |
122+
| `table` | `columns`, `fields`, `title`, `description`, `filter`, `defaultFilters`, `sort`, `defaultSort`, `pagination`, `pageSize`, `selection`, `selectable`, `operations`, `className` |
123123
| `form` | `fields`, `customFields`, `sections`, `groups`, `layout`, `columns`, `title`, `description`, `subforms`, `buttons`, `defaults`, `initialValues`, `readOnly`, `showSubmit`, `submitText`, `showCancel`, `cancelText`, `showReset`, `className` |
124124

125-
The forwarding is literal, key by key (`ObjectView.tsx:833-848` for `table`,
126-
`:857-890` for `form`), which is why the list is worth reading: page size is
127-
`table.pageSize` and **not** `table.pagination` — the latter is a declared
128-
`ObjectGridSchema` key, but it is not one of the keys `ObjectView` forwards, so
129-
on an `object-view` node it has no effect.
130-
131-
That is one instance of a general point: several of the forwarded `table` keys
132-
are the ones `ObjectGridSchema` marks legacy — `fields`, `pageSize`,
133-
`selectable`, `defaultFilters` and `defaultSort` each have a newer counterpart
134-
there (`columns`, `pagination`, `selection`, `filter`, `sort`). `ObjectView`
135-
forwards the legacy spellings, so on an `object-view` node those are the ones
136-
that take effect. `columns` is the exception — it is forwarded alongside
137-
`fields` and preferred over it. Shapes follow `ObjectGridSchema`:
138-
`defaultSort` is a single `{ field, order }` object and `defaultFilters` is a
139-
plain record of field to value.
125+
The forwarding is literal, key by key, spread across three sites in
126+
`ObjectView.tsx` — the non-grid data fetch (around `:604-611`), the grid
127+
schema (around `:1041-1078`), and the schema handed to a host-supplied list
128+
renderer (around `:1201-1209`) — so the four keys below behave the same on
129+
every rendering path.
130+
131+
#### Canonical keys now take effect (objectui#5102)
132+
133+
Four of the forwarded `table` keys are pairs — a canonical `ObjectGridSchema`
134+
key and the `@deprecated` legacy spelling it replaced. Both now work; write
135+
the canonical one:
136+
137+
| write this (canonical) | not this (legacy alias — still works) |
138+
| --- | --- |
139+
| `pagination: { pageSize, pageSizeOptions? }` | `pageSize: number` |
140+
| `selection: { type: 'single' \| 'multiple' \| 'none' }` | `selectable: boolean \| 'single' \| 'multiple'` |
141+
| `filter: [{ field, operator, value }, …]` (same shape as a named view's `filter`) | `defaultFilters: Record<field, value>` (equality-only) |
142+
| `sort: 'field direction'` or `SortConfig[]` | `defaultSort: { field, order }` (**no string form** — that arity only exists on `sort`) |
143+
144+
Before objectui#5102, `pagination` / `selection` / `filter` / `sort` had **no
145+
read point at all** in this file: an author who wrote the canonical shape
146+
`ObjectGridSchema`'s own JSDoc recommends got a view that compiled, read
147+
correctly, and silently did nothing. That is fixed — the legacy spellings on
148+
the right are not going away, they are simply no longer the ones to reach for.
149+
150+
**When a key is written both ways, the canonical spelling wins** — that is
151+
`ObjectGrid`'s own existing resolution (`schema.pagination?.pageSize ||
152+
schema.pageSize`; `if (schema.selection?.type) … else if (schema.selectable
153+
!== undefined)`; `schemaFilter !== undefined ? … : schema.defaultFilters`;
154+
`schemaSort ?? (schema.defaultSort ? [schema.defaultSort] : undefined)`), and
155+
`ObjectView` defers to it by forwarding both slots rather than re-resolving
156+
the pair itself:
157+
158+
```typescript
159+
import type { ObjectViewSchema } from '@object-ui/types';
160+
161+
const bothSpellingsWritten: ObjectViewSchema = {
162+
type: 'object-view',
163+
objectName: 'products',
164+
table: {
165+
pagination: { pageSize: 10 }, // wins
166+
pageSize: 50, // ignored while `pagination` is present
167+
},
168+
};
169+
```
170+
171+
⚠️ **`filter` / `sort` have one more tier ahead of `table` entirely**, and it
172+
predates this change: an **active named view's own** `filter` / `sort`
173+
(`listViews.<name>.filter` / `.sort`) always outranks anything written on
174+
`table` — `table.filter` does **not** universally win over the legacy
175+
`table.defaultFilters`, it wins only when no active named view supplies its
176+
own filter. In order, highest first: the active named view's `filter`/`sort`,
177+
then `table.filter`/`table.sort`, then
178+
`table.defaultFilters`/`table.defaultSort`. If you never write `listViews`,
179+
that first tier never applies.
180+
181+
`pagination` and `selection` have no such tier, and no effect outside the
182+
grid: `defaultViewType: 'kanban' | 'gallery' | 'calendar' | 'timeline' |
183+
'gantt' | 'map'` don't page or multi-select, so `ObjectView` never forwards
184+
either spelling to those renderers.
185+
186+
`columns` is the one forwarded `table` key that is **not** part of this
187+
canonical/legacy story, and its gap is still open: it is forwarded on the grid
188+
path only (the row above, and the section below), so on a non-grid
189+
`defaultViewType` the field list still comes from `table.fields`
190+
(objectui#5269).
140191

141192
## Usage
142193

@@ -209,7 +260,7 @@ const userDirectory: ObjectViewSchema = {
209260
defaultViewType: 'grid',
210261
table: {
211262
columns: ['name', 'email', 'role', 'created_at'],
212-
defaultSort: { field: 'created_at', order: 'desc' },
263+
sort: 'created_at desc', // or [{ field: 'created_at', order: 'desc' }]
213264
},
214265
};
215266
```
@@ -301,8 +352,8 @@ opening a drawer, so the host route owns the form.
301352

302353
### Read/List
303354

304-
Search, filter and sort are toolbar toggles; the column set, default filter,
305-
default sort and page size live in `table`:
355+
Search, filter and sort are toolbar toggles; the column set, filter, sort and
356+
page size live in `table`:
306357

307358
```typescript
308359
import type { ObjectViewSchema } from '@object-ui/types';
@@ -316,8 +367,8 @@ const productList: ObjectViewSchema = {
316367
showSort: true,
317368
table: {
318369
columns: ['name', 'price', 'category'],
319-
defaultFilters: { category: 'electronics' },
320-
pageSize: 25,
370+
filter: [{ field: 'category', operator: 'equals', value: 'electronics' }],
371+
pagination: { pageSize: 25 },
321372
},
322373
};
323374
```
@@ -492,7 +543,7 @@ const contactView: ObjectViewSchema = {
492543
showSort: true,
493544
table: {
494545
columns: ['first_name', 'last_name', 'email', 'company'],
495-
pageSize: 25,
546+
pagination: { pageSize: 25 },
496547
},
497548
};
498549

‎packages/plugin-view/README.md‎

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,57 @@ object through. Anything else you put in them is ignored:
202202

203203
| Sub-config | Keys `ObjectView` forwards |
204204
| --- | --- |
205-
| `table` | `columns`, `fields`, `title`, `description`, `defaultFilters`, `defaultSort`, `pageSize`, `selectable`, `operations`, `className` |
205+
| `table` | `columns`, `fields`, `title`, `description`, `filter`, `defaultFilters`, `sort`, `defaultSort`, `pagination`, `pageSize`, `selection`, `selectable`, `operations`, `className` |
206206
| `form` | `fields`, `customFields`, `sections`, `groups`, `layout`, `columns`, `title`, `description`, `subforms`, `buttons`, `defaults`, `initialValues`, `readOnly`, `showSubmit`, `submitText`, `showCancel`, `cancelText`, `showReset`, `className` |
207207

208-
Note that several of the forwarded `table` keys are the ones `ObjectGridSchema`
209-
marks legacy — `fields`, `pageSize`, `selectable`, `defaultFilters` and
210-
`defaultSort` each have a newer counterpart there (`columns`, `pagination`,
211-
`selection`, `filter`, `sort`). `ObjectView` forwards the legacy spellings, so
212-
on an `object-view` node those are the ones that take effect; `columns` is the
213-
exception, forwarded alongside `fields` and preferred here. Shapes follow
214-
`ObjectGridSchema`: `defaultSort` is a single `{ field, order }` object and
215-
`defaultFilters` is a plain `Record` of field to value.
208+
Four of the forwarded `table` keys are pairs — a canonical `ObjectGridSchema`
209+
key and the `@deprecated` legacy spelling it replaced. As of objectui#5102 the
210+
canonical spelling **takes effect** on every rendering path (the grid, and the
211+
non-grid `kanban` / `gallery` / `calendar` / `timeline` / `gantt` / `map`
212+
renderers); the legacy spelling on the right keeps working as an alias, it is
213+
just no longer the one to reach for:
214+
215+
| write this (canonical) | not this (legacy alias — still works) |
216+
| --- | --- |
217+
| `pagination: { pageSize, pageSizeOptions? }` | `pageSize: number` |
218+
| `selection: { type: 'single' \| 'multiple' \| 'none' }` | `selectable: boolean \| 'single' \| 'multiple'` |
219+
| `filter: [{ field, operator, value }, …]` (same shape as a named view's `filter`) | `defaultFilters: Record<field, value>` (equality-only) |
220+
| `sort: 'field direction'` or `SortConfig[]` | `defaultSort: { field, order }` (**no string form** — that arity only exists on `sort`) |
221+
222+
**Precedence when a key is written both ways** — `table: { pagination: {
223+
pageSize: 10 }, pageSize: 50 }`, say — the canonical spelling wins. That is
224+
`ObjectGrid`'s own existing resolution (`schema.pagination?.pageSize ||
225+
schema.pageSize`; `if (schema.selection?.type) … else if (schema.selectable
226+
!== undefined)`; `schemaFilter !== undefined ? … : schema.defaultFilters`;
227+
`schemaSort ?? (schema.defaultSort ? [schema.defaultSort] : undefined)`), and
228+
`ObjectView` defers to it by forwarding both slots rather than re-resolving
229+
the pair itself:
230+
231+
```typescript
232+
const schema: ObjectViewSchema = {
233+
type: 'object-view',
234+
objectName: 'products',
235+
table: {
236+
pagination: { pageSize: 10 }, // wins
237+
pageSize: 50, // ignored while `pagination` is present
238+
},
239+
};
240+
```
241+
242+
`filter` / `sort` have one more tier ahead of `table` entirely, and it
243+
predates this change: an **active named view's own** `filter` / `sort`
244+
(`listViews.<name>.filter` / `.sort`) always outranks anything written on
245+
`table`. In order, highest first: the active named view's `filter`/`sort`,
246+
then `table.filter`/`table.sort`, then `table.defaultFilters`/
247+
`table.defaultSort`. (If you never write `listViews`, that first tier never
248+
applies.) `pagination` and `selection` have no such tier, and no effect
249+
outside the grid — the non-grid renderers don't page or multi-select, so
250+
`ObjectView` never forwards either spelling to them.
251+
252+
`columns` is the one forwarded `table` key that is **not** part of this
253+
canonical/legacy story, and it has an unrelated gap: it is forwarded on the
254+
grid path only, so on a non-grid `defaultViewType` the field list still comes
255+
from `table.fields` (objectui#5269, open).
216256

217257
### ViewSwitcher
218258

@@ -285,7 +325,7 @@ const schema: ObjectViewSchema = {
285325
defaultViewType: 'grid',
286326
table: {
287327
columns: ['name', 'email', 'role', 'created_at'],
288-
defaultSort: { field: 'created_at', order: 'desc' },
328+
sort: 'created_at desc', // or [{ field: 'created_at', order: 'desc' }]
289329
},
290330
};
291331
```
@@ -367,8 +407,8 @@ opening a drawer, so the host route owns the form.
367407

368408
### Read/List
369409

370-
Search, filter and sort are toolbar toggles; column set, default filter,
371-
default sort and page size live in `table`:
410+
Search, filter and sort are toolbar toggles; column set, filter, sort and page
411+
size live in `table`:
372412

373413
```typescript
374414
const schema: ObjectViewSchema = {
@@ -380,8 +420,8 @@ const schema: ObjectViewSchema = {
380420
showSort: true,
381421
table: {
382422
columns: ['name', 'price', 'category'],
383-
defaultFilters: { category: 'electronics' },
384-
pageSize: 25,
423+
filter: [{ field: 'category', operator: 'equals', value: 'electronics' }],
424+
pagination: { pageSize: 25 },
385425
},
386426
};
387427
```
@@ -459,7 +499,7 @@ const schema: ObjectViewSchema = {
459499
showSort: true,
460500
table: {
461501
columns: ['first_name', 'last_name', 'email', 'company'],
462-
pageSize: 25,
502+
pagination: { pageSize: 25 },
463503
},
464504
};
465505

0 commit comments

Comments
 (0)