@tristan2828/ui-foundation 4.86.0 → 4.88.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 (47) hide show
  1. package/README.md +1 -1
  2. package/conventions/docs/add-an-entity.md +52 -23
  3. package/conventions/docs/cell-patterns.md +49 -24
  4. package/conventions/docs/design-language.md +30 -3
  5. package/dist/components/app/app-shell-nav.d.ts +24 -0
  6. package/dist/components/app/app-shell-nav.js +30 -0
  7. package/dist/components/app/app-shell.d.ts +12 -1
  8. package/dist/components/app/app-shell.js +19 -5
  9. package/dist/components/app/choice-buttons.d.ts +25 -0
  10. package/dist/components/app/choice-buttons.js +17 -0
  11. package/dist/components/app/date-field.d.ts +28 -9
  12. package/dist/components/app/date-field.js +103 -10
  13. package/dist/components/app/edit-in-place-controls.d.ts +1 -3
  14. package/dist/components/app/edit-in-place-controls.js +4 -58
  15. package/dist/components/app/edit-in-place-presets.d.ts +38 -4
  16. package/dist/components/app/edit-in-place-presets.js +48 -27
  17. package/dist/components/app/edit-row.d.ts +7 -0
  18. package/dist/components/app/edit-row.js +23 -0
  19. package/dist/components/app/editable-value.d.ts +8 -1
  20. package/dist/components/app/editable-value.js +36 -4
  21. package/dist/components/app/entity-view.d.ts +11 -1
  22. package/dist/components/app/entity-view.js +19 -2
  23. package/dist/components/app/multi-pick.d.ts +8 -1
  24. package/dist/components/app/multi-pick.js +19 -5
  25. package/dist/components/app/multi-reference.d.ts +8 -1
  26. package/dist/components/app/multi-reference.js +44 -6
  27. package/dist/components/app/page-trail-context.d.ts +18 -0
  28. package/dist/components/app/page-trail-context.js +28 -0
  29. package/dist/components/app/page-trail.d.ts +1 -1
  30. package/dist/components/app/page-trail.js +1 -1
  31. package/dist/components/app/reference-combobox.d.ts +37 -0
  32. package/dist/components/app/reference-combobox.js +96 -0
  33. package/dist/components/app/search-palette.d.ts +29 -0
  34. package/dist/components/app/search-palette.js +160 -0
  35. package/dist/components/ui/field.d.ts +2 -2
  36. package/dist/components/ui/field.js +2 -1
  37. package/dist/hooks/use-recent-record.d.ts +10 -0
  38. package/dist/hooks/use-recent-record.js +20 -0
  39. package/dist/index.d.ts +7 -2
  40. package/dist/index.js +6 -1
  41. package/dist/lib/names-record.d.ts +4 -0
  42. package/dist/lib/names-record.js +7 -0
  43. package/dist/lib/plain-date.d.ts +20 -0
  44. package/dist/lib/plain-date.js +72 -0
  45. package/dist/lib/search-palette.d.ts +50 -0
  46. package/dist/lib/search-palette.js +119 -0
  47. package/package.json +1 -1
package/README.md CHANGED
@@ -18,7 +18,7 @@ than installing this by hand:
18
18
 
19
19
  | Import | What |
20
20
  |---|---|
21
- | `@tristan2828/ui-foundation` | `AppShell`, `DataTable`, `EntityView` (with `EditableValue`, `editInPlace`, printing its notes and `usePrinting`, `KeyStats`, `IconAction`), `EntityForm`, `Markdown` (with `countTasks`, `toggleTaskAt`), `RichTextEditor`, `ErrorState`, `MultiChoice`, `MultiReference`, `ListEditor`, `PasswordInput`, `RouteErrorBoundary`, `FoundationProviders`, `DataEnvironmentBanner`, `LoginRoute`, `RegisterRoute`, `useAuth`, `useTableUrlState`, `useRecordUpdate`, `useDebouncedValue`, `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. For timed screens (`docs/foundation/timed-screens.md`): `SessionView`, `useSessionClock`, `useWakeLock`, `useMuted`, `usePrefersReducedMotion`, and the audio cues `unlockAudio`, `chime`, `sequence`, `cancelCues`, `onCuesRecovered`, `cuesInSync`, `keepAudioAlive`, `say`, `hush`, `vibrate`, `canVibrate`. For the page standards (`docs/foundation/design-language.md` "Parts of the page standards"): `ValueList`, `ListHeader`, `Timeline`, `NeedsYou`, `Freshness`, `PartEmpty`. For a list's tools (`docs/foundation/cell-patterns.md` 25 and 26): `FilterBar`, `FilterSelect`, `RelatedTable`, and DataTable's `views`, `columnsMenu`, `rowActions`, `phoneRow`, `limit` and `viewAll`. For reminders (`docs/foundation/reminders.md`): `AllowReminders`, `usePushPermission`. For a record opened in a dialog over its list (`docs/foundation/add-an-entity.md`): `RecordDialogRoute`, `RecordLink`, `useOpenRecord`, `useRecordDialog`, `recordDialogState`, and for a new record over it `useNewRecordDialog`. A small form in a dialog: `FormDialog`. For the form standard (`docs/foundation/add-an-entity.md` "Forms"): `FormSection`, `OptionSelect`, `countFormErrors`, `fieldRows`; from `/ui/field`, `Field` takes `size`, `solo` and `kind`, and `FieldLabel` takes `required`. From `/ui/dialog`, `DialogContent` takes `size` and `dirty`, and `DiscardChangesDialog` is the "Discard your changes?" prompt |
21
+ | `@tristan2828/ui-foundation` | `AppShell`, `DataTable`, `EntityView` (with `EditableValue`, `editInPlace`, printing its notes and `usePrinting`, `KeyStats`, `IconAction`), `EntityForm`, `Markdown` (with `countTasks`, `toggleTaskAt`), `RichTextEditor`, `ErrorState`, `MultiChoice`, `MultiReference`, `ListEditor`, `PasswordInput`, `RouteErrorBoundary`, `FoundationProviders`, `DataEnvironmentBanner`, `LoginRoute`, `RegisterRoute`, `useAuth`, `useTableUrlState`, `useRecordUpdate`, `useDebouncedValue`, `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. For timed screens (`docs/foundation/timed-screens.md`): `SessionView`, `useSessionClock`, `useWakeLock`, `useMuted`, `usePrefersReducedMotion`, and the audio cues `unlockAudio`, `chime`, `sequence`, `cancelCues`, `onCuesRecovered`, `cuesInSync`, `keepAudioAlive`, `say`, `hush`, `vibrate`, `canVibrate`. For the page standards (`docs/foundation/design-language.md` "Parts of the page standards"): `ValueList`, `ListHeader`, `Timeline`, `NeedsYou`, `Freshness`, `PartEmpty`. For a list's tools (`docs/foundation/cell-patterns.md` 25 and 26): `FilterBar`, `FilterSelect`, `RelatedTable`, and DataTable's `views`, `columnsMenu`, `rowActions`, `phoneRow`, `limit` and `viewAll`. For reminders (`docs/foundation/reminders.md`): `AllowReminders`, `usePushPermission`. For a record opened in a dialog over its list (`docs/foundation/add-an-entity.md`): `RecordDialogRoute`, `RecordLink`, `useOpenRecord`, `useRecordDialog`, `recordDialogState`, and for a new record over it `useNewRecordDialog`. A small form in a dialog: `FormDialog`. For the trail and search in `AppShell`'s bar (`docs/foundation/design-language.md` "The sidebar and the phone's bar"): `usePageTrail`, `useRecentRecord`, `PageTrail`; types `AppShellSearch`, `SearchRecord`, `RecentRecord`. For the form standard (`docs/foundation/add-an-entity.md` "Forms"): `FormSection`, `OptionSelect`, `ChoiceButtons`, `ReferenceCombobox`, `countFormErrors`, `fieldRows`, `parsePlainDate`, and for a record's rows edited in place `editRowClass`, `onEditRowClick` and `inPlace.choice`; from `/ui/field`, `Field` takes `size`, `solo` and `kind`, and `FieldLabel` takes `required`. From `/ui/dialog`, `DialogContent` takes `size` and `dirty`, and `DiscardChangesDialog` is the "Discard your changes?" prompt |
22
22
  | `@tristan2828/ui-foundation/ui/<name>` | shadcn primitives: badge, button, calendar, card, checkbox, combobox, dialog, empty, field, input, input-group, label, popover, select, separator, sheet, sidebar, skeleton, sonner, spinner, switch, table, textarea, tooltip |
23
23
  | `@tristan2828/ui-foundation/gateway` | `safeFetch`, `toAppError`, `networkError` — for an app's `src/api/gateway/` only |
24
24
  | `@tristan2828/ui-foundation/mocks` | MSW: `authHandlers`, `environmentHandlers`, `resetMockAuth`, `getMockCurrentUser`, `MOCK_USER`, `exposeMswForE2E` |
@@ -4,27 +4,27 @@
4
4
  ## Index
5
5
 
6
6
  - [The reference files](#the-reference-files) · lines 43–65
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 67–812
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 67–830
8
8
  - Step 1: Add `<Entity>` to `openapi.yaml` · lines 109–116
9
9
  - Step 2: `npm run gen:api` · lines 117–118
10
10
  - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 119–130
11
11
  - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 131–140
12
12
  - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 141–145
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 146–699
14
- - Step 7: Register routes · lines 700–715
15
- - Step 8: Add Playwright specs for all three screens · lines 716–794
16
- - Step 9: Register the nav entry and route names · lines 795–809
17
- - Step 10: `npm run verify`. · lines 810–812
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 814–1072
19
- - [The record view](#the-record-view) · lines 963–1002
20
- - [Forms](#forms) · lines 1004–1045
21
- - [Dialogs](#dialogs) · lines 1047–1072
22
- - [What not to copy](#what-not-to-copy) · lines 1074–1100
23
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1102–1119
24
- - [Deleting](#deleting) · lines 1121–1150
25
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1152–1173
26
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1175–1184
27
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1187–1226
13
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 146–717
14
+ - Step 7: Register routes · lines 718–733
15
+ - Step 8: Add Playwright specs for all three screens · lines 734–812
16
+ - Step 9: Register the nav entry and route names · lines 813–827
17
+ - Step 10: `npm run verify`. · lines 828–830
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 832–1101
19
+ - [The record view](#the-record-view) · lines 981–1020
20
+ - [Forms](#forms) · lines 1022–1074
21
+ - [Dialogs](#dialogs) · lines 1076–1101
22
+ - [What not to copy](#what-not-to-copy) · lines 1103–1129
23
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1131–1148
24
+ - [Deleting](#deleting) · lines 1150–1179
25
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1181–1202
26
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1204–1213
27
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1216–1255
28
28
 
29
29
  <!-- /index -->
30
30
 
@@ -220,11 +220,15 @@ is a filled-in example while the Widgets demo is still here).
220
220
  it's the foundation's `DateField` in a `Controller` (`clearable` when
221
221
  optional); the schema is the string (`z.string().min(1, …)` when
222
222
  required). The table and the view show `formatPlainDate(value)`
223
- ("Sep 2, 2026"), the not-set label when empty. Editing in place is
224
- `editInPlace({ kind: 'choice', ... })` with `DateField` as the
225
- control, `defaultOpen`, `modal={false}`, `onChange={(day) =>
226
- props.commit(day)}` and `onOpenChange` cancelling on close, as a
227
- Select is (the fixtures' `app/DateField` EditInPlace). The backend column
223
+ ("Sep 2, 2026"), the not-set label when empty. `DateField` is typed
224
+ (4.88): a box that reads "3/14", "Mar 14", "2026-03-14" or "today",
225
+ with the calendar on its button, and something unreadable says "Try a
226
+ date like 3/14 or Mar 14" and gives `''`. Editing in place is
227
+ `inPlace.date({ value, save })`: Enter or leaving saves the day typed,
228
+ a day picked in the calendar saves at once. (`typing={false}` is the
229
+ button alone; in place then `editInPlace({ kind: 'choice', ... })` with
230
+ `defaultOpen`, `modal={false}` and `onChange={(day) => props.commit(day)}`,
231
+ the fixtures' `app/DateField` EditInPlace.) The backend column
228
232
  is a SQL `date` (`datetime.date` in the model).
229
233
 
230
234
  **A `month-day`** (a day that comes round every year, with no year:
@@ -426,6 +430,20 @@ is a filled-in example while the Widgets demo is still here).
426
430
  in `actions`, Delete as an `IconAction` (`icon={Trash2Icon}
427
431
  label="Delete" tone="destructive"`, the dialog's trigger through
428
432
  `render`).
433
+ - **The way back is a trail.** `back={{ to: '/widgets', label:
434
+ 'Widgets', trail: [{ label: 'Inventory', href: '/inventory' }, {
435
+ label: 'Widgets', href: '/widgets' }] }}`: the crumbs above the
436
+ record, from the module down to its list; the record's title follows
437
+ them. In `AppShell` it is the trail in the bar ("The sidebar and the
438
+ phone's bar" in design-language.md), and the page has no back link;
439
+ on a phone the header's back arrow goes to the list. Without `trail`
440
+ the view keeps its "← Widgets" link. `to` and `label` are still the
441
+ not-found state's way out. Any other page below a nav entry (a
442
+ record's sub-page, a step of a task) names its trail with
443
+ `usePageTrail([...crumbs, { label: 'This page' }])` in place of a
444
+ back link. Once the record has loaded, call
445
+ `useRecentRecord({ title, to: `/widgets/${id}`, detail: 'Widget' })`
446
+ too, so search lists it before you type.
429
447
  - **The browser tab** reads the record's title once it loads
430
448
  ("Wireless Mouse · <app>"): `EntityView` sets it from `title`, and
431
449
  puts the nav's ("Widgets · <app>") back while loading, on an error
@@ -1015,8 +1033,8 @@ shape (4.85):
1015
1033
  fields share a row, up to three, as wide as their sizes; a long one
1016
1034
  takes one short partner (Series and Number). `<Field solo>` keeps a
1017
1035
  short one alone where a pairing would read wrong. Under 48rem every
1018
- field takes its own row but two dates or two numbers (a date picker of
1019
- your own says so with `kind="date"`). Never a hand-made
1036
+ field takes its own row but two dates or two numbers (`DateField` says
1037
+ so itself; a date picker of your own with `kind="date"`). Never a hand-made
1020
1038
  `sm:grid-cols-2` row.
1021
1039
  - **Order:** required first, the status next, long text last.
1022
1040
  - **Required:** `<FieldLabel required>` (an asterisk, and `aria-required`
@@ -1030,6 +1048,17 @@ shape (4.85):
1030
1048
  "Enter a full address, starting https://", never "Title is required".
1031
1049
  - **A status** is an `OptionSelect` with the same `render` (its badge) as
1032
1050
  its cell and the record: `inPlace.select`'s `{ value, label }` options.
1051
+ - **The controls** (4.88): a choice of two to four short options is
1052
+ `ChoiceButtons` (`inPlace.choice` in place), five or more an
1053
+ `OptionSelect`. A date is `DateField`, typed ("3/14", "Mar 14",
1054
+ "today") with the calendar on its button. A single reference is
1055
+ `ReferenceCombobox` (`inPlace.reference` in place), several are
1056
+ `MultiReference`, and a set the app loads whole (tags, a few dozen
1057
+ records from its list query) is `MultiPick`, whose chips wrap and which
1058
+ shows 30 before "Show all". Where a missing record stops the form, give
1059
+ the reference `onCreate(name)`: open the other entity's `FormDialog`
1060
+ with the name filled in, and resolve with the record it saves (or
1061
+ `null` on Cancel).
1033
1062
  - **Cards** (`<FormSection title>`) only on a form of eight fields or
1034
1063
  more, never in a dialog; a short form is one run of fields. Sub-record
1035
1064
  editors (`ListEditor`) sit in a card of their own.
@@ -26,22 +26,22 @@
26
26
  - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 618–701
27
27
  - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 703–738
28
28
  - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 740–813
29
- - [18. Editable value](#18-editable-value) · lines 815–1458
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1100–1158
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1160–1196
32
- - [A link and its label](#a-link-and-its-label) · lines 1198–1222
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1224–1357
34
- - [In a table's rows](#in-a-tables-rows) · lines 1359–1444
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1446–1458
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1460–1526
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1528–1592
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1594–1692
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1694–1723
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1725–1763
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1765–1841
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1843–1866
43
- - [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 1868–1954
44
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1956–1992
29
+ - [18. Editable value](#18-editable-value) · lines 815–1483
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1115–1183
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1185–1221
32
+ - [A link and its label](#a-link-and-its-label) · lines 1223–1247
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1249–1382
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1384–1469
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1471–1483
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1485–1551
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1553–1617
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1619–1717
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1719–1748
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1750–1788
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1790–1866
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1868–1891
43
+ - [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 1893–1979
44
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1981–2017
45
45
 
46
46
  <!-- /index -->
47
47
 
@@ -845,6 +845,16 @@ touch screen the pencil always shows. A click anywhere on the value opens it, ex
845
845
  link inside it (a reference to a record with a view, a link in the
846
846
  notes), which still navigates.
847
847
 
848
+ **In a field list, the row is the target** (4.88, `look="row"`, which
849
+ EntityView's field rows use). The row wears the list's row hover, the
850
+ `--table-hover` tint and the 3px `--primary` bar at its start, as a
851
+ DataTable row does, with its label readable on it and the pencil at its
852
+ end; a click anywhere on the row (its label too) opens the value. Under
853
+ 48rem or on a touch screen there's no pencil but a chevron, and the row
854
+ is 44px tall at least; the control still opens in the row. The header's
855
+ strip and the title keep the value-sized tint above. A field list of the
856
+ app's own gets the same with `editRowClass` and `onEditRowClick` on its row.
857
+
848
858
  **Open: the form's control, nothing else.** The same labels, choices and
849
859
  pickers as `EntityForm`; the field's label is its accessible name. No
850
860
  Save button, no Undo:
@@ -868,9 +878,13 @@ multi field whose options are few (up to about 25) and all loaded (a
868
878
  dozen labels, a short tag list) uses `MultiPick` instead, on the form
869
879
  and in place: every option a toggle chip with its icon or colour where
870
880
  the app draws one (`icon`), the picked ones pressed with a check, and a
871
- filter box above them, not in front of them. Larger sets, or ones that
872
- grow with the data, keep `MultiReference` (typing searches the server)
873
- or `MultiChoice`.
881
+ filter box above them, not in front of them. The chips wrap at every
882
+ width (4.88); past 30 options (`limit`) it shows the picked ones and the
883
+ first 30, then "Show all N", and a filter searches them all. The options
884
+ can be the app's list of records (its query's rows as `{ id, label }`,
885
+ `loading` meanwhile), so links to a few dozen other records use it too.
886
+ Larger sets, or ones that grow with the data, keep `MultiReference`
887
+ (typing searches the server) or `MultiChoice`.
874
888
 
875
889
  - **The plan says which**, by marking the field `small`; the control
876
890
  isn't switched by option count. The two save differently in place
@@ -924,7 +938,8 @@ open.
924
938
 
925
939
  **Saving: still open, read-only, and says so.** Under the control,
926
940
  "Saving…" with a spinner (`role="status"`) until the server agrees, then
927
- it closes on the saved value. **Not optimistic**: the value only shows as
941
+ it closes on the saved value, with "✓ Saved" beside it for two seconds
942
+ (4.88, `role="status"`). **Not optimistic**: the value only shows as
928
943
  saved once it is, and the view shows the record the server returned (a
929
944
  side effect included). The rest of the page stays usable.
930
945
 
@@ -1115,11 +1130,13 @@ fields: [
1115
1130
  { label: 'Budget', edit: inPlace.money({ value: project.budget, save: (budget) => save({ budget }) }) },
1116
1131
  { label: 'Due', edit: inPlace.date({ value: project.due, required: true, save: (due) => save({ due }) }) },
1117
1132
  { label: 'Renews on', edit: inPlace.monthDay({ value: project.renewsOn, save: (renewsOn) => save({ renewsOn }) }) },
1133
+ { label: 'Format', edit: inPlace.choice({ value: project.format, options: FORMAT_OPTIONS, save: (format) => save({ format }) }) },
1118
1134
  { label: 'Priority', edit: inPlace.select({ value: project.priority, options: PRIORITY_OPTIONS,
1119
1135
  render: (priority, label) => <Badge variant={PRIORITY_BADGE[priority]}>{label}</Badge>,
1120
1136
  save: (priority) => save({ priority }) }) },
1121
1137
  { label: 'Category', edit: inPlace.reference({ value: project.categoryId, label: categoryName,
1122
- search: (text) => searchCategories(text), save: (categoryId) => save({ categoryId }) }) },
1138
+ search: (text) => searchCategories(text), onCreate: (name) => openNewCategory(name),
1139
+ save: (categoryId) => save({ categoryId }) }) },
1123
1140
  ]
1124
1141
  // The title: <EntityView titleEdit={{ label: 'Name', ...inPlace.text({ value: project.name, required: true, save: … }) }} />
1125
1142
  // A badge: <EditableValue label="Priority" edit={priority} layout="inline" /> (its children default to the preset's look)
@@ -1136,20 +1153,28 @@ fields: [
1136
1153
  | `text` | the text | it trimmed; blank is `null` | blank when `required`, past `maxLength` |
1137
1154
  | `number` | `1,234 h` (`unit`) | a number; blank is `null` | not a number, under `min`, over `max`, a fraction with `integer` |
1138
1155
  | `money` | `$1,234.56` (`currency`, `locale`) | the API's decimal string, two places (`"1234.50"`), built from the digits, never a float; `$` and commas typed are fine | a third decimal, words, under `min` (0 by default), over `max` |
1139
- | `date` | `Sep 2, 2026` | `'YYYY-MM-DD'`; Clear is `null` | Clear when `required` |
1156
+ | `date` | `Sep 2, 2026` | `'YYYY-MM-DD'`, typed ("3/14", "Mar 14", "today") or picked; an empty box or Clear is `null` | empty when `required`; what it can't read ("Try a date like 3/14 or Mar 14", nothing sent) |
1140
1157
  | `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") |
1141
1158
  | `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` |
1159
+ | `choice` | as `select` | as `select`, drawn as ChoiceButtons (two to four short options); pressing the picked one again is `null` | as `select` |
1142
1160
  | `reference` | the record's `label` (the view's lookup by id) | the picked record's id | "Not set" isn't offered when `required` |
1143
1161
 
1144
1162
  - **They save the way their kind does** (the table above): `text`,
1145
- `number` and `money` on Enter or leaving them, `date`, `monthDay`,
1146
- `select` and `reference` on the pick (the list opens with the field).
1163
+ `number`, `money` and a typed `date` on Enter or leaving them, a day
1164
+ picked in the date's calendar, `monthDay`, `select`, `choice` and
1165
+ `reference` on the pick (a list opens with the field).
1147
1166
  `required: true` types the save without `null`.
1148
1167
  - **`reference` searches through the app.** The package knows no
1149
1168
  endpoint: `search(text)` is the app's (its gateway's search by name,
1150
1169
  `''` when the list opens), called a pause after typing stops; a
1151
1170
  rejection reads as nothing found. Names come from the searches and from
1152
1171
  `label`, so the saved record's name shows before any search answers.
1172
+ With `onCreate(name)`, Create "name" ends the list when what's typed
1173
+ names no record: the app opens the other entity's `FormDialog` with the
1174
+ name filled in and resolves with the record it saves (`null` on
1175
+ Cancel); the field stays open meanwhile and saves the new record's id.
1176
+ The form's control is the same `ReferenceCombobox`; `MultiReference`
1177
+ takes the same `onCreate`.
1153
1178
  - **Keep the app's own control when it has one.** A field whose control
1154
1179
  is the form's own (a rich-text editor, a multi picker, an icon select,
1155
1180
  anything in `<entity>-fields.tsx` beyond a plain box) stays
@@ -33,7 +33,7 @@
33
33
  - [Picking at random](#picking-at-random) · lines 1357–1388
34
34
  - [Filling in what's missing](#filling-in-whats-missing) · lines 1390–1457
35
35
  - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1459–1484
36
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1486–1532
36
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1486–1559
37
37
 
38
38
  <!-- /index -->
39
39
 
@@ -1486,8 +1486,10 @@ both themes and every palette.
1486
1486
  ## The sidebar and the phone's bar
1487
1487
 
1488
1488
  `AppShell`'s navigation (4.80), all set in the app's `nav` and
1489
- `bottomBar`; an app that sets none of it looks as it did, except the
1490
- current entry's bar and the phone's back arrow, which every app gets.
1489
+ `bottomBar`, and (4.87) the trail and search in the bar; an app that
1490
+ sets none of it looks as it did, except the current entry's bar, the
1491
+ phone's back arrow and the nav entry's name in the bar, which every app
1492
+ gets.
1491
1493
 
1492
1494
  ```tsx
1493
1495
  const nav: NavEntry[] = [
@@ -1530,3 +1532,28 @@ const bottomBar: BottomBarItem[] = [
1530
1532
  one tile per entry, the icon in `--link` over the label, bordered,
1531
1533
  44px tall at least; the tile holding the page has a `--primary`
1532
1534
  border. The entries' own pages are left to the module.
1535
+ - **The trail in the bar** (`usePageTrail`, `EntityView`'s
1536
+ `back.trail`): between the menu button and the search box, from 48rem
1537
+ up, `PageTrail` at 14px: every crumb but the last a
1538
+ link in the muted text tone, the page itself in the foreground, a `›`
1539
+ between them, the middle folded into "…" when it doesn't fit. A page
1540
+ that names none shows its nav entry's ("Finance › Accounts" for one of
1541
+ Finance's pages, "Home" on the hub). On a phone the trail is hidden and
1542
+ the back arrow goes to its closest crumb above the page that links.
1543
+ It replaces a page's own back link; the bar sits outside `<main>`, so
1544
+ the page's links are still the only ones in it.
1545
+ - **Search in the bar** (`search={{ placeholder, findRecords, recent }}`):
1546
+ a box from 48rem up, 14rem wide (16rem from 64rem), bordered in
1547
+ `--input` on the page's background, the placeholder in the muted
1548
+ tone and the shortcut (Ctrl K, ⌘K on a Mac) in a `kbd` at its end; a
1549
+ search button on a phone. Both, and the shortcut, open a palette: a
1550
+ dialog 32rem wide at 12% from the top, the field over a list of
1551
+ options under caption headings in the muted tone. Before typing:
1552
+ Recent (the records opened lately on this device, `useRecentRecord`),
1553
+ then the nav's first pages. Typing: Pages (a module's own named
1554
+ "Finance · Accounts", the closest name first), then the app's records
1555
+ under their `kind`, a `detail` in the caption size at the end. The
1556
+ highlighted option has `bg-muted`, its detail in the foreground; a
1557
+ spinner while records are found, "Couldn't search records" (the pages
1558
+ still listed) when the search fails, "Nothing found for …" when
1559
+ nothing matches.
@@ -135,6 +135,30 @@ export declare function navBackTarget(nav: readonly NavEntry[], pathname: string
135
135
  label: string;
136
136
  to: string;
137
137
  } | undefined;
138
+ /**
139
+ * The bar's trail for a page that names none of its own (#N5): the active
140
+ * entry, after the entry it sits under when it's one of a module's own
141
+ * pages ("Finance / Accounts"). The entry is the trail's last crumb even
142
+ * on a page below it. Nothing on a page no entry covers.
143
+ */
144
+ export declare function navTrail(nav: readonly NavEntry[], pathname: string): {
145
+ label: string;
146
+ href?: string;
147
+ }[];
148
+ /**
149
+ * Where a phone's back arrow goes once a page has put up a trail of its
150
+ * own (`usePageTrail`): the closest crumb above the page that links
151
+ * somewhere, on a page below a nav entry (or one no entry covers), and
152
+ * otherwise the entry (`navBackTarget`). An entry's own page keeps the
153
+ * menu button, whatever its trail.
154
+ */
155
+ export declare function trailBackTarget(nav: readonly NavEntry[], pathname: string, trail: readonly {
156
+ label: string;
157
+ href?: string;
158
+ }[] | null): {
159
+ label: string;
160
+ to: string;
161
+ } | undefined;
138
162
  /**
139
163
  * One item of `AppShell`'s `bottomBar`, the phone's bar of shortcuts: a
140
164
  * page, or one of the nav's sections by its label, which opens a sheet of
@@ -133,6 +133,36 @@ export function navBackTarget(nav, pathname) {
133
133
  const trimmed = pathname.length > 1 ? pathname.replace(/\/+$/, '') : pathname;
134
134
  return trimmed === path ? undefined : { label: item.label, to: item.to };
135
135
  }
136
+ /**
137
+ * The bar's trail for a page that names none of its own (#N5): the active
138
+ * entry, after the entry it sits under when it's one of a module's own
139
+ * pages ("Finance / Accounts"). The entry is the trail's last crumb even
140
+ * on a page below it. Nothing on a page no entry covers.
141
+ */
142
+ export function navTrail(nav, pathname) {
143
+ const item = activeNavItem(nav, pathname);
144
+ if (!item)
145
+ return [];
146
+ const parent = navItems(nav).find((other) => childItems(other).includes(item));
147
+ return parent ? [{ label: parent.label, href: parent.to }, { label: item.label }] : [{ label: item.label }];
148
+ }
149
+ /**
150
+ * Where a phone's back arrow goes once a page has put up a trail of its
151
+ * own (`usePageTrail`): the closest crumb above the page that links
152
+ * somewhere, on a page below a nav entry (or one no entry covers), and
153
+ * otherwise the entry (`navBackTarget`). An entry's own page keeps the
154
+ * menu button, whatever its trail.
155
+ */
156
+ export function trailBackTarget(nav, pathname, trail) {
157
+ const fromNav = navBackTarget(nav, pathname);
158
+ if (!fromNav && activeNavItem(nav, pathname))
159
+ return undefined;
160
+ const above = trail
161
+ ?.slice(0, -1)
162
+ .reverse()
163
+ .find((crumb) => crumb.href);
164
+ return above?.href ? { label: above.label, to: above.href } : fromNav;
165
+ }
136
166
  /** The nav's section with this label, if there is one. */
137
167
  export function bottomBarSection(nav, label) {
138
168
  return nav.find((entry) => isNavSection(entry) && entry.label === label);
@@ -1,9 +1,11 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type BottomBarItem, type NavEntry } from './app-shell-nav.js';
3
3
  import { type AppShellVersion } from './app-shell-version.js';
4
+ import { type AppShellSearch } from './search-palette.js';
4
5
  import type { IconComponent } from './icon-component.js';
5
6
  export type { BottomBarItem, NavChild, NavEntry, NavItem, NavItemGroup, NavSection } from './app-shell-nav.js';
6
7
  export type { AppShellVersion } from './app-shell-version.js';
8
+ export type { AppShellSearch, RecentRecord, SearchRecord } from './search-palette.js';
7
9
  export type AppShellProps = {
8
10
  /**
9
11
  * Shown at the top of the sidebar (hidden on the collapsed icon rail), and
@@ -70,5 +72,14 @@ export type AppShellProps = {
70
72
  * takes its place. The shell pads its content so nothing sits under the bar.
71
73
  */
72
74
  bottomBar?: readonly BottomBarItem[];
75
+ /**
76
+ * Search in the header (#N6): a box ("Search", or `placeholder`) from
77
+ * md up and a button on a phone, both opening a palette (Ctrl K, ⌘K on
78
+ * a Mac) that finds the nav's pages by name and, with `findRecords`,
79
+ * the app's records, listed under their kinds; Enter opens the one
80
+ * highlighted. Before you type it lists the records opened lately
81
+ * (`useRecentRecord`), `recent` of them. No search, no box.
82
+ */
83
+ search?: AppShellSearch;
73
84
  };
74
- export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, }: AppShellProps): import("react").JSX.Element;
85
+ export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, search, }: AppShellProps): import("react").JSX.Element;
@@ -1,18 +1,22 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ChevronLeftIcon, ChevronRightIcon, LogOutIcon, MoonIcon, PaletteIcon, Rows3Icon, SunIcon } from 'lucide-react';
3
3
  import { useTheme } from 'next-themes';
4
- import { useEffect, useId, useState } from 'react';
4
+ import { useCallback, useEffect, useId, useMemo, useState } from 'react';
5
5
  import { Link, Navigate, Outlet, useLocation } from 'react-router';
6
6
  import { useAuth } from '../../auth/use-auth.js';
7
7
  import { BottomBar, BOTTOM_BAR_PADDING } from './app-shell-bottom-bar.js';
8
- import { activeNavTo, childItems, childrenOpen, isNavItemGroup, navBackTarget, navGroups, navPageLabel, navTooltip, withChildren, } from './app-shell-nav.js';
8
+ import { activeNavTo, childItems, childrenOpen, isNavItemGroup, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
9
9
  import { versionHref, versionLabel } from './app-shell-version.js';
10
10
  import { ErrorState } from './error-state.js';
11
+ import { PageTrail } from './page-trail.js';
12
+ import { PageTrailContext } from './page-trail-context.js';
13
+ import { SearchPalette } from './search-palette.js';
11
14
  import { useErrorReporter } from '../../error-reporting/error-reporting-context.js';
12
15
  import { ReportRoutePattern } from '../../error-reporting/error-reporting-provider.js';
13
16
  import { useShellDocumentTitle } from '../../hooks/use-document-title.js';
14
17
  import { usePalette } from '../../hooks/use-palette.js';
15
18
  import { useRows } from '../../hooks/use-rows.js';
19
+ import { clearRecentRecords } from '../../lib/search-palette.js';
16
20
  import { isPaletteName, PALETTE_LABELS, PALETTES } from '../../lib/palettes.js';
17
21
  import { isRowsName, ROWS, ROWS_LABELS } from '../../lib/rows.js';
18
22
  import { cn } from 'cn';
@@ -185,7 +189,7 @@ function PhoneBack({ back }) {
185
189
  function AppShellSkeleton() {
186
190
  return (_jsxs("div", { className: "flex h-screen w-full gap-4 p-4", "data-state": "loading", children: [_jsx(Skeleton, { className: "h-full w-56 shrink-0" }), _jsxs("div", { className: "flex-1 space-y-4 pt-2", children: [_jsx(Skeleton, { className: "h-8 w-64" }), _jsx(Skeleton, { className: "h-40 w-full" })] })] }));
187
191
  }
188
- export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, }) {
192
+ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, search, }) {
189
193
  const { user, status, error, retry, logout } = useAuth();
190
194
  const location = useLocation();
191
195
  const reporter = useErrorReporter();
@@ -195,6 +199,11 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
195
199
  // component then renders starts a second navigation that wins.
196
200
  const [isLoggingOut, setIsLoggingOut] = useState(false);
197
201
  useShellDocumentTitle(title, navPageLabel(nav, location.pathname));
202
+ // The trail a page put up (usePageTrail, #N5), for the bar.
203
+ const [pageTrail, setPageTrail] = useState(null);
204
+ const set = useCallback((owner, crumbs) => setPageTrail({ owner, crumbs }), []);
205
+ const clear = useCallback((owner) => setPageTrail((current) => (current?.owner === owner ? null : current)), []);
206
+ const trailSlot = useMemo(() => ({ set, clear }), [set, clear]);
198
207
  if (status === 'loading') {
199
208
  return _jsx(AppShellSkeleton, {});
200
209
  }
@@ -215,14 +224,19 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
215
224
  return _jsx(Navigate, { to: "/login", replace: true, state: isLoggingOut ? undefined : { from } });
216
225
  }
217
226
  const activeTo = activeNavTo(nav, location.pathname);
218
- const back = navBackTarget(nav, location.pathname);
227
+ const ownTrail = pageTrail?.crumbs ?? null;
228
+ const back = trailBackTarget(nav, location.pathname, ownTrail);
229
+ const trail = ownTrail ?? navTrail(nav, location.pathname);
219
230
  const groups = navGroups(nav);
220
231
  const renderGroup = (group, groupIndex) => group.collapsible && group.label !== undefined ? (_jsx(CollapsibleNavGroup, { group: { ...group, label: group.label }, activeTo: activeTo }, `${group.placement ?? 'top'}:${groupIndex}:${group.label}`)) : (_jsxs(SidebarGroup, { children: [group.label !== undefined && _jsx(SidebarGroupLabel, { children: group.label }), _jsx(SidebarGroupContent, { children: _jsx(NavMenu, { items: group.items, activeTo: activeTo }) })] }, `${group.placement ?? 'top'}:${groupIndex}:${group.label ?? ''}`));
221
232
  return (_jsxs(TooltipProvider, { children: [reporter && _jsx(ReportRoutePattern, { reporter: reporter }), _jsxs(SidebarProvider, { defaultOpen: storedSidebarOpen(defaultSidebarOpen), children: [_jsx(CloseMobileSidebarOnNavigate, {}), _jsx("nav", { "aria-label": "Primary", children: _jsxs(Sidebar, { collapsible: "icon", children: [_jsx(SidebarHeader, { children: _jsxs("div", { className: "flex items-center gap-2 px-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [Logo && (_jsx(Logo, { "aria-hidden": "true", className: "size-5 shrink-0 text-sidebar-foreground group-data-[collapsible=icon]:size-4" })), _jsx("span", { className: "truncate text-sm font-semibold text-sidebar-foreground group-data-[collapsible=icon]:hidden", children: title })] }) }), _jsxs(SidebarContent, { children: [groups.filter((group) => !group.placement).map(renderGroup), sidebarExtra, groups.some((group) => group.placement) && (_jsx("div", { "data-slot": "nav-foot", className: "mt-auto flex flex-col", children: groups.filter((group) => group.placement).map(renderGroup) }))] }), _jsxs(SidebarFooter, { children: [version && _jsx(VersionEntry, { version: version }), _jsxs("div", { className: "flex items-center justify-between gap-2 px-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [_jsx("span", { className: "truncate type-caption text-sidebar-foreground/70 group-data-[collapsible=icon]:hidden", children: user.name }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Log out", onClick: () => {
222
233
  setIsLoggingOut(true);
234
+ // The records opened lately are this person's: the
235
+ // next to sign in on this device doesn't see them.
236
+ clearRecentRecords();
223
237
  // A failed request still ends the session on screen
224
238
  // (AuthProvider), so this stays a deliberate logout: a
225
239
  // clean /login, never the previous user's page as `from`.
226
240
  logout().catch(() => { });
227
- }, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsxs(SidebarInset, { className: "min-w-0", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && bottomBar?.length && 'max-md:hidden') }), _jsx("div", { className: "flex-1" }), _jsx(LookControl, {})] }), _jsx("div", { className: cn('flex-1 p-6', bottomBar?.length && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) })] }), bottomBar && bottomBar.length > 0 && _jsx(BottomBar, { items: bottomBar, nav: nav, activeTo: activeTo })] }), _jsx(Toaster, { position: "top-center" })] }));
241
+ }, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && bottomBar?.length && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { search: search, nav: nav }), _jsx(LookControl, {})] }), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', bottomBar?.length && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), bottomBar && bottomBar.length > 0 && _jsx(BottomBar, { items: bottomBar, nav: nav, activeTo: activeTo })] }), _jsx(Toaster, { position: "top-center" })] }));
228
242
  }
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from 'react';
2
+ export type ChoiceButtonsOption<T> = {
3
+ value: T;
4
+ label: string;
5
+ };
6
+ export type ChoiceButtonsProps<T extends string | number> = {
7
+ /** The group's id. Name it with `aria-labelledby` (the FieldLabel's id) or `aria-label`. */
8
+ id?: string;
9
+ /** Two to four short options, in the order they read. */
10
+ options: readonly ChoiceButtonsOption<T>[];
11
+ /** The picked one, or `null` for none. */
12
+ value: T | null;
13
+ onValueChange: (value: T | null) => void;
14
+ /** How an option reads on its button. Defaults to its label. */
15
+ render?: (value: T, label: string) => ReactNode;
16
+ /** Pressing the picked one again unpicks it (`null`): an optional field. */
17
+ clearable?: boolean;
18
+ invalid?: boolean;
19
+ disabled?: boolean;
20
+ className?: string;
21
+ 'aria-label'?: string;
22
+ 'aria-labelledby'?: string;
23
+ 'aria-describedby'?: string;
24
+ };
25
+ export declare function ChoiceButtons<T extends string | number>({ id, options, value, onValueChange, render, clearable, invalid, disabled, className, ...aria }: ChoiceButtonsProps<T>): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from 'cn';
3
+ import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group.js';
4
+ export function ChoiceButtons({ id, options, value, onValueChange, render, clearable = false, invalid = false, disabled = false, className, ...aria }) {
5
+ const at = value == null ? -1 : options.findIndex((option) => option.value === value);
6
+ return (_jsx(ToggleGroup, { id: id, "data-slot": "choice-buttons", variant: "outline", spacing: 0, value: at === -1 ? [] : [String(at)], onValueChange: (next) => {
7
+ const key = next[0];
8
+ if (key === undefined) {
9
+ if (clearable)
10
+ onValueChange(null);
11
+ return;
12
+ }
13
+ const option = options[Number(key)];
14
+ if (option && option.value !== value)
15
+ onValueChange(option.value);
16
+ }, disabled: disabled, "aria-invalid": invalid || undefined, className: cn('max-w-full flex-wrap rounded-md aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40', className), ...aria, children: options.map((option, index) => (_jsx(ToggleGroupItem, { value: String(index), className: cn('h-(--control-height,--spacing(8)) px-3 font-normal text-muted-foreground aria-pressed:font-medium aria-pressed:text-foreground', invalid && 'border-destructive'), children: render ? render(option.value, option.label) : option.label }, String(option.value)))) }));
17
+ }
@@ -1,26 +1,45 @@
1
1
  import { type PlainDate } from '../../lib/plain-date.js';
2
2
  export type DateFieldProps = {
3
- /** The trigger button's id, for the field's `<FieldLabel htmlFor>`. */
3
+ /** The box's id (the button's with `typing={false}`), for the field's `<FieldLabel htmlFor>`. */
4
4
  id?: string;
5
5
  /** `'YYYY-MM-DD'`, or `''` for not set. */
6
6
  value: PlainDate;
7
- /** Called with the picked day as `'YYYY-MM-DD'`, or `''` when cleared. */
7
+ /**
8
+ * Called with the day as `'YYYY-MM-DD'`, or `''` when cleared or when
9
+ * what's typed can't be read.
10
+ */
8
11
  onChange: (value: PlainDate) => void;
9
- /** What the button says with no day set. Defaults to "Pick a date". */
12
+ /**
13
+ * A box to type the day in, with the calendar on its button (the
14
+ * default). `false`: the button alone, opening the calendar.
15
+ */
16
+ typing?: boolean;
17
+ /**
18
+ * A day picked in the calendar, when that should do more than a typed
19
+ * one does (editing in place saves it at once). Defaults to `onChange`.
20
+ */
21
+ onPick?: (value: PlainDate) => void;
22
+ /**
23
+ * Told when what's typed can't be read (with its message), and `null`
24
+ * once it can: editing in place gives it to `onProblem`, so the field
25
+ * won't save a day nobody meant.
26
+ */
27
+ onProblem?: (message: string | null) => void;
28
+ /** The empty box's words. Defaults to "3/14 or Mar 14" typed (the locale's order), "Pick a date" on the button. */
10
29
  placeholder?: string;
11
30
  /** Offer Clear in the calendar, for an optional field. */
12
31
  clearable?: boolean;
13
- /** The value was refused: `aria-invalid` on the button. */
32
+ /** The value was refused: `aria-invalid` on the box (or button). */
14
33
  invalid?: boolean;
15
- /** Saving: the button shows the day but won't open. */
34
+ /** Saving: the day shows but can't change. */
16
35
  readOnly?: boolean;
17
- /** Open on mount: editing in place, where the calendar opens with the field. */
36
+ /** Open the calendar on mount (the button's way of editing in place). */
18
37
  defaultOpen?: boolean;
19
38
  /** Passed to the Popover; `false` when editing in place, as for a Select. */
20
39
  modal?: boolean;
21
- /** Told when the calendar opens or closes; editing in place gives up on a close with nothing picked. */
40
+ /** Told when the calendar opens or closes. */
22
41
  onOpenChange?: (open: boolean) => void;
23
- /** How the day is shown on the button. Defaults to `{ dateStyle: 'medium' }`. */
42
+ /** How the day is shown. Defaults to `{ dateStyle: 'medium' }`. */
24
43
  format?: Intl.DateTimeFormatOptions;
25
44
  locale?: string;
26
45
  className?: string;
@@ -28,4 +47,4 @@ export type DateFieldProps = {
28
47
  'aria-labelledby'?: string;
29
48
  'aria-describedby'?: string;
30
49
  };
31
- export declare function DateField({ id, value, onChange, placeholder, clearable, invalid, readOnly, defaultOpen, modal, onOpenChange, format, locale, className, ...aria }: DateFieldProps): import("react").JSX.Element;
50
+ export declare function DateField({ typing, onProblem, ...props }: DateFieldProps): import("react").JSX.Element;