@tristan2828/ui-foundation 4.88.0 → 4.89.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/README.md CHANGED
@@ -18,7 +18,7 @@ than installing this by hand:
18
18
 
19
19
  | Import | What |
20
20
  |---|---|
21
- | `@tristan2828/ui-foundation` | `AppShell`, `DataTable`, `EntityView` (with `EditableValue`, `editInPlace`, printing its notes and `usePrinting`, `KeyStats`, `IconAction`), `EntityForm`, `Markdown` (with `countTasks`, `toggleTaskAt`), `RichTextEditor`, `ErrorState`, `MultiChoice`, `MultiReference`, `ListEditor`, `PasswordInput`, `RouteErrorBoundary`, `FoundationProviders`, `DataEnvironmentBanner`, `LoginRoute`, `RegisterRoute`, `useAuth`, `useTableUrlState`, `useRecordUpdate`, `useDebouncedValue`, `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. For timed screens (`docs/foundation/timed-screens.md`): `SessionView`, `useSessionClock`, `useWakeLock`, `useMuted`, `usePrefersReducedMotion`, and the audio cues `unlockAudio`, `chime`, `sequence`, `cancelCues`, `onCuesRecovered`, `cuesInSync`, `keepAudioAlive`, `say`, `hush`, `vibrate`, `canVibrate`. For the page standards (`docs/foundation/design-language.md` "Parts of the page standards"): `ValueList`, `ListHeader`, `Timeline`, `NeedsYou`, `Freshness`, `PartEmpty`. For a list's tools (`docs/foundation/cell-patterns.md` 25 and 26): `FilterBar`, `FilterSelect`, `RelatedTable`, and DataTable's `views`, `columnsMenu`, `rowActions`, `phoneRow`, `limit` and `viewAll`. For reminders (`docs/foundation/reminders.md`): `AllowReminders`, `usePushPermission`. For a record opened in a dialog over its list (`docs/foundation/add-an-entity.md`): `RecordDialogRoute`, `RecordLink`, `useOpenRecord`, `useRecordDialog`, `recordDialogState`, and for a new record over it `useNewRecordDialog`. A small form in a dialog: `FormDialog`. For the trail and search in `AppShell`'s bar (`docs/foundation/design-language.md` "The sidebar and the phone's bar"): `usePageTrail`, `useRecentRecord`, `PageTrail`; types `AppShellSearch`, `SearchRecord`, `RecentRecord`. For the form standard (`docs/foundation/add-an-entity.md` "Forms"): `FormSection`, `OptionSelect`, `ChoiceButtons`, `ReferenceCombobox`, `countFormErrors`, `fieldRows`, `parsePlainDate`, and for a record's rows edited in place `editRowClass`, `onEditRowClick` and `inPlace.choice`; from `/ui/field`, `Field` takes `size`, `solo` and `kind`, and `FieldLabel` takes `required`. From `/ui/dialog`, `DialogContent` takes `size` and `dirty`, and `DiscardChangesDialog` is the "Discard your changes?" prompt |
21
+ | `@tristan2828/ui-foundation` | `AppShell`, `DataTable`, `EntityView` (with `EditableValue`, `editInPlace`, printing its notes and `usePrinting`, `KeyStats`, `IconAction`), `EntityForm`, `Markdown` (with `countTasks`, `toggleTaskAt`), `RichTextEditor`, `ErrorState`, `MultiChoice`, `MultiReference`, `ListEditor`, `PasswordInput`, `RouteErrorBoundary`, `FoundationProviders`, `DataEnvironmentBanner`, `LoginRoute`, `RegisterRoute`, `useAuth`, `useTableUrlState`, `useRecordUpdate`, `useDebouncedValue`, `createQueryClient`, `cn`; types `Page`, `AppError`, `QuerySpec`. For timed screens (`docs/foundation/timed-screens.md`): `SessionView`, `useSessionClock`, `useWakeLock`, `useMuted`, `usePrefersReducedMotion`, and the audio cues `unlockAudio`, `chime`, `sequence`, `cancelCues`, `onCuesRecovered`, `cuesInSync`, `keepAudioAlive`, `say`, `hush`, `vibrate`, `canVibrate`. For the page standards (`docs/foundation/design-language.md` "Parts of the page standards"): `ValueList`, `ListHeader`, `Timeline`, `NeedsYou`, `Freshness`, `PartEmpty`. For a module's overview ("An overview page" there): `OverviewPage`, and `WidgetCard`'s `to`, `value`, `line` and `freshness`. For a list's tools (`docs/foundation/cell-patterns.md` 25 and 26): `FilterBar`, `FilterSelect`, `RelatedTable`, and DataTable's `views`, `columnsMenu`, `rowActions`, `phoneRow`, `limit` and `viewAll`. For reminders (`docs/foundation/reminders.md`): `AllowReminders`, `usePushPermission`. For a record opened in a dialog over its list (`docs/foundation/add-an-entity.md`): `RecordDialogRoute`, `RecordLink`, `useOpenRecord`, `useRecordDialog`, `recordDialogState`, and for a new record over it `useNewRecordDialog`. A small form in a dialog: `FormDialog`. For the trail and search in `AppShell`'s bar (`docs/foundation/design-language.md` "The sidebar and the phone's bar"): `usePageTrail`, `useRecentRecord`, `PageTrail`; types `AppShellSearch`, `SearchRecord`, `RecentRecord`. For the form standard (`docs/foundation/add-an-entity.md` "Forms"): `FormSection`, `OptionSelect`, `ChoiceButtons`, `ReferenceCombobox`, `countFormErrors`, `fieldRows`, `parsePlainDate`, and for a record's rows edited in place `editRowClass`, `onEditRowClick` and `inPlace.choice`; from `/ui/field`, `Field` takes `size`, `solo` and `kind`, and `FieldLabel` takes `required`. From `/ui/dialog`, `DialogContent` takes `size` and `dirty`, and `DiscardChangesDialog` is the "Discard your changes?" prompt |
22
22
  | `@tristan2828/ui-foundation/ui/<name>` | shadcn primitives: badge, button, calendar, card, checkbox, combobox, dialog, empty, field, input, input-group, label, popover, select, separator, sheet, sidebar, skeleton, sonner, spinner, switch, table, textarea, tooltip |
23
23
  | `@tristan2828/ui-foundation/gateway` | `safeFetch`, `toAppError`, `networkError` — for an app's `src/api/gateway/` only |
24
24
  | `@tristan2828/ui-foundation/mocks` | MSW: `authHandlers`, `environmentHandlers`, `resetMockAuth`, `getMockCurrentUser`, `MOCK_USER`, `exposeMswForE2E` |
@@ -3,37 +3,38 @@
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
- - [Palettes](#palettes) · lines 46–113
7
- - [Glow](#glow) · lines 115–133
8
- - [Semantic tones](#semantic-tones) · lines 135–163
9
- - [The three badge styles](#the-three-badge-styles) · lines 165–182
10
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 184–213
11
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 215–228
12
- - [Logos and brand marks](#logos-and-brand-marks) · lines 230–274
13
- - [Categorical colour](#categorical-colour) · lines 276–346
14
- - [Heat scale](#heat-scale) · lines 348–409
15
- - [Depth ramps](#depth-ramps) · lines 411–489
16
- - [A stored colour](#a-stored-colour) · lines 491–539
17
- - [Shapes and sizes](#shapes-and-sizes) · lines 541–562
18
- - [Typography](#typography) · lines 564–684
19
- - [Written text (notes)](#written-text-notes) · lines 598–684
20
- - [Density](#density) · lines 686–779
21
- - [Rows on this device](#rows-on-this-device) · lines 752–779
22
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 781–895
23
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 897–974
24
- - [Notices](#notices) · lines 976–1004
25
- - [A value over time](#a-value-over-time) · lines 1006–1092
26
- - [Several values over time](#several-values-over-time) · lines 1055–1092
27
- - [A list as a board](#a-list-as-a-board) · lines 1094–1145
28
- - [A list as cards](#a-list-as-cards) · lines 1147–1193
29
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1195–1224
30
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1226–1269
31
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1270–1308
32
- - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1310–1355
33
- - [Picking at random](#picking-at-random) · lines 1357–1388
34
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1390–1457
35
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1459–1484
36
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1486–1559
6
+ - [Palettes](#palettes) · lines 47–114
7
+ - [Glow](#glow) · lines 116–134
8
+ - [Semantic tones](#semantic-tones) · lines 136–164
9
+ - [The three badge styles](#the-three-badge-styles) · lines 166–183
10
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 185–214
11
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 216–229
12
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 231–275
13
+ - [Categorical colour](#categorical-colour) · lines 277–347
14
+ - [Heat scale](#heat-scale) · lines 349–410
15
+ - [Depth ramps](#depth-ramps) · lines 412–490
16
+ - [A stored colour](#a-stored-colour) · lines 492–540
17
+ - [Shapes and sizes](#shapes-and-sizes) · lines 542–563
18
+ - [Typography](#typography) · lines 565–685
19
+ - [Written text (notes)](#written-text-notes) · lines 599–685
20
+ - [Density](#density) · lines 687–780
21
+ - [Rows on this device](#rows-on-this-device) · lines 753–780
22
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 782–896
23
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 898–975
24
+ - [Notices](#notices) · lines 977–1005
25
+ - [A value over time](#a-value-over-time) · lines 1007–1093
26
+ - [Several values over time](#several-values-over-time) · lines 1056–1093
27
+ - [A list as a board](#a-list-as-a-board) · lines 1095–1146
28
+ - [A list as cards](#a-list-as-cards) · lines 1148–1194
29
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1196–1225
30
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1227–1270
31
+ - [An overview page](#an-overview-page) · lines 1272–1335
32
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1336–1374
33
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1376–1421
34
+ - [Picking at random](#picking-at-random) · lines 1423–1454
35
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1456–1523
36
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1525–1550
37
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1552–1625
37
38
 
38
39
  <!-- /index -->
39
40
 
@@ -1267,6 +1268,71 @@ into a table, a record or an overview.
1267
1268
  Every one is measured with axe and the glyph check in both themes
1268
1269
  (fixtures `app/ValueList`, `ListHeader`, `Timeline`, `NeedsYou`,
1269
1270
  `Freshness`, `PartEmpty`).
1271
+
1272
+ ## An overview page
1273
+
1274
+ The overview standard (4.89): a module's first page when it has three
1275
+ or more lists, saying how things stand and what waits on the user, each
1276
+ part one click from its list. `OverviewPage` draws the whole page; the
1277
+ hub's `WidgetCard`s take the same card anatomy, so a hub and an overview
1278
+ read alike.
1279
+
1280
+ ```tsx
1281
+ <OverviewPage
1282
+ title="Household"
1283
+ stats={<KeyStats stats={[{ label: 'Savings', value: '$24,800', icon: LandmarkIcon }]} />}
1284
+ needs={[{ text: 'Balances are three months old', to: '/accounts' }]}
1285
+ parts={[
1286
+ {
1287
+ id: 'savings',
1288
+ title: 'Savings',
1289
+ icon: LandmarkIcon,
1290
+ to: '/accounts',
1291
+ value: '$24,800',
1292
+ line: '+$1,120 since August',
1293
+ freshness: { label: 'Balances entered', at: entered, staleAfter: addDays(entered, 90) },
1294
+ detail: <WidgetList>…</WidgetList>,
1295
+ isLoading,
1296
+ error,
1297
+ onRetry: refetch,
1298
+ },
1299
+ { id: 'budget', title: 'Budget', icon: WalletIcon, to: '/budget',
1300
+ empty: { action: { label: 'Add the first line', to: '/budget/new' } } },
1301
+ ]}
1302
+ />
1303
+ ```
1304
+
1305
+ - **The top:** the title (the page's h1, `actions` at its end), then
1306
+ `stats` (a `KeyStats` strip of three to five numbers), then `NeedsYou`
1307
+ from `needs`, which draws nothing when nothing waits. Collect `needs`
1308
+ from what each part says about itself.
1309
+ - **From 48rem up, tiles.** One per part, at least 170px, as many as fit:
1310
+ the icon and title, `value` in the numeric type, and `freshness`. A
1311
+ tile is a button (`aria-expanded`, `aria-controls` the detail); a click
1312
+ opens its part's detail below the grid, one at a time, and a second
1313
+ click or Escape inside the detail closes it, focus back on the tile.
1314
+ `defaultOpen` names a part open at first.
1315
+ - **The detail is a `WidgetCard`:** the title as a link to `to` with a
1316
+ chevron, `value`, `line`, the app's `detail` (a few `WidgetList` rows,
1317
+ a small `LineChart`) and `freshness`.
1318
+ - **Under 48rem, an accordion.** The same cards in a `WidgetCardGroup`,
1319
+ each folded to one line with its value; opening one folds the others.
1320
+ - **Each part owns its states:** `isLoading` (a skeleton in the tile and
1321
+ the card), `error` with `onRetry` (a dash in the tile, the compact
1322
+ `ErrorState` in the card), and `empty` (a part with nothing yet: "Nothing
1323
+ yet" in the tile, `PartEmpty` and its one way to start in the card). An
1324
+ empty part stays on the page: hiding it makes the part forgotten.
1325
+ - **One card anatomy on a hub** (`WidgetCard`): `to` makes the title the
1326
+ link with a chevron (in place of the header's `link`), `value` the
1327
+ headline in the numeric type, `line` one muted line under it, and
1328
+ `freshness` the `Freshness` line at the body's end, after the
1329
+ children. A folded card shows `value` when it has no `summary`. All
1330
+ optional: a card without them is drawn as before, and its folding on a
1331
+ phone is unchanged.
1332
+
1333
+ Measured with axe and the glyph check in both themes and every palette
1334
+ (fixture `app/OverviewPage`); `e2e/overview-page.spec.ts` clicks the
1335
+ tiles, Escape and the accordion.
1270
1336
  ## A record's header and empty values
1271
1337
 
1272
1338
  The record page standard (4.81): the same header on every record, the
@@ -0,0 +1,44 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { To } from 'react-router';
3
+ import type { AppError } from '../../api/contracts.js';
4
+ import { type FreshnessProps } from './freshness.js';
5
+ import type { IconComponent } from './icon-component.js';
6
+ import { type NeedsYouItem } from './needs-you.js';
7
+ import type { PartEmptyState } from './part-empty.js';
8
+ export type OverviewPart = {
9
+ /** Unique on the page: the tile's and the card's id. */
10
+ id: string;
11
+ title: string;
12
+ /** Decorative: the title names the part. */
13
+ icon?: IconComponent;
14
+ /** Where the part's full list or page is: its detail's title links there. */
15
+ to: To;
16
+ /** The headline: a number or a word or two ("$412,300", "3 of 7"). */
17
+ value?: ReactNode;
18
+ /** One muted line under the value, in the detail: what it means. */
19
+ line?: ReactNode;
20
+ /** How old the value is, in the tile and the detail. */
21
+ freshness?: FreshnessProps;
22
+ /** What the detail shows under the value: a few rows (WidgetList), a small chart. */
23
+ detail?: ReactNode;
24
+ /** A part with nothing yet: given, the part is empty, and its detail offers this one way to start. */
25
+ empty?: PartEmptyState;
26
+ isLoading?: boolean;
27
+ error?: AppError | null;
28
+ onRetry?: () => void;
29
+ };
30
+ export type OverviewPageProps = {
31
+ /** The page's h1: the module's name. */
32
+ title: string;
33
+ parts: readonly OverviewPart[];
34
+ /** What waits on the user, collected from the parts: NeedsYou under the title. */
35
+ needs?: readonly NeedsYouItem[];
36
+ /** A strip of key numbers under the title (a KeyStats), before Needs you. */
37
+ stats?: ReactNode;
38
+ /** Controls at the title's end. */
39
+ actions?: ReactNode;
40
+ /** The part open at first; none when left out. */
41
+ defaultOpen?: string | null;
42
+ className?: string;
43
+ };
44
+ export declare function OverviewPage({ title, parts, needs, stats, actions, defaultOpen, className, }: OverviewPageProps): import("react").JSX.Element;
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // A module's overview page (overview standard O1): what sums a module up
3
+ // rather than lists it. The title (the page's h1), an optional strip of
4
+ // key numbers (`stats`, a KeyStats), NeedsYou from `needs` (nothing when
5
+ // it's empty), then the module's parts:
6
+ //
7
+ // - from 48rem up, a grid of tiles, each at least 170px, as many as fit.
8
+ // A tile is a button: the part's icon and title, its `value` in the
9
+ // numeric type, and its `freshness`. A click opens the part's detail
10
+ // below the grid, one at a time (`aria-expanded`, `aria-controls` the
11
+ // detail); a second click, or Escape inside the detail, closes it.
12
+ // The detail is the part's WidgetCard: the title as a link to `to`
13
+ // with a chevron, `value`, `line`, the app's own `detail`, `freshness`.
14
+ // - under 48rem, the same WidgetCards as an accordion (WidgetCardGroup):
15
+ // each folded to one line with its value, opening one folds the others.
16
+ //
17
+ // A part owns its states as a WidgetCard does: `isLoading` (a skeleton in
18
+ // the tile and the card), `error` (a dash in the tile, ErrorState with
19
+ // `onRetry` in the card), and `empty` (a part with nothing yet: "Nothing
20
+ // yet" in the tile, PartEmpty with its one way to start in the card).
21
+ //
22
+ // The breakpoint is read with matchMedia; on the server, or where it's
23
+ // missing (a test's DOM), the page is drawn wide.
24
+ import { useId, useState, useSyncExternalStore } from 'react';
25
+ import { cn } from 'cn';
26
+ import { Freshness } from './freshness.js';
27
+ import { NeedsYou } from './needs-you.js';
28
+ import { WidgetCard, WidgetCardGroup } from './widget-card.js';
29
+ import { Skeleton } from '../ui/skeleton.js';
30
+ const WIDE_QUERY = '(min-width: 48rem)';
31
+ const canMatchMedia = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function';
32
+ function subscribeWide(listener) {
33
+ if (!canMatchMedia())
34
+ return () => { };
35
+ const query = window.matchMedia(WIDE_QUERY);
36
+ query.addEventListener('change', listener);
37
+ return () => query.removeEventListener('change', listener);
38
+ }
39
+ const useIsWide = () => useSyncExternalStore(subscribeWide, () => !canMatchMedia() || window.matchMedia(WIDE_QUERY).matches, () => true);
40
+ export function OverviewPage({ title, parts, needs = [], stats, actions, defaultOpen = null, className, }) {
41
+ const wide = useIsWide();
42
+ const detailId = useId();
43
+ const [openId, setOpenId] = useState(defaultOpen);
44
+ const open = parts.find((part) => part.id === openId);
45
+ const tileId = (id) => `${detailId}-tile-${id}`;
46
+ // Escape in the detail closes it and puts focus back on its tile.
47
+ const onDetailKeyDown = (event) => {
48
+ if (event.key !== 'Escape' || openId === null)
49
+ return;
50
+ const tile = document.getElementById(tileId(openId));
51
+ setOpenId(null);
52
+ tile?.focus();
53
+ };
54
+ return (_jsxs("div", { "data-slot": "overview-page", className: cn('flex flex-col gap-4', className), children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2", children: [_jsx("h1", { className: "type-page-title text-foreground", children: title }), actions && _jsx("div", { className: "flex shrink-0 items-center gap-2", children: actions })] }), stats, _jsx(NeedsYou, { items: needs }), wide ? (_jsxs(_Fragment, { children: [_jsx("ul", { "data-slot": "overview-tiles", className: "grid grid-cols-[repeat(auto-fill,minmax(170px,1fr))] gap-2.5", children: parts.map((part) => (_jsx("li", { className: "flex min-w-0", children: _jsx(OverviewTile, { id: tileId(part.id), part: part, open: part.id === openId, controls: detailId, onToggle: () => setOpenId(part.id === openId ? null : part.id) }) }, part.id))) }), _jsx("div", { id: detailId, "data-slot": "overview-detail", onKeyDown: onDetailKeyDown, children: open && _jsx(PartCard, { part: open }) })] })) : (_jsx(WidgetCardGroup, { accordion: true, defaultOpen: openId, className: "flex flex-col gap-2.5", children: parts.map((part) => (_jsx(PartCard, { part: part }, part.id))) }))] }));
55
+ }
56
+ function PartCard({ part }) {
57
+ return (_jsx(WidgetCard, { id: part.id, title: part.title, icon: part.icon, to: part.to, value: part.value, line: part.line, freshness: part.freshness, isLoading: part.isLoading ?? false, error: part.error, onRetry: part.onRetry, isEmpty: part.empty !== undefined, emptyMessage: part.empty?.text ?? 'Nothing here yet', empty: part.empty, emptySummary: "Nothing yet", className: "w-full", children: part.detail }));
58
+ }
59
+ function OverviewTile({ id, part, open, controls, onToggle, }) {
60
+ const { icon: Icon } = part;
61
+ const state = part.error ? 'error' : part.isLoading ? 'loading' : part.empty ? 'empty' : 'success';
62
+ return (_jsxs("button", { type: "button", id: id, "data-slot": "overview-tile", "data-state": state, "aria-expanded": open, "aria-controls": controls, onClick: onToggle, className: cn('glow-edge flex w-full min-w-0 flex-col items-start gap-0.5 rounded-lg bg-card px-3 py-2.5 text-left text-card-foreground', 'shadow-(--card-shadow) ring-1 ring-border outline-none hover:bg-muted', 'focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:ring-2 aria-expanded:ring-primary'), children: [_jsxs("span", { className: "flex min-w-0 max-w-full items-center gap-1.5 type-label text-muted-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-link" }), _jsx("span", { className: "truncate", children: part.title })] }), state === 'loading' ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { "data-state": "loading", className: "my-1 h-6 w-16" }), _jsx("span", { className: "sr-only", children: "Loading" })] })) : state === 'error' ? (_jsxs("span", { "data-state": "error", className: "type-numeric text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "Couldn't load" })] })) : state === 'empty' ? (_jsx("span", { "data-state": "empty", className: "py-0.5 type-body text-muted-foreground", children: "Nothing yet" })) : (part.value !== undefined && (_jsx("span", { "data-slot": "overview-tile-value", className: "max-w-full truncate type-numeric text-foreground", children: part.value }))), state === 'success' && part.freshness && _jsx(Freshness, { ...part.freshness })] }));
63
+ }
@@ -1,6 +1,7 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import { type To } from 'react-router';
3
3
  import type { AppError } from '../../api/contracts.js';
4
+ import { type FreshnessProps } from './freshness.js';
4
5
  import type { IconComponent } from './icon-component.js';
5
6
  import { type PartEmptyState } from './part-empty.js';
6
7
  export interface WidgetCardProps {
@@ -16,6 +17,18 @@ export interface WidgetCardProps {
16
17
  * title names the card.
17
18
  */
18
19
  icon?: IconComponent;
20
+ /**
21
+ * Makes the title the link to everything the card sums up, with a
22
+ * chevron after it ("Net worth ›"): the overview standard's one way a
23
+ * card links its list (O4). Use it in place of `link`, not beside it.
24
+ */
25
+ to?: To;
26
+ /** The card's headline: a number or a word or two ("$412,300", "On track"), in the numeric type. */
27
+ value?: ReactNode;
28
+ /** One muted line under `value`: what it means ("+$6,240 since Aug"). */
29
+ line?: ReactNode;
30
+ /** How old the number is: Freshness's props, drawn at the body's end. */
31
+ freshness?: FreshnessProps;
19
32
  /** The title's heading level: 2 under the page's h1 (the default), deeper under a section. */
20
33
  headingLevel?: 2 | 3 | 4 | 5 | 6;
21
34
  /**
@@ -55,7 +68,7 @@ export interface WidgetCardProps {
55
68
  /**
56
69
  * One short value shown in the header while the card is folded: a count
57
70
  * (`3`), or a word or two (`"Due today"`). A skeleton while loading, a
58
- * muted dash on an error. Ignored while open.
71
+ * muted dash on an error. Ignored while open. Defaults to `value`.
59
72
  */
60
73
  summary?: ReactNode;
61
74
  /** What a folded card's summary says when it's empty (`"None"`); nothing when left out. */
@@ -72,7 +85,7 @@ export type WidgetCardLink = {
72
85
  label: string;
73
86
  to?: never;
74
87
  };
75
- export declare function WidgetCard({ id, title, icon: Icon, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows, collapsible, defaultCollapsed, storageKey, summary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
88
+ export declare function WidgetCard({ id, title, icon: Icon, to, value, line, freshness, headingLevel, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows, collapsible, defaultCollapsed, storageKey, summary: ownSummary, emptySummary, children, className, }: WidgetCardProps): import("react").JSX.Element;
76
89
  export interface WidgetCardGroupProps {
77
90
  /**
78
91
  * One card open at a time: `true` always, `"mobile"` only below the
@@ -50,15 +50,25 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
50
50
  // switch). A trailing control is labelled by the row's text: pass a
51
51
  // function and it gets the id to put in `aria-labelledby`.
52
52
  //
53
+ // One card anatomy (overview standard O4), shared with OverviewPage's
54
+ // parts so the hub's widgets and an overview's parts read alike: `to`
55
+ // makes the title the link to everything the card sums up, with a
56
+ // chevron after it; `value` is its headline in the numeric type, `line`
57
+ // one muted line under it, and `freshness` how old the number is
58
+ // (Freshness) at the body's end. A folded card shows `value` as its
59
+ // summary when no `summary` is given. All optional: a card without them
60
+ // is drawn as before, and its folding on a phone is unchanged.
61
+ //
53
62
  // Under data-density="compact" (#224) the card's padding drops to 12px and
54
63
  // a row's to 4px, for a dense hub; text stays at type-body. On a phone a
55
64
  // compact row is 44px tall and its link fills that height, so it stays a
56
65
  // finger's target.
57
66
  import { createContext, useContext, useId, useState } from 'react';
58
67
  import { Link } from 'react-router';
59
- import { ChevronDownIcon, ExternalLinkIcon } from 'lucide-react';
68
+ import { ChevronDownIcon, ChevronRightIcon, ExternalLinkIcon } from 'lucide-react';
60
69
  import { cn } from 'cn';
61
70
  import { ErrorState } from './error-state.js';
71
+ import { Freshness } from './freshness.js';
62
72
  import { PartEmpty } from './part-empty.js';
63
73
  import { Button } from '../ui/button.js';
64
74
  import { Card, CardContent, CardHeader } from '../ui/card.js';
@@ -67,7 +77,8 @@ import { useIsMobile } from '../../hooks/use-mobile.js';
67
77
  import { useRememberedFlag } from '../../hooks/use-remembered-flag.js';
68
78
  const HEADER_LINK_CLASS = 'shrink-0 rounded-sm type-label text-foreground underline underline-offset-4 outline-none ' +
69
79
  'hover:decoration-2 focus-visible:ring-3 focus-visible:ring-ring/50';
70
- export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary, emptySummary, children, className, }) {
80
+ export function WidgetCard({ id, title, icon: Icon, to, value, line, freshness, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary: ownSummary, emptySummary, children, className, }) {
81
+ const summary = ownSummary ?? value;
71
82
  const headingId = useId();
72
83
  const contentId = useId();
73
84
  const summaryId = useId();
@@ -91,10 +102,10 @@ export function WidgetCard({ id, title, icon: Icon, headingLevel = 2, link, isLo
91
102
  return;
92
103
  toggle();
93
104
  };
94
- return (_jsx("section", { id: id, "aria-labelledby": headingId, "data-slot": "widget-card", "data-state": state, "data-collapsed": collapsed || undefined, className: cn('min-w-0 self-start', className), children: _jsxs(Card, { className: cn('glow-edge density-compact:[--card-spacing:--spacing(3)]', collapsed && 'pb-0'), children: [_jsxs(CardHeader, { onClick: onHeaderClick, className: cn('flex items-center justify-between gap-3', inAccordion && 'cursor-pointer select-none', collapsed && 'border-b-0'), children: [_jsxs(Heading, { id: headingId, className: "flex min-w-0 items-center gap-2 type-section-title text-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("span", { className: "truncate", children: title })] }), (link || foldable || summaryShown) && (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [summaryShown && (_jsx("span", { id: summaryId, "data-slot": "widget-card-summary", className: "mr-2 flex items-center", children: _jsx(WidgetCardSummary, { state: state, summary: summary, emptySummary: emptySummary }) })), link?.href !== undefined ? (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", "aria-describedby": headingId, className: cn(HEADER_LINK_CLASS, 'inline-flex items-center gap-1'), children: [link.label, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (link && (_jsx(Link, { to: link.to, "aria-describedby": headingId, className: HEADER_LINK_CLASS, children: link.label }))), foldable && (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-labelledby": headingId, "aria-describedby": summaryShown ? summaryId : undefined, "aria-expanded": !collapsed, "aria-controls": contentId, onClick: toggle,
105
+ return (_jsx("section", { id: id, "aria-labelledby": headingId, "data-slot": "widget-card", "data-state": state, "data-collapsed": collapsed || undefined, className: cn('min-w-0 self-start', className), children: _jsxs(Card, { className: cn('glow-edge density-compact:[--card-spacing:--spacing(3)]', collapsed && 'pb-0'), children: [_jsxs(CardHeader, { onClick: onHeaderClick, className: cn('flex items-center justify-between gap-3', inAccordion && 'cursor-pointer select-none', collapsed && 'border-b-0'), children: [_jsxs(Heading, { id: headingId, className: "flex min-w-0 items-center gap-2 type-section-title text-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), to !== undefined ? (_jsxs(Link, { to: to, "data-slot": "widget-card-title-link", className: "group/title -mx-1 flex min-w-0 items-center gap-0.5 rounded-sm px-1 outline-none hover:text-link focus-visible:ring-3 focus-visible:ring-ring/50", children: [_jsx("span", { className: "truncate underline-offset-4 group-hover/title:underline", children: title }), _jsx(ChevronRightIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground group-hover/title:text-link" })] })) : (_jsx("span", { className: "truncate", children: title }))] }), (link || foldable || summaryShown) && (_jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [summaryShown && (_jsx("span", { id: summaryId, "data-slot": "widget-card-summary", className: "mr-2 flex items-center", children: _jsx(WidgetCardSummary, { state: state, summary: summary, emptySummary: emptySummary }) })), link?.href !== undefined ? (_jsxs("a", { href: link.href, target: "_blank", rel: "noreferrer", "aria-describedby": headingId, className: cn(HEADER_LINK_CLASS, 'inline-flex items-center gap-1'), children: [link.label, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (link && (_jsx(Link, { to: link.to, "aria-describedby": headingId, className: HEADER_LINK_CLASS, children: link.label }))), foldable && (_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-labelledby": headingId, "aria-describedby": summaryShown ? summaryId : undefined, "aria-expanded": !collapsed, "aria-controls": contentId, onClick: toggle,
95
106
  // The button's own open look (a filled background) would
96
107
  // read as pressed: the chevron says it.
97
- className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (empty ? (_jsx(PartEmpty, { ...empty })) : (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage }))) : (children) })] }) }));
108
+ className: "-my-1 -mr-1.5 aria-expanded:not-hover:bg-transparent", children: _jsx(ChevronDownIcon, { "aria-hidden": "true", className: cn('transition-transform', collapsed && '-rotate-90') }) }))] }))] }), _jsx(CardContent, { id: contentId, hidden: collapsed, "aria-busy": state === 'loading' || undefined, children: error ? (_jsx(ErrorState, { error: error, onRetry: onRetry, size: "compact" })) : state === 'loading' ? (_jsx(WidgetListSkeleton, { rows: skeletonRows })) : state === 'empty' ? (empty ? (_jsx(PartEmpty, { ...empty })) : (_jsx("p", { "data-state": "empty", className: "py-2 type-body text-muted-foreground", children: emptyMessage }))) : value !== undefined || line !== undefined || freshness !== undefined ? (_jsxs("div", { "data-slot": "widget-card-anatomy", className: "flex flex-col gap-1.5", children: [(value !== undefined || line !== undefined) && (_jsxs("div", { className: "flex flex-col gap-0.5", children: [value !== undefined && (_jsx("p", { "data-slot": "widget-card-value", className: "type-numeric text-foreground", children: value })), line !== undefined && _jsx("p", { className: "type-body text-muted-foreground", children: line })] })), children, freshness && _jsx(Freshness, { ...freshness, className: cn('self-start', freshness.className) })] })) : (children) })] }) }));
98
109
  }
99
110
  // A folded card's one value, by state. Loading's skeleton is about one
100
111
  // number wide; an error's dash says "Couldn't load" to a screen reader,
package/dist/index.d.ts CHANGED
@@ -84,6 +84,7 @@ export { formatMonthDay, isMonthDay, monthDayProblem, type MonthDay } from './li
84
84
  export { ChoiceCell, LinkCell, LinkOut, NameCell, type ChoiceCellProps, type LinkCellProps, type NameCellProps, } from './components/app/row-edit-cells.js';
85
85
  export { ModuleCard, ModuleStrip, type CategorySlot, type ModuleCardLink, type ModuleCardPlace, type ModuleCardProps, type ModuleStripMobile, type ModuleStripProps, } from './components/app/module-card.js';
86
86
  export { WidgetCard, WidgetCardGroup, WidgetList, WidgetListItem, type WidgetCardGroupProps, type WidgetCardLink, type WidgetCardProps, type WidgetListItemProps, } from './components/app/widget-card.js';
87
+ export { OverviewPage, type OverviewPageProps, type OverviewPart } from './components/app/overview-page.js';
87
88
  export { WidgetLayoutSheet, type WidgetLayoutSheetProps } from './components/app/widget-layout-sheet.js';
88
89
  export { ThemeProvider } from './components/theme-provider.js';
89
90
  export { LoginRoute, type LoginRouteProps } from './routes/login.js';
package/dist/index.js CHANGED
@@ -86,6 +86,7 @@ export { formatMonthDay, isMonthDay, monthDayProblem } from './lib/month-day.js'
86
86
  export { ChoiceCell, LinkCell, LinkOut, NameCell, } from './components/app/row-edit-cells.js';
87
87
  export { ModuleCard, ModuleStrip, } from './components/app/module-card.js';
88
88
  export { WidgetCard, WidgetCardGroup, WidgetList, WidgetListItem, } from './components/app/widget-card.js';
89
+ export { OverviewPage } from './components/app/overview-page.js';
89
90
  export { WidgetLayoutSheet } from './components/app/widget-layout-sheet.js';
90
91
  export { ThemeProvider } from './components/theme-provider.js';
91
92
  // Screens outside the app shell
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.88.0",
3
+ "version": "4.89.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": {