@tristan2828/ui-foundation 4.97.0 → 4.99.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 +66 -50
- package/conventions/docs/cell-patterns.md +41 -34
- package/conventions/docs/design-language.md +140 -68
- package/conventions/docs/entity-plan-template.md +15 -21
- package/dist/components/app/app-shell-bottom-bar.d.ts +4 -2
- package/dist/components/app/app-shell-bottom-bar.js +30 -13
- package/dist/components/app/app-shell-nav.d.ts +34 -1
- package/dist/components/app/app-shell-nav.js +35 -0
- package/dist/components/app/app-shell.d.ts +15 -3
- package/dist/components/app/app-shell.js +35 -7
- package/dist/components/app/entity-view.d.ts +29 -11
- package/dist/components/app/entity-view.js +103 -26
- package/dist/components/app/key-stats.d.ts +3 -1
- package/dist/components/app/key-stats.js +2 -2
- package/dist/components/app/record-dialog-context.d.ts +9 -0
- package/dist/components/app/record-dialog.d.ts +8 -1
- package/dist/components/app/record-dialog.js +19 -3
- package/dist/components/app/status-mark.d.ts +17 -0
- package/dist/components/app/status-mark.js +12 -0
- package/dist/components/ui/field.d.ts +3 -2
- package/dist/components/ui/field.js +13 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/lib/field-rows.d.ts +3 -1
- package/dist/lib/field-rows.js +24 -6
- package/dist/lib/status-kinds.d.ts +10 -0
- package/dist/lib/status-kinds.js +33 -0
- package/package.json +1 -1
- package/styles/index.css +9 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { type BottomBarItem, type NavEntry } from './app-shell-nav.js';
|
|
1
|
+
import { type BottomBarItem, type NavEntry, type NavLook } from './app-shell-nav.js';
|
|
2
2
|
/**
|
|
3
3
|
* What the shell pads its content's bottom by on a phone: its own p-6,
|
|
4
4
|
* plus the bar (4rem and its 1px border) and the phone's safe area.
|
|
5
5
|
*/
|
|
6
6
|
export declare const BOTTOM_BAR_PADDING = "max-md:pb-[calc(--spacing(22)+1px+env(safe-area-inset-bottom))]";
|
|
7
|
-
export declare function BottomBar({ items, nav, activeTo, }: {
|
|
7
|
+
export declare function BottomBar({ items, nav, activeTo, navLook, }: {
|
|
8
8
|
items: readonly BottomBarItem[];
|
|
9
9
|
nav: readonly NavEntry[];
|
|
10
10
|
activeTo: string | undefined;
|
|
11
|
+
/** The shell's `navLook`: a section's sheet follows its look when its item sets no `sheet`. */
|
|
12
|
+
navLook?: NavLook;
|
|
11
13
|
}): import("react").JSX.Element;
|
|
@@ -12,7 +12,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
12
12
|
// the phone's safe area, so a page's last row clears it.
|
|
13
13
|
import { useId, useState } from 'react';
|
|
14
14
|
import { Link, useLocation } from 'react-router';
|
|
15
|
-
import { bottomBarCurrent, bottomBarSection, childItems, isNavItemGroup, } from './app-shell-nav.js';
|
|
15
|
+
import { bottomBarCurrent, bottomBarSection, bottomBarTiles, childItems, childRuns, childrenOpen, isNavItemGroup, } from './app-shell-nav.js';
|
|
16
16
|
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '../ui/sheet.js';
|
|
17
17
|
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
18
|
'outline-none focus-visible:ring-3 focus-visible:ring-ring/50 aria-[current]:text-foreground aria-[current]:font-medium ' +
|
|
@@ -40,17 +40,31 @@ function SheetGroup({ label, items, activeTo }) {
|
|
|
40
40
|
function SheetChildren({ items, activeTo }) {
|
|
41
41
|
return (_jsx("ul", { className: "flex flex-col gap-0.5", children: items.map((child) => isNavItemGroup(child) ? (_jsx(SheetGroup, { label: child.label, items: child.items, activeTo: activeTo }, `group:${child.label}`)) : (_jsx(SheetLink, { item: child, activeTo: activeTo }, child.to))) }));
|
|
42
42
|
}
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
// A page tile, under a tiles section's tiles: smaller, four to a row,
|
|
44
|
+
// 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 ' +
|
|
46
|
+
'text-foreground outline-none hover:bg-accent focus-visible:ring-3 focus-visible:ring-ring/50 ' +
|
|
47
|
+
'aria-[current=page]:bg-accent aria-[current=page]:font-medium [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-muted-foreground';
|
|
48
|
+
// The current entry's pages under a tiles section's tiles (#6C): a
|
|
49
|
+
// hairline, then its pages as small tiles, each heading a hairline of its
|
|
50
|
+
// own with its list still named by it.
|
|
51
|
+
function SheetPageTiles({ items, activeTo }) {
|
|
52
|
+
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("span", { className: "max-w-full break-words", children: label })] }) }, to))) })] }, run.label ?? `run:${runIndex}`))) }, item.to)));
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
// The tiles (#N8): one per entry. Its pages are left to the module itself,
|
|
56
|
+
// unless the section's look is tiles (#6C): then the current entry's are
|
|
57
|
+
// under the tiles. The tile holding the current page, its own or one of
|
|
58
|
+
// its pages, is marked.
|
|
59
|
+
function SheetTiles({ items, activeTo, withPages, }) {
|
|
60
|
+
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;
|
|
62
|
+
// "page" on the module's own page, "true" on one of its pages.
|
|
63
|
+
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("span", { className: "max-w-full break-words", children: label })] }) }, to));
|
|
65
|
+
}) }), withPages && _jsx(SheetPageTiles, { items: items, activeTo: activeTo })] }));
|
|
66
|
+
}
|
|
67
|
+
export function BottomBar({ items, nav, activeTo, navLook = 'list', }) {
|
|
54
68
|
// The section open, and the location it was opened at: following a link
|
|
55
69
|
// in the sheet (or anywhere) moves to a new location, which closes it.
|
|
56
70
|
const [opened, setOpened] = useState(null);
|
|
@@ -61,7 +75,10 @@ export function BottomBar({ items, nav, activeTo, }) {
|
|
|
61
75
|
const shown = items.slice(0, 5);
|
|
62
76
|
const current = bottomBarCurrent(shown, nav, activeTo);
|
|
63
77
|
const section = openGroup === null ? undefined : bottomBarSection(nav, openGroup);
|
|
64
|
-
const
|
|
78
|
+
const openItem = shown.find((item) => 'group' in item && item.group === openGroup);
|
|
79
|
+
const tiles = openItem !== undefined && bottomBarTiles(openItem, section, navLook);
|
|
80
|
+
// The current entry's pages show under the tiles when the section's own look is tiles.
|
|
81
|
+
const withPages = (section?.look ?? navLook) === 'tiles';
|
|
65
82
|
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) => {
|
|
66
83
|
const Icon = item.icon;
|
|
67
84
|
const isCurrent = index === current;
|
|
@@ -70,5 +87,5 @@ export function BottomBar({ items, nav, activeTo, }) {
|
|
|
70
87
|
}
|
|
71
88
|
const label = item.label ?? item.group;
|
|
72
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(Icon, { "aria-hidden": "true" }), _jsx("span", { className: "max-w-full truncate", children: label })] }) }, `group:${item.group}`));
|
|
73
|
-
}) }) }), _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 })) : (_jsx(SheetChildren, { items: section.items, activeTo: activeTo })) })] })) }) })] }));
|
|
90
|
+
}) }) }), _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 })) })] })) }) })] }));
|
|
74
91
|
}
|
|
@@ -53,6 +53,13 @@ export declare function childItems(item: NavItem): NavItem[];
|
|
|
53
53
|
* heading where it has them ("Finance: Money, Spending, Taxes").
|
|
54
54
|
*/
|
|
55
55
|
export declare function navTooltip(item: NavItem): string;
|
|
56
|
+
/**
|
|
57
|
+
* How a sidebar group draws its entries: a list, icon beside label
|
|
58
|
+
* (`'list'`, the default), or a grid of tiles, icon over a short label,
|
|
59
|
+
* three to a row, with no visible heading (`'tiles'`). Set for the whole
|
|
60
|
+
* nav with `AppShell`'s `navLook`, or per section with its `look`.
|
|
61
|
+
*/
|
|
62
|
+
export type NavLook = 'list' | 'tiles';
|
|
56
63
|
/** A labelled group of sidebar entries: one module's pages, say. */
|
|
57
64
|
export type NavSection = {
|
|
58
65
|
label: string;
|
|
@@ -72,6 +79,15 @@ export type NavSection = {
|
|
|
72
79
|
* (`'bottom'`: a Tools group, say).
|
|
73
80
|
*/
|
|
74
81
|
placement?: 'top' | 'bottom';
|
|
82
|
+
/**
|
|
83
|
+
* This section's look, over `AppShell`'s `navLook`: `'tiles'` draws its
|
|
84
|
+
* entries as a grid of icon tiles, its label kept for screen readers
|
|
85
|
+
* only, and the current entry's pages listed under the grid. A tiles
|
|
86
|
+
* section doesn't fold (`collapsible` is ignored). On the icon rail it's
|
|
87
|
+
* the rail's icons, as any section. A `bottomBar` item for it opens its
|
|
88
|
+
* sheet as tiles too, the current entry's pages under them.
|
|
89
|
+
*/
|
|
90
|
+
look?: NavLook;
|
|
75
91
|
};
|
|
76
92
|
/** One entry of `AppShell`'s `nav`: a page, or a labelled section of pages. */
|
|
77
93
|
export type NavEntry = NavItem | NavSection;
|
|
@@ -85,6 +101,8 @@ export type NavGroup = {
|
|
|
85
101
|
defaultOpen?: boolean;
|
|
86
102
|
/** From its section: at the sidebar's foot (NavSection's `placement`). */
|
|
87
103
|
placement?: 'bottom';
|
|
104
|
+
/** From its section: its own look (NavSection's `look`), over the shell's. */
|
|
105
|
+
look?: NavLook;
|
|
88
106
|
};
|
|
89
107
|
/**
|
|
90
108
|
* The sidebar groups for a nav, in order. A flat nav (no sections) is the
|
|
@@ -176,10 +194,25 @@ export type BottomBarItem = {
|
|
|
176
194
|
/**
|
|
177
195
|
* How its sheet shows the section: a list of its entries with their
|
|
178
196
|
* pages (`'list'`, the default), or a grid of tiles, one per entry,
|
|
179
|
-
* icon over label, like a phone's home screen (`'tiles'`).
|
|
197
|
+
* icon over label, like a phone's home screen (`'tiles'`). Without
|
|
198
|
+
* it, the section's look decides (`NavSection.look`, `navLook`).
|
|
180
199
|
*/
|
|
181
200
|
sheet?: 'list' | 'tiles';
|
|
182
201
|
};
|
|
202
|
+
/**
|
|
203
|
+
* Whether a bottom bar item's sheet is tiles: its own `sheet`, or else
|
|
204
|
+
* its section's look (the section's `look`, or the shell's `navLook`).
|
|
205
|
+
*/
|
|
206
|
+
export declare function bottomBarTiles(item: BottomBarItem, section: NavSection | undefined, navLook?: NavLook): boolean;
|
|
207
|
+
/**
|
|
208
|
+
* The runs of an entry's pages, for a look with no headings: each group
|
|
209
|
+
* its own run, named by its label, and each run of plain pages between
|
|
210
|
+
* them an unnamed one.
|
|
211
|
+
*/
|
|
212
|
+
export declare function childRuns(item: NavItem): {
|
|
213
|
+
label?: string;
|
|
214
|
+
items: NavItem[];
|
|
215
|
+
}[];
|
|
183
216
|
/** The nav's section with this label, if there is one. */
|
|
184
217
|
export declare function bottomBarSection(nav: readonly NavEntry[], label: string): NavSection | undefined;
|
|
185
218
|
/**
|
|
@@ -39,6 +39,7 @@ export function navGroups(nav) {
|
|
|
39
39
|
items: entry.items,
|
|
40
40
|
...(entry.collapsible && { collapsible: true, defaultOpen: entry.defaultOpen ?? true }),
|
|
41
41
|
...(entry.placement === 'bottom' && { placement: 'bottom' }),
|
|
42
|
+
...(entry.look && { look: entry.look }),
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
@@ -163,6 +164,40 @@ export function trailBackTarget(nav, pathname, trail) {
|
|
|
163
164
|
.find((crumb) => crumb.href);
|
|
164
165
|
return above?.href ? { label: above.label, to: above.href } : fromNav;
|
|
165
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* Whether a bottom bar item's sheet is tiles: its own `sheet`, or else
|
|
169
|
+
* its section's look (the section's `look`, or the shell's `navLook`).
|
|
170
|
+
*/
|
|
171
|
+
export function bottomBarTiles(item, section, navLook = 'list') {
|
|
172
|
+
if (!('group' in item))
|
|
173
|
+
return false;
|
|
174
|
+
if (item.sheet)
|
|
175
|
+
return item.sheet === 'tiles';
|
|
176
|
+
return (section?.look ?? navLook) === 'tiles';
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* The runs of an entry's pages, for a look with no headings: each group
|
|
180
|
+
* its own run, named by its label, and each run of plain pages between
|
|
181
|
+
* them an unnamed one.
|
|
182
|
+
*/
|
|
183
|
+
export function childRuns(item) {
|
|
184
|
+
const runs = [];
|
|
185
|
+
let run = [];
|
|
186
|
+
for (const child of item.children ?? []) {
|
|
187
|
+
if (isNavItemGroup(child)) {
|
|
188
|
+
if (run.length)
|
|
189
|
+
runs.push({ items: run });
|
|
190
|
+
run = [];
|
|
191
|
+
runs.push({ label: child.label, items: [...child.items] });
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
run.push(child);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (run.length)
|
|
198
|
+
runs.push({ items: run });
|
|
199
|
+
return runs;
|
|
200
|
+
}
|
|
166
201
|
/** The nav's section with this label, if there is one. */
|
|
167
202
|
export function bottomBarSection(nav, label) {
|
|
168
203
|
return nav.find((entry) => isNavSection(entry) && entry.label === label);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import { type BottomBarItem, type NavEntry } from './app-shell-nav.js';
|
|
2
|
+
import { type BottomBarItem, type NavEntry, type NavLook } from './app-shell-nav.js';
|
|
3
3
|
import { type AppShellVersion } from './app-shell-version.js';
|
|
4
4
|
import { type AppShellSearch } from './search-palette.js';
|
|
5
5
|
import type { IconComponent } from './icon-component.js';
|
|
6
|
-
export type { BottomBarItem, NavChild, NavEntry, NavItem, NavItemGroup, NavSection } from './app-shell-nav.js';
|
|
6
|
+
export type { BottomBarItem, NavChild, NavEntry, NavItem, NavItemGroup, NavLook, NavSection } from './app-shell-nav.js';
|
|
7
7
|
export type { AppShellVersion } from './app-shell-version.js';
|
|
8
8
|
export type { AppShellSearch, RecentRecord, SearchRecord } from './search-palette.js';
|
|
9
9
|
export type AppShellProps = {
|
|
@@ -72,6 +72,18 @@ export type AppShellProps = {
|
|
|
72
72
|
* takes its place. The shell pads its content so nothing sits under the bar.
|
|
73
73
|
*/
|
|
74
74
|
bottomBar?: readonly BottomBarItem[];
|
|
75
|
+
/**
|
|
76
|
+
* How the sidebar draws its groups (design-language.md "The sidebar and
|
|
77
|
+
* the phone's bar"): lists, icon beside label (`'list'`, the default),
|
|
78
|
+
* or `'tiles'`: each group a grid of tiles, icon over a short label,
|
|
79
|
+
* three to a row, with no visible headings (a section's label is kept
|
|
80
|
+
* for screen readers), and the current entry's pages listed under its
|
|
81
|
+
* group's grid, with hairlines in place of their headings. A section's
|
|
82
|
+
* own `look` wins. The icon rail is unchanged, and a `bottomBar` item
|
|
83
|
+
* for a tiles section opens its sheet as tiles, the current entry's
|
|
84
|
+
* pages under them. Keep the labels short: a word or two.
|
|
85
|
+
*/
|
|
86
|
+
navLook?: NavLook;
|
|
75
87
|
/**
|
|
76
88
|
* Search in the header (#N6): a box ("Search", or `placeholder`) from
|
|
77
89
|
* md up and a button on a phone, both opening a palette (Ctrl K, ⌘K on
|
|
@@ -82,4 +94,4 @@ export type AppShellProps = {
|
|
|
82
94
|
*/
|
|
83
95
|
search?: AppShellSearch;
|
|
84
96
|
};
|
|
85
|
-
export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, search, }: AppShellProps): import("react").JSX.Element;
|
|
97
|
+
export declare function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen, version, bottomBar, navLook, search, }: AppShellProps): import("react").JSX.Element;
|
|
@@ -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, childrenOpen, isNavItemGroup, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
|
|
8
|
+
import { activeNavTo, childItems, childRuns, childrenOpen, isNavItemGroup, 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';
|
|
@@ -23,7 +23,7 @@ import { cn } from 'cn';
|
|
|
23
23
|
import { Button, buttonVariants } from '../ui/button.js';
|
|
24
24
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
|
|
25
25
|
import { Skeleton } from '../ui/skeleton.js';
|
|
26
|
-
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarTrigger, useSidebar, } from '../ui/sidebar.js';
|
|
26
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarSeparator, SidebarTrigger, useSidebar, } from '../ui/sidebar.js';
|
|
27
27
|
import { Toaster } from '../ui/sonner.js';
|
|
28
28
|
import { OfflineNotice } from './offline-notice.js';
|
|
29
29
|
import { TooltipProvider } from '../ui/tooltip.js';
|
|
@@ -122,16 +122,44 @@ function NavSubGroup({ group, activeTo }) {
|
|
|
122
122
|
// in the page but hidden, as a folded section's are. The icon rail has no
|
|
123
123
|
// room for them: there the entry looks current while one of them is, and
|
|
124
124
|
// its tooltip names them (or their headings).
|
|
125
|
-
function NavMenu({ items, activeTo }) {
|
|
125
|
+
function NavMenu({ items, activeTo, label, }) {
|
|
126
126
|
const { state, isMobile } = useSidebar();
|
|
127
127
|
const rail = state === 'collapsed' && !isMobile;
|
|
128
|
-
return (_jsx(SidebarMenu, { children: items.map((item) => {
|
|
128
|
+
return (_jsx(SidebarMenu, { "aria-label": label, children: items.map((item) => {
|
|
129
129
|
const { to, label, icon: Icon, children, count, countLabel } = item;
|
|
130
130
|
const isActive = to === activeTo;
|
|
131
131
|
const childActive = childItems(item).some((child) => child.to === activeTo);
|
|
132
132
|
return (_jsxs(SidebarMenuItem, { children: [_jsxs(SidebarMenuButton, { isActive: isActive || (rail && childActive), tooltip: navTooltip(item), className: cn('relative', ACTIVE_MARK), render: _jsx(Link, { to: to, "aria-current": isActive ? 'page' : undefined }), children: [_jsx(Icon, {}), _jsx("span", { className: "min-w-0 flex-1 truncate", children: label }), _jsx(NavCount, { count: count, countLabel: countLabel })] }), children && children.length > 0 && (_jsx(SidebarMenuSub, { hidden: !childrenOpen(item, activeTo), children: children.map((child) => isNavItemGroup(child) ? (_jsx(NavSubGroup, { group: child, activeTo: activeTo }, `group:${child.label}`)) : (_jsx(NavSubLink, { item: child, activeTo: activeTo }, child.to))) }))] }, to));
|
|
133
133
|
}) }));
|
|
134
134
|
}
|
|
135
|
+
// A tile in the tiles look (#6C): the entry's icon over its label, a
|
|
136
|
+
// finger's target at least, its count in the corner. The current one,
|
|
137
|
+
// or the one holding the current page, has the tint and a --primary ring.
|
|
138
|
+
const NAV_TILE_CLASS = 'relative flex min-h-14 w-full min-w-0 flex-col items-center justify-center gap-1 rounded-lg bg-sidebar-accent/50 px-1 py-2 ' +
|
|
139
|
+
'text-center type-caption text-sidebar-foreground outline-hidden ring-sidebar-ring transition-colors ' +
|
|
140
|
+
'hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 ' +
|
|
141
|
+
'data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground ' +
|
|
142
|
+
'data-active:shadow-[inset_0_0_0_1px_var(--primary)] [&>svg]:size-5 [&>svg]:shrink-0';
|
|
143
|
+
function NavTile({ item, activeTo }) {
|
|
144
|
+
const { to, label, icon: Icon, count, countLabel } = item;
|
|
145
|
+
// "page" on the entry's own page, "true" on one of its pages.
|
|
146
|
+
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: countLabel ? `${count} ${countLabel}` : count })] })) : null] }) }));
|
|
148
|
+
}
|
|
149
|
+
// A group in the tiles look (#6C): its entries as a three-column grid,
|
|
150
|
+
// its label for screen readers only (the grid is a list named by it), and
|
|
151
|
+
// under the grid the pages of the entry you're in, as the list look's
|
|
152
|
+
// children, each heading a hairline (its list still named by it). On the
|
|
153
|
+
// icon rail it's the rail's icons, as every group.
|
|
154
|
+
function TilesNavGroup({ group, activeTo }) {
|
|
155
|
+
const { state, isMobile } = useSidebar();
|
|
156
|
+
const headingId = useId();
|
|
157
|
+
if (state === 'collapsed' && !isMobile) {
|
|
158
|
+
return (_jsxs(SidebarGroup, { children: [group.label !== undefined && _jsx(SidebarGroupLabel, { children: group.label }), _jsx(SidebarGroupContent, { children: _jsx(NavMenu, { items: group.items, activeTo: activeTo }) })] }));
|
|
159
|
+
}
|
|
160
|
+
const open = group.items.filter((item) => childrenOpen(item, activeTo));
|
|
161
|
+
return (_jsxs(SidebarGroup, { "data-nav-look": "tiles", children: [group.label !== undefined && (_jsx("span", { id: headingId, className: "sr-only", children: group.label })), _jsxs(SidebarGroupContent, { className: "flex flex-col gap-2", children: [_jsx("ul", { "data-slot": "nav-tiles", "aria-labelledby": group.label !== undefined ? headingId : undefined, className: "grid grid-cols-3 gap-1.5", children: group.items.map((item) => (_jsx(NavTile, { item: item, activeTo: activeTo }, item.to))) }), open.map((item) => (_jsx("div", { role: "group", "aria-label": `${item.label} pages`, "data-slot": "nav-tile-pages", className: "flex flex-col gap-1", children: childRuns(item).map((run, runIndex) => (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(SidebarSeparator, { className: "mx-0" }), _jsx(NavMenu, { items: run.items, activeTo: activeTo, label: run.label })] }, run.label ?? `run:${runIndex}`))) }, item.to)))] })] }));
|
|
162
|
+
}
|
|
135
163
|
// Whether a collapsible section is open, remembered per browser by its
|
|
136
164
|
// label. Storage can be missing or refuse (a private window): then it's
|
|
137
165
|
// remembered for the page's life only.
|
|
@@ -190,7 +218,7 @@ function PhoneBack({ back }) {
|
|
|
190
218
|
function AppShellSkeleton() {
|
|
191
219
|
return (_jsxs("div", { className: "flex h-screen w-full gap-4 p-4", "data-state": "loading", children: [_jsx(Skeleton, { className: "h-full w-56 shrink-0" }), _jsxs("div", { className: "flex-1 space-y-4 pt-2", children: [_jsx(Skeleton, { className: "h-8 w-64" }), _jsx(Skeleton, { className: "h-40 w-full" })] })] }));
|
|
192
220
|
}
|
|
193
|
-
export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, search, }) {
|
|
221
|
+
export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarOpen = true, version, bottomBar, navLook = 'list', search, }) {
|
|
194
222
|
const { user, status, error, retry, logout } = useAuth();
|
|
195
223
|
const location = useLocation();
|
|
196
224
|
const reporter = useErrorReporter();
|
|
@@ -229,7 +257,7 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
|
|
|
229
257
|
const back = trailBackTarget(nav, location.pathname, ownTrail);
|
|
230
258
|
const trail = ownTrail ?? navTrail(nav, location.pathname);
|
|
231
259
|
const groups = navGroups(nav);
|
|
232
|
-
const renderGroup = (group, groupIndex) => group.collapsible && group.label !== undefined ? (_jsx(CollapsibleNavGroup, { group: { ...group, label: group.label }, activeTo: activeTo }, `${group.placement ?? 'top'}:${groupIndex}:${group.label}`)) : (_jsxs(SidebarGroup, { children: [group.label !== undefined && _jsx(SidebarGroupLabel, { children: group.label }), _jsx(SidebarGroupContent, { children: _jsx(NavMenu, { items: group.items, activeTo: activeTo }) })] }, `${group.placement ?? 'top'}:${groupIndex}:${group.label ?? ''}`));
|
|
260
|
+
const renderGroup = (group, groupIndex) => (group.look ?? navLook) === 'tiles' ? (_jsx(TilesNavGroup, { group: group, activeTo: activeTo }, `${group.placement ?? 'top'}:${groupIndex}:${group.label ?? ''}`)) : group.collapsible && group.label !== undefined ? (_jsx(CollapsibleNavGroup, { group: { ...group, label: group.label }, activeTo: activeTo }, `${group.placement ?? 'top'}:${groupIndex}:${group.label}`)) : (_jsxs(SidebarGroup, { children: [group.label !== undefined && _jsx(SidebarGroupLabel, { children: group.label }), _jsx(SidebarGroupContent, { children: _jsx(NavMenu, { items: group.items, activeTo: activeTo }) })] }, `${group.placement ?? 'top'}:${groupIndex}:${group.label ?? ''}`));
|
|
233
261
|
return (_jsxs(TooltipProvider, { children: [reporter && _jsx(ReportRoutePattern, { reporter: reporter }), _jsxs(SidebarProvider, { defaultOpen: storedSidebarOpen(defaultSidebarOpen), children: [_jsx(CloseMobileSidebarOnNavigate, {}), _jsx("nav", { "aria-label": "Primary", children: _jsxs(Sidebar, { collapsible: "icon", children: [_jsx(SidebarHeader, { children: _jsxs("div", { className: "flex items-center gap-2 px-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [Logo && (_jsx(Logo, { "aria-hidden": "true", className: "size-5 shrink-0 text-sidebar-foreground group-data-[collapsible=icon]:size-4" })), _jsx("span", { className: "truncate text-sm font-semibold text-sidebar-foreground group-data-[collapsible=icon]:hidden", children: title })] }) }), _jsxs(SidebarContent, { children: [groups.filter((group) => !group.placement).map(renderGroup), sidebarExtra, groups.some((group) => group.placement) && (_jsx("div", { "data-slot": "nav-foot", className: "mt-auto flex flex-col", children: groups.filter((group) => group.placement).map(renderGroup) }))] }), _jsxs(SidebarFooter, { children: [version && _jsx(VersionEntry, { version: version }), _jsxs("div", { className: "flex items-center justify-between gap-2 px-2 group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:px-0", children: [_jsx("span", { className: "truncate type-caption text-sidebar-foreground/70 group-data-[collapsible=icon]:hidden", children: user.name }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Log Out", onClick: () => {
|
|
234
262
|
setIsLoggingOut(true);
|
|
235
263
|
// The records opened lately are this person's: the
|
|
@@ -239,5 +267,5 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
|
|
|
239
267
|
// (AuthProvider), so this stays a deliberate logout: a
|
|
240
268
|
// clean /login, never the previous user's page as `from`.
|
|
241
269
|
logout().catch(() => { });
|
|
242
|
-
}, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && bottomBar?.length && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { search: search, nav: nav }), _jsx(LookControl, {})] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', bottomBar?.length && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), bottomBar && bottomBar.length > 0 && _jsx(BottomBar, { items: bottomBar, nav: nav, activeTo: activeTo })] }), _jsx(Toaster, {})] }));
|
|
270
|
+
}, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && bottomBar?.length && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { search: search, nav: nav }), _jsx(LookControl, {})] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', bottomBar?.length && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), bottomBar && bottomBar.length > 0 && _jsx(BottomBar, { items: bottomBar, nav: nav, activeTo: activeTo, navLook: navLook })] }), _jsx(Toaster, {})] }));
|
|
243
271
|
}
|
|
@@ -44,9 +44,12 @@ export type EntityViewSection = ({
|
|
|
44
44
|
edit?: EditInPlace | EditInPlaceList;
|
|
45
45
|
}) & {
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* `rail` for the short facts (a summary, label/value fields, a few
|
|
48
|
+
* links), `main` (the default) for long text and long lists. In the
|
|
49
|
+
* `tabs` layout (the default) a `rail` section with no `tab` goes in the
|
|
50
|
+
* Details tab, and one with a `tab` in a narrow box beside that tab's
|
|
51
|
+
* sections (short facts only, never free text). In the `rail` layout it
|
|
52
|
+
* goes in the column on the right. The `column` layout ignores it.
|
|
50
53
|
*/
|
|
51
54
|
placement?: EntityViewPlacement;
|
|
52
55
|
/**
|
|
@@ -61,8 +64,9 @@ export type EntityViewSection = ({
|
|
|
61
64
|
answerSpace?: boolean;
|
|
62
65
|
};
|
|
63
66
|
/**
|
|
64
|
-
* The tab the section goes under, by name ("Steps", "Used in")
|
|
65
|
-
*
|
|
67
|
+
* The tab the section goes under, by name ("Steps", "Used in"). In the
|
|
68
|
+
* `tabs` layout a `rail` section with a tab sits beside the tab's own
|
|
69
|
+
* sections; in the others a `rail` one ignores it. Any main section with a tab
|
|
66
70
|
* adds a tab list to the main column, one tab per name in the order the
|
|
67
71
|
* sections first give it; sections without one stay above the list. The
|
|
68
72
|
* selected tab is in the address, `?tab=<slug of the name>`.
|
|
@@ -71,11 +75,14 @@ export type EntityViewSection = ({
|
|
|
71
75
|
};
|
|
72
76
|
export type EntityViewPlacement = 'main' | 'rail';
|
|
73
77
|
/**
|
|
74
|
-
* `
|
|
75
|
-
*
|
|
76
|
-
*
|
|
78
|
+
* `tabs` (the default since 4.98): one column, at most max-w-4xl wide, the
|
|
79
|
+
* short facts (sections placed `rail`) in a Details tab after the record's
|
|
80
|
+
* other tabs. `column`: one column, `placement` ignored. `rail` (before
|
|
81
|
+
* 4.98's record standard; move off it, consuming.md "4.98"): the content
|
|
82
|
+
* area's whole width, with the sections placed `rail` in a narrow column
|
|
83
|
+
* on the right (one column on a narrow screen, rail first).
|
|
77
84
|
*/
|
|
78
|
-
export type EntityViewLayout = 'column' | 'rail';
|
|
85
|
+
export type EntityViewLayout = 'tabs' | 'column' | 'rail';
|
|
79
86
|
/**
|
|
80
87
|
* Which column comes first where the rail layout is one column (a phone,
|
|
81
88
|
* or a narrow content area): `rail-first` (the default) or `main-first`.
|
|
@@ -154,8 +161,19 @@ export type EntityViewProps = {
|
|
|
154
161
|
* (`<SourceCredit>`), when its source's terms ask for a credit.
|
|
155
162
|
*/
|
|
156
163
|
footer?: ReactNode;
|
|
157
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* `tabs` (the default since 4.98): the sections placed `rail` are a
|
|
166
|
+
* Details tab after the other tabs (in the column where there's no other
|
|
167
|
+
* tab). `column`: one column, `placement` ignored. `rail`: the sections
|
|
168
|
+
* placed `rail` in a column on the right, the shape before 4.98's record
|
|
169
|
+
* standard (no right rail); drop it to move to `tabs`.
|
|
170
|
+
*/
|
|
158
171
|
layout?: EntityViewLayout;
|
|
172
|
+
/**
|
|
173
|
+
* The `tabs` layout's facts tab: its name ("Details" by default). A
|
|
174
|
+
* section of the record's own with this tab joins it.
|
|
175
|
+
*/
|
|
176
|
+
detailsTab?: string;
|
|
159
177
|
/**
|
|
160
178
|
* In the `rail` layout, where its columns stack (a phone): the rail
|
|
161
179
|
* before the main column (`rail-first`, the default), or the main column
|
|
@@ -215,4 +233,4 @@ export type EntityViewProps = {
|
|
|
215
233
|
trail?: readonly PageCrumb[];
|
|
216
234
|
};
|
|
217
235
|
};
|
|
218
|
-
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|
|
236
|
+
export declare function EntityView({ title, documentTitle, titleEdit, leading, subtitle, badges, actions, notice, strip, sections, footer, layout, detailsTab, mobileOrder, railLabel, railFields, emptyFields, emptyText, printLabel, printLook, isLoading, error, onRetry, back, }: EntityViewProps): import("react").JSX.Element;
|