@tristan2828/ui-foundation 4.93.0 → 4.95.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.
@@ -219,7 +219,11 @@ function checkContract(specPath) {
219
219
  for (const [name, entry] of Object.entries(entries)) {
220
220
  const appEntry = app.components?.[section]?.[name]
221
221
  if (appEntry === undefined) {
222
- if (!optionalOnly.has(`${section}/${name}`)) problems.push(`missing components.${section}.${name}`)
222
+ // A component marked x-optional (Recurrence) is one an app's own
223
+ // schemas may reference; no path here needs it.
224
+ if (!entry['x-optional'] && !optionalOnly.has(`${section}/${name}`)) {
225
+ problems.push(`missing components.${section}.${name}`)
226
+ }
223
227
  } else if (!same(appEntry, entry)) {
224
228
  problems.push(`components.${section}.${name} differs`)
225
229
  }
@@ -4,28 +4,28 @@
4
4
  ## Index
5
5
 
6
6
  - [The reference files](#the-reference-files) · lines 44–66
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 68–832
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 68–848
8
8
  - Step 1: Add `<Entity>` to `openapi.yaml` · lines 110–117
9
9
  - Step 2: `npm run gen:api` · lines 118–119
10
10
  - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 120–131
11
11
  - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 132–141
12
12
  - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 142–146
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 147–719
14
- - Step 7: Register routes · lines 720–735
15
- - Step 8: Add Playwright specs for all three screens · lines 736–814
16
- - Step 9: Register the nav entry and route names · lines 815–829
17
- - Step 10: `npm run verify`. · lines 830–832
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 834–1150
19
- - [The record view](#the-record-view) · lines 983–1028
20
- - [Forms](#forms) · lines 1030–1082
21
- - [Dialogs](#dialogs) · lines 1084–1109
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1111–1150
23
- - [What not to copy](#what-not-to-copy) · lines 1152–1178
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1180–1197
25
- - [Deleting](#deleting) · lines 1199–1230
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1232–1253
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1255–1264
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1267–1306
13
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 147–735
14
+ - Step 7: Register routes · lines 736–751
15
+ - Step 8: Add Playwright specs for all three screens · lines 752–830
16
+ - Step 9: Register the nav entry and route names · lines 831–845
17
+ - Step 10: `npm run verify`. · lines 846–848
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 850–1169
19
+ - [The record view](#the-record-view) · lines 999–1047
20
+ - [Forms](#forms) · lines 1049–1101
21
+ - [Dialogs](#dialogs) · lines 1103–1128
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1130–1169
23
+ - [What not to copy](#what-not-to-copy) · lines 1171–1197
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1199–1216
25
+ - [Deleting](#deleting) · lines 1218–1249
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1251–1272
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1274–1283
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1286–1328
29
29
 
30
30
  <!-- /index -->
31
31
 
@@ -252,6 +252,22 @@ is a filled-in example while the Widgets demo is still here).
252
252
  written, and the field shows it as written with nothing picked, refused
253
253
  until a day is picked.
254
254
 
255
+ **A `recurrence`** (how something repeats: a chore, a reminder, a
256
+ task) is the foundation's `Recurrence` schema: copy it from the
257
+ package's `openapi/foundation.yaml` into `components.schemas` (it's
258
+ `x-optional`, so `check-contract` holds it to the foundation's shape
259
+ once it's there) and reference it, nullable when it may not repeat.
260
+ On the form it's the foundation's `RecurrenceField` in a `Controller`
261
+ (presets, a phrase read as it's typed, and a preview of the next five);
262
+ the schema checks it with `recurrenceProblem(value)`, and a phrase the
263
+ field can't read gives `null`, so a required one is refused. The table
264
+ shows `formatRecurrence(value)` and a Next column (cell pattern 27);
265
+ editing in place is `inPlace.recurrence({ value, save })`. The backend
266
+ column is JSON, read and checked with
267
+ `foundation_backend.recurrence.Recurrence` (a 422 on the field for a
268
+ rule it refuses); `next_after` and `occurrences` say when it falls
269
+ (reminders.md "Repeating reminders").
270
+
255
271
  **An image on a record** (a photo of it) is the stored file's id on the
256
272
  wire (`string`, nullable), and on the form the foundation's
257
273
  `ImageField` in a `Controller` (`z.string().nullable()`): `value` and
@@ -1020,7 +1036,10 @@ view reaches them all. A record uses the parts it has, in this order:
1020
1036
  per set: `cards` for little to say about each, `table` for things
1021
1037
  compared on the same values, `featured` when one is current or best,
1022
1038
  `panels` when each has several details (design-language.md "A few
1023
- equal things"). Never hand-made cards or a grid of their own.
1039
+ equal things"). Never hand-made cards or a grid of their own. An item
1040
+ edited or removed on its own carries its editor as `content` and its
1041
+ Edit and Remove as `actions` (4.94), `wide` while the editor is open;
1042
+ never an editor put in a field's value.
1024
1043
  - **A big record's own parts** (a drawing, a player, a checklist of
1025
1044
  documents) are sections in the view, not a screen of their own.
1026
1045
 
@@ -1279,7 +1298,10 @@ Four more things an app sets for AI chats (4.71), each in
1279
1298
  must be found exactly once (missing, or found twice, is a refusal that
1280
1299
  says so and saves nothing), or `append` adds text on a new line at the
1281
1300
  end. It saves and logs as `update` does, so a long note isn't sent back
1282
- whole to change a line. Each must be a text field of `update_schema`
1301
+ whole to change a line. A table's widths comment (design-language.md
1302
+ "Written text (notes)") is hidden from every read answer and kept
1303
+ in what's stored, so an edit never drops it (4.94); `search` leaves
1304
+ out a record whose only match is inside it. Each must be a text field of `update_schema`
1283
1305
  and not `script_only`; the backend refuses to start otherwise.
1284
1306
  - **The server's instructions** a chat gets when it connects:
1285
1307
  `register_entities(ENTITIES, instructions="…")` (or
@@ -3,45 +3,46 @@
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 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–1489
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1121–1189
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1191–1227
32
- - [A link and its label](#a-link-and-its-label) · lines 1229–1253
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1255–1388
34
- - [In a table's rows](#in-a-tables-rows) · lines 1390–1475
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1477–1489
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1491–1557
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1559–1623
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1625–1723
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1725–1754
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1756–1794
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1796–1872
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1874–1897
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 1899–1985
44
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1987–2023
6
+ - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 74–93
7
+ - [1. Plain text](#1-plain-text) · lines 95–148
8
+ - [2. Icon + label](#2-icon--label) · lines 150–173
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 175–188
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 190–267
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 215–267
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 269–282
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 284–296
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 298–319
15
+ - [8. Date, relative](#8-date-relative) · lines 321–358
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 360–408
17
+ - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 378–408
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 410–460
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 428–460
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 462–502
21
+ - [12. Boolean](#12-boolean) · lines 504–534
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 536–572
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 556–572
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 574–591
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 593–702
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 619–702
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 704–739
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 741–814
29
+ - [18. Editable value](#18-editable-value) · lines 816–1494
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1126–1194
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1196–1232
32
+ - [A link and its label](#a-link-and-its-label) · lines 1234–1258
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1260–1393
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1395–1480
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1482–1494
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1496–1562
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1564–1628
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1630–1728
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1730–1759
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1761–1799
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1801–1877
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1879–1902
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 1904–1990
44
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1992–2028
45
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2030–2075
45
46
 
46
47
  <!-- /index -->
47
48
 
@@ -849,7 +850,11 @@ on that tint, since muted on `bg-muted` is under 4.5:1; the package does
849
850
  it, so an app just uses `text-muted-foreground` as anywhere else. On a
850
851
  touch screen the pencil always shows. A click anywhere on the value opens it, except on a
851
852
  link inside it (a reference to a record with a view, a link in the
852
- notes), which still navigates.
853
+ notes), which still navigates. The tint reaches 0.375rem past the value
854
+ on each side without moving it, and never wraps it: a short title or
855
+ badge edited in place (`layout="inline"`) stays on one line, and a long
856
+ one wraps between words within its column (4.94; before, a title like
857
+ "Dr. Example" broke over two lines).
853
858
 
854
859
  **In a field list, the row is the target** (4.88, `look="row"`, which
855
860
  EntityView's field rows use). The row wears the list's row hover, the
@@ -2021,3 +2026,50 @@ const visits = useVisits({ provider: provider.id, sort: 'date:desc', page: 1, pa
2021
2026
  - On a DataTable of your own, `limit` and `viewAll` do the same.
2022
2027
  - The fixture `app/DataTable tools` Related draws a capped list and a
2023
2028
  short one with no link; the spec follows View all.
2029
+
2030
+ ## 27. A repeat and its next time
2031
+
2032
+ A record that repeats (a chore, a reminder) shows two columns: **Repeats**,
2033
+ the rule in words, and **Next**, when it falls next. The value is the
2034
+ contract's `Recurrence` (reminders.md "Repeating reminders"); both cells
2035
+ read it in the rule's own zone, so a reminder set in Chicago says 9:00 AM
2036
+ wherever it's looked at.
2037
+
2038
+ ```tsx
2039
+ import { formatOccurrence, formatRecurrence, nextOccurrence, EmptyText } from '@tristan2828/ui-foundation'
2040
+
2041
+ {
2042
+ id: 'repeats',
2043
+ header: 'Repeats',
2044
+ cell: ({ row }) => (row.original.repeats ? formatRecurrence(row.original.repeats) : <EmptyText />),
2045
+ },
2046
+ {
2047
+ id: 'next',
2048
+ header: 'Next',
2049
+ cell: ({ row }) => {
2050
+ const repeats = row.original.repeats
2051
+ if (!repeats) return <EmptyText />
2052
+ const next = nextOccurrence(repeats, new Date())
2053
+ if (!next) return <span className="text-muted-foreground">Ended</span>
2054
+ return (
2055
+ <time dateTime={next.toISOString()} className="tabular-nums">
2056
+ {formatOccurrence(next, repeats.timeZone)}
2057
+ </time>
2058
+ )
2059
+ },
2060
+ },
2061
+ ```
2062
+
2063
+ - **The label** reads "Every 2nd Tue at 9:00 AM", "Every Mon and Thu at
2064
+ 7:00 AM and 7:30 PM", "Every 30 days after done, at 9:00 AM" (from
2065
+ completion), "…, until Mar 1, 2027", "…, 10 times". `times: false`
2066
+ leaves the times out, for a table with its own time column. A rule it
2067
+ can't read shows as stored, never blank.
2068
+ - **Next** is "Tue, Dec 8, 9:00 AM", the year only when it isn't this
2069
+ one; a rule that has ended (UNTIL passed, COUNT used up) says Ended, in
2070
+ muted text. For a `fromCompletion` repeat whose next depends on being
2071
+ done, use the server's `next_at` if it sends one; `nextOccurrence`
2072
+ counts from the schedule's start.
2073
+ - **Sorting by Next** is the server's (`next_at`), not the cell's text.
2074
+ - The fixture `app/RecurrenceField` List cells draws both on six chores;
2075
+ its spec reads each cell.
@@ -15,27 +15,27 @@
15
15
  - [Depth ramps](#depth-ramps) · lines 454–539
16
16
  - [A stored colour](#a-stored-colour) · lines 541–589
17
17
  - [Shapes and sizes](#shapes-and-sizes) · lines 591–612
18
- - [Typography](#typography) · lines 614–734
19
- - [Written text (notes)](#written-text-notes) · lines 648–734
20
- - [Density](#density) · lines 736–829
21
- - [Rows on this device](#rows-on-this-device) · lines 802–829
22
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 831–945
23
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 947–1024
24
- - [Notices](#notices) · lines 1026–1054
25
- - [A value over time](#a-value-over-time) · lines 1056–1142
26
- - [Several values over time](#several-values-over-time) · lines 1105–1142
27
- - [A list as a board](#a-list-as-a-board) · lines 1144–1195
28
- - [A list as cards](#a-list-as-cards) · lines 1197–1243
29
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1245–1274
30
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1276–1319
31
- - [A few equal things](#a-few-equal-things) · lines 1321–1366
32
- - [An overview page](#an-overview-page) · lines 1368–1431
33
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1432–1470
34
- - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1472–1517
35
- - [Picking at random](#picking-at-random) · lines 1519–1550
36
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1552–1619
37
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1621–1646
38
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1648–1721
18
+ - [Typography](#typography) · lines 614–736
19
+ - [Written text (notes)](#written-text-notes) · lines 648–736
20
+ - [Density](#density) · lines 738–831
21
+ - [Rows on this device](#rows-on-this-device) · lines 804–831
22
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 833–947
23
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 949–1026
24
+ - [Notices](#notices) · lines 1028–1056
25
+ - [A value over time](#a-value-over-time) · lines 1058–1144
26
+ - [Several values over time](#several-values-over-time) · lines 1107–1144
27
+ - [A list as a board](#a-list-as-a-board) · lines 1146–1197
28
+ - [A list as cards](#a-list-as-cards) · lines 1199–1245
29
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1247–1276
30
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1278–1321
31
+ - [A few equal things](#a-few-equal-things) · lines 1323–1407
32
+ - [An overview page](#an-overview-page) · lines 1409–1472
33
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1473–1511
34
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1513–1558
35
+ - [Picking at random](#picking-at-random) · lines 1560–1591
36
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1593–1660
37
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1662–1687
38
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1689–1762
39
39
 
40
40
  <!-- /index -->
41
41
 
@@ -686,7 +686,9 @@ least), a column's menu has Narrower, Wider, Fit to content and Fit all
686
686
  columns, and a double-click on the edge fits it again. The width is kept
687
687
  in the Markdown as a comment after the table, naming its columns
688
688
  (`<!-- table widths: Item=140, Cost=72 -->`), which `<Markdown>` and the
689
- editor read and never show. A column named nowhere fits its words. A
689
+ editor read and never show; nor do the backend's MCP read tools (4.94:
690
+ `fetch`, `list`, `search`, and `update`'s answer), while `edit_text` and
691
+ `update` keep it in what's stored. A column named nowhere fits its words. A
690
692
  phone ignores the widths and can't set them; on paper they scale to the
691
693
  page.
692
694
 
@@ -1361,9 +1363,48 @@ one look per set; a fifth is asked for first.
1361
1363
  reader (the list's name, the table's caption); titles are `h3` under a
1362
1364
  section's `h2` (`headingLevel`).
1363
1365
 
1366
+ **An item's own content and actions** (4.94). When an item holds more
1367
+ than label/value rows (an editor of several fields, a note, a chart), it
1368
+ carries them itself, never as a field's value, where the label/value grid
1369
+ squeezes them into its narrow value column:
1370
+
1371
+ ```tsx
1372
+ items={stores.map((store) => ({
1373
+ id: store.id,
1374
+ title: store.name,
1375
+ fields: editing === store.id ? undefined : [{ label: 'Price', value: store.price }],
1376
+ content: editing === store.id && <StoreEditor store={store} onDone={stopEditing} />,
1377
+ wide: editing === store.id,
1378
+ actions: (
1379
+ <>
1380
+ <IconAction icon={PencilIcon} label={`Edit ${store.name}`} size="sm" variant="ghost" onClick={() => edit(store.id)} />
1381
+ <IconAction icon={Trash2Icon} label={`Remove ${store.name}`} tone="destructive" size="sm" variant="ghost" onClick={() => remove(store.id)} />
1382
+ </>
1383
+ ),
1384
+ }))}
1385
+ ```
1386
+
1387
+ - **`content`** goes under the item's fields at the item's full width (in
1388
+ `table`, a row of its own under the item's, as wide as the table's box
1389
+ and held in view while a phone scrolls the table sideways). An item with
1390
+ content and no fields reads no "No details".
1391
+ - **`actions`** are the item's own buttons, at the end of its title line;
1392
+ in `featured` beside the toggle, never inside its button; in `table` a
1393
+ last column, named `actionsColumn` ("Actions") for a screen reader. Icon
1394
+ actions (`IconAction`, a tooltip and a name each) named for the item
1395
+ ("Edit Corner Hardware"), as the record standard's header draws them.
1396
+ A Remove that loses data asks first, as any delete does
1397
+ (add-an-entity.md "Deleting").
1398
+ - **`wide`** gives the item the whole row of `cards` or `panels`, for
1399
+ content that needs it: set it while the item's editor is open. The
1400
+ items keep their order; the others wrap around it.
1401
+ - **Editing one item swaps its fields for its editor** (the content), then
1402
+ back on Save or Cancel. The set's other items stay as they are.
1403
+
1364
1404
  Measured with axe, the token check and the glyph check in both themes and
1365
- every palette (fixtures `app/EqualItems`), and from the keyboard and at a
1366
- phone's width in `e2e/equal-items.spec.ts`.
1405
+ every palette (fixtures `app/EqualItems`, "Content and actions" among
1406
+ them), and from the keyboard and at a phone's width in
1407
+ `e2e/equal-items.spec.ts`.
1367
1408
 
1368
1409
  ## An overview page
1369
1410
 
@@ -55,7 +55,9 @@ One or two sentences: what one record is, and who uses the screens.
55
55
  time: OpenAPI `format: date`; the foundation's `DateField`; say
56
56
  whether it's optional), `month-day` (a day that comes round every
57
57
  year, no year: `'MM-DD'`; the foundation's `MonthDayField`; say
58
- whether it's optional).
58
+ whether it's optional), `recurrence` (how it repeats: the
59
+ foundation's `Recurrence` schema and `RecurrenceField`; say whether
60
+ it's optional).
59
61
  - *Not supported yet:* a yes/no that can also be unset (three states),
60
62
  file, and anything else.
61
63
  Write it anyway with a note; the playbook will stop and raise it
@@ -111,6 +111,59 @@ Scope it to the signed-in user, as Widgets are.
111
111
  that's the `tzdata` package, which the backend doesn't install: a
112
112
  Windows dev machine reads only `UTC` until it's added.
113
113
 
114
+ ## Repeating reminders (4.95)
115
+
116
+ A weekday set and one time is the simple schedule. For anything more
117
+ (every 2nd Tuesday, the last day of the month, several times a day, an
118
+ end, "every! 3 days" counted from when it's done), a reminder carries a
119
+ **recurrence**: the contract's `Recurrence` schema (in the package's
120
+ `openapi/foundation.yaml`, marked `x-optional`: copy it into
121
+ `components.schemas` and reference it from the reminder's schema), the
122
+ package's `RecurrenceField` on the form and `inPlace.recurrence` on the
123
+ view, and `foundation_backend.recurrence` on the server. Both sides read
124
+ the same rules and agree on every next occurrence.
125
+
126
+ - **The value**: `{ rule, start, times, timeZone, fromCompletion }`.
127
+ `rule` is RFC 5545's RRULE without DTSTART (`FREQ=MONTHLY;BYDAY=2TU`):
128
+ FREQ daily to yearly, INTERVAL, BYDAY with an nth (`2TU`, `-1FR`),
129
+ BYMONTHDAY (`-1` the last day), BYMONTH, UNTIL (a date) or COUNT.
130
+ `start` is the first day it can fall on; each of `times` is an
131
+ occurrence on every day the rule falls on, read in `timeZone`. A day a
132
+ month lacks is skipped (the 31st, Feb 29), as in RFC 5545.
133
+ - **The columns**: the app's reminders model inherits
134
+ `foundation_backend.recurrence_models.RecurringReminderFields` and its
135
+ migration adds them: `recurrence` (JSON), `next_at`, `sent_at`,
136
+ `last_sent_at`, `done_occurrence`, `done_at` (timestamps with time
137
+ zone), `nag_count` (integer, default 0), `nag_every_minutes` and
138
+ `nag_limit` (integers, null for no nagging). `days` and `time_of_day`
139
+ become nullable. Hand the model to the job as before
140
+ (`reminders.register(model=MyReminder)`).
141
+ - **What the job does with a row whose `recurrence` is set**: each
142
+ occurrence is due from its time until 15 minutes have passed, so
143
+ several a day go out; one missed past that is skipped, not sent late
144
+ (the run's line says "1 missed"). Sent and not done, it's re-sent
145
+ every `nag_every_minutes`, at most `nag_limit` times (3 when only the
146
+ interval is set). The next occurrence coming round ends the wait; a
147
+ `fromCompletion` rule waits for done instead. A row with no
148
+ `recurrence` is the weekday set, as before.
149
+ - **Done**: the app's Done button (or a notification action that calls
150
+ the app) runs `reminders.mark_done(row)` and commits: the occurrence is
151
+ recorded (`done_occurrence`, `done_at`), nagging stops, and the next is
152
+ pending; for `fromCompletion` it counts from the done time. After the
153
+ rule itself changes, `reminders.schedule_changed(row)` forgets where it
154
+ was.
155
+ - **Moving a simple schedule over**: `recurrence.from_weekdays(days,
156
+ time_of_day, time_zone, start=today)` (and the package's
157
+ `recurrenceFromWeekdays`) is the same schedule exactly; store its
158
+ `model_dump(by_alias=True, mode="json")` in `recurrence`.
159
+ `recurrence.as_weekdays(rule)` goes back when a rule is still that
160
+ simple.
161
+ - **On screens**: `RecurrenceField` in the form (a `Controller`; check
162
+ with `recurrenceProblem`), `inPlace.recurrence` on the view, and in the
163
+ list `formatRecurrence` for a Repeats column and `nextOccurrence` with
164
+ `formatOccurrence` for a Next one (cell-patterns.md "A repeat and its
165
+ next time").
166
+
114
167
  ## Testing
115
168
 
116
169
  Under MSW the page is held by MSW's service worker, so `usePushPermission`
@@ -259,6 +259,25 @@ export interface components {
259
259
  PushSubscriptionCreated: {
260
260
  id: number;
261
261
  };
262
+ /** @description A repeating schedule (RecurrenceField, foundation_backend.recurrence). The rule's days, each at every one of its times, read in its zone. */
263
+ Recurrence: {
264
+ /** @description RFC 5545's RRULE value, without DTSTART: FREQ (daily, weekly, monthly, yearly), INTERVAL, BYMONTH, BYMONTHDAY (-1 is the last day), BYDAY (an nth for monthly and yearly: 2TU, -1FR), UNTIL (a date, YYYYMMDD, the last day it can fall on) or COUNT (occurrences, each time of each day). "FREQ=MONTHLY;BYDAY=2TU". */
265
+ rule: string;
266
+ /**
267
+ * Format: date
268
+ * @description The first day it can fall on (DTSTART's date).
269
+ */
270
+ start: string;
271
+ /** @description Its times of day, HH:MM, in order, each once. */
272
+ times: string[];
273
+ /** @description The IANA zone its days and times are read in. */
274
+ timeZone: string;
275
+ /**
276
+ * @description Repeat from when it was done ("every!"), not from the schedule: the next one is the rule's days counted from the day it was done.
277
+ * @default false
278
+ */
279
+ fromCompletion: boolean;
280
+ };
262
281
  /** @description FastAPI's default 422 shape (RequestValidationError). */
263
282
  ValidationErrorBody: {
264
283
  detail: {
@@ -1,6 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import { type MonthDay } from '../../lib/month-day.js';
3
3
  import { type PlainDate } from '../../lib/plain-date.js';
4
+ import { type Recurrence } from '../../lib/recurrence.js';
4
5
  import type { EditInPlace } from './edit-in-place.js';
5
6
  /** What the value saves as: with `required: true` never `null` (a blank is refused). */
6
7
  export type InPlaceSaved<TValue, TRequired extends boolean> = TRequired extends true ? TValue : TValue | null;
@@ -78,6 +79,23 @@ export type InPlaceMonthDayConfig<TRequired extends boolean = boolean> = {
78
79
  locale?: string;
79
80
  placeholder?: string;
80
81
  };
82
+ /**
83
+ * How something repeats (RecurrenceField): presets, a phrase read as it's
84
+ * typed, and a preview. Enter in the box or leaving the field saves; a
85
+ * phrase it can't read isn't saved. Not `required`: emptying the box saves
86
+ * `null` (doesn't repeat).
87
+ */
88
+ export type InPlaceRecurrenceConfig<TRequired extends boolean = boolean> = {
89
+ required?: TRequired;
90
+ /** The IANA zone a new repeat is read in. Defaults to the value's, else the browser's. */
91
+ timeZone?: string;
92
+ /** The times a new repeat starts with. Defaults to 09:00. */
93
+ defaultTimes?: string[];
94
+ /** Today, `'YYYY-MM-DD'`, and "now", for a fixed preview (tests). Default to the clock. */
95
+ today?: string;
96
+ now?: Date;
97
+ locale?: string;
98
+ };
81
99
  /** One option of a select: its value and its words. */
82
100
  export type InPlaceOption<T> = {
83
101
  value: T;
@@ -208,6 +226,13 @@ export declare const inPlace: {
208
226
  * Reads as "Mar 14"; February 29 is a day, February 30 is refused.
209
227
  */
210
228
  monthDay<R extends boolean = false>(options: Common<MonthDay | null | undefined, InPlaceSaved<MonthDay, R>> & InPlaceMonthDayConfig<R>): EditInPlace;
229
+ /**
230
+ * How something repeats (the contract's `Recurrence`) in RecurrenceField:
231
+ * presets, a phrase read as it's typed ("every 2nd tue at 9am") and a
232
+ * preview of the next five. Reads as its label ("Every 2nd Tue at 9:00
233
+ * AM"); Enter or leaving saves, and a phrase it can't read is refused.
234
+ */
235
+ recurrence<R extends boolean = false>(options: Common<Recurrence | null | undefined, InPlaceSaved<Recurrence, R>> & InPlaceRecurrenceConfig<R>): EditInPlace;
211
236
  /**
212
237
  * One of a fixed list; its list opens with the field and a pick saves.
213
238
  * `look: 'buttons'` draws it as ChoiceButtons (`inPlace.choice`).
@@ -4,10 +4,13 @@ import { InputGroup, InputGroupAddon, InputGroupInput, InputGroupText } from '..
4
4
  import { linkHost, linkRule } from '../../lib/link-href.js';
5
5
  import { formatMonthDay, monthDayProblem } from '../../lib/month-day.js';
6
6
  import { formatPlainDate, unreadableDateMessage } from '../../lib/plain-date.js';
7
+ import { normalizeRecurrence, recurrenceProblem } from '../../lib/recurrence.js';
8
+ import { formatRecurrence } from '../../lib/recurrence-format.js';
7
9
  import { ChoiceButtons } from './choice-buttons.js';
8
10
  import { DateField } from './date-field.js';
9
11
  import { MonthDayField } from './month-day-field.js';
10
12
  import { OptionSelect } from './option-select.js';
13
+ import { RecurrenceField } from './recurrence-field.js';
11
14
  import { Parts, ReferencePicker } from './edit-in-place-controls.js';
12
15
  import { LinkOut } from './row-edit-cells.js';
13
16
  const REQUIRED = 'Required';
@@ -177,6 +180,20 @@ function monthDayKind(config) {
177
180
  : undefined, "aria-label": props.label, "aria-describedby": props.describedBy })),
178
181
  };
179
182
  }
183
+ function recurrenceKind(config) {
184
+ return {
185
+ editKind: 'text',
186
+ toDraft: (value) => value ?? null,
187
+ check: (draft) => {
188
+ if (draft === null)
189
+ return config.required ? { ok: false, message: REQUIRED } : { ok: true, value: null };
190
+ const problem = recurrenceProblem(draft);
191
+ return problem ? { ok: false, message: problem } : { ok: true, value: normalizeRecurrence(draft) };
192
+ },
193
+ show: (value) => (value ? formatRecurrence(value, { locale: config.locale }) : null),
194
+ control: (props) => (_jsx(RecurrenceField, { id: props.id, value: props.value, onChange: props.onChange, onProblem: props.onProblem, timeZone: config.timeZone, defaultTimes: config.defaultTimes, today: config.today, now: config.now, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, "aria-label": props.label, "aria-describedby": props.describedBy })),
195
+ };
196
+ }
180
197
  function selectKind(config) {
181
198
  const labelOf = (value) => config.options.find((option) => option.value === value)?.label ?? String(value);
182
199
  const shownOf = (value) => (config.render ? config.render(value, labelOf(value)) : labelOf(value));
@@ -421,6 +438,15 @@ export const inPlace = {
421
438
  monthDay(options) {
422
439
  return single(monthDayKind(options), { ...options, value: options.value || null });
423
440
  },
441
+ /**
442
+ * How something repeats (the contract's `Recurrence`) in RecurrenceField:
443
+ * presets, a phrase read as it's typed ("every 2nd tue at 9am") and a
444
+ * preview of the next five. Reads as its label ("Every 2nd Tue at 9:00
445
+ * AM"); Enter or leaving saves, and a phrase it can't read is refused.
446
+ */
447
+ recurrence(options) {
448
+ return single(recurrenceKind(options), { ...options, value: options.value ?? null });
449
+ },
424
450
  /**
425
451
  * One of a fixed list; its list opens with the field and a pick saves.
426
452
  * `look: 'buttons'` draws it as ChoiceButtons (`inPlace.choice`).
@@ -237,7 +237,12 @@ export function EditableField({ label, edit, children, layout = 'block', look =
237
237
  const row = look === 'row';
238
238
  return (_jsxs("span", { "data-slot": "editable-value", "data-look": look, onClick: onShownClick, className: cn('group/editable relative cursor-text items-start gap-1',
239
239
  // A row: the row (editRowClass) wears the hover, not the value.
240
- !row && '-mx-1.5 rounded-md px-1.5 transition-colors hover:bg-muted has-[[data-edit]:focus-visible]:bg-muted', layout === 'block' ? 'flex w-full' : 'inline-flex max-w-full align-top', className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
240
+ !row && '-mx-1.5 rounded-md px-1.5 transition-colors hover:bg-muted has-[[data-edit]:focus-visible]:bg-muted',
241
+ // Inline, the cap is its column plus the 0.75rem the negative
242
+ // margins give back: a parent sized to its content (a title on
243
+ // its line) is sized to the margin box, 0.75rem under the box,
244
+ // and `max-w-full` then wrapped a short value mid-word (4.94).
245
+ layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+0.75rem)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
241
246
  'group-hover/editable:[&_.text-muted-foreground]:text-foreground group-has-[[data-edit]:focus-visible]/editable:[&_.text-muted-foreground]:text-foreground'), children: [children !== undefined ? children : edit.shown, _jsx("span", { role: "status", "data-slot": "editable-value-saved", className: "ml-2 inline-flex items-center gap-1 align-baseline type-caption text-success-text empty:hidden", children: justSaved && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }), "Saved"] })) })] }), _jsx(Button, { ref: editButton, "data-edit": "", type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Edit ${label}`, onClick: start, className: cn('shrink-0 text-muted-foreground opacity-0 focus-visible:opacity-100 pointer-coarse:opacity-100', row ? 'group-hover/edit-row:opacity-100 hover:bg-transparent max-md:opacity-100' : 'group-hover/editable:opacity-100'), children: row ? (_jsxs(_Fragment, { children: [_jsx(PencilIcon, { className: "max-md:hidden pointer-coarse:hidden" }), _jsx(ChevronRightIcon, { className: "hidden max-md:block pointer-coarse:block" })] })) : (_jsx(PencilIcon, {})) })] }));
242
247
  }
243
248
  // Always editable, before the store has it (the first render): the saved value.
@@ -286,7 +286,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
286
286
  const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
287
287
  .filter((section) => !tabbed(section))
288
288
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
289
- return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 sm:min-w-64 sm:gap-4", children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: "min-w-0 max-w-full type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", className: "w-full", children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), (actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] }))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), layout === 'rail' ? (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections, fields: railFields })), mobileOrder === 'rail-first' && main] })) : (_jsxs(_Fragment, { children: [sections
289
+ return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { className: layout === 'rail' ? RAIL_LAYOUT.page : 'flex max-w-4xl flex-col gap-6', "data-state": "success", "data-layout": layout, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-start gap-3 sm:min-w-64 sm:gap-4", children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: "min-w-0 max-w-full type-page-title break-words text-foreground", children: titleEdit ? (_jsx(EditableValue, { label: titleEdit.label, edit: titleEdit, layout: "inline", children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), (actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] }))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), layout === 'rail' ? (_jsxs("div", { className: RAIL_LAYOUT.columns, children: [mobileOrder === 'main-first' && main, railSections.length > 0 && (_jsx(Rail, { label: railLabel ?? `${title ?? 'Record'} details`, sections: railSections, fields: railFields })), mobileOrder === 'rail-first' && main] })) : (_jsxs(_Fragment, { children: [sections
290
290
  .filter((section) => !tabbed(section))
291
291
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] })), footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
292
292
  }