@tristan2828/ui-foundation 4.124.0 → 4.124.2
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.
|
@@ -4,29 +4,29 @@
|
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
6
|
- [The reference files](#the-reference-files) · lines 45–67
|
|
7
|
-
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–
|
|
7
|
+
- [Before anything: the entity plan](#before-anything-the-entity-plan) · lines 69–859
|
|
8
8
|
- Step 1: Add `<Entity>` to `openapi.yaml` · lines 111–118
|
|
9
9
|
- Step 2: `npm run gen:api` · lines 119–120
|
|
10
10
|
- Step 3: Add gateway tests in `tests/gateway/<entity>.test.ts`, derived from the spec · lines 121–132
|
|
11
11
|
- Step 4: Add MSW handlers in `src/mocks/<entity>.ts` · lines 133–142
|
|
12
12
|
- Step 5: Add a gateway module in `src/api/gateway/<entity>.ts` · lines 143–149
|
|
13
|
-
- Step 6: Copy the reference files, one for one, not just the two screens · lines 150–
|
|
14
|
-
- Step 7: Register routes · lines
|
|
15
|
-
- Step 8: Add Playwright specs for all three screens · lines
|
|
16
|
-
- Step 9: Register the nav entry and route names · lines
|
|
17
|
-
- Step 10: `npm run verify`. · lines
|
|
18
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines
|
|
19
|
-
- [The record view](#the-record-view) · lines
|
|
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
|
|
13
|
+
- Step 6: Copy the reference files, one for one, not just the two screens · lines 150–747
|
|
14
|
+
- Step 7: Register routes · lines 748–763
|
|
15
|
+
- Step 8: Add Playwright specs for all three screens · lines 764–841
|
|
16
|
+
- Step 9: Register the nav entry and route names · lines 842–856
|
|
17
|
+
- Step 10: `npm run verify`. · lines 857–859
|
|
18
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 861–1330
|
|
19
|
+
- [The record view](#the-record-view) · lines 1014–1171
|
|
20
|
+
- [Forms](#forms) · lines 1173–1244
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1246–1277
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1279–1330
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1332–1365
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1367–1384
|
|
25
|
+
- [Deleting](#deleting) · lines 1386–1417
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1419–1440
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1442–1451
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1454–1496
|
|
29
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1498–1534
|
|
30
30
|
|
|
31
31
|
<!-- /index -->
|
|
32
32
|
|
|
@@ -606,7 +606,11 @@ is a filled-in example while the Widgets demo is still here).
|
|
|
606
606
|
renames its tooltip and name) that prints the marked sections alone, under the title
|
|
607
607
|
and subtitle: no rail, no shell, no buttons, light paper in either
|
|
608
608
|
theme, headings and bullets as written, nothing folded, tables
|
|
609
|
-
ruled with room in their empty cells.
|
|
609
|
+
ruled with room in their empty cells. On a phone, whose print()
|
|
610
|
+
returns at once and fires `afterprint` before its preview exists, the
|
|
611
|
+
copy stays until the person next touches the page or presses a key
|
|
612
|
+
(4.124.1), so the preview prints the notes; the browser's own print
|
|
613
|
+
(Ctrl+P) in that gap prints them too. `print: { answerSpace: true }`
|
|
610
614
|
also leaves space under each item of the section's numbered lists,
|
|
611
615
|
for questions answered by hand. A section's own content that should
|
|
612
616
|
print differently (a list of sub-items as plain text) reads
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1394–1464
|
|
33
33
|
- [A few equal things](#a-few-equal-things) · lines 1466–1550
|
|
34
34
|
- [An overview page](#an-overview-page) · lines 1552–1623
|
|
35
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1624–
|
|
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
|
|
35
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1624–1690
|
|
36
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1692–1816
|
|
37
|
+
- [Picking at random](#picking-at-random) · lines 1818–1849
|
|
38
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1851–1918
|
|
39
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1920–1945
|
|
40
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1947–2043
|
|
41
41
|
|
|
42
42
|
<!-- /index -->
|
|
43
43
|
|
|
@@ -1661,6 +1661,9 @@ data on each its own.
|
|
|
1661
1661
|
the universal actions only (Delete, Print Notes, Copy link, Pin, Open
|
|
1662
1662
|
site, Restore, Open Full Page, Close, More); everything else keeps its
|
|
1663
1663
|
word. `printLook="words"` keeps Print Notes as a button with its words.
|
|
1664
|
+
Print Notes prints a hidden copy of the notes: a desktop browser takes it
|
|
1665
|
+
away when its dialog closes, a phone's (print() returns at once) when the
|
|
1666
|
+
person next touches the page (4.124.1).
|
|
1664
1667
|
- **An empty value** reads as a dash (`emptyText`, default `'—'`), in the
|
|
1665
1668
|
muted text tone, read by a screen reader as "Not set": the same on
|
|
1666
1669
|
every field, the presets' included. A field's own `emptyLabel` still
|
|
@@ -13,8 +13,11 @@ export type EntityViewPrintSection = {
|
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* The header's Print notes button and, while it prints, the printed copy.
|
|
16
|
-
* The copy mounts, then the browser's print dialog opens on it
|
|
17
|
-
* when the dialog closes
|
|
16
|
+
* The copy mounts, then the browser's print dialog opens on it. Where
|
|
17
|
+
* print() blocks (a desktop browser) it goes when the dialog closes
|
|
18
|
+
* (`afterprint`). Where print() returns at once (a phone) `afterprint`
|
|
19
|
+
* comes too early to mean anything, so the copy goes on the person's next
|
|
20
|
+
* pointerdown or key instead.
|
|
18
21
|
*/
|
|
19
22
|
export declare function PrintNotes({ label, look, title, subtitle, sections, }: {
|
|
20
23
|
label: string;
|
|
@@ -13,7 +13,16 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
13
13
|
// write. A section marked `print: { answerSpace: true }` leaves space
|
|
14
14
|
// under each item of its numbered lists, for questions answered by hand.
|
|
15
15
|
//
|
|
16
|
-
//
|
|
16
|
+
// How long the copy stays depends on the browser. A desktop browser blocks
|
|
17
|
+
// in window.print() until the dialog closes, so `afterprint` ends it. A
|
|
18
|
+
// phone (Android Chrome, iOS Safari) returns from print() at once and
|
|
19
|
+
// fires `afterprint` before its preview is built, and a copy that went then
|
|
20
|
+
// would leave the preview to print the whole app page. So when print()
|
|
21
|
+
// returns in under a second, that early `afterprint` is ignored and the copy
|
|
22
|
+
// stays until the person next touches the page (a pointerdown or a key).
|
|
23
|
+
// Hidden on screen, it costs nothing to keep. The one visible side effect:
|
|
24
|
+
// the browser's own print (Ctrl+P) made before that touch prints the notes
|
|
25
|
+
// copy rather than the page. Otherwise Ctrl+P prints the page as it is; only
|
|
17
26
|
// the button prints the notes alone.
|
|
18
27
|
import { useEffect, useState } from 'react';
|
|
19
28
|
import { createPortal } from 'react-dom';
|
|
@@ -30,23 +39,53 @@ function PrintedSection({ section }) {
|
|
|
30
39
|
function PrintedNotes({ title, subtitle, sections }) {
|
|
31
40
|
return createPortal(_jsx(PrintingContext.Provider, { value: true, children: _jsxs("article", { "data-print-notes": "", "data-slot": "entity-view-print", className: "hidden flex-col gap-6 bg-background text-foreground print:flex", children: [_jsxs("header", { className: "flex flex-col gap-1", children: [_jsx("h1", { className: "type-heading-1 break-words", children: title }), subtitle && _jsx("div", { className: "type-body break-words text-muted-foreground", children: subtitle })] }), sections.map((section) => (_jsx(PrintedSection, { section: section }, section.title)))] }) }), document.body);
|
|
32
41
|
}
|
|
42
|
+
/** A print() that returns sooner than this didn't wait for the dialog: a phone's. */
|
|
43
|
+
const BLOCKING_PRINT_MS = 1000;
|
|
33
44
|
/**
|
|
34
45
|
* The header's Print notes button and, while it prints, the printed copy.
|
|
35
|
-
* The copy mounts, then the browser's print dialog opens on it
|
|
36
|
-
* when the dialog closes
|
|
46
|
+
* The copy mounts, then the browser's print dialog opens on it. Where
|
|
47
|
+
* print() blocks (a desktop browser) it goes when the dialog closes
|
|
48
|
+
* (`afterprint`). Where print() returns at once (a phone) `afterprint`
|
|
49
|
+
* comes too early to mean anything, so the copy goes on the person's next
|
|
50
|
+
* pointerdown or key instead.
|
|
37
51
|
*/
|
|
38
52
|
export function PrintNotes({ label, look = 'icon', title, subtitle, sections, }) {
|
|
39
53
|
// How many times it's been pressed since the copy last went: a press
|
|
40
|
-
// while one is up (a browser that never said the dialog closed
|
|
41
|
-
// it again rather than doing nothing.
|
|
54
|
+
// while one is up (a browser that never said the dialog closed, or a phone
|
|
55
|
+
// still holding the copy) prints it again rather than doing nothing.
|
|
42
56
|
const [printing, setPrinting] = useState(0);
|
|
43
57
|
useEffect(() => {
|
|
44
58
|
if (printing === 0)
|
|
45
59
|
return;
|
|
46
|
-
const
|
|
47
|
-
|
|
60
|
+
const release = () => setPrinting(0);
|
|
61
|
+
// Whether print() waited for the dialog; unknown until it returns, and an
|
|
62
|
+
// `afterprint` inside the call is kept until then.
|
|
63
|
+
let blocked = undefined;
|
|
64
|
+
let endedInside = false;
|
|
65
|
+
const onAfterPrint = () => {
|
|
66
|
+
if (blocked === undefined)
|
|
67
|
+
endedInside = true;
|
|
68
|
+
else if (blocked)
|
|
69
|
+
release();
|
|
70
|
+
};
|
|
71
|
+
window.addEventListener('afterprint', onAfterPrint);
|
|
72
|
+
const started = performance.now();
|
|
48
73
|
window.print();
|
|
49
|
-
|
|
74
|
+
blocked = performance.now() - started >= BLOCKING_PRINT_MS;
|
|
75
|
+
if (blocked) {
|
|
76
|
+
if (endedInside)
|
|
77
|
+
release();
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
// A phone: the copy waits for the person to come back to the page.
|
|
81
|
+
window.addEventListener('pointerdown', release);
|
|
82
|
+
window.addEventListener('keydown', release);
|
|
83
|
+
}
|
|
84
|
+
return () => {
|
|
85
|
+
window.removeEventListener('afterprint', onAfterPrint);
|
|
86
|
+
window.removeEventListener('pointerdown', release);
|
|
87
|
+
window.removeEventListener('keydown', release);
|
|
88
|
+
};
|
|
50
89
|
}, [printing]);
|
|
51
90
|
return (_jsxs(_Fragment, { children: [look === 'icon' ? (_jsx(IconAction, { icon: PrinterIcon, label: label, onClick: () => setPrinting((count) => count + 1) })) : (_jsxs(Button, { variant: "outline", onClick: () => setPrinting((count) => count + 1), children: [_jsx(PrinterIcon, {}), label] })), printing > 0 && _jsx(PrintedNotes, { title: title, subtitle: subtitle, sections: sections })] }));
|
|
52
91
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.124.
|
|
3
|
+
"version": "4.124.2",
|
|
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": {
|