@protobase/cli 0.97.1 → 0.98.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.
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "0.97.1";
2
+ var version = "0.98.1";
3
3
  //#endregion
4
4
  export { version };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/cli",
3
- "version": "0.97.1",
3
+ "version": "0.98.1",
4
4
  "description": "The protobase command: scaffold, doctor, dev, build and serve a Protobase project.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,13 +43,13 @@
43
43
  "dependencies": {
44
44
  "@better-auth/core": "^1.7.12",
45
45
  "@hono/node-server": "^2.1.3",
46
- "@protobase/config": "0.97.1",
47
- "@protobase/layout": "0.97.1",
48
- "@protobase/query": "0.97.1",
49
- "@protobase/schema": "0.97.1",
50
- "@protobase/server": "0.97.1",
51
- "@protobase/ui": "0.97.1",
52
- "@protobase/workflows": "0.97.1",
46
+ "@protobase/config": "0.98.1",
47
+ "@protobase/layout": "0.98.1",
48
+ "@protobase/query": "0.98.1",
49
+ "@protobase/schema": "0.98.1",
50
+ "@protobase/server": "0.98.1",
51
+ "@protobase/ui": "0.98.1",
52
+ "@protobase/workflows": "0.98.1",
53
53
  "@react-email/render": "^2.1.0",
54
54
  "@scalar/hono-api-reference": "^0.12.10",
55
55
  "@sentry/vite-plugin": "^11.10.0",
@@ -13,3 +13,11 @@ Apps written for other systems that keep working on Protobase, and moving their
13
13
  - [Supabase Storage](../reference/supabase-storage.md) (beta): supabase-js storage calls keep working, over the app's file storage.
14
14
  - [Supabase Realtime](../reference/supabase-realtime.md) (beta): Database changes, broadcast and presence through supabase-js channels, private ones authorized by the policies on `realtime.messages`, broadcasts sent from a server without joining a channel, and broadcasts from the database with `realtime.send()` and `realtime.broadcast_changes()`, across [several processes](../reference/supabase-realtime.md#several-processes) serving one app.
15
15
  - [Edge Functions](../guides/api-functions.md#functions-moved-from-supabase): Functions moved from Supabase answer at their old addresses.
16
+
17
+ ## Template paths
18
+
19
+ - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout paths follow Mustache's context-stack lookup and Handlebars' path grammar: `../`, `this`, `./`, `@root`, `@index`, `@first` and `@last`, though `@root` cannot be read yet. Protobase differs in three ways: a placeholder is escaped for the string it lands in, such as a filter's quoted value, rather than for HTML; `@params` names a page parameter, which the build accepts but a path cannot read yet; and a name no record around it has fails the build instead of drawing empty.
20
+
21
+ ## react-admin
22
+
23
+ - [Related records](../reference/layouts.md#related-records) (beta): Layouts take react-admin's `ReferenceManyField`, `ReferenceArrayField`, `ArrayField`, `RecordsIterator` and `ReferenceField` with their names, props and defaults: `source` is `id`, `sort` the key descending, and a `ReferenceManyField`'s `perPage` 25. Protobase differs in five ways: `filter` and `sort` also take AIP-160 and AIP-132 text, since an object cannot say `OR`; a list reads at most 500 records, the API's largest page, which is also a `ReferenceArrayField`'s `perPage` where react-admin's is 1000; a text item of an `ArrayField` is read as `this`; `RecordsIterator` takes no `render`, `data`, `total` or `isPending`, as a layout holds no functions and the list around it gives the rest; and a `ReferenceField` links to the record's page for both `edit` and `show`, as a record has one page. An `ArrayField` takes no `filter`, `sort` or `perPage` yet.
@@ -7,7 +7,8 @@ Pages of your own, built from blocks in a JSX layout.
7
7
  - [Composed pages](../reference/layouts.md#setup): Pages built from a JSX layout, with their own address, sidebar entry and role limits, reading the API under the same access rules as the lists.
8
8
  - [Layout checks](../reference/layouts.md#what-a-layout-may-hold): The build refuses a layout with code, unknown props or unknown fields, and names the file and place.
9
9
  - [Conditions](../reference/layouts.md#conditions): Part of a page shows only while a condition on a record or a count holds.
10
- - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout values resolve through the records around them with Handlebars paths, such as `../name`, `@root` and `@index`; typos and reads that would wait on other reads fail the build, and `Show`, `Switch` and `Match` choose what is drawn.
10
+ - [Paths and scopes](../reference/layouts.md#paths-and-scopes) (beta): Layout values resolve through the records around them with paths relative to those records, such as `../name`, `this.name` and `@index`; typos and reads that would wait on other reads fail the build, and `Show`, `Switch` and `Match` choose what is drawn.
11
+ - [Field values and expanding lines](../reference/layouts.md#field-values) (beta): Layouts show a record's values inline in text and links with react-admin's field components, such as `DateField` and `NumberField`, and a line that opens to show more with `Details` and `Summary`.
11
12
  - [App addresses](../reference/layouts.md#addresses): Links to lists, records, create forms and pages are typed addresses that can carry filters and prefilled values.
12
13
  - [Component fallbacks](../reference/custom-components.md#fallbacks): A custom component declares what a client that cannot draw it shows instead, or nothing, and the web shows it too when the component is missing or throws.
13
14
  - [Text form](../reference/layouts.md#text-form): Every layout block renders to Markdown text through one shared function, built up from its children, as the last-resort fallback and for MCP clients and LLMs.
@@ -16,6 +17,7 @@ Pages of your own, built from blocks in a JSX layout.
16
17
  - [Tailwind classes](../reference/layouts.md#tailwind-classes) (experimental): Layouts can carry Tailwind classes, on plain elements and on blocks, for pages too custom for blocks.
17
18
  - [Full-width pages](../reference/blocks.md#page): A page fills the whole area beside the sidebar instead of a centred column, for a dashboard with many blocks.
18
19
  - [Data blocks](../reference/blocks.md#data): Counts, tables, single records, rows of cards, field values and progress bars.
20
+ - [Related records](../reference/layouts.md#related-records) (beta): Layouts repeat over a record's related records, the records a JSON list of keys points at and the items of a JSON list with `ReferenceManyField`, `ReferenceArrayField`, `ArrayField`, `RecordsIterator` and `ReferenceField`, nested as deep as needed, and a table draws such a list.
19
21
  - [Table columns on a phone](../reference/blocks.md#columns-on-a-phone): Table blocks choose which columns show at mobile width by priority, with a sensible default, and fall back to a Markdown table.
20
22
  - [Row buttons](../reference/blocks.md#row-buttons) (experimental): A table's rows carry a button labelled by a field of the row, such as its next step; the row decides where it goes: a record tab a field names, a list with a filter built from its fields, or an outside https link a field holds. On mobile width the button sits under the row's first cell.
21
23
  - [Record rows](../reference/blocks.md#recordrow): A sideways row of cards for a filter, favorites or saved searches, with a count and new-record marks.
@@ -25,9 +25,9 @@ export const billing = page(
25
25
  actions={[<Action name="cancel" variant="danger" />, <Action name="upgrade" variant="primary" />]}
26
26
  >
27
27
  <Grid columns={3}>
28
- <Field name="plan.name" label="Plan" />
29
- <Field name="plan.price" label="Per month" />
30
- <Field name="renews_at" />
28
+ <Field source="plan.name" label="Plan" />
29
+ <Field source="plan.price" label="Per month" />
30
+ <Field source="renews_at" />
31
31
  </Grid>
32
32
  <Progress label="Seats" value="seats_used" max="plan.seats" />
33
33
  </RecordCard>
@@ -95,9 +95,9 @@ export const billing = page(
95
95
  actions={[<Action name="cancel" variant="danger" />, <Action name="upgrade" variant="primary" />]}
96
96
  >
97
97
  <Grid columns={3}>
98
- <Field name="plan.name" label="Plan" />
99
- <Field name="plan.price" label="Per month" />
100
- <Field name="renews_at" />
98
+ <Field source="plan.name" label="Plan" />
99
+ <Field source="plan.price" label="Per month" />
100
+ <Field source="renews_at" />
101
101
  </Grid>
102
102
  <Progress label="Seats" value="seats_used" max="plan.seats" />
103
103
  </RecordCard>
@@ -107,10 +107,10 @@ export const billing = page(
107
107
  actions={<ModalForm mode="edit" label="Edit" title="Edit billing details" fields={['company', 'vat_number', 'address', 'email']} />}
108
108
  >
109
109
  <Grid columns={2}>
110
- <Field name="company" />
111
- <Field name="vat_number" />
112
- <Field name="address" />
113
- <Field name="email" />
110
+ <Field source="company" />
111
+ <Field source="vat_number" />
112
+ <Field source="address" />
113
+ <Field source="email" />
114
114
  </Grid>
115
115
  </RecordCard>
116
116
  </Grid>
@@ -139,9 +139,9 @@ export const billing = page(
139
139
  actions={[<Action name="cancel" variant="danger" />, <Action name="upgrade" variant="primary" />]}
140
140
  >
141
141
  <Grid columns={3}>
142
- <Field name="plan.name" label="Plan" />
143
- <Field name="plan.price" label="Per month" />
144
- <Field name="renews_at" />
142
+ <Field source="plan.name" label="Plan" />
143
+ <Field source="plan.price" label="Per month" />
144
+ <Field source="renews_at" />
145
145
  </Grid>
146
146
  <Progress label="Seats" value="seats_used" max="plan.seats" />
147
147
  </RecordCard>
@@ -151,10 +151,10 @@ export const billing = page(
151
151
  actions={<ModalForm mode="edit" label="Edit" title="Edit billing details" fields={['company', 'vat_number', 'address', 'email']} />}
152
152
  >
153
153
  <Grid columns={2}>
154
- <Field name="company" />
155
- <Field name="vat_number" />
156
- <Field name="address" />
157
- <Field name="email" />
154
+ <Field source="company" />
155
+ <Field source="vat_number" />
156
+ <Field source="address" />
157
+ <Field source="email" />
158
158
  </Grid>
159
159
  </RecordCard>
160
160
  </Grid>
@@ -164,9 +164,9 @@ export const billing = page(
164
164
  sort="is_default desc, id"
165
165
  actions={<ModalForm mode="create" label="Add card" resource="payment_methods" fields={['brand', 'last4', 'expires']} />}
166
166
  >
167
- <Field name="brand" label={false} />
168
- <Field name="last4" label="Number" />
169
- <Field name="expires" />
167
+ <Field source="brand" label={false} />
168
+ <Field source="last4" label="Number" />
169
+ <Field source="expires" />
170
170
  <Show when="is_default = true">Default card</Show>
171
171
  <Show when="is_default = false">
172
172
  <Action name="makeDefault" />
@@ -203,9 +203,9 @@ export const billing = page(
203
203
  actions={[<Action name="cancel" variant="danger" />, <Action name="upgrade" variant="primary" />]}
204
204
  >
205
205
  <Grid columns={3}>
206
- <Field name="plan.name" label="Plan" />
207
- <Field name="plan.price" label="Per month" />
208
- <Field name="renews_at" />
206
+ <Field source="plan.name" label="Plan" />
207
+ <Field source="plan.price" label="Per month" />
208
+ <Field source="renews_at" />
209
209
  </Grid>
210
210
  <Progress label="Seats" value="seats_used" max="plan.seats" />
211
211
  <SeatHistory months={6} />
@@ -216,10 +216,10 @@ export const billing = page(
216
216
  actions={<ModalForm mode="edit" label="Edit" title="Edit billing details" fields={['company', 'vat_number', 'address', 'email']} />}
217
217
  >
218
218
  <Grid columns={2}>
219
- <Field name="company" />
220
- <Field name="vat_number" />
221
- <Field name="address" />
222
- <Field name="email" />
219
+ <Field source="company" />
220
+ <Field source="vat_number" />
221
+ <Field source="address" />
222
+ <Field source="email" />
223
223
  </Grid>
224
224
  </RecordCard>
225
225
  </Grid>
@@ -229,9 +229,9 @@ export const billing = page(
229
229
  sort="is_default desc, id"
230
230
  actions={<ModalForm mode="create" label="Add card" resource="payment_methods" fields={['brand', 'last4', 'expires']} />}
231
231
  >
232
- <Field name="brand" label={false} />
233
- <Field name="last4" label="Number" />
234
- <Field name="expires" />
232
+ <Field source="brand" label={false} />
233
+ <Field source="last4" label="Number" />
234
+ <Field source="expires" />
235
235
  <Show when="is_default = true">Default card</Show>
236
236
  <Show when="is_default = false">
237
237
  <Action name="makeDefault" />
@@ -244,8 +244,8 @@ export const billing = page(
244
244
  <Stat label="Open invoices" resource="invoices" filter="status = 'open'" />
245
245
  <RecordCard title="Latest invoice" resource="invoices" sort="issued_at desc" actions={<Action name="download" />}>
246
246
  <Grid columns={2}>
247
- <Field name="number" />
248
- <Field name="total" />
247
+ <Field source="number" />
248
+ <Field source="total" />
249
249
  </Grid>
250
250
  </RecordCard>
251
251
  <Card title="Questions about a bill?">
@@ -95,10 +95,10 @@ export const overview = page(
95
95
  actions={<Action name="markPaid" variant="primary" />}
96
96
  >
97
97
  <Grid columns={4}>
98
- <Field name="number" />
99
- <Field name="total" />
100
- <Field name="company_id" label="Customer" />
101
- <Field name="company_id.city" label="City" />
98
+ <Field source="number" />
99
+ <Field source="total" />
100
+ <Field source="company_id" label="Customer" />
101
+ <Field source="company_id.city" label="City" />
102
102
  </Grid>
103
103
  <Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
104
104
  </RecordCard>
@@ -192,10 +192,10 @@ export const overview = page(
192
192
  actions={<Action name="markPaid" variant="primary" />}
193
193
  >
194
194
  <Grid columns={4}>
195
- <Field name="number" />
196
- <Field name="total" />
197
- <Field name="company_id" label="Customer" />
198
- <Field name="company_id.city" label="City" />
195
+ <Field source="number" />
196
+ <Field source="total" />
197
+ <Field source="company_id" label="Customer" />
198
+ <Field source="company_id.city" label="City" />
199
199
  </Grid>
200
200
  <Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
201
201
  </RecordCard>
@@ -211,9 +211,9 @@ export const overview = page(
211
211
  sort="created_at desc"
212
212
  actions={<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'email']} values={{ status: 'lead' }} />}
213
213
  >
214
- <Field name="name" label={false} />
215
- <Field name="city" />
216
- <Field name="email" />
214
+ <Field source="name" label={false} />
215
+ <Field source="city" />
216
+ <Field source="email" />
217
217
  <ModalForm mode="edit" label="Edit" fields={['name', 'city', 'email', 'status']} />
218
218
  </CardRow>
219
219
  </Page>,
@@ -4,7 +4,7 @@
4
4
 
5
5
  Every built-in layout block, its props and what it does, with examples from the ERP's sales overview.
6
6
 
7
- Blocks are imported from `@protobase/layout`. Every block also takes [`className`](layouts.md#tailwind-classes), Tailwind classes for its outer element. "Record" below means the record of the `RecordCard` or `CardRow` card around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API. The ERP example's sales overview uses `Page`, `Grid`, `Card`, `Stat`, `Table`, `RecordCard`, `CardRow`, `Field`, `Chart`, `Action`, `ModalForm` and `Show`; of the others, the property portal's home uses `RecordRow`, and the [Users page](auth.md#users-page) `Users`:
7
+ Blocks are imported from `@protobase/layout`. Every block also takes [`className`](layouts.md#tailwind-classes), Tailwind classes for its outer element. "Record" below means the record of the `RecordCard`, `CardRow` card or `RecordsIterator` entry around a block (see [Data](layouts.md#data)); `filter` is AIP-160 and `sort` AIP-132, as in the list API. The ERP example's sales overview uses `Page`, `Grid`, `Card`, `Stat`, `Table`, `RecordCard`, `CardRow`, `Field`, `Chart`, `Action`, `ModalForm` and `Show`; of the others, the property portal's home uses `RecordRow`, and the [Users page](auth.md#users-page) `Users`:
8
8
 
9
9
  ```tsx title="tests/apps/erp/config/overview/page.tsx"
10
10
  /** @jsxImportSource @protobase/layout */
@@ -36,10 +36,10 @@ export const salesOverview = page(
36
36
  actions={<Action name="markPaid" variant="primary" />}
37
37
  >
38
38
  <Grid columns={2}>
39
- <Field name="number" />
40
- <Field name="total" />
41
- <Field name="company_id" label="Customer" />
42
- <Field name="company_id.city" label="City" />
39
+ <Field source="number" />
40
+ <Field source="total" />
41
+ <Field source="company_id" label="Customer" />
42
+ <Field source="company_id.city" label="City" />
43
43
  </Grid>
44
44
  <Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
45
45
  </RecordCard>
@@ -52,10 +52,10 @@ export const salesOverview = page(
52
52
  actions={[<Action name="send" label="Send reminder" />, <Action name="recordPayment" variant="primary" />]}
53
53
  >
54
54
  <Grid columns={2}>
55
- <Field name="number" />
56
- <Field name="total" />
57
- <Field name="company_id" label="Customer" />
58
- <Field name="due_at" label="Due" />
55
+ <Field source="number" />
56
+ <Field source="total" />
57
+ <Field source="company_id" label="Customer" />
58
+ <Field source="due_at" label="Due" />
59
59
  </Grid>
60
60
  </RecordCard>
61
61
  <Card title="Orders per day" description="The last 30 days.">
@@ -79,9 +79,9 @@ export const salesOverview = page(
79
79
  limit={8}
80
80
  actions={<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'country_code', 'email']} values={{ status: 'lead' }} />}
81
81
  >
82
- <Field name="name" label={false} />
83
- <Field name="city" />
84
- <Field name="email" />
82
+ <Field source="name" label={false} />
83
+ <Field source="city" />
84
+ <Field source="email" />
85
85
  <ModalForm mode="edit" label="Edit" fields={['name', 'city', 'email', 'phone', 'status']} />
86
86
  </CardRow>
87
87
  </Page>,
@@ -142,7 +142,7 @@ A box with a heading. Text and `Link`s inside it run together as paragraphs.
142
142
 
143
143
  ### Link
144
144
 
145
- A link in text: `to` an address in the app, or an `href` that leaves it (`https:` opens in a new tab, `mailto:` in the mail app). It shows its children inline, text and `Text as="span"`s, or without them where it leads. It cannot hold another `Link`. With [`className`](layouts.md#tailwind-classes) it drops its own look for those classes.
145
+ A link in text: `to` an address in the app, or an `href` that leaves it (`https:` opens in a new tab, `mailto:` in the mail app). It shows its children inline, text, `Text as="span"`s and [field components](#field-components), or without them where it leads. It cannot hold another `Link` or a `UrlField`. With [`className`](layouts.md#tailwind-classes) it drops its own look for those classes.
146
146
 
147
147
  ```tsx
148
148
  <Link to={{ kind: 'list', resource: 'invoices', filter: "status = 'overdue'" }}>Overdue invoices</Link>
@@ -165,7 +165,7 @@ Plain elements for a page too custom for the blocks, drawn by their [Tailwind cl
165
165
  | `Box` | An element of its own, such as a panel or a banner. No look of its own. |
166
166
  | `Row` | Its children side by side: `flex`. |
167
167
  | `Column` | Its children one under another: `flex flex-col`. |
168
- | `Text` | Text, `Link`s and `Text as="span"`s in it, nothing else, run as one line. `as` makes it `p` (the default), `span`, or a heading `h1` to `h4`. |
168
+ | `Text` | Text, `Link`s, `Text as="span"`s and [field components](#field-components) in it, nothing else, run as one line. `as` makes it `p` (the default), `span`, or a heading `h1` to `h4`. |
169
169
 
170
170
  ```tsx
171
171
  <Row className="items-center gap-3">
@@ -174,6 +174,21 @@ Plain elements for a page too custom for the blocks, drawn by their [Tailwind cl
174
174
  </Row>
175
175
  ```
176
176
 
177
+ ### Details and Summary
178
+
179
+ A line that opens to show the rest and closes again, drawn as HTML's [`<details>` and `<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details), so the browser opens and closes it with no script. A `Details` takes one `Summary`, as its first child; the `Summary` is one line, holding what a `Text` holds. See [Field values](layouts.md#field-values).
180
+
181
+ ```tsx
182
+ <Details>
183
+ <Summary>Brakes, <ChipField source="state" /></Summary>
184
+ <Text>Pads and cables replaced.</Text>
185
+ </Details>
186
+ ```
187
+
188
+ | Prop | |
189
+ | --- | --- |
190
+ | `open` | `Details` only: starts open. |
191
+
177
192
  ### Tabs and Tab
178
193
 
179
194
  `Tabs` splits a page into tabs, each at its own address: the first at the page's (`/<page>`), each other at its name below it (`/<page>/<name>`). Only the shown tab's elements are drawn, so the others load nothing. On a phone the tabs are a select. `Tabs` takes no props and holds only `Tab`s; it sits directly in the `Page`, once per page, with other elements before or after it if you like.
@@ -224,7 +239,7 @@ The first records of a list, drawn the way the resource's list page draws them:
224
239
 
225
240
  | Prop | |
226
241
  | --- | --- |
227
- | `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
242
+ | `resource`, `filter`, `sort` | Which records, in which order; `sort` defaults to the list's. Without `resource`, inside a [`ReferenceManyField`](#referencemanyfield) or `ReferenceArrayField`, it draws that list's records and reads none of its own, so it takes no `filter`, `sort`, `limit`, `display` or `bulk`. |
228
243
  | `columns` | Field names for the table, or `{ name, priority }` for a column that matters on a phone, 1 the most important; default the view's list columns. See [Columns on a phone](#columns-on-a-phone). |
229
244
  | `button` | A [button on each row](#row-buttons) to an address the row's fields name, or to the outside page a field holds; a list of these gives each row the first whose fields it holds. |
230
245
  | `bulk` | `true`: rows can be selected, and the view's `bulk` actions run on the selected rows, as on the list page; see [signing several records off](#signing-several-records-off). |
@@ -333,8 +348,8 @@ One record and what is inside it: the one `recordKey` names (the key as the reco
333
348
 
334
349
  ```tsx
335
350
  <RecordCard title="Biggest unpaid delivery" resource="orders" filter="status = 'delivered' AND paid = false" sort="total desc" actions={<Action name="markPaid" variant="primary" />}>
336
- <Field name="number" />
337
- <Field name="company_id.city" label="City" />
351
+ <Field source="number" />
352
+ <Field source="company_id.city" label="City" />
338
353
  </RecordCard>
339
354
  ```
340
355
 
@@ -399,10 +414,18 @@ A label over a value of the record, formatted as on the record page: statuses as
399
414
 
400
415
  | Prop | |
401
416
  | --- | --- |
402
- | `name` | A field, through relations (`company_id.city`). Required. |
403
- | `label` | Default: the view's label, else the name in words. `false` shows the value alone. |
417
+ | `source` | A field, through relations (`company_id.city`), named as react-admin's fields name it. Required. |
418
+ | `label` | Default: the view's label, else the path in words. `false` shows the value alone. |
404
419
  | `format` | Instead of the view's [format](ui-config.md#names-and-columns). |
405
420
 
421
+ ### Field components
422
+
423
+ `TextField`, `NumberField`, `DateField`, `BooleanField`, `UrlField` and `ChipField` show one value of the record inline, in a `Text`, a `Link` or a `Summary`, as [react-admin's field components](https://marmelab.com/react-admin/Fields.html) do. Each takes `source` and `emptyText`; see [Field values](layouts.md#field-values) for their props and where they differ from react-admin's.
424
+
425
+ ```tsx
426
+ <Text>Due <DateField source="due_at" format="relative" />, quoted at <NumberField source="quote" options={{ style: 'currency', currency: 'EUR' }} /></Text>
427
+ ```
428
+
406
429
  ### Progress
407
430
 
408
431
  A bar for `value` out of `max`, with both numbers. It turns amber from 90%.
@@ -486,6 +509,76 @@ Counts, sums or averages of the records that match `filter`, per value of a fiel
486
509
 
487
510
  Each value takes its colour from the view's `valueColors`, else an enum value's place among its values, from the [chart tokens](theme.md#tokens). A chart whose field the user cannot read is left out of their page, and a field it cannot group or add up stops the server at startup.
488
511
 
512
+ ## Related records
513
+
514
+ The blocks that repeat over a record's related records, as [related records](layouts.md#related-records) explains, with the names, props and defaults of react-admin's components. `ReferenceManyField`, `ReferenceArrayField` and `ArrayField` hold a list and draw nothing of their own; a `RecordsIterator` or a `Table` without `resource` inside one draws it. Each sits inside a record, whose field it reads.
515
+
516
+ ### ReferenceManyField
517
+
518
+ The records of `reference` whose `target` holds the record's `source`, as [react-admin's ReferenceManyField](https://marmelab.com/react-admin/ReferenceManyField.html).
519
+
520
+ | Prop | |
521
+ | --- | --- |
522
+ | `reference` | The resource it reads. Required. |
523
+ | `target` | The field of `reference` that points at the record. Required. |
524
+ | `source` | The field of the record it matches; default `id`, of the nearest record. A [path](layouts.md#paths-and-scopes), such as `../id`. |
525
+ | `filter` | More conditions, as AIP-160 text or react-admin's `{ field: value }`, its fields ANDed. |
526
+ | `sort` | AIP-132 text, or react-admin's `{ field, order: 'ASC' \| 'DESC' }`; default the key, descending. |
527
+ | `perPage` | How many records it reads, at most 500; default 25. |
528
+ | `pagination` | `more`: a **Load more** button reads the next `perPage` records into the same list. |
529
+ | `empty` | Text instead of the children when no record matches. |
530
+
531
+ ```tsx
532
+ <ReferenceManyField reference="task_claims" target="task_id" filter={{ status: 'open' }} sort={{ field: 'claimed_at', order: 'DESC' }} pagination="more">
533
+ <Table title="Open claims" columns={['worker_id', 'claimed_at']} />
534
+ </ReferenceManyField>
535
+ ```
536
+
537
+ ### ReferenceArrayField
538
+
539
+ The records of `reference` whose keys the record's `source`, a JSON list of keys, holds, as [react-admin's ReferenceArrayField](https://marmelab.com/react-admin/ReferenceArrayField.html).
540
+
541
+ | Prop | |
542
+ | --- | --- |
543
+ | `source` | A JSON field of the record holding the keys. Required. |
544
+ | `reference` | The resource the keys belong to. Required. |
545
+ | `filter`, `sort` | As `ReferenceManyField`'s. |
546
+ | `perPage` | How many records it reads; default and at most 500, the API's largest page. |
547
+ | `empty` | Text instead of the children when no record matches. |
548
+
549
+ ### ArrayField
550
+
551
+ The items of the record's `source`, a JSON list, as [react-admin's ArrayField](https://marmelab.com/react-admin/ArrayField.html). An object item is read by its keys, and a text item as `this`: `<Field source="this" />`.
552
+
553
+ | Prop | |
554
+ | --- | --- |
555
+ | `source` | A JSON field of the record. Required. |
556
+
557
+ <gap>An `ArrayField` cannot filter, sort or page its items because react-admin's `filter`, `sort` and `perPage` on it are not implemented.</gap>
558
+
559
+ ### RecordsIterator
560
+
561
+ Its children once per entry of the list around it, each inside that record or item, with nothing drawn around them, as [react-admin's RecordsIterator](https://marmelab.com/react-admin/RecordsIterator.html). It takes no props.
562
+
563
+ ```tsx
564
+ <ArrayField source="labels">
565
+ <RecordsIterator>
566
+ <Field source="this" label={false} />
567
+ </RecordsIterator>
568
+ </ArrayField>
569
+ ```
570
+
571
+ ### ReferenceField
572
+
573
+ The record of `reference` the record's `source` points at, as [react-admin's ReferenceField](https://marmelab.com/react-admin/ReferenceField.html): its children inside that record, or without children its title, as a link to the record's page.
574
+
575
+ | Prop | |
576
+ | --- | --- |
577
+ | `source` | The field holding the key, such as a relation. Required. |
578
+ | `reference` | The resource it points at. Required. |
579
+ | `link` | `edit` (default) or `show` links to the record's page, `false` does not. |
580
+ | `empty` | Text when the field holds no key. |
581
+
489
582
  ## Conversation
490
583
 
491
584
  A chat declared in the layout like any other block: a `Thread` lists the messages of a resource and a `Composer` beneath it sends one, so [`/meta`](api.md#meta-and-openapi-per-caller) describes the conversation and every client can draw it, with no component of the app's own. On a record page, [`l.thread` and `l.composer`](ui-config.md#conversations) hold the conversation of that record.
@@ -60,7 +60,7 @@ Every layout block renders to Markdown text through one shared function, `render
60
60
  ```tsx
61
61
  import { Field, Page, renderText } from '@protobase/layout'
62
62
 
63
- renderText(<Page title="Order"><Field name="status" /></Page>, {
63
+ renderText(<Page title="Order"><Field source="status" /></Page>, {
64
64
  record: { status: 'in_progress' },
65
65
  fields: { status: { label: 'Status', valueLabels: { in_progress: 'In progress' } } },
66
66
  })
@@ -71,9 +71,11 @@ renderText(<Page title="Order"><Field name="status" /></Page>, {
71
71
 
72
72
  | Option | |
73
73
  | --- | --- |
74
- | `record` | The record around the tree. `Field`, `Stat field`, `Progress`, `Show` conditions and the `{{field}}`s of addresses read it, through relations as nested objects (`plan.name`); a count a condition names, such as `billing_profiles.count`, is a key of its own. The `{{path}}`s of props read it too. Without it, a field reads as its label alone, a condition as holding (a `Show` reads as its children, a `Switch` as its first `Match`), a prop's `{{path}}`s as empty, and addresses keep their `{{field}}`s. |
74
+ | `record` | The record around the tree. `Field`, the [field components](#field-values), `Stat field`, `Progress`, `Show` conditions and the `{{field}}`s of addresses read it, through relations as nested objects (`plan.name`); a count a condition names, such as `billing_profiles.count`, is a key of its own. The `{{path}}`s of props read it too. Without it, a field reads as its label alone, a condition as holding (a `Show` reads as its children, a `Switch` as its first `Match`), a prop's `{{path}}`s as empty, and addresses keep their `{{field}}`s. |
75
75
  | `fields` | Per field path, its `label` and the `valueLabels` its enum values read as; a field without a label reads under its path. |
76
+ | `records` | Per `ReferenceManyField`, `ReferenceArrayField` or `ReferenceField` element and the record around it, the records it holds, which you loaded; its `RecordsIterator` then reads as its children once per record, in that record, and an empty list as its `empty`. Without it, the block reads as a link to its records. An `ArrayField` reads its items from the record around it. |
76
77
  | `tables` | Per `Table` element, the records it shows and its columns (`{ columns: [{ name, label, title?, badge?, valueLabels? }], rows }`), which you loaded; the table then reads as its heading and a Markdown table. Without it, a table reads as its heading. |
78
+ | `locale` | The reader's locale, such as `nl-NL`, in which [field components](#field-values) without `locales` format numbers and dates; the runtime's default when omitted. |
77
79
  | `basePath` | What links start with, such as `https://example.com/admin`. |
78
80
  | `forms` | Text forms by block type, over the built-in ones. |
79
81
 
@@ -92,7 +94,7 @@ renderText(tree, { forms: { Grid: ruled, Card: noted, SeatChart: childrenText }
92
94
 
93
95
  A custom component reads as its [fallback](custom-components.md#fallbacks) when it declares one, and otherwise as what it holds, unless `forms` names it.
94
96
 
95
- <gap>A data block's text form cannot read its records itself, such as a table's rows, because reading records for the text form is not implemented.</gap> A `Thread` holding the elements of [`threadItemNodes`](blocks.md#tool-calls) reads as its messages and calls. <gap>A data block other than a `Table` or a `Thread` cannot list records you pass because its text form for records is not implemented.</gap> <gap>A field's text form cannot apply its `format`, such as a relative time, because formatting in the text form is not implemented.</gap> <gap>MCP clients cannot read a page's text form because a tool that serves it is not implemented.</gap>
97
+ <gap>A data block's text form cannot read its records itself, such as a table's rows, because reading records for the text form is not implemented.</gap> A `Thread` holding the elements of [`threadItemNodes`](blocks.md#tool-calls) reads as its messages and calls. <gap>A data block other than a `Table`, a `Thread` or a list block cannot list records you pass because its text form for records is not implemented.</gap> <gap>A field's text form cannot apply its `format`, such as a relative time, because formatting in the text form is not implemented.</gap> <gap>MCP clients cannot read a page's text form because a tool that serves it is not implemented.</gap>
96
98
 
97
99
  ## What a layout may hold
98
100
 
@@ -105,37 +107,112 @@ Behaviour comes from [named actions](#named-actions); React code from [custom co
105
107
 
106
108
  ## Data
107
109
 
108
- `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160 and `sort` AIP-132, exactly as the list API's `filter` and `order_by`, so a filter that works in the list's URL works here. `Thread` takes no `sort`: it orders its messages by its `time` field, newest first.
110
+ `Stat`, `RecordCard`, `Table`, `CardRow`, `RecordRow`, `RecordCards` and `Thread` read records of a `resource`. `filter` is AIP-160 and `sort` AIP-132, exactly as the list API's `filter` and `order_by`, so a filter that works in the list's URL works here. `Thread` takes no `sort`: it orders its messages by its `time` field, newest first. `ReferenceManyField`, `ReferenceArrayField` and `ReferenceField` read records of their `reference` that the record around them points to or is pointed at by: see [related records](#related-records).
109
111
 
110
- A `RecordCard` (its first match) and each card of a `CardRow` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
112
+ A `RecordCard` (its first match), a `ReferenceField`, each card of a `CardRow` and each entry of a `RecordsIterator` hold a **record**. Inside one, `Field`, `Progress`, `Stat field`, `Show`, `Action` and `ModalForm mode="edit"` work on that record, and a `RecordCard`'s header `actions` do too. A field name may follow relations: `company_id.city` is the city of the record's company, fetched like the record page fetches it and cached.
113
+
114
+ ## Related records
115
+
116
+ :::caution[Beta]
117
+ Each list block reads its records once the record around it has drawn. Coming soon: reads planned at build, so every list's read starts at page load.
118
+ :::
119
+
120
+ A record's related records repeat under it as a list: a `ReferenceManyField` holds the records of another resource that point at it, a `ReferenceArrayField` the records whose keys a JSON field of it lists, and an `ArrayField` the items of a JSON list it holds. A `RecordsIterator` inside one draws its children once for each entry, with nothing around them, and a `Table` without `resource` draws the list as a table. A `ReferenceField` draws the one record a field points at. They take the names, props and defaults of the [react-admin](../features/compatibility.md#react-admin) components of the same names.
121
+
122
+ ```tsx
123
+ <RecordCard resource="tasks" recordKey="7">
124
+ <ArrayField source="labels">
125
+ <RecordsIterator><Field source="this" label={false} /></RecordsIterator>
126
+ </ArrayField>
127
+ <ReferenceManyField reference="task_claims" target="task_id" sort={{ field: 'claimed_at', order: 'DESC' }}>
128
+ <RecordsIterator>
129
+ <Card title="Claim {{@index}}">
130
+ <ReferenceField source="worker_id" reference="workers" />
131
+ <ReferenceManyField reference="claim_steps" target="claim_id" empty="No steps yet">
132
+ <RecordsIterator><Field source="name" /></RecordsIterator>
133
+ </ReferenceManyField>
134
+ </Card>
135
+ </RecordsIterator>
136
+ </ReferenceManyField>
137
+ </RecordCard>
138
+ ```
139
+
140
+ Each entry is a record of the stack while its children draw, so `Field`, `Show`, `{{path}}` placeholders and nested lists inside it read it, and `@index`, `@first` and `@last` count its place in the list. A text item of an `ArrayField`, such as a label, is read as `this`; an object item by its keys, which no model describes, so the build does not check them, and it warns when an item's key could shadow a field of a record further out. A list ties itself to the record around it by a field of that record: `source`, `id` of the nearest record by default. `filter` and `sort` take AIP-160 and AIP-132 text, or the objects react-admin writes: `{ status: 'open' }` is `status = "open"`, its fields ANDed, and `{ field: 'claimed_at', order: 'DESC' }` is `claimed_at desc`. Without `sort`, a list is in its key's order, descending, as react-admin's is. `pagination="more"` adds a button that reads the next `perPage` records into the same list. The [blocks reference](blocks.md#related-records) lists every prop.
141
+
142
+ <gap>A list block cannot read its records at page load, beside the records around it, because planning a page's reads is not implemented; each reads once the record around it has drawn.</gap> <gap>A `ReferenceArrayField` cannot read its records through a `related()` filter because array fields in `related()` are not implemented; it reads them by their keys with `in()`.</gap>
143
+
144
+ ## Field values
145
+
146
+ :::caution[Beta]
147
+ A [`ReferenceField`](#related-records), a related record, cannot sit in a line of text yet, and these components may still change.
148
+ :::
149
+
150
+ The field components show one value of the record around them inside a line of text: in a `Text`, a `Link` or a `Summary`, beside words and links. They are [react-admin's field components](https://marmelab.com/react-admin/Fields.html), with the same names, props and defaults, so a layout reads as a react-admin page does. `source` is a [path](#paths-and-scopes), and a `source` no record around it has fails the build with the closest field, as any path does.
151
+
152
+ ```tsx
153
+ <RecordCard resource="repairs" recordKey="42">
154
+ <Details>
155
+ <Summary><TextField source="bike" /> <ChipField source="state" /></Summary>
156
+ <Text>Due <DateField source="due_at" format="relative" />, quoted at <NumberField source="quote" options={{ style: 'currency', currency: 'EUR' }} />.</Text>
157
+ <Text>Paid: <BooleanField source="paid" />. Manual: <UrlField source="manual_url" content="Workshop manual" /></Text>
158
+ </Details>
159
+ </RecordCard>
160
+ ```
161
+
162
+ | Component | Shows | Props besides `source` and `emptyText` |
163
+ | --- | --- | --- |
164
+ | [`TextField`](https://marmelab.com/react-admin/TextField.html) | The value as text; an enum value as its label. | |
165
+ | [`NumberField`](https://marmelab.com/react-admin/NumberField.html) | A number, a numeric string read as one, formatted by `Intl.NumberFormat`. | `locales`, `options` |
166
+ | [`DateField`](https://marmelab.com/react-admin/DateField.html) | A date, by default without its time; a date-only value such as `2026-02-15` on its own day in every time zone. | `showDate` (default `true`), `showTime` (default `false`), `locales`, `options`, `format` |
167
+ | [`BooleanField`](https://marmelab.com/react-admin/BooleanField.html) | A check mark for true and the word for false. | `valueLabelTrue`, `valueLabelFalse` |
168
+ | [`UrlField`](https://marmelab.com/react-admin/UrlField.html) | A link to the address the value holds. | `content`, the link's text instead of the address |
169
+ | [`ChipField`](https://marmelab.com/react-admin/ChipField.html) | The value as a badge, in the view's value colours. | |
170
+
171
+ `emptyText` is shown when the value is empty, and nothing is shown without it. `locales` is a locale or a list of them, such as `nl-NL`, and is the reader's language when omitted; `options` are the `Intl` options, such as `{ style: 'currency', currency: 'EUR' }` or `{ dateStyle: 'long' }`, and locales or options `Intl` does not take fail the build. Where Protobase differs from react-admin:
172
+
173
+ - `DateField format="relative"`, which react-admin does not have, shows how long ago or ahead the moment is, such as "3 hours ago", as the lists show relative times. It takes no `showDate`, `showTime`, `locales` or `options`.
174
+ - A `DateField` with `showDate` and `showTime` both false, which react-admin refuses as it draws, fails the build.
175
+ - `UrlField` links only to an `http:`, `https:`, `mailto:` or `tel:` address or a path on the app's own origin; any other address, such as a `javascript:` one, shows as text. It cannot sit in a `Link`, as a link cannot hold a link.
176
+ - `TextField` and `ChipField` show an enum value by its label from the view, where react-admin shows the stored value.
177
+ - Props that take code in react-admin, such as `transform`, `render` or icons, are not taken: a layout holds data only.
178
+
179
+ <gap>A layout cannot show a related record's value inside a line of text with a `ReferenceField` because drawing a `ReferenceField` inline is not implemented; it stands on its own, as [related records](#related-records) show.</gap>
180
+
181
+ In the [text form](#text-form) each one reads as its formatted value, a `UrlField` as a Markdown link, and a `BooleanField` as Yes or No.
182
+
183
+ `Details` and `Summary` are HTML's [`<details>` and `<summary>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details): a line that opens to show the rest and closes again, by the browser alone, with no script. A `Details` takes one `Summary`, as its first child, and `open` to start open; a `Summary` holds one line, as a `Text` does, and sits in a `Details` only. In the text form a `Details` reads as its summary, then the rest.
111
184
 
112
185
  ## Paths and scopes
113
186
 
114
- A `RecordCard` and each card of a `CardRow` put their record on a stack of records, as each section does in [Mustache](https://mustache.github.io/mustache.5.html): an element inside both a task's `RecordCard` and a `CardRow` of its claims sits in a claim, inside the task. A name in a layout is looked up through that stack, by the rules of the [Mustache spec](https://github.com/mustache/spec) and [Handlebars path expressions](https://handlebarsjs.com/guide/expressions.html#path-expressions):
187
+ :::caution[Beta]
188
+ A path cannot read `@root` or `@params` yet, and a block inside a card or under a condition reads its records only once it draws, as the marked limits below say.
189
+ :::
190
+
191
+ A `RecordCard`, a `ReferenceField`, each card of a `CardRow` and each entry of a [`RecordsIterator`](#related-records) put their record on a stack of records: an element inside both a task's `RecordCard` and a `CardRow` of its claims sits in a claim, inside the task. A bare name is looked up in the innermost record, then in each record further out, then in the page's own record; the [compatibility page](../features/compatibility.md#template-paths) says which template syntax this follows:
115
192
 
116
193
  | Path | Reads |
117
194
  | --- | --- |
118
195
  | `status` | The nearest record that has a field `status`, then each record around it in turn. |
119
- | `meta.size` | `meta` as above, then `size` from that value only: when it has none, the path is empty, and no record further out is tried (Mustache's "Dotted Names - Context Precedence"). |
196
+ | `meta.size` | `meta` as above, then `size` from that value only: when it has none, the path is empty, and no record further out is tried. |
120
197
  | `../id`, `../../id` | The record one, or two, out from the nearest. |
121
198
  | `this.id`, `./id` | The nearest record only. |
122
- | `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, from 0, and whether it is the first or the last. |
199
+ | `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, or the entry's among a `RecordsIterator`'s, from 0, and whether it is the first or the last. |
123
200
  | `@root.id` | The page's own record. <gap>A path cannot read `@root` because pages with a record of their own are not implemented.</gap> |
124
201
  | `@params.window` | The page parameter `window`. <gap>A path cannot read `@params` because the input that sets a page parameter is not implemented.</gap> |
125
202
 
126
- `Field name`, `Stat field`, `Progress`, and the names in a [condition](#conditions) take a path. A string prop takes `{{path}}` placeholders, double braces as in Handlebars, filled with the path's value where the element draws, and empty when it has none:
203
+ `Field source`, a field component's `source`, `Stat field`, `Progress`, and the names in a [condition](#conditions) take a path. A string prop takes `{{path}}` placeholders in double braces, filled with the path's value where the element draws, and empty when it has none:
127
204
 
128
- - `title`, `description`, `empty` and `label` read any path: `<Table resource="claim_steps" title="Steps of {{title}}" />`.
205
+ - `title`, `description`, `empty`, `label`, and a field component's `emptyText`, `content`, `valueLabelTrue` and `valueLabelFalse` read any path: `<Table resource="claim_steps" title="Steps of {{title}}" />`.
129
206
  - `filter`, `recordKey` and `values` read a field of a record around them. A filter takes one only as a top-level `AND` equality, `claim_id = {{id}} AND done = false`, the shape a read can take for every row at once with a [`related()`](api.md#filtering-through-related-records) filter. A filter takes a page parameter anywhere.
130
207
  - `when` takes them where a name cannot go, such as `this.status = '{{../status}}'`, since a name in AIP-160 cannot start with `../` or `@`.
131
208
  - A [link's address](#addresses) takes them in its resource, key, tab, filter, order and values.
132
209
 
133
- A placeholder quoted on its own in a filter or condition, `title = '{{title}}'`, is filled with its quotes and backslashes escaped, so any text stays one value; Handlebars escapes for HTML instead. One inside a longer quoted value, `title = 'about {{title}}'`, fails the build, as it would be filled unescaped. Paths are all a placeholder holds: no helpers, subexpressions, literals, `@key` or `{{{triple braces}}}`. A `{{…}}` that holds anything else fails as soon as the layout loads, before its names are checked.
210
+ A placeholder quoted on its own in a filter or condition, `title = '{{title}}'`, is filled with its quotes and backslashes escaped, so any text stays one value: a placeholder is escaped for the string it lands in, not for HTML. One inside a longer quoted value, `title = 'about {{title}}'`, fails the build, as it would be filled unescaped. Paths are all a placeholder holds: no helpers, subexpressions, literals, `@key` or `{{{triple braces}}}`. A `{{…}}` that holds anything else fails as soon as the layout loads, before its names are checked.
134
211
 
135
212
  The build checks every path where it sits:
136
213
 
137
- - **Typos.** A name no record around it has fails, naming every record searched and the closest field: `"claimd_at" is no field of task_claims, tasks; did you mean claimed_at?`. Mustache would draw it empty, so a layout the build accepts draws the same under Mustache's rules.
138
- - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow`, and `@params.x` without an input setting `x` fail.
214
+ - **Typos.** A name no record around it has fails, naming every record searched and the closest field: `"claimd_at" is no field of task_claims, tasks; did you mean claimed_at?`. A name the build accepts that has no value in a record draws empty.
215
+ - **Bad roots.** `../` past the outermost record, `@root` on a page without a record, `@index` outside a `CardRow` or `RecordsIterator`, and `@params.x` without an input setting `x` fail.
139
216
  - **Reads that would wait.** A per-row value in a filter in any other place than a top-level `AND` equality (with `>=`, inside `OR` or `NOT`, a second one), `@index`, `@first`, `@last` or `this` in a filter, key or values, and any placeholder in `resource`, `sort`, `columns` or `limit` fail with "this would wait for the parent's rows": each block's records are one read of their own, and none may wait for another's rows.
140
217
  - **Shadowing.** A bare name that more than one record around it has reads the nearest, and the build warns which it read and how to write the others: `"id" resolves to task_claims; write ../id for the one of tasks`. `protobase build --strict` fails on it instead. `this.`, `./`, `../` and `@` paths never warn.
141
218