@tristan2828/ui-foundation 4.87.0 → 4.89.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/conventions/docs/add-an-entity.md +38 -23
- package/conventions/docs/cell-patterns.md +49 -24
- package/conventions/docs/design-language.md +97 -31
- package/dist/components/app/choice-buttons.d.ts +25 -0
- package/dist/components/app/choice-buttons.js +17 -0
- package/dist/components/app/date-field.d.ts +28 -9
- package/dist/components/app/date-field.js +103 -10
- package/dist/components/app/edit-in-place-controls.d.ts +1 -3
- package/dist/components/app/edit-in-place-controls.js +4 -58
- package/dist/components/app/edit-in-place-presets.d.ts +38 -4
- package/dist/components/app/edit-in-place-presets.js +48 -27
- package/dist/components/app/edit-row.d.ts +7 -0
- package/dist/components/app/edit-row.js +23 -0
- package/dist/components/app/editable-value.d.ts +8 -1
- package/dist/components/app/editable-value.js +36 -4
- package/dist/components/app/entity-view.js +5 -1
- package/dist/components/app/multi-pick.d.ts +8 -1
- package/dist/components/app/multi-pick.js +19 -5
- package/dist/components/app/multi-reference.d.ts +8 -1
- package/dist/components/app/multi-reference.js +44 -6
- package/dist/components/app/overview-page.d.ts +44 -0
- package/dist/components/app/overview-page.js +63 -0
- package/dist/components/app/reference-combobox.d.ts +37 -0
- package/dist/components/app/reference-combobox.js +96 -0
- package/dist/components/app/widget-card.d.ts +15 -2
- package/dist/components/app/widget-card.js +15 -4
- package/dist/components/ui/field.d.ts +2 -2
- package/dist/components/ui/field.js +2 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/lib/names-record.d.ts +4 -0
- package/dist/lib/names-record.js +7 -0
- package/dist/lib/plain-date.d.ts +20 -0
- package/dist/lib/plain-date.js +72 -0
- 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 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`, `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 module's overview ("An overview page" there): `OverviewPage`, and `WidgetCard`'s `to`, `value`, `line` and `freshness`. 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–
|
|
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–
|
|
14
|
-
- Step 7: Register routes · lines
|
|
15
|
-
- Step 8: Add Playwright specs for all three screens · lines
|
|
16
|
-
- Step 9: Register the nav entry and route names · lines
|
|
17
|
-
- Step 10: `npm run verify`. · lines
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines
|
|
19
|
-
- [The record view](#the-record-view) · lines
|
|
20
|
-
- [Forms](#forms) · lines
|
|
21
|
-
- [Dialogs](#dialogs) · lines
|
|
22
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
23
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
24
|
-
- [Deleting](#deleting) · lines
|
|
25
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
26
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
27
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
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.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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:
|
|
@@ -1029,8 +1033,8 @@ shape (4.85):
|
|
|
1029
1033
|
fields share a row, up to three, as wide as their sizes; a long one
|
|
1030
1034
|
takes one short partner (Series and Number). `<Field solo>` keeps a
|
|
1031
1035
|
short one alone where a pairing would read wrong. Under 48rem every
|
|
1032
|
-
field takes its own row but two dates or two numbers (
|
|
1033
|
-
your own
|
|
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
|
|
1034
1038
|
`sm:grid-cols-2` row.
|
|
1035
1039
|
- **Order:** required first, the status next, long text last.
|
|
1036
1040
|
- **Required:** `<FieldLabel required>` (an asterisk, and `aria-required`
|
|
@@ -1044,6 +1048,17 @@ shape (4.85):
|
|
|
1044
1048
|
"Enter a full address, starting https://", never "Title is required".
|
|
1045
1049
|
- **A status** is an `OptionSelect` with the same `render` (its badge) as
|
|
1046
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).
|
|
1047
1062
|
- **Cards** (`<FormSection title>`) only on a form of eight fields or
|
|
1048
1063
|
more, never in a dialog; a short form is one run of fields. Sub-record
|
|
1049
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–
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
41
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
42
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
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
|
|
44
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
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.
|
|
872
|
-
|
|
873
|
-
|
|
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
|
|
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),
|
|
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'
|
|
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 `
|
|
1146
|
-
|
|
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
|
|
@@ -3,37 +3,38 @@
|
|
|
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
|
-
- [Palettes](#palettes) · lines
|
|
7
|
-
- [Glow](#glow) · lines
|
|
8
|
-
- [Semantic tones](#semantic-tones) · lines
|
|
9
|
-
- [The three badge styles](#the-three-badge-styles) · lines
|
|
10
|
-
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines
|
|
11
|
-
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines
|
|
12
|
-
- [Logos and brand marks](#logos-and-brand-marks) · lines
|
|
13
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
14
|
-
- [Heat scale](#heat-scale) · lines
|
|
15
|
-
- [Depth ramps](#depth-ramps) · lines
|
|
16
|
-
- [A stored colour](#a-stored-colour) · lines
|
|
17
|
-
- [Shapes and sizes](#shapes-and-sizes) · lines
|
|
18
|
-
- [Typography](#typography) · lines
|
|
19
|
-
- [Written text (notes)](#written-text-notes) · lines
|
|
20
|
-
- [Density](#density) · lines
|
|
21
|
-
- [Rows on this device](#rows-on-this-device) · lines
|
|
22
|
-
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines
|
|
23
|
-
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines
|
|
24
|
-
- [Notices](#notices) · lines
|
|
25
|
-
- [A value over time](#a-value-over-time) · lines
|
|
26
|
-
- [Several values over time](#several-values-over-time) · lines
|
|
27
|
-
- [A list as a board](#a-list-as-a-board) · lines
|
|
28
|
-
- [A list as cards](#a-list-as-cards) · lines
|
|
29
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines
|
|
30
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
31
|
-
- [
|
|
32
|
-
- [A record's
|
|
33
|
-
- [
|
|
34
|
-
- [
|
|
35
|
-
- [
|
|
36
|
-
- [
|
|
6
|
+
- [Palettes](#palettes) · lines 47–114
|
|
7
|
+
- [Glow](#glow) · lines 116–134
|
|
8
|
+
- [Semantic tones](#semantic-tones) · lines 136–164
|
|
9
|
+
- [The three badge styles](#the-three-badge-styles) · lines 166–183
|
|
10
|
+
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 185–214
|
|
11
|
+
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 216–229
|
|
12
|
+
- [Logos and brand marks](#logos-and-brand-marks) · lines 231–275
|
|
13
|
+
- [Categorical colour](#categorical-colour) · lines 277–347
|
|
14
|
+
- [Heat scale](#heat-scale) · lines 349–410
|
|
15
|
+
- [Depth ramps](#depth-ramps) · lines 412–490
|
|
16
|
+
- [A stored colour](#a-stored-colour) · lines 492–540
|
|
17
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 542–563
|
|
18
|
+
- [Typography](#typography) · lines 565–685
|
|
19
|
+
- [Written text (notes)](#written-text-notes) · lines 599–685
|
|
20
|
+
- [Density](#density) · lines 687–780
|
|
21
|
+
- [Rows on this device](#rows-on-this-device) · lines 753–780
|
|
22
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 782–896
|
|
23
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 898–975
|
|
24
|
+
- [Notices](#notices) · lines 977–1005
|
|
25
|
+
- [A value over time](#a-value-over-time) · lines 1007–1093
|
|
26
|
+
- [Several values over time](#several-values-over-time) · lines 1056–1093
|
|
27
|
+
- [A list as a board](#a-list-as-a-board) · lines 1095–1146
|
|
28
|
+
- [A list as cards](#a-list-as-cards) · lines 1148–1194
|
|
29
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1196–1225
|
|
30
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1227–1270
|
|
31
|
+
- [An overview page](#an-overview-page) · lines 1272–1335
|
|
32
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1336–1374
|
|
33
|
+
- [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1376–1421
|
|
34
|
+
- [Picking at random](#picking-at-random) · lines 1423–1454
|
|
35
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1456–1523
|
|
36
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1525–1550
|
|
37
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1552–1625
|
|
37
38
|
|
|
38
39
|
<!-- /index -->
|
|
39
40
|
|
|
@@ -1267,6 +1268,71 @@ into a table, a record or an overview.
|
|
|
1267
1268
|
Every one is measured with axe and the glyph check in both themes
|
|
1268
1269
|
(fixtures `app/ValueList`, `ListHeader`, `Timeline`, `NeedsYou`,
|
|
1269
1270
|
`Freshness`, `PartEmpty`).
|
|
1271
|
+
|
|
1272
|
+
## An overview page
|
|
1273
|
+
|
|
1274
|
+
The overview standard (4.89): a module's first page when it has three
|
|
1275
|
+
or more lists, saying how things stand and what waits on the user, each
|
|
1276
|
+
part one click from its list. `OverviewPage` draws the whole page; the
|
|
1277
|
+
hub's `WidgetCard`s take the same card anatomy, so a hub and an overview
|
|
1278
|
+
read alike.
|
|
1279
|
+
|
|
1280
|
+
```tsx
|
|
1281
|
+
<OverviewPage
|
|
1282
|
+
title="Household"
|
|
1283
|
+
stats={<KeyStats stats={[{ label: 'Savings', value: '$24,800', icon: LandmarkIcon }]} />}
|
|
1284
|
+
needs={[{ text: 'Balances are three months old', to: '/accounts' }]}
|
|
1285
|
+
parts={[
|
|
1286
|
+
{
|
|
1287
|
+
id: 'savings',
|
|
1288
|
+
title: 'Savings',
|
|
1289
|
+
icon: LandmarkIcon,
|
|
1290
|
+
to: '/accounts',
|
|
1291
|
+
value: '$24,800',
|
|
1292
|
+
line: '+$1,120 since August',
|
|
1293
|
+
freshness: { label: 'Balances entered', at: entered, staleAfter: addDays(entered, 90) },
|
|
1294
|
+
detail: <WidgetList>…</WidgetList>,
|
|
1295
|
+
isLoading,
|
|
1296
|
+
error,
|
|
1297
|
+
onRetry: refetch,
|
|
1298
|
+
},
|
|
1299
|
+
{ id: 'budget', title: 'Budget', icon: WalletIcon, to: '/budget',
|
|
1300
|
+
empty: { action: { label: 'Add the first line', to: '/budget/new' } } },
|
|
1301
|
+
]}
|
|
1302
|
+
/>
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
- **The top:** the title (the page's h1, `actions` at its end), then
|
|
1306
|
+
`stats` (a `KeyStats` strip of three to five numbers), then `NeedsYou`
|
|
1307
|
+
from `needs`, which draws nothing when nothing waits. Collect `needs`
|
|
1308
|
+
from what each part says about itself.
|
|
1309
|
+
- **From 48rem up, tiles.** One per part, at least 170px, as many as fit:
|
|
1310
|
+
the icon and title, `value` in the numeric type, and `freshness`. A
|
|
1311
|
+
tile is a button (`aria-expanded`, `aria-controls` the detail); a click
|
|
1312
|
+
opens its part's detail below the grid, one at a time, and a second
|
|
1313
|
+
click or Escape inside the detail closes it, focus back on the tile.
|
|
1314
|
+
`defaultOpen` names a part open at first.
|
|
1315
|
+
- **The detail is a `WidgetCard`:** the title as a link to `to` with a
|
|
1316
|
+
chevron, `value`, `line`, the app's `detail` (a few `WidgetList` rows,
|
|
1317
|
+
a small `LineChart`) and `freshness`.
|
|
1318
|
+
- **Under 48rem, an accordion.** The same cards in a `WidgetCardGroup`,
|
|
1319
|
+
each folded to one line with its value; opening one folds the others.
|
|
1320
|
+
- **Each part owns its states:** `isLoading` (a skeleton in the tile and
|
|
1321
|
+
the card), `error` with `onRetry` (a dash in the tile, the compact
|
|
1322
|
+
`ErrorState` in the card), and `empty` (a part with nothing yet: "Nothing
|
|
1323
|
+
yet" in the tile, `PartEmpty` and its one way to start in the card). An
|
|
1324
|
+
empty part stays on the page: hiding it makes the part forgotten.
|
|
1325
|
+
- **One card anatomy on a hub** (`WidgetCard`): `to` makes the title the
|
|
1326
|
+
link with a chevron (in place of the header's `link`), `value` the
|
|
1327
|
+
headline in the numeric type, `line` one muted line under it, and
|
|
1328
|
+
`freshness` the `Freshness` line at the body's end, after the
|
|
1329
|
+
children. A folded card shows `value` when it has no `summary`. All
|
|
1330
|
+
optional: a card without them is drawn as before, and its folding on a
|
|
1331
|
+
phone is unchanged.
|
|
1332
|
+
|
|
1333
|
+
Measured with axe and the glyph check in both themes and every palette
|
|
1334
|
+
(fixture `app/OverviewPage`); `e2e/overview-page.spec.ts` clicks the
|
|
1335
|
+
tiles, Escape and the accordion.
|
|
1270
1336
|
## A record's header and empty values
|
|
1271
1337
|
|
|
1272
1338
|
The record page standard (4.81): the same header on every record, the
|
|
@@ -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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
34
|
+
/** Saving: the day shows but can't change. */
|
|
16
35
|
readOnly?: boolean;
|
|
17
|
-
/** Open on mount
|
|
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
|
|
40
|
+
/** Told when the calendar opens or closes. */
|
|
22
41
|
onOpenChange?: (open: boolean) => void;
|
|
23
|
-
/** How the day is shown
|
|
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({
|
|
50
|
+
export declare function DateField({ typing, onProblem, ...props }: DateFieldProps): import("react").JSX.Element;
|