@protobase/cli 0.97.0 → 0.98.0
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/dist/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/actions.md +1 -0
- package/skills/protobase/references/features/compatibility.md +4 -0
- package/skills/protobase/references/features/composed-pages.md +2 -1
- package/skills/protobase/references/guides/billing-page.md +32 -32
- package/skills/protobase/references/guides/first-composed-page.md +11 -11
- package/skills/protobase/references/reference/blocks.md +40 -17
- package/skills/protobase/references/reference/layouts.md +54 -8
- package/skills/protobase/references/reference/ui-config.md +19 -0
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.98.0",
|
|
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.
|
|
47
|
-
"@protobase/layout": "0.
|
|
48
|
-
"@protobase/query": "0.
|
|
49
|
-
"@protobase/schema": "0.
|
|
50
|
-
"@protobase/server": "0.
|
|
51
|
-
"@protobase/ui": "0.
|
|
52
|
-
"@protobase/workflows": "0.
|
|
46
|
+
"@protobase/config": "0.98.0",
|
|
47
|
+
"@protobase/layout": "0.98.0",
|
|
48
|
+
"@protobase/query": "0.98.0",
|
|
49
|
+
"@protobase/schema": "0.98.0",
|
|
50
|
+
"@protobase/server": "0.98.0",
|
|
51
|
+
"@protobase/ui": "0.98.0",
|
|
52
|
+
"@protobase/workflows": "0.98.0",
|
|
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",
|
|
@@ -6,6 +6,7 @@ Buttons that change records, ask for input or run your own code, per role.
|
|
|
6
6
|
|
|
7
7
|
- [Record actions](../reference/ui-config.md#actions-and-views-per-role): Buttons that update fields, delete, open a link, run an AI action or call your own code.
|
|
8
8
|
- [Actions that ask for input](../reference/ui-config.md#actions-that-ask-for-input): An action opens a dialog for text, numbers, dates, choices or records before it runs.
|
|
9
|
+
- [Secret inputs](../reference/ui-config.md#secret-inputs) (beta): An action can take a secret value, such as an API key, in a masked input that browsers and password managers do not offer to save, and the value is never sent back.
|
|
9
10
|
- [Actions that send from someone's mailbox](../reference/ui-config.md#actions-that-send-from-someones-mailbox) (beta): An action that sends from the person's own mailbox offers to connect it right in its dialog while none is linked or its link expired.
|
|
10
11
|
- [Conditional and bulk actions](../reference/ui-config.md#where-an-action-applies): Actions show, or show disabled with a reason, only where a condition holds, and run on several selected rows at once.
|
|
11
12
|
- [Signing several records off](../reference/blocks.md#signing-several-records-off) (experimental): An action can sign several records off at once, after a checklist.
|
|
@@ -13,3 +13,7 @@ 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.
|
|
@@ -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
|
|
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.
|
|
@@ -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
|
|
29
|
-
<Field
|
|
30
|
-
<Field
|
|
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
|
|
99
|
-
<Field
|
|
100
|
-
<Field
|
|
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
|
|
111
|
-
<Field
|
|
112
|
-
<Field
|
|
113
|
-
<Field
|
|
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
|
|
143
|
-
<Field
|
|
144
|
-
<Field
|
|
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
|
|
155
|
-
<Field
|
|
156
|
-
<Field
|
|
157
|
-
<Field
|
|
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
|
|
168
|
-
<Field
|
|
169
|
-
<Field
|
|
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
|
|
207
|
-
<Field
|
|
208
|
-
<Field
|
|
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
|
|
220
|
-
<Field
|
|
221
|
-
<Field
|
|
222
|
-
<Field
|
|
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
|
|
233
|
-
<Field
|
|
234
|
-
<Field
|
|
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
|
|
248
|
-
<Field
|
|
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
|
|
99
|
-
<Field
|
|
100
|
-
<Field
|
|
101
|
-
<Field
|
|
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
|
|
196
|
-
<Field
|
|
197
|
-
<Field
|
|
198
|
-
<Field
|
|
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
|
|
215
|
-
<Field
|
|
216
|
-
<Field
|
|
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>,
|
|
@@ -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
|
|
40
|
-
<Field
|
|
41
|
-
<Field
|
|
42
|
-
<Field
|
|
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
|
|
56
|
-
<Field
|
|
57
|
-
<Field
|
|
58
|
-
<Field
|
|
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
|
|
83
|
-
<Field
|
|
84
|
-
<Field
|
|
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
|
|
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
|
|
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.
|
|
@@ -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
|
|
337
|
-
<Field
|
|
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
|
-
| `
|
|
403
|
-
| `label` | Default: the view's label, else the
|
|
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%.
|
|
@@ -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
|
|
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,10 @@ 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
76
|
| `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. |
|
|
77
|
+
| `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
78
|
| `basePath` | What links start with, such as `https://example.com/admin`. |
|
|
78
79
|
| `forms` | Text forms by block type, over the built-in ones. |
|
|
79
80
|
|
|
@@ -109,32 +110,77 @@ Behaviour comes from [named actions](#named-actions); React code from [custom co
|
|
|
109
110
|
|
|
110
111
|
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.
|
|
111
112
|
|
|
113
|
+
## Field values
|
|
114
|
+
|
|
115
|
+
:::caution[Beta]
|
|
116
|
+
React-admin's `ReferenceField`, a related record's value, is not built yet, and these components may still change.
|
|
117
|
+
:::
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<RecordCard resource="repairs" recordKey="42">
|
|
123
|
+
<Details>
|
|
124
|
+
<Summary><TextField source="bike" /> <ChipField source="state" /></Summary>
|
|
125
|
+
<Text>Due <DateField source="due_at" format="relative" />, quoted at <NumberField source="quote" options={{ style: 'currency', currency: 'EUR' }} />.</Text>
|
|
126
|
+
<Text>Paid: <BooleanField source="paid" />. Manual: <UrlField source="manual_url" content="Workshop manual" /></Text>
|
|
127
|
+
</Details>
|
|
128
|
+
</RecordCard>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Component | Shows | Props besides `source` and `emptyText` |
|
|
132
|
+
| --- | --- | --- |
|
|
133
|
+
| [`TextField`](https://marmelab.com/react-admin/TextField.html) | The value as text; an enum value as its label. | |
|
|
134
|
+
| [`NumberField`](https://marmelab.com/react-admin/NumberField.html) | A number, a numeric string read as one, formatted by `Intl.NumberFormat`. | `locales`, `options` |
|
|
135
|
+
| [`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` |
|
|
136
|
+
| [`BooleanField`](https://marmelab.com/react-admin/BooleanField.html) | A check mark for true and the word for false. | `valueLabelTrue`, `valueLabelFalse` |
|
|
137
|
+
| [`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 |
|
|
138
|
+
| [`ChipField`](https://marmelab.com/react-admin/ChipField.html) | The value as a badge, in the view's value colours. | |
|
|
139
|
+
|
|
140
|
+
`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:
|
|
141
|
+
|
|
142
|
+
- `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`.
|
|
143
|
+
- A `DateField` with `showDate` and `showTime` both false, which react-admin refuses as it draws, fails the build.
|
|
144
|
+
- `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.
|
|
145
|
+
- `TextField` and `ChipField` show an enum value by its label from the view, where react-admin shows the stored value.
|
|
146
|
+
- Props that take code in react-admin, such as `transform`, `render` or icons, are not taken: a layout holds data only.
|
|
147
|
+
|
|
148
|
+
<gap>A layout cannot show a related record's value inline with react-admin's `ReferenceField` because `ReferenceField` is not implemented.</gap>
|
|
149
|
+
|
|
150
|
+
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.
|
|
151
|
+
|
|
152
|
+
`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.
|
|
153
|
+
|
|
112
154
|
## Paths and scopes
|
|
113
155
|
|
|
114
|
-
|
|
156
|
+
:::caution[Beta]
|
|
157
|
+
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.
|
|
158
|
+
:::
|
|
159
|
+
|
|
160
|
+
A `RecordCard` and each card of a `CardRow` 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
161
|
|
|
116
162
|
| Path | Reads |
|
|
117
163
|
| --- | --- |
|
|
118
164
|
| `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
|
|
165
|
+
| `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
166
|
| `../id`, `../../id` | The record one, or two, out from the nearest. |
|
|
121
167
|
| `this.id`, `./id` | The nearest record only. |
|
|
122
168
|
| `@index`, `@first`, `@last` | The card's place among a `CardRow`'s cards, from 0, and whether it is the first or the last. |
|
|
123
169
|
| `@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
170
|
| `@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
171
|
|
|
126
|
-
`Field
|
|
172
|
+
`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
173
|
|
|
128
|
-
- `title`, `description`, `empty` and `
|
|
174
|
+
- `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
175
|
- `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
176
|
- `when` takes them where a name cannot go, such as `this.status = '{{../status}}'`, since a name in AIP-160 cannot start with `../` or `@`.
|
|
131
177
|
- A [link's address](#addresses) takes them in its resource, key, tab, filter, order and values.
|
|
132
178
|
|
|
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
|
|
179
|
+
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
180
|
|
|
135
181
|
The build checks every path where it sits:
|
|
136
182
|
|
|
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?`.
|
|
183
|
+
- **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.
|
|
138
184
|
- **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.
|
|
139
185
|
- **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
186
|
- **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.
|
|
@@ -1356,6 +1356,7 @@ a.update('answer', { label: 'Answer', inputs: (i) => [i.text('answer', { label:
|
|
|
1356
1356
|
| `i.decimal(name, o)` | A number with decimals, which the handler gets as text, as the API gives decimals, so no digit is lost. |
|
|
1357
1357
|
| `i.boolean(name, o)` | A switch, `true` or `false`, so it is never required. |
|
|
1358
1358
|
| `i.date(name, o)` | A date, `YYYY-MM-DD`. |
|
|
1359
|
+
| `i.secret(name, o)` | A [secret](#secret-inputs), such as an API key, in a masked field; the handler gets it exactly as typed. |
|
|
1359
1360
|
| `i.choice(name, { options })` | One of `options`, each a `value` with the `label` it reads as. |
|
|
1360
1361
|
| `i.choice(name, { resource })` | A record of `resource`, picked as the create form picks a relation; the handler gets its key. |
|
|
1361
1362
|
| `i.checklist(name, { items })` | Boxes to tick, every one, before the action runs: the same `items` for every record. The answer is the list of their texts. |
|
|
@@ -1368,6 +1369,24 @@ An empty answer is `null`. Before the handler runs, the dialog refuses a require
|
|
|
1368
1369
|
|
|
1369
1370
|
A custom input's component gets the answer as `value` (`null` when empty), `onChange`, `invalid` while its answer is refused, the input's `props` and the `input` itself (`ActionInputProps`), as a [field type's](custom-components.md#field-types) editor does. Without that component the button is disabled, with the reason as its tooltip. In `/api/meta`, a user who cannot read the resource of a choice does not get the action.
|
|
1370
1371
|
|
|
1372
|
+
#### Secret inputs
|
|
1373
|
+
|
|
1374
|
+
:::caution[Beta]
|
|
1375
|
+
A secret input has no button that shows what you typed. It takes no `default`, a later input's `when` cannot read it, and an `a.update` cannot write it.
|
|
1376
|
+
:::
|
|
1377
|
+
|
|
1378
|
+
`i.secret(name, { label, help })` asks for a value that must not be seen or kept, such as an API key, so an app takes one without a custom component. The field draws what you type as discs, and browsers and password managers do not offer to save it, fill it, correct it or keep it in their form history. The value goes only to the handler, as `values[name]`:
|
|
1379
|
+
|
|
1380
|
+
```ts
|
|
1381
|
+
a.action('connect_carrier', {
|
|
1382
|
+
label: 'Connect carrier',
|
|
1383
|
+
icon: 'key',
|
|
1384
|
+
inputs: (i) => [i.secret('api_key', { label: 'API key', help: 'From the carrier’s settings page.' })],
|
|
1385
|
+
})
|
|
1386
|
+
```
|
|
1387
|
+
|
|
1388
|
+
It is never sent back: when the handler's error or an input's message holds the value, the dialog or the toast shows discs in its place. A secret takes no `default`, a later input's `when` cannot read it, and an `a.update` whose `set` writes it stops the config from loading, since the update would store the value and send it back; the handler decides what to do with it.
|
|
1389
|
+
|
|
1371
1390
|
### Actions that send from someone's mailbox
|
|
1372
1391
|
|
|
1373
1392
|
An `a.action` whose handler sends mail from the signed-in person's [own mailbox](email.md#from-someones-own-mailbox), such as an invoice from their Gmail, says so with `mailbox: true`. While they have linked no mailbox, its dialog offers to connect one instead of running: **Connect Gmail** starts the same sign-in as the account page's and comes back to the page they were on, where the action runs. Someone who signs in with Google without having allowed it to send mail is told that sign-in is no mailbox. The check needs a dialog, so give the action `confirm` or inputs:
|