@protobase/cli 0.22.12 → 0.23.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/main.js +2 -0
- package/dist/package.js +1 -1
- package/dist/skill/install.js +29 -0
- package/dist/skill/register.js +14 -0
- package/package.json +8 -7
- package/skills/protobase/SKILL.md +89 -0
- package/skills/protobase/references/getting-started.md +78 -0
- package/skills/protobase/references/guides/api-functions.md +240 -0
- package/skills/protobase/references/guides/billing-page.md +288 -0
- package/skills/protobase/references/guides/create-page.md +108 -0
- package/skills/protobase/references/guides/deploy.md +52 -0
- package/skills/protobase/references/guides/export-a-list.md +44 -0
- package/skills/protobase/references/guides/field-type.md +131 -0
- package/skills/protobase/references/guides/first-composed-page.md +230 -0
- package/skills/protobase/references/guides/first-plugin.md +166 -0
- package/skills/protobase/references/guides/import-records.md +43 -0
- package/skills/protobase/references/guides/plugin-build.md +64 -0
- package/skills/protobase/references/guides/record-card.md +70 -0
- package/skills/protobase/references/guides/remote-resources.md +185 -0
- package/skills/protobase/references/guides/table-to-admin.md +205 -0
- package/skills/protobase/references/guides/theme-an-app.md +87 -0
- package/skills/protobase/references/reference/access.md +115 -0
- package/skills/protobase/references/reference/ai.md +106 -0
- package/skills/protobase/references/reference/api.md +231 -0
- package/skills/protobase/references/reference/architecture.md +63 -0
- package/skills/protobase/references/reference/assistant.md +157 -0
- package/skills/protobase/references/reference/auth.md +462 -0
- package/skills/protobase/references/reference/blocks.md +341 -0
- package/skills/protobase/references/reference/bottom-bar.md +44 -0
- package/skills/protobase/references/reference/cli.md +493 -0
- package/skills/protobase/references/reference/client.md +38 -0
- package/skills/protobase/references/reference/comments.md +83 -0
- package/skills/protobase/references/reference/custom-components.md +285 -0
- package/skills/protobase/references/reference/data-config.md +266 -0
- package/skills/protobase/references/reference/email.md +166 -0
- package/skills/protobase/references/reference/events.md +121 -0
- package/skills/protobase/references/reference/files.md +291 -0
- package/skills/protobase/references/reference/forms.md +133 -0
- package/skills/protobase/references/reference/history.md +86 -0
- package/skills/protobase/references/reference/jobs.md +174 -0
- package/skills/protobase/references/reference/layouts.md +126 -0
- package/skills/protobase/references/reference/plugins.md +328 -0
- package/skills/protobase/references/reference/remote-resources.md +198 -0
- package/skills/protobase/references/reference/sidebar.md +51 -0
- package/skills/protobase/references/reference/theme.md +132 -0
- package/skills/protobase/references/reference/ui-config.md +880 -0
- package/skills/protobase/references/reference/user-menu.md +38 -0
- package/skills/protobase/references/reference/versioning.md +91 -0
- package/skills/protobase/references/reference/webhooks.md +136 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/blocks.mdx: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Blocks
|
|
4
|
+
|
|
5
|
+
Every built-in layout block, its props and what it does, with examples from the ERP's sales overview.
|
|
6
|
+
|
|
7
|
+
Blocks are imported from `@protobase/layout`. "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. Every block below but `RecordRow`, which the property portal's home uses, and `Users`, which the [Users page](auth.md#users-page)) uses, appears in the ERP example's sales overview:
|
|
8
|
+
|
|
9
|
+
```tsx title="examples/erp/config/overview/page.tsx"
|
|
10
|
+
/** @jsxImportSource @protobase/layout */
|
|
11
|
+
import { Action, Card, CardRow, Chart, Field, Grid, ModalForm, Page, RecordCard, Show, Stat, Table, component, page } from '@protobase/layout'
|
|
12
|
+
|
|
13
|
+
/** Orders per day for the last `days` days, drawn by protobase.ui.tsx. */
|
|
14
|
+
export const OrdersPerDay = component<{ days: 7 | 30 | 90 }>('OrdersPerDay')
|
|
15
|
+
|
|
16
|
+
/** The sales team's start page: what needs attention today, and the leads to follow up. */
|
|
17
|
+
export const salesOverview = page(
|
|
18
|
+
'overview',
|
|
19
|
+
<Page title="Sales overview" description="What needs attention today: unpaid orders, overdue invoices and new leads.">
|
|
20
|
+
<Show when="orders.count = 0">
|
|
21
|
+
<Card title="No orders yet">Create the first order from Orders; this page fills up as the team sells.</Card>
|
|
22
|
+
</Show>
|
|
23
|
+
<Grid columns={4}>
|
|
24
|
+
<Stat label="Draft orders" resource="orders" filter="status = 'draft'" />
|
|
25
|
+
<Stat label="Delivered, not paid" resource="orders" filter="status = 'delivered' AND paid = false" />
|
|
26
|
+
<Stat label="Overdue invoices" resource="invoices" filter="status = 'overdue'" />
|
|
27
|
+
<Stat label="Open leads" resource="companies" filter="status = 'lead'" />
|
|
28
|
+
</Grid>
|
|
29
|
+
<Grid columns={3}>
|
|
30
|
+
<RecordCard
|
|
31
|
+
title="Biggest unpaid delivery"
|
|
32
|
+
resource="orders"
|
|
33
|
+
filter="status = 'delivered' AND paid = false"
|
|
34
|
+
sort="total desc"
|
|
35
|
+
empty="Every delivered order is paid."
|
|
36
|
+
actions={<Action name="markPaid" variant="primary" />}
|
|
37
|
+
>
|
|
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" />
|
|
43
|
+
</Grid>
|
|
44
|
+
<Show when="company_id.status = 'dormant'">The customer has gone quiet: call before sending a reminder.</Show>
|
|
45
|
+
</RecordCard>
|
|
46
|
+
<RecordCard
|
|
47
|
+
title="Oldest overdue invoice"
|
|
48
|
+
resource="invoices"
|
|
49
|
+
filter="status = 'overdue'"
|
|
50
|
+
sort="issued_at"
|
|
51
|
+
empty="Nothing is overdue."
|
|
52
|
+
actions={[<Action name="send" label="Send reminder" />, <Action name="recordPayment" variant="primary" />]}
|
|
53
|
+
>
|
|
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" />
|
|
59
|
+
</Grid>
|
|
60
|
+
</RecordCard>
|
|
61
|
+
<Card title="Orders per day" description="The last 30 days.">
|
|
62
|
+
<OrdersPerDay days={30} />
|
|
63
|
+
</Card>
|
|
64
|
+
</Grid>
|
|
65
|
+
<Grid columns={2}>
|
|
66
|
+
<Chart title="Orders by status" resource="orders" groupBy="status" type="donut" />
|
|
67
|
+
<Chart title="Revenue by customer" description="Orders not cancelled." resource="orders" groupBy="company_id" sum="total" filter="status != 'cancelled'" limit={5} />
|
|
68
|
+
</Grid>
|
|
69
|
+
<Grid columns={2}>
|
|
70
|
+
<Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
|
|
71
|
+
<Table title="Latest orders" resource="orders" sort="created_at desc" columns={['number', 'company_id', 'status', 'total']} limit={5} />
|
|
72
|
+
</Grid>
|
|
73
|
+
<CardRow
|
|
74
|
+
title="New leads"
|
|
75
|
+
description="Companies that have not ordered yet."
|
|
76
|
+
resource="companies"
|
|
77
|
+
filter="status = 'lead'"
|
|
78
|
+
sort="created_at desc"
|
|
79
|
+
limit={8}
|
|
80
|
+
actions={<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'country_code', 'email']} values={{ status: 'lead' }} />}
|
|
81
|
+
>
|
|
82
|
+
<Field name="name" label={false} />
|
|
83
|
+
<Field name="city" />
|
|
84
|
+
<Field name="email" />
|
|
85
|
+
<ModalForm mode="edit" label="Edit" fields={['name', 'city', 'email', 'phone', 'status']} />
|
|
86
|
+
</CardRow>
|
|
87
|
+
</Page>,
|
|
88
|
+
{ nav: { group: 'Sales', order: 0 }, icon: 'layout-dashboard' },
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Layout
|
|
93
|
+
|
|
94
|
+
### Page
|
|
95
|
+
|
|
96
|
+
The root of every page, and only the root.
|
|
97
|
+
|
|
98
|
+
| Prop | |
|
|
99
|
+
| --- | --- |
|
|
100
|
+
| `title` | Heading, and the page's name in the sidebar and breadcrumbs. Required. |
|
|
101
|
+
| `description` | A line under the title. |
|
|
102
|
+
| `actions` | Elements beside the title, such as a `ModalForm`. |
|
|
103
|
+
|
|
104
|
+
### Grid
|
|
105
|
+
|
|
106
|
+
Columns that collapse to one on a phone, or to two when the grid holds only `Stat`s. A child's `span` (1 to 4) makes it wider.
|
|
107
|
+
|
|
108
|
+
| Prop | |
|
|
109
|
+
| --- | --- |
|
|
110
|
+
| `columns` | 1 to 4; default 2. |
|
|
111
|
+
| `span` | Its own width when it sits in another grid. |
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<Grid columns={4}>
|
|
115
|
+
<Stat label="Draft orders" resource="orders" filter="status = 'draft'" />
|
|
116
|
+
...
|
|
117
|
+
</Grid>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Card
|
|
121
|
+
|
|
122
|
+
A box with a heading. Text and `Link`s inside it run together as paragraphs.
|
|
123
|
+
|
|
124
|
+
| Prop | |
|
|
125
|
+
| --- | --- |
|
|
126
|
+
| `title`, `description` | The heading. |
|
|
127
|
+
| `actions` | Elements in the heading. |
|
|
128
|
+
| `span` | Width in a grid. |
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
<Card title="No orders yet">Create the first order from Orders; this page fills up as the team sells.</Card>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Link
|
|
135
|
+
|
|
136
|
+
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). Its text is its children.
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<Link to={{ kind: 'list', resource: 'invoices', filter: "status = 'overdue'" }}>Overdue invoices</Link>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
| Prop | |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `to` | An [address](layouts.md#addresses)). Inside a record, `{field}` in its key, filter or order is the record's value. |
|
|
145
|
+
| `href` | A link that leaves the app. A path in the app is refused when the config loads: give it as `to`. |
|
|
146
|
+
|
|
147
|
+
One of the two is required. A link to a resource or field the user cannot see is left out of their page.
|
|
148
|
+
|
|
149
|
+
## Data
|
|
150
|
+
|
|
151
|
+
### Stat
|
|
152
|
+
|
|
153
|
+
One number or value with a label. Exactly one of `value`, `resource` and `field`.
|
|
154
|
+
|
|
155
|
+
| Prop | |
|
|
156
|
+
| --- | --- |
|
|
157
|
+
| `label` | Required. |
|
|
158
|
+
| `value` | A fixed value. |
|
|
159
|
+
| `resource`, `filter` | Counts the matching records the user can see; the card links to that filtered list. |
|
|
160
|
+
| `field` | A field of the record, through relations (`plan.name`). |
|
|
161
|
+
| `format` | Instead of the view's [format](ui-config.md#names-and-columns)), such as `badge`. |
|
|
162
|
+
| `description` | A line under the value. |
|
|
163
|
+
| `span` | Width in a grid. |
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
<Stat label="Delivered, not paid" resource="orders" filter="status = 'delivered' AND paid = false" />
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Table
|
|
170
|
+
|
|
171
|
+
The first records of a list, drawn the way the resource's list page draws them: its table, or one of the view's [list displays](ui-config.md#list-displays)) such as cards, with the same switch between them when the view has several. A row or card opens the record, and **View all** opens the list with the same filter and order. On a phone a view with a cards display opens in it, as one row of cards that scrolls sideways; a display the viewer picks is kept for them in the browser.
|
|
172
|
+
|
|
173
|
+
| Prop | |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
|
|
176
|
+
| `columns` | Field names for the table; default the view's list columns. |
|
|
177
|
+
| `limit` | How many records it shows; default 10. It has no pages: the rest are in the list. Before 0.13 this was `pageSize`, rows per page; rename it. |
|
|
178
|
+
| `display` | The display it opens in, such as `cards`; default the list's. |
|
|
179
|
+
| `title`, `description`, `actions` | The heading. |
|
|
180
|
+
| `empty` | Text when nothing matches; default "Nothing here yet.". |
|
|
181
|
+
| `span` | Width in a grid. |
|
|
182
|
+
|
|
183
|
+
```tsx
|
|
184
|
+
<Table title="Overdue invoices" resource="invoices" filter="status = 'overdue'" sort="issued_at" columns={['number', 'company_id', 'due_at', 'total']} limit={5} empty="Nothing is overdue." />
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### RecordCard
|
|
188
|
+
|
|
189
|
+
One record and what is inside it: the one `recordKey` names (the key as the record's URL has it), else the first that matches `filter` in `sort` order. Its children and its heading `actions` work on that record.
|
|
190
|
+
|
|
191
|
+
| Prop | |
|
|
192
|
+
| --- | --- |
|
|
193
|
+
| `resource`, `filter`, `sort` | Which record. `resource` is required. |
|
|
194
|
+
| `recordKey` | A fixed record instead. |
|
|
195
|
+
| `title`, `description`, `actions` | The heading. |
|
|
196
|
+
| `empty` | Text when no record matches. |
|
|
197
|
+
| `span` | Width in a grid. |
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
<RecordCard title="Biggest unpaid delivery" resource="orders" filter="status = 'delivered' AND paid = false" sort="total desc" actions={<Action name="markPaid" variant="primary" />}>
|
|
201
|
+
<Field name="number" />
|
|
202
|
+
<Field name="company_id.city" label="City" />
|
|
203
|
+
</RecordCard>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### CardRow
|
|
207
|
+
|
|
208
|
+
Up to `limit` records side by side, each a small card made from the children, which work on that card's record. The heading's `actions` do not have a record: use them for a `ModalForm mode="create"`.
|
|
209
|
+
|
|
210
|
+
| Prop | |
|
|
211
|
+
| --- | --- |
|
|
212
|
+
| `resource`, `filter`, `sort` | Which records, in which order. `resource` is required. |
|
|
213
|
+
| `limit` | How many; default 12. |
|
|
214
|
+
| `title`, `description`, `actions` | The heading. |
|
|
215
|
+
| `empty` | Text when nothing matches. |
|
|
216
|
+
| `span` | Width in a grid. |
|
|
217
|
+
|
|
218
|
+
### RecordRow
|
|
219
|
+
|
|
220
|
+
What a filter finds, the way a home page shows it: the filter's chips, as the list's filter panel names them, how many records match, the records as the cards of the resource's [cards display](ui-config.md#list-displays)) in one row, and **View all**, which opens the list with the same filter and order. The row scrolls sideways by touch, trackpad or its arrow buttons; only the cards near the view are drawn, and the records load through the list API in pages as it scrolls. Each card opens its record. A resource without a cards display gets cards of the title alone.
|
|
221
|
+
|
|
222
|
+
It follows the resource's view as its list page does. Of a resource whose view has [`listOf`](ui-config.md#favorites)), such as favorites, it shows the records the user's saved ones point at, as their own resource's cards, and **View all** opens the favorites. Of one whose view has [`searchesOf`](ui-config.md#saved-searches)), it shows a row for each of the user's saved searches, under its name or its filters, with the records new to them marked **New** and **View all results**, as their list page shows them. `filter` and `sort` do not apply to those two.
|
|
223
|
+
|
|
224
|
+
| Prop | |
|
|
225
|
+
| --- | --- |
|
|
226
|
+
| `resource`, `filter`, `sort` | Which records, in which order. `resource` is required; `sort` defaults to the list's. |
|
|
227
|
+
| `limit` | How many records it shows at most; default every one that matches. |
|
|
228
|
+
| `display` | The cards display whose cards it draws; default the view's first. |
|
|
229
|
+
| `title`, `description`, `actions` | The heading. |
|
|
230
|
+
| `empty` | Text when nothing matches; default "No … match.", with the view's plural. |
|
|
231
|
+
| `span` | Width in a grid. |
|
|
232
|
+
|
|
233
|
+
```tsx
|
|
234
|
+
<RecordRow title="For rent" resource="listings" filter="for_rent = true AND status = 'available'" sort="published_at desc" />
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Field
|
|
238
|
+
|
|
239
|
+
A label over a value of the record, formatted as on the record page: statuses as badges with the view's value labels, relations as the related record's name (linked), the view's prefix and decimals.
|
|
240
|
+
|
|
241
|
+
| Prop | |
|
|
242
|
+
| --- | --- |
|
|
243
|
+
| `name` | A field, through relations (`company_id.city`). Required. |
|
|
244
|
+
| `label` | Default: the view's label, else the name in words. `false` shows the value alone. |
|
|
245
|
+
| `format` | Instead of the view's [format](ui-config.md#names-and-columns)). |
|
|
246
|
+
|
|
247
|
+
### Progress
|
|
248
|
+
|
|
249
|
+
A bar for `value` out of `max`, with both numbers. It turns amber from 90%.
|
|
250
|
+
|
|
251
|
+
| Prop | |
|
|
252
|
+
| --- | --- |
|
|
253
|
+
| `value` | A number, or the name of a field of the record. Required. |
|
|
254
|
+
| `max` | A number or a field; default 100. |
|
|
255
|
+
| `label`, `span` | |
|
|
256
|
+
|
|
257
|
+
```tsx
|
|
258
|
+
<Progress label="Seats" value="seats_used" max="plan.seats" />
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Chart
|
|
262
|
+
|
|
263
|
+
Counts, sums or averages of the records that match `filter`, per value of a field or per hour, day, week, month or year of a date field, in a card. It reads [`:aggregate`](api.md#routes)), so only what the user may see is counted, and the grouped field needs an index ([scan guard](api.md#safety))).
|
|
264
|
+
|
|
265
|
+
| Prop | |
|
|
266
|
+
| --- | --- |
|
|
267
|
+
| `resource`, `filter` | The records it counts. `resource` is required. |
|
|
268
|
+
| `groupBy` | A filterable field. Values, such as an enum, a boolean or a relation (named by the related record), are ranked bars or a donut, each linking to its records; a date or timestamp field is a bar or line per bucket, empty ones included. Required. |
|
|
269
|
+
| `splitBy` | With a date `groupBy`: a field of values that splits each bucket, as stacked bars or a line per value; its 8 largest values over the range, the rest as Other for a count or sum. An index must serve it. A stacked bar takes no average. |
|
|
270
|
+
| `type` | `bar` (the default), `line` for a date `groupBy`, `donut` for one of values. |
|
|
271
|
+
| `sum`, `average` | A numeric field each group adds up or averages, with its prefix, suffix and decimals, instead of counting. One of the two; a donut takes no average. |
|
|
272
|
+
| `granularity`, `range` | A date `groupBy`'s bucket, `hour` to `year` (default `day`), and how far back it reaches: `7d`, `30d` (the default), `90d`, `1y` or `all`. |
|
|
273
|
+
| `limit` | How many values it shows, the largest; default 10. |
|
|
274
|
+
| `title`, `description`, `actions`, `empty`, `span` | As on `Table`. |
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
<Chart title="Orders by status" resource="orders" groupBy="status" type="donut" />
|
|
278
|
+
<Chart title="Revenue by customer" resource="orders" groupBy="company_id" sum="total" filter="status != 'cancelled'" limit={5} />
|
|
279
|
+
<Chart title="Invoiced per month" resource="invoices" groupBy="issued_at" granularity="month" range="1y" type="line" sum="total" />
|
|
280
|
+
<Chart title="Revenue per day by status" resource="orders" groupBy="created_at" splitBy="status" sum="total" />
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
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.
|
|
284
|
+
|
|
285
|
+
## Behaviour
|
|
286
|
+
|
|
287
|
+
### Action
|
|
288
|
+
|
|
289
|
+
A button for a [named action](layouts.md#named-actions)) of the view, on the record around it.
|
|
290
|
+
|
|
291
|
+
| Prop | |
|
|
292
|
+
| --- | --- |
|
|
293
|
+
| `name` | The action's name in the view. Required. |
|
|
294
|
+
| `resource` | Outside a record: the resource whose view declares it. |
|
|
295
|
+
| `label` | Default: the action's label. |
|
|
296
|
+
| `variant` | `primary`, `secondary` (default), `danger` or `ghost`. |
|
|
297
|
+
|
|
298
|
+
### ModalForm
|
|
299
|
+
|
|
300
|
+
A button that opens a form in a dialog. `create` makes a record of `resource`; `edit` changes the record around it (or `resource` with `recordKey`), sending only the changed fields with the record's ETag. The editors are the record page's, and errors from the server show on their fields. It is not shown to a user who may not create or update, and it keeps only the fields they may write.
|
|
301
|
+
|
|
302
|
+
| Prop | |
|
|
303
|
+
| --- | --- |
|
|
304
|
+
| `mode` | `create` or `edit`. Required. |
|
|
305
|
+
| `label` | The button. Required. |
|
|
306
|
+
| `fields` | The fields of the form, writable ones only. Required. |
|
|
307
|
+
| `resource` | Default: the record's resource. |
|
|
308
|
+
| `recordKey` | Edit this record. |
|
|
309
|
+
| `title` | The dialog's title; default the label. |
|
|
310
|
+
| `values` | Sent with every create, such as `{ status: 'lead' }` or a parent's key. |
|
|
311
|
+
| `variant` | As for `Action`. |
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
<ModalForm mode="create" label="Add lead" resource="companies" fields={['name', 'city', 'country_code', 'email']} values={{ status: 'lead' }} />
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Show
|
|
318
|
+
|
|
319
|
+
Its children while [`when`](layouts.md#conditions)) holds.
|
|
320
|
+
|
|
321
|
+
| Prop | |
|
|
322
|
+
| --- | --- |
|
|
323
|
+
| `when` | A condition. Required. |
|
|
324
|
+
|
|
325
|
+
```tsx
|
|
326
|
+
<Show when="orders.count = 0">
|
|
327
|
+
<Card title="No orders yet">...</Card>
|
|
328
|
+
</Show>
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Accounts
|
|
332
|
+
|
|
333
|
+
### Users
|
|
334
|
+
|
|
335
|
+
Everyone who can sign in, for admins: find them by address, tick their roles, block or unblock them, invite someone by email and add an account. It takes no props or children. The [Users page](auth.md#users-page)) is a `Page` with it alone; a page of your own can put it beside other blocks, with `roles: ['admin']`, since the server refuses everyone else.
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
<Page title="People">
|
|
339
|
+
<Users />
|
|
340
|
+
</Page>
|
|
341
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- Generated by scripts/protobase-skill.ts from website/src/content/docs/reference/bottom-bar.md: run `bun run docs:skill`, do not edit. -->
|
|
2
|
+
|
|
3
|
+
# Bottom bar
|
|
4
|
+
|
|
5
|
+
Tabs along the bottom of a phone, as on iOS, for the roles that work from one.
|
|
6
|
+
|
|
7
|
+
On phones the sidebar is a drawer behind the top bar's menu button. For people who work from a phone, such as on a warehouse floor, a bottom bar puts their few screens one tap away: up to four tabs, each an icon above its label, the current one highlighted, and "More" last, which opens the drawer with the rest. The bar keeps clear of the iPhone home indicator. From the `md` breakpoint (768px) up there is no bar; the sidebar shows instead.
|
|
8
|
+
|
|
9
|
+
Export a [`bottomBar(...)`](https://docs.protobase.net/api/schema/functions/bottombar/)) from the config module for each group of roles that gets one:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
// examples/erp/config/bottom-bar.ts, re-exported from config/index.ts
|
|
13
|
+
import { bottomBar } from '@protobase/schema'
|
|
14
|
+
|
|
15
|
+
export const warehouseBar = bottomBar({ label: 'Warehouse', roles: ['warehouse'] }, (m) => [
|
|
16
|
+
m.resource('stock_levels', { label: 'Stock' }),
|
|
17
|
+
m.resource('stock_moves', { label: 'Moves' }),
|
|
18
|
+
m.resource('orders', { label: 'Orders' }),
|
|
19
|
+
m.resource('locations', { label: 'Locations' }),
|
|
20
|
+
])
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Item | Does |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| `m.resource(name, { label, icon? })` | Opens the resource's list. Without `icon`, the resource's sidebar icon. |
|
|
26
|
+
| `m.page(name, { label, icon? })` | Opens a [composed page](layouts.md)). Without `icon`, the page's own. |
|
|
27
|
+
| `m.link(label, href, { icon? })` | Opens `href` in a new tab. Only `https://`, `http://` and `mailto:` are accepted. |
|
|
28
|
+
|
|
29
|
+
Every tab needs its `label`: tabs are narrow, so the bar does not borrow a view's or page's longer name. `icon` takes the names the [user menu](user-menu.md)) does. Items keep their order. Unlike the user menu, a bar takes nothing out of the sidebar.
|
|
30
|
+
|
|
31
|
+
## Which bar someone gets
|
|
32
|
+
|
|
33
|
+
Each bar names its roles, and a role belongs to one bar. A caller gets the bar that names their active role, through `/meta` as `bottomBar`, without the resources and pages they cannot see, except that a visitor keeps a resource whose view has a [sign-in prompt](ui-config.md#sign-in-prompts)), which tells them to sign in; a bar with none left is not sent. Someone whose active role no bar names gets no bar. The active role is the one the session acts with, which the person [switches in the profile menu](auth.md#active-role)); with an authenticator other than Better Auth's, the caller's first role.
|
|
34
|
+
|
|
35
|
+
## Checks
|
|
36
|
+
|
|
37
|
+
`createAdmin` refuses to start when a bar names a resource or page that does not exist, has no roles, no items or more than four, names a role the app does not have (the roles of [`createAuth`](auth.md)) and [`defineRoles`](access.md)); without either, any role is accepted), shares a role with another bar, or has the label of another bar. The checks are [`bottomBarErrors`](https://docs.protobase.net/api/schema/functions/bottombarerrors/)) from `@protobase/schema`, a pure function of the bars and the app's names.
|
|
38
|
+
|
|
39
|
+
`protobase dev`, `protobase build` and `protobase serve` pick the bars up from the config module. With `createAdmin` directly, pass them as `bottomBars`:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const { resources, views, bottomBars } = configExports(config)
|
|
43
|
+
const admin = createAdmin({ resources, views, bottomBars, db, authenticate })
|
|
44
|
+
```
|