@tristan2828/ui-foundation 4.114.0 → 4.117.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.
@@ -15,18 +15,18 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 755–832
16
16
  - Step 9: Register the nav entry and route names · lines 833–847
17
17
  - Step 10: `npm run verify`. · lines 848–850
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1261
19
- - [The record view](#the-record-view) · lines 1005–1106
20
- - [Forms](#forms) · lines 1108–1178
21
- - [Dialogs](#dialogs) · lines 1180–1211
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1213–1261
23
- - [What not to copy](#what-not-to-copy) · lines 1263–1295
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1297–1314
25
- - [Deleting](#deleting) · lines 1316–1347
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1349–1370
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1372–1381
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1384–1426
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1428–1464
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
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -1023,7 +1023,9 @@ A record uses the parts it has, in this order:
1023
1023
  notes is an icon of EntityView's own.
1024
1024
  - **Strip**: the record's key numbers and ratings (`strip`, a
1025
1025
  `KeyStats`, as wide as its numbers since 4.98), each edited in place
1026
- where it's shown.
1026
+ where it's shown. An inline `EditableValue` there keeps its pencil's room
1027
+ at rest (4.115), so nothing moves on hover; an app's own wrapping row of
1028
+ inline values passes `keepPencilRoom` for the same.
1027
1029
  - **Sections** (4.98, no right rail): one column. The label/value facts
1028
1030
  are placed `rail`, which makes them the last tab, Details, on a record
1029
1031
  with tabs, and keeps them in the column on one without; the long text
@@ -1082,6 +1084,41 @@ A record uses the parts it has, in this order:
1082
1084
  nothing isn't drawn. On a phone (or a view under 60rem) the rail's
1083
1085
  sections are back in Details, as rows.
1084
1086
  - `edit` works on a fact as on a field; at rest it's drawn by its kind.
1087
+ - **The status first** (4.115): a record's status is the first fact at
1088
+ the top of the right rail, edited in place there; a status that
1089
+ changes only through an action stays read-only, with the action as a
1090
+ small button under it and a tooltip saying why. Mark it
1091
+ `recordStatus: true` and the view puts it first, wherever it is in
1092
+ `facts`:
1093
+
1094
+ ```tsx
1095
+ { label: 'Status', recordStatus: true, kind: 'status', status: STATUS_KINDS[record.status], word: STATUS_LABELS[record.status],
1096
+ // Editable in place:
1097
+ edit: inPlace.select({ ... }),
1098
+ // Or, changed only by an action (closing records a date and a reason):
1099
+ hint: 'Changes when the record is closed.',
1100
+ action: { label: 'Close…', render: (button) => <CloseRecord record={record} trigger={button} /> } }
1101
+ ```
1102
+
1103
+ `action` is a small button under the value: `onClick`, or `render`,
1104
+ which is given the button so the app's own action (its dialog) opens
1105
+ from it with the same look (`<DialogTrigger render={button} />`).
1106
+ `hint` is an info button after the value, its words in a tooltip on
1107
+ hover and keyboard focus, and a line under the value on a touch
1108
+ screen. Both are drawn in Details too, where the rail folds.
1109
+ - A `badges` item may be `{ label, icon }` (4.115): the icon (a
1110
+ component or a node) before the label, in the muted tone.
1111
+ - **A rating** (4.117) is `kind: 'rating'`, drawn as the list's cells
1112
+ draw it, never as "4 of 5" text: stars (the default) or hearts for a
1113
+ score out of `max` (5), the step bar for a quality level. `null` is
1114
+ empty (its `emptyLabel`). Edited in place with `inPlace.select`:
1115
+
1116
+ ```tsx
1117
+ { label: 'My Rating', kind: 'rating', look: 'hearts', value: record.rating, emptyLabel: 'Not rated',
1118
+ edit: inPlace.select({ value: record.rating, options: [1, 2, 3, 4, 5].map((n) => ({ value: n, label: `${n} of 5` })),
1119
+ emptyLabel: 'Not rated', save: (rating) => save({ rating }) }) },
1120
+ { label: 'Quality', kind: 'rating', look: 'bar', value: QUALITY[record.quality].value, word: QUALITY[record.quality].word },
1121
+ ```
1085
1122
  - **A tiny record** (4.98: a few fields and no notes, like a lookup's
1086
1123
  row) opens as a small card: `RecordDialogRoute look="card"`, usually
1087
1124
  with `fullPage={false}`. A 420px dialog (a sheet on a phone), its
@@ -13,37 +13,37 @@
13
13
  - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 298–310
14
14
  - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 312–333
15
15
  - [8. Date, relative](#8-date-relative) · lines 335–372
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 374–422
17
- - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 392–422
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 424–474
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 442–474
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 476–516
21
- - [12. Boolean](#12-boolean) · lines 518–548
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 550–586
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 570–586
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 588–605
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 607–716
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 633–716
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 718–764
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 766–839
29
- - [18. Editable value](#18-editable-value) · lines 841–1544
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1176–1244
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1246–1282
32
- - [A link and its label](#a-link-and-its-label) · lines 1284–1308
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1310–1443
34
- - [In a table's rows](#in-a-tables-rows) · lines 1445–1530
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1532–1544
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1546–1612
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1614–1678
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1680–1778
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1780–1809
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1811–1849
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1851–1927
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1929–1952
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 1954–2157
44
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2102–2157
45
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2159–2195
46
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2197–2242
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 374–433
17
+ - [Three variants the package draws: a step bar, a star and a score](#three-variants-the-package-draws-a-step-bar-a-star-and-a-score) · lines 392–433
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 435–485
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 453–485
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 487–527
21
+ - [12. Boolean](#12-boolean) · lines 529–559
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 561–597
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 581–597
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 599–616
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 618–727
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 644–727
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 729–775
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 777–850
29
+ - [18. Editable value](#18-editable-value) · lines 852–1555
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1187–1255
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1257–1293
32
+ - [A link and its label](#a-link-and-its-label) · lines 1295–1319
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1321–1454
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1456–1541
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1543–1555
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1557–1623
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1625–1689
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1691–1789
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1791–1820
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1822–1860
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1862–1938
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1940–1963
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
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2113–2184
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
47
47
 
48
48
  <!-- /index -->
49
49
 
@@ -389,7 +389,7 @@ own state.
389
389
  does not check icon contrast. That's a defensible choice — make it
390
390
  deliberately, in a comment, not by accident.
391
391
 
392
- ### Two variants the package draws: a step bar and a star
392
+ ### Three variants the package draws: a step bar, a star and a score
393
393
 
394
394
  Both are in the package's fixtures (`patterns/Scales`), every value on
395
395
  the page and on a card, measured by axe and the glyph check in both
@@ -418,7 +418,18 @@ themes. Each is one image to a screen reader, named in words.
418
418
  <RatingStar value={OWNED[o].value /* 'full' | 'half' | 'empty' */} word={OWNED[o].word} />
419
419
  ```
420
420
 
421
- - Both draw in `foreground`. Tone one only as pattern 5 would (a `*-text`
421
+ - **`RatingScore`, a score out of a few** (4.117): `max` stars (the
422
+ default) or hearts (`glyph="heart"`), the first `value` filled in
423
+ `foreground`, the rest outlines in `muted-foreground` (which clears 3:1,
424
+ so an empty glyph is still seen). Named "4 of 5";
425
+ pass the field in `label` where the column doesn't give it. The facts
426
+ rail's `rating` fact draws it too.
427
+
428
+ ```tsx
429
+ {row.rating === null ? <Muted>Not rated</Muted> : <RatingScore value={row.rating} glyph="heart" />}
430
+ ```
431
+
432
+ - All three draw in `foreground`. Tone one only as pattern 5 would (a `*-text`
422
433
  class in `className`), never by band alone.
423
434
 
424
435
  ## 10. Summary in the cell, detail in a popover
@@ -2145,6 +2156,22 @@ header row ends where the card does:
2145
2156
  ("Table Settings, Grouped by Status") and a dot marks it. Fold All
2146
2157
  stays a button of its own while grouped. On a phone it holds Group By
2147
2158
  alone.
2159
+ - **One more button beside New** (`secondaryAction`, 4.117), in the
2160
+ header in or out of the table: a list's second most common action, as
2161
+ an outline button just before New, which stays the primary.
2162
+
2163
+ ```tsx
2164
+ <ListHeader title="Feeds" count={total}
2165
+ secondaryAction={{ label: 'Refresh Now', icon: RefreshCwIcon, onClick: () => refresh.mutate(), disabled: refresh.isPending }}
2166
+ newAction={{ label: 'New Feed', to: '/feeds/new' }} />
2167
+ ```
2168
+
2169
+ One at most: a third action goes in ⋯ (`more`). On a phone it's ⋯'s
2170
+ first item, so the row keeps the title, ⋯ and New; ⋯ shows on a phone
2171
+ for it alone when nothing else is in the menu. The fixtures'
2172
+ `app/ListHeader` Secondary action story, and
2173
+ `e2e/list-header-secondary.spec.ts` (its place, the fold, axe in both
2174
+ themes at both widths).
2148
2175
  - **Siblings** are the page's peers, a switch of links beside the title,
2149
2176
  the current one marked (`aria-current="page"`); they don't go in ⋯,
2150
2177
  which keeps what's left. Two or more; on a phone the switch has its own
@@ -29,15 +29,15 @@
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
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–1425
33
- - [A few equal things](#a-few-equal-things) · lines 1427–1511
34
- - [An overview page](#an-overview-page) · lines 1513–1576
35
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1577–1628
36
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1630–1711
37
- - [Picking at random](#picking-at-random) · lines 1713–1744
38
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1746–1813
39
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1815–1840
40
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1842–1938
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
41
41
 
42
42
  <!-- /index -->
43
43
 
@@ -1397,7 +1397,12 @@ into a table, a record or an overview.
1397
1397
  framed DataTable's `pageHeader` (4.106, C3) it's as wide as the
1398
1398
  table, so ⋯ and New end on the card's right edge. The menu is as
1399
1399
  wide as its longest item and never wraps one (4.105), as is a row's ⋯
1400
- menu.
1400
+ menu. **One more button beside New** (`secondaryAction`, 4.117) for
1401
+ the list's second most common action ("Refresh Now", "Add from
1402
+ Catalog"): `{ label, icon?, onClick | to, disabled? }`, an outline
1403
+ button just before New, which stays the one filled button. Only one:
1404
+ anything else is in ⋯. On a phone it folds into ⋯ as the menu's first
1405
+ item (⋯ shows there for it alone if nothing else is in the menu).
1401
1406
  - **`Timeline`: a record's dated history.** `items` newest first
1402
1407
  (`{ id, date, dateTime?, kind?, body, edit? }`): dates in a tabular
1403
1408
  column on the left, a dot and a thin line, the entry on the right with
@@ -1689,8 +1694,42 @@ its short facts the last tab, Details. A mark goes left of the title.
1689
1694
  bullet otherwise, in the muted colour; a wrapped line starts after the
1690
1695
  mark (a hanging indent), and items have a little room between them.
1691
1696
  Never a bare stack of links.
1697
+ - **The record's status** (4.115): a record's status is the first fact at
1698
+ the top of the right rail, edited in place there; a status that changes
1699
+ only through an action stays read-only, with the action as a small
1700
+ button under it and a tooltip saying why. Mark it `recordStatus: true`
1701
+ and EntityView draws it first, whatever its place in `facts` and its
1702
+ section's among the rail's, and first in Details where the rail folds.
1703
+ One per record.
1704
+ - **An action under a fact** (`action`, 4.115): a small outline button
1705
+ (`xs`, 44px tall on a touch screen) under the value, its words a verb
1706
+ ("Close…", an ellipsis when it opens a dialog), an icon before them if
1707
+ the app's actions have one. For the status above, and for any read-only
1708
+ fact that one action changes. Never several: more belong in the
1709
+ header's actions.
1710
+ - **Why a fact can't be edited here** (`hint`, 4.115): a few words, in a
1711
+ tooltip on a small info button after the value, shown on hover and on
1712
+ keyboard focus, and read with the button by a screen reader. A touch
1713
+ screen has no hover, so there the words are a caption line under the
1714
+ value instead. Nothing that only hover shows.
1715
+ - **A rating** (`kind: 'rating'`, 4.117) is drawn as the list's cells
1716
+ draw it: a score out of `max` (5) as stars (`RatingScore`, the
1717
+ default) or hearts (`look: 'hearts'`), a quality level as the step bar
1718
+ (`look: 'bar'`, `StepBar`, with its `word`). Never "4 of 5" as text:
1719
+ that's what a screen reader hears, one image named in words. The
1720
+ glyphs are a fixed size, so the value never moves on hover, and it's
1721
+ drawn the same in Details on a phone. An empty one reads its
1722
+ `emptyLabel` ("Not rated"), not a row of empty stars. Edited in place
1723
+ like any fact (`edit`), usually `inPlace.select` over the scores.
1724
+ - **Icons on badges** (4.115): a `badges` fact's items may each carry an
1725
+ icon (a component or a node) before the label, at the badge's icon size
1726
+ in the muted tone a list's item icons have; items without one stay
1727
+ words alone. The label always stays.
1692
1728
  - **The strip** (`KeyStats`) is as wide as its numbers (`width="content"`,
1693
- the default since 4.98), not the page's width.
1729
+ the default since 4.98), not the page's width. **Nothing in it moves on
1730
+ hover or focus** (4.115): a value edited in place inline keeps its
1731
+ pencil's room at rest there, as in a table cell, so a click lands on the
1732
+ value under the mouse, wrapped onto two lines on a phone too.
1694
1733
  - **A mark or avatar** (`leading`): left of the title, top-aligned,
1695
1734
  with the title, subtitle and badges beside it at every width. 40 to
1696
1735
  64px (`size-10` to `size-16`): an avatar round (`rounded-full`), a
@@ -16,6 +16,14 @@ export type EditableValueProps = {
16
16
  * have); under 48rem or on a touch screen a chevron, not the pencil.
17
17
  */
18
18
  look?: 'value' | 'row';
19
+ /**
20
+ * Inline, the pencil's room is kept at rest, as before 4.102, so nothing
21
+ * moves on hover or focus: a table cell (row-edit-cells.tsx), whose
22
+ * column would otherwise widen, EntityView's title, which ends its line
23
+ * and can fill it, and every value inside a <KeyStats> (4.115, which
24
+ * sets it for them: a wrapping row moved the values after it along).
25
+ */
26
+ keepPencilRoom?: boolean;
19
27
  className?: string;
20
28
  };
21
29
  /** EditableValue's own props, plus what a list's rows and its Add box need (editable-list.tsx). */
@@ -28,15 +36,9 @@ export type EditableFieldProps = EditableValueProps & {
28
36
  trigger?: (start: () => void) => ReactNode;
29
37
  /** Opens again, empty, once a save from the keyboard succeeds: adding one item after another. */
30
38
  reopenAfterKeyboardSave?: boolean;
31
- /**
32
- * Inline, the pencil's room is kept at rest, as before 4.102: a table
33
- * cell (row-edit-cells.tsx), whose column would otherwise widen on
34
- * hover, and EntityView's title, which ends its line and can fill it.
35
- */
36
- keepPencilRoom?: boolean;
37
39
  };
38
40
  export declare function EditableValue(props: EditableValueProps): import("react").JSX.Element;
39
- export declare function EditableField({ label, edit, children, layout, look, className, trigger, reopenAfterKeyboardSave, keepPencilRoom, }: EditableFieldProps): import("react").JSX.Element;
41
+ export declare function EditableField({ label, edit, children, layout, look, className, trigger, reopenAfterKeyboardSave, keepPencilRoom: keepPencilRoomProp, }: EditableFieldProps): import("react").JSX.Element;
40
42
  /**
41
43
  * While a field holds something unsaved, leaving asks first: an in-app
42
44
  * link or Back (React Router's blocker, so the app needs a data router),
@@ -22,6 +22,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
22
22
  // for two seconds (`role="status"`).
23
23
  // - `layout="inline"` (4.102): the pencil takes no room until hover or
24
24
  // focus, so nothing gaps before what follows the value on its line.
25
+ // `keepPencilRoom` (and every value inside a KeyStats, 4.115) keeps it
26
+ // at rest instead, so nothing moves on hover or focus.
25
27
  // - `look="row"` (4.88, F15 and F18): in a record's field list the row is
26
28
  // the target (edit-row.ts): it wears the list's row hover and the pencil
27
29
  // sits at its end; under 48rem or on a touch screen there's a chevron
@@ -37,6 +39,7 @@ import { Spinner } from '../ui/spinner.js';
37
39
  import { EditInPlaceContext } from './edit-in-place.js';
38
40
  import { SAVED_FOR_MS } from './edit-row.js';
39
41
  import { escapePassedThrough } from './escape-passthrough.js';
42
+ import { KeepPencilRoomContext } from './keep-pencil-room.js';
40
43
  // What a click on the shown value must leave alone: links navigate,
41
44
  // buttons and boxes do their own thing (a list item's done box ticks it).
42
45
  const INTERACTIVE = 'a[href], button, input, select, textarea, label, [role="button"], [role="link"], [role="checkbox"], [role="switch"]';
@@ -74,8 +77,10 @@ function useStore() {
74
77
  export function EditableValue(props) {
75
78
  return _jsx(EditableField, { ...props });
76
79
  }
77
- export function EditableField({ label, edit, children, layout = 'block', look = 'value', className, trigger, reopenAfterKeyboardSave = false, keepPencilRoom = false, }) {
80
+ export function EditableField({ label, edit, children, layout = 'block', look = 'value', className, trigger, reopenAfterKeyboardSave = false, keepPencilRoom: keepPencilRoomProp, }) {
78
81
  const store = useStore();
82
+ const keepRoomHere = useContext(KeepPencilRoomContext);
83
+ const keepPencilRoom = keepPencilRoomProp ?? keepRoomHere;
79
84
  const key = useId();
80
85
  const controlId = `${key}-control`;
81
86
  const describedBy = `${key}-status`;
@@ -1,4 +1,4 @@
1
- import type { ReactNode } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
  import type { StatusKind } from '../../lib/status-kinds.js';
3
3
  import type { EditInPlace } from './edit-in-place.js';
4
4
  import type { IconComponent } from './icon-component.js';
@@ -15,10 +15,10 @@ export type EntityViewFactValue =
15
15
  kind: 'text';
16
16
  text: string | number | null | undefined;
17
17
  }
18
- /** A few short labels (areas, tags) as badges. None is empty. */
18
+ /** A few short labels (areas, tags) as badges, each with its icon if it has one (4.115). None is empty. */
19
19
  | {
20
20
  kind: 'badges';
21
- items: readonly string[];
21
+ items: readonly (string | EntityViewFactBadge)[];
22
22
  }
23
23
  /** A count, and where it links to, if anywhere (`/discussions?provider=3`). */
24
24
  | {
@@ -52,7 +52,23 @@ export type EntityViewFactValue =
52
52
  | {
53
53
  kind: 'list';
54
54
  items: readonly EntityViewFactListItem[];
55
+ }
56
+ /**
57
+ * A rating (4.117), drawn as the list's cells draw it: `stars` (the
58
+ * default) or `hearts` for a score out of `max` (RatingScore), `bar` for a
59
+ * quality level of `max` steps (StepBar). `value` is how many are
60
+ * filled; `null` is empty. Named "4 of 5" for a screen reader (with
61
+ * `word` first when given: "High, 4 of 5"). `word` is shown after it.
62
+ */
63
+ | {
64
+ kind: 'rating';
65
+ value: number | null | undefined;
66
+ max?: number;
67
+ look?: EntityViewFactRatingLook;
68
+ word?: string;
55
69
  };
70
+ /** How a `rating` fact draws its score. */
71
+ export type EntityViewFactRatingLook = 'stars' | 'hearts' | 'bar';
56
72
  /** One item of a `list` fact. */
57
73
  export type EntityViewFactListItem = {
58
74
  name: string;
@@ -63,22 +79,71 @@ export type EntityViewFactListItem = {
63
79
  /** Its kind's icon (the record standard's 4I); a bullet without one. */
64
80
  icon?: IconComponent;
65
81
  };
82
+ /** One item of a `badges` fact with an icon (4.115): the icon before its label, in the muted tone. */
83
+ export type EntityViewFactBadge = {
84
+ label: string;
85
+ /** An icon component (a `LucideIcon`, an app's own mark) or a node drawn as it is. Decorative: the label says it. */
86
+ icon?: IconComponent | ReactNode;
87
+ };
88
+ /** A small button under a fact's value (4.115): "Close…" under a status that changes only through it. */
89
+ export type EntityViewFactAction = {
90
+ /** The button's words ("Close…"; an ellipsis when it opens a dialog). */
91
+ label: string;
92
+ /** Drawn before the words. */
93
+ icon?: IconComponent;
94
+ /** What a click does, when `render` isn't given. */
95
+ onClick?: () => void;
96
+ /**
97
+ * The app's own action instead (one that opens its dialog), given the
98
+ * button the fact would draw, so it can be the dialog's trigger with the
99
+ * same look: `(button) => <CloseDialog trigger={button} />`, or
100
+ * `<DialogTrigger render={button} />`. What it returns is drawn as it is.
101
+ */
102
+ render?: (button: ReactElement) => ReactNode;
103
+ };
66
104
  export type EntityViewFact = EntityViewFactValue & {
67
105
  label: string;
68
106
  /** What an empty value reads as, for this fact. Defaults to the view's `emptyText`. */
69
107
  emptyLabel?: string;
70
108
  /** Editable in place, as a field is (`inPlace.select`, `inPlace.date`); it's drawn by its kind at rest. */
71
109
  edit?: EditInPlace;
110
+ /**
111
+ * The record's status (4.115): drawn first, at the top of the rail (or
112
+ * of Details), whatever its place in `facts` or its section's among the
113
+ * rail's. One per record; usually a `kind: 'status'` fact.
114
+ */
115
+ recordStatus?: boolean;
116
+ /**
117
+ * A few words on the value (4.115), such as why it can't be edited here
118
+ * ("Changes when the record is closed"). An info button after the value
119
+ * shows it on hover and keyboard focus; a touch screen shows it as a
120
+ * line under the value instead. A screen reader reads it with the value.
121
+ */
122
+ hint?: string;
123
+ /** A small button under the value (4.115), drawn in the rail and in Details alike. */
124
+ action?: EntityViewFactAction;
72
125
  };
73
126
  /** A fact as the view draws it: `null` when empty. */
74
127
  export declare function factValue(fact: EntityViewFactValue): ReactNode;
75
- /** A facts section's facts as fields rows, for Details, the column and printing. */
128
+ /** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
76
129
  export declare function factsAsFields(facts: readonly EntityViewFact[]): {
77
130
  label: string;
78
131
  value: ReactNode;
79
132
  emptyLabel: string | undefined;
80
133
  edit: EditInPlace | undefined;
134
+ hint: string | undefined;
135
+ action: EntityViewFactAction | undefined;
136
+ recordStatus: boolean | undefined;
81
137
  }[];
138
+ /**
139
+ * The sections with the one holding the status fact (4.115) moved before
140
+ * the other sections that share its place (the rail, or a tab's
141
+ * side), so the status is the first fact there. Nothing else moves.
142
+ */
143
+ export declare function statusSectionFirst<T extends {
144
+ placement?: string;
145
+ tab?: string;
146
+ }>(sections: readonly T[]): T[];
82
147
  /** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
83
148
  export declare const FACTS_RAIL_MIN_WIDTH = 960;
84
149
  /**
@@ -1,12 +1,23 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useLayoutEffect, useState } from 'react';
2
+ import { isValidElement, useLayoutEffect, useState } from 'react';
3
3
  import { Link } from 'react-router';
4
4
  import { ExternalLinkIcon } from 'lucide-react';
5
5
  import { cn } from 'cn';
6
6
  import { Badge } from '../ui/badge.js';
7
7
  import { FactList, FactListItem } from './fact-list.js';
8
+ import { RatingScore } from './rating-score.js';
9
+ import { StepBar } from './step-bar.js';
8
10
  import { StatusMark } from './status-mark.js';
9
11
  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
+ // A badge item's icon in the muted tone a list's item icons have
13
+ // (FactList's marks): a component drawn at the badge's icon size, or the
14
+ // app's own node as it is.
15
+ function badgeIcon(icon) {
16
+ // A component: a function, or a forwardRef or memo object (a LucideIcon); an element is a node.
17
+ const isComponent = typeof icon === 'function' || (typeof icon === 'object' && icon !== null && !isValidElement(icon) && '$$typeof' in icon);
18
+ const Icon = icon;
19
+ 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
+ }
10
21
  /** A fact as the view draws it: `null` when empty. */
11
22
  export function factValue(fact) {
12
23
  switch (fact.kind) {
@@ -21,7 +32,10 @@ export function factValue(fact) {
21
32
  case 'badges':
22
33
  if (fact.items.length === 0)
23
34
  return null;
24
- return (_jsx("span", { className: "inline-flex max-w-full flex-wrap gap-1", children: fact.items.map((item) => (_jsx(Badge, { variant: "outline", className: "max-w-full truncate", children: item }, item))) }));
35
+ return (_jsx("span", { className: "inline-flex max-w-full flex-wrap gap-1", children: fact.items.map((item, index) => {
36
+ const { label, icon } = typeof item === 'string' ? { label: item, icon: undefined } : item;
37
+ return (_jsxs(Badge, { variant: "outline", className: "max-w-full", children: [icon !== undefined && icon !== null && badgeIcon(icon), _jsx("span", { className: "min-w-0 truncate", children: label })] }, `${index}:${label}`));
38
+ }) }));
25
39
  case 'count':
26
40
  return fact.to ? (_jsx(Link, { to: fact.to, className: cn(LINK_CLASS, 'tabular-nums'), children: fact.count })) : (_jsx("span", { className: "tabular-nums", children: fact.count }));
27
41
  case 'link':
@@ -30,13 +44,51 @@ export function factValue(fact) {
30
44
  if (fact.items.length === 0)
31
45
  return null;
32
46
  return (_jsx(FactList, { children: fact.items.map((item, index) => (_jsx(FactListItem, { icon: item.icon, children: item.to ? (_jsx(Link, { to: item.to, className: LINK_CLASS, children: item.name })) : item.href ? (_jsxs("a", { href: item.href, target: "_blank", rel: "noreferrer", className: LINK_CLASS, children: [item.name, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "ml-1 inline size-3.5 align-[-0.125em]" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] })) : (item.name) }, `${index}:${item.name}`))) }));
47
+ case 'rating': {
48
+ if (fact.value === null || fact.value === undefined)
49
+ return null;
50
+ const max = fact.max ?? 5;
51
+ return fact.look === 'bar' ? (_jsx(StepBar, { value: fact.value, steps: max, word: fact.word, className: "align-middle" })) : (_jsx(RatingScore, { value: fact.value, max: max, glyph: fact.look === 'hearts' ? 'heart' : 'star', word: fact.word }));
52
+ }
33
53
  case 'record':
34
54
  return (_jsx(Link, { to: fact.to, title: fact.name, className: cn(LINK_CLASS, 'inline-block max-w-full truncate align-bottom'), children: fact.name }));
35
55
  }
36
56
  }
37
- /** A facts section's facts as fields rows, for Details, the column and printing. */
57
+ /** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
38
58
  export function factsAsFields(facts) {
39
- return facts.map((fact) => ({ label: fact.label, value: factValue(fact), emptyLabel: fact.emptyLabel, edit: fact.edit }));
59
+ return statusFirst(facts).map((fact) => ({
60
+ label: fact.label,
61
+ value: factValue(fact),
62
+ emptyLabel: fact.emptyLabel,
63
+ edit: fact.edit,
64
+ hint: fact.hint,
65
+ action: fact.action,
66
+ recordStatus: fact.recordStatus,
67
+ }));
68
+ }
69
+ // The status fact first, the rest in their order.
70
+ function statusFirst(facts) {
71
+ const at = facts.findIndex((fact) => fact.recordStatus);
72
+ return at <= 0 ? facts : [facts[at], ...facts.slice(0, at), ...facts.slice(at + 1)];
73
+ }
74
+ /**
75
+ * The sections with the one holding the status fact (4.115) moved before
76
+ * the other sections that share its place (the rail, or a tab's
77
+ * side), so the status is the first fact there. Nothing else moves.
78
+ */
79
+ export function statusSectionFirst(sections) {
80
+ const holds = (section) => 'facts' in section && section.facts.some((fact) => fact.recordStatus);
81
+ const at = sections.findIndex(holds);
82
+ if (at < 0)
83
+ return [...sections];
84
+ const status = sections[at];
85
+ const sameSpot = (section) => section.placement === status.placement && section.tab === status.tab;
86
+ const first = sections.findIndex(sameSpot);
87
+ if (first === at)
88
+ return [...sections];
89
+ const rest = sections.filter((_, index) => index !== at);
90
+ rest.splice(first, 0, status);
91
+ return rest;
40
92
  }
41
93
  /** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
42
94
  export const FACTS_RAIL_MIN_WIDTH = 960;
@@ -275,4 +275,4 @@ export type EntityViewProps = {
275
275
  trail?: readonly PageCrumb[];
276
276
  };
277
277
  };
278
- export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip, sections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, factsRail, factsRailLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
278
+ export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip, sections: givenSections, footer, layout, detailsTab, tabCounts, tabsStickyTop, mobileOrder, railLabel, factsRail, factsRailLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
@@ -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, SearchXIcon } from 'lucide-react';
100
+ import { ArrowLeftIcon, ChevronDownIcon, InfoIcon, 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,7 +119,8 @@ 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 { factsAsFields, useWideParent } from './entity-view-facts.js';
122
+ import { factsAsFields, statusSectionFirst, useWideParent } from './entity-view-facts.js';
123
+ import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip.js';
123
124
  // The view's empty text and whether fields cards fold their empty ones,
124
125
  // for every section without threading them through each layout.
125
126
  const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
@@ -143,12 +144,30 @@ function OrEmpty({ value, emptyLabel }) {
143
144
  }
144
145
  // A preset shows its own value unless the screen gives one.
145
146
  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
+ }
146
164
  function FieldRow({ field, place }) {
147
165
  const value = fieldValue(field);
148
166
  // An editable row is the target as a whole (4.88, F15/F18): the list's
149
167
  // row hover, its pencil at the end, a chevron on a phone.
150
168
  const editable = Boolean(field.edit);
151
- return (_jsxs("div", { className: cn(FIELD_ROW_BASE, FIELD_ROW[place], editable && cn(editRowClass, '-mx-2 px-2 first:pt-2 last:pb-2')), onClick: editable ? onEditRowClick : undefined, children: [_jsx("dt", { className: FIELD_LABEL, children: field.label }), _jsx("dd", { className: FIELD_VALUE, children: field.edit ? (_jsx(EditableValue, { label: field.label, edit: field.edit, look: "row", children: _jsx(OrEmpty, { value: value, emptyLabel: field.emptyLabel }) })) : (_jsx(OrEmpty, { value: value, emptyLabel: field.emptyLabel })) })] }));
169
+ const shown = field.edit ? (_jsx(EditableValue, { label: field.label, edit: field.edit, look: "row", children: _jsx(OrEmpty, { value: value, emptyLabel: field.emptyLabel }) })) : (_jsx(OrEmpty, { value: value, emptyLabel: field.emptyLabel }));
170
+ return (_jsxs("div", { className: cn(FIELD_ROW_BASE, FIELD_ROW[place], editable && cn(editRowClass, '-mx-2 px-2 first:pt-2 last:pb-2')), onClick: editable ? onEditRowClick : undefined, children: [_jsx("dt", { className: FIELD_LABEL, children: field.label }), _jsxs("dd", { className: cn(FIELD_VALUE, field.action && 'flex flex-col items-start gap-1.5'), "data-record-status": field.recordStatus ? '' : undefined, children: [field.hint ? (_jsxs("span", { className: "inline-flex max-w-full flex-wrap items-center gap-x-1", children: [_jsx("span", { className: "min-w-0 max-w-full", children: shown }), _jsx(FactHint, { label: field.label, hint: field.hint })] })) : (shown), field.action && _jsx(FactAction, { action: field.action })] })] }));
152
171
  }
153
172
  // A fields card's rows. Folded (`emptyFields="fold"`), the filled fields
154
173
  // show and the empty ones wait behind "N empty", which opens them in their
@@ -382,7 +401,9 @@ function tabsLayout(sections, detailsTab) {
382
401
  tabs.push({ slug, name: detailsTab, sections: facts, side: [], details: true });
383
402
  return { above: main.filter((section) => section.tab === undefined), tabs, factsInColumn: false };
384
403
  }
385
- export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip = false, sections, footer, layout = 'tabs', detailsTab = 'Details', tabCounts, tabsStickyTop, mobileOrder = 'rail-first', railLabel, factsRail = false, factsRailLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
404
+ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, cardStrip = false, sections: givenSections, footer, layout = 'tabs', detailsTab = 'Details', tabCounts, tabsStickyTop, mobileOrder = 'rail-first', railLabel, factsRail = false, factsRailLabel, railFields = 'beside', emptyFields = 'show', emptyText = EMPTY_DASH, printLabel = 'Print Notes', printLook = 'icon', isLoading, error, onRetry, back, }) {
405
+ // The record's status first among the sections in its place (4.115).
406
+ const sections = statusSectionFirst(givenSections);
386
407
  // Editing in place: one store per view, and the leave-page prompt only
387
408
  // while a field is open (or one is always editable).
388
409
  const [store] = useState(() => new EditInPlaceStore());
@@ -0,0 +1 @@
1
+ export declare const KeepPencilRoomContext: import("react").Context<boolean>;
@@ -0,0 +1,7 @@
1
+ // Set by a container whose inline <EditableValue>s must keep their
2
+ // pencil's room at rest (KeyStats, 4.115), as `keepPencilRoom` does for
3
+ // one: a value growing on hover moved the values after it along a
4
+ // wrapping row, and a nearly full row wrapped, so the hovered value slid
5
+ // out from under the mouse and a click opened the next one.
6
+ import { createContext } from 'react';
7
+ export const KeepPencilRoomContext = createContext(false);
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from 'cn';
3
3
  import { EmptyText } from './empty-value.js';
4
4
  import { EMPTY_DASH } from '../../lib/empty-value.js';
5
+ import { KeepPencilRoomContext } from './keep-pencil-room.js';
5
6
  const isEmpty = (value) => value === null || value === undefined || value === false || value === '';
6
7
  export function KeyStats({ stats, emptyLabel = EMPTY_DASH, width = 'content', className }) {
7
- return (_jsx("dl", { "data-slot": "key-stats", "data-width": width, className: cn('flex flex-wrap gap-x-8 gap-y-3 rounded-lg border border-border bg-card px-4 py-3 text-card-foreground', width === 'content' && 'w-fit max-w-full', className), children: stats.map((stat) => {
8
- const Icon = stat.icon;
9
- return (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsxs("dt", { className: cn('type-caption text-muted-foreground', Icon && 'inline-flex items-center gap-1'), children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-3.25 shrink-0" }), stat.label] }), _jsx("dd", { className: "type-section-title tabular-nums break-words text-foreground", children: isEmpty(stat.value) ? _jsx(EmptyText, { text: emptyLabel, className: "type-body text-muted-foreground" }) : stat.value }), stat.hint && _jsx("dd", { className: "type-caption text-muted-foreground", children: stat.hint })] }, stat.label));
10
- }) }));
8
+ return (_jsx(KeepPencilRoomContext.Provider, { value: true, children: _jsx("dl", { "data-slot": "key-stats", "data-width": width, className: cn('flex flex-wrap gap-x-8 gap-y-3 rounded-lg border border-border bg-card px-4 py-3 text-card-foreground', width === 'content' && 'w-fit max-w-full', className), children: stats.map((stat) => {
9
+ const Icon = stat.icon;
10
+ return (_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsxs("dt", { className: cn('type-caption text-muted-foreground', Icon && 'inline-flex items-center gap-1'), children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-3.25 shrink-0" }), stat.label] }), _jsx("dd", { className: "type-section-title tabular-nums break-words text-foreground", children: isEmpty(stat.value) ? _jsx(EmptyText, { text: emptyLabel, className: "type-body text-muted-foreground" }) : stat.value }), stat.hint && _jsx("dd", { className: "type-caption text-muted-foreground", children: stat.hint })] }, stat.label));
11
+ }) }) }));
11
12
  }
@@ -10,6 +10,20 @@ export type ListHeaderAction = {
10
10
  onSelect: () => void;
11
11
  icon?: IconComponent;
12
12
  };
13
+ /** The one button beside New (4.117): a link to a page, or a function. */
14
+ export type ListHeaderSecondaryAction = {
15
+ label: string;
16
+ /** Drawn before the words, in the button and in ⋯. */
17
+ icon?: IconComponent;
18
+ /** Can't be used now (a refresh in flight): the button and its menu item are disabled. */
19
+ disabled?: boolean;
20
+ } & ({
21
+ to: To;
22
+ onClick?: never;
23
+ } | {
24
+ onClick: () => void;
25
+ to?: never;
26
+ });
13
27
  /** One list in the `siblings` switch. */
14
28
  export type ListHeaderSibling = {
15
29
  label: string;
@@ -40,6 +54,12 @@ export type ListHeaderProps = {
40
54
  onClick: () => void;
41
55
  to?: never;
42
56
  };
57
+ /**
58
+ * One more button beside New (4.117), for the list's second most common
59
+ * action ("Refresh Now", "Add from Catalog"). An outline button before
60
+ * New, which stays the primary. On a phone it's the first item in ⋯.
61
+ */
62
+ secondaryAction?: ListHeaderSecondaryAction;
43
63
  /** The page's other actions (Export, Import), in ⋯ after the folded links. */
44
64
  more?: readonly ListHeaderAction[];
45
65
  /**
@@ -61,4 +81,4 @@ export type ListHeaderProps = {
61
81
  siblingsLabel?: string;
62
82
  className?: string;
63
83
  };
64
- export declare function ListHeader({ title, count, links, newAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
84
+ export declare function ListHeader({ title, count, links, newAction, secondaryAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
@@ -18,6 +18,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
18
18
  // page's own peers, so they aren't in ⋯, which keeps only what's left
19
19
  // (Show deleted). On a phone the switch takes its own line under the
20
20
  // title and scrolls sideways if it must.
21
+ //
22
+ // `secondaryAction` (4.117) is one more button, beside New and before it,
23
+ // for a list's second most common action ("Refresh Now", "Add from
24
+ // Catalog"): an outline button, so New stays the primary. On a phone it
25
+ // folds into ⋯, the menu's first item, so the row keeps the title, ⋯ and
26
+ // New.
21
27
  import { EllipsisIcon, PlusIcon, Trash2Icon } from 'lucide-react';
22
28
  import { Link, NavLink } from 'react-router';
23
29
  import { cn } from 'cn';
@@ -36,11 +42,16 @@ function SiblingSwitch({ siblings, label }) {
36
42
  return sibling.current === undefined ? (_jsx(NavLink, { to: sibling.to, end: true, className: SIBLING_CLASS, children: inner }, sibling.label)) : (_jsx(Link, { to: sibling.to, "aria-current": sibling.current ? 'page' : undefined, className: SIBLING_CLASS, children: inner }, sibling.label));
37
43
  }) }) }));
38
44
  }
39
- export function ListHeader({ title, count, links = [], newAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
45
+ export function ListHeader({ title, count, links = [], newAction, secondaryAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
40
46
  // One link is a button of its own; two or more go in the menu.
41
47
  const outLink = links.length === 1 ? links[0] : undefined;
42
48
  const menuLinks = links.length > 1 ? links : [];
43
- const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
44
- return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-max max-w-(--available-width) whitespace-nowrap", children: [menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), newAction &&
49
+ const hasOwnMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
50
+ // The secondary action folds into ⋯ on a phone, so ⋯ is there on a
51
+ // phone even when nothing else is in it (and only there).
52
+ const hasMenu = hasOwnMenu || secondaryAction !== undefined;
53
+ const SecondaryIcon = secondaryAction?.icon;
54
+ return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more", className: hasOwnMenu ? undefined : 'md:hidden' }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-max max-w-(--available-width) whitespace-nowrap", children: [secondaryAction && (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { "data-slot": "list-header-secondary-item", className: "md:hidden", disabled: secondaryAction.disabled, render: secondaryAction.to !== undefined ? _jsx(Link, { to: secondaryAction.to }) : undefined, onClick: secondaryAction.onClick, children: [SecondaryIcon && _jsx(SecondaryIcon, { "aria-hidden": "true" }), secondaryAction.label] }), hasOwnMenu && _jsx(DropdownMenuSeparator, { className: "md:hidden" })] })), menuLinks.map((link) => (_jsxs(DropdownMenuItem, { render: _jsx(Link, { to: link.to }), children: [link.icon && _jsx(link.icon, { "aria-hidden": "true" }), link.label] }, link.label))), more.map((action) => (_jsxs(DropdownMenuItem, { onClick: action.onSelect, children: [action.icon && _jsx(action.icon, { "aria-hidden": "true" }), action.label] }, action.label))), deleted && (menuLinks.length > 0 || more.length > 0) && _jsx(DropdownMenuSeparator, {}), deleted && (_jsxs(DropdownMenuCheckboxItem, { closeOnClick: true, checked: deleted.shown, onCheckedChange: deleted.onShownChange, children: [_jsx(Trash2Icon, { "aria-hidden": "true" }), "Show Deleted"] }))] })] })), secondaryAction &&
55
+ (secondaryAction.to !== undefined && !secondaryAction.disabled ? (_jsxs(Button, { size: "sm", variant: "outline", "data-slot": "list-header-secondary", className: "max-md:hidden", nativeButton: false, render: _jsx(Link, { to: secondaryAction.to }), children: [SecondaryIcon && _jsx(SecondaryIcon, { "aria-hidden": "true" }), secondaryAction.label] })) : (_jsxs(Button, { size: "sm", variant: "outline", "data-slot": "list-header-secondary", className: "max-md:hidden", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, children: [SecondaryIcon && _jsx(SecondaryIcon, { "aria-hidden": "true" }), secondaryAction.label] }))), newAction &&
45
56
  (newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the List" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
46
57
  }
@@ -0,0 +1,15 @@
1
+ export type RatingScoreGlyph = 'star' | 'heart';
2
+ export type RatingScoreProps = {
3
+ /** How many glyphs are filled, 0…max (rounded). */
4
+ value: number;
5
+ /** How many glyphs the score has. Defaults to 5. */
6
+ max?: number;
7
+ /** Stars (the default) or hearts. */
8
+ glyph?: RatingScoreGlyph;
9
+ /** A word shown after the glyphs, in the muted tone ("Loved"). */
10
+ word?: string;
11
+ /** What a screen reader hears. Defaults to "4 of 5" (with the word first when given: "Loved, 4 of 5"). */
12
+ label?: string;
13
+ className?: string;
14
+ };
15
+ export declare function RatingScore({ value, max, glyph, word, label, className }: RatingScoreProps): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A score out of a few (cell pattern 9, 4.117): `max` stars or hearts,
3
+ // the first `value` filled. "My Rating: 4 of 5" as ★★★★☆. The count of
4
+ // filled glyphs carries the value, so it survives greyscale.
5
+ //
6
+ // The filled glyphs are the ink (currentColor, `foreground`); the empty
7
+ // ones are outlines in `muted-foreground`, which clears 3:1 on the page in
8
+ // both themes, so an empty glyph is seen as a glyph, not as nothing. One
9
+ // image to a screen reader, named in words ("4 of 5"); pass the field's
10
+ // name in front where nothing near it gives it ("My Rating: 4 of 5").
11
+ //
12
+ // Fixed-size glyphs: the score is as wide at 1 as at 5, so a value edited
13
+ // in place never moves what's beside it.
14
+ import { cn } from 'cn';
15
+ // Lucide's star and heart (24×24), so they match the icons around them.
16
+ const PATHS = {
17
+ star: 'M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z',
18
+ heart: 'M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5',
19
+ };
20
+ /** A score's spoken words: "4 of 5", or "Loved, 4 of 5" with a word. */
21
+ function ratingScoreName(value, max = 5, word) {
22
+ const filled = Math.min(Math.max(0, Math.round(value)), max);
23
+ return `${word ? `${word}, ` : ''}${filled} of ${max}`;
24
+ }
25
+ export function RatingScore({ value, max = 5, glyph = 'star', word, label, className }) {
26
+ const filled = Math.min(Math.max(0, Math.round(value)), max);
27
+ const path = PATHS[glyph];
28
+ return (_jsxs("span", { role: "img", "aria-label": label ?? ratingScoreName(filled, max, word), "data-slot": "rating-score", "data-value": filled, "data-glyph": glyph, className: cn('inline-flex shrink-0 items-center gap-1.5 align-middle text-foreground', className), children: [_jsx("span", { "aria-hidden": "true", className: "inline-flex shrink-0 items-center gap-0.5", children: Array.from({ length: max }, (_, at) => (_jsx("svg", { viewBox: "0 0 24 24", "data-filled": at < filled ? '' : undefined, className: cn('size-4 shrink-0', at < filled ? 'text-current' : 'text-muted-foreground'), children: _jsx("path", { d: path, className: at < filled ? 'fill-current stroke-current' : 'fill-none stroke-current', strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }, at))) }), word && (_jsx("span", { "aria-hidden": "true", className: "text-muted-foreground", children: word }))] }));
29
+ }
package/dist/index.d.ts CHANGED
@@ -28,7 +28,7 @@ export { EmptyText, type EmptyTextProps } from './components/app/empty-value.js'
28
28
  export { isEmptyValue } from './lib/empty-value.js';
29
29
  export { IconAction, type IconActionProps } from './components/app/icon-action.js';
30
30
  export { EntityView, type EntityViewEmptyFields, type EntityViewField, type EntityViewLayout, type EntityViewMobileOrder, type EntityViewPlacement, type EntityViewProps, type EntityViewRailFields, type EntityViewSection, } from './components/app/entity-view.js';
31
- export { type EntityViewFact, type EntityViewFactListItem, type EntityViewFactValue } from './components/app/entity-view-facts.js';
31
+ export { type EntityViewFact, type EntityViewFactAction, type EntityViewFactBadge, type EntityViewFactListItem, type EntityViewFactRatingLook, type EntityViewFactValue, } from './components/app/entity-view-facts.js';
32
32
  export { entityViewTabSlug } from './lib/entity-view-tab.js';
33
33
  export { usePrinting } from './components/app/print-context.js';
34
34
  export { RecordDialogRoute, RecordLink, type RecordDialogRouteProps, type RecordLinkProps, } from './components/app/record-dialog.js';
@@ -78,7 +78,7 @@ export { AllowReminders, type AllowRemindersProps } from './components/app/allow
78
78
  export { StageCircle, type StageCircleProps, type StageCircleStage, type StageCircleTone, } from './components/app/stage-circle.js';
79
79
  export { Notice, type NoticeProps, type NoticeTone } from './components/app/notice.js';
80
80
  export { ValueList, type ValueListItem, type ValueListProps } from './components/app/value-list.js';
81
- export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, type ListHeaderSibling, } from './components/app/list-header.js';
81
+ export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, type ListHeaderSecondaryAction, type ListHeaderSibling, } from './components/app/list-header.js';
82
82
  export { Timeline, type TimelineItem, type TimelineProps } from './components/app/timeline.js';
83
83
  export { EqualItems, type EqualItem, type EqualItemField, type EqualItemState, type EqualItemTone, type EqualItemsLook, type EqualItemsProps, } from './components/app/equal-items.js';
84
84
  export { NeedsYou, type NeedsYouItem, type NeedsYouProps, type NeedsYouTone } from './components/app/needs-you.js';
@@ -91,6 +91,7 @@ export { LineChart, type LineChartMark, type LineChartPoint, type LineChartProps
91
91
  export { MultiLineChart, type ChartSeries, type ChartTone, type MultiLineChartProps, } from './components/app/multi-line-chart.js';
92
92
  export { StepBar, type StepBarProps } from './components/app/step-bar.js';
93
93
  export { RatingStar, type RatingStarProps, type RatingStarValue } from './components/app/rating-star.js';
94
+ export { RatingScore, type RatingScoreGlyph, type RatingScoreProps } from './components/app/rating-score.js';
94
95
  export { DateField, type DateFieldProps } from './components/app/date-field.js';
95
96
  export { EmojiField, type EmojiFieldProps } from './components/app/emoji-field.js';
96
97
  export { MonthDayField, type MonthDayFieldProps } from './components/app/month-day-field.js';
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ export { LineChart, } from './components/app/line-chart.js';
97
97
  export { MultiLineChart, } from './components/app/multi-line-chart.js';
98
98
  export { StepBar } from './components/app/step-bar.js';
99
99
  export { RatingStar } from './components/app/rating-star.js';
100
+ export { RatingScore } from './components/app/rating-score.js';
100
101
  export { DateField } from './components/app/date-field.js';
101
102
  export { EmojiField } from './components/app/emoji-field.js';
102
103
  export { MonthDayField } from './components/app/month-day-field.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.114.0",
3
+ "version": "4.117.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {