@argon8/react 0.0.0-stage → 0.1.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 { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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,13 @@
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";
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
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";
@@ -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?: "strong" | "inline" | "quiet" | 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", { 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
+ }
@@ -0,0 +1,40 @@
1
+ import type { ReactNode } from "react";
2
+ /**
3
+ * The five tones, by what they mean for the data (docs/components.md 1.3), worst first:
4
+ * danger (stopped), warning (behind or partial), info (working), neutral (off, or not yet), success.
5
+ */
6
+ export type Tone = "danger" | "warning" | "info" | "neutral" | "success";
7
+ export declare const TONES: readonly Tone[];
8
+ /** A view's tone is the worst of its parts. */
9
+ export declare function worstTone(...tones: (Tone | null | undefined | false)[]): Tone;
10
+ export declare const toneText: (t: Tone) => string;
11
+ export declare const toneSolid: (t: Tone) => string;
12
+ /** A tone's left edge, for a calm panel that carries a status (`border-l-4` with it). */
13
+ export declare const toneEdge: (t: Tone) => string;
14
+ /** A tone's tint and line, for a strong panel (what stops everything). */
15
+ export declare const toneTint: (t: Tone) => string;
16
+ /** A tone's shape, so tones differ without colour. Decorative: the words beside it say it. */
17
+ export declare function ToneIcon({ tone, className, live, size }: {
18
+ tone: Tone;
19
+ className?: string;
20
+ live?: boolean;
21
+ size?: 12 | 16;
22
+ }): import("react").JSX.Element;
23
+ /** A status: its shape for scanning, and always the words. `live` pulses a working status. */
24
+ export declare function Badge({ tone, children, title, live, className }: {
25
+ tone?: Tone;
26
+ children: ReactNode;
27
+ title?: string;
28
+ live?: boolean;
29
+ className?: string;
30
+ }): import("react").JSX.Element;
31
+ /**
32
+ * A count beside a nav item or a button: `danger` when the things counted need someone, else
33
+ * `neutral`. The figure is decorative; `label` is what a screen reader hears ("2 need you").
34
+ */
35
+ export declare function Count({ value, label, tone, className }: {
36
+ value: number;
37
+ label: string;
38
+ tone?: "danger" | "neutral";
39
+ className?: string;
40
+ }): import("react").JSX.Element;
package/dist/status.js ADDED
@@ -0,0 +1,48 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { cn } from "./cn.js";
3
+ export const TONES = ["danger", "warning", "info", "neutral", "success"];
4
+ /** A view's tone is the worst of its parts. */
5
+ export function worstTone(...tones) {
6
+ return tones.filter(Boolean).reduce((a, b) => (TONES.indexOf(b) < TONES.indexOf(a) ? b : a), "success");
7
+ }
8
+ const TONE = {
9
+ danger: { text: "text-danger", solid: "text-danger-solid", badge: "border-danger-line bg-danger-tint text-danger", edge: "border-l-danger-solid", tint: "border-danger-line bg-danger-tint" },
10
+ warning: { text: "text-warning", solid: "text-warning-solid", badge: "border-warning-line bg-warning-tint text-warning", edge: "border-l-warning-solid", tint: "border-warning-line bg-warning-tint" },
11
+ info: { text: "text-info", solid: "text-info-solid", badge: "border-info-line bg-info-tint text-info", edge: "border-l-info-solid", tint: "border-info-line bg-info-tint" },
12
+ neutral: { text: "text-neutral", solid: "text-neutral-solid", badge: "border-neutral-line bg-neutral-tint text-neutral", edge: "border-l-neutral-solid", tint: "border-neutral-line bg-neutral-tint" },
13
+ success: { text: "text-success", solid: "text-success-solid", badge: "border-success-line bg-success-tint text-success", edge: "border-l-success-solid", tint: "border-success-line bg-success-tint" },
14
+ };
15
+ export const toneText = (t) => TONE[t].text;
16
+ export const toneSolid = (t) => TONE[t].solid;
17
+ /** A tone's left edge, for a calm panel that carries a status (`border-l-4` with it). */
18
+ export const toneEdge = (t) => TONE[t].edge;
19
+ /** A tone's tint and line, for a strong panel (what stops everything). */
20
+ export const toneTint = (t) => TONE[t].tint;
21
+ /** A tone's shape, so tones differ without colour. Decorative: the words beside it say it. */
22
+ export function ToneIcon({ tone, className, live, size = 12 }) {
23
+ const cls = cn(size === 16 ? "size-4" : "size-3", "shrink-0", TONE[tone].solid, live && tone === "info" && "motion-safe:animate-pulse", className);
24
+ const common = { viewBox: "0 0 12 12", "aria-hidden": true, focusable: "false", className: cls, "data-tone": tone };
25
+ switch (tone) {
26
+ case "danger":
27
+ return (_jsxs("svg", { ...common, children: [_jsx("path", { d: "M3.8 0.5h4.4l3.3 3.3v4.4l-3.3 3.3H3.8L0.5 8.2V3.8z", className: "fill-current" }), _jsx("path", { d: "M6 3v3.4M6 8.2v.6", className: "stroke-on-danger", strokeWidth: "1.5", strokeLinecap: "round" })] }));
28
+ case "warning":
29
+ return (_jsxs("svg", { ...common, children: [_jsx("path", { d: "M6 0.8l5.4 10H0.6z", className: "fill-current" }), _jsx("path", { d: "M6 4.3v2.9M6 8.7v.2", className: "stroke-surface", strokeWidth: "1.3", strokeLinecap: "round" })] }));
30
+ case "info":
31
+ return (_jsxs("svg", { ...common, children: [_jsx("circle", { cx: "6", cy: "6", r: "4.9", className: "fill-none stroke-current", strokeWidth: "1.4" }), _jsx("path", { d: "M6 1.1a4.9 4.9 0 0 1 0 9.8z", className: "fill-current" })] }));
32
+ case "success":
33
+ return (_jsxs("svg", { ...common, children: [_jsx("circle", { cx: "6", cy: "6", r: "5.5", className: "fill-current" }), _jsx("path", { d: "M3.4 6.2l1.8 1.8 3.5-3.6", className: "fill-none stroke-surface", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })] }));
34
+ default:
35
+ return (_jsx("svg", { ...common, children: _jsx("circle", { cx: "6", cy: "6", r: "4.6", className: "fill-none stroke-current", strokeWidth: "1.6" }) }));
36
+ }
37
+ }
38
+ /** A status: its shape for scanning, and always the words. `live` pulses a working status. */
39
+ export function Badge({ tone = "neutral", children, title, live, className }) {
40
+ return (_jsxs("span", { title: title, "data-tone": tone, className: cn("inline-flex max-w-full items-center gap-1 rounded-tag border px-1.5 py-0.5 text-meta font-medium", TONE[tone].badge, className), children: [_jsx(ToneIcon, { tone: tone, live: live }), _jsx("span", { className: "min-w-0", children: children })] }));
41
+ }
42
+ /**
43
+ * A count beside a nav item or a button: `danger` when the things counted need someone, else
44
+ * `neutral`. The figure is decorative; `label` is what a screen reader hears ("2 need you").
45
+ */
46
+ export function Count({ value, label, tone = "danger", className }) {
47
+ return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, "data-tone": tone, className: cn("rounded-tag px-1.5 text-meta leading-4 font-semibold tabular-nums", tone === "danger" ? "bg-danger-solid text-on-danger" : "bg-neutral-tint text-neutral", className), children: value }), _jsxs("span", { className: "sr-only", children: [", ", label] })] }));
48
+ }
@@ -0,0 +1,2 @@
1
+ /* Tailwind's default palette deleted, so only the tokens compile. Import between Tailwind and styles.css. */
2
+ @import "@argon8/tokens/strict.css";
@@ -0,0 +1,30 @@
1
+ /*
2
+ * What a product app imports, after Tailwind:
3
+ *
4
+ * @import "tailwindcss";
5
+ * @import "@argon8/react/strict.css";
6
+ * @import "@argon8/react/styles.css";
7
+ *
8
+ * The tokens and their Tailwind theme (from @argon8/tokens), the components' classes (@source), and
9
+ * the base layer that follows from the tokens. No colour, size or duration is defined here:
10
+ * @argon8/tokens is the one source. strict.css deletes Tailwind's default palette so only the
11
+ * tokens compile.
12
+ */
13
+ @import "@argon8/tokens/tailwind.css";
14
+
15
+ /* Tailwind scans these for the classes the components use. */
16
+ @source "./";
17
+
18
+ @layer base {
19
+ /* A bare `border` means the divider token, not currentColor. */
20
+ *, ::before, ::after { border-color: var(--a8-color-line); }
21
+
22
+ /* Figures line up in columns wherever they are data. */
23
+ td, time, [data-numeric] { font-variant-numeric: tabular-nums; }
24
+
25
+ /* The focus ring: accent, 2px, offset 2px, on every focusable thing. */
26
+ :focus-visible { outline: 2px solid var(--a8-color-accent); outline-offset: 2px; }
27
+
28
+ /* A dialog's backdrop. (Tailwind's backdrop: variant works too; this is the default for every dialog.) */
29
+ dialog::backdrop { background-color: var(--a8-color-overlay); }
30
+ }
@@ -0,0 +1,26 @@
1
+ import { type ComponentProps, type ReactNode } from "react";
2
+ export type Density = "dense" | "compact" | "comfortable";
3
+ export declare function DensityProvider({ density, children }: {
4
+ density: "comfortable" | "compact";
5
+ children: ReactNode;
6
+ }): import("react").JSX.Element;
7
+ /** `multiline`: some cells hold more than one line (a badge and its reason), so every cell reads from the top. */
8
+ export declare function Table({ caption, density: own, fixed, stickyHeader, multiline, className, children, ...props }: ComponentProps<"table"> & {
9
+ caption: string;
10
+ density?: Density;
11
+ fixed?: boolean;
12
+ stickyHeader?: boolean;
13
+ multiline?: boolean;
14
+ }): import("react").JSX.Element;
15
+ export declare function THead({ className, ...props }: ComponentProps<"thead">): import("react").JSX.Element;
16
+ export declare function TBody({ className, ...props }: ComponentProps<"tbody">): import("react").JSX.Element;
17
+ /** `link`: the whole row leads somewhere, so it shows hover. */
18
+ export declare function Tr({ className, link, ...props }: ComponentProps<"tr"> & {
19
+ link?: boolean;
20
+ }): import("react").JSX.Element;
21
+ export declare function Th({ className, num, scope, ...props }: ComponentProps<"th"> & {
22
+ num?: boolean;
23
+ }): import("react").JSX.Element;
24
+ export declare function Td({ className, num, ...props }: ComponentProps<"td"> & {
25
+ num?: boolean;
26
+ }): import("react").JSX.Element;
package/dist/table.js ADDED
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ import { cn } from "./cn.js";
4
+ const DensityCtx = createContext("comfortable");
5
+ // D30: tables are comfortable unless the person picks compact for the whole app (one setting, not
6
+ // one per table). A table may still say `dense` for logs and long lists of IDs.
7
+ const AppDensityCtx = createContext("comfortable");
8
+ export function DensityProvider({ density, children }) {
9
+ return _jsx(AppDensityCtx, { value: density, children: children });
10
+ }
11
+ // The height is a minimum: a cell with more than one line grows, keeping its padding.
12
+ const ROW = { dense: "h-row-dense py-1", compact: "h-row-compact py-1.5", comfortable: "h-row-comfortable py-2" };
13
+ /** `multiline`: some cells hold more than one line (a badge and its reason), so every cell reads from the top. */
14
+ export function Table({ caption, density: own, fixed, stickyHeader, multiline, className, children, ...props }) {
15
+ const app = useContext(AppDensityCtx);
16
+ const density = own ?? app;
17
+ return (_jsx("div", { className: cn("overflow-x-auto", className), children: _jsxs("table", { "data-density": density, "data-sticky": stickyHeader ? "" : undefined, "data-multiline": multiline ? "" : undefined, className: cn("w-full border-collapse text-body", fixed && "table-fixed"), ...props, children: [_jsx("caption", { className: "sr-only", children: caption }), _jsx(DensityCtx, { value: density, children: children })] }) }));
18
+ }
19
+ export function THead({ className, ...props }) {
20
+ return _jsx("thead", { className: cn("border-b border-line text-meta text-ink-muted [[data-sticky]_&]:sticky [[data-sticky]_&]:top-0 [[data-sticky]_&]:bg-surface", className), ...props });
21
+ }
22
+ export function TBody({ className, ...props }) {
23
+ return _jsx("tbody", { className: cn("divide-y divide-line", className), ...props });
24
+ }
25
+ /** `link`: the whole row leads somewhere, so it shows hover. */
26
+ export function Tr({ className, link, ...props }) {
27
+ return _jsx("tr", { className: cn(link && "hover:bg-surface-hover", className), ...props });
28
+ }
29
+ export function Th({ className, num, scope = "col", ...props }) {
30
+ const d = useContext(DensityCtx);
31
+ return _jsx("th", { scope: scope, className: cn(ROW[d], "px-3 text-left font-medium [[data-multiline]_tbody_&]:align-top", num && "text-right", className), ...props });
32
+ }
33
+ export function Td({ className, num, ...props }) {
34
+ const d = useContext(DensityCtx);
35
+ return _jsx("td", { className: cn(ROW[d], "px-3 align-middle [[data-multiline]_&]:align-top", num && "text-right tabular-nums", className), ...props });
36
+ }
package/dist/term.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from "react";
2
+ /**
3
+ * A word that needs explaining (docs/components.md 3.6, Tooltip / Term). Opens on hover, on keyboard focus and on a tap
4
+ * (an `abbr title` shows nothing on focus or touch); closes on Escape or when focus leaves.
5
+ */
6
+ export declare function Term({ tip, children }: {
7
+ tip: ReactNode;
8
+ children: ReactNode;
9
+ }): import("react").JSX.Element;
package/dist/term.js ADDED
@@ -0,0 +1,26 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId, useState } from "react";
3
+ /**
4
+ * A word that needs explaining (docs/components.md 3.6, Tooltip / Term). Opens on hover, on keyboard focus and on a tap
5
+ * (an `abbr title` shows nothing on focus or touch); closes on Escape or when focus leaves.
6
+ */
7
+ export function Term({ tip, children }) {
8
+ const id = useId();
9
+ const [open, setOpen] = useState(false);
10
+ const [pinned, setPinned] = useState(false);
11
+ const show = open || pinned;
12
+ const onKey = (e) => {
13
+ if (e.key === "Escape" && show) {
14
+ e.stopPropagation();
15
+ setOpen(false);
16
+ setPinned(false);
17
+ }
18
+ };
19
+ return (_jsxs("span", { className: "relative inline-block", onMouseEnter: () => setOpen(true), onMouseLeave: () => setOpen(false), children: [_jsx("button", { type: "button", "aria-expanded": show, "aria-describedby": show ? id : undefined, onFocus: () => setOpen(true), onBlur: () => {
20
+ setOpen(false);
21
+ setPinned(false);
22
+ }, onClick: (e) => {
23
+ e.preventDefault();
24
+ setPinned((p) => !p);
25
+ }, onKeyDown: onKey, className: "cursor-help text-left underline decoration-ink-subtle decoration-dotted underline-offset-2", children: children }), _jsx("span", { id: id, role: "tooltip", hidden: !show, className: "absolute top-full left-0 z-20 mt-1 w-64 max-w-[80vw] rounded-control border border-line bg-surface-raised p-2 text-meta font-normal whitespace-normal text-ink-muted normal-case shadow-float", children: tip })] }));
26
+ }
package/dist/time.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ type Instant = Date | string | null | undefined;
2
+ declare function local(d: Date, withDate: boolean): string;
3
+ /** "3 min ago", "in 2 hours". */
4
+ export declare function relativeText(d: Date, now: number): string;
5
+ /** An instant: local date and time (no year when it is this year), UTC in the tooltip. `relative` adds "· 3 min ago". */
6
+ export declare function When({ at, relative: rel, fallback, timeOnly }: {
7
+ at: Instant;
8
+ relative?: boolean;
9
+ fallback?: string;
10
+ timeOnly?: boolean;
11
+ }): import("react").JSX.Element;
12
+ /** A calendar day as people say it: "Nov 9" ("Nov 9, 2025" in another year). The same on the server and in the browser. */
13
+ export declare function dayText(at: Date | string): string;
14
+ /** A date that is a calendar day in the data (a watermark): the day, ISO and UTC in the tooltip. */
15
+ export declare function Day({ at, fallback, className }: {
16
+ at: Instant;
17
+ fallback?: string;
18
+ className?: string;
19
+ }): import("react").JSX.Element;
20
+ /**
21
+ * A period: "Oct 26 – Nov 9". Periods end at midnight of the day after their last day, so the end
22
+ * shown is the last day the period covers.
23
+ */
24
+ export declare function DayRange({ start, end }: {
25
+ start: Instant;
26
+ end: Instant;
27
+ }): import("react").JSX.Element;
28
+ export declare function dayRangeText(start: Date | string, end: Date | string): string;
29
+ export declare function Ago({ seconds }: {
30
+ seconds: number | null;
31
+ }): import("react").JSX.Element;
32
+ export { local as formatLocal };
package/dist/time.js ADDED
@@ -0,0 +1,76 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // docs/components.md 3.4 (DateTime). Times: in the reader's own time zone, with UTC on hover. The server renders UTC (it does not
3
+ // know the reader's zone); the browser switches to local time once the page is running.
4
+ // Days in the data (watermarks, periods) are calendar days: "Nov 9", the year only when it is not
5
+ // this year, ISO and UTC on hover. Figures are tabular so dates line up in columns.
6
+ import { useEffect, useState } from "react";
7
+ import { cn } from "./cn.js";
8
+ const utc = (d) => `${d.toISOString().slice(0, 16).replace("T", " ")} UTC`;
9
+ const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
10
+ const thisYear = () => new Date().getUTCFullYear();
11
+ function local(d, withDate) {
12
+ const year = d.getFullYear() !== new Date().getFullYear() ? "numeric" : undefined;
13
+ return d.toLocaleString(undefined, withDate ? { year, month: "short", day: "numeric", hour: "2-digit", minute: "2-digit" } : { hour: "2-digit", minute: "2-digit" });
14
+ }
15
+ /** "3 min ago", "in 2 hours". */
16
+ export function relativeText(d, now) {
17
+ const s = Math.round((d.getTime() - now) / 1000);
18
+ const a = Math.abs(s);
19
+ const plural = (n, one) => `${n} ${one}${n === 1 ? "" : "s"}`;
20
+ const text = a < 90 ? `${a} s` : a < 5400 ? `${Math.round(a / 60)} min` : a < 129600 ? plural(Math.round(a / 3600), "hour") : plural(Math.round(a / 86400), "day");
21
+ return s >= 0 ? `in ${text}` : `${text} ago`;
22
+ }
23
+ function useMounted() {
24
+ const [m, setM] = useState(false);
25
+ useEffect(() => setM(true), []);
26
+ return m;
27
+ }
28
+ /** An instant: local date and time (no year when it is this year), UTC in the tooltip. `relative` adds "· 3 min ago". */
29
+ export function When({ at, relative: rel = false, fallback = "never", timeOnly = false }) {
30
+ const mounted = useMounted();
31
+ if (!at)
32
+ return _jsx("span", { className: "text-ink-subtle", children: fallback });
33
+ const d = new Date(at);
34
+ if (Number.isNaN(d.getTime()))
35
+ return _jsx("span", { children: String(at) });
36
+ const text = mounted ? (timeOnly ? d.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit", second: "2-digit" }) : local(d, true)) : timeOnly ? d.toISOString().slice(11, 19) : utc(d);
37
+ return (_jsxs("time", { dateTime: d.toISOString(), title: utc(d), className: "whitespace-nowrap tabular-nums", children: [text, rel && mounted ? _jsxs("span", { className: "text-ink-muted", children: [" \u00B7 ", relativeText(d, Date.now())] }) : null] }));
38
+ }
39
+ /** A calendar day as people say it: "Nov 9" ("Nov 9, 2025" in another year). The same on the server and in the browser. */
40
+ export function dayText(at) {
41
+ const d = new Date(at);
42
+ return `${MONTHS[d.getUTCMonth()]} ${d.getUTCDate()}${d.getUTCFullYear() !== thisYear() ? `, ${d.getUTCFullYear()}` : ""}`;
43
+ }
44
+ /** A date that is a calendar day in the data (a watermark): the day, ISO and UTC in the tooltip. */
45
+ export function Day({ at, fallback = "-", className }) {
46
+ if (!at)
47
+ return _jsx("span", { className: "text-ink-subtle", children: fallback });
48
+ const d = new Date(at);
49
+ return _jsx("time", { dateTime: d.toISOString(), title: `${d.toISOString().slice(0, 10)} (${utc(d)})`, className: cn("whitespace-nowrap tabular-nums", className), children: dayText(d) });
50
+ }
51
+ /**
52
+ * A period: "Oct 26 – Nov 9". Periods end at midnight of the day after their last day, so the end
53
+ * shown is the last day the period covers.
54
+ */
55
+ export function DayRange({ start, end }) {
56
+ if (!start || !end)
57
+ return _jsx("span", { className: "text-ink-subtle", children: "-" });
58
+ const last = lastDay(end);
59
+ return _jsxs("span", { className: "whitespace-nowrap tabular-nums", children: [_jsx(Day, { at: start }), last.getTime() > new Date(start).getTime() ? _jsxs(_Fragment, { children: [" \u2013 ", _jsx(Day, { at: last })] }) : null] });
60
+ }
61
+ export function dayRangeText(start, end) {
62
+ const last = lastDay(end);
63
+ return last.getTime() > new Date(start).getTime() ? `${dayText(start)} to ${dayText(last)}` : dayText(start);
64
+ }
65
+ /** The last day an exclusive end covers: an end at midnight belongs to the day before. */
66
+ function lastDay(end) {
67
+ const e = new Date(end);
68
+ return e.getUTCHours() === 0 && e.getUTCMinutes() === 0 && e.getUTCSeconds() === 0 ? new Date(e.getTime() - 86_400_000) : e;
69
+ }
70
+ export function Ago({ seconds }) {
71
+ if (seconds === null)
72
+ return _jsx("span", { children: "never" });
73
+ const a = Math.round(seconds);
74
+ return _jsxs("span", { className: "tabular-nums", children: [a < 90 ? `${a} s` : a < 5400 ? `${Math.round(a / 60)} min` : a < 129600 ? `${Math.round(a / 3600)} h` : `${Math.round(a / 86400)} days`, " ago"] });
75
+ }
76
+ export { local as formatLocal };