@tristan2828/ui-foundation 4.126.0 → 4.128.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.
Files changed (74) hide show
  1. package/conventions/docs/add-an-entity.md +154 -34
  2. package/conventions/docs/cell-patterns.md +88 -41
  3. package/conventions/docs/design-language.md +62 -13
  4. package/dist/api/contracts.d.ts +8 -1
  5. package/dist/api/gateway/errors.js +4 -0
  6. package/dist/api/schema.d.ts +9 -0
  7. package/dist/components/app/data-table-tools.d.ts +12 -0
  8. package/dist/components/app/data-table-tools.js +2 -2
  9. package/dist/components/app/data-table.d.ts +2 -1
  10. package/dist/components/app/data-table.js +1 -1
  11. package/dist/components/app/edit-in-place-presets.d.ts +51 -1
  12. package/dist/components/app/edit-in-place-presets.js +30 -0
  13. package/dist/components/app/edit-in-place-store.d.ts +33 -7
  14. package/dist/components/app/edit-in-place-store.js +112 -20
  15. package/dist/components/app/edit-in-place.d.ts +11 -0
  16. package/dist/components/app/editable-value.js +43 -8
  17. package/dist/components/app/entity-form.d.ts +9 -1
  18. package/dist/components/app/entity-form.js +9 -2
  19. package/dist/components/app/entity-view.js +5 -1
  20. package/dist/components/app/equal-items.d.ts +33 -6
  21. package/dist/components/app/equal-items.js +42 -7
  22. package/dist/components/app/error-state.js +1 -0
  23. package/dist/components/app/form-conflict-notice.d.ts +8 -0
  24. package/dist/components/app/form-conflict-notice.js +15 -0
  25. package/dist/components/app/form-dialog.d.ts +8 -1
  26. package/dist/components/app/form-dialog.js +9 -2
  27. package/dist/components/app/milkdown-editor.js +24 -331
  28. package/dist/components/app/notify.d.ts +18 -1
  29. package/dist/components/app/notify.js +26 -3
  30. package/dist/components/app/page-restore.js +1 -1
  31. package/dist/components/app/pill-filter.d.ts +16 -0
  32. package/dist/components/app/pill-filter.js +22 -1
  33. package/dist/components/app/rating-input.d.ts +22 -0
  34. package/dist/components/app/rating-input.js +65 -0
  35. package/dist/components/app/rating-score.d.ts +2 -1
  36. package/dist/components/app/rating-score.js +2 -6
  37. package/dist/components/app/rich-text-box-anchor.d.ts +6 -0
  38. package/dist/components/app/rich-text-box-anchor.js +8 -0
  39. package/dist/components/app/rich-text-editor.d.ts +4 -2
  40. package/dist/components/app/rich-text-editor.js +3 -2
  41. package/dist/components/app/rich-text-heading-view.d.ts +4 -0
  42. package/dist/components/app/rich-text-heading-view.js +91 -0
  43. package/dist/components/app/rich-text-keyboard-bar.js +3 -2
  44. package/dist/components/app/rich-text-link-box.d.ts +9 -0
  45. package/dist/components/app/rich-text-link-box.js +40 -0
  46. package/dist/components/app/rich-text-links.d.ts +14 -0
  47. package/dist/components/app/rich-text-links.js +92 -0
  48. package/dist/components/app/rich-text-page-box.d.ts +10 -0
  49. package/dist/components/app/rich-text-page-box.js +45 -0
  50. package/dist/components/app/rich-text-task-item-view.d.ts +4 -0
  51. package/dist/components/app/rich-text-task-item-view.js +59 -0
  52. package/dist/components/app/rich-text-toggle-heading.js +1 -1
  53. package/dist/components/app/rich-text-toolbar.js +1 -1
  54. package/dist/components/app/rich-text-tools-bar.d.ts +3 -1
  55. package/dist/components/app/rich-text-tools-bar.js +2 -2
  56. package/dist/components/app/step-row.d.ts +15 -0
  57. package/dist/components/app/step-row.js +27 -0
  58. package/dist/components/app/step-track.d.ts +82 -0
  59. package/dist/components/app/step-track.js +98 -0
  60. package/dist/components/ui/sonner.js +1 -1
  61. package/dist/hooks/use-form-version.d.ts +101 -0
  62. package/dist/hooks/use-form-version.js +187 -0
  63. package/dist/hooks/use-record-update.d.ts +15 -8
  64. package/dist/hooks/use-record-update.js +19 -14
  65. package/dist/index.d.ts +7 -3
  66. package/dist/index.js +7 -0
  67. package/dist/lib/markdown-merge.d.ts +12 -0
  68. package/dist/lib/markdown-merge.js +90 -0
  69. package/dist/lib/rating-glyphs.d.ts +3 -0
  70. package/dist/lib/rating-glyphs.js +7 -0
  71. package/dist/lib/refusal.d.ts +9 -0
  72. package/dist/lib/refusal.js +19 -0
  73. package/openapi/foundation.yaml +12 -0
  74. package/package.json +1 -1
@@ -3,30 +3,31 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [The reference files](#the-reference-files) · lines 45–67
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–880
8
- - Step 1: Add `<Entity>` to `openapi.yaml` · lines 111–118
9
- - Step 2: `npm run gen:api` · lines 119–120
10
- - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 121–132
11
- - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 133–142
12
- - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 143–149
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 150–758
14
- - Step 7: Register routes · lines 759–774
15
- - Step 8: Add Playwright specs for all three screens · lines 775–862
16
- - Step 9: Register the nav entry and route names · lines 863–877
17
- - Step 10: `npm run verify`. · lines 878–880
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 882–1351
19
- - [The record view](#the-record-view) · lines 1035–1192
20
- - [Forms](#forms) · lines 1194–1265
21
- - [Dialogs](#dialogs) · lines 1267–1298
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1300–1351
23
- - [What not to copy](#what-not-to-copy) · lines 1353–1386
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1388–1405
25
- - [Deleting](#deleting) · lines 1407–1438
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1440–1461
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1463–1472
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1475–1517
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1519–1555
6
+ - [The reference files](#the-reference-files) · lines 46–68
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 70–881
8
+ - Step 1: Add `<Entity>` to `openapi.yaml` · lines 112–119
9
+ - Step 2: `npm run gen:api` · lines 120–121
10
+ - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 122–133
11
+ - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 134–143
12
+ - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 144–150
13
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 151–759
14
+ - Step 7: Register routes · lines 760–775
15
+ - Step 8: Add Playwright specs for all three screens · lines 776–863
16
+ - Step 9: Register the nav entry and route names · lines 864–878
17
+ - Step 10: `npm run verify`. · lines 879–881
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 883–1402
19
+ - [The record view](#the-record-view) · lines 1036–1217
20
+ - [Forms](#forms) · lines 1219–1301
21
+ - [Dialogs](#dialogs) · lines 1303–1336
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1338–1402
23
+ - [What not to copy](#what-not-to-copy) · lines 1404–1439
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1441–1458
25
+ - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1460–1525
26
+ - [Deleting](#deleting) · lines 1527–1558
27
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1560–1581
28
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1583–1592
29
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1595–1637
30
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1639–1675
30
31
 
31
32
  <!-- /index -->
32
33
 
@@ -650,8 +651,8 @@ is a filled-in example while the Widgets demo is still here).
650
651
  a number or integer too), `long-text` (Markdown, `RichTextEditor`
651
652
  with `onProblem={props.onProblem}`; notes are `inline: true` by
652
653
  default, the control passing `inline={props.inline}` and
653
- `toolbar={props.inline ? 'floating' : true}` with no `autoFocus`,
654
- as Widget's Description does; a short one opened by a click is
654
+ `toolbar="floating"` (on the form too: "Forms" below) with no
655
+ `autoFocus`, as Widget's Description does; a short one opened by a click is
655
656
  `autosave: true` with `autoFocus`), `choice` (a
656
657
  select or a single reference: its list opens with the field,
657
658
  `defaultOpen`, non-modal, `onChange={(v) => props.commit(v)}`,
@@ -1141,18 +1142,38 @@ A record uses the parts it has, in this order:
1141
1142
  component or a node) before the label, in the muted tone. With
1142
1143
  `tone` (4.123: `success`, `warning`, `info`, `destructive`) a label
1143
1144
  that is a state ("Pinned", "Overdue") is the outline badge in that
1144
- tone, its icon too; the word still says it.
1145
+ tone, its icon too; the word still says it. A flag that's set reads
1146
+ at a glance this way, edited in place as any badges fact (its `edit`
1147
+ picks the flags; at rest each is drawn in its tone), and the tone
1148
+ comes along where the rail folds into Details on a phone. Untoned
1149
+ items are the plain outline. Give each state its tone from the design
1150
+ language's badge tones, never a colour of the app's own:
1151
+
1152
+ ```tsx
1153
+ const FLAG_BADGE = { blocked: { label: 'Blocked', tone: 'destructive' }, needsYou: { label: 'Needs you', tone: 'warning' } } as const
1154
+ { label: 'Flags', kind: 'badges', items: record.flags.map((flag) => FLAG_BADGE[flag]), emptyLabel: 'None',
1155
+ edit: editInPlace({ kind: 'multi', value: record.flags, save: (flags) => save({ flags }), control: (props) => <MultiPick options={FLAGS} value={props.value} onValueChange={props.onChange} aria-label={props.label} aria-describedby={props.describedBy} /> }) },
1156
+ ```
1145
1157
  - **A rating** (4.117) is `kind: 'rating'`, drawn as the list's cells
1146
1158
  draw it, never as "4 of 5" text: stars (the default) or hearts for a
1147
1159
  score out of `max` (5), the step bar for a quality level. `null` is
1148
- empty (its `emptyLabel`). Edited in place with `inPlace.select`:
1160
+ empty (its `emptyLabel`). A score the person gives (my rating) is
1161
+ edited in place with **`inPlace.rating`** (4.127): the stars are then
1162
+ the value, a click on one saves it, a second press on the set one
1163
+ saves `null`, and an empty one shows five empty stars to click rather
1164
+ than its `emptyLabel`. A score that isn't the person's to set (a
1165
+ critics' average) stays read-only:
1149
1166
 
1150
1167
  ```tsx
1151
- { label: 'My Rating', kind: 'rating', look: 'hearts', value: record.rating, emptyLabel: 'Not rated',
1152
- edit: inPlace.select({ value: record.rating, options: [1, 2, 3, 4, 5].map((n) => ({ value: n, label: `${n} of 5` })),
1153
- emptyLabel: 'Not rated', save: (rating) => save({ rating }) }) },
1168
+ { label: 'My Rating', kind: 'rating', value: record.rating,
1169
+ edit: inPlace.rating({ value: record.rating, save: (rating) => save({ rating }) }) },
1170
+ { label: 'Loved', kind: 'rating', look: 'hearts', value: record.loved,
1171
+ edit: inPlace.rating({ value: record.loved, glyph: 'heart', save: (loved) => save({ loved }) }) },
1154
1172
  { label: 'Quality', kind: 'rating', look: 'bar', value: QUALITY[record.quality].value, word: QUALITY[record.quality].word },
1155
1173
  ```
1174
+
1175
+ A quality level drawn as the step bar is an enum, not a score: edit
1176
+ it with `inPlace.select` over its levels.
1156
1177
  - **A yes/no** (4.120) is `kind: 'switch'`, a switch toggled where it
1157
1178
  is, named by the label, never a two-choice select. Return the save's
1158
1179
  promise: the switch shows the new state while it runs and goes back
@@ -1180,8 +1201,12 @@ A record uses the parts it has, in this order:
1180
1201
  handful of options) are one `EqualItems` (4.93) in a section, one look
1181
1202
  per set: `cards` for little to say about each, `table` for things
1182
1203
  compared on the same values, `featured` when one is current or best,
1183
- `panels` when each has several details (design-language.md "A few
1184
- equal things"). Never hand-made cards or a grid of their own. An item
1204
+ `panels` when each has several details, `stepper` (4.127) for a
1205
+ sequence with a current step whose items are looked at one at a time
1206
+ (numbered steps picking the one panel shown; design-language.md "A few
1207
+ equal things"). The same steps read only, on a list card with a
1208
+ caption under the current one ("Day 12"), are `StepTrack` (4.128).
1209
+ Never hand-made cards, a grid or a stepper of their own. An item
1185
1210
  edited or removed on its own carries its editor as `content` and its
1186
1211
  Edit and Remove as `actions` (4.94), `wide` while the editor is open;
1187
1212
  never an editor put in a field's value.
@@ -1215,6 +1240,17 @@ shape (4.85):
1215
1240
  a status choice gives each option its `kind`, so its icons are
1216
1241
  `StatusMark`'s in their colours (below).
1217
1242
  - **Order:** required first, the status next, long text last.
1243
+ - **Notes** (a Markdown long text: notes, a description, a body) are a
1244
+ `RichTextEditor` with `toolbar="floating"` on the form as in place
1245
+ (4.127): no bar above the text, the formats over selected words, every
1246
+ block in the slash menu ("/"), and Image, Full Screen and (on a narrow
1247
+ or touch screen) Indent and Outdent on the small "Editor tools" strip
1248
+ while it has focus. On a phone the row pinned to the keyboard carries
1249
+ them, Image included, at 40px. Give it the app's `upload` (the one
1250
+ `ImageField` takes) for the Image button and for pasted and dropped
1251
+ pictures, which go in as `![](url)`; a refused or failed picture says
1252
+ why in a toast. Without `upload` there's no Image button, and a picture
1253
+ can't go in at all.
1218
1254
  - **Required:** `<FieldLabel required>` (an asterisk, and `aria-required`
1219
1255
  on the control it names). Nothing on an optional field: never
1220
1256
  "(optional)".
@@ -1292,6 +1328,8 @@ instead, as a small card: `RecordDialogRoute look="card"` (4.98).
1292
1328
  - **A form in a dialog is a `FormDialog`**: the title, the fields
1293
1329
  scrolling between it and the pinned Cancel and Add, a failed save as a
1294
1330
  destructive `Notice` above the buttons with Try Again, and `dirty`.
1331
+ An edit refused because the record changed elsewhere is its
1332
+ `conflict` instead ("Saves that don't overwrite").
1295
1333
  Opened from a page with `open`/`onOpenChange`; as a list's `new` route
1296
1334
  with neither (above).
1297
1335
  - **Always a dialog, never a side panel**, except a phone's filters
@@ -1307,6 +1345,7 @@ sight.** What happened where the person is looking says so there.
1307
1345
  | --- | --- |
1308
1346
  | A delete (soft: with Undo) | `DeleteAction`'s toast, "Deleted The Long Walk" |
1309
1347
  | A record made, landing on its own page | a toast, "Added The Long Walk" |
1348
+ | A record made where the person stays (a dialog over a page of tiles) | a toast with Open, "Added The Long Walk" · Open (`notify.done`'s `open`) |
1310
1349
  | An edit in place, a quick action, a toggle | the value itself and its "Saved" (cell pattern 18). **Never a toast** |
1311
1350
  | An action that failed, its button still there | `ActionError` beside the button: the reason and Try Again |
1312
1351
  | An action that failed after its page was left | a toast that stays until it's closed (`useAction` does this) |
@@ -1340,6 +1379,18 @@ sight.** What happened where the person is looking says so there.
1340
1379
  verb first, "Deleted The Long Walk", "Added Paper Atlas"; Undo, when
1341
1380
  given, then says "Restored The Long Walk". Never "X deleted", never
1342
1381
  "Book deleted". Toasts last 4 seconds, Undo's too.
1382
+ - **A record made without leaving the page gets Open:**
1383
+ ``notify.done('Added', book.title, { open: `/books/${book.id}` })``.
1384
+ When saving closes a dialog and stays put (a homepage of tiles, a
1385
+ `FormDialog` opened from a page), the toast says "Added The Long Walk"
1386
+ with an **Open** link to the new record; never a hand-built sonner
1387
+ toast. `open` is a path (anything `Link`'s `to` takes) or
1388
+ `{ to, label }` for another word ("View"). It is a real link, named
1389
+ "Open The Long Walk" for a screen reader, reached from the keyboard
1390
+ (Alt+T to the toasts, then Tab), and closes the toast as it goes; the
1391
+ toast keeps its 4 seconds. With `undo` too, both show, Open first. A
1392
+ create that lands on the record's own
1393
+ page doesn't need it: the person is already there.
1343
1394
  - **An error stays beside what failed**: `const save = useAction(mutation)`,
1344
1395
  `save.run(…)` on the button (`disabled={save.pending}`, a `Spinner` in
1345
1396
  it), `<ActionError action={save} />` next to it. Never
@@ -1375,7 +1426,9 @@ sight.** What happened where the person is looking says so there.
1375
1426
  opens on with `defaultView`, and put what no control can show (a
1376
1427
  computed "overdue") in the view's `rule` (cell-patterns.md "Saved views
1377
1428
  are pills"). The default view's `sort` is its plain address's too
1378
- (4.123): pressing it writes no `?sort=`, and the rows keep that order.
1429
+ (4.123): pressing it writes no `?sort=`, and the rows keep that order. A view the plan says
1430
+ shows a count gets `count` from the app's own query, passed to
1431
+ `DataTable`'s `views` (cell-patterns.md "A view can carry a count").
1379
1432
  - `src/api/gateway/widgets.ts`, `src/mocks/data.ts`, `src/mocks/handlers.ts`
1380
1433
  are demo-domain content — write the entity's own versions rather than
1381
1434
  adapting these by find-and-replace.
@@ -1404,6 +1457,73 @@ asyncio is a `MissingGreenlet` and a 500.
1404
1457
  a `User(...)` in for `get_current_user` in an override: a detached user
1405
1458
  never expires, so the test passes and the route fails live.
1406
1459
 
1460
+ ## Saves that don't overwrite
1461
+
1462
+ A record edited in more than one place (a laptop tab, a phone, an AI chat
1463
+ through MCP) needs a version, or the last save wins: a phone left open on
1464
+ a note, typed into after the laptop changed it, replaces the laptop's
1465
+ work. The fix is optimistic concurrency, the same for every entity:
1466
+
1467
+ - **The record carries its version: `updatedAt`** (`updated_at`, a
1468
+ `timestamptz` every write sets with `foundation_backend.versions.touch()`,
1469
+ never null, commented in its migration). Not a counter or an ETag: most
1470
+ tables already have one, a person or an AI reading the row knows what it
1471
+ means, and it rides in the JSON body, where an MCP tool call can send it
1472
+ back too (an `If-Match` header can't reach a chat). It's compared for
1473
+ equality, never ordered, so clocks don't matter.
1474
+ - **An update may send the version it was built on: `baseUpdatedAt`**, an
1475
+ optional field of `<Entity>Update` that isn't a column. The router locks
1476
+ the row, calls `check_version(record.updated_at, base)` before changing
1477
+ anything, and sets `updated_at = touch()`. A version that's no longer the
1478
+ record's is a **409** (`ConflictError`, `VersionConflict`): nothing is
1479
+ written. No version sent: no check, so older clients and scripts keep
1480
+ working. `responses=VERSIONED_UPDATE_RESPONSES` documents it, and the
1481
+ PATCH in `openapi.yaml` lists `"409": ConflictError`.
1482
+ - **The client sends it with every single-field save:** `useRecordUpdate`'s
1483
+ `withVersion: (update, record) => ({ ...update, baseUpdatedAt:
1484
+ record.updatedAt })`. The record it gets is the latest the server
1485
+ returned (a burst of saves chains through each answer's version), so a
1486
+ save never conflicts with the tab's own. The gateway needs no change:
1487
+ `toAppError` makes the 409 an `AppError` of kind `conflict`, and
1488
+ `useRecordUpdate` refetches the record.
1489
+ - **What the person sees.** A quick action's toast gives the 409's reason,
1490
+ and the refetch shows what the other writer saved. A field edited in
1491
+ place asks: "This changed elsewhere", with **Keep Mine** and **Show
1492
+ Saved**, and nothing saves until a pick. Long text's Keep Mine keeps
1493
+ both, block by block (`rebaseMarkdown`); when both changed the same
1494
+ paragraph it says so, and only a second Keep Mine replaces theirs. Any
1495
+ other field's Keep Mine saves what's typed over theirs. An `editInPlace`
1496
+ takes its own `rebase`, or `rebase: false`.
1497
+ - **The edit form sends it too: `useFormVersion`**, with the same
1498
+ `withVersion`. `useFormVersion({ record: query.data, withVersion,
1499
+ refetch: query.refetch })` keeps the record the form opened with: the
1500
+ form's `values` come from `version.record`, so a refetch in the
1501
+ background never resets what's typed, and the save sends
1502
+ `version.send(update)`, that record's version. In the save's `onError`,
1503
+ `if (version.refused(error)) return` first: a 409 is the hook's (it
1504
+ fetches the newer version), anything else the form's as before. Pass
1505
+ `conflict={version.conflict}` to `EntityForm` (or `FormDialog`, for an
1506
+ edit in a dialog): the bar shows a warning Notice, "Changed elsewhere",
1507
+ saying nothing was saved and what's typed is still there, with **Keep
1508
+ Mine** (saves the form as it is over theirs, built on the newer
1509
+ version) and **Show Saved** (the form takes their record; the Notice
1510
+ says the typing goes). Never Try Again: the same save would be refused
1511
+ again. A form that stays open after a save (a dialog) calls
1512
+ `version.saved(record)` in `onSuccess`, so its next save builds on it.
1513
+ Keep Mine sends the whole form, so a field they changed and the form
1514
+ didn't goes back to the form's value.
1515
+ - **A chat** gets the same check through the entity's `McpEntity.update`:
1516
+ the `update` tool tells it to send the `updatedAt` it read as
1517
+ `baseUpdatedAt`, and a 409 comes back as a refusal that says to fetch
1518
+ the record again. `edit_text` is safe without it (its `old` text must
1519
+ still be there).
1520
+ - **Copy:** `template/backend/app/routers/widgets.py` (`update_widget`),
1521
+ migration `0017_widget_updated_at.py`, `WidgetOut.updated_at` and
1522
+ `WidgetUpdate.base_updated_at` in `app/schemas.py`, the PATCH mock in
1523
+ `src/mocks/handlers.ts`, `withVersion` in `use-widgets.ts`,
1524
+ `useFormVersion` in `widget-form.tsx`, and the "two writers" specs in
1525
+ `e2e/widget-edit-in-place.spec.ts` and `e2e/widget-form.spec.ts`.
1526
+
1407
1527
  ## Deleting
1408
1528
 
1409
1529
  The plan's "Deleting" line says which of three. The Widget reference is the
@@ -13,38 +13,38 @@
13
13
  - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 299–311
14
14
  - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 313–334
15
15
  - [8. Date, relative](#8-date-relative) · lines 336–373
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 375–434
17
- - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 393–434
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 436–486
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 454–486
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 488–528
21
- - [12. Boolean](#12-boolean) · lines 530–560
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 562–598
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 582–598
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 600–617
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 619–728
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 645–728
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 730–776
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 778–851
29
- - [18. Editable value](#18-editable-value) · lines 853–1597
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1229–1297
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1299–1335
32
- - [A link and its label](#a-link-and-its-label) · lines 1337–1361
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1363–1496
34
- - [In a table's rows](#in-a-tables-rows) · lines 1498–1583
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1585–1597
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1599–1665
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1667–1731
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1733–1831
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1833–1862
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1864–1902
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1904–1980
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1982–2068
43
- - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2007–2068
44
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2070–2295
45
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2224–2295
46
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2297–2333
47
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2335–2384
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 375–453
17
+ - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 393–453
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 455–505
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 473–505
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 507–547
21
+ - [12. Boolean](#12-boolean) · lines 549–579
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 581–617
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 601–617
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 619–636
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 638–747
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 664–747
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 749–795
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 797–870
29
+ - [18. Editable value](#18-editable-value) · lines 872–1628
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1257–1328
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1330–1366
32
+ - [A link and its label](#a-link-and-its-label) · lines 1368–1392
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1394–1527
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1529–1614
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1616–1628
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1630–1696
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1698–1762
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1764–1862
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1864–1893
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1895–1933
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1935–2011
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 2013–2099
43
+ - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2038–2099
44
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2101–2342
45
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2271–2342
46
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2344–2380
47
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2382–2431
48
48
 
49
49
  <!-- /index -->
50
50
 
@@ -430,6 +430,25 @@ themes. Each is one image to a screen reader, named in words.
430
430
  {row.rating === null ? <Muted>Not rated</Muted> : <RatingScore value={row.rating} glyph="heart" />}
431
431
  ```
432
432
 
433
+ - **`RatingInput`, the same score set by a click** (4.127): RatingScore's
434
+ glyphs and tokens as a radio group named by `label`, one radio per
435
+ star ("2 of 5"). A click (or Space) sets a star, a click on the set one
436
+ clears it to `null`, the arrow keys move and set it, a mouse's hover
437
+ previews it. 24px targets on a laptop, 44px on a touch screen.
438
+ `onChange(value, source)`: `source` is `'pointer'` or `'keyboard'`.
439
+ On a form it's the field's control; on a record or in a row it's
440
+ `inPlace.rating` ("Presets" below), so a cell sets its row's score where
441
+ it's drawn:
442
+
443
+ ```tsx
444
+ <RatingInput label="Taste" value={value} onChange={(next) => setValue(next)} />
445
+ // A table's cell: inside DataTable, which runs editing in place.
446
+ cell: ({ row }) => (
447
+ <EditableValue layout="inline" label={`Rating of ${row.original.name}`}
448
+ edit={inPlace.rating({ value: row.original.rating, save: (rating) => save(row.original.id, { rating }) })} />
449
+ ),
450
+ ```
451
+
433
452
  - All three draw in `foreground`. Tone one only as pattern 5 would (a `*-text`
434
453
  class in `className`), never by band alone.
435
454
 
@@ -1050,9 +1069,15 @@ nobody has to click away to save notes. Opt in per field:
1050
1069
  query refetches): with nothing typed waiting, the note shows the new
1051
1070
  text at once, even with the caret in it, which keeps its paragraph.
1052
1071
  Under unsaved typing nothing saves over it: the line says it "changed
1053
- elsewhere", with **Keep Mine** (save what's typed over it) and **Show
1054
- Saved** (drop what's typed). The server sending back what it was sent,
1055
- even trimmed, is not a change: the editor keeps its undo.
1072
+ elsewhere", with **Keep Mine** and **Show Saved** (drop what's typed).
1073
+ Keep Mine keeps both, block by block: what's typed is laid onto the
1074
+ other writer's text and the editor shows the result as it saves; when
1075
+ both changed the same paragraph it says so, and a second Keep Mine
1076
+ replaces theirs. A save the server refuses because another writer saved
1077
+ first (a 409, the record's version check: add-an-entity.md "Saves that
1078
+ don't overwrite") asks the same way, never a plain failure to retry.
1079
+ The server sending back what it was sent, even trimmed, is not a
1080
+ change: the editor keeps its undo.
1056
1081
  - **Leaving mid-save:** a field that leaves the view while a save is in
1057
1082
  flight (a session ending, a parent that stops showing it) still sends
1058
1083
  what was typed after that save started.
@@ -1100,7 +1125,8 @@ but drops the bar above the text. An empty one shows the editor's
1100
1125
  `placeholder` (say "or type / for blocks" in it), not the view's "Not
1101
1126
  set". It saves like any always-editable value (a pause after typing,
1102
1127
  leaving the page saves first) and is otherwise the same: on the form the
1103
- control is the boxed editor with its fixed toolbar.
1128
+ control is the boxed editor, with the floating toolbar too (4.127,
1129
+ [add-an-entity.md "Forms"](add-an-entity.md#forms)).
1104
1130
 
1105
1131
  ```tsx
1106
1132
  notes: editInPlace({
@@ -1198,11 +1224,12 @@ const price = editInPlace({
1198
1224
  button fills the window with the field (Esc leaves; nothing is lost or
1199
1225
  saved by it), and on a touch screen or under 768px it carries Indent
1200
1226
  and Outdent for list items, where there is no Tab. A field with only the
1201
- floating toolbar (`inline` notes) gets the same two in a small "Editor
1202
- tools" strip over its corner while it has focus. On a touch screen the
1227
+ floating toolbar (`inline` notes, and notes on a form) gets the same
1228
+ two in a small "Editor tools" strip over its corner while it has focus,
1229
+ with the Image button too when the editor has `upload` (4.127). On a touch screen the
1203
1230
  toolbar is instead one row pinned to the top of the keyboard while the
1204
1231
  field has focus (Aa for every format, in the keyboard's place; the list
1205
- buttons, Insert and Undo; with words selected, their formats first, and
1232
+ buttons, Insert, Image (with `upload`) and Undo; with words selected, their formats first, and
1206
1233
  no floating bar under the system's Copy bar), and the checkbox, the
1207
1234
  table grips, the fold button and the callout icon take a 40px tap. A new checklist item
1208
1235
  shows a "To-do" placeholder and the caret until you type. `[] ` (or
@@ -1214,7 +1241,8 @@ const price = editInPlace({
1214
1241
  the floating one and the slash menu without the bar above (an `inline`
1215
1242
  field's look). Images in the text (`![alt](url)`) show; give it the
1216
1243
  app's `upload` (the same one `ImageField` takes) and an image pasted,
1217
- dropped or picked with the toolbar's Image button is uploaded and goes
1244
+ dropped or picked with an Image button (the fixed toolbar's, the tools
1245
+ strip's, the phone's row) is uploaded and goes
1218
1246
  in as `![](url)`, a placeholder showing meanwhile (never saved), a
1219
1247
  refusal or failure in a toast. No `upload`, no file handling at all.
1220
1248
  - **The save is the single-field save** (`useRecordUpdate` with
@@ -1248,6 +1276,7 @@ fields: [
1248
1276
  { label: 'Priority', edit: inPlace.select({ value: project.priority, options: PRIORITY_OPTIONS,
1249
1277
  render: (priority, label) => <Badge variant={PRIORITY_BADGE[priority]}>{label}</Badge>,
1250
1278
  save: (priority) => save({ priority }) }) },
1279
+ { label: 'My Rating', edit: inPlace.rating({ value: project.rating, save: (rating) => save({ rating }) }) },
1251
1280
  { label: 'Category', edit: inPlace.reference({ value: project.categoryId, label: categoryName,
1252
1281
  search: (text) => searchCategories(text), onCreate: (name) => openNewCategory(name),
1253
1282
  save: (categoryId) => save({ categoryId }) }) },
@@ -1271,12 +1300,14 @@ fields: [
1271
1300
  | `monthDay` | `Mar 14` (`format`, `locale`); a stored value that isn't a day, as written | `'MM-DD'`, no year; February 29 is a day; Clear is `null` | Clear when `required`, a day the month can't have ("February has 29 days") |
1272
1301
  | `select` | the option's label, or its `render` (a badge) | the option's value; "Not set" is `null` | "Not set" isn't offered when `required` |
1273
1302
  | `choice` | as `select` | as `select`, drawn as ChoiceButtons (two to four short options); pressing the picked one again is `null` | as `select` |
1303
+ | `rating` | `RatingScore` (`max`, `glyph`); always the stars (`RatingInput`), with no click to open | the star's number, at once on a click; an arrow's a pause after the last; pressing the set star again is `null` | clearing when `required` (the press does nothing) |
1274
1304
  | `reference` | the record's `label` (the view's lookup by id) | the picked record's id | "Not set" isn't offered when `required` |
1275
1305
 
1276
1306
  - **They save the way their kind does** (the table above): `text`,
1277
1307
  `number`, `money` and a typed `date` on Enter or leaving them, a day
1278
1308
  picked in the date's calendar, `monthDay`, `select`, `choice` and
1279
- `reference` on the pick (a list opens with the field).
1309
+ `reference` on the pick (a list opens with the field), `rating` on a
1310
+ click of a star (it's always open: the stars are the value).
1280
1311
  `required: true` types the save without `null`.
1281
1312
  - **`reference` searches through the app.** The package knows no
1282
1313
  endpoint: `search(text)` is the app's (its gateway's search by name,
@@ -2120,6 +2151,22 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
2120
2151
  once the filters move off every view. Under 48rem they stay on one line
2121
2152
  that scrolls sideways. Replaces a hand-written row of view buttons; a
2122
2153
  Deleted view goes in ListHeader's ⋯ menu as Show Deleted instead.
2154
+ - **A view can carry a count** (4.127): `count` on the view you pass
2155
+ `DataTable`, shown after its label as "Needs a Look · 3" and read as
2156
+ "Needs a Look, 3". The app counts with its own query (the list's
2157
+ `total` under that view's filters, or a count endpoint); the table
2158
+ computes nothing. null, undefined and 0 show no count, as the
2159
+ sidebar's counts and a record's tab counts don't, and past 99 it reads
2160
+ "99+". Count only views that ask you to act (Needs a Look, To Fill
2161
+ In), not All. Give the view the key from the first render, `undefined`
2162
+ while the query loads: a view with the key keeps room for a two-digit
2163
+ count, so no pill moves when it arrives, on a phone's scrolling row
2164
+ too.
2165
+
2166
+ ```tsx
2167
+ const { data: needsLook } = useNewsSourcesQuery({ ...VIEWS.look.filters, pageSize: 1 })
2168
+ <DataTable views={{ ...VIEWS, look: { ...VIEWS.look, count: needsLook?.total } }} … />
2169
+ ```
2123
2170
  - **Views fill the filters** (4.105), so the bar always says why rows are
2124
2171
  hidden:
2125
2172
  - A view's `filters` and `multiFilters` are what the bar's controls
@@ -30,14 +30,14 @@
30
30
  - [A list as cards](#a-list-as-cards) · lines 1308–1354
31
31
  - [Key numbers on a record](#key-numbers-on-a-record) · lines 1356–1392
32
32
  - [Parts of the page standards](#parts-of-the-page-standards) · lines 1394–1464
33
- - [A few equal things](#a-few-equal-things) · lines 1466–1550
34
- - [An overview page](#an-overview-page) · lines 1552–1623
35
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1624–1690
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1692–1816
37
- - [Picking at random](#picking-at-random) · lines 1818–1849
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1851–1918
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1920–1945
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1947–2043
33
+ - [A few equal things](#a-few-equal-things) · lines 1466–1586
34
+ - [An overview page](#an-overview-page) · lines 1588–1659
35
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1660–1726
36
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1728–1865
37
+ - [Picking at random](#picking-at-random) · lines 1867–1898
38
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1900–1967
39
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1969–1994
40
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1996–2092
41
41
 
42
42
  <!-- /index -->
43
43
 
@@ -1467,8 +1467,8 @@ Every one is measured with axe and the glyph check in both themes
1467
1467
 
1468
1468
  `EqualItems` (4.93, record standard R10): a small set of equal, related
1469
1469
  things inside a record (a plan's phases, the stores a price is compared
1470
- at, a handful of options), one data shape in four looks. A record picks
1471
- one look per set; a fifth is asked for first.
1470
+ at, a handful of options), one data shape in five looks. A record picks
1471
+ one look per set; a sixth is asked for first.
1472
1472
 
1473
1473
  ```tsx
1474
1474
  <EqualItems
@@ -1490,6 +1490,7 @@ one look per set; a fifth is asked for first.
1490
1490
  | `table` | one compact row per item, the title as its row header, a column per field label (first-seen order), a dash where an item has none; scrolls sideways in its own box on a phone | things compared on the same values (a price at each store) |
1491
1491
  | `featured` | the item `featuredId` names in full, in a card with the accent border, then the rest as toggles that open in place | one is current or best (a program's phases) |
1492
1492
  | `panels` | a panel per item side by side, its title and state in a muted band, every detail labelled above its value; stacked on a phone | each has several details and must read as separate |
1493
+ | `stepper` (4.127) | a row of numbered steps joined by a line, each done, current or upcoming, picking the one item whose panel shows under it; opens on the current step; the row scrolls sideways in its own box on a phone | a sequence with one running and the others looked at in turn (a program's phases), where `featured`'s toggles would stack every phase's long content |
1493
1494
 
1494
1495
  - **A state is a badge**, the outline style in its tone (`state: 'Planned'`
1495
1496
  is the neutral one; `{ label, tone }` with `info`, `success`, `warning`
@@ -1501,6 +1502,41 @@ one look per set; a fifth is asked for first.
1501
1502
  Enter or Space opens one, Tab moves to the next, several can be open,
1502
1503
  `aria-expanded` says which. Never a link; `defaultOpenIds` opens some at
1503
1504
  first.
1505
+ - **The stepper** (4.127): each item's `step` is `done` (filled with
1506
+ the primary, a check), `current` (ringed, "Current" under its name, its
1507
+ panel's border the accent) or `upcoming` (outlined, the default); the
1508
+ line into a step is the primary up to the current one. It opens on
1509
+ `featuredId`, else the `current` step, else the first; the shown step
1510
+ has a ring round its mark and its name semibold. The steps are a
1511
+ tablist named `label`: arrow keys, Home and End move and pick, Tab goes
1512
+ on into the panel, and the current step is `aria-current="step"`. A
1513
+ step's name is what it shows plus hidden words ("Step 2: Phase 2:
1514
+ Build, done"), never an `aria-label`. An app that keeps the shown step
1515
+ (in the URL as `?phase=`) passes `selectedId` and `onSelectedChange`.
1516
+ `attention` ("needs an answer") puts a small warning dot on a step and
1517
+ those words in its name, for something in a panel not shown (an
1518
+ unsaved change waiting on an answer). **On a phone** the row stays a
1519
+ row: each step at least 4.5rem wide and 44px tall, scrolling sideways
1520
+ in its own box (never the page) as the record's tab bar does, the
1521
+ shown step kept in view; it never folds into a select, which would
1522
+ hide the done and current marks the stepper is for.
1523
+ - **The same steps, read only** (4.128): `StepTrack` draws the stepper's
1524
+ row on its own, with no panels and nothing to pick, for a display of
1525
+ where a sequence is (a list card showing a program's phases). The
1526
+ marks, the line and the sizes are the stepper's own parts, so the two
1527
+ never differ; the current step is ringed and has "Current" under it,
1528
+ or `caption` in its place ("Day 12"), its name still saying ", current"
1529
+ to a screen reader. It's a named list (`<ol aria-label={label}>`), never
1530
+ a tablist: steps are list items, not tabs or buttons. On a phone it
1531
+ scrolls sideways in its own box with the current step in view, and
1532
+ only while it overflows is the box a tab stop, so the arrow keys
1533
+ scroll it. Pass the stepper's items as they are (an `EqualItem` is a
1534
+ `StepTrackStep`); no steps reads `emptyText`. Never a hand-drawn row of
1535
+ steps on a card.
1536
+
1537
+ ```tsx
1538
+ <StepTrack label={`${program.name}, phases`} caption={`Day ${program.day}`} steps={phases} />
1539
+ ```
1504
1540
  - **Empty**: no items reads `emptyText` ("Nothing yet"), an item with no
1505
1541
  fields `noFieldsText` ("No details"). `label` names the set for a screen
1506
1542
  reader (the list's name, the table's caption); titles are `h3` under a
@@ -1546,7 +1582,7 @@ items={stores.map((store) => ({
1546
1582
 
1547
1583
  Measured with axe, the token check and the glyph check in both themes and
1548
1584
  every palette (fixtures `app/EqualItems`, "Content and actions" among
1549
- them), and from the keyboard and at a phone's width in
1585
+ them, and "Stepper"), and from the keyboard and at a phone's width in
1550
1586
  `e2e/equal-items.spec.ts`.
1551
1587
 
1552
1588
  ## An overview page
@@ -1776,8 +1812,21 @@ its short facts the last tab, Details. A mark goes left of the title.
1776
1812
  that's what a screen reader hears, one image named in words. The
1777
1813
  glyphs are a fixed size, so the value never moves on hover, and it's
1778
1814
  drawn the same in Details on a phone. An empty one reads its
1779
- `emptyLabel` ("Not rated"), not a row of empty stars. Edited in place
1780
- like any fact (`edit`), usually `inPlace.select` over the scores.
1815
+ `emptyLabel` ("Not rated"), not a row of empty stars. A score the
1816
+ person sets is edited with `inPlace.rating` (4.127): the stars become
1817
+ `RatingInput`, set by a click where they're drawn (no select to open),
1818
+ and an empty one is then five empty stars to click. "Saving…" and
1819
+ "Saved" are an icon beside the stars, words for a screen reader, so the
1820
+ row never grows. On a touch screen each star is a 44px target and the
1821
+ row puts its label above them, which a narrow value column can't hold.
1822
+ - **`RatingInput`** (4.127): RatingScore's glyphs and tokens as a radio
1823
+ group named by the field's label, each star a radio ("2 of 5"). The
1824
+ arrow keys move and set it, a click or Space sets the star it's on,
1825
+ pressing the set star again clears it. A mouse's hover previews the
1826
+ score in the same ink (the filled count is the preview; leaving puts it
1827
+ back); a finger gets no preview. 24px targets on a laptop, 44px on a
1828
+ touch screen, fixed-size either way. Disabled, it's the score at half
1829
+ opacity and ignores the pointer.
1781
1830
  - **A yes/no** (`kind: 'switch'`, 4.120) is a switch on the value's
1782
1831
  line, never a two-choice select: `checked`, `onCheckedChange` (return
1783
1832
  the save's promise and the switch shows the new state, busy, until it
@@ -11,8 +11,15 @@ export type AppError = {
11
11
  * lapsed, not from the app: a page or a redirect where JSON was
12
12
  * expected. Only a full page load signs in again. Not the app's own
13
13
  * session, which is `auth`.
14
+ *
15
+ * `conflict` (a 409): the save was refused because the record changed
16
+ * since the version it was built on (another tab, a phone, an AI chat
17
+ * saved in between). Nothing was written: fetch the record again and
18
+ * let the person choose. `useRecordUpdate` refetches it, and editing in
19
+ * place asks "This changed elsewhere" (docs/foundation/add-an-entity.md
20
+ * "Saves that don't overwrite").
14
21
  */
15
- kind: "validation" | "notfound" | "auth" | "rate_limited" | "server" | "network" | "proxy_auth";
22
+ kind: "validation" | "notfound" | "auth" | "rate_limited" | "conflict" | "server" | "network" | "proxy_auth";
16
23
  message: string;
17
24
  fieldErrors?: Record<string, string[]>;
18
25
  /**
@@ -89,6 +89,10 @@ function translate(status, body, headers) {
89
89
  return { kind: "notfound", message };
90
90
  if (status === 401)
91
91
  return { kind: "auth", message };
92
+ // The record changed since the version the save was built on: nothing
93
+ // was written (ConflictError in openapi/foundation.yaml).
94
+ if (status === 409)
95
+ return { kind: "conflict", message };
92
96
  if (status === 429) {
93
97
  const retryAfterSeconds = parseRetryAfter(headers?.get("retry-after") ?? null);
94
98
  return retryAfterSeconds === undefined