@tristan2828/ui-foundation 4.111.0 → 4.113.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 +17 -13
- package/conventions/docs/design-language.md +10 -3
- package/dist/components/app/app-shell-bottom-bar.js +44 -14
- package/dist/components/app/app-shell-nav.d.ts +20 -0
- package/dist/components/app/app-shell-nav.js +38 -0
- package/dist/components/app/app-shell.js +5 -4
- package/dist/components/app/entity-view.js +25 -8
- package/dist/components/app/field-rows.d.ts +1 -0
- package/dist/components/app/field-rows.js +5 -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–1261
|
|
19
|
+
- [The record view](#the-record-view) · lines 1005–1106
|
|
20
|
+
- [Forms](#forms) · lines 1108–1178
|
|
21
|
+
- [Dialogs](#dialogs) · lines 1180–1211
|
|
22
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1213–1261
|
|
23
|
+
- [What not to copy](#what-not-to-copy) · lines 1263–1295
|
|
24
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1297–1314
|
|
25
|
+
- [Deleting](#deleting) · lines 1316–1347
|
|
26
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1349–1370
|
|
27
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1372–1381
|
|
28
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1384–1426
|
|
29
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1428–1464
|
|
30
30
|
|
|
31
31
|
<!-- /index -->
|
|
32
32
|
|
|
@@ -1051,7 +1051,11 @@ A record uses the parts it has, in this order:
|
|
|
1051
1051
|
dialog), so the page doesn't end 900px in. The strip stays above it at
|
|
1052
1052
|
full width, and the rail starts level with the first content under the
|
|
1053
1053
|
strip: the open tab's first section (beside the tab's content, not its
|
|
1054
|
-
bar), or the first card when cards come before the tabs (4.108).
|
|
1054
|
+
bar), or the first card when cards come before the tabs (4.108). Beside
|
|
1055
|
+
the rail the record's cards fill the column up to it, as wide as the
|
|
1056
|
+
tab bar (Details too, which elsewhere keeps a 42rem reading width), and
|
|
1057
|
+
their rows keep a compact 10rem label so the values get the rest
|
|
1058
|
+
(4.112). Only short values go in it,
|
|
1055
1059
|
and the API holds to that: a rail section is `facts`, not `fields`,
|
|
1056
1060
|
each fact one of a few kinds, never free markup:
|
|
1057
1061
|
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
- [Picking at random](#picking-at-random) · lines 1713–1744
|
|
38
38
|
- [Filling in what's missing](#filling-in-whats-missing) · lines 1746–1813
|
|
39
39
|
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1815–1840
|
|
40
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1842–
|
|
40
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1842–1938
|
|
41
41
|
|
|
42
42
|
<!-- /index -->
|
|
43
43
|
|
|
@@ -1874,8 +1874,15 @@ const bottomBar: BottomBarItem[] = [
|
|
|
1874
1874
|
- **Counts** (`count`, `countLabel`): a plain number at the entry's end
|
|
1875
1875
|
in the muted text tone, never a coloured badge; on the icon rail a dot
|
|
1876
1876
|
in `--primary` on the icon. Only on entries that ask you to act
|
|
1877
|
-
(unread, to fill in, new); 0 shows nothing
|
|
1878
|
-
|
|
1877
|
+
(unread, to fill in, new); 0 shows nothing, nor does a count still
|
|
1878
|
+
loading, and past 99 it reads "99+". `countLabel` is what the number
|
|
1879
|
+
counts, read after the entry's name ("News 24 unread"). On a phone
|
|
1880
|
+
(4.113) the bottom bar has no room at an item's end, so its count is
|
|
1881
|
+
a small `--primary` badge on the item's icon, ringed in the bar's
|
|
1882
|
+
background: a page's own count, or a section's sum of its entries'
|
|
1883
|
+
(with their `countLabel` when they share one). The sheet's tiles carry
|
|
1884
|
+
theirs in the corner and its list links at their end, as the sidebar
|
|
1885
|
+
does. Each is read after its name ("News, 7 new").
|
|
1879
1886
|
- **A section at the foot** (`placement: 'bottom'`): under every other
|
|
1880
1887
|
section and `sidebarExtra`, pushed to the sidebar's foot when there's
|
|
1881
1888
|
room; for tools rather than modules.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// AppShell's bottom bar on a phone (#240): Home and a few of the nav's
|
|
3
3
|
// sections in thumb reach, where the sidebar is a sheet behind the
|
|
4
4
|
// header's menu button. An item is a link, or a nav section by its label,
|
|
@@ -7,16 +7,20 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
7
7
|
// `sheet: 'tiles'` a grid of the entries as tiles, icon over label, like
|
|
8
8
|
// a phone's home screen. The sheet closes on navigation, as the
|
|
9
9
|
// sidebar's does. The item holding the current page is marked
|
|
10
|
-
// (`aria-current`).
|
|
10
|
+
// (`aria-current`). An entry's `count` shows on the phone as it does in
|
|
11
|
+
// the sidebar: a badge on a bar item's icon (a page's own, or the sum of a
|
|
12
|
+
// section's), in a tile's corner, at a sheet link's end; nothing at 0 or
|
|
13
|
+
// while loading, "99+" past 99, and read after the label ("News, 7 new").
|
|
14
|
+
// Shown below the md breakpoint only (the sidebar's own
|
|
11
15
|
// mobile breakpoint); the shell pads its content by the bar's height and
|
|
12
16
|
// the phone's safe area, so a page's last row clears it.
|
|
13
17
|
import { useId, useState } from 'react';
|
|
14
18
|
import { Link, useLocation } from 'react-router';
|
|
15
|
-
import { bottomBarCurrent, bottomBarSection, bottomBarTiles, childItems, childRuns, childrenOpen, isNavItemGroup, } from './app-shell-nav.js';
|
|
19
|
+
import { bottomBarCount, bottomBarCurrent, bottomBarSection, bottomBarTiles, childItems, childRuns, childrenOpen, isNavItemGroup, navCountSpoken, navCountText, } from './app-shell-nav.js';
|
|
16
20
|
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '../ui/sheet.js';
|
|
17
21
|
const ITEM_CLASS = 'flex min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md px-1 type-caption text-muted-foreground ' +
|
|
18
22
|
'outline-none focus-visible:ring-3 focus-visible:ring-ring/50 aria-[current]:text-foreground aria-[current]:font-medium ' +
|
|
19
|
-
'[
|
|
23
|
+
'[&_svg]:size-5 [&_svg]:shrink-0';
|
|
20
24
|
const SHEET_LINK_CLASS = 'flex min-h-11 items-center gap-3 rounded-md px-3 type-body text-foreground outline-none ' +
|
|
21
25
|
'hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 aria-[current=page]:bg-accent aria-[current=page]:font-medium ' +
|
|
22
26
|
'[&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-muted-foreground';
|
|
@@ -25,13 +29,39 @@ const SHEET_LINK_CLASS = 'flex min-h-11 items-center gap-3 rounded-md px-3 type-
|
|
|
25
29
|
* plus the bar (4rem and its 1px border) and the phone's safe area.
|
|
26
30
|
*/
|
|
27
31
|
export const BOTTOM_BAR_PADDING = 'max-md:pb-[calc(--spacing(22)+1px+env(safe-area-inset-bottom))]';
|
|
32
|
+
// A link's label, and with a count its name: "News, 7 new". The name is
|
|
33
|
+
// one hidden text, the drawn label and count aria-hidden, so it reads
|
|
34
|
+
// exactly that (a hidden span beside the label would add a space before
|
|
35
|
+
// the comma).
|
|
36
|
+
function CountedLabel({ label, count, countLabel, className, }) {
|
|
37
|
+
const spoken = navCountSpoken(count, countLabel);
|
|
38
|
+
if (spoken === undefined)
|
|
39
|
+
return _jsx("span", { className: className, children: label });
|
|
40
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: className, children: label }), _jsx("span", { className: "sr-only", children: `${label}, ${spoken}` })] }));
|
|
41
|
+
}
|
|
42
|
+
// A tile's count in its corner, as the sidebar's tiles have it.
|
|
43
|
+
// Its link's name reads it (CountedLabel).
|
|
44
|
+
function TileCount({ count }) {
|
|
45
|
+
const text = navCountText(count);
|
|
46
|
+
if (text === undefined)
|
|
47
|
+
return null;
|
|
48
|
+
return (_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "absolute top-1 right-1.5 type-caption leading-none text-foreground tabular-nums", children: text }));
|
|
49
|
+
}
|
|
50
|
+
// A bar item's icon, with its count as a badge on its corner: the
|
|
51
|
+
// primary's fill, ringed in the bar's background so it stands off the
|
|
52
|
+
// icon. Sized in em, so it grows with the type at large density.
|
|
53
|
+
function BarIcon({ icon: Icon, count }) {
|
|
54
|
+
const text = navCountText(count);
|
|
55
|
+
return (_jsxs("span", { className: "relative inline-flex", children: [_jsx(Icon, { "aria-hidden": "true" }), text !== undefined && (_jsx("span", { "aria-hidden": "true", "data-slot": "bottom-bar-count", className: "absolute -top-1.5 left-[calc(100%-0.5rem)] inline-flex h-[1.5em] min-w-[1.5em] items-center justify-center rounded-full bg-primary px-[0.35em] type-caption leading-none font-medium text-primary-foreground tabular-nums ring-2 ring-background", children: text }))] }));
|
|
56
|
+
}
|
|
28
57
|
// A tile: the entry's icon over its label, a finger's target at least.
|
|
29
|
-
const TILE_CLASS = 'flex min-h-11 min-w-0 flex-col items-center justify-center gap-1 rounded-lg border border-border bg-background px-1.5 py-2.5 ' +
|
|
58
|
+
const TILE_CLASS = 'relative flex min-h-11 min-w-0 flex-col items-center justify-center gap-1 rounded-lg border border-border bg-background px-1.5 py-2.5 ' +
|
|
30
59
|
'text-center type-caption text-foreground outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 ' +
|
|
31
60
|
'aria-[current]:border-primary aria-[current]:font-medium [&>svg]:size-5 [&>svg]:shrink-0 [&>svg]:text-link';
|
|
32
61
|
function SheetLink({ item, activeTo }) {
|
|
33
|
-
const { to, label, icon: Icon, children } = item;
|
|
34
|
-
|
|
62
|
+
const { to, label, icon: Icon, children, count, countLabel } = item;
|
|
63
|
+
const text = navCountText(count);
|
|
64
|
+
return (_jsxs("li", { children: [_jsxs(Link, { to: to, "aria-current": to === activeTo ? 'page' : undefined, className: SHEET_LINK_CLASS, children: [_jsx(Icon, {}), _jsx(CountedLabel, { label: label, count: count, countLabel: countLabel, className: "truncate" }), text !== undefined && (_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "ml-auto shrink-0 type-caption text-muted-foreground tabular-nums", children: text }))] }), children && children.length > 0 && (_jsx("div", { className: "ml-5 border-l border-border pl-2", children: _jsx(SheetChildren, { items: children, activeTo: activeTo }) }))] }));
|
|
35
65
|
}
|
|
36
66
|
function SheetGroup({ label, items, activeTo }) {
|
|
37
67
|
const headingId = useId();
|
|
@@ -42,7 +72,7 @@ function SheetChildren({ items, activeTo }) {
|
|
|
42
72
|
}
|
|
43
73
|
// A page tile, under a tiles section's tiles: smaller, four to a row,
|
|
44
74
|
// still a finger's target.
|
|
45
|
-
const PAGE_TILE_CLASS = 'flex min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md px-1 py-1.5 text-center type-caption ' +
|
|
75
|
+
const PAGE_TILE_CLASS = 'relative flex min-h-11 min-w-0 flex-1 flex-col items-center justify-center gap-0.5 rounded-md px-1 py-1.5 text-center type-caption ' +
|
|
46
76
|
'text-foreground outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 ' +
|
|
47
77
|
'aria-[current=page]:bg-accent aria-[current=page]:font-medium [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-muted-foreground';
|
|
48
78
|
// The current entry's pages under a tiles section's tiles (#6C): a
|
|
@@ -50,7 +80,7 @@ const PAGE_TILE_CLASS = 'flex min-h-11 min-w-0 flex-1 flex-col items-center just
|
|
|
50
80
|
// own with its list still named by it.
|
|
51
81
|
function SheetPageTiles({ items, activeTo }) {
|
|
52
82
|
const open = items.filter((item) => childrenOpen(item, activeTo));
|
|
53
|
-
return open.map((item) => (_jsx("div", { role: "group", "aria-label": `${item.label} pages`, "data-slot": "app-shell-sheet-pages", className: "flex flex-col", children: childRuns(item).map((run, runIndex) => (_jsxs("div", { className: "flex flex-col", children: [_jsx("div", { role: "separator", className: "my-2 h-px bg-border" }), _jsx("ul", { "aria-label": run.label, className: "grid grid-cols-4 gap-1.5", children: run.items.map(({ to, label, icon: Icon }) => (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": to === activeTo ? 'page' : undefined, className: PAGE_TILE_CLASS, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx(
|
|
83
|
+
return open.map((item) => (_jsx("div", { role: "group", "aria-label": `${item.label} pages`, "data-slot": "app-shell-sheet-pages", className: "flex flex-col", children: childRuns(item).map((run, runIndex) => (_jsxs("div", { className: "flex flex-col", children: [_jsx("div", { role: "separator", className: "my-2 h-px bg-border" }), _jsx("ul", { "aria-label": run.label, className: "grid grid-cols-4 gap-1.5", children: run.items.map(({ to, label, icon: Icon, count, countLabel }) => (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": to === activeTo ? 'page' : undefined, className: PAGE_TILE_CLASS, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx(CountedLabel, { label: label, count: count, countLabel: countLabel, className: "max-w-full break-words" }), _jsx(TileCount, { count: count })] }) }, to))) })] }, run.label ?? `run:${runIndex}`))) }, item.to)));
|
|
54
84
|
}
|
|
55
85
|
// The tiles (#N8): one per entry. Its pages are left to the module itself,
|
|
56
86
|
// unless the section's look is tiles (#6C): then the current entry's are
|
|
@@ -58,10 +88,10 @@ function SheetPageTiles({ items, activeTo }) {
|
|
|
58
88
|
// its pages, is marked.
|
|
59
89
|
function SheetTiles({ items, activeTo, withPages, }) {
|
|
60
90
|
return (_jsxs(_Fragment, { children: [_jsx("ul", { "data-slot": "app-shell-sheet-tiles", className: "grid grid-cols-3 gap-2", children: items.map((item) => {
|
|
61
|
-
const { to, label, icon: Icon } = item;
|
|
91
|
+
const { to, label, icon: Icon, count, countLabel } = item;
|
|
62
92
|
// "page" on the module's own page, "true" on one of its pages.
|
|
63
93
|
const current = to === activeTo ? 'page' : childItems(item).some((child) => child.to === activeTo) ? 'true' : undefined;
|
|
64
|
-
return (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": current, className: `${TILE_CLASS} flex-1`, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx(
|
|
94
|
+
return (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": current, className: `${TILE_CLASS} flex-1`, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx(CountedLabel, { label: label, count: count, countLabel: countLabel, className: "max-w-full break-words" }), _jsx(TileCount, { count: count })] }) }, to));
|
|
65
95
|
}) }), withPages && _jsx(SheetPageTiles, { items: items, activeTo: activeTo })] }));
|
|
66
96
|
}
|
|
67
97
|
export function BottomBar({ items, nav, activeTo, navLook = 'list', }) {
|
|
@@ -80,12 +110,12 @@ export function BottomBar({ items, nav, activeTo, navLook = 'list', }) {
|
|
|
80
110
|
// The current entry's pages show under the tiles when the section's own look is tiles.
|
|
81
111
|
const withPages = (section?.look ?? navLook) === 'tiles';
|
|
82
112
|
return (_jsxs(_Fragment, { children: [_jsx("nav", { "aria-label": "Bottom bar", "data-slot": "app-shell-bottom-bar", className: "fixed inset-x-0 bottom-0 z-20 border-t border-border bg-background pb-[env(safe-area-inset-bottom)] md:hidden", children: _jsx("ul", { className: "flex h-16 items-stretch gap-1 px-2 py-1.5", children: shown.map((item, index) => {
|
|
83
|
-
const Icon = item.icon;
|
|
84
113
|
const isCurrent = index === current;
|
|
114
|
+
const { count, countLabel } = bottomBarCount(item, nav);
|
|
85
115
|
if ('to' in item) {
|
|
86
|
-
return (_jsx("li", { className: "flex min-w-0 flex-1", children: _jsxs(Link, { to: item.to, "aria-current": isCurrent ? 'page' : undefined, className: ITEM_CLASS, children: [_jsx(
|
|
116
|
+
return (_jsx("li", { className: "flex min-w-0 flex-1", children: _jsxs(Link, { to: item.to, "aria-current": isCurrent ? 'page' : undefined, className: ITEM_CLASS, children: [_jsx(BarIcon, { icon: item.icon, count: count }), _jsx(CountedLabel, { label: item.label, count: count, countLabel: countLabel, className: "max-w-full truncate" })] }) }, `to:${item.to}`));
|
|
87
117
|
}
|
|
88
118
|
const label = item.label ?? item.group;
|
|
89
|
-
return (_jsx("li", { className: "flex min-w-0 flex-1", children: _jsxs("button", { type: "button", "aria-haspopup": "dialog", "aria-expanded": openGroup === item.group, "aria-current": isCurrent ? 'true' : undefined, onClick: () => setOpenGroup(item.group), className: ITEM_CLASS, children: [_jsx(
|
|
119
|
+
return (_jsx("li", { className: "flex min-w-0 flex-1", children: _jsxs("button", { type: "button", "aria-haspopup": "dialog", "aria-expanded": openGroup === item.group, "aria-current": isCurrent ? 'true' : undefined, onClick: () => setOpenGroup(item.group), className: ITEM_CLASS, children: [_jsx(BarIcon, { icon: item.icon, count: count }), _jsx(CountedLabel, { label: label, count: count, countLabel: countLabel, className: "max-w-full truncate" })] }) }, `group:${item.group}`));
|
|
90
120
|
}) }) }), _jsx(Sheet, { open: section !== undefined, onOpenChange: (open) => !open && setOpenGroup(null), children: _jsx(SheetContent, { side: "bottom", className: "max-h-[80dvh] gap-2 pb-[calc(--spacing(4)+env(safe-area-inset-bottom))] md:hidden", children: section && (_jsxs(_Fragment, { children: [_jsx(SheetHeader, { className: "pb-0", children: _jsx(SheetTitle, { children: section.label }) }), _jsx("nav", { "aria-label": section.label, className: "overflow-y-auto px-2", children: tiles ? (_jsx(SheetTiles, { items: section.items, activeTo: activeTo, withPages: withPages })) : (_jsx(SheetChildren, { items: section.items, activeTo: activeTo })) })] })) }) })] }));
|
|
91
121
|
}
|
|
@@ -220,3 +220,23 @@ export declare function bottomBarSection(nav: readonly NavEntry[], label: string
|
|
|
220
220
|
* the page's own link, or else the section it's in, children included.
|
|
221
221
|
*/
|
|
222
222
|
export declare function bottomBarCurrent(items: readonly BottomBarItem[], nav: readonly NavEntry[], activeTo: string | undefined): number | undefined;
|
|
223
|
+
/**
|
|
224
|
+
* A count as drawn: nothing at 0, below it or while it's loading (no
|
|
225
|
+
* count yet), and "99+" past 99, so a badge keeps its size.
|
|
226
|
+
*/
|
|
227
|
+
export declare function navCountText(count: number | undefined): string | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* A count as read, after its entry's label: "7 new" with its
|
|
230
|
+
* `countLabel`, the number alone without. The real number, past 99 too.
|
|
231
|
+
* Nothing where nothing is drawn.
|
|
232
|
+
*/
|
|
233
|
+
export declare function navCountSpoken(count: number | undefined, countLabel?: string): string | undefined;
|
|
234
|
+
/**
|
|
235
|
+
* A bottom bar item's count: a page's, from its nav entry, or a
|
|
236
|
+
* section's, the sum of its entries' and their pages'. A section's
|
|
237
|
+
* `countLabel` is its entries' when they share one, and none otherwise.
|
|
238
|
+
*/
|
|
239
|
+
export declare function bottomBarCount(item: BottomBarItem, nav: readonly NavEntry[]): {
|
|
240
|
+
count?: number;
|
|
241
|
+
countLabel?: string;
|
|
242
|
+
};
|
|
@@ -215,3 +215,41 @@ export function bottomBarCurrent(items, nav, activeTo) {
|
|
|
215
215
|
const group = items.findIndex((item) => 'group' in item && withChildren(bottomBarSection(nav, item.group)?.items ?? []).some((entry) => entry.to === activeTo));
|
|
216
216
|
return group === -1 ? undefined : group;
|
|
217
217
|
}
|
|
218
|
+
/**
|
|
219
|
+
* A count as drawn: nothing at 0, below it or while it's loading (no
|
|
220
|
+
* count yet), and "99+" past 99, so a badge keeps its size.
|
|
221
|
+
*/
|
|
222
|
+
export function navCountText(count) {
|
|
223
|
+
if (count === undefined || !Number.isFinite(count) || count <= 0)
|
|
224
|
+
return undefined;
|
|
225
|
+
return count > 99 ? '99+' : String(Math.floor(count));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* A count as read, after its entry's label: "7 new" with its
|
|
229
|
+
* `countLabel`, the number alone without. The real number, past 99 too.
|
|
230
|
+
* Nothing where nothing is drawn.
|
|
231
|
+
*/
|
|
232
|
+
export function navCountSpoken(count, countLabel) {
|
|
233
|
+
if (navCountText(count) === undefined)
|
|
234
|
+
return undefined;
|
|
235
|
+
const n = Math.floor(count);
|
|
236
|
+
return countLabel ? `${n} ${countLabel}` : String(n);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* A bottom bar item's count: a page's, from its nav entry, or a
|
|
240
|
+
* section's, the sum of its entries' and their pages'. A section's
|
|
241
|
+
* `countLabel` is its entries' when they share one, and none otherwise.
|
|
242
|
+
*/
|
|
243
|
+
export function bottomBarCount(item, nav) {
|
|
244
|
+
if ('to' in item) {
|
|
245
|
+
const entry = navItems(nav).find((other) => other.to === item.to);
|
|
246
|
+
return entry ? { count: entry.count, countLabel: entry.countLabel } : {};
|
|
247
|
+
}
|
|
248
|
+
const counted = withChildren(bottomBarSection(nav, item.group)?.items ?? []).filter((entry) => navCountText(entry.count) !== undefined);
|
|
249
|
+
if (!counted.length)
|
|
250
|
+
return {};
|
|
251
|
+
const count = counted.reduce((sum, entry) => sum + Math.floor(entry.count), 0);
|
|
252
|
+
const labels = new Set(counted.map((entry) => entry.countLabel));
|
|
253
|
+
const [only] = labels;
|
|
254
|
+
return { count, countLabel: labels.size === 1 ? only : undefined };
|
|
255
|
+
}
|
|
@@ -5,7 +5,7 @@ import { useCallback, useEffect, useId, useMemo, useState } from 'react';
|
|
|
5
5
|
import { Link, Navigate, Outlet, useLocation } from 'react-router';
|
|
6
6
|
import { useAuth } from '../../auth/use-auth.js';
|
|
7
7
|
import { BottomBar, BOTTOM_BAR_PADDING } from './app-shell-bottom-bar.js';
|
|
8
|
-
import { activeNavTo, childItems, childRuns, childrenOpen, isNavItemGroup, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
|
|
8
|
+
import { activeNavTo, childItems, childRuns, childrenOpen, isNavItemGroup, navCountSpoken, navCountText, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
|
|
9
9
|
import { versionHref, versionLabel } from './app-shell-version.js';
|
|
10
10
|
import { ErrorState } from './error-state.js';
|
|
11
11
|
import { PageTrail } from './page-trail.js';
|
|
@@ -98,9 +98,10 @@ const ACTIVE_MARK = 'data-active:shadow-[inset_3px_0_0_0_var(--primary)]';
|
|
|
98
98
|
// An entry's count (#N3): a plain number at its end in the muted tone,
|
|
99
99
|
// read with what it counts; on the icon rail, a dot on the icon.
|
|
100
100
|
function NavCount({ count, countLabel }) {
|
|
101
|
-
|
|
101
|
+
const text = navCountText(count);
|
|
102
|
+
if (text === undefined)
|
|
102
103
|
return null;
|
|
103
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "ml-auto shrink-0 type-caption text-muted-foreground tabular-nums group-data-[collapsible=icon]:hidden", children:
|
|
104
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "ml-auto shrink-0 type-caption text-muted-foreground tabular-nums group-data-[collapsible=icon]:hidden", children: text }), _jsx("span", { className: "sr-only", children: navCountSpoken(count, countLabel) }), _jsx("span", { "aria-hidden": "true", "data-slot": "nav-count-dot", className: "pointer-events-none absolute top-1 right-1 hidden size-1.5 rounded-full bg-primary group-data-[collapsible=icon]:block" })] }));
|
|
104
105
|
}
|
|
105
106
|
function NavSubLink({ item, activeTo }) {
|
|
106
107
|
const { to, label, icon: Icon, count, countLabel } = item;
|
|
@@ -144,7 +145,7 @@ function NavTile({ item, activeTo }) {
|
|
|
144
145
|
const { to, label, icon: Icon, count, countLabel } = item;
|
|
145
146
|
// "page" on the entry's own page, "true" on one of its pages.
|
|
146
147
|
const current = to === activeTo ? 'page' : childItems(item).some((child) => child.to === activeTo) ? 'true' : undefined;
|
|
147
|
-
return (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": current, "data-slot": "nav-tile", "data-active": current ? '' : undefined, className: NAV_TILE_CLASS, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx("span", { className: "max-w-full break-words", children: label }), count ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "absolute top-1 right-1.5 type-caption leading-none text-sidebar-foreground tabular-nums", children: count }), _jsx("span", { className: "sr-only", children:
|
|
148
|
+
return (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": current, "data-slot": "nav-tile", "data-active": current ? '' : undefined, className: NAV_TILE_CLASS, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx("span", { className: "max-w-full break-words", children: label }), navCountText(count) !== undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", "data-slot": "nav-count", className: "absolute top-1 right-1.5 type-caption leading-none text-sidebar-foreground tabular-nums", children: navCountText(count) }), _jsx("span", { className: "sr-only", children: navCountSpoken(count, countLabel) })] })) : null] }) }));
|
|
148
149
|
}
|
|
149
150
|
// A group in the tiles look (#6C): its entries as a three-column grid,
|
|
150
151
|
// its label for screen readers only (the grid is a list named by it), and
|
|
@@ -123,6 +123,10 @@ import { factsAsFields, useWideParent } from './entity-view-facts.js';
|
|
|
123
123
|
// The view's empty text and whether fields cards fold their empty ones,
|
|
124
124
|
// for every section without threading them through each layout.
|
|
125
125
|
const EmptyContext = createContext({ text: EMPTY_DASH, fold: false });
|
|
126
|
+
// Whether the facts rail is drawn (4.112): the record's column then fills
|
|
127
|
+
// the room up to the rail (Details' reading-width cap off), and its fields
|
|
128
|
+
// rows keep a compact label (`FIELD_ROW.wide`) so the values get the rest.
|
|
129
|
+
const BesideFactsRailContext = createContext(false);
|
|
126
130
|
// The record's trail (#R2): the crumbs above it, then its own title
|
|
127
131
|
// once it has loaded; the list's crumb is the last until then.
|
|
128
132
|
function recordTrail(back, title) {
|
|
@@ -159,10 +163,20 @@ function FieldList({ fields, place }) {
|
|
|
159
163
|
const shown = emptyCount === 0 || open ? fields : fields.filter((field) => !isEmptyValue(fieldValue(field)));
|
|
160
164
|
return (_jsxs("div", { className: "flex flex-col gap-3", children: [shown.length > 0 && (_jsx("dl", { id: listId, className: "@container/fields flex flex-col divide-y divide-border", children: shown.map((field) => (_jsx(FieldRow, { field: field, place: place }, field.label))) })), emptyCount > 0 && (_jsxs("button", { type: "button", "data-slot": "entity-view-empty-toggle", "aria-expanded": open, "aria-controls": shown.length > 0 ? listId : undefined, onClick: () => setOpen((was) => !was), className: "inline-flex w-fit items-center gap-1 rounded-sm type-label text-muted-foreground underline underline-offset-3 outline-none hover:text-foreground focus-visible:ring-3 focus-visible:ring-ring/50 pointer-coarse:min-h-11", children: [open ? 'Hide Empty' : `${emptyCount} Empty`, _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('size-3.5 transition-transform', open && 'rotate-180') })] }))] }));
|
|
161
165
|
}
|
|
162
|
-
function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, }) {
|
|
166
|
+
function ViewSection({ section, inRail = false, railFields = 'beside', bare, factsRail = false, side = false, }) {
|
|
163
167
|
const headingId = useId();
|
|
164
168
|
const empty = useContext(EmptyContext);
|
|
165
|
-
const
|
|
169
|
+
const besideFactsRail = useContext(BesideFactsRailContext);
|
|
170
|
+
const place = factsRail
|
|
171
|
+
? 'facts'
|
|
172
|
+
: besideFactsRail && !side && bare === undefined
|
|
173
|
+
? 'wide'
|
|
174
|
+
: !inRail
|
|
175
|
+
? 'page'
|
|
176
|
+
: railFields === 'beside'
|
|
177
|
+
? 'railBeside'
|
|
178
|
+
: 'rail';
|
|
179
|
+
const body = 'fields' in section || 'facts' in section ? (_jsx(FieldList, { fields: 'fields' in section ? section.fields : factsAsFields(section.facts), place: place })) : section.edit?.kind === 'list' ? (_jsxs("div", { className: "flex min-w-0 flex-col gap-2 type-body break-words text-foreground", children: [!isEmptyValue(section.content) && section.content, _jsx(EditableList, { label: section.title, edit: section.edit, emptyLabel: section.emptyLabel ?? empty.text })] })) : (_jsx("div", { className: "min-w-0 type-body break-words text-foreground", children: section.edit ? (_jsx(EditableValue, { label: section.title, edit: section.edit, children: _jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel }) })) : (_jsx(OrEmpty, { value: section.content, emptyLabel: section.emptyLabel })) }));
|
|
166
180
|
if (bare) {
|
|
167
181
|
return (_jsxs("section", { "aria-labelledby": headingId, "data-slot": "entity-view-bare-section", className: "flex flex-col gap-2", children: [_jsx("h2", { id: headingId, className: bare === 'hidden' ? 'sr-only' : 'type-label text-muted-foreground', children: section.title }), body] }));
|
|
168
182
|
}
|
|
@@ -275,14 +289,17 @@ const TAB_SIDE = {
|
|
|
275
289
|
side: 'flex min-w-0 flex-col gap-6',
|
|
276
290
|
};
|
|
277
291
|
function TabBody({ tab, railFields }) {
|
|
292
|
+
const besideFactsRail = useContext(BesideFactsRailContext);
|
|
278
293
|
if (tab.details) {
|
|
279
|
-
// The facts on their own: a reading width, never the whole page.
|
|
280
|
-
|
|
294
|
+
// The facts on their own: a reading width, never the whole page. Beside
|
|
295
|
+
// the facts rail the column is already that (the page's own cap), so
|
|
296
|
+
// they fill it up to the rail, level with the tab bar (4.112).
|
|
297
|
+
return (_jsx("div", { "data-slot": "entity-view-details", className: cn('flex w-full min-w-0 flex-col gap-6', !besideFactsRail && 'max-w-2xl'), children: tab.sections.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) }));
|
|
281
298
|
}
|
|
282
299
|
const main = tab.sections.map((section) => _jsx(ViewSection, { section: section }, section.title));
|
|
283
300
|
if (tab.side.length === 0)
|
|
284
301
|
return main;
|
|
285
|
-
return (_jsxs("div", { className: TAB_SIDE.columns, children: [_jsx("div", { className: TAB_SIDE.main, children: main }), _jsx("aside", { "aria-label": `${tab.name} Facts`, "data-slot": "entity-view-tab-side", className: TAB_SIDE.side, children: tab.side.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title))) })] }));
|
|
302
|
+
return (_jsxs("div", { className: TAB_SIDE.columns, children: [_jsx("div", { className: TAB_SIDE.main, children: main }), _jsx("aside", { "aria-label": `${tab.name} Facts`, "data-slot": "entity-view-tab-side", className: TAB_SIDE.side, children: tab.side.map((section) => (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields, side: true }, section.title))) })] }));
|
|
286
303
|
}
|
|
287
304
|
// The tab list, under the sections with no tab, and every tab's sections
|
|
288
305
|
// (hidden but mounted unless selected). The selected tab is the address's,
|
|
@@ -441,7 +458,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
441
458
|
.filter((section) => !tabbed(section))
|
|
442
459
|
.map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
|
|
443
460
|
}
|
|
444
|
-
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
|
|
445
|
-
|
|
446
|
-
|
|
461
|
+
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
|
|
462
|
+
? RAIL_LAYOUT.page
|
|
463
|
+
: 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 }))] }) }) }) }));
|
|
447
464
|
}
|
|
@@ -21,6 +21,11 @@ export const FIELD_ROW = {
|
|
|
21
21
|
// The facts rail (4.106, A1): a 300px card, so side by side from a
|
|
22
22
|
// 16rem list, the label column a little narrower again.
|
|
23
23
|
facts: '@3xs/fields:grid @3xs/fields:grid-cols-[--spacing(24)_minmax(0,1fr)] @3xs/fields:items-baseline @3xs/fields:gap-3 @3xs/fields:py-2.5',
|
|
24
|
+
// Beside the facts rail (4.112): the cards fill the column up to the
|
|
25
|
+
// rail, so the label keeps a compact 10rem and the value takes the rest
|
|
26
|
+
// (a 12rem label, a third of a 36rem card, wrapped most values onto two
|
|
27
|
+
// lines). Stacked below `sm` or a 24rem list, as on the page.
|
|
28
|
+
wide: 'sm:@sm/fields:grid sm:@sm/fields:grid-cols-[--spacing(40)_minmax(0,1fr)] sm:@sm/fields:items-baseline sm:@sm/fields:gap-6',
|
|
24
29
|
};
|
|
25
30
|
/** A row's own spacing, before its place's grid. */
|
|
26
31
|
export const FIELD_ROW_BASE = 'flex flex-col gap-1 py-3 first:pt-0 last:pb-0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.113.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": {
|