@argon8/react 0.0.0-stage → 0.2.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.
@@ -0,0 +1,28 @@
1
+ import { type ReactNode } from "react";
2
+ export declare function Dialog({ open, onOpenChange, title, description, size, dismissible, className, children, footer, }: {
3
+ open: boolean;
4
+ onOpenChange: (open: boolean) => void;
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
+ size?: "sm" | "md";
8
+ dismissible?: boolean;
9
+ className?: string;
10
+ children?: ReactNode;
11
+ footer?: ReactNode;
12
+ }): import("react").JSX.Element;
13
+ /**
14
+ * A destructive action (components.md Part 4): names the object, states the consequence and what is
15
+ * kept; Cancel first and focused; the confirm button is verb plus object; `typeToConfirm` for what
16
+ * cannot be undone. Pending and the error stay inside the dialog.
17
+ */
18
+ export declare function ConfirmDialog({ open, onOpenChange, title, consequence, confirmLabel, onConfirm, typeToConfirm, pending, error, }: {
19
+ open: boolean;
20
+ onOpenChange: (open: boolean) => void;
21
+ title: ReactNode;
22
+ consequence: ReactNode;
23
+ confirmLabel: string;
24
+ onConfirm: () => void;
25
+ typeToConfirm?: string;
26
+ pending?: boolean;
27
+ error?: ReactNode;
28
+ }): import("react").JSX.Element;
package/dist/dialog.js ADDED
@@ -0,0 +1,62 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from "react";
3
+ import { Button } from "./button.js";
4
+ import { cn } from "./cn.js";
5
+ import { Field, Input } from "./field.js";
6
+ // docs/components.md 3.6: the native <dialog> (focus trap, Escape, inert page, top layer, no
7
+ // dependency, CSP-safe). Focus returns to the element that had it. Not dismissible while pending.
8
+ export function Dialog({ open, onOpenChange, title, description, size = "sm", dismissible = true, className, children, footer, }) {
9
+ const ref = useRef(null);
10
+ const returnTo = useRef(null);
11
+ const titleId = useId();
12
+ const descId = useId();
13
+ useEffect(() => {
14
+ const d = ref.current;
15
+ if (!d)
16
+ return;
17
+ if (open && !d.open) {
18
+ returnTo.current = document.activeElement;
19
+ d.showModal();
20
+ d.querySelector("[data-autofocus]")?.focus();
21
+ }
22
+ else if (!open && d.open) {
23
+ d.close();
24
+ }
25
+ }, [open]);
26
+ return (_jsxs("dialog", { ref: ref, "data-size": size, "aria-labelledby": titleId, "aria-describedby": description ? descId : undefined, onCancel: (e) => {
27
+ e.preventDefault();
28
+ if (dismissible)
29
+ onOpenChange(false);
30
+ }, onClose: () => {
31
+ if (returnTo.current instanceof HTMLElement)
32
+ returnTo.current.focus();
33
+ if (open)
34
+ onOpenChange(false);
35
+ }, className: cn("m-auto w-[calc(100%-2rem)] rounded-dialog border border-line bg-surface-raised p-0 text-ink shadow-float", size === "sm" ? "max-w-[440px]" : "max-w-[560px]", className), children: [_jsxs("div", { className: "flex flex-col gap-3 p-5", children: [_jsx("h2", { id: titleId, className: "text-section font-semibold", children: title }), description ? (_jsx("p", { id: descId, className: "text-body text-ink-muted", children: description })) : null, children] }), footer ? _jsx("div", { className: "flex flex-wrap justify-end gap-2 border-t border-line px-5 py-3", children: footer }) : null] }));
36
+ }
37
+ /**
38
+ * A destructive action (components.md Part 4): names the object, states the consequence and what is
39
+ * kept; Cancel first and focused; the confirm button is verb plus object; `typeToConfirm` for what
40
+ * cannot be undone. Pending and the error stay inside the dialog.
41
+ */
42
+ export function ConfirmDialog({ open, onOpenChange, title, consequence, confirmLabel, onConfirm, typeToConfirm, pending, error, }) {
43
+ const [typed, setTyped] = useState("");
44
+ const [mismatch, setMismatch] = useState(false);
45
+ useEffect(() => {
46
+ if (!open) {
47
+ setTyped("");
48
+ setMismatch(false);
49
+ }
50
+ }, [open]);
51
+ const submit = (e) => {
52
+ e.preventDefault();
53
+ if (pending)
54
+ return;
55
+ if (typeToConfirm && typed !== typeToConfirm) {
56
+ setMismatch(true);
57
+ return;
58
+ }
59
+ onConfirm();
60
+ };
61
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, title: title, description: consequence, dismissible: !pending, children: _jsxs("form", { id: "confirm", onSubmit: submit, className: "flex flex-col gap-3", noValidate: true, children: [typeToConfirm ? (_jsx(Field, { label: _jsxs(_Fragment, { children: ["Type ", _jsx("strong", { children: typeToConfirm }), " to confirm"] }), error: mismatch ? `Type ${typeToConfirm} exactly as shown.` : undefined, children: (p) => _jsx(Input, { ...p, autoComplete: "off", spellCheck: false, value: typed, onChange: (e) => { setTyped(e.target.value); setMismatch(false); } }) })) : null, error ? (_jsx("p", { role: "alert", className: "text-body text-danger", children: error })) : null, _jsxs("div", { className: "flex flex-wrap justify-end gap-2 pt-1", children: [_jsx(Button, { variant: "secondary", "data-autofocus": "", autoFocus: true, "aria-disabled": pending || undefined, onClick: () => !pending && onOpenChange(false), children: "Cancel" }), _jsx(Button, { type: "submit", variant: "destructive", pending: pending, children: confirmLabel })] })] }) }));
62
+ }
@@ -0,0 +1,26 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export type ControlProps = {
3
+ id: string;
4
+ "aria-describedby"?: string;
5
+ "aria-invalid"?: true;
6
+ required?: boolean;
7
+ };
8
+ export declare function Label({ className, ...props }: ComponentProps<"label">): import("react").JSX.Element;
9
+ export declare function Field({ label, hint, error, required, className, children }: {
10
+ label: ReactNode;
11
+ hint?: ReactNode;
12
+ error?: ReactNode;
13
+ required?: boolean;
14
+ className?: string;
15
+ children: (p: ControlProps) => ReactNode;
16
+ }): import("react").JSX.Element;
17
+ type Size = {
18
+ size?: "sm" | "md";
19
+ invalid?: boolean;
20
+ };
21
+ export declare function Input({ className, size, invalid, startAddon, endAddon, type, ...props }: Omit<ComponentProps<"input">, "size"> & Size & {
22
+ startAddon?: ReactNode;
23
+ endAddon?: ReactNode;
24
+ }): import("react").JSX.Element;
25
+ export declare function Select({ className, size, invalid, ...props }: Omit<ComponentProps<"select">, "size"> & Size): import("react").JSX.Element;
26
+ export {};
package/dist/field.js ADDED
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ import { cn } from "./cn.js";
4
+ export function Label({ className, ...props }) {
5
+ return _jsx("label", { className: cn("text-body font-medium text-ink", className), ...props });
6
+ }
7
+ export function Field({ label, hint, error, required, className, children }) {
8
+ const id = useId();
9
+ const hintId = `${id}-hint`;
10
+ const errorId = `${id}-error`;
11
+ const describedBy = [hint ? hintId : null, error ? errorId : null].filter(Boolean).join(" ") || undefined;
12
+ return (_jsxs("div", { className: cn("flex flex-col gap-1", className), children: [_jsxs("div", { className: "flex items-baseline gap-2", children: [_jsx(Label, { htmlFor: id, children: label }), required ? _jsx("span", { className: "text-meta text-ink-muted", children: "required" }) : null] }), hint ? (_jsx("p", { id: hintId, className: "text-meta text-ink-muted", children: hint })) : null, children({ id, "aria-describedby": describedBy, "aria-invalid": error ? true : undefined, required }), error ? (_jsx("p", { id: errorId, role: "alert", className: "text-meta font-medium text-danger", children: error })) : null] }));
13
+ }
14
+ const control = (invalid, size) => cn("w-full rounded-control border bg-surface px-2.5 text-ink placeholder:text-ink-subtle hover:border-ink-subtle disabled:cursor-not-allowed disabled:bg-surface-sunk disabled:text-ink-subtle read-only:bg-surface-sunk", size === "sm" ? "h-control-touch-sm text-meta sm:h-control-sm" : "h-control-touch-md text-body sm:h-control-md", invalid ? "border-danger-solid" : "border-line-strong");
15
+ export function Input({ className, size = "md", invalid, startAddon, endAddon, type, ...props }) {
16
+ const bad = Boolean(invalid || props["aria-invalid"] === true || props["aria-invalid"] === "true");
17
+ const input = _jsx("input", { type: type, className: cn(control(bad, size), type === "number" && "tabular-nums", !startAddon && !endAddon && className), ...props });
18
+ if (!startAddon && !endAddon)
19
+ return input;
20
+ return (_jsxs("div", { className: cn("flex items-center gap-2", className), children: [startAddon ? _jsx("span", { className: "shrink-0 text-meta text-ink-muted", children: startAddon }) : null, input, endAddon ? _jsx("span", { className: "shrink-0 text-meta text-ink-muted", children: endAddon }) : null] }));
21
+ }
22
+ export function Select({ className, size = "md", invalid, ...props }) {
23
+ const bad = Boolean(invalid || props["aria-invalid"] === true || props["aria-invalid"] === "true");
24
+ return _jsx("select", { className: cn(control(bad, size), "pr-8", className), ...props });
25
+ }
@@ -0,0 +1,20 @@
1
+ export { cn } from "./cn.js";
2
+ export { Button, type ButtonProps, buttonVariants, Spinner } from "./button.js";
3
+ export { type ControlProps, Field, Input, Label, Select } from "./field.js";
4
+ export { Checkbox, Fieldset, type Option, RadioGroup, Segmented, Switch } from "./choice.js";
5
+ export { Badge, Count, type Tone, TONES, ToneIcon, toneEdge, toneSolid, toneText, toneTint, worstTone } from "./status.js";
6
+ export { Alert, Details } from "./alert.js";
7
+ export { type Density, DensityProvider, Table, TBody, Td, Th, THead, Tr } from "./table.js";
8
+ export { Card, CardBody, CardHeader, EmptyState, KeyValues, LoadingState, Panel, Section } from "./containers.js";
9
+ export { Code, CopyButton } from "./code.js";
10
+ export { Breadcrumb, linkVariants, PageHeader, SkipLink, StepMarker } from "./navigation.js";
11
+ export { Term } from "./term.js";
12
+ export { Ago, Day, DayRange, dayRangeText, dayText, formatLocal, relativeText, When } from "./time.js";
13
+ export { ConfirmDialog, Dialog } from "./dialog.js";
14
+ export { Slot } from "./slot.js";
15
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarTopBar, SidebarTrigger, SystemBanners, useSidebar, } from "./sidebar.js";
16
+ export { Page, PageMain, PagePane, pageVariants, StatusPanel, StatusPanelActions, StatusPanelDetail, StatusPanelFacts, StatusPanelFigure, StatusPanelSummary, StatusPanelText, StatusPanelVerdict, } from "./page.js";
17
+ export { Tabs, TabsCount, TabsLink } from "./tabs.js";
18
+ export { type ToastItem, Toaster, toast } from "./toast.js";
19
+ export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "./sheet.js";
20
+ export { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "./menu.js";
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ export { cn } from "./cn.js";
2
+ export { Button, buttonVariants, Spinner } from "./button.js";
3
+ export { Field, Input, Label, Select } from "./field.js";
4
+ export { Checkbox, Fieldset, RadioGroup, Segmented, Switch } from "./choice.js";
5
+ export { Badge, Count, TONES, ToneIcon, toneEdge, toneSolid, toneText, toneTint, worstTone } from "./status.js";
6
+ export { Alert, Details } from "./alert.js";
7
+ export { DensityProvider, Table, TBody, Td, Th, THead, Tr } from "./table.js";
8
+ export { Card, CardBody, CardHeader, EmptyState, KeyValues, LoadingState, Panel, Section } from "./containers.js";
9
+ export { Code, CopyButton } from "./code.js";
10
+ export { Breadcrumb, linkVariants, PageHeader, SkipLink, StepMarker } from "./navigation.js";
11
+ export { Term } from "./term.js";
12
+ export { Ago, Day, DayRange, dayRangeText, dayText, formatLocal, relativeText, When } from "./time.js";
13
+ export { ConfirmDialog, Dialog } from "./dialog.js";
14
+ export { Slot } from "./slot.js";
15
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarTopBar, SidebarTrigger, SystemBanners, useSidebar, } from "./sidebar.js";
16
+ export { Page, PageMain, PagePane, pageVariants, StatusPanel, StatusPanelActions, StatusPanelDetail, StatusPanelFacts, StatusPanelFigure, StatusPanelSummary, StatusPanelText, StatusPanelVerdict, } from "./page.js";
17
+ export { Tabs, TabsCount, TabsLink } from "./tabs.js";
18
+ export { Toaster, toast } from "./toast.js";
19
+ export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger } from "./sheet.js";
20
+ export { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "./menu.js";
package/dist/menu.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export declare function Menu({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
3
+ export declare function MenuTrigger({ asChild, onClick, onKeyDown, ...props }: ComponentProps<"button"> & {
4
+ asChild?: boolean;
5
+ }): import("react").JSX.Element;
6
+ export declare function MenuContent({ align, className, onKeyDown, ...props }: ComponentProps<"div"> & {
7
+ align?: "start" | "end";
8
+ }): import("react").JSX.Element;
9
+ /** One action. A button by default; `asChild` for a link. `onSelect` runs, then the menu closes. */
10
+ export declare function MenuItem({ asChild, variant, onSelect, onClick, className, disabled, ...props }: Omit<ComponentProps<"button">, "onSelect"> & {
11
+ asChild?: boolean;
12
+ variant?: "default" | "destructive";
13
+ onSelect?: () => void;
14
+ children?: ReactNode;
15
+ }): import("react").JSX.Element;
16
+ export declare function MenuSeparator({ className }: {
17
+ className?: string;
18
+ }): import("react").JSX.Element;
package/dist/menu.js ADDED
@@ -0,0 +1,117 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext, useEffect, useId, useMemo, useRef, useState, } from "react";
3
+ import { cn } from "./cn.js";
4
+ import { Slot } from "./slot.js";
5
+ const MenuContext = createContext(null);
6
+ function useMenu() {
7
+ const ctx = useContext(MenuContext);
8
+ if (!ctx)
9
+ throw new Error("Menu parts must be used inside <Menu>.");
10
+ return ctx;
11
+ }
12
+ const items = (contentId) => Array.from(document.getElementById(contentId)?.querySelectorAll('[role="menuitem"]:not([aria-disabled="true"])') ?? []);
13
+ export function Menu({ className, children, ...props }) {
14
+ const id = useId();
15
+ const [open, setOpenState] = useState(false);
16
+ const wrapper = useRef(null);
17
+ const value = useMemo(() => ({
18
+ open,
19
+ setOpen: (next, focusTrigger) => {
20
+ setOpenState(next);
21
+ if (!next && focusTrigger)
22
+ document.getElementById(`${id}-trigger`)?.focus();
23
+ },
24
+ triggerId: `${id}-trigger`,
25
+ contentId: `${id}-content`,
26
+ }), [id, open]);
27
+ useEffect(() => {
28
+ if (!open)
29
+ return;
30
+ const onDown = (e) => {
31
+ if (wrapper.current && !wrapper.current.contains(e.target))
32
+ setOpenState(false);
33
+ };
34
+ document.addEventListener("pointerdown", onDown);
35
+ return () => document.removeEventListener("pointerdown", onDown);
36
+ }, [open]);
37
+ return (_jsx(MenuContext.Provider, { value: value, children: _jsx("div", { ref: wrapper, "data-slot": "menu", className: cn("relative inline-flex", className), ...props, children: children }) }));
38
+ }
39
+ export function MenuTrigger({ asChild, onClick, onKeyDown, ...props }) {
40
+ const { open, setOpen, triggerId, contentId } = useMenu();
41
+ const Comp = asChild ? Slot : "button";
42
+ const openAt = (which) => {
43
+ setOpen(true);
44
+ requestAnimationFrame(() => {
45
+ const list = items(contentId);
46
+ (which === "first" ? list[0] : list[list.length - 1])?.focus();
47
+ });
48
+ };
49
+ return (_jsx(Comp, { id: triggerId, "data-slot": "menu-trigger", type: asChild ? undefined : "button", "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": contentId, onClick: (e) => {
50
+ onClick?.(e);
51
+ if (e.defaultPrevented)
52
+ return;
53
+ if (open)
54
+ setOpen(false);
55
+ else
56
+ openAt("first");
57
+ }, onKeyDown: (e) => {
58
+ onKeyDown?.(e);
59
+ if (e.defaultPrevented)
60
+ return;
61
+ if (e.key === "ArrowDown") {
62
+ e.preventDefault();
63
+ openAt("first");
64
+ }
65
+ else if (e.key === "ArrowUp") {
66
+ e.preventDefault();
67
+ openAt("last");
68
+ }
69
+ }, ...props }));
70
+ }
71
+ export function MenuContent({ align = "end", className, onKeyDown, ...props }) {
72
+ const { open, setOpen, triggerId, contentId } = useMenu();
73
+ return (_jsx("div", { id: contentId, role: "menu", "aria-labelledby": triggerId, "data-slot": "menu-content", hidden: !open, onKeyDown: (e) => {
74
+ onKeyDown?.(e);
75
+ if (e.defaultPrevented)
76
+ return;
77
+ const list = items(contentId);
78
+ const at = list.indexOf(document.activeElement);
79
+ const move = (i) => {
80
+ e.preventDefault();
81
+ list[(i + list.length) % list.length]?.focus();
82
+ };
83
+ if (e.key === "ArrowDown")
84
+ move(at + 1);
85
+ else if (e.key === "ArrowUp")
86
+ move(at - 1);
87
+ else if (e.key === "Home")
88
+ move(0);
89
+ else if (e.key === "End")
90
+ move(list.length - 1);
91
+ else if (e.key === "Escape") {
92
+ e.preventDefault();
93
+ setOpen(false, true);
94
+ }
95
+ else if (e.key === "Tab")
96
+ setOpen(false);
97
+ }, className: cn("absolute top-full z-40 mt-1 flex min-w-44 flex-col rounded-control border border-line bg-surface-raised py-1 shadow-float", align === "end" ? "right-0" : "left-0", className), ...props }));
98
+ }
99
+ /** One action. A button by default; `asChild` for a link. `onSelect` runs, then the menu closes. */
100
+ export function MenuItem({ asChild, variant = "default", onSelect, onClick, className, disabled, ...props }) {
101
+ const { setOpen } = useMenu();
102
+ const Comp = asChild ? Slot : "button";
103
+ return (_jsx(Comp, { role: "menuitem", tabIndex: -1, "data-slot": "menu-item", "data-variant": variant, type: asChild ? undefined : "button", "aria-disabled": disabled || undefined, onClick: (e) => {
104
+ if (disabled) {
105
+ e.preventDefault();
106
+ return;
107
+ }
108
+ onClick?.(e);
109
+ if (e.defaultPrevented)
110
+ return;
111
+ onSelect?.();
112
+ setOpen(false, true);
113
+ }, className: cn("flex w-full items-center gap-2 px-3 py-2 text-left text-body whitespace-nowrap text-ink outline-none hover:bg-surface-hover focus-visible:bg-surface-hover focus:bg-surface-hover sm:py-1.5", "data-[variant=destructive]:text-danger aria-disabled:cursor-not-allowed aria-disabled:text-ink-subtle", className), ...props }));
114
+ }
115
+ export function MenuSeparator({ className }) {
116
+ return _jsx("div", { role: "separator", "data-slot": "menu-separator", className: cn("my-1 h-px bg-line", className) });
117
+ }
@@ -0,0 +1,35 @@
1
+ import { type ReactNode } from "react";
2
+ /** `inline`: underlined, in running text. `quiet`: underline on hover (lists, breadcrumbs). `strong`: a quiet link that leads a row. */
3
+ export declare const linkVariants: (props?: ({
4
+ variant?: "inline" | "quiet" | "strong" | null | undefined;
5
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
6
+ /** The trail back to the list a page belongs to. Each item but the last is a link; the last is this page. */
7
+ export declare function Breadcrumb({ items, className }: {
8
+ items: ReactNode[];
9
+ className?: string;
10
+ }): import("react").JSX.Element;
11
+ /**
12
+ * The top of every page: breadcrumb, the one h1, a meta line, what it is about, and its actions.
13
+ * `live` announces a changing description. `metaAfter` puts the meta line under the description, for
14
+ * a page whose description is its verdict (only the description is live, so a refresh time in the
15
+ * meta line is not announced).
16
+ */
17
+ export declare function PageHeader({ title, description, meta, actions, breadcrumb, live, metaAfter, }: {
18
+ title: ReactNode;
19
+ description?: ReactNode;
20
+ meta?: ReactNode;
21
+ actions?: ReactNode;
22
+ breadcrumb?: ReactNode[];
23
+ live?: boolean;
24
+ metaAfter?: boolean;
25
+ }): import("react").JSX.Element;
26
+ /** The marker of a numbered step: its number, a check once done, a ring while current. Decorative: the step's words say it. */
27
+ export declare function StepMarker({ n, state }: {
28
+ n: number;
29
+ state: "done" | "current" | "todo";
30
+ }): import("react").JSX.Element;
31
+ /** The first focusable thing on a page: jumps past the navigation. */
32
+ export declare function SkipLink({ target, children }: {
33
+ target: string;
34
+ children?: ReactNode;
35
+ }): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { Fragment } from "react";
4
+ import { cn } from "./cn.js";
5
+ // docs/components.md 3.7. Router-agnostic: an app passes its router's <Link> the class from
6
+ // `linkVariants`, the same way a link that looks like a button takes `buttonVariants`.
7
+ /** `inline`: underlined, in running text. `quiet`: underline on hover (lists, breadcrumbs). `strong`: a quiet link that leads a row. */
8
+ export const linkVariants = cva("rounded-tag", {
9
+ variants: {
10
+ variant: {
11
+ inline: "text-accent underline underline-offset-2 hover:text-accent-hover",
12
+ quiet: "hover:text-ink hover:underline underline-offset-2",
13
+ strong: "font-medium text-accent underline-offset-2 hover:text-accent-hover hover:underline",
14
+ },
15
+ },
16
+ defaultVariants: { variant: "inline" },
17
+ });
18
+ /** The trail back to the list a page belongs to. Each item but the last is a link; the last is this page. */
19
+ export function Breadcrumb({ items, className }) {
20
+ return (_jsx("nav", { "aria-label": "Breadcrumb", className: cn("flex flex-wrap items-center gap-1 text-meta text-ink-muted [&_a]:hover:text-ink [&_a]:hover:underline", className), children: items.map((item, i) => (_jsxs(Fragment, { children: [i > 0 ? (_jsx("span", { "aria-hidden": true, className: "text-ink-subtle", children: "/" })) : null, i === items.length - 1 ? _jsx("span", { "aria-current": "page", children: item }) : item] }, i))) }));
21
+ }
22
+ /**
23
+ * The top of every page: breadcrumb, the one h1, a meta line, what it is about, and its actions.
24
+ * `live` announces a changing description. `metaAfter` puts the meta line under the description, for
25
+ * a page whose description is its verdict (only the description is live, so a refresh time in the
26
+ * meta line is not announced).
27
+ */
28
+ export function PageHeader({ title, description, meta, actions, breadcrumb, live, metaAfter, }) {
29
+ const metaLine = meta ? _jsx("p", { className: "mt-0.5 text-meta text-ink-muted", children: meta }) : null;
30
+ return (_jsxs("div", { "data-slot": "page-header", className: "mb-6 flex flex-wrap items-end justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0", children: [breadcrumb ? _jsx(Breadcrumb, { items: breadcrumb, className: "mb-1" }) : null, _jsx("h1", { className: "text-page font-semibold tracking-tight text-ink", children: title }), metaAfter ? null : metaLine, description ? (_jsx("div", { "aria-live": live ? "polite" : undefined, className: "mt-1 max-w-prose text-body text-ink-muted", children: description })) : null, metaAfter ? metaLine : null] }), actions ? _jsx("div", { className: "flex flex-wrap items-center gap-2", children: actions }) : null] }));
31
+ }
32
+ /** The marker of a numbered step: its number, a check once done, a ring while current. Decorative: the step's words say it. */
33
+ export function StepMarker({ n, state }) {
34
+ return (_jsx("span", { "aria-hidden": true, "data-state": state, className: cn("grid size-6 shrink-0 place-items-center rounded-full border text-meta font-medium tabular-nums", state === "done" ? "border-success-solid bg-success-solid text-surface" : state === "current" ? "border-ink font-semibold text-ink" : "border-line-strong text-ink-muted"), children: state === "done" ? (_jsx("svg", { viewBox: "0 0 12 12", className: "size-3", children: _jsx("path", { d: "M2.5 6.2l2.2 2.2 4.8-4.9", className: "fill-none stroke-current", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (n) }));
35
+ }
36
+ /** The first focusable thing on a page: jumps past the navigation. */
37
+ export function SkipLink({ target, children = "Skip to content" }) {
38
+ return (_jsx("a", { href: `#${target}`, className: "sr-only focus:not-sr-only focus:absolute focus:z-50 focus:m-2 focus:rounded-control focus:bg-surface focus:p-2 focus:text-ink focus:shadow-float", children: children }));
39
+ }
package/dist/page.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import type { ComponentProps, ReactNode } from "react";
3
+ import { type Tone } from "./status.js";
4
+ export declare const pageVariants: (props?: ({
5
+ width?: "full" | "narrow" | "split" | null | undefined;
6
+ } & import("class-variance-authority/types").ClassProp) | undefined) => string;
7
+ /** The page's frame at one of three widths: `full` (lists), `split` (main + 320 px pane), `narrow` (forms). */
8
+ export declare function Page({ width, className, ...props }: ComponentProps<"div"> & VariantProps<typeof pageVariants>): import("react").JSX.Element;
9
+ /** The subject of the page, in the order of layout.md §4. Sections 24 px apart. */
10
+ export declare function PageMain({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
11
+ /**
12
+ * What supports the subject (facts, credentials, where the data comes from). Beside the main column
13
+ * from `lg`, under it below. Never a second subject.
14
+ */
15
+ export declare function PagePane({ className, "aria-label": label, ...props }: ComponentProps<"aside">): import("react").JSX.Element;
16
+ /** The state of one object: tone edge, verdict on the left, the figure on the right. */
17
+ export declare function StatusPanel({ tone, className, "aria-label": label, ...props }: ComponentProps<"section"> & {
18
+ tone?: Tone;
19
+ }): import("react").JSX.Element;
20
+ /** Left: verdict, sentence, the actions that fix it. Below `lg` it follows the figure. */
21
+ export declare function StatusPanelSummary({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
22
+ /** The condition badge and when it began. Announced politely when a refresh changes it. */
23
+ export declare function StatusPanelVerdict({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
24
+ export declare function StatusPanelText({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
25
+ /** Only the actions that resolve this condition. When there is one, the header's buttons are secondary. */
26
+ export declare function StatusPanelActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
27
+ /** Right: the key figure, its visual and up to three small facts. First below `lg`. */
28
+ export declare function StatusPanelDetail({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
29
+ /** The one number the object is about, with its label and how old it is. */
30
+ export declare function StatusPanelFigure({ label, hint, className, children, ...props }: ComponentProps<"div"> & {
31
+ label: ReactNode;
32
+ hint?: ReactNode;
33
+ }): import("react").JSX.Element;
34
+ /** Up to three small facts under the figure. Pass `KeyValues`-style pairs. */
35
+ export declare function StatusPanelFacts({ items, className }: {
36
+ items: [ReactNode, ReactNode][];
37
+ className?: string;
38
+ }): import("react").JSX.Element;
package/dist/page.js ADDED
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cva } from "class-variance-authority";
3
+ import { cn } from "./cn.js";
4
+ import { toneEdge } from "./status.js";
5
+ // docs/layout.md §3 and §4. A page picks one width; pages never write max-w-* or page grids.
6
+ //
7
+ // <Page width="split">
8
+ // <PageHeader … /> full width, above both columns
9
+ // <PageMain>status, tabs, sections</PageMain>
10
+ // <PagePane>facts, credentials, help</PagePane>
11
+ // </Page>
12
+ export const pageVariants = cva("mx-auto w-full px-4 py-6 sm:px-6 [&>[data-slot=page-header]]:mb-0", {
13
+ variants: {
14
+ width: {
15
+ full: "flex max-w-7xl flex-col gap-6",
16
+ split: "grid max-w-7xl grid-cols-1 gap-6 lg:grid-cols-[minmax(0,1fr)_20rem] lg:[&>:not([data-slot=page-main]):not([data-slot=page-pane])]:col-span-2",
17
+ narrow: "flex max-w-2xl flex-col gap-6",
18
+ },
19
+ },
20
+ defaultVariants: { width: "full" },
21
+ });
22
+ /** The page's frame at one of three widths: `full` (lists), `split` (main + 320 px pane), `narrow` (forms). */
23
+ export function Page({ width, className, ...props }) {
24
+ return _jsx("div", { "data-slot": "page", "data-width": width ?? "full", className: cn(pageVariants({ width }), className), ...props });
25
+ }
26
+ /** The subject of the page, in the order of layout.md §4. Sections 24 px apart. */
27
+ export function PageMain({ className, ...props }) {
28
+ return _jsx("div", { "data-slot": "page-main", className: cn("flex min-w-0 flex-col gap-6", className), ...props });
29
+ }
30
+ /**
31
+ * What supports the subject (facts, credentials, where the data comes from). Beside the main column
32
+ * from `lg`, under it below. Never a second subject.
33
+ */
34
+ export function PagePane({ className, "aria-label": label = "Details", ...props }) {
35
+ return _jsx("aside", { "data-slot": "page-pane", "aria-label": label, className: cn("flex min-w-0 flex-col gap-6 lg:sticky lg:top-6 lg:self-start", className), ...props });
36
+ }
37
+ // docs/patterns.md §5. One per detail page, under the page header (and any page notice).
38
+ //
39
+ // <StatusPanel tone="warning">
40
+ // <StatusPanelSummary>
41
+ // <StatusPanelVerdict><Badge tone="warning">Behind</Badge> since …</StatusPanelVerdict>
42
+ // <StatusPanelText>What it means and whether you need to act.</StatusPanelText>
43
+ // <StatusPanelActions><Button>Load the missing days</Button></StatusPanelActions>
44
+ // </StatusPanelSummary>
45
+ // <StatusPanelDetail>
46
+ // <StatusPanelFigure label="Data through" hint="3 days ago">14 Nov 2026</StatusPanelFigure>
47
+ // <Coverage … />
48
+ // </StatusPanelDetail>
49
+ // </StatusPanel>
50
+ /** The state of one object: tone edge, verdict on the left, the figure on the right. */
51
+ export function StatusPanel({ tone = "neutral", className, "aria-label": label = "Status", ...props }) {
52
+ return (_jsx("section", { "data-slot": "status-panel", "data-tone": tone, "aria-label": label, className: cn("grid gap-6 rounded-control border border-l-4 border-line bg-surface p-4 lg:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)]", toneEdge(tone), className), ...props }));
53
+ }
54
+ /** Left: verdict, sentence, the actions that fix it. Below `lg` it follows the figure. */
55
+ export function StatusPanelSummary({ className, ...props }) {
56
+ return _jsx("div", { "data-slot": "status-panel-summary", className: cn("order-2 flex min-w-0 flex-col gap-2 lg:order-1", className), ...props });
57
+ }
58
+ /** The condition badge and when it began. Announced politely when a refresh changes it. */
59
+ export function StatusPanelVerdict({ className, ...props }) {
60
+ return _jsx("div", { "data-slot": "status-panel-verdict", "aria-live": "polite", className: cn("flex flex-wrap items-center gap-2 text-meta text-ink-muted", className), ...props });
61
+ }
62
+ export function StatusPanelText({ className, ...props }) {
63
+ return _jsx("p", { "data-slot": "status-panel-text", className: cn("max-w-prose text-body text-ink", className), ...props });
64
+ }
65
+ /** Only the actions that resolve this condition. When there is one, the header's buttons are secondary. */
66
+ export function StatusPanelActions({ className, ...props }) {
67
+ return _jsx("div", { "data-slot": "status-panel-actions", className: cn("flex flex-wrap gap-2 pt-1", className), ...props });
68
+ }
69
+ /** Right: the key figure, its visual and up to three small facts. First below `lg`. */
70
+ export function StatusPanelDetail({ className, ...props }) {
71
+ return _jsx("div", { "data-slot": "status-panel-detail", className: cn("order-1 flex min-w-0 flex-col gap-3 lg:order-2", className), ...props });
72
+ }
73
+ /** The one number the object is about, with its label and how old it is. */
74
+ export function StatusPanelFigure({ label, hint, className, children, ...props }) {
75
+ return (_jsxs("div", { "data-slot": "status-panel-figure", className: cn("flex flex-wrap items-baseline gap-x-3 gap-y-1", className), ...props, children: [_jsx("span", { className: "text-meta font-medium text-ink-muted", children: label }), _jsx("span", { className: "text-figure font-semibold tabular-nums", children: children }), hint ? _jsx("span", { className: "text-meta text-ink-muted", children: hint }) : null] }));
76
+ }
77
+ /** Up to three small facts under the figure. Pass `KeyValues`-style pairs. */
78
+ export function StatusPanelFacts({ items, className }) {
79
+ return (_jsx("dl", { "data-slot": "status-panel-facts", className: cn("grid grid-cols-2 gap-4 text-body sm:grid-cols-3", className), children: items.slice(0, 3).map(([k, v], i) => (_jsxs("div", { children: [_jsx("dt", { className: "text-meta text-ink-muted", children: k }), _jsx("dd", { className: "tabular-nums", children: v ?? _jsx("span", { className: "text-ink-subtle", children: "none" }) })] }, i))) }));
80
+ }
@@ -0,0 +1,20 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export declare function Sheet({ open: openProp, onOpenChange, defaultOpen, children }: {
3
+ open?: boolean;
4
+ onOpenChange?: (open: boolean) => void;
5
+ defaultOpen?: boolean;
6
+ children: ReactNode;
7
+ }): import("react").JSX.Element;
8
+ export declare function SheetTrigger({ asChild, onClick, ...props }: ComponentProps<"button"> & {
9
+ asChild?: boolean;
10
+ }): import("react").JSX.Element;
11
+ export declare function SheetContent({ className, children, ...props }: ComponentProps<"dialog">): import("react").JSX.Element;
12
+ export declare function SheetHeader({ className, children, ...props }: ComponentProps<"div">): import("react").JSX.Element;
13
+ export declare function SheetTitle({ className, ...props }: ComponentProps<"h2">): import("react").JSX.Element;
14
+ export declare function SheetDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
15
+ export declare function SheetBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
16
+ /** Cancel then the primary, at the bottom right (patterns.md §9). */
17
+ export declare function SheetFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
18
+ export declare function SheetClose({ asChild, onClick, ...props }: ComponentProps<"button"> & {
19
+ asChild?: boolean;
20
+ }): import("react").JSX.Element;