@protobase/cli 0.77.1 → 0.78.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/record-pages.md +2 -0
- package/skills/protobase/references/features/your-own-code.md +3 -0
- package/skills/protobase/references/reference/custom-components.md +45 -0
- package/skills/protobase/references/reference/layouts.md +1 -1
- package/skills/protobase/references/reference/plugins.md +3 -0
- package/skills/protobase/references/reference/ui-config.md +20 -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.78.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.78.0",
|
|
47
|
+
"@protobase/layout": "0.78.0",
|
|
48
|
+
"@protobase/query": "0.78.0",
|
|
49
|
+
"@protobase/schema": "0.78.0",
|
|
50
|
+
"@protobase/server": "0.78.0",
|
|
51
|
+
"@protobase/ui": "0.78.0",
|
|
52
|
+
"@protobase/workflows": "0.78.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,8 @@ The page of one record, with its sections, related records, galleries, charts an
|
|
|
6
6
|
|
|
7
7
|
- [Record page layout](../reference/ui-config.md#the-record-page): Sections, a summary sidebar, related tables, maps, charts, galleries, history, comments and your own components.
|
|
8
8
|
- [Full-width record pages](../reference/ui-config.md#page-width): A view's record pages and create form fill the whole area beside the sidebar instead of a centred column, with the sidebar cards still beside the sections.
|
|
9
|
+
- [Focus pages](../reference/ui-config.md#focus-pages) (beta): A record whose page is one big surface, such as a graph or a board, fills the page under a thin bar with its Save, actions and panels, its form a link away.
|
|
10
|
+
- [A create address that opens a page](../reference/ui-config.md#focus-pages) (beta): `.createOpens(to)` sends a resource's create address to a page in place of its form, such as a record's focus page with a panel open, filled from the address's values.
|
|
9
11
|
- [Page-wide sections](../reference/ui-config.md#page-wide-sections): A section spans the page above the main column and the sidebar cards, such as a workflow's graph, with Save in a bar at the foot of the window.
|
|
10
12
|
- [Record pages that open another](../reference/ui-config.md#a-record-page-that-opens-another): A record's page opens another address built from its fields in its place, such as a workflow run opening its workflow's page with the run shown.
|
|
11
13
|
- [Full-area record pages](../reference/ui-config.md#full-area-record-pages) (beta): A view draws its record pages with a component of its own that fills the area beside the sidebar and under the top bar, such as a chat channel, and links to the standard page.
|
|
@@ -25,3 +25,6 @@ React components, field types, pages and handlers of your own, loaded as plugins
|
|
|
25
25
|
- [Plugin fallbacks](../reference/plugins.md#when-a-plugin-is-off): A plugin that fails or does not fit the version is turned off alone, and admins see why.
|
|
26
26
|
- [Before sign-in](../reference/plugins.md#before-sign-in): A plugin can run around the sign-in page, for example to sign someone in from a link.
|
|
27
27
|
- [Unstable modules](../reference/plugins.md#the-unstable-entry): UI with its own build imports any module of the app's UI, without a promise that it stays the same, instead of copying it.
|
|
28
|
+
- [Focus page parts](../reference/custom-components.md#focus-pages) (beta): Fill a focus page's bar, notice and side panels from your own surface or component, with the record's draft and Save from the framework.
|
|
29
|
+
- [Search picker](../reference/custom-components.md#focus-pages) (beta): A searchable list with icons, descriptions and keywords, to pick one thing in a panel or a dialog.
|
|
30
|
+
- [Forms in place](../reference/custom-components.md#focus-pages) (beta): Create a record from a form in a panel or a dialog, with the view's fields, its failure and one create at a time.
|
|
@@ -163,6 +163,51 @@ export const ChannelChat = () => {
|
|
|
163
163
|
}
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
+
## Focus pages
|
|
167
|
+
|
|
168
|
+
:::caution[Beta]
|
|
169
|
+
These parts serve a record's focus page, or a page of your own that draws `FocusPage`; the page never scrolls, each side holds one panel at a time, and the bar's widths for moving actions into "..." are estimates.
|
|
170
|
+
:::
|
|
171
|
+
|
|
172
|
+
A [focus page](ui-config.md#focus-pages) knows nothing of what it shows: whatever draws the surface fills the page's parts from anywhere inside it, and the framework adds the record's Save and actions. All of it comes from `@protobase/ui`, for a field type's `editor`, a `.record({ component, focus: true })` component, or a page of your own that draws `FocusPage` itself:
|
|
173
|
+
|
|
174
|
+
| Part | |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| `<FocusPage label>` | The page: bar, notice, surface and panels. It takes the content area and stops the page scrolling. `.record(...)` draws it for you. |
|
|
177
|
+
| `<FocusSlot zone>` | Draws its children in the bar: `mode` says what shows and picks it, `controls` holds tools for the surface, `state` says how the work stands, `secondary` and `primary` hold the page's own buttons. A `primary` of yours moves Save to `secondary`; a `state` of yours replaces the framework's. `fallback` shows it only while nothing else fills the zone. |
|
|
178
|
+
| `<FocusActions actions>` | Adds actions, an action rail's `{ name, icon, onRun, blocked, tone, render }`: `inBar` shows at most two by name while there is room, and the rest go behind "...". |
|
|
179
|
+
| `<FocusNotice level actions>` | One strip under the bar, which pushes the surface down. One shows at a time, in the order `refused`, `conflict`, `draft`, `info`, and the next returns as one clears. |
|
|
180
|
+
| `<FocusPanel side title onClose footer takesFocus>` | A panel beside the surface, `end` by default, which the surface makes room for; with too little room it lies over the surface's edge, and below `md` it covers the screen. Its content scrolls on its own. `takesFocus` is for a panel a button opens: it takes the keyboard and hands it back. |
|
|
181
|
+
| `useFocusPage()` | `{ size }`, how much room the bar has, by its own width: `wide`, `medium`, `narrow` or `compact`. |
|
|
182
|
+
| `useFocusZoneFilled(zone)` | Whether something fills a zone. |
|
|
183
|
+
| `useFocusRecord()` | On a record's focus page: the record, its draft (`value`, `change`, `dirty`, `saving`, `refused`), `save()`, which resolves to whether it saved, `discard()`, `readOnly` and `mayUpdate`. |
|
|
184
|
+
| `<SearchPicker groups onPick>` | A searchable list to pick from, for a panel or a dialog: `{ title, items }` groups of `{ id, title, description, keywords, icon }`, with the arrow keys and Enter. |
|
|
185
|
+
| `useCreateForm({ resource, onCreated })`, `<InPlaceForm form fields submit>` | A create form that stays where it is, so an action is done beside what it acts on: the view's fields you name, its failure and its submit button. `onCreated` says what comes next. |
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
// A field type's editor that fills the surface: it owns its state, and hands the framework the parts
|
|
189
|
+
import { Button, FocusActions, FocusPanel, FocusSlot, SearchPicker, type FieldWidgetEditorProps } from '@protobase/ui'
|
|
190
|
+
import { Eraser } from 'lucide-react'
|
|
191
|
+
import { useState } from 'react'
|
|
192
|
+
|
|
193
|
+
export const PinBoard = ({ value, onChange }: FieldWidgetEditorProps<string[]>) => {
|
|
194
|
+
const pins = value ?? []
|
|
195
|
+
const [adding, setAdding] = useState(false)
|
|
196
|
+
return (
|
|
197
|
+
<div className="h-full p-6">
|
|
198
|
+
<FocusSlot zone="controls"><Button onClick={() => setAdding(true)}>Add pin</Button></FocusSlot>
|
|
199
|
+
<FocusActions actions={[{ name: 'Clear the board', icon: Eraser, onRun: () => onChange([]) }]} />
|
|
200
|
+
{pins.map((pin) => <p key={pin}>{pin}</p>)}
|
|
201
|
+
{adding && (
|
|
202
|
+
<FocusPanel title="Add a pin" onClose={() => setAdding(false)} takesFocus>
|
|
203
|
+
<SearchPicker autoFocus groups={[{ title: 'Places', items: [{ id: 'lisbon', title: 'Lisbon' }] }]} onPick={(item) => onChange([...pins, item.id])} />
|
|
204
|
+
</FocusPanel>
|
|
205
|
+
)}
|
|
206
|
+
</div>
|
|
207
|
+
)
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
166
211
|
## Record cards
|
|
167
212
|
|
|
168
213
|
A cards display can draw each card's content with a component, declared in the view with `d.cards(fields, { card })`. The card stays a link to the record, with the display's frame; the component draws what is inside it from `row`, the record with the fields the display names, so name every field the card shows:
|
|
@@ -115,7 +115,7 @@ Every place in the app has an address, and the app writes and reads them in one
|
|
|
115
115
|
| Address | Is |
|
|
116
116
|
| --- | --- |
|
|
117
117
|
| `{ kind: 'list', resource, filter?, orderBy?, display? }` | A resource's list, with the filter, order and [display](ui-config.md#list-displays) the list page would show. |
|
|
118
|
-
| `{ kind: 'record', resource, key, edit?, open?, tab?, standard?, version?, run? }` | One record; `key` is its value, or its parts for a composite key. `edit: true` is its form (`?edit=true`), on a view whose record page opens as a [read view or locked](ui-config.md#read-view-and-edit). `open` lists the titles of the record page's collapsed [groups](ui-config.md#groups) that are open (`?open=<title>`, once per group), and `tab` the title of the [tab](ui-config.md#tabs) it shows (`?tab=<title>`). `standard: true` is its standard page (`?standard=true`), on a view whose record page is a [component of the app's own](ui-config.md#full-area-record-pages) or [opens another](ui-config.md#a-record-page-that-opens-another). On a workflow, `version` is the saved version its graph shows, read-only (`?version=<number>`), and `run` the run shown on it (`?run=<id>`); see [The workflow's page](workflows.md#the-workflows-page). |
|
|
118
|
+
| `{ kind: 'record', resource, key, edit?, open?, tab?, standard?, version?, run?, panel? }` | One record; `key` is its value, or its parts for a composite key. `edit: true` is its form (`?edit=true`), on a view whose record page opens as a [read view or locked](ui-config.md#read-view-and-edit). `open` lists the titles of the record page's collapsed [groups](ui-config.md#groups) that are open (`?open=<title>`, once per group), and `tab` the title of the [tab](ui-config.md#tabs) it shows (`?tab=<title>`). `standard: true` is its standard page (`?standard=true`), on a view whose record page is a [component of the app's own](ui-config.md#full-area-record-pages) or [opens another](ui-config.md#a-record-page-that-opens-another). On a workflow, `version` is the saved version its graph shows, read-only (`?version=<number>`), and `run` the run shown on it (`?run=<id>`); see [The workflow's page](workflows.md#the-workflows-page). `panel` is the panel a [focus page](ui-config.md#focus-pages) opens with, by a name its surface knows (`?panel=<name>`). |
|
|
119
119
|
| `{ kind: 'create', resource, values? }` | The form for a new record, with `values` filled in by field name, as text: `{ kind: 'create', resource: 'notes', values: { listing_id: '{id}' } }` on a listing's page starts a note about that listing. A relation shows the name of the record it points at. The values are a start the person can change, not a rule: what they may write is still up to the access rules. A view with a [create page](ui-config.md#create-pages) shows that page here instead, with the values in the address. |
|
|
120
120
|
| `{ kind: 'page', page, tab? }` | A composed page; `tab` the name of one of its [tabs](blocks.md#tabs-and-tab) (`/<page>/<tab>`), the first when omitted. |
|
|
121
121
|
|
|
@@ -343,6 +343,9 @@ From `@protobase/ui`:
|
|
|
343
343
|
| `usePlugin()` | The plugin the calling component belongs to (see [above](#writing-a-plugin)). |
|
|
344
344
|
| `useResourceClient(resource)` | The client of the API that serves a resource: the app's own, or a source's for a [remote resource](remote-resources.md). |
|
|
345
345
|
| `FieldWidget`, `FieldWidgetProps`, `FieldWidgetEditorProps` | The types of a [field type](#field-types) and of its parts' props. |
|
|
346
|
+
| `FocusPage`, `FocusSlot`, `FocusActions`, `FocusNotice`, `FocusPanel`, `useFocusPage`, `useFocusZoneFilled`, `useFocusRecord` | The parts of a [focus page](custom-components.md#focus-pages). |
|
|
347
|
+
| `SearchPicker` | A searchable list to pick from, for a panel or a dialog (see [focus pages](custom-components.md#focus-pages)). |
|
|
348
|
+
| `useCreateForm`, `InPlaceForm` | A create form that stays where it is (see [focus pages](custom-components.md#focus-pages)). |
|
|
346
349
|
| `RecordCardProps` | The props of a [record card](custom-components.md#record-cards), `{ row }`. |
|
|
347
350
|
| `AuthLayout`, `CodeForm`, `ResendCodeButton`, `Button`, `buttonClass`, `Input`, `Spinner`, `LogoMark` | The pieces of the app's sign-in pages, for a page of a plugin or a host's own that looks like them. Outside the app, `@protobase/ui/styles.css` is the stylesheet that draws them, for a Vite build with Tailwind. |
|
|
348
351
|
| `isFramed`, `useArmedAfterFocus`, `useGuardedPress`, `allowDelayMs` | The connect page's guard against clickjacking and click-through, for a host's own consent screen: it refuses to render when `isFramed()`, and its Allow button spreads `useGuardedPress(armed, onAllow)`, so a press counts only once the page has been in front for `allowDelayMs`, and a press anywhere on the page before then starts that wait again. |
|
|
@@ -712,6 +712,26 @@ view<typeof channels>('channels').record({ component: ChannelChat })
|
|
|
712
712
|
|
|
713
713
|
The standard record page, with the layout's sections, the related records, Edit and Delete, stays at the record's address with `?standard=true` (`{ kind: 'record', resource, key, standard: true }`), which the component links to. Links to the record, from relations, search and notifications, open the component's page. Without the component, from a plugin that is off for instance, and when it throws, the standard page shows instead. <gap>A full-area record component cannot take props from the view because props for `.record` are not implemented.</gap>
|
|
714
714
|
|
|
715
|
+
### Focus pages
|
|
716
|
+
|
|
717
|
+
:::caution[Beta]
|
|
718
|
+
A focus page is for a record's page only, not a list or a page of the app's own; its page never scrolls, so a surface that needs to, such as a long document, does not fit it yet; it has one panel on each side at a time; and its bar moves actions into "..." at widths set by estimate.
|
|
719
|
+
:::
|
|
720
|
+
|
|
721
|
+
A focus page is for work on one big thing, such as a graph, a map or a canvas: a thin bar under the top bar, one notice at a time, a surface that takes the rest, and at most a panel on each side. The page does not scroll, so the surface is the window, and it is a sibling of the form rather than a change to it. Any record can have one:
|
|
722
|
+
|
|
723
|
+
```ts
|
|
724
|
+
// One field fills the page, drawn by its field type, and the framework saves it
|
|
725
|
+
view<typeof boards>('boards').record((r) => ({ surface: r.pins }))
|
|
726
|
+
|
|
727
|
+
// A component of the app's own, in the same frame
|
|
728
|
+
view<typeof reports>('reports').record({ component: component('ReportStudio'), focus: true })
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
The bar gets the record's state, Save, its [actions](#actions-and-views-per-role) behind "...", *Discard changes* while there are any, and a link to the form at `?standard=true`, named after the record, such as *Workflow details*, where the layout's sections and related records stay. A refused save, a conflict and a restored draft show in the notice, a reader who may not change the record gets no Save, and the form shows instead when the surface throws. A caller who may not read the surface's field gets the form. The record's name is in the breadcrumb, with a hidden heading for screen readers. What fills the bar and panels, and how a surface reaches them, is under [Focus pages](custom-components.md#focus-pages). `.record(...)` with `surface` needs a [field type](plugins.md#field-types) that draws the whole area; the built-in `workflow` field is one.
|
|
732
|
+
|
|
733
|
+
A create address can open a page in place of the form too, for a record made where it is used, as a workflow's test run is made in the workflow's page. `.createOpens(to)` replaces the address, its `{field}`s filled from the address's `values`; an address without them shows the form. A record address's `panel` (`?panel=<name>`) names a panel its surface opens with.
|
|
734
|
+
|
|
715
735
|
### Read view and edit
|
|
716
736
|
|
|
717
737
|
`.recordMode(mode)` says how the record page opens to a user who may change the record:
|