@protobase/cli 0.88.0 → 0.88.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.
- package/dist/cli/package.js +1 -1
- package/package.json +8 -8
- package/skills/protobase/references/features/composed-pages.md +1 -0
- package/skills/protobase/references/features/your-own-code.md +1 -1
- package/skills/protobase/references/reference/custom-components.md +17 -0
- package/skills/protobase/references/reference/layouts.md +9 -1
- package/skills/protobase/references/reference/ui-config.md +1 -1
package/dist/cli/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.88.
|
|
3
|
+
"version": "0.88.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.88.
|
|
47
|
-
"@protobase/layout": "0.88.
|
|
48
|
-
"@protobase/query": "0.88.
|
|
49
|
-
"@protobase/schema": "0.88.
|
|
50
|
-
"@protobase/server": "0.88.
|
|
51
|
-
"@protobase/ui": "0.88.
|
|
52
|
-
"@protobase/workflows": "0.88.
|
|
46
|
+
"@protobase/config": "0.88.1",
|
|
47
|
+
"@protobase/layout": "0.88.1",
|
|
48
|
+
"@protobase/query": "0.88.1",
|
|
49
|
+
"@protobase/schema": "0.88.1",
|
|
50
|
+
"@protobase/server": "0.88.1",
|
|
51
|
+
"@protobase/ui": "0.88.1",
|
|
52
|
+
"@protobase/workflows": "0.88.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",
|
|
@@ -8,6 +8,7 @@ Pages of your own, built from blocks in a JSX layout.
|
|
|
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
10
|
- [App addresses](../reference/layouts.md#addresses): Links to lists, records, create forms and pages are typed addresses that can carry filters and prefilled values.
|
|
11
|
+
- [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.
|
|
11
12
|
- [Per-user pages](../reference/layouts.md#access): Each user gets the page without the parts, fields and actions they cannot use.
|
|
12
13
|
- [Layout blocks](../reference/blocks.md#layout): Pages, responsive grids, cards and links.
|
|
13
14
|
- [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.
|
|
@@ -6,7 +6,7 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
6
6
|
|
|
7
7
|
- [Custom components](../reference/custom-components.md#components): Your own React components used by name in layouts, reading data under the user's access.
|
|
8
8
|
- [Custom list displays](../reference/custom-components.md#list-displays): Draw a list with your own component while the list page keeps loading, filters, search and paging.
|
|
9
|
-
- [Custom record sections](../reference/custom-components.md#record-sections): Your own component on a record page, beside its sections.
|
|
9
|
+
- [Custom record sections](../reference/custom-components.md#record-sections): Your own component on a record page, beside its sections, with sections to show instead where it cannot be drawn.
|
|
10
10
|
- [Custom record cards](../reference/custom-components.md#record-cards): Draw each card with your own component, with the built-in card as the fallback.
|
|
11
11
|
- [Custom field types](../reference/plugins.md#field-types): Register how a kind of value is shown and edited, and pick it per field in a view.
|
|
12
12
|
- [Custom create pages](../reference/custom-components.md#create-pages): Replace a resource's create form with your own page, such as a booking flow.
|
|
@@ -76,6 +76,17 @@ A component that shows markdown, such as a chat message, uses `Markdown` from `@
|
|
|
76
76
|
|
|
77
77
|
`protobase build` fails when the config declares a component that `protobase.ui.tsx` does not export, naming it; while you work, `protobase dev` draws a warning in its place. A component a plugin provides is declared with the plugin's name, `component('DraftOrders', { plugin: 'sales-tools' })`, and the build does not look for it in `protobase.ui.tsx`. A component that throws while drawing shows a warning in its own place, not a blank app. The object form, `defineUi({ components: { OrdersPerDay } })`, still works, and a name given both ways must be the same component.
|
|
78
78
|
|
|
79
|
+
### Fallbacks
|
|
80
|
+
|
|
81
|
+
A client that cannot draw a component, such as a native app without React or the admin app without the plugin that provides it, draws the component's fallback in its place. Declare it with `component()`, as elements or `[]` to draw nothing:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
export const SeatChart = component('SeatChart', { fallback: <Progress label="Seats" value="seats_used" max="plan.seats" /> })
|
|
85
|
+
export const Confetti = component('Confetti', { fallback: [] })
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The admin app draws the fallback too when the component is missing or throws while drawing; `protobase dev` also shows the warning above it. Without a fallback, the warning stands in the component's place, as above. A [record section](#record-sections) takes `fallback` in `l.custom`.
|
|
89
|
+
|
|
79
90
|
### Fields and resources in props
|
|
80
91
|
|
|
81
92
|
A prop that names a field is a field reference, `fieldRef('plan.name')` from `@protobase/layout`, read from the record around the element or the resource its `resource` prop names. The component gets the plain name (`'plan.name'`), and the names are checked when the server starts. A `resource` prop names a resource the way a block's does.
|
|
@@ -140,6 +151,12 @@ export const CustomerRepairs = ({ limit }: { limit: number }) => {
|
|
|
140
151
|
|
|
141
152
|
A list that should stay live polls: `useList('repairs', { refetchInterval: 5000 })` refetches every 5 seconds. It is TanStack Query's `refetchInterval`, so it also takes `false` to stop, or a function of the query, and pauses while the tab is in the background.
|
|
142
153
|
|
|
154
|
+
`fallback` gives what shows in the section's place, its title included, where the component cannot be drawn: sections and related tables in the main column, sidebar maps in the sidebar, or `[]` for nothing. `/api/meta` sends it with what the user cannot see left out, as [fallbacks](#fallbacks) of composed pages. <gap>A sidebar section cannot fall back to sections or related tables because drawing those in the sidebar is not implemented.</gap>
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
l.custom(CustomerRepairs, { title: 'Earlier repairs', props: { limit: 5 }, fallback: [l.section('Customer', [r.customer_id])] })
|
|
158
|
+
```
|
|
159
|
+
|
|
143
160
|
## Full-area record pages
|
|
144
161
|
|
|
145
162
|
A view can make a component the whole record page with [`.record({ component })`](ui-config.md#full-area-record-pages). It gets the record from `useLayoutRecord()`, as a record section does, and fills the area beside the sidebar and under the top bar, where the page does not scroll: a list in it scrolls in a box of its own with `min-h-0 flex-1 overflow-y-auto`, and what follows the list stays at the bottom. It links to the record's standard page, which keeps the form, the related records, Edit and Delete:
|
|
@@ -45,6 +45,14 @@ Every element compiles to `{ type, props, children }`, and a custom component al
|
|
|
45
45
|
|
|
46
46
|
Children are elements and text. `null`, `undefined` and booleans render nothing and numbers become text, as in React, so `{isBeta && <Card />}` and `.map()` over a constant list work. Fragments are flattened. An element may be a prop value too: `actions={<Action name="cancel" />}` or a list of them.
|
|
47
47
|
|
|
48
|
+
A custom component declared with a [fallback](custom-components.md#fallbacks) carries it on each of its elements as `fallback`, elements and text like children, or `[]` to draw nothing:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{ "type": "SeatChart", "props": {}, "children": [], "custom": true, "fallback": [{ "type": "Progress", "props": { "label": "Seats", "value": "seats_used", "max": "plan.seats" }, "children": [] }] }
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
A client that cannot draw the component, such as one without React, draws the fallback instead, and the checks read it like the rest of the tree.
|
|
55
|
+
|
|
48
56
|
## What a layout may hold
|
|
49
57
|
|
|
50
58
|
A prop is a string, a finite number, a boolean, `null`, or an array or plain object of those (elements included). It is JSON in the end, so the rules are checked twice:
|
|
@@ -133,4 +141,4 @@ Every block reads the regular API with the user's token, so the access rules app
|
|
|
133
141
|
- `ModalForm` needs create or update permission and keeps only the fields they may write;
|
|
134
142
|
- an `Action` missing from their view of the resource is left out, and so is a `Show` that names something they cannot see.
|
|
135
143
|
|
|
136
|
-
Custom components are kept: they get only their props, and fetch through the same API.
|
|
144
|
+
Custom components are kept: they get only their props, and fetch through the same API. A custom component's fallback loses what the user cannot use like the rest of the tree, and a fallback left with nothing is sent as `[]`, so a client still draws nothing in the component's place.
|
|
@@ -659,7 +659,7 @@ export const repairsView = filtered
|
|
|
659
659
|
| `l.tab(title, items)` | A tab holding main-column items; a view's tabs show as one strip on the read view and the form. See [Tabs](#tabs). |
|
|
660
660
|
| `l.sidebar(fields, { when? })` | A summary card beside it, read-only, each value on one line, cut off with an ellipsis when it does not fit and shown whole on hover. The record's created and updated times show in a Details card below it, but for those the summary lists. `when` also takes a [condition](#form-and-read-view). |
|
|
661
661
|
| `l.related(title, { ... })` | A table or cards of the records of another resource that point at this one, in the main column. See [Related records](#related-records). |
|
|
662
|
-
| `l.custom(Component, { title?, props?, sidebar?, when? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. |
|
|
662
|
+
| `l.custom(Component, { title?, props?, sidebar?, when?, fallback? })` | A [custom component](custom-components.md#record-sections) where it is listed: in the main column under `title`, or with `sidebar: true` as a sidebar card. `fallback` shows in its place where it cannot be drawn. |
|
|
663
663
|
| `l.map(title, { latitude, longitude, zoom?, sidebar?, when? })` | A map with a pin at the record's position, in the main column or with `sidebar: true` as a sidebar card. See [Maps](#maps). |
|
|
664
664
|
| `l.chart(title, { resource, field, at, series, range?, help?, when? })` | Line graphs of numbers of the records that point at this one, such as a machine's samples, over the last hour, day or week. See [Charts of related records](#charts-of-related-records). |
|
|
665
665
|
| `l.gallery(title, { image?, photos?, when? })` | The record's photos as tiles, opening a lightbox. See [Galleries](#galleries). |
|