@@ -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
308359import 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
0 commit comments