@tristan2828/ui-foundation 4.98.0 → 4.100.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/cell-patterns.md +81 -40
- package/conventions/docs/design-language.md +17 -1
- 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/data-table-tools.d.ts +5 -1
- package/dist/components/app/data-table-tools.js +7 -2
- package/dist/components/app/data-table.d.ts +16 -1
- package/dist/components/app/data-table.js +128 -67
- package/dist/components/app/list-header.d.ts +21 -1
- package/dist/components/app/list-header.js +23 -4
- package/dist/index.d.ts +3 -3
- package/package.json +1 -1
|
@@ -3,46 +3,47 @@
|
|
|
3
3
|
<!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
|
|
4
4
|
## Index
|
|
5
5
|
|
|
6
|
-
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines
|
|
7
|
-
- [1. Plain text](#1-plain-text) · lines
|
|
8
|
-
- [2. Icon + label](#2-icon--label) · lines
|
|
9
|
-
- [3. Icon in a badge](#3-icon-in-a-badge) · lines
|
|
10
|
-
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines
|
|
11
|
-
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines
|
|
12
|
-
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines
|
|
13
|
-
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines
|
|
14
|
-
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines
|
|
15
|
-
- [8. Date, relative](#8-date-relative) · lines
|
|
16
|
-
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines
|
|
17
|
-
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines
|
|
18
|
-
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines
|
|
19
|
-
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines
|
|
20
|
-
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines
|
|
21
|
-
- [12. Boolean](#12-boolean) · lines
|
|
22
|
-
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines
|
|
23
|
-
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines
|
|
24
|
-
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines
|
|
25
|
-
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines
|
|
26
|
-
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines
|
|
27
|
-
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines
|
|
28
|
-
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines
|
|
29
|
-
- [18. Editable value](#18-editable-value) · lines
|
|
30
|
-
- [Presets: one line per field](#presets-one-line-per-field) · lines
|
|
31
|
-
- [Several fields edited as one](#several-fields-edited-as-one) · lines
|
|
32
|
-
- [A link and its label](#a-link-and-its-label) · lines
|
|
33
|
-
- [A list of sub-items](#a-list-of-sub-items) · lines
|
|
34
|
-
- [In a table's rows](#in-a-tables-rows) · lines
|
|
35
|
-
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines
|
|
36
|
-
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines
|
|
37
|
-
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines
|
|
38
|
-
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines
|
|
39
|
-
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines
|
|
40
|
-
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines
|
|
41
|
-
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines
|
|
42
|
-
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines
|
|
43
|
-
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines
|
|
44
|
-
- [
|
|
45
|
-
- [
|
|
6
|
+
- [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 75–98
|
|
7
|
+
- [1. Plain text](#1-plain-text) · lines 100–153
|
|
8
|
+
- [2. Icon + label](#2-icon--label) · lines 155–178
|
|
9
|
+
- [3. Icon in a badge](#3-icon-in-a-badge) · lines 180–193
|
|
10
|
+
- [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 195–272
|
|
11
|
+
- [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 220–272
|
|
12
|
+
- [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 274–294
|
|
13
|
+
- [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 296–308
|
|
14
|
+
- [7. Link as an outline button](#7-link-as-an-outline-button) · lines 310–331
|
|
15
|
+
- [8. Date, relative](#8-date-relative) · lines 333–370
|
|
16
|
+
- [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 372–420
|
|
17
|
+
- [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 390–420
|
|
18
|
+
- [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 422–472
|
|
19
|
+
- [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 440–472
|
|
20
|
+
- [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 474–514
|
|
21
|
+
- [12. Boolean](#12-boolean) · lines 516–546
|
|
22
|
+
- [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 548–584
|
|
23
|
+
- [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 568–584
|
|
24
|
+
- [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 586–603
|
|
25
|
+
- [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 605–714
|
|
26
|
+
- [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 631–714
|
|
27
|
+
- [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 716–751
|
|
28
|
+
- [17. Quick action on the view](#17-quick-action-on-the-view) · lines 753–826
|
|
29
|
+
- [18. Editable value](#18-editable-value) · lines 828–1506
|
|
30
|
+
- [Presets: one line per field](#presets-one-line-per-field) · lines 1138–1206
|
|
31
|
+
- [Several fields edited as one](#several-fields-edited-as-one) · lines 1208–1244
|
|
32
|
+
- [A link and its label](#a-link-and-its-label) · lines 1246–1270
|
|
33
|
+
- [A list of sub-items](#a-list-of-sub-items) · lines 1272–1405
|
|
34
|
+
- [In a table's rows](#in-a-tables-rows) · lines 1407–1492
|
|
35
|
+
- [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1494–1506
|
|
36
|
+
- [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1508–1574
|
|
37
|
+
- [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1576–1640
|
|
38
|
+
- [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1642–1740
|
|
39
|
+
- [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1742–1771
|
|
40
|
+
- [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1773–1811
|
|
41
|
+
- [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1813–1889
|
|
42
|
+
- [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1891–1914
|
|
43
|
+
- [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1916–2042
|
|
44
|
+
- [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2004–2042
|
|
45
|
+
- [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2044–2080
|
|
46
|
+
- [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2082–2127
|
|
46
47
|
|
|
47
48
|
<!-- /index -->
|
|
48
49
|
|
|
@@ -2000,6 +2001,46 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
|
|
|
2000
2001
|
pick and a view's columns winning, the ⋯ menu, the 44px rows, the
|
|
2001
2002
|
phone's line and sheet.
|
|
2002
2003
|
|
|
2004
|
+
### The framed look, and sibling lists beside the title
|
|
2005
|
+
|
|
2006
|
+
The toolbar a list-page review picked (4.100): `look="framed"` on
|
|
2007
|
+
`DataTable`, and `siblings` on `ListHeader`. Both are opt-in.
|
|
2008
|
+
|
|
2009
|
+
```tsx
|
|
2010
|
+
<ListHeader
|
|
2011
|
+
title="Exercises" count={total}
|
|
2012
|
+
siblings={[
|
|
2013
|
+
{ label: 'Exercises', to: '/training/exercises', count: 5 },
|
|
2014
|
+
{ label: 'Targets', to: '/training/targets', count: 9 },
|
|
2015
|
+
{ label: 'Weak spots', to: '/training/weak-spots', count: 4 },
|
|
2016
|
+
]}
|
|
2017
|
+
deleted={{ shown, onShownChange: setShown, noun: 'exercises' }}
|
|
2018
|
+
newAction={{ label: 'New Exercise', to: '/training/exercises/new' }}
|
|
2019
|
+
/>
|
|
2020
|
+
<DataTable look="framed" views={VIEWS} columnsMenu={…} groupings={…} toolbar={<FilterBar … />} … />
|
|
2021
|
+
```
|
|
2022
|
+
|
|
2023
|
+
- **The card**: the toolbar in its top bar (search and Filters keep their
|
|
2024
|
+
words), the rows, then the count and pager in its bottom bar. Saved
|
|
2025
|
+
views sit above it, outside the bar. Loading, empty and error show
|
|
2026
|
+
inside it.
|
|
2027
|
+
- **The tools end at the table's edge**: the card is as wide as `width`
|
|
2028
|
+
makes the table, tools and pager with it, so nothing sits off at the
|
|
2029
|
+
far right of a wide page. `width="full"` fills the area as before.
|
|
2030
|
+
- **One settings button** in place of Columns and Group: the Columns
|
|
2031
|
+
ticks, then Group By, in one menu. Its name says the grouping that's on
|
|
2032
|
+
("Table Settings, Grouped by Status") and a dot marks it. Fold All
|
|
2033
|
+
stays a button of its own while grouped. On a phone it holds Group By
|
|
2034
|
+
alone.
|
|
2035
|
+
- **Siblings** are the page's peers, a switch of links beside the title,
|
|
2036
|
+
the current one marked (`aria-current="page"`); they don't go in ⋯,
|
|
2037
|
+
which keeps what's left. Two or more; on a phone the switch has its own
|
|
2038
|
+
line. Pass `current` when the siblings differ only by query string.
|
|
2039
|
+
- The fixtures' `app/DataTable tools` Framed and `app/ListHeader`
|
|
2040
|
+
Siblings stories hold it, under axe and the token check in both
|
|
2041
|
+
themes; `e2e/data-table-framed.spec.ts` checks the edges, the menu
|
|
2042
|
+
from the mouse and the keyboard, the switch and the phone.
|
|
2043
|
+
|
|
2003
2044
|
## 26. A record's related list, capped
|
|
2004
2045
|
|
|
2005
2046
|
A list of records related to this one, in a section of its view (a
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
- [Picking at random](#picking-at-random) · lines 1665–1696
|
|
38
38
|
- [Filling in what's missing](#filling-in-whats-missing) · lines 1698–1765
|
|
39
39
|
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1767–1792
|
|
40
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1794–
|
|
40
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1794–1883
|
|
41
41
|
|
|
42
42
|
<!-- /index -->
|
|
43
43
|
|
|
@@ -1840,6 +1840,22 @@ const bottomBar: BottomBarItem[] = [
|
|
|
1840
1840
|
one tile per entry, the icon in `--link` over the label, bordered,
|
|
1841
1841
|
44px tall at least; the tile holding the page has a `--primary`
|
|
1842
1842
|
border. The entries' own pages are left to the module.
|
|
1843
|
+
- **The sidebar as icon tiles** (`navLook="tiles"` on `AppShell`, or a
|
|
1844
|
+
section's own `look: 'tiles'`; 4.99): fewer words, more icons. Each
|
|
1845
|
+
group is a three-column grid of tiles, the icon (20px) over a short
|
|
1846
|
+
label in the caption size, on the sidebar's tint at half strength; no
|
|
1847
|
+
visible headings (a section's label names its grid for screen
|
|
1848
|
+
readers). The tile you're in, or the one holding the page, has the
|
|
1849
|
+
full tint and a 1px `--primary` ring; a count sits in its top corner
|
|
1850
|
+
in the sidebar's text tone. The pages of the entry you're in list
|
|
1851
|
+
under its group's grid as the list look's, a hairline in place of
|
|
1852
|
+
each heading (each run still a list named by it). A tiles section
|
|
1853
|
+
doesn't fold. The icon rail is the rail's icons, as in the list look,
|
|
1854
|
+
and the sidebar's phone sheet shows the tiles. A `bottomBar` item for
|
|
1855
|
+
a tiles section with no `sheet` of its own opens its sheet as tiles,
|
|
1856
|
+
with the current entry's pages under them as smaller tiles, four to a
|
|
1857
|
+
row, 44px at least. Keep tile labels to a word or two; a section that
|
|
1858
|
+
should stay a list (Tools at the foot) sets `look: 'list'`.
|
|
1843
1859
|
- **The trail in the bar** (`usePageTrail`, `EntityView`'s
|
|
1844
1860
|
`back.trail`): between the menu button and the search box, from 48rem
|
|
1845
1861
|
up, `PageTrail` at 14px: every crumb but the last a
|
|
@@ -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
|
}
|
|
@@ -30,7 +30,7 @@ export type DataTableColumnsMenu = {
|
|
|
30
30
|
/** The button's text: "Columns" unless set. */
|
|
31
31
|
label?: string;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
type ColumnsMenuProps = {
|
|
34
34
|
/** Every column the menu can tick, in order, with its name. */
|
|
35
35
|
columns: readonly {
|
|
36
36
|
id: string;
|
|
@@ -44,6 +44,9 @@ export declare function ColumnsMenu({ columns, visible, fixed, pick, onPickChang
|
|
|
44
44
|
onPickChange: (pick: ColumnsPick | null) => void;
|
|
45
45
|
/** A view on that sets its own columns: the ticks show them and can't change. */
|
|
46
46
|
setByView: boolean;
|
|
47
|
+
};
|
|
48
|
+
export declare function ColumnsMenuItems({ columns, visible, fixed, pick, onPickChange, setByView }: ColumnsMenuProps): import("react").JSX.Element;
|
|
49
|
+
export declare function ColumnsMenu({ label, ...props }: ColumnsMenuProps & {
|
|
47
50
|
label?: string;
|
|
48
51
|
}): import("react").JSX.Element;
|
|
49
52
|
/** One of a row's actions (DataTable `rowActions`). */
|
|
@@ -96,3 +99,4 @@ export declare function ViewAllLink({ viewAll, total, navigator }: {
|
|
|
96
99
|
total: number;
|
|
97
100
|
navigator?: Navigator;
|
|
98
101
|
}): import("react").JSX.Element;
|
|
102
|
+
export {};
|
|
@@ -14,9 +14,14 @@ export function ViewPills({ views, value, onValueChange, label, }) {
|
|
|
14
14
|
// No view's id matches '' (filters set by hand), so none is pressed.
|
|
15
15
|
value: value ?? '', onValueChange: onValueChange, className: "max-md:w-max max-md:flex-nowrap" }) }));
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
// The menu's items alone: the Columns menu's, and the framed look's
|
|
18
|
+
// settings menu's first group (data-table.tsx's TableSettingsMenu).
|
|
19
|
+
export function ColumnsMenuItems({ columns, visible, fixed, pick, onPickChange, setByView }) {
|
|
18
20
|
const ids = [...fixed, ...columns.map((column) => column.id)];
|
|
19
|
-
return (_jsxs(
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: setByView ? 'Set by This View' : 'Show Columns' }), columns.map((column) => (_jsx(DropdownMenuCheckboxItem, { checked: visible.includes(column.id), disabled: setByView, onCheckedChange: (checked) => onPickChange(togglePick(ids, visible, column.id, checked, pick)), children: column.label }, column.id)))] }), pick && !setByView ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsx(DropdownMenuItem, { onClick: () => onPickChange(null), children: "Reset to the List's Columns" })] })) : null] }));
|
|
22
|
+
}
|
|
23
|
+
export function ColumnsMenu({ label = 'Columns', ...props }) {
|
|
24
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-columns-menu" }), children: [_jsx(Columns3Icon, { "aria-hidden": "true" }), label] }), _jsx(DropdownMenuContent, { align: "end", className: "w-52", children: _jsx(ColumnsMenuItems, { ...props }) })] }));
|
|
20
25
|
}
|
|
21
26
|
export function RowActions({ actions, rowLabel }) {
|
|
22
27
|
if (actions.length === 0)
|
|
@@ -305,7 +305,22 @@ export type DataTableProps<TData extends Record<string, unknown>, TView extends
|
|
|
305
305
|
* when there are more than the rows shown.
|
|
306
306
|
*/
|
|
307
307
|
viewAll?: DataTableViewAll;
|
|
308
|
+
/**
|
|
309
|
+
* How the list is drawn around its rows (4.100). `plain` (the default):
|
|
310
|
+
* the toolbar above the whole width, the Columns and Group menus as
|
|
311
|
+
* buttons at its end, the pagination under the rows. `framed`: the
|
|
312
|
+
* list is a card with a border, as wide as the table under `width`'s
|
|
313
|
+
* rules, so its tools end at the table's own edge and nothing sits off
|
|
314
|
+
* at the far right of a wide page. The card's top bar holds the toolbar
|
|
315
|
+
* (search and Filters keep their words), Fold All while grouped, one
|
|
316
|
+
* settings button holding the Columns ticks and Group By, and the layout
|
|
317
|
+
* switch; its bottom bar holds the count and the pager. Saved views stay
|
|
318
|
+
* above the card, outside its bar. Every other prop works the same way.
|
|
319
|
+
*/
|
|
320
|
+
look?: DataTableLook;
|
|
308
321
|
};
|
|
322
|
+
/** How DataTable draws the list around its rows (`look`). */
|
|
323
|
+
export type DataTableLook = 'plain' | 'framed';
|
|
309
324
|
/** A field DataTable's rows can be grouped by (`groupings`). */
|
|
310
325
|
export type DataTableGrouping<TData> = {
|
|
311
326
|
/**
|
|
@@ -380,4 +395,4 @@ export type DataTableTotals = {
|
|
|
380
395
|
*/
|
|
381
396
|
cells?: Partial<Record<string, ReactNode>>;
|
|
382
397
|
};
|
|
383
|
-
export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, columnsMenu, rowActions, phoneRow, limit, viewAll, }: DataTableProps<TData, TView>): import("react").JSX.Element;
|
|
398
|
+
export declare function DataTable<TData extends Record<string, unknown>, TView extends DataTableView = DataTableView>({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width, striped, groupBy, groupSummary, stickyGroupHeadings, stickyTop, header: showHeader, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel, views, activeView, onViewChange, viewsLabel, columnsMenu, rowActions, phoneRow, limit, viewAll, look, }: DataTableProps<TData, TView>): import("react").JSX.Element;
|
|
@@ -15,10 +15,10 @@ import { UNSAFE_LocationContext as LocationContext, UNSAFE_NavigationContext as
|
|
|
15
15
|
import { flexRender } from '@tanstack/react-table';
|
|
16
16
|
import { cn } from 'cn';
|
|
17
17
|
import { getCoreRowModel, useLegacyTable } from '@tanstack/react-table/legacy';
|
|
18
|
-
import { ArrowDownIcon, ArrowUpIcon, ArrowUpDownIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ListTreeIcon, TableIcon, XIcon, } from 'lucide-react';
|
|
18
|
+
import { ArrowDownIcon, ArrowUpIcon, ArrowUpDownIcon, ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ListTreeIcon, Settings2Icon, TableIcon, XIcon, } from 'lucide-react';
|
|
19
19
|
import { ErrorState } from './error-state.js';
|
|
20
20
|
import { Button } from '../ui/button.js';
|
|
21
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
|
|
21
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
|
|
22
22
|
import { Empty, EmptyDescription, EmptyHeader, EmptyTitle } from '../ui/empty.js';
|
|
23
23
|
import { Sheet, SheetContent, SheetHeader, SheetTitle } from '../ui/sheet.js';
|
|
24
24
|
import { Skeleton } from '../ui/skeleton.js';
|
|
@@ -28,8 +28,9 @@ import { EditInPlaceContext } from './edit-in-place.js';
|
|
|
28
28
|
import { EditInPlaceStore } from './edit-in-place-store.js';
|
|
29
29
|
import { LeaveGuard } from './editable-value.js';
|
|
30
30
|
import { recordDialogState } from './record-dialog-context.js';
|
|
31
|
+
import { IconAction } from './icon-action.js';
|
|
31
32
|
import { groupByValues, groupRuns } from './table-groups.js';
|
|
32
|
-
import { ColumnsMenu, PHONE_LIST_CLASS, PhoneRow, PhoneRowsSkeleton, RowActions, ViewAllLink, ViewPills, } from './data-table-tools.js';
|
|
33
|
+
import { ColumnsMenu, ColumnsMenuItems, PHONE_LIST_CLASS, PhoneRow, PhoneRowsSkeleton, RowActions, ViewAllLink, ViewPills, } from './data-table-tools.js';
|
|
33
34
|
import { ROW_ACTIONS_COLUMN_ID, visibleFromPick } from './table-columns.js';
|
|
34
35
|
import { useColumnsPick } from '../../hooks/use-columns-pick.js';
|
|
35
36
|
import { useIsPhone } from '../../hooks/use-is-phone.js';
|
|
@@ -95,10 +96,38 @@ function LayoutSwitch({ options, value, onValueChange, }) {
|
|
|
95
96
|
// a pick. Base UI's radio group needs a value for None, so it's this
|
|
96
97
|
// stand-in, never '' (the grouping's own word for None).
|
|
97
98
|
const NO_GROUPING = '__none__';
|
|
98
|
-
|
|
99
|
+
// The Group menu's items alone: its own menu's, and the framed look's
|
|
100
|
+
// settings menu's second group.
|
|
101
|
+
function GroupMenuItems({ groupings, value, onValueChange }) {
|
|
99
102
|
const current = groupings.find((grouping) => grouping.id === value);
|
|
100
|
-
return (_jsxs(
|
|
103
|
+
return (_jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { children: "Group By" }), _jsxs(DropdownMenuRadioGroup, { value: current?.id ?? NO_GROUPING, onValueChange: (next) => onValueChange(next === NO_GROUPING ? '' : String(next)), children: [_jsx(DropdownMenuRadioItem, { value: NO_GROUPING, closeOnClick: true, children: "None" }), groupings.map((grouping) => (_jsx(DropdownMenuRadioItem, { value: grouping.id, closeOnClick: true, children: grouping.label }, grouping.id)))] })] }));
|
|
101
104
|
}
|
|
105
|
+
function GroupMenu(props) {
|
|
106
|
+
const current = props.groupings.find((grouping) => grouping.id === props.value);
|
|
107
|
+
return (_jsxs(DropdownMenu, { children: [_jsxs(DropdownMenuTrigger, { render: _jsx(Button, { variant: "outline", size: "sm", "data-slot": "data-table-group-menu" }), children: [_jsx(ListTreeIcon, { "aria-hidden": "true" }), current ? `Group: ${current.label}` : 'Group'] }), _jsx(DropdownMenuContent, { align: "end", className: "w-48", children: _jsx(GroupMenuItems, { ...props }) })] }));
|
|
108
|
+
}
|
|
109
|
+
// The framed look's one settings button (`look="framed"`): the Columns
|
|
110
|
+
// ticks, then Group By, in one menu, in place of the two buttons with
|
|
111
|
+
// words. Its name says what's set that the bar no longer shows ("Table
|
|
112
|
+
// Settings, Grouped by Status"), and a dot on it says so to the eye.
|
|
113
|
+
function TableSettingsMenu({ columns, grouping, changed, }) {
|
|
114
|
+
const current = grouping?.groupings.find((each) => each.id === grouping.value);
|
|
115
|
+
const label = current ? `Table Settings, Grouped by ${current.label}` : 'Table Settings';
|
|
116
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(IconAction, { icon: Settings2Icon, label: label, size: "sm", "data-tool": "table-settings", "data-set": current || changed ? true : undefined, className: SETTINGS_DOT_CLASS }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-56", children: [columns ? _jsx(ColumnsMenuItems, { ...columns }) : null, columns && grouping ? _jsx(DropdownMenuSeparator, {}) : null, grouping ? _jsx(GroupMenuItems, { ...grouping }) : null] })] }));
|
|
117
|
+
}
|
|
118
|
+
// The dot on the settings button while something in it is set: the
|
|
119
|
+
// primary colour, ringed in the button's own background so it reads on
|
|
120
|
+
// either theme. Decoration: the button's name says it in words.
|
|
121
|
+
const SETTINGS_DOT_CLASS = 'relative data-set:after:absolute data-set:after:top-0.5 data-set:after:right-0.5 data-set:after:size-2 ' +
|
|
122
|
+
'data-set:after:rounded-full data-set:after:bg-primary data-set:after:ring-2 data-set:after:ring-background ' +
|
|
123
|
+
"data-set:after:content-['']";
|
|
124
|
+
// `look="framed"`: the card around the list, and its two bars. The card
|
|
125
|
+
// clips (never hides) its overflow, so the rounded corners hold and sticky
|
|
126
|
+
// headings still stick to the page.
|
|
127
|
+
const FRAME_CLASS = 'flex flex-col overflow-clip rounded-lg border border-border bg-background';
|
|
128
|
+
// The phone's row list inside the card: the card is its border.
|
|
129
|
+
const FRAMED_PHONE_ROWS_CLASS = '[&_[data-slot=data-table-phone-rows]_ul]:rounded-none [&_[data-slot=data-table-phone-rows]_ul]:border-0';
|
|
130
|
+
const FRAME_BAR_CLASS = 'flex flex-wrap items-center gap-x-4 gap-y-2 bg-card px-3 py-2.5 text-card-foreground max-md:gap-x-2';
|
|
102
131
|
// The rows-per-page menu in the pagination bar (`pageSizes`): a radio list
|
|
103
132
|
// that closes on a pick. The button says the size in words of its own
|
|
104
133
|
// ("50 rows", as the list page standard drew it), and the menu says
|
|
@@ -383,7 +412,7 @@ const ROW_ACTIONS_COLUMN = {
|
|
|
383
412
|
};
|
|
384
413
|
// The cell under the actions' column: as narrow as its button.
|
|
385
414
|
const ROW_ACTIONS_CELL_CLASS = 'w-px py-0';
|
|
386
|
-
export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, groupBy, groupSummary, stickyGroupHeadings = false, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', views, activeView = null, onViewChange, viewsLabel = 'Views', columnsMenu, rowActions, phoneRow, limit, viewAll, }) {
|
|
415
|
+
export function DataTable({ columns, data, total, page, pageSize, onPageChange, pageSizes, onPageSizeChange, sorting, onSortingChange, isLoading, error, onRetry, emptyTitle, emptyDescription, emptyAction, toolbar, getRowId, pinFirstColumn, pinLastColumn, enableSortingRemoval, visibleColumns, width = 'content', striped = false, groupBy, groupSummary, stickyGroupHeadings = false, stickyTop = '0px', header: showHeader = true, highlightRow, totals, layouts, layout: layoutProp, onLayoutChange, tableLayout, groupings, grouping: groupingProp, onGroupingChange, opens, detailPanel, onRowClick: onRowClickProp, detailRow, onDetailRowChange, detailLabel = 'Details', views, activeView = null, onViewChange, viewsLabel = 'Views', columnsMenu, rowActions, phoneRow, limit, viewAll, look = 'plain', }) {
|
|
387
416
|
// The switch's own state, for a table that doesn't pass `layout`.
|
|
388
417
|
const [ownLayout, setOwnLayout] = useState('table');
|
|
389
418
|
const requestedLayout = layoutProp ?? ownLayout;
|
|
@@ -707,67 +736,99 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
|
|
|
707
736
|
const viewAllTotal = viewAll?.total ?? total;
|
|
708
737
|
// The row list a phone gets has no columns to pick.
|
|
709
738
|
const showColumnsMenu = Boolean(columnsMenu) && !showPhoneRows;
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
739
|
+
// The pieces, placed as `look` says: plain, or a framed card.
|
|
740
|
+
const framed = look === 'framed';
|
|
741
|
+
const viewPills = (_jsx(_Fragment, { children: viewEntries.length > 0 ? (_jsx(ViewPills, { label: viewsLabel, views: viewEntries.map(([id, view]) => ({ id, label: view.label ?? id })), value: activeView, onValueChange: (id) => {
|
|
742
|
+
const view = views?.[id];
|
|
743
|
+
if (view)
|
|
744
|
+
onViewChange?.(view, id);
|
|
745
|
+
} })) : null }));
|
|
746
|
+
const foldAllButton = activeGrouping ? (_jsx(Button, { variant: "ghost", size: "sm", "data-slot": "data-table-fold-all", disabled: !runs?.length, onClick: foldAll, children: allFolded ? 'Unfold All' : 'Fold All' })) : null;
|
|
747
|
+
const columnsItems = showColumnsMenu
|
|
748
|
+
? {
|
|
749
|
+
columns: menuColumns,
|
|
750
|
+
visible: shownColumns ?? leafIds,
|
|
751
|
+
fixed: fixedColumns,
|
|
752
|
+
pick: columnsPick,
|
|
753
|
+
onPickChange: setColumnsPick,
|
|
754
|
+
setByView: viewColumns !== undefined,
|
|
755
|
+
}
|
|
756
|
+
: undefined;
|
|
757
|
+
const layoutSwitch = layouts?.length ? (_jsx(LayoutSwitch, { options: [
|
|
758
|
+
{ id: 'table', label: tableLayout?.label ?? 'Table', icon: tableLayout?.icon ?? TableIcon },
|
|
759
|
+
...layouts,
|
|
760
|
+
], value: currentLayout, onValueChange: setLayout })) : null;
|
|
761
|
+
const hasTools = Boolean(layouts?.length || groupings?.length || showColumnsMenu);
|
|
762
|
+
// `plain`: the toolbar, then the Columns and Group menus as buttons.
|
|
763
|
+
const plainToolbar = hasTools ? (_jsxs("div", { className: "flex flex-wrap items-end gap-x-4 gap-y-2", children: [_jsx("div", { className: "min-w-0 flex-1 basis-72", children: toolbar }), columnsItems ? _jsx(ColumnsMenu, { label: columnsMenu?.label, ...columnsItems }) : null, groupings?.length ? (_jsxs("div", { className: "flex items-center gap-2", children: [foldAllButton, _jsx(GroupMenu, { groupings: groupings, value: activeGrouping?.id ?? '', onValueChange: setGrouping })] })) : null, layoutSwitch] })) : (toolbar);
|
|
764
|
+
// `framed`: the card's top bar, one settings button in place of the two
|
|
765
|
+
// menus. Left out when there's nothing to put in it.
|
|
766
|
+
const framedToolbar = toolbar || hasTools ? (_jsxs("div", { "data-slot": "data-table-top-bar", className: cn(FRAME_BAR_CLASS, 'border-b border-border'), children: [_jsx("div", { className: "min-w-0 flex-1 basis-72 max-md:basis-0", children: toolbar }), hasTools ? (_jsxs("div", { className: "flex items-center gap-2", children: [foldAllButton, columnsItems || groupings?.length ? (_jsx(TableSettingsMenu, { columns: columnsItems, grouping: groupings?.length
|
|
767
|
+
? { groupings, value: activeGrouping?.id ?? '', onValueChange: setGrouping }
|
|
768
|
+
: undefined, changed: Boolean(columnsItems && (columnsPick || viewColumns !== undefined)) })) : null, layoutSwitch] })) : null] })) : null;
|
|
769
|
+
// Loading, empty or failed: in place of the rows.
|
|
770
|
+
const stateView = error ? (_jsx(ErrorState, { error: error, onRetry: onRetry })) : isLoading || isPastLastPage ? (cardLayout ? (_jsx(CardsSkeleton, { layout: cardLayout })) : showPhoneRows ? (_jsx(PhoneRowsSkeleton, {})) : (_jsx(TableSkeleton, { columnCount: table.getVisibleLeafColumns().length }))) : isEmpty ? (_jsxs(Empty, { "data-state": "empty", children: [_jsxs(EmptyHeader, { children: [_jsx(EmptyTitle, { children: emptyTitle }), emptyDescription && _jsx(EmptyDescription, { children: emptyDescription })] }), emptyAction] })) : null;
|
|
771
|
+
const detailAside = !isSuccessView
|
|
772
|
+
? null
|
|
773
|
+
: (selectedRow && detailPanel && isWide ? (_jsxs("aside", { "aria-label": detailLabel, "data-slot": "data-table-detail", className: DETAIL_ASIDE_CLASS, onKeyDown: (event) => {
|
|
774
|
+
const target = event.target;
|
|
775
|
+
if (event.key !== 'Escape' || event.defaultPrevented || target.closest(TYPING_SELECTOR))
|
|
776
|
+
return;
|
|
777
|
+
event.preventDefault();
|
|
778
|
+
closeDetail();
|
|
779
|
+
}, children: [_jsxs("div", { className: "flex items-center justify-between gap-2", children: [_jsx("h2", { className: "type-label text-muted-foreground", children: detailLabel }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Close", onClick: closeDetail, children: _jsx(XIcon, { "aria-hidden": "true" }) })] }), detailPanel(selectedRow.original)] })) : null);
|
|
780
|
+
const rowsView = (_jsxs(_Fragment, { children: [cardLayout ? (_jsx(Cards, { layout: cardLayout, runs: runs, rows: rows, folded: folded, onToggleFold: toggleFold, groupSummary: groupSummary, groupIcons: groupIcons, onCardClick: onCardClick })) : showPhoneRows ? (_jsx("div", { "data-state": "success", "data-slot": "data-table-phone-rows", className: "flex flex-col gap-4", children: runs
|
|
781
|
+
? runs.map((run, runIndex) => {
|
|
782
|
+
const isFolded = folded.has(run.key);
|
|
783
|
+
return (_jsxs("section", { "data-slot": "table-group", "data-folded": isFolded || undefined, className: "flex flex-col gap-2", children: [_jsxs("h2", { "data-slot": "table-group-heading", className: "flex items-baseline gap-2 px-1", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }), !isFolded && phoneList(run.rows)] }, `${runIndex}:${run.key}`));
|
|
784
|
+
})
|
|
785
|
+
: phoneList(rows) })) : (_jsxs(Table, { "data-state": "success", containerRef: containerRef, onKeyDown: rowsOpen ? onListKeyDown : undefined, className: cn(stickyGroups && STICKY_FOCUS_CLASS), containerStyle: stickyGroups
|
|
786
|
+
? {
|
|
787
|
+
'--data-table-head-height': `${headHeight}px`,
|
|
788
|
+
'--data-table-sticky-top': stickyTop,
|
|
789
|
+
'--data-table-pin-top': scrollsSideways ? '0px' : stickyTop,
|
|
790
|
+
}
|
|
791
|
+
: undefined,
|
|
792
|
+
// With the sticky bar below as the visible scrollbar, hide the
|
|
793
|
+
// container's own. It stays overflow-x-auto and fully
|
|
794
|
+
// scrollable (wheel, trackpad, drag, and the sync effect); it
|
|
795
|
+
// just no longer draws a bar directly under the last row.
|
|
796
|
+
containerClassName: cn(
|
|
797
|
+
// A size container has no width of its own to give, so
|
|
798
|
+
// `width="content"` couldn't fit the table: there the
|
|
799
|
+
// pinned column's `cqw` measures the table's area
|
|
800
|
+
// (`@container/data-table`) instead.
|
|
801
|
+
pinFirstColumn && width !== 'content' && '@container', pinFirstColumn && '[scrollbar-width:none] [&::-webkit-scrollbar]:hidden', stickyGroups && (scrollsSideways ? STICKY_OWN_SCROLL_CLASS : STICKY_PAGE_SCROLL_CLASS)), children: [_jsx(TableHeader, { className: cn((!showHeader || stickyGroups) && '[&_tr]:border-0'), children: table.getHeaderGroups().map((headerGroup) => (_jsx(TableRow, { children: headerGroup.headers.map((header, index) => {
|
|
802
|
+
const canSort = header.column.getCanSort();
|
|
803
|
+
const sortDirection = header.column.getIsSorted();
|
|
804
|
+
// Hidden, a header is its name only: a sort button no
|
|
805
|
+
// one can see would still take focus.
|
|
806
|
+
const content = header.isPlaceholder ? null : canSort && showHeader ? (_jsxs("button", { type: "button", className: cn('flex items-center gap-1 text-foreground', header.column.columnDef.meta?.align === 'center' && 'w-full justify-center',
|
|
807
|
+
// The arrow on the label's left, so the label's
|
|
808
|
+
// right edge lines up with the numbers under it.
|
|
809
|
+
header.column.columnDef.meta?.align === 'right' && 'ml-auto flex-row-reverse'), onClick: header.column.getToggleSortingHandler(), children: [flexRender(header.column.columnDef.header, header.getContext()), sortDirection === 'asc' ? (_jsx(ArrowUpIcon, { className: "size-3.5 text-muted-foreground" })) : sortDirection === 'desc' ? (_jsx(ArrowDownIcon, { className: "size-3.5 text-muted-foreground" })) : (_jsx(ArrowUpDownIcon, { className: "size-3.5 text-muted-foreground/50" }))] })) : (flexRender(header.column.columnDef.header, header.getContext()));
|
|
810
|
+
return (_jsx(TableHead, { className: cn(!showHeader && HIDDEN_HEAD_CLASS, pinFirstColumn && index === 0 && PINNED_COLUMN_CLASS, pinLast &&
|
|
811
|
+
index === headerGroup.headers.length - 1 &&
|
|
812
|
+
PINNED_LAST_COLUMN_CLASS, stickyGroups && showHeader && STICKY_HEAD_CELL_CLASS, alignClass(header.column.columnDef.meta?.align)), "aria-sort": !canSort
|
|
813
|
+
? undefined
|
|
814
|
+
: sortDirection === 'asc'
|
|
815
|
+
? 'ascending'
|
|
816
|
+
: sortDirection === 'desc'
|
|
817
|
+
? 'descending'
|
|
818
|
+
: 'none', children: !showHeader ? (_jsx("span", { className: "sr-only", children: content })) : pinFirstColumn && index === 0 ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: content })) : (content) }, header.id));
|
|
819
|
+
}) }, headerGroup.id))) }), runs ? (runs.map((run, runIndex) => {
|
|
820
|
+
const isFolded = folded.has(run.key);
|
|
821
|
+
return (_jsxs(TableBody, { "data-slot": "table-group", "data-folded": isFolded || undefined, className: cn(!striped && UNSTRIPED_BODY_CLASS), children: [_jsx(TableRow, { "data-slot": "table-group-heading", className: cn('hover:bg-transparent has-aria-expanded:bg-transparent', stickyGroups && 'border-b-0'), children: _jsx(TableHead, { scope: "rowgroup", colSpan: visibleColumnCount, className: cn(GROUP_HEADING_CLASS, stickyGroups && STICKY_GROUP_HEADING_CLASS), children: _jsxs("span", { className: "sticky left-(--table-cell-px) inline-flex items-baseline gap-2", children: [_jsx(GroupLabel, { run: run, icon: groupIcons?.get(run.key), isFolded: isFolded, onToggle: () => toggleFold(run.key) }), groupSummary && (_jsx("span", { className: "type-caption text-muted-foreground tabular-nums", children: groupSummary(run.rows.map((row) => row.original), { key: run.key, label: run.label }) }))] }) }) }), _jsx("tr", { hidden: true, "aria-hidden": "true", "data-slot": "table-group-stripe-offset" }), !isFolded && run.rows.map((row) => renderRow(row, placeKey(run.key, row.id)))] }, `${runIndex}:${run.key}`));
|
|
822
|
+
})) : (_jsx(TableBody, { className: cn(!striped && UNSTRIPED_BODY_CLASS), children: rows.map((row) => renderRow(row)) })), totals && (_jsx(TableFooter, { className: TOTALS_FOOTER_CLASS, children: _jsx(TableRow, { "data-slot": "table-totals", className: "hover:bg-transparent", children: visibleLeafColumns.map((column, index) => {
|
|
823
|
+
const className = cn(pinFirstColumn && index === 0 && PINNED_TOTALS_LABEL_CLASS, pinLast && index === visibleColumnCount - 1 && PINNED_LAST_COLUMN_CLASS, alignClass(column.columnDef.meta?.align));
|
|
824
|
+
return index === 0 ? (_jsx(TableHead, { scope: "row", className: cn(TOTALS_LABEL_CLASS, className), children: pinFirstColumn ? (_jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: totals.label })) : (totals.label) }, column.id)) : (_jsx(TableCell, { className: className, children: totals.cells?.[column.id] }, column.id));
|
|
825
|
+
}) }) }))] })), pinFirstColumn && isOverflowing && !cardLayout && !showPhoneRows && (_jsx("div", { ref: barRef, "aria-hidden": "true", tabIndex: -1, "data-slot": "bottom-scrollbar", className: "sticky bottom-0 z-20 h-4 overflow-x-auto border-t border-border bg-background", children: _jsx("div", { style: { width: scrollWidth, height: 1 } }) })), viewAll && limit !== undefined && viewAllTotal > rows.length ? (_jsx(ViewAllLink, { viewAll: viewAll, total: viewAllTotal, navigator: navigation?.navigator })) : null] }));
|
|
826
|
+
const pagination = limit === undefined ? (_jsxs("div", { className: cn('flex flex-wrap items-center justify-between gap-x-4 gap-y-2', framed && [FRAME_BAR_CLASS, 'border-t border-border py-2']), "data-slot": "data-table-pagination", children: [_jsxs("p", { className: "type-body text-muted-foreground", children: [total === 0 ? 0 : (page - 1) * pageSize + 1, '–', Math.min(page * pageSize, total), " of ", total] }), _jsxs("div", { className: "flex items-center gap-2", children: [pageSizes && pageSizes.length > 1 && onPageSizeChange ? (_jsx(PageSizeMenu, { pageSizes: pageSizes, value: pageSize, onValueChange: onPageSizeChange })) : null, _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Previous Page", disabled: page <= 1, onClick: () => onPageChange(page - 1), children: _jsx(ChevronLeftIcon, {}) }), _jsxs("span", { className: "type-body text-muted-foreground", children: ["Page ", page, " of ", pageCount] }), _jsx(Button, { variant: "outline", size: "icon-sm", "aria-label": "Next Page", disabled: page >= pageCount, onClick: () => onPageChange(page + 1), children: _jsx(ChevronRightIcon, {}) })] })] })) : null;
|
|
827
|
+
// `width="content"`'s last width, kept while another state shows.
|
|
828
|
+
const lastWidthStyle = fitsColumns && !isSuccessView && lastWidth !== null
|
|
829
|
+
? { '--data-table-last-width': `${lastWidth}px` }
|
|
830
|
+
: undefined;
|
|
831
|
+
const content = framed ? (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-look": "framed", "data-layout": layouts?.length ? currentLayout : undefined, children: [viewPills, _jsx(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: _jsxs("div", { ref: body, "data-slot": "data-table-frame", className: cn(FRAME_CLASS, fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: [framedToolbar, _jsx("div", { "data-slot": "data-table-body", className: cn('flex flex-col gap-4', (stateView || cardLayout) && 'p-3', showPhoneRows && !stateView && FRAMED_PHONE_ROWS_CLASS), children: stateView ?? rowsView }), stateView ? null : pagination] }) })] })) : (_jsxs("div", { ref: root, className: "flex flex-col gap-4", "data-width": width, "data-layout": layouts?.length ? currentLayout : undefined, children: [viewPills, plainToolbar, _jsx("div", { ref: body, "data-slot": "data-table-body", className: cn('flex flex-col gap-4', fitsColumns && CONTENT_WIDTH_CLASS), style: lastWidthStyle, children: stateView ?? (_jsxs(DetailFrame, { enabled: Boolean(detailPanel) && !cardLayout, aside: detailAside, children: [rowsView, pagination] })) })] }));
|
|
771
832
|
return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsxs(RowActionsContext.Provider, { value: rowActions, children: [editing && _jsx(LeaveGuard, { store: store }), width === 'content' ? _jsx("div", { className: "@container/data-table", children: content }) : content, detailPanel && (_jsx(Sheet, { open: Boolean(selectedRow) && !isWide && isSuccessView && !cardLayout, onOpenChange: (open) => {
|
|
772
833
|
if (!open)
|
|
773
834
|
setSelection(null);
|
|
@@ -10,6 +10,19 @@ export type ListHeaderAction = {
|
|
|
10
10
|
onSelect: () => void;
|
|
11
11
|
icon?: IconComponent;
|
|
12
12
|
};
|
|
13
|
+
/** One list in the `siblings` switch. */
|
|
14
|
+
export type ListHeaderSibling = {
|
|
15
|
+
label: string;
|
|
16
|
+
to: To;
|
|
17
|
+
/** How many records it holds, after its label. */
|
|
18
|
+
count?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Whether it's the list showing. Left out, it's the one whose path is
|
|
21
|
+
* the page's (react-router's NavLink, `end`), so set it for siblings
|
|
22
|
+
* told apart by their query string.
|
|
23
|
+
*/
|
|
24
|
+
current?: boolean;
|
|
25
|
+
};
|
|
13
26
|
export type ListHeaderProps = {
|
|
14
27
|
/** The list's name: the page's h1. */
|
|
15
28
|
title: string;
|
|
@@ -39,6 +52,13 @@ export type ListHeaderProps = {
|
|
|
39
52
|
onShownChange: (shown: boolean) => void;
|
|
40
53
|
noun?: string;
|
|
41
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Lists that are this one's peers (4.100): a switch beside the title,
|
|
57
|
+
* this list among them. Two or more; fewer draws nothing.
|
|
58
|
+
*/
|
|
59
|
+
siblings?: readonly ListHeaderSibling[];
|
|
60
|
+
/** The switch's landmark name: "<title> Lists" unless set. */
|
|
61
|
+
siblingsLabel?: string;
|
|
42
62
|
className?: string;
|
|
43
63
|
};
|
|
44
|
-
export declare function ListHeader({ title, count, links, newAction, more, deleted, className }: ListHeaderProps): import("react").JSX.Element;
|
|
64
|
+
export declare function ListHeader({ title, count, links, newAction, more, deleted, siblings, siblingsLabel, className, }: ListHeaderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// A list page's header (list standard L12): the title with its count,
|
|
3
3
|
// the New button alone beside it, and everything else behind one ⋯ menu.
|
|
4
4
|
// The related screens (Board, Change log) stay out as buttons while
|
|
@@ -11,17 +11,36 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
// Holds no state: the app keeps `shown` (usually a URL filter). `links`
|
|
12
12
|
// are routes, `more` are the app's own actions. The ⋯ button has an
|
|
13
13
|
// accessible name and is left out when the menu would be empty.
|
|
14
|
+
//
|
|
15
|
+
// `siblings` (4.100) is a switch beside the title between lists that are
|
|
16
|
+
// one thing seen three ways (Exercises / Targets / Weak spots): links in a
|
|
17
|
+
// segmented row, the one on marked as the current page. They're the
|
|
18
|
+
// page's own peers, so they aren't in ⋯, which keeps only what's left
|
|
19
|
+
// (Show deleted). On a phone the switch takes its own line under the
|
|
20
|
+
// title and scrolls sideways if it must.
|
|
14
21
|
import { EllipsisIcon, PlusIcon, Trash2Icon } from 'lucide-react';
|
|
15
|
-
import { Link } from 'react-router';
|
|
22
|
+
import { Link, NavLink } from 'react-router';
|
|
16
23
|
import { cn } from 'cn';
|
|
17
24
|
import { Notice } from './notice.js';
|
|
18
25
|
import { Button } from '../ui/button.js';
|
|
19
26
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from '../ui/dropdown-menu.js';
|
|
20
|
-
|
|
27
|
+
// The switch: one bordered row, the current list filled. Each link is
|
|
28
|
+
// 32px tall (40 on a phone), its focus ring inside the row.
|
|
29
|
+
const SIBLING_CLASS = 'inline-flex min-h-8 shrink-0 items-center gap-1.5 border-r border-border px-3 type-body whitespace-nowrap ' +
|
|
30
|
+
'text-muted-foreground outline-none last:border-r-0 hover:bg-muted hover:text-foreground ' +
|
|
31
|
+
'focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset max-md:min-h-10 ' +
|
|
32
|
+
'aria-[current=page]:bg-muted aria-[current=page]:font-medium aria-[current=page]:text-foreground';
|
|
33
|
+
function SiblingSwitch({ siblings, label }) {
|
|
34
|
+
return (_jsx("nav", { "aria-label": label, "data-slot": "list-header-siblings", className: "max-w-full max-md:order-last max-md:basis-full max-md:overflow-x-auto", children: _jsx("div", { className: "inline-flex overflow-hidden rounded-md border border-border", children: siblings.map((sibling) => {
|
|
35
|
+
const inner = (_jsxs(_Fragment, { children: [sibling.label, sibling.count !== undefined && (_jsxs("span", { className: "tabular-nums", children: [_jsx("span", { className: "sr-only", children: ", " }), sibling.count] }))] }));
|
|
36
|
+
return sibling.current === undefined ? (_jsx(NavLink, { to: sibling.to, end: true, className: SIBLING_CLASS, children: inner }, sibling.label)) : (_jsx(Link, { to: sibling.to, "aria-current": sibling.current ? 'page' : undefined, className: SIBLING_CLASS, children: inner }, sibling.label));
|
|
37
|
+
}) }) }));
|
|
38
|
+
}
|
|
39
|
+
export function ListHeader({ title, count, links = [], newAction, more = [], deleted, siblings = [], siblingsLabel, className, }) {
|
|
21
40
|
// One link is a button of its own; two or more go in the menu.
|
|
22
41
|
const outLink = links.length === 1 ? links[0] : undefined;
|
|
23
42
|
const menuLinks = links.length > 1 ? links : [];
|
|
24
43
|
const hasMenu = menuLinks.length > 0 || more.length > 0 || deleted !== undefined;
|
|
25
|
-
return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [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"] }))] })] })), newAction &&
|
|
44
|
+
return (_jsxs("div", { "data-slot": "list-header", className: cn('flex flex-col', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2", children: [_jsxs("h1", { className: "flex items-baseline gap-2 type-page-title text-foreground", children: [title, count !== undefined && (_jsxs("span", { className: "type-body font-normal tabular-nums text-muted-foreground", children: [_jsx("span", { className: "sr-only", children: ", " }), count] }))] }), siblings.length > 1 && _jsx(SiblingSwitch, { siblings: siblings, label: siblingsLabel ?? `${title} Lists` }), _jsxs("div", { className: "ml-auto flex flex-wrap items-center gap-2", children: [outLink && (_jsxs(Button, { size: "sm", variant: "outline", nativeButton: false, render: _jsx(Link, { to: outLink.to }), children: [outLink.icon && _jsx(outLink.icon, { "aria-hidden": "true" }), outLink.label] })), hasMenu && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsx(Button, { size: "icon-sm", variant: "outline", "aria-label": `More for ${title}`, "data-slot": "list-header-more" }), children: _jsx(EllipsisIcon, { "aria-hidden": "true" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [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"] }))] })] })), newAction &&
|
|
26
45
|
(newAction.to !== undefined ? (_jsxs(Button, { size: "sm", nativeButton: false, render: _jsx(Link, { to: newAction.to }), children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })) : (_jsxs(Button, { size: "sm", onClick: newAction.onClick, children: [_jsx(PlusIcon, { "aria-hidden": "true" }), newAction.label] })))] })] }), _jsx("div", { role: "status", "data-slot": "list-header-notice", className: "not-empty:mt-3", children: deleted?.shown && (_jsxs(Notice, { tone: "info", icon: Trash2Icon, action: _jsx(Button, { size: "sm", variant: "outline", onClick: () => deleted.onShownChange(false), children: "Back to the List" }), children: ["Showing deleted ", deleted.noun ?? 'records', "."] })) })] }));
|
|
27
46
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AppShell, type AppShellProps, type AppShellSearch, type RecentRecord, type SearchRecord, type AppShellVersion, type BottomBarItem, type NavEntry, type NavItem, type NavSection, } from './components/app/app-shell.js';
|
|
1
|
+
export { AppShell, type AppShellProps, type AppShellSearch, type RecentRecord, type SearchRecord, type AppShellVersion, type BottomBarItem, type NavEntry, type NavItem, type NavLook, type NavSection, } from './components/app/app-shell.js';
|
|
2
2
|
export type { IconComponent } from './components/app/icon-component.js';
|
|
3
3
|
export { Board, type BoardColumn, type BoardMoveTarget, type BoardProps } from './components/app/board.js';
|
|
4
4
|
export { SpinWheel, type SpinWheelProps } from './components/app/spin-wheel.js';
|
|
@@ -9,7 +9,7 @@ export { Artwork, ArtworkTag, ArtworkToggle, type ArtworkAspect, type ArtworkPro
|
|
|
9
9
|
export { ColorSwatch, type ColorSwatchProps } from './components/app/color-swatch.js';
|
|
10
10
|
export { storedColor } from './lib/stored-color.js';
|
|
11
11
|
export { CountLink, type CountLinkProps } from './components/app/count-link.js';
|
|
12
|
-
export { DataTable, type DataTableCardLayout, type DataTableOpens, type DataTableOpensKind, type DataTableGrouping, type DataTableProps, type DataTableTotals, type DataTableWidth, type SortingState, } from './components/app/data-table.js';
|
|
12
|
+
export { DataTable, type DataTableCardLayout, type DataTableOpens, type DataTableOpensKind, type DataTableGrouping, type DataTableLook, type DataTableProps, type DataTableTotals, type DataTableWidth, type SortingState, } from './components/app/data-table.js';
|
|
13
13
|
export { type DataTableColumnsMenu, type DataTablePhoneRow, type DataTableRowAction, type DataTableView, type DataTableViewAll, } from './components/app/data-table-tools.js';
|
|
14
14
|
export { RelatedTable, type RelatedTableProps } from './components/app/related-table.js';
|
|
15
15
|
export { type RowGroup } from './components/app/table-groups.js';
|
|
@@ -74,7 +74,7 @@ export { AllowReminders, type AllowRemindersProps } from './components/app/allow
|
|
|
74
74
|
export { StageCircle, type StageCircleProps, type StageCircleStage, type StageCircleTone, } from './components/app/stage-circle.js';
|
|
75
75
|
export { Notice, type NoticeProps, type NoticeTone } from './components/app/notice.js';
|
|
76
76
|
export { ValueList, type ValueListItem, type ValueListProps } from './components/app/value-list.js';
|
|
77
|
-
export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, } from './components/app/list-header.js';
|
|
77
|
+
export { ListHeader, type ListHeaderAction, type ListHeaderLink, type ListHeaderProps, type ListHeaderSibling, } from './components/app/list-header.js';
|
|
78
78
|
export { Timeline, type TimelineItem, type TimelineProps } from './components/app/timeline.js';
|
|
79
79
|
export { EqualItems, type EqualItem, type EqualItemField, type EqualItemState, type EqualItemTone, type EqualItemsLook, type EqualItemsProps, } from './components/app/equal-items.js';
|
|
80
80
|
export { NeedsYou, type NeedsYouItem, type NeedsYouProps, type NeedsYouTone } from './components/app/needs-you.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.100.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": {
|