@tristan2828/ui-foundation 4.119.0 → 4.121.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 +27 -12
- package/conventions/docs/design-language.md +51 -11
- package/dist/components/app/action-hint.d.ts +9 -0
- package/dist/components/app/action-hint.js +22 -0
- package/dist/components/app/entity-view-facts.d.ts +19 -2
- package/dist/components/app/entity-view-facts.js +8 -4
- package/dist/components/app/entity-view.js +4 -20
- package/dist/components/app/fact-extras.d.ts +16 -0
- package/dist/components/app/fact-extras.js +49 -0
- package/dist/components/app/key-stats.d.ts +11 -0
- package/dist/components/app/key-stats.js +3 -1
- package/dist/components/app/list-header.d.ts +8 -1
- package/dist/components/app/list-header.js +18 -5
- package/dist/components/app/milkdown-editor.js +4 -1
- package/dist/components/app/overview-page.d.ts +13 -1
- package/dist/components/app/overview-page.js +14 -2
- package/dist/components/app/rich-text-empty-paragraph.d.ts +10 -0
- package/dist/components/app/rich-text-empty-paragraph.js +26 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -0
- package/dist/testing/index.js +1 -18
- package/dist/testing/transitions.d.ts +11 -0
- package/dist/testing/transitions.js +18 -0
- package/package.json +27 -27
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
- Step 8: Add Playwright specs for all three screens · lines 760–837
|
|
16
16
|
- Step 9: Register the nav entry and route names · lines 838–852
|
|
17
17
|
- Step 10: `npm run verify`. · lines 853–855
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines 857–
|
|
19
|
-
- [The record view](#the-record-view) · lines 1010–
|
|
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 857–1318
|
|
19
|
+
- [The record view](#the-record-view) · lines 1010–1163
|
|
20
|
+
- [Forms](#forms) · lines 1165–1235
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1237–1268
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1270–1318
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1320–1352
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1354–1371
|
|
25
|
+
- [Deleting](#deleting) · lines 1373–1404
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1406–1427
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1429–1438
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1441–1483
|
|
29
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1485–1521
|
|
30
30
|
|
|
31
31
|
<!-- /index -->
|
|
32
32
|
|
|
@@ -1124,6 +1124,21 @@ A record uses the parts it has, in this order:
|
|
|
1124
1124
|
emptyLabel: 'Not rated', save: (rating) => save({ rating }) }) },
|
|
1125
1125
|
{ label: 'Quality', kind: 'rating', look: 'bar', value: QUALITY[record.quality].value, word: QUALITY[record.quality].word },
|
|
1126
1126
|
```
|
|
1127
|
+
- **A yes/no** (4.120) is `kind: 'switch'`, a switch toggled where it
|
|
1128
|
+
is, named by the label, never a two-choice select. Return the save's
|
|
1129
|
+
promise: the switch shows the new state while it runs and goes back
|
|
1130
|
+
if it fails. `on`/`off` words are optional (both or neither):
|
|
1131
|
+
|
|
1132
|
+
```tsx
|
|
1133
|
+
{ label: 'Shared', kind: 'switch', checked: record.shared, on: 'With the team', off: 'Only me',
|
|
1134
|
+
onCheckedChange: (shared) => save({ shared }) },
|
|
1135
|
+
```
|
|
1136
|
+
- **The strip's values** take `info` (a tooltip on an info button) and
|
|
1137
|
+
`action` (a small button under the value) as rail facts take `hint`
|
|
1138
|
+
and `action` (4.120); a stat's `hint` stays its caption line. A
|
|
1139
|
+
header button that needs a short line under it ("12 searches left")
|
|
1140
|
+
is wrapped in `<ActionHint hint="…">`. Inline-edited header badges
|
|
1141
|
+
keep their pencil's room on their own.
|
|
1127
1142
|
- **A tiny record** (4.98: a few fields and no notes, like a lookup's
|
|
1128
1143
|
row) opens as a small card: `RecordDialogRoute look="card"`, usually
|
|
1129
1144
|
with `fullPage={false}`. A 420px dialog (a sheet on a phone), its
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
- [Several values over time](#several-values-over-time) · lines 1207–1244
|
|
29
29
|
- [A list as a board](#a-list-as-a-board) · lines 1246–1297
|
|
30
30
|
- [A list as cards](#a-list-as-cards) · lines 1299–1345
|
|
31
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1347–
|
|
32
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
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
|
|
31
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1347–1383
|
|
32
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1385–1446
|
|
33
|
+
- [A few equal things](#a-few-equal-things) · lines 1448–1532
|
|
34
|
+
- [An overview page](#an-overview-page) · lines 1534–1605
|
|
35
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1606–1664
|
|
36
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1666–1790
|
|
37
|
+
- [Picking at random](#picking-at-random) · lines 1792–1823
|
|
38
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1825–1892
|
|
39
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1894–1919
|
|
40
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1921–2017
|
|
41
41
|
|
|
42
42
|
<!-- /index -->
|
|
43
43
|
|
|
@@ -1370,6 +1370,13 @@ row under the header, across the page at every width.
|
|
|
1370
1370
|
- **An empty value reads as a dash** (`emptyLabel`, 4.81; "Not set"
|
|
1371
1371
|
before), in body type and muted, read by a screen reader as "Not set".
|
|
1372
1372
|
Never a blank.
|
|
1373
|
+
- **A tip and an action on a value** (4.120), as a rail fact has:
|
|
1374
|
+
`info` is a few words behind a small info button after the value (a
|
|
1375
|
+
tooltip on hover and keyboard focus, a caption line under the value on
|
|
1376
|
+
a touch screen, read with the value by a screen reader), and `action`
|
|
1377
|
+
(`{ label, icon?, onClick | render }`) a small outline button under it.
|
|
1378
|
+
Both are there at rest, so nothing moves on hover. `hint` stays the
|
|
1379
|
+
caption line ("of 12"); `info` is the tooltip.
|
|
1373
1380
|
- **Three to five.** It's what the page is for at a glance; anything
|
|
1374
1381
|
more is a section's label/value rows.
|
|
1375
1382
|
- **`subtitle`** is the line under the title: what the record is for,
|
|
@@ -1403,6 +1410,15 @@ into a table, a record or an overview.
|
|
|
1403
1410
|
button just before New, which stays the one filled button. Only one:
|
|
1404
1411
|
anything else is in ⋯. On a phone it folds into ⋯ as the menu's first
|
|
1405
1412
|
item (⋯ shows there for it alone if nothing else is in the menu).
|
|
1413
|
+
Its `hint` (4.120) is a short line under the button ("12 searches
|
|
1414
|
+
left"), in caption type and the muted tone, describing the button to a
|
|
1415
|
+
screen reader; the buttons stay level, the line hanging below. On a
|
|
1416
|
+
phone it's under the words of ⋯'s first item. **A line of context**
|
|
1417
|
+
(`description`, 4.120): one short muted sentence under the title, for a
|
|
1418
|
+
list that needs it ("Each search runs against the catalog once a
|
|
1419
|
+
day."). It wraps in the header's width and never widens a framed
|
|
1420
|
+
table's shared width; on a phone it's under the title and its buttons.
|
|
1421
|
+
One sentence: anything longer belongs in a help page.
|
|
1406
1422
|
- **`Timeline`: a record's dated history.** `items` newest first
|
|
1407
1423
|
(`{ id, date, dateTime?, kind?, body, edit? }`): dates in a tabular
|
|
1408
1424
|
column on the left, a dot and a thin line, the entry on the right with
|
|
@@ -1568,6 +1584,13 @@ read alike.
|
|
|
1568
1584
|
`ErrorState` in the card), and `empty` (a part with nothing yet: "Nothing
|
|
1569
1585
|
yet" in the tile, `PartEmpty` and its one way to start in the card). An
|
|
1570
1586
|
empty part stays on the page: hiding it makes the part forgotten.
|
|
1587
|
+
- **Links out** (`links`, 4.120): a short list of pages outside the app
|
|
1588
|
+
(`{ label, href, icon? }`), one section after the parts under a
|
|
1589
|
+
"Links" heading (`linksTitle`). Each link is its label, its icon
|
|
1590
|
+
before it if it has one, and the external-link mark, opening in a new
|
|
1591
|
+
tab and saying so to a screen reader. In a row from 48rem, one per
|
|
1592
|
+
line on a phone, each 44px tall. A few: a module's whole bookmark list
|
|
1593
|
+
is a list of its own.
|
|
1571
1594
|
- **One card anatomy on a hub** (`WidgetCard`): `to` makes the title the
|
|
1572
1595
|
link with a chevron (in place of the header's `link`), `value` the
|
|
1573
1596
|
headline in the numeric type, `line` one muted line under it, and
|
|
@@ -1578,7 +1601,8 @@ read alike.
|
|
|
1578
1601
|
|
|
1579
1602
|
Measured with axe and the glyph check in both themes and every palette
|
|
1580
1603
|
(fixture `app/OverviewPage`); `e2e/overview-page.spec.ts` clicks the
|
|
1581
|
-
tiles, Escape and the accordion.
|
|
1604
|
+
tiles, Escape and the accordion, and `e2e/overview-links.spec.ts` checks
|
|
1605
|
+
the links.
|
|
1582
1606
|
## A record's header and empty values
|
|
1583
1607
|
|
|
1584
1608
|
The record page standard (4.81): the same header on every record, the
|
|
@@ -1599,6 +1623,13 @@ data on each its own.
|
|
|
1599
1623
|
(12px apart, 6px between badges), centred on the title's line; a title
|
|
1600
1624
|
too long for both pushes them to the next line, starting under it.
|
|
1601
1625
|
`subtitle` is the line below, in muted body type.
|
|
1626
|
+
- **Badges edited in place** (an inline `EditableValue` around a
|
|
1627
|
+
`Badge`) keep their pencil's room at rest (4.120), as the strip's values
|
|
1628
|
+
do, so hovering one moves nothing after it and never wraps the line.
|
|
1629
|
+
- **A hint under a header button** (`ActionHint`, 4.120): `<ActionHint
|
|
1630
|
+
hint="12 searches left"><Button>Search</Button></ActionHint>` draws a
|
|
1631
|
+
short caption line under the button, describing it; the header's
|
|
1632
|
+
buttons line up by their tops, so it stays level with the rest.
|
|
1602
1633
|
- **Actions**: the record's own commands in words (New visit, Mark
|
|
1603
1634
|
done), then the universal ones as `IconAction`s: Print Notes
|
|
1604
1635
|
(`printer`, EntityView's own) and Delete (`trash-2`, the destructive
|
|
@@ -1721,6 +1752,15 @@ its short facts the last tab, Details. A mark goes left of the title.
|
|
|
1721
1752
|
drawn the same in Details on a phone. An empty one reads its
|
|
1722
1753
|
`emptyLabel` ("Not rated"), not a row of empty stars. Edited in place
|
|
1723
1754
|
like any fact (`edit`), usually `inPlace.select` over the scores.
|
|
1755
|
+
- **A yes/no** (`kind: 'switch'`, 4.120) is a switch on the value's
|
|
1756
|
+
line, never a two-choice select: `checked`, `onCheckedChange` (return
|
|
1757
|
+
the save's promise and the switch shows the new state, busy, until it
|
|
1758
|
+
lands, going back if it fails), and optional `on`/`off` words after it
|
|
1759
|
+
("With the team", "Only me"). Its accessible name is the fact's label;
|
|
1760
|
+
a click, Space or Enter toggles it. Both words keep their room, so
|
|
1761
|
+
toggling or hovering moves nothing, and it works the same in Details on
|
|
1762
|
+
a phone. `disabled` with a `hint` for one that can't change here.
|
|
1763
|
+
Printed, it's its word (or Yes/No).
|
|
1724
1764
|
- **Icons on badges** (4.115): a `badges` fact's items may each carry an
|
|
1725
1765
|
icon (a component or a node) before the label, at the badge's icon size
|
|
1726
1766
|
in the muted tone a list's item icons have; items without one stay
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export type ActionHintProps = {
|
|
3
|
+
/** A few words under the button. */
|
|
4
|
+
hint: string;
|
|
5
|
+
/** The button (one element): it's given `aria-describedby` for the line. */
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function ActionHint({ hint, children, className }: ActionHintProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// A short line under a header button (4.120): what the button has left
|
|
3
|
+
// or costs ("12 searches left"), in caption type and the muted tone,
|
|
4
|
+
// centred under it on one line. The row it's in lines its buttons up by
|
|
5
|
+
// their tops (ListHeader and EntityView do, while one has a hint), so the
|
|
6
|
+
// button stays level with the others and the line hangs below. The button
|
|
7
|
+
// is described by it, so a screen reader hears the line with its name.
|
|
8
|
+
//
|
|
9
|
+
// ListHeader's `secondaryAction` takes it as `hint`; a record header's
|
|
10
|
+
// `actions` (EntityView) wrap the button: `<ActionHint hint="12 searches
|
|
11
|
+
// left"><Button>Search</Button></ActionHint>`.
|
|
12
|
+
import { cloneElement, isValidElement, useId } from 'react';
|
|
13
|
+
import { cn } from 'cn';
|
|
14
|
+
export function ActionHint({ hint, children, className }) {
|
|
15
|
+
const id = useId();
|
|
16
|
+
const button = isValidElement(children)
|
|
17
|
+
? cloneElement(children, {
|
|
18
|
+
'aria-describedby': cn(children.props['aria-describedby'], id),
|
|
19
|
+
})
|
|
20
|
+
: children;
|
|
21
|
+
return (_jsxs("span", { "data-slot": "action-hint", className: cn('inline-flex flex-col items-center gap-0.5', className), children: [button, _jsx("span", { id: id, "data-slot": "action-hint-text", className: "whitespace-nowrap type-caption text-muted-foreground", children: hint })] }));
|
|
22
|
+
}
|
|
@@ -66,6 +66,23 @@ export type EntityViewFactValue =
|
|
|
66
66
|
max?: number;
|
|
67
67
|
look?: EntityViewFactRatingLook;
|
|
68
68
|
word?: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A yes/no (4.120), toggled in place by a switch named by the fact's
|
|
72
|
+
* label. `onCheckedChange` saves it: while a promise it returns is
|
|
73
|
+
* pending the switch shows the new state and is busy, and if it rejects
|
|
74
|
+
* the switch goes back. `on`/`off` are words after the switch ("Shared",
|
|
75
|
+
* "Private"); give both or neither. `disabled` keeps it read-only (a
|
|
76
|
+
* `hint` can say why). Never empty, so `emptyLabel` doesn't apply, and
|
|
77
|
+
* it isn't an `edit` fact: the switch is its own editor.
|
|
78
|
+
*/
|
|
79
|
+
| {
|
|
80
|
+
kind: 'switch';
|
|
81
|
+
checked: boolean;
|
|
82
|
+
onCheckedChange: (checked: boolean) => void | Promise<unknown>;
|
|
83
|
+
on?: string;
|
|
84
|
+
off?: string;
|
|
85
|
+
disabled?: boolean;
|
|
69
86
|
};
|
|
70
87
|
/** How a `rating` fact draws its score. */
|
|
71
88
|
export type EntityViewFactRatingLook = 'stars' | 'hearts' | 'bar';
|
|
@@ -123,8 +140,8 @@ export type EntityViewFact = EntityViewFactValue & {
|
|
|
123
140
|
/** A small button under the value (4.115), drawn in the rail and in Details alike. */
|
|
124
141
|
action?: EntityViewFactAction;
|
|
125
142
|
};
|
|
126
|
-
/** A fact as the view draws it: `null` when empty. */
|
|
127
|
-
export declare function factValue(fact: EntityViewFactValue): ReactNode;
|
|
143
|
+
/** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
|
|
144
|
+
export declare function factValue(fact: EntityViewFactValue, label?: string): ReactNode;
|
|
128
145
|
/** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
|
|
129
146
|
export declare function factsAsFields(facts: readonly EntityViewFact[]): {
|
|
130
147
|
label: string;
|
|
@@ -8,6 +8,7 @@ import { FactList, FactListItem } from './fact-list.js';
|
|
|
8
8
|
import { RatingScore } from './rating-score.js';
|
|
9
9
|
import { StepBar } from './step-bar.js';
|
|
10
10
|
import { StatusMark } from './status-mark.js';
|
|
11
|
+
import { FactSwitch } from './fact-extras.js';
|
|
11
12
|
const LINK_CLASS = 'rounded-sm font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50';
|
|
12
13
|
// A badge item's icon in the muted tone a list's item icons have
|
|
13
14
|
// (FactList's marks): a component drawn at the badge's icon size, or the
|
|
@@ -18,9 +19,11 @@ function badgeIcon(icon) {
|
|
|
18
19
|
const Icon = icon;
|
|
19
20
|
return (_jsx("span", { "data-slot": "entity-view-fact-badge-icon", "aria-hidden": "true", "data-icon": "inline-start", className: "inline-flex shrink-0 text-muted-foreground", children: isComponent ? _jsx(Icon, { "aria-hidden": "true", className: "size-3" }) : icon }));
|
|
20
21
|
}
|
|
21
|
-
/** A fact as the view draws it: `null` when empty. */
|
|
22
|
-
export function factValue(fact) {
|
|
22
|
+
/** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
|
|
23
|
+
export function factValue(fact, label = '') {
|
|
23
24
|
switch (fact.kind) {
|
|
25
|
+
case 'switch':
|
|
26
|
+
return _jsx(FactSwitch, { fact: fact, label: label });
|
|
24
27
|
case 'status':
|
|
25
28
|
return _jsx(StatusMark, { kind: fact.status, children: fact.word });
|
|
26
29
|
case 'text': {
|
|
@@ -58,9 +61,10 @@ export function factValue(fact) {
|
|
|
58
61
|
export function factsAsFields(facts) {
|
|
59
62
|
return statusFirst(facts).map((fact) => ({
|
|
60
63
|
label: fact.label,
|
|
61
|
-
value: factValue(fact),
|
|
64
|
+
value: factValue(fact, fact.label),
|
|
62
65
|
emptyLabel: fact.emptyLabel,
|
|
63
|
-
|
|
66
|
+
// A switch is its own editor: an `edit` would wrap it in another.
|
|
67
|
+
edit: fact.kind === 'switch' ? undefined : fact.edit,
|
|
64
68
|
hint: fact.hint,
|
|
65
69
|
action: fact.action,
|
|
66
70
|
recordStatus: fact.recordStatus,
|
|
@@ -97,7 +97,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
97
97
|
// ones behind an "N empty" toggle, still edited in place once opened.
|
|
98
98
|
import { createContext, useContext, useEffect, useId, useState, useSyncExternalStore } from 'react';
|
|
99
99
|
import { Link, useLocation, useNavigate } from 'react-router';
|
|
100
|
-
import { ArrowLeftIcon, ChevronDownIcon,
|
|
100
|
+
import { ArrowLeftIcon, ChevronDownIcon, SearchXIcon } from 'lucide-react';
|
|
101
101
|
import { cn } from 'cn';
|
|
102
102
|
import { ErrorState } from './error-state.js';
|
|
103
103
|
import { Button } from '../ui/button.js';
|
|
@@ -119,8 +119,9 @@ import { FIELD_LABEL, FIELD_ROW, FIELD_ROW_BASE, FIELD_VALUE } from './field-row
|
|
|
119
119
|
import { PageTrail } from './page-trail.js';
|
|
120
120
|
import { usePageTrail } from './page-trail-context.js';
|
|
121
121
|
import { entityViewTabSlug } from '../../lib/entity-view-tab.js';
|
|
122
|
+
import { FactAction, FactHint } from './fact-extras.js';
|
|
123
|
+
import { KeepPencilRoomContext } from './keep-pencil-room.js';
|
|
122
124
|
import { factsAsFields, statusSectionFirst, useWideParent } from './entity-view-facts.js';
|
|
123
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip.js';
|
|
124
125
|
// The view's empty text and whether fields cards fold their empty ones,
|
|
125
126
|
// for every section without threading them through each layout.
|
|
126
127
|
const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
|
|
@@ -144,23 +145,6 @@ function OrEmpty({ value, emptyLabel }) {
|
|
|
144
145
|
}
|
|
145
146
|
// A preset shows its own value unless the screen gives one.
|
|
146
147
|
const fieldValue = (field) => (field.value !== undefined ? field.value : field.edit?.shown);
|
|
147
|
-
// A fact's hint (4.115): an info button after the value, its words in a
|
|
148
|
-
// tooltip on hover and on keyboard focus. On a touch screen, where a
|
|
149
|
-
// tooltip has no hover to open it, the words are a line under the value
|
|
150
|
-
// instead (and the button goes). A screen reader reads the words with the
|
|
151
|
-
// value either way: the line is there for it, only visually hidden on a
|
|
152
|
-
// mouse's screen, and it describes the button.
|
|
153
|
-
function FactHint({ label, hint }) {
|
|
154
|
-
const id = useId();
|
|
155
|
-
return (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "entity-view-fact-hint", "aria-label": `About ${label}`, "aria-describedby": id, className: "inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:hidden" }), children: _jsx(InfoIcon, { "aria-hidden": "true", className: "size-3.5" }) }), _jsx(TooltipContent, { children: hint })] }), _jsx("span", { id: id, "data-slot": "entity-view-fact-hint-text", className: "sr-only basis-full type-caption text-muted-foreground pointer-coarse:not-sr-only", children: hint })] }));
|
|
156
|
-
}
|
|
157
|
-
// A fact's action (4.115): a small button under its value, or the app's
|
|
158
|
-
// own action given that button (`render`), so its dialog opens from it.
|
|
159
|
-
function FactAction({ action }) {
|
|
160
|
-
const Icon = action.icon;
|
|
161
|
-
const button = (_jsxs(Button, { type: "button", variant: "outline", size: "xs", "data-slot": "entity-view-fact-action", onClick: action.render ? undefined : action.onClick, className: "pointer-coarse:min-h-11", children: [Icon && _jsx(Icon, { "aria-hidden": "true", "data-icon": "inline-start" }), action.label] }));
|
|
162
|
-
return _jsx("div", { className: "flex", children: action.render ? action.render(button) : button });
|
|
163
|
-
}
|
|
164
148
|
function FieldRow({ field, place }) {
|
|
165
149
|
const value = fieldValue(field);
|
|
166
150
|
// An editable row is the target as a whole (4.88, F15/F18): the list's
|
|
@@ -481,5 +465,5 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
481
465
|
}
|
|
482
466
|
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsx(BesideFactsRailContext.Provider, { value: railFacts.length > 0, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
|
|
483
467
|
? RAIL_LAYOUT.page
|
|
484
|
-
: cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && 'sm:min-w-64 sm:gap-4'), children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && (!card || cardStrip) && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }) }));
|
|
468
|
+
: cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && 'sm:min-w-64 sm:gap-4'), children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx(KeepPencilRoomContext.Provider, { value: true, children: _jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }) }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 has-[[data-slot=action-hint]]:items-start sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && (!card || cardStrip) && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }) }));
|
|
485
469
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EntityViewFactAction, EntityViewFactValue } from './entity-view-facts.js';
|
|
2
|
+
export declare function FactHint({ label, hint }: {
|
|
3
|
+
label: string;
|
|
4
|
+
hint: string;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
6
|
+
export declare function FactAction({ action }: {
|
|
7
|
+
action: EntityViewFactAction;
|
|
8
|
+
}): import("react").JSX.Element;
|
|
9
|
+
type SwitchFact = Extract<EntityViewFactValue, {
|
|
10
|
+
kind: 'switch';
|
|
11
|
+
}>;
|
|
12
|
+
export declare function FactSwitch({ fact, label }: {
|
|
13
|
+
fact: SwitchFact;
|
|
14
|
+
label: string;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// A fact's extras (4.115), shared by the facts rail, Details and the
|
|
3
|
+
// strip's values (KeyStats, 4.120): a hint behind an info button, and a
|
|
4
|
+
// small action button under the value. And a `switch` fact's switch (4.120).
|
|
5
|
+
import { useId, useState } from 'react';
|
|
6
|
+
import { InfoIcon } from 'lucide-react';
|
|
7
|
+
import { cn } from 'cn';
|
|
8
|
+
import { Button } from '../ui/button.js';
|
|
9
|
+
import { Switch } from '../ui/switch.js';
|
|
10
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from '../ui/tooltip.js';
|
|
11
|
+
import { usePrinting } from './print-context.js';
|
|
12
|
+
// A fact's hint (4.115): an info button after the value, its words in a
|
|
13
|
+
// tooltip on hover and on keyboard focus. On a touch screen, where a
|
|
14
|
+
// tooltip has no hover to open it, the words are a line under the value
|
|
15
|
+
// instead (and the button goes). A screen reader reads the words with the
|
|
16
|
+
// value either way: the line is there for it, only visually hidden on a
|
|
17
|
+
// mouse's screen, and it describes the button.
|
|
18
|
+
export function FactHint({ label, hint }) {
|
|
19
|
+
const id = useId();
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx("button", { type: "button", "data-slot": "entity-view-fact-hint", "aria-label": `About ${label}`, "aria-describedby": id, className: "inline-flex size-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:hidden" }), children: _jsx(InfoIcon, { "aria-hidden": "true", className: "size-3.5" }) }), _jsx(TooltipContent, { children: hint })] }), _jsx("span", { id: id, "data-slot": "entity-view-fact-hint-text", className: "sr-only basis-full type-caption text-muted-foreground pointer-coarse:not-sr-only", children: hint })] }));
|
|
21
|
+
}
|
|
22
|
+
// A fact's action (4.115): a small button under its value, or the app's
|
|
23
|
+
// own action given that button (`render`), so its dialog opens from it.
|
|
24
|
+
export function FactAction({ action }) {
|
|
25
|
+
const Icon = action.icon;
|
|
26
|
+
const button = (_jsxs(Button, { type: "button", variant: "outline", size: "xs", "data-slot": "entity-view-fact-action", onClick: action.render ? undefined : action.onClick, className: "pointer-coarse:min-h-11", children: [Icon && _jsx(Icon, { "aria-hidden": "true", "data-icon": "inline-start" }), action.label] }));
|
|
27
|
+
return _jsx("div", { className: "flex", children: action.render ? action.render(button) : button });
|
|
28
|
+
}
|
|
29
|
+
// A `switch` fact's switch and its word. The shown state is the app's
|
|
30
|
+
// `checked` unless a save is in flight, when it's the state being saved.
|
|
31
|
+
export function FactSwitch({ fact, label }) {
|
|
32
|
+
const printing = usePrinting();
|
|
33
|
+
const [saving, setSaving] = useState(null);
|
|
34
|
+
const checked = saving ?? fact.checked;
|
|
35
|
+
const words = fact.on !== undefined && fact.off !== undefined ? { on: fact.on, off: fact.off } : undefined;
|
|
36
|
+
if (printing)
|
|
37
|
+
return _jsx("span", { "data-slot": "entity-view-fact-switch-print", children: words ? (checked ? words.on : words.off) : checked ? 'Yes' : 'No' });
|
|
38
|
+
const onCheckedChange = (next) => {
|
|
39
|
+
// One save at a time: a toggle while one is in flight waits for it (focus stays).
|
|
40
|
+
if (saving !== null)
|
|
41
|
+
return;
|
|
42
|
+
const result = fact.onCheckedChange(next);
|
|
43
|
+
if (!result || typeof result.then !== 'function')
|
|
44
|
+
return;
|
|
45
|
+
setSaving(next);
|
|
46
|
+
result.then(() => setSaving(null), () => setSaving(null));
|
|
47
|
+
};
|
|
48
|
+
return (_jsxs("span", { "data-slot": "entity-view-fact-switch", className: "inline-flex max-w-full items-center gap-2 align-middle", children: [_jsx(Switch, { checked: checked, onCheckedChange: onCheckedChange, disabled: fact.disabled, "aria-label": label, "aria-busy": saving !== null || undefined }), words && (_jsxs("span", { "aria-hidden": "true", "data-slot": "entity-view-fact-switch-word", className: "grid min-w-0 text-foreground", children: [_jsx("span", { className: cn('col-start-1 row-start-1 truncate', !checked && 'invisible'), children: words.on }), _jsx("span", { className: cn('col-start-1 row-start-1 truncate', checked && 'invisible'), children: words.off })] }))] }));
|
|
49
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { IconComponent } from './icon-component.js';
|
|
3
|
+
import type { EntityViewFactAction } from './entity-view-facts.js';
|
|
3
4
|
export type KeyStat = {
|
|
4
5
|
label: string;
|
|
5
6
|
value: ReactNode;
|
|
@@ -7,7 +8,17 @@ export type KeyStat = {
|
|
|
7
8
|
hint?: ReactNode;
|
|
8
9
|
/** The concept's icon, drawn at 13px before the label (decorative: the label still says it). */
|
|
9
10
|
icon?: IconComponent;
|
|
11
|
+
/**
|
|
12
|
+
* A few words on the value (4.120), behind an info button after it: a
|
|
13
|
+
* tooltip on hover and keyboard focus, a line under the value on a touch
|
|
14
|
+
* screen. A screen reader reads it with the value.
|
|
15
|
+
*/
|
|
16
|
+
info?: string;
|
|
17
|
+
/** A small button under the value (4.120), as a rail fact's `action`. */
|
|
18
|
+
action?: EntityViewFactAction;
|
|
10
19
|
};
|
|
20
|
+
/** A strip value's action: the same shape as a rail fact's. */
|
|
21
|
+
export type KeyStatAction = EntityViewFactAction;
|
|
11
22
|
export type KeyStatsProps = {
|
|
12
23
|
stats: readonly KeyStat[];
|
|
13
24
|
/** What an empty value reads as. Defaults to a dash, read as "Not set". */
|
|
@@ -2,11 +2,13 @@ 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 { FactAction, FactHint } from './fact-extras.js';
|
|
5
6
|
import { KeepPencilRoomContext } from './keep-pencil-room.js';
|
|
6
7
|
const isEmpty = (value) => value === null || value === undefined || value === false || value === '';
|
|
7
8
|
export function KeyStats({ stats, emptyLabel = EMPTY_DASH, width = 'content', className }) {
|
|
9
|
+
const shown = (stat) => isEmpty(stat.value) ? _jsx(EmptyText, { text: emptyLabel, className: "type-body text-muted-foreground" }) : stat.value;
|
|
8
10
|
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
11
|
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:
|
|
12
|
+
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: stat.info ? (_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(stat) }), _jsx(FactHint, { label: stat.label, hint: stat.info })] })) : (shown(stat)) }), stat.hint && _jsx("dd", { className: "type-caption text-muted-foreground", children: stat.hint }), stat.action && (_jsx("dd", { "data-slot": "key-stats-action", className: "mt-1", children: _jsx(FactAction, { action: stat.action }) }))] }, stat.label));
|
|
11
13
|
}) }) }));
|
|
12
14
|
}
|
|
@@ -17,6 +17,8 @@ export type ListHeaderSecondaryAction = {
|
|
|
17
17
|
icon?: IconComponent;
|
|
18
18
|
/** Can't be used now (a refresh in flight): the button and its menu item are disabled. */
|
|
19
19
|
disabled?: boolean;
|
|
20
|
+
/** A few words under the button (4.120): "12 searches left". In ⋯ on a phone, under its words. */
|
|
21
|
+
hint?: string;
|
|
20
22
|
} & ({
|
|
21
23
|
to: To;
|
|
22
24
|
onClick?: never;
|
|
@@ -42,6 +44,11 @@ export type ListHeaderProps = {
|
|
|
42
44
|
title: string;
|
|
43
45
|
/** How many records there are, beside the title in the muted tone. Left out while loading. */
|
|
44
46
|
count?: number;
|
|
47
|
+
/**
|
|
48
|
+
* One short line under the title (4.120), in the muted tone: a sentence
|
|
49
|
+
* of context for a list that needs it. Wraps in the header's width.
|
|
50
|
+
*/
|
|
51
|
+
description?: string;
|
|
45
52
|
/** Related screens (Board, Change log). One stays a button; two or more fold into ⋯. */
|
|
46
53
|
links?: readonly ListHeaderLink[];
|
|
47
54
|
/** The New button: a link to the new-record page, or a function that opens its dialog. */
|
|
@@ -81,4 +88,4 @@ export type ListHeaderProps = {
|
|
|
81
88
|
siblingsLabel?: string;
|
|
82
89
|
className?: string;
|
|
83
90
|
};
|
|
84
|
-
export declare function ListHeader({ title, count, links, newAction, secondaryAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
|
|
91
|
+
export declare function ListHeader({ title, count, description, links, newAction, secondaryAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
|
|
@@ -23,10 +23,18 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
23
23
|
// for a list's second most common action ("Refresh Now", "Add from
|
|
24
24
|
// Catalog"): an outline button, so New stays the primary. On a phone it
|
|
25
25
|
// folds into ⋯, the menu's first item, so the row keeps the title, ⋯ and
|
|
26
|
-
// New.
|
|
26
|
+
// New. Its `hint` (4.120) is a short line under the button ("12 searches
|
|
27
|
+
// left", ActionHint), and the line under its words in ⋯ on a phone.
|
|
28
|
+
//
|
|
29
|
+
// `description` (4.120) is one short muted line under the title, for a
|
|
30
|
+
// list that needs a sentence of context ("Searches run against the
|
|
31
|
+
// catalog once a day."). It wraps in the header's width (under a framed
|
|
32
|
+
// table's, where DataTable's `pageHeader` shares it), never widening it,
|
|
33
|
+
// and on a phone it sits under the title's row, the buttons staying on it.
|
|
27
34
|
import { EllipsisIcon, PlusIcon, Trash2Icon } from 'lucide-react';
|
|
28
35
|
import { Link, NavLink } from 'react-router';
|
|
29
36
|
import { cn } from 'cn';
|
|
37
|
+
import { ActionHint } from './action-hint.js';
|
|
30
38
|
import { Notice } from './notice.js';
|
|
31
39
|
import { Button } from '../ui/button.js';
|
|
32
40
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
|
|
@@ -42,7 +50,7 @@ function SiblingSwitch({ siblings, label }) {
|
|
|
42
50
|
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));
|
|
43
51
|
}) }) }));
|
|
44
52
|
}
|
|
45
|
-
export function ListHeader({ title, count, links = [], newAction, secondaryAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
|
|
53
|
+
export function ListHeader({ title, count, description, links = [], newAction, secondaryAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
|
|
46
54
|
// One link is a button of its own; two or more go in the menu.
|
|
47
55
|
const outLink = links.length === 1 ? links[0] : undefined;
|
|
48
56
|
const menuLinks = links.length > 1 ? links : [];
|
|
@@ -51,7 +59,12 @@ export function ListHeader({ title, count, links = [], newAction, secondaryActio
|
|
|
51
59
|
// phone even when nothing else is in it (and only there).
|
|
52
60
|
const hasMenu = hasOwnMenu || secondaryAction !== undefined;
|
|
53
61
|
const SecondaryIcon = secondaryAction?.icon;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
const secondaryButton = secondaryAction &&
|
|
63
|
+
(secondaryAction.to !== undefined && !secondaryAction.disabled ? (_jsxs(Button, { size: "sm", variant: "outline", "data-slot": "list-header-secondary", 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", disabled: secondaryAction.disabled, onClick: secondaryAction.onClick, children: [SecondaryIcon && _jsx(SecondaryIcon, { "aria-hidden": "true" }), secondaryAction.label] })));
|
|
64
|
+
// A hint line under the button lines the row up by its tops (the title
|
|
65
|
+
// and the buttons level), the line hanging below.
|
|
66
|
+
const hinted = Boolean(secondaryAction?.hint);
|
|
67
|
+
return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: cn('flex flex-wrap justify-between gap-x-4 gap-y-2', hinted ? 'items-start' : 'items-center'), 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: cn('ml-auto flex flex-wrap gap-2', hinted ? 'items-start' : 'items-center'), 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.hint ? (_jsxs("span", { className: "flex flex-col", children: [secondaryAction.label, _jsx("span", { className: "sr-only", children: ", " }), _jsx("span", { "data-slot": "list-header-secondary-item-hint", className: "type-caption text-muted-foreground", children: secondaryAction.hint })] })) : (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"] }))] })] })), secondaryButton &&
|
|
68
|
+
(secondaryAction?.hint ? (_jsx(ActionHint, { hint: secondaryAction.hint, className: "max-md:hidden", children: secondaryButton })) : (_jsx("span", { className: "contents max-md:hidden", children: secondaryButton }))), newAction &&
|
|
69
|
+
(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] })))] })] }), description && (_jsx("p", { "data-slot": "list-header-description", className: "mt-1 max-w-prose type-body text-muted-foreground contain-inline-size", children: description })), _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', "."] })) })] }));
|
|
57
70
|
}
|
|
@@ -76,7 +76,7 @@ import { createPortal } from 'react-dom';
|
|
|
76
76
|
import { useInRouterContext, useNavigate } from 'react-router';
|
|
77
77
|
import { defaultValueCtx, Editor, editorViewCtx, editorViewOptionsCtx, parserCtx, remarkStringifyOptionsCtx, rootCtx, schemaCtx, serializerCtx, } from '@milkdown/kit/core';
|
|
78
78
|
import { history } from '@milkdown/kit/plugin/history';
|
|
79
|
-
import { commands, headingSchema, inputRules, keymap, markInputRules, plugins, remarkPreserveEmptyLinePlugin, schema, } from '@milkdown/kit/preset/commonmark';
|
|
79
|
+
import { commands, headingSchema, paragraphSchema, inputRules, keymap, markInputRules, plugins, remarkPreserveEmptyLinePlugin, schema, } from '@milkdown/kit/preset/commonmark';
|
|
80
80
|
import { gfm, tableCellSchema, tableHeaderSchema, tableSchema } from '@milkdown/kit/preset/gfm';
|
|
81
81
|
import { Fragment, Slice } from '@milkdown/kit/prose/model';
|
|
82
82
|
import { NodeSelection, Plugin, TextSelection } from '@milkdown/kit/prose/state';
|
|
@@ -110,6 +110,7 @@ import { calloutKind, calloutView, tableView } from './rich-text-node-views.js';
|
|
|
110
110
|
import { droppedFiles, imageUploadPlugin, pastedImages, uploadImages, uploadPlaceholders } from './rich-text-image-upload.js';
|
|
111
111
|
import { handleShortcut } from './rich-text-shortcuts.js';
|
|
112
112
|
import { splitTaskItem, taskInputRule } from './rich-text-tasks.js';
|
|
113
|
+
import { withEmptyParagraphChildren } from './rich-text-empty-paragraph.js';
|
|
113
114
|
import { toggleHeadingInputRule, toggleHeadingRemark, withToggle } from './rich-text-toggle-heading.js';
|
|
114
115
|
import { addRowAtEnd, colorTableCells, fitAllColumns, handleTableKey, previewColumnWidth, runTableAction, setColumnWidth, tableLook as tableLookPlugin, tableWidthsOf } from './rich-text-table.js';
|
|
115
116
|
import { TABLE_MENU_EVENT, TableGrips } from './rich-text-table-grips.js';
|
|
@@ -872,6 +873,8 @@ export default function MilkdownEditor({ id, defaultValue, onChange, onProblem,
|
|
|
872
873
|
}));
|
|
873
874
|
// Headings carry `toggle` (rich-text-toggle-heading.ts).
|
|
874
875
|
ctx.update(headingSchema.key, withToggle);
|
|
876
|
+
// An empty paragraph keeps its `children` (rich-text-empty-paragraph.ts).
|
|
877
|
+
ctx.update(paragraphSchema.key, withEmptyParagraphChildren);
|
|
875
878
|
ctx.update(editorViewOptionsCtx, (options) => ({
|
|
876
879
|
...options,
|
|
877
880
|
editable: () => !latest.current.readOnly,
|
|
@@ -27,6 +27,14 @@ export type OverviewPart = {
|
|
|
27
27
|
error?: AppError | null;
|
|
28
28
|
onRetry?: () => void;
|
|
29
29
|
};
|
|
30
|
+
/** A page outside the app (4.120), in the overview's Links section. */
|
|
31
|
+
export type OverviewLink = {
|
|
32
|
+
label: string;
|
|
33
|
+
/** The page's address: opened in a new tab. */
|
|
34
|
+
href: string;
|
|
35
|
+
/** Decorative: the label names the page. */
|
|
36
|
+
icon?: IconComponent;
|
|
37
|
+
};
|
|
30
38
|
export type OverviewPageProps = {
|
|
31
39
|
/** The page's h1: the module's name. */
|
|
32
40
|
title: string;
|
|
@@ -37,8 +45,12 @@ export type OverviewPageProps = {
|
|
|
37
45
|
stats?: ReactNode;
|
|
38
46
|
/** Controls at the title's end. */
|
|
39
47
|
actions?: ReactNode;
|
|
48
|
+
/** Pages outside the app (4.120): one section after the parts, each opening in a new tab. */
|
|
49
|
+
links?: readonly OverviewLink[];
|
|
50
|
+
/** The links section's heading. Defaults to "Links". */
|
|
51
|
+
linksTitle?: string;
|
|
40
52
|
/** The part open at first; none when left out. */
|
|
41
53
|
defaultOpen?: string | null;
|
|
42
54
|
className?: string;
|
|
43
55
|
};
|
|
44
|
-
export declare function OverviewPage({ title, parts, needs, stats, actions, defaultOpen, className, }: OverviewPageProps): import("react").JSX.Element;
|
|
56
|
+
export declare function OverviewPage({ title, parts, needs, stats, actions, links, linksTitle, defaultOpen, className, }: OverviewPageProps): import("react").JSX.Element;
|
|
@@ -19,8 +19,15 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
19
19
|
// `onRetry` in the card), and `empty` (a part with nothing yet: "Nothing
|
|
20
20
|
// yet" in the tile, PartEmpty with its one way to start in the card).
|
|
21
21
|
//
|
|
22
|
+
// `links` (4.120) are a short list of pages outside the app (the
|
|
23
|
+
// module's account page, a supplier's site): one section after the parts,
|
|
24
|
+
// titled `linksTitle` ("Links"), each link its label with its icon if it
|
|
25
|
+
// has one and the external-link mark, opening in a new tab. In a row of
|
|
26
|
+
// as many as fit from 48rem, one per line under it. None draws nothing.
|
|
27
|
+
//
|
|
22
28
|
// The breakpoint is read with matchMedia; on the server, or where it's
|
|
23
29
|
// missing (a test's DOM), the page is drawn wide.
|
|
30
|
+
import { ExternalLinkIcon } from 'lucide-react';
|
|
24
31
|
import { useId, useState, useSyncExternalStore } from 'react';
|
|
25
32
|
import { cn } from 'cn';
|
|
26
33
|
import { Freshness } from './freshness.js';
|
|
@@ -38,7 +45,8 @@ function subscribeWide(listener) {
|
|
|
38
45
|
return () => query.removeEventListener('change', listener);
|
|
39
46
|
}
|
|
40
47
|
const useIsWide = () => useSyncExternalStore(subscribeWide, () => !canMatchMedia() || window.matchMedia(WIDE_QUERY).matches, () => true);
|
|
41
|
-
export function OverviewPage({ title, parts, needs = [], stats, actions, defaultOpen = null, className, }) {
|
|
48
|
+
export function OverviewPage({ title, parts, needs = [], stats, actions, links = [], linksTitle = 'Links', defaultOpen = null, className, }) {
|
|
49
|
+
const linksId = useId();
|
|
42
50
|
const wide = useIsWide();
|
|
43
51
|
const detailId = useId();
|
|
44
52
|
const [openId, setOpenId] = useState(defaultOpen);
|
|
@@ -52,7 +60,11 @@ export function OverviewPage({ title, parts, needs = [], stats, actions, default
|
|
|
52
60
|
setOpenId(null);
|
|
53
61
|
tile?.focus();
|
|
54
62
|
};
|
|
55
|
-
return (_jsxs("div", { "data-slot": "overview-page", className: cn('flex flex-col gap-4', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("h1", { className: "type-page-title text-foreground", children: title }), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] }), stats, _jsx(NeedsYou, { items: needs }), wide ? (_jsxs(_Fragment, { children: [_jsx("ul", { "data-slot": "overview-tiles", className: "grid grid-cols-[repeat(auto-fill,minmax(170px,1fr))] gap-2.5", children: parts.map((part) => (_jsx("li", { className: "flex min-w-0", children: _jsx(OverviewTile, { id: tileId(part.id), part: part, open: part.id === openId, controls: detailId, onToggle: () => setOpenId(part.id === openId ? null : part.id) }) }, part.id))) }), _jsx("div", { id: detailId, "data-slot": "overview-detail", onKeyDown: onDetailKeyDown, children: open && _jsx(PartCard, { part: open }) })] })) : (_jsx(WidgetCardGroup, { accordion: true, defaultOpen: openId, className: "flex flex-col gap-2.5", children: parts.map((part) => (_jsx(PartCard, { part: part }, part.id))) }))] }));
|
|
63
|
+
return (_jsxs("div", { "data-slot": "overview-page", className: cn('flex flex-col gap-4', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("h1", { className: "type-page-title text-foreground", children: title }), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] }), stats, _jsx(NeedsYou, { items: needs }), wide ? (_jsxs(_Fragment, { children: [_jsx("ul", { "data-slot": "overview-tiles", className: "grid grid-cols-[repeat(auto-fill,minmax(170px,1fr))] gap-2.5", children: parts.map((part) => (_jsx("li", { className: "flex min-w-0", children: _jsx(OverviewTile, { id: tileId(part.id), part: part, open: part.id === openId, controls: detailId, onToggle: () => setOpenId(part.id === openId ? null : part.id) }) }, part.id))) }), _jsx("div", { id: detailId, "data-slot": "overview-detail", onKeyDown: onDetailKeyDown, children: open && _jsx(PartCard, { part: open }) })] })) : (_jsx(WidgetCardGroup, { accordion: true, defaultOpen: openId, className: "flex flex-col gap-2.5", children: parts.map((part) => (_jsx(PartCard, { part: part }, part.id))) })), links.length > 0 && (_jsxs("section", { "data-slot": "overview-links", "aria-labelledby": linksId, className: "flex flex-col gap-2", children: [_jsx("h2", { id: linksId, className: "type-section-title text-foreground", children: linksTitle }), _jsx("ul", { className: "flex flex-col md:flex-row md:flex-wrap md:gap-x-6 md:gap-y-1", children: links.map((link) => (_jsx("li", { className: "min-w-0", children: _jsx(OverviewLinkItem, { link: link }) }, `${link.label}:${link.href}`))) })] }))] }));
|
|
64
|
+
}
|
|
65
|
+
function OverviewLinkItem({ link }) {
|
|
66
|
+
const { icon: Icon } = link;
|
|
67
|
+
return (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", "data-slot": "overview-link", className: cn('inline-flex max-w-full items-center gap-1.5 rounded-sm py-1 type-body font-medium text-link underline-offset-4 outline-none', 'hover:underline focus-visible:ring-3 focus-visible:ring-ring/50 max-md:min-h-11'), children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 truncate", children: link.label }), _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3.5 shrink-0" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] }));
|
|
56
68
|
}
|
|
57
69
|
function PartCard({ part }) {
|
|
58
70
|
return (_jsx(WidgetCard, { id: part.id, title: part.title, icon: part.icon, to: part.to, value: part.value, line: part.line, freshness: part.freshness, isLoading: part.isLoading ?? false, error: part.error, onRetry: part.onRetry, isEmpty: part.empty !== undefined, emptyMessage: part.empty?.text ?? 'Nothing here yet', empty: part.empty, emptySummary: "Nothing yet", className: "w-full", children: part.detail }));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { NodeSchema } from '@milkdown/kit/transformer';
|
|
2
|
+
/**
|
|
3
|
+
* An empty paragraph goes to Markdown with `children: []`. Milkdown's own
|
|
4
|
+
* runner opens and closes the node with nothing in it, and its serializer
|
|
5
|
+
* then leaves `children` out. mdast says a paragraph always has the
|
|
6
|
+
* array, and mdast-util-gfm-task-list-item 2.0.1 reads its length: an
|
|
7
|
+
* empty task item ("- [ ] ", Enter at a list's end) threw there, and the
|
|
8
|
+
* edit was never saved.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withEmptyParagraphChildren<Ctx>(previous: (ctx: Ctx) => NodeSchema): (ctx: Ctx) => NodeSchema;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An empty paragraph goes to Markdown with `children: []`. Milkdown's own
|
|
3
|
+
* runner opens and closes the node with nothing in it, and its serializer
|
|
4
|
+
* then leaves `children` out. mdast says a paragraph always has the
|
|
5
|
+
* array, and mdast-util-gfm-task-list-item 2.0.1 reads its length: an
|
|
6
|
+
* empty task item ("- [ ] ", Enter at a list's end) threw there, and the
|
|
7
|
+
* edit was never saved.
|
|
8
|
+
*/
|
|
9
|
+
export function withEmptyParagraphChildren(previous) {
|
|
10
|
+
return (ctx) => {
|
|
11
|
+
const base = previous(ctx);
|
|
12
|
+
const runner = base.toMarkdown.runner;
|
|
13
|
+
return {
|
|
14
|
+
...base,
|
|
15
|
+
toMarkdown: {
|
|
16
|
+
...base.toMarkdown,
|
|
17
|
+
runner: (state, node) => {
|
|
18
|
+
if (node.content.size === 0)
|
|
19
|
+
state.addNode('paragraph', []);
|
|
20
|
+
else
|
|
21
|
+
runner(state, node);
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export { OptionSelect, type OptionSelectOption, type OptionSelectProps } from '.
|
|
|
21
21
|
export { ChoiceButtons, type ChoiceButtonsOption, type ChoiceButtonsProps } from './components/app/choice-buttons.js';
|
|
22
22
|
export { ReferenceCombobox, type ReferenceComboboxProps, type ReferenceRecord } from './components/app/reference-combobox.js';
|
|
23
23
|
export { fieldRows, type FieldKind, type FieldRowItem, type FieldRowPlace, type FieldSize } from './lib/field-rows.js';
|
|
24
|
-
export { KeyStats, type KeyStat, type KeyStatsProps } from './components/app/key-stats.js';
|
|
24
|
+
export { KeyStats, type KeyStat, type KeyStatAction, type KeyStatsProps } from './components/app/key-stats.js';
|
|
25
|
+
export { ActionHint, type ActionHintProps } from './components/app/action-hint.js';
|
|
25
26
|
export { StatusMark, type StatusMarkProps } from './components/app/status-mark.js';
|
|
26
27
|
export { STATUS_KINDS, STATUS_KIND_ICONS, STATUS_KIND_LABELS, STATUS_KIND_TONES, type StatusKind, } from './lib/status-kinds.js';
|
|
27
28
|
export { EmptyText, type EmptyTextProps } from './components/app/empty-value.js';
|
|
@@ -106,7 +107,7 @@ export { formatOccurrence, formatRecurrence, todayIn, type OccurrenceFormatOptio
|
|
|
106
107
|
export { ChoiceCell, LinkCell, LinkOut, NameCell, type ChoiceCellProps, type LinkCellProps, type NameCellProps, } from './components/app/row-edit-cells.js';
|
|
107
108
|
export { ModuleCard, ModuleStrip, type CategorySlot, type ModuleCardLink, type ModuleCardPlace, type ModuleCardProps, type ModuleStripMobile, type ModuleStripProps, } from './components/app/module-card.js';
|
|
108
109
|
export { WidgetCard, WidgetCardGroup, WidgetList, WidgetListItem, type WidgetCardGroupProps, type WidgetCardLink, type WidgetCardProps, type WidgetListItemProps, } from './components/app/widget-card.js';
|
|
109
|
-
export { OverviewPage, type OverviewPageProps, type OverviewPart } from './components/app/overview-page.js';
|
|
110
|
+
export { OverviewPage, type OverviewLink, type OverviewPageProps, type OverviewPart } from './components/app/overview-page.js';
|
|
110
111
|
export { WidgetLayoutSheet, type WidgetLayoutSheetProps } from './components/app/widget-layout-sheet.js';
|
|
111
112
|
export { ThemeProvider } from './components/theme-provider.js';
|
|
112
113
|
export { LoginRoute, type LoginRouteProps } from './routes/login.js';
|
package/dist/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { ChoiceButtons } from './components/app/choice-buttons.js';
|
|
|
26
26
|
export { ReferenceCombobox } from './components/app/reference-combobox.js';
|
|
27
27
|
export { fieldRows } from './lib/field-rows.js';
|
|
28
28
|
export { KeyStats } from './components/app/key-stats.js';
|
|
29
|
+
export { ActionHint } from './components/app/action-hint.js';
|
|
29
30
|
export { StatusMark } from './components/app/status-mark.js';
|
|
30
31
|
export { STATUS_KINDS, STATUS_KIND_ICONS, STATUS_KIND_LABELS, STATUS_KIND_TONES, } from './lib/status-kinds.js';
|
|
31
32
|
// The record's empty value (4.96): a muted dash read as "Not set", for an
|
package/dist/testing/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import AxeBuilder from '@axe-core/playwright';
|
|
|
15
15
|
import { expect, test as base } from '@playwright/test';
|
|
16
16
|
import { navPathname, navTargets } from '../components/app/app-shell-nav.js';
|
|
17
17
|
import { PALETTE_STORAGE_KEY, paletteColorScheme } from '../lib/palettes.js';
|
|
18
|
+
import { waitForTransitions } from './transitions.js';
|
|
18
19
|
export { expect };
|
|
19
20
|
// A page load returns at the load event, but the app isn't up yet: React
|
|
20
21
|
// renders only after MSW's worker.start(), which took up to 2.4 s past
|
|
@@ -112,24 +113,6 @@ export function forceLoggedOut(page) {
|
|
|
112
113
|
* they're never read out.
|
|
113
114
|
*/
|
|
114
115
|
export const POPUP_FOCUS_GUARDS = '[data-base-ui-focus-guard]';
|
|
115
|
-
/**
|
|
116
|
-
* Resolves once the page's open and close transitions have finished. A
|
|
117
|
-
* popup fading in is already "visible" to Playwright, and its text is
|
|
118
|
-
* blended with the page behind: axe measured a sheet's muted labels at
|
|
119
|
-
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
120
|
-
* Two frames first, so a transition that starts on the next frame (Base
|
|
121
|
-
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
122
|
-
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
123
|
-
*/
|
|
124
|
-
async function waitForTransitions(page) {
|
|
125
|
-
await page.evaluate(async () => {
|
|
126
|
-
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
127
|
-
const ending = document
|
|
128
|
-
.getAnimations()
|
|
129
|
-
.filter((animation) => animation.effect?.getComputedTiming().endTime !== Infinity);
|
|
130
|
-
await Promise.all(ending.map((animation) => animation.finished.catch(() => undefined)));
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
116
|
/**
|
|
134
117
|
* axe on the page as it is now, once its transitions have finished. The
|
|
135
118
|
* options are for a state whose structure a rule doesn't fit, said where
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Page } from '@playwright/test';
|
|
2
|
+
/**
|
|
3
|
+
* Resolves once the page's open and close transitions have finished. A
|
|
4
|
+
* popup fading in is already "visible" to Playwright, and its text is
|
|
5
|
+
* blended with the page behind: axe measured a sheet's muted labels at
|
|
6
|
+
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
7
|
+
* Two frames first, so a transition that starts on the next frame (Base
|
|
8
|
+
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
9
|
+
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
10
|
+
*/
|
|
11
|
+
export declare function waitForTransitions(page: Page): Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves once the page's open and close transitions have finished. A
|
|
3
|
+
* popup fading in is already "visible" to Playwright, and its text is
|
|
4
|
+
* blended with the page behind: axe measured a sheet's muted labels at
|
|
5
|
+
* 4.37:1 mid-fade, 4.74:1 once shown, and failed CI on correct colours.
|
|
6
|
+
* Two frames first, so a transition that starts on the next frame (Base
|
|
7
|
+
* UI drops `data-starting-style` there) is running by the time it's read.
|
|
8
|
+
* Endless animations (a spinner, a skeleton's pulse) are left out.
|
|
9
|
+
*/
|
|
10
|
+
export async function waitForTransitions(page) {
|
|
11
|
+
await page.evaluate(async () => {
|
|
12
|
+
await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
|
|
13
|
+
const ending = document
|
|
14
|
+
.getAnimations()
|
|
15
|
+
.filter((animation) => animation.effect?.getComputedTiming().endTime !== Infinity);
|
|
16
|
+
await Promise.all(ending.map((animation) => animation.finished.catch(() => undefined)));
|
|
17
|
+
});
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.121.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": {
|
|
@@ -137,53 +137,53 @@
|
|
|
137
137
|
},
|
|
138
138
|
"dependencies": {
|
|
139
139
|
"@fontsource-variable/geist": "^5.3.0",
|
|
140
|
-
"@hookform/resolvers": "^5.9.
|
|
141
|
-
"@milkdown/kit": "^7.
|
|
140
|
+
"@hookform/resolvers": "^5.9.2",
|
|
141
|
+
"@milkdown/kit": "^7.23.0",
|
|
142
142
|
"class-variance-authority": "^0.7.1",
|
|
143
|
-
"cn": "^0.3.
|
|
143
|
+
"cn": "^0.3.3",
|
|
144
144
|
"date-fns": "^4.4.0",
|
|
145
|
-
"js-yaml": "^5.
|
|
146
|
-
"lucide-react": "^1.
|
|
147
|
-
"react-day-picker": "^10.0.
|
|
145
|
+
"js-yaml": "^5.5.0",
|
|
146
|
+
"lucide-react": "^1.73.0",
|
|
147
|
+
"react-day-picker": "^10.0.2",
|
|
148
148
|
"react-markdown": "^10.1.0",
|
|
149
149
|
"remark-gfm": "^4.0.1",
|
|
150
150
|
"remark-parse": "^11.0.0",
|
|
151
151
|
"rrule": "2.8.1",
|
|
152
|
-
"shadcn": "^4.
|
|
152
|
+
"shadcn": "^4.23.0",
|
|
153
153
|
"tw-animate-css": "^1.4.0",
|
|
154
154
|
"unified": "^11.0.5"
|
|
155
155
|
},
|
|
156
156
|
"devDependencies": {
|
|
157
|
-
"@axe-core/playwright": "^4.
|
|
158
|
-
"@base-ui/react": "^1.
|
|
157
|
+
"@axe-core/playwright": "^4.14.0",
|
|
158
|
+
"@base-ui/react": "^1.9.0",
|
|
159
159
|
"@eslint/js": "^10.0.1",
|
|
160
|
-
"@playwright/test": "^1.
|
|
161
|
-
"@tailwindcss/vite": "^4.3.
|
|
162
|
-
"@tanstack/eslint-plugin-query": "^5.
|
|
163
|
-
"@tanstack/react-query": "^5.
|
|
164
|
-
"@tanstack/react-table": "^9.
|
|
165
|
-
"@types/node": "^24.
|
|
160
|
+
"@playwright/test": "^1.65.1",
|
|
161
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
162
|
+
"@tanstack/eslint-plugin-query": "^5.107.1",
|
|
163
|
+
"@tanstack/react-query": "^5.107.1",
|
|
164
|
+
"@tanstack/react-table": "^9.3.1",
|
|
165
|
+
"@types/node": "^24.19.2",
|
|
166
166
|
"@types/react": "^19.3.0",
|
|
167
167
|
"@types/react-dom": "^19.3.0",
|
|
168
|
-
"@vitejs/plugin-react": "^6.
|
|
169
|
-
"eslint": "^10.
|
|
168
|
+
"@vitejs/plugin-react": "^6.3.0",
|
|
169
|
+
"eslint": "^10.15.0",
|
|
170
170
|
"eslint-plugin-check-file": "^3.3.2",
|
|
171
171
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
172
172
|
"eslint-plugin-react-refresh": "^0.5.7",
|
|
173
|
-
"globals": "^17.
|
|
173
|
+
"globals": "^17.14.0",
|
|
174
174
|
"msw": "^2.15.0",
|
|
175
175
|
"next-themes": "^0.4.6",
|
|
176
176
|
"openapi-typescript": "^7.13.0",
|
|
177
|
-
"react": "^19.3.
|
|
178
|
-
"react-dom": "^19.3.
|
|
179
|
-
"react-hook-form": "^7.
|
|
180
|
-
"react-router": "^7.18.
|
|
177
|
+
"react": "^19.3.1",
|
|
178
|
+
"react-dom": "^19.3.1",
|
|
179
|
+
"react-hook-form": "^7.92.0",
|
|
180
|
+
"react-router": "^7.18.5",
|
|
181
181
|
"sonner": "^2.0.8",
|
|
182
|
-
"tailwindcss": "^4.3.
|
|
182
|
+
"tailwindcss": "^4.3.5",
|
|
183
183
|
"typescript": "~6.0.3",
|
|
184
|
-
"typescript-eslint": "^8.
|
|
185
|
-
"vite": "^8.3.
|
|
186
|
-
"vitest": "^5.0
|
|
184
|
+
"typescript-eslint": "^8.72.2",
|
|
185
|
+
"vite": "^8.3.8",
|
|
186
|
+
"vitest": "^5.1.0",
|
|
187
187
|
"zod": "^4.6.7"
|
|
188
188
|
},
|
|
189
189
|
"publishConfig": {
|