@protobase/cli 0.23.14 → 0.24.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/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.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": {
|
|
@@ -35,11 +35,11 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@hono/node-server": "^2.1.3",
|
|
37
37
|
"@hono/vite-dev-server": "^0.26.1",
|
|
38
|
-
"@protobase/layout": "0.
|
|
39
|
-
"@protobase/query": "0.
|
|
40
|
-
"@protobase/schema": "0.
|
|
41
|
-
"@protobase/server": "0.
|
|
42
|
-
"@protobase/ui": "0.
|
|
38
|
+
"@protobase/layout": "0.24.1",
|
|
39
|
+
"@protobase/query": "0.24.1",
|
|
40
|
+
"@protobase/schema": "0.24.1",
|
|
41
|
+
"@protobase/server": "0.24.1",
|
|
42
|
+
"@protobase/ui": "0.24.1",
|
|
43
43
|
"@react-email/render": "^2.1.0",
|
|
44
44
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
45
45
|
"@tailwindcss/vite": "^4.3.3",
|
|
@@ -195,10 +195,46 @@ export const invoiceItemsView = view<typeof invoiceItems>('invoice_items')
|
|
|
195
195
|
|
|
196
196
|
The list of a resource ordered as one, such as the products, has a **Reorder** button beside its other buttons; a related section of records ordered within the page's record, such as the invoice's items, has one at the end of its title's line. **Reorder** shows every record in its order in the list's table, without the filters, search, chart and display switch, with a drag handle in each row where its checkbox was, and the page scrolls them; **Done** goes back. A row moves by dragging its handle, by a long press and drag on a touch screen, or from the keyboard: Space on a handle picks the row up, the up and down arrow keys move it, Space or Enter drops it and Escape puts it back, and a screen reader is told each step. The rest of the row still opens its record.
|
|
197
197
|
|
|
198
|
-
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes)) sends only the stretch of records whose place changed, with the ETags they were listed with, and numbers them on from the record before them; it reaches further only where a gap or a tie left by an earlier write needs it, so a list of thousands saves a short move as a few records. Drops made while one saves are saved after it. A refusal, such as a record someone else changed since, puts the rows back as the server has them, with the reason. Every list of the resource reloads afterwards.
|
|
198
|
+
Each drop shows at once and is saved straight away: one [batch `reorder`](api.md#batch-writes)) sends only the stretch of records whose place changed, with the ETags they were listed with, and numbers them on from the record before them; it reaches further only where a gap or a tie left by an earlier write needs it, so a list of thousands saves a short move as a few records. Drops made while one saves are saved after it. A saved drop says so in a toast with **Undo**, which puts back the positions it changed; see [Dragging in the list](#dragging-in-the-list). A refusal, such as a record someone else changed since, puts the rows back as the server has them, with the reason. Every list of the resource reloads afterwards.
|
|
199
199
|
|
|
200
200
|
A user who may not update the resource or write the field gets no **Reorder**, and `/api/meta` leaves out `position` for one who cannot read its field or its `within`. A related section offers it only when it lists all of the parent's records: its `field` is the `within` relation, without a `filter` or `through`. The list page does not offer it for a resource ordered within a parent, since its list mixes the parents. The field must be `.sortable()` and `within` a `.filterable()` relation, checked when the config loads, and [`protobase doctor`](cli.md#doctor)) checks that an index serves each read in the field's order, such as `(invoice_id, position)`. Records created later are not numbered for you: give them a position, or the next drop numbers them, after the others when the field is empty.
|
|
201
201
|
|
|
202
|
+
### Dragging in the list
|
|
203
|
+
|
|
204
|
+
Nothing in a list moves by dragging unless its `.list(...)` says so with `drag`, each part on its own:
|
|
205
|
+
|
|
206
|
+
| `drag` | What it lets a user drag |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| `rank: true` | The records of a resource with a [`.position(...)`](#reordering-by-hand) and no `within`, at any time: the table's rows by their handles while the list shows every record in the position's order, ascending, without a filter or search, instead of after **Reorder**; and a [board's](#boards) cards to their place in a column. |
|
|
209
|
+
| `board: true` | A board's card to another column, which saves the record with that column's value. |
|
|
210
|
+
| `rule: 'name'` | Where the table's rows may land when re-ranked, by **Reorder** or `rank`: the drop rule of that name in the UI config's `dropRules`. See [Drop rules](#drop-rules). |
|
|
211
|
+
|
|
212
|
+
```ts
|
|
213
|
+
.list((r, d) => ({ columns: [r.title, r.status], sort: [[r.rank, 'asc']], displays: [d.board({ by: r.status })], drag: { rank: true, board: true } }))
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
A board may let cards move between columns without re-ranking (`board` alone), or be re-ranked within its columns without moving cards between them (`rank` alone). A list sorted another way, filtered or searched shows its own table, and **Reorder** stays for it. A named list has its own `drag`. Either part needs the right to update the field it writes, as **Reorder** does: a user without it drags nothing.
|
|
217
|
+
|
|
218
|
+
On a touch screen a card or a row's handle lifts only after a short hold, a quarter of a second, so a swipe across the board scrolls it instead of moving a card; a mouse or trackpad drags it straight away. Every saved drag says so in a toast with **Undo**, which puts back what it changed, the column and every position it renumbered, with the ETags the save gave the records, so a record changed again since is refused rather than overwritten. Only the latest drag can be undone: a new one replaces the toast.
|
|
219
|
+
|
|
220
|
+
#### Drop rules
|
|
221
|
+
|
|
222
|
+
Some orders must hold, such as a task never ranked above one it waits for. A drop rule, a function in `protobase.ui.tsx` under `dropRules`, gets the dropped record, the records in the order the drop would leave them and the record's place among them, 0 the first, as the API gives them, every field the user may read; it returns why the record may not be there, or nothing when it may:
|
|
223
|
+
|
|
224
|
+
```tsx
|
|
225
|
+
export default defineUi({
|
|
226
|
+
dropRules: {
|
|
227
|
+
afterWhatItWaitsFor: ({ record, order, index }) => {
|
|
228
|
+
const waited = order.find((task) => task.id === record.waits_for_id)
|
|
229
|
+
if (!waited || order.indexOf(waited) < index) return undefined
|
|
230
|
+
return `${record.title} waits for ${waited.title}.`
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
The list names it with `drag: { rank: true, rule: 'afterWhatItWaitsFor' }`. A drop the rule refuses lands in the first place below that it allows, and a warning says where with the rule's reason; with no such place the row stays where it was, with the same warning. The rule only guides the drag: the server's access rules and `validate` still decide what is saved. A list naming a rule the UI config does not register says so in place of its rows.
|
|
237
|
+
|
|
202
238
|
## A filter the list opens with
|
|
203
239
|
|
|
204
240
|
```ts
|
|
@@ -291,6 +327,8 @@ export const repairsView = daily
|
|
|
291
327
|
d.calendar({ start: r.booked_on, title: r.number }),
|
|
292
328
|
],
|
|
293
329
|
default: 'board',
|
|
330
|
+
// A repair moves to another column of the board by dragging it
|
|
331
|
+
drag: { board: true },
|
|
294
332
|
}))
|
|
295
333
|
.layout((r) => [
|
|
296
334
|
l.section('The bike', [r.customer_id, r.bike, r.problem]),
|
|
@@ -304,7 +342,7 @@ export const repairsView = daily
|
|
|
304
342
|
| --- | --- |
|
|
305
343
|
| `d.cards({ image?, title?, subtitle?, amount?, badge?, meta?, footer?, flags?, dots? }, { name?, label?, icon?, card?, photos?, favorite? })` | A card per record, opening it: `image`, a [file field](files.md)), as a picture across the card's top (a raster image; anything else leaves the frame empty), then `title` (default: the view's `.title`) over `subtitle`, `badge` drawn as a badge with its value labels, `amount` the first of its fields with a value in bold (its suffix, such as ` /month`, not), such as a purchase price or else a rent, and a few small `meta` fields such as dates, each only when it has a value, after its field's `.icon` and as a badge when its field's format is `badge`. `footer` is a line at the card's bottom of its fields with a value, joined by bullets, such as a place and an agent. `flags` are boolean fields shown as small badges of their labels when true, such as a garden or parking. `dots` are [related columns](#related-records-in-a-list) of the list, each a line of its dots at the card's bottom. A relation shows the name of the record it points at. With `card`, a component declared with `component('RepairCard')` draws each card's content from the row of those fields instead (see [Record cards](custom-components.md#record-cards))). With `photos`, the picture steps through more photos, by swipe or arrows (see [Card photos](#card-photos)). With `favorite`, a heart in the card's top right corner saves the record (see [Favorites](#favorites)). Named `cards` unless `name` says otherwise. |
|
|
306
344
|
| `d.map({ latitude, longitude, approximate?, exact?, radius?, area? }, { name?, label?, icon?, cards?, defaultRadius? })` | The matching records in the map's view, with how many there are below it; it asks again as it pans and zooms, through the list API's [`:map`](api.md#maps)). From far out it shows a count for each part of the map, which zooms in when chosen; close in, or with few records in view, the records themselves. Nearby records share a marker with their count; choosing one shows the record's card at the map's bottom, with arrows through the marker's records, and choosing the map elsewhere or closing the card clears it. The card is the one of the cards display `cards` names, else the list's first cards display, else the record's title. A record at an approximate position has a hollow marker and the area around it; see [Approximate positions](#approximate-positions). Named `map` unless `name` says otherwise. See [Maps](#maps). |
|
|
307
|
-
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them.
|
|
345
|
+
| `d.board({ by, title?, subtitle?, badge?, meta? }, { name?, label?, icon? })` | A column per value of the enum field `by`, each with how many records have it, and a card per record that opens it: `title` (default: the view's `.title`) over `subtitle`, with `badge` and a few small `meta` fields, as the built-in card of `d.cards` draws them. With the list's `drag: { board: true }`, dragging a card to another column, or moving it with the keyboard, saves the record with that column's value; with `drag: { rank: true }`, cards are reordered within a column when the resource has a `.position()`. Named `board` unless `name` says otherwise. See [Boards](#boards). |
|
|
308
346
|
| `d.calendar({ start, end?, title? }, { name?, label?, icon? })` | The records on the days from their date or timestamp field `start` to `end`, or on their start day alone, in a month grid or a week grid, each event a link to its record showing `title` (default: the view's `.title`). Dragging an event to another day, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `calendar` unless `name` says otherwise. See [Calendars](#calendars). |
|
|
309
347
|
| `d.timeline({ start, end?, group?, title? }, { name?, label?, icon? })` | A Gantt-style timeline: each record a row with a bar from its date or timestamp field `start` to `end`, or on its start day alone, over a week, a month or a quarter, in lanes by the values of `group`. Each bar is a link to its record showing `title` (default: the view's `.title`). Dragging a bar along its row, or moving it with the keyboard, saves the record with `start` and `end` moved by the same days. Named `timeline` unless `name` says otherwise. See [Timelines](#timelines). |
|
|
310
348
|
| `d.custom(Component, { name, label, fields, props?, icon? })` | The rows drawn by a [custom component](custom-components.md#list-displays)). `fields` are the fields it shows, loaded with the names of the records relations point at; `props` are plain data, with `r.field` where it takes a field. |
|
|
@@ -321,14 +359,15 @@ Display names are checked when the config loads: unique, not `table`, and `defau
|
|
|
321
359
|
|
|
322
360
|
Each column reads its own records through the list API, with the list's filter, search and order and its value added, such as `(search("brompton")) AND status = "ready"`, page by page with **Show more** at its bottom. A filter on `by` itself leaves the other columns empty. The sort menu orders the cards in every column, unless the resource has a position. In an embedded list each column shows its first records, up to the list's limit, and **View all** opens the whole board.
|
|
323
361
|
|
|
324
|
-
|
|
362
|
+
With the list's `drag: { board: true }` (see [Dragging in the list](#dragging-in-the-list)), a card moves to another column by dragging it, by a long press and drag on a touch screen, or from the keyboard: Space on a card picks it up, the left and right arrow keys move it between columns, Space or Enter drops it and Escape puts it back; a screen reader is told each step. A move is one update of the record, `by` set to the column's value with the ETag the card was listed with, the same request a named [`a.update`](layouts.md#named-actions)) sends. So the resource's [access rules](access.md)) and `validate` decide: the card shows in its new column at once, a refused move puts it back with the server's reason, such as `validate`'s message, and a record changed by someone else since it was listed is refused too, as a stale ETag is. Every list of the resource reloads afterwards. A user who may not update the resource, or the `by` field, or a record its [row filters](access.md#restricted-model-and-row-filters)) keep them from updating, can open its card but not move it.
|
|
325
363
|
|
|
326
364
|
A resource with a [`.position(...)`](data-config.md#resource)) and no `within` has its board's columns in that order instead of the list's, so the board has no sort menu:
|
|
327
365
|
|
|
328
366
|
```ts title="docs-examples/reference/ranked-board.ts"
|
|
329
367
|
import { f, resource, view } from '@protobase/schema'
|
|
330
368
|
|
|
331
|
-
// A team's tasks on a board in the order of their rank, each
|
|
369
|
+
// A team's tasks on a board in the order of their rank, each card dragged to its place in a column or to another
|
|
370
|
+
// column, and the table in the same order, its rows dragged too.
|
|
332
371
|
|
|
333
372
|
export const tasks = resource('tasks')
|
|
334
373
|
.table('tasks')
|
|
@@ -343,10 +382,16 @@ export const tasks = resource('tasks')
|
|
|
343
382
|
|
|
344
383
|
export const tasksView = view<typeof tasks>('tasks')
|
|
345
384
|
.title((r) => r.title)
|
|
346
|
-
.list((r, d) => ({
|
|
385
|
+
.list((r, d) => ({
|
|
386
|
+
columns: [r.title, r.status],
|
|
387
|
+
sort: [[r.rank, 'asc']],
|
|
388
|
+
displays: [d.board({ by: r.status })],
|
|
389
|
+
default: 'board',
|
|
390
|
+
drag: { rank: true, board: true },
|
|
391
|
+
}))
|
|
347
392
|
```
|
|
348
393
|
|
|
349
|
-
|
|
394
|
+
With the list's `drag: { rank: true }`, a card then moves within its column by dragging it, or from the keyboard: Space, the up and down arrow keys, and Space again. In another column it lands where it is dropped, before the card under it or after the last one; the left and right arrow keys put it at the top. A screen reader is told the column and the place. A drop is one [batch write](api.md#batch-writes)): in another column first the update of `by` with the card's ETag, then a `reorder` numbering the column's cards 1, 2, 3, ... down to the last one that moved, each with its ETag. So access, `validate` and a stale ETag refuse it as they do a column move, and a refusal puts the cards back with the reason. The numbers are per column after a drop, so a unique index on the position alone would clash, while one that includes `by` is fine. Changing the order takes the right to update the position field, as **Reorder** does; a user without it, or a board without `rank`, moves cards between columns only, as on a board without a position, and one without `board` keeps each card in its column. A resource without a position, or with `within`, keeps the list's order.
|
|
350
395
|
|
|
351
396
|
`by` must be a filterable enum field, checked when the config loads and when the server starts, since each column filters by it. [`protobase doctor`](cli.md#doctor)) checks that an index serves each column's filter in the list's order, or the position's, as it does the list's. In `/api/meta`, a user who cannot read `by` gets the list without the board, opening in the table when it was the default, and a card loses the fields they cannot read.
|
|
352
397
|
|