@tristan2828/ui-foundation 4.118.0 → 4.120.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/bin/ui-foundation.mjs +28 -3
  2. package/conventions/docs/add-an-entity.md +39 -19
  3. package/conventions/docs/cell-patterns.md +8 -4
  4. package/conventions/docs/design-language.md +51 -11
  5. package/conventions/docs/entity-plan-template.md +3 -1
  6. package/conventions/docs/reminders.md +29 -1
  7. package/dist/api/schema.d.ts +1 -1
  8. package/dist/components/app/action-hint.d.ts +9 -0
  9. package/dist/components/app/action-hint.js +22 -0
  10. package/dist/components/app/edit-in-place-presets.d.ts +5 -1
  11. package/dist/components/app/edit-in-place-presets.js +2 -2
  12. package/dist/components/app/entity-view-facts.d.ts +19 -2
  13. package/dist/components/app/entity-view-facts.js +8 -4
  14. package/dist/components/app/entity-view.js +4 -20
  15. package/dist/components/app/fact-extras.d.ts +16 -0
  16. package/dist/components/app/fact-extras.js +49 -0
  17. package/dist/components/app/key-stats.d.ts +11 -0
  18. package/dist/components/app/key-stats.js +3 -1
  19. package/dist/components/app/list-header.d.ts +8 -1
  20. package/dist/components/app/list-header.js +18 -5
  21. package/dist/components/app/overview-page.d.ts +13 -1
  22. package/dist/components/app/overview-page.js +14 -2
  23. package/dist/components/app/recurrence-field.d.ts +15 -2
  24. package/dist/components/app/recurrence-field.js +54 -13
  25. package/dist/index.d.ts +5 -4
  26. package/dist/index.js +2 -1
  27. package/dist/lib/recurrence-format.d.ts +13 -4
  28. package/dist/lib/recurrence-format.js +14 -7
  29. package/dist/lib/recurrence-phrase.d.ts +24 -2
  30. package/dist/lib/recurrence-phrase.js +26 -8
  31. package/dist/lib/recurrence.d.ts +16 -1
  32. package/dist/lib/recurrence.js +29 -2
  33. package/openapi/foundation.yaml +9 -2
  34. package/package.json +1 -1
@@ -143,7 +143,7 @@ function sync({ check }) {
143
143
  // ---------------------------------------------------------- check-contract
144
144
 
145
145
  // Wording may differ between the app's spec and the foundation's; shapes may not.
146
- const IGNORED_KEYS = new Set(['description', 'summary', 'example', 'examples', 'tags', 'x-optional'])
146
+ const IGNORED_KEYS = new Set(['description', 'summary', 'example', 'examples', 'tags', 'x-optional', 'x-earlier-patterns'])
147
147
 
148
148
  function normalise(value) {
149
149
  if (Array.isArray(value)) return value.map(normalise)
@@ -160,6 +160,31 @@ function normalise(value) {
160
160
 
161
161
  const same = (a, b) => JSON.stringify(normalise(a)) === JSON.stringify(normalise(b))
162
162
 
163
+ // A pattern the foundation widened keeps the ones before it
164
+ // (`x-earlier-patterns`, Recurrence's rule since 4.119), and an app's copy
165
+ // with an earlier one still matches: it allows less, so the package reads
166
+ // everything it can hold, and the app copies the new one when it wants
167
+ // what that allows. The nth earlier version takes every such node's nth.
168
+ function withEarlierPattern(value, nth) {
169
+ if (Array.isArray(value)) return value.map((each) => withEarlierPattern(each, nth))
170
+ if (!value || typeof value !== 'object') return value
171
+ const out = Object.fromEntries(Object.entries(value).map(([key, child]) => [key, withEarlierPattern(child, nth)]))
172
+ const earlier = value['x-earlier-patterns']
173
+ if (Array.isArray(earlier) && nth < earlier.length) out.pattern = earlier[nth]
174
+ return out
175
+ }
176
+
177
+ function earlierCount(value) {
178
+ if (Array.isArray(value)) return Math.max(0, ...value.map(earlierCount))
179
+ if (!value || typeof value !== 'object') return 0
180
+ const own = Array.isArray(value['x-earlier-patterns']) ? value['x-earlier-patterns'].length : 0
181
+ return Math.max(own, ...Object.values(value).map(earlierCount))
182
+ }
183
+
184
+ const matches = (app, foundation) =>
185
+ same(app, foundation) ||
186
+ Array.from({ length: earlierCount(foundation) }, (_, nth) => withEarlierPattern(foundation, nth)).some((earlier) => same(app, earlier))
187
+
163
188
  // Every component a value reaches through $refs, following refs inside the
164
189
  // components themselves, as 'section/name' keys.
165
190
  function reachableComponents(roots, components) {
@@ -207,7 +232,7 @@ function checkContract(specPath) {
207
232
  const appItem = app.paths?.[route]
208
233
  if (appItem === undefined) {
209
234
  if (!item['x-optional']) problems.push(`missing path ${route}`)
210
- } else if (!same(appItem, item)) {
235
+ } else if (!matches(appItem, item)) {
211
236
  problems.push(`path ${route} differs`)
212
237
  }
213
238
  }
@@ -224,7 +249,7 @@ function checkContract(specPath) {
224
249
  if (!entry['x-optional'] && !optionalOnly.has(`${section}/${name}`)) {
225
250
  problems.push(`missing components.${section}.${name}`)
226
251
  }
227
- } else if (!same(appEntry, entry)) {
252
+ } else if (!matches(appEntry, entry)) {
228
253
  problems.push(`components.${section}.${name} differs`)
229
254
  }
230
255
  }
@@ -4,29 +4,29 @@
4
4
  ## Index
5
5
 
6
6
  - [The reference files](#the-reference-files) · lines 45–67
7
- - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–850
7
+ - [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–855
8
8
  - Step 1: Add `<Entity>` to `openapi.yaml` · lines 111–118
9
9
  - Step 2: `npm run gen:api` · lines 119–120
10
10
  - Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 121–132
11
11
  - Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 133–142
12
12
  - Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 143–149
13
- - Step 6: Copy the reference files, one for one, not just the two screens · lines 150–738
14
- - Step 7: Register routes · lines 739–754
15
- - Step 8: Add Playwright specs for all three screens · lines 755–832
16
- - Step 9: Register the nav entry and route names · lines 833–847
17
- - Step 10: `npm run verify`. · lines 848–850
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1298
19
- - [The record view](#the-record-view) · lines 1005–1143
20
- - [Forms](#forms) · lines 1145–1215
21
- - [Dialogs](#dialogs) · lines 1217–1248
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1250–1298
23
- - [What not to copy](#what-not-to-copy) · lines 1300–1332
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1334–1351
25
- - [Deleting](#deleting) · lines 1353–1384
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1386–1407
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1409–1418
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1421–1463
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1465–1501
13
+ - Step 6: Copy the reference files, one for one, not just the two screens · lines 150–743
14
+ - Step 7: Register routes · lines 744–759
15
+ - Step 8: Add Playwright specs for all three screens · lines 760–837
16
+ - Step 9: Register the nav entry and route names · lines 838–852
17
+ - Step 10: `npm run verify`. · lines 853–855
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 857–1318
19
+ - [The record view](#the-record-view) · lines 1010–1163
20
+ - [Forms](#forms) · lines 1165–1235
21
+ - [Dialogs](#dialogs) · lines 1237–1268
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1270–1318
23
+ - [What not to copy](#what-not-to-copy) · lines 1320–1352
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1354–1371
25
+ - [Deleting](#deleting) · lines 1373–1404
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1406–1427
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1429–1438
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1441–1483
29
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1485–1521
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -265,7 +265,12 @@ is a filled-in example while the Widgets demo is still here).
265
265
  the schema checks it with `recurrenceProblem(value)`, and a phrase the
266
266
  field can't read gives `null`, so a required one is refused. The table
267
267
  shows `formatRecurrence(value)` and a Next column (cell pattern 27);
268
- editing in place is `inPlace.recurrence({ value, save })`. The backend
268
+ editing in place is `inPlace.recurrence({ value, save })`. A record
269
+ whose times are fields of its own (an event's start and end) gives the
270
+ field and the preset `times={false}`: dates only, no "at". An app whose
271
+ weeks start on Sunday gives them `weekStart="SU"`, which adds
272
+ `WKST=SU` to the weekly rules they build (reminders.md "Repeating
273
+ reminders" says when that moves a day). The backend
269
274
  column is JSON, read and checked with
270
275
  `foundation_backend.recurrence.Recurrence` (a 422 on the field for a
271
276
  rule it refuses); `next_after` and `occurrences` say when it falls
@@ -1119,6 +1124,21 @@ A record uses the parts it has, in this order:
1119
1124
  emptyLabel: 'Not rated', save: (rating) => save({ rating }) }) },
1120
1125
  { label: 'Quality', kind: 'rating', look: 'bar', value: QUALITY[record.quality].value, word: QUALITY[record.quality].word },
1121
1126
  ```
1127
+ - **A yes/no** (4.120) is `kind: 'switch'`, a switch toggled where it
1128
+ is, named by the label, never a two-choice select. Return the save's
1129
+ promise: the switch shows the new state while it runs and goes back
1130
+ if it fails. `on`/`off` words are optional (both or neither):
1131
+
1132
+ ```tsx
1133
+ { label: 'Shared', kind: 'switch', checked: record.shared, on: 'With the team', off: 'Only me',
1134
+ onCheckedChange: (shared) => save({ shared }) },
1135
+ ```
1136
+ - **The strip's values** take `info` (a tooltip on an info button) and
1137
+ `action` (a small button under the value) as rail facts take `hint`
1138
+ and `action` (4.120); a stat's `hint` stays its caption line. A
1139
+ header button that needs a short line under it ("12 searches left")
1140
+ is wrapped in `<ActionHint hint="…">`. Inline-edited header badges
1141
+ keep their pencil's room on their own.
1122
1142
  - **A tiny record** (4.98: a few fields and no notes, like a lookup's
1123
1143
  row) opens as a small card: `RecordDialogRoute look="card"`, usually
1124
1144
  with `fullPage={false}`. A 420px dialog (a sheet on a phone), its
@@ -43,7 +43,7 @@
43
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 1965–2184
44
44
  - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2113–2184
45
45
  - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2186–2222
46
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2224–2269
46
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2224–2273
47
47
 
48
48
  <!-- /index -->
49
49
 
@@ -2257,10 +2257,14 @@ import { formatOccurrence, formatRecurrence, nextOccurrence, EmptyText } from '@
2257
2257
  - **The label** reads "Every 2nd Tue at 9:00 AM", "Every Mon and Thu at
2258
2258
  7:00 AM and 7:30 PM", "Every 30 days after done, at 9:00 AM" (from
2259
2259
  completion), "…, until Mar 1, 2027", "…, 10 times". `times: false`
2260
- leaves the times out, for a table with its own time column. A rule it
2261
- can't read shows as stored, never blank.
2260
+ leaves the times out, for a table with its own time column. An app
2261
+ whose weeks start on Sunday passes `weekStart: 'SU'`: an every-N-weeks
2262
+ rule whose WKST isn't the app's says so (", weeks start Mon"), and a
2263
+ week's days read from its first ("Sun and Wed"). A rule it can't read
2264
+ shows as stored, never blank.
2262
2265
  - **Next** is "Tue, Dec 8, 9:00 AM", the year only when it isn't this
2263
- one; a rule that has ended (UNTIL passed, COUNT used up) says Ended, in
2266
+ one, or "Tue, Dec 8" with `{ time: false }` (a record whose times are
2267
+ its own); a rule that has ended (UNTIL passed, COUNT used up) says Ended, in
2264
2268
  muted text. For a `fromCompletion` repeat whose next depends on being
2265
2269
  done, use the server's `next_at` if it sends one; `nextOccurrence`
2266
2270
  counts from the schedule's start.
@@ -28,16 +28,16 @@
28
28
  - [Several values over time](#several-values-over-time) · lines 1207–1244
29
29
  - [A list as a board](#a-list-as-a-board) · lines 1246–1297
30
30
  - [A list as cards](#a-list-as-cards) · lines 1299–1345
31
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1347–1376
32
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1378–1430
33
- - [A few equal things](#a-few-equal-things) · lines 1432–1516
34
- - [An overview page](#an-overview-page) · lines 1518–1581
35
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1582–1633
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1635–1750
37
- - [Picking at random](#picking-at-random) · lines 1752–1783
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1785–1852
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1854–1879
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1881–1977
31
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1347–1383
32
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1385–1446
33
+ - [A few equal things](#a-few-equal-things) · lines 1448–1532
34
+ - [An overview page](#an-overview-page) · lines 1534–1605
35
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1606–1664
36
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1666–1790
37
+ - [Picking at random](#picking-at-random) · lines 1792–1823
38
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1825–1892
39
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1894–1919
40
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1921–2017
41
41
 
42
42
  <!-- /index -->
43
43
 
@@ -1370,6 +1370,13 @@ row under the header, across the page at every width.
1370
1370
  - **An empty value reads as a dash** (`emptyLabel`, 4.81; "Not set"
1371
1371
  before), in body type and muted, read by a screen reader as "Not set".
1372
1372
  Never a blank.
1373
+ - **A tip and an action on a value** (4.120), as a rail fact has:
1374
+ `info` is a few words behind a small info button after the value (a
1375
+ tooltip on hover and keyboard focus, a caption line under the value on
1376
+ a touch screen, read with the value by a screen reader), and `action`
1377
+ (`{ label, icon?, onClick | render }`) a small outline button under it.
1378
+ Both are there at rest, so nothing moves on hover. `hint` stays the
1379
+ caption line ("of 12"); `info` is the tooltip.
1373
1380
  - **Three to five.** It's what the page is for at a glance; anything
1374
1381
  more is a section's label/value rows.
1375
1382
  - **`subtitle`** is the line under the title: what the record is for,
@@ -1403,6 +1410,15 @@ into a table, a record or an overview.
1403
1410
  button just before New, which stays the one filled button. Only one:
1404
1411
  anything else is in ⋯. On a phone it folds into ⋯ as the menu's first
1405
1412
  item (⋯ shows there for it alone if nothing else is in the menu).
1413
+ Its `hint` (4.120) is a short line under the button ("12 searches
1414
+ left"), in caption type and the muted tone, describing the button to a
1415
+ screen reader; the buttons stay level, the line hanging below. On a
1416
+ phone it's under the words of ⋯'s first item. **A line of context**
1417
+ (`description`, 4.120): one short muted sentence under the title, for a
1418
+ list that needs it ("Each search runs against the catalog once a
1419
+ day."). It wraps in the header's width and never widens a framed
1420
+ table's shared width; on a phone it's under the title and its buttons.
1421
+ One sentence: anything longer belongs in a help page.
1406
1422
  - **`Timeline`: a record's dated history.** `items` newest first
1407
1423
  (`{ id, date, dateTime?, kind?, body, edit? }`): dates in a tabular
1408
1424
  column on the left, a dot and a thin line, the entry on the right with
@@ -1568,6 +1584,13 @@ read alike.
1568
1584
  `ErrorState` in the card), and `empty` (a part with nothing yet: "Nothing
1569
1585
  yet" in the tile, `PartEmpty` and its one way to start in the card). An
1570
1586
  empty part stays on the page: hiding it makes the part forgotten.
1587
+ - **Links out** (`links`, 4.120): a short list of pages outside the app
1588
+ (`{ label, href, icon? }`), one section after the parts under a
1589
+ "Links" heading (`linksTitle`). Each link is its label, its icon
1590
+ before it if it has one, and the external-link mark, opening in a new
1591
+ tab and saying so to a screen reader. In a row from 48rem, one per
1592
+ line on a phone, each 44px tall. A few: a module's whole bookmark list
1593
+ is a list of its own.
1571
1594
  - **One card anatomy on a hub** (`WidgetCard`): `to` makes the title the
1572
1595
  link with a chevron (in place of the header's `link`), `value` the
1573
1596
  headline in the numeric type, `line` one muted line under it, and
@@ -1578,7 +1601,8 @@ read alike.
1578
1601
 
1579
1602
  Measured with axe and the glyph check in both themes and every palette
1580
1603
  (fixture `app/OverviewPage`); `e2e/overview-page.spec.ts` clicks the
1581
- tiles, Escape and the accordion.
1604
+ tiles, Escape and the accordion, and `e2e/overview-links.spec.ts` checks
1605
+ the links.
1582
1606
  ## A record's header and empty values
1583
1607
 
1584
1608
  The record page standard (4.81): the same header on every record, the
@@ -1599,6 +1623,13 @@ data on each its own.
1599
1623
  (12px apart, 6px between badges), centred on the title's line; a title
1600
1624
  too long for both pushes them to the next line, starting under it.
1601
1625
  `subtitle` is the line below, in muted body type.
1626
+ - **Badges edited in place** (an inline `EditableValue` around a
1627
+ `Badge`) keep their pencil's room at rest (4.120), as the strip's values
1628
+ do, so hovering one moves nothing after it and never wraps the line.
1629
+ - **A hint under a header button** (`ActionHint`, 4.120): `<ActionHint
1630
+ hint="12 searches left"><Button>Search</Button></ActionHint>` draws a
1631
+ short caption line under the button, describing it; the header's
1632
+ buttons line up by their tops, so it stays level with the rest.
1602
1633
  - **Actions**: the record's own commands in words (New visit, Mark
1603
1634
  done), then the universal ones as `IconAction`s: Print Notes
1604
1635
  (`printer`, EntityView's own) and Delete (`trash-2`, the destructive
@@ -1721,6 +1752,15 @@ its short facts the last tab, Details. A mark goes left of the title.
1721
1752
  drawn the same in Details on a phone. An empty one reads its
1722
1753
  `emptyLabel` ("Not rated"), not a row of empty stars. Edited in place
1723
1754
  like any fact (`edit`), usually `inPlace.select` over the scores.
1755
+ - **A yes/no** (`kind: 'switch'`, 4.120) is a switch on the value's
1756
+ line, never a two-choice select: `checked`, `onCheckedChange` (return
1757
+ the save's promise and the switch shows the new state, busy, until it
1758
+ lands, going back if it fails), and optional `on`/`off` words after it
1759
+ ("With the team", "Only me"). Its accessible name is the fact's label;
1760
+ a click, Space or Enter toggles it. Both words keep their room, so
1761
+ toggling or hovering moves nothing, and it works the same in Details on
1762
+ a phone. `disabled` with a `hint` for one that can't change here.
1763
+ Printed, it's its word (or Yes/No).
1724
1764
  - **Icons on badges** (4.115): a `badges` fact's items may each carry an
1725
1765
  icon (a component or a node) before the label, at the badge's icon size
1726
1766
  in the muted tone a list's item icons have; items without one stay
@@ -57,7 +57,9 @@ One or two sentences: what one record is, and who uses the screens.
57
57
  year, no year: `'MM-DD'`; the foundation's `MonthDayField`; say
58
58
  whether it's optional), `recurrence` (how it repeats: the
59
59
  foundation's `Recurrence` schema and `RecurrenceField`; say whether
60
- it's optional).
60
+ it's optional, whether its times are the record's own fields
61
+ (`times={false}`), and the day the app's weeks start on when it
62
+ isn't Monday (`weekStart`)).
61
63
  - *Not supported yet:* a yes/no that can also be unset (three states),
62
64
  file, and anything else.
63
65
  Write it anyway with a note; the playbook will stop and raise it
@@ -126,10 +126,29 @@ the same rules and agree on every next occurrence.
126
126
  - **The value**: `{ rule, start, times, timeZone, fromCompletion }`.
127
127
  `rule` is RFC 5545's RRULE without DTSTART (`FREQ=MONTHLY;BYDAY=2TU`):
128
128
  FREQ daily to yearly, INTERVAL, BYDAY with an nth (`2TU`, `-1FR`),
129
- BYMONTHDAY (`-1` the last day), BYMONTH, UNTIL (a date) or COUNT.
129
+ BYMONTHDAY (`-1` the last day), BYMONTH, UNTIL (a date) or COUNT, and
130
+ WKST (4.119, below).
130
131
  `start` is the first day it can fall on; each of `times` is an
131
132
  occurrence on every day the rule falls on, read in `timeZone`. A day a
132
133
  month lacks is skipped (the 31st, Feb 29), as in RFC 5545.
134
+ - **Which day a week starts on (WKST, 4.119)**: weeks start on Monday
135
+ unless the rule says `WKST=SU` (or any weekday; `WKST=MO` is the
136
+ default and isn't stored). It moves only an every-N-weeks rule with
137
+ days: from Wednesday 2026-11-04, `FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,WE`
138
+ next falls on Sunday the 8th (its Monday week runs to the 8th), and
139
+ with `;WKST=SU` on Sunday the 15th (its Sunday week began on the 1st,
140
+ before the start). Both sides agree, as python-dateutil and `rrule` do.
141
+ An app whose weeks start on Sunday gives `RecurrenceField` and
142
+ `inPlace.recurrence` `weekStart="SU"`: every weekly rule they build
143
+ (the presets and what's typed) gets `WKST=SU`, and "weeks start mon"
144
+ typed says otherwise. Give the same `weekStart` to `formatRecurrence`
145
+ in a Repeats cell, which otherwise says ", weeks start Sun" on a rule
146
+ where it matters. A rule stored without WKST keeps counting from
147
+ Monday; an app that wants its old every-N-weeks rules counted from
148
+ Sunday rewrites them in a migration of its own (append `;WKST=SU`).
149
+ The rule pattern in `openapi/foundation.yaml` allows WKST since 4.119:
150
+ an app copies the new `Recurrence` when it stores one (an older copy
151
+ still passes `check-contract`, but its mocks and spec refuse WKST).
133
152
  - **The columns**: the app's reminders model inherits
134
153
  `foundation_backend.recurrence_models.RecurringReminderFields` and its
135
154
  migration adds them: `recurrence` (JSON), `next_at`, `sent_at`,
@@ -164,6 +183,15 @@ the same rules and agree on every next occurrence.
164
183
  list `formatRecurrence` for a Repeats column and `nextOccurrence` with
165
184
  `formatOccurrence` for a Next one (cell-patterns.md "A repeat and its
166
185
  next time").
186
+ - **A record whose times are its own fields** (a calendar event with a
187
+ start and an end, 4.119): `RecurrenceField times={false}` (and
188
+ `inPlace.recurrence({ times: false })`) says only dates: the preview
189
+ lists the next days from today on ("Sun, Nov 15"), the label and the
190
+ box leave the times out, and "at 9am" typed is refused. The value still
191
+ carries `times`, as the schema needs one: the value's own, else
192
+ `defaultTimes` (09:00 when not given; `['00:00']` reads best for a
193
+ calendar). In the list, `formatRecurrence(value, { times: false })` and
194
+ `formatOccurrence(next, zone, { time: false })`.
167
195
 
168
196
  ## A Done button on the notification (4.104)
169
197
 
@@ -261,7 +261,7 @@ export interface components {
261
261
  };
262
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
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". */
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), and WKST (the day weeks start on, MO when left out: it moves an every-N-weeks rule's weeks). "FREQ=MONTHLY;BYDAY=2TU", "FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,WE;WKST=SU". */
265
265
  rule: string;
266
266
  /**
267
267
  * Format: date
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from 'react';
2
+ export type ActionHintProps = {
3
+ /** A few words under the button. */
4
+ hint: string;
5
+ /** The button (one element): it's given `aria-describedby` for the line. */
6
+ children: ReactNode;
7
+ className?: string;
8
+ };
9
+ export declare function ActionHint({ hint, children, className }: ActionHintProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A short line under a header button (4.120): what the button has left
3
+ // or costs ("12 searches left"), in caption type and the muted tone,
4
+ // centred under it on one line. The row it's in lines its buttons up by
5
+ // their tops (ListHeader and EntityView do, while one has a hint), so the
6
+ // button stays level with the others and the line hangs below. The button
7
+ // is described by it, so a screen reader hears the line with its name.
8
+ //
9
+ // ListHeader's `secondaryAction` takes it as `hint`; a record header's
10
+ // `actions` (EntityView) wrap the button: `<ActionHint hint="12 searches
11
+ // left"><Button>Search</Button></ActionHint>`.
12
+ import { cloneElement, isValidElement, useId } from 'react';
13
+ import { cn } from 'cn';
14
+ export function ActionHint({ hint, children, className }) {
15
+ const id = useId();
16
+ const button = isValidElement(children)
17
+ ? cloneElement(children, {
18
+ 'aria-describedby': cn(children.props['aria-describedby'], id),
19
+ })
20
+ : children;
21
+ return (_jsxs("span", { "data-slot": "action-hint", className: cn('inline-flex flex-col items-center gap-0.5', className), children: [button, _jsx("span", { id: id, "data-slot": "action-hint-text", className: "whitespace-nowrap type-caption text-muted-foreground", children: hint })] }));
22
+ }
@@ -1,7 +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
+ import { type Recurrence, type WeekdayCode } from '../../lib/recurrence.js';
5
5
  import { type ChoiceButtonsOption } from './choice-buttons.js';
6
6
  import type { EditInPlace } from './edit-in-place.js';
7
7
  /** What the value saves as: with `required: true` never `null` (a blank is refused). */
@@ -92,6 +92,10 @@ export type InPlaceRecurrenceConfig<TRequired extends boolean = boolean> = {
92
92
  timeZone?: string;
93
93
  /** The times a new repeat starts with. Defaults to 09:00. */
94
94
  defaultTimes?: string[];
95
+ /** RecurrenceField's `times` (4.114): false for a record whose times are its own fields; the value at rest says no times either. */
96
+ times?: boolean;
97
+ /** RecurrenceField's `weekStart` (4.114): `'SU'` for an app whose weeks start on Sunday. */
98
+ weekStart?: WeekdayCode;
95
99
  /** Today, `'YYYY-MM-DD'`, and "now", for a fixed preview (tests). Default to the clock. */
96
100
  today?: string;
97
101
  now?: Date;
@@ -190,8 +190,8 @@ function recurrenceKind(config) {
190
190
  const problem = recurrenceProblem(draft);
191
191
  return problem ? { ok: false, message: problem } : { ok: true, value: normalizeRecurrence(draft) };
192
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 })),
193
+ show: (value) => (value ? formatRecurrence(value, { locale: config.locale, times: config.times, weekStart: config.weekStart }) : null),
194
+ control: (props) => (_jsx(RecurrenceField, { id: props.id, value: props.value, onChange: props.onChange, onProblem: props.onProblem, timeZone: config.timeZone, defaultTimes: config.defaultTimes, times: config.times, weekStart: config.weekStart, today: config.today, now: config.now, locale: config.locale, invalid: props.invalid, readOnly: props.disabled, "aria-label": props.label, "aria-describedby": props.describedBy })),
195
195
  };
196
196
  }
197
197
  function selectKind(config) {
@@ -66,6 +66,23 @@ export type EntityViewFactValue =
66
66
  max?: number;
67
67
  look?: EntityViewFactRatingLook;
68
68
  word?: string;
69
+ }
70
+ /**
71
+ * A yes/no (4.120), toggled in place by a switch named by the fact's
72
+ * label. `onCheckedChange` saves it: while a promise it returns is
73
+ * pending the switch shows the new state and is busy, and if it rejects
74
+ * the switch goes back. `on`/`off` are words after the switch ("Shared",
75
+ * "Private"); give both or neither. `disabled` keeps it read-only (a
76
+ * `hint` can say why). Never empty, so `emptyLabel` doesn't apply, and
77
+ * it isn't an `edit` fact: the switch is its own editor.
78
+ */
79
+ | {
80
+ kind: 'switch';
81
+ checked: boolean;
82
+ onCheckedChange: (checked: boolean) => void | Promise<unknown>;
83
+ on?: string;
84
+ off?: string;
85
+ disabled?: boolean;
69
86
  };
70
87
  /** How a `rating` fact draws its score. */
71
88
  export type EntityViewFactRatingLook = 'stars' | 'hearts' | 'bar';
@@ -123,8 +140,8 @@ export type EntityViewFact = EntityViewFactValue & {
123
140
  /** A small button under the value (4.115), drawn in the rail and in Details alike. */
124
141
  action?: EntityViewFactAction;
125
142
  };
126
- /** A fact as the view draws it: `null` when empty. */
127
- export declare function factValue(fact: EntityViewFactValue): ReactNode;
143
+ /** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
144
+ export declare function factValue(fact: EntityViewFactValue, label?: string): ReactNode;
128
145
  /** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
129
146
  export declare function factsAsFields(facts: readonly EntityViewFact[]): {
130
147
  label: string;
@@ -8,6 +8,7 @@ import { FactList, FactListItem } from './fact-list.js';
8
8
  import { RatingScore } from './rating-score.js';
9
9
  import { StepBar } from './step-bar.js';
10
10
  import { StatusMark } from './status-mark.js';
11
+ import { FactSwitch } from './fact-extras.js';
11
12
  const LINK_CLASS = 'rounded-sm font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50';
12
13
  // A badge item's icon in the muted tone a list's item icons have
13
14
  // (FactList's marks): a component drawn at the badge's icon size, or the
@@ -18,9 +19,11 @@ function badgeIcon(icon) {
18
19
  const Icon = icon;
19
20
  return (_jsx("span", { "data-slot": "entity-view-fact-badge-icon", "aria-hidden": "true", "data-icon": "inline-start", className: "inline-flex shrink-0 text-muted-foreground", children: isComponent ? _jsx(Icon, { "aria-hidden": "true", className: "size-3" }) : icon }));
20
21
  }
21
- /** A fact as the view draws it: `null` when empty. */
22
- export function factValue(fact) {
22
+ /** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
23
+ export function factValue(fact, label = '') {
23
24
  switch (fact.kind) {
25
+ case 'switch':
26
+ return _jsx(FactSwitch, { fact: fact, label: label });
24
27
  case 'status':
25
28
  return _jsx(StatusMark, { kind: fact.status, children: fact.word });
26
29
  case 'text': {
@@ -58,9 +61,10 @@ export function factValue(fact) {
58
61
  export function factsAsFields(facts) {
59
62
  return statusFirst(facts).map((fact) => ({
60
63
  label: fact.label,
61
- value: factValue(fact),
64
+ value: factValue(fact, fact.label),
62
65
  emptyLabel: fact.emptyLabel,
63
- edit: fact.edit,
66
+ // A switch is its own editor: an `edit` would wrap it in another.
67
+ edit: fact.kind === 'switch' ? undefined : fact.edit,
64
68
  hint: fact.hint,
65
69
  action: fact.action,
66
70
  recordStatus: fact.recordStatus,
@@ -97,7 +97,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
97
97
  // ones behind an "N empty" toggle, still edited in place once opened.
98
98
  import { createContext, useContext, useEffect, useId, useState, useSyncExternalStore } from 'react';
99
99
  import { Link, useLocation, useNavigate } from 'react-router';
100
- import { ArrowLeftIcon, ChevronDownIcon, InfoIcon, SearchXIcon } from 'lucide-react';
100
+ import { ArrowLeftIcon, ChevronDownIcon, SearchXIcon } from 'lucide-react';
101
101
  import { cn } from 'cn';
102
102
  import { ErrorState } from './error-state.js';
103
103
  import { Button } from '../ui/button.js';
@@ -119,8 +119,9 @@ import { FIELD_LABEL, FIELD_ROW, FIELD_ROW_BASE, FIELD_VALUE } from './field-row
119
119
  import { PageTrail } from './page-trail.js';
120
120
  import { usePageTrail } from './page-trail-context.js';
121
121
  import { entityViewTabSlug } from '../../lib/entity-view-tab.js';
122
+ import { FactAction, FactHint } from './fact-extras.js';
123
+ import { KeepPencilRoomContext } from './keep-pencil-room.js';
122
124
  import { factsAsFields, statusSectionFirst, useWideParent } from './entity-view-facts.js';
123
- import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip.js';
124
125
  // The view's empty text and whether fields cards fold their empty ones,
125
126
  // for every section without threading them through each layout.
126
127
  const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
@@ -144,23 +145,6 @@ function OrEmpty({ value, emptyLabel }) {
144
145
  }
145
146
  // A preset shows its own value unless the screen gives one.
146
147
  const fieldValue = (field) => (field.value !== undefined ? field.value : field.edit?.shown);
147
- // A fact's hint (4.115): an info button after the value, its words in a
148
- // tooltip on hover and on keyboard focus. On a touch screen, where a
149
- // tooltip has no hover to open it, the words are a line under the value
150
- // instead (and the button goes). A screen reader reads the words with the
151
- // value either way: the line is there for it, only visually hidden on a
152
- // mouse's screen, and it describes the button.
153
- function FactHint({ label, hint }) {
154
- const id = useId();
155
- return (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "entity-view-fact-hint", "aria-label": `About ${label}`, "aria-describedby": id, className: "inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:hidden" }), children: _jsx(InfoIcon, { "aria-hidden": "true", className: "size-3.5" }) }), _jsx(TooltipContent, { children: hint })] }), _jsx("span", { id: id, "data-slot": "entity-view-fact-hint-text", className: "sr-only basis-full type-caption text-muted-foreground pointer-coarse:not-sr-only", children: hint })] }));
156
- }
157
- // A fact's action (4.115): a small button under its value, or the app's
158
- // own action given that button (`render`), so its dialog opens from it.
159
- function FactAction({ action }) {
160
- const Icon = action.icon;
161
- const button = (_jsxs(Button, { type: "button", variant: "outline", size: "xs", "data-slot": "entity-view-fact-action", onClick: action.render ? undefined : action.onClick, className: "pointer-coarse:min-h-11", children: [Icon && _jsx(Icon, { "aria-hidden": "true", "data-icon": "inline-start" }), action.label] }));
162
- return _jsx("div", { className: "flex", children: action.render ? action.render(button) : button });
163
- }
164
148
  function FieldRow({ field, place }) {
165
149
  const value = fieldValue(field);
166
150
  // An editable row is the target as a whole (4.88, F15/F18): the list's
@@ -481,5 +465,5 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
481
465
  }
482
466
  return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsx(BesideFactsRailContext.Provider, { value: railFacts.length > 0, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
483
467
  ? RAIL_LAYOUT.page
484
- : cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && '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: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, 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 }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((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 && (!card || cardStrip) && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }) }));
468
+ : cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && '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: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx(KeepPencilRoomContext.Provider, { value: true, children: _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 }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 has-[[data-slot=action-hint]]:items-start sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && (!card || cardStrip) && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }) }));
485
469
  }
@@ -0,0 +1,16 @@
1
+ import type { EntityViewFactAction, EntityViewFactValue } from './entity-view-facts.js';
2
+ export declare function FactHint({ label, hint }: {
3
+ label: string;
4
+ hint: string;
5
+ }): import("react").JSX.Element;
6
+ export declare function FactAction({ action }: {
7
+ action: EntityViewFactAction;
8
+ }): import("react").JSX.Element;
9
+ type SwitchFact = Extract<EntityViewFactValue, {
10
+ kind: 'switch';
11
+ }>;
12
+ export declare function FactSwitch({ fact, label }: {
13
+ fact: SwitchFact;
14
+ label: string;
15
+ }): import("react").JSX.Element;
16
+ export {};
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // A fact's extras (4.115), shared by the facts rail, Details and the
3
+ // strip's values (KeyStats, 4.120): a hint behind an info button, and a
4
+ // small action button under the value. And a `switch` fact's switch (4.120).
5
+ import { useId, useState } from 'react';
6
+ import { InfoIcon } from 'lucide-react';
7
+ import { cn } from 'cn';
8
+ import { Button } from '../ui/button.js';
9
+ import { Switch } from '../ui/switch.js';
10
+ import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip.js';
11
+ import { usePrinting } from './print-context.js';
12
+ // A fact's hint (4.115): an info button after the value, its words in a
13
+ // tooltip on hover and on keyboard focus. On a touch screen, where a
14
+ // tooltip has no hover to open it, the words are a line under the value
15
+ // instead (and the button goes). A screen reader reads the words with the
16
+ // value either way: the line is there for it, only visually hidden on a
17
+ // mouse's screen, and it describes the button.
18
+ export function FactHint({ label, hint }) {
19
+ const id = useId();
20
+ return (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "entity-view-fact-hint", "aria-label": `About ${label}`, "aria-describedby": id, className: "inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:hidden" }), children: _jsx(InfoIcon, { "aria-hidden": "true", className: "size-3.5" }) }), _jsx(TooltipContent, { children: hint })] }), _jsx("span", { id: id, "data-slot": "entity-view-fact-hint-text", className: "sr-only basis-full type-caption text-muted-foreground pointer-coarse:not-sr-only", children: hint })] }));
21
+ }
22
+ // A fact's action (4.115): a small button under its value, or the app's
23
+ // own action given that button (`render`), so its dialog opens from it.
24
+ export function FactAction({ action }) {
25
+ const Icon = action.icon;
26
+ const button = (_jsxs(Button, { type: "button", variant: "outline", size: "xs", "data-slot": "entity-view-fact-action", onClick: action.render ? undefined : action.onClick, className: "pointer-coarse:min-h-11", children: [Icon && _jsx(Icon, { "aria-hidden": "true", "data-icon": "inline-start" }), action.label] }));
27
+ return _jsx("div", { className: "flex", children: action.render ? action.render(button) : button });
28
+ }
29
+ // A `switch` fact's switch and its word. The shown state is the app's
30
+ // `checked` unless a save is in flight, when it's the state being saved.
31
+ export function FactSwitch({ fact, label }) {
32
+ const printing = usePrinting();
33
+ const [saving, setSaving] = useState(null);
34
+ const checked = saving ?? fact.checked;
35
+ const words = fact.on !== undefined && fact.off !== undefined ? { on: fact.on, off: fact.off } : undefined;
36
+ if (printing)
37
+ return _jsx("span", { "data-slot": "entity-view-fact-switch-print", children: words ? (checked ? words.on : words.off) : checked ? 'Yes' : 'No' });
38
+ const onCheckedChange = (next) => {
39
+ // One save at a time: a toggle while one is in flight waits for it (focus stays).
40
+ if (saving !== null)
41
+ return;
42
+ const result = fact.onCheckedChange(next);
43
+ if (!result || typeof result.then !== 'function')
44
+ return;
45
+ setSaving(next);
46
+ result.then(() => setSaving(null), () => setSaving(null));
47
+ };
48
+ return (_jsxs("span", { "data-slot": "entity-view-fact-switch", className: "inline-flex max-w-full items-center gap-2 align-middle", children: [_jsx(Switch, { checked: checked, onCheckedChange: onCheckedChange, disabled: fact.disabled, "aria-label": label, "aria-busy": saving !== null || undefined }), words && (_jsxs("span", { "aria-hidden": "true", "data-slot": "entity-view-fact-switch-word", className: "grid min-w-0 text-foreground", children: [_jsx("span", { className: cn('col-start-1 row-start-1 truncate', !checked && 'invisible'), children: words.on }), _jsx("span", { className: cn('col-start-1 row-start-1 truncate', checked && 'invisible'), children: words.off })] }))] }));
49
+ }