@tristan2828/ui-foundation 4.115.0 → 4.118.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/conventions/docs/add-an-entity.md +23 -12
- package/conventions/docs/cell-patterns.md +60 -33
- package/conventions/docs/design-language.md +24 -10
- package/dist/components/app/entity-view-facts.d.ts +16 -0
- package/dist/components/app/entity-view-facts.js +8 -0
- package/dist/components/app/list-header.d.ts +21 -1
- package/dist/components/app/list-header.js +14 -3
- package/dist/components/app/rating-score.d.ts +15 -0
- package/dist/components/app/rating-score.js +29 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -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–
|
|
19
|
-
- [The record view](#the-record-view) · lines 1005–
|
|
20
|
-
- [Forms](#forms) · lines
|
|
21
|
-
- [Dialogs](#dialogs) · lines
|
|
22
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
23
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
24
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
25
|
-
- [Deleting](#deleting) · lines
|
|
26
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
27
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
28
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
29
|
-
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines
|
|
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
|
|
|
@@ -1108,6 +1108,17 @@ A record uses the parts it has, in this order:
|
|
|
1108
1108
|
screen. Both are drawn in Details too, where the rail folds.
|
|
1109
1109
|
- A `badges` item may be `{ label, icon }` (4.115): the icon (a
|
|
1110
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
|
+
```
|
|
1111
1122
|
- **A tiny record** (4.98: a few fields and no notes, like a lookup's
|
|
1112
1123
|
row) opens as a small card: `RecordDialogRoute look="card"`, usually
|
|
1113
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–
|
|
17
|
-
- [
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
41
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
42
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
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
|
|
44
|
-
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines
|
|
45
|
-
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines
|
|
46
|
-
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines
|
|
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
|
-
###
|
|
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
|
-
-
|
|
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–
|
|
33
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
34
|
-
- [An overview page](#an-overview-page) · lines
|
|
35
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
36
|
-
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines
|
|
37
|
-
- [Picking at random](#picking-at-random) · lines
|
|
38
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
39
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
40
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines
|
|
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
|
|
@@ -1707,6 +1712,15 @@ its short facts the last tab, Details. A mark goes left of the title.
|
|
|
1707
1712
|
keyboard focus, and read with the button by a screen reader. A touch
|
|
1708
1713
|
screen has no hover, so there the words are a caption line under the
|
|
1709
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.
|
|
1710
1724
|
- **Icons on badges** (4.115): a `badges` fact's items may each carry an
|
|
1711
1725
|
icon (a component or a node) before the label, at the badge's icon size
|
|
1712
1726
|
in the muted tone a list's item icons have; items without one stay
|
|
@@ -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;
|
|
@@ -5,6 +5,8 @@ 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';
|
|
10
12
|
// A badge item's icon in the muted tone a list's item icons have
|
|
@@ -42,6 +44,12 @@ export function factValue(fact) {
|
|
|
42
44
|
if (fact.items.length === 0)
|
|
43
45
|
return null;
|
|
44
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
|
+
}
|
|
45
53
|
case 'record':
|
|
46
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 }));
|
|
47
55
|
}
|
|
@@ -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
|
|
44
|
-
|
|
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 EntityViewFactAction, type EntityViewFactBadge, 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.
|
|
3
|
+
"version": "4.118.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": {
|