@tristan2828/ui-foundation 4.85.0 → 4.87.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 +34 -17
- package/conventions/docs/cell-patterns.md +165 -37
- package/conventions/docs/design-language.md +30 -3
- package/dist/components/app/app-shell-nav.d.ts +24 -0
- package/dist/components/app/app-shell-nav.js +30 -0
- package/dist/components/app/app-shell.d.ts +12 -1
- package/dist/components/app/app-shell.js +19 -5
- package/dist/components/app/data-table-tools.d.ts +98 -0
- package/dist/components/app/data-table-tools.js +59 -0
- package/dist/components/app/data-table.d.ts +60 -2
- package/dist/components/app/data-table.js +97 -20
- package/dist/components/app/entity-view.d.ts +11 -1
- package/dist/components/app/entity-view.js +14 -1
- package/dist/components/app/filter-bar.d.ts +55 -0
- package/dist/components/app/filter-bar.js +28 -0
- package/dist/components/app/multi-choice.d.ts +9 -1
- package/dist/components/app/multi-choice.js +3 -3
- package/dist/components/app/page-trail-context.d.ts +18 -0
- package/dist/components/app/page-trail-context.js +28 -0
- package/dist/components/app/page-trail.d.ts +1 -1
- package/dist/components/app/page-trail.js +1 -1
- package/dist/components/app/pill-filter.d.ts +3 -1
- package/dist/components/app/pill-filter.js +3 -2
- package/dist/components/app/related-table.d.ts +11 -0
- package/dist/components/app/related-table.js +28 -0
- package/dist/components/app/search-palette.d.ts +29 -0
- package/dist/components/app/search-palette.js +160 -0
- package/dist/components/app/secondary-filters.d.ts +3 -1
- package/dist/components/app/secondary-filters.js +5 -4
- package/dist/components/app/table-columns.d.ts +15 -0
- package/dist/components/app/table-columns.js +50 -0
- package/dist/hooks/table-url-changes.d.ts +2 -0
- package/dist/hooks/use-columns-pick.d.ts +3 -0
- package/dist/hooks/use-columns-pick.js +18 -0
- package/dist/hooks/use-is-phone.d.ts +1 -0
- package/dist/hooks/use-is-phone.js +18 -0
- package/dist/hooks/use-recent-record.d.ts +10 -0
- package/dist/hooks/use-recent-record.js +20 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -0
- package/dist/lib/search-palette.d.ts +50 -0
- package/dist/lib/search-palette.js +119 -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 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`, `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 |
|
|
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–826
|
|
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–713
|
|
14
|
+
- Step 7: Register routes · lines 714–729
|
|
15
|
+
- Step 8: Add Playwright specs for all three screens · lines 730–808
|
|
16
|
+
- Step 9: Register the nav entry and route names · lines 809–823
|
|
17
|
+
- Step 10: `npm run verify`. · lines 824–826
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 828–1086
|
|
19
|
+
- [The record view](#the-record-view) · lines 977–1016
|
|
20
|
+
- [Forms](#forms) · lines 1018–1059
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1061–1086
|
|
22
|
+
- [What not to copy](#what-not-to-copy) · lines 1088–1114
|
|
23
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1116–1133
|
|
24
|
+
- [Deleting](#deleting) · lines 1135–1164
|
|
25
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1166–1187
|
|
26
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1189–1198
|
|
27
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1201–1240
|
|
28
28
|
|
|
29
29
|
<!-- /index -->
|
|
30
30
|
|
|
@@ -377,7 +377,10 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
377
377
|
`<SecondaryFilters>`, as the template does with Extra Categories,
|
|
378
378
|
Progress and In Stock. Pass it each filter that's on as an
|
|
379
379
|
`ActiveFilter` (its chip text and how to take it off) and an
|
|
380
|
-
`onClear` that clears them all in one `setFilters` call.
|
|
380
|
+
`onClear` that clears them all in one `setFilters` call. A list on
|
|
381
|
+
the list page standard uses `FilterBar` for all of it, with
|
|
382
|
+
`views`, `columnsMenu`, `rowActions` and `phoneRow` on the
|
|
383
|
+
DataTable (cell-patterns.md 25).
|
|
381
384
|
- `src/routes/widgets/widget-view.tsx` →
|
|
382
385
|
`src/routes/<entity>/<entity>-view.tsx` — thin consumer of the
|
|
383
386
|
foundation's `<EntityView>`. Swap the title, badges and sections for
|
|
@@ -423,6 +426,20 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
423
426
|
in `actions`, Delete as an `IconAction` (`icon={Trash2Icon}
|
|
424
427
|
label="Delete" tone="destructive"`, the dialog's trigger through
|
|
425
428
|
`render`).
|
|
429
|
+
- **The way back is a trail.** `back={{ to: '/widgets', label:
|
|
430
|
+
'Widgets', trail: [{ label: 'Inventory', href: '/inventory' }, {
|
|
431
|
+
label: 'Widgets', href: '/widgets' }] }}`: the crumbs above the
|
|
432
|
+
record, from the module down to its list; the record's title follows
|
|
433
|
+
them. In `AppShell` it is the trail in the bar ("The sidebar and the
|
|
434
|
+
phone's bar" in design-language.md), and the page has no back link;
|
|
435
|
+
on a phone the header's back arrow goes to the list. Without `trail`
|
|
436
|
+
the view keeps its "← Widgets" link. `to` and `label` are still the
|
|
437
|
+
not-found state's way out. Any other page below a nav entry (a
|
|
438
|
+
record's sub-page, a step of a task) names its trail with
|
|
439
|
+
`usePageTrail([...crumbs, { label: 'This page' }])` in place of a
|
|
440
|
+
back link. Once the record has loaded, call
|
|
441
|
+
`useRecentRecord({ title, to: `/widgets/${id}`, detail: 'Widget' })`
|
|
442
|
+
too, so search lists it before you type.
|
|
426
443
|
- **The browser tab** reads the record's title once it loads
|
|
427
444
|
("Wireless Mouse · <app>"): `EntityView` sets it from `title`, and
|
|
428
445
|
puts the nav's ("Widgets · <app>") back while loading, on an error
|
|
@@ -3,43 +3,45 @@
|
|
|
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 rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines
|
|
7
|
-
- [1. Plain text](#1-plain-text) · lines
|
|
8
|
-
- [2. Icon + label](#2-icon--label) · lines
|
|
9
|
-
- [3. Icon in a badge](#3-icon-in-a-badge) · lines
|
|
10
|
-
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines
|
|
11
|
-
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines
|
|
12
|
-
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines
|
|
13
|
-
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines
|
|
14
|
-
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines
|
|
15
|
-
- [8. Date, relative](#8-date-relative) · lines
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines
|
|
17
|
-
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
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
|
|
6
|
+
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 73–92
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 94–147
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 149–172
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 174–187
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 189–266
|
|
11
|
+
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 214–266
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 268–281
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 283–295
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 297–318
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 320–357
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 359–407
|
|
17
|
+
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 377–407
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 409–459
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 427–459
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 461–501
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 503–533
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 535–571
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 555–571
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 573–590
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 592–701
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 618–701
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 703–738
|
|
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
|
|
43
45
|
|
|
44
46
|
<!-- /index -->
|
|
45
47
|
|
|
@@ -1862,3 +1864,129 @@ import { ColorSwatch } from '@tristan2828/ui-foundation'
|
|
|
1862
1864
|
|
|
1863
1865
|
The package's fixture `app/ColorSwatch` "In a table" renders it; its
|
|
1864
1866
|
checks measure the ring at 3:1 in both themes and every palette.
|
|
1867
|
+
|
|
1868
|
+
## 25. A list's tools: views, filters, columns, row actions, a phone's rows
|
|
1869
|
+
|
|
1870
|
+
The rest of the list page standard (4.86): what sits above a list's rows,
|
|
1871
|
+
at the end of each row, and what a phone gets instead of the table. Each
|
|
1872
|
+
is a prop or a part; leave it out and the list is as before.
|
|
1873
|
+
|
|
1874
|
+
```tsx
|
|
1875
|
+
import { DataTable, FilterBar, FilterSelect, MultiChoice } from '@tristan2828/ui-foundation'
|
|
1876
|
+
|
|
1877
|
+
const VIEWS = {
|
|
1878
|
+
current: { label: 'Current', filters: { status: 'active' } },
|
|
1879
|
+
review: { label: 'To review', filters: { status: 'watch' }, columns: ['name', 'status', 'notes'] },
|
|
1880
|
+
all: { label: 'All' },
|
|
1881
|
+
}
|
|
1882
|
+
const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView, applyView, ... } =
|
|
1883
|
+
useTableUrlState(FILTERS, MULTI, VIEWS)
|
|
1884
|
+
|
|
1885
|
+
<DataTable
|
|
1886
|
+
views={VIEWS} activeView={activeView} onViewChange={applyView}
|
|
1887
|
+
columnsMenu={{ storageKey: 'my-app:plants:columns' }}
|
|
1888
|
+
rowActions={(plant) => [
|
|
1889
|
+
{ label: 'Water', icon: DropletIcon, onSelect: () => water(plant) },
|
|
1890
|
+
{ label: 'Delete', icon: Trash2Icon, tone: 'destructive', onSelect: () => remove(plant) },
|
|
1891
|
+
]}
|
|
1892
|
+
phoneRow={{
|
|
1893
|
+
title: (plant) => plant.name,
|
|
1894
|
+
status: (plant) => <StatusBadge status={plant.status} />,
|
|
1895
|
+
facts: (plant) => [plant.light, `Watered ${plant.watered}`],
|
|
1896
|
+
}}
|
|
1897
|
+
toolbar={
|
|
1898
|
+
<FilterBar
|
|
1899
|
+
search={{ value: filters.search, onChange: (value) => setFilter('search', value), placeholder: 'Search by name' }}
|
|
1900
|
+
primary={<>
|
|
1901
|
+
<FilterSelect label="Status" options={STATUS_OPTIONS} value={filters.status}
|
|
1902
|
+
onValueChange={(value) => setFilter('status', value)} />
|
|
1903
|
+
<MultiChoice label="Rooms" placeholder="Any room" aria-label="Filter by rooms" options={ROOMS}
|
|
1904
|
+
value={multiFilters.rooms} onValueChange={(rooms) => setMultiFilter('rooms', rooms)} />
|
|
1905
|
+
</>}
|
|
1906
|
+
primaryActive={/* the chips of the two, for a phone */}
|
|
1907
|
+
secondary={<>{/* the rest, each a FilterSelect */}</>}
|
|
1908
|
+
active={/* the chips of the rest */}
|
|
1909
|
+
onClear={() => setFilters({ light: '', kind: '' })}
|
|
1910
|
+
onClearAll={() => setFilters({ status: '', light: '', kind: '', rooms: [] })}
|
|
1911
|
+
/>
|
|
1912
|
+
}
|
|
1913
|
+
… />
|
|
1914
|
+
```
|
|
1915
|
+
|
|
1916
|
+
- **Saved views are pills** above the toolbar (L3): useTableUrlState's
|
|
1917
|
+
views, each with its `label`, in order. The view on is pressed; none is
|
|
1918
|
+
once the filters move off every view. Under 48rem they stay on one line
|
|
1919
|
+
that scrolls sideways. Replaces a hand-written row of view buttons; a
|
|
1920
|
+
Deleted view goes in ListHeader's ⋯ menu as Show deleted instead.
|
|
1921
|
+
- **The filters** (L4): `FilterBar` holds search, the two filters used
|
|
1922
|
+
most (`primary`), and the rest behind Filters (`secondary`, with their
|
|
1923
|
+
chips, as `SecondaryFilters` draws them). No captions over controls:
|
|
1924
|
+
each names itself. `FilterSelect` says "Any status" while off and
|
|
1925
|
+
"Status: Active" on; `MultiChoice`'s `label` makes it "Rooms: Hall +1"
|
|
1926
|
+
instead of a chip per pick. Below 48rem search and Filters share a line
|
|
1927
|
+
and every filter, primary ones too, is in Filters' bottom sheet, so pass
|
|
1928
|
+
`primaryActive` (their chips) and an `onClearAll` that clears them all
|
|
1929
|
+
in one `setFilters` call.
|
|
1930
|
+
- **The Columns menu** (L5) sits at the end of the toolbar: a tick for
|
|
1931
|
+
every column but the first (the name) and the actions, remembered on
|
|
1932
|
+
this device under `storageKey` as every column's id in order and the
|
|
1933
|
+
unticked ones, so a column added later shows. Until something is ticked
|
|
1934
|
+
it starts from `visibleColumns`. While a view with `columns` is on, the
|
|
1935
|
+
view's columns show and the ticks can't change. A column whose `header`
|
|
1936
|
+
isn't a string names itself in the menu with `meta.label`. It isn't
|
|
1937
|
+
shown with the phone's row list.
|
|
1938
|
+
- **Row actions** (L9) take a column of their own, pinned to the right
|
|
1939
|
+
edge with its header for screen readers only. One action is its icon,
|
|
1940
|
+
its label the tooltip and accessible name; two or more are a ⋯ menu.
|
|
1941
|
+
A click on them never opens the row. Return `[]` for a row with none.
|
|
1942
|
+
Drop a hand-made Actions column and `pinLastColumn` when moving to it.
|
|
1943
|
+
- **A phone gets a row list** (L11) under 48rem: the `title`, the
|
|
1944
|
+
`status` at the line's end and one muted line of the `facts` that matter
|
|
1945
|
+
(two, usually), between dots. The whole row is the target, 44px at
|
|
1946
|
+
least, and opens as `opens` says: a link to the record, so a long press
|
|
1947
|
+
or a modified click works as a link's does. `title` is plain text (the
|
|
1948
|
+
row is already the link). Row actions sit at the row's end; headings,
|
|
1949
|
+
paging and every state hold. A card layout, when picked, wins.
|
|
1950
|
+
- The fixtures' `app/DataTable tools` ListTools, ListToolsFiltered and
|
|
1951
|
+
OneRowAction stories hold all of it, under axe and the token check in
|
|
1952
|
+
both themes; `e2e/data-table-tools.spec.ts` checks the pills, the stored
|
|
1953
|
+
pick and a view's columns winning, the ⋯ menu, the 44px rows, the
|
|
1954
|
+
phone's line and sheet.
|
|
1955
|
+
|
|
1956
|
+
## 26. A record's related list, capped
|
|
1957
|
+
|
|
1958
|
+
A list of records related to this one, in a section of its view (a
|
|
1959
|
+
provider's visits, a project's tasks): the ten newest, then View all N to
|
|
1960
|
+
the whole list filtered to this record (R8), so a long list doesn't push
|
|
1961
|
+
the rest of the record away. With tabs (EntityView's), each such list
|
|
1962
|
+
counts as a group.
|
|
1963
|
+
|
|
1964
|
+
```tsx
|
|
1965
|
+
import { RelatedTable } from '@tristan2828/ui-foundation'
|
|
1966
|
+
|
|
1967
|
+
const visits = useVisits({ provider: provider.id, sort: 'date:desc', page: 1, pageSize: 10 })
|
|
1968
|
+
<RelatedTable
|
|
1969
|
+
columns={VISIT_COLUMNS}
|
|
1970
|
+
opens={{ kind: 'dialog', to: (visit) => `/health/visits/${visit.id}` }}
|
|
1971
|
+
data={visits.data?.items ?? []}
|
|
1972
|
+
total={visits.data?.total ?? 0}
|
|
1973
|
+
isLoading={visits.isLoading}
|
|
1974
|
+
error={visits.error}
|
|
1975
|
+
onRetry={() => visits.refetch()}
|
|
1976
|
+
emptyTitle="No visits yet"
|
|
1977
|
+
viewAll={{ to: `/health/visits?provider=${provider.id}` }}
|
|
1978
|
+
phoneRow={{ title: (visit) => visit.what, facts: (visit) => [visit.date, visit.kind] }}
|
|
1979
|
+
/>
|
|
1980
|
+
```
|
|
1981
|
+
|
|
1982
|
+
- **`limit`** is 10 unless set; ask the server for that many, newest
|
|
1983
|
+
first. No pagination bar, and the headers aren't sort buttons (View all
|
|
1984
|
+
has the list's own sorting).
|
|
1985
|
+
- **View all** shows only when `total` is over the rows shown, its text
|
|
1986
|
+
"View all 19" unless `viewAll.label` says otherwise. It's a link, so a
|
|
1987
|
+
modified click opens a tab.
|
|
1988
|
+
- **`opens` is required**, as on any list. Everything else a DataTable
|
|
1989
|
+
takes for its rows (`rowActions`, `phoneRow`, `highlightRow`) works.
|
|
1990
|
+
- On a DataTable of your own, `limit` and `viewAll` do the same.
|
|
1991
|
+
- The fixture `app/DataTable tools` Related draws a capped list and a
|
|
1992
|
+
short one with no link; the spec follows View all.
|
|
@@ -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–
|
|
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
|
|
1490
|
-
|
|
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,
|
|
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
|
|
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(
|
|
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,98 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Navigator } from 'react-router';
|
|
3
|
+
import type { IconComponent } from './icon-component.js';
|
|
4
|
+
import { type ColumnsPick } from './table-columns.js';
|
|
5
|
+
/**
|
|
6
|
+
* A saved view as DataTable's `views` reads it: useTableUrlState's
|
|
7
|
+
* TableView, which has these two among its fields.
|
|
8
|
+
*/
|
|
9
|
+
export type DataTableView = {
|
|
10
|
+
/** The pill's word ("Current"); the view's id unless set. */
|
|
11
|
+
label?: string;
|
|
12
|
+
/** The columns this view shows; while it's on they win over the Columns menu. */
|
|
13
|
+
columns?: readonly string[];
|
|
14
|
+
};
|
|
15
|
+
export declare function ViewPills({ views, value, onValueChange, label, }: {
|
|
16
|
+
views: readonly {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
20
|
+
value: string | null;
|
|
21
|
+
onValueChange: (id: string) => void;
|
|
22
|
+
label: string;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
export type DataTableColumnsMenu = {
|
|
25
|
+
/**
|
|
26
|
+
* Where the pick is remembered on this device, one key per list
|
|
27
|
+
* (`"my-app:medications:columns"`).
|
|
28
|
+
*/
|
|
29
|
+
storageKey: string;
|
|
30
|
+
/** The button's text: "Columns" unless set. */
|
|
31
|
+
label?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function ColumnsMenu({ columns, visible, fixed, pick, onPickChange, setByView, label, }: {
|
|
34
|
+
/** Every column the menu can tick, in order, with its name. */
|
|
35
|
+
columns: readonly {
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
}[];
|
|
39
|
+
/** Every column id showing now, ticked or not tickable. */
|
|
40
|
+
visible: readonly string[];
|
|
41
|
+
/** Columns always shown (the name, the actions): never in the menu. */
|
|
42
|
+
fixed: readonly string[];
|
|
43
|
+
pick: ColumnsPick | null;
|
|
44
|
+
onPickChange: (pick: ColumnsPick | null) => void;
|
|
45
|
+
/** A view on that sets its own columns: the ticks show them and can't change. */
|
|
46
|
+
setByView: boolean;
|
|
47
|
+
label?: string;
|
|
48
|
+
}): import("react").JSX.Element;
|
|
49
|
+
/** One of a row's actions (DataTable `rowActions`). */
|
|
50
|
+
export type DataTableRowAction = {
|
|
51
|
+
/** What it does ("Delete"): the menu item's text, or the icon's tooltip and name when it's the only one. */
|
|
52
|
+
label: string;
|
|
53
|
+
/** Drawn alone when it's the row's only action, beside the label in the ⋯ menu. */
|
|
54
|
+
icon?: IconComponent;
|
|
55
|
+
onSelect: () => void;
|
|
56
|
+
/** `destructive` for Delete and the like. */
|
|
57
|
+
tone?: 'default' | 'destructive';
|
|
58
|
+
disabled?: boolean;
|
|
59
|
+
};
|
|
60
|
+
export declare function RowActions({ actions, rowLabel }: {
|
|
61
|
+
actions: readonly DataTableRowAction[];
|
|
62
|
+
rowLabel?: string;
|
|
63
|
+
}): import("react").JSX.Element | null;
|
|
64
|
+
/** What a row shows in the row list a phone gets (DataTable `phoneRow`). */
|
|
65
|
+
export type DataTablePhoneRow<TData> = {
|
|
66
|
+
/** The record's name: plain text, since the whole row is the link or button. */
|
|
67
|
+
title: (row: TData) => ReactNode;
|
|
68
|
+
/** Beside the name, at the end of the line: the status badge. */
|
|
69
|
+
status?: (row: TData) => ReactNode;
|
|
70
|
+
/** The facts that matter (two, usually) on one muted line under it, between dots; empty ones are left out. */
|
|
71
|
+
facts?: (row: TData) => readonly ReactNode[];
|
|
72
|
+
};
|
|
73
|
+
export declare function PhoneRow<TData>({ row, phoneRow, actions, highlighted, href, onOpen, }: {
|
|
74
|
+
row: TData;
|
|
75
|
+
phoneRow: DataTablePhoneRow<TData>;
|
|
76
|
+
actions?: ReactNode;
|
|
77
|
+
highlighted: boolean;
|
|
78
|
+
/** The record's address: the row is a link to it. */
|
|
79
|
+
href?: string;
|
|
80
|
+
/** What a plain click (or Enter) on the row does; with no `href`, the row is a button. */
|
|
81
|
+
onOpen?: () => void;
|
|
82
|
+
}): import("react").JSX.Element;
|
|
83
|
+
export declare const PHONE_LIST_CLASS = "flex flex-col overflow-hidden rounded-lg border border-border";
|
|
84
|
+
export declare function PhoneRowsSkeleton(): import("react").JSX.Element;
|
|
85
|
+
/** Where a capped list's whole list is (DataTable `viewAll`). */
|
|
86
|
+
export type DataTableViewAll = {
|
|
87
|
+
/** The list, filtered to this record (`/health/visits?provider=12`). */
|
|
88
|
+
to: string;
|
|
89
|
+
/** How many there are: the table's `total` unless set. */
|
|
90
|
+
total?: number;
|
|
91
|
+
/** The link's text: "View all <total>" unless set. */
|
|
92
|
+
label?: string;
|
|
93
|
+
};
|
|
94
|
+
export declare function ViewAllLink({ viewAll, total, navigator }: {
|
|
95
|
+
viewAll: DataTableViewAll;
|
|
96
|
+
total: number;
|
|
97
|
+
navigator?: Navigator;
|
|
98
|
+
}): import("react").JSX.Element;
|