@tristan2828/ui-foundation 4.146.0 → 4.148.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 CHANGED
@@ -18,7 +18,7 @@ than installing this by hand:
18
18
 
19
19
  | Import | What |
20
20
  |---|---|
21
- | `@tristan2828/ui-foundation` | The composites and what goes with them: `AppShell`, `DataTable`, `EntityView` (with editing in place: `EditableValue`, `editInPlace`, `inPlace`), `EntityForm`, `FormDialog`, `RecordDialogRoute`, `Markdown`, `RichTextEditor`, `ErrorState`, `FoundationProviders`, `LoginRoute`, `RegisterRoute`; the hooks `useAuth`, `useTableUrlState`, `useRecordUpdate`; `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. The full list is the package's type declarations (`dist/index.d.ts`); what each part is for is in the app's `docs/foundation/` |
21
+ | `@tristan2828/ui-foundation` | The composites and what goes with them: `AppShell`, `DataTable`, `EntityView` (with editing in place: `EditableValue`, `editInPlace`, `inPlace`; `EditInPlaceScope` runs it on a page of the app's own), `EntityForm`, `FormDialog`, `RecordDialogRoute`, `Markdown`, `RichTextEditor` (and `preloadRichTextEditor`), `ErrorState`, `FoundationProviders`, `LoginRoute`, `RegisterRoute`; the hooks `useAuth`, `useTableUrlState`, `useRecordUpdate`; `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. The full list is the package's type declarations (`dist/index.d.ts`); what each part is for is in the app's `docs/foundation/` |
22
22
  | `@tristan2828/ui-foundation/ui/<name>` | shadcn primitives: alert, badge, breadcrumb, button, calendar, card, checkbox, collapsible, combobox, dialog, dropdown-menu, empty, field, input, input-group, label, popover, progress, radio-group, select, separator, sheet, sidebar, skeleton, slider, sonner, spinner, switch, table, tabs, textarea, toggle, toggle-group, tooltip |
23
23
  | `@tristan2828/ui-foundation/gateway` | `safeFetch`, `toAppError`, `networkError`, `proxyAuthError` — for an app's `src/api/gateway/` only |
24
24
  | `@tristan2828/ui-foundation/mocks` | MSW: `authHandlers`, `environmentHandlers`, `clientErrorHandlers`, `pushHandlers`, `resetMockAuth`, `getMockCurrentUser`, `MOCK_USER`, `startMockWorker` (mock mode's boot), `exposeMswForE2E`, among others (`dist/mocks/index.d.ts`) |
@@ -3,48 +3,49 @@
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 63–86
7
- - [1. Plain text](#1-plain-text) · lines 88–137
8
- - [2. Icon + label](#2-icon--label) · lines 139–162
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 164–177
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 179–255
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 204–255
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 257–277
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 279–291
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 293–314
15
- - [8. Date, relative](#8-date-relative) · lines 316–353
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 355–431
17
- - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 373–431
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 433–482
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 451–482
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 484–524
21
- - [12. Boolean](#12-boolean) · lines 526–554
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 556–590
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 575–590
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 592–610
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 612–714
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 635–714
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 716–757
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 759–831
29
- - [18. Editable value](#18-editable-value) · lines 833–1571
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1217–1289
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1291–1327
32
- - [A link and its label](#a-link-and-its-label) · lines 1329–1353
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1355–1488
34
- - [In a table's rows](#in-a-tables-rows) · lines 1490–1564
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1566–1571
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1573–1639
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1641–1695
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1697–1779
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1781–1806
40
- - [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1808–1841
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1843–1894
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1896–1970
43
- - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1916–1970
44
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1972–2184
45
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2133–2184
46
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2186–2220
47
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2222–2269
6
+ - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 64–87
7
+ - [1. Plain text](#1-plain-text) · lines 89–138
8
+ - [2. Icon + label](#2-icon--label) · lines 140–163
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 165–178
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 180–256
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 205–256
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 258–278
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 280–292
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 294–315
15
+ - [8. Date, relative](#8-date-relative) · lines 317–354
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 356–432
17
+ - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 374–432
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 434–483
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 452–483
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 485–525
21
+ - [12. Boolean](#12-boolean) · lines 527–555
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 557–591
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 576–591
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 593–611
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 613–715
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 636–715
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 717–758
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 760–832
29
+ - [18. Editable value](#18-editable-value) · lines 834–1627
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1227–1299
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1301–1337
32
+ - [A link and its label](#a-link-and-its-label) · lines 1339–1363
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1365–1498
34
+ - [On a page of the app's own: `EditInPlaceScope`](#on-a-page-of-the-apps-own-editinplacescope) · lines 1500–1544
35
+ - [In a table's rows](#in-a-tables-rows) · lines 1546–1620
36
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1622–1627
37
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1629–1695
38
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1697–1751
39
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1753–1835
40
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1837–1862
41
+ - [28. A list's rows: hover, lines, rows per page](#28-a-lists-rows-hover-lines-rows-per-page) · lines 1864–1897
42
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1899–1950
43
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1952–2026
44
+ - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 1972–2026
45
+ - [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 2028–2240
46
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2189–2240
47
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2242–2276
48
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2278–2325
48
49
 
49
50
  <!-- /index -->
50
51
 
@@ -840,6 +841,13 @@ header `StatusMark`), Price, Description (rich text edited where it's read,
840
841
  `inline`) and Extra Categories, with the controls in `widget-fields.tsx`,
841
842
  the same ones the form uses.
842
843
 
844
+ Something has to run the editing: one value open at a time, autosave,
845
+ the leave-page prompt. A record's view (`EntityView`) runs it for what's
846
+ on it, a table (`DataTable`) for its rows, and a page of the app's own
847
+ that is neither (a notes screen that is nothing but its text) wraps what
848
+ it edits in `EditInPlaceScope` ("On a page of the app's own" below).
849
+ `<EditableValue>` outside all three throws, naming them.
850
+
843
851
  The rule behind every part of it: **nothing typed is ever lost.**
844
852
 
845
853
  **No toast, but one.** An edit in place says what happened where it
@@ -1069,7 +1077,9 @@ to open, and it never closes. Ctrl/Cmd+Enter or Esc saves now and leaves
1069
1077
  the caret where it is. It sits beside the one open value rather than
1070
1078
  being it: opening another value leaves it alone. Don't give its control
1071
1079
  `autoFocus`. The cost: at rest the page shows the editor, not the read
1072
- view, and the editor loads on every visit. A click on a link in the
1080
+ view, and the editor loads on every visit (an app whose first screen is
1081
+ an editor starts that load as it starts: `preloadRichTextEditor()`, "On a
1082
+ page of the app's own" below). A click on a link in the
1073
1083
  notes still opens it in a new tab; its words are edited from the
1074
1084
  keyboard or by dragging over them, and Ctrl/Cmd+K edits its address. Use it where the notes are what the page is
1075
1085
  for; elsewhere `autosave` alone keeps the read view at rest.
@@ -1487,6 +1497,52 @@ const files = editInPlace<Attachment>({
1487
1497
  })
1488
1498
  ```
1489
1499
 
1500
+ ### On a page of the app's own: `EditInPlaceScope`
1501
+
1502
+ A page that is neither a record's view nor a table, such as a notes app
1503
+ whose screen is nothing but the note, wraps what it edits in
1504
+ `<EditInPlaceScope>` and puts `<EditableValue>`s inside: the same rules
1505
+ as a view, the same "Saving…" and "Saved", refusals, Keep Mine or Show
1506
+ Saved, and leaving the page saves first. The page needs a data router
1507
+ (`createBrowserRouter`), as a view does: the leave-page prompt uses its
1508
+ blocker.
1509
+
1510
+ ```tsx
1511
+ const body = editInPlace<string>({
1512
+ kind: 'long-text',
1513
+ inline: true,
1514
+ value: note.body,
1515
+ save: (body) => editField.mutateAsync({ body }),
1516
+ // The form's own control, spreading what it gets onto RichTextEditor
1517
+ // with inline={props.inline} toolbar="floating"
1518
+ control: (props) => <NoteBodyEditor … />,
1519
+ })
1520
+
1521
+ <EditInPlaceScope>
1522
+ <EditableValue label="Note" edit={body} />
1523
+ </EditInPlaceScope>
1524
+ ```
1525
+
1526
+ - **One scope per page, around everything it edits**, not one per
1527
+ value. Each scope renders a leave guard, which takes the router's
1528
+ blocker, and a router holds one at a time. A page with an `EntityView`
1529
+ or a `DataTable` doesn't need one: they run their own.
1530
+ - **Several always-editable values in one scope** is what a notes app's
1531
+ tabs are: one pane per open note, all mounted, only the one in front
1532
+ shown (the others `hidden`), so each keeps its caret and undo. A
1533
+ hidden value still saves, and the one leave guard covers them all.
1534
+ - **A value that leaves the page mid-typing is still saved** (a tab
1535
+ closed, a pane unmounted): what was typed goes at once rather than
1536
+ after the pause.
1537
+ - **An app that opens on an editor** calls `preloadRichTextEditor()`
1538
+ as it starts (in `main.tsx`), so the editor's code is loading while
1539
+ the note is fetched, not after. It returns nothing, never throws, and
1540
+ is safe to call more than once; a failed load is the editor's to meet
1541
+ when one mounts.
1542
+
1543
+ The stories are `app/EditInPlaceScope` (one note, and two in one scope);
1544
+ `e2e/edit-in-place-scope.spec.ts` is the browser behaviour.
1545
+
1490
1546
  ### In a table's rows
1491
1547
 
1492
1548
  For a **small entity edited in its table** (a name and a few fields,
@@ -23,31 +23,31 @@
23
23
  - [Density](#density) · lines 822–951
24
24
  - [Rows on this device](#rows-on-this-device) · lines 895–923
25
25
  - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 925–951
26
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 953–1065
27
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1067–1139
28
- - [Notices](#notices) · lines 1141–1168
29
- - [A value over time](#a-value-over-time) · lines 1170–1300
30
- - [Several values over time](#several-values-over-time) · lines 1219–1257
31
- - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1259–1300
32
- - [A list as a board](#a-list-as-a-board) · lines 1302–1412
33
- - [Order, groups and the header](#order-groups-and-the-header) · lines 1355–1412
34
- - [A list as cards](#a-list-as-cards) · lines 1414–1461
35
- - [Images full screen](#images-full-screen) · lines 1463–1509
36
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1511–1547
37
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1549–1585
38
- - [A few equal things](#a-few-equal-things) · lines 1587–1702
39
- - [An overview page](#an-overview-page) · lines 1704–1769
40
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1771–1834
41
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1836–1923
42
- - [Picking at random](#picking-at-random) · lines 1925–1956
43
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1958–2025
44
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2027–2046
45
- - [A quick add line](#a-quick-add-line) · lines 2048–2076
46
- - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2078–2102
47
- - [A few choices, then the month](#a-few-choices-then-the-month) · lines 2104–2130
48
- - [A month calendar](#a-month-calendar) · lines 2132–2164
49
- - [A settings page](#a-settings-page) · lines 2166–2223
50
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2225–2284
26
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 953–1070
27
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1072–1144
28
+ - [Notices](#notices) · lines 1146–1173
29
+ - [A value over time](#a-value-over-time) · lines 1175–1305
30
+ - [Several values over time](#several-values-over-time) · lines 1224–1262
31
+ - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1264–1305
32
+ - [A list as a board](#a-list-as-a-board) · lines 1307–1417
33
+ - [Order, groups and the header](#order-groups-and-the-header) · lines 1360–1417
34
+ - [A list as cards](#a-list-as-cards) · lines 1419–1466
35
+ - [Images full screen](#images-full-screen) · lines 1468–1514
36
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1516–1552
37
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1554–1590
38
+ - [A few equal things](#a-few-equal-things) · lines 1592–1707
39
+ - [An overview page](#an-overview-page) · lines 1709–1774
40
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1776–1839
41
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1841–1928
42
+ - [Picking at random](#picking-at-random) · lines 1930–1961
43
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1963–2030
44
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2032–2051
45
+ - [A quick add line](#a-quick-add-line) · lines 2053–2081
46
+ - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2083–2107
47
+ - [A few choices, then the month](#a-few-choices-then-the-month) · lines 2109–2135
48
+ - [A month calendar](#a-month-calendar) · lines 2137–2169
49
+ - [A settings page](#a-settings-page) · lines 2171–2228
50
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2230–2289
51
51
 
52
52
  <!-- /index -->
53
53
 
@@ -997,6 +997,11 @@ const { data, isLoading, error, refetch } = useReadyTasksQuery() // one page of
997
997
  <service>' }}` opens it in a new tab, with the external-link mark and
998
998
  "(opens in a new tab)" for a screen reader. Set `skeletonRows` to the number it usually holds, so the card
999
999
  keeps its height when the data arrives.
1000
+ - **A row's words:** its text is one line, cut. A small muted `note`
1001
+ ("2 h ago", "holds 2") sits beside it, at the row's end; a `line`
1002
+ ("Every day · 4 steps", 4.147) sits under it, wraps rather than cuts,
1003
+ and the row keeps room under it. Neither is part of the link's name.
1004
+ Don't reach into the row's spans through `className` to move a note.
1000
1005
  - **Each widget owns its four states.** Loading is a skeleton of rows,
1001
1006
  empty is one quiet line the app writes ("Nothing waiting", not "No
1002
1007
  data"), and **an error stays inside the card**: the compact
@@ -49,7 +49,7 @@ export function DateChoiceRows({ label, showLabel = true, choices, slot = 'date-
49
49
  if (choices.length === 0)
50
50
  return null;
51
51
  const shown = label && showLabel;
52
- return (_jsxs("div", { role: "group", "aria-label": shown ? undefined : label, "aria-labelledby": shown ? headingId : undefined, "data-slot": slot, className: "flex flex-col gap-0.5 border-b border-border p-2", children: [shown && (_jsx("div", { id: headingId, className: "px-3 py-1 text-xs font-medium text-muted-foreground", children: label })), choices.map((choice) => (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "data-slot": "date-choice", disabled: choice.disabled, className: "w-full justify-between gap-4 font-normal", "aria-label": choice.value ? `${choice.label}, ${choice.value}` : choice.label, onClick: choice.onSelect, children: [_jsx("span", { children: choice.label }), choice.value && _jsx("span", { className: "text-muted-foreground tabular-nums", children: choice.value })] }, choice.label)))] }));
52
+ return (_jsxs("div", { role: "group", "aria-label": shown ? undefined : label, "aria-labelledby": shown ? headingId : undefined, "data-slot": slot, className: "flex flex-col gap-0.5 border-b border-border p-2", children: [shown && (_jsx("div", { id: headingId, className: "px-3 py-1 text-xs font-medium text-muted-foreground", children: label })), choices.map((choice) => (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "data-slot": "date-choice", disabled: choice.disabled, className: "w-full justify-between gap-4 font-normal", "aria-label": choice.value ? `${choice.label}, ${choice.value}` : choice.label, onClick: choice.onSelect, children: [_jsx("span", { children: choice.label }), choice.value && ' ', choice.value && _jsx("span", { className: "text-muted-foreground tabular-nums", children: choice.value })] }, choice.label)))] }));
53
53
  }
54
54
  // Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
55
55
  const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from 'react';
2
+ export type EditInPlaceScopeProps = {
3
+ children: ReactNode;
4
+ };
5
+ export declare function EditInPlaceScope({ children }: EditInPlaceScopeProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Editing in place on a page of the app's own: one that isn't a record's
3
+ // view or a table. EntityView and DataTable each run it for what's inside
4
+ // them (one field open at a time, autosave, the leave-page prompt); a page
5
+ // built from other parts, such as a notes screen that is nothing but its
6
+ // text, wraps those parts in this and uses <EditableValue> inside, with
7
+ // the same rules (cell-patterns.md "Editable value").
8
+ //
9
+ // Everything inside one scope is one page's worth of editing: opening a
10
+ // value saves the open one first, and leaving the page (a link, Back,
11
+ // closing the tab, hiding it on a phone) saves what autosaves and asks
12
+ // about the rest.
13
+ //
14
+ // One scope per page, around everything editable on it, not one per
15
+ // value, and not on a page that has an EntityView or a DataTable (each
16
+ // runs its own). Every one of them renders a leave guard, which takes
17
+ // React Router's blocker, and the router holds one blocker at a time. A
18
+ // scope holds any number of always-editable values, such as a notes
19
+ // app's open tabs kept mounted with only the one in front shown.
20
+ import { useState, useSyncExternalStore } from 'react';
21
+ import { EditInPlaceContext } from './edit-in-place.js';
22
+ import { EditInPlaceStore } from './edit-in-place-store.js';
23
+ import { LeaveGuard } from './editable-value.js';
24
+ export function EditInPlaceScope({ children }) {
25
+ const [store] = useState(() => new EditInPlaceStore());
26
+ // The leave-page prompt only while a value is open (or one is always
27
+ // editable), so a page nobody's editing never blocks anything.
28
+ const editing = useSyncExternalStore(store.subscribe, () => store.editing, () => store.editing);
29
+ return (_jsxs(EditInPlaceContext.Provider, { value: store, children: [editing && _jsx(LeaveGuard, { store: store }), children] }));
30
+ }
@@ -42,8 +42,9 @@ export declare function EditableField({ label, edit, children, layout, look, cla
42
42
  /**
43
43
  * While a field holds something unsaved, leaving asks first: an in-app
44
44
  * link or Back (React Router's blocker, so the app needs a data router),
45
- * or closing the tab (`beforeunload`). Rendered by EntityView only while
46
- * a field is being edited, so a view nobody's editing never blocks anything.
45
+ * or closing the tab (`beforeunload`). Rendered by EntityView, DataTable
46
+ * and EditInPlaceScope only while a field is being edited, so a view
47
+ * nobody's editing never blocks anything.
47
48
  *
48
49
  * When everything unsaved autosaves, an in-app move saves it first and
49
50
  * goes on once saved, asking only if that save fails. Closing the tab
@@ -2,7 +2,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  // A value on a record's view that turns into its form control where it's
3
3
  // shown, and saves when you leave it (cell-patterns.md "Editable value").
4
4
  // EntityView wraps every field, section and title marked `edit`; a header
5
- // badge uses <EditableValue> itself. The rules are edit-in-place-store.ts.
5
+ // badge uses <EditableValue> itself, and so does a page of the app's own
6
+ // inside an <EditInPlaceScope>. The rules are edit-in-place-store.ts.
6
7
  //
7
8
  // - Start: click the value (a link inside it still navigates), or tab to
8
9
  // its edit button and press Enter. Hover and focus show it's editable.
@@ -156,7 +157,7 @@ function usePinnedStatus(field, enabled) {
156
157
  function useStore() {
157
158
  const store = useContext(EditInPlaceContext);
158
159
  if (!store)
159
- throw new Error('<EditableValue> works inside an <EntityView>, which runs editing in place.');
160
+ throw new Error('<EditableValue> works inside an <EntityView> or an <EditInPlaceScope>, which run editing in place.');
160
161
  return store;
161
162
  }
162
163
  // Long text's "Keep Mine": both sides kept block by block (rebaseMarkdown).
@@ -458,8 +459,9 @@ const sameAsJson = (a, b) => JSON.stringify(a) === JSON.stringify(b);
458
459
  /**
459
460
  * While a field holds something unsaved, leaving asks first: an in-app
460
461
  * link or Back (React Router's blocker, so the app needs a data router),
461
- * or closing the tab (`beforeunload`). Rendered by EntityView only while
462
- * a field is being edited, so a view nobody's editing never blocks anything.
462
+ * or closing the tab (`beforeunload`). Rendered by EntityView, DataTable
463
+ * and EditInPlaceScope only while a field is being edited, so a view
464
+ * nobody's editing never blocks anything.
463
465
  *
464
466
  * When everything unsaved autosaves, an in-app move saves it first and
465
467
  * goes on once saved, asking only if that save fails. Closing the tab
@@ -44,12 +44,14 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
44
44
  // The editor (Milkdown) is loaded on first use, so a page that only reads
45
45
  // Markdown never downloads it. Until it arrives the text shows as
46
46
  // <Markdown> draws it, the field's size, so nothing moves when the editor
47
- // takes its place; an empty one shows skeleton lines.
47
+ // takes its place; an empty one shows skeleton lines. An app that opens on
48
+ // an editor loads it ahead with `preloadRichTextEditor()`.
48
49
  import { lazy, Suspense, useLayoutEffect, useRef, useState } from 'react';
49
50
  import { cn } from 'cn';
50
51
  import { Skeleton } from '../ui/skeleton.js';
51
52
  import { Markdown } from './markdown.js';
52
- const MilkdownEditor = lazy(() => import('./milkdown-editor.js'));
53
+ import { loadRichTextEditor } from './rich-text-load.js';
54
+ const MilkdownEditor = lazy(loadRichTextEditor);
53
55
  // When the editor opens again: each time `defaultValue` changes to
54
56
  // Markdown it didn't report. Adjusted while rendering (React's "storing
55
57
  // information from previous renders"), so the new text never shows a
@@ -0,0 +1,11 @@
1
+ /** The editor's module, fetched once: later calls get the same one. */
2
+ export declare const loadRichTextEditor: () => Promise<typeof import("./milkdown-editor.js")>;
3
+ /**
4
+ * Starts loading the editor now, before one is on screen: an app whose
5
+ * first screen is an editor (a notes app that opens on a note) calls it as
6
+ * the app starts, so the editor is there when the note is, not a moment
7
+ * after it. Safe to call more than once, and anywhere: it never throws,
8
+ * and a failed load is swallowed here, so the page goes on; the editor
9
+ * meets the same failure when one mounts, as it would with no preload.
10
+ */
11
+ export declare function preloadRichTextEditor(): void;
@@ -0,0 +1,16 @@
1
+ // The editor's own code (Milkdown), loaded apart from the page that shows
2
+ // it: RichTextEditor asks for it when it first mounts, and an app that
3
+ // opens on an editor asks ahead with `preloadRichTextEditor()`.
4
+ /** The editor's module, fetched once: later calls get the same one. */
5
+ export const loadRichTextEditor = () => import('./milkdown-editor.js');
6
+ /**
7
+ * Starts loading the editor now, before one is on screen: an app whose
8
+ * first screen is an editor (a notes app that opens on a note) calls it as
9
+ * the app starts, so the editor is there when the note is, not a moment
10
+ * after it. Safe to call more than once, and anywhere: it never throws,
11
+ * and a failed load is swallowed here, so the page goes on; the editor
12
+ * meets the same failure when one mounts, as it would with no preload.
13
+ */
14
+ export function preloadRichTextEditor() {
15
+ void loadRichTextEditor().catch(() => { });
16
+ }
@@ -120,6 +120,13 @@ export interface WidgetListItemProps {
120
120
  lead?: ReactNode;
121
121
  /** A small muted note after the text: "2 h ago", "holds 2". */
122
122
  note?: ReactNode;
123
+ /**
124
+ * A muted line under the text: what the row is about in a few words
125
+ * ("Every day · 4 steps"). Unlike the text it isn't cut: on a narrow row
126
+ * it wraps, and the row grows to hold it. Outside the link, so it isn't
127
+ * part of the row's name.
128
+ */
129
+ line?: ReactNode;
123
130
  /**
124
131
  * What ends the row: a badge, or a control. A control needs a name: pass
125
132
  * a function, and put the id it gets in the control's `aria-labelledby`,
@@ -128,4 +135,4 @@ export interface WidgetListItemProps {
128
135
  trailing?: ReactNode | ((rowTextId: string) => ReactNode);
129
136
  className?: string;
130
137
  }
131
- export declare function WidgetListItem({ children, to, href, lead, note, trailing, className }: WidgetListItemProps): import("react").JSX.Element;
138
+ export declare function WidgetListItem({ children, to, href, lead, note, line, trailing, className }: WidgetListItemProps): import("react").JSX.Element;
@@ -142,15 +142,20 @@ function WidgetListSkeleton({ rows }) {
142
142
  export function WidgetList({ children, className }) {
143
143
  return (_jsx("ul", { "data-slot": "widget-list", className: cn('flex flex-col divide-y divide-border', className), children: children }));
144
144
  }
145
+ // A row with a line under its text keeps room under the line at every
146
+ // density, so a wrapped line doesn't sit against the divider (a compact
147
+ // phone row has no padding of its own: its link's is the target).
148
+ const ROW_WITH_LINE_CLASS = 'density-compact:py-1.5 max-sm:density-compact:pb-2';
145
149
  const ROW_LINK_CLASS = 'min-w-0 truncate rounded-sm font-medium text-foreground underline-offset-4 outline-none ' +
146
150
  'hover:underline focus-visible:underline focus-visible:ring-3 focus-visible:ring-ring/50 ' +
147
151
  'max-sm:density-compact:py-3';
148
- export function WidgetListItem({ children, to, href, lead, note, trailing, className }) {
152
+ export function WidgetListItem({ children, to, href, lead, note, line, trailing, className }) {
149
153
  const textId = useId();
150
154
  const hasLead = lead !== undefined && lead !== null && lead !== false;
151
155
  // With a lead the text is its own cut span after it, both on one line.
152
156
  const words = hasLead ? (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "widget-list-item-lead", "aria-hidden": "true", className: "inline-flex shrink-0", children: lead }), _jsx("span", { className: "min-w-0 truncate", children: children })] })) : (children);
153
157
  const leadRow = hasLead && 'flex items-center gap-1.5';
154
158
  const text = to !== undefined ? (_jsx(Link, { id: textId, to: to, title: children, className: cn(ROW_LINK_CLASS, leadRow), children: words })) : href !== undefined ? (_jsxs("a", { id: textId, href: href, target: "_blank", rel: "noreferrer", title: children, className: cn(ROW_LINK_CLASS, 'flex items-center gap-1', hasLead && 'gap-1.5'), children: [hasLead ? words : _jsx("span", { className: "truncate", children: children }), _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (_jsx("span", { id: textId, title: children, className: cn('min-w-0 truncate text-foreground', leadRow), children: words }));
155
- return (_jsxs("li", { "data-slot": "widget-list-item", className: cn(ROW_CLASS, 'type-body', className), children: [text, (note !== undefined || trailing !== undefined) && (_jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-3", children: [note !== undefined && _jsx("span", { className: "type-caption tabular-nums text-muted-foreground", children: note }), typeof trailing === 'function' ? trailing(textId) : trailing] }))] }));
159
+ const hasLine = line !== undefined && line !== null && line !== false;
160
+ return (_jsxs("li", { "data-slot": "widget-list-item", className: cn(ROW_CLASS, 'type-body', hasLine && ROW_WITH_LINE_CLASS, className), children: [hasLine ? (_jsxs("span", { "data-slot": "widget-list-item-text", className: "flex min-w-0 flex-col gap-0.5", children: [text, _jsx("span", { "data-slot": "widget-list-item-line", className: "type-caption text-muted-foreground", children: line })] })) : (text), (note !== undefined || trailing !== undefined) && (_jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-3", children: [note !== undefined && _jsx("span", { className: "type-caption tabular-nums text-muted-foreground", children: note }), typeof trailing === 'function' ? trailing(textId) : trailing] }))] }));
156
161
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import { DayPicker, type DayButton, type Locale } from "react-day-picker";
3
3
  import { Button } from "./button.js";
4
- declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, weekStartsOn, locale, formatters, components, ...props }: React.ComponentProps<typeof DayPicker> & {
4
+ declare function Calendar({ className, classNames, showOutsideDays, captionLayout, buttonVariant, weekStartsOn, locale, formatters, components, labels, ...props }: React.ComponentProps<typeof DayPicker> & {
5
5
  buttonVariant?: React.ComponentProps<typeof Button>["variant"];
6
6
  }): React.JSX.Element;
7
7
  declare function CalendarDayButton({ className, day, modifiers, locale, ...props }: React.ComponentProps<typeof DayButton> & {
@@ -9,11 +9,14 @@ function Calendar({ className, classNames, showOutsideDays = true, captionLayout
9
9
  // Patched (ui-foundation): upstream leaves this to react-day-picker, which
10
10
  // starts weeks on Sunday. Monday unless the caller says, the default of
11
11
  // MonthCalendar, RecurrenceField and byDay; a `locale` doesn't change it.
12
- weekStartsOn = 1, locale, formatters, components, ...props }) {
12
+ weekStartsOn = 1, locale, formatters, components, labels, ...props }) {
13
13
  const defaultClassNames = getDefaultClassNames();
14
14
  return (_jsx(DayPicker, { showOutsideDays: showOutsideDays, className: cn("group/calendar bg-background p-2 [--cell-radius:var(--radius-md)] [--cell-size:--spacing(7)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent", String.raw `rtl:**:[.rdp-button\_next>svg]:rotate-180`, String.raw `rtl:**:[.rdp-button\_previous>svg]:rotate-180`, className), captionLayout: captionLayout, weekStartsOn: weekStartsOn, locale: locale, formatters: {
15
15
  formatMonthDropdown: (date) => date.toLocaleString(locale?.code, { month: "short" }),
16
16
  ...formatters,
17
+ }, labels: {
18
+ labelDayButton: (date, modifiers) => dayButtonLabel(date, modifiers, locale?.code),
19
+ ...labels,
17
20
  }, classNames: {
18
21
  root: cn("w-fit", defaultClassNames.root),
19
22
  months: cn("relative flex flex-col gap-4 md:flex-row", defaultClassNames.months),
@@ -65,6 +68,24 @@ weekStartsOn = 1, locale, formatters, components, ...props }) {
65
68
  ...components,
66
69
  }, ...props }));
67
70
  }
71
+ // Patched (ui-foundation): react-day-picker names a day "Monday, September
72
+ // 14th, 2026" (date-fns' PPPP), and axe's label-content-name-mismatch doesn't
73
+ // find the "14" the button shows in "14th". The locale's own long date
74
+ // ("Monday, September 14, 2026"), with react-day-picker's "Today, " and
75
+ // ", selected" kept, so the shown number is a word of the name.
76
+ function dayButtonLabel(date, modifiers, localeCode) {
77
+ let label = date.toLocaleDateString(localeCode ?? "en-US", {
78
+ weekday: "long",
79
+ month: "long",
80
+ day: "numeric",
81
+ year: "numeric",
82
+ });
83
+ if (modifiers.today)
84
+ label = `Today, ${label}`;
85
+ if (modifiers.selected)
86
+ label = `${label}, selected`;
87
+ return label;
88
+ }
68
89
  function CalendarDayButton({ className, day, modifiers, locale, ...props }) {
69
90
  const defaultClassNames = getDefaultClassNames();
70
91
  const ref = React.useRef(null);
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { AppShell, type AppShellProps, type AppShellSearch, type RecentRecord, type SearchRecord, type AppShellVersion, type BottomBarItem, type NavEntry, type NavItem, type NavLook, type NavSection, } from './components/app/app-shell.js';
2
+ export { navItems, navPathname } from './components/app/app-shell-nav.js';
2
3
  export type { IconComponent } from './components/app/icon-component.js';
3
4
  export { Board, type BoardColumn, type BoardGroup, type BoardMoveTarget, type BoardPlace, type BoardProps } from './components/app/board.js';
4
5
  export { SpinWheel, type SpinWheelProps } from './components/app/spin-wheel.js';
@@ -51,6 +52,7 @@ export { linkHost, linkHref, linkRule } from './lib/link-href.js';
51
52
  export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
52
53
  export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
53
54
  export { EditableValue, type EditableValueProps } from './components/app/editable-value.js';
55
+ export { EditInPlaceScope, type EditInPlaceScopeProps } from './components/app/edit-in-place-scope.js';
54
56
  export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
55
57
  export { ErrorState } from './components/app/error-state.js';
56
58
  export { InlineCreate, type InlineCreateProps } from './components/app/inline-create.js';
@@ -70,6 +72,7 @@ export { MultiReference } from './components/app/multi-reference.js';
70
72
  export { ListEditor } from './components/app/list-editor.js';
71
73
  export { PasswordInput } from './components/app/password-input.js';
72
74
  export { RichTextEditor, type RichTextEditorProps } from './components/app/rich-text-editor.js';
75
+ export { preloadRichTextEditor } from './components/app/rich-text-load.js';
73
76
  export { flushPendingEdits, hasPendingEdits } from './lib/pending-edits.js';
74
77
  export { RouteErrorBoundary } from './components/app/route-error-boundary.js';
75
78
  export { PillFilter, type PillFilterOption, type PillFilterProps } from './components/app/pill-filter.js';
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  // points (`/gateway`, `/mocks`, `/testing`) so each stays behind its boundary.
5
5
  // Composites
6
6
  export { AppShell, } from './components/app/app-shell.js';
7
+ export { navItems, navPathname } from './components/app/app-shell-nav.js';
7
8
  export { Board } from './components/app/board.js';
8
9
  export { SpinWheel } from './components/app/spin-wheel.js';
9
10
  export { pickSpinWheelIndex } from './components/app/spin-wheel-pick.js';
@@ -62,6 +63,7 @@ export { linkHost, linkHref, linkRule } from './lib/link-href.js';
62
63
  export { TITLE_CASE_SMALL_WORDS, titleCase } from './lib/title-case.js';
63
64
  export { DataEnvironmentBanner } from './components/app/data-environment-banner.js';
64
65
  export { EditableValue } from './components/app/editable-value.js';
66
+ export { EditInPlaceScope } from './components/app/edit-in-place-scope.js';
65
67
  export { editRowClass, onEditRowClick, SAVED_FOR_MS } from './components/app/edit-row.js';
66
68
  export { ErrorState } from './components/app/error-state.js';
67
69
  export { InlineCreate } from './components/app/inline-create.js';
@@ -79,6 +81,7 @@ export { MultiReference } from './components/app/multi-reference.js';
79
81
  export { ListEditor } from './components/app/list-editor.js';
80
82
  export { PasswordInput } from './components/app/password-input.js';
81
83
  export { RichTextEditor } from './components/app/rich-text-editor.js';
84
+ export { preloadRichTextEditor } from './components/app/rich-text-load.js';
82
85
  // Typing a RichTextEditor holds back until a pause, reported now: call it
83
86
  // before reading a rich-text field's value to save it in your own form.
84
87
  export { flushPendingEdits, hasPendingEdits } from './lib/pending-edits.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.146.0",
3
+ "version": "4.148.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {